diff --git a/.gitignore b/.gitignore index e6a442e2d4..de0b1e7a5d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ ably-js.iml node_modules npm-debug.log .tool-versions -objects.d.mts +liveobjects.d.mts build/ react/ typedoc/generated/ diff --git a/Gruntfile.js b/Gruntfile.js index c10d197feb..57f52ef7d9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,7 +73,7 @@ module.exports = function (grunt) { }); }); - grunt.registerTask('build', ['webpack:all', 'build:browser', 'build:node', 'build:push', 'build:objects']); + grunt.registerTask('build', ['webpack:all', 'build:browser', 'build:node', 'build:push', 'build:liveobjects']); grunt.registerTask('all', ['build', 'requirejs']); @@ -138,14 +138,14 @@ module.exports = function (grunt) { }); }); - grunt.registerTask('build:objects:bundle', function () { + grunt.registerTask('build:liveobjects:bundle', function () { var done = this.async(); Promise.all([ - esbuild.build(esbuildConfig.objectsPluginConfig), - esbuild.build(esbuildConfig.objectsPluginEsmConfig), - esbuild.build(esbuildConfig.objectsPluginCdnConfig), - esbuild.build(esbuildConfig.minifiedObjectsPluginCdnConfig), + esbuild.build(esbuildConfig.liveObjectsPluginConfig), + esbuild.build(esbuildConfig.liveObjectsPluginEsmConfig), + esbuild.build(esbuildConfig.liveObjectsPluginCdnConfig), + esbuild.build(esbuildConfig.minifiedLiveObjectsPluginCdnConfig), ]) .then(() => { done(true); @@ -156,22 +156,22 @@ module.exports = function (grunt) { }); grunt.registerTask( - 'build:objects:types', - 'Generate objects.d.mts from objects.d.ts by adding .js extensions to relative imports', + 'build:liveobjects:types', + 'Generate liveobjects.d.mts from liveobjects.d.ts by adding .js extensions to relative imports', function () { - const dtsContent = fs.readFileSync('objects.d.ts', 'utf8'); + const dtsContent = fs.readFileSync('liveobjects.d.ts', 'utf8'); const mtsContent = dtsContent.replace(/from '(\.\/[^']+)'/g, "from '$1.js'"); - fs.writeFileSync('objects.d.mts', mtsContent); - grunt.log.ok('Generated objects.d.mts from objects.d.ts'); + fs.writeFileSync('liveobjects.d.mts', mtsContent); + grunt.log.ok('Generated liveobjects.d.mts from liveobjects.d.ts'); }, ); - grunt.registerTask('build:objects', ['build:objects:bundle', 'build:objects:types']); + grunt.registerTask('build:liveobjects', ['build:liveobjects:bundle', 'build:liveobjects:types']); grunt.registerTask('test:webserver', 'Launch the Mocha test web server on http://localhost:3000/', [ 'build:browser', 'build:push', - 'build:objects', + 'build:liveobjects', 'checkGitSubmodules', 'mocha:webserver', ]); diff --git a/ably.d.ts b/ably.d.ts index 0827987ba0..3b2f2e31e6 100644 --- a/ably.d.ts +++ b/ably.d.ts @@ -304,7 +304,7 @@ export type Transport = 'web_socket' | 'xhr_polling' | 'comet'; * This enables TypeScript to distinguish between these otherwise empty interfaces, * which would be structurally identical without this discriminating property. * - * This symbol is exported from 'ably' so that the types in 'ably/objects' + * This symbol is exported from 'ably' so that the types in 'ably/liveobjects' * (both ESM and CJS versions) share the same symbol, ensuring type compatibility. */ export declare const __livetype: unique symbol; @@ -638,7 +638,7 @@ export interface CorePlugins { /** * A plugin which allows the client to use LiveObjects functionality at {@link RealtimeChannel.object}. */ - Objects?: unknown; + LiveObjects?: unknown; } /** diff --git a/grunt/esbuild/build.js b/grunt/esbuild/build.js index 5aea84f3ba..b6d7b95c04 100644 --- a/grunt/esbuild/build.js +++ b/grunt/esbuild/build.js @@ -77,35 +77,35 @@ const minifiedPushPluginCdnConfig = { minify: true, }; -const objectsPluginConfig = { +const liveObjectsPluginConfig = { ...createBaseConfig(), - entryPoints: ['src/plugins/objects/index.ts'], - plugins: [umdWrapper.default({ libraryName: 'AblyObjectsPlugin', amdNamedModule: false })], - outfile: 'build/objects.js', + entryPoints: ['src/plugins/liveobjects/index.ts'], + plugins: [umdWrapper.default({ libraryName: 'AblyLiveObjectsPlugin', amdNamedModule: false })], + outfile: 'build/liveobjects.js', external: ['dequal'], }; -const objectsPluginEsmConfig = { +const liveObjectsPluginEsmConfig = { ...createBaseConfig(), format: 'esm', plugins: [], - entryPoints: ['src/plugins/objects/index.ts'], - outfile: 'build/objects.mjs', + entryPoints: ['src/plugins/liveobjects/index.ts'], + outfile: 'build/liveobjects.mjs', external: ['dequal'], }; -const objectsPluginCdnConfig = { +const liveObjectsPluginCdnConfig = { ...createBaseConfig(), - entryPoints: ['src/plugins/objects/index.ts'], - plugins: [umdWrapper.default({ libraryName: 'AblyObjectsPlugin', amdNamedModule: false })], - outfile: 'build/objects.umd.js', + entryPoints: ['src/plugins/liveobjects/index.ts'], + plugins: [umdWrapper.default({ libraryName: 'AblyLiveObjectsPlugin', amdNamedModule: false })], + outfile: 'build/liveobjects.umd.js', }; -const minifiedObjectsPluginCdnConfig = { +const minifiedLiveObjectsPluginCdnConfig = { ...createBaseConfig(), - entryPoints: ['src/plugins/objects/index.ts'], - plugins: [umdWrapper.default({ libraryName: 'AblyObjectsPlugin', amdNamedModule: false })], - outfile: 'build/objects.umd.min.js', + entryPoints: ['src/plugins/liveobjects/index.ts'], + plugins: [umdWrapper.default({ libraryName: 'AblyLiveObjectsPlugin', amdNamedModule: false })], + outfile: 'build/liveobjects.umd.min.js', minify: true, }; @@ -117,8 +117,8 @@ module.exports = { pushPluginConfig, pushPluginCdnConfig, minifiedPushPluginCdnConfig, - objectsPluginConfig, - objectsPluginEsmConfig, - objectsPluginCdnConfig, - minifiedObjectsPluginCdnConfig, + liveObjectsPluginConfig, + liveObjectsPluginEsmConfig, + liveObjectsPluginCdnConfig, + minifiedLiveObjectsPluginCdnConfig, }; diff --git a/objects.d.ts b/liveobjects.d.ts similarity index 98% rename from objects.d.ts rename to liveobjects.d.ts index 9de8322041..700575b1df 100644 --- a/objects.d.ts +++ b/liveobjects.d.ts @@ -1,7 +1,7 @@ /** - * You are currently viewing the Ably Objects plugin type definitions for the Ably JavaScript Client Library SDK. + * You are currently viewing the Ably LiveObjects plugin type definitions for the Ably JavaScript Client Library SDK. * - * To get started with Objects, follow the [Quickstart Guide](https://ably.com/docs/liveobjects/quickstart/javascript) or view the [Introduction to Objects](https://ably.com/docs/liveobjects). + * To get started with LiveObjects, follow the [Quickstart Guide](https://ably.com/docs/liveobjects/quickstart/javascript) or view the [Introduction to LiveObjects](https://ably.com/docs/liveobjects). * * @module */ @@ -70,7 +70,7 @@ export declare interface RealtimeObject { * Example: * * ```typescript - * import { LiveCounter } from 'ably/objects'; + * import { LiveCounter } from 'ably/liveobjects'; * * type MyObject = { * myTypedCounter: LiveCounter; @@ -1852,35 +1852,35 @@ export class LiveCounter { } /** - * The Objects plugin that provides a {@link RealtimeClient} instance with the ability to use Objects functionality. + * The LiveObjects plugin that provides a {@link RealtimeClient} instance with the ability to use LiveObjects functionality. * * To create a client that includes this plugin, include it in the client options that you pass to the {@link RealtimeClient.constructor}: * * ```javascript * import { Realtime } from 'ably'; - * import { Objects } from 'ably/objects'; - * const realtime = new Realtime({ ...options, plugins: { Objects } }); + * import { LiveObjects } from 'ably/liveobjects'; + * const realtime = new Realtime({ ...options, plugins: { LiveObjects } }); * ``` * - * The Objects plugin can also be used with a {@link BaseRealtime} client: + * The LiveObjects plugin can also be used with a {@link BaseRealtime} client: * * ```javascript * import { BaseRealtime, WebSocketTransport, FetchRequest } from 'ably/modular'; - * import { Objects } from 'ably/objects'; - * const realtime = new BaseRealtime({ ...options, plugins: { WebSocketTransport, FetchRequest, Objects } }); + * import { LiveObjects } from 'ably/liveobjects'; + * const realtime = new BaseRealtime({ ...options, plugins: { WebSocketTransport, FetchRequest, LiveObjects } }); * ``` * * You can also import individual utilities alongside the plugin: * * ```javascript - * import { Objects, LiveCounter, LiveMap } from 'ably/objects'; + * import { LiveObjects, LiveCounter, LiveMap } from 'ably/liveobjects'; * ``` */ -export declare const Objects: any; +export declare const LiveObjects: any; /** * Module augmentation to add the `object` property to `RealtimeChannel` when - * importing from 'ably/objects'. This ensures all Objects types come from + * importing from 'ably/liveobjects'. This ensures all LiveObjects types come from * the same module (CJS or ESM), avoiding type incompatibility issues. */ declare module './ably' { diff --git a/package.json b/package.json index 812c834d16..cad13cc239 100644 --- a/package.json +++ b/package.json @@ -30,22 +30,22 @@ "types": "./push.d.ts", "import": "./build/push.js" }, - "./objects": { + "./liveobjects": { "import": { - "types": "./objects.d.mts", - "default": "./build/objects.mjs" + "types": "./liveobjects.d.mts", + "default": "./build/liveobjects.mjs" }, "require": { - "types": "./objects.d.ts", - "default": "./build/objects.js" + "types": "./liveobjects.d.ts", + "default": "./build/liveobjects.js" } } }, "files": [ "build/**", "ably.d.ts", - "objects.d.ts", - "objects.d.mts", + "liveobjects.d.ts", + "liveobjects.d.mts", "modular.d.ts", "push.d.ts", "resources/**", @@ -151,8 +151,8 @@ "start:react": "npx vite serve", "grunt": "grunt", "test": "npm run test:node", - "test:node": "npm run build:node && npm run build:push && npm run build:objects && mocha", - "test:grep": "npm run build:node && npm run build:push && npm run build:objects && mocha --grep", + "test:node": "npm run build:node && npm run build:push && npm run build:liveobjects && mocha", + "test:grep": "npm run build:node && npm run build:push && npm run build:liveobjects && mocha --grep", "test:node:skip-build": "mocha", "test:webserver": "grunt test:webserver", "test:playwright": "node test/support/runPlaywrightTests.js", @@ -166,7 +166,7 @@ "build:react:mjs": "tsc --project src/platform/react-hooks/tsconfig.mjs.json && cp src/platform/react-hooks/res/package.mjs.json react/mjs/package.json", "build:react:cjs": "tsc --project src/platform/react-hooks/tsconfig.cjs.json && cp src/platform/react-hooks/res/package.cjs.json react/cjs/package.json", "build:push": "grunt build:push", - "build:objects": "grunt build:objects", + "build:liveobjects": "grunt build:liveobjects", "requirejs": "grunt requirejs", "lint": "eslint .", "lint:fix": "eslint --fix .", diff --git a/scripts/moduleReport.ts b/scripts/moduleReport.ts index af5444d6ae..3dae6fc282 100644 --- a/scripts/moduleReport.ts +++ b/scripts/moduleReport.ts @@ -46,9 +46,9 @@ interface PluginInfo { external?: string[]; } -const buildablePlugins: Record<'push' | 'objects', PluginInfo> = { +const buildablePlugins: Record<'push' | 'liveobjects', PluginInfo> = { push: { description: 'Push', path: './build/push.js', external: ['ulid'] }, - objects: { description: 'Objects', path: './build/objects.js', external: ['dequal'] }, + liveobjects: { description: 'LiveObjects', path: './build/liveobjects.js', external: ['dequal'] }, }; function formatBytes(bytes: number) { @@ -217,8 +217,8 @@ async function calculatePushPluginSize(): Promise { return calculatePluginSize(buildablePlugins.push); } -async function calculateObjectsPluginSize(): Promise { - return calculatePluginSize(buildablePlugins.objects); +async function calculateLiveObjectsPluginSize(): Promise { + return calculatePluginSize(buildablePlugins.liveobjects); } async function calculateAndCheckMinimalUsefulRealtimeBundleSize(): Promise { @@ -321,28 +321,28 @@ async function checkPushPluginFiles() { return checkBundleFiles(pushPluginBundleInfo, allowedFiles, 100); } -async function checkObjectsPluginFiles() { - const { path, external } = buildablePlugins.objects; +async function checkLiveObjectsPluginFiles() { + const { path, external } = buildablePlugins.liveobjects; const pluginBundleInfo = getBundleInfo(path, undefined, external); - // These are the files that are allowed to contribute >= `threshold` bytes to the Objects bundle. + // These are the files that are allowed to contribute >= `threshold` bytes to the LiveObjects bundle. const allowedFiles = new Set([ - 'src/plugins/objects/batchcontext.ts', - 'src/plugins/objects/index.ts', - 'src/plugins/objects/instance.ts', - 'src/plugins/objects/livecounter.ts', - 'src/plugins/objects/livecountervaluetype.ts', - 'src/plugins/objects/livemap.ts', - 'src/plugins/objects/livemapvaluetype.ts', - 'src/plugins/objects/liveobject.ts', - 'src/plugins/objects/objectid.ts', - 'src/plugins/objects/objectmessage.ts', - 'src/plugins/objects/objectspool.ts', - 'src/plugins/objects/pathobject.ts', - 'src/plugins/objects/pathobjectsubscriptionregister.ts', - 'src/plugins/objects/realtimeobject.ts', - 'src/plugins/objects/rootbatchcontext.ts', - 'src/plugins/objects/syncobjectsdatapool.ts', + 'src/plugins/liveobjects/batchcontext.ts', + 'src/plugins/liveobjects/index.ts', + 'src/plugins/liveobjects/instance.ts', + 'src/plugins/liveobjects/livecounter.ts', + 'src/plugins/liveobjects/livecountervaluetype.ts', + 'src/plugins/liveobjects/livemap.ts', + 'src/plugins/liveobjects/livemapvaluetype.ts', + 'src/plugins/liveobjects/liveobject.ts', + 'src/plugins/liveobjects/objectid.ts', + 'src/plugins/liveobjects/objectmessage.ts', + 'src/plugins/liveobjects/objectspool.ts', + 'src/plugins/liveobjects/pathobject.ts', + 'src/plugins/liveobjects/pathobjectsubscriptionregister.ts', + 'src/plugins/liveobjects/realtimeobject.ts', + 'src/plugins/liveobjects/rootbatchcontext.ts', + 'src/plugins/liveobjects/syncobjectsdatapool.ts', ]); return checkBundleFiles(pluginBundleInfo, allowedFiles, 100); @@ -399,7 +399,7 @@ async function checkBundleFiles(bundleInfo: BundleInfo, allowedFiles: Set ({ tableRows: [...accum.tableRows, ...current.tableRows], @@ -408,7 +408,7 @@ async function checkBundleFiles(bundleInfo: BundleInfo, allowedFiles: Set>(serialized, MsgPack, format); @@ -42,7 +42,7 @@ export function fromDeserialized( deserialized: Record, presenceMessagePlugin: PresenceMessagePlugin | null, annotationsPlugin: AnnotationsPlugin | null, - objectsPlugin: typeof ObjectsPlugin | null, + objectsPlugin: typeof LiveObjectsPlugin | null, ): ProtocolMessage { let error: ErrorInfo | undefined; if (deserialized.error) { @@ -68,10 +68,10 @@ export function fromDeserialized( ); } - let state: ObjectsPlugin.WireObjectMessage[] | undefined; + let state: LiveObjectsPlugin.WireObjectMessage[] | undefined; if (objectsPlugin && deserialized.state) { state = objectsPlugin.WireObjectMessage.fromValuesArray( - deserialized.state as ObjectsPlugin.WireObjectMessage[], + deserialized.state as LiveObjectsPlugin.WireObjectMessage[], Utils, MessageEncoding, ); @@ -83,10 +83,12 @@ export function fromDeserialized( /** * Used internally by the tests. * - * ObjectsPlugin code can't be included as part of the core library to prevent size growth, + * LiveObjectsPlugin code can't be included as part of the core library to prevent size growth, * so if a test needs to build object messages, then it must provide the plugin upon call. */ -export function makeFromDeserializedWithDependencies(dependencies?: { ObjectsPlugin: typeof ObjectsPlugin | null }) { +export function makeFromDeserializedWithDependencies(dependencies?: { + LiveObjectsPlugin: typeof LiveObjectsPlugin | null; +}) { return (deserialized: Record): ProtocolMessage => { return fromDeserialized( deserialized, @@ -95,7 +97,7 @@ export function makeFromDeserializedWithDependencies(dependencies?: { ObjectsPlu WirePresenceMessage, }, { Annotation, WireAnnotation, RealtimeAnnotations, RestAnnotations }, - dependencies?.ObjectsPlugin ?? null, + dependencies?.LiveObjectsPlugin ?? null, ); }; } @@ -108,7 +110,7 @@ export function stringify( msg: any, presenceMessagePlugin: PresenceMessagePlugin | null, annotationsPlugin: AnnotationsPlugin | null, - objectsPlugin: typeof ObjectsPlugin | null, + objectsPlugin: typeof LiveObjectsPlugin | null, ): string { let result = '[ProtocolMessage'; if (msg.action !== undefined) result += '; action=' + ActionName[msg.action] || msg.action; @@ -167,9 +169,9 @@ class ProtocolMessage { presence?: WirePresenceMessage[]; annotations?: WireAnnotation[]; /** - * This will be undefined if we skipped decoding this property due to user not requesting Objects functionality — see {@link fromDeserialized} + * This will be undefined if we skipped decoding this property due to user not requesting LiveObjects functionality — see {@link fromDeserialized} */ - state?: ObjectsPlugin.WireObjectMessage[]; // TR4r + state?: LiveObjectsPlugin.WireObjectMessage[]; // TR4r auth?: unknown; connectionDetails?: Record; params?: Record; diff --git a/src/plugins/index.d.ts b/src/plugins/index.d.ts index b1a4fa3ce5..035cc3d14e 100644 --- a/src/plugins/index.d.ts +++ b/src/plugins/index.d.ts @@ -1,7 +1,7 @@ -import Objects from './objects'; +import LiveObjects from './liveobjects'; import Push from './push'; export interface StandardPlugins { - Objects?: typeof Objects; + LiveObjects?: typeof LiveObjects; Push?: typeof Push; } diff --git a/src/plugins/objects/batchcontext.ts b/src/plugins/liveobjects/batchcontext.ts similarity index 99% rename from src/plugins/objects/batchcontext.ts rename to src/plugins/liveobjects/batchcontext.ts index 1f7858acc2..0a998faacc 100644 --- a/src/plugins/objects/batchcontext.ts +++ b/src/plugins/liveobjects/batchcontext.ts @@ -7,7 +7,7 @@ import type { Instance, Primitive, Value, -} from '../../../objects'; +} from '../../../liveobjects'; import { DefaultInstance } from './instance'; import { LiveCounter } from './livecounter'; import { LiveMap } from './livemap'; diff --git a/src/plugins/objects/constants.ts b/src/plugins/liveobjects/constants.ts similarity index 100% rename from src/plugins/objects/constants.ts rename to src/plugins/liveobjects/constants.ts diff --git a/src/plugins/objects/defaults.ts b/src/plugins/liveobjects/defaults.ts similarity index 100% rename from src/plugins/objects/defaults.ts rename to src/plugins/liveobjects/defaults.ts diff --git a/src/plugins/objects/index.ts b/src/plugins/liveobjects/index.ts similarity index 82% rename from src/plugins/objects/index.ts rename to src/plugins/liveobjects/index.ts index bf0e7c2232..337a52f442 100644 --- a/src/plugins/objects/index.ts +++ b/src/plugins/liveobjects/index.ts @@ -12,9 +12,9 @@ export { }; /** - * The named Objects plugin object export to be passed to the Ably client. + * The named LiveObjects plugin object export to be passed to the Ably client. */ -export const Objects = { +export const LiveObjects = { LiveCounter: LiveCounterValueType, LiveMap: LiveMapValueType, ObjectMessage, diff --git a/src/plugins/objects/instance.ts b/src/plugins/liveobjects/instance.ts similarity index 99% rename from src/plugins/objects/instance.ts rename to src/plugins/liveobjects/instance.ts index 08e2f9c020..e49ef64a3f 100644 --- a/src/plugins/objects/instance.ts +++ b/src/plugins/liveobjects/instance.ts @@ -11,7 +11,7 @@ import type { LiveObject as LiveObjectType, Primitive, Value, -} from '../../../objects'; +} from '../../../liveobjects'; import { LiveCounter } from './livecounter'; import { LiveMap } from './livemap'; import { LiveObject } from './liveobject'; diff --git a/src/plugins/objects/livecounter.ts b/src/plugins/liveobjects/livecounter.ts similarity index 99% rename from src/plugins/objects/livecounter.ts rename to src/plugins/liveobjects/livecounter.ts index 31db134f85..ae2e06edde 100644 --- a/src/plugins/objects/livecounter.ts +++ b/src/plugins/liveobjects/livecounter.ts @@ -1,5 +1,5 @@ import { __livetype } from '../../../ably'; -import { LiveCounter as PublicLiveCounter } from '../../../objects'; +import { LiveCounter as PublicLiveCounter } from '../../../liveobjects'; import { LiveObject, LiveObjectData, LiveObjectUpdate, LiveObjectUpdateNoop } from './liveobject'; import { ObjectData, ObjectMessage, ObjectOperation, ObjectOperationAction, ObjectsCounterOp } from './objectmessage'; import { RealtimeObject } from './realtimeobject'; diff --git a/src/plugins/objects/livecountervaluetype.ts b/src/plugins/liveobjects/livecountervaluetype.ts similarity index 98% rename from src/plugins/objects/livecountervaluetype.ts rename to src/plugins/liveobjects/livecountervaluetype.ts index 266c17fb84..456f3e4fe4 100644 --- a/src/plugins/objects/livecountervaluetype.ts +++ b/src/plugins/liveobjects/livecountervaluetype.ts @@ -1,5 +1,5 @@ import { __livetype } from '../../../ably'; -import { LiveCounter } from '../../../objects'; +import { LiveCounter } from '../../../liveobjects'; import { ObjectId } from './objectid'; import { createInitialValueJSONString, diff --git a/src/plugins/objects/livemap.ts b/src/plugins/liveobjects/livemap.ts similarity index 99% rename from src/plugins/objects/livemap.ts rename to src/plugins/liveobjects/livemap.ts index 2255c53905..b3d64c654a 100644 --- a/src/plugins/objects/livemap.ts +++ b/src/plugins/liveobjects/livemap.ts @@ -1,14 +1,14 @@ import { dequal } from 'dequal'; -import { __livetype } from '../../../ably'; +import { __livetype } from '../../../ably'; import { CompactedJsonValue, CompactedValue, + Primitive, LiveMap as PublicLiveMap, LiveObject as PublicLiveObject, - Primitive, Value, -} from '../../../objects'; +} from '../../../liveobjects'; import { LiveCounter } from './livecounter'; import { LiveCounterValueType } from './livecountervaluetype'; import { LiveMapValueType } from './livemapvaluetype'; diff --git a/src/plugins/objects/livemapvaluetype.ts b/src/plugins/liveobjects/livemapvaluetype.ts similarity index 98% rename from src/plugins/objects/livemapvaluetype.ts rename to src/plugins/liveobjects/livemapvaluetype.ts index cb40259f16..40ce2a860f 100644 --- a/src/plugins/objects/livemapvaluetype.ts +++ b/src/plugins/liveobjects/livemapvaluetype.ts @@ -1,5 +1,5 @@ import { __livetype } from '../../../ably'; -import { LiveMap as PublicLiveMap, Primitive, Value } from '../../../objects'; +import { Primitive, LiveMap as PublicLiveMap, Value } from '../../../liveobjects'; import { LiveCounterValueType } from './livecountervaluetype'; import { LiveMap, LiveMapObjectData, ObjectIdObjectData, ValueObjectData } from './livemap'; import { ObjectId } from './objectid'; diff --git a/src/plugins/objects/liveobject.ts b/src/plugins/liveobjects/liveobject.ts similarity index 100% rename from src/plugins/objects/liveobject.ts rename to src/plugins/liveobjects/liveobject.ts diff --git a/src/plugins/objects/objectid.ts b/src/plugins/liveobjects/objectid.ts similarity index 100% rename from src/plugins/objects/objectid.ts rename to src/plugins/liveobjects/objectid.ts diff --git a/src/plugins/objects/objectmessage.ts b/src/plugins/liveobjects/objectmessage.ts similarity index 99% rename from src/plugins/objects/objectmessage.ts rename to src/plugins/liveobjects/objectmessage.ts index 14caf71fda..c6cbda5af8 100644 --- a/src/plugins/objects/objectmessage.ts +++ b/src/plugins/liveobjects/objectmessage.ts @@ -2,7 +2,7 @@ import type BaseClient from 'common/lib/client/baseclient'; import type RealtimeChannel from 'common/lib/client/realtimechannel'; import type { MessageEncoding } from 'common/lib/types/basemessage'; import type * as Utils from 'common/lib/util/utils'; -import type * as ObjectsApi from '../../../objects'; +import type * as ObjectsApi from '../../../liveobjects'; const operationActions: ObjectsApi.ObjectOperationAction[] = [ 'map.create', diff --git a/src/plugins/objects/objectspool.ts b/src/plugins/liveobjects/objectspool.ts similarity index 97% rename from src/plugins/objects/objectspool.ts rename to src/plugins/liveobjects/objectspool.ts index 4c2fe021b2..f9f1fe7bd2 100644 --- a/src/plugins/objects/objectspool.ts +++ b/src/plugins/liveobjects/objectspool.ts @@ -118,7 +118,7 @@ export class ObjectsPool { const toDelete: string[] = []; for (const [objectId, obj] of this._pool.entries()) { // tombstoned objects should be removed from the pool if they have been tombstoned for longer than grace period. - // by removing them from the local pool, Objects plugin no longer keeps a reference to those objects, allowing JS's + // by removing them from the local pool, LiveObjects plugin no longer keeps a reference to those objects, allowing JS's // Garbage Collection to eventually free the memory for those objects, provided the user no longer references them either. if (obj.isTombstoned() && Date.now() - obj.tombstonedAt()! >= this._realtimeObject.gcGracePeriod) { toDelete.push(objectId); diff --git a/src/plugins/objects/pathobject.ts b/src/plugins/liveobjects/pathobject.ts similarity index 99% rename from src/plugins/objects/pathobject.ts rename to src/plugins/liveobjects/pathobject.ts index 9e1e9c2438..bc184f5344 100644 --- a/src/plugins/objects/pathobject.ts +++ b/src/plugins/liveobjects/pathobject.ts @@ -13,7 +13,7 @@ import type { PathObjectSubscriptionOptions, Primitive, Value, -} from '../../../objects'; +} from '../../../liveobjects'; import { DefaultInstance } from './instance'; import { LiveCounter } from './livecounter'; import { LiveMap } from './livemap'; diff --git a/src/plugins/objects/pathobjectsubscriptionregister.ts b/src/plugins/liveobjects/pathobjectsubscriptionregister.ts similarity index 99% rename from src/plugins/objects/pathobjectsubscriptionregister.ts rename to src/plugins/liveobjects/pathobjectsubscriptionregister.ts index 2649aaaafb..68e2f22be5 100644 --- a/src/plugins/objects/pathobjectsubscriptionregister.ts +++ b/src/plugins/liveobjects/pathobjectsubscriptionregister.ts @@ -1,6 +1,6 @@ import type BaseClient from 'common/lib/client/baseclient'; import type { EventCallback, Subscription } from '../../../ably'; -import type { PathObjectSubscriptionEvent, PathObjectSubscriptionOptions } from '../../../objects'; +import type { PathObjectSubscriptionEvent, PathObjectSubscriptionOptions } from '../../../liveobjects'; import { ObjectMessage } from './objectmessage'; import { DefaultPathObject } from './pathobject'; import { RealtimeObject } from './realtimeobject'; diff --git a/src/plugins/objects/realtimeobject.ts b/src/plugins/liveobjects/realtimeobject.ts similarity index 99% rename from src/plugins/objects/realtimeobject.ts rename to src/plugins/liveobjects/realtimeobject.ts index 8f1287a276..4b786b19a8 100644 --- a/src/plugins/objects/realtimeobject.ts +++ b/src/plugins/liveobjects/realtimeobject.ts @@ -2,7 +2,7 @@ import type BaseClient from 'common/lib/client/baseclient'; import type RealtimeChannel from 'common/lib/client/realtimechannel'; import type EventEmitter from 'common/lib/util/eventemitter'; import type { ChannelState } from '../../../ably'; -import type * as ObjectsApi from '../../../objects'; +import type * as ObjectsApi from '../../../liveobjects'; import { DEFAULTS } from './defaults'; import { LiveCounter } from './livecounter'; import { LiveMap } from './livemap'; diff --git a/src/plugins/objects/rootbatchcontext.ts b/src/plugins/liveobjects/rootbatchcontext.ts similarity index 97% rename from src/plugins/objects/rootbatchcontext.ts rename to src/plugins/liveobjects/rootbatchcontext.ts index 4edbbee01a..ed93c0e32e 100644 --- a/src/plugins/objects/rootbatchcontext.ts +++ b/src/plugins/liveobjects/rootbatchcontext.ts @@ -1,4 +1,4 @@ -import type { Instance, Value } from '../../../objects'; +import type { Instance, Value } from '../../../liveobjects'; import { DefaultBatchContext } from './batchcontext'; import { ObjectMessage } from './objectmessage'; import { RealtimeObject } from './realtimeobject'; diff --git a/src/plugins/objects/syncobjectsdatapool.ts b/src/plugins/liveobjects/syncobjectsdatapool.ts similarity index 100% rename from src/plugins/objects/syncobjectsdatapool.ts rename to src/plugins/liveobjects/syncobjectsdatapool.ts diff --git a/test/common/globals/named_dependencies.js b/test/common/globals/named_dependencies.js index 5e9367ff45..db0d819e60 100644 --- a/test/common/globals/named_dependencies.js +++ b/test/common/globals/named_dependencies.js @@ -11,9 +11,9 @@ define(function () { browser: 'build/push', node: 'build/push', }, - objects: { - browser: 'build/objects', - node: 'build/objects', + liveobjects: { + browser: 'build/liveobjects', + node: 'build/liveobjects', }, // test modules @@ -27,9 +27,9 @@ define(function () { browser: 'test/common/modules/private_api_recorder', node: 'test/common/modules/private_api_recorder', }, - objects_helper: { - browser: 'test/common/modules/objects_helper', - node: 'test/common/modules/objects_helper', + liveobjects_helper: { + browser: 'test/common/modules/liveobjects_helper', + node: 'test/common/modules/liveobjects_helper', }, }); }); diff --git a/test/common/modules/objects_helper.js b/test/common/modules/liveobjects_helper.js similarity index 97% rename from test/common/modules/objects_helper.js rename to test/common/modules/liveobjects_helper.js index 744cbb8e70..3c0dc05bc2 100644 --- a/test/common/modules/objects_helper.js +++ b/test/common/modules/liveobjects_helper.js @@ -3,8 +3,8 @@ /** * Helper class to create pre-determined objects tree on channels and create object messages. */ -define(['ably', 'shared_helper', 'objects'], function (Ably, Helper, ObjectsPlugin) { - const createPM = Ably.makeProtocolMessageFromDeserialized({ ObjectsPlugin }); +define(['ably', 'shared_helper', 'liveobjects'], function (Ably, Helper, LiveObjectsPlugin) { + const createPM = Ably.makeProtocolMessageFromDeserialized({ LiveObjectsPlugin }); const ACTIONS = { MAP_CREATE: 0, @@ -27,7 +27,7 @@ define(['ably', 'shared_helper', 'objects'], function (Ably, Helper, ObjectsPlug return Helper.randomString(); } - class ObjectsHelper { + class LiveObjectsHelper { constructor(helper) { this._helper = helper; this._rest = helper.AblyRest({ useBinaryProtocol: false }); @@ -426,5 +426,5 @@ define(['ably', 'shared_helper', 'objects'], function (Ably, Helper, ObjectsPlug } } - return (module.exports = ObjectsHelper); + return (module.exports = LiveObjectsHelper); }); diff --git a/test/package/browser/template/README.md b/test/package/browser/template/README.md index e1653d7987..540571d13d 100644 --- a/test/package/browser/template/README.md +++ b/test/package/browser/template/README.md @@ -8,7 +8,7 @@ This directory is intended to be used for testing the following aspects of the a It contains three files, each of which import ably-js in different manners, and provide a way to briefly exercise its functionality: - `src/index-default.ts` imports the default ably-js package (`import { Realtime } from 'ably'`). -- `src/index-objects.ts` imports the Objects ably-js plugin (`import { Objects } from 'ably/objects'`). +- `src/index-liveobjects.ts` imports the LiveObjects ably-js plugin (`import { LiveObjects } from 'ably/liveobjects'`). - `src/index-modular.ts` imports the tree-shakable ably-js package (`import { BaseRealtime, WebSocketTransport, FetchRequest } from 'ably/modular'`). - `src/ReactApp.tsx` imports React hooks from the ably-js package (`import { useChannel } from 'ably/react'`). @@ -26,7 +26,7 @@ This directory exposes three package scripts that are to be used for testing: - `build`: Uses esbuild to create: 1. a bundle containing `src/index-default.ts` and ably-js; - 2. a bundle containing `src/index-objects.ts` and ably-js. + 2. a bundle containing `src/index-liveobjects.ts` and ably-js. 3. a bundle containing `src/index-modular.ts` and ably-js. - `test`: Using the bundles created by `build` and playwright components setup, tests that the code that exercises ably-js’s functionality is working correctly in a browser. - `typecheck`: Type-checks the code that imports ably-js. diff --git a/test/package/browser/template/package.json b/test/package/browser/template/package.json index 574da1a7b3..f2c023b6e6 100644 --- a/test/package/browser/template/package.json +++ b/test/package/browser/template/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "esbuild --bundle src/index-default.ts --outdir=dist && esbuild --bundle src/index-objects.ts --outdir=dist && esbuild --bundle src/index-modular.ts --outdir=dist", + "build": "esbuild --bundle src/index-default.ts --outdir=dist && esbuild --bundle src/index-liveobjects.ts --outdir=dist && esbuild --bundle src/index-modular.ts --outdir=dist", "typecheck": "tsc --project src -noEmit", "test-support:server": "ts-node server/server.ts", "test": "npm run test:lib && npm run test:hooks", diff --git a/test/package/browser/template/server/resources/index-objects.html b/test/package/browser/template/server/resources/index-liveobjects.html similarity index 54% rename from test/package/browser/template/server/resources/index-objects.html rename to test/package/browser/template/server/resources/index-liveobjects.html index 44d594e83c..b7f284af5a 100644 --- a/test/package/browser/template/server/resources/index-objects.html +++ b/test/package/browser/template/server/resources/index-liveobjects.html @@ -2,10 +2,10 @@ - Ably NPM package test (Objects plugin export) + Ably NPM package test (LiveObjects plugin export) - + diff --git a/test/package/browser/template/server/server.ts b/test/package/browser/template/server/server.ts index 0cac0b7f18..faa1399f70 100644 --- a/test/package/browser/template/server/server.ts +++ b/test/package/browser/template/server/server.ts @@ -5,7 +5,7 @@ async function startWebServer(listenPort: number) { const server = express(); server.get('/', (req, res) => res.send('OK')); server.use(express.static(path.join(__dirname, '/resources'))); - for (const filename of ['index-default.js', 'index-objects.js', 'index-modular.js']) { + for (const filename of ['index-default.js', 'index-liveobjects.js', 'index-modular.js']) { server.use(`/${filename}`, express.static(path.join(__dirname, '..', 'dist', filename))); } diff --git a/test/package/browser/template/src/index-objects.ts b/test/package/browser/template/src/index-liveobjects.ts similarity index 93% rename from test/package/browser/template/src/index-objects.ts rename to test/package/browser/template/src/index-liveobjects.ts index f56112e3d5..1603637f47 100644 --- a/test/package/browser/template/src/index-objects.ts +++ b/test/package/browser/template/src/index-liveobjects.ts @@ -7,10 +7,10 @@ import { LiveCounterPathObject, LiveMap, LiveMapPathObject, + LiveObjects, ObjectMessage, - Objects, PathObject, -} from 'ably/objects'; +} from 'ably/liveobjects'; import { createSandboxAblyAPIKey } from './sandbox'; // Fix for "type 'typeof globalThis' has no index signature" error: @@ -38,12 +38,12 @@ type MyCustomObject = { globalThis.testAblyPackage = async function () { const key = await createSandboxAblyAPIKey(); - const realtime = new Realtime({ key, endpoint: 'nonprod:sandbox', plugins: { Objects } }); + const realtime = new Realtime({ key, endpoint: 'nonprod:sandbox', plugins: { LiveObjects } }); const channel = realtime.channels.get('channel', { modes: ['OBJECT_SUBSCRIBE', 'OBJECT_PUBLISH'] }); await channel.attach(); - // check Objects can be accessed on a channel with a custom type parameter. - // check that we can refer to the Objects types exported from 'ably/objects' by referencing a LiveMap interface. + // check LiveObjects can be accessed on a channel with a custom type parameter. + // check that we can refer to the LiveObjects types exported from 'ably/liveobjects' by referencing a LiveMap interface. const myObject: PathObject> = await channel.object.get(); // check entrypoint has expected LiveMap TypeScript type methods diff --git a/test/package/browser/template/test/lib/package.test.ts b/test/package/browser/template/test/lib/package.test.ts index 6c903d7f4a..8554dd762b 100644 --- a/test/package/browser/template/test/lib/package.test.ts +++ b/test/package/browser/template/test/lib/package.test.ts @@ -3,7 +3,7 @@ import { test, expect } from '@playwright/test'; test.describe('NPM package', () => { for (const scenario of [ { name: 'default export', path: '/index-default.html' }, - { name: 'Objects plugin export', path: '/index-objects.html' }, + { name: 'LiveObjects plugin export', path: '/index-liveobjects.html' }, { name: 'modular export', path: '/index-modular.html' }, ]) { test.describe(scenario.name, () => { diff --git a/test/realtime/objects.test.js b/test/realtime/liveobjects.test.js similarity index 98% rename from test/realtime/objects.test.js rename to test/realtime/liveobjects.test.js index 148a336bb4..f4fca6a3f2 100644 --- a/test/realtime/objects.test.js +++ b/test/realtime/liveobjects.test.js @@ -1,28 +1,28 @@ 'use strict'; -define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function ( +define(['ably', 'shared_helper', 'chai', 'liveobjects', 'liveobjects_helper'], function ( Ably, Helper, chai, - ObjectsPlugin, - ObjectsHelper, + LiveObjectsPlugin, + LiveObjectsHelper, ) { const expect = chai.expect; const BufferUtils = Ably.Realtime.Platform.BufferUtils; const Utils = Ably.Realtime.Utils; const MessageEncoding = Ably.Realtime._MessageEncoding; - const createPM = Ably.makeProtocolMessageFromDeserialized({ ObjectsPlugin }); - const objectsFixturesChannel = 'objects_fixtures'; + const createPM = Ably.makeProtocolMessageFromDeserialized({ LiveObjectsPlugin }); + const liveobjectsFixturesChannel = 'liveobjects_fixtures'; const nextTick = Ably.Realtime.Platform.Config.nextTick; - const gcIntervalOriginal = ObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval; - const LiveMap = ObjectsPlugin.LiveMap; - const LiveCounter = ObjectsPlugin.LiveCounter; + const gcIntervalOriginal = LiveObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval; + const LiveMap = LiveObjectsPlugin.LiveMap; + const LiveCounter = LiveObjectsPlugin.LiveCounter; - function RealtimeWithObjects(helper, options) { - return helper.AblyRealtime({ ...options, plugins: { Objects: ObjectsPlugin } }); + function RealtimeWithLiveObjects(helper, options) { + return helper.AblyRealtime({ ...options, plugins: { LiveObjects: LiveObjectsPlugin } }); } - function channelOptionsWithObjects(options) { + function channelOptionsWithLiveObjects(options) { return { ...options, modes: ['OBJECT_SUBSCRIBE', 'OBJECT_PUBLISH'], @@ -92,7 +92,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function } function objectMessageFromValues(values) { - return ObjectsPlugin.ObjectMessage.fromValues(values, Utils, MessageEncoding); + return LiveObjectsPlugin.ObjectMessage.fromValues(values, Utils, MessageEncoding); } async function waitForMapKeyUpdate(mapInstance, key) { @@ -164,12 +164,12 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function } /** - * The channel with fixture data may not yet be populated by REST API requests made by ObjectsHelper. + * The channel with fixture data may not yet be populated by REST API requests made by LiveObjectsHelper. * This function waits for a channel to have all keys set. */ async function waitFixtureChannelIsReady(client) { - const channel = client.channels.get(objectsFixturesChannel, channelOptionsWithObjects()); - const expectedKeys = ObjectsHelper.fixtureRootKeys(); + const channel = client.channels.get(liveobjectsFixturesChannel, channelOptionsWithLiveObjects()); + const expectedKeys = LiveObjectsHelper.fixtureRootKeys(); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -180,7 +180,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function ); } - describe('realtime/objects', function () { + describe('realtime/liveobjects', function () { this.timeout(60 * 1000); before(function (done) { @@ -192,26 +192,26 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function return; } - new ObjectsHelper(helper) - .initForChannel(objectsFixturesChannel) + new LiveObjectsHelper(helper) + .initForChannel(liveobjectsFixturesChannel) .then(done) .catch((err) => done(err)); }); }); - describe('Realtime without Objects plugin', () => { + describe('Realtime without LiveObjects plugin', () => { /** @nospec */ it("throws an error when attempting to access the channel's `object` property", async function () { const helper = this.test.helper; const client = helper.AblyRealtime({ autoConnect: false }); const channel = client.channels.get('channel'); - expect(() => channel.object).to.throw('Objects plugin not provided'); + expect(() => channel.object).to.throw('LiveObjects plugin not provided'); }); /** @nospec */ it(`doesn't break when it receives an OBJECT ProtocolMessage`, async function () { const helper = this.test.helper; - const objectsHelper = new ObjectsHelper(helper); + const objectsHelper = new LiveObjectsHelper(helper); const testClient = helper.AblyRealtime(); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { @@ -243,7 +243,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it(`doesn't break when it receives an OBJECT_SYNC ProtocolMessage`, async function () { const helper = this.test.helper; - const objectsHelper = new ObjectsHelper(helper); + const objectsHelper = new LiveObjectsHelper(helper); const testClient = helper.AblyRealtime(); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { @@ -277,11 +277,11 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function }); }); - describe('Realtime with Objects plugin', () => { + describe('Realtime with LiveObjects plugin', () => { /** @nospec */ it("returns RealtimeObject class instance when accessing channel's `object` property", async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper, { autoConnect: false }); + const client = RealtimeWithLiveObjects(helper, { autoConnect: false }); const channel = client.channels.get('channel'); expectInstanceOf(channel.object, 'RealtimeObject'); }); @@ -289,10 +289,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() returns LiveObject with id "root"', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -304,10 +304,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() returns empty root when no objects exist on a channel', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -319,10 +319,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() waits for initial OBJECT_SYNC to be completed before resolving', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); const getPromise = channel.object.get(); @@ -347,10 +347,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() resolves immediately when OBJECT_SYNC sequence is completed', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); await channel.attach(); // wait for sync sequence to complete by accessing root for the first time @@ -372,11 +372,11 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() waits for OBJECT_SYNC with empty cursor before resolving', async function () { const helper = this.test.helper; - const objectsHelper = new ObjectsHelper(helper); - const client = RealtimeWithObjects(helper); + const objectsHelper = new LiveObjectsHelper(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); await channel.attach(); // wait for initial sync sequence to complete @@ -432,10 +432,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ it('RealtimeObject.get() on unattached channel implicitly attaches and waits for sync', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); expect(channel.state).to.equal('initialized', 'Channel should be in initialized state'); // Set up a timeout to catch if get() hangs @@ -540,7 +540,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function await waitFixtureChannelIsReady(client); - const channel = client.channels.get(objectsFixturesChannel, channelOptionsWithObjects()); + const channel = client.channels.get(liveobjectsFixturesChannel, channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -632,10 +632,10 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function ]); // create a new client and check it syncs with the aggregated data - const client2 = RealtimeWithObjects(helper, clientOptions); + const client2 = RealtimeWithLiveObjects(helper, clientOptions); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel2 = client2.channels.get(channelName, channelOptionsWithObjects()); + const channel2 = client2.channels.get(channelName, channelOptionsWithLiveObjects()); await channel2.attach(); const pathObject2 = await channel2.object.get(); @@ -712,7 +712,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function await waitFixtureChannelIsReady(client); - const channel = client.channels.get(objectsFixturesChannel, channelOptionsWithObjects()); + const channel = client.channels.get(liveobjectsFixturesChannel, channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -738,7 +738,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function await waitFixtureChannelIsReady(client); - const channel = client.channels.get(objectsFixturesChannel, channelOptionsWithObjects()); + const channel = client.channels.get(liveobjectsFixturesChannel, channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -6720,11 +6720,11 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function ...instanceScenarios, ], async function (helper, scenario, clientOptions, channelName) { - const objectsHelper = new ObjectsHelper(helper); - const client = RealtimeWithObjects(helper, clientOptions); + const objectsHelper = new LiveObjectsHelper(helper); + const client = RealtimeWithLiveObjects(helper, clientOptions); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get(channelName, channelOptionsWithObjects()); + const channel = client.channels.get(channelName, channelOptionsWithLiveObjects()); const realtimeObject = channel.object; await channel.attach(); @@ -6990,7 +6990,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function action: async (ctx) => { const { channelName, sampleMapKey, sampleCounterKey, helper, entryPathObject, entryInstance } = ctx; const publishClientId = 'publish-clientId'; - const publishClient = RealtimeWithObjects(helper, { clientId: publishClientId }); + const publishClient = RealtimeWithLiveObjects(helper, { clientId: publishClientId }); // get the connection ID from the publish client once connected let publishConnectionId; @@ -7072,7 +7072,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function ]); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const publishChannel = publishClient.channels.get(channelName, channelOptionsWithObjects()); + const publishChannel = publishClient.channels.get(channelName, channelOptionsWithLiveObjects()); await publishChannel.attach(); const publishRoot = await publishChannel.object.get(); @@ -7253,11 +7253,11 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ forScenarios(this, subscriptionCallbacksScenarios, async function (helper, scenario, clientOptions, channelName) { - const objectsHelper = new ObjectsHelper(helper); - const client = RealtimeWithObjects(helper, clientOptions); + const objectsHelper = new LiveObjectsHelper(helper); + const client = RealtimeWithLiveObjects(helper, clientOptions); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get(channelName, channelOptionsWithObjects()); + const channel = client.channels.get(channelName, channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -7300,12 +7300,12 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function it('gcGracePeriod is set from connectionDetails.objectsGCGracePeriod', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { await client.connection.once('connected'); - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); const realtimeObject = channel.object; const connectionManager = client.connection.connectionManager; const connectionDetails = connectionManager.connectionDetails; @@ -7339,7 +7339,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function helper.recordPrivateApi('listen.connectionManager.connectiondetails'); await connectionDetailsPromise; - // wait for next tick to ensure the connectionDetails event was processed by Objects plugin + // wait for next tick to ensure the connectionDetails event was processed by LiveObjects plugin await new Promise((res) => nextTick(res)); helper.recordPrivateApi('read.RealtimeObject.gcGracePeriod'); @@ -7349,12 +7349,12 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function it('gcGracePeriod has a default value if connectionDetails.objectsGCGracePeriod is missing', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { await client.connection.once('connected'); - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); const realtimeObject = channel.object; const connectionManager = client.connection.connectionManager; const connectionDetails = connectionManager.connectionDetails; @@ -7362,7 +7362,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function helper.recordPrivateApi('read.RealtimeObject._DEFAULTS.gcGracePeriod'); helper.recordPrivateApi('write.RealtimeObject.gcGracePeriod'); // set gcGracePeriod to a value different from the default - realtimeObject.gcGracePeriod = ObjectsPlugin.RealtimeObject._DEFAULTS.gcGracePeriod + 1; + realtimeObject.gcGracePeriod = LiveObjectsPlugin.RealtimeObject._DEFAULTS.gcGracePeriod + 1; const connectionDetailsPromise = connectionManager.once('connectiondetails'); @@ -7379,27 +7379,31 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function helper.recordPrivateApi('listen.connectionManager.connectiondetails'); await connectionDetailsPromise; - // wait for next tick to ensure the connectionDetails event was processed by Objects plugin + // wait for next tick to ensure the connectionDetails event was processed by LiveObjects plugin await new Promise((res) => nextTick(res)); helper.recordPrivateApi('read.RealtimeObject._DEFAULTS.gcGracePeriod'); helper.recordPrivateApi('read.RealtimeObject.gcGracePeriod'); expect(realtimeObject.gcGracePeriod).to.equal( - ObjectsPlugin.RealtimeObject._DEFAULTS.gcGracePeriod, + LiveObjectsPlugin.RealtimeObject._DEFAULTS.gcGracePeriod, 'Check gcGracePeriod is set to a default value if connectionDetails.objectsGCGracePeriod is missing', ); }, client); }); const tombstonesGCScenarios = [ - // for the next tests we need to access the private API of Objects plugin in order to verify that tombstoned entities were indeed deleted after the GC grace period. + // for the next tests we need to access the private API of LiveObjects plugin in order to verify that tombstoned entities were indeed deleted after the GC grace period. // public API hides that kind of information from the user and returns undefined for tombstoned entities even if realtime client still keeps a reference to them. { description: 'tombstoned object is removed from the pool after the GC grace period', action: async (ctx) => { const { objectsHelper, channelName, channel, realtimeObject, helper, waitForGCCycles, client } = ctx; - const counterCreatedPromise = waitForObjectOperation(helper, client, ObjectsHelper.ACTIONS.COUNTER_CREATE); + const counterCreatedPromise = waitForObjectOperation( + helper, + client, + LiveObjectsHelper.ACTIONS.COUNTER_CREATE, + ); // send a CREATE op, this adds an object to the pool const { objectId } = await objectsHelper.operationRequest( channelName, @@ -7500,13 +7504,13 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function forScenarios(this, tombstonesGCScenarios, async function (helper, scenario, clientOptions, channelName) { try { helper.recordPrivateApi('write.RealtimeObject._DEFAULTS.gcInterval'); - ObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval = 500; + LiveObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval = 500; - const objectsHelper = new ObjectsHelper(helper); - const client = RealtimeWithObjects(helper, clientOptions); + const objectsHelper = new LiveObjectsHelper(helper); + const client = RealtimeWithLiveObjects(helper, clientOptions); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { - const channel = client.channels.get(channelName, channelOptionsWithObjects()); + const channel = client.channels.get(channelName, channelOptionsWithLiveObjects()); const realtimeObject = channel.object; await channel.attach(); @@ -7555,7 +7559,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function }, client); } finally { helper.recordPrivateApi('write.RealtimeObject._DEFAULTS.gcInterval'); - ObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval = gcIntervalOriginal; + LiveObjectsPlugin.RealtimeObject._DEFAULTS.gcInterval = gcIntervalOriginal; } }); @@ -7760,13 +7764,13 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ forScenarios(this, clientConfigurationScenarios, async function (helper, scenario, clientOptions, channelName) { - const objectsHelper = new ObjectsHelper(helper); - const client = RealtimeWithObjects(helper, clientOptions); + const objectsHelper = new LiveObjectsHelper(helper); + const client = RealtimeWithLiveObjects(helper, clientOptions); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { // attach with correct channel modes so we can create Objects on the root for testing. // some scenarios will modify the underlying modes array to test specific behavior - const channel = client.channels.get(channelName, channelOptionsWithObjects()); + const channel = client.channels.get(channelName, channelOptionsWithLiveObjects()); const realtimeObject = channel.object; await channel.attach(); @@ -7805,7 +7809,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function */ it('object message publish respects connectionDetails.maxMessageSize', async function () { const helper = this.test.helper; - const client = RealtimeWithObjects(helper); + const client = RealtimeWithLiveObjects(helper); await helper.monitorConnectionThenCloseAndFinishAsync(async () => { await client.connection.once('connected'); @@ -7831,7 +7835,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function helper.recordPrivateApi('listen.connectionManager.connectiondetails'); await connectionDetailsPromise; - const channel = client.channels.get('channel', channelOptionsWithObjects()); + const channel = client.channels.get('channel', channelOptionsWithLiveObjects()); await channel.attach(); const entryPathObject = await channel.object.get(); @@ -8148,7 +8152,7 @@ define(['ably', 'shared_helper', 'chai', 'objects', 'objects_helper'], function /** @nospec */ forScenarios(this, objectMessageSizeScenarios, function (helper, scenario) { - const client = RealtimeWithObjects(helper, { autoConnect: false }); + const client = RealtimeWithLiveObjects(helper, { autoConnect: false }); helper.recordPrivateApi('call.ObjectMessage.encode'); const encodedMessage = scenario.message.encode(client); helper.recordPrivateApi('call.BufferUtils.utf8Encode'); // was called by a scenario to create buffers diff --git a/test/support/browser_file_list.js b/test/support/browser_file_list.js index c6cd5668c5..41c92692f7 100644 --- a/test/support/browser_file_list.js +++ b/test/support/browser_file_list.js @@ -39,7 +39,7 @@ window.__testFiles__.files = { 'test/realtime/failure.test.js': true, 'test/realtime/history.test.js': true, 'test/realtime/init.test.js': true, - 'test/realtime/objects.test.js': true, + 'test/realtime/liveobjects.test.js': true, 'test/realtime/message.test.js': true, 'test/realtime/presence.test.js': true, 'test/realtime/reauth.test.js': true, diff --git a/tsconfig.typedoc.json b/tsconfig.typedoc.json index 4f2342baa5..fbc3eb23ce 100644 --- a/tsconfig.typedoc.json +++ b/tsconfig.typedoc.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["src/platform/react-hooks", "test/package", "objects.d.mts"] + "exclude": ["src/platform/react-hooks", "test/package", "liveobjects.d.mts"] } diff --git a/typedoc.json b/typedoc.json index 027b9fcd28..3a7708bd4b 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,6 +1,6 @@ { "$schema": "https://typedoc.org/schema.json", - "entryPoints": ["ably.d.ts", "modular.d.ts", "objects.d.ts"], + "entryPoints": ["ably.d.ts", "modular.d.ts", "liveobjects.d.ts"], "tsconfig": "tsconfig.typedoc.json", "out": "typedoc/generated", "readme": "typedoc/landing-page.md",