@earendil-works/chord 1.0.4 → 1.2.0
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.
- package/CHANGELOG.md +20 -0
- package/README.md +77 -194
- package/dist/cell.d.ts +101 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +316 -0
- package/dist/cell.js.map +1 -0
- package/dist/cluster.d.ts +26 -0
- package/dist/cluster.d.ts.map +1 -0
- package/dist/cluster.js +214 -0
- package/dist/cluster.js.map +1 -0
- package/dist/connection.d.ts +157 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +757 -0
- package/dist/connection.js.map +1 -0
- package/dist/context/index.d.ts +12 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/contract.d.ts +133 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +157 -0
- package/dist/contract.js.map +1 -0
- package/dist/declare.d.ts +70 -0
- package/dist/declare.d.ts.map +1 -0
- package/dist/declare.js +22 -0
- package/dist/declare.js.map +1 -0
- package/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/dist/delta/diff.d.ts +1 -1
- package/dist/delta/diff.d.ts.map +1 -1
- package/dist/delta/diff.js.map +1 -1
- package/dist/delta/index.d.ts +2 -2
- package/dist/delta/index.d.ts.map +1 -1
- package/dist/delta/index.js +41 -0
- package/dist/delta/index.js.map +1 -1
- package/dist/delta/revision-validator.d.ts +1 -1
- package/dist/delta/revision-validator.d.ts.map +1 -1
- package/dist/delta/revision-validator.js.map +1 -1
- package/dist/delta/tracker.d.ts +1 -1
- package/dist/delta/tracker.d.ts.map +1 -1
- package/dist/delta/tracker.js +40 -4
- package/dist/delta/tracker.js.map +1 -1
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +44 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +254 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +795 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +9 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js.map +1 -1
- package/dist/link.d.ts +72 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +169 -0
- package/dist/link.js.map +1 -0
- package/dist/loader.d.ts +4 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +68 -0
- package/dist/loader.js.map +1 -0
- package/dist/manager.d.ts +115 -0
- package/dist/manager.d.ts.map +1 -0
- package/dist/manager.js +319 -0
- package/dist/manager.js.map +1 -0
- package/dist/node.d.ts +3 -4
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +3 -2
- package/dist/node.js.map +1 -1
- package/dist/publish.d.ts +5 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +40 -0
- package/dist/publish.js.map +1 -0
- package/dist/record.d.ts +320 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +1292 -0
- package/dist/record.js.map +1 -0
- package/dist/registry.d.ts +25 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +6 -0
- package/dist/registry.js.map +1 -0
- package/dist/reload.d.ts +118 -0
- package/dist/reload.d.ts.map +1 -0
- package/dist/reload.js +589 -0
- package/dist/reload.js.map +1 -0
- package/dist/remote.d.ts +70 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +308 -0
- package/dist/remote.js.map +1 -0
- package/dist/schema.d.ts +21 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +228 -0
- package/dist/schema.js.map +1 -0
- package/dist/state.d.ts +92 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/{services/state.js → state.js} +28 -138
- package/dist/state.js.map +1 -0
- package/dist/types.d.ts +62 -262
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/websocket.d.ts +16 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +15 -0
- package/dist/websocket.js.map +1 -0
- package/dist/wire.d.ts +135 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +112 -0
- package/dist/wire.js.map +1 -0
- package/docs/guide.md +750 -0
- package/docs/spec.md +261 -0
- package/docs/tutorial.md +909 -0
- package/package.json +10 -11
- package/src/delta/README.md +5 -3
- package/dist/api.d.ts +0 -20
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -77
- package/dist/api.js.map +0 -1
- package/dist/bundler.d.ts +0 -6
- package/dist/bundler.d.ts.map +0 -1
- package/dist/bundler.js +0 -3
- package/dist/bundler.js.map +0 -1
- package/dist/facets/host.d.ts +0 -12
- package/dist/facets/host.d.ts.map +0 -1
- package/dist/facets/host.js +0 -763
- package/dist/facets/host.js.map +0 -1
- package/dist/facets/loader.d.ts +0 -3
- package/dist/facets/loader.d.ts.map +0 -1
- package/dist/facets/loader.js +0 -5
- package/dist/facets/loader.js.map +0 -1
- package/dist/node/bundle-loader.d.ts +0 -30
- package/dist/node/bundle-loader.d.ts.map +0 -1
- package/dist/node/bundle-loader.js +0 -377
- package/dist/node/bundle-loader.js.map +0 -1
- package/dist/node/bundle.d.ts +0 -26
- package/dist/node/bundle.d.ts.map +0 -1
- package/dist/node/bundle.js +0 -183
- package/dist/node/bundle.js.map +0 -1
- package/dist/node/manifest.d.ts +0 -36
- package/dist/node/manifest.d.ts.map +0 -1
- package/dist/node/manifest.js +0 -6
- package/dist/node/manifest.js.map +0 -1
- package/dist/node/package.d.ts +0 -15
- package/dist/node/package.d.ts.map +0 -1
- package/dist/node/package.js +0 -199
- package/dist/node/package.js.map +0 -1
- package/dist/services/consumer.d.ts +0 -11
- package/dist/services/consumer.d.ts.map +0 -1
- package/dist/services/consumer.js +0 -585
- package/dist/services/consumer.js.map +0 -1
- package/dist/services/errors.d.ts +0 -8
- package/dist/services/errors.d.ts.map +0 -1
- package/dist/services/errors.js +0 -22
- package/dist/services/errors.js.map +0 -1
- package/dist/services/handle.d.ts +0 -15
- package/dist/services/handle.d.ts.map +0 -1
- package/dist/services/handle.js +0 -101
- package/dist/services/handle.js.map +0 -1
- package/dist/services/instances.d.ts +0 -26
- package/dist/services/instances.d.ts.map +0 -1
- package/dist/services/instances.js +0 -140
- package/dist/services/instances.js.map +0 -1
- package/dist/services/loopback.d.ts +0 -5
- package/dist/services/loopback.d.ts.map +0 -1
- package/dist/services/loopback.js +0 -15
- package/dist/services/loopback.js.map +0 -1
- package/dist/services/provider.d.ts +0 -37
- package/dist/services/provider.d.ts.map +0 -1
- package/dist/services/provider.js +0 -521
- package/dist/services/provider.js.map +0 -1
- package/dist/services/state-codec.d.ts +0 -15
- package/dist/services/state-codec.d.ts.map +0 -1
- package/dist/services/state-codec.js +0 -133
- package/dist/services/state-codec.js.map +0 -1
- package/dist/services/state-internals.d.ts +0 -13
- package/dist/services/state-internals.d.ts.map +0 -1
- package/dist/services/state-internals.js +0 -10
- package/dist/services/state-internals.js.map +0 -1
- package/dist/services/state.d.ts +0 -28
- package/dist/services/state.d.ts.map +0 -1
- package/dist/services/state.js.map +0 -1
- package/dist/services/wire.d.ts +0 -63
- package/dist/services/wire.d.ts.map +0 -1
- package/dist/services/wire.js +0 -186
- package/dist/services/wire.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../src/reload.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAEN,UAAU,EACV,WAAW,EACX,aAAa,GAOb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkDrD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I,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACrE,6FAA6F;YAC7F,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAClD,KAAK,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,0GAA0G;YAC1G,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC;oBACJ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAClE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,MAAM,CAAC,IAAI,CACV,IAAI,UAAU,CAAC,kBAAkB,EAAE,GAAG,MAAM,CAAC,QAAQ,iCAAiC,EAAE;wBACvF,KAAK,EAAE,KAAK;qBACZ,CAAC,CACF,CAAC;oBACF,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACvB,SAAS;gBACV,CAAC;YACF,CAAC;YACD,MAAM,CAAC,YAAY,EAAE,CAAC;QACvB,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { Cell } from \"./cell.ts\";\nimport { type AnyContract, bind, coverage } from \"./contract.ts\";\nimport { asChordError, ChordError, invalid } from \"./errors.ts\";\nimport type { EpochState, Facet, HostImpl, PluginRef, Serve } from \"./host.ts\";\nimport { holdPublications } from \"./publish.ts\";\nimport {\n\ttype Factory,\n\tHandleImpl,\n\tmakeService,\n\tmemberSchemas,\n\ttype RecordImpl,\n\ttype ResourceImpl,\n\ttype Run,\n\ttype ServeOptions,\n\ttype Service,\n\ttype StagedListeners,\n} from \"./record.ts\";\nimport type { RegistryTable } from \"./registry.ts\";\nimport { assertValid, deepEqual } from \"./schema.ts\";\n\nexport interface ReloadOptions {\n\t/** Facet names to remove. */\n\treadonly remove?: readonly string[];\n\t/** Milliseconds the gate waits for grandfathered roots (default 5000). Missed: the reload aborts. */\n\treadonly gateDeadline?: number;\n\t/** Milliseconds to wait for the previous epoch to retire first (default 5000). Missed: it is retired anyway. */\n\treadonly retireDeadline?: number;\n\t/** Server: facet modules for child hosts by host-name prefix (longest wins). Every connected host participates. */\n\treadonly remote?: Readonly<Record<string, readonly string[]>>;\n\t/** Server: facet names to remove on child hosts, by the same host-name prefix rules. */\n\treadonly remoteRemove?: Readonly<Record<string, readonly string[]>>;\n\t/** Server: milliseconds to wait for every child's vote (default: gate + retire deadlines + 5000). */\n\treadonly voteDeadline?: number;\n}\n\nexport interface ReloadReport {\n\treadonly epoch: number;\n\treadonly previous: number;\n\treadonly changed: readonly string[];\n\treadonly removed: readonly string[];\n\t/** Addresses of records whose new factory was installed. */\n\treadonly prepared: readonly string[];\n\t/** Addresses of records that went through the gate. */\n\treadonly gated: readonly string[];\n\t/**\n\t * Cluster reloads: what each participating child host prepared, by host name (its vote; the child commits it after\n\t * the server). Absent for local reloads.\n\t */\n\treadonly children?: Readonly<Record<string, ReloadReport>>;\n}\n\ninterface Candidate {\n\treadonly record: RecordImpl;\n\treadonly service: Service;\n\treadonly run: Run;\n\t/** Why the record needs the gate (empty: compatible). */\n\treadonly reasons: string[];\n\t/** New exclusive resources and their new dependents, opened at the gate. */\n\treadonly atGate: ResourceImpl[];\n\t/** Old exclusive resources closed at the gate. */\n\treadonly replaced: ResourceImpl[];\n\treadonly migrated: Map<Cell<unknown>, unknown>;\n\t/** Values of the run's derivations over the candidate (migrated) values, validated. */\n\tderived: Map<unknown, unknown>;\n\t/** Listener subscriptions made at the end of prepare, activated by the commit. */\n\tstaged: StagedListeners | undefined;\n}\n\nconst noop = (): void => {};\n\n/**\n * Computes the new derivation functions over the candidate values and validates every prospective value (migrated\n * cells and derivations) against every schema that will apply after the commit: the cell's new schema and the new\n * behavior's remote state-member schemas. A failure fails prepare; the commit then installs without re-checking.\n */\nfunction dryRun(candidate: Candidate): void {\n\tconst { run, migrated, service, record } = candidate;\n\tconst exposed = memberSchemas(service, run.behavior);\n\tfor (const [cell, value] of migrated) {\n\t\tfor (const schema of exposed.get(cell) ?? [])\n\t\t\tassertValid(\"state\", `${record.address}: migrated state ${cell.key}`, schema, value);\n\t}\n\tconst values = new Map<unknown, unknown>(migrated);\n\tconst derives = [...run.decls.derives].sort(([, a], [, b]) => a.seq - b.seq);\n\tfor (const [name, derived] of derives) {\n\t\tconst value = derived.compute(\n\t\t\t(source) => (values.has(source) ? values.get(source) : source.value),\n\t\t\trun.decls.deriveFns.get(name),\n\t\t);\n\t\tfor (const schema of exposed.get(derived) ?? [])\n\t\t\tassertValid(\"state\", `${record.address}: derived ${name}`, schema, value);\n\t\tvalues.set(derived, value);\n\t}\n\tcandidate.derived = values;\n}\n\n/** A reload error keeps the underlying code (`contract_mismatch`, `invalid`, ...) and says it aborted the reload. */\nexport function reloadError(error: unknown): ChordError {\n\tconst cause = asChordError(error, \"reload\");\n\tif (/^reload aborted/.test(cause.message.replace(/^[^:]*: /, \"\"))) return cause;\n\treturn new ChordError(cause.code, `reload aborted: ${cause.message}`, {\n\t\tcause,\n\t\treason: cause.reason,\n\t\tdetails: cause.details,\n\t});\n}\n\n/** Serialized: a second reload while one runs is rejected. */\nexport async function runReload(\n\thost: HostImpl,\n\tplugins: readonly PluginRef[],\n\toptions: ReloadOptions,\n): Promise<ReloadReport> {\n\tconst reload = await beginReload(host, plugins, options);\n\ttry {\n\t\tawait reload.prepare();\n\t\treturn reload.commit();\n\t} finally {\n\t\tendReload(host);\n\t}\n}\n\n/** Takes the host's reload slot and loads the plugin modules. Pair with `endReload`. */\nexport async function beginReload(\n\thost: HostImpl,\n\tplugins: readonly PluginRef[],\n\toptions: ReloadOptions,\n\tepoch?: number,\n): Promise<Reload> {\n\tif (host.reloading) {\n\t\tthrow new ChordError(\"unavailable\", \"a reload is already running\", { reason: \"reload_running\" });\n\t}\n\thost.reloading = true;\n\ttry {\n\t\treturn new Reload(host, await host.resolve(plugins), options, epoch);\n\t} catch (error) {\n\t\thost.reloading = false;\n\t\tthrow reloadError(error);\n\t}\n}\n\nexport function endReload(host: HostImpl): void {\n\thost.reloading = false;\n\thost.maybeRetire();\n}\n\n/** One reload on one host: `prepare` (load, prepare, gate), then `commit` or `rollback`. */\nexport class Reload {\n\treadonly host: HostImpl;\n\treadonly facets: readonly Facet[];\n\treadonly options: ReloadOptions;\n\t/** Epoch id to commit (issued by the coordinating server); a local reload allocates one. */\n\treadonly epoch: number | undefined;\n\treadonly candidates = new Map<RecordImpl, Candidate>();\n\treadonly abort = new AbortController();\n\treadonly closed: [RecordImpl, ResourceImpl][] = [];\n\tservices = new Map<string, Service>();\n\tchanged = new Set<string>();\n\tremoved = new Set<string>();\n\ttables = new Map<string, RegistryTable<unknown>>();\n\tgated: Candidate[] = [];\n\trolledBack = false;\n\t/** Records of types this reload adds, with their staged listeners: their runtime starts at commit. */\n\treadonly deferred = new Map<RecordImpl, StagedListeners>();\n\n\tconstructor(host: HostImpl, facets: readonly Facet[], options: ReloadOptions, epoch?: number) {\n\t\tthis.host = host;\n\t\tthis.facets = facets;\n\t\tthis.options = options;\n\t\tthis.epoch = epoch;\n\t}\n\n\t/** Everything up to the commit. On failure the host is rolled back and the underlying error is thrown. */\n\tasync prepare(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.waitForRetirement();\n\t\t\tthis.load();\n\t\t\tthis.checkProviders();\n\t\t\tawait this.prepareAll();\n\t\t\t// From here new records of changed types are rejected (upgrade_conflict, retryable) until commit or abort,\n\t\t\t// so the candidate set is final once the activations already in flight have been prepared.\n\t\t\tthis.host.gating = this.changed;\n\t\t\tawait this.withDeadline(this.prepareAll(), \"activations in flight did not finish\");\n\t\t\tthis.checkHolds();\n\t\t\tthis.tables = this.host.buildTables(this.entries());\n\t\t\tawait this.gate();\n\t\t\tthis.#alive();\n\t\t\tthis.#stage();\n\t\t} catch (error) {\n\t\t\tawait this.rollback();\n\t\t\tthrow reloadError(error);\n\t\t}\n\t}\n\n\t/** What a successful prepare will commit (a child sends it with its vote). */\n\tsummary(): ReloadReport {\n\t\tconst live = [...this.candidates.values()].filter(({ record }) => record.status === \"live\");\n\t\treturn {\n\t\t\tepoch: this.host.pending?.id ?? this.host.current.id,\n\t\t\tprevious: this.host.current.id,\n\t\t\tchanged: [...this.changed],\n\t\t\tremoved: [...this.removed],\n\t\t\tprepared: live.map(({ record }) => record.address),\n\t\t\tgated: this.gated.map(({ record }) => record.address),\n\t\t};\n\t}\n\n\t/** After every await of prepare: a rollback meanwhile (abort from the coordinator) ends it. */\n\t#alive(): void {\n\t\tif (this.rolledBack) throw new ChordError(\"aborted\", \"reload aborted while preparing\", { reason: \"aborted\" });\n\t}\n\n\t/**\n\t * Subscribes every new listener now, buffering its events, so a failing source fails prepare instead of leaving a\n\t * half-installed epoch. Records running only the new code (types this reload adds) are staged too.\n\t */\n\t#stage(): void {\n\t\tfor (const candidate of this.candidates.values()) {\n\t\t\tif (candidate.record.status === \"live\")\n\t\t\t\tcandidate.staged = candidate.record.stageListeners(candidate.run.decls);\n\t\t}\n\t\tfor (const record of this.host.records.values()) {\n\t\t\tif (record.status === \"live\" && record.deferredRuntime)\n\t\t\t\tthis.deferred.set(record, record.stageListeners(record.decls));\n\t\t}\n\t}\n\n\tasync waitForRetirement(): Promise<void> {\n\t\tconst host = this.host;\n\t\tif (host.previous === undefined) return;\n\t\tif (host.previous.roots.size > 0) {\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\thost.retired = resolve;\n\t\t\t\ttimer = setTimeout(resolve, this.options.retireDeadline ?? 5000);\n\t\t\t});\n\t\t\tclearTimeout(timer);\n\t\t\thost.retired = noop;\n\t\t}\n\t\t// Roots of the dropped epoch still running get `superseded` on their next call.\n\t\thost.retire();\n\t}\n\n\t/** Builds the candidate service table: unchanged services plus everything the given facets serve. */\n\tload(): void {\n\t\tconst replaced = new Set([...this.facets.map((facet) => facet.name), ...(this.options.remove ?? [])]);\n\t\tconst current = this.host.current.services;\n\t\tthis.services = new Map([...current].filter(([, service]) => !replaced.has(service.facet)));\n\t\tfor (const facet of this.facets) {\n\t\t\tfacet.setup(\n\t\t\t\tthis.host.facetApi(((type: AnyContract, factory: Factory<AnyContract>, options: ServeOptions = {}) =>\n\t\t\t\t\tthis.host.serveInto(this.services, makeService(type, factory, options, facet.name))) as Serve),\n\t\t\t);\n\t\t}\n\t\tfor (const [name, service] of this.services) if (current.get(name) !== service) this.changed.add(name);\n\t\tfor (const name of current.keys()) if (!this.services.has(name)) this.removed.add(name);\n\t\tthis.host.pending = {\n\t\t\tid: this.host.nextEpochId(this.epoch),\n\t\t\tservices: this.services,\n\t\t\ttables: new Map(),\n\t\t\troots: new Map(),\n\t\t};\n\t}\n\n\tasync withDeadline<T>(promise: Promise<T>, what: string): Promise<T> {\n\t\tconst deadline = this.options.gateDeadline ?? 5000;\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst timeout = new Promise<never>((_, reject) => {\n\t\t\ttimer = setTimeout(\n\t\t\t\t() => reject(new ChordError(\"aborted\", `${what} within ${deadline} ms`, { reason: \"deadline\" })),\n\t\t\t\tdeadline,\n\t\t\t);\n\t\t});\n\t\ttry {\n\t\t\treturn await Promise.race([promise, timeout]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n\n\t/** Same contract version must cover the old description (forgotten bump); facets' `uses` must bind. */\n\tcheckProviders(): void {\n\t\tfor (const name of this.changed) {\n\t\t\tconst next = this.services.get(name)!.contract;\n\t\t\tconst old = this.host.current.services.get(name)?.contract;\n\t\t\tif (old === undefined || old.version !== next.version) continue;\n\t\t\tconst reason = coverage(next.description, old.description);\n\t\t\tif (reason !== undefined) {\n\t\t\t\tthrow new ChordError(\n\t\t\t\t\t\"contract_mismatch\",\n\t\t\t\t\t`${name}@${next.version} changed incompatibly without a version bump (${reason})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst facets = new Map(this.host.facets);\n\t\tfor (const facet of this.facets) facets.set(facet.name, facet);\n\t\tfor (const name of this.options.remove ?? []) facets.delete(name);\n\t\tfor (const facet of facets.values()) {\n\t\t\tfor (const token of facet.uses ?? []) {\n\t\t\t\tconst service = this.services.get(token.name);\n\t\t\t\tif (service !== undefined && this.changed.has(token.name))\n\t\t\t\t\tbind(service.contract, service.options.accepts, token);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepares every live record of a changed type, including records that activate meanwhile, to a fixpoint. Records\n\t * already running the new code (types this reload adds) are skipped.\n\t */\n\tasync prepareAll(): Promise<void> {\n\t\tfor (;;) {\n\t\t\tconst todo = [...this.host.records.values()].filter(\n\t\t\t\t(record) =>\n\t\t\t\t\tthis.changed.has(record.typeName) &&\n\t\t\t\t\t!this.candidates.has(record) &&\n\t\t\t\t\trecord.service !== this.services.get(record.typeName) &&\n\t\t\t\t\t(record.status === \"live\" || record.status === \"activating\"),\n\t\t\t);\n\t\t\tif (todo.length === 0) return;\n\t\t\tawait Promise.allSettled(todo.map((record) => record.ready));\n\t\t\tthis.#alive();\n\t\t\tfor (const record of todo) {\n\t\t\t\tif (record.status === \"live\" && record.service !== this.services.get(record.typeName)) {\n\t\t\t\t\tawait this.prepareRecord(record);\n\t\t\t\t\tthis.#alive();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Runs the new factory in recording mode and opens what can be opened without the gate. */\n\tasync prepareRecord(record: RecordImpl): Promise<void> {\n\t\tconst service = this.services.get(record.typeName)!;\n\t\tconst run = record.run(service, record.decls);\n\t\tconst candidate: Candidate = {\n\t\t\trecord,\n\t\t\tservice,\n\t\t\trun,\n\t\t\treasons: [],\n\t\t\tatGate: [],\n\t\t\treplaced: [],\n\t\t\tmigrated: new Map(),\n\t\t\tderived: new Map(),\n\t\t\tstaged: undefined,\n\t\t};\n\t\tthis.candidates.set(record, candidate);\n\t\tconst bumped = service.stateVersion !== record.stateVersion;\n\t\tif (bumped) candidate.reasons.push(`state version ${record.stateVersion} -> ${service.stateVersion}`);\n\t\tfor (const [name, cell] of run.decls.cells) {\n\t\t\tif (record.decls.cells.get(name) !== cell || deepEqual(cell.schema, run.decls.cellSchemas.get(name))) continue;\n\t\t\tif (!bumped) {\n\t\t\t\tthrow invalid(\"state\", `${record.address}: schema of state ${name} changed without a state-version bump`);\n\t\t\t}\n\t\t}\n\t\tfor (const name of Object.keys(service.options.state?.migrate ?? {})) {\n\t\t\tif (!run.decls.cells.has(name))\n\t\t\t\tthrow invalid(\"state\", `${record.address}: migrate for undeclared state ${name}`);\n\t\t}\n\t\tconst deferred = new Set<ResourceImpl>();\n\t\tfor (const resource of run.created.resources) {\n\t\t\tif (resource.exclusive || resource.deps.some((dep) => deferred.has(dep as ResourceImpl)))\n\t\t\t\tdeferred.add(resource);\n\t\t}\n\t\tfor (const resource of deferred) {\n\t\t\tcandidate.atGate.push(resource);\n\t\t\tconst old = record.decls.resources.get(resource.key);\n\t\t\tif (resource.exclusive && old?.exclusive && old.state === \"open\") candidate.replaced.push(old);\n\t\t}\n\t\tif (deferred.size > 0) candidate.reasons.push(\"exclusive resource replaced\");\n\t\tif (candidate.reasons.length === 0) dryRun(candidate);\n\t\tawait record.open(\n\t\t\trun.created.resources.filter((resource) => !deferred.has(resource)),\n\t\t\trun.created.holds,\n\t\t\tthis.abort.signal,\n\t\t);\n\t}\n\n\t/**\n\t * Every hold that survives into the new epoch must bind to the new provider. Browser holds don't block a reload:\n\t * after the commit they get `upgrade_required` instead.\n\t */\n\tcheckHolds(): void {\n\t\tconst dropped = new Set<unknown>();\n\t\tfor (const { record, run } of this.candidates.values()) {\n\t\t\tfor (const hold of record.decls.holds.values())\n\t\t\t\tif (![...run.decls.holds.values()].includes(hold)) dropped.add(hold);\n\t\t}\n\t\tfor (const record of this.host.records.values()) {\n\t\t\tconst service = this.services.get(record.typeName);\n\t\t\tif (service === undefined || !this.changed.has(record.typeName)) continue;\n\t\t\tfor (const hold of record.holds) {\n\t\t\t\t// The host's bootstrap hold follows this provider at commit; it is not an old-code consumer.\n\t\t\t\tif (hold === this.host.eager.get(record.typeName)) continue;\n\t\t\t\tif (!dropped.has(hold) && hold.owner !== \"client\")\n\t\t\t\t\tbind(service.contract, service.options.accepts, hold.contract);\n\t\t\t}\n\t\t}\n\t}\n\n\tentries(): [RecordImpl, Run[\"decls\"]][] {\n\t\treturn this.host\n\t\t\t.liveDecls(true)\n\t\t\t.filter(([record]) => !this.removed.has(record.typeName))\n\t\t\t.map(([record, decls]) => [record, this.candidates.get(record)?.run.decls ?? decls]);\n\t}\n\n\t/**\n\t * Admission cut, wait for grandfathered roots (deadline), replace exclusive resources, migrate into private\n\t * copies. Old tasks of gated records are stopped at the cut; listener events are queued until commit or abort.\n\t */\n\tasync gate(): Promise<void> {\n\t\tthis.gated = [...this.candidates.values()].filter(\n\t\t\t(candidate) => candidate.reasons.length > 0 && candidate.record.status === \"live\",\n\t\t);\n\t\tconst drained = this.gated.map(({ record }) => {\n\t\t\tconst grandfathered = new Set(record.leases.keys());\n\t\t\treturn new Promise<void>((resolve) => {\n\t\t\t\trecord.gate = { grandfathered, queue: [], drained: resolve };\n\t\t\t\trecord.stopTasks();\n\t\t\t\tif (grandfathered.size === 0) resolve();\n\t\t\t});\n\t\t});\n\t\tconst deadline = this.options.gateDeadline ?? 5000;\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst timedOut = await Promise.race([\n\t\t\tPromise.all(drained).then(() => false),\n\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(true), deadline);\n\t\t\t}),\n\t\t]);\n\t\tclearTimeout(timer);\n\t\tif (timedOut) {\n\t\t\tconst blocking = this.gated.flatMap(({ record }) => [...(record.gate?.grandfathered ?? [])]);\n\t\t\tthrow new ChordError(\n\t\t\t\t\"aborted\",\n\t\t\t\t`gate deadline (${deadline} ms) missed; blocking roots: ${blocking.join(\", \")}`,\n\t\t\t\t{\n\t\t\t\t\treason: \"gate_deadline\",\n\t\t\t\t\tdetails: { blocking },\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tthis.#alive();\n\t\tfor (const candidate of this.gated) {\n\t\t\tconst { record } = candidate;\n\t\t\tfor (const old of candidate.replaced) {\n\t\t\t\t// Owned by the rollback before closing: a failing close must still be restored.\n\t\t\t\tthis.closed.push([record, old]);\n\t\t\t\tawait old.close(record.openOrder);\n\t\t\t}\n\t\t\tawait record.open(candidate.atGate, [], this.abort.signal);\n\t\t\tthis.#alive();\n\t\t}\n\t\tfor (const candidate of this.gated) this.migrate(candidate);\n\t}\n\n\tmigrate(candidate: Candidate): void {\n\t\tconst { record, service, run } = candidate;\n\t\tconst migrate = service.options.state?.migrate ?? {};\n\t\tconst bumped = service.stateVersion !== record.stateVersion;\n\t\tfor (const [name, cell] of run.decls.cells) {\n\t\t\tif (record.decls.cells.get(name) !== cell) continue;\n\t\t\tconst schema = run.decls.cellSchemas.get(name)!;\n\t\t\tconst fn = migrate[name];\n\t\t\tlet value: unknown;\n\t\t\tif (bumped && fn !== undefined) value = fn(structuredClone(cell.value), record.stateVersion);\n\t\t\telse if (!deepEqual(cell.schema, schema)) value = cell.value;\n\t\t\telse continue;\n\t\t\tassertValid(\"state\", `${record.address}: migrated state ${name}`, schema, value);\n\t\t\tcandidate.migrated.set(cell, value);\n\t\t}\n\t\tdryRun(candidate);\n\t}\n\n\tasync rollback(): Promise<void> {\n\t\tif (this.rolledBack) return;\n\t\tthis.rolledBack = true;\n\t\tthis.abort.abort(new ChordError(\"aborted\", \"reload aborted\"));\n\t\tconst report = (error: unknown): void => this.host.report(error);\n\t\tfor (const candidate of this.candidates.values()) candidate.staged?.discard();\n\t\tfor (const staged of this.deferred.values()) staged.discard();\n\t\tfor (const { record, run } of this.candidates.values()) {\n\t\t\trecord.pending.delete(run.decls);\n\t\t\tawait record.unwind(run).catch(report);\n\t\t}\n\t\t// Replaced exclusive resources are restored; one that cannot be is marked unavailable, never silently closed.\n\t\tfor (const [record, resource] of this.closed) {\n\t\t\tif (resource.state !== \"closed\") continue;\n\t\t\tawait resource.open(new AbortController().signal, record.openOrder).catch((error: unknown) => {\n\t\t\t\tresource.markUnavailable();\n\t\t\t\treport(\n\t\t\t\t\tnew ChordError(\"unavailable\", `${record.address}: resource ${resource.key} could not be restored`, {\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tfor (const { record } of this.gated) {\n\t\t\tif (record.gate === undefined) continue;\n\t\t\trecord.openGate();\n\t\t\tfor (const name of record.decls.tasks.keys()) record.startTask(name, this.host.current.id);\n\t\t}\n\t\t// Records of types this reload would have added lose their code.\n\t\tconst reason = new ChordError(\"gone\", \"reload aborted; type not served\");\n\t\tfor (const record of [...this.host.records.values()]) {\n\t\t\tif (!this.host.current.services.has(record.typeName)) await record.dispose(true, reason).catch(report);\n\t\t}\n\t\tthis.host.pending = undefined;\n\t\tthis.host.gating = undefined;\n\t}\n\n\t/**\n\t * Publishes the new epoch in one synchronous step. Everything fallible ran in prepare (factories, opens, migration\n\t * and derivation checks against the prospective schemas, listener subscriptions), so this only installs. Observers\n\t * (state, shapes, registries, listener roots) are notified after the whole step. If an install still throws, the\n\t * epoch is half-published: the host fails terminally and admits no more work.\n\t */\n\tcommit(beforeStart?: () => void): ReloadReport {\n\t\ttry {\n\t\t\treturn holdPublications(() => {\n\t\t\t\tconst report = this.#publish();\n\t\t\t\t// Installed, not yet started: the coordinator queues its commit frames here, so nothing this epoch starts\n\t\t\t\t// (tasks, eager activations, then the held listener/registry/state notifications) can reach a child first.\n\t\t\t\tbeforeStart?.();\n\t\t\t\tfor (const start of this.#starts.splice(0)) start();\n\t\t\t\treturn report;\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.host.fail(error);\n\t\t\tthrow reloadError(error);\n\t\t}\n\t}\n\n\t/** Work that may start new-epoch roots, run after installation (and after the coordinator's commit frames). */\n\treadonly #starts: (() => void)[] = [];\n\n\t#publish(): ReloadReport {\n\t\tconst host = this.host;\n\t\tconst previous = host.current;\n\t\tconst next: EpochState = host.pending!;\n\t\thost.pending = undefined;\n\t\thost.epochs.set(next.id, next);\n\t\thost.previous = previous;\n\t\thost.current = next;\n\t\tconst prepared: string[] = [];\n\t\tfor (const record of [...host.records.values()]) {\n\t\t\tif (this.removed.has(record.typeName)) continue;\n\t\t\tconst candidate = this.candidates.get(record);\n\t\t\tif (candidate === undefined) {\n\t\t\t\tconst installed = record.behaviors.get(previous.id);\n\t\t\t\tif (installed !== undefined) record.behaviors.set(next.id, { ...installed, epoch: next.id });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (record.status !== \"live\") continue;\n\t\t\tthis.install(candidate, next.id);\n\t\t\tprepared.push(record.address);\n\t\t}\n\t\tfor (const { record, run, staged } of this.candidates.values()) {\n\t\t\tif (record.status === \"live\") continue;\n\t\t\tstaged?.discard();\n\t\t\trecord.pending.delete(run.decls);\n\t\t\trecord.unwind(run).catch((error: unknown) => host.report(error));\n\t\t}\n\t\t// Records of types this reload adds start their runtime now.\n\t\tfor (const [record, staged] of this.deferred) {\n\t\t\tif (record.status !== \"live\") {\n\t\t\t\tstaged.discard();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\trecord.deferredRuntime = false;\n\t\t\tstaged.activate();\n\t\t\tthis.#starts.push(() => record.startTasks());\n\t\t}\n\t\thost.installTables(next, this.tables, true);\n\t\tconst reason = new ChordError(\"gone\", \"type no longer served\");\n\t\tfor (const record of [...host.records.values()]) {\n\t\t\tif (this.removed.has(record.typeName))\n\t\t\t\trecord.dispose(true, reason).catch((error: unknown) => host.report(error));\n\t\t}\n\t\tfor (const name of this.removed) host.eager.delete(name);\n\t\tfor (const facet of this.facets) host.facets.set(facet.name, facet);\n\t\tfor (const name of this.options.remove ?? []) host.facets.delete(name);\n\t\thost.gating = undefined;\n\t\tfor (const [name, service] of this.services) {\n\t\t\tif (service.options.eager && this.changed.has(name) && host.eager.get(name)?.record?.status !== \"live\") {\n\t\t\t\tthis.#starts.push(() => host.startEager(service));\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tepoch: next.id,\n\t\t\tprevious: previous.id,\n\t\t\tchanged: [...this.changed],\n\t\t\tremoved: [...this.removed],\n\t\t\tprepared,\n\t\t\tgated: this.gated.map(({ record }) => record.address),\n\t\t};\n\t}\n\n\tinstall(candidate: Candidate, epoch: number): void {\n\t\tconst { record, run, service } = candidate;\n\t\tconst gated = candidate.reasons.length > 0;\n\t\trecord.pending.delete(run.decls);\n\t\trecord.stopTasks();\n\t\tif (gated) {\n\t\t\t// Old derivations would compute over migrated values; the old behavior can no longer run anyway.\n\t\t\tconst kept = new Set(run.decls.derives.values());\n\t\t\tfor (const derived of record.decls.derives.values()) if (!kept.has(derived)) derived.detach();\n\t\t}\n\t\trecord.decls = run.decls;\n\t\trecord.service = service;\n\t\trecord.stateVersion = service.stateVersion;\n\t\trecord.behaviors.set(epoch, { epoch, service, behavior: run.behavior, decls: run.decls });\n\t\tif (gated) {\n\t\t\t// Old code can never run over migrated state: drop the previous behavior now, not at retirement.\n\t\t\trecord.minEpoch = epoch;\n\t\t\tfor (const old of [...record.behaviors.keys()]) if (old !== epoch) this.host.retireBehavior(record, old);\n\t\t}\n\t\t// Schemas first, then the values validated against them in prepare.\n\t\trecord.refreshSchemas();\n\t\tfor (const [name, derived] of run.decls.derives) derived.setFn(run.decls.deriveFns.get(name)!);\n\t\tfor (const [name, cell] of run.decls.cells) {\n\t\t\tconst schema = run.decls.cellSchemas.get(name)!;\n\t\t\tif (candidate.migrated.has(cell)) cell.reset(candidate.migrated.get(cell), schema);\n\t\t\telse cell.schema = schema;\n\t\t}\n\t\tconst created = new Set(run.created.derives);\n\t\tfor (const derived of run.created.derives) derived.attach(candidate.derived);\n\t\tfor (const derived of run.decls.derives.values()) if (!created.has(derived)) derived.refresh();\n\t\tcandidate.staged?.activate();\n\t\tthis.#starts.push(() => record.startTasks());\n\t\trecord.openGate();\n\t\tconst eager = this.host.eager.get(record.typeName);\n\t\tif (eager?.record === record && eager.contract.fingerprint !== service.contract.fingerprint) {\n\t\t\tconst replacement = new HandleImpl(record, service.contract, \"host\");\n\t\t\t// Acquire first: releasing the only hold must not dispose/reopen the surviving eager record.\n\t\t\trecord.addHold(replacement);\n\t\t\tthis.host.eager.set(record.typeName, replacement);\n\t\t\teager.release();\n\t\t}\n\t\tfor (const handle of [...record.holds]) {\n\t\t\t// Browser holds whose contract no longer binds are told to reload their code (they never block a reload).\n\t\t\tif (handle.owner === \"client\") {\n\t\t\t\ttry {\n\t\t\t\t\tbind(service.contract, service.options.accepts, handle.contract);\n\t\t\t\t} catch (error) {\n\t\t\t\t\thandle.gone(\n\t\t\t\t\t\tnew ChordError(\"upgrade_required\", `${record.typeName} changed; reload the web facets`, {\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\trecord.release(handle);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\thandle.shapeChanged();\n\t\t}\n\t}\n}\n"]}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AnyContract } from "./contract.ts";
|
|
2
|
+
import { type WireOp } from "./delta/index.ts";
|
|
3
|
+
import { type Hold, type HoldOwner, type StatusListener } from "./record.ts";
|
|
4
|
+
import type { Ctx, HandleStatus, Principal, Shape } from "./types.ts";
|
|
5
|
+
import { type RootRef, type WireError } from "./wire.ts";
|
|
6
|
+
export interface StateSink {
|
|
7
|
+
snap?: unknown;
|
|
8
|
+
reset?: unknown;
|
|
9
|
+
ops?: readonly WireOp[];
|
|
10
|
+
error?: WireError;
|
|
11
|
+
}
|
|
12
|
+
/** What a remote handle needs from the link it is bound to (implemented by Connection). */
|
|
13
|
+
export interface RemoteChannel {
|
|
14
|
+
hold(handle: RemoteHandle): number;
|
|
15
|
+
release(id: number): void;
|
|
16
|
+
call(hold: number, member: string, args: unknown, root: RootRef | undefined, signal: AbortSignal): Promise<unknown>;
|
|
17
|
+
sub(hold: number, member: string, sink: (frame: StateSink) => void): number;
|
|
18
|
+
unsub(id: number): void;
|
|
19
|
+
}
|
|
20
|
+
/** What a remote handle needs from its host. */
|
|
21
|
+
export interface RemoteHost {
|
|
22
|
+
readonly inFactory: number;
|
|
23
|
+
report(error: unknown): void;
|
|
24
|
+
root<T>(fn: (ctx: Ctx) => T | Promise<T>, options?: {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): Promise<T>;
|
|
27
|
+
forgetRemote(handle: RemoteHandle): void;
|
|
28
|
+
}
|
|
29
|
+
/** A hold on an object on another host, bound to a link. Late-bound like a local handle. */
|
|
30
|
+
export declare class RemoteHandle implements Hold {
|
|
31
|
+
#private;
|
|
32
|
+
readonly record: undefined;
|
|
33
|
+
readonly host: RemoteHost;
|
|
34
|
+
readonly contract: AnyContract;
|
|
35
|
+
readonly at: string;
|
|
36
|
+
readonly input: unknown;
|
|
37
|
+
/** Forwarded principal (omitted for the host's own principal). */
|
|
38
|
+
readonly principal: Principal | undefined;
|
|
39
|
+
readonly owner: HoldOwner;
|
|
40
|
+
readonly address: string;
|
|
41
|
+
readonly proxy: object;
|
|
42
|
+
readonly ready: Promise<void>;
|
|
43
|
+
status: HandleStatus;
|
|
44
|
+
error: unknown;
|
|
45
|
+
shape: Shape | undefined;
|
|
46
|
+
binding: {
|
|
47
|
+
readonly channel: RemoteChannel;
|
|
48
|
+
readonly id: number;
|
|
49
|
+
} | undefined;
|
|
50
|
+
readonly shapeListeners: Set<(shape: Shape) => void>;
|
|
51
|
+
constructor(host: RemoteHost, fields: {
|
|
52
|
+
contract: AnyContract;
|
|
53
|
+
at: string;
|
|
54
|
+
input: unknown;
|
|
55
|
+
principal: Principal | undefined;
|
|
56
|
+
owner: HoldOwner;
|
|
57
|
+
address: string;
|
|
58
|
+
});
|
|
59
|
+
get kind(): string | undefined;
|
|
60
|
+
onShape(listener: (shape: Shape) => void): () => void;
|
|
61
|
+
onStatus(listener: StatusListener): () => void;
|
|
62
|
+
release(): void;
|
|
63
|
+
bound(channel: RemoteChannel, id: number): void;
|
|
64
|
+
shaped(shape: Shape): void;
|
|
65
|
+
gone(error: unknown): void;
|
|
66
|
+
/** The link went down but may come back (upstream reconnect): wait, then re-hold. */
|
|
67
|
+
detached(): void;
|
|
68
|
+
member(name: string): unknown;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAyC,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAGN,KAAK,IAAI,EACT,KAAK,SAAS,EAId,KAAK,cAAc,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAY,KAAK,EAAc,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAIxE,MAAM,WAAW,SAAS;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC7B,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;IACnC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IA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der } from "./delta/index.js";
|
|
3
|
+
import { ChordError } from "./errors.js";
|
|
4
|
+
import { CtxImpl, HANDLE_BASE, holdsByProxy, notifyStatus, raceSignal, } from "./record.js";
|
|
5
|
+
import { fromWireError } from "./wire.js";
|
|
6
|
+
const noop = () => { };
|
|
7
|
+
/**
|
|
8
|
+
* A state member of a remote handle: hydrated while subscribed (snapshot, then decoded ops); `undefined` before.
|
|
9
|
+
* Re-subscribing after a reconnect delivers the new snapshot as a reset.
|
|
10
|
+
*/
|
|
11
|
+
class RemoteReadable {
|
|
12
|
+
#handle;
|
|
13
|
+
#name;
|
|
14
|
+
#values = new Set();
|
|
15
|
+
#events = new Set();
|
|
16
|
+
#sub;
|
|
17
|
+
#decoder = decoder();
|
|
18
|
+
#value;
|
|
19
|
+
constructor(handle, name) {
|
|
20
|
+
this.#handle = handle;
|
|
21
|
+
this.#name = name;
|
|
22
|
+
}
|
|
23
|
+
get value() {
|
|
24
|
+
return this.#value;
|
|
25
|
+
}
|
|
26
|
+
subscribe(listener) {
|
|
27
|
+
this.#values.add(listener);
|
|
28
|
+
this.#safe(() => listener(this.#value));
|
|
29
|
+
this.bind();
|
|
30
|
+
return () => this.#remove(this.#values, listener);
|
|
31
|
+
}
|
|
32
|
+
events(listener) {
|
|
33
|
+
this.#events.add(listener);
|
|
34
|
+
this.#safe(() => listener({ type: "snap", value: this.#value }));
|
|
35
|
+
this.bind();
|
|
36
|
+
return () => this.#remove(this.#events, listener);
|
|
37
|
+
}
|
|
38
|
+
/** Subscribes upstream while someone listens and the handle is bound; drops a subscription on an old link. */
|
|
39
|
+
bind() {
|
|
40
|
+
const listening = this.#values.size + this.#events.size > 0;
|
|
41
|
+
// Nobody listens: the value would go stale, so forget it. The next subscriber sees `undefined`, then the snapshot.
|
|
42
|
+
if (!listening)
|
|
43
|
+
this.#value = undefined;
|
|
44
|
+
const binding = listening ? this.#handle.binding : undefined;
|
|
45
|
+
if (binding !== undefined && this.#sub?.channel === binding.channel)
|
|
46
|
+
return;
|
|
47
|
+
if (this.#sub !== undefined) {
|
|
48
|
+
if (this.#sub.channel !== binding?.channel || binding === undefined)
|
|
49
|
+
this.#sub.channel.unsub(this.#sub.id);
|
|
50
|
+
this.#sub = undefined;
|
|
51
|
+
}
|
|
52
|
+
if (binding === undefined)
|
|
53
|
+
return;
|
|
54
|
+
const channel = binding.channel;
|
|
55
|
+
this.#decoder = decoder();
|
|
56
|
+
const id = channel.sub(binding.id, this.#name, (frame) => this.#receive(frame));
|
|
57
|
+
this.#sub = { channel, id };
|
|
58
|
+
}
|
|
59
|
+
/** The link is gone: keep the last value, resubscribe on the next binding. */
|
|
60
|
+
detach() {
|
|
61
|
+
this.#sub = undefined;
|
|
62
|
+
}
|
|
63
|
+
stop() {
|
|
64
|
+
this.#values.clear();
|
|
65
|
+
this.#events.clear();
|
|
66
|
+
this.bind();
|
|
67
|
+
}
|
|
68
|
+
#receive(frame) {
|
|
69
|
+
if (frame.error !== undefined) {
|
|
70
|
+
this.#handle.host.report(fromWireError(frame.error));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let event;
|
|
74
|
+
if (frame.ops === undefined && !("snap" in frame) && !("reset" in frame))
|
|
75
|
+
return;
|
|
76
|
+
if (frame.ops !== undefined) {
|
|
77
|
+
const ops = this.#decoder.decode(frame.ops);
|
|
78
|
+
this.#value = applyImmutable(this.#value, ops);
|
|
79
|
+
event = { type: "ops", ops, value: this.#value };
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Listeners already saw a snapshot (`undefined` or an older value), so every upstream snapshot is a reset.
|
|
83
|
+
this.#decoder = decoder();
|
|
84
|
+
this.#value = "snap" in frame ? frame.snap : frame.reset;
|
|
85
|
+
event = { type: "reset", value: this.#value };
|
|
86
|
+
}
|
|
87
|
+
for (const listener of [...this.#events])
|
|
88
|
+
this.#safe(() => listener(event));
|
|
89
|
+
for (const listener of [...this.#values])
|
|
90
|
+
this.#safe(() => listener(this.#value));
|
|
91
|
+
}
|
|
92
|
+
#remove(set, listener) {
|
|
93
|
+
set.delete(listener);
|
|
94
|
+
this.bind();
|
|
95
|
+
}
|
|
96
|
+
#safe(fn) {
|
|
97
|
+
try {
|
|
98
|
+
fn();
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
this.#handle.host.report(error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** A hold on an object on another host, bound to a link. Late-bound like a local handle. */
|
|
106
|
+
export class RemoteHandle {
|
|
107
|
+
record = undefined;
|
|
108
|
+
host;
|
|
109
|
+
contract;
|
|
110
|
+
at;
|
|
111
|
+
input;
|
|
112
|
+
/** Forwarded principal (omitted for the host's own principal). */
|
|
113
|
+
principal;
|
|
114
|
+
owner;
|
|
115
|
+
address;
|
|
116
|
+
proxy;
|
|
117
|
+
ready;
|
|
118
|
+
status = "loading";
|
|
119
|
+
error;
|
|
120
|
+
shape;
|
|
121
|
+
binding;
|
|
122
|
+
shapeListeners = new Set();
|
|
123
|
+
#readables = new Map();
|
|
124
|
+
#callers = new Map();
|
|
125
|
+
#settleReady;
|
|
126
|
+
#live;
|
|
127
|
+
constructor(host, fields) {
|
|
128
|
+
this.host = host;
|
|
129
|
+
this.contract = fields.contract;
|
|
130
|
+
this.at = fields.at;
|
|
131
|
+
this.input = fields.input;
|
|
132
|
+
this.principal = fields.principal;
|
|
133
|
+
this.owner = fields.owner;
|
|
134
|
+
this.address = fields.address;
|
|
135
|
+
this.ready = new Promise((resolve, reject) => {
|
|
136
|
+
this.#settleReady = { resolve, reject };
|
|
137
|
+
});
|
|
138
|
+
this.ready.catch(noop);
|
|
139
|
+
this.#live = this.#newLive();
|
|
140
|
+
this.proxy = new Proxy(this, {
|
|
141
|
+
get: (target, property) => {
|
|
142
|
+
if (HANDLE_BASE.has(property)) {
|
|
143
|
+
const value = Reflect.get(target, property, target);
|
|
144
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
145
|
+
}
|
|
146
|
+
if (typeof property !== "string" || property === "then")
|
|
147
|
+
return undefined;
|
|
148
|
+
return target.member(property);
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
holdsByProxy.set(this.proxy, this);
|
|
152
|
+
}
|
|
153
|
+
get kind() {
|
|
154
|
+
return this.shape?.kind;
|
|
155
|
+
}
|
|
156
|
+
onShape(listener) {
|
|
157
|
+
this.shapeListeners.add(listener);
|
|
158
|
+
return () => this.shapeListeners.delete(listener);
|
|
159
|
+
}
|
|
160
|
+
onStatus(listener) {
|
|
161
|
+
this.#statusListeners.add(listener);
|
|
162
|
+
return () => this.#statusListeners.delete(listener);
|
|
163
|
+
}
|
|
164
|
+
#statusListeners = new Set();
|
|
165
|
+
#statusChanged() {
|
|
166
|
+
notifyStatus(this.#statusListeners, this.status, this.error, (error) => this.host.report(error));
|
|
167
|
+
}
|
|
168
|
+
release() {
|
|
169
|
+
if (this.status === "released" || this.status === "gone")
|
|
170
|
+
return;
|
|
171
|
+
this.status = "released";
|
|
172
|
+
this.#statusChanged();
|
|
173
|
+
const error = new ChordError("released", `handle ${this.address} released`);
|
|
174
|
+
this.#settleReady?.reject(error);
|
|
175
|
+
this.#live.reject(error);
|
|
176
|
+
for (const readable of this.#readables.values())
|
|
177
|
+
readable.stop();
|
|
178
|
+
if (this.binding !== undefined)
|
|
179
|
+
this.binding.channel.release(this.binding.id);
|
|
180
|
+
this.binding = undefined;
|
|
181
|
+
this.host.forgetRemote(this);
|
|
182
|
+
}
|
|
183
|
+
// ─── driven by the link ───
|
|
184
|
+
bound(channel, id) {
|
|
185
|
+
this.binding = { channel, id };
|
|
186
|
+
}
|
|
187
|
+
shaped(shape) {
|
|
188
|
+
if (this.status === "released" || this.status === "gone")
|
|
189
|
+
return;
|
|
190
|
+
this.shape = shape;
|
|
191
|
+
const wasLoading = this.status === "loading";
|
|
192
|
+
this.status = "live";
|
|
193
|
+
if (wasLoading)
|
|
194
|
+
this.#statusChanged();
|
|
195
|
+
if (wasLoading) {
|
|
196
|
+
this.#settleReady?.resolve();
|
|
197
|
+
this.#settleReady = undefined;
|
|
198
|
+
this.#live.resolve();
|
|
199
|
+
}
|
|
200
|
+
for (const readable of this.#readables.values())
|
|
201
|
+
readable.bind();
|
|
202
|
+
for (const listener of [...this.shapeListeners]) {
|
|
203
|
+
try {
|
|
204
|
+
listener(shape);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
this.host.report(error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
gone(error) {
|
|
212
|
+
if (this.status === "released" || this.status === "gone")
|
|
213
|
+
return;
|
|
214
|
+
this.status = "gone";
|
|
215
|
+
this.error = error;
|
|
216
|
+
this.#statusChanged();
|
|
217
|
+
this.binding = undefined;
|
|
218
|
+
this.#settleReady?.reject(error);
|
|
219
|
+
this.#live.reject(error);
|
|
220
|
+
for (const readable of this.#readables.values())
|
|
221
|
+
readable.stop();
|
|
222
|
+
this.host.forgetRemote(this);
|
|
223
|
+
}
|
|
224
|
+
/** The link went down but may come back (upstream reconnect): wait, then re-hold. */
|
|
225
|
+
detached() {
|
|
226
|
+
if (this.status === "released" || this.status === "gone")
|
|
227
|
+
return;
|
|
228
|
+
this.binding = undefined;
|
|
229
|
+
for (const readable of this.#readables.values())
|
|
230
|
+
readable.detach();
|
|
231
|
+
if (this.status === "live") {
|
|
232
|
+
this.status = "loading";
|
|
233
|
+
this.#live = this.#newLive();
|
|
234
|
+
this.#statusChanged();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// ─── members ───
|
|
238
|
+
member(name) {
|
|
239
|
+
const description = Object.values(this.contract.description.variants)
|
|
240
|
+
.map((members) => members[name])
|
|
241
|
+
.find((member) => member !== undefined);
|
|
242
|
+
if (description?.kind === "method")
|
|
243
|
+
return this.#caller(name);
|
|
244
|
+
if (description?.kind === "state") {
|
|
245
|
+
let readable = this.#readables.get(name);
|
|
246
|
+
if (readable === undefined) {
|
|
247
|
+
readable = new RemoteReadable(this, name);
|
|
248
|
+
this.#readables.set(name, readable);
|
|
249
|
+
}
|
|
250
|
+
return readable;
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
#caller(name) {
|
|
255
|
+
let caller = this.#callers.get(name);
|
|
256
|
+
if (caller === undefined) {
|
|
257
|
+
caller = (args, ctx) => {
|
|
258
|
+
if (this.host.inFactory > 0)
|
|
259
|
+
throw new ChordError("not_ready", `${this.address}.${name} called inside a factory`);
|
|
260
|
+
if (ctx instanceof CtxImpl) {
|
|
261
|
+
try {
|
|
262
|
+
ctx.check(ctx.host);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return Promise.reject(error);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (ctx === undefined || (ctx instanceof CtxImpl && ctx.holder)) {
|
|
269
|
+
return this.host.root((root) => this.#call(name, args, root), { signal: ctx?.signal });
|
|
270
|
+
}
|
|
271
|
+
return this.#call(name, args, ctx);
|
|
272
|
+
};
|
|
273
|
+
this.#callers.set(name, caller);
|
|
274
|
+
}
|
|
275
|
+
return caller;
|
|
276
|
+
}
|
|
277
|
+
async #call(name, args, ctx) {
|
|
278
|
+
for (;;) {
|
|
279
|
+
if (this.status === "released" || this.status === "gone") {
|
|
280
|
+
throw this.status === "gone" ? this.error : new ChordError("released", `handle ${this.address} released`);
|
|
281
|
+
}
|
|
282
|
+
if (this.status === "loading")
|
|
283
|
+
await raceSignal(this.#live.promise, ctx.signal);
|
|
284
|
+
const binding = this.binding;
|
|
285
|
+
if (binding === undefined)
|
|
286
|
+
continue;
|
|
287
|
+
const kind = this.shape?.kind;
|
|
288
|
+
if (kind === undefined || this.contract.description.variants[kind]?.[name]?.kind !== "method") {
|
|
289
|
+
throw new ChordError("not_in_variant", `${this.address}: ${name} is not a method of variant ${kind}`);
|
|
290
|
+
}
|
|
291
|
+
// Send only what the consumer's own schema knows (the additive rule's premise; see RecordImpl.call).
|
|
292
|
+
const description = this.contract.description.variants[kind]?.[name];
|
|
293
|
+
const sent = description?.kind === "method" ? Value.Clean(description.args, Value.Clone(args)) : args;
|
|
294
|
+
return binding.channel.call(binding.id, name, sent, { rootId: ctx.rootId, epoch: ctx.epoch }, ctx.signal);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
#newLive() {
|
|
298
|
+
let resolve = noop;
|
|
299
|
+
let reject = noop;
|
|
300
|
+
const promise = new Promise((done, fail) => {
|
|
301
|
+
resolve = done;
|
|
302
|
+
reject = fail;
|
|
303
|
+
});
|
|
304
|
+
promise.catch(noop);
|
|
305
|
+
return { promise, resolve, reject };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAgB,OAAO,EAAe,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,OAAO,EACP,WAAW,EAGX,YAAY,EACZ,YAAY,EACZ,UAAU,GAEV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAgC,MAAM,WAAW,CAAC;AAExE,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AA0B5B;;;GAGG;AACH,MAAM,cAAc;IACV,OAAO,CAAe;IACtB,KAAK,CAAS;IACd,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC9C,OAAO,GAAG,IAAI,GAAG,EAAwC,CAAC;IACnE,IAAI,CAAuE;IAC3E,QAAQ,GAAY,OAAO,EAAE,CAAC;IAC9B,MAAM,CAAU;IAEhB,YAAY,MAAoB,EAAE,IAAY;QAC7C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,G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AW,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACtG,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3G,CAAC;IACF,CAAC;IAED,QAAQ;QACP,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,MAAM,GAA6B,IAAI,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YAChD,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,GAAG,IAAI,CAAC;QACf,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC;CACD","sourcesContent":["import { Value } from \"typebox/value\";\nimport type { AnyContract } from \"./contract.ts\";\nimport { applyImmutable, type Decoder, decoder, type WireOp } from \"./delta/index.ts\";\nimport { ChordError } from \"./errors.ts\";\nimport {\n\tCtxImpl,\n\tHANDLE_BASE,\n\ttype Hold,\n\ttype HoldOwner,\n\tholdsByProxy,\n\tnotifyStatus,\n\traceSignal,\n\ttype StatusListener,\n} from \"./record.ts\";\nimport type { Ctx, HandleStatus, Principal, Readable, Shape, StateEvent } from \"./types.ts\";\nimport { fromWireError, type RootRef, type WireError } from \"./wire.ts\";\n\nconst noop = (): void => {};\n\nexport interface StateSink {\n\tsnap?: unknown;\n\treset?: unknown;\n\tops?: readonly WireOp[];\n\terror?: WireError;\n}\n\n/** What a remote handle needs from the link it is bound to (implemented by Connection). */\nexport interface RemoteChannel {\n\thold(handle: RemoteHandle): number;\n\trelease(id: number): void;\n\tcall(hold: number, member: string, args: unknown, root: RootRef | undefined, signal: AbortSignal): Promise<unknown>;\n\tsub(hold: number, member: string, sink: (frame: StateSink) => void): number;\n\tunsub(id: number): void;\n}\n\n/** What a remote handle needs from its host. */\nexport interface RemoteHost {\n\treadonly inFactory: number;\n\treport(error: unknown): void;\n\troot<T>(fn: (ctx: Ctx) => T | Promise<T>, options?: { signal?: AbortSignal }): Promise<T>;\n\tforgetRemote(handle: RemoteHandle): void;\n}\n\n/**\n * A state member of a remote handle: hydrated while subscribed (snapshot, then decoded ops); `undefined` before.\n * Re-subscribing after a reconnect delivers the new snapshot as a reset.\n */\nclass RemoteReadable implements Readable<unknown> {\n\treadonly #handle: RemoteHandle;\n\treadonly #name: string;\n\treadonly #values = new Set<(value: unknown) => void>();\n\treadonly #events = new Set<(event: StateEvent<unknown>) => void>();\n\t#sub: { readonly channel: RemoteChannel; readonly id: number } | undefined;\n\t#decoder: Decoder = decoder();\n\t#value: unknown;\n\n\tconstructor(handle: RemoteHandle, name: string) {\n\t\tthis.#handle = handle;\n\t\tthis.#name = name;\n\t}\n\n\tget value(): unknown {\n\t\treturn this.#value;\n\t}\n\n\tsubscribe(listener: (value: unknown) => void): () => void {\n\t\tthis.#values.add(listener);\n\t\tthis.#safe(() => listener(this.#value));\n\t\tthis.bind();\n\t\treturn () => this.#remove(this.#values, listener);\n\t}\n\n\tevents(listener: (event: StateEvent<unknown>) => void): () => void {\n\t\tthis.#events.add(listener);\n\t\tthis.#safe(() => listener({ type: \"snap\", value: this.#value }));\n\t\tthis.bind();\n\t\treturn () => this.#remove(this.#events, listener);\n\t}\n\n\t/** Subscribes upstream while someone listens and the handle is bound; drops a subscription on an old link. */\n\tbind(): void {\n\t\tconst listening = this.#values.size + this.#events.size > 0;\n\t\t// Nobody listens: the value would go stale, so forget it. The next subscriber sees `undefined`, then the snapshot.\n\t\tif (!listening) this.#value = undefined;\n\t\tconst binding = listening ? this.#handle.binding : undefined;\n\t\tif (binding !== undefined && this.#sub?.channel === binding.channel) return;\n\t\tif (this.#sub !== undefined) {\n\t\t\tif (this.#sub.channel !== binding?.channel || binding === undefined) this.#sub.channel.unsub(this.#sub.id);\n\t\t\tthis.#sub = undefined;\n\t\t}\n\t\tif (binding === undefined) return;\n\t\tconst channel = binding.channel;\n\t\tthis.#decoder = decoder();\n\t\tconst id = channel.sub(binding.id, this.#name, (frame) => this.#receive(frame));\n\t\tthis.#sub = { channel, id };\n\t}\n\n\t/** The link is gone: keep the last value, resubscribe on the next binding. */\n\tdetach(): void {\n\t\tthis.#sub = undefined;\n\t}\n\n\tstop(): void {\n\t\tthis.#values.clear();\n\t\tthis.#events.clear();\n\t\tthis.bind();\n\t}\n\n\t#receive(frame: StateSink): void {\n\t\tif (frame.error !== undefined) {\n\t\t\tthis.#handle.host.report(fromWireError(frame.error));\n\t\t\treturn;\n\t\t}\n\t\tlet event: StateEvent<unknown>;\n\t\tif (frame.ops === undefined && !(\"snap\" in frame) && !(\"reset\" in frame)) return;\n\t\tif (frame.ops !== undefined) {\n\t\t\tconst ops = this.#decoder.decode(frame.ops);\n\t\t\tthis.#value = applyImmutable(this.#value, ops);\n\t\t\tevent = { type: \"ops\", ops, value: this.#value };\n\t\t} else {\n\t\t\t// Listeners already saw a snapshot (`undefined` or an older value), so every upstream snapshot is a reset.\n\t\t\tthis.#decoder = decoder();\n\t\t\tthis.#value = \"snap\" in frame ? frame.snap : frame.reset;\n\t\t\tevent = { type: \"reset\", value: this.#value };\n\t\t}\n\t\tfor (const listener of [...this.#events]) this.#safe(() => listener(event));\n\t\tfor (const listener of [...this.#values]) this.#safe(() => listener(this.#value));\n\t}\n\n\t#remove<T>(set: Set<T>, listener: T): void {\n\t\tset.delete(listener);\n\t\tthis.bind();\n\t}\n\n\t#safe(fn: () => void): void {\n\t\ttry {\n\t\t\tfn();\n\t\t} catch (error) {\n\t\t\tthis.#handle.host.report(error);\n\t\t}\n\t}\n}\n\n/** A hold on an object on another host, bound to a link. Late-bound like a local handle. */\nexport class RemoteHandle implements Hold {\n\treadonly record = undefined;\n\treadonly host: RemoteHost;\n\treadonly contract: AnyContract;\n\treadonly at: string;\n\treadonly input: unknown;\n\t/** Forwarded principal (omitted for the host's own principal). */\n\treadonly principal: Principal | undefined;\n\treadonly owner: HoldOwner;\n\treadonly address: string;\n\treadonly proxy: object;\n\treadonly ready: Promise<void>;\n\tstatus: HandleStatus = \"loading\";\n\terror: unknown;\n\tshape: Shape | undefined;\n\tbinding: { readonly channel: RemoteChannel; readonly id: number } | undefined;\n\treadonly shapeListeners = new Set<(shape: Shape) => void>();\n\treadonly #readables = new Map<string, RemoteReadable>();\n\treadonly #callers = new Map<string, (args: unknown, ctx?: Ctx) => Promise<unknown>>();\n\t#settleReady: { resolve: () => void; reject: (error: unknown) => void } | undefined;\n\t#live: { promise: Promise<void>; resolve: () => void; reject: (error: unknown) => void };\n\n\tconstructor(\n\t\thost: RemoteHost,\n\t\tfields: {\n\t\t\tcontract: AnyContract;\n\t\t\tat: string;\n\t\t\tinput: unknown;\n\t\t\tprincipal: Principal | undefined;\n\t\t\towner: HoldOwner;\n\t\t\taddress: string;\n\t\t},\n\t) {\n\t\tthis.host = host;\n\t\tthis.contract = fields.contract;\n\t\tthis.at = fields.at;\n\t\tthis.input = fields.input;\n\t\tthis.principal = fields.principal;\n\t\tthis.owner = fields.owner;\n\t\tthis.address = fields.address;\n\t\tthis.ready = new Promise<void>((resolve, reject) => {\n\t\t\tthis.#settleReady = { resolve, reject };\n\t\t});\n\t\tthis.ready.catch(noop);\n\t\tthis.#live = this.#newLive();\n\t\tthis.proxy = new Proxy(this, {\n\t\t\tget: (target, property) => {\n\t\t\t\tif (HANDLE_BASE.has(property)) {\n\t\t\t\t\tconst value: unknown = Reflect.get(target, property, target);\n\t\t\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t\t\t}\n\t\t\t\tif (typeof property !== \"string\" || property === \"then\") return undefined;\n\t\t\t\treturn target.member(property);\n\t\t\t},\n\t\t});\n\t\tholdsByProxy.set(this.proxy, this);\n\t}\n\n\tget kind(): string | undefined {\n\t\treturn this.shape?.kind;\n\t}\n\n\tonShape(listener: (shape: Shape) => void): () => void {\n\t\tthis.shapeListeners.add(listener);\n\t\treturn () => this.shapeListeners.delete(listener);\n\t}\n\n\tonStatus(listener: StatusListener): () => void {\n\t\tthis.#statusListeners.add(listener);\n\t\treturn () => this.#statusListeners.delete(listener);\n\t}\n\n\treadonly #statusListeners = new Set<StatusListener>();\n\n\t#statusChanged(): void {\n\t\tnotifyStatus(this.#statusListeners, this.status, this.error, (error) => this.host.report(error));\n\t}\n\n\trelease(): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.status = \"released\";\n\t\tthis.#statusChanged();\n\t\tconst error = new ChordError(\"released\", `handle ${this.address} released`);\n\t\tthis.#settleReady?.reject(error);\n\t\tthis.#live.reject(error);\n\t\tfor (const readable of this.#readables.values()) readable.stop();\n\t\tif (this.binding !== undefined) this.binding.channel.release(this.binding.id);\n\t\tthis.binding = undefined;\n\t\tthis.host.forgetRemote(this);\n\t}\n\n\t// ─── driven by the link ───\n\n\tbound(channel: RemoteChannel, id: number): void {\n\t\tthis.binding = { channel, id };\n\t}\n\n\tshaped(shape: Shape): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.shape = shape;\n\t\tconst wasLoading = this.status === \"loading\";\n\t\tthis.status = \"live\";\n\t\tif (wasLoading) this.#statusChanged();\n\t\tif (wasLoading) {\n\t\t\tthis.#settleReady?.resolve();\n\t\t\tthis.#settleReady = undefined;\n\t\t\tthis.#live.resolve();\n\t\t}\n\t\tfor (const readable of this.#readables.values()) readable.bind();\n\t\tfor (const listener of [...this.shapeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener(shape);\n\t\t\t} catch (error) {\n\t\t\t\tthis.host.report(error);\n\t\t\t}\n\t\t}\n\t}\n\n\tgone(error: unknown): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.status = \"gone\";\n\t\tthis.error = error;\n\t\tthis.#statusChanged();\n\t\tthis.binding = undefined;\n\t\tthis.#settleReady?.reject(error);\n\t\tthis.#live.reject(error);\n\t\tfor (const readable of this.#readables.values()) readable.stop();\n\t\tthis.host.forgetRemote(this);\n\t}\n\n\t/** The link went down but may come back (upstream reconnect): wait, then re-hold. */\n\tdetached(): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.binding = undefined;\n\t\tfor (const readable of this.#readables.values()) readable.detach();\n\t\tif (this.status === \"live\") {\n\t\t\tthis.status = \"loading\";\n\t\t\tthis.#live = this.#newLive();\n\t\t\tthis.#statusChanged();\n\t\t}\n\t}\n\n\t// ─── members ───\n\n\tmember(name: string): unknown {\n\t\tconst description = Object.values(this.contract.description.variants)\n\t\t\t.map((members) => members[name])\n\t\t\t.find((member) => member !== undefined);\n\t\tif (description?.kind === \"method\") return this.#caller(name);\n\t\tif (description?.kind === \"state\") {\n\t\t\tlet readable = this.#readables.get(name);\n\t\t\tif (readable === undefined) {\n\t\t\t\treadable = new RemoteReadable(this, name);\n\t\t\t\tthis.#readables.set(name, readable);\n\t\t\t}\n\t\t\treturn readable;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t#caller(name: string): (args: unknown, ctx?: Ctx) => Promise<unknown> {\n\t\tlet caller = this.#callers.get(name);\n\t\tif (caller === undefined) {\n\t\t\tcaller = (args, ctx) => {\n\t\t\t\tif (this.host.inFactory > 0)\n\t\t\t\t\tthrow new ChordError(\"not_ready\", `${this.address}.${name} called inside a factory`);\n\t\t\t\tif (ctx instanceof CtxImpl) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.check(ctx.host);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn Promise.reject(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ctx === undefined || (ctx instanceof CtxImpl && ctx.holder)) {\n\t\t\t\t\treturn this.host.root((root) => this.#call(name, args, root), { signal: ctx?.signal });\n\t\t\t\t}\n\t\t\t\treturn this.#call(name, args, ctx);\n\t\t\t};\n\t\t\tthis.#callers.set(name, caller);\n\t\t}\n\t\treturn caller;\n\t}\n\n\tasync #call(name: string, args: unknown, ctx: Ctx): Promise<unknown> {\n\t\tfor (;;) {\n\t\t\tif (this.status === \"released\" || this.status === \"gone\") {\n\t\t\t\tthrow this.status === \"gone\" ? this.error : new ChordError(\"released\", `handle ${this.address} released`);\n\t\t\t}\n\t\t\tif (this.status === \"loading\") await raceSignal(this.#live.promise, ctx.signal);\n\t\t\tconst binding = this.binding;\n\t\t\tif (binding === undefined) continue;\n\t\t\tconst kind = this.shape?.kind;\n\t\t\tif (kind === undefined || this.contract.description.variants[kind]?.[name]?.kind !== \"method\") {\n\t\t\t\tthrow new ChordError(\"not_in_variant\", `${this.address}: ${name} is not a method of variant ${kind}`);\n\t\t\t}\n\t\t\t// Send only what the consumer's own schema knows (the additive rule's premise; see RecordImpl.call).\n\t\t\tconst description = this.contract.description.variants[kind]?.[name];\n\t\t\tconst sent = description?.kind === \"method\" ? Value.Clean(description.args, Value.Clone(args)) : args;\n\t\t\treturn binding.channel.call(binding.id, name, sent, { rootId: ctx.rootId, epoch: ctx.epoch }, ctx.signal);\n\t\t}\n\t}\n\n\t#newLive(): { promise: Promise<void>; resolve: () => void; reject: (error: unknown) => void } {\n\t\tlet resolve = noop;\n\t\tlet reject: (error: unknown) => void = noop;\n\t\tconst promise = new Promise<void>((done, fail) => {\n\t\t\tresolve = done;\n\t\t\treject = fail;\n\t\t});\n\t\tpromise.catch(noop);\n\t\treturn { promise, resolve, reject };\n\t}\n}\n"]}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TSchema } from "typebox";
|
|
2
|
+
import { type ChordErrorReason } from "./errors.ts";
|
|
3
|
+
/** Canonical JSON: sorted object keys, `undefined` members dropped. */
|
|
4
|
+
export declare function canonicalJson(value: unknown): string;
|
|
5
|
+
/** Non-cryptographic 64-bit hash (two FNV-1a lanes). Contracts are trusted, so collisions are not an attack surface. */
|
|
6
|
+
export declare function hash64(text: string): string;
|
|
7
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
8
|
+
/** Throws `invalid` (with `reason`) and the first schema errors when `value` does not match. */
|
|
9
|
+
export declare function assertValid(reason: ChordErrorReason, what: string, schema: TSchema, value: unknown): void;
|
|
10
|
+
/** Applies defaults, strips unknown fields, validates. Returns a fresh value. */
|
|
11
|
+
export declare function normalize(schema: TSchema, value: unknown, what: string): unknown;
|
|
12
|
+
/** Canonical identity of a normalized value: fields equal to their schema default are omitted. */
|
|
13
|
+
export declare function canonicalIdentity(schema: TSchema, value: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* Conservative structural subtyping: true only if every value valid under `sub` is valid under `sup`, where object
|
|
16
|
+
* fields missing from `sub` but optional in `sup` count as fine (unknown fields are stripped at the provider, see
|
|
17
|
+
* `RecordImpl.call`). A provider schema using a keyword this function does not model (`not`, `allOf`, `contains`,
|
|
18
|
+
* `$ref`, ...) or an `additionalProperties` schema only fits an identical consumer schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fits(subSchema: unknown, supSchema: unknown): boolean;
|
|
21
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,aAAa,CAAC;AAQ7D,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOpD;AAED,wHAAwH;AACxH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS3C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAKzG;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhF;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzE;AAyED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CA0BpE"}
|