@1kbgz/transports 0.7.0 → 0.8.4

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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../pkg/transports.js", "../../src/ts/bridge.ts", "../../src/ts/codecs.ts", "../../src/ts/client.ts", "../../src/ts/index.ts"],
4
- "sourcesContent": ["/* @ts-self-types=\"./transports.d.ts\" */\n\n/**\n * In-process model store: host / mutate \u2192 patch / apply / snapshot.\n */\nexport class Store {\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n StoreFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_store_free(ptr, 0);\n }\n /**\n * Apply a JSON patch to a mirrored model; returns whether the id was known.\n * @param {bigint} id\n * @param {string} patch_json\n * @returns {boolean}\n */\n apply(id, patch_json) {\n const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.store_apply(this.__wbg_ptr, id, ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n }\n /**\n * Host a model from its JSON; returns the assigned id.\n * @param {string} type_name\n * @param {string} value_json\n * @returns {bigint}\n */\n host(type_name, value_json) {\n const ptr0 = passStringToWasm0(type_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.store_host(this.__wbg_ptr, ptr0, len0, ptr1, len1);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return BigInt.asUintN(64, ret[0]);\n }\n /**\n * Replace a hosted model from JSON; returns the JSON patch (or `undefined` if id unknown).\n * @param {bigint} id\n * @param {string} value_json\n * @returns {string | undefined}\n */\n mutate(id, value_json) {\n const ptr0 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.store_mutate(this.__wbg_ptr, id, ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n let v2;\n if (ret[0] !== 0) {\n v2 = getStringFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v2;\n }\n constructor() {\n const ret = wasm.store_new();\n this.__wbg_ptr = ret;\n StoreFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * `{\"type_name\":..,\"rev\":..,\"value\":..}` for a hosted model, or `undefined`.\n * @param {bigint} id\n * @returns {string | undefined}\n */\n snapshot(id) {\n const ret = wasm.store_snapshot(this.__wbg_ptr, id);\n let v1;\n if (ret[0] !== 0) {\n v1 = getStringFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v1;\n }\n}\nif (Symbol.dispose) Store.prototype[Symbol.dispose] = Store.prototype.free;\n\n/**\n * Apply a JSON-encoded patch to a JSON-encoded model, returning the JSON-encoded result.\n * @param {string} value\n * @param {string} patch\n * @returns {string}\n */\nexport function apply(value, patch) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(patch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.apply(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Convert CBOR bytes back to a JSON document.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function cbor_to_json(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cbor_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Decode codec bytes back to a JSON-encoded model string.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function decode(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.decode(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Decode bytes (produced by `codec`'s codec) back to a JSON-encoded model string.\n * @param {Uint8Array} data\n * @param {string} codec\n * @returns {string}\n */\nexport function decode_as(data, codec) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.decode_as(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Diff two JSON-encoded models, returning the JSON-encoded patch.\n * @param {string} old\n * @param {string} _new\n * @returns {string}\n */\nexport function diff(old, _new) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passStringToWasm0(old, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(_new, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.diff(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Encode a JSON-encoded model to codec bytes (a `Uint8Array` in JS).\n * @param {string} value\n * @returns {Uint8Array}\n */\nexport function encode(value) {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.encode(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Encode a JSON-encoded model with the codec named by `codec` (e.g. `\"application/msgpack\"`).\n * @param {string} value\n * @param {string} codec\n * @returns {Uint8Array}\n */\nexport function encode_as(value, codec) {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.encode_as(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Convert an arbitrary JSON document to CBOR bytes (a `Uint8Array` in JS).\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function json_to_cbor(json) {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.json_to_cbor(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Convert an arbitrary JSON document to MessagePack bytes (a `Uint8Array` in JS).\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function json_to_msgpack(json) {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.json_to_msgpack(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Convert MessagePack bytes back to a JSON document.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function msgpack_to_json(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.msgpack_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./transports_bg.js\": import0,\n };\n}\n\nconst StoreFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_store_free(ptr, 1));\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return decodeText(ptr >>> 0, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasmInstance, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasmInstance = instance;\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('transports_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n", "/** The core `Value` wire form: the externally-tagged enum the Rust core speaks. */\nexport type Value =\n | \"Null\"\n | { Bool: boolean }\n | { Int: number }\n | { Float: number }\n | { Str: string }\n | { List: Value[] }\n | { Map: { [k: string]: Value } }\n | { Submodel: number };\n\n/**\n * Convert a plain JS value to the core `Value` wire form.\n *\n * Note: JS has a single number type, so integers and whole-valued floats both encode as `Int`.\n */\nexport function toValue(v: unknown): Value {\n if (v === null || v === undefined) return \"Null\";\n if (typeof v === \"boolean\") return { Bool: v };\n if (typeof v === \"number\")\n return Number.isInteger(v) ? { Int: v } : { Float: v };\n if (typeof v === \"string\") return { Str: v };\n if (Array.isArray(v)) return { List: v.map(toValue) };\n if (typeof v === \"object\") {\n const m: { [k: string]: Value } = {};\n for (const [k, x] of Object.entries(v as object)) m[k] = toValue(x);\n return { Map: m };\n }\n throw new TypeError(`unsupported value for transports: ${typeof v}`);\n}\n\n/** Convert a core `Value` back to a plain JS value. */\nexport function fromValue(value: Value): unknown {\n if (value === \"Null\") return null;\n const [tag, inner] = Object.entries(value)[0];\n switch (tag) {\n case \"Bool\":\n case \"Int\":\n case \"Float\":\n case \"Str\":\n case \"Submodel\":\n return inner;\n case \"List\":\n return (inner as Value[]).map(fromValue);\n case \"Map\": {\n const o: { [k: string]: unknown } = {};\n for (const [k, x] of Object.entries(inner as { [k: string]: Value }))\n o[k] = fromValue(x);\n return o;\n }\n default:\n throw new Error(`unrecognized tagged value: ${JSON.stringify(value)}`);\n }\n}\n", "/** Custom wire codec registry (the JS analog of `transports.register_codec` in Python).\n *\n * A codec turns a JSON-able object (a protocol message, or a model `Value`) into a wire frame\n * (`string` or `Uint8Array`) and back. Register a matching implementation here for any content type\n * you also register on the server, then use it via `new Client(contentType)` / `?codec=`.\n */\n\nexport type CodecEncode = (obj: unknown) => string | Uint8Array;\nexport type CodecDecode = (data: string | Uint8Array) => unknown;\n\nconst BUILTIN = new Set([\n \"\",\n \"json\",\n \"application/json\",\n \"msgpack\",\n \"application/msgpack\",\n \"x-msgpack\",\n \"application/x-msgpack\",\n \"cbor\",\n \"application/cbor\",\n]);\n\nconst registry = new Map<\n string,\n { encode: CodecEncode; decode: CodecDecode }\n>();\n\n/** Register a custom codec under `contentType`. The built-in json/msgpack codecs cannot be overridden. */\nexport function registerCodec(\n contentType: string,\n encode: CodecEncode,\n decode: CodecDecode,\n): void {\n if (BUILTIN.has(contentType)) {\n throw new Error(`cannot override built-in codec: ${contentType}`);\n }\n registry.set(contentType, { encode, decode });\n}\n\n/** Remove a previously registered custom codec. */\nexport function unregisterCodec(contentType: string): void {\n registry.delete(contentType);\n}\n\n/** The currently registered custom codec for `contentType`, if any. */\nexport function codecFor(\n contentType: string,\n): { encode: CodecEncode; decode: CodecDecode } | undefined {\n return registry.get(contentType);\n}\n", "import { codecFor } from \"./codecs\";\nimport {\n cborToJson,\n diff,\n jsonToCbor,\n jsonToMsgpack,\n msgpackToJson,\n} from \"./index\";\nimport type { Value } from \"./bridge\";\n\ntype SnapshotMsg = {\n t: \"snapshot\";\n id: number;\n type: string;\n rev: number;\n value: unknown;\n};\nexport type PathSeg = { Key: string } | { Index: number };\nexport type PatchOp =\n | { Set: { path: PathSeg[]; value: Value } }\n | { Remove: { path: PathSeg[] } }\n | { Insert: { path: PathSeg[]; index: number; value: Value } }\n | { RemoveAt: { path: PathSeg[]; index: number } };\nexport type ModelPatch = { rev: number; ops: PatchOp[] };\ntype PatchMsg = {\n t: \"patch\";\n id: number;\n patch: ModelPatch;\n};\n/** The server refused a proposed edit; `rev` is its current revision and `error` says why (the\n * model's validation message). Sent to the proposer only, after the authoritative revert. */\nexport type RejectMsg = { t: \"reject\"; id: number; rev: number; error: string };\n/** Frame metadata returned after the mirror accepts a snapshot or patch. */\nexport type ReceiveChange =\n | { t: \"snapshot\"; id: number; rev: number }\n | PatchMsg;\n\nfunction mapValue(value: Value | undefined): Record<string, Value> {\n if (\n value &&\n typeof value === \"object\" &&\n \"Map\" in value &&\n value.Map &&\n typeof value.Map === \"object\" &&\n !Array.isArray(value.Map)\n )\n return value.Map;\n throw new Error(\"patch path expected a map\");\n}\n\nfunction listValue(value: Value | undefined): Value[] {\n if (\n value &&\n typeof value === \"object\" &&\n \"List\" in value &&\n Array.isArray(value.List)\n )\n return value.List;\n throw new Error(\"patch path expected a list\");\n}\n\nfunction updateAt(\n value: Value | undefined,\n path: PathSeg[],\n update: (current: Value | undefined) => Value,\n): Value {\n if (!path.length) return update(value);\n const [segment, ...rest] = path;\n if (\"Key\" in segment) {\n const map = mapValue(value);\n if (rest.length && !Object.prototype.hasOwnProperty.call(map, segment.Key))\n throw new Error(\n `patch path key ${JSON.stringify(segment.Key)} not found`,\n );\n return {\n Map: {\n ...map,\n [segment.Key]: updateAt(map[segment.Key], rest, update),\n },\n };\n }\n const list = listValue(value);\n if (segment.Index < 0 || segment.Index >= list.length)\n throw new Error(\n `patch path index ${segment.Index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next[segment.Index] = updateAt(next[segment.Index], rest, update);\n return { List: next };\n}\n\nfunction applyOp(value: Value, op: PatchOp): Value {\n if (\"Set\" in op) return updateAt(value, op.Set.path, () => op.Set.value);\n if (\"Remove\" in op) {\n const { path } = op.Remove;\n const segment = path[path.length - 1];\n if (!segment || !(\"Key\" in segment))\n throw new Error(\"remove path must end in a map key\");\n return updateAt(value, path.slice(0, -1), (container) => {\n const map = { ...mapValue(container) };\n delete map[segment.Key];\n return { Map: map };\n });\n }\n if (\"Insert\" in op) {\n const { path, index, value: inserted } = op.Insert;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (index < 0 || index > list.length)\n throw new Error(\n `insert index ${index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next.splice(index, 0, inserted);\n return { List: next };\n });\n }\n if (\"RemoveAt\" in op) {\n const { path, index } = op.RemoveAt;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (index < 0 || index >= list.length)\n throw new Error(\n `remove index ${index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next.splice(index, 1);\n return { List: next };\n });\n }\n throw new Error(\"unknown patch op\");\n}\n\nfunction applyPatch(value: Value, patch: ModelPatch): Value {\n let next = value;\n for (const op of patch.ops) next = applyOp(next, op);\n return next;\n}\n\n/** Mirrors a remote transports `Session` from connection messages.\n *\n * Inbound frames are decoded by type \u2014 text frames are JSON, binary frames are MessagePack \u2014 so a\n * client transparently mirrors a server regardless of the negotiated codec. Binary built-in codecs\n * and edit generation require the wasm core to be initialized.\n */\nexport class Client {\n private values = new Map<number, unknown>();\n private revs = new Map<number, number>();\n private changeListeners: Array<(change: ReceiveChange) => void> = [];\n private rejectListeners: Array<(reject: RejectMsg) => void> = [];\n\n constructor(private codec: string = \"json\") {}\n\n /** Register a listener fired when the server refuses a proposed edit, with the decoded `reject`\n * frame (model id, the server's current rev, and the validation error). The mirror itself reverts\n * via the authoritative snapshot the server sends alongside. Returns an unsubscribe function.\n */\n onReject(listener: (reject: RejectMsg) => void): () => void {\n this.rejectListeners.push(listener);\n return () => {\n const i = this.rejectListeners.indexOf(listener);\n if (i >= 0) this.rejectListeners.splice(i, 1);\n };\n }\n\n /** Register a listener fired after each accepted snapshot or patch \u2014 the same `ReceiveChange`\n * `recv` returns \u2014 so `connect`/`run`/`connectSSE` consumers get path-level changes without\n * managing the socket themselves. Not fired for ignored frames (stale revision, unknown message\n * type). Returns an unsubscribe function. A listener exception propagates to the `recv` caller;\n * the mirror has already updated by then.\n */\n onChange(listener: (change: ReceiveChange) => void): () => void {\n this.changeListeners.push(listener);\n return () => {\n const i = this.changeListeners.indexOf(listener);\n if (i >= 0) this.changeListeners.splice(i, 1);\n };\n }\n\n private accepted(change: ReceiveChange): ReceiveChange {\n for (const listener of [...this.changeListeners]) listener(change);\n return change;\n }\n\n /** Apply an inbound snapshot or patch frame to the mirror.\n *\n * Decodes by the client's codec: a registered custom codec, else built-in JSON (text) / msgpack\n * (binary). Returns the accepted change so reactive adapters can update only its paths; returns\n * `undefined` for a patch whose revision was already applied, and for an unrecognized message\n * type \u2014 ignored, not an error, so a newer server can add message types without breaking older\n * clients. The returned change and values from `value()` share immutable branches with the\n * mirror; consumers must not mutate them. Invalid frames throw without changing the mirror or its\n * accepted revision.\n */\n recv(data: string | Uint8Array): ReceiveChange | undefined {\n const custom = codecFor(this.codec);\n let msg: SnapshotMsg | PatchMsg | RejectMsg;\n if (custom) {\n msg = custom.decode(data) as SnapshotMsg | PatchMsg | RejectMsg;\n } else if (typeof data === \"string\") {\n msg = JSON.parse(data);\n } else {\n // binary frame: disambiguate by the connection's codec (msgpack vs cbor)\n msg = JSON.parse(\n this.codec === \"cbor\" ? cborToJson(data) : msgpackToJson(data),\n );\n }\n if (msg.t === \"snapshot\") {\n this.values.set(msg.id, msg.value);\n this.revs.set(msg.id, msg.rev);\n return this.accepted({ t: \"snapshot\", id: msg.id, rev: msg.rev });\n } else if (msg.t === \"patch\") {\n // rev is the model's sequence number; ignore a patch already reflected in the mirror (e.g. one\n // the opening snapshot already captured, which the server then also broadcasts).\n const seen = this.revs.get(msg.id);\n if (seen !== undefined && msg.patch.rev <= seen) return undefined;\n const current = this.values.get(msg.id);\n if (current === undefined)\n throw new Error(`patch received before snapshot for model ${msg.id}`);\n this.values.set(msg.id, applyPatch(current as Value, msg.patch));\n this.revs.set(msg.id, msg.patch.rev);\n return this.accepted(msg);\n } else if (msg.t === \"reject\") {\n // the mirror is untouched: the server reverts the proposer with the snapshot sent alongside\n for (const listener of [...this.rejectListeners]) listener(msg);\n return undefined;\n }\n // an unrecognized message type is ignored (not an error): the server may be newer than this\n // client and send types it predates (e.g. a future presence frame)\n return undefined;\n }\n\n /** The current mirrored core `Value` of a model. */\n value(id: number): unknown {\n return this.values.get(id);\n }\n\n ids(): number[] {\n return [...this.values.keys()];\n }\n\n /** Propose an edit to a mirrored model; returns the patch frame to send (encoded in this codec).\n *\n * Server-authoritative: the local mirror updates when the server echoes the authoritative patch\n * back via `recv`, not optimistically.\n */\n edit(id: number, value: unknown): string | Uint8Array {\n const patch = JSON.parse(\n diff(JSON.stringify(this.values.get(id)), JSON.stringify(value)),\n );\n const msg = { t: \"patch\", id, patch };\n const custom = codecFor(this.codec);\n if (custom) return custom.encode(msg);\n const s = JSON.stringify(msg);\n if (this.codec === \"msgpack\") return jsonToMsgpack(s);\n if (this.codec === \"cbor\") return jsonToCbor(s);\n return s;\n }\n\n /** Connect to a transports server and mirror it. Returns the `WebSocket`.\n *\n * On a reconnect (this client already mirrors models) it appends `?since=` with its last-seen rev per\n * model, so the server replays only the delta instead of re-sending each whole model.\n */\n connect(url: string): WebSocket {\n const sep = url.includes(\"?\") ? \"&\" : \"?\";\n let params = `codec=${this.codec}`;\n if (this.revs.size) {\n const since = encodeURIComponent(\n JSON.stringify(Object.fromEntries(this.revs)),\n );\n params += `&since=${since}`;\n }\n const ws = new WebSocket(`${url}${sep}${params}`);\n ws.binaryType = \"arraybuffer\";\n ws.addEventListener(\"message\", (e) => {\n const data = (e as MessageEvent).data;\n this.recv(\n typeof data === \"string\" ? data : new Uint8Array(data as ArrayBuffer),\n );\n });\n return ws;\n }\n\n /** Connect and mirror, **reconnecting** whenever the socket drops \u2014 so the client survives a server\n * restart or a refresh. `authority` decides reconciliation on each (re)connect:\n *\n * - `\"server\"` (default): the server is canonical; the client adopts its state (resuming via `?since=`\n * when it can, else a fresh snapshot) \u2014 the \"refetch on refresh\" behavior.\n * - `\"client\"`: the client is canonical; after the server's snapshot it pushes its last-known state\n * back as an edit, rectifying a server that came back stale/empty (merges under a CRDT, else\n * overwrites).\n *\n * `onMessage` fires after each applied frame (e.g. to re-render). Returns `{ stop() }`.\n */\n run(\n url: string,\n opts: {\n authority?: \"server\" | \"client\";\n retry?: number;\n onMessage?: () => void;\n } = {},\n ): { stop: () => void } {\n const { authority = \"server\", retry = 1000, onMessage } = opts;\n let stopped = false;\n const loop = () => {\n if (stopped) return;\n const pre = authority === \"client\" ? new Map(this.values) : null;\n const pushed = new Set<number>();\n const ws = this.connect(url); // reuses connect(): adds the recv listener + ?since= resume\n ws.addEventListener(\"message\", () => {\n onMessage?.();\n if (pre) {\n // rectify: once the server has (re)snapshotted a model, push our copy back to it\n for (const id of this.values.keys()) {\n if (!pushed.has(id) && pre.has(id)) {\n // cast, not copy: wasm-bindgen types its output Uint8Array<ArrayBufferLike>, but it\n // is always ArrayBuffer-backed, which is what WebSocket.send requires\n ws.send(\n this.edit(id, pre.get(id)) as string | Uint8Array<ArrayBuffer>,\n );\n pushed.add(id);\n }\n }\n }\n });\n ws.addEventListener(\"close\", () => {\n if (!stopped) setTimeout(loop, retry);\n });\n ws.addEventListener(\"error\", () => {\n try {\n ws.close();\n } catch {\n /* already closing */\n }\n });\n };\n loop();\n return {\n stop() {\n stopped = true;\n },\n };\n }\n\n /** Mirror a server over Server-Sent Events (receive-only, JSON). Returns the `EventSource`. */\n connectSSE(url: string): EventSource {\n const es = new EventSource(url);\n es.addEventListener(\"message\", (e) =>\n this.recv((e as MessageEvent).data as string),\n );\n return es;\n }\n}\n", "import * as wasm from \"../../dist/pkg/transports\";\n\nexport * as wasm from \"../../dist/pkg/transports\";\n\nexport const placeholder = \"\";\n\n/** Diff two JSON-encoded models, returning the JSON-encoded patch. */\nexport const diff = (oldModel: string, newModel: string): string =>\n wasm.diff(oldModel, newModel);\n\n/** Apply a JSON-encoded patch to a JSON-encoded model, returning the JSON-encoded result. */\nexport const apply = (model: string, patch: string): string =>\n wasm.apply(model, patch);\n\n/** Encode a JSON-encoded model to codec bytes. */\nexport const encode = (model: string): Uint8Array => wasm.encode(model);\n\n/** Decode codec bytes back to a JSON-encoded model string. */\nexport const decode = (bytes: Uint8Array): string => wasm.decode(bytes);\n\n/** Encode a JSON-encoded model with the codec named by `codec` (e.g. \"application/msgpack\"). */\nexport const encodeAs = (model: string, codec: string): Uint8Array =>\n wasm.encode_as(model, codec);\n\n/** Decode bytes (from `codec`'s codec) back to a JSON-encoded model string. */\nexport const decodeAs = (bytes: Uint8Array, codec: string): string =>\n wasm.decode_as(bytes, codec);\n\n/** Convert an arbitrary JSON document to MessagePack bytes (for whole protocol messages). */\nexport const jsonToMsgpack = (json: string): Uint8Array =>\n wasm.json_to_msgpack(json);\n\n/** Convert MessagePack bytes back to a JSON document. */\nexport const msgpackToJson = (bytes: Uint8Array): string =>\n wasm.msgpack_to_json(bytes);\n\n/** Convert an arbitrary JSON document to CBOR bytes (for whole protocol messages). */\nexport const jsonToCbor = (json: string): Uint8Array => wasm.json_to_cbor(json);\n\n/** Convert CBOR bytes back to a JSON document. */\nexport const cborToJson = (bytes: Uint8Array): string =>\n wasm.cbor_to_json(bytes);\n\n/** In-process model store: host / mutate \u2192 patch / apply / snapshot. */\nexport const Store = wasm.Store;\n\n// Plain JS object <-> core `Value` bridge (the JS analog of the Python bridge).\nexport { toValue, fromValue } from \"./bridge\";\nexport type { Value } from \"./bridge\";\n\n// WebSocket client that mirrors a remote Session.\nexport { Client } from \"./client\";\nexport type {\n ModelPatch,\n PatchOp,\n PathSeg,\n ReceiveChange,\n RejectMsg,\n} from \"./client\";\n\n// Custom wire codec registry.\nexport { registerCodec, unregisterCodec, codecFor } from \"./codecs\";\nexport type { CodecEncode, CodecDecode } from \"./codecs\";\n"],
5
- "mappings": ";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAM,QAAN,MAAY;AAAA,EACf,qBAAqB;AACjB,UAAM,MAAM,KAAK;AACjB,SAAK,YAAY;AACjB,sBAAkB,WAAW,IAAI;AACjC,WAAO;AAAA,EACX;AAAA,EACA,OAAO;AACH,UAAM,MAAM,KAAK,mBAAmB;AACpC,SAAK,iBAAiB,KAAK,CAAC;AAAA,EAChC;AAA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AACF,aAAG,MAAM;AAAA,QACX,QAAQ;AAAA,QAER;AAAA,MACF,CAAC;AAAA,IACH;AACA,SAAK;AACL,WAAO;AAAA,MACL,OAAO;AACL,kBAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,WAAW,KAA0B;AACnC,UAAM,KAAK,IAAI,YAAY,GAAG;AAC9B,OAAG;AAAA,MAAiB;AAAA,MAAW,CAAC,MAC9B,KAAK,KAAM,EAAmB,IAAc;AAAA,IAC9C;AACA,WAAO;AAAA,EACT;AACF;;;AC7VO,IAAM,cAAc;AAGpB,IAAMC,QAAO,CAAC,UAAkB,aAChC,KAAK,UAAU,QAAQ;AAGvB,IAAMC,SAAQ,CAAC,OAAe,UAC9B,MAAM,OAAO,KAAK;AAGlB,IAAMC,UAAS,CAAC,UAAmC,OAAO,KAAK;AAG/D,IAAMC,UAAS,CAAC,UAAmC,OAAO,KAAK;AAG/D,IAAM,WAAW,CAAC,OAAe,UACjC,UAAU,OAAO,KAAK;AAGtB,IAAM,WAAW,CAAC,OAAmB,UACrC,UAAU,OAAO,KAAK;AAGtB,IAAM,gBAAgB,CAAC,SACvB,gBAAgB,IAAI;AAGpB,IAAM,gBAAgB,CAAC,UACvB,gBAAgB,KAAK;AAGrB,IAAM,aAAa,CAAC,SAAkC,aAAa,IAAI;AAGvE,IAAM,aAAa,CAAC,UACpB,aAAa,KAAK;AAGlB,IAAMC,SAAa;",
6
- "names": ["ptr", "encode", "decode", "diff", "diff", "apply", "encode", "decode", "Store"]
4
+ "sourcesContent": ["/* @ts-self-types=\"./transports.d.ts\" */\n\n/**\n * Shared revision and proposal reducer for a language-level client adapter.\n */\nexport class ClientState {\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n ClientStateFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_clientstate_free(ptr, 0);\n }\n /**\n * @param {string} proposal\n * @returns {boolean}\n */\n abandon(proposal) {\n const ptr0 = passStringToWasm0(proposal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.clientstate_abandon(this.__wbg_ptr, ptr0, len0);\n return ret !== 0;\n }\n /**\n * @param {string} effect_json\n */\n commit(effect_json) {\n const ptr0 = passStringToWasm0(effect_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.clientstate_commit(this.__wbg_ptr, ptr0, len0);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @returns {string}\n */\n disconnect() {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.clientstate_disconnect(this.__wbg_ptr);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n constructor() {\n const ret = wasm.clientstate_new();\n this.__wbg_ptr = ret;\n ClientStateFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * @returns {string}\n */\n pending() {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.clientstate_pending(this.__wbg_ptr);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {string} message_json\n * @returns {string}\n */\n prepare(message_json) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(message_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.clientstate_prepare(this.__wbg_ptr, ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n }\n /**\n * @param {bigint} id\n * @param {string} ops_json\n * @param {string | null} [proposal]\n * @returns {string}\n */\n proposal(id, ops_json, proposal) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passStringToWasm0(ops_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n var ptr1 = isLikeNone(proposal) ? 0 : passStringToWasm0(proposal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n const ret = wasm.clientstate_proposal(this.__wbg_ptr, id, ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n }\n /**\n * @returns {string}\n */\n revisions() {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.clientstate_revisions(this.__wbg_ptr);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n}\nif (Symbol.dispose) ClientState.prototype[Symbol.dispose] = ClientState.prototype.free;\n\n/**\n * In-process model store: host / mutate \u2192 patch / apply / snapshot.\n */\nexport class Store {\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n StoreFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_store_free(ptr, 0);\n }\n /**\n * Apply a JSON patch to a mirrored model; returns whether the id was known.\n * @param {bigint} id\n * @param {string} patch_json\n * @returns {boolean}\n */\n apply(id, patch_json) {\n const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.store_apply(this.__wbg_ptr, id, ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n }\n /**\n * Host a model from its JSON; returns the assigned id.\n * @param {string} type_name\n * @param {string} value_json\n * @returns {bigint}\n */\n host(type_name, value_json) {\n const ptr0 = passStringToWasm0(type_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.store_host(this.__wbg_ptr, ptr0, len0, ptr1, len1);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return BigInt.asUintN(64, ret[0]);\n }\n /**\n * Replace a hosted model from JSON; returns the JSON patch (or `undefined` if id unknown).\n * @param {bigint} id\n * @param {string} value_json\n * @returns {string | undefined}\n */\n mutate(id, value_json) {\n const ptr0 = passStringToWasm0(value_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.store_mutate(this.__wbg_ptr, id, ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n let v2;\n if (ret[0] !== 0) {\n v2 = getStringFromWasm0(ret[0], ret[1]);\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v2;\n }\n constructor() {\n const ret = wasm.store_new();\n this.__wbg_ptr = ret;\n StoreFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * `{\"type_name\":..,\"rev\":..,\"value\":..}` for a hosted model, or `undefined`.\n * @param {bigint} id\n * @returns {string | undefined}\n */\n snapshot(id) {\n const ret = wasm.store_snapshot(this.__wbg_ptr, id);\n let v1;\n if (ret[0] !== 0) {\n v1 = getStringFromWasm0(ret[0], ret[1]);\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v1;\n }\n}\nif (Symbol.dispose) Store.prototype[Symbol.dispose] = Store.prototype.free;\n\n/**\n * Apply a JSON-encoded patch to a JSON-encoded model, returning the JSON-encoded result.\n * @param {string} value\n * @param {string} patch\n * @returns {string}\n */\nexport function apply(value, patch) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(patch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.apply(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Convert CBOR bytes back to a JSON document.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function cbor_to_json(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cbor_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Decode codec bytes back to a JSON-encoded model string.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function decode(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.decode(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Decode bytes (produced by `codec`'s codec) back to a JSON-encoded model string.\n * @param {Uint8Array} data\n * @param {string} codec\n * @returns {string}\n */\nexport function decode_as(data, codec) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.decode_as(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Decode one built-in connection-codec payload as a typed live protocol message JSON string.\n * @param {Uint8Array} data\n * @param {string} codec\n * @returns {string}\n */\nexport function decode_message(data, codec) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.decode_message(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Diff two JSON-encoded models, returning the JSON-encoded patch.\n * @param {string} old\n * @param {string} _new\n * @returns {string}\n */\nexport function diff(old, _new) {\n let deferred4_0;\n let deferred4_1;\n try {\n const ptr0 = passStringToWasm0(old, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(_new, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.diff(ptr0, len0, ptr1, len1);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Encode a JSON-encoded model to codec bytes (a `Uint8Array` in JS).\n * @param {string} value\n * @returns {Uint8Array}\n */\nexport function encode(value) {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.encode(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Encode a JSON-encoded model with the codec named by `codec` (e.g. `\"application/msgpack\"`).\n * @param {string} value\n * @param {string} codec\n * @returns {Uint8Array}\n */\nexport function encode_as(value, codec) {\n const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.encode_as(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Encode one JSON live protocol message with a built-in connection codec.\n * @param {string} json\n * @param {string} codec\n * @returns {Uint8Array}\n */\nexport function encode_message(json, codec) {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.encode_message(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Convert an arbitrary JSON document to CBOR bytes (a `Uint8Array` in JS).\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function json_to_cbor(json) {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.json_to_cbor(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Convert an arbitrary JSON document to MessagePack bytes (a `Uint8Array` in JS).\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function json_to_msgpack(json) {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.json_to_msgpack(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Convert MessagePack bytes back to a JSON document.\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function msgpack_to_json(data) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.msgpack_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Parse and serialize one typed live protocol message as compact JSON.\n * @param {string} json\n * @returns {string}\n */\nexport function normalize_message(json) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.normalize_message(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./transports_bg.js\": import0,\n };\n}\n\nconst ClientStateFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_clientstate_free(ptr, 1));\nconst StoreFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_store_free(ptr, 1));\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return decodeText(ptr >>> 0, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasmInstance, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasmInstance = instance;\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (!module.ok) {\n throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);\n }\n\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('transports_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n", "/** The core `Value` wire form: the externally-tagged enum the Rust core speaks. */\nexport type Value =\n | \"Null\"\n | { Bool: boolean }\n | { Int: number }\n | { Float: number }\n | { Str: string }\n | { List: Value[] }\n | { Map: { [k: string]: Value } }\n | { Submodel: number };\n\n/**\n * Convert a plain JS value to the core `Value` wire form.\n *\n * Note: JS has a single number type, so integers and whole-valued floats both encode as `Int`.\n */\nexport function toValue(v: unknown): Value {\n if (v === null || v === undefined) return \"Null\";\n if (typeof v === \"boolean\") return { Bool: v };\n if (typeof v === \"number\")\n return Number.isInteger(v) ? { Int: v } : { Float: v };\n if (typeof v === \"string\") return { Str: v };\n if (Array.isArray(v)) return { List: v.map(toValue) };\n if (typeof v === \"object\") {\n const m: { [k: string]: Value } = {};\n for (const [k, x] of Object.entries(v as object)) m[k] = toValue(x);\n return { Map: m };\n }\n throw new TypeError(`unsupported value for transports: ${typeof v}`);\n}\n\n/** Convert a core `Value` back to a plain JS value. */\nexport function fromValue(value: Value): unknown {\n if (value === \"Null\") return null;\n const [tag, inner] = Object.entries(value)[0];\n switch (tag) {\n case \"Bool\":\n case \"Int\":\n case \"Float\":\n case \"Str\":\n case \"Submodel\":\n return inner;\n case \"List\":\n return (inner as Value[]).map(fromValue);\n case \"Map\": {\n const o: { [k: string]: unknown } = {};\n for (const [k, x] of Object.entries(inner as { [k: string]: Value }))\n o[k] = fromValue(x);\n return o;\n }\n default:\n throw new Error(`unrecognized tagged value: ${JSON.stringify(value)}`);\n }\n}\n", "/** Custom wire codec registry (the JS analog of `transports.register_codec` in Python).\n *\n * A codec turns a JSON-able object (a protocol message, or a model `Value`) into a wire frame\n * (`string` or `Uint8Array`) and back. Register a matching implementation here for any content type\n * you also register on the server, then use it via `new Client(contentType)` / `?codec=`.\n */\n\nexport type CodecEncode = (obj: unknown) => string | Uint8Array;\nexport type CodecDecode = (data: string | Uint8Array) => unknown;\n\nconst BUILTIN = new Set([\n \"\",\n \"json\",\n \"application/json\",\n \"msgpack\",\n \"application/msgpack\",\n \"x-msgpack\",\n \"application/x-msgpack\",\n \"cbor\",\n \"application/cbor\",\n]);\n\nconst registry = new Map<\n string,\n { encode: CodecEncode; decode: CodecDecode }\n>();\n\n/** Register a custom codec under `contentType`. The built-in json/msgpack codecs cannot be overridden. */\nexport function registerCodec(\n contentType: string,\n encode: CodecEncode,\n decode: CodecDecode,\n): void {\n if (BUILTIN.has(contentType)) {\n throw new Error(`cannot override built-in codec: ${contentType}`);\n }\n registry.set(contentType, { encode, decode });\n}\n\n/** Remove a previously registered custom codec. */\nexport function unregisterCodec(contentType: string): void {\n registry.delete(contentType);\n}\n\n/** The currently registered custom codec for `contentType`, if any. */\nexport function codecFor(\n contentType: string,\n): { encode: CodecEncode; decode: CodecDecode } | undefined {\n return registry.get(contentType);\n}\n", "import { codecFor } from \"./codecs\";\nimport {\n ClientState as WasmClientState,\n decodeMessage,\n diff,\n encodeMessage,\n} from \"./index\";\nimport type { Value } from \"./bridge\";\n\ntype SnapshotMsg = {\n t: \"snapshot\";\n id: number;\n type: string;\n rev: number;\n value: unknown;\n};\nexport type PathSeg = { Key: string } | { Index: number };\nexport type PatchOp =\n | { Set: { path: PathSeg[]; value: Value } }\n | { Remove: { path: PathSeg[] } }\n | { Insert: { path: PathSeg[]; index: number; value: Value } }\n | { RemoveAt: { path: PathSeg[]; index: number } }\n | { Move: { path: PathSeg[]; from: number; to: number } }\n | { Reorder: { path: PathSeg[]; order: number[] } };\nexport type ModelPatch = { rev: number; ops: PatchOp[] };\nexport type PatchMsg = {\n t: \"patch\";\n id: number;\n patch: ModelPatch;\n proposal?: string;\n};\n/** An accepted proposal that produced no authoritative patch. */\nexport type AckMsg = { t: \"ack\"; id: number; rev: number; proposal: string };\n/** The server refused a proposed edit; `rev` is its current revision and `error` says why (the\n * model's validation message). Sent to the proposer only, after the authoritative revert. */\nexport type RejectMsg = {\n t: \"reject\";\n id: number;\n rev: number;\n error: string;\n proposal?: string;\n};\n/** Frame metadata returned after the mirror accepts a snapshot or patch. */\nexport type ReceiveChange =\n | { t: \"snapshot\"; id: number; rev: number }\n | PatchMsg;\n\ntype ClientEffect =\n | { effect: \"snapshot\"; id: number; rev: number }\n | {\n effect: \"patch\" | \"stale_patch\";\n id: number;\n rev: number;\n proposal?: string;\n }\n | {\n effect: \"acknowledgement\";\n id: number;\n rev: number;\n proposal: string;\n }\n | {\n effect: \"rejection\";\n id: number;\n rev: number;\n error: string;\n proposal?: string;\n }\n | { effect: \"ignore\" }\n | { effect: \"disconnect\"; proposals: string[] };\n\ninterface ClientStateAdapter {\n prepare(message: object): ClientEffect;\n commit(effect: ClientEffect): void;\n proposal(id: number, ops: PatchOp[], proposal?: string): string;\n disconnect(): Extract<ClientEffect, { effect: \"disconnect\" }>;\n revisions(): Record<string, number>;\n pending(): string[];\n abandon(proposal: string): boolean;\n}\n\nclass SharedClientState implements ClientStateAdapter {\n private inner = new WasmClientState();\n\n prepare(message: object): ClientEffect {\n return JSON.parse(this.inner.prepare(JSON.stringify(message)));\n }\n\n commit(effect: ClientEffect): void {\n this.inner.commit(JSON.stringify(effect));\n }\n\n proposal(id: number, ops: PatchOp[], proposal?: string): string {\n return this.inner.proposal(BigInt(id), JSON.stringify(ops), proposal);\n }\n\n disconnect(): Extract<ClientEffect, { effect: \"disconnect\" }> {\n return JSON.parse(this.inner.disconnect());\n }\n\n revisions(): Record<string, number> {\n return JSON.parse(this.inner.revisions());\n }\n\n pending(): string[] {\n return JSON.parse(this.inner.pending());\n }\n\n abandon(proposal: string): boolean {\n return this.inner.abandon(proposal);\n }\n}\n\nfunction mapValue(value: Value | undefined): Record<string, Value> {\n if (\n value &&\n typeof value === \"object\" &&\n \"Map\" in value &&\n value.Map &&\n typeof value.Map === \"object\" &&\n !Array.isArray(value.Map)\n )\n return value.Map;\n throw new Error(\"patch path expected a map\");\n}\n\ninterface BatchMsg {\n t: \"batch\";\n msgs: (SnapshotMsg | PatchMsg | RejectMsg)[];\n}\n\nfunction listValue(value: Value | undefined): Value[] {\n if (\n value &&\n typeof value === \"object\" &&\n \"List\" in value &&\n Array.isArray(value.List)\n )\n return value.List;\n throw new Error(\"patch path expected a list\");\n}\n\nfunction validIndex(index: number): boolean {\n return Number.isSafeInteger(index) && index >= 0;\n}\n\nfunction updateAt(\n value: Value | undefined,\n path: PathSeg[],\n update: (current: Value | undefined) => Value,\n): Value {\n if (!path.length) return update(value);\n const [segment, ...rest] = path;\n if (\"Key\" in segment) {\n const map = mapValue(value);\n if (rest.length && !Object.prototype.hasOwnProperty.call(map, segment.Key))\n throw new Error(\n `patch path key ${JSON.stringify(segment.Key)} not found`,\n );\n return {\n Map: {\n ...map,\n [segment.Key]: updateAt(map[segment.Key], rest, update),\n },\n };\n }\n const list = listValue(value);\n if (!validIndex(segment.Index) || segment.Index >= list.length)\n throw new Error(\n `patch path index ${segment.Index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next[segment.Index] = updateAt(next[segment.Index], rest, update);\n return { List: next };\n}\n\nfunction applyOp(value: Value, op: PatchOp): Value {\n if (\"Set\" in op) return updateAt(value, op.Set.path, () => op.Set.value);\n if (\"Remove\" in op) {\n const { path } = op.Remove;\n const segment = path[path.length - 1];\n if (!segment || !(\"Key\" in segment))\n throw new Error(\"remove path must end in a map key\");\n return updateAt(value, path.slice(0, -1), (container) => {\n const map = { ...mapValue(container) };\n delete map[segment.Key];\n return { Map: map };\n });\n }\n if (\"Insert\" in op) {\n const { path, index, value: inserted } = op.Insert;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (!validIndex(index) || index > list.length)\n throw new Error(\n `insert index ${index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next.splice(index, 0, inserted);\n return { List: next };\n });\n }\n if (\"RemoveAt\" in op) {\n const { path, index } = op.RemoveAt;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (!validIndex(index) || index >= list.length)\n throw new Error(\n `remove index ${index} out of bounds (len ${list.length})`,\n );\n const next = [...list];\n next.splice(index, 1);\n return { List: next };\n });\n }\n if (\"Move\" in op) {\n const { path, from, to } = op.Move;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (!validIndex(from) || from >= list.length)\n throw new Error(\n `move source index ${from} out of bounds (len ${list.length})`,\n );\n if (!validIndex(to) || to >= list.length)\n throw new Error(\n `move destination index ${to} out of bounds (len ${list.length})`,\n );\n if (from === to) return container as Value;\n const next = [...list];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved);\n return { List: next };\n });\n }\n if (\"Reorder\" in op) {\n const { path, order } = op.Reorder;\n return updateAt(value, path, (container) => {\n const list = listValue(container);\n if (!Array.isArray(order))\n throw new Error(\"reorder order must be an array\");\n if (order.length !== list.length)\n throw new Error(\n `reorder length ${order.length} does not match list length ${list.length}`,\n );\n const seen = new Set<number>();\n for (const index of order) {\n if (!validIndex(index) || index >= list.length)\n throw new Error(\n `reorder index ${index} out of bounds (len ${list.length})`,\n );\n if (seen.has(index))\n throw new Error(`reorder index ${index} is duplicated`);\n seen.add(index);\n }\n if (order.every((old, current) => old === current))\n return container as Value;\n return { List: order.map((index) => list[index]) };\n });\n }\n throw new Error(\"unknown patch op\");\n}\n\nfunction applyPatch(value: Value, patch: ModelPatch): Value {\n let next = value;\n for (const op of patch.ops) next = applyOp(next, op);\n return next;\n}\n\n/** Mirrors a remote transports `Session` from connection messages.\n *\n * Inbound frames are decoded by type \u2014 text frames are JSON, binary frames are MessagePack \u2014 so a\n * client transparently mirrors a server regardless of the negotiated codec. Binary built-in codecs\n * and edit generation require the wasm core to be initialized.\n */\nexport class Client {\n private values = new Map<number, unknown>();\n private changeListeners: Array<(change: ReceiveChange) => void> = [];\n private ackListeners: Array<(ack: PatchMsg | AckMsg) => void> = [];\n private rejectListeners: Array<(reject: RejectMsg) => void> = [];\n private abandonListeners: Array<(proposals: string[]) => void> = [];\n private disconnectListeners: Array<() => void> = [];\n private state: ClientStateAdapter;\n // outbound channel of the active managed connection (set by connect()/run(), cleared on close)\n private sender: ((frame: string | Uint8Array) => void) | null = null;\n\n constructor(private codec: string = \"json\") {\n this.state = new SharedClientState();\n }\n\n /** Whether a managed connection (`connect()`/`run()`) is open right now. */\n get connected(): boolean {\n return this.sender !== null;\n }\n\n /** Send a frame over the active managed connection (`connect()`/`run()`).\n *\n * Returns `true` when handed to an open connection, `false` when none is active (never connected,\n * in a reconnect gap, or receive-only `connectSSE`) \u2014 the frame is dropped, matching a browser\n * WebSocket's send on a closed socket. That makes it a drop-in fire-and-forget callback for an\n * adapter \u2014 e.g. spaday's `connectStore(store, client, (f) => client.send(f), codec)` \u2014 check\n * `connected` (or the return) when delivery matters.\n */\n send(frame: string | Uint8Array): boolean {\n if (!this.sender) return false;\n this.sender(frame);\n return true;\n }\n\n /** Propose an edit over the active connection: `send(edit(id, value))`. Server-authoritative \u2014\n * the mirror updates when the authoritative patch echoes back (or `onReject` fires). Returns\n * `false` (dropped) when not connected. */\n propose(id: number, value: unknown, proposal?: string): boolean {\n return this.sendProposal(this.edit(id, value, proposal));\n }\n\n /** Propose explicit patch operations over the active connection. */\n proposeOps(id: number, ops: PatchOp[], proposal?: string): boolean {\n return this.sendProposal(this.editOps(id, ops, proposal));\n }\n\n private sendProposal(frame: string | Uint8Array): boolean {\n const custom = codecFor(this.codec);\n const message = custom\n ? (custom.decode(frame) as PatchMsg)\n : JSON.parse(\n typeof frame === \"string\" ? frame : decodeMessage(frame, this.codec),\n );\n try {\n const sent = this.send(frame);\n if (!sent && message.proposal !== undefined)\n this.state.abandon(message.proposal);\n return sent;\n } catch (error) {\n if (message.proposal !== undefined) this.state.abandon(message.proposal);\n throw error;\n }\n }\n\n /** Register a listener fired when the server refuses a proposed edit, with the decoded `reject`\n * frame (model id, the server's current rev, and the validation error). The mirror itself reverts\n * via the authoritative snapshot the server sends alongside. Returns an unsubscribe function.\n */\n onReject(listener: (reject: RejectMsg) => void): () => void {\n this.rejectListeners.push(listener);\n return () => {\n const i = this.rejectListeners.indexOf(listener);\n if (i >= 0) this.rejectListeners.splice(i, 1);\n };\n }\n\n /** Register a listener fired when the server accepts a tagged proposal. Receives an authoritative\n * patch or no-op acknowledgement carrying the same opaque proposal identifier. */\n onAck(listener: (ack: PatchMsg | AckMsg) => void): () => void {\n this.ackListeners.push(listener);\n return () => {\n const i = this.ackListeners.indexOf(listener);\n if (i >= 0) this.ackListeners.splice(i, 1);\n };\n }\n\n /** Register a listener fired when an active managed WebSocket disconnects. */\n onDisconnect(listener: () => void): () => void {\n this.disconnectListeners.push(listener);\n return () => {\n const i = this.disconnectListeners.indexOf(listener);\n if (i >= 0) this.disconnectListeners.splice(i, 1);\n };\n }\n\n /** Register a listener fired with unsettled proposal identifiers on disconnect. */\n onAbandon(listener: (proposals: string[]) => void): () => void {\n this.abandonListeners.push(listener);\n return () => {\n const i = this.abandonListeners.indexOf(listener);\n if (i >= 0) this.abandonListeners.splice(i, 1);\n };\n }\n\n private disconnected(): void {\n const { proposals } = this.state.disconnect();\n if (proposals.length)\n for (const listener of [...this.abandonListeners]) listener(proposals);\n for (const listener of [...this.disconnectListeners]) listener();\n }\n\n /** Register a listener fired after each accepted snapshot or patch \u2014 the same `ReceiveChange`\n * `recv` returns \u2014 so `connect`/`run`/`connectSSE` consumers get path-level changes without\n * managing the socket themselves. Not fired for ignored frames (stale revision, unknown message\n * type). Returns an unsubscribe function. A listener exception propagates to the `recv` caller;\n * the mirror has already updated by then.\n */\n onChange(listener: (change: ReceiveChange) => void): () => void {\n this.changeListeners.push(listener);\n return () => {\n const i = this.changeListeners.indexOf(listener);\n if (i >= 0) this.changeListeners.splice(i, 1);\n };\n }\n\n private accepted(change: ReceiveChange): ReceiveChange {\n for (const listener of [...this.changeListeners]) listener(change);\n return change;\n }\n\n private acknowledge(msg: PatchMsg | AckMsg): void {\n if (msg.proposal !== undefined)\n for (const listener of [...this.ackListeners]) listener(msg);\n }\n\n /** Apply an inbound snapshot or patch frame to the mirror.\n *\n * Decodes by the client's codec: a registered custom codec, else built-in JSON (text) / msgpack\n * (binary). Returns the accepted change so reactive adapters can update only its paths; returns\n * `undefined` for a patch whose revision was already applied, and for an unrecognized message\n * type \u2014 ignored, not an error, so a newer server can add message types without breaking older\n * clients. The returned change and values from `value()` share immutable branches with the\n * mirror; consumers must not mutate them. Invalid frames throw without changing the mirror or its\n * accepted revision.\n */\n recv(data: string | Uint8Array): ReceiveChange | ReceiveChange[] | undefined {\n const custom = codecFor(this.codec);\n let msg: SnapshotMsg | PatchMsg | AckMsg | RejectMsg | BatchMsg;\n if (custom) {\n msg = custom.decode(data) as SnapshotMsg | PatchMsg | AckMsg | RejectMsg;\n } else if (typeof data === \"string\") {\n msg = JSON.parse(data);\n } else {\n // binary frame: disambiguate by the connection's codec (msgpack vs cbor)\n msg = JSON.parse(decodeMessage(data, this.codec));\n }\n if (msg.t === \"batch\") {\n // a negotiated batch frame (the connection asked with ?batch=1): apply each message in\n // order and return the accepted changes as an array\n const accepted = msg.msgs\n .map((m) => this.apply(m))\n .filter((a): a is ReceiveChange => a !== undefined);\n return accepted.length ? accepted : undefined;\n }\n return this.apply(msg);\n }\n\n private apply(\n msg: SnapshotMsg | PatchMsg | AckMsg | RejectMsg,\n ): ReceiveChange | undefined {\n const effect = this.state.prepare(msg);\n if (effect.effect === \"snapshot\") {\n const snapshot = msg as SnapshotMsg;\n this.values.set(snapshot.id, snapshot.value);\n this.state.commit(effect);\n return this.accepted({\n t: \"snapshot\",\n id: snapshot.id,\n rev: snapshot.rev,\n });\n } else if (effect.effect === \"patch\") {\n const patch = msg as PatchMsg;\n const current = this.values.get(patch.id);\n if (current === undefined)\n throw new Error(`patch received before snapshot for model ${patch.id}`);\n const value = applyPatch(current as Value, patch.patch);\n this.state.commit(effect);\n this.values.set(patch.id, value);\n const accepted = this.accepted(patch);\n this.acknowledge(patch);\n return accepted;\n } else if (effect.effect === \"stale_patch\") {\n this.state.commit(effect);\n this.acknowledge(msg as PatchMsg);\n return undefined;\n } else if (effect.effect === \"acknowledgement\") {\n this.state.commit(effect);\n this.acknowledge(msg as AckMsg);\n return undefined;\n } else if (effect.effect === \"rejection\") {\n this.state.commit(effect);\n const rejection = msg as RejectMsg;\n for (const listener of [...this.rejectListeners]) listener(rejection);\n return undefined;\n }\n return undefined;\n }\n\n /** The current mirrored core `Value` of a model. */\n value(id: number): unknown {\n return this.values.get(id);\n }\n\n ids(): number[] {\n return [...this.values.keys()];\n }\n\n /** Identifiers for proposals that have not settled or been abandoned. */\n pendingProposals(): string[] {\n return this.state.pending();\n }\n\n /** Propose an edit to a mirrored model; returns the patch frame to send (encoded in this codec).\n *\n * Server-authoritative: the local mirror updates when the server echoes the authoritative patch\n * back via `recv`, not optimistically.\n */\n edit(id: number, value: unknown, proposal?: string): string | Uint8Array {\n const patch = JSON.parse(\n diff(JSON.stringify(this.values.get(id)), JSON.stringify(value)),\n );\n return this.editOps(id, patch.ops, proposal);\n }\n\n /** Propose explicit patch operations. This can express a value equal to the current mirror while\n * an older optimistic proposal is pending. A client-local proposal id is assigned by default. */\n editOps(id: number, ops: PatchOp[], proposal?: string): string | Uint8Array {\n const message = this.state.proposal(id, ops, proposal);\n const decoded = JSON.parse(message) as PatchMsg;\n try {\n const custom = codecFor(this.codec);\n if (custom) return custom.encode(decoded);\n if (this.codec !== \"json\") return encodeMessage(message, this.codec);\n return message;\n } catch (error) {\n if (decoded.proposal !== undefined) this.state.abandon(decoded.proposal);\n throw error;\n }\n }\n\n /** Connect to a transports server and mirror it. Returns the `WebSocket`.\n *\n * On a reconnect (this client already mirrors models) it appends `?since=` with its last-seen rev per\n * model, so the server replays only the delta instead of re-sending each whole model.\n */\n connect(url: string): WebSocket {\n const sep = url.includes(\"?\") ? \"&\" : \"?\";\n let params = `codec=${this.codec}`;\n const revisions = this.state.revisions();\n if (Object.keys(revisions).length) {\n const since = encodeURIComponent(JSON.stringify(revisions));\n params += `&since=${since}`;\n }\n const ws = new WebSocket(`${url}${sep}${params}`);\n ws.binaryType = \"arraybuffer\";\n ws.addEventListener(\"message\", (e) => {\n const data = (e as MessageEvent).data;\n this.recv(\n typeof data === \"string\" ? data : new Uint8Array(data as ArrayBuffer),\n );\n });\n const sender = (frame: string | Uint8Array) =>\n ws.send(frame as string | Uint8Array<ArrayBuffer>);\n ws.addEventListener(\"open\", () => {\n this.sender = sender; // arm only once open: send during CONNECTING throws in the DOM\n });\n ws.addEventListener(\"close\", () => {\n if (this.sender === sender) {\n this.sender = null; // don't clobber a newer reconnect's channel\n this.disconnected();\n }\n });\n return ws;\n }\n\n /** Connect and mirror, **reconnecting** whenever the socket drops \u2014 so the client survives a server\n * restart or a refresh. `authority` decides reconciliation on each (re)connect:\n *\n * - `\"server\"` (default): the server is canonical; the client adopts its state (resuming via `?since=`\n * when it can, else a fresh snapshot) \u2014 the \"refetch on refresh\" behavior.\n * - `\"client\"`: the client is canonical; after the server's snapshot it pushes its last-known state\n * back as an edit, rectifying a server that came back stale/empty (merges under a CRDT, else\n * overwrites).\n *\n * `onMessage` fires after each applied frame (e.g. to re-render). Returns `{ stop() }`.\n */\n run(\n url: string,\n opts: {\n authority?: \"server\" | \"client\";\n retry?: number;\n onMessage?: () => void;\n } = {},\n ): { stop: () => void } {\n const { authority = \"server\", retry = 1000, onMessage } = opts;\n let stopped = false;\n const loop = () => {\n if (stopped) return;\n const pre = authority === \"client\" ? new Map(this.values) : null;\n const pushed = new Set<number>();\n const ws = this.connect(url); // reuses connect(): adds the recv listener + ?since= resume\n ws.addEventListener(\"message\", () => {\n onMessage?.();\n if (pre) {\n // rectify: once the server has (re)snapshotted a model, push our copy back to it\n for (const id of this.values.keys()) {\n if (!pushed.has(id) && pre.has(id)) {\n // cast, not copy: wasm-bindgen types its output Uint8Array<ArrayBufferLike>, but it\n // is always ArrayBuffer-backed, which is what WebSocket.send requires\n ws.send(\n this.edit(id, pre.get(id)) as string | Uint8Array<ArrayBuffer>,\n );\n pushed.add(id);\n }\n }\n }\n });\n ws.addEventListener(\"close\", () => {\n if (!stopped) setTimeout(loop, retry);\n });\n ws.addEventListener(\"error\", () => {\n try {\n ws.close();\n } catch {\n /* already closing */\n }\n });\n };\n loop();\n return {\n stop() {\n stopped = true;\n },\n };\n }\n\n /** Mirror a server over Server-Sent Events (receive-only, JSON). Returns the `EventSource`. */\n connectSSE(url: string): EventSource {\n const es = new EventSource(url);\n es.addEventListener(\"message\", (e) =>\n this.recv((e as MessageEvent).data as string),\n );\n return es;\n }\n}\n", "import * as wasm from \"../../dist/pkg/transports\";\n\nexport * as wasm from \"../../dist/pkg/transports\";\n\nexport const placeholder = \"\";\n\n/** Diff two JSON-encoded models, returning the JSON-encoded patch. */\nexport const diff = (oldModel: string, newModel: string): string =>\n wasm.diff(oldModel, newModel);\n\n/** Apply a JSON-encoded patch to a JSON-encoded model, returning the JSON-encoded result. */\nexport const apply = (model: string, patch: string): string =>\n wasm.apply(model, patch);\n\n/** Encode a JSON-encoded model to codec bytes. */\nexport const encode = (model: string): Uint8Array => wasm.encode(model);\n\n/** Decode codec bytes back to a JSON-encoded model string. */\nexport const decode = (bytes: Uint8Array): string => wasm.decode(bytes);\n\n/** Encode a JSON-encoded model with the codec named by `codec` (e.g. \"application/msgpack\"). */\nexport const encodeAs = (model: string, codec: string): Uint8Array =>\n wasm.encode_as(model, codec);\n\n/** Decode bytes (from `codec`'s codec) back to a JSON-encoded model string. */\nexport const decodeAs = (bytes: Uint8Array, codec: string): string =>\n wasm.decode_as(bytes, codec);\n\n/** Convert an arbitrary JSON document to MessagePack bytes (for whole protocol messages). */\nexport const jsonToMsgpack = (json: string): Uint8Array =>\n wasm.json_to_msgpack(json);\n\n/** Convert MessagePack bytes back to a JSON document. */\nexport const msgpackToJson = (bytes: Uint8Array): string =>\n wasm.msgpack_to_json(bytes);\n\n/** Convert an arbitrary JSON document to CBOR bytes (for whole protocol messages). */\nexport const jsonToCbor = (json: string): Uint8Array => wasm.json_to_cbor(json);\n\n/** Convert CBOR bytes back to a JSON document. */\nexport const cborToJson = (bytes: Uint8Array): string =>\n wasm.cbor_to_json(bytes);\n\n/** Parse and serialize one typed live protocol message as compact JSON. */\nexport const normalizeMessage = (json: string): string =>\n wasm.normalize_message(json);\n\n/** Encode one JSON live protocol message with a built-in connection codec. */\nexport const encodeMessage = (json: string, codec: string): Uint8Array =>\n wasm.encode_message(json, codec);\n\n/** Decode one built-in connection-codec payload as typed live protocol message JSON. */\nexport const decodeMessage = (bytes: Uint8Array, codec: string): string =>\n wasm.decode_message(bytes, codec);\n\n/** In-process model store: host / mutate \u2192 patch / apply / snapshot. */\nexport const Store = wasm.Store;\n\n/** Shared revision and proposal reducer used by `Client`. */\nexport const ClientState = wasm.ClientState;\n\n// Plain JS object <-> core `Value` bridge (the JS analog of the Python bridge).\nexport { toValue, fromValue } from \"./bridge\";\nexport type { Value } from \"./bridge\";\n\n// WebSocket client that mirrors a remote Session.\nexport { Client } from \"./client\";\nexport type {\n AckMsg,\n ModelPatch,\n PatchMsg,\n PatchOp,\n PathSeg,\n ReceiveChange,\n RejectMsg,\n} from \"./client\";\n\n// Custom wire codec registry.\nexport { registerCodec, unregisterCodec, codecFor } from \"./codecs\";\nexport type { CodecEncode, CodecDecode } from \"./codecs\";\n"],
5
+ "mappings": "6FAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,iBAAAE,EAAA,UAAAC,EAAA,UAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,YAAAC,GAAA,SAAAC,EAAA,WAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,aAAAC,GAAA,iBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,sBAAAC,IAKO,IAAMhB,EAAN,KAAkB,CACrB,oBAAqB,CACjB,IAAMiB,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AAMC,GAAc,GAGdC,GAAO,CAACC,EAAkBC,IAChCF,EAAKC,EAAUC,CAAQ,EAGjBC,GAAQ,CAACC,EAAeC,IAC9BF,EAAMC,EAAOC,CAAK,EAGZC,GAAUF,GAAmCE,EAAOF,CAAK,EAGzDG,GAAUC,GAAmCD,EAAOC,CAAK,EAGzDC,GAAW,CAACL,EAAeM,IACjCC,EAAUP,EAAOM,CAAK,EAGhBE,GAAW,CAACJ,EAAmBE,IACrCG,EAAUL,EAAOE,CAAK,EAGhBI,GAAiBC,GACvBC,EAAgBD,CAAI,EAGdE,GAAiBT,GACvBU,EAAgBV,CAAK,EAGfW,GAAcJ,GAAkCK,EAAaL,CAAI,EAGjEM,GAAcb,GACpBc,EAAad,CAAK,EAGZe,GAAoBR,GAC1BS,EAAkBT,CAAI,EAGhBU,GAAgB,CAACV,EAAcL,IACrCgB,EAAeX,EAAML,CAAK,EAGpBiB,EAAgB,CAACnB,EAAmBE,IAC1CkB,EAAepB,EAAOE,CAAK,EAGrBmB,GAAaA,EAGbC,GAAmBA",
6
+ "names": ["transports_exports", "__export", "ClientState", "Store", "apply", "cbor_to_json", "decode", "decode_as", "decode_message", "__wbg_init", "diff", "encode", "encode_as", "encode_message", "initSync", "json_to_cbor", "json_to_msgpack", "msgpack_to_json", "normalize_message", "ptr", "ClientStateFinalization", "wasm", "proposal", "ptr0", "passStringToWasm0", "len0", "WASM_VECTOR_LEN", "effect_json", "ret", "takeFromExternrefTable0", "deferred2_0", "deferred2_1", "ptr1", "len1", "getStringFromWasm0", "message_json", "deferred3_0", "deferred3_1", "ptr2", "len2", "id", "ops_json", "deferred4_0", "deferred4_1", "isLikeNone", "ptr3", "len3", "StoreFinalization", "patch_json", "type_name", "value_json", "v2", "v1", "value", "patch", "data", "passArray8ToWasm0", "codec", "old", "_new", "getArrayU8FromWasm0", "v3", "json", "__wbg_get_imports", "arg0", "arg1", "table", "offset", "len", "getUint8ArrayMemory0", "decodeText", "cachedUint8ArrayMemory0", "x", "arg", "malloc", "realloc", "buf", "cachedTextEncoder", "mem", "code", "view", "idx", "cachedTextDecoder", "MAX_SAFARI_DECODE_BYTES", "numBytesDecoded", "wasmModule", "wasmInstance", "__wbg_finalize_init", "instance", "module", "__wbg_load", "imports", "e", "expectedResponseType", "bytes", "type", "module_or_path", "toValue", "v", "m", "k", "x", "fromValue", "value", "tag", "inner", "o", "BUILTIN", "registry", "registerCodec", "contentType", "encode", "decode", "unregisterCodec", "codecFor", "SharedClientState", "ClientState", "message", "effect", "id", "ops", "proposal", "mapValue", "value", "listValue", "validIndex", "index", "updateAt", "path", "update", "segment", "rest", "map", "list", "next", "applyOp", "op", "container", "inserted", "from", "to", "moved", "order", "seen", "old", "current", "applyPatch", "patch", "Client", "codec", "frame", "custom", "codecFor", "decodeMessage", "sent", "error", "listener", "i", "proposals", "change", "msg", "data", "accepted", "m", "a", "snapshot", "rejection", "diff", "decoded", "encodeMessage", "url", "sep", "params", "revisions", "since", "ws", "e", "sender", "opts", "authority", "retry", "onMessage", "stopped", "loop", "pre", "pushed", "es", "placeholder", "diff", "oldModel", "newModel", "apply", "model", "patch", "encode", "decode", "bytes", "encodeAs", "codec", "encode_as", "decodeAs", "decode_as", "jsonToMsgpack", "json", "json_to_msgpack", "msgpackToJson", "msgpack_to_json", "jsonToCbor", "json_to_cbor", "cborToJson", "cbor_to_json", "normalizeMessage", "normalize_message", "encodeMessage", "encode_message", "decodeMessage", "decode_message", "Store", "ClientState"]
7
7
  }