@dittolive/ditto 3.0.6-experimental.node-loading-issues.2.linux-x64 → 3.0.6-experimental.node-loading-issues.3.linux-x64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"file":"ditto.cjs.pretty.js","sources":["../../../sources/bridge.ts","../../../sources/internal.ts","../../node/ditto.node.js","../../../sources/ffi.ts","../../transports/transports.js","../../../sources/build-time-constants.ts","../../../sources/init.ts","../../../sources/keep-alive.ts","../../../sources/logger.ts","../../../sources/observer-manager.ts","../../../sources/observer.ts","../../../sources/authenticator.ts","../../../sources/identity.ts","../../../sources/transport-config.ts","../../cbor-redux/CBOR.js","../../../sources/cbor.ts","../../../sources/document-id.ts","../../../sources/attachment.ts","../../../sources/attachment-token.ts","../../../sources/attachment-fetcher.ts","../../../sources/subscription.ts","../../../sources/counter.ts","../../../sources/register.ts","../../../sources/rga.ts","../../../sources/update-result.ts","../../../sources/augment.ts","../../../sources/key-path.ts","../../../sources/document-path.ts","../../../sources/document.ts","../../../sources/update-results-map.ts","../../../sources/live-query-event.ts","../../../sources/live-query.ts","../../../sources/pending-cursor-operation.ts","../../../sources/pending-id-specific-operation.ts","../../../sources/collection.ts","../../../sources/collections-event.ts","../../../sources/pending-collections-operation.ts","../../../sources/store.ts","../../../sources/presence.ts","../../../sources/presence-manager.ts","../../../sources/transport-conditions-manager.ts","../../../sources/sync.ts","../../../sources/ditto.ts","../../../sources/value.ts"],"sourcesContent":["//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\n// REFACTOR: use a WeakMap to associate shell objects with their pointers\n// instead of storing it directly in the shell object as we currently do (in a\n// private `@ptr` property). Main reason for this is complete encapsulation and\n// somewhat better security by not exposing physical pointers to client code.\n// The way it is right now is useful during development because it's easier to\n// debug.\n\n// REFACTOR: tweak the API to use Rust concepts of ownership. For example,\n// register() could be named something like yieldOwnership() while unregister()\n// be named takeOwnership() and return the taken pointer. See discussion here:\n// https://dittolive.slack.com/archives/C01NLL95095/p1618311222027700?thread_ts=1618308918.024500&cid=C01NLL95095\n\nconst debugTypeNames = [] // Add bridged type name to debug, for example 'Ditto'.\nconst debugAllTypes = false\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nclass Meta<JSClass extends object, FFIType> {\n readonly type: Function\n readonly object: WeakRef<JSClass>\n readonly pointer: FFI.Pointer<FFIType>\n\n /** @internal */\n constructor(type: Function, object: WeakRef<JSClass>, pointer: FFI.Pointer<FFIType>) {\n this.type = type\n this.object = object\n this.pointer = pointer\n }\n\n toString(): string {\n return `{ Meta | type: ${this.type.name}, object: ${this.object.deref()}, FFI address: ${this.pointer.addr}, FFI type: ${this.pointer.type} }`\n }\n}\n\n/** @internal */\nexport class Bridge<JSClass extends object, FFIType> {\n type: Function\n release: (pointer: FFI.Pointer<FFIType>) => void\n\n /**\n * Creates a new bridge for objects of `type`. Requires a `release` function\n * that is called whenever a registered object is garbage collected, passing\n * the associated `pointer` to it. The release function is then responsible\n * to free or drop the corresponding native object.\n *\n * @internal\n */\n constructor(type: Function, release: (pointer: FFI.Pointer<FFIType>) => void, options = {}) {\n this.type = type\n this.release = release\n this.metaByAddrMap = {}\n this.finalizationRegistry = new FinalizationRegistry(this.finalize.bind(this))\n\n // We keep track of all bridges for debugging and test purposes. With this,\n // we can iterate over all bridges and make sure everything is deallocated\n // after a test, or a suite of tests, has run.\n Bridge.all.push(new WeakRef(this))\n }\n\n /**\n * Returns the FFI pointer for `object` if registered, otherwise returns\n * `undefined`. If `object` has been unregistered before, returns\n * `undefined`, too.\n *\n * @internal\n */\n pointerFor(object: JSClass): FFI.Pointer<FFIType> | undefined {\n return object['@ditto.ptr' as any]\n }\n\n /**\n * Convenience method, returns the object for the FFI `pointer` if registered,\n * otherwise returns `undefined`. If the object associated with the `pointer`\n * has been unregistered before, returns `undefined`, too.\n *\n * @internal\n */\n objectFor(pointer: FFI.Pointer<FFIType>): JSClass | undefined {\n const meta = this.metaByAddrMap[pointer.addr]\n if (!meta) return undefined\n if (meta.type !== this.type) throw new Error(`Can't return object for pointer, pointer is associated with an object of type ${meta.type} but this bridge is configured for ${this.type}`)\n\n const object = meta.object.deref()\n if (!object) throw new Error(`Internal inconsistency, found a meta entry for an object whose object is undefined (garbage collected): ${pointer}`)\n\n return object\n }\n\n /**\n * Returns the object for the FFI `pointer` if registered. Otherwise, calls\n * the passed in `create` function to create a new object, which it then\n * returns after registering. If no `create` function is given, uses the\n * type of the bridge as a constructor and creates a new instance of it\n * without passing any parameters.\n *\n * @internal\n */\n bridge(pointer: FFI.Pointer<FFIType>, objectOrCreate?: object | (() => JSClass), options = {}): JSClass {\n const throwIfAlreadyBridged = options['throwIfAlreadyBridged']\n const existingObject = this.objectFor(pointer)\n\n if (existingObject && throwIfAlreadyBridged) {\n throw new Error(`Can't bridge, pointer has already been bridged: ${JSON.stringify(pointer)}`)\n }\n\n if (existingObject) {\n return existingObject\n }\n\n if (!objectOrCreate) {\n objectOrCreate = () => {\n return Reflect.construct(this.type, [])\n }\n }\n\n let object\n\n if (typeof objectOrCreate === 'function') {\n object = objectOrCreate()\n if (!object) {\n throw new Error(`Can't bridge, expected passed in create function to return an object but got: ${object}`)\n }\n } else {\n object = objectOrCreate\n }\n\n this.register(object, pointer)\n return object\n }\n\n /** @internal */\n register(object: JSClass, pointer: FFI.Pointer<FFIType>) {\n const objectType = object.constructor\n const bridgeType = this.type\n if (objectType !== bridgeType) throw new Error(`Can't register, bridge is configured for type ${bridgeType.name} but passed in object is of type ${objectType.name}`)\n\n const existingPointer = this.pointerFor(object)\n const existingMeta = this.metaByAddrMap[pointer.addr]\n if (existingPointer && existingMeta) throw new Error(`Can't register, an object for the passed in pointer has previously been registered: ${existingMeta.pointer}`)\n\n if (existingPointer && !existingMeta) throw new Error(`Internal inconsistency, trying to register an object which has an associated pointer but no meta entry: ${object}`)\n if (!existingPointer && existingMeta) throw new Error(`Internal inconsistency, trying to register an object which has a meta entry but no associated pointer: ${object}`)\n\n const meta = new Meta<JSClass, FFIType>(objectType, new WeakRef(object), pointer)\n object['@ditto.ptr' as any] = pointer\n this.metaByAddrMap[meta.pointer.addr] = meta\n this.finalizationRegistry.register(object, pointer, object)\n\n if (debugTypeNames.includes(this.type.name) || debugAllTypes) {\n console.log(`[VERBOSE] Bridge REGISTERED a new instance of ${this.type.name}, current count: ${Object.keys(this.metaByAddrMap).length}`)\n }\n }\n\n /** @internal */\n unregister(object: JSClass) {\n const objectType = object.constructor\n const bridgeType = this.type\n if (objectType !== bridgeType) throw new Error(`Can't unregister, bridge is configured for type ${bridgeType.name} but passed in object is of type ${objectType.name}`)\n\n const pointer = this.pointerFor(object)\n if (!pointer) throw new Error(`Can't unregister, object that has not been registered before: ${object}`)\n\n const meta = this.metaByAddrMap[pointer.addr]\n if (!meta) throw new Error(`Internal inconsistency, trying to unregister an object which has an associated pointer but no meta entry: ${object}`)\n if (meta.type !== bridgeType) throw new Error(`Internal inconsistency, trying to unregister an object that has a meta entry with a different type than that of the bridge: ${meta}`)\n if (!meta.object.deref()) throw new Error(`Internal inconsistency, trying to unregister an object that has a meta entry whose object is undfined (garbage collected): ${meta}`)\n if (meta.object.deref() !== object) throw new Error(`Internal inconsistency, trying to unregister an object that has a meta entry holding a different object: ${meta}`)\n\n this.finalizationRegistry.unregister(object)\n delete this.metaByAddrMap[pointer.addr]\n delete object['@ditto.ptr' as any]\n\n if (debugTypeNames.includes(this.type.name) || debugAllTypes) {\n console.log(`[VERBOSE] Bridge UNREGISTERED an instance of ${this.type.name}, current count: ${Object.keys(this.metaByAddrMap).length}`)\n }\n }\n\n /** @internal */\n unregisterAll() {\n if (debugTypeNames.includes(this.type.name) || debugAllTypes) {\n console.log(`[VERBOSE] Unregistering ALL bridged instances of type ${this.type.name}.`)\n }\n\n for (const meta of Object.values(this.metaByAddrMap)) {\n const object = meta.object.deref()\n if (object) {\n this.unregister(object)\n }\n }\n }\n\n /** @internal */\n get count(): number {\n return Object.keys(this.metaByAddrMap).length\n }\n\n /** @internal */\n static readonly all = []\n\n // ------ Private ------\n\n private metaByAddrMap: { [key: string]: Meta<JSClass, FFIType> }\n private finalizationRegistry: FinalizationRegistry<any>\n\n private finalize(pointer: FFI.Pointer<FFIType>) {\n const meta = this.metaByAddrMap[pointer.addr]\n if (!meta) throw new Error(`Internal inconsistency, tried to finalize an instance for a pointer, that has no meta entry: ${pointer}`)\n\n delete this.metaByAddrMap[pointer.addr]\n this.release(pointer)\n\n if (debugTypeNames.includes(this.type.name) || debugAllTypes) {\n console.log(`[VERBOSE] Bridge FINALIZED an instance of ${this.type.name}, current count: ${Object.keys(this.metaByAddrMap).length}`)\n }\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { Identity } from './identity.js'\nimport { Bridge } from './bridge.js'\nimport type { Document, MutableDocument } from './document.js'\nimport { Ditto } from './ditto.js'\n\n// ------------------------------------------------------------ Constants ------\n\n/** @internal */\nexport const isNodeBuild = (function () {\n nodeBuildOnly: {\n return true\n }\n return false\n})()\n\n/** @internal */\nexport const isWebBuild = (function () {\n webBuildOnly: {\n return true\n }\n return false\n})()\n\nexport const defaultDittoCloudDomain = `cloud.ditto.live`\n\n// ------------------------------------------------------------- Defaults ------\n\n/** @internal */\nexport function defaultAuthURL(appID: string): string {\n return `https://${appID}.${defaultDittoCloudDomain}`\n}\n\n/** @internal */\nexport function defaultDittoCloudURL(appID: string): string {\n return `wss://${appID}.${defaultDittoCloudDomain}`\n}\n\n// ---------------------------------------------------------- Validations ------\n\n/**\n * Validates a number and returns it as-is if all requirements are met,\n * otherwise throws an exception. Options:\n *\n * - `integer`: if `true`, requires the number to be an integer\n *\n * - `min`: if given, requires the number to be >= `min`\n * - `max`: if given, requires the number to be <= `max`\n *\n * - `minX`: if given, requires the number to be > `minX` (x stands for \"exclusive\")\n * - `maxX`: if given, requires the number to be < `maxX` (x stands for \"exclusive\")\n *\n * You can also customize the error message by providing a prefix via\n * `errorMessagePrefix`, which defaults to `\"Number validation failed:\"`.\n *\n * @internal\n */\nexport function validateNumber(value, options = {}): number {\n const errorMessagePrefix = options['errorMessagePrefix'] ?? 'Number validation failed:'\n const integer = !!options['integer']\n\n const min = options['min']\n const max = options['max']\n\n const minX = options['minX']\n const maxX = options['maxX']\n\n if (typeof value !== 'number') throw new Error(`${errorMessagePrefix} '${value}' is not a number.`)\n if (integer && Math.floor(value) !== value) throw new Error(`${errorMessagePrefix} '${value}' is not an integer.`)\n\n if (typeof min !== 'undefined' && value < min) throw new Error(`${errorMessagePrefix} '${value}' must be >= ${min}.`)\n if (typeof max !== 'undefined' && value > max) throw new Error(`${errorMessagePrefix} '${value}' must be <= ${max}.`)\n\n if (typeof minX !== 'undefined' && value <= minX) throw new Error(`${errorMessagePrefix} '${value}' must be > ${minX}.`)\n if (typeof maxX !== 'undefined' && value >= maxX) throw new Error(`${errorMessagePrefix} '${value}' must be < ${maxX}.`)\n\n return value\n}\n\nexport function validateQuery(query, options = {}): string {\n const errorMessagePrefix = options['errorMessagePrefix'] ?? 'Query validation failed,'\n\n if (typeof query !== 'string') throw new Error(`${errorMessagePrefix} query is not a string: ${query}`)\n if (query === '') throw new Error(`${errorMessagePrefix} query is an empty string.`)\n\n const validatedQuery = query.trim()\n if (validatedQuery === '') throw new Error(`${errorMessagePrefix} query contains only whitespace characters.`)\n return validatedQuery\n}\n\n// ---------------------------------------------- TCP & Websocket Clients ------\n\n// HACK: don't export these publicly, only needed internally.\n\n/** @internal */\nexport class StaticTCPClient {}\n\n/** @internal */\nexport class WebsocketClient {}\n\n/** @internal */\nexport const staticTCPClientBridge = new Bridge<StaticTCPClient, FFI.FFIStaticTCPClient>(StaticTCPClient, FFI.staticTCPClientFreeHandle)\n\n/** @internal */\nexport const websocketClientBridge = new Bridge<WebsocketClient, FFI.FFIWebsocketClient>(WebsocketClient, FFI.websocketClientFreeHandle)\n\n// -------------------------------------------------------------- Helpers ------\n\n/** @internal */\nexport function generateEphemeralToken(): string {\n let webcrypto = undefined\n\n nodeBuildOnly: {\n webcrypto = require('crypto').webcrypto\n }\n\n webBuildOnly: {\n webcrypto = crypto\n }\n\n const data = new Uint16Array(16)\n webcrypto.getRandomValues(data)\n\n const doublets = Array.from(data)\n return doublets.map((doublet) => doublet.toString(16)).join('')\n}\n\n// --------------------------------------------------------------- System ------\n\n/** @internal */\nexport function sleep(milliseconds): Promise<void> {\n return new Promise((resolve, reject) => {\n setTimeout(resolve, milliseconds)\n })\n}\n\n/** @internal use this to asyncify chunks of code. */\nexport async function step(block): Promise<any> {\n await sleep(0)\n return block()\n}\n\n/** @internal */\n// WORKAROUND: the corresponding FFI function(s) is not async at the\n// moment, we therefore artificially make it async via step() until an\n// async variant becomes available.\n//\n// Why? Any function marked as async that isn't under the hood appears to be\n// yield-ing on the use site but isn't. This may lead to blocking the\n// even loop for a long time, which in turn can lead to excessive memory\n// consumption and other side-effects. Plus, WebAssembly limitations may\n// lead to deadlocks and other crashes.\n//\n// The function alias here is to be able to easily see that its use is\n// a workaround, plus easily finding all of those workarounds to fix\n// them all once the FFI API is properly asyncified.\n//\n// See PR #4833 for details:\n// https://github.com/getditto/ditto/pull/4833\nexport const performAsyncToWorkaroundNonAsyncFFIAPI = step\n","const ditto = function() {\n // IMPORTANT: most packagers perform _static_ analysis to identity native\n // Node modules to copy them into the right directory within the\n // final package. This only works if we use constant strings with\n // require(). Therefore, we use an if for all supported targets and\n // explicitly require each instead of dynamically building the require\n // path.\n\n const target = process.platform + '-' + process.arch\n try {\n if (target === \"darwin-x64\") return require('./ditto.darwin-x64.node')\n if (target === \"darwin-arm64\") return require('./ditto.darwin-arm64.node')\n if (target === \"linux-x64\") return require('./ditto.linux-x64.node')\n if (target === \"linux-arm\") return require('./ditto.linux-arm.node')\n if (target === \"win32-x64\") return require('./ditto.win32-x64.node')\n } catch (error) {\n throw new Error(\"Couldn't load native module 'ditto.\" + target + \".node' due to error:\" + error.toString())\n }\n\n throw new Error(\"No native module 'ditto.\" + target + \".node' found.\")\n}();\n\nexport function auth_server_auth_submit_with_error(...args) { return ditto.auth_server_auth_submit_with_error(...args) }\nexport function auth_server_auth_submit_with_success(...args) { return ditto.auth_server_auth_submit_with_success(...args) }\nexport function auth_server_refresh_submit_with_error(...args) { return ditto.auth_server_refresh_submit_with_error(...args) }\nexport function auth_server_refresh_submit_with_success(...args) { return ditto.auth_server_refresh_submit_with_success(...args) }\nexport function ble_client_free_handle(...args) { return ditto.ble_client_free_handle(...args) }\nexport function ble_server_free_handle(...args) { return ditto.ble_server_free_handle(...args) }\nexport function boxCBytesIntoBuffer(...args) { return ditto.boxCBytesIntoBuffer(...args) }\nexport function boxCStringIntoString(...args) { return ditto.boxCStringIntoString(...args) }\nexport function cDocsToJsDocs(...args) { return ditto.cDocsToJsDocs(...args) }\nexport function cStringVecToStringArray(...args) { return ditto.cStringVecToStringArray(...args) }\nexport function ditto_add_internal_ble_client_transport(...args) { return ditto.ditto_add_internal_ble_client_transport(...args) }\nexport function ditto_add_internal_ble_server_transport(...args) { return ditto.ditto_add_internal_ble_server_transport(...args) }\nexport function ditto_add_internal_mdns_advertiser(...args) { return ditto.ditto_add_internal_mdns_advertiser(...args) }\nexport function ditto_add_internal_mdns_transport(...args) { return ditto.ditto_add_internal_mdns_transport(...args) }\nexport function ditto_add_multicast_transport(...args) { return ditto.ditto_add_multicast_transport(...args) }\nexport function ditto_add_static_tcp_client(...args) { return ditto.ditto_add_static_tcp_client(...args) }\nexport function ditto_add_subscription(...args) { return ditto.ditto_add_subscription(...args) }\nexport function ditto_add_websocket_client(...args) { return ditto.ditto_add_websocket_client(...args) }\nexport function ditto_auth_client_free(...args) { return ditto.ditto_auth_client_free(...args) }\nexport function ditto_auth_client_get_app_id(...args) { return ditto.ditto_auth_client_get_app_id(...args) }\nexport function ditto_auth_client_get_site_id(...args) { return ditto.ditto_auth_client_get_site_id(...args) }\nexport function ditto_auth_client_is_web_valid(...args) { return ditto.ditto_auth_client_is_web_valid(...args) }\nexport function ditto_auth_client_is_x509_valid(...args) { return ditto.ditto_auth_client_is_x509_valid(...args) }\nexport function ditto_auth_client_login_with_credentials(...args) { return ditto.ditto_auth_client_login_with_credentials(...args) }\nexport function ditto_auth_client_login_with_token(...args) { return ditto.ditto_auth_client_login_with_token(...args) }\nexport function ditto_auth_client_login_with_token_and_feedback(...args) { return ditto.ditto_auth_client_login_with_token_and_feedback(...args) }\nexport function ditto_auth_client_logout(...args) { return ditto.ditto_auth_client_logout(...args) }\nexport function ditto_auth_client_make_anonymous_client(...args) { return ditto.ditto_auth_client_make_anonymous_client(...args) }\nexport function ditto_auth_client_make_anonymous_client_with_executor(...args) { return ditto.ditto_auth_client_make_anonymous_client_with_executor(...args) }\nexport function ditto_auth_client_make_for_development(...args) { return ditto.ditto_auth_client_make_for_development(...args) }\nexport function ditto_auth_client_make_for_development_with_executor(...args) { return ditto.ditto_auth_client_make_for_development_with_executor(...args) }\nexport function ditto_auth_client_make_login_provider(...args) { return ditto.ditto_auth_client_make_login_provider(...args) }\nexport function ditto_auth_client_make_with_shared_key(...args) { return ditto.ditto_auth_client_make_with_shared_key(...args) }\nexport function ditto_auth_client_make_with_shared_key_with_executor(...args) { return ditto.ditto_auth_client_make_with_shared_key_with_executor(...args) }\nexport function ditto_auth_client_make_with_static_x509(...args) { return ditto.ditto_auth_client_make_with_static_x509(...args) }\nexport function ditto_auth_client_make_with_static_x509_with_executor(...args) { return ditto.ditto_auth_client_make_with_static_x509_with_executor(...args) }\nexport function ditto_auth_client_make_with_web(...args) { return ditto.ditto_auth_client_make_with_web(...args) }\nexport function ditto_auth_client_make_with_web_with_executor(...args) { return ditto.ditto_auth_client_make_with_web_with_executor(...args) }\nexport function ditto_auth_client_set_validity_listener(...args) { return ditto.ditto_auth_client_set_validity_listener(...args) }\nexport function ditto_auth_client_unset_validity_listener(...args) { return ditto.ditto_auth_client_unset_validity_listener(...args) }\nexport function ditto_auth_client_user_id(...args) { return ditto.ditto_auth_client_user_id(...args) }\nexport function ditto_auth_extract_executor(...args) { return ditto.ditto_auth_extract_executor(...args) }\nexport function ditto_auth_login_provider_free(...args) { return ditto.ditto_auth_login_provider_free(...args) }\nexport function ditto_c_bytes_free(...args) { return ditto.ditto_c_bytes_free(...args) }\nexport function ditto_c_string_free(...args) { return ditto.ditto_c_string_free(...args) }\nexport function ditto_callback_err_nop(...args) { return ditto.ditto_callback_err_nop(...args) }\nexport function ditto_callback_nop(...args) { return ditto.ditto_callback_nop(...args) }\nexport function ditto_cancel_resolve_attachment(...args) { return ditto.ditto_cancel_resolve_attachment(...args) }\nexport function ditto_cbor_get_cbor_with_path_type(...args) { return ditto.ditto_cbor_get_cbor_with_path_type(...args) }\nexport function ditto_clear_presence_callback(...args) { return ditto.ditto_clear_presence_callback(...args) }\nexport function ditto_clear_presence_v1_callback(...args) { return ditto.ditto_clear_presence_v1_callback(...args) }\nexport function ditto_clear_presence_v2_callback(...args) { return ditto.ditto_clear_presence_v2_callback(...args) }\nexport function ditto_clear_presence_v3_callback(...args) { return ditto.ditto_clear_presence_v3_callback(...args) }\nexport function ditto_collection(...args) { return ditto.ditto_collection(...args) }\nexport function ditto_collection_evict(...args) { return ditto.ditto_collection_evict(...args) }\nexport function ditto_collection_evict_query_str(...args) { return ditto.ditto_collection_evict_query_str(...args) }\nexport function ditto_collection_exec_query_str(...args) { return ditto.ditto_collection_exec_query_str(...args) }\nexport function ditto_collection_get(...args) { return ditto.ditto_collection_get(...args) }\nexport function ditto_collection_insert_value(...args) { return ditto.ditto_collection_insert_value(...args) }\nexport function ditto_collection_remove(...args) { return ditto.ditto_collection_remove(...args) }\nexport function ditto_collection_remove_query_str(...args) { return ditto.ditto_collection_remove_query_str(...args) }\nexport function ditto_collection_update(...args) { return ditto.ditto_collection_update(...args) }\nexport function ditto_collection_update_multiple(...args) { return ditto.ditto_collection_update_multiple(...args) }\nexport function ditto_disable_sync_with_v2(...args) { return ditto.ditto_disable_sync_with_v2(...args) }\nexport function ditto_disk_usage(...args) { return ditto.ditto_disk_usage(...args) }\nexport function ditto_document_cbor(...args) { return ditto.ditto_document_cbor(...args) }\nexport function ditto_document_cds(...args) { return ditto.ditto_document_cds(...args) }\nexport function ditto_document_free(...args) { return ditto.ditto_document_free(...args) }\nexport function ditto_document_get_cbor(...args) { return ditto.ditto_document_get_cbor(...args) }\nexport function ditto_document_get_cbor_with_path_type(...args) { return ditto.ditto_document_get_cbor_with_path_type(...args) }\nexport function ditto_document_get_variant_cbor(...args) { return ditto.ditto_document_get_variant_cbor(...args) }\nexport function ditto_document_id(...args) { return ditto.ditto_document_id(...args) }\nexport function ditto_document_id_query_compatible(...args) { return ditto.ditto_document_id_query_compatible(...args) }\nexport function ditto_document_increment_counter(...args) { return ditto.ditto_document_increment_counter(...args) }\nexport function ditto_document_remove(...args) { return ditto.ditto_document_remove(...args) }\nexport function ditto_document_set_cbor(...args) { return ditto.ditto_document_set_cbor(...args) }\nexport function ditto_document_set_cbor_with_timestamp(...args) { return ditto.ditto_document_set_cbor_with_timestamp(...args) }\nexport function ditto_document_update(...args) { return ditto.ditto_document_update(...args) }\nexport function ditto_documents_hash(...args) { return ditto.ditto_documents_hash(...args) }\nexport function ditto_documents_hash_mnemonic(...args) { return ditto.ditto_documents_hash_mnemonic(...args) }\nexport function ditto_drop(...args) { return ditto.ditto_drop(...args) }\nexport function ditto_error_message(...args) { return ditto.ditto_error_message(...args) }\nexport function ditto_error_message_peek(...args) { return ditto.ditto_error_message_peek(...args) }\nexport function ditto_executor_free(...args) { return ditto.ditto_executor_free(...args) }\nexport function ditto_free(...args) { return ditto.ditto_free(...args) }\nexport function ditto_free_attachment_handle(...args) { return ditto.ditto_free_attachment_handle(...args) }\nexport function ditto_free_documents(...args) { return ditto.ditto_free_documents(...args) }\nexport function ditto_free_indices(...args) { return ditto.ditto_free_indices(...args) }\nexport function ditto_get_attachment_status(...args) { return ditto.ditto_get_attachment_status(...args) }\nexport function ditto_get_collection_names(...args) { return ditto.ditto_get_collection_names(...args) }\nexport function ditto_get_complete_attachment_data(...args) { return ditto.ditto_get_complete_attachment_data(...args) }\nexport function ditto_get_complete_attachment_path(...args) { return ditto.ditto_get_complete_attachment_path(...args) }\nexport function ditto_get_sdk_version(...args) { return ditto.ditto_get_sdk_version(...args) }\nexport function ditto_init_sdk_version(...args) { return ditto.ditto_init_sdk_version(...args) }\nexport function ditto_insert_timeseries_event(...args) { return ditto.ditto_insert_timeseries_event(...args) }\nexport function ditto_invalidate_tcp_listeners(...args) { return ditto.ditto_invalidate_tcp_listeners(...args) }\nexport function ditto_live_query_register_str_detached(...args) { return ditto.ditto_live_query_register_str_detached(...args) }\nexport function ditto_live_query_signal_available_next(...args) { return ditto.ditto_live_query_signal_available_next(...args) }\nexport function ditto_live_query_start(...args) { return ditto.ditto_live_query_start(...args) }\nexport function ditto_live_query_stop(...args) { return ditto.ditto_live_query_stop(...args) }\nexport function ditto_live_query_webhook_generate_new_api_secret(...args) { return ditto.ditto_live_query_webhook_generate_new_api_secret(...args) }\nexport function ditto_live_query_webhook_register_str(...args) { return ditto.ditto_live_query_webhook_register_str(...args) }\nexport function ditto_live_query_webhook_start_all(...args) { return ditto.ditto_live_query_webhook_start_all(...args) }\nexport function ditto_live_query_webhook_start_by_id(...args) { return ditto.ditto_live_query_webhook_start_by_id(...args) }\nexport function ditto_log(...args) { return ditto.ditto_log(...args) }\nexport function ditto_logger_emoji_headings_enabled(...args) { return ditto.ditto_logger_emoji_headings_enabled(...args) }\nexport function ditto_logger_emoji_headings_enabled_get(...args) { return ditto.ditto_logger_emoji_headings_enabled_get(...args) }\nexport function ditto_logger_enabled(...args) { return ditto.ditto_logger_enabled(...args) }\nexport function ditto_logger_enabled_get(...args) { return ditto.ditto_logger_enabled_get(...args) }\nexport function ditto_logger_init(...args) { return ditto.ditto_logger_init(...args) }\nexport function ditto_logger_minimum_log_level(...args) { return ditto.ditto_logger_minimum_log_level(...args) }\nexport function ditto_logger_minimum_log_level_get(...args) { return ditto.ditto_logger_minimum_log_level_get(...args) }\nexport function ditto_logger_set_custom_log_cb(...args) { return ditto.ditto_logger_set_custom_log_cb(...args) }\nexport function ditto_logger_set_log_file(...args) { return ditto.ditto_logger_set_log_file(...args) }\nexport function ditto_make(...args) { return ditto.ditto_make(...args) }\nexport function ditto_make_executor_from_handle(...args) { return ditto.ditto_make_executor_from_handle(...args) }\nexport function ditto_make_executor_from_runtime(...args) { return ditto.ditto_make_executor_from_runtime(...args) }\nexport function ditto_make_executor_new_runtime(...args) { return ditto.ditto_make_executor_new_runtime(...args) }\nexport function ditto_new_attachment_from_bytes(...args) { return ditto.ditto_new_attachment_from_bytes(...args) }\nexport function ditto_new_attachment_from_file(...args) { return ditto.ditto_new_attachment_from_file(...args) }\nexport function ditto_only_vec_documents_free(...args) { return ditto.ditto_only_vec_documents_free(...args) }\nexport function ditto_presence_v1(...args) { return ditto.ditto_presence_v1(...args) }\nexport function ditto_presence_v2(...args) { return ditto.ditto_presence_v2(...args) }\nexport function ditto_presence_v3(...args) { return ditto.ditto_presence_v3(...args) }\nexport function ditto_read_transaction(...args) { return ditto.ditto_read_transaction(...args) }\nexport function ditto_read_transaction_free(...args) { return ditto.ditto_read_transaction_free(...args) }\nexport function ditto_register_disk_usage_callback(...args) { return ditto.ditto_register_disk_usage_callback(...args) }\nexport function ditto_register_local_auth_server(...args) { return ditto.ditto_register_local_auth_server(...args) }\nexport function ditto_register_presence_v1_callback(...args) { return ditto.ditto_register_presence_v1_callback(...args) }\nexport function ditto_register_presence_v2_callback(...args) { return ditto.ditto_register_presence_v2_callback(...args) }\nexport function ditto_register_presence_v3_callback(...args) { return ditto.ditto_register_presence_v3_callback(...args) }\nexport function ditto_register_transport_condition_changed_callback(...args) { return ditto.ditto_register_transport_condition_changed_callback(...args) }\nexport function ditto_release_disk_usage_callback(...args) { return ditto.ditto_release_disk_usage_callback(...args) }\nexport function ditto_remove_mdns_advertiser(...args) { return ditto.ditto_remove_mdns_advertiser(...args) }\nexport function ditto_remove_multicast_transport(...args) { return ditto.ditto_remove_multicast_transport(...args) }\nexport function ditto_remove_subscription(...args) { return ditto.ditto_remove_subscription(...args) }\nexport function ditto_resolve_attachment(...args) { return ditto.ditto_resolve_attachment(...args) }\nexport function ditto_run_garbage_collection(...args) { return ditto.ditto_run_garbage_collection(...args) }\nexport function ditto_set_device_name(...args) { return ditto.ditto_set_device_name(...args) }\nexport function ditto_set_max_outgoing_ble_peers(...args) { return ditto.ditto_set_max_outgoing_ble_peers(...args) }\nexport function ditto_set_priority_for_query_overlap_group(...args) { return ditto.ditto_set_priority_for_query_overlap_group(...args) }\nexport function ditto_set_query_overlap_group(...args) { return ditto.ditto_set_query_overlap_group(...args) }\nexport function ditto_set_sync_group(...args) { return ditto.ditto_set_sync_group(...args) }\nexport function ditto_shutdown(...args) { return ditto.ditto_shutdown(...args) }\nexport function ditto_start_http_server(...args) { return ditto.ditto_start_http_server(...args) }\nexport function ditto_start_tcp_server(...args) { return ditto.ditto_start_tcp_server(...args) }\nexport function ditto_stop_all_live_queries(...args) { return ditto.ditto_stop_all_live_queries(...args) }\nexport function ditto_stop_http_server(...args) { return ditto.ditto_stop_http_server(...args) }\nexport function ditto_stop_tcp_server(...args) { return ditto.ditto_stop_tcp_server(...args) }\nexport function ditto_tcp_server_listen_addr(...args) { return ditto.ditto_tcp_server_listen_addr(...args) }\nexport function ditto_transports_diagnostics(...args) { return ditto.ditto_transports_diagnostics(...args) }\nexport function ditto_unregister_local_auth_server(...args) { return ditto.ditto_unregister_local_auth_server(...args) }\nexport function ditto_validate_document_id(...args) { return ditto.ditto_validate_document_id(...args) }\nexport function ditto_vec_usizes_free(...args) { return ditto.ditto_vec_usizes_free(...args) }\nexport function ditto_wifi_aware_client_peer_appeared(...args) { return ditto.ditto_wifi_aware_client_peer_appeared(...args) }\nexport function ditto_wifi_aware_server_free_handle(...args) { return ditto.ditto_wifi_aware_server_free_handle(...args) }\nexport function ditto_write_transaction(...args) { return ditto.ditto_write_transaction(...args) }\nexport function ditto_write_transaction_add_metadata(...args) { return ditto.ditto_write_transaction_add_metadata(...args) }\nexport function ditto_write_transaction_commit(...args) { return ditto.ditto_write_transaction_commit(...args) }\nexport function ditto_write_transaction_free(...args) { return ditto.ditto_write_transaction_free(...args) }\nexport function ditto_write_transaction_rollback(...args) { return ditto.ditto_write_transaction_rollback(...args) }\nexport function free_c_string_vec(...args) { return ditto.free_c_string_vec(...args) }\nexport function jsDocsToCDocs(...args) { return ditto.jsDocsToCDocs(...args) }\nexport function mdns_client_free_handle(...args) { return ditto.mdns_client_free_handle(...args) }\nexport function mdns_platform_peer_appeared(...args) { return ditto.mdns_platform_peer_appeared(...args) }\nexport function mdns_server_free_handle(...args) { return ditto.mdns_server_free_handle(...args) }\nexport function new_c_string_vec(...args) { return ditto.new_c_string_vec(...args) }\nexport function refCStringToString(...args) { return ditto.refCStringToString(...args) }\nexport function static_tcp_client_free_handle(...args) { return ditto.static_tcp_client_free_handle(...args) }\nexport function uninitialized_ditto_make(...args) { return ditto.uninitialized_ditto_make(...args) }\nexport function uninitialized_ditto_make_with_executor(...args) { return ditto.uninitialized_ditto_make_with_executor(...args) }\nexport function verify_license(...args) { return ditto.verify_license(...args) }\nexport function websocket_client_free_handle(...args) { return ditto.websocket_client_free_handle(...args) }\nexport function withCBytes(...args) { return ditto.withCBytes(...args) }\nexport function withCString(...args) { return ditto.withCString(...args) }\nexport function withOutBoolean(...args) { return ditto.withOutBoolean(...args) }\nexport function withOutBoxCBytes(...args) { return ditto.withOutBoxCBytes(...args) }\nexport function withOutPtr(...args) { return ditto.withOutPtr(...args) }\nexport function withOutU64(...args) { return ditto.withOutU64(...args) }\nexport function withOutVecOfPtrs(...args) { return ditto.withOutVecOfPtrs(...args) }\n\nexport async function init(info) {\n // IDEA: allow passing in the module path (similar to Wasm)?\n // Nothing to do so far, no-op for the time being.\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n// NOTE: This is a temporary *hand-written* shim file for glue code for the\n// Ditto native Node module. Mid to long term, we'll either move all of this\n// code to the native side or generate this file via a companion CLI tool or\n// something equivalent.\n\nimport { isWebBuild, isNodeBuild } from './internal.js'\nimport * as dittoCore from './@ditto.core.js'\nimport { WriteStrategy } from './essentials.js'\n\n// -------------------------------------------------------------- Prelude ------\n\n/** @internal */\nexport type Pointer<Type> = { type: Type; addr: string }\n\n/** @internal */\nexport var isTracingEnabled = false\n\n/** @internal */\nexport const DittoCRDTTypeKey = '_ditto_internal_type_jkb12973t4b'\n\n/** @internal */\nexport const DittoCRDTValueKey = '_value'\n\n// ---------------------------------------------------------------- Types ------\n\n/** @internal */\nexport type FFIDocument = 'CDocument_t'\n\n/** @internal */\nexport type FFIReadTransaction = 'CReadTransaction_t'\n\n/** @internal */\nexport type FFIWriteTransaction = 'CWriteTransaction_t'\n\n/** @internal */\nexport type FFIUninitializedDitto = 'CUninitializedDitto_t'\n\n/** @internal */\nexport type FFIDitto = 'CDitto_t'\n\n/** @internal */\nexport type FFIAuthClient = 'CAuthClient_t'\n\n/** @internal */\nexport type FFILoginProvider = 'CLoginProvider_t'\n\n/** @internal */\nexport type FFIAuthServerAuthRequest = 'CAuthServerAuthRequest_t'\n\n/** @internal */\nexport type FFIAuthServerRefreshRequest = 'CAuthServerRefreshRequest_t'\n\n/** @internal */\nexport type FFIStaticTCPClient = 'TransportHandle_StaticTCPClientPlatformEvent_t'\n\n/** @internal */\nexport type FFIWebsocketClient = 'TransportHandle_WebsocketClientPlatformEvent_t'\n\n/** @internal */\nexport type LiveQueryAvailability = 'Always' | 'WhenSignalled'\n\n/** @internal */\nexport type StringPrimitiveFormat = 'WithQuotes' | 'WithoutQuotes'\n\n/** @internal */\nexport type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose'\n\n/** @internal */\nexport type LicenseVerificationResult = 'LicenseOk' | 'VerificationFailed' | 'LicenseExpired' | 'UnsupportedFutureVersion'\n\n/** @internal */\nexport type WebsocketMode = 'Enabled' | 'Disabled'\n\n/** @internal */\nexport type HistoryTracking = 'Enabled' | 'Disabled'\n\n/** @internal */\nexport type ConditionSource = 'Bluetooth' | 'Tcp' | 'Awdl' | 'Mdns'\n\n/** @internal */\nexport type TransportCondition = 'Unknown' | 'Ok' | 'GenericFailure' | 'AppInBackground' | 'MdnsFailure' | 'TcpListenFailure' | 'NoBleCentralPermission' | 'NoBlePeripheralPermission' | 'CannotEstablishConnection' | 'BleDisabled' | 'NoBleHardware' | 'WifiDisabled' | 'TemporarilyUnavailable'\n\n/** @internal */\nexport type Platform = 'Windows' | 'Mac' | 'Ios' | 'Android' | 'Linux' | 'Web' | 'Unknown'\n\n/** @internal */\nexport type Language = 'Swift' | 'ObjectiveC' | 'CPlusPlus' | 'CSharp' | 'JavaScript' | 'Unknown' | 'Rust'\n\n/** @internal */\nexport type OrderBy = { query: string; direction: 'Ascending' | 'Descending' }\n\n/** @internal */\nexport type PathAccessorType = 'String' | 'Number' | 'Int' | 'UInt' | 'Float' | 'Double' | 'Bool' | 'Null' | 'Object' | 'Array' | 'Any' | 'Counter' | 'Register' | 'Attachment' | 'Rga' | 'RWMap'\n\n/** @internal */\nexport enum DittoCRDTType {\n counter = 0,\n register = 1,\n attachment = 2,\n rga = 3,\n rwMap = 4,\n}\n\n/** @internal */\nexport type CBParams = {\n documents: Pointer<FFIDocument>[]\n is_initial: boolean\n old_documents: Pointer<FFIDocument>[]\n insertions: number[]\n deletions: number[]\n updates: number[]\n moves: [number, number][]\n}\n\n/** @internal */\nexport type CBORPathResult = {\n statusCode: number\n cbor: Uint8Array\n}\n\n/** Various options to pass the web assembly module to Ditto. */\nexport type WebAssemblyModule = RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null\n\n/** @internal */\nexport type AttachmentFileOperation = 'Copy' | 'Move'\n\n/** @internal */\n// IDEA: rename to AttachmentHandleType for consistency.\nexport type AttachmentHandle = 'AttachmentHandle_t'\n\n/** @internal */\nexport type RawAttachment = {\n id: Uint8Array\n len: number | BigInt\n handle: Pointer<AttachmentHandle>\n}\n\n// ------------------------------------------------------- Linux BLE Hack ------\n\n// HACK: quick and dirty, wrap the internal BLE functions which\n// are currently only used by the Node Linux build. See comment\n// in `sync.ts` -> `Ditto.applyPeerToPeerBluetoothLE()` for details.\n\nexport function dittoAddInternalBLEClientTransport(ditto: Pointer<FFIDitto>): any {\n nodeBuildOnly: {\n return dittoCore.ditto_add_internal_ble_client_transport(ditto)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't add internal BLE client, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function dittoAddInternalBLEServerTransport(ditto: Pointer<FFIDitto>): any {\n nodeBuildOnly: {\n return dittoCore.ditto_add_internal_ble_server_transport(ditto)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't add internal BLE server, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function bleClientFreeHandle(handle: any) {\n nodeBuildOnly: {\n return dittoCore.ble_client_free_handle(handle)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't free BLE client handle, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function bleServerFreeHandle(handle: any) {\n nodeBuildOnly: {\n return dittoCore.ble_server_free_handle(handle)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't free BLE server handle, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function dittoAddInternalMdnsTransport(ditto: Pointer<FFIDitto>): any {\n nodeBuildOnly: {\n return dittoCore.ditto_add_internal_mdns_transport(ditto)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't add internal MDNS transport/client, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function mdnsClientFreeHandle(handle: any) {\n nodeBuildOnly: {\n return dittoCore.mdns_client_free_handle(handle)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't free MDNS transport/client handle, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function dittoAddInternalMdnsAdvertiser(ditto: Pointer<FFIDitto>): any {\n nodeBuildOnly: {\n return dittoCore.ditto_add_internal_mdns_advertiser(ditto)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't add internal MDNS advertiser/server, only available for non-apple Ditto Node builds.`)\n }\n}\n\nexport function mdnsServerFreeHandle(handle: any) {\n nodeBuildOnly: {\n return dittoCore.mdns_server_free_handle(handle)\n }\n\n webBuildOnly: {\n throw new Error(`Internal inconsistency, can't free MDNS advertiser/server handle, only available for non-apple Ditto Node builds.`)\n }\n}\n\n// ------------------------------------------------------------- Document ------\n\n/** @internal */\nexport function documentSetCBORWithTimestamp(document: Pointer<FFIDocument>, path: string, cbor: Uint8Array, createPath: boolean, timestamp: number) {\n trace()\n ensureInitialized()\n\n const pathX = bytesFromString(path)\n const errorCode = dittoCore.ditto_document_set_cbor_with_timestamp(document, pathX, cbor, createPath, timestamp)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_set_cbor_with_timestamp() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function documentSetCBOR(document: Pointer<FFIDocument>, path: string, cbor: Uint8Array, createPath: boolean) {\n trace()\n ensureInitialized()\n\n // NOTE: not sure if this should be async or not.\n const pathX = bytesFromString(path)\n const errorCode = dittoCore.ditto_document_set_cbor(document, pathX, cbor, createPath)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_set_cbor() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function documentID(self: Pointer<FFIDocument>): Uint8Array {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n const documentIDX = dittoCore.ditto_document_id(self)\n return dittoCore.boxCBytesIntoBuffer(documentIDX)\n}\n\n/** @internal */\nexport function documentCBOR(self: Pointer<FFIDocument>): Uint8Array {\n trace()\n ensureInitialized()\n\n const cborBytes = dittoCore.ditto_document_cbor(self)\n return dittoCore.boxCBytesIntoBuffer(cborBytes)\n}\n\n/** @internal */\nexport function documentCDS(self: Pointer<FFIDocument>): Uint8Array {\n trace()\n ensureInitialized()\n\n const cborBytes = dittoCore.ditto_document_cds(self)\n return dittoCore.boxCBytesIntoBuffer(cborBytes)\n}\n\n/** @internal */\nexport function documentGetCBOR(document: Pointer<FFIDocument>, path: string): Uint8Array {\n trace()\n ensureInitialized()\n\n const pathBytes = bytesFromString(path)\n const cborCBytes = dittoCore.ditto_document_get_cbor(document, pathBytes)\n return dittoCore.boxCBytesIntoBuffer(cborCBytes)\n}\n\n/** @internal */\nexport function documentGetCBORWithPathType(document: Pointer<FFIDocument>, path: string, pathType: PathAccessorType): CBORPathResult {\n trace()\n ensureInitialized()\n\n const pathBytes = bytesFromString(path)\n const cborPathResultRaw = dittoCore.ditto_document_get_cbor_with_path_type(document, pathBytes, pathType)\n\n const cborPathResult: CBORPathResult = {\n statusCode: cborPathResultRaw.status_code,\n cbor: dittoCore.boxCBytesIntoBuffer(cborPathResultRaw.cbor),\n }\n\n return cborPathResult\n}\n\n/** @internal */\nexport function documentRemove(document: Pointer<FFIDocument>, path: string) {\n trace()\n ensureInitialized()\n\n const pathBytes = bytesFromString(path)\n const errorCode = dittoCore.ditto_document_remove(document, pathBytes)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_remove() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function documentIncrementCounter(document: Pointer<FFIDocument>, path: string, amount: number) {\n trace()\n ensureInitialized()\n\n const pathBytes = bytesFromString(path)\n const errorCode = dittoCore.ditto_document_increment_counter(document, pathBytes, amount)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_increment_counter() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function documentFree(self: Pointer<FFIDocument>) {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n dittoCore.ditto_document_free(self)\n}\n\n// ----------------------------------------------------------- DocumentID ------\n\n/** @internal */\nexport function documentIDQueryCompatible(docID: Uint8Array, stringPrimitiveFormat: StringPrimitiveFormat): string {\n trace()\n ensureInitialized()\n\n const docIDString = dittoCore.ditto_document_id_query_compatible(docID, stringPrimitiveFormat)\n return dittoCore.boxCStringIntoString(docIDString)\n}\n\n/** @internal */\nexport function validateDocumentID(docID: Uint8Array): Uint8Array {\n trace()\n ensureInitialized()\n\n const cborCBytes = dittoCore.withOutBoxCBytes((outCBOR) => {\n const errorCode = dittoCore.ditto_validate_document_id(docID, outCBOR)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_validate_document_id() failed with error code: ${errorCode}`)\n return outCBOR\n })\n\n return dittoCore.boxCBytesIntoBuffer(cborCBytes)\n}\n\n// ----------------------------------------------------------- Collection ------\n\n/** @internal */\nexport async function collectionGet(ditto: Pointer<FFIDitto>, collectionName: string, documentID: Uint8Array, readTransaction: Pointer<FFIReadTransaction>): Promise<Pointer<FFIDocument> | null> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n const collectionNameX = bytesFromString(collectionName)\n\n const { status_code: errorCode, document } = await dittoCore.ditto_collection_get(ditto, collectionNameX, documentID, readTransaction)\n if (errorCode === NOT_FOUND_ERROR_CODE) return null\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_get() failed with error code: ${errorCode}`)\n return document\n}\n\n/** @internal */\nexport async function collectionInsertValue(ditto: Pointer<FFIDitto>, collectionName: string, doc_cbor: Uint8Array, doc_id: Uint8Array | null, writeStrategy: WriteStrategy): Promise<Uint8Array> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n const collectionNameX = bytesFromString(collectionName)\n\n let strategy\n switch (writeStrategy) {\n case 'merge':\n strategy = 'Merge'\n break\n case 'insertIfAbsent':\n strategy = 'InsertIfAbsent'\n break\n case 'insertDefaultIfAbsent':\n strategy = 'InsertDefaultIfAbsent'\n break\n default:\n throw new Error('Invalid write strategy provided')\n }\n\n const { status_code: errorCode, id } = await dittoCore.ditto_collection_insert_value(ditto, collectionNameX, doc_cbor, doc_id, strategy, null, null)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_insert_value() failed with error code: ${errorCode}`)\n return dittoCore.boxCBytesIntoBuffer(id)\n}\n\n/** @internal */\nexport async function collectionRemove(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documentID: Uint8Array): Promise<boolean> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n const collectionNameX = bytesFromString(collectionName)\n\n const { status_code: errorCode, bool_value: didRemove } = await dittoCore.ditto_collection_remove(ditto, collectionNameX, writeTransaction, documentID)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_remove() failed with error code: ${errorCode}`)\n return didRemove\n}\n\n/** @internal */\nexport async function collectionEvict(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documentID: Uint8Array): Promise<boolean> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n const collectionNameX = bytesFromString(collectionName)\n\n const { status_code: errorCode, bool_value: didEvict } = await dittoCore.ditto_collection_evict(ditto, collectionNameX, writeTransaction, documentID)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_evict() failed with error code: ${errorCode}`)\n return didEvict\n}\n\n/** @internal */\nexport async function collectionUpdate(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, document: Pointer<FFIDocument>): Promise<void> {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const errorCode = await dittoCore.ditto_collection_update(ditto, collectionNameX, writeTransaction, document)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_update() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport async function collectionUpdateMultiple(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documents: Pointer<FFIDocument>[]): Promise<void> {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const cDocuments = dittoCore.jsDocsToCDocs(documents)\n const errorCode = await dittoCore.ditto_collection_update_multiple(ditto, collectionNameX, writeTransaction, cDocuments)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_update_multiple() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport async function collectionExecQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Pointer<FFIDocument>[]> {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const queryX = bytesFromString(query)\n return await dittoCore.ditto_collection_exec_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)\n}\n\n/** @internal */\nexport async function collectionRemoveQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Uint8Array[]> {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const queryX = bytesFromString(query)\n return await dittoCore.ditto_collection_remove_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)\n}\n\n/** @internal */\nexport async function collectionEvictQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Uint8Array[]> {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const queryX = bytesFromString(query)\n return await dittoCore.ditto_collection_evict_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)\n}\n\n/** @internal */\nexport function addSubscription(ditto: Pointer<FFIDitto>, collectionName: string, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number) {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const queryX = bytesFromString(query)\n return dittoCore.ditto_add_subscription(ditto, collectionNameX, queryX, queryArgsCBOR, orderBy, limit, offset)\n}\n\n/** @internal */\nexport function removeSubscription(ditto: Pointer<FFIDitto>, collectionName: string, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number) {\n trace()\n ensureInitialized()\n\n const collectionNameX = bytesFromString(collectionName)\n const queryX = bytesFromString(query)\n return dittoCore.ditto_remove_subscription(ditto, collectionNameX, queryX, queryArgsCBOR, orderBy, limit, offset)\n}\n\n// ------------------------------------------------------------ LiveQuery ------\n\n/** @internal */\nexport function liveQueryRegister(\n ditto: Pointer<FFIDitto>,\n collectionName: string,\n query: string,\n queryArgsCBOR: Uint8Array | null,\n orderBy: OrderBy[],\n limit: number,\n offset: number,\n eventHandler: (cbParams: CBParams) => any,\n // Cb may be called in parallel at any point, so let's use\n // an optional error handler (which defaults to `console.error`).\n onError?: (error: any) => void,\n): number {\n trace()\n ensureInitialized()\n\n const collectionNameBuffer = bytesFromString(collectionName)\n const queryBuffer = bytesFromString(query)\n // Note(Daniel): the callback is now registered to be called in a detached manner:\n // if the FFI / Rust does `cb()`, then when that call returns, the js callback itself may not\n // have completed. This is fine, since `signalNext()` shall be the proper way to achieve this.\n const { status_code: errorCode, i64: id } = dittoCore.ditto_live_query_register_str_detached(ditto, collectionNameBuffer, queryBuffer, queryArgsCBOR, orderBy, limit, offset, wrapBackgroundCbForFFI(onError, eventHandler))\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_live_query_register_str()\\` failed with error code: ${errorCode}`)\n return id\n}\n\n/** @internal */\nexport async function liveQueryStart(ditto: Pointer<FFIDitto>, liveQueryID: number): Promise<void> {\n trace()\n ensureInitialized()\n\n const errorCode = await dittoCore.ditto_live_query_start(ditto, liveQueryID)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_live_query_start()\\` failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function liveQueryStop(ditto: Pointer<FFIDitto>, liveQueryID: number) {\n trace()\n ensureInitialized()\n dittoCore.ditto_live_query_stop(ditto, liveQueryID)\n}\n\nexport async function liveQuerySignalAvailableNext(ditto: Pointer<FFIDitto>, liveQueryID: number): Promise<void> {\n trace()\n ensureInitialized()\n await dittoCore.ditto_live_query_signal_available_next(ditto, liveQueryID)\n}\n\n// ------------------------------------------------------------ Webhook ------\n\n/** @internal */\nexport async function liveQueryWebhookRegister(ditto: Pointer<FFIDitto>, collectionName: string, query: string, orderBy: OrderBy[], limit: number, offset: number, url: string): Promise<Uint8Array> {\n trace()\n ensureInitialized()\n const collectionNameBuffer = bytesFromString(collectionName)\n const queryBuffer = bytesFromString(query)\n const urlBuffer = bytesFromString(url)\n\n const { status_code: errorCode, id } = await dittoCore.ditto_live_query_webhook_register_str(ditto, collectionNameBuffer, queryBuffer, orderBy, limit, offset, urlBuffer)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_live_query_webhook_register_str()\\` failed with error code: ${errorCode}`)\n return dittoCore.boxCBytesIntoBuffer(id)\n}\n\n// ------------------------------------------------------ ReadTransaction ------\n\n/** @internal */\nexport async function readTransaction(ditto: Pointer<FFIDitto>): Promise<Pointer<FFIReadTransaction>> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n\n const { status_code: errorCode, txn: readTransaction } = await dittoCore.ditto_read_transaction(ditto)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_read_transaction()\\` failed with error code: ${errorCode}`)\n return readTransaction\n}\n\n/** @internal */\nexport function readTransactionFree(self: Pointer<FFIReadTransaction>) {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n return dittoCore.ditto_read_transaction_free(self)\n}\n\n// ----------------------------------------------------- WriteTransaction ------\n\n/** @internal */\nexport async function writeTransaction(ditto: Pointer<FFIDitto>): Promise<Pointer<FFIWriteTransaction>> {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n\n const { status_code: errorCode, txn: writeTransaction } = await dittoCore.ditto_write_transaction(ditto, null)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_write_transaction() failed with error code: ${errorCode}`)\n return writeTransaction\n}\n\n/** @internal */\nexport async function writeTransactionCommit(ditto: Pointer<FFIDitto>, self: Pointer<FFIWriteTransaction>): Promise<void> {\n trace()\n ensureInitialized()\n\n const errorCode = await dittoCore.ditto_write_transaction_commit(ditto, self)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_write_transaction_commit() failed with error code: ${errorCode}`)\n}\n\n// ------------------------------------------------------ StaticTCPClient ------\n\n/** @internal */\nexport function addStaticTCPClient(ditto: Pointer<FFIDitto>, address: string): Pointer<FFIStaticTCPClient> {\n trace()\n ensureInitialized()\n\n const addressBuffer = bytesFromString(address)\n return (dittoCore as any).ditto_add_static_tcp_client(ditto, addressBuffer)\n}\n\n/** @internal */\nexport function staticTCPClientFreeHandle(self: Pointer<FFIStaticTCPClient>) {\n trace()\n ;(dittoCore as any).static_tcp_client_free_handle(self)\n}\n\n// ------------------------------------------------------ WebsocketClient ------\n\n/** @internal */\nexport function addWebsocketClient(ditto: Pointer<FFIDitto>, address: string, routingHint: number): Pointer<FFIWebsocketClient> {\n trace()\n ensureInitialized()\n\n const addressBuffer = bytesFromString(address)\n return dittoCore.ditto_add_websocket_client(ditto, addressBuffer, routingHint)\n}\n\n/** @internal */\nexport function websocketClientFreeHandle(self: Pointer<FFIWebsocketClient>) {\n trace()\n ensureInitialized()\n dittoCore.websocket_client_free_handle(self)\n}\n\n// --------------------------------------------------------------- Logger ------\n\n/** @internal */\nexport function loggerInit() {\n trace()\n ensureInitialized()\n dittoCore.ditto_logger_init()\n}\n\n/** @internal */\nexport async function loggerSetCustomLogCb(cb: null | ((lvl: LogLevel, msg: string) => void)): Promise<void> {\n trace()\n ensureInitialized()\n\n if (null === cb) {\n await dittoCore.ditto_logger_set_custom_log_cb(null)\n } else {\n // IDEA: pass custom error handler here instead of null?\n const wrappedCallback = wrapBackgroundCbForFFI(null, (loglevel: LogLevel, cMsg: Pointer<'char'>) => {\n try {\n const msg: string = dittoCore.boxCStringIntoString(cMsg)\n cb(loglevel, msg)\n } catch (e) {\n console.error(`The registered cb in \\`ditto_logger_set_custom_log_cb()\\` failed with: ${e}`)\n }\n })\n await dittoCore.ditto_logger_set_custom_log_cb(wrappedCallback)\n }\n}\n\n/** @internal */\nexport function loggerEnabled(enabled: boolean) {\n trace()\n ensureInitialized()\n dittoCore.ditto_logger_enabled(!!enabled)\n}\n\n/** @internal */\nexport function loggerEnabledGet(): boolean {\n trace()\n ensureInitialized()\n return !!dittoCore.ditto_logger_enabled_get()\n}\n\n/** @internal */\nexport function loggerEmojiHeadingsEnabled(loggerEmojiHeadingsEnabled: boolean) {\n trace()\n ensureInitialized()\n dittoCore.ditto_logger_emoji_headings_enabled(loggerEmojiHeadingsEnabled)\n}\n\n/** @internal */\nexport function loggerEmojiHeadingsEnabledGet() {\n trace()\n ensureInitialized()\n return dittoCore.ditto_logger_emoji_headings_enabled_get()\n}\n\n/** @internal */\nexport function loggerMinimumLogLevel(logLevel: LogLevel) {\n trace()\n ensureInitialized()\n dittoCore.ditto_logger_minimum_log_level(logLevel)\n}\n\n/** @internal */\nexport function loggerMinimumLogLevelGet() {\n trace()\n ensureInitialized()\n return dittoCore.ditto_logger_minimum_log_level_get()\n}\n\n/** @internal */\nexport function loggerSetLogFile(path?: string) {\n trace()\n ensureInitialized()\n const pathBytesOrNull = path ? bytesFromString(path) : null\n const errorCode = dittoCore.ditto_logger_set_log_file(pathBytesOrNull)\n if (errorCode !== 0) {\n const message = errorMessage()\n throw new Error(`Can't set log file, due to error: ${errorMessage}`)\n }\n}\n\n/** @internal */\nexport function log(level: LogLevel, message: string) {\n trace()\n ensureInitialized()\n const levelBuffer = bytesFromString(level)\n const messageBuffer = bytesFromString(message)\n dittoCore.ditto_log(level, messageBuffer)\n}\n\n// ----------------------------------------------------------- AuthClient ------\n\n/** @internal */\nexport function dittoAuthClientMakeAnonymousClient(path: string, appID: string, sharedToken: string, baseURL: string): Pointer<FFIAuthClient> {\n trace()\n ensureInitialized()\n\n const pathX = bytesFromString(path)\n const appIDX = bytesFromString(appID)\n const sharedTokenX = bytesFromString(sharedToken)\n const baseURLX = bytesFromString(baseURL)\n\n const { status_code: errorCode, auth_client: authClient } = dittoCore.ditto_auth_client_make_anonymous_client(pathX, appIDX, sharedTokenX, baseURLX)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_auth_client_make_anonymous_client() failed with error code: ${errorCode}`)\n return authClient\n}\n\n/** @internal */\nexport function dittoAuthClientMakeWithWeb(path: string, appID: string, baseURL: string, loginProvider: Pointer<FFILoginProvider>): Pointer<FFIAuthClient> {\n trace()\n ensureInitialized()\n\n const pathX = bytesFromString(path)\n const appIDX = bytesFromString(appID)\n const baseURLX = bytesFromString(baseURL)\n\n const { status_code: errorCode, auth_client: authClient } = dittoCore.ditto_auth_client_make_with_web(pathX, appIDX, baseURLX, loginProvider)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_auth_client_make_with_web() failed with error code: ${errorCode}`)\n return authClient\n}\n\n/** @internal */\nexport function dittoAuthClientMakeForDevelopment(path: string, appId: string, siteID: number | BigInt): Pointer<FFIAuthClient> {\n trace()\n ensureInitialized()\n\n const pathX = bytesFromString(path)\n const appIdX = bytesFromString(appId)\n const siteIDX = Number(siteID)\n const { status_code: errorCode, auth_client: authClient } = dittoCore.ditto_auth_client_make_for_development(pathX, appIdX, siteIDX)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_auth_client_make_for_development() failed with error code: ${errorCode}`)\n return authClient\n}\n\n/** @internal */\nexport function dittoAuthClientMakeWithSharedKey(path: string, appId: string, sharedKey: string, siteID: number | BigInt): Pointer<FFIAuthClient> {\n trace()\n ensureInitialized()\n\n const pathX = bytesFromString(path)\n const appIdX = bytesFromString(appId)\n const sharedKeyX = bytesFromString(sharedKey)\n const siteIDX = Number(siteID)\n const { status_code: errorCode, auth_client: authClient } = dittoCore.ditto_auth_client_make_with_shared_key(pathX, appIdX, sharedKeyX, siteIDX)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_auth_client_make_with_shared_key() failed with error code: ${errorCode}`)\n return authClient\n}\n\n/** @internal */\nexport function dittoAuthClientMakeWithStaticX509(configCBORBase64: string): Pointer<FFIAuthClient> {\n trace()\n ensureInitialized()\n\n const configCBORBase64X = bytesFromString(configCBORBase64)\n\n const { status_code: errorCode, auth_client: authClient } = dittoCore.ditto_auth_client_make_with_static_x509(configCBORBase64X)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_auth_client_make_with_static_x509() failed with error code: ${errorCode}`)\n return authClient\n}\n\n/** @internal */\nexport function dittoAuthClientGetSiteID(authClient: Pointer<FFIAuthClient>): number | BigInt {\n trace()\n ensureInitialized()\n return dittoCore.ditto_auth_client_get_site_id(authClient)\n}\n\n/** @internal */\nexport function dittoAuthClientFree(authClient: Pointer<FFIAuthClient>) {\n trace()\n ensureInitialized()\n return dittoCore.ditto_auth_client_free(authClient)\n}\n\nexport function dittoAuthClientIsWebValid(authClient: Pointer<FFIAuthClient>): boolean {\n trace()\n ensureInitialized()\n return dittoCore.ditto_auth_client_is_web_valid(authClient) !== 0\n}\n\nexport function dittoAuthClientUserID(authClient: Pointer<FFIAuthClient>): string {\n trace()\n ensureInitialized()\n const cStr = dittoCore.ditto_auth_client_user_id(authClient)\n return dittoCore.boxCStringIntoString(cStr)\n}\n\nexport function dittoAuthClientIsX509Valid(authClient: Pointer<FFIAuthClient>): boolean {\n trace()\n ensureInitialized()\n return dittoCore.ditto_auth_client_is_x509_valid(authClient) !== 0\n}\n\nexport async function dittoAuthClientLoginWithToken(authClient: Pointer<FFIAuthClient>, token: string, provider: string) {\n trace()\n ensureInitialized()\n\n const tokenBytes = bytesFromString(token)\n const providerBytes = bytesFromString(provider)\n\n const errorCode = await dittoCore.ditto_auth_client_login_with_token(authClient, tokenBytes, providerBytes)\n if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to authenticate (error code: ${errorCode}).`)\n}\n\nexport async function dittoAuthClientLoginWithUsernameAndPassword(authClient: Pointer<FFIAuthClient>, username: string, password: string, provider: string) {\n trace()\n ensureInitialized()\n\n const usernameBytes = bytesFromString(username)\n const passwordBytes = bytesFromString(password)\n const providerBytes = bytesFromString(provider)\n\n const errorCode = await dittoCore.ditto_auth_client_login_with_credentials(authClient, usernameBytes, passwordBytes, providerBytes)\n if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to authenticate (error code: ${errorCode}).`)\n}\n\nexport async function dittoAuthClientLogout(authClient: Pointer<FFIAuthClient>) {\n trace()\n ensureInitialized()\n\n const errorCode = await dittoCore.ditto_auth_client_logout(authClient)\n if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to logout (error code: ${errorCode}).`)\n}\n\n// ---------------------------------------------------------------- Ditto ------\n\n/** @internal */\nexport function uninitializedDittoMake(path: string): Pointer<FFIUninitializedDitto> {\n trace()\n ensureInitialized()\n const pathX = bytesFromString(path)\n return dittoCore.uninitialized_ditto_make(pathX)\n}\n\n/** @internal */\nexport function dittoMake(uninitializedDitto: Pointer<FFIUninitializedDitto>, authClient: Pointer<FFIAuthClient>): Pointer<FFIDitto> {\n trace()\n ensureInitialized()\n return dittoCore.ditto_make(uninitializedDitto, authClient, 'Disabled')\n}\n\n/** @internal */\nexport async function dittoGetCollectionNames(self: Pointer<FFIDitto>): Promise<string[]> {\n trace()\n ensureInitialized()\n\n const result = await dittoCore.ditto_get_collection_names(self)\n const errorCode = result.status_code\n const cStringVec: { ptr: Pointer<'char *'>; len: number; cap: number } = result.names\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_get_collection_names() failed with error code: ${errorCode}`)\n\n // WORKAROUND: cStringVecToStringArray() returns an `object` for the Wasm\n // variant, but it really is an array. We therefore force-cast here. Remove as\n // soon the exported function has proper type.\n const strings: string[] = dittoCore.cStringVecToStringArray(cStringVec) as string[]\n return strings\n}\n\n/** @internal */\nexport function dittoDrop(self: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n return dittoCore.ditto_drop(self)\n}\n\n/** @internal */\nexport function dittoFree(self: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n\n // REFACTOR: add proper error handling.\n return dittoCore.ditto_free(self)\n}\n\n/** @internal */\nexport async function dittoRegisterPresenceV1Callback(self: Pointer<FFIDitto>, cb: null | ((string) => void)): Promise<void> {\n trace()\n ensureInitialized()\n\n if (cb) {\n dittoCore.ditto_register_presence_v1_callback(\n self,\n wrapBackgroundCbForFFI(\n (err) => console.error(`The registered presence callback errored with ${err}`),\n (cJsonStr: Pointer<'char'>) => {\n const jsonStr: string = dittoCore.refCStringToString(cJsonStr)\n cb(jsonStr)\n },\n ),\n )\n } else {\n await dittoCore.ditto_clear_presence_callback(self)\n }\n}\n\n/** @internal */\nexport async function dittoRegisterPresenceV3Callback(self: Pointer<FFIDitto>, cb: (string) => void) {\n trace()\n ensureInitialized()\n\n dittoCore.ditto_register_presence_v3_callback(\n self,\n wrapBackgroundCbForFFI(\n (err) => console.error(`The registered presence callback v3 errored with ${err}`),\n (cJsonStr: Pointer<'char'>) => {\n const jsonStr: string = dittoCore.refCStringToString(cJsonStr)\n cb(jsonStr)\n },\n ),\n )\n}\n\n/** @internal */\nexport async function dittoClearPresenceV3Callback(self: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n dittoCore.ditto_clear_presence_v3_callback(self)\n}\n\n/** @internal */\nexport async function dittoClearPresenceCallback(self: Pointer<FFIDitto>): Promise<void> {\n trace()\n ensureInitialized()\n await dittoCore.ditto_clear_presence_callback(self)\n}\n\n/** @internal */\nexport function dittoRegisterTransportConditionChangedCallback(self: Pointer<FFIDitto>, cb: null | ((ConditionSource, TransportCondition) => void)) {\n trace()\n ensureInitialized()\n\n if (!cb) {\n // @Konstantin: do we do this?\n dittoCore.ditto_register_transport_condition_changed_callback(self, null)\n } else {\n dittoCore.ditto_register_transport_condition_changed_callback(\n self,\n wrapBackgroundCbForFFI((err) => console.error(`The registered \"transport condition changed\" callback errored with ${err}`), cb),\n )\n }\n}\n\n/** @internal */\nexport function dittoSetDeviceName(dittoPointer: Pointer<FFIDitto>, deviceName: string) {\n trace()\n ensureInitialized()\n\n let deviceNameCString = bytesFromString(deviceName)\n\n if (isWebBuild && deviceNameCString.length > 64) {\n // WORKAROUND: the Wasm build won't sync when passing a device name with\n // more than 64 bytes. As a quick workaround, we strip all non-ASCII\n // characters and cap that at 63 bytes leaving one byte for '\\0'.\n const sanitizedDeviceName = deviceName.replace(/[^ -~]+/g, '')\n deviceNameCString = bytesFromString(sanitizedDeviceName.substr(0, 63))\n\n // NOTE: to reproduce the issue, comment the following two in. You'll see\n // that an ASCII string of 64 characters and more will make prevent sync\n // from working.\n //\n // const demoDeviceName = \"123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-4\" //56789-70-456789-80-456789-90-456789\" // 100\n // deviceNameCString = bytesFromString(demoDeviceName)\n }\n\n return dittoCore.ditto_set_device_name(dittoPointer, deviceNameCString)\n}\n\n/** @internal */\nexport function dittoSetSyncGroup(dittoPointer: Pointer<FFIDitto>, syncGroup: number) {\n trace()\n ensureInitialized()\n\n return dittoCore.ditto_set_sync_group(dittoPointer, syncGroup)\n}\n\n// Not supported on Wasm.\n/** @internal */\nexport function dittoNewAttachmentFromFile(ditto: Pointer<FFIDitto>, sourcePath: string, fileOperation: AttachmentFileOperation): RawAttachment {\n trace()\n ensureInitialized()\n\n const sourcePathCString = bytesFromString(sourcePath)\n const outAttachment: any = {}\n const errorCode = dittoCore.ditto_new_attachment_from_file(ditto, sourcePathCString, fileOperation, outAttachment)\n if (errorCode !== 0) {\n throw new Error(errorMessage() || `ditto_new_attachment_from_file() failed with error code: ${errorCode}`)\n }\n return outAttachment\n}\n\n/** @internal */\nexport async function dittoNewAttachmentFromBytes(ditto: Pointer<FFIDitto>, bytes: Uint8Array): Promise<RawAttachment> {\n trace()\n ensureInitialized()\n\n const outAttachment: any = {}\n const errorCode = await dittoCore.ditto_new_attachment_from_bytes(ditto, bytes, outAttachment)\n if (errorCode !== 0) {\n throw new Error(errorMessage() || `ditto_new_attachment_from_bytes() failed with error code: ${errorCode}`)\n }\n return outAttachment\n}\n\n/** @internal */\nexport async function dittoResolveAttachment(\n ditto: Pointer<FFIDitto>,\n id: Uint8Array,\n namedCallbacks: {\n onComplete: (attachmentHandlePointer: Pointer<AttachmentHandle>) => void\n onProgress: (downloaded: number | BigInt, toDownload: number | BigInt) => void\n onDelete: () => void\n },\n // Cb may be called in parallel at any point, so let's use\n // an optional error handler (which defaults to `console.error`).\n onError?: (error: any) => void,\n): Promise<number | BigInt> {\n trace()\n ensureInitialized()\n\n const { onComplete, onProgress, onDelete } = namedCallbacks\n const { status_code: errorCode, cancel_token: cancelToken } = await dittoCore.ditto_resolve_attachment(ditto, id, wrapBackgroundCbForFFI(onError, onComplete), wrapBackgroundCbForFFI(onError, onProgress), wrapBackgroundCbForFFI(onError, onDelete))\n if (errorCode !== 0) {\n throw new Error(errorMessage() || `ditto_resolve_attachment() failed with error code: ${errorCode}`)\n }\n return cancelToken\n}\n\n/** @internal */\nexport function dittoCancelResolveAttachment(dittoPointer: Pointer<FFIDitto>, id: Uint8Array, cancelToken: any) {\n trace()\n ensureInitialized()\n\n const errorCode = dittoCore.ditto_cancel_resolve_attachment(dittoPointer, id, cancelToken)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_cancel_resolve_attachment() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function freeAttachmentHandle(attachmentHandlePointer: Pointer<AttachmentHandle>) {\n trace()\n ensureInitialized()\n dittoCore.ditto_free_attachment_handle(attachmentHandlePointer)\n}\n\n/** @internal */\nexport async function dittoGetAttachmentStatus(dittoPointer: Pointer<FFIDitto>, id: Uint8Array): Promise<Pointer<AttachmentHandle>> {\n trace()\n ensureInitialized()\n\n const { status_code: errorCode, handle: attachmentHandle } = await dittoCore.ditto_get_attachment_status(dittoPointer, id)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_get_attachment_status() failed with error code: ${errorCode}`)\n return attachmentHandle\n}\n\n/** @internal */\nexport async function dittoGetCompleteAttachmentData(dittoPointer: Pointer<FFIDitto>, attachmentHandlePointer: Pointer<AttachmentHandle>): Promise<Uint8Array> {\n trace()\n ensureInitialized()\n\n const { status: errorCode, data } = await dittoCore.ditto_get_complete_attachment_data(dittoPointer, attachmentHandlePointer)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_get_complete_attachment_data()\\` failed with error code: ${errorCode}`)\n return dittoCore.boxCBytesIntoBuffer(data)\n}\n\n/** @internal */\nexport function dittoGetCompleteAttachmentPath(dittoPointer: Pointer<FFIDitto>, attachmentHandlePointer: Pointer<AttachmentHandle>): string {\n trace()\n ensureInitialized()\n\n const pathCString = dittoCore.ditto_get_complete_attachment_path(dittoPointer, attachmentHandlePointer)\n return dittoCore.refCStringToString(pathCString)\n}\n\n/** @internal */\nexport function dittoGetSDKVersion(ditto: Pointer<FFIDitto>): string {\n trace()\n ensureInitialized()\n\n const cString = dittoCore.ditto_get_sdk_version(ditto)\n return dittoCore.boxCStringIntoString(cString)\n}\n\n/** @internal */\nexport function dittoPresenceV1(self: Pointer<FFIDitto>): string {\n trace()\n ensureInitialized()\n\n const cString = dittoCore.ditto_presence_v1(self)\n return dittoCore.boxCStringIntoString(cString)\n}\n\n/** @internal */\nexport function dittoPresenceV2(self: Pointer<FFIDitto>): string {\n trace()\n ensureInitialized()\n\n const cString = dittoCore.ditto_presence_v2(self)\n return dittoCore.boxCStringIntoString(cString)\n}\n\n/** @internal */\nexport function dittoPresenceV3(self: Pointer<FFIDitto>): string {\n trace()\n ensureInitialized()\n\n const cString = dittoCore.ditto_presence_v3(self)\n return dittoCore.boxCStringIntoString(cString)\n}\n\n/** @internal */\nexport function dittoStartTCPServer(dittoPointer: Pointer<FFIDitto>, bind: string) {\n trace()\n ensureInitialized()\n\n const bindBuffer = bytesFromString(bind)\n return (dittoCore as any).ditto_start_tcp_server(dittoPointer, bindBuffer)\n}\n\n/** @internal */\nexport function dittoStopTCPServer(dittoPointer: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n return (dittoCore as any).ditto_stop_tcp_server(dittoPointer)\n}\n\n/** @internal */\nexport function dittoAddMulticastTransport(dittoPointer: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n\n return (dittoCore as any).ditto_add_multicast_transport(dittoPointer)\n}\n\n/** @internal */\nexport function dittoRemoveMulticastTransport(dittoPointer: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n\n return (dittoCore as any).ditto_remove_multicast_transport(dittoPointer)\n}\n\n/** @internal */\nexport function dittoStartHTTPServer(dittoPointer: Pointer<FFIDitto>, bind: string, staticPath: string | null, websocketMode: WebsocketMode, tlsCertPath: string | null, tlsKeyPath: string | null) {\n trace()\n ensureInitialized()\n\n const bindBuffer = bytesFromString(bind)\n const staticPathBuffer = bytesFromString(staticPath)\n const tlsCertPathBuffer = bytesFromString(tlsCertPath)\n const tlsKeyPathBuffer = bytesFromString(tlsKeyPath)\n return (dittoCore as any).ditto_start_http_server(dittoPointer, bindBuffer, staticPathBuffer, websocketMode, tlsCertPathBuffer, tlsKeyPathBuffer)\n}\n\n/** @internal */\nexport function dittoStopHTTPServer(dittoPointer: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n return (dittoCore as any).ditto_stop_http_server(dittoPointer)\n}\n\n/** @internal */\nexport function dittoRunGarbageCollection(dittoPointer: Pointer<FFIDitto>) {\n trace()\n ensureInitialized()\n return dittoCore.ditto_run_garbage_collection(dittoPointer)\n}\n\n/** @internal */\nexport async function dittoDisableSyncWithV2(dittoPointer: Pointer<FFIDitto>): Promise<void> {\n trace()\n ensureInitialized()\n const errorCode = await dittoCore.ditto_disable_sync_with_v2(dittoPointer)\n if (errorCode !== 0) throw new Error(errorMessage() || `ditto_disable_sync_with_v2() failed with error code: ${errorCode}`)\n}\n\n// ------------------------------------------------------ Hash & Mnemonic ------\n\n/** @internal */\nexport function documentsHash(documents: Pointer<FFIDocument>[]): BigInt {\n trace()\n ensureInitialized()\n const { status_code: errorCode, u64: hash } = dittoCore.ditto_documents_hash(documents)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_documents_hash()\\` failed with error code: ${errorCode}`)\n // `hash` is of type `number | BigInt`, let's unify it to `BigInt` to keep it simple.\n return BigInt(hash)\n}\n\n/** @internal */\nexport function documentsHashMnemonic(documents: Pointer<FFIDocument>[]): string {\n trace()\n ensureInitialized()\n const { status_code: errorCode, c_string } = dittoCore.ditto_documents_hash_mnemonic(documents)\n if (errorCode !== 0) throw new Error(errorMessage() || `\\`ditto_documents_hash_mnemonic()\\` failed with error code: ${errorCode}`)\n return dittoCore.boxCStringIntoString(c_string)\n}\n\n// ------------------------------------------------------------- Auth ----------\n\n/** @internal */\nexport function authServerAuthSubmitWithSuccess(req: Pointer<FFIAuthServerAuthRequest>, successCbor: Uint8Array): void {\n trace()\n ensureInitialized()\n return dittoCore.auth_server_auth_submit_with_success(req, successCbor)\n}\n\n/** @internal */\nexport function authServerAuthSubmitWithError(req: Pointer<FFIAuthServerAuthRequest>, errorCode: number): void {\n trace()\n ensureInitialized()\n return dittoCore.auth_server_auth_submit_with_error(req, errorCode)\n}\n\n/** @internal */\nexport function authServerRefreshSubmitWithSuccess(req: Pointer<FFIAuthServerRefreshRequest>, successCbor: Uint8Array): void {\n trace()\n ensureInitialized()\n return dittoCore.auth_server_refresh_submit_with_success(req, successCbor)\n}\n\n/** @internal */\nexport function authServerRefreshSubmitWithError(req: Pointer<FFIAuthServerRefreshRequest>, errorCode: number): void {\n trace()\n ensureInitialized()\n return dittoCore.auth_server_refresh_submit_with_error(req, errorCode)\n}\n\n/** @internal */\nexport function dittoUnregisterLocalAuthServer(ditto: Pointer<FFIDitto>): void {\n trace()\n ensureInitialized()\n return dittoCore.ditto_unregister_local_auth_server(ditto)\n}\n\n/** @internal */\nexport function dittoRegisterLocalAuthServer(namedArgs: {\n ditto: Pointer<FFIDitto>\n signingKeyPem: string\n verifyingKeysPem: string[]\n caKeyPem?: string\n authCb: (authRequest: Pointer<FFIAuthServerAuthRequest>, cbor: Uint8Array) => void\n refreshCb: (authRequest: Pointer<FFIAuthServerRefreshRequest>, cbor: Uint8Array) => void\n // Cb may be called in parallel at any point, so let's use\n // an optional error handler\n onError?: (error: any) => void\n}): void {\n const { ditto, signingKeyPem, verifyingKeysPem, caKeyPem, authCb, refreshCb, onError } = namedArgs\n trace()\n ensureInitialized()\n\n const signingKeyPemFfi = bytesFromString(signingKeyPem)\n const verifyingKeysPemFfi = verifyingKeysPem.map(bytesFromString)\n const caKeyPemFfi = typeof caKeyPem !== 'undefined' ? bytesFromString(caKeyPem) : null\n const authCbFfi = wrapBackgroundCbForFFI(onError, authCb)\n const refreshCbFfi = wrapBackgroundCbForFFI(onError, refreshCb)\n return dittoCore.ditto_register_local_auth_server(ditto, signingKeyPemFfi, verifyingKeysPemFfi, caKeyPemFfi, authCbFfi, refreshCbFfi)\n}\n\n/** @internal */\nexport function dittoAuthClientMakeLoginProvider(\n expiringCb: (secs_until_expiry: number) => void,\n // Cb may be called in parallel at any point, so let's use an optional error handler\n onError?: (error: any) => void,\n): Pointer<FFILoginProvider> {\n trace()\n ensureInitialized()\n\n return dittoCore.ditto_auth_client_make_login_provider(wrapBackgroundCbForFFI(onError, expiringCb))\n}\n\n/** @internal */\nexport function dittoAuthClientSetValidityListener(\n authClient: Pointer<FFIAuthClient>,\n validityUpdateCb: (isWebValid: boolean, isX509Valid: boolean) => void,\n // Cb may be called in parallel at any point, so let's use an optional error handler\n onError?: (error: any) => void,\n): void {\n trace()\n ensureInitialized()\n\n const validityUpdateRawCb = wrapBackgroundCbForFFI(onError, function (isWebValidInt: number, isX509ValidInt: number) {\n return validityUpdateCb(isWebValidInt === 1, isX509ValidInt === 1)\n })\n\n return dittoCore.ditto_auth_client_set_validity_listener(authClient, validityUpdateRawCb)\n}\n\n// ---------------------------------------------------------------- Other ------\n\n/** @internal */\nlet isInitialized = false\n\n/** @internal */\nlet withOutPtr: (ptr_type: string, callback: any) => any\n\nnodeBuildOnly: {\n isInitialized = true\n withOutPtr = wrapFFIOutFunction(dittoCore.withOutPtr)\n}\n\n/** @internal */\nexport async function init(webAssemblyModule?: WebAssemblyModule): Promise<void> {\n webBuildOnly: {\n if (webAssemblyModule) {\n await (dittoCore as any).init(webAssemblyModule)\n } else {\n await (dittoCore as any).init()\n }\n\n isInitialized = true\n withOutPtr = wrapFFIOutFunction(dittoCore.withOutPtr)\n }\n}\n\n/** @internal */\nexport function initSDKVersion(platform: Platform, language: Language, semVer: string) {\n trace()\n ensureInitialized()\n\n const platformCString = bytesFromString(platform)\n const languageCString = bytesFromString(language)\n const semVerCString = bytesFromString(semVer)\n\n const errorCode = dittoCore.ditto_init_sdk_version(platform, language, semVerCString)\n if (typeof errorCode !== 'undefined' && errorCode !== 0) throw new Error(errorMessage() || `ditto_init_sdk_version() failed with error code: ${errorCode}`)\n}\n\n/** @internal */\nexport function verifyLicense(license: string): { result: LicenseVerificationResult; errorMessage?: string } {\n trace()\n ensureInitialized()\n\n const licenseBuffer = bytesFromString(license)\n let result: LicenseVerificationResult\n const errorMessageCString = withOutPtr('char *', (outErrorMessage) => {\n result = dittoCore.verify_license(licenseBuffer, outErrorMessage)\n return outErrorMessage\n })\n\n const errorMessage = dittoCore.boxCStringIntoString(errorMessageCString)\n return { result, errorMessage }\n}\n\n// -------------------------------------------------------------- Private ------\n\n// HACK: this is a left-over error code still in use which will be removed\n// in the near future. Until then, we hard-code it here, just like the\n// ObjC/Swift SDK. See discussion on Slack for details:\n// https://dittolive.slack.com/archives/CRRAWK99A/p1616065662069800\n/** @internal */\nconst NOT_FOUND_ERROR_CODE = -30798\n\n/** @internal */\nfunction wrapBackgroundCbForFFI(onError: undefined | ((err: any) => void), cb: any): any {\n if (onError === undefined) {\n // Basic fallback based off: https://stackoverflow.com/a/3390635\n onError = console.error\n }\n return (ret_sender, ...args) => {\n let ret\n try {\n ret = cb(...args)\n } catch (err) {\n try {\n onError(err)\n } catch (nested_error) {\n console.error(`Internal error: \\`onError()\\` handler oughtn't throw, but it did throw ${nested_error}`)\n }\n }\n return ret_sender(ret)\n }\n}\n\n/** @internal */\nfunction wrapFFIOutFunction(ffiOutFunction: any): any {\n return function (...args) {\n let occurredError = undefined\n let callbackResult = undefined\n let isCallbackResultOutParameter = false\n\n const callback = args[args.length - 1]\n const previous_args = args.splice(0, args.length - 1)\n\n const dittoCoreResult = ffiOutFunction(...previous_args, (outParameter) => {\n try {\n callbackResult = callback(outParameter)\n isCallbackResultOutParameter = callbackResult === outParameter\n } catch (error) {\n occurredError = error\n }\n })\n\n if (occurredError) {\n throw occurredError\n }\n\n return isCallbackResultOutParameter ? dittoCoreResult : callbackResult\n }\n}\n\n/** @internal */\nfunction bytesFromString(jsString: string | null | undefined): Uint8Array | null | undefined {\n if (typeof jsString === 'undefined') return undefined\n if (jsString === null) return null\n if (typeof jsString !== 'string') throw new Error(`Can't convert string to Uint8Array, not a string: ${jsString}`)\n const textEncoder = new TextEncoder()\n return textEncoder.encode(`${jsString}\\0`)\n}\n\n/** @internal */\nfunction errorMessage(): string {\n trace()\n ensureInitialized()\n\n const errorMessageCString = dittoCore.ditto_error_message()\n return dittoCore.boxCStringIntoString(errorMessageCString)\n}\n\n/** @internal */\nfunction trace() {\n if (isTracingEnabled) {\n // Copied and adapted from a Stack Overflow comment:\n // https://stackoverflow.com/a/38435618\n const error = new Error()\n const stack = error.stack\n let caller = '<unknown>'\n try {\n caller = stack.split('\\n')[2].trim().split(/\\s+/)[1].replace('Module.', '')\n } catch (error) {\n // Nothing to do, caller remains unknown.\n }\n console.log(`💗 [TRACE] ${caller}()`)\n }\n}\n\n/** @internal */\nfunction ensureInitialized() {\n if (!isInitialized) {\n throw new Error('Ditto needs to be initialized before using any of its API, please make sure to call `await init()` first.')\n }\n}\n","let transportsLoadError = null\n\n// NOTE: we only try to load the native module if we are running in a Node-like\n// environment. Furthermore, there might not be a native module for the current\n// platform and/or architecture.\n//\n// In either case, if no native Node module could be loaded, we fallback to\n// init being a no-op, all availability functions returning false, and\n// everything else throwing an \"unsupported\" exception.\n\nconst transports = function() {\n nodeBuildOnly: {\n if (typeof process !== 'undefined' && typeof require !== 'undefined') {\n // IMPORTANT: most packagers perform _static_ analysis to identity native\n // Node modules to copy them into the right directory within the\n // final package. This only works if we use constant strings with\n // require(). Therefore, we use an if for all supported targets and\n // explicitly require each instead of dynamically building the require\n // path.\n\n const target = process.platform + '-' + process.arch\n\n try {\n if (target === 'darwin-x64') return require(`./transports.darwin-x64.node`)\n if (target === 'darwin-arm64') return require(`./transports.darwin-arm64.node`)\n } catch (error) {\n // Swallow it, we'll do error reporting in the individual functions if\n // need be.\n transportsLoadError = error\n return null\n }\n }\n }\n\n // Fall-back to no-op.\n return null\n}()\n\n// ----------------------------------------------------------------- Init ------\n\nexport async function init() {\n if (transports !== null) {\n return transports.init()\n } else {\n // Nothing to do.\n }\n}\n\n// ------------------------------------------------------------------ BLE ------\n\nexport function bleIsAvailable(ditto) {\n nodeBuildOnly: {\n // HACK: quick & dirty Linux/Win hack. LAN is available there via libdittoffi\n // functions and not this transports module. See corresponding hack\n // in `sync.ts` for details. Because we enable P2P transports by default\n // by checking this function, we'll have to make sure it returns true here\n // when running on Linux.\n if (process.platform === 'linux' || process.platform === 'win32') {\n return true\n }\n }\n\n if (transports !== null) {\n return transports.bleIsAvailable(ditto)\n } else {\n return false\n }\n}\n\nexport function bleCreate(ditto) {\n if (transports !== null) {\n return transports.bleCreate(ditto)\n } else {\n throw new Error(\"Can't create BluetoothLE handle, P2P BluetoothLE is not supported on this platform.\")\n }\n}\n\nexport function bleDestroy(ble) {\n if (transports !== null) {\n return transports.bleDestroy(ble)\n } else {\n throw new Error(\"Can't destroy BluetoothLE handle, P2P BluetoothLE is not supported on this platform.\")\n }\n}\n\n// ------------------------------------------------------------------ LAN ------\n\nexport function lanIsAvailable(ditto) {\n nodeBuildOnly: {\n // HACK: quick & dirty Linux/Win hack. LAN is available there via libdittoffi\n // functions and not this transports module. See corresponding hack\n // in `sync.ts` for details. Because we enable P2P transports by default\n // by checking this function, we'll have to make sure it returns true here\n // when running on Linux.\n if (process.platform === 'win32') {\n // FIXME: include 'linux' as well\n return true\n }\n }\n if (transports !== null) {\n return transports.lanIsAvailable(ditto)\n } else {\n return false;\n }\n}\n\nexport function lanCreate(ditto) {\n if (transports !== null) {\n return transports.lanCreate(ditto)\n } else {\n throw new Error(\"Can't create LAN handle, P2P LAN transport is not supported on this platform.\")\n }\n}\n\nexport function lanDestroy(lan) {\n if (transports !== null) {\n return transports.lanDestroy(lan)\n } else {\n throw new Error(\"Can't destroy LAN handle, P2P LAN transport is not supported on this platform.\")\n }\n}\n\n// ----------------------------------------------------------------- AWDL ------\n\nexport function awdlIsAvailable(ditto) {\n if (transports !== null) {\n return transports.awdlIsAvailable(ditto)\n } else {\n return false\n }\n}\n\nexport function awdlCreate(ditto) {\n if (transports !== null) {\n return transports.awdlCreate(ditto)\n } else {\n throw new Error(\"Can't create AWDL handle, P2P AWDL transport is not supported on this platform.\")\n }\n}\n\nexport function awdlDestroy(awdl) {\n if (transports !== null) {\n return transports.awdlDestroy(awdl)\n } else {\n throw new Error(\"Can't destroy AWDL handle, P2P AWDL transport is not supported on this platform.\")\n }\n}\n","// NOTE: this is patched up with the actual build version by Jake task\n// build:package and has to be a valid semantic version as defined here: https://semver.org.\nexport const fullBuildVersionString = '{full-build-version-string}'\n\n// NOTE: this is patched up with the default URL for the ditto.wasm by Jake task\n// build:package. Usually it looks something like this:\n// https://software.ditto.live/js/Ditto/1.2.3-alpha.456/ditto.wasm\nexport const defaultDittoWasmFileURL = '{default-ditto-wasm-file-url}'\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport * as TR from './@transports.js'\nimport { fullBuildVersionString } from './build-time-constants.js'\nimport { Ditto } from './ditto.js'\nimport { WebAssemblyModule } from './ffi.js'\nimport { defaultDittoWasmFileURL } from './build-time-constants.js'\n\nlet isInitialized = false\n\nexport { WebAssemblyModule }\n\n/**\n * Available options for {@link init | init()}.\n */\nexport type InitOptions = {\n /**\n * You can explicitly pass the WebAssembly module or its location via the\n * `webAssemblyModule` option. By default, Ditto tries to load the WebAssembly\n * module from the same path where this JavaScript is served.\n */\n webAssemblyModule?: WebAssemblyModule\n}\n\n/**\n * Initializes the whole Ditto module. Needs to be called and complete before\n * any of the Ditto API is used.\n *\n * @param options - Dictionary with global {@link InitOptions | initialization options}.\n */\nexport async function init(options: InitOptions = {}): Promise<void> {\n if (!isInitialized) {\n webBuildOnly: {\n // IDEA: throw or log a warning if init() was called a second time with\n // different options (because those wouldn't have any effect).\n\n const webAssemblyModule = options.webAssemblyModule || defaultDittoWasmFileURL\n\n await FFI.init(webAssemblyModule)\n await TR.init()\n\n FFI.initSDKVersion('Web', 'JavaScript', fullBuildVersionString)\n FFI.loggerInit()\n }\n\n isInitialized = true\n }\n}\n\nnodeBuildOnly: {\n switch (process.platform) {\n case 'android':\n FFI.initSDKVersion('Android', 'JavaScript', fullBuildVersionString)\n break\n case 'darwin':\n FFI.initSDKVersion('Mac', 'JavaScript', fullBuildVersionString)\n break\n case 'linux':\n FFI.initSDKVersion('Linux', 'JavaScript', fullBuildVersionString)\n break\n case 'win32':\n FFI.initSDKVersion('Windows', 'JavaScript', fullBuildVersionString)\n break\n default:\n FFI.initSDKVersion('Unknown', 'JavaScript', fullBuildVersionString)\n break\n }\n\n FFI.loggerInit()\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n/** @internal */\nexport class KeepAlive {\n /** @internal */\n get isActive(): boolean {\n return this.intervalID !== null\n }\n\n /** @internal */\n constructor() {\n this.countsByID = {}\n this.intervalID = null\n }\n\n /** @internal */\n retain(id: string): void {\n if (typeof this.countsByID[id] === 'undefined') {\n this.countsByID[id] = 0\n }\n\n this.countsByID[id] += 1\n\n if (this.intervalID === null) {\n // Keep the process alive as long as there is at least one ID being\n // tracked by setting a time interval with the maximum delay. This will\n // prevent the process from exiting.\n const maxDelay = 2147483647 // Signed 32 bit integer, see docs: https://developer.mozilla.org/en-US/docs/Web/API/setInterval\n this.intervalID = setInterval(() => {\n /* no-op */\n }, maxDelay)\n KeepAlive.finalizationRegistry.register(this, this.intervalID, this)\n }\n }\n\n /** @internal */\n release(id: string): void {\n if (typeof this.countsByID[id] === 'undefined') {\n throw new Error(`Internal inconsistency, trying to release a keep-alive ID that hasn't been retained before or isn't tracked anymore: ${id}`)\n }\n\n this.countsByID[id] -= 1\n\n if (this.countsByID[id] === 0) {\n delete this.countsByID[id]\n }\n\n if (Object.keys(this.countsByID).length === 0) {\n // Nothing is tracked anymore, it's safe to clear the interval\n // and let the process do what it wants.\n KeepAlive.finalizationRegistry.unregister(this)\n clearInterval(this.intervalID)\n this.intervalID = null\n }\n }\n\n /** @internal */\n currentIDs(): string[] {\n return Object.keys(this.countsByID)\n }\n\n /** @internal */\n countForID(id: string): number | null {\n return this.countsByID[id] ?? null\n }\n\n private static finalizationRegistry = new FinalizationRegistry(clearInterval)\n\n private intervalID\n private countsByID\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\n/** The log levels supported by Ditto. */\nexport type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose'\n\n/**\n * Closure that {@link Logger.setCustomLogCallback} can be set as a custom\n * log callback on {@link Logger}.\n */\nexport type CustomLogCallback = (logLevel: LogLevel, message: string) => void\n\n/**\n * Class with static methods to customize the logging behavior from Ditto and\n * log messages with the Ditto logging infrastructure.\n */\nexport class Logger {\n /**\n * Registers a file path where logs will be written to, whenever Ditto wants\n * to issue a log (on _top_ of emitting the log to the console).\n */\n static readonly logFile?: string\n\n /**\n * On Node, registers a file path where logs will be written to, whenever\n * Ditto wants to issue a log (on _top_ of emitting the log to the console).\n * In the browser, this method has no effect.\n *\n * @param path can be `null`, in which case the current logging file, if any,\n * is unregistered, otherwise, the file path must be within an already\n * existing directory.\n */\n static setLogFile(path: string | null) {\n if (path) {\n FFI.loggerSetLogFile(path)\n this['logFile' as any] = path\n } else {\n FFI.loggerSetLogFile(null)\n delete this['logFile' as any]\n }\n }\n\n /**\n * Convenience method, takes the path part of the URL and calls\n * {@link setLogFile | setLogFile()} with it.\n */\n static setLogFileURL(url: URL | undefined) {\n this.setLogFile(url?.pathname)\n }\n\n /** Whether the logger is currently enabled. */\n static get enabled(): boolean {\n return FFI.loggerEnabledGet()\n }\n\n /** Enables or disables logging. */\n static set enabled(enabled: boolean) {\n FFI.loggerEnabled(enabled)\n }\n\n /**\n * Represents whether or not emojis should be used as the log level\n * indicator in the logs.\n */\n static get emojiLogLevelHeadingsEnabled(): boolean {\n return FFI.loggerEmojiHeadingsEnabledGet()\n }\n\n /**\n * Represents whether or not emojis should be used as the log level\n * indicator in the logs.\n */\n static set emojiLogLevelHeadingsEnabled(emojiLogLevelHeadingsEnabled: boolean) {\n FFI.loggerEmojiHeadingsEnabled(emojiLogLevelHeadingsEnabled)\n }\n\n /**\n * The minimum log level at which logs will be logged.\n *\n * For example if this is set to `Warning`, then only logs that are logged\n * with the `Warning` or `Error` log levels will be shown.\n */\n static get minimumLogLevel(): LogLevel {\n return FFI.loggerMinimumLogLevelGet()\n }\n\n /**\n * The minimum log level at which logs will be logged.\n *\n * For example if this is set to `Warning`, then only logs that are logged\n * with the `Warning` or `Error` log levels will be shown.\n */\n static set minimumLogLevel(minimumLogLevel: LogLevel) {\n FFI.loggerMinimumLogLevel(minimumLogLevel)\n }\n\n /**\n * Returns the current custom log callback, `undefined` by default. See\n * {@link setCustomLogCallback | setCustomLogCallback()} for a detailed\n * description.\n */\n static readonly customLogCallback?: CustomLogCallback\n\n /**\n * Registers a custom callback that will be called to report each log entry.\n *\n * @param callback function called for each log entry. `undefined` will\n * unregister any previous callback and stop reporting log entries through\n * callbacks.\n */\n static async setCustomLogCallback(callback: CustomLogCallback | undefined): Promise<void> {\n if (callback) {\n await FFI.loggerSetCustomLogCb(callback)\n this['customLogCallback' as any] = callback\n } else {\n await FFI.loggerSetCustomLogCb(null)\n delete this['customLogCallback' as any]\n }\n }\n\n /**\n * Logs the message for the given `level`.\n *\n * @see {@link error | error()}\n * @see {@link warning | warning()}\n * @see {@link info | info()}\n * @see {@link debug | debug()}\n * @see {@link verbose | verbose()}\n */\n static log(level: LogLevel, message: string) {\n FFI.log(level, message)\n }\n\n /**\n * Convenience method, same as calling {@link log | log()} with\n * {@link LogLevel} `Error`.\n */\n static error(message: string) {\n this.log('Error', message)\n }\n\n /**\n * Convenience method, same as calling {@link log | log()} with\n * {@link LogLevel} `Warning`.\n */\n static warning(message: string) {\n this.log('Warning', message)\n }\n\n /**\n * Convenience method, same as calling {@link log | log()} with\n * {@link LogLevel} `Info`.\n */\n static info(message: string) {\n this.log('Info', message)\n }\n\n /**\n * Convenience method, same as calling {@link log | log()} with\n * {@link LogLevel} `Debug`.\n */\n static debug(message: string) {\n this.log('Debug', message)\n }\n\n /**\n * Convenience method, same as calling {@link log | log()} with\n * {@link LogLevel} `Verbose`.\n */\n static verbose(message: string) {\n this.log('Verbose', message)\n }\n\n // ------------------------------------------------------------ Private ------\n\n private constructor() {\n throw new Error(\"Logger can't be instantiated, use it's static properties & methods directly instead.\")\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport { generateEphemeralToken } from './internal.js'\nimport { KeepAlive } from './keep-alive.js'\n\n/** @internal */\nexport type ObserverToken = string\n\n/** @internal */\nexport type ObserverManagerConstructorOptions = {\n keepAlive?: KeepAlive\n register?: (callback: (...args: any[]) => void) => void\n unregister?: () => void\n process?: (...args: any[]) => any[]\n}\n\n/** @internal */\nexport class ObserverManager {\n /** @internal */\n readonly id: string\n\n /** @internal */\n readonly keepAlive: KeepAlive | null\n\n /** @internal */\n constructor(id: string, options: ObserverManagerConstructorOptions = {}) {\n const keepAlive = options.keepAlive ?? null\n const register = options.register ?? null\n const unregister = options.unregister ?? null\n const process = options.process ?? null\n\n this.id = id\n this.keepAlive = keepAlive\n\n this.isRegistered = false\n this.callbacksByToken = {}\n\n if (register !== null) {\n this.register = register\n }\n\n if (unregister !== null) {\n this.unregister = unregister\n }\n\n if (process !== null) {\n this.process = process\n }\n }\n\n /** @internal */\n addObserver(callback: any): ObserverToken {\n this.registerIfNeeded()\n\n const token = generateEphemeralToken()\n this.callbacksByToken[token] = callback\n\n this.keepAlive?.retain(`${this.id}.${token}`)\n return token\n }\n\n /** @internal */\n removeObserver(token: ObserverToken) {\n delete this.callbacksByToken[token]\n this.keepAlive?.release(`${this.id}.${token}`)\n this.unregisterIfNeeded()\n }\n\n /** @internal */\n notify(...args: any[]) {\n const processedArgs = this.process(...args)\n for (const token in this.callbacksByToken) {\n const callback = this.callbacksByToken[token]\n callback(...processedArgs)\n }\n }\n\n /**\n * Can be injected and replaced via constructor options.\n *\n * @abstract\n */\n protected register(callback: (...args: any[]) => void) {\n // No-op, subclasses may override and register.\n }\n\n /**\n * Can be injected and replaced via constructor options.\n *\n * @abstract\n */\n protected unregister() {\n // No-op, subclasses may override and unregister.\n }\n\n /**\n * Can be injected and replaced via constructor options.\n *\n * @abstract\n */\n protected process(...args: any[]): any[] {\n // No-op, subclasses may override and process/transform the callback parameters.\n return args\n }\n\n private isRegistered: boolean\n private callbacksByToken: { [key: string]: (...args: any[]) => void }\n private constructorOptions: ObserverManagerConstructorOptions\n\n private hasObservers(): boolean {\n return Object.keys(this.callbacksByToken).length > 0\n }\n\n private registerIfNeeded() {\n const needsToRegister = !this.isRegistered\n if (needsToRegister) {\n const weakThis = new WeakRef(this)\n this.isRegistered = true\n this.register(function (...args) {\n const strongThis = weakThis.deref()\n if (!strongThis) {\n return\n }\n\n strongThis.notify(...args)\n })\n }\n }\n\n private unregisterIfNeeded() {\n const needsToUnregister = !this.hasObservers() && this.isRegistered\n if (needsToUnregister) {\n this.isRegistered = false\n this.unregister()\n }\n }\n\n private async finalize(token: ObserverToken): Promise<void> {\n await this.removeObserver(token)\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n/** @internal */\ninterface ObserverRemoving {\n removeObserver(token: any)\n}\n\n/** @internal */\nexport type ObserverOptions = {\n stopsWhenFinalized?: boolean\n}\n\n/**\n * Generic observer handle returned by various observation APIs. The observation\n * remains active until the {@link stop | stop()} method is called explicitly or\n * the observer instance is garbage collected. Therefore, to keep the observation\n * alive, you have to keep a reference to the corresponding observer.\n */\nexport class Observer {\n // NOTE: the core functionality of the observer manager is token-based. We use\n // the `Observer` class merely as a public API wrapper around the token\n // exposing a convenience `stop()` method plus life-cycle tracking.\n\n /** @internal */\n readonly observerManager: ObserverRemoving\n\n /** @internal */\n readonly token?: any\n\n /** @internal */\n readonly options?: ObserverOptions\n\n /** @internal */\n constructor(observerManager: ObserverRemoving, token: any, options: ObserverOptions = {}) {\n this.observerManager = observerManager\n this.token = token\n this.options = options\n\n if (options.stopsWhenFinalized) {\n Observer.finalizationRegistry.register(this, { observerManager, token }, this)\n }\n }\n\n /**\n * Returns `true` if the observer has been explicitly stopped via the `stop()`\n * method. Otherwise returns `false`.\n */\n get isStopped(): boolean {\n return typeof this.token === 'undefined'\n }\n\n /**\n * Stops the observation. Calling this method multiple times has no effect.\n */\n stop() {\n const token = this.token\n if (token) {\n delete this['token' as any]\n Observer.finalizationRegistry.unregister(this)\n this.observerManager.removeObserver(token)\n }\n }\n\n private static finalizationRegistry = new FinalizationRegistry(Observer.finalize)\n\n private static finalize(observerManagerAndToken) {\n const { observerManager, token } = observerManagerAndToken\n observerManager.removeObserver(token)\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { Pointer, FFIAuthClient } from './ffi.js'\n\nimport type { Ditto } from './ditto.js'\nimport { Logger } from './logger.js'\nimport { KeepAlive } from './keep-alive.js'\n\nimport { ObserverManager } from './observer-manager.js'\nimport { Observer } from './observer.js'\n\n// REFACTOR: get rid of the subclasses by merging into a single class plus\n// some conditional logic. The inheritance isn't worth it here.\n\n// -----------------------------------------------------------------------------\n\n/**\n * Provides info about the authentication status.\n */\nexport type AuthenticationStatus = {\n /**\n * Returns `true` if authenticated, otherwise returns `false`.\n */\n isAuthenticated: boolean\n\n /**\n * If authenticated, returns the `userID` if one was provided by the\n * authentication service. Otherwise returns `null`.\n */\n userID: string | null\n}\n\n/**\n * Provides feedback to the developer about Ditto authentication status.\n */\nexport interface AuthenticationHandler {\n /**\n * There is no Ditto authentication token or it has expired. Sync will not\n * work until there is a successful login using one of the login methods on\n * {@link Authenticator}.\n */\n authenticationRequired: (authenticator: Authenticator) => void\n\n /**\n * Warns that the Ditto authentication token is getting old.\n *\n * Ditto will attempt to refresh tokens periodically, starting from halfway\n * through the token's validity period. This reduces the risk of\n * authentication expiring while the user is offline.\n *\n * The refresh will happen automatically if Ditto has a suitable refresh\n * token. If new credentials are required, such as a third-party token or a\n * username/password, then Ditto does not cache that information and you must\n * submit it again using one of the `login` methods on {@link Authenticator}.\n */\n authenticationExpiringSoon: (authenticator: Authenticator, secondsRemaining: number) => void\n\n /**\n * Notifies the authentication handler that the authentication status did\n * change. Use the `authenticator`s property `status` to query for the current\n * authentication status.\n *\n * This method is **optional**.\n */\n authenticationStatusDidChange?: (authenticator: Authenticator) => void\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Log in to a remote authentication service, using an\n * `OnlineWithAuthentication` or an `Online` identity.\n */\nexport class Authenticator {\n /**\n * Returns `true` if authentication is avaiable and the login methods can be\n * used, otherwise returns `false`. Currently, authentication is only\n * available if Ditto was initialized with an identity of type\n * {@link IdentityOnlineWithAuthentication | 'onlineWithAuthentication'}.\n */\n readonly loginSupported: boolean\n\n /**\n Returns the current authentication status.\n */\n readonly status: AuthenticationStatus\n\n /**\n * Log in to Ditto with a third-party token. Throws if authentication is not\n * available, which can be checked with {@link loginSupported}.\n *\n * @param token the authentication token required to log in.\n * @param provider the name of the authentication provider.\n */\n loginWithToken(token: string, provider: string): Promise<void> {\n throw new Error(`Authenticator.loginWithToken() is abstract and must be implemented by subclasses.`)\n }\n\n /**\n * Log in to Ditto with a username and password. Throws if authentication is\n * not available, which can be checked with {@link loginSupported}.\n *\n * @param username the username component of the credentials used for log in.\n * @param password the password component of the credentials used for log in.\n * @param provider the name of the authentication provider.\n */\n loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void> {\n throw new Error(`Authenticator.loginWithUsernameAndPassword() is abstract and must be implemented by subclasses.`)\n }\n\n /**\n * Log out of Ditto.\n *\n * This will stop sync, shut down all replication sessions, and remove any\n * cached authentication credentials. Note that this does not remove any data\n * from the store. If you wish to delete data from the store then use the\n * optional `cleanupFn` parameter to perform any required cleanup.\n *\n * @param cleanupFn An optional function that will be called with the relevant\n * [Ditto] instance as the sole argument that allows you to perform any\n * required cleanup of the store as part of the logout process.\n */\n logout(cleanupFn?: (Ditto) => void): Promise<void> {\n throw new Error(`Authenticator.logout() is abstract and must be implemented by subclasses.`)\n }\n\n /*\n * Registers a callback that is called whenever the authentication status\n * changes. Returns an `Observer` object that needs to be retained as long as\n * you want to receive the updates.\n */\n observeStatus(callback: (authenticationStatus: AuthenticationStatus) => void): Observer {\n const token = this.observerManager.addObserver(callback)\n return new Observer(this.observerManager, token, { stopsWhenFinalized: true })\n }\n\n /** @internal */\n constructor(keepAlive: KeepAlive) {\n this.keepAlive = keepAlive\n this.status = { isAuthenticated: false, userID: null }\n this.loginSupported = false\n this.observerManager = new ObserverManager('AuthenticationStatusObservation', { keepAlive })\n }\n\n /** @internal */\n '@ditto.authenticationExpiring'(number): void {\n throw new Error(`Authenticator['@ditto.authenticationExpiring']() is abstract and must be implemented by subclasses.`)\n }\n\n /** @internal */\n '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void {\n throw new Error(`Authenticator['@ditto.authClientValidityChanged']() is abstract and must be implemented by subclasses.`)\n }\n\n /** @internal */\n protected keepAlive: KeepAlive\n\n /** @internal */\n protected observerManager: ObserverManager\n}\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nexport class OnlineAuthenticator extends Authenticator {\n async loginWithToken(token: string, provider: string): Promise<void> {\n await FFI.dittoAuthClientLoginWithToken(this.authClientPointer, token, provider)\n }\n\n async loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void> {\n await FFI.dittoAuthClientLoginWithUsernameAndPassword(this.authClientPointer, username, password, provider)\n }\n\n async logout(cleanupFn?: (Ditto) => void): Promise<void> {\n const ditto = this.ditto.deref()\n if (ditto) {\n await FFI.dittoAuthClientLogout(this.authClientPointer)\n ditto.stopSync()\n cleanupFn?.(this.ditto)\n } else {\n Logger.warning('Unable to logout, related Ditto object does not exist anymore.')\n }\n }\n\n readonly authClientPointer: Pointer<FFIAuthClient>\n readonly authenticationHandler: AuthenticationHandler\n\n private ditto: WeakRef<Ditto>\n\n constructor(keepAlive: KeepAlive, authClientPointer: Pointer<FFIAuthClient>, ditto: Ditto, authenticationHandler: AuthenticationHandler) {\n super(keepAlive)\n this['loginSupported' as any] = true\n this['status' as any] = { isAuthenticated: false, userID: null }\n this.authClientPointer = authClientPointer\n this.ditto = new WeakRef<Ditto>(ditto)\n this.authenticationHandler = authenticationHandler\n this.updateAndNotify(false)\n\n // NOTE: The ownership of the auth client is transferred to us (from Ditto),\n // so we have to free the auth client once this instance is garbage\n // collected.\n OnlineAuthenticator.finalizationRegistry.register(this, authClientPointer)\n }\n\n '@ditto.authenticationExpiring'(secondsRemaining: number): void {\n const authenticationHandler = this.authenticationHandler\n if (secondsRemaining > 0) {\n authenticationHandler.authenticationExpiringSoon(this, secondsRemaining)\n } else {\n authenticationHandler.authenticationRequired(this)\n }\n }\n\n '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void {\n this.updateAndNotify(true)\n }\n\n private updateAndNotify(shouldNotify: boolean) {\n const wasAuthenticated = this.status.isAuthenticated\n const previousUserID = this.status.userID\n\n const isAuthenticated = FFI.dittoAuthClientIsWebValid(this.authClientPointer)\n const userID = FFI.dittoAuthClientUserID(this.authClientPointer)\n const status = { isAuthenticated, userID }\n\n this['status' as any] = status\n\n if (shouldNotify) {\n const sameStatus = !!wasAuthenticated === !!isAuthenticated && previousUserID === userID\n if (!sameStatus) {\n this.authenticationHandler.authenticationStatusDidChange?.call(this.authenticationHandler, this)\n this.observerManager.notify(status)\n }\n }\n }\n\n private static finalizationRegistry = new FinalizationRegistry(OnlineAuthenticator.finalize)\n\n private static finalize(authClientPointer) {\n FFI.dittoAuthClientFree(authClientPointer)\n }\n}\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nexport class NotAvailableAuthenticator extends Authenticator {\n async loginWithToken(token: string, provider: string): Promise<void> {\n throw new Error(`Can't login, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)\n }\n\n async loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void> {\n throw new Error(`Can't login, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)\n }\n\n logout(cleanupFn?: (Ditto) => void): Promise<void> {\n throw new Error(`Can't logout, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)\n }\n\n '@ditto.authenticationExpiring'(secondsRemaining) {\n throw new Error(`Internal inconsistency, authentication is not available, yet the @ditto.authenticationExpiring() was called on authenticator: ${this}`)\n }\n\n '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void {\n throw new Error(`Internal inconsistency, authentication is not available, yet the @ditto.authClientValidityChanged() was called on authenticator: ${this}`)\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport type { AuthenticationHandler } from './authenticator.js'\n\n/**\n * An identity to be used while in development when you want to control the app\n * name and the site ID of the peer.\n */\nexport interface IdentityOfflinePlayground {\n type: 'offlinePlayground'\n\n /**\n * The app ID for the Ditto instance.\n */\n appID: string\n\n /**\n * The `siteID` needs to be an unsigned 64 bit integer >= 0, i.e. either a\n * regular non-fractional `number` or a `BigInt` in the range between 0 and\n * 2^64 - 1 (inclusive). If `siteID` is `0`, Ditto will generate an\n * appropriate site ID and persist it when needed. Default is `0`.\n */\n siteID?: number | BigInt\n}\n\n/**\n * An identity with intermediate level of security where all users and devices\n * are trusted and a single shared secret (key) between all peers satisfies the\n * security requirements.\n *\n * **NOTE**: This identity type is only supported for Node environments, using\n * this to create a Ditto instance in the web browser will throw an exception.\n */\nexport interface IdentitySharedKey {\n type: 'sharedKey'\n\n /**\n * The app ID for the Ditto instance.\n */\n appID: string\n\n /**\n * The `siteID` needs to be an unsigned 64 bit integer >= 0, i.e. either a\n * regular non-fractional `number` or a `BigInt` in the range between 0 and\n * 2^64 - 1 (inclusive). If `siteID` is `0`, Ditto will generate an\n * appropriate site ID and persist it when needed. Default is `0`.\n */\n siteID?: number | BigInt\n\n /**\n * A base64 encoded DER representation of a private key, which is shared\n * between devices for a single app.\n */\n sharedKey: string\n}\n\n/**\n * A manually-provided certificate identity. This accepts a\n * base64-encoded bundle.\n */\nexport interface IdentityManual {\n type: 'manual'\n certificate: string\n}\n\n/**\n * Test a Ditto Cloud app with weak shared token authentication (\"Playground\n * mode\"). This mode is not secure and must only be used for development.\n */\nexport interface IdentityOnlinePlayground {\n type: 'onlinePlayground'\n\n /**\n * An ID identifying this app registration on the Ditto portal, which can be\n * found at https://portal.ditto.live.\n */\n appID: string\n\n /**\n * A shared token used to set up the OnlinePlayground session. This token is\n * provided by the Ditto Portal when setting up the application.\n */\n token: string\n\n /** If true, auto-configure sync with Ditto Cloud. Default is `true`. */\n enableDittoCloudSync?: boolean\n\n /**\n * If specified, use a custom authentication service instead of Ditto Cloud.\n * @internal\n */\n customAuthURL?: string\n\n /**\n * A custom Ditto Cloud URL.\n * @internal\n */\n customDittoCloudURL?: string\n}\n\n/**\n * Run Ditto in secure production mode, logging on to Ditto Cloud or an\n * on-premises authentication server. User permissions are centrally managed.\n * Sync will not work until a successful login has occurred.\n *\n * The only required configuration is the application's UUID, which can be found\n * on the Ditto portal where the app is registered.\n *\n * By default cloud sync is enabled. This means the SDK will sync to a Big Peer\n * in Ditto's cloud when an internet connection is available. This is controlled\n * by the `enableCloudSync` parameter. If `true` (default), a suitable wss://\n * URL will be added to the `TransportConfig`. To prevent cloud sync, or to\n * specify your own URL later, pass `false`.\n *\n * Authentication requests are handled by Ditto's cloud by default, configured\n * in the portal at https://portal.ditto.live.\n *\n * To use a different or on-premises authentication service, pass a custom HTTPS\n * base URL as the `customAuthUrl` parameter.\n */\nexport interface IdentityOnlineWithAuthentication {\n type: 'onlineWithAuthentication'\n\n /**\n * An ID identifying this app registration on the Ditto portal, which can be\n * found at https://portal.ditto.live.\n */\n appID: string\n\n /**\n * If true, auto-configure sync with Ditto Cloud. Default is `true`.\n */\n enableDittoCloudSync?: boolean\n\n /**\n * A handler for when Ditto requires (re)authentication.\n */\n authHandler: AuthenticationHandler\n\n /**\n * If specified, use a custom authentication service instead of Ditto Cloud.\n */\n customAuthURL?: string\n\n /**\n * A custom Ditto Cloud URL.\n * @internal\n */\n customDittoCloudURL?: string\n}\n\n/**\n * The various identity configurations that you can use when initializing a\n * `Ditto` instance.\n */\nexport type Identity = IdentityOfflinePlayground | IdentitySharedKey | IdentityManual | IdentityOnlinePlayground | IdentityOnlineWithAuthentication\n\n/** The list of identity types that require activation through an offlineLicenseToken */\nexport const IdentityTypesRequiringOfflineLicenseToken = ['manual', 'sharedKey', 'offlinePlayground']\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n/**\n * Part of {@link TransportConfig} type, configuration for listening for TCP\n * connections.\n */\nexport interface TransportConfigListenTCP {\n isEnabled: boolean\n interfaceIP: string\n port: number\n}\n\n/**\n * Part of {@link TransportConfig} type, configuration for listening for HTTP,\n * including Websocket, connections.\n */\nexport interface TransportConfigListenHTTP {\n isEnabled: boolean\n interfaceIP: string\n port: number\n staticContentPath?: string\n websocketSync: boolean\n tlsKeyPath?: string\n tlsCertificatePath?: string\n}\n\n/**\n * Part of {@link TransportConfig} type, configuration for all P2P transports.\n */\nexport interface TransportConfigPeerToPeer {\n bluetoothLE: { isEnabled: boolean }\n awdl: { isEnabled: boolean }\n lan: TransportConfigLan\n}\n\n/**\n * Part of {@link TransportConfig} type, configuration for discovering and syncing with peers on LAN.\n */\nexport interface TransportConfigLan {\n isEnabled: boolean\n isMdnsEnabled: boolean\n isMulticastEnabled: boolean\n}\n\n/**\n * Part of {@link TransportConfig} type, configuration for connecting to TCP\n * and Websocket servers.\n */\nexport interface TransportConfigConnect {\n tcpServers: string[]\n websocketURLs: string[]\n}\n\n/**\n * Part of {@link TransportConfig} type, configuration for listening for\n * incoming TCP and HTTP connections.\n */\nexport interface TransportConfigListen {\n tcp: TransportConfigListenTCP\n http: TransportConfigListenHTTP\n}\n\nconst NO_PREFERRED_ROUTE_HINT = 0\n\n/**\n * Part of {@link TransportConfig} type, settings not associated with any specific type of transport.\n */\nexport interface TransportConfigGlobal {\n /**\n * The sync group for this device.\n *\n * When peer-to-peer transports are enabled, all devices with the same App ID will\n * normally form an interconnected mesh network. In some situations it may be\n * desirable to have distinct groups of devices within the same app, so that\n * connections will only be formed within each group. The `syncGroup` parameter\n * changes that group membership. A device can only ever be in one sync group, which\n * by default is group 0. Up to 2^32 distinct group numbers can be used in an app.\n *\n * This is an optimization, not a security control. If a connection is created\n * manually, such as by specifying a `connect` transport, then devices from\n * different sync groups will still sync as normal. If two groups of devices are\n * intended to have access to different data sets, this must be enforced using\n * Ditto's permissions system.\n */\n syncGroup: number\n\n /**\n * The routing hint for this device.\n *\n * A routing hint is a performance tuning option which can improve the performance of\n * applications that use large collections. Ditto will make a best effort to co-locate data for\n * the same routing key. In most circumstances, this should substantially improve responsiveness\n * of the Ditto Cloud.\n *\n * The value of the routing hint is application specific - you are free to chose any value.\n * Devices which you expect to operate on much the same data should be configured to\n * use the same value.\n *\n * A routing hint does not partition data. The value of the routing hint will not affect the data\n * returned for a query. The routing hint only improves the efficiency of the Cloud's\n * ability to satisfy the query.\n */\n routingHint: number\n}\n\n/**\n * A configuration object specifying which network transports Ditto should\n * use to sync data.\n *\n * A Ditto object comes with a default transport configuration where all\n * available peer-to-peer transports are enabled. You can customize this by\n * copying that or initializing a new `TransportConfig`, adjusting its\n * properties, and supplying it to `setTransportConfig()` on `Ditto`.\n *\n * When you initialize a new `TransportConfig` instance, all transports are\n * disabled. You must enable each one explicitly.\n *\n * Peer-to-peer transports will automatically discover peers in the vicinity\n * and create connections without any configuration. These are configured via\n * the `peerToPeer` property. To turn each one on, set its `isEnabled` property\n * to `true`.\n *\n * To connect to a peer at a known location, such as a Ditto Big Peer, add its\n * address inside the connect configuration. These are either \"host:port\"\n * strings for raw TCP sync, or a \"wss://…\" URL for websockets.\n *\n * The listen configurations are for specific less common data sync scenarios.\n * Please read the documentation on the Ditto website for examples. Incorrect\n * use of listen can result in insecure configurations.\n *\n * **IMPORTANT**: when running in the browser, only the `connect.websocketURLs`\n * part is considered, the rest of the configuration is ignored.\n */\nexport class TransportConfig {\n /** Configuration for peer-to-peer connections. */\n readonly peerToPeer: TransportConfigPeerToPeer\n\n /** Configuration for connecting to servers. */\n readonly connect: TransportConfigConnect\n\n /** Configuration for listening for incomping connections. */\n readonly listen: TransportConfigListen\n\n /** Settings not associated with any specific type of transport. */\n readonly global: TransportConfigGlobal\n\n /**\n * Create a new transport config initialized with the default settings.\n */\n constructor() {\n this.peerToPeer = {\n bluetoothLE: { isEnabled: false },\n awdl: { isEnabled: false },\n lan: { isEnabled: false, isMdnsEnabled: true, isMulticastEnabled: true },\n }\n\n this.connect = {\n tcpServers: [],\n websocketURLs: [],\n }\n\n this.listen = {\n tcp: {\n isEnabled: false,\n interfaceIP: '0.0.0.0',\n port: 4040,\n },\n\n http: {\n isEnabled: false,\n interfaceIP: '0.0.0.0',\n port: 80,\n websocketSync: true,\n },\n }\n\n this.global = {\n syncGroup: 0,\n routingHint: NO_PREFERRED_ROUTE_HINT,\n }\n }\n\n /**\n * Enables all peer-to-peer transports. Throws if receiver is frozen.\n */\n setAllPeerToPeerEnabled(enabled: boolean) {\n this.peerToPeer.bluetoothLE.isEnabled = enabled\n this.peerToPeer.lan.isEnabled = enabled\n this.peerToPeer.awdl.isEnabled = enabled\n }\n\n /**\n * Returns `true` if the transport configuration is frozen, otherwise\n * returns `false`.\n */\n readonly isFrozen: boolean\n\n /**\n * (Deep) freezes the receiver such that it can't be modified anymore.\n */\n freeze(): TransportConfig {\n if (this.isFrozen) return this\n this['isFrozen' as any] = true\n\n Object.freeze(this.peerToPeer.bluetoothLE)\n Object.freeze(this.peerToPeer.awdl)\n Object.freeze(this.peerToPeer.lan)\n Object.freeze(this.peerToPeer)\n\n Object.freeze(this.connect.tcpServers)\n Object.freeze(this.connect.websocketURLs)\n Object.freeze(this.connect)\n\n Object.freeze(this.listen.tcp)\n Object.freeze(this.listen.http)\n Object.freeze(this.listen)\n\n Object.freeze(this.global)\n\n return this\n }\n\n /**\n * Returns a (deep) copy of the receiver.\n */\n copy(): TransportConfig {\n const copy = new TransportConfig()\n\n copy.peerToPeer.bluetoothLE.isEnabled = this.peerToPeer.bluetoothLE.isEnabled\n copy.peerToPeer.awdl.isEnabled = this.peerToPeer.awdl.isEnabled\n copy.peerToPeer.lan.isEnabled = this.peerToPeer.lan.isEnabled\n copy.peerToPeer.lan.isMdnsEnabled = this.peerToPeer.lan.isMdnsEnabled\n copy.peerToPeer.lan.isMulticastEnabled = this.peerToPeer.lan.isMulticastEnabled\n\n copy.connect.tcpServers = this.connect.tcpServers.slice()\n copy.connect.websocketURLs = this.connect.websocketURLs.slice()\n\n copy.listen['tcp' as any] = { ...this.listen.tcp }\n copy.listen['http' as any] = { ...this.listen.http }\n\n copy.global.syncGroup = this.global.syncGroup\n copy.global.routingHint = this.global.routingHint\n\n return copy\n }\n\n /**\n * Returns `true` if passed in TCP configurations are equal, otherwise\n * returns `false`.\n */\n static areListenTCPsEqual(left: TransportConfigListenTCP, right: TransportConfigListenTCP): boolean {\n /* eslint-disable */\n return (\n left.isEnabled === right.isEnabled &&\n left.interfaceIP === right.interfaceIP &&\n left.port === right.port\n )\n /* eslint-enable */\n }\n\n /**\n * Returns `true` if passed in HTTP configurations are equal, otherwise\n * returns `false`.\n */\n static areListenHTTPsEqual(left: TransportConfigListenHTTP, right: TransportConfigListenHTTP): boolean {\n /* eslint-disable */\n return (\n left.isEnabled === right.isEnabled &&\n left.interfaceIP === right.interfaceIP &&\n left.port === right.port &&\n\n left.staticContentPath === right.staticContentPath &&\n left.websocketSync === right.websocketSync &&\n left.tlsKeyPath === right.tlsKeyPath &&\n left.tlsCertificatePath === right.tlsCertificatePath\n )\n /* eslint-enable */\n }\n}\n","/** @hidden */\nconst POW_2_24 = 5.960464477539063e-8;\n/** @hidden */\nconst POW_2_32 = 4294967296;\n/** @hidden */\nconst POW_2_53 = 9007199254740992;\n/** @hidden */\nconst DECODE_CHUNK_SIZE = 8192;\n/** @hidden */\nfunction objectIs(x, y) {\n if (typeof Object.is === 'function')\n return Object.is(x, y);\n // SameValue algorithm\n // Steps 1-5, 7-10\n if (x === y) {\n // Steps 6.b-6.e: +0 != -0\n return x !== 0 || 1 / x === 1 / y;\n }\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n}\n/** Convenience class for structuring a tagged value. */\nexport class TaggedValue {\n constructor(value, tag) {\n this.value = value;\n this.tag = tag;\n }\n}\n/** Convenience class for structuring a simple value. */\nexport class SimpleValue {\n constructor(value) {\n this.value = value;\n }\n}\n/**\n * Converts a Concise Binary Object Representation (CBOR) buffer into an object.\n * @param {ArrayBuffer|SharedArrayBuffer} data - A valid CBOR buffer.\n * @param {Function} [tagger] - A function that extracts tagged values. This function is called for each member of the object.\n * @param {Function} [simpleValue] - A function that extracts simple values. This function is called for each member of the object.\n * @returns {any} The CBOR buffer converted to a JavaScript value.\n */\nexport function decode(data, tagger, simpleValue) {\n let dataView = new DataView(data);\n let ta = new Uint8Array(data);\n let offset = 0;\n let tagValueFunction = function (value, tag) {\n return new TaggedValue(value, tag);\n };\n let simpleValFunction = function (value) {\n return undefined;\n };\n if (typeof tagger === 'function')\n tagValueFunction = tagger;\n if (typeof simpleValue === 'function')\n simpleValFunction = simpleValue;\n function commitRead(length, value) {\n offset += length;\n return value;\n }\n function readArrayBuffer(length) {\n return commitRead(length, new Uint8Array(data, offset, length));\n }\n function readFloat16() {\n let tempArrayBuffer = new ArrayBuffer(4);\n let tempDataView = new DataView(tempArrayBuffer);\n let value = readUint16();\n let sign = value & 0x8000;\n let exponent = value & 0x7c00;\n let fraction = value & 0x03ff;\n if (exponent === 0x7c00)\n exponent = 0xff << 10;\n else if (exponent !== 0)\n exponent += (127 - 15) << 10;\n else if (fraction !== 0)\n return (sign ? -1 : 1) * fraction * POW_2_24;\n tempDataView.setUint32(0, (sign << 16) | (exponent << 13) | (fraction << 13));\n return tempDataView.getFloat32(0);\n }\n function readFloat32() {\n return commitRead(4, dataView.getFloat32(offset));\n }\n function readFloat64() {\n return commitRead(8, dataView.getFloat64(offset));\n }\n function readUint8() {\n return commitRead(1, ta[offset]);\n }\n function readUint16() {\n return commitRead(2, dataView.getUint16(offset));\n }\n function readUint32() {\n return commitRead(4, dataView.getUint32(offset));\n }\n function readUint64() {\n return readUint32() * POW_2_32 + readUint32();\n }\n function readBreak() {\n if (ta[offset] !== 0xff)\n return false;\n offset += 1;\n return true;\n }\n function readLength(additionalInformation) {\n if (additionalInformation < 24)\n return additionalInformation;\n if (additionalInformation === 24)\n return readUint8();\n if (additionalInformation === 25)\n return readUint16();\n if (additionalInformation === 26)\n return readUint32();\n if (additionalInformation === 27)\n return readUint64();\n if (additionalInformation === 31)\n return -1;\n throw new Error('Invalid length encoding');\n }\n function readIndefiniteStringLength(majorType) {\n let initialByte = readUint8();\n if (initialByte === 0xff)\n return -1;\n let length = readLength(initialByte & 0x1f);\n if (length < 0 || initialByte >> 5 !== majorType)\n throw new Error('Invalid indefinite length element');\n return length;\n }\n function appendUtf16Data(utf16data, length) {\n for (let i = 0; i < length; ++i) {\n let value = readUint8();\n if (value & 0x80) {\n if (value < 0xe0) {\n value = ((value & 0x1f) << 6) | (readUint8() & 0x3f);\n length -= 1;\n }\n else if (value < 0xf0) {\n value = ((value & 0x0f) << 12) | ((readUint8() & 0x3f) << 6) | (readUint8() & 0x3f);\n length -= 2;\n }\n else {\n value =\n ((value & 0x0f) << 18) | ((readUint8() & 0x3f) << 12) | ((readUint8() & 0x3f) << 6) | (readUint8() & 0x3f);\n length -= 3;\n }\n }\n if (value < 0x10000) {\n utf16data.push(value);\n }\n else {\n value -= 0x10000;\n utf16data.push(0xd800 | (value >> 10));\n utf16data.push(0xdc00 | (value & 0x3ff));\n }\n }\n }\n function decodeItem() {\n let initialByte = readUint8();\n let majorType = initialByte >> 5;\n let additionalInformation = initialByte & 0x1f;\n let i;\n let length;\n if (majorType === 7) {\n switch (additionalInformation) {\n case 25:\n return readFloat16();\n case 26:\n return readFloat32();\n case 27:\n return readFloat64();\n }\n }\n length = readLength(additionalInformation);\n if (length < 0 && (majorType < 2 || 6 < majorType))\n throw new Error('Invalid length');\n switch (majorType) {\n case 0:\n return length;\n case 1:\n return -1 - length;\n case 2:\n if (length < 0) {\n let elements = [];\n let fullArrayLength = 0;\n while ((length = readIndefiniteStringLength(majorType)) >= 0) {\n fullArrayLength += length;\n elements.push(readArrayBuffer(length));\n }\n let fullArray = new Uint8Array(fullArrayLength);\n let fullArrayOffset = 0;\n for (i = 0; i < elements.length; ++i) {\n fullArray.set(elements[i], fullArrayOffset);\n fullArrayOffset += elements[i].length;\n }\n return fullArray;\n }\n return readArrayBuffer(length);\n case 3:\n let utf16data = [];\n if (length < 0) {\n while ((length = readIndefiniteStringLength(majorType)) >= 0)\n appendUtf16Data(utf16data, length);\n }\n else {\n appendUtf16Data(utf16data, length);\n }\n let string = '';\n for (i = 0; i < utf16data.length; i += DECODE_CHUNK_SIZE) {\n string += String.fromCharCode.apply(null, utf16data.slice(i, i + DECODE_CHUNK_SIZE));\n }\n return string;\n case 4:\n let retArray;\n if (length < 0) {\n retArray = [];\n while (!readBreak())\n retArray.push(decodeItem());\n }\n else {\n retArray = new Array(length);\n for (i = 0; i < length; ++i)\n retArray[i] = decodeItem();\n }\n return retArray;\n case 5:\n let retObject = {};\n for (i = 0; i < length || (length < 0 && !readBreak()); ++i) {\n let key = decodeItem();\n retObject[key] = decodeItem();\n }\n return retObject;\n case 6:\n return tagValueFunction(decodeItem(), length);\n case 7:\n switch (length) {\n case 20:\n return false;\n case 21:\n return true;\n case 22:\n return null;\n case 23:\n return undefined;\n default:\n return simpleValFunction(length);\n }\n }\n }\n let ret = decodeItem();\n if (offset !== data.byteLength)\n throw new Error('Remaining bytes');\n return ret;\n}\n/**\n * Converts a JavaScript value to a Concise Binary Object Representation (CBOR) buffer.\n * @param {any} value - A JavaScript value, usually an object or array, to be converted.\n * @returns {ArrayBuffer} The JavaScript value converted to CBOR format.\n */\nexport function encode(value) {\n let data = new ArrayBuffer(256);\n let dataView = new DataView(data);\n let byteView = new Uint8Array(data);\n let lastLength;\n let offset = 0;\n function prepareWrite(length) {\n let newByteLength = data.byteLength;\n let requiredLength = offset + length;\n while (newByteLength < requiredLength)\n newByteLength <<= 1;\n if (newByteLength !== data.byteLength) {\n let oldDataView = dataView;\n data = new ArrayBuffer(newByteLength);\n dataView = new DataView(data);\n byteView = new Uint8Array(data);\n let uint32count = (offset + 3) >> 2;\n for (let i = 0; i < uint32count; ++i)\n dataView.setUint32(i << 2, oldDataView.getUint32(i << 2));\n }\n lastLength = length;\n return dataView;\n }\n function commitWrite(...args) {\n offset += lastLength;\n }\n function writeFloat64(val) {\n commitWrite(prepareWrite(8).setFloat64(offset, val));\n }\n function writeUint8(val) {\n commitWrite(prepareWrite(1).setUint8(offset, val));\n }\n function writeUint8Array(val) {\n prepareWrite(val.length);\n byteView.set(val, offset);\n commitWrite();\n }\n function writeUint16(val) {\n commitWrite(prepareWrite(2).setUint16(offset, val));\n }\n function writeUint32(val) {\n commitWrite(prepareWrite(4).setUint32(offset, val));\n }\n function writeUint64(val) {\n let low = val % POW_2_32;\n let high = (val - low) / POW_2_32;\n let view = prepareWrite(8);\n view.setUint32(offset, high);\n view.setUint32(offset + 4, low);\n commitWrite();\n }\n function writeVarUint(val, mod) {\n if (val <= 0xff) {\n if (val < 24) {\n writeUint8(val | mod);\n }\n else {\n writeUint8(0x18 | mod);\n writeUint8(val);\n }\n }\n else if (val <= 0xffff) {\n writeUint8(0x19 | mod);\n writeUint16(val);\n }\n else if (val <= 0xffffffff) {\n writeUint8(0x1a | mod);\n writeUint32(val);\n }\n else {\n writeUint8(0x1b | mod);\n writeUint64(val);\n }\n }\n function writeTypeAndLength(type, length) {\n if (length < 24) {\n writeUint8((type << 5) | length);\n }\n else if (length < 0x100) {\n writeUint8((type << 5) | 24);\n writeUint8(length);\n }\n else if (length < 0x10000) {\n writeUint8((type << 5) | 25);\n writeUint16(length);\n }\n else if (length < 0x100000000) {\n writeUint8((type << 5) | 26);\n writeUint32(length);\n }\n else {\n writeUint8((type << 5) | 27);\n writeUint64(length);\n }\n }\n function encodeItem(val) {\n let i;\n if (val === false)\n return writeUint8(0xf4);\n if (val === true)\n return writeUint8(0xf5);\n if (val === null)\n return writeUint8(0xf6);\n if (val === undefined)\n return writeUint8(0xf7);\n if (objectIs(val, -0))\n return writeUint8Array([0xf9, 0x80, 0x00]);\n switch (typeof val) {\n case 'number':\n if (Math.floor(val) === val) {\n if (0 <= val && val <= POW_2_53)\n return writeTypeAndLength(0, val);\n if (-POW_2_53 <= val && val < 0)\n return writeTypeAndLength(1, -(val + 1));\n }\n writeUint8(0xfb);\n return writeFloat64(val);\n case 'string':\n let utf8data = [];\n for (i = 0; i < val.length; ++i) {\n let charCode = val.charCodeAt(i);\n if (charCode < 0x80) {\n utf8data.push(charCode);\n }\n else if (charCode < 0x800) {\n utf8data.push(0xc0 | (charCode >> 6));\n utf8data.push(0x80 | (charCode & 0x3f));\n }\n else if (charCode < 0xd800 || charCode >= 0xe000) {\n utf8data.push(0xe0 | (charCode >> 12));\n utf8data.push(0x80 | ((charCode >> 6) & 0x3f));\n utf8data.push(0x80 | (charCode & 0x3f));\n }\n else {\n charCode = (charCode & 0x3ff) << 10;\n charCode |= val.charCodeAt(++i) & 0x3ff;\n charCode += 0x10000;\n utf8data.push(0xf0 | (charCode >> 18));\n utf8data.push(0x80 | ((charCode >> 12) & 0x3f));\n utf8data.push(0x80 | ((charCode >> 6) & 0x3f));\n utf8data.push(0x80 | (charCode & 0x3f));\n }\n }\n writeTypeAndLength(3, utf8data.length);\n return writeUint8Array(utf8data);\n default:\n let length;\n let converted;\n if (Array.isArray(val)) {\n length = val.length;\n writeTypeAndLength(4, length);\n for (i = 0; i < length; i += 1)\n encodeItem(val[i]);\n }\n else if (val instanceof Uint8Array) {\n writeTypeAndLength(2, val.length);\n writeUint8Array(val);\n }\n else if (ArrayBuffer.isView(val)) {\n converted = new Uint8Array(val.buffer);\n writeTypeAndLength(2, converted.length);\n writeUint8Array(converted);\n }\n else if (val instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer === 'function' && val instanceof SharedArrayBuffer)) {\n converted = new Uint8Array(val);\n writeTypeAndLength(2, converted.length);\n writeUint8Array(converted);\n }\n else if (val instanceof TaggedValue) {\n writeVarUint(val.tag, 0b11000000);\n encodeItem(val.value);\n }\n else {\n let keys = Object.keys(val);\n length = keys.length;\n writeTypeAndLength(5, length);\n for (i = 0; i < length; i += 1) {\n let key = keys[i];\n encodeItem(key);\n encodeItem(val[key]);\n }\n }\n }\n }\n encodeItem(value);\n if ('slice' in data)\n return data.slice(0, offset);\n let ret = new ArrayBuffer(offset);\n let retView = new DataView(ret);\n for (let i = 0; i < offset; ++i)\n retView.setUint8(i, dataView.getUint8(i));\n return ret;\n}\n/**\n * An intrinsic object that provides functions to convert JavaScript values\n * to and from the Concise Binary Object Representation (CBOR) format.\n */\nexport const CBOR = {\n decode,\n encode\n};\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport { CBOR as CBORRedux } from './@cbor-redux.js'\n\n/** @internal */\nexport class CBOR {\n /** @internal */\n static encode(data: any): Uint8Array {\n const arrayBuffer = CBORRedux.encode(data)\n return new Uint8Array(arrayBuffer)\n }\n\n /** @internal */\n static decode(data: Uint8Array): any {\n const arrayBuffer = data.buffer\n return CBORRedux.decode(arrayBuffer)\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { CBOR } from './cbor.js'\n\n/** Represents a unique identifier for a {@link Document}. */\nexport type DocumentIDValue = any // REFACTOR: get rid of any.\n\n/** Represents a unique identifier for a {@link Document}. */\nexport class DocumentID {\n /**\n * Returns the value of the receiver, lazily decoded from its CBOR\n * representation if needed.\n */\n get value(): any {\n let value = this['@ditto.value']\n if (typeof value === 'undefined') {\n value = CBOR.decode(this['@ditto.cbor'])\n this['@ditto.value'] = value\n }\n return value\n }\n\n /**\n * Returns `false` if validation has been skipped at construction time,\n * otherwise returns `true`. This is mostly for internal use only, you\n * shouldn't need this in client code.\n */\n readonly isValidated: boolean\n\n /**\n * Creates a new `DocumentID`.\n *\n * A document ID can be created from any of the following:\n *\n * - `string`\n * - `number` (integer)\n * - `boolean`\n * - `null`\n * - raw data in the form of a JS [Typed Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays)\n * - `Array` (containing any of the items in this list)\n * - Map (a raw JS `object`, where the keys must be strings and the values\n * can be made up of any of the items in this list)\n *\n * Note that you cannot use floats or other custom types to create a document\n * ID.\n *\n * Document IDs are also limited in size, based on their serialized\n * representation, to 256 bytes. You will receive an error if you try to\n * create a document ID that exceeds the size limit.\n *\n * @param value The value that represents the document identifier.\n * @param skipCBOREncoding If `true, skips CBOR encoding and assumes\n * the passed in `value` is already CBOR encoded. You shouldn't need to ever\n * pass this parameter, it's only used internally for certain edge cases.\n * @param skipValidation If `true, skips validation of the passed in value or\n * CBOR. You shouldn't need to ever pass this parameter, it's only used\n * internally for certain edge cases.\n */\n constructor(value: any, skipCBOREncoding: boolean = false, skipValidation: boolean = false) {\n const cbor = skipCBOREncoding ? value : CBOR.encode(value)\n const validatedCBOR = skipValidation ? cbor : validateDocumentIDCBOR(cbor)\n\n if (!validatedCBOR) {\n throw new Error(`Can't create DocumentID, passed in value is not valid: ${value}`)\n }\n\n this.isValidated = !skipValidation\n this['@ditto.cbor'] = validatedCBOR\n }\n\n /**\n * Returns `true` if passed in `documentID` is equal to the receiver,\n * otherwise returns `false`.\n */\n equals(documentID: DocumentID): boolean {\n const left = this['@ditto.cbor']\n const right = documentID['@ditto.cbor']\n\n if (left === right) {\n return true\n }\n\n if (!(left instanceof Uint8Array)) {\n return false\n }\n\n if (!(right instanceof Uint8Array)) {\n return false\n }\n\n if (left.length !== right.length) {\n return false\n }\n\n for (let i = 0; i < left.length; i += 1) {\n if (left[i] !== right[i]) return false\n }\n\n return true\n }\n\n /**\n * Returns a string representation of the receiver.\n *\n * If you need a string representation to be used directly in a query,\n * please use `toQueryCompatibleString()` instead.\n */\n toString(): string {\n return FFI.documentIDQueryCompatible(this['@ditto.cbor'], 'WithoutQuotes')\n }\n\n /**\n * Returns a byte representation of the document ID value as base64 string.\n */\n toBase64String(): string {\n const bytes = this['@ditto.cbor']\n return btoa(String.fromCharCode.apply(null, bytes))\n }\n\n /**\n * Returns a query compatible string representation of the receiver.\n *\n * The returned string can be used directly in queries that you use with\n * other Ditto functions. For example you could create a query that was like\n * this:\n *\n * ``` TypeScript\n * collection.find(`_id == ${documentID.toQueryCompatibleString()}`)\n * ```\n */\n toQueryCompatibleString(): string {\n return FFI.documentIDQueryCompatible(this['@ditto.cbor'], 'WithQuotes')\n }\n\n /** @internal */\n toCBOR(): Uint8Array {\n return this['@ditto.cbor']\n }\n}\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nexport function validateDocumentIDValue(id: DocumentIDValue): DocumentIDValue {\n if (typeof id === 'undefined') {\n throw new Error(`Invalid document ID: ${id}`)\n }\n\n return id\n}\n\n/** @internal */\nexport function validateDocumentIDCBOR(idCBOR: Uint8Array): Uint8Array {\n const validatedIDCBOROrNull = FFI.validateDocumentID(idCBOR)\n return validatedIDCBOROrNull ?? idCBOR\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { Bridge } from './bridge.js'\nimport { dittoBridge } from './ditto.js'\n\nimport type { Ditto } from './ditto.js'\nimport type { AttachmentToken } from './attachment-token.js'\n\n/**\n * Represents an attachment and can be used to insert the associated attachment\n * into a document at a specific key-path. You can't instantiate an attachment\n * directly, please use the {@link Collection.newAttachment | newAttachment()}\n * method of {@link Collection} instead.\n */\nexport class Attachment {\n /** @internal */\n readonly ditto: Ditto\n\n /** @internal */\n readonly token: AttachmentToken\n\n /** The attachment's metadata. */\n get metadata(): { [key: string]: string } {\n return this.token.metadata\n }\n\n /**\n * Returns the attachment's data.\n */\n getData(): Promise<Uint8Array> {\n webBuildOnly: {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n const attachmentHandlePointer = attachmentBridge.pointerFor(this)\n return FFI.dittoGetCompleteAttachmentData(dittoPointer, attachmentHandlePointer)\n }\n\n nodeBuildOnly: {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n const attachmentHandlePointer = attachmentBridge.pointerFor(this)\n const attachmentPath = FFI.dittoGetCompleteAttachmentPath(dittoPointer, attachmentHandlePointer)\n const fs = require('fs/promises')\n return fs.readFile(attachmentPath)\n }\n }\n\n /**\n * Copies the attachment to the specified file path. Node-only,\n * throws in the browser.\n *\n * @param path The path that the attachment should be copied to.\n */\n copyToPath(path: string): Promise<void> {\n webBuildOnly: {\n throw new Error(`Can't copy attachment to path, not available when running in the browser.`)\n }\n\n nodeBuildOnly: {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n const attachmentHandlePointer = attachmentBridge.pointerFor(this)\n const attachmentPath = FFI.dittoGetCompleteAttachmentPath(dittoPointer, attachmentHandlePointer)\n const fs = require('fs/promises')\n // If the file already exists, we fail. This is the same behavior as\n // for the Swift/ObjC SDK.\n return fs.copyFile(attachmentPath, path, fs.COPYFILE_EXCL)\n }\n }\n\n /** @internal */\n constructor(ditto: Ditto, token: AttachmentToken) {\n this.ditto = ditto\n this.token = token\n }\n}\n\n/** @internal */\nexport const attachmentBridge = new Bridge<Attachment, FFI.AttachmentHandle>(Attachment, FFI.freeAttachmentHandle)\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\n/**\n * Serves as a token for a specific attachment that you can pass to a call to\n * {@link Collection.fetchAttachment | fetchAttachment()} on a\n * {@link Collection}.\n */\nexport class AttachmentToken {\n /** @internal */\n readonly id: Uint8Array\n\n /** @internal */\n readonly len: number\n\n /** @internal */\n readonly metadata: { [key: string]: string }\n\n /** @internal */\n constructor(jsObj: object) {\n const type = jsObj[FFI.DittoCRDTTypeKey]\n if (type !== FFI.DittoCRDTType.attachment) {\n throw new Error('Invalid attachment token')\n }\n\n const id = jsObj['_id']\n if (!(id instanceof Uint8Array)) {\n throw new Error('Invalid attachment token id')\n }\n\n const len = jsObj['_len']\n if (typeof len !== 'number' || len < 0) {\n throw new Error('Invalid attachment token length')\n }\n\n const meta = jsObj['_meta']\n if (typeof meta !== 'object') {\n throw new Error('Invalid attachment token meta')\n }\n\n this.id = id\n this.len = len\n this.metadata = meta\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport type { Ditto } from './ditto.js'\nimport { dittoBridge } from './ditto.js'\nimport { Attachment, attachmentBridge } from './attachment.js'\nimport { AttachmentToken } from './attachment-token.js'\nimport { AttachmentFetchEvent } from './attachment-fetch-event.js'\nimport { step } from './internal.js'\n\n/** @internal */\ntype AttachmentFetcherContextInfo = {\n ditto: Ditto\n attachmentTokenID: Uint8Array\n cancelTokenPromise: Promise<unknown | null>\n}\n\n/**\n * These objects are returned by calls to\n * {@link Collection.fetchAttachment | fetchAttachment()} on {@link Collection}\n * and allow you to stop an in-flight attachment fetch.\n */\nexport class AttachmentFetcher implements PromiseLike<Attachment | null> {\n /**\n * Returns a promise for the attachment that you can `await`. The promise\n * resolves to either an attachment or `null` if the attachment has been\n * deleted meanwhile. The promise is rejected if an error occurs during\n * the fetch. Note that the `AttachmentFetcher` itself implementes\n * `PromiseLike`, so you can `await` it directly.\n */\n readonly attachment: Promise<Attachment | null>\n\n /**\n * Stops fetching the associated attachment and cleans up any associated\n * resources.\n *\n * Note that you are not required to call `stop()` once your attachment fetch\n * operation has finished. The method primarily exists to allow you to cancel\n * an attachment fetch request while it is ongoing if you no longer wish for\n * the attachment to be made available locally to the device.\n */\n stop() {\n AttachmentFetcher.stopWithContextInfo({\n ditto: this.ditto,\n attachmentTokenID: this.token.id,\n cancelTokenPromise: this.cancelTokenPromise,\n })\n }\n\n /** @internal */\n then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {\n return this.attachment.then(onfulfilled, onrejected)\n }\n\n /** @internal */\n readonly ditto: Ditto\n\n /** @internal */\n readonly token: AttachmentToken\n\n /** @internal */\n readonly eventHandler: (attachmentFetchEvent: AttachmentFetchEvent) => void | null\n\n /** @internal */\n constructor(ditto: Ditto, token: AttachmentToken, eventHandler?: (attachmentFetchEvent: AttachmentFetchEvent) => void) {\n this.ditto = ditto\n this.token = token\n this.eventHandler = eventHandler || null\n this.cancelTokenPromise = null\n\n const eventHandlerOrNoOp = eventHandler || function () {}\n\n this.attachment = new Promise((resolve, reject) => {\n const dittoPointer = dittoBridge.pointerFor(ditto)\n // not awaited yet; only needs to be fully resolved (and `await`ed over)\n // when using the actual `cancelTokenPromise`, which only happens in `stop()`.\n this.cancelTokenPromise = FFI.dittoResolveAttachment(\n dittoPointer,\n token.id,\n {\n onComplete: (attachmentHandlePointer: FFI.Pointer<FFI.AttachmentHandle>) => {\n this['eventHandler' as any] = null\n this['cancelTokenPromise' as any] = null\n\n const attachment = new Attachment(this.ditto, this.token)\n attachmentBridge.bridge(attachmentHandlePointer, () => attachment, { throwIfAlreadyBridged: true })\n\n eventHandlerOrNoOp({ type: 'Completed', attachment })\n resolve(attachment)\n },\n\n onProgress: (downloaded: number | BigInt, toDownload: number | BigInt) => {\n eventHandlerOrNoOp({ type: 'Progress', totalBytes: toDownload, downloadedBytes: downloaded })\n },\n\n onDelete: () => {\n this['eventHandler' as any] = null\n this['cancelTokenPromise' as any] = null\n eventHandlerOrNoOp({ type: 'Deleted' })\n resolve(null)\n },\n },\n /* onError: */ (err) => {\n this['eventHandler' as any] = null\n this['cancelTokenPromise' as any] = null\n // REFACTOR: We simply throw this error at the moment. Maybe we should\n // bubble it up?\n reject(err)\n },\n )\n })\n\n const contextInfo: AttachmentFetcherContextInfo = {\n ditto: ditto,\n attachmentTokenID: token.id,\n cancelTokenPromise: this.cancelTokenPromise,\n }\n\n AttachmentFetcher.finalizationRegistry.register(this, contextInfo, contextInfo)\n }\n\n private cancelTokenPromise: Promise<unknown | null>\n\n private static finalizationRegistry = new FinalizationRegistry(AttachmentFetcher.stopWithContextInfo)\n\n private static stopWithContextInfo(contextInfo: AttachmentFetcherContextInfo) {\n // No need for synchronicity, here: we let the \"stop promise\", float / run\n // in a detached fashion since there is no point in awaiting the\n // \"stop signaling\" itself.\n step(async () => {\n // await the initial resolution of `FFI.dittoResolveAttachment` below.\n const cancelToken = await contextInfo.cancelTokenPromise\n if (cancelToken) {\n const dittoPointer = dittoBridge.pointerFor(contextInfo.ditto)\n FFI.dittoCancelResolveAttachment(dittoPointer, contextInfo.attachmentTokenID, cancelToken)\n }\n })\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { dittoBridge } from './ditto.js'\nimport { validateQuery } from './internal.js'\n\nimport type { Collection } from './collection.js'\nimport type { Ditto } from './ditto.js'\n\n/** @internal */\ntype SubscriptionContextInfo = {\n ditto: Ditto\n collectionName: string\n query: string\n queryArgsCBOR: Uint8Array | null\n orderBys: FFI.OrderBy[]\n limit: number\n offset: number\n}\n\n/**\n * Used to subscribe to receive updates from remote peers about matching\n * documents.\n *\n * While {@link Subscription} objects remain in scope they ensure that\n * documents in the collection specified and that match the query provided will\n * try to be kept up-to-date with the latest changes from remote peers.\n */\nexport class Subscription {\n /**\n * The query that the subscription is based on.\n */\n readonly query: string\n\n /**\n * Returns `true` if subscription has been explicitly cancelled, `false`\n * otherwise.\n */\n readonly isCancelled = false\n\n /**\n * The name of the collection that the subscription is based on.\n */\n get collectionName() {\n return this.collection.name\n }\n\n /**\n * Cancels a subscription and releases all associated resources.\n */\n cancel() {\n if (!this.isCancelled) {\n this['isCancelled' as any] = true\n Subscription.remove(this, this.contextInfo)\n }\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n constructor(collection: Collection, query: string, queryArgsCBOR: Uint8Array | null, orderBys: FFI.OrderBy[], limit: number, offset: number) {\n // Query should be validated at this point.\n this.query = query\n this.queryArgsCBOR = queryArgsCBOR\n this.collection = collection\n this.contextInfo = {\n ditto: collection.store.ditto,\n collectionName: collection.name,\n query,\n queryArgsCBOR,\n orderBys,\n limit,\n offset,\n }\n Subscription.add(this, this.contextInfo)\n }\n\n /**\n * The collection this subscription belongs to.\n * @internal Because not exposed in any of the other SDKs (yet?).\n */\n readonly collection: Collection\n\n /**\n * The corresponding named arguments for {@link query}, if any.\n * @internal Because not exposed in any of the other SDKs (yet?).\n */\n readonly queryArgsCBOR: Uint8Array | null\n\n private static finalizationRegistry = new FinalizationRegistry((contextInfo: SubscriptionContextInfo) => {\n Subscription.remove(null, contextInfo)\n })\n\n private static add(subscription: Subscription, contextInfo: SubscriptionContextInfo) {\n const dittoX = dittoBridge.pointerFor(contextInfo.ditto)\n FFI.addSubscription(dittoX, contextInfo.collectionName, contextInfo.query, contextInfo.queryArgsCBOR, contextInfo.orderBys, contextInfo.limit, contextInfo.offset)\n this.finalizationRegistry.register(subscription, contextInfo, contextInfo)\n }\n\n private static remove(subscription: Subscription | null, contextInfo: SubscriptionContextInfo) {\n const dittoX = dittoBridge.pointerFor(contextInfo.ditto)\n FFI.removeSubscription(dittoX, contextInfo.collectionName, contextInfo.query, contextInfo.queryArgsCBOR, contextInfo.orderBys, contextInfo.limit, contextInfo.offset)\n if (subscription) this.finalizationRegistry.unregister(contextInfo)\n }\n\n private contextInfo: SubscriptionContextInfo\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport { MutableDocument } from './document.js'\n\n// NOTE: we use a token to detect private invocation of the constructor. This is\n// not secure and just to prevent accidental private invocation on the client\n// side.\nconst privateToken = '@ditto.64d129224a5377b63e9727479ec987d9'\n\n/**\n * Represents a CRDT counter that can be upserted as part of a document or\n * assigned to a property during an update of a document.\n */\nexport class Counter {\n /** The value of the counter. */\n readonly value: number\n\n /**\n * Creates a new counter that can be used as part of a document's content.\n */\n constructor() {\n this.value = 0.0\n }\n\n /** @internal */\n static '@ditto.create'(mutDoc, path, value) {\n const counter = mutDoc ? new (MutableCounter as any)(privateToken) : new Counter()\n counter.mutDoc = mutDoc\n counter.path = path\n counter['value' as any] = value\n return counter\n }\n\n private mutDoc: any\n private path: any\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents a mutable CRDT counter that can be incremented by a specific\n * amount while updating a document.\n *\n * This class can't be instantiated directly, it's returned automatically for\n * any counter property within an update block via {@link MutableDocumentPath.counter}.\n */\nexport class MutableCounter extends Counter {\n /**\n * Increments the counter by `amount`, which can be any valid number.\n *\n * Only valid within the `update` closure of\n * {@link PendingCursorOperation.update | PendingCursorOperation.update()} and\n * {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},\n * otherwise an exception is thrown.\n */\n increment(amount: number) {\n const mutDoc = this['mutDoc' as any]\n const path = this['path' as any]\n\n if (!mutDoc) {\n throw new Error(`Can't increment counter, only possible within the closure of a collection's update() method.`)\n }\n\n mutDoc.at(path)['@ditto.increment'](amount)\n // We also increment the local value to make sure that the change is\n // reflected locally as well as in the underlying document\n this['value' as any] += amount\n }\n\n /** @internal */\n constructor() {\n if (arguments[0] === privateToken) {\n super()\n } else {\n throw new Error(`MutableCounter constructor is for internal use only.`)\n }\n }\n}\n","//\n// Copyright © 2022 DittoLive Incorporated. All rights reserved.\n//\n\nimport { MutableDocument } from './document.js'\n\n// NOTE: we use a token to detect private invocation of the constructor. This is\n// not secure and just to prevent accidental private invocation on the client\n// side.\nconst privateToken = '@ditto.ff82dae89821c5ab822a8b539056bce4'\n\n/**\n * Represents a CRDT register that can be upserted as part of a document or\n * assigned to a property during an update of a document.\n */\nexport class Register {\n /** Returns the value of the register. */\n get value(): any {\n return this['@ditto.value']\n }\n\n /**\n * Creates a new Register that can be used as part of a document's content.\n */\n constructor(value: any) {\n this['@ditto.value'] = value\n }\n\n /** @internal */\n static '@ditto.create'(mutableDocument, path, value) {\n const register = mutableDocument ? new (MutableRegister as any)(value, privateToken) : new Register(value)\n register['@ditto.mutableDocument'] = mutableDocument\n register['@ditto.path'] = path\n register['@ditto.value'] = value\n return register\n }\n\n /** @internal */\n protected '@ditto.mutableDocument': any\n\n /** @internal */\n protected '@ditto.path': any\n\n /** @internal */\n protected '@ditto.value': any\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents a mutable CRDT register that can be set to a specific value when\n * updating a document.\n *\n * This class can't be instantiated directly, it's returned automatically for\n * any register property of a document within an update block via {@link MutableDocumentPath.register}.\n */\nexport class MutableRegister extends Register {\n /** Returns the value of the register. */\n get value(): any {\n return super.value\n }\n\n /**\n * Convenience setter, equivalent to {@link set | set()}.\n */\n set value(value: any) {\n this.set(value)\n }\n\n /**\n * Sets the register to the provided value.\n *\n * Only valid within the `update` closure of\n * {@link PendingCursorOperation.update | PendingCursorOperation.update()} and\n * {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},\n * otherwise an exception is thrown.\n */\n set(value: any) {\n const mutableDocument = this['@ditto.mutableDocument']\n const path = this['@ditto.path']\n\n mutableDocument.at(path)['@ditto.set'](value)\n\n // We also set the local value to make sure that the change is\n // reflected locally as well as in the underlying document.\n this['@ditto.value'] = value\n }\n\n /** @internal */\n constructor(value: any) {\n if (arguments[1] === privateToken) {\n super(value)\n } else {\n throw new Error(`MutableRegister constructor is for internal use only.`)\n }\n }\n}\n","//\n// Copyright © 2022 DittoLive Incorporated. All rights reserved.\n//\n\n/**\n * Represents a CRDT Replicated Growable Array (RGA).\n *\n * RGAs are deprecated and you should instead use a `Register` containing an\n * array.\n */\nexport class RGA {\n /** The array representation of the RGA. */\n get value(): any[] {\n return this['@ditto.value']\n }\n\n /** @internal */\n private constructor(array: any[] = []) {\n this['@ditto.value'] = array\n }\n\n /** @internal */\n static '@ditto.create'(path, value) {\n const rga = new RGA(value)\n rga['@ditto.path'] = path\n rga['@ditto.value'] = value\n return rga\n }\n\n /** @internal */\n protected '@ditto.path': any\n\n /** @internal */\n protected '@ditto.value': any\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport type { DocumentID } from './document-id.js'\n\n/**\n * The types of an {@link UpdateResult}.\n */\nexport type UpdateResultType = 'set' | 'incremented' | 'removed'\n\n/*\n * Provides information about a successful update operation on a document.\n *\n * The update result can be one of the following types:\n * - `set`\n * - `removed`\n * - `incremented`\n */\nexport class UpdateResult {\n /** The update result's type. */\n readonly type: UpdateResultType\n\n /** The ID of the document that was updated. */\n readonly docID: DocumentID\n\n /** The path to the key in the document that was updated. */\n readonly path: string\n\n /**\n * The associated value for `set` operations. The value will be the new value\n * at the key path.\n *\n * All other types of update results do not have this property set.\n */\n readonly value?: any\n\n /** The associated amount, only set if {@link type} is `incremented`. */\n readonly amount?: number\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n static set(docID: DocumentID, path: string, value?: any): UpdateResult {\n return new UpdateResult('set', docID, path, value, undefined)\n }\n\n /** @internal */\n static incremented(docID: DocumentID, path: string, amount: number): UpdateResult {\n return new UpdateResult('incremented', docID, path, undefined, amount)\n }\n\n /** @internal */\n static removed(docID: DocumentID, path: string): UpdateResult {\n return new UpdateResult('removed', docID, path, undefined, undefined)\n }\n\n /** @internal */\n private constructor(type: UpdateResultType, docID: DocumentID, path: string, value?: any, amount?: number) {\n this.type = type\n this.docID = docID\n this.path = path\n if (value !== undefined) this.value = value\n if (amount !== undefined) this.amount = amount\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n// NOTE: proxy was originally written in pure JS rather than TypeScript. We'll\n// gradually port it to TypeScript and until done, we've renamed the pure JS\n// file to proxy.raw.js and introduced proxy.ts that'll contain all parts ported\n// to TypeScript or type declarations for the JS parts.\n\n// import * as proxyRaw from './proxy.raw.js'\n\nimport * as FFI from './ffi.js'\nimport { DocumentID } from './document-id.js'\nimport { AttachmentToken } from './attachment-token.js'\nimport { Attachment } from './attachment.js'\nimport { Counter } from './counter.js'\nimport { Register } from './register.js'\nimport { RGA } from './rga.js'\n\n// Takes an annotated JSON representation of a document (see CRDT's Document\n// class for more info about what an annotated representation is) and turns it\n// into a JavaScript-appropriate version. This means that counters get\n// represented by `Counter` objects and attachments get represented by\n// `Attachment` objects.\nexport function augmentJSONValue(json, mutDoc, workingPath) {\n if (json && typeof json === 'object') {\n if (Array.isArray(json)) {\n return json.map((v, idx) => augmentJSONValue(v, mutDoc, `${workingPath}[${idx}]`))\n } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.counter) {\n return Counter['@ditto.create'](mutDoc, workingPath, json[FFI.DittoCRDTValueKey])\n } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.register) {\n return Register['@ditto.create'](mutDoc, workingPath, json[FFI.DittoCRDTValueKey])\n } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.rga) {\n const augmentedValue = augmentJSONValue(json[FFI.DittoCRDTValueKey], mutDoc, workingPath)\n return RGA['@ditto.create'](workingPath, augmentedValue)\n } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.attachment) {\n return new AttachmentToken(json)\n } else {\n for (const [key, value] of Object.entries(json)) {\n json[key] = augmentJSONValue(value, mutDoc, `${workingPath}['${key}']`)\n }\n return json\n }\n } else {\n return json\n }\n}\n\nexport function desugarJSObject(jsObj, atRoot: boolean = false) {\n if (jsObj && typeof jsObj === 'object') {\n if (Array.isArray(jsObj)) {\n return jsObj.map((v, idx) => desugarJSObject(v, false))\n } else if (jsObj instanceof DocumentID) {\n return jsObj.value\n } else if (jsObj instanceof Counter) {\n const counterJSON = {}\n counterJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.counter\n counterJSON[FFI.DittoCRDTValueKey] = jsObj.value\n return counterJSON\n } else if (jsObj instanceof Register) {\n const registerJSON = {}\n registerJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.register\n registerJSON[FFI.DittoCRDTValueKey] = jsObj.value\n return registerJSON\n } else if (jsObj instanceof RGA) {\n const rgaJSON = {}\n rgaJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.rga\n rgaJSON[FFI.DittoCRDTValueKey] = desugarJSObject(jsObj.value)\n return rgaJSON\n } else if (jsObj instanceof Attachment) {\n const attachmentJSON = {\n _id: jsObj.token.id,\n _len: jsObj.token.len,\n _meta: jsObj.token.metadata,\n }\n attachmentJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.attachment\n return attachmentJSON\n } else {\n for (const [key, value] of Object.entries(jsObj)) {\n jsObj[key] = desugarJSObject(value, false)\n }\n return jsObj\n }\n } else {\n return jsObj\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nconst regularKeyPattern = /\\.([A-Za-z_]\\w*)/.source\nconst subscriptIndexPattern = /\\[(\\d+)\\]/.source\nconst subscriptSingleQuoteKeyPattern = /\\[\\'(.+?)\\'\\]/.source\nconst subscriptDoubleQuoteKeyPattern = /\\[\\\"(.+?)\\\"\\]/.source\nconst validKeyPathPattern = `((${regularKeyPattern})|(${subscriptIndexPattern})|(${subscriptSingleQuoteKeyPattern})|(${subscriptDoubleQuoteKeyPattern}))*`\n\nconst regularKeyRegExp = new RegExp(`^${regularKeyPattern}`)\nconst subscriptIndexRegExp = new RegExp(`^${subscriptIndexPattern}`)\nconst subscriptSingleQuoteKeyRegExp = new RegExp(`^${subscriptSingleQuoteKeyPattern}`)\nconst subscriptDoubleQuoteKeyRegExp = new RegExp(`^${subscriptDoubleQuoteKeyPattern}`)\nconst validKeyPathRegExp = new RegExp(`^${validKeyPathPattern}$`)\n\nexport type KeyPathValidateOptions = {\n isInitial?: boolean // default: false\n}\n\nexport type KeyPathEvaluateOptions = {\n stopAtLastContainer?: boolean // default: false\n}\n\nexport type KeyPathEvaluationResult = {\n keyPath: string | number\n object: any\n options: KeyPathEvaluateOptions\n coveredPath: string | number\n nextPathComponent: string | number | null\n remainingPath: string | number\n value: any\n}\n\n/**\n * Namespace for key-path related functions.\n * @internal\n */\nexport class KeyPath {\n /**\n * Returns the key-path by prefixing it with a leading dot if first key\n * starts with a character or an underscore.\n */\n static withLeadingDot(keyPath: string | number): any /* string | number */ {\n if (typeof keyPath === 'number') {\n return keyPath\n }\n\n if (typeof keyPath !== 'string') {\n throw new Error(`Key-path must be a string or a number but is ${typeof keyPath}: ${keyPath}`)\n }\n\n const needsLeadingDot = typeof keyPath === 'string' && !!keyPath.match(/^[A-Za-z_]/)\n return needsLeadingDot ? `.${keyPath}` : keyPath\n }\n\n /**\n * Returns the key-path by removing the leading dot if it starts with one.\n */\n static withoutLeadingDot(keyPath: string | number): any /* string | number */ {\n if (typeof keyPath === 'number') {\n return keyPath\n }\n\n if (typeof keyPath !== 'string') {\n throw new Error(`Key-path must be a string or a number but is ${typeof keyPath}: ${keyPath}`)\n }\n\n const hasLeadingDot = typeof keyPath === 'string' && !!keyPath.match(/^\\./)\n return hasLeadingDot ? keyPath.slice(1) : keyPath\n }\n\n /**\n * Validates a key-path by adding a leading dot if appropriate and checking\n * its syntax. Throws if syntax is invalid.\n */\n static validate(keyPath: string | number, options: KeyPathValidateOptions = {}): any /* string | number */ {\n const isInitial = options.isInitial ?? false\n\n if (typeof keyPath === 'number') {\n return Math.floor(Math.abs(keyPath))\n }\n\n if (typeof keyPath !== 'string') {\n throw new Error(`Key-path must be a string or a number but is ${typeof keyPath}: ${keyPath}`)\n }\n\n const keyPathWithLeadingDot = this.withLeadingDot(keyPath) as string\n\n if (!validKeyPathRegExp.test(keyPathWithLeadingDot)) {\n throw new Error(`Key-path is not valid: ${keyPath}`)\n }\n\n return isInitial ? keyPath : keyPathWithLeadingDot\n }\n\n /**\n * Follows the `keyPath`, boring down through `object` recursively until the\n * final key-path is reached. Implemented as a free function to help ensure it's\n * purely functional in nature and that no modifications are made to a\n * `Document{ID}` or `DocumentPath` where similarly named variables are at play.\n * @internal\n */\n static evaluate(keyPath: string | number, object: any, options: KeyPathEvaluateOptions = {}): KeyPathEvaluationResult {\n const stopAtLastContainer = options.stopAtLastContainer ?? false\n\n const evaluationResult = {\n keyPath: keyPath,\n object: object,\n options: { ...options },\n coveredPath: null,\n nextPathComponent: null,\n remainingPath: keyPath,\n value: object,\n }\n\n function advance(keyPath: string | number): { nextPathComponentRaw: string | number; nextPathComponent: string | number; remainingPath: string } {\n if (typeof keyPath === 'number') {\n return { nextPathComponentRaw: keyPath, nextPathComponent: keyPath, remainingPath: '' }\n }\n\n if (typeof keyPath !== 'string') {\n throw new Error(`Can't return value at given keyPath, expected keyPath to be a string or a number but got ${typeof keyPath}: ${keyPath}`)\n }\n\n // NOTE: `nextPathComponentRaw` represents next path component plus all\n // of it's surrounding delimiters, i.e. given a path `[\"abc\"].blah.blub`,\n // `nextPathComponentRaw` would be `[\"abc\"]` while nextPathComponent\n // would just yield 'abc'.\n\n const regularKeyMatch = keyPath.match(regularKeyRegExp)\n if (regularKeyMatch !== null) {\n const nextPathComponentRaw = regularKeyMatch[0]\n const nextPathComponent = regularKeyMatch[1]\n const remainingPath = keyPath.slice(nextPathComponent.length + /* stripped out . */ 1)\n return { nextPathComponentRaw, nextPathComponent, remainingPath }\n }\n\n const subscriptIndexMatch = keyPath.match(subscriptIndexRegExp)\n if (subscriptIndexMatch !== null) {\n const nextPathComponentRaw = subscriptIndexMatch[0]\n const nextPathComponentString = subscriptIndexMatch[1]\n const nextPathComponent = parseInt(nextPathComponentString)\n const remainingPath = keyPath.slice(nextPathComponentString.length + /* stripped out [] */ 2)\n return { nextPathComponentRaw, nextPathComponent, remainingPath }\n }\n\n const subscriptSingleQuoteMatch = keyPath.match(subscriptSingleQuoteKeyRegExp)\n if (subscriptSingleQuoteMatch !== null) {\n const nextPathComponentRaw = subscriptSingleQuoteMatch[0]\n const nextPathComponent = subscriptSingleQuoteMatch[1]\n const remainingPath = keyPath.slice(nextPathComponent.length + /* stripped out [''] */ 4)\n return { nextPathComponentRaw, nextPathComponent, remainingPath }\n }\n\n const subscriptDoubleQuoteMatch = keyPath.match(subscriptDoubleQuoteKeyRegExp)\n if (subscriptDoubleQuoteMatch !== null) {\n const nextPathComponentRaw = subscriptDoubleQuoteMatch[0]\n const nextPathComponent = subscriptDoubleQuoteMatch[1]\n const remainingPath = keyPath.slice(nextPathComponent.length + /* stripped out [\"\"] */ 4)\n return { nextPathComponentRaw, nextPathComponent, remainingPath }\n }\n\n throw new Error(`Can't return value at keyPath because the following part of the keyPath is invalid: ${keyPath}`)\n }\n\n function recurse(object: any, keyPath: string | number): KeyPathEvaluationResult {\n if (keyPath === '') {\n evaluationResult.value = object\n return evaluationResult\n }\n\n const { nextPathComponentRaw, nextPathComponent, remainingPath } = advance(keyPath)\n\n evaluationResult.nextPathComponent = nextPathComponent\n evaluationResult.remainingPath = remainingPath\n\n if (evaluationResult.coveredPath === null || typeof nextPathComponentRaw === 'number') {\n evaluationResult.coveredPath = nextPathComponentRaw\n } else {\n evaluationResult.coveredPath += nextPathComponentRaw\n }\n\n if (remainingPath === '' && stopAtLastContainer) {\n evaluationResult.value = object\n return evaluationResult\n }\n\n const nextObject = object[nextPathComponent]\n return recurse(nextObject, remainingPath)\n }\n\n const keyPathWithLeadingDot = this.withLeadingDot(keyPath)\n return recurse(object, keyPathWithLeadingDot)\n }\n\n private constructor() {}\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { CBOR } from './cbor.js'\nimport { Logger } from './logger.js'\nimport { Counter, MutableCounter } from './counter.js'\nimport { Register, MutableRegister } from './register.js'\nimport { RGA } from './rga.js'\nimport { AttachmentToken } from './attachment-token.js'\nimport { UpdateResult } from './update-result.js'\nimport { Document, MutableDocument, DocumentValue } from './document.js'\nimport { documentBridge, mutableDocumentBridge } from './document.js'\nimport { desugarJSObject, augmentJSONValue } from './augment.js'\nimport { validateNumber } from './internal.js'\nimport { KeyPath } from './key-path.js'\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents a portion of the document at a specific key-path.\n *\n * Provides an interface to specify a path to a key in a document that you can\n * then call a function on to get the value at the specified key as a specific\n * type. You don't create a `DocumentPath` directly but obtain one via the\n * {@link Document.path | path} property or the {@link Document.at | at()}\n * method of {@link Document}.\n */\nexport class DocumentPath {\n /** The document this path belongs to. */\n readonly document: Document\n\n /** The full document path so far. */\n readonly path: string\n\n /**\n * Returns a new document path instance with the passed in key-path or\n * index appended.\n *\n * A key-path can be a single property name or multiple property names\n * separated by a dot. Indexes can also be specified as part of the key\n * path using the square bracket syntax. The empty string returns a document\n * path representing the same portion of the document as the receiver. If a\n * key-path starts with a property name and is prefixed by a dot, the dot is\n * ignored.\n *\n * Examples:\n *\n * - `documentPath.at('mileage')`\n * - `documentPath.at('driver.name')`\n * - `documentPath.at('passengers[2]')`\n * - `documentPath.at('passengers[2].belongings[1].kind')`\n * - `documentPath.at('.mileage')`\n */\n at(keyPathOrIndex: string | number): DocumentPath {\n if (typeof keyPathOrIndex === 'string') {\n const keyPath: string = keyPathOrIndex\n const validatedKeyPath = KeyPath.validate(keyPath)\n // this.path can be an empty string.\n const absoluteKeyPath = KeyPath.withoutLeadingDot(`${this.path}${validatedKeyPath}`)\n return new DocumentPath(this.document, absoluteKeyPath, false)\n }\n\n if (typeof keyPathOrIndex === 'number') {\n const index: number = keyPathOrIndex\n const validatedIndex = validateNumber(index, { integer: true, min: 0, errorMessagePrefix: 'DocumentPath.at() validation failed index:' })\n return new DocumentPath(this.document, `${this.path}[${validatedIndex.toString()}]`, false)\n }\n\n throw new Error(`Can't return document path at key-path or index, string or number expected but got ${typeof keyPathOrIndex}: ${keyPathOrIndex}`)\n }\n\n /**\n * Traverses the document with the key-path represented by the receiver and\n * returns the corresponding object or value.\n */\n get value(): any | undefined {\n return this.underlyingValueForPathType('Any')\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link Counter} if possible, otherwise returns `null`.\n */\n get counter(): Counter | null {\n const underlyingValue = this.underlyingValueForPathType('Counter')\n return typeof underlyingValue !== 'undefined' ? Counter['@ditto.create'](null, this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link Register} if possible, otherwise returns `null`.\n */\n get register(): Register | null {\n const underlyingValue = this.underlyingValueForPathType('Register')\n return typeof underlyingValue !== 'undefined' ? Register['@ditto.create'](null, this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as an\n * {@link RGA} if possible, otherwise returns `null`.\n *\n * @deprecated RGA usage should be replaced. Use arrays inside Registers\n * instead.\n */\n get rga(): RGA | null {\n const underlyingValue = this.underlyingValueForPathType('Rga')\n return typeof underlyingValue !== 'undefined' ? RGA['@ditto.create'](this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as an\n * {@link AttachmentToken} if possible, otherwise returns `null`.\n */\n get attachmentToken(): AttachmentToken | null {\n const underlyingValue = this.underlyingValueForPathType('Attachment')\n return typeof underlyingValue !== 'undefined' ? new AttachmentToken(underlyingValue) : null\n }\n\n /** @internal */\n constructor(document: Document, path: string, validate: boolean) {\n this.document = document\n this.path = validate ? KeyPath.validate(path, { isInitial: true }) : path\n }\n\n /** @internal */\n underlyingValueForPathType(pathType: FFI.PathAccessorType): any | undefined {\n const path = this.path\n const document = this.document\n const documentX = documentBridge.pointerFor(document)\n const cborPathResult = FFI.documentGetCBORWithPathType(documentX, path, pathType)\n return cborPathResult.cbor !== null ? CBOR.decode(cborPathResult.cbor) : undefined\n }\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Mutable version of {@link DocumentPath} allowing you to mutate a document at\n * a specific key-path. You don't create a `MutableDocumentPath` directly but\n * obtain one via the {@link MutableDocument.path | path} property or the\n * {@link MutableDocument.at | at()} method of {@link MutableDocument}.\n */\nexport class MutableDocumentPath {\n /** The (mutable) document this path belongs to. */\n readonly mutableDocument: MutableDocument\n\n /** The full document path so far. */\n readonly path: string\n\n /**\n * Returns a new mutable document path instance with the passed in key-path or\n * index appended.\n *\n * A key-path can be a single property name or multiple property names\n * separated by a dot. Indexes can also be specified as part of the key\n * path using square brackets syntax. The empty string returns a document path\n * representing the same portion of the document as the receiver. If a key\n * path starts with a property name and is prefixed by a dot, the dot is\n * ignored.\n *\n * Examples:\n *\n * - `mutableDocumentPath.at('mileage')`\n * - `mutableDocumentPath.at('driver.name')`\n * - `mutableDocumentPath.at('passengers[2]')`\n * - `mutableDocumentPath.at('passengers[2].belongings[1].kind')`\n * - `mutableDocumentPath.at('.mileage')`\n */\n at(keyPathOrIndex: string | number): MutableDocumentPath {\n if (typeof keyPathOrIndex === 'string') {\n const keyPath: string = keyPathOrIndex\n const validatedKeyPath = KeyPath.validate(keyPath)\n // this.path can be an empty string.\n const absoluteKeyPath = KeyPath.withoutLeadingDot(`${this.path}${validatedKeyPath}`)\n return new MutableDocumentPath(this.mutableDocument, absoluteKeyPath, false)\n }\n\n if (typeof keyPathOrIndex === 'number') {\n const index: number = keyPathOrIndex\n const validatedIndex = validateNumber(index, { integer: true, min: 0, errorMessagePrefix: 'MutableDocumentPath.at() validation failed index:' })\n return new MutableDocumentPath(this.mutableDocument, `${this.path}[${validatedIndex.toString()}]`, false)\n }\n\n throw new Error(`Can't return mutable document path at key-path or index, string or number expected but got ${typeof keyPathOrIndex}: ${keyPathOrIndex}`)\n }\n\n /**\n * Traverses the document with the key-path represented by the receiver and\n * returns the corresponding object or value.\n */\n get value(): any | undefined {\n return this.underlyingValueForPathType('Any')\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link MutableCounter} if possible, otherwise returns `null`.\n */\n get counter(): MutableCounter | null {\n const underlyingValue = this.underlyingValueForPathType('Counter')\n return typeof underlyingValue !== 'undefined' ? Counter['@ditto.create'](this.mutableDocument, this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link MutableRegister} if possible, otherwise returns `null`.\n */\n get register(): MutableRegister | null {\n const underlyingValue = this.underlyingValueForPathType('Register')\n return typeof underlyingValue !== 'undefined' ? Register['@ditto.create'](this.mutableDocument, this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link RGA} if possible, otherwise returns `null`.\n *\n * Note that the returned type, {@link RGA}, is deprecated and does not allow\n * any mutation. RGAs cannot be created or mutated with this version of the\n * SDK; they can only be read and this is for backwards compatibility reasons.\n *\n * @deprecated RGA usage should be replaced. Use arrays inside Registers\n * instead.\n */\n get rga(): RGA | null {\n const underlyingValue = this.underlyingValueForPathType('Rga')\n return typeof underlyingValue !== 'undefined' ? RGA['@ditto.create'](this.path, underlyingValue) : null\n }\n\n /**\n * Returns the value at the previously specified key in the document as a\n * {@link AttachmentToken} if possible, otherwise returns `null`.\n */\n get attachmentToken(): AttachmentToken | null {\n const underlyingValue = this.underlyingValueForPathType('Attachment')\n return typeof underlyingValue !== 'undefined' ? new AttachmentToken(underlyingValue) : null\n }\n\n /**\n * Sets a value at the document's key-path defined by the receiver.\n *\n * @param isDefault Represents whether or not the value should be set as a\n * default value. Set this to `true` if you want to set a default value that\n * you expect to be overwritten by other devices in the network. The default\n * value is `false`.\n */\n set(value: any, isDefault?: boolean) {\n return this['@ditto.set'](value, isDefault)\n }\n\n /**\n * Removes a value at the document's key-path defined by the receiver.\n * If removing an index from an `RGA`, any subsequent indexes will be shifted\n * left to fill the gap.\n */\n remove() {\n return this['@ditto.remove']()\n }\n\n /** @internal */\n constructor(mutableDocument: MutableDocument, path: string, validate: boolean) {\n this.mutableDocument = mutableDocument\n this.path = validate ? KeyPath.validate(path, { isInitial: true }) : path\n }\n\n /** @internal */\n underlyingValueForPathType(pathType: FFI.PathAccessorType): any | null {\n const path = this.path\n const document = this.mutableDocument\n const documentX = mutableDocumentBridge.pointerFor(document)\n const cborPathResult = FFI.documentGetCBORWithPathType(documentX, path, pathType)\n return cborPathResult.cbor !== null ? CBOR.decode(cborPathResult.cbor) : undefined\n }\n\n /** @internal */\n '@ditto.increment'(amount: number) {\n // REFACTOR: this body should probably move to\n // `MutableCounter.incrementBy()`. Keeping as-is for now until we implement\n // more explicit CRDT types.\n const documentPointer = mutableDocumentBridge.pointerFor(this.mutableDocument)\n FFI.documentIncrementCounter(documentPointer, this.path, amount)\n\n const updateResult = UpdateResult.incremented(this.mutableDocument.id, this.path, amount)\n this.recordUpdateResult(updateResult)\n }\n\n /** @internal */\n '@ditto.set'(value: any, isDefault?: boolean) {\n const documentX = mutableDocumentBridge.pointerFor(this.mutableDocument)\n const valueJSON = desugarJSObject(value, false)\n const valueCBOR = CBOR.encode(valueJSON)\n\n if (isDefault) {\n FFI.documentSetCBORWithTimestamp(documentX, this.path, valueCBOR, true, 0)\n } else {\n FFI.documentSetCBOR(documentX, this.path, valueCBOR, true)\n }\n\n // HACK: we need a copy of value because the original value can be mutated\n // later on and an update result needs the state of the value at this\n // particular point in time. Decoding from CBOR might be a bit inefficient\n // but good enough for now.\n const valueJSONCopy = CBOR.decode(valueCBOR)\n const valueCopy = augmentJSONValue(valueJSONCopy, this.mutableDocument, this.path)\n\n const updateResult = UpdateResult.set(this.mutableDocument.id, this.path, valueCopy)\n this.recordUpdateResult(updateResult)\n }\n\n /** @internal */\n '@ditto.remove'() {\n const documentPointer = mutableDocumentBridge.pointerFor(this.mutableDocument)\n FFI.documentRemove(documentPointer, this.path)\n\n this.updateInMemory((container, lastPathComponent) => {\n if (Array.isArray(container) && typeof lastPathComponent === 'number') {\n container.splice(lastPathComponent, 1)\n } else {\n delete container[lastPathComponent]\n }\n })\n\n const updateResult = UpdateResult.removed(this.mutableDocument.id, this.path)\n this.recordUpdateResult(updateResult)\n }\n\n /** @private */\n private updateInMemory(block: (container: any, lastPathComponent: any) => void) {\n const mutableDocumentValue = this.mutableDocument.value\n const evaluationResult = KeyPath.evaluate(this.path, mutableDocumentValue, { stopAtLastContainer: true })\n block(evaluationResult.value, evaluationResult.nextPathComponent)\n }\n\n /** @private */\n private recordUpdateResult(updateResult: UpdateResult) {\n // OPTIMIZE: not sure how much of a performance hit this\n // clone-modify-freeze dance implies. Investigate and fix.\n const updateResults = this.mutableDocument['@ditto.updateResults'].slice()\n updateResults.push(updateResult)\n Object.freeze(updateResults)\n this.mutableDocument['@ditto.updateResults' as any] = updateResults\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { Bridge } from './bridge.js'\nimport { UpdateResult } from './update-result.js'\nimport { CBOR } from './cbor.js'\nimport { DocumentID } from './document-id.js'\nimport { validateDocumentIDCBOR } from './document-id.js'\nimport { DocumentPath, MutableDocumentPath } from './document-path.js'\n\n// -----------------------------------------------------------------------------\n\n/**\n * A document value is a JavaScript object containing values for keys that\n * can be serialized via CBOR.\n */\nexport type DocumentValue = Record<string, any>\n\n// -----------------------------------------------------------------------------\n\n/** A document belonging to a {@link Collection} with an inner value. */\nexport class Document {\n /**\n * Returns a hash that represents the passed in document(s).\n */\n static hash(documentOrMany: Document | Document[]): BigInt {\n const documents = documentsFrom(documentOrMany)\n const documentPointers = documents.map((doc) => documentBridge.pointerFor(doc))\n return FFI.documentsHash(documentPointers)\n }\n\n /**\n * Returns a pattern of words that together create a mnemonic, which\n * represents the passed in document(s).\n */\n static hashMnemonic(documentOrMany: Document | Document[]): string {\n const documents = documentsFrom(documentOrMany)\n const documentPointers = documents.map((doc) => documentBridge.pointerFor(doc))\n return FFI.documentsHashMnemonic(documentPointers)\n }\n\n /**\n * Returns the document ID.\n */\n get id(): DocumentID {\n let id = this['@ditto.id']\n if (typeof id === 'undefined') {\n const documentX = documentBridge.pointerFor(this)\n const documentIDCBOR = FFI.documentID(documentX)\n id = new DocumentID(documentIDCBOR, true)\n this['@ditto.id'] = id\n }\n return id\n }\n\n /**\n * Returns the document path at the root of the document.\n */\n get path(): DocumentPath {\n return new DocumentPath(this, '', false)\n }\n\n /**\n * Convenience property, same as calling `path.value`. The value is cached on\n * first access and returned on subsequent calls without calling `path.value`\n * again.\n */\n get value(): DocumentValue {\n let value = this['@ditto.value']\n if (typeof value === 'undefined') {\n value = this.path.value\n this['@ditto.value'] = value\n }\n return value\n }\n\n /**\n * Convenience method, same as calling `path.at()`.\n */\n at(keyPathOrIndex: string | number): DocumentPath {\n return this.path.at(keyPathOrIndex)\n }\n\n /** @internal */\n constructor() {}\n\n // TEMPORARY: helpers to deal with non-canonical IDs.\n\n /** @internal */\n static idCBOR(document: Document): Uint8Array {\n const documentX = documentBridge.pointerFor(document)\n return FFI.documentID(documentX)\n }\n\n /** @internal */\n static canonicalizedIDCBOR(idCBOR: Uint8Array): Uint8Array {\n return validateDocumentIDCBOR(idCBOR)\n }\n\n /** @internal */\n static isIDCBORCanonical(idCBOR: Uint8Array): boolean {\n const canonicalIDCBOR = this.canonicalizedIDCBOR(idCBOR)\n return idCBOR === canonicalIDCBOR\n }\n}\n\n// -----------------------------------------------------------------------------\n\n// REFACTOR: adapt the mutable document proxying to the way it is done for\n// Document, i.e. only use the proxy to dispatch and delegate to actual\n// methods on the corresponding classes. The way it is right now is that\n// most of the code of this code is duplicated within the MutableDocument,\n// the MutableDocumentPath classes and the proxy implementation. Also make\n// sure to proxy the mutable document right within its constructor. Same\n// for mutable and immutable document path.\n\n/**\n * A representation of a {@link Document} that can be mutated via\n * {@link MutableDocumentPath}. You don't create or interact with\n * a `MutableDocument` direclty but rather through our proxy-based\n * subscripting API exposed within the `update()` methods of\n * {@link PendingCursorOperation.update | PendingCursorOperation} and\n * {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation}.\n */\nexport class MutableDocument {\n /**\n * Returns the ID of the document.\n */\n get id(): DocumentID {\n let id = this['@ditto.id']\n if (typeof id === 'undefined') {\n const documentX = mutableDocumentBridge.pointerFor(this)\n const documentIDCBOR = FFI.documentID(documentX)\n id = new DocumentID(documentIDCBOR, true)\n this['@ditto.id'] = id\n }\n return id\n }\n\n /**\n * Returns the document path at the root of the document.\n */\n get path(): MutableDocumentPath {\n return new MutableDocumentPath(this, '', false)\n }\n\n /**\n * Convenience property, same as `path.value`.\n */\n get value(): DocumentValue {\n return this.path.value\n }\n\n /**\n * Convenience method, same as calling `path.at()`.\n */\n at(keyPathOrIndex: string | number): MutableDocumentPath {\n return this.path.at(keyPathOrIndex)\n }\n\n /** @internal */\n constructor() {}\n\n /** @internal */\n readonly '@ditto.updateResults': UpdateResult[] = []\n\n // TEMPORARY: helpers to deal with non-canonical IDs.\n\n /** @internal */\n static idCBOR(mutableDocument: MutableDocument): Uint8Array {\n const documentX = mutableDocumentBridge.pointerFor(mutableDocument)\n return FFI.documentID(documentX)\n }\n\n /** @internal */\n static canonicalizedIDCBOR = Document.canonicalizedIDCBOR\n\n /** @internal */\n static isIDCBORCanonical = Document.isIDCBORCanonical\n}\n\n// -----------------------------------------------------------------------------\n\n// REFACTOR: make the bridges entirely unaccessible from outside.\n\n/** @internal */\nexport const documentBridge = new Bridge<Document, FFI.FFIDocument>(Document, FFI.documentFree)\n\n/** @internal */\nexport const mutableDocumentBridge = new Bridge<MutableDocument, FFI.FFIDocument>(MutableDocument, FFI.documentFree)\n\n// -----------------------------------------------------------------------------\n\n/** @private */\nfunction documentsFrom(documentOrMany: Document | Document[] | null): Document[] {\n if (!documentOrMany) {\n return []\n }\n\n if (documentOrMany instanceof Document) {\n return [documentOrMany]\n }\n\n if (documentOrMany instanceof Array) {\n return documentOrMany as Document[]\n }\n\n throw new Error(`Expected null, a single document, or an array of documents but got value of type ${typeof documentOrMany}: ${documentOrMany}`)\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport { Document } from './document.js'\nimport { DocumentID, DocumentIDValue } from './document-id.js'\nimport { UpdateResult } from './update-result.js'\n\n/**\n * Maps a {@link DocumentID} to an array of\n * {@link UpdateResult | update results}. This is the data structure you get\n * when {@link PendingCursorOperation.update | updating} a set of documents\n * with detailed info about the performed updates.\n */\nexport class UpdateResultsMap {\n /**\n * Returns an array of {@link UpdateResult | update results} associated with\n * the `documentID` or undefined if not found.\n */\n get(documentIDOrValue: DocumentID | DocumentIDValue): UpdateResult[] | undefined {\n const documentID: DocumentID = documentIDOrValue instanceof DocumentID ? documentIDOrValue : new DocumentID(documentIDOrValue)\n const documentIDString = documentID.toString()\n return this.updateResultsByDocumentIDString[documentIDString]\n }\n\n /**\n * Returns all contained keys, i.e. {@link DocumentID | document IDs}\n * contained in this map.\n */\n keys(): DocumentID[] {\n return this.documentIDs.slice()\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n constructor(documentIDs: DocumentID[], updateResultsByDocumentIDString: object) {\n // REFACTOR: this quick & dirty implementation assumes Document.toString()\n // to be isomorphic, i.e. id1.equals(id2) <==> id1.toString() == id2.toString(),\n // which isn't the case in certain edge cases. Fix by implementing a proper\n // data structure ensuring correctness. One idea would be to use toString()\n // as a hash value and add a check plus conflict resolution after lookup.\n // Another idea would be to check for isomorphism for the particular subset\n // that is passed in and fallback to O(n) linear array search if not.\n\n const documentIDStrings = documentIDs\n .map((documentID) => documentID.toString())\n .sort()\n .join(', ')\n const updateResultsKeys = Object.keys(updateResultsByDocumentIDString).sort().join(', ')\n\n if (documentIDStrings !== updateResultsKeys) {\n throw new Error(\"Internal inconsistency, can't construct update results map, documentIDs must all be keys in update results (by document ID string)\")\n }\n\n this.documentIDs = documentIDs.slice()\n this.updateResultsByDocumentIDString = { ...updateResultsByDocumentIDString }\n }\n\n // ------------------------------------------------------------ Private ------\n\n private documentIDs: DocumentID[]\n private updateResultsByDocumentIDString: object\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport type { Document } from './document.js'\n\nimport { documentBridge } from './document.js'\nimport { dittoBridge } from './ditto.js'\n\n// -----------------------------------------------------------------------------\n\n/**\n * An object that describes how a document's position in a live query's list of\n * matching documents has changed since the previous live query event.\n */\nexport interface LiveQueryMove {\n /**\n * The index of the document in the list of matching documents from the\n * previous live query event.\n */\n readonly from: number\n\n /**\n * The index of the document in the list of matching documents from the new\n * live query event.\n */\n readonly to: number\n}\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nexport interface LiveQueryEventUpdateParams {\n oldDocuments: Document[]\n insertions: number[]\n deletions: number[]\n updates: number[]\n moves: LiveQueryMove[]\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * First event fired immediately after registering a live query without any\n * mutations. All subsequent events are of type {@link LiveQueryEventUpdate}.\n */\nexport class LiveQueryEventInitial {\n /**\n * Whether or not this is the initial event being delivered. Always `true`\n * for `LiveQueryEventInitial`.\n */\n readonly isInitial = true\n\n /**\n * Returns a hash that represents the set of matching documents.\n */\n hash(documents: Document[]): BigInt {\n return FFI.documentsHash(documents.map((doc) => documentBridge.pointerFor(doc)))\n }\n\n /**\n * Returns a pattern of words that together create a mnemonic, which\n * represents the set of matching documents.\n */\n hashMnemonic(documents: Document[]): string {\n return FFI.documentsHashMnemonic(documents.map((doc) => documentBridge.pointerFor(doc)))\n }\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents an update event describing all changes that occured for documents\n * covered by a (live) query.\n */\nexport class LiveQueryEventUpdate {\n /**\n * Whether or not this is the initial event being delivered. Always `false`\n * for `LiveQueryEventUpdate`.\n */\n readonly isInitial = false\n\n /**\n * The documents that previously matched the query, before the latest event.\n */\n readonly oldDocuments: Document[]\n\n /**\n * The indexes in the array of matching documents that accompany this event,\n * which relate to a document that was not in the previous most recent list of\n * matching documents.\n */\n readonly insertions: number[]\n\n /**\n * The indexes into the array {@link oldDocuments}, which relate to a document\n * that was in the previous most recent list of matching documents but is no\n * longer a matching document.\n */\n readonly deletions: number[]\n\n /**\n * The indexes in the array of matching documents that accompany this event,\n * which relate to a document that has been updated since the previous live\n * query event.\n */\n readonly updates: number[]\n\n /**\n * Objects that describe how documents' positions in the list of matching\n * documents have changed since the previous live query event.\n */\n readonly moves: LiveQueryMove[]\n\n /**\n * Returns a hash that represents the set of matching documents.\n */\n hash(documents: Document[]): BigInt {\n return FFI.documentsHash(documents.map((doc) => documentBridge.pointerFor(doc)))\n }\n\n /**\n * Returns a pattern of words that together create a mnemonic, which\n * represents the set of matching documents.\n */\n hashMnemonic(documents: Document[]): string {\n return FFI.documentsHashMnemonic(documents.map((doc) => documentBridge.pointerFor(doc)))\n }\n\n /** @internal */\n constructor(params: LiveQueryEventUpdateParams) {\n this.oldDocuments = params.oldDocuments\n this.insertions = params.insertions\n this.deletions = params.deletions\n this.updates = params.updates\n this.moves = params.moves\n }\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents events delivered by a {@link LiveQuery}, which can be initial\n * (fired immediately upon registration) or an update (all subsequent events).\n */\nexport type LiveQueryEvent = LiveQueryEventInitial | LiveQueryEventUpdate\n\n// -----------------------------------------------------------------------------\n\n/**\n * Provides information about a live query event relating to a single document\n * live query.\n */\nexport class SingleDocumentLiveQueryEvent {\n /**\n * Whether or not this is the initial event being delivered.\n */\n readonly isInitial: boolean\n\n /** The old representation of the document with the relveant document ID. */\n readonly oldDocument?: Document\n\n /**\n * Returns a hash that represents the set of matching documents.\n */\n hash(document: Document | null): BigInt {\n return FFI.documentsHash(document === null ? [] : [documentBridge.pointerFor(document)])\n }\n\n /**\n * Returns a pattern of words that together create a mnemonic, which\n * represents the set of matching documents.\n */\n hashMnemonic(document: Document | null): string {\n return FFI.documentsHashMnemonic(document === null ? [] : [documentBridge.pointerFor(document)])\n }\n\n /** @internal */\n constructor(isInitial: boolean, oldDocument?: Document) {\n this.isInitial = isInitial\n this.oldDocument = oldDocument\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\nimport { QueryArguments } from './essentials.js'\nimport { Subscription } from './subscription.js'\nimport { Collection } from './collection.js'\nimport { KeepAlive } from './keep-alive.js'\nimport { performAsyncToWorkaroundNonAsyncFFIAPI, step } from './internal.js'\n\nimport { LiveQueryEvent } from './live-query-event.js'\nimport { LiveQueryEventInitial } from './live-query-event.js'\nimport { LiveQueryEventUpdate } from './live-query-event.js'\n\nimport { documentBridge } from './document.js'\nimport { dittoBridge } from './ditto.js'\n\nimport type { QueryObservationHandler } from './pending-cursor-operation.js'\n\n/**\n * The type that is returned when calling\n * {@link PendingCursorOperation.observeLocal | observeLocal()} on a\n * {@link PendingCursorOperation} object. It handles the logic for calling the\n * event handler that is provided to `observeLocal()` calls.\n *\n * Ditto will prevent the process from exiting as long as there are active live\n * queries (not relevant when running in the browser).\n *\n * `LiveQuery` objects must be kept in scope for as long as you wish to have\n * your event handler be called when there is an update to a document matching\n * the query you provide. When you no longer want to receive updates about\n * documents matching a query then you must call {@link stop | stop()}.\n */\nexport class LiveQuery {\n /** The query that the live query is based on. */\n readonly query: string\n\n /** The arguments belonging to {@link query}. */\n readonly queryArgs: QueryArguments | null\n\n /** The name of the collection that the live query is based on. */\n get collectionName(): string {\n return this.collection.name\n }\n\n /** Returns true if the receiver has been stopped. */\n get isStopped(): boolean {\n return this.liveQueryID === null\n }\n\n /**\n * Stop the live query from delivering updates.\n */\n stop() {\n const liveQueryID = this.liveQueryID\n if (liveQueryID !== null) {\n this.collection.store.ditto.keepAlive.release(`LiveQuery.${liveQueryID}`)\n this.liveQueryID = null\n const dittoPointer = dittoBridge.pointerFor(this.collection.store.ditto)\n this.subscription?.cancel()\n FFI.liveQueryStop(dittoPointer, liveQueryID)\n }\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n readonly limit: number\n\n /** @internal */\n readonly offset: number\n\n /** @internal */\n readonly collection: Collection\n\n /** @internal */\n readonly subscription?: Subscription\n\n /** @internal */\n readonly handler: QueryObservationHandler\n\n /** @internal */\n constructor(query: string, queryArgs: QueryArguments | null, queryArgsCBOR: Uint8Array | null, orderBys: FFI.OrderBy[], limit: number, offset: number, collection: Collection, subscription: Subscription | null, handler: QueryObservationHandler) {\n // Query should be validated at this point.\n this.query = query\n this.queryArgs = queryArgs ? Object.freeze({ ...queryArgs }) : null\n this.queryArgsCBOR = queryArgsCBOR\n this.orderBys = orderBys\n this.limit = limit\n this.offset = offset\n this.collection = collection\n this.handler = handler\n\n if (subscription) {\n this.subscription = subscription\n }\n\n const collectionName = collection.name\n const weakDitto = new WeakRef(collection.store.ditto)\n\n let liveQueryID = undefined\n const signalNext = async () => {\n const ditto = weakDitto.deref()\n if (ditto) {\n const dittoPointer = dittoBridge.pointerFor(ditto)\n await FFI.liveQuerySignalAvailableNext(dittoPointer, liveQueryID)\n }\n }\n\n const dittoPointer = dittoBridge.pointerFor(collection.store.ditto)\n liveQueryID = FFI.liveQueryRegister(dittoPointer, collectionName, query, queryArgsCBOR, this.orderBys, limit, offset, (cCBParams) => {\n const documents = cCBParams.documents.map((ptr) => documentBridge.bridge(ptr))\n\n let event: LiveQueryEvent\n if (cCBParams.is_initial) {\n event = new LiveQueryEventInitial()\n } else {\n event = new LiveQueryEventUpdate({\n oldDocuments: cCBParams.old_documents.map((ptr) => documentBridge.bridge(ptr)),\n insertions: cCBParams.insertions,\n deletions: cCBParams.deletions,\n updates: cCBParams.updates,\n moves: cCBParams.moves.map((move) => ({ from: move[0], to: move[1] })),\n })\n }\n\n handler(documents, event, signalNext)\n })\n\n if (!liveQueryID) {\n throw new Error(\"Internal inconsistency, couldn't create a valid live query ID.\")\n }\n\n this.liveQueryID = liveQueryID\n // not awaited on purpose; let the invocation of the initial observation\n // happen in a \"fire-and-forget\" / detached / escaping fashion, to be\n // consistent with the subsequent invocations.\n step(async () => await FFI.liveQueryStart(dittoPointer, liveQueryID))\n collection.store.ditto.keepAlive.retain(`LiveQuery.${liveQueryID}`)\n }\n\n /** @internal */\n async signalNext() {\n // IDEA: make this public?\n const dittoPointer = dittoBridge.pointerFor(this.collection.store.ditto)\n await FFI.liveQuerySignalAvailableNext(dittoPointer, this.liveQueryID)\n }\n\n // ------------------------------------------------------------ Private ------\n\n private orderBys: FFI.OrderBy[]\n private queryArgsCBOR: Uint8Array | null\n private liveQueryID: number | null\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\nimport { QueryArguments, SortDirection } from './essentials.js'\nimport { Subscription } from './subscription.js'\n\nimport { DocumentID } from './document-id.js'\nimport { Document, MutableDocument } from './document.js'\n\nimport { UpdateResult } from './update-result.js'\nimport { UpdateResultsMap } from './update-results-map.js'\n\nimport { LiveQuery } from './live-query.js'\nimport { LiveQueryEvent } from './live-query-event.js'\n\nimport { CBOR } from './cbor.js'\nimport { Logger } from './logger.js'\nimport { validateQuery } from './internal.js'\nimport { performAsyncToWorkaroundNonAsyncFFIAPI } from './internal.js'\nimport { documentBridge, mutableDocumentBridge } from './document.js'\nimport { dittoBridge } from './ditto.js'\n\nimport type { Collection } from './collection.js'\n\n// -----------------------------------------------------------------------------\n\n/**\n * The closure that is called whenever the documents covered by a live query\n * change.\n */\nexport type QueryObservationHandler = (documents: Document[], event: LiveQueryEvent, signalNext?: () => void) => void | Promise<void>\n\n// -----------------------------------------------------------------------------\n\n/**\n * These objects are returned when using `find`-like functionality on\n * {@link Collection}.\n *\n * They allow chaining of further query-related functions to do things like add\n * a limit to the number of documents you want returned or specify how you want\n * the documents to be sorted and ordered.\n *\n * You can either call {@link exec | exec()} on the object to get an array of\n * {@link Document | documents} as an immediate return value, or you can\n * establish either a live query or a subscription, which both work over time.\n *\n * A live query, established by calling\n * {@link PendingCursorOperation.observeLocal | observeLocal()}, will notify you\n * every time there's an update to a document that matches the query you\n * provided in the preceding `find`-like call.\n *\n * A subscription, established by calling\n * {@link PendingCursorOperation.subscribe | subscribe()}, will act as a signal\n * to other peers that the device connects to that you would like to receive\n * updates from them about documents that match the query you provided in the\n * preceding `find`-like call.\n *\n * Update and remove functionality is also exposed through this object.\n */\nexport class PendingCursorOperation implements PromiseLike<Document[]> {\n /** The query the receiver is operating with. */\n readonly query: string\n\n /** The named arguments for the {@link query}. */\n readonly queryArgs: QueryArguments | null\n\n /** The collection the receiver is operating on. */\n readonly collection: Collection\n\n /**\n * Sorts the documents that match the query provided in the preceding\n * `find`-like function call.\n *\n * @param query The query specifies the logic to be used when sorting the\n * matching documents.\n *\n * @param direction Specify whether you want the sorting order to be\n * `Ascending` or `Descending`.\n *\n * @return A {@link PendingCursorOperation} that you can chain further\n * function calls and then either get the matching documents immediately or\n * get updates about them over time.\n */\n sort(propertyPath: string, direction: SortDirection = 'ascending'): PendingCursorOperation {\n this.orderBys.push({\n query: propertyPath,\n direction: direction === 'ascending' ? 'Ascending' : 'Descending',\n })\n return this\n }\n\n /**\n * Offsets the resulting set of matching documents.\n *\n * This is useful if you aren't interested in the first N matching documents\n * for one reason or another. For example, you might already have queried the\n * collection and obtained the first 20 matching documents and so you might\n * want to run the same query as you did previously but ignore the first 20\n * matching documents, and that is when you would use `offset`.\n *\n * @param offset The number of matching documents that you want the eventual\n * resulting set of matching documents to be offset by (and thus not include).\n *\n * @return A {@link PendingCursorOperation} that you can chain further\n * function calls and then either get the matching documents immediately or\n * get updates about them over time.\n */\n offset(offset: number): PendingCursorOperation {\n // REFACTOR: factor out parameter validation.\n\n if (offset < 0) throw new Error(`Can't offset by '${offset}', offset must be >= 0`)\n if (!Number.isFinite(offset)) throw new Error(`Can't offset by '${offset}', offset must be a finite number`)\n if (Number.isNaN(offset)) throw new Error(`Can't offset by '${offset}', offset must be a valid number`)\n\n const integerOffset = Math.round(offset)\n if (offset !== integerOffset) throw new Error(`Can't offset by '${offset}', offset must be an integer number`)\n\n this.currentOffset = offset\n return this\n }\n\n /**\n * Limits the number of documents that get returned when querying a collection\n * for matching documents.\n *\n * @param limit The maximum number of documents that will be returned.\n *\n * @return A {@link PendingCursorOperation} that you can chain further\n * function calls and then either get the matching documents immediately or\n * get updates about them over time.\n */\n limit(limit: number): PendingCursorOperation {\n // REFACTOR: factor out parameter validation.\n\n if (limit < -1) throw new Error(`Can't limit to '${limit}', limit must be >= -1 (where -1 means unlimited)`)\n if (!Number.isFinite(limit)) throw new Error(`Can't limit to '${limit}', limit must be a finite number`)\n if (Number.isNaN(limit)) throw new Error(`Can't limit to '${limit}', limit must be a valid number`)\n\n const integerLimit = Math.round(limit)\n if (limit !== integerLimit) throw new Error(`Can't limit to '${limit}', limit must be an integer number`)\n\n this.currentLimit = limit\n return this\n }\n\n /**\n * Enables you to subscribe to changes that occur in a collection remotely.\n *\n * Having a subscription acts as a signal to other peers that you are\n * interested in receiving updates when local or remote changes are made to\n * documents that match the query generated by the chain of operations that\n * precedes the call to {@link subscribe | subscribe()}.\n *\n * The returned {@link Subscription} object must be kept in scope for as long\n * as you want to keep receiving updates.\n *\n * @returns A {@link Subscription} object that must be kept in scope for as\n * long as you want to keep receiving updates for documents that match the\n * query specified in the preceding chain.\n */\n subscribe(): Subscription {\n return new Subscription(this.collection, this.query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)\n }\n\n /**\n * Enables you to listen for changes that occur in a collection locally.\n *\n * The `handler` block will be called when local changes are\n * made to documents that match the query generated by the chain of operations\n * that precedes the call to {@link PendingCursorOperation.observeLocal | observeLocal()}.\n * The returned {@link LiveQuery} object must be kept in scope for as long as\n * you want the provided `handler` to be called when an update occurs.\n *\n * This won't subscribe to receive changes made remotely by others and so it\n * will only fire updates when a local change is made. If you want to receive\n * remotely performed updates as well, you'll have to create a subscription\n * via {@link PendingCursorOperation.subscribe | subscribe()} with the\n * relevant query. The returned {@link LiveQuery} object must be kept in scope\n * for as long as you want the provided `eventHandler` to be called when an\n * update occurs.\n *\n * @param handler A closure that will be called every time there is a\n * transaction committed to the store that involves modifications to documents\n * matching the query in the collection this method was called on.\n *\n * @return A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocal(handler: QueryObservationHandler): LiveQuery {\n return this._observe(handler, false, false)\n }\n\n /**\n * Enables you to listen for changes that occur in a collection locally and\n * to signal when you are ready for the live query to deliver the next event.\n *\n * The `handler` block will be called when local changes are\n * made to documents that match the query generated by the chain of operations\n * that precedes the call to {@link PendingCursorOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}.\n * The returned {@link LiveQuery} object must be kept in scope for as long as\n * you want the provided `handler` to be called when an update occurs.\n *\n * This won't subscribe to receive changes made remotely by others and so it\n * will only fire updates when a local change is made. If you want to receive\n * remotely performed updates as well, you'll have to create a subscription\n * via {@link PendingCursorOperation.subscribe | subscribe()} with the\n * relevant query. The returned {@link LiveQuery} object must be kept in scope\n * for as long as you want the provided `eventHandler` to be called when an\n * update occurs.\n *\n * @param handler A closure that will be called every time there is a\n * transaction committed to the store that involves modifications to\n * documents matching the query in the collection that this method was called\n * on.\n *\n * @return A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocalWithNextSignal(handler: QueryObservationHandler): LiveQuery {\n return this._observe(handler, false, true)\n }\n\n /**\n * Removes all documents that match the query generated by the preceding\n * function chaining.\n *\n * @returns An array promise containing the IDs of the documents that were\n * removed.\n */\n async remove(): Promise<DocumentID[]> {\n const query = this.query\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n\n const documentsX = await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n const documentsX = await FFI.collectionRemoveQueryStr(dittoX, this.collection.name, writeTransactionX, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n return documentsX\n })\n\n return documentsX.map((idCBOR) => {\n return new DocumentID(idCBOR, true)\n })\n }\n\n /**\n * Evicts all documents that match the query generated by the preceding\n * function chaining.\n *\n * @return An array promise containing the IDs of the documents that were\n * evicted.\n */\n async evict(): Promise<DocumentID[]> {\n const query = this.query\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n\n const documentsX = await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n const documentsX = await FFI.collectionEvictQueryStr(dittoX, this.collection.name, writeTransactionX, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n return documentsX\n })\n\n return documentsX.map((idCBOR) => {\n return new DocumentID(idCBOR, true)\n })\n }\n\n /**\n * Executes the query generated by the preceding function chaining and return\n * the list of matching documents.\n *\n * @returns An array promise containing {@link Document | documents} matching\n * the query generated by the preceding function chaining.\n */\n async exec(): Promise<Document[]> {\n const query = this.query\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n\n const documentsX = await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n return await FFI.collectionExecQueryStr(dittoX, this.collection.name, null, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)\n })\n\n return documentsX.map((documentX) => {\n return documentBridge.bridge(documentX)\n })\n }\n\n /**\n * Updates documents that match the query generated by the preceding function\n * chaining.\n *\n * @param closure A closure that gets called with all of the documents\n * matching the query. The documents are instances of {@link MutableDocument}\n * so you can call update-related functions on them.\n *\n * @returns An {@link UpdateResultsMap} promise mapping document IDs to lists\n * of {@link UpdateResult | update results} that describe the updates that\n * were performed for each document.\n */\n async update(closure: (documents: MutableDocument[]) => void): Promise<UpdateResultsMap> {\n return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const query = this.query\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n const documentsX = await FFI.collectionExecQueryStr(dittoX, this.collection.name, writeTransactionX, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)\n\n const mutableDocuments = documentsX.map((documentX) => {\n return mutableDocumentBridge.bridge(documentX, () => new MutableDocument())\n })\n\n closure(mutableDocuments)\n\n const updateResultsDocumentIDs = []\n const updateResultsByDocumentIDString = {}\n\n for (const mutableDocument of mutableDocuments) {\n const documentID = mutableDocument.id\n const documentIDString = documentID.toString()\n const updateResults = mutableDocument['@ditto.updateResults']\n\n if (updateResultsByDocumentIDString[documentIDString]) {\n // HACK: in theory, 2 different document IDs can have the exact\n // same string representation at the time of this writing. There is\n // already a REFACTOR comment in `UpdateResultsMap` to implement a\n // proper and correct data structure for holding these update results.\n // Until then, we'll leave this check here to see how often we hit\n // this edge case.\n throw new Error(`Internal inconsistency, update results for document ID as string already exist: ${documentIDString}`)\n }\n\n updateResultsDocumentIDs.push(documentID)\n updateResultsByDocumentIDString[documentIDString] = updateResults\n\n const documentX = mutableDocumentBridge.pointerFor(mutableDocument)\n mutableDocumentBridge.unregister(mutableDocument)\n }\n\n // NOTE: ownership of documentsX (and contained documents)\n // is transferred to Rust at this point.\n await FFI.collectionUpdateMultiple(dittoX, this.collection.name, writeTransactionX, documentsX)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n\n return new UpdateResultsMap(updateResultsDocumentIDs, updateResultsByDocumentIDString)\n })\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n constructor(query: string, queryArgs: QueryArguments | null, collection: Collection) {\n this.query = validateQuery(query)\n this.queryArgs = queryArgs ? Object.freeze({ ...queryArgs }) : null\n this.collection = collection\n this.queryArgsCBOR = queryArgs ? CBOR.encode(queryArgs) : null\n }\n\n /** @internal */\n _observe(handler: QueryObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery {\n const subscription = createSubscription ? this.subscribe() : null\n\n function wrappedHandler(documents, event, nextSignal) {\n try {\n return handler.call(this, documents, event)\n } finally {\n nextSignal()\n }\n }\n\n const handlerOrWrapped: QueryObservationHandler = waitForNextSignal ? handler : wrappedHandler\n return new LiveQuery(this.query, this.queryArgs, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset, this.collection, subscription, handlerOrWrapped)\n }\n\n /** @internal */\n then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {\n return this.exec().then(onfulfilled, onrejected)\n }\n\n // ------------------------------------------------------------ Private ------\n\n private queryArgsCBOR: Uint8Array | null\n private currentLimit = -1\n private currentOffset = 0\n private orderBys: FFI.OrderBy[] = []\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\nimport { Subscription } from './subscription.js'\n\nimport { DocumentID } from './document-id.js'\nimport { validateDocumentIDCBOR } from './document-id.js'\nimport { Document, MutableDocument } from './document.js'\n\nimport { UpdateResult } from './update-result.js'\nimport { UpdateResultsMap } from './update-results-map.js'\n\nimport { LiveQuery } from './live-query.js'\nimport { SingleDocumentLiveQueryEvent } from './live-query-event.js'\n\nimport { CBOR } from './cbor.js'\nimport { documentBridge, mutableDocumentBridge } from './document.js'\nimport { dittoBridge } from './ditto.js'\nimport { Logger } from './logger.js'\nimport { performAsyncToWorkaroundNonAsyncFFIAPI } from './internal.js'\n\nimport type { Collection } from './collection.js'\nimport { Sync } from './sync.js'\n\n// REFACTOR: turn null into undefined for consistency.\n\n/**\n * The closure that is called whenever a single documunent covered by a\n * live query changes.\n */\nexport type SingleObservationHandler = (document: Document | null, event: SingleDocumentLiveQueryEvent, signalNext?: () => void) => void | Promise<void>\n\n// -----------------------------------------------------------------------------\n\n/**\n * These objects are returned when using {@link Collection.findByID | findByID()}\n * functionality on {@link Collection | collections}.\n *\n * You can either call {@link exec | exec()} on the object to get an immediate\n * return value, or you can establish either a live query or a subscription,\n * which both work over time.\n *\n * A live query, established by calling\n * {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, will notify\n * you every time there's an update to the document with the ID you provided in\n * the preceding {@link Collection.findByID | findByID()} call.\n *\n * A subscription, established by calling {@link PendingIDSpecificOperation.subscribe | subscribe()}, will\n * act as a signal to other peers that you would like to receive updates from\n * them about the document with the ID you provided in the preceding\n * {@link Collection.findByID | findByID()} call.\n *\n * Update and remove functionality is also exposed through this object.\n */\nexport class PendingIDSpecificOperation implements PromiseLike<Document | undefined> {\n /** The ID of the document this operation operates on. */\n readonly documentID: DocumentID\n\n /** The collection the receiver is operating on. */\n readonly collection: Collection\n\n /**\n * Enables you to subscribe to changes that occur in relation to a document\n * remotely.\n *\n * Having a subscription acts as a signal to other peers that you are\n * interested in receiving updates when local or remote changes are made to\n * the relevant document.\n *\n * The returned {@link Subscription} object must be kept in scope for as long\n * as you want to keep receiving updates.\n *\n * @returns A {@link Subscription} object that must be kept in scope for as\n * long as you want to keep receiving updates for the document.\n */\n subscribe(): Subscription {\n return new Subscription(this.collection, this.query, null, [], -1, 0)\n }\n\n /**\n * Enables you to listen for changes that occur in relation to a document\n * locally.\n *\n * This won't subscribe to receive changes made remotely by others and so it\n * will only fire updates when a local change is made. If you want to receive\n * remotely performed updates as well, you'll have to create a subscription\n * via {@link PendingIDSpecificOperation.subscribe | subscribe()} for the same\n * document ID.\n *\n * The returned {@link LiveQuery} object must be kept in scope for as long\n * as you want the provided `handler` to be called when an update\n * occurs.\n *\n * @param handler A block that will be called every time there is a\n * transaction committed to the store that involves a modification to the\n * document with the relevant ID in the collection that\n * {@link PendingIDSpecificOperation.observeLocal | observeLocal()} was called on.\n *\n * @returns A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocal(handler: SingleObservationHandler): LiveQuery {\n return this._observe(handler, false, false)\n }\n\n /**\n * Enables you to listen for changes that occur in relation to a document\n * locally and to signal when you are ready for the live query to deliver\n * the next event.\n *\n * This won't subscribe to receive changes made remotely by others and so it\n * will only fire updates when a local change is made. If you want to receive\n * remotely performed updates as well, you'll have to create a subscription\n * via {@link PendingIDSpecificOperation.subscribe | subscribe()} for the same\n * document ID.\n *\n * The returned {@link LiveQuery} object must be kept in scope for as long\n * as you want the provided `handler` to be called when an update\n * occurs.\n *\n * @param handler A block that will be called every time there is a\n * transaction committed to the store that involves a modification to the\n * document with the relevant ID in the collection that\n * {@link PendingIDSpecificOperation.observeLocal | observeLocal()} was called on.\n *\n * @returns A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocalWithNextSignal(handler: SingleObservationHandler): LiveQuery {\n return this._observe(handler, false, true)\n }\n\n /**\n * Removes the document with the matching ID.\n *\n * @returns `true` promise if the document was found and removed. `false`\n * promise if the document wasn't found and therefore wasn't removed.\n */\n async remove(): Promise<boolean> {\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n const didRemove = await FFI.collectionRemove(dittoX, this.collection.name, writeTransactionX, this.documentIDCBOR)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n return didRemove\n })\n }\n\n /**\n * Evicts the document with the matching ID.\n *\n * @returns `true` promise if the document was found and evicted. `false`\n * promise if the document wasn't found and therefore wasn't evicted.\n */\n async evict(): Promise<boolean> {\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n const didEvict = await FFI.collectionEvict(dittoX, this.collection.name, writeTransactionX, this.documentIDCBOR)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n return didEvict\n })\n }\n\n /**\n * Executes the find operation to return the document with the matching ID.\n *\n * @returns The {@link Document} promise with the ID provided in the\n * {@link Collection.findByID | findByID()} call or `undefined` if the document was\n * not found.\n */\n async exec(): Promise<Document | undefined> {\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n\n return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n const readTransactionX = await FFI.readTransaction(dittoX)\n const documentX = await FFI.collectionGet(dittoX, this.collection.name, this.documentIDCBOR, readTransactionX)\n\n let document: Document = undefined\n if (documentX) document = documentBridge.bridge(documentX)\n\n FFI.readTransactionFree(readTransactionX)\n return document\n })\n }\n\n /**\n * Updates the document with the matching ID.\n *\n * @param closure A closure that gets called with the document matching the\n * ID. If found, the document is a {@link MutableDocument}, so you can call\n * update-related functions on it. If the document is not found then the value\n * provided to the closure will be `undefined`.\n *\n * @return An array promise of {@link UpdateResult | update results} that\n * describe the updates that were performed on the document.\n */\n async update(closure: (document: MutableDocument) => void): Promise<UpdateResult[]> {\n const dittoX = dittoBridge.pointerFor(this.collection.store.ditto)\n const readTransactionX = await FFI.readTransaction(dittoX)\n const documentX = await FFI.collectionGet(dittoX, this.collection.name, this.documentIDCBOR, readTransactionX)\n FFI.readTransactionFree(readTransactionX)\n\n if (!documentX) throw new Error(`Can't update, document with ID '${this.documentID.toString()}' not found in collection named '${this.collection.name}'`)\n\n const mutableDocument = mutableDocumentBridge.bridge(documentX, () => new MutableDocument())\n closure(mutableDocument)\n\n // Ownership is transferred back to the FFI layer via collectionUpdate(),\n // we therefore need to explicitly unregister the instance.\n mutableDocumentBridge.unregister(mutableDocument)\n\n const writeTransactionX = await FFI.writeTransaction(dittoX)\n await FFI.collectionUpdate(dittoX, this.collection.name, writeTransactionX, documentX)\n await FFI.writeTransactionCommit(dittoX, writeTransactionX)\n\n return mutableDocument['@ditto.updateResults'].slice()\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n constructor(documentID: DocumentID, collection: Collection) {\n this.documentID = documentID\n this.collection = collection\n this.documentIDCBOR = documentID.toCBOR()\n }\n\n /** @internal */\n _observe(handler: SingleObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery {\n const subscription = createSubscription ? this.subscribe() : null\n\n return new LiveQuery(this.query, null, null, [], -1, 0, this.collection, subscription, (documents, event, signalNext) => {\n if (documents.length > 1) {\n const documentIDsAsBase64Strings = documents.map((document) => document.id.toBase64String())\n throw new Error(`Internal inconsistency, single document live query returned more than one document. Query: ${this.query}, documentIDs: ${documentIDsAsBase64Strings.join(', ')}.`)\n }\n\n if (event.isInitial === false && event.oldDocuments.length > 1) throw new Error(`Internal inconsistency, single document live query returned an update event with more than one old documents. Query ${this.query}.`)\n if (event.isInitial === false && event.insertions.length > 1) throw new Error(`Internal inconsistency, single document live query returned an update event with more than one insertion, which doesn't make sense for single document observations. Query ${this.query}.`)\n if (event.isInitial === false && event.deletions.length > 1) throw new Error(`Internal inconsistency, single document live query returned an update event with more than one deletion, which doesn't make sense for single document observations. Query ${this.query}.`)\n if (event.isInitial === false && event.updates.length > 1) throw new Error(`Internal inconsistency, single document live query returned an update event with more than one update, which doesn't make sense for single document observations. Query ${this.query}.`)\n if (event.isInitial === false && event.moves.length > 0) throw new Error(`Internal inconsistency, single document live query returned an update event with moves, which doesn't make sense for single document observations. Query ${this.query}.`)\n\n const totalNumberOfManipulations = event.isInitial === true ? 0 : event.insertions.length + event.deletions.length + event.updates.length\n if (totalNumberOfManipulations > 1) throw new Error(`Internal inconsistency, single document live query returned a combination of inserts, updates, and/or deletes, which doesn't make sense for single document observation. Query ${this.query}.`)\n\n // IDEA: use `undefined` instead of `null` and\n // adapt Wasm variant plus API definition.\n const document = documents[0] || null\n const oldDocument = event.isInitial === true ? undefined : event.oldDocuments[0]\n\n const singleDocumentEvent = new SingleDocumentLiveQueryEvent(event.isInitial, oldDocument)\n if (waitForNextSignal) {\n handler(document, singleDocumentEvent, signalNext)\n } else {\n try {\n handler(document, singleDocumentEvent)\n } finally {\n signalNext()\n }\n }\n })\n }\n\n /** @internal */\n then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {\n return this.exec().then(onfulfilled, onrejected)\n }\n\n // ------------------------------------------------------------ Private ------\n\n private documentIDCBOR: Uint8Array\n\n private get query(): string {\n return `_id == ${this.documentID.toQueryCompatibleString()}`\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\nimport { QueryArguments, WriteStrategy } from './essentials.js'\nimport { Logger } from './logger.js'\nimport { CBOR } from './cbor.js'\nimport { DocumentValue } from './document.js'\nimport { DocumentID, DocumentIDValue } from './document-id.js'\nimport { validateDocumentIDValue, validateDocumentIDCBOR } from './document-id.js'\nimport { Attachment, attachmentBridge } from './attachment.js'\nimport { AttachmentToken } from './attachment-token.js'\nimport { AttachmentFetcher } from './attachment-fetcher.js'\nimport { PendingCursorOperation } from './pending-cursor-operation.js'\nimport { PendingIDSpecificOperation } from './pending-id-specific-operation.js'\n\nimport { isWebBuild, sleep } from './internal.js'\nimport { performAsyncToWorkaroundNonAsyncFFIAPI } from './internal.js'\n\nimport { dittoBridge } from './ditto.js'\nimport { desugarJSObject } from './augment.js'\nimport type { Store } from './store.js'\n\nexport type UpsertOptions = {\n writeStrategy?: WriteStrategy\n}\n\n/**\n * Represents a collection of a Ditto store.\n *\n * This is the entrypoint for inserting documents into a collection, as well as\n * querying a collection. You can get a collection by calling\n * {@link Store.collection | collection()} on a {@link Store} of a {@link Ditto}\n * object.\n */\nexport class Collection {\n /** The name of the collection. */\n readonly name: string\n\n /** The store this collection belongs to. */\n readonly store: Store\n\n /**\n * Generates a {@link PendingCursorOperation} using the provided query.\n *\n * The returned object can be used to find and return the documents or you can\n * chain a call to `observeLocal()` or `subscribe()` if you want to get\n * updates about the list of matching documents over time. It can also be used\n * to update, remove or evict the matching documents.\n *\n * You can incorporate dynamic data into the query string with placeholders in\n * the form of `$args.my_arg_name`, along with providing an accompanying\n * dictionary in the form of `{ \"my_arg_name\": \"some value\" }`. The\n * placeholders will be appropriately replaced by the corresponding argument\n * contained in `queryArgs`. This includes handling things like wrapping\n * strings in quotation marks and arrays in square brackets, for example.\n *\n * @param query The query to run against the collection.\n * @param queryArgs The arguments to use to replace placeholders in the\n * provided query.\n */\n find(query: string, queryArgs?: QueryArguments): PendingCursorOperation {\n return new PendingCursorOperation(query, queryArgs ?? null, this)\n }\n\n /**\n * Convenience method, equivalent to calling {@link find | find()} and passing\n * the query `\"true\"`.\n */\n findAll(): PendingCursorOperation {\n return this.find('true')\n }\n\n /**\n * Generates a {@link PendingIDSpecificOperation} with the provided document\n * ID.\n *\n * The returned object can be used to find and return the document or you can\n * chain a call to\n * {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, or\n * {@link PendingIDSpecificOperation.subscribe | subscribe()} if you want to\n * get updates about the document over time. It can also be used to update,\n * remove or evict the document.\n *\n * @param id The ID of the document to find.\n */\n findByID(id: DocumentID | DocumentIDValue): PendingIDSpecificOperation {\n const documentID: DocumentID = id instanceof DocumentID ? id : new DocumentID(id)\n return new PendingIDSpecificOperation(documentID, this)\n }\n\n /**\n * Inserts a new document into the collection and returns its ID. If the\n * document already exists, the contents of both are merged by default. You\n * can change this by providing a different `writeStrategy` via `options`.\n *\n * @param value The content for the new document to insert or update.\n *\n * @param options.writeStrategy Specifies the desired strategy for inserting a\n * document, defaults to `'merge'`.\n */\n async upsert(value: DocumentValue, options: UpsertOptions = {}): Promise<DocumentID> {\n const writeStrategy = options.writeStrategy ?? 'merge'\n\n const ditto = this.store.ditto\n const dittoPointer = dittoBridge.pointerFor(ditto)\n\n const id = value._id\n let documentID: DocumentID\n\n if (typeof id === 'undefined') {\n documentID = undefined\n } else if (id instanceof DocumentID) {\n documentID = id\n } else {\n documentID = new DocumentID(id)\n }\n\n const documentIDCBOR = typeof documentID === 'undefined' ? null : documentID.toCBOR()\n\n const documentValueJSON = desugarJSObject(value, true)\n const documentValueCBOR = CBOR.encode(documentValueJSON)\n\n const idCBOR = await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {\n return await FFI.collectionInsertValue(dittoPointer, this.name, documentValueCBOR, documentIDCBOR, writeStrategy)\n })\n\n return new DocumentID(idCBOR, true)\n }\n\n /**\n * Creates a new {@link Attachment} object, which can then be inserted into a\n * document. Node only, throws when running in the web browser.\n *\n * The file residing at the provided path will be copied into Ditto's store.\n * The {@link Attachment} object that is returned is what you can then use to\n * insert an attachment into a document.\n *\n * You can provide metadata about the attachment, which will be replicated to\n * other peers alongside the file attachment.\n *\n * Below is a snippet to show how you can use the\n * {@link newAttachment | newAttachment()} functionality to insert an\n * attachment into a document.\n *\n * ``` JavaScript\n * const attachment = await collection.newAttachment('/path/to/my/file.pdf')\n * await collection.upsert({ _id: '123', attachment, other: 'some-string' })\n * }\n * ```\n *\n * @param pathOrData The path to the file that you want to create an\n * attachment with or the raw data.\n *\n * @param metadata Metadata relating to the attachment.\n */\n async newAttachment(pathOrData: string | Uint8Array, metadata: { [key: string]: string } = {}): Promise<Attachment> {\n const ditto = this.store.ditto\n const dittoPointer = dittoBridge.pointerFor(ditto)\n\n const { id, len, handle } = await (async () => {\n if (typeof pathOrData === 'string') {\n webBuildOnly: {\n throw new Error(`Can't create attachment from file when running in the browser. Please pass the raw data (as a Uint8Array) instead.`)\n }\n\n nodeBuildOnly: {\n return FFI.dittoNewAttachmentFromFile(dittoPointer, pathOrData as string, 'Copy')\n }\n }\n\n if (pathOrData instanceof Uint8Array) {\n return await FFI.dittoNewAttachmentFromBytes(dittoPointer, pathOrData)\n }\n\n throw new Error(`Can't create new attachment, only file path as string or raw data as Uint8Array are supported, but got: ${typeof pathOrData}, ${pathOrData}`)\n })()\n\n const attachmentTokenJSON = { _id: id, _len: len, _meta: { ...metadata } }\n attachmentTokenJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.attachment\n\n const attachmentToken = new AttachmentToken(attachmentTokenJSON)\n const attachment = new Attachment(ditto, attachmentToken)\n\n return attachmentBridge.bridge(handle, () => attachment, { throwIfAlreadyBridged: true })\n }\n\n /**\n * Trigger an attachment to be downloaded locally to the device and observe\n * its progress as it does so.\n *\n * When you encounter a document that contains an attachment the attachment\n * will not automatically be downloaded along with the document. You trigger\n * an attachment to be downloaded locally to a device by calling this method.\n * It will report events relating to the attachment fetch attempt as it tries\n * to download it. The `eventHandler` block may be called multiple times with\n * progress events. It will then be called with either a `Completed` event or\n * a `Deleted` event. If downloading the attachment succeeds then the\n * `Completed` event that the `eventHandler` will be called with will hold a\n * reference to the downloaded attachment.\n *\n * @param token The {@link AttachmentToken} relevant to the attachment that\n * you wish to download and observe. Throws if token is invalid.\n *\n * @param eventHandler An optional callback that will be called when there is\n * an update to the status of the attachment fetch attempt.\n *\n * @return An `AttachmentFetcher` object, which must be kept alive for the\n * fetch request to proceed and for you to be notified about the attachment's\n * fetch status changes.\n */\n fetchAttachment(token: AttachmentToken, eventHandler?: (AttachmentFetchEvent) => void): AttachmentFetcher {\n const ditto = this.store.ditto\n return new AttachmentFetcher(ditto, token, eventHandler)\n }\n\n /** @internal */\n constructor(name: string, store: Store) {\n this.name = name\n this.store = store\n }\n\n // TEMPORARY: helpers to deal with non-canonical IDs.\n\n /** @internal */\n findByIDCBOR(idCBOR: Uint8Array): PendingIDSpecificOperation {\n const documentID = new DocumentID(idCBOR, true, true)\n return new PendingIDSpecificOperation(documentID, this)\n }\n}\n","//\n// Copyright (c) 2020 - 2021 DittoLive Inc. All rights reserved.\n//\n\nimport type { Collection } from './collection.js'\nimport type { LiveQueryMove } from './live-query-event.js'\n\n// -----------------------------------------------------------------------------\n\n/** @internal */\nexport interface CollectionsEventParams {\n isInitial: boolean\n collections: Collection[]\n oldCollections: Collection[]\n insertions: number[]\n deletions: number[]\n updates: number[]\n moves: LiveQueryMove[]\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Provides information about the changes that have occurred in relation to an\n * event delivered when observing the collections in a {@link Store}.\n *\n * It contains information about the collections that are known about as well as\n * the collections that were previously known about in the previous event, along\n * with information about what collections have been inserted, deleted, updated,\n * or moved since the last event.\n */\nexport class CollectionsEvent {\n /**\n * Indicates whether or not this is the first event to be delivered when\n * observing collections in the store.\n */\n readonly isInitial: boolean\n\n /**\n * A list of all of the known collections.\n */\n readonly collections: Collection[]\n\n /**\n * A list of all of the known collections at the time the previous event was\n * delivered.\n */\n readonly oldCollections: Collection[]\n\n /**\n * A list of the indexes in the list of currently known about collections at\n * which new collections have been inserted.\n */\n readonly insertions: number[]\n\n /**\n * A list of the indexes in the list of previously known about collections at\n * which collections have been removed.\n */\n readonly deletions: number[]\n\n /**\n * A list of the indexes in the list of currently known about collections at\n * which pre-existing collections have been updated.\n */\n readonly updates: number[]\n\n /**\n * A list of the tuples that provides the indexes, in relation to the list of\n * previously known about collections, that already known about collections\n * have moved from and the indexes, in relation to the list of currently known\n * about collections, that the collections have moved to.\n */\n readonly moves: LiveQueryMove[]\n\n /** @internal */\n static initial(collections: Collection[]): CollectionsEvent {\n return new CollectionsEvent({\n isInitial: true,\n collections: collections,\n oldCollections: [],\n insertions: [],\n deletions: [],\n updates: [],\n moves: [],\n })\n }\n\n /** @internal */\n constructor(params: CollectionsEventParams) {\n this.isInitial = params.isInitial\n this.collections = params.collections\n this.oldCollections = params.oldCollections\n this.insertions = params.insertions\n this.deletions = params.deletions\n this.updates = params.updates\n this.moves = params.moves\n }\n}\n","//\n// Copyright (c) 2020 - 2021 DittoLive Inc. All rights reserved.\n//\n\nimport { SortDirection } from './essentials.js'\n\nimport { Collection } from './collection.js'\nimport { Document } from './document.js'\nimport { Store } from './store.js'\nimport { Subscription } from './subscription.js'\nimport { PendingCursorOperation } from './pending-cursor-operation.js'\n\nimport { CollectionsEvent } from './collections-event.js'\nimport { LiveQuery } from './live-query.js'\nimport { Logger } from './logger.js'\n\n// -----------------------------------------------------------------------------\n\n/**\n * The closure that is called whenever the collections covered by a live query\n * change.\n */\nexport type CollectionsObservationHandler = (event: CollectionsEvent, signalNext?: () => void) => void | Promise<void>\n\n// -----------------------------------------------------------------------------\n\n/**\n * These objects are returned when calling\n * {@link Store.collections | collections()} on {@link Store}.\n *\n * They allow chaining of further collections-related functions. You can either\n * call {@link exec | exec()} on the object to get an array of\n * {@link Collection}s as an immediate return value, or you can establish either\n * a live query or a subscription, which both work over time.\n *\n * A live query, established by calling\n * {@link PendingCollectionsOperation.observeLocal | observeLocal()}, will\n * notify you every time there's a change in the collections that the device\n * knows about.\n *\n * A subscription, established by calling {@link subscribe | subscribe()}, will\n * act as a signal to other peers that the device connects to that you would\n * like to receive updates from them about the collections that they know about.\n */\nexport class PendingCollectionsOperation implements PromiseLike<Collection[]> {\n /**\n * Sort the collections based on a property of the collection.\n *\n * @param propertyPath The property path specifies the logic to be used when\n * sorting the matching collections.\n *\n * @param direction Specify whether you want the sorting order to be\n * `Ascending` or `Descending`.\n *\n * @return A {@link PendingCollectionsOperation} that you can chain further\n * function calls to.\n */\n sort(propertyPath: string, direction: SortDirection = 'ascending'): PendingCollectionsOperation {\n this.pendingCursorOperation.sort(propertyPath, direction)\n return this\n }\n\n /**\n * Offset the resulting set of collections.\n *\n * This is useful if you aren't interested in the first N collections for one\n * reason or another. For example, you might already have obtained the first\n * 20 collections and so you might want to get the next 20 collections, and\n * that is when you would use {@link offset | offset()}.\n *\n * @param offset The number of collections that you want the eventual\n * resulting set of collections to be offset by (and thus not include).\n *\n * @return A {@link PendingCollectionsOperation} that you can chain further\n * function calls to.\n */\n offset(offset: number): PendingCollectionsOperation {\n this.pendingCursorOperation.offset(offset)\n return this\n }\n\n /**\n * Limit the number of collections that get returned.\n *\n * @param limit The maximum number of collections that will be returned.\n *\n * @return A {@link PendingCollectionsOperation} that you can chain further\n * function calls to.\n */\n limit(limit: number): PendingCollectionsOperation {\n this.pendingCursorOperation.limit(limit)\n return this\n }\n\n /**\n * Subscribes the device to updates about collections that other devices know\n * about.\n *\n * The returned {@link Subscription} object must be kept in scope for as long\n * as you want to keep receiving updates.\n *\n * @return A {@link Subscription} object that must be kept in scope for as\n * long as you want to keep receiving updates from other devices about the\n * collections that they know about.\n */\n subscribe(): Subscription {\n return this.pendingCursorOperation.subscribe()\n }\n\n /**\n * Enables you to listen for changes that occur in relation to the collections\n * that are known about locally.\n *\n * The returned {@link LiveQuery} object must be kept in scope for as long as\n * you want the provided `handler` to be called when an update occurs.\n *\n * This won't subscribe to receive updates from other devices and so it will\n * only fire when a local change to the known about collections occurs. If\n * you want to receive remote updates as well, then create a subscription via\n * {@link PendingCollectionsOperation.subscribe | subscribe()}.\n *\n * @param handler A closure that will be called every time there is an update\n * about the list of known about collections.\n *\n * @return A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocal(handler: CollectionsObservationHandler): LiveQuery {\n return this._observe(handler, false, false)\n }\n\n /**\n * Enables you to listen for changes that occur in relation to the collections\n * that are known about locally.\n *\n * The returned {@link LiveQuery} object must be kept in scope for as long as\n * you want the provided `handler` to be called when an update occurs.\n *\n * This won't subscribe to receive updates from other devices and so it will\n * only fire when a local change to the known about collections occurs. If\n * you want to receive remote updates as well, then create a subscription via\n * {@link PendingCollectionsOperation.subscribe | subscribe()}.\n *\n * @param handler A closure that will be called every time there is an update\n * about the list of known about collections.\n *\n * @return A {@link LiveQuery} object that must be kept in scope for as long\n * as you want to keep receiving updates.\n */\n observeLocalWithNextSignal(handler: CollectionsObservationHandler): LiveQuery {\n return this._observe(handler, false, true)\n }\n\n /**\n * Return the list of collections requested based on the preceding function\n * chaining.\n *\n * @return A list of {@link Collection}s based on the preceding function\n * chaining.\n */\n async exec(): Promise<Collection[]> {\n const documents = await this.pendingCursorOperation.exec()\n return collectionsFromDocuments(documents, this.store)\n }\n\n /** @internal */\n readonly store: Store\n\n /** @internal */\n constructor(store: Store) {\n this.store = store\n this.pendingCursorOperation = new PendingCursorOperation('true', null, new Collection('__collections', store))\n }\n\n /** @internal */\n then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {\n return this.exec().then(onfulfilled, onrejected)\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n _observe(handler: CollectionsObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery {\n const weakThis = new WeakRef(this)\n const collectionsObservationHandler = function (documents, event, nextSignal) {\n const strongThis = weakThis.deref()\n if (strongThis === null) return\n\n const collections = collectionsFromDocuments(documents, strongThis.store)\n let collEvent: CollectionsEvent\n\n if (event.isInitial === true) {\n collEvent = CollectionsEvent.initial(collections)\n } else {\n const oldCollections = collectionsFromDocuments(event.oldDocuments, strongThis.store)\n collEvent = new CollectionsEvent({\n isInitial: false,\n collections,\n oldCollections,\n insertions: event.insertions,\n deletions: event.deletions,\n updates: event.updates,\n moves: event.moves,\n })\n }\n\n if (waitForNextSignal) {\n handler(collEvent, nextSignal)\n } else {\n handler(collEvent)\n }\n }\n\n return this.pendingCursorOperation._observe(collectionsObservationHandler, createSubscription, waitForNextSignal)\n }\n\n // ------------------------------------------------------------ Private ------\n\n private readonly pendingCursorOperation: PendingCursorOperation\n}\n\n/** @private */\nfunction collectionsFromDocuments(documents: Document[], store: Store): Collection[] {\n const collections: Collection[] = []\n for (const document of documents) {\n const collectionName = document.at('name').value\n if (collectionName !== undefined && typeof collectionName === 'string') {\n collections.push(new Collection(collectionName, store))\n }\n }\n return collections\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { CBOR } from './cbor.js'\nimport { Collection } from './collection.js'\nimport { PendingCollectionsOperation } from './pending-collections-operation.js'\nimport { validateQuery } from './internal.js'\nimport { dittoBridge } from './ditto.js'\nimport type { Ditto } from './ditto.js'\nimport { DocumentID } from './document-id.js'\n\n/**\n * The entrypoint for all actions that relate to data stored by Ditto. Provides\n * access to collections, a write transaction API, and a query hash API.\n *\n * You don't create one directly but can access it from a particular {@link Ditto}\n * instance via its {@link Ditto.store | store} property.\n */\nexport class Store {\n /** The {@link Ditto} instance this store belongs to. */\n readonly ditto: Ditto\n\n /**\n * Returns the collection for the given name. If the collection doesn't\n * exist yet, it will be created automatically as soon as the first\n * entry is inserted.\n */\n collection(name: string): Collection {\n return new Collection(name, this)\n }\n\n /**\n * Returns an object that lets you fetch or observe the collections in the\n * store.\n *\n * @return A {@link PendingCollectionsOperation} object that you can use to\n * fetch or observe the collections in the store\n */\n collections(): PendingCollectionsOperation {\n return new PendingCollectionsOperation(this.ditto.store)\n }\n\n /**\n * Returns the names of all available collections in the store of the\n * related {@link Ditto} instance.\n */\n collectionNames(): Promise<string[]> {\n return FFI.dittoGetCollectionNames(dittoBridge.pointerFor(this.ditto))\n }\n\n // ----------------------------------------------------------- Internal ------\n\n /** @internal */\n constructor(ditto: Ditto) {\n this.ditto = ditto\n }\n\n /**\n * Private method, used only by the Portal https://github.com/getditto/ditto/pull/3652\n * @internal\n */\n async registerLiveQueryWebhook(collectionName: string, query: string, url: string): Promise<DocumentID> {\n const validatedQuery = validateQuery(query)\n const idCBOR = await FFI.liveQueryWebhookRegister(dittoBridge.pointerFor(this.ditto), collectionName, validatedQuery, [], 0, 0, url)\n return new DocumentID(idCBOR, true)\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { dittoBridge } from './ditto.js'\nimport { KeepAlive } from './keep-alive.js'\nimport { Observer } from './observer.js'\nimport { ObserverManager } from './observer-manager.js'\nimport type { Ditto } from './ditto.js'\n\n/** Types of connections that can be established between two peers. */\nexport type ConnectionType = 'P2PWiFi' | 'WebSocket' | 'AccessPoint' | 'Bluetooth'\n\n// -----------------------------------------------------------------------------\n\n/**\n * An opaque address uniquely identifying another peer on the Ditto mesh\n * network.\n *\n * IMPORTANT: You should not rely on the individual components of the address,\n * those can change at any time. Please use\n * {@link addressToString | addressToString()} to compare individual addresses\n * with each other.\n */\nexport type Address = {\n siteId: string\n pubkey: Uint8Array\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Returns a string representation of the given address. Use this function\n * to compare multiple addresses or whenever you need the address to be a key\n * in a hash object.\n */\nexport function addressToString(address: Address) {\n return `${address.siteId}-${address.pubkey}`\n}\n\n// -----------------------------------------------------------------------------\n\n/** Represents a connection between two peers on the Ditto mesh network. */\nexport type Connection = {\n /** Unique identifier for the connection. */\n id: string\n\n /** Type of transport enabling this connection. */\n type: ConnectionType\n\n /** The address of the peer at one end of the connection. */\n peer1: Address\n\n /** The address of the peer at one end of the connection. */\n peer2: Address\n\n /*\n * Gets an estimate of distance to the remote peer. This value is inaccurate.\n * The environment, hardware, and several other factors can greatly affect\n * this value. It is currently derived from RSSI. Can be (yet) unknown and\n * therefore not set.\n */\n approximateDistanceInMeters?: number\n}\n\n// -----------------------------------------------------------------------------\n\n/** An instance of Ditto taking part in the Ditto mesh network. */\nexport type Peer = {\n /**\n * Address to contact this peer via Ditto Bus, unique with a Ditto mesh\n * network.\n */\n address: Address\n\n /**\n * The human-readable device name of the peer. This defaults to the hostname\n * but can be manually set by the application developer of the other peer.\n * It is not necessarily unique.\n */\n deviceName: string\n\n /**\n * Currently active connections of the peer.\n */\n connections: Connection[]\n\n /**\n * Indicates whether the peer is connected to Ditto Cloud.\n */\n isConnectedToDittoCloud: boolean\n\n /** The operating system the peer is running on, `undefined` if (yet) unknown. */\n os?: string\n\n /** The Ditto SDK version the peer is running with, `undefined` if (yet) unknown. */\n dittoSDKVersion?: string\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Represents the Ditto mesh network of peers and their connections between each\n * other. The `localPeer` is the entry point, all others are remote peers known\n * by the local peer (either directly or via other remote peers).\n */\nexport type PresenceGraph = {\n /**\n * Returns the local peer (usually the peer that is represented by the\n * currently running Ditto instance). The `localPeer` is the entry point, all\n * others are remote peers known by the local peer (either directly or via\n * other remote peers).\n */\n localPeer: Peer\n\n /**\n * Returns all remote peers known by the `localPeer`, either directly or via\n * other remote peers.\n */\n remotePeers: Peer[]\n\n /**\n * Returns the underlying CBOR data if the presence graph has been initialized\n * with CBOR. All of Ditto API returning a presence graph has this property\n * set.\n */\n underlyingCBOR?: Uint8Array\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * The entrypoint for all actions that relate presence of other peers known by\n * the current peer, either directly or through other peers.\n *\n * You don't create one directly but can access it from a particular `Ditto`\n * instance via its `presence` property.\n */\nexport class Presence {\n /** The Ditto instance this object belongs to. */\n readonly ditto: Ditto\n\n /**\n * Returns the current presence graph capturing all known peers and\n * connections between them.\n */\n get graph(): PresenceGraph {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n const graphJSONString = FFI.dittoPresenceV3(dittoPointer)\n return JSON.parse(graphJSONString)\n }\n\n /**\n * Request information about Ditto peers in range of this device.\n *\n * This method returns an observer which should be held as long as updates are\n * required. A newly registered observer will have a peers update delivered to\n * it immediately. From then on it will be invoked repeatedly when Ditto\n * devices come and go, or the active connections to them change.\n */\n observe(didChangeHandler: (presenceGraph: PresenceGraph) => void): Observer {\n const observerToken = this.observerManager.addObserver(didChangeHandler)\n const observer = new Observer(this.observerManager, observerToken, { stopsWhenFinalized: true })\n\n // REFACTOR: make the initial callback call async, too (othewise we'd be\n // mixing sync with async, which is a bit problematic in general but might\n // be OK with single-threaded JS). This is a bit tricky, simply\n // setTimeout(..., 0) here could lead us to a situation where the initial\n // call would be sent AFTER the regular notification.\n didChangeHandler(this.graph)\n\n return observer\n }\n\n /** @internal */\n constructor(ditto: Ditto) {\n this.ditto = ditto\n\n this.observerManager = new ObserverManager('PresenceObservation', {\n keepAlive: ditto.keepAlive,\n\n register: (callback) => {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n FFI.dittoRegisterPresenceV3Callback(dittoPointer, callback)\n },\n\n unregister: () => {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n FFI.dittoClearPresenceV3Callback(dittoPointer)\n },\n\n process: (presenceGraphJSONString) => {\n const presenceGraph = JSON.parse(presenceGraphJSONString)\n return [presenceGraph]\n },\n })\n }\n\n private observerManager: ObserverManager\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport { dittoBridge } from './ditto.js'\nimport { KeepAlive } from './keep-alive.js'\nimport type { Ditto, RemotePeer } from './ditto.js'\nimport { generateEphemeralToken } from './internal.js'\n\n/** @internal */\nexport type PresenceToken = string\n\n/**\n @internal\n @deprecated Replaced by `Presence`.\n */\nexport class PresenceManager {\n // REFACTOR: make subclass of Observer and adapt this one.\n readonly ditto: Ditto\n\n constructor(ditto: Ditto) {\n this.ditto = ditto\n this.isRegistered = false\n this.currentRemotePeers = []\n this.callbacksByPresenceToken = {}\n }\n\n /** @internal */\n addObserver(callback: (remotePeers: RemotePeer[]) => void): PresenceToken {\n this.registerIfNeeded()\n\n const token = generateEphemeralToken()\n this.callbacksByPresenceToken[token] = callback\n this.ditto.keepAlive.retain(`PresenceObservation.${token}`)\n\n // REFACTOR: make the initial callback call async, too (othewise we'd be\n // mixing sync with async, which is a bit problematic in general but might\n // be OK with single-threaded JS). This is a bit tricky, simply\n // setTimeout(..., 0) here could lead us to a situation where the initial\n // call would be sent AFTER the regular notification.\n callback(this.currentRemotePeers)\n\n return token\n }\n\n /** @internal */\n removeObserver(token: PresenceToken) {\n this.ditto.keepAlive.release(`PresenceObservation.${token}`)\n delete this.callbacksByPresenceToken[token]\n this.unregisterIfNeeded()\n }\n\n // ------------------------------------------------------------ Private ------\n\n private isRegistered: boolean\n private currentRemotePeers: RemotePeer[]\n private callbacksByPresenceToken: { [key: string]: (remotePeers: RemotePeer[]) => void }\n\n private hasObservers(): boolean {\n return Object.keys(this.callbacksByPresenceToken).length > 0\n }\n\n private registerIfNeeded() {\n const needsToRegister = !this.isRegistered\n if (needsToRegister) {\n this.isRegistered = true\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n const remotePeersJSONString = FFI.dittoPresenceV1(dittoPointer)\n this.currentRemotePeers = this.decode(remotePeersJSONString).sort(this.compareRemotePeers)\n FFI.dittoRegisterPresenceV1Callback(dittoPointer, this.handlePresenceV1Callback.bind(this))\n }\n }\n\n private unregisterIfNeeded() {\n const needsToUnregister = !this.hasObservers() && this.isRegistered\n if (needsToUnregister) {\n this.isRegistered = false\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n FFI.dittoRegisterPresenceV1Callback(dittoPointer, null)\n this.currentRemotePeers = []\n }\n }\n\n private handlePresenceV1Callback(remotePeersJSONString: string) {\n const remotePeers = this.decode(remotePeersJSONString).sort(this.compareRemotePeers)\n this.currentRemotePeers = remotePeers\n this.notify()\n }\n\n private notify() {\n for (const token in this.callbacksByPresenceToken) {\n const callback = this.callbacksByPresenceToken[token]\n callback(this.currentRemotePeers)\n }\n }\n\n private decode(remotePeersJSONString: string): RemotePeer[] {\n const remotePeersJSON: any[] = JSON.parse(remotePeersJSONString)\n return remotePeersJSON.map((remotePeerJSON) => {\n return {\n networkID: remotePeerJSON['network_id'],\n deviceName: remotePeerJSON['device_name'],\n rssi: remotePeerJSON['rssi'] ?? undefined,\n approximateDistanceInMeters: remotePeerJSON['approximate_distance_in_meters'] ?? undefined,\n connections: remotePeerJSON['connections'],\n }\n })\n }\n\n private finalize(token: PresenceToken) {\n this.removeObserver(token)\n }\n\n private compareRemotePeers(left: RemotePeer, right: RemotePeer) {\n // NOTE: we use the exact same sort order here as in the ObjC version.\n\n if (left.connections.length === 0 && right.connections.length > 0) return +1\n if (left.connections.length > 0 && right.connections.length === 0) return -1\n\n if (left.deviceName < right.deviceName) return -1\n if (left.deviceName > right.deviceName) return +1\n\n return 0\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\n\nimport { ObserverManager } from './observer-manager.js'\nimport { KeepAlive } from './keep-alive.js'\n\nimport { dittoBridge } from './ditto.js'\nimport type { Ditto, TransportCondition, ConditionSource } from './ditto.js'\n\n/** @internal */\nexport class TransportConditionsManager extends ObserverManager {\n readonly ditto: Ditto\n\n constructor(ditto: Ditto) {\n const keepAlive = ditto.keepAlive\n super('TransportConditionsObservation', { keepAlive })\n this.ditto = ditto\n }\n\n protected register(callback: (...args: any[]) => void) {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n return FFI.dittoRegisterTransportConditionChangedCallback(dittoPointer, callback)\n }\n\n protected unregister() {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n return FFI.dittoRegisterTransportConditionChangedCallback(dittoPointer, null)\n }\n\n protected process(conditionSource: FFI.ConditionSource, transportCondition: FFI.TransportCondition): [TransportCondition, ConditionSource] {\n /* eslint-disable */\n let apiConditionSource: ConditionSource\n switch (conditionSource) {\n case 'Bluetooth': apiConditionSource = 'BLE'; break\n case 'Tcp': apiConditionSource = 'TCP'; break\n case 'Awdl': apiConditionSource = 'AWDL'; break\n case 'Mdns': apiConditionSource = 'MDNS'; break\n }\n /* eslint-enable */\n\n /* eslint-disable */\n let apiTransportCondition: TransportCondition\n switch (transportCondition) {\n case 'Unknown' : apiTransportCondition = 'Unknown'; break\n case 'Ok' : apiTransportCondition = 'OK'; break\n case 'GenericFailure' : apiTransportCondition = 'GenericFailure'; break\n case 'AppInBackground' : apiTransportCondition = 'AppInBackground'; break\n case 'MdnsFailure' : apiTransportCondition = 'MDNSFailure'; break\n case 'TcpListenFailure' : apiTransportCondition = 'TCPListenFailure'; break\n case 'NoBleCentralPermission' : apiTransportCondition = 'NoBLECentralPermission'; break\n case 'NoBlePeripheralPermission' : apiTransportCondition = 'NoBLEPeripheralPermission'; break\n case 'CannotEstablishConnection' : apiTransportCondition = 'CannotEstablishConnection'; break\n case 'BleDisabled' : apiTransportCondition = 'BLEDisabled'; break\n case 'NoBleHardware' : apiTransportCondition = 'NoBLEHardware'; break\n case 'WifiDisabled' : apiTransportCondition = 'WiFiDisabled'; break\n case 'TemporarilyUnavailable' : apiTransportCondition = 'TemporarilyUnavailable'; break\n }\n /* eslint-enable */\n\n return [apiTransportCondition, apiConditionSource]\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport * as TR from './@transports.js'\n\nimport { Identity } from './identity.js'\nimport { TransportConfig } from './transport-config.js'\n\nimport { StaticTCPClient, staticTCPClientBridge } from './internal.js'\nimport { WebsocketClient, websocketClientBridge } from './internal.js'\nimport { defaultDittoCloudURL } from './internal.js'\n\nimport type { Ditto } from './ditto.js'\nimport { dittoBridge } from './ditto.js'\n\n/** @internal */\nexport type SyncParameters = {\n readonly isSyncActive: boolean\n readonly isX509Valid: boolean\n readonly isWebValid: boolean\n readonly identity: Identity\n readonly transportConfig: TransportConfig\n}\n\n/** @internal */\nexport type SyncState = {\n // NOTE: we can get away with just an effective transport config for now,\n // but this is meant to carry more state if need be. Whenever possible,\n // prefer putting logic into the `stateFrom()` function together with some\n // flags here and keep the `updateXXX()` to just diffing and updating the\n // low-level transports machinery.\n readonly underlyingSyncParameters: SyncParameters\n readonly effectiveTransportConfig: TransportConfig\n}\n\n/** @internal */\nexport class Sync {\n readonly ditto: Ditto\n readonly parameters: SyncParameters\n\n constructor(ditto: Ditto) {\n const identity = ditto.identity\n const transportConfig = new TransportConfig()\n const parameters = { identity, transportConfig, isWebValid: false, isX509Valid: false, isSyncActive: false }\n\n this.ditto = ditto\n this.parameters = parameters\n this.state = stateFrom(parameters)\n this.staticTCPClientsByAddress = {}\n this.websocketClientsByURL = {}\n }\n\n update(parameters: SyncParameters) {\n this['parameters' as any] = { ...parameters }\n\n // NOTE: updating is a two-step process. Given all parameters, we\n // first compute the final \"state\" we want the transports stuff to\n // be in via the `stateFrom()` function. We then take that \"desired\" state\n // and feed it into the various update methods, which essentially perform\n // a diff on the state before and after, and update the low-lever transports\n // machinery accordingly.\n\n const stateOld = this.state\n const stateNew = stateFrom(this.parameters)\n this.updatePeerToPeerBluetoothLE(stateOld, stateNew)\n this.updatePeerToPeerAWDL(stateOld, stateNew)\n this.updatePeerToPeerLAN(stateOld, stateNew)\n this.updateListenTCP(stateOld, stateNew)\n this.updateListenHTTP(stateOld, stateNew)\n this.updateConnectTCPServers(stateOld, stateNew)\n this.updateConnectWebsocketURLs(stateOld, stateNew)\n this.updateGlobal(stateOld, stateNew)\n this.state = stateNew\n }\n\n // ------------------------------------------------------------ Private ------\n\n private state: SyncState\n\n private bluetoothLETransportPointer: FFI.Pointer<'DittoTransportsBLE_t'> | null = null\n private awdlTransportPointer: FFI.Pointer<'DittoTransportsAWDL_t'> | null = null\n private lanTransportPointer: FFI.Pointer<'DittoTransportsLAN_t'> | null = null\n private mdnsClientTransportPointer: FFI.Pointer<'DittoTransportsMdnsClient_t'> | null = null\n private mdnsServerAdvertiserPointer: FFI.Pointer<'DittoTransportsMdnsServer_t'> | null = null\n\n private staticTCPClientsByAddress: { [key: string]: StaticTCPClient }\n private websocketClientsByURL: { [key: string]: WebsocketClient }\n\n private updatePeerToPeerBluetoothLE(stateOld: SyncState, stateNew: SyncState) {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n\n const bluetoothLEOld = stateOld.effectiveTransportConfig.peerToPeer.bluetoothLE\n const bluetoothLENew = stateNew.effectiveTransportConfig.peerToPeer.bluetoothLE\n\n const shouldStart = !bluetoothLEOld.isEnabled && bluetoothLENew.isEnabled\n const shouldStop = bluetoothLEOld.isEnabled && !bluetoothLENew.isEnabled\n\n if (shouldStart && this.bluetoothLETransportPointer) throw new Error(`Internal inconsistency, when starting BLE transport, no BLE transport pointer should exist.`)\n if (shouldStop && !this.bluetoothLETransportPointer) throw new Error(`Internal inconsistency, when stopping BLE transport, a BLE transport pointer should exist.`)\n\n nodeBuildOnly: {\n // HACK: quick & dirty Linux & Windows hack. A proper implementation\n // should encapsulate everything behind the transports module. To undo,\n // remove the whole if block.\n if (process.platform === 'linux' || process.platform === 'win32') {\n if (shouldStart) {\n const clientTransport = FFI.dittoAddInternalBLEClientTransport(dittoPointer)\n const serverTransport = FFI.dittoAddInternalBLEServerTransport(dittoPointer)\n const blePlatform = { clientTransport, serverTransport } as any\n this.bluetoothLETransportPointer = blePlatform\n }\n\n if (shouldStop) {\n const blePlatform = this.bluetoothLETransportPointer as any\n const { clientTransport, serverTransport } = blePlatform\n FFI.bleServerFreeHandle(serverTransport)\n FFI.bleClientFreeHandle(clientTransport)\n this.bluetoothLETransportPointer = null\n }\n\n return\n }\n }\n\n if (shouldStart) {\n if (!TR.bleIsAvailable(dittoPointer)) throw new Error(\"Can't start P2P BluetoothLE transport because not available.\")\n this.bluetoothLETransportPointer = TR.bleCreate(dittoPointer)\n }\n\n if (shouldStop) {\n TR.bleDestroy(this.bluetoothLETransportPointer)\n delete this.bluetoothLETransportPointer\n }\n }\n\n private updatePeerToPeerAWDL(stateOld: SyncState, stateNew: SyncState) {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n\n const awdlOld = stateOld.effectiveTransportConfig.peerToPeer.awdl\n const awdlNew = stateNew.effectiveTransportConfig.peerToPeer.awdl\n\n const shouldStart = !awdlOld.isEnabled && awdlNew.isEnabled\n const shouldStop = awdlOld.isEnabled && !awdlNew.isEnabled\n\n if (shouldStart && this.awdlTransportPointer) throw new Error(`Internal inconsistency, when starting AWDL transport, no AWDL transport pointer should exist.`)\n if (shouldStop && !this.awdlTransportPointer) throw new Error(`Internal inconsistency, when stopping AWDL transport, an AWDL transport pointer should exist.`)\n\n if (shouldStart) {\n if (!TR.awdlIsAvailable(dittoPointer)) throw new Error(\"Can't start P2P AWDL transport because not available.\")\n this.awdlTransportPointer = TR.awdlCreate(dittoPointer)\n }\n\n if (shouldStop) {\n TR.awdlDestroy(this.awdlTransportPointer)\n this.awdlTransportPointer = null\n }\n }\n\n private updatePeerToPeerLAN(stateOld: SyncState, stateNew: SyncState) {\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n\n const lanOld = stateOld.effectiveTransportConfig.peerToPeer.lan\n const lanNew = stateNew.effectiveTransportConfig.peerToPeer.lan\n\n nodeBuildOnly: {\n // HACK: quick & dirty Linux & Windows hack. A proper implementation\n // should encapsulate everything behind the transports module. To undo,\n // remove the whole if block.\n\n // FIXME: include 'linux' as well\n if (process.platform === 'win32') {\n if (lanOld.isEnabled) {\n if (lanOld.isMdnsEnabled) {\n FFI.mdnsClientFreeHandle(this.mdnsClientTransportPointer)\n this.mdnsClientTransportPointer = null\n\n FFI.mdnsServerFreeHandle(this.mdnsServerAdvertiserPointer)\n this.mdnsServerAdvertiserPointer = null\n }\n\n if (lanOld.isMulticastEnabled) {\n FFI.dittoRemoveMulticastTransport(dittoPointer)\n }\n }\n\n if (lanNew.isEnabled) {\n if (lanNew.isMdnsEnabled) {\n this.mdnsClientTransportPointer = FFI.dittoAddInternalMdnsTransport(dittoPointer)\n this.mdnsServerAdvertiserPointer = FFI.dittoAddInternalMdnsAdvertiser(dittoPointer)\n }\n\n if (lanNew.isMulticastEnabled) {\n FFI.dittoAddMulticastTransport(dittoPointer)\n }\n }\n\n return\n }\n }\n\n // IDEA: move the logic for this dance into stateFrom() signal\n // via some additional state signaling the actions here.\n\n if (lanOld.isEnabled) {\n if (lanOld.isMdnsEnabled) {\n TR.lanDestroy(this.lanTransportPointer)\n delete this.lanTransportPointer\n }\n\n if (lanOld.isMulticastEnabled) {\n FFI.dittoRemoveMulticastTransport(dittoPointer)\n }\n }\n\n if (lanNew.isEnabled) {\n if (lanNew.isMdnsEnabled) {\n if (!TR.lanIsAvailable(dittoPointer)) throw new Error(\"Can't start P2P LAN transport because not available.\")\n this.lanTransportPointer = TR.lanCreate(dittoPointer)\n }\n\n if (lanNew.isMulticastEnabled) {\n FFI.dittoAddMulticastTransport(dittoPointer)\n }\n }\n }\n\n private updateListenTCP(stateOld: SyncState, stateNew: SyncState) {\n const tcpOld = stateOld.effectiveTransportConfig.listen.tcp\n const tcpNew = stateNew.effectiveTransportConfig.listen.tcp\n\n if (TransportConfig.areListenTCPsEqual(tcpNew, tcpOld)) return\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n\n if (tcpOld.isEnabled) FFI.dittoStopTCPServer(dittoPointer)\n if (tcpNew.isEnabled) FFI.dittoStartTCPServer(dittoPointer, `${tcpNew.interfaceIP}:${tcpNew.port}`)\n }\n\n private updateListenHTTP(stateOld: SyncState, stateNew: SyncState) {\n const httpOld = stateOld.effectiveTransportConfig.listen.http\n const httpNew = stateNew.effectiveTransportConfig.listen.http\n\n if (TransportConfig.areListenHTTPsEqual(httpOld, httpNew)) return\n const dittoPointer = dittoBridge.pointerFor(this.ditto)\n\n if (httpOld.isEnabled) FFI.dittoStopHTTPServer(dittoPointer)\n\n /* eslint-disable */\n if (httpNew.isEnabled) {\n FFI.dittoStartHTTPServer(\n dittoPointer,\n `${httpNew.interfaceIP}:${httpNew.port}`,\n httpNew.staticContentPath || null,\n httpNew.websocketSync ? 'Enabled' : 'Disabled',\n httpNew.tlsCertificatePath || null,\n httpNew.tlsKeyPath || null\n )\n }\n /* eslint-enable */\n }\n\n private updateConnectTCPServers(stateOld: SyncState, stateNew: SyncState) {\n // REFACTOR: same \"algorithm\" as for Websockets below, DRY up.\n\n const currentTCPServers = Object.getOwnPropertyNames(this.staticTCPClientsByAddress)\n const desiredTCPServers = stateNew.effectiveTransportConfig.connect.tcpServers\n\n const tcpServersToConnectToSet = new Set(desiredTCPServers)\n for (const tcpServer of currentTCPServers) tcpServersToConnectToSet.delete(tcpServer)\n\n const tcpServersToDisconnectFromSet = new Set(currentTCPServers)\n for (const tcpServer of desiredTCPServers) tcpServersToDisconnectFromSet.delete(tcpServer)\n\n const tcpServersToConnectTo = tcpServersToConnectToSet.values()\n const tcpServersToDisconnectFrom = tcpServersToDisconnectFromSet.values()\n\n for (const tcpServer of tcpServersToConnectTo) {\n const staticTCPClientPointer = FFI.addStaticTCPClient(dittoBridge.pointerFor(this.ditto), tcpServer)\n const staticTCPClient = staticTCPClientBridge.bridge(staticTCPClientPointer)\n this.staticTCPClientsByAddress[tcpServer] = staticTCPClient\n }\n\n for (const tcpServer of tcpServersToDisconnectFrom) {\n // REFACTOR: we have to make sure freeing the tcpServer handle is done\n // BEFORE the Ditto instance itself is freed.\n const staticTCPClient = this.staticTCPClientsByAddress[tcpServer]\n if (!staticTCPClient) throw new Error(`Internal inconsistency, can't disconnect from TCP address '${tcpServer}', no staticTCPClient found.`)\n const staticTCPClientPointer = staticTCPClientBridge.pointerFor(staticTCPClient)\n\n // Unregister to avoid double-free for this pointer, then free manually:\n staticTCPClientBridge.unregister(staticTCPClient)\n FFI.staticTCPClientFreeHandle(staticTCPClientPointer)\n\n delete this.staticTCPClientsByAddress[tcpServer]\n }\n }\n\n private updateConnectWebsocketURLs(stateOld: SyncState, stateNew: SyncState) {\n // REFACTOR: same \"algorithm\" as for TCP servers above, DRY up.\n // IDEA: normalize URLs so that we don't connect to the same URL twice?\n\n const currentWebsocketURLs = Object.getOwnPropertyNames(this.websocketClientsByURL)\n const desiredWebsocketURLs = stateNew.effectiveTransportConfig.connect.websocketURLs.slice()\n\n const websocketURLsToConnectToSet = new Set(desiredWebsocketURLs)\n for (const websocketURL of currentWebsocketURLs) websocketURLsToConnectToSet.delete(websocketURL)\n\n const websocketURLsToDisconnectFromSet = new Set(currentWebsocketURLs)\n for (const websocketURL of desiredWebsocketURLs) websocketURLsToDisconnectFromSet.delete(websocketURL)\n\n const websocketURLsToConnectTo = websocketURLsToConnectToSet.values()\n const websocketURLsToDisconnectFrom = websocketURLsToDisconnectFromSet.values()\n\n const routingHint = stateNew.effectiveTransportConfig.global.routingHint\n\n for (const websocketURL of websocketURLsToConnectTo) {\n const websocketClientPointer = FFI.addWebsocketClient(dittoBridge.pointerFor(this.ditto), websocketURL, routingHint)\n const websocketClient = websocketClientBridge.bridge(websocketClientPointer)\n this.websocketClientsByURL[websocketURL] = websocketClient\n }\n\n for (const websocketURL of websocketURLsToDisconnectFrom) {\n // REFACTOR: we have to make sure freeing the websocket handle is done\n // BEFORE the Ditto instance itself is freed.\n const websocketClient = this.websocketClientsByURL[websocketURL]\n if (!websocketClient) throw new Error(`Internal inconsistency, can't disconnect from websocket URL '${websocketURL}', no websocketClient found.`)\n const websocketClientPointer = websocketClientBridge.pointerFor(websocketClient)\n\n // Unregister to avoid double-free for this pointer, then free manually:\n websocketClientBridge.unregister(websocketClient)\n FFI.websocketClientFreeHandle(websocketClientPointer)\n\n delete this.websocketClientsByURL[websocketURL]\n }\n }\n\n private updateGlobal(stateOld: SyncState, stateNew: SyncState) {\n if (stateOld.effectiveTransportConfig.global.syncGroup !== stateNew.effectiveTransportConfig.global.syncGroup) {\n FFI.dittoSetSyncGroup(dittoBridge.pointerFor(this.ditto), stateNew.effectiveTransportConfig.global.syncGroup)\n }\n }\n}\n\n/**\n * @private\n */\nfunction stateFrom(parameters: SyncParameters): SyncState {\n // IMPORTANT: this function maps a set of sync parameters to an effective\n // transport config plus some extra state where need be. Make sure\n // to keep this function free of side-effects.\n\n const transportConfig = parameters.transportConfig.copy()\n const identity = parameters.identity\n\n const isSyncActive = parameters.isSyncActive\n const isX509Valid = parameters.isX509Valid\n const isWebValid = parameters.isWebValid\n\n const tcpServers = transportConfig.connect.tcpServers\n const websocketURLs = transportConfig.connect.websocketURLs\n\n let appID\n let customDittoCloudURL\n let isDittoCloudSyncEnabled = false\n\n if (identity.type === 'onlinePlayground' || identity.type === 'onlineWithAuthentication') {\n // NOTE: enableDittoCloudSync is true by default for any online identity.\n appID = identity.appID\n customDittoCloudURL = identity.customDittoCloudURL ?? null\n isDittoCloudSyncEnabled = identity.hasOwnProperty('enableDittoCloudSync') ? identity.enableDittoCloudSync : true\n }\n\n webBuildOnly: {\n // No P2P transport is supported on the Web, so we throw an error.\n const enabledP2PTransports = []\n\n if (transportConfig.peerToPeer.bluetoothLE.isEnabled) {\n enabledP2PTransports.push('BluetoothLE')\n }\n\n if (transportConfig.peerToPeer.awdl.isEnabled) {\n enabledP2PTransports.push('AWDL')\n }\n\n if (transportConfig.peerToPeer.lan.isEnabled) {\n enabledP2PTransports.push('LAN')\n }\n\n if (enabledP2PTransports.length > 0) {\n throw new Error(`Ditto does not support P2P transports when running in the browser, but the following were enabled: ${enabledP2PTransports.join(', ')}`)\n }\n }\n\n if (!isSyncActive || !isX509Valid) {\n transportConfig.peerToPeer.bluetoothLE.isEnabled = false\n transportConfig.peerToPeer.awdl.isEnabled = false\n transportConfig.peerToPeer.lan.isEnabled = false\n transportConfig.listen.tcp.isEnabled = false\n transportConfig.connect.tcpServers = []\n }\n\n if (!isSyncActive || !isWebValid) {\n transportConfig.connect.websocketURLs = []\n }\n\n if (!isSyncActive) {\n transportConfig.listen.http.isEnabled = false\n }\n\n // NOTE: we have to smuggle in an additional Ditto Cloud websocket URL to\n // connect to if cloud sync is enabled.\n if (isSyncActive && isWebValid && isDittoCloudSyncEnabled) {\n const dittoCloudURL = customDittoCloudURL ?? defaultDittoCloudURL(appID)\n transportConfig.connect.websocketURLs.push(dittoCloudURL)\n }\n\n // NOTE: LAN transport & TCP listening are interrelated at the moment. We\n // have to start a TCP server for LAN transport to work properly _unless_\n // TCP listening is explicitly enabled. This means we also have to stop it\n // if we started it previously due to this condition.\n if (transportConfig.peerToPeer.lan.isEnabled && !transportConfig.listen.tcp.isEnabled) {\n transportConfig.listen.tcp.isEnabled = true\n transportConfig.listen.tcp.interfaceIP = '0.0.0.0'\n transportConfig.listen.tcp.port = 0\n }\n\n return {\n underlyingSyncParameters: parameters,\n effectiveTransportConfig: transportConfig.freeze(),\n }\n}\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\nimport * as FFI from './ffi.js'\nimport * as TR from './@transports.js'\n\nimport { TransportConfig, TransportConfigListenTCP, TransportConfigListenHTTP, TransportConfigLan } from './transport-config.js'\n\nimport { Authenticator, OnlineAuthenticator, NotAvailableAuthenticator } from './authenticator.js'\nimport { Identity, IdentityOfflinePlayground, IdentitySharedKey, IdentityOnlineWithAuthentication, IdentityTypesRequiringOfflineLicenseToken } from './identity.js'\nimport { Bridge } from './bridge.js'\nimport { Store } from './store.js'\nimport { Logger } from './logger.js'\nimport { KeepAlive } from './keep-alive.js'\n\nimport { Observer } from './observer.js'\nimport { Presence } from './presence.js'\nimport { PresenceManager } from './presence-manager.js'\nimport { TransportConditionsManager } from './transport-conditions-manager.js'\nimport { SyncParameters, Sync } from './sync.js'\n\nimport { isWebBuild, isNodeBuild } from './internal.js'\nimport { StaticTCPClient, staticTCPClientBridge } from './internal.js'\nimport { WebsocketClient, websocketClientBridge } from './internal.js'\nimport { defaultAuthURL } from './internal.js'\n\n// -----------------------------------------------------------------------------\n\n/** Types of connections that can be established between two peers. */\nexport type TransportCondition = 'Unknown' | 'OK' | 'GenericFailure' | 'AppInBackground' | 'MDNSFailure' | 'TCPListenFailure' | 'NoBLECentralPermission' | 'NoBLEPeripheralPermission' | 'CannotEstablishConnection' | 'BLEDisabled' | 'NoBLEHardware' | 'WiFiDisabled' | 'TemporarilyUnavailable'\n\n/** The source for a transport condition. */\nexport type ConditionSource = 'BLE' | 'TCP' | 'AWDL' | 'MDNS'\n\n// -----------------------------------------------------------------------------\n\n/**\n * Types of connections that can be established between two peers.\n * @deprecated replaced by {@link ConnectionType}.\n */\nexport type PresenceConnectionType = 'WiFi' | 'WebSocket' | 'AWDL' | 'BLE'\n\n/**\n * A peer object with information about an observed peer.\n * @deprecated replaced by {@link Peer}.\n */\nexport type RemotePeer = {\n networkID: string\n deviceName: string\n rssi?: number\n approximateDistanceInMeters?: number\n connections: PresenceConnectionType[]\n}\n\n// -----------------------------------------------------------------------------\n\n/**\n * Ditto is the entry point for accessing Ditto-related functionality.\n */\nexport class Ditto {\n /**\n * Configure a custom identifier for the current device.\n *\n * When using {@link Presence.observe | presence.observe()}, each remote peer is\n * represented by a short UTF-8 \"device name\". By default this will be a\n * truncated version of the device's hostname. It does not need to be unique\n * among peers. Configure the device name before calling\n * {@link startSync | startSync()}. If it is too long it may be truncated.\n */\n deviceName: string\n\n /** Returns a string identifying the version of the Ditto SDK. */\n get sdkVersion() {\n const dittoPointer = dittoBridge.pointerFor(this)\n return FFI.dittoGetSDKVersion(dittoPointer)\n }\n\n /**\n * The (validated) identity this Ditto instance was initialized with.\n */\n readonly identity: Identity\n\n /**\n * The path this Ditto instance was initialized with, if no path was given at\n * construction time, the default value is returned (see constructor).\n */\n readonly path: string\n\n /**\n * Provides access to the SDK's store functionality.\n */\n readonly store: Store\n\n /**\n * Provides access to the SDK's presence functionality.\n */\n readonly presence: Presence\n\n /**\n * Provides access to authentication methods for logging on to Ditto Cloud.\n */\n readonly auth: Authenticator\n\n /**\n * The site ID that the instance of `Ditto` is using as part of its identity.\n */\n readonly siteID: number | BigInt\n\n /**\n * Returns `true` if an offline license token has been set, otherwise returns `false`.\n *\n * @see {@link setOfflineOnlyLicenseToken | setOfflineOnlyLicenseToken()}\n */\n readonly isActivated: boolean\n\n /**\n * Returns `true` if sync is active, otherwise returns `false`. Use\n * {@link startSync | startSync()} to activate and {@link stopSync | stopSync()}\n * to deactivate sync.\n */\n readonly isSyncActive: boolean\n\n /**\n * Initializes a new `Ditto` instance.\n *\n * **NOTE**: The `sharedKey` identity is only supported for Node environments,\n * using this to create a Ditto instance in the web browser will throw an\n * exception.\n *\n * @param identity - Identity for the new Ditto instance, defaults to\n * `offlinePlayground` with `appID` being the empty string `''`.\n *\n * @param path - On Node, `path` corresponds to a real directory\n * on the file system (intermediate directories are created if needed). In the\n * browser, `path` is used as an internal namespace into the backing storage\n * (in-memory at the moment, support for IndexedDB is in development).\n * Defaults to `\"ditto\"`.\n *\n * @see {@link Ditto.identity}\n * @see {@link Ditto.path}\n */\n constructor(identity?: Identity, path?: string) {\n const isPathGiven = path && path.trim().length > 0\n\n const identityOrDefault = identity ?? { type: 'offlinePlayground', appID: '' }\n const pathOrDefault = isPathGiven ? path : 'ditto'\n\n const validIdentity = Object.freeze(this.validateIdentity(identityOrDefault))\n\n this.identity = Object.freeze(validIdentity)\n this.path = pathOrDefault\n\n nodeBuildOnly: {\n const fs = require('fs')\n fs.mkdirSync(pathOrDefault, { recursive: true })\n }\n\n nodeBuildOnly: {\n const os = require('os')\n this.deviceName = os.hostname()\n }\n\n webBuildOnly: {\n this.deviceName = navigator.userAgent\n }\n\n this.keepAlive = new KeepAlive()\n\n // NOTE: some behavior not implemented yet as compared to the ObjC/Swift\n // version:\n //\n // 1. Optional `identity` parameter falling back to a default one.\n //\n // 2. Optional siteID of the identity, falling back to a random one if\n // newly created or to the stored one if already persisted.\n\n const uninitializedDittoX = FFI.uninitializedDittoMake(pathOrDefault)\n\n // WORKAROUND: the login provider triggers the registered callback right\n // when the auth client is being constructed. At this point, we don't have\n // the auth client, which would be needed to perform a login, nor did we\n // have a chance to create an authenticator. Therefore catch that first\n // callback, store the seconds remaining and proceed with propagating\n // it after all pieces are in place.\n let secondsRemainingUntilAuthenticationExpires: number = null\n\n const weakThis = new WeakRef(this)\n const authClientX = (() => {\n if (validIdentity.type === 'offlinePlayground') {\n return FFI.dittoAuthClientMakeForDevelopment(pathOrDefault, validIdentity.appID, validIdentity.siteID ?? 0)\n }\n\n if (validIdentity.type === 'manual') {\n return FFI.dittoAuthClientMakeWithStaticX509(validIdentity.certificate)\n }\n\n if (validIdentity.type === 'sharedKey') {\n return FFI.dittoAuthClientMakeWithSharedKey(pathOrDefault, validIdentity.appID, validIdentity.sharedKey, validIdentity.siteID)\n }\n\n if (validIdentity.type === 'onlinePlayground') {\n const authURL = validIdentity.customAuthURL ?? defaultAuthURL(validIdentity.appID)\n return FFI.dittoAuthClientMakeAnonymousClient(pathOrDefault, validIdentity.appID, validIdentity.token, authURL)\n }\n\n if (validIdentity.type === 'onlineWithAuthentication') {\n const authURL = validIdentity.customAuthURL ?? defaultAuthURL(validIdentity.appID)\n\n const loginProviderX = FFI.dittoAuthClientMakeLoginProvider(function (secondsRemaining) {\n const strongThis = weakThis.deref()\n if (!strongThis) {\n Logger.warning(`Internal inconsistency, LoginProvider callback fired after the corresponding Ditto instance has been deallocated.`)\n return\n }\n\n if (strongThis.auth) {\n strongThis.auth['@ditto.authenticationExpiring'](secondsRemaining)\n } else {\n // WORKAROUND: see description above where the\n // secondsRemainingUntilAuthenticationExpires variable is declared.\n secondsRemainingUntilAuthenticationExpires = secondsRemaining\n }\n })\n\n return FFI.dittoAuthClientMakeWithWeb(pathOrDefault, validIdentity.appID, authURL, loginProviderX)\n }\n\n throw new Error(`Can't create Ditto, unsupported identity type: ${validIdentity}`)\n })()\n\n FFI.dittoAuthClientSetValidityListener(authClientX, function (...args) {\n weakThis.deref()?.authClientValidityChanged(...args)\n })\n\n const isWebValid = FFI.dittoAuthClientIsWebValid(authClientX)\n const isX509Valid = FFI.dittoAuthClientIsX509Valid(authClientX)\n\n const siteID = FFI.dittoAuthClientGetSiteID(authClientX)\n const dittoX = FFI.dittoMake(uninitializedDittoX, authClientX)\n\n dittoBridge.bridge(dittoX, this)\n\n // IMPORTANT: Keeping the auth client around accumulates run-times and\n // resources which becomes a problem specifically in tests (where we use one\n // Ditto instance per test). We therefore keep it only if needed, i.e.\n // _only_ for the onlineWithAuthentication and online identities and\n // transfer ownership of it to the authenticator.\n if (validIdentity.type === 'onlineWithAuthentication') {\n this.auth = new OnlineAuthenticator(this.keepAlive, authClientX, this, validIdentity.authHandler)\n } else if (validIdentity.type === 'onlinePlayground') {\n this.auth = new OnlineAuthenticator(this.keepAlive, authClientX, this, {\n authenticationRequired: function (authenticator: Authenticator) {\n // No-op.\n },\n\n authenticationExpiringSoon: function (authenticator: Authenticator, secondsRemaining: number) {\n // No-op.\n },\n })\n } else {\n FFI.dittoAuthClientFree(authClientX)\n this.auth = new NotAvailableAuthenticator(this.keepAlive)\n }\n\n const transportConfig = this.makeDefaultTransportConfig()\n\n this.siteID = siteID\n this.transportConfig = transportConfig.copy().freeze()\n\n this.isX509Valid = isX509Valid\n this.isWebValid = isWebValid\n\n this.sync = new Sync(this)\n this.sync.update({ isSyncActive: false, isX509Valid, isWebValid, identity: validIdentity, transportConfig })\n\n // We don't need a license when running in the browser, so we\n // mark the instance as activated from the get-go in that case.\n this.isActivated = isWebBuild || !IdentityTypesRequiringOfflineLicenseToken.includes(validIdentity.type)\n\n this.store = new Store(this)\n this.presence = new Presence(this)\n this.presenceManager = new PresenceManager(this)\n this.transportConditionsManager = new TransportConditionsManager(this)\n\n // WORKAROUND: see description above where the\n // secondsRemainingUntilAuthenticationExpires variable is declared.\n if (secondsRemainingUntilAuthenticationExpires !== null) {\n this.auth['@ditto.authenticationExpiring'](secondsRemainingUntilAuthenticationExpires)\n }\n }\n\n /**\n * Activate a `Ditto` instance by setting an offline only license token. You cannot initiate sync\n * with `Ditto` before you have activated it. The offline license token is only valid for identities\n * of type `development`, `manual`, `offlinePlayground`, and `sharedKey`.\n *\n * @param licenseToken the license token to activate the `Ditto` instance\n * with. You can find yours on the [Ditto portal](https://portal.ditto.live).\n */\n setOfflineOnlyLicenseToken(licenseToken: string) {\n if (isWebBuild) {\n // We don't need a license when running in the browser. Web builds mark the instance as activated\n // inside the constructor.\n Logger.info('Offline license token are ignored on web builds. Token validation will be skipped.')\n } else {\n if (IdentityTypesRequiringOfflineLicenseToken.includes(this.identity.type)) {\n const { result, errorMessage } = FFI.verifyLicense(licenseToken)\n if (result !== 'LicenseOk') {\n this['isActivated' as any] = false\n throw new Error(errorMessage)\n } else {\n this['isActivated' as any] = true\n }\n } else {\n throw new Error('Offline license tokens should only be used for manual, sharedKey or offlinePlayground identities')\n }\n }\n }\n\n /**\n * Returns the current transport configuration, frozen. If you want to modify\n * the transport config, make a {@link TransportConfig.copy | copy} first. Or\n * use the {@link updateTransportConfig | updateTransportConfig()}\n * convenience method. By default peer-to-peer transports (Bluetooth, WiFi,\n * and AWDL) are enabled if available in the current environment\n * (Web, Node, OS, etc.).\n *\n * @see {@link setTransportConfig | setTransportConfig()}\n * @see {@link updateTransportConfig | updateTransportConfig()}\n */\n readonly transportConfig: TransportConfig\n\n /**\n * Assigns a new transports configuration. By default peer-to-peer transports\n * (Bluetooth, WiFi, and AWDL) are enabled. You may use this method to alter\n * the configuration at any time, however sync will not begin until\n * {@link startSync | startSync()} is called.\n *\n * @see {@link transportConfig}\n * @see {@link updateTransportConfig | updateTransportConfig()}\n */\n setTransportConfig(transportConfig: TransportConfig) {\n const transportConfigOld = this.transportConfig\n this['transportConfig' as any] = transportConfig.copy().freeze()\n const transportConfigNew = this.transportConfig\n\n const identity = this.identity\n const isWebValid = this.isWebValid\n const isX509Valid = this.isX509Valid\n\n this.sync.update({ transportConfig: transportConfigNew, identity, isWebValid, isX509Valid, isSyncActive: this.isSyncActive })\n }\n\n /**\n * Convenience method for updating the transport config. Creates a copy of the\n * current transport config, passes that copy to the `update` closure,\n * allowing it to mutate as needed, and sets that updated copy afterwards.\n */\n updateTransportConfig(update: (transportConfig: TransportConfig) => void): Ditto {\n const transportConfig = this.transportConfig.copy()\n update(transportConfig)\n this.setTransportConfig(transportConfig)\n return this as any\n }\n\n /**\n * Starts the network transports. Ditto will connect to other devices.\n *\n * By default Ditto will enable all peer-to-peer transport types. On **Node**,\n * this means BluetoothLE, WiFi/LAN, and AWDL. On the **Web**, only connecting\n * via Websockets is supported. The network configuration can be\n * customized with {@link updateTransportConfig | updateTransportConfig()}\n * or replaced entirely with {@link setTransportConfig | setTransportConfig()}.\n *\n *\n * Ditto will prevent the process from exiting until sync is stopped (not\n * relevant when running in the browser).\n *\n * **NOTE**: the BluetoothLE transport on Linux is experimental, this\n * method panics if no BluetoothLE hardware is available. Therefore, contrary\n * to the above, the BluetoothLE transport is temporarily disabled by default\n * on Linux.\n *\n * @see {@link isSyncActive}\n * @see {@link stopSync | stopSync()}\n */\n startSync() {\n this.setSyncActive(true)\n }\n\n /**\n * Stops all network transports.\n *\n * You may continue to use the database locally but no data will sync to or\n * from other devices.\n *\n * @see {@link isSyncActive}\n * @see {@link startSync | startSync()}\n */\n stopSync() {\n this.setSyncActive(false)\n }\n\n /**\n * Registers an observer for info about Ditto peers in range of this device.\n *\n * Ditto will prevent the process from exiting as long as there are active\n * peers observers (not relevant when running in the browser).\n *\n * @param callback called immediately with the current state of peers\n * in range and whenever that state changes. Then it will be invoked\n * repeatedly when Ditto devices come and go, or the active connections to\n * them change.\n *\n * @deprecated please use {@link Presence.observe | presence.observe()} instead.\n */\n observePeers(callback: (peersData: RemotePeer[]) => void): Observer {\n Logger.warning('`ditto.observePeers()` is deprecated, please use `ditto.presence.observe()` instead.')\n const token = this.presenceManager.addObserver(callback)\n return new Observer(this.presenceManager, token, { stopsWhenFinalized: true })\n }\n\n /**\n * Register observer for changes of underlying transport conditions.\n *\n * Ditto will prevent the process from exiting as long as there are active\n * transport conditions observers (not relevant when running in the browser).\n *\n * @param callback called when underlying transport conditions change with\n * the changed `condition` and it's `source`.\n */\n observeTransportConditions(callback: (condition: TransportCondition, source: ConditionSource) => void): Observer {\n const token = this.transportConditionsManager.addObserver(callback)\n return new Observer(this.transportConditionsManager, token, { stopsWhenFinalized: true })\n }\n\n /**\n * Removes all sync metadata for any remote peers which aren't currently\n * connected. This method shouldn't usually be called. Manually running\n * garbage collection often will result in slower sync times. Ditto\n * automatically runs a garbage a collection process in the background at\n * optimal times.\n *\n * Manually running garbage collection is typically only useful during testing\n * if large amounts of data are being generated. Alternatively, if an entire\n * data set is to be evicted and it's clear that maintaining this metadata\n * isn't necessary, then garbage collection could be run after evicting the\n * old data.\n *\n * Only available in Node environments at the moment, no-op in the browser.\n */\n runGarbageCollection() {\n const dittoPointer = dittoBridge.pointerFor(this)\n FFI.dittoRunGarbageCollection(dittoPointer)\n }\n\n /**\n * Explicitly opt-in to disabling the ability to sync with Ditto peers running\n * any version of the SDK in the v2 series of releases.\n *\n * Assuming this succeeds then this peer will only be able to sync with other\n * peers using SDKs in the v3 series of releases. Note that this disabling of\n * sync spreads to peers that sync with a peer that has disabled, or has\n * (transitively) had disabled, syncing with v2 SDK peers.\n */\n disableSyncWithV2() {\n const dittoPointer = dittoBridge.pointerFor(this)\n FFI.dittoDisableSyncWithV2(dittoPointer)\n }\n\n // ------------------------------------------------------------ Private ------\n\n /** @internal */\n keepAlive: KeepAlive\n\n // ------------------------------------------------------------ Private ------\n\n private sync: Sync\n\n private isWebValid: boolean = false\n private isX509Valid: boolean = false\n\n private presenceManager: PresenceManager\n private transportConditionsManager: TransportConditionsManager\n\n private authClientValidityChanged(isWebValid: boolean, isX509Valid: boolean) {\n const transportConfig = this.transportConfig\n const identity = this.identity\n\n const isSyncActive = this.isSyncActive\n const wasX509Valid = this.isX509Valid\n const wasWebValid = this.isWebValid\n\n this.isX509Valid = isX509Valid\n this.isWebValid = isWebValid\n\n this.auth['@ditto.authClientValidityChanged'](isWebValid, isX509Valid)\n this.sync.update({ transportConfig, identity, isWebValid, isX509Valid, isSyncActive })\n }\n\n private validateIdentity(identity: Identity): Identity {\n const validIdentity = { ...identity }\n\n const appName = identity['appName' as any]\n const appID = identity['appID' as any]\n\n if (!['offlinePlayground', 'sharedKey', 'manual', 'onlinePlayground', 'onlineWithAuthentication'].includes(identity.type)) {\n throw new Error(`Can't create Ditto instance, unknown identity type: ${identity.type}`)\n }\n\n if ((identity.type === 'offlinePlayground' || identity.type === 'sharedKey' || identity.type === 'onlinePlayground' || identity.type === 'onlineWithAuthentication') && typeof appID === 'undefined') {\n throw new Error(`Property .appID must be given for identity, but isn't.`)\n }\n\n if (typeof appID !== 'undefined' && typeof appID !== 'string') {\n throw new Error(`Property .appID must be be of type string, but is of type '${typeof appID}': ${appID}`)\n }\n\n if ((identity.type === 'offlinePlayground' || identity.type === 'sharedKey') && typeof identity.siteID !== 'undefined') {\n const siteID = identity.siteID\n const isSiteIDNumberOrBigInt = typeof siteID === 'number' || typeof siteID === 'bigint'\n\n if (!isSiteIDNumberOrBigInt) throw new Error(\"Can't create Ditto instance, siteID must be a number or BigInt\")\n if (siteID < 0) throw new Error(\"Can't create Ditto instance, siteID must be >= 0\")\n if (siteID > BigInt('0xffffffffffffffff')) throw new Error(\"Can't create Ditto instance, siteID must be < 2^64\")\n }\n\n if (identity.type === 'sharedKey') {\n // No validations yet.\n }\n\n if (identity.type === 'manual') {\n // No validations yet.\n }\n\n if (identity.type === 'onlinePlayground') {\n const token = identity.token\n\n if (typeof token === 'undefined') {\n throw new Error(`Property .token must be given for identity but isn't. You can find the corresponding token on the Ditto Portal.`)\n }\n\n if (typeof token !== 'undefined' && typeof token !== 'string') {\n throw new Error(`Property .token of identity must be be of type string, but is of type '${typeof token}': ${token}`)\n }\n }\n\n if (identity.type === 'onlineWithAuthentication') {\n // No validations yet.\n }\n\n return validIdentity\n }\n\n private setSyncActive(flag: boolean) {\n if (flag && IdentityTypesRequiringOfflineLicenseToken.includes(this.identity.type) && !this.isActivated) {\n throw new Error('Sync could not be started because Ditto has not yet been activated. This can be achieved with a successful call to `setOfflineOnlyLicenseToken`. If you need to obtain a license token then please visit https://portal.ditto.live.')\n }\n\n if (!this.isSyncActive && flag) {\n this.keepAlive.retain('sync')\n }\n\n if (this.isSyncActive && !flag) {\n this.keepAlive.release('sync')\n }\n\n const dittoPointer = dittoBridge.pointerFor(this)\n this['isSyncActive' as any] = flag\n\n const isWebValid = this.isWebValid\n const isX509Valid = this.isX509Valid\n\n const identity = this.identity\n const transportConfig = this.transportConfig\n\n FFI.dittoSetDeviceName(dittoPointer, this.deviceName)\n this.sync.update({ identity, transportConfig, isWebValid, isX509Valid, isSyncActive: !!flag })\n }\n\n private makeDefaultTransportConfig(): TransportConfig {\n const dittoPointer = dittoBridge.pointerFor(this)\n const transportConfig = new TransportConfig()\n\n if (TR.bleIsAvailable(dittoPointer)) {\n transportConfig.peerToPeer.bluetoothLE.isEnabled = true\n }\n\n if (TR.awdlIsAvailable(dittoPointer)) {\n transportConfig.peerToPeer.awdl.isEnabled = true\n }\n\n if (TR.lanIsAvailable(dittoPointer)) {\n transportConfig.peerToPeer.lan.isEnabled = true\n }\n\n // WORKAROUND: the Linux implementation panics if no BLE hardware is\n // available but should report `NoBleHardware` via transport condition\n // observation instead. Until this is fixed, we'll disable the BLE transport\n // by default on Linux. To undo, remove the following block of code.\n //\n // See issue #5686 for details:\n // https://github.com/getditto/ditto/pull/5608\n nodeBuildOnly: {\n if (process.platform === 'linux') {\n transportConfig.peerToPeer.bluetoothLE.isEnabled = false\n }\n }\n\n return transportConfig.freeze()\n }\n}\n\n/** @internal */\nexport const dittoBridge = new Bridge<Ditto, FFI.FFIDitto>(Ditto, (dittoPointer) => {\n // HACK: quick and dirty, clear all presence callbacks. This covers presence\n // v1 and v2 callbacks. v3 should be cleared properly by the `Presence` class\n // itself.\n FFI.dittoClearPresenceCallback(dittoPointer)\n FFI.dittoFree(dittoPointer)\n})\n","//\n// Copyright © 2021 DittoLive Incorporated. All rights reserved.\n//\n\n/** @internal */\nexport class Value {\n readonly value: unknown\n readonly isDefault: boolean\n\n constructor(value: unknown, options: unknown = {}) {\n this.value = value\n this.isDefault = !!options['isDefault']\n }\n}\n"],"names":["FFI.staticTCPClientFreeHandle","FFI.websocketClientFreeHandle","withOutPtr","dittoCore.ditto_add_internal_ble_client_transport","dittoCore.ditto_add_internal_ble_server_transport","dittoCore.ble_client_free_handle","dittoCore.ble_server_free_handle","dittoCore.ditto_add_internal_mdns_transport","dittoCore.mdns_client_free_handle","dittoCore.ditto_add_internal_mdns_advertiser","dittoCore.mdns_server_free_handle","dittoCore.ditto_document_set_cbor_with_timestamp","dittoCore.ditto_document_set_cbor","dittoCore.ditto_document_id","dittoCore.boxCBytesIntoBuffer","dittoCore.ditto_document_get_cbor_with_path_type","dittoCore.ditto_document_remove","dittoCore.ditto_document_increment_counter","dittoCore.ditto_document_free","dittoCore.ditto_document_id_query_compatible","dittoCore.boxCStringIntoString","dittoCore.withOutBoxCBytes","dittoCore.ditto_validate_document_id","dittoCore.ditto_collection_get","dittoCore.ditto_collection_insert_value","dittoCore.ditto_collection_remove","dittoCore.ditto_collection_evict","dittoCore.ditto_collection_update","dittoCore.jsDocsToCDocs","dittoCore.ditto_collection_update_multiple","dittoCore.ditto_collection_exec_query_str","dittoCore.ditto_collection_remove_query_str","dittoCore.ditto_collection_evict_query_str","dittoCore.ditto_add_subscription","dittoCore.ditto_remove_subscription","dittoCore.ditto_live_query_register_str_detached","dittoCore.ditto_live_query_start","dittoCore.ditto_live_query_stop","dittoCore.ditto_live_query_signal_available_next","dittoCore.ditto_live_query_webhook_register_str","dittoCore.ditto_read_transaction","dittoCore.ditto_read_transaction_free","dittoCore.ditto_write_transaction","dittoCore.ditto_write_transaction_commit","dittoCore.ditto_add_static_tcp_client","dittoCore.static_tcp_client_free_handle","dittoCore.ditto_add_websocket_client","dittoCore.websocket_client_free_handle","dittoCore.ditto_logger_init","dittoCore.ditto_logger_set_custom_log_cb","dittoCore.ditto_logger_enabled","dittoCore.ditto_logger_enabled_get","dittoCore.ditto_logger_emoji_headings_enabled","dittoCore.ditto_logger_emoji_headings_enabled_get","dittoCore.ditto_logger_minimum_log_level","dittoCore.ditto_logger_minimum_log_level_get","dittoCore.ditto_logger_set_log_file","dittoCore.ditto_log","dittoCore.ditto_auth_client_make_anonymous_client","dittoCore.ditto_auth_client_make_with_web","dittoCore.ditto_auth_client_make_for_development","dittoCore.ditto_auth_client_make_with_shared_key","dittoCore.ditto_auth_client_make_with_static_x509","dittoCore.ditto_auth_client_get_site_id","dittoCore.ditto_auth_client_free","dittoCore.ditto_auth_client_is_web_valid","dittoCore.ditto_auth_client_user_id","dittoCore.ditto_auth_client_is_x509_valid","dittoCore.ditto_auth_client_login_with_token","dittoCore.ditto_auth_client_login_with_credentials","dittoCore.ditto_auth_client_logout","dittoCore.uninitialized_ditto_make","dittoCore.ditto_make","dittoCore.ditto_get_collection_names","dittoCore.cStringVecToStringArray","dittoCore.ditto_free","dittoCore.ditto_register_presence_v1_callback","dittoCore.refCStringToString","dittoCore.ditto_clear_presence_callback","dittoCore.ditto_register_presence_v3_callback","dittoCore.ditto_clear_presence_v3_callback","dittoCore.ditto_register_transport_condition_changed_callback","dittoCore.ditto_set_device_name","dittoCore.ditto_set_sync_group","dittoCore.ditto_new_attachment_from_file","dittoCore.ditto_new_attachment_from_bytes","dittoCore.ditto_resolve_attachment","dittoCore.ditto_cancel_resolve_attachment","dittoCore.ditto_free_attachment_handle","dittoCore.ditto_get_complete_attachment_path","dittoCore.ditto_get_sdk_version","dittoCore.ditto_presence_v1","dittoCore.ditto_presence_v3","dittoCore.ditto_start_tcp_server","dittoCore.ditto_stop_tcp_server","dittoCore.ditto_add_multicast_transport","dittoCore.ditto_remove_multicast_transport","dittoCore.ditto_start_http_server","dittoCore.ditto_stop_http_server","dittoCore.ditto_run_garbage_collection","dittoCore.ditto_disable_sync_with_v2","dittoCore.ditto_documents_hash","dittoCore.ditto_documents_hash_mnemonic","dittoCore.ditto_auth_client_make_login_provider","dittoCore.ditto_auth_client_set_validity_listener","dittoCore.withOutPtr","dittoCore.ditto_init_sdk_version","dittoCore.verify_license","dittoCore.ditto_error_message","FFI.initSDKVersion","FFI.loggerInit","FFI.loggerSetLogFile","FFI.loggerEnabledGet","FFI.loggerEnabled","FFI.loggerEmojiHeadingsEnabledGet","FFI.loggerEmojiHeadingsEnabled","FFI.loggerMinimumLogLevelGet","FFI.loggerMinimumLogLevel","FFI.loggerSetCustomLogCb","FFI.log","FFI.dittoAuthClientLoginWithToken","FFI.dittoAuthClientLoginWithUsernameAndPassword","FFI.dittoAuthClientLogout","FFI.dittoAuthClientIsWebValid","FFI.dittoAuthClientUserID","FFI.dittoAuthClientFree","CBOR","CBORRedux","FFI.documentIDQueryCompatible","FFI.validateDocumentID","FFI.dittoGetCompleteAttachmentPath","FFI.freeAttachmentHandle","FFI.DittoCRDTTypeKey","FFI.DittoCRDTType","FFI.dittoResolveAttachment","FFI.dittoCancelResolveAttachment","FFI.addSubscription","FFI.removeSubscription","privateToken","FFI.DittoCRDTValueKey","FFI.documentGetCBORWithPathType","FFI.documentIncrementCounter","FFI.documentSetCBORWithTimestamp","FFI.documentSetCBOR","FFI.documentRemove","FFI.documentsHash","FFI.documentsHashMnemonic","FFI.documentID","FFI.documentFree","FFI.liveQueryStop","FFI.liveQuerySignalAvailableNext","FFI.liveQueryRegister","FFI.liveQueryStart","FFI.writeTransaction","FFI.collectionRemoveQueryStr","FFI.writeTransactionCommit","FFI.collectionEvictQueryStr","FFI.collectionExecQueryStr","FFI.collectionUpdateMultiple","FFI.collectionRemove","FFI.collectionEvict","FFI.readTransaction","FFI.collectionGet","FFI.readTransactionFree","FFI.collectionUpdate","FFI.collectionInsertValue","FFI.dittoNewAttachmentFromFile","FFI.dittoNewAttachmentFromBytes","FFI.dittoGetCollectionNames","FFI.liveQueryWebhookRegister","FFI.dittoPresenceV3","FFI.dittoRegisterPresenceV3Callback","FFI.dittoClearPresenceV3Callback","FFI.dittoPresenceV1","FFI.dittoRegisterPresenceV1Callback","FFI.dittoRegisterTransportConditionChangedCallback","FFI.dittoAddInternalBLEClientTransport","FFI.dittoAddInternalBLEServerTransport","FFI.bleServerFreeHandle","FFI.bleClientFreeHandle","TR.bleIsAvailable","TR.bleCreate","TR.bleDestroy","TR.awdlIsAvailable","TR.awdlCreate","TR.awdlDestroy","FFI.mdnsClientFreeHandle","FFI.mdnsServerFreeHandle","FFI.dittoRemoveMulticastTransport","FFI.dittoAddInternalMdnsTransport","FFI.dittoAddInternalMdnsAdvertiser","FFI.dittoAddMulticastTransport","TR.lanDestroy","TR.lanIsAvailable","TR.lanCreate","FFI.dittoStopTCPServer","FFI.dittoStartTCPServer","FFI.dittoStopHTTPServer","FFI.dittoStartHTTPServer","FFI.addStaticTCPClient","FFI.addWebsocketClient","FFI.dittoSetSyncGroup","FFI.dittoGetSDKVersion","FFI.uninitializedDittoMake","FFI.dittoAuthClientMakeForDevelopment","FFI.dittoAuthClientMakeWithStaticX509","FFI.dittoAuthClientMakeWithSharedKey","FFI.dittoAuthClientMakeAnonymousClient","FFI.dittoAuthClientMakeLoginProvider","FFI.dittoAuthClientMakeWithWeb","FFI.dittoAuthClientSetValidityListener","FFI.dittoAuthClientIsX509Valid","FFI.dittoAuthClientGetSiteID","FFI.dittoMake","FFI.verifyLicense","FFI.dittoRunGarbageCollection","FFI.dittoDisableSyncWithV2","FFI.dittoSetDeviceName","FFI.dittoClearPresenceCallback","FFI.dittoFree"],"mappings":";;AAAA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA,MAAM,cAAc,GAAG,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