@earendil-works/chord 1.4.0 → 1.5.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 +41 -0
- package/README.md +79 -14
- package/dist/cell.d.ts +7 -7
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/contract.d.ts +51 -52
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +19 -24
- package/dist/contract.js.map +1 -1
- package/dist/delta/apply-immutable-trusted.js +3 -4
- package/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/dist/delta/diff.d.ts.map +1 -1
- package/dist/delta/diff.js +5 -3
- package/dist/delta/diff.js.map +1 -1
- package/dist/delta/index.d.ts +9 -1
- package/dist/delta/index.d.ts.map +1 -1
- package/dist/delta/index.js +15 -11
- package/dist/delta/index.js.map +1 -1
- package/dist/delta/pending.d.ts +36 -0
- package/dist/delta/pending.d.ts.map +1 -0
- package/dist/delta/pending.js +143 -0
- package/dist/delta/pending.js.map +1 -0
- package/dist/delta/tracker.d.ts +12 -0
- package/dist/delta/tracker.d.ts.map +1 -1
- package/dist/delta/tracker.js +109 -39
- package/dist/delta/tracker.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +9 -7
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/next/contracts/accepts.d.ts +81 -0
- package/dist/next/contracts/accepts.d.ts.map +1 -0
- package/dist/next/contracts/accepts.js +123 -0
- package/dist/next/contracts/accepts.js.map +1 -0
- package/dist/next/contracts/contract.d.ts +121 -0
- package/dist/next/contracts/contract.d.ts.map +1 -0
- package/dist/next/contracts/contract.js +50 -0
- package/dist/next/contracts/contract.js.map +1 -0
- package/dist/next/contracts/declare.d.ts +107 -0
- package/dist/next/contracts/declare.d.ts.map +1 -0
- package/dist/next/contracts/declare.js +136 -0
- package/dist/next/contracts/declare.js.map +1 -0
- package/dist/next/contracts/evolve.d.ts +92 -0
- package/dist/next/contracts/evolve.d.ts.map +1 -0
- package/dist/next/contracts/evolve.js +179 -0
- package/dist/next/contracts/evolve.js.map +1 -0
- package/dist/next/contracts/fingerprint.d.ts +16 -0
- package/dist/next/contracts/fingerprint.d.ts.map +1 -0
- package/dist/next/contracts/fingerprint.js +50 -0
- package/dist/next/contracts/fingerprint.js.map +1 -0
- package/dist/next/contracts/history.d.ts +71 -0
- package/dist/next/contracts/history.d.ts.map +1 -0
- package/dist/next/contracts/history.js +3 -0
- package/dist/next/contracts/history.js.map +1 -0
- package/dist/next/contracts/host-kind.d.ts +40 -0
- package/dist/next/contracts/host-kind.d.ts.map +1 -0
- package/dist/next/contracts/host-kind.js +37 -0
- package/dist/next/contracts/host-kind.js.map +1 -0
- package/dist/next/contracts/index.d.ts +7 -0
- package/dist/next/contracts/index.d.ts.map +1 -0
- package/dist/next/contracts/index.js +6 -0
- package/dist/next/contracts/index.js.map +1 -0
- package/dist/next/contracts/internal.d.ts +10 -0
- package/dist/next/contracts/internal.d.ts.map +1 -0
- package/dist/next/contracts/internal.js +9 -0
- package/dist/next/contracts/internal.js.map +1 -0
- package/dist/next/contracts/names.d.ts +3 -0
- package/dist/next/contracts/names.d.ts.map +1 -0
- package/dist/next/contracts/names.js +13 -0
- package/dist/next/contracts/names.js.map +1 -0
- package/dist/next/contracts/params.d.ts +28 -0
- package/dist/next/contracts/params.d.ts.map +1 -0
- package/dist/next/contracts/params.js +50 -0
- package/dist/next/contracts/params.js.map +1 -0
- package/dist/next/contracts/schema.d.ts +102 -0
- package/dist/next/contracts/schema.d.ts.map +1 -0
- package/dist/next/contracts/schema.js +103 -0
- package/dist/next/contracts/schema.js.map +1 -0
- package/dist/next/contracts/snapshot.d.ts +16 -0
- package/dist/next/contracts/snapshot.d.ts.map +1 -0
- package/dist/next/contracts/snapshot.js +167 -0
- package/dist/next/contracts/snapshot.js.map +1 -0
- package/dist/next/data/args.d.ts +50 -0
- package/dist/next/data/args.d.ts.map +1 -0
- package/dist/next/data/args.js +83 -0
- package/dist/next/data/args.js.map +1 -0
- package/dist/next/data/errors.d.ts +73 -0
- package/dist/next/data/errors.d.ts.map +1 -0
- package/dist/next/data/errors.js +107 -0
- package/dist/next/data/errors.js.map +1 -0
- package/dist/next/data/failure.d.ts +26 -0
- package/dist/next/data/failure.d.ts.map +1 -0
- package/dist/next/data/failure.js +72 -0
- package/dist/next/data/failure.js.map +1 -0
- package/dist/next/data/index.d.ts +4 -0
- package/dist/next/data/index.d.ts.map +1 -0
- package/dist/next/data/index.js +4 -0
- package/dist/next/data/index.js.map +1 -0
- package/dist/next/data/internal.d.ts +7 -0
- package/dist/next/data/internal.d.ts.map +1 -0
- package/dist/next/data/internal.js +8 -0
- package/dist/next/data/internal.js.map +1 -0
- package/dist/next/data/params.d.ts +20 -0
- package/dist/next/data/params.d.ts.map +1 -0
- package/dist/next/data/params.js +31 -0
- package/dist/next/data/params.js.map +1 -0
- package/dist/next/data/principal.d.ts +17 -0
- package/dist/next/data/principal.d.ts.map +1 -0
- package/dist/next/data/principal.js +41 -0
- package/dist/next/data/principal.js.map +1 -0
- package/dist/next/data/validator.d.ts +12 -0
- package/dist/next/data/validator.d.ts.map +1 -0
- package/dist/next/data/validator.js +34 -0
- package/dist/next/data/validator.js.map +1 -0
- package/dist/next/documents/address-source.d.ts +20 -0
- package/dist/next/documents/address-source.d.ts.map +1 -0
- package/dist/next/documents/address-source.js +44 -0
- package/dist/next/documents/address-source.js.map +1 -0
- package/dist/next/documents/definition.d.ts +84 -0
- package/dist/next/documents/definition.d.ts.map +1 -0
- package/dist/next/documents/definition.js +73 -0
- package/dist/next/documents/definition.js.map +1 -0
- package/dist/next/documents/documents.d.ts +106 -0
- package/dist/next/documents/documents.d.ts.map +1 -0
- package/dist/next/documents/documents.js +224 -0
- package/dist/next/documents/documents.js.map +1 -0
- package/dist/next/documents/fence.d.ts +9 -0
- package/dist/next/documents/fence.d.ts.map +1 -0
- package/dist/next/documents/fence.js +15 -0
- package/dist/next/documents/fence.js.map +1 -0
- package/dist/next/documents/handles.d.ts +76 -0
- package/dist/next/documents/handles.d.ts.map +1 -0
- package/dist/next/documents/handles.js +66 -0
- package/dist/next/documents/handles.js.map +1 -0
- package/dist/next/documents/index.d.ts +4 -0
- package/dist/next/documents/index.d.ts.map +1 -0
- package/dist/next/documents/index.js +3 -0
- package/dist/next/documents/index.js.map +1 -0
- package/dist/next/documents/internal.d.ts +9 -0
- package/dist/next/documents/internal.d.ts.map +1 -0
- package/dist/next/documents/internal.js +9 -0
- package/dist/next/documents/internal.js.map +1 -0
- package/dist/next/documents/keyed-slot.d.ts +103 -0
- package/dist/next/documents/keyed-slot.d.ts.map +1 -0
- package/dist/next/documents/keyed-slot.js +395 -0
- package/dist/next/documents/keyed-slot.js.map +1 -0
- package/dist/next/documents/line.d.ts +7 -0
- package/dist/next/documents/line.d.ts.map +1 -0
- package/dist/next/documents/line.js +14 -0
- package/dist/next/documents/line.js.map +1 -0
- package/dist/next/documents/persistence.d.ts +104 -0
- package/dist/next/documents/persistence.d.ts.map +1 -0
- package/dist/next/documents/persistence.js +128 -0
- package/dist/next/documents/persistence.js.map +1 -0
- package/dist/next/documents/residency.d.ts +31 -0
- package/dist/next/documents/residency.d.ts.map +1 -0
- package/dist/next/documents/residency.js +93 -0
- package/dist/next/documents/residency.js.map +1 -0
- package/dist/next/documents/slot.d.ts +109 -0
- package/dist/next/documents/slot.d.ts.map +1 -0
- package/dist/next/documents/slot.js +181 -0
- package/dist/next/documents/slot.js.map +1 -0
- package/dist/next/documents/transaction.d.ts +133 -0
- package/dist/next/documents/transaction.d.ts.map +1 -0
- package/dist/next/documents/transaction.js +409 -0
- package/dist/next/documents/transaction.js.map +1 -0
- package/dist/next/host/activity.d.ts +31 -0
- package/dist/next/host/activity.d.ts.map +1 -0
- package/dist/next/host/activity.js +40 -0
- package/dist/next/host/activity.js.map +1 -0
- package/dist/next/host/adapted.d.ts +49 -0
- package/dist/next/host/adapted.d.ts.map +1 -0
- package/dist/next/host/adapted.js +214 -0
- package/dist/next/host/adapted.js.map +1 -0
- package/dist/next/host/attempt.d.ts +278 -0
- package/dist/next/host/attempt.d.ts.map +1 -0
- package/dist/next/host/attempt.js +1072 -0
- package/dist/next/host/attempt.js.map +1 -0
- package/dist/next/host/backoff.d.ts +29 -0
- package/dist/next/host/backoff.d.ts.map +1 -0
- package/dist/next/host/backoff.js +69 -0
- package/dist/next/host/backoff.js.map +1 -0
- package/dist/next/host/ctx.d.ts +47 -0
- package/dist/next/host/ctx.d.ts.map +1 -0
- package/dist/next/host/ctx.js +108 -0
- package/dist/next/host/ctx.js.map +1 -0
- package/dist/next/host/deadline.d.ts +12 -0
- package/dist/next/host/deadline.d.ts.map +1 -0
- package/dist/next/host/deadline.js +40 -0
- package/dist/next/host/deadline.js.map +1 -0
- package/dist/next/host/dependencies.d.ts +65 -0
- package/dist/next/host/dependencies.d.ts.map +1 -0
- package/dist/next/host/dependencies.js +115 -0
- package/dist/next/host/dependencies.js.map +1 -0
- package/dist/next/host/destination.d.ts +48 -0
- package/dist/next/host/destination.d.ts.map +1 -0
- package/dist/next/host/destination.js +101 -0
- package/dist/next/host/destination.js.map +1 -0
- package/dist/next/host/facet.d.ts +79 -0
- package/dist/next/host/facet.d.ts.map +1 -0
- package/dist/next/host/facet.js +55 -0
- package/dist/next/host/facet.js.map +1 -0
- package/dist/next/host/follow.d.ts +52 -0
- package/dist/next/host/follow.d.ts.map +1 -0
- package/dist/next/host/follow.js +207 -0
- package/dist/next/host/follow.js.map +1 -0
- package/dist/next/host/host.d.ts +495 -0
- package/dist/next/host/host.d.ts.map +1 -0
- package/dist/next/host/host.js +1075 -0
- package/dist/next/host/host.js.map +1 -0
- package/dist/next/host/index.d.ts +17 -0
- package/dist/next/host/index.d.ts.map +1 -0
- package/dist/next/host/index.js +6 -0
- package/dist/next/host/index.js.map +1 -0
- package/dist/next/host/internal.d.ts +10 -0
- package/dist/next/host/internal.d.ts.map +1 -0
- package/dist/next/host/internal.js +8 -0
- package/dist/next/host/internal.js.map +1 -0
- package/dist/next/host/members.d.ts +50 -0
- package/dist/next/host/members.d.ts.map +1 -0
- package/dist/next/host/members.js +107 -0
- package/dist/next/host/members.js.map +1 -0
- package/dist/next/host/native.d.ts +55 -0
- package/dist/next/host/native.d.ts.map +1 -0
- package/dist/next/host/native.js +92 -0
- package/dist/next/host/native.js.map +1 -0
- package/dist/next/host/object.d.ts +290 -0
- package/dist/next/host/object.d.ts.map +1 -0
- package/dist/next/host/object.js +1127 -0
- package/dist/next/host/object.js.map +1 -0
- package/dist/next/host/parked.d.ts +23 -0
- package/dist/next/host/parked.d.ts.map +1 -0
- package/dist/next/host/parked.js +79 -0
- package/dist/next/host/parked.js.map +1 -0
- package/dist/next/host/presence.d.ts +34 -0
- package/dist/next/host/presence.d.ts.map +1 -0
- package/dist/next/host/presence.js +117 -0
- package/dist/next/host/presence.js.map +1 -0
- package/dist/next/host/ref-state.d.ts +53 -0
- package/dist/next/host/ref-state.d.ts.map +1 -0
- package/dist/next/host/ref-state.js +83 -0
- package/dist/next/host/ref-state.js.map +1 -0
- package/dist/next/host/reference-keys.d.ts +36 -0
- package/dist/next/host/reference-keys.d.ts.map +1 -0
- package/dist/next/host/reference-keys.js +168 -0
- package/dist/next/host/reference-keys.js.map +1 -0
- package/dist/next/host/reference-source.d.ts +65 -0
- package/dist/next/host/reference-source.d.ts.map +1 -0
- package/dist/next/host/reference-source.js +285 -0
- package/dist/next/host/reference-source.js.map +1 -0
- package/dist/next/host/reference.d.ts +308 -0
- package/dist/next/host/reference.d.ts.map +1 -0
- package/dist/next/host/reference.js +775 -0
- package/dist/next/host/reference.js.map +1 -0
- package/dist/next/host/retry-on.d.ts +28 -0
- package/dist/next/host/retry-on.d.ts.map +1 -0
- package/dist/next/host/retry-on.js +52 -0
- package/dist/next/host/retry-on.js.map +1 -0
- package/dist/next/host/revocation.d.ts +16 -0
- package/dist/next/host/revocation.d.ts.map +1 -0
- package/dist/next/host/revocation.js +27 -0
- package/dist/next/host/revocation.js.map +1 -0
- package/dist/next/host/root.d.ts +27 -0
- package/dist/next/host/root.d.ts.map +1 -0
- package/dist/next/host/root.js +68 -0
- package/dist/next/host/root.js.map +1 -0
- package/dist/next/host/route.d.ts +64 -0
- package/dist/next/host/route.d.ts.map +1 -0
- package/dist/next/host/route.js +190 -0
- package/dist/next/host/route.js.map +1 -0
- package/dist/next/host/routines.d.ts +76 -0
- package/dist/next/host/routines.d.ts.map +1 -0
- package/dist/next/host/routines.js +350 -0
- package/dist/next/host/routines.js.map +1 -0
- package/dist/next/host/sleep.d.ts +9 -0
- package/dist/next/host/sleep.d.ts.map +1 -0
- package/dist/next/host/sleep.js +40 -0
- package/dist/next/host/sleep.js.map +1 -0
- package/dist/next/host/staging.d.ts +94 -0
- package/dist/next/host/staging.d.ts.map +1 -0
- package/dist/next/host/staging.js +302 -0
- package/dist/next/host/staging.js.map +1 -0
- package/dist/next/host/unbound.d.ts +30 -0
- package/dist/next/host/unbound.d.ts.map +1 -0
- package/dist/next/host/unbound.js +67 -0
- package/dist/next/host/unbound.js.map +1 -0
- package/dist/next/host/uuid.d.ts +3 -0
- package/dist/next/host/uuid.d.ts.map +1 -0
- package/dist/next/host/uuid.js +38 -0
- package/dist/next/host/uuid.js.map +1 -0
- package/dist/next/index.d.ts +28 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +18 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/jobs/definition.d.ts +96 -0
- package/dist/next/jobs/definition.d.ts.map +1 -0
- package/dist/next/jobs/definition.js +83 -0
- package/dist/next/jobs/definition.js.map +1 -0
- package/dist/next/jobs/index.d.ts +5 -0
- package/dist/next/jobs/index.d.ts.map +1 -0
- package/dist/next/jobs/index.js +3 -0
- package/dist/next/jobs/index.js.map +1 -0
- package/dist/next/jobs/internal.d.ts +3 -0
- package/dist/next/jobs/internal.d.ts.map +1 -0
- package/dist/next/jobs/internal.js +4 -0
- package/dist/next/jobs/internal.js.map +1 -0
- package/dist/next/jobs/job.d.ts +152 -0
- package/dist/next/jobs/job.d.ts.map +1 -0
- package/dist/next/jobs/job.js +320 -0
- package/dist/next/jobs/job.js.map +1 -0
- package/dist/next/jobs/persisted.d.ts +38 -0
- package/dist/next/jobs/persisted.d.ts.map +1 -0
- package/dist/next/jobs/persisted.js +95 -0
- package/dist/next/jobs/persisted.js.map +1 -0
- package/dist/next/jobs/records.d.ts +231 -0
- package/dist/next/jobs/records.d.ts.map +1 -0
- package/dist/next/jobs/records.js +869 -0
- package/dist/next/jobs/records.js.map +1 -0
- package/dist/next/jobs/run-states.d.ts +69 -0
- package/dist/next/jobs/run-states.d.ts.map +1 -0
- package/dist/next/jobs/run-states.js +228 -0
- package/dist/next/jobs/run-states.js.map +1 -0
- package/dist/next/jobs/run.d.ts +113 -0
- package/dist/next/jobs/run.d.ts.map +1 -0
- package/dist/next/jobs/run.js +200 -0
- package/dist/next/jobs/run.js.map +1 -0
- package/dist/next/jobs/running.d.ts +44 -0
- package/dist/next/jobs/running.d.ts.map +1 -0
- package/dist/next/jobs/running.js +117 -0
- package/dist/next/jobs/running.js.map +1 -0
- package/dist/next/jobs/stored.d.ts +63 -0
- package/dist/next/jobs/stored.d.ts.map +1 -0
- package/dist/next/jobs/stored.js +55 -0
- package/dist/next/jobs/stored.js.map +1 -0
- package/dist/next/link/binary.d.ts +4 -0
- package/dist/next/link/binary.d.ts.map +1 -0
- package/dist/next/link/binary.js +534 -0
- package/dist/next/link/binary.js.map +1 -0
- package/dist/next/link/channel.d.ts +63 -0
- package/dist/next/link/channel.d.ts.map +1 -0
- package/dist/next/link/channel.js +202 -0
- package/dist/next/link/channel.js.map +1 -0
- package/dist/next/link/errors.d.ts +7 -0
- package/dist/next/link/errors.d.ts.map +1 -0
- package/dist/next/link/errors.js +21 -0
- package/dist/next/link/errors.js.map +1 -0
- package/dist/next/link/index.d.ts +8 -0
- package/dist/next/link/index.d.ts.map +1 -0
- package/dist/next/link/index.js +8 -0
- package/dist/next/link/index.js.map +1 -0
- package/dist/next/link/internal.d.ts +9 -0
- package/dist/next/link/internal.d.ts.map +1 -0
- package/dist/next/link/internal.js +10 -0
- package/dist/next/link/internal.js.map +1 -0
- package/dist/next/link/ipc.d.ts +22 -0
- package/dist/next/link/ipc.d.ts.map +1 -0
- package/dist/next/link/ipc.js +64 -0
- package/dist/next/link/ipc.js.map +1 -0
- package/dist/next/link/link.d.ts +34 -0
- package/dist/next/link/link.d.ts.map +1 -0
- package/dist/next/link/link.js +87 -0
- package/dist/next/link/link.js.map +1 -0
- package/dist/next/link/message.d.ts +249 -0
- package/dist/next/link/message.d.ts.map +1 -0
- package/dist/next/link/message.js +123 -0
- package/dist/next/link/message.js.map +1 -0
- package/dist/next/link/part.d.ts +80 -0
- package/dist/next/link/part.d.ts.map +1 -0
- package/dist/next/link/part.js +164 -0
- package/dist/next/link/part.js.map +1 -0
- package/dist/next/link/text.d.ts +6 -0
- package/dist/next/link/text.d.ts.map +1 -0
- package/dist/next/link/text.js +335 -0
- package/dist/next/link/text.js.map +1 -0
- package/dist/next/link/values.d.ts +40 -0
- package/dist/next/link/values.d.ts.map +1 -0
- package/dist/next/link/values.js +117 -0
- package/dist/next/link/values.js.map +1 -0
- package/dist/next/link/websocket.d.ts +26 -0
- package/dist/next/link/websocket.d.ts.map +1 -0
- package/dist/next/link/websocket.js +91 -0
- package/dist/next/link/websocket.js.map +1 -0
- package/dist/next/registries/contribution.d.ts +50 -0
- package/dist/next/registries/contribution.d.ts.map +1 -0
- package/dist/next/registries/contribution.js +129 -0
- package/dist/next/registries/contribution.js.map +1 -0
- package/dist/next/registries/entries.d.ts +18 -0
- package/dist/next/registries/entries.d.ts.map +1 -0
- package/dist/next/registries/entries.js +42 -0
- package/dist/next/registries/entries.js.map +1 -0
- package/dist/next/registries/index.d.ts +3 -0
- package/dist/next/registries/index.d.ts.map +1 -0
- package/dist/next/registries/index.js +5 -0
- package/dist/next/registries/index.js.map +1 -0
- package/dist/next/registries/internal.d.ts +4 -0
- package/dist/next/registries/internal.d.ts.map +1 -0
- package/dist/next/registries/internal.js +5 -0
- package/dist/next/registries/internal.js.map +1 -0
- package/dist/next/registries/record.d.ts +94 -0
- package/dist/next/registries/record.d.ts.map +1 -0
- package/dist/next/registries/record.js +253 -0
- package/dist/next/registries/record.js.map +1 -0
- package/dist/next/registries/registry.d.ts +74 -0
- package/dist/next/registries/registry.d.ts.map +1 -0
- package/dist/next/registries/registry.js +14 -0
- package/dist/next/registries/registry.js.map +1 -0
- package/dist/next/registries/value.d.ts +48 -0
- package/dist/next/registries/value.d.ts.map +1 -0
- package/dist/next/registries/value.js +199 -0
- package/dist/next/registries/value.js.map +1 -0
- package/dist/next/remote/calls.d.ts +25 -0
- package/dist/next/remote/calls.d.ts.map +1 -0
- package/dist/next/remote/calls.js +62 -0
- package/dist/next/remote/calls.js.map +1 -0
- package/dist/next/remote/consumer.d.ts +42 -0
- package/dist/next/remote/consumer.d.ts.map +1 -0
- package/dist/next/remote/consumer.js +343 -0
- package/dist/next/remote/consumer.js.map +1 -0
- package/dist/next/remote/hold.d.ts +130 -0
- package/dist/next/remote/hold.d.ts.map +1 -0
- package/dist/next/remote/hold.js +537 -0
- package/dist/next/remote/hold.js.map +1 -0
- package/dist/next/remote/host-link.d.ts +77 -0
- package/dist/next/remote/host-link.d.ts.map +1 -0
- package/dist/next/remote/host-link.js +182 -0
- package/dist/next/remote/host-link.js.map +1 -0
- package/dist/next/remote/internal.d.ts +6 -0
- package/dist/next/remote/internal.d.ts.map +1 -0
- package/dist/next/remote/internal.js +6 -0
- package/dist/next/remote/internal.js.map +1 -0
- package/dist/next/remote/path.d.ts +46 -0
- package/dist/next/remote/path.d.ts.map +1 -0
- package/dist/next/remote/path.js +73 -0
- package/dist/next/remote/path.js.map +1 -0
- package/dist/next/remote/provider.d.ts +76 -0
- package/dist/next/remote/provider.d.ts.map +1 -0
- package/dist/next/remote/provider.js +506 -0
- package/dist/next/remote/provider.js.map +1 -0
- package/dist/next/remote/relay.d.ts +58 -0
- package/dist/next/remote/relay.d.ts.map +1 -0
- package/dist/next/remote/relay.js +117 -0
- package/dist/next/remote/relay.js.map +1 -0
- package/dist/next/remote/remote-object.d.ts +133 -0
- package/dist/next/remote/remote-object.d.ts.map +1 -0
- package/dist/next/remote/remote-object.js +411 -0
- package/dist/next/remote/remote-object.js.map +1 -0
- package/dist/next/remote/replica.d.ts +59 -0
- package/dist/next/remote/replica.d.ts.map +1 -0
- package/dist/next/remote/replica.js +125 -0
- package/dist/next/remote/replica.js.map +1 -0
- package/dist/next/state/batch.d.ts +64 -0
- package/dist/next/state/batch.d.ts.map +1 -0
- package/dist/next/state/batch.js +163 -0
- package/dist/next/state/batch.js.map +1 -0
- package/dist/next/state/derive.d.ts +52 -0
- package/dist/next/state/derive.d.ts.map +1 -0
- package/dist/next/state/derive.js +182 -0
- package/dist/next/state/derive.js.map +1 -0
- package/dist/next/state/index.d.ts +6 -0
- package/dist/next/state/index.d.ts.map +1 -0
- package/dist/next/state/index.js +4 -0
- package/dist/next/state/index.js.map +1 -0
- package/dist/next/state/internal.d.ts +6 -0
- package/dist/next/state/internal.d.ts.map +1 -0
- package/dist/next/state/internal.js +8 -0
- package/dist/next/state/internal.js.map +1 -0
- package/dist/next/state/native-source.d.ts +106 -0
- package/dist/next/state/native-source.d.ts.map +1 -0
- package/dist/next/state/native-source.js +240 -0
- package/dist/next/state/native-source.js.map +1 -0
- package/dist/next/state/watchable.d.ts +114 -0
- package/dist/next/state/watchable.d.ts.map +1 -0
- package/dist/next/state/watchable.js +156 -0
- package/dist/next/state/watchable.js.map +1 -0
- package/dist/next/state/writable.d.ts +32 -0
- package/dist/next/state/writable.d.ts.map +1 -0
- package/dist/next/state/writable.js +49 -0
- package/dist/next/state/writable.js.map +1 -0
- package/dist/next/store/adapter.d.ts +67 -0
- package/dist/next/store/adapter.d.ts.map +1 -0
- package/dist/next/store/adapter.js +118 -0
- package/dist/next/store/adapter.js.map +1 -0
- package/dist/next/store/allocator.d.ts +17 -0
- package/dist/next/store/allocator.d.ts.map +1 -0
- package/dist/next/store/allocator.js +30 -0
- package/dist/next/store/allocator.js.map +1 -0
- package/dist/next/store/applier.d.ts +8 -0
- package/dist/next/store/applier.d.ts.map +1 -0
- package/dist/next/store/applier.js +375 -0
- package/dist/next/store/applier.js.map +1 -0
- package/dist/next/store/apply-batch.d.ts +12 -0
- package/dist/next/store/apply-batch.d.ts.map +1 -0
- package/dist/next/store/apply-batch.js +83 -0
- package/dist/next/store/apply-batch.js.map +1 -0
- package/dist/next/store/archive.d.ts +32 -0
- package/dist/next/store/archive.d.ts.map +1 -0
- package/dist/next/store/archive.js +129 -0
- package/dist/next/store/archive.js.map +1 -0
- package/dist/next/store/backend.d.ts +10 -0
- package/dist/next/store/backend.d.ts.map +1 -0
- package/dist/next/store/backend.js +15 -0
- package/dist/next/store/backend.js.map +1 -0
- package/dist/next/store/catalog.d.ts +24 -0
- package/dist/next/store/catalog.d.ts.map +1 -0
- package/dist/next/store/catalog.js +17 -0
- package/dist/next/store/catalog.js.map +1 -0
- package/dist/next/store/claims.d.ts +23 -0
- package/dist/next/store/claims.d.ts.map +1 -0
- package/dist/next/store/claims.js +65 -0
- package/dist/next/store/claims.js.map +1 -0
- package/dist/next/store/columns.d.ts +77 -0
- package/dist/next/store/columns.d.ts.map +1 -0
- package/dist/next/store/columns.js +77 -0
- package/dist/next/store/columns.js.map +1 -0
- package/dist/next/store/engine.d.ts +176 -0
- package/dist/next/store/engine.d.ts.map +1 -0
- package/dist/next/store/engine.js +283 -0
- package/dist/next/store/engine.js.map +1 -0
- package/dist/next/store/evaluate.d.ts +17 -0
- package/dist/next/store/evaluate.d.ts.map +1 -0
- package/dist/next/store/evaluate.js +128 -0
- package/dist/next/store/evaluate.js.map +1 -0
- package/dist/next/store/export.d.ts +17 -0
- package/dist/next/store/export.d.ts.map +1 -0
- package/dist/next/store/export.js +200 -0
- package/dist/next/store/export.js.map +1 -0
- package/dist/next/store/expression.d.ts +150 -0
- package/dist/next/store/expression.d.ts.map +1 -0
- package/dist/next/store/expression.js +268 -0
- package/dist/next/store/expression.js.map +1 -0
- package/dist/next/store/import.d.ts +10 -0
- package/dist/next/store/import.d.ts.map +1 -0
- package/dist/next/store/import.js +276 -0
- package/dist/next/store/import.js.map +1 -0
- package/dist/next/store/index.d.ts +16 -0
- package/dist/next/store/index.d.ts.map +1 -0
- package/dist/next/store/index.js +13 -0
- package/dist/next/store/index.js.map +1 -0
- package/dist/next/store/json-column.d.ts +33 -0
- package/dist/next/store/json-column.d.ts.map +1 -0
- package/dist/next/store/json-column.js +61 -0
- package/dist/next/store/json-column.js.map +1 -0
- package/dist/next/store/jsonl.d.ts +9 -0
- package/dist/next/store/jsonl.d.ts.map +1 -0
- package/dist/next/store/jsonl.js +61 -0
- package/dist/next/store/jsonl.js.map +1 -0
- package/dist/next/store/outbox.d.ts +26 -0
- package/dist/next/store/outbox.d.ts.map +1 -0
- package/dist/next/store/outbox.js +80 -0
- package/dist/next/store/outbox.js.map +1 -0
- package/dist/next/store/query.d.ts +39 -0
- package/dist/next/store/query.d.ts.map +1 -0
- package/dist/next/store/query.js +97 -0
- package/dist/next/store/query.js.map +1 -0
- package/dist/next/store/refusal.d.ts +15 -0
- package/dist/next/store/refusal.d.ts.map +1 -0
- package/dist/next/store/refusal.js +36 -0
- package/dist/next/store/refusal.js.map +1 -0
- package/dist/next/store/rows.d.ts +80 -0
- package/dist/next/store/rows.d.ts.map +1 -0
- package/dist/next/store/rows.js +183 -0
- package/dist/next/store/rows.js.map +1 -0
- package/dist/next/store/schema.d.ts +25 -0
- package/dist/next/store/schema.d.ts.map +1 -0
- package/dist/next/store/schema.js +115 -0
- package/dist/next/store/schema.js.map +1 -0
- package/dist/next/store/sql.d.ts +73 -0
- package/dist/next/store/sql.d.ts.map +1 -0
- package/dist/next/store/sql.js +234 -0
- package/dist/next/store/sql.js.map +1 -0
- package/dist/next/store/step.d.ts +48 -0
- package/dist/next/store/step.d.ts.map +1 -0
- package/dist/next/store/step.js +50 -0
- package/dist/next/store/step.js.map +1 -0
- package/dist/next/store/store.d.ts +161 -0
- package/dist/next/store/store.d.ts.map +1 -0
- package/dist/next/store/store.js +627 -0
- package/dist/next/store/store.js.map +1 -0
- package/dist/next/store/table-changes.d.ts +29 -0
- package/dist/next/store/table-changes.d.ts.map +1 -0
- package/dist/next/store/table-changes.js +102 -0
- package/dist/next/store/table-changes.js.map +1 -0
- package/dist/next/store/table-evolve.d.ts +74 -0
- package/dist/next/store/table-evolve.d.ts.map +1 -0
- package/dist/next/store/table-evolve.js +201 -0
- package/dist/next/store/table-evolve.js.map +1 -0
- package/dist/next/store/table-handle.d.ts +67 -0
- package/dist/next/store/table-handle.d.ts.map +1 -0
- package/dist/next/store/table-handle.js +101 -0
- package/dist/next/store/table-handle.js.map +1 -0
- package/dist/next/store/table-history.d.ts +75 -0
- package/dist/next/store/table-history.d.ts.map +1 -0
- package/dist/next/store/table-history.js +42 -0
- package/dist/next/store/table-history.js.map +1 -0
- package/dist/next/store/table-migration.d.ts +16 -0
- package/dist/next/store/table-migration.d.ts.map +1 -0
- package/dist/next/store/table-migration.js +202 -0
- package/dist/next/store/table-migration.js.map +1 -0
- package/dist/next/store/table-writes.d.ts +125 -0
- package/dist/next/store/table-writes.d.ts.map +1 -0
- package/dist/next/store/table-writes.js +165 -0
- package/dist/next/store/table-writes.js.map +1 -0
- package/dist/next/store/table.d.ts +80 -0
- package/dist/next/store/table.d.ts.map +1 -0
- package/dist/next/store/table.js +103 -0
- package/dist/next/store/table.js.map +1 -0
- package/dist/next/store/text.d.ts +14 -0
- package/dist/next/store/text.d.ts.map +1 -0
- package/dist/next/store/text.js +51 -0
- package/dist/next/store/text.js.map +1 -0
- package/dist/next/store/writes.d.ts +5 -0
- package/dist/next/store/writes.d.ts.map +1 -0
- package/dist/next/store/writes.js +4 -0
- package/dist/next/store/writes.js.map +1 -0
- package/dist/next-node/compression.d.ts +7 -0
- package/dist/next-node/compression.d.ts.map +1 -0
- package/dist/next-node/compression.js +24 -0
- package/dist/next-node/compression.js.map +1 -0
- package/dist/next-node/http/admission.d.ts +63 -0
- package/dist/next-node/http/admission.d.ts.map +1 -0
- package/dist/next-node/http/admission.js +134 -0
- package/dist/next-node/http/admission.js.map +1 -0
- package/dist/next-node/http/authenticate.d.ts +21 -0
- package/dist/next-node/http/authenticate.d.ts.map +1 -0
- package/dist/next-node/http/authenticate.js +34 -0
- package/dist/next-node/http/authenticate.js.map +1 -0
- package/dist/next-node/http/cookies.d.ts +24 -0
- package/dist/next-node/http/cookies.d.ts.map +1 -0
- package/dist/next-node/http/cookies.js +62 -0
- package/dist/next-node/http/cookies.js.map +1 -0
- package/dist/next-node/http/file.d.ts +23 -0
- package/dist/next-node/http/file.d.ts.map +1 -0
- package/dist/next-node/http/file.js +94 -0
- package/dist/next-node/http/file.js.map +1 -0
- package/dist/next-node/http/headers.d.ts +37 -0
- package/dist/next-node/http/headers.d.ts.map +1 -0
- package/dist/next-node/http/headers.js +129 -0
- package/dist/next-node/http/headers.js.map +1 -0
- package/dist/next-node/http/http.d.ts +100 -0
- package/dist/next-node/http/http.d.ts.map +1 -0
- package/dist/next-node/http/http.js +462 -0
- package/dist/next-node/http/http.js.map +1 -0
- package/dist/next-node/http/incoming.d.ts +19 -0
- package/dist/next-node/http/incoming.d.ts.map +1 -0
- package/dist/next-node/http/incoming.js +31 -0
- package/dist/next-node/http/incoming.js.map +1 -0
- package/dist/next-node/http/index.d.ts +11 -0
- package/dist/next-node/http/index.d.ts.map +1 -0
- package/dist/next-node/http/index.js +12 -0
- package/dist/next-node/http/index.js.map +1 -0
- package/dist/next-node/http/node.d.ts +78 -0
- package/dist/next-node/http/node.d.ts.map +1 -0
- package/dist/next-node/http/node.js +291 -0
- package/dist/next-node/http/node.js.map +1 -0
- package/dist/next-node/http/request.d.ts +54 -0
- package/dist/next-node/http/request.d.ts.map +1 -0
- package/dist/next-node/http/request.js +116 -0
- package/dist/next-node/http/request.js.map +1 -0
- package/dist/next-node/http/response.d.ts +63 -0
- package/dist/next-node/http/response.d.ts.map +1 -0
- package/dist/next-node/http/response.js +202 -0
- package/dist/next-node/http/response.js.map +1 -0
- package/dist/next-node/http/router.d.ts +114 -0
- package/dist/next-node/http/router.d.ts.map +1 -0
- package/dist/next-node/http/router.js +261 -0
- package/dist/next-node/http/router.js.map +1 -0
- package/dist/next-node/http/upgrades.d.ts +58 -0
- package/dist/next-node/http/upgrades.d.ts.map +1 -0
- package/dist/next-node/http/upgrades.js +184 -0
- package/dist/next-node/http/upgrades.js.map +1 -0
- package/dist/next-node/plugins/build.d.ts +57 -0
- package/dist/next-node/plugins/build.d.ts.map +1 -0
- package/dist/next-node/plugins/build.js +334 -0
- package/dist/next-node/plugins/build.js.map +1 -0
- package/dist/next-node/plugins/discover.d.ts +36 -0
- package/dist/next-node/plugins/discover.d.ts.map +1 -0
- package/dist/next-node/plugins/discover.js +91 -0
- package/dist/next-node/plugins/discover.js.map +1 -0
- package/dist/next-node/plugins/evaluate.d.ts +33 -0
- package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
- package/dist/next-node/plugins/evaluate.js +98 -0
- package/dist/next-node/plugins/evaluate.js.map +1 -0
- package/dist/next-node/plugins/index.d.ts +9 -0
- package/dist/next-node/plugins/index.d.ts.map +1 -0
- package/dist/next-node/plugins/index.js +11 -0
- package/dist/next-node/plugins/index.js.map +1 -0
- package/dist/next-node/plugins/install.d.ts +13 -0
- package/dist/next-node/plugins/install.d.ts.map +1 -0
- package/dist/next-node/plugins/install.js +37 -0
- package/dist/next-node/plugins/install.js.map +1 -0
- package/dist/next-node/plugins/plugins.d.ts +135 -0
- package/dist/next-node/plugins/plugins.d.ts.map +1 -0
- package/dist/next-node/plugins/plugins.js +206 -0
- package/dist/next-node/plugins/plugins.js.map +1 -0
- package/dist/next-node/plugins/runtime.d.ts +41 -0
- package/dist/next-node/plugins/runtime.d.ts.map +1 -0
- package/dist/next-node/plugins/runtime.js +136 -0
- package/dist/next-node/plugins/runtime.js.map +1 -0
- package/dist/next-node/plugins/stack.d.ts +16 -0
- package/dist/next-node/plugins/stack.d.ts.map +1 -0
- package/dist/next-node/plugins/stack.js +61 -0
- package/dist/next-node/plugins/stack.js.map +1 -0
- package/dist/next-node/plugins/watcher.d.ts +58 -0
- package/dist/next-node/plugins/watcher.d.ts.map +1 -0
- package/dist/next-node/plugins/watcher.js +281 -0
- package/dist/next-node/plugins/watcher.js.map +1 -0
- package/dist/next-node/workers/control.d.ts +83 -0
- package/dist/next-node/workers/control.d.ts.map +1 -0
- package/dist/next-node/workers/control.js +77 -0
- package/dist/next-node/workers/control.js.map +1 -0
- package/dist/next-node/workers/index.d.ts +5 -0
- package/dist/next-node/workers/index.d.ts.map +1 -0
- package/dist/next-node/workers/index.js +7 -0
- package/dist/next-node/workers/index.js.map +1 -0
- package/dist/next-node/workers/lock.d.ts +21 -0
- package/dist/next-node/workers/lock.d.ts.map +1 -0
- package/dist/next-node/workers/lock.js +137 -0
- package/dist/next-node/workers/lock.js.map +1 -0
- package/dist/next-node/workers/main.d.ts +46 -0
- package/dist/next-node/workers/main.d.ts.map +1 -0
- package/dist/next-node/workers/main.js +230 -0
- package/dist/next-node/workers/main.js.map +1 -0
- package/dist/next-node/workers/process.d.ts +42 -0
- package/dist/next-node/workers/process.d.ts.map +1 -0
- package/dist/next-node/workers/process.js +125 -0
- package/dist/next-node/workers/process.js.map +1 -0
- package/dist/next-node/workers/workers.d.ts +80 -0
- package/dist/next-node/workers/workers.d.ts.map +1 -0
- package/dist/next-node/workers/workers.js +572 -0
- package/dist/next-node/workers/workers.js.map +1 -0
- package/dist/object.d.ts +4 -4
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +3 -4
- package/dist/object.js.map +1 -1
- package/dist/output.d.ts +1 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +4 -2
- package/dist/output.js.map +1 -1
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +2 -2
- package/dist/remote.js.map +1 -1
- package/dist/schema.d.ts +8 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +180 -5
- package/dist/schema.js.map +1 -1
- package/dist/sqlite/cloudflare.d.ts +2 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -1
- package/dist/sqlite/cloudflare.js +10 -0
- package/dist/sqlite/cloudflare.js.map +1 -1
- package/dist/sqlite/database.d.ts +5 -2
- package/dist/sqlite/database.d.ts.map +1 -1
- package/dist/sqlite/database.js.map +1 -1
- package/dist/sqlite/node.d.ts +4 -1
- package/dist/sqlite/node.d.ts.map +1 -1
- package/dist/sqlite/node.js +22 -5
- package/dist/sqlite/node.js.map +1 -1
- package/dist/watch.d.ts +194 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +383 -0
- package/dist/watch.js.map +1 -0
- package/dist/wire.d.ts +174 -193
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +81 -80
- package/dist/wire.js.map +1 -1
- package/docs/guide.md +15 -15
- package/docs/next/benchmarks.md +959 -0
- package/docs/next/decisions.md +2957 -0
- package/docs/next/dependencies/book.md +1671 -0
- package/docs/next/dependencies/index.html +2641 -0
- package/docs/next/dependencies/model.md +330 -0
- package/docs/next/design.md +2554 -0
- package/docs/next/durable-observers/book.md +432 -0
- package/docs/next/durable-observers/index.html +517 -0
- package/docs/next/flow-control/book.md +333 -0
- package/docs/next/flow-control/fold/index.html +265 -0
- package/docs/next/flow-control/index.html +548 -0
- package/docs/next/flow-control/window/index.html +228 -0
- package/docs/next/guide-plugins-hosts/book.md +607 -0
- package/docs/next/guide-plugins-hosts/index.html +652 -0
- package/docs/next/http-workers/book.md +378 -0
- package/docs/next/http-workers/index.html +515 -0
- package/docs/next/layer-1.md +311 -0
- package/docs/next/layer-2.md +216 -0
- package/docs/next/plugin-model/book.md +186 -0
- package/docs/next/plugin-model/index.html +310 -0
- package/docs/next/plugin-primer/book.md +273 -0
- package/docs/next/plugin-primer/index.html +430 -0
- package/docs/next/slice-1.md +236 -0
- package/docs/next/slice-10.md +285 -0
- package/docs/next/slice-11.md +93 -0
- package/docs/next/slice-2.md +174 -0
- package/docs/next/slice-3a.md +296 -0
- package/docs/next/slice-3b.md +197 -0
- package/docs/next/slice-4.md +146 -0
- package/docs/next/slice-4a.md +418 -0
- package/docs/next/slice-4b.md +208 -0
- package/docs/next/slice-5.md +281 -0
- package/docs/next/slice-6a.md +676 -0
- package/docs/next/slice-6b.md +332 -0
- package/docs/next/slice-7a.md +130 -0
- package/docs/next/slice-7b/book.md +608 -0
- package/docs/next/slice-7b/index.html +842 -0
- package/docs/next/slice-7b.md +255 -0
- package/docs/next/slice-7c.md +165 -0
- package/docs/next/slice-8.md +194 -0
- package/docs/next/slices.md +230 -0
- package/docs/next/store/book.md +665 -0
- package/docs/next/store/index.html +861 -0
- package/docs/next/store/walkthrough.md +193 -0
- package/docs/spec.md +9 -9
- package/docs/tutorial.md +26 -25
- package/package.json +22 -6
- package/src/delta/README.md +69 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// The consumer side of a link (§7, §22, W1): the holds this host's own remote references sent on it, by this side's
|
|
2
|
+
// ids, the calls through them within the peer's call window, and each `bound` and `state` message applied to their
|
|
3
|
+
// replicas as one batch, then acknowledged. Messages with an origin answer holds this host relays: they go to that
|
|
4
|
+
// origin's provider side. On a host without a compressor, the deflated parts of this host's own holds and calls are
|
|
5
|
+
// inflated asynchronously first, and the message is handled once they are.
|
|
6
|
+
import { takesNoArgs } from "../contracts/internal.js";
|
|
7
|
+
import { ChordError, isChordError } from "../data/index.js";
|
|
8
|
+
import { asChordError } from "../data/internal.js";
|
|
9
|
+
import { errorFromWire, parsePayload, payloadPart, } from "../link/internal.js";
|
|
10
|
+
import { CallWindow } from "./calls.js";
|
|
11
|
+
import { actingFor } from "./hold.js";
|
|
12
|
+
/**
|
|
13
|
+
* The consumer side of one link. Ids are its own counters, from 0; a reply naming an id this side gave up is ignored
|
|
14
|
+
* (Q1). When the link closes, every call rejects `unavailable` (never resent) and its path tells every holder.
|
|
15
|
+
*/
|
|
16
|
+
export class ConsumerSide {
|
|
17
|
+
#link;
|
|
18
|
+
#entries = new Map();
|
|
19
|
+
#calls = new Map();
|
|
20
|
+
#window = new CallWindow();
|
|
21
|
+
#nextHold = 0;
|
|
22
|
+
#nextCall = 0;
|
|
23
|
+
constructor(link) {
|
|
24
|
+
this.#link = link;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Holds `holder` on this link and returns its new id: its first hold, or a re-hold on a new link; `chain`: the
|
|
28
|
+
* activation chain it is held for, if any (Q5).
|
|
29
|
+
*/
|
|
30
|
+
attach(holder, chain) {
|
|
31
|
+
const id = this.#nextHold++;
|
|
32
|
+
this.#entries.set(id, holder);
|
|
33
|
+
const acting = actingFor(this.#link, holder.caller);
|
|
34
|
+
this.#link.send({
|
|
35
|
+
kind: "hold",
|
|
36
|
+
hold: id,
|
|
37
|
+
...holder.request,
|
|
38
|
+
...acting,
|
|
39
|
+
...(chain === undefined ? {} : { chain }),
|
|
40
|
+
});
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Calls method `method` (an index into the bound variant) on hold `hold` with `args`: left out for a method without
|
|
45
|
+
* arguments, with byte segments when its argument schema has a `bytes()` leaf, deflated above the threshold except on
|
|
46
|
+
* the parent link. The result is parsed here. The caller's cancellation rejects it at once and sends `abort` when it
|
|
47
|
+
* is in flight.
|
|
48
|
+
*/
|
|
49
|
+
call(hold, method, data, args, context) {
|
|
50
|
+
const signal = context.abortSignal;
|
|
51
|
+
signal?.throwIfAborted();
|
|
52
|
+
const payload = takesNoArgs(data) ? undefined : payloadPart(args, data.args.bytes);
|
|
53
|
+
// Up a parent link they travel uncompressed: the parent may have accepted this host as a child, and child links
|
|
54
|
+
// refuse compressed parts (§22).
|
|
55
|
+
const link = this.#link;
|
|
56
|
+
const part = payload === undefined ? undefined : link.role === "parent" ? payload.json : link.part(payload.json, context);
|
|
57
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
58
|
+
const cancel = () => {
|
|
59
|
+
this.#cancel(call);
|
|
60
|
+
reject(signal.reason);
|
|
61
|
+
};
|
|
62
|
+
const done = () => signal?.removeEventListener("abort", cancel);
|
|
63
|
+
const call = {
|
|
64
|
+
hold,
|
|
65
|
+
method,
|
|
66
|
+
args: part,
|
|
67
|
+
segments: payload?.segments,
|
|
68
|
+
resolve: (value) => {
|
|
69
|
+
done();
|
|
70
|
+
resolve(value);
|
|
71
|
+
},
|
|
72
|
+
reject: (error) => {
|
|
73
|
+
done();
|
|
74
|
+
reject(error);
|
|
75
|
+
},
|
|
76
|
+
id: undefined,
|
|
77
|
+
send: () => this.#send(call),
|
|
78
|
+
};
|
|
79
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
80
|
+
this.#window.submit(call);
|
|
81
|
+
return promise;
|
|
82
|
+
}
|
|
83
|
+
/** Hold `hold` was released: the provider is told, its calls fail with `error`. */
|
|
84
|
+
release(hold, error) {
|
|
85
|
+
this.#link.send({ kind: "release", hold });
|
|
86
|
+
this.forget(hold, error);
|
|
87
|
+
}
|
|
88
|
+
/** `ref.retry()` on a failed hold, with `hops` left of its budget: the provider is asked for an attempt now. */
|
|
89
|
+
retry(hold, hops) {
|
|
90
|
+
this.#link.send({ kind: "retry", hold, hops });
|
|
91
|
+
}
|
|
92
|
+
/** Drops hold `hold` from the tables; its calls, in flight and waiting, fail with `error` and free their slots. */
|
|
93
|
+
forget(hold, error) {
|
|
94
|
+
this.#entries.delete(hold);
|
|
95
|
+
this.#failCalls(hold, error);
|
|
96
|
+
}
|
|
97
|
+
/** The peer's `hello` arrived: calls go out within its window. */
|
|
98
|
+
opened(calls) {
|
|
99
|
+
this.#window.opened(calls);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handles one message from the provider: this host's own, or (with an origin) one for a relayed hold. A `bound`,
|
|
103
|
+
* `state` or `result` with deflated parts to inflate asynchronously returns that promise and is handled after it.
|
|
104
|
+
*/
|
|
105
|
+
message(message) {
|
|
106
|
+
if (message.origin !== undefined) {
|
|
107
|
+
this.#link.host.relays.get(message.origin)?.forward(message, this.#link);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
switch (message.kind) {
|
|
111
|
+
case "bound":
|
|
112
|
+
case "state": {
|
|
113
|
+
const deflated = this.#deflated(message.holds);
|
|
114
|
+
if (deflated !== undefined)
|
|
115
|
+
return this.#link.inflate(deflated, () => this.message(message));
|
|
116
|
+
if (message.kind === "bound")
|
|
117
|
+
this.#bound(message.holds);
|
|
118
|
+
else
|
|
119
|
+
this.#state(message.holds);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "failed":
|
|
123
|
+
this.#failed(message);
|
|
124
|
+
break;
|
|
125
|
+
case "loading":
|
|
126
|
+
this.#loading(message.hold);
|
|
127
|
+
break;
|
|
128
|
+
case "result":
|
|
129
|
+
case "error":
|
|
130
|
+
return this.#reply(message);
|
|
131
|
+
case "gone":
|
|
132
|
+
this.#gone(message);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** The link closed: calls in flight and waiting reject `unavailable` (never resent, §7); the tables are dropped. */
|
|
137
|
+
closed() {
|
|
138
|
+
const error = new ChordError({ code: "unavailable", message: "the link closed" });
|
|
139
|
+
const calls = [...this.#calls.values(), ...this.#window.clear()];
|
|
140
|
+
this.#calls.clear();
|
|
141
|
+
this.#entries.clear();
|
|
142
|
+
for (const call of calls)
|
|
143
|
+
call.reject(error);
|
|
144
|
+
}
|
|
145
|
+
/** Sends a call that got its slot, with the next id. */
|
|
146
|
+
#send(call) {
|
|
147
|
+
const id = this.#nextCall++;
|
|
148
|
+
call.id = id;
|
|
149
|
+
this.#calls.set(id, call);
|
|
150
|
+
const { hold, method, args, segments } = call;
|
|
151
|
+
this.#link.send({
|
|
152
|
+
kind: "call",
|
|
153
|
+
call: id,
|
|
154
|
+
hold,
|
|
155
|
+
method,
|
|
156
|
+
...(args === undefined ? {} : { args }),
|
|
157
|
+
...(segments === undefined ? {} : { segments }),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Cancels `call`: a waiting one leaves the window and nothing is sent; one in flight sends `abort` and frees its
|
|
162
|
+
* slot. Settling the caller is the caller's.
|
|
163
|
+
*/
|
|
164
|
+
#cancel(call) {
|
|
165
|
+
if (call.id === undefined) {
|
|
166
|
+
this.#window.remove(call);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (!this.#calls.delete(call.id))
|
|
170
|
+
return;
|
|
171
|
+
this.#link.send({ kind: "abort", call: call.id });
|
|
172
|
+
this.#window.freed();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The deflated parts of this side's own holds in `entries` that wait for an asynchronous inflate, each with the
|
|
176
|
+
* link's decoded limit; `undefined` when none does (nothing allocated). Entries of holds this side gave up are not
|
|
177
|
+
* inflated (Q1).
|
|
178
|
+
*/
|
|
179
|
+
#deflated(entries) {
|
|
180
|
+
const { limits } = this.#link;
|
|
181
|
+
let deflated;
|
|
182
|
+
for (const entry of entries) {
|
|
183
|
+
if (!this.#entries.has(entry.hold))
|
|
184
|
+
continue;
|
|
185
|
+
for (const member of entry.members) {
|
|
186
|
+
const part = "value" in member ? member.value : member.ops;
|
|
187
|
+
if (!this.#link.inflates(part, limits))
|
|
188
|
+
continue;
|
|
189
|
+
deflated ??= [];
|
|
190
|
+
deflated.push([part, limits.decoded]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return deflated;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* One `bound` message: every entry prepared first (one that does not fit closes the link before anything changed)
|
|
197
|
+
* and applied in one batch; then the references go live, and the message is acknowledged. An entry with a part past
|
|
198
|
+
* the link's limits fails only its hold (`too_large/part`); the others apply.
|
|
199
|
+
*/
|
|
200
|
+
#bound(holds) {
|
|
201
|
+
const adoptions = [];
|
|
202
|
+
const bound = [];
|
|
203
|
+
let oversized;
|
|
204
|
+
for (const entry of holds) {
|
|
205
|
+
const holder = this.#entries.get(entry.hold);
|
|
206
|
+
if (holder === undefined)
|
|
207
|
+
continue;
|
|
208
|
+
try {
|
|
209
|
+
adoptions.push(holder.prepareBound(entry, this.#link));
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (!isChordError(error, "too_large"))
|
|
213
|
+
throw error;
|
|
214
|
+
oversized ??= [];
|
|
215
|
+
oversized.push([holder, error]);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
bound.push(holder);
|
|
219
|
+
}
|
|
220
|
+
this.#adopt(adoptions);
|
|
221
|
+
// After the batch: the references go live with every replica of the message in place.
|
|
222
|
+
for (const holder of bound)
|
|
223
|
+
holder.wentLive();
|
|
224
|
+
for (const [holder, error] of oversized ?? [])
|
|
225
|
+
holder.tooLarge(error);
|
|
226
|
+
this.#link.send({ kind: "ack" });
|
|
227
|
+
}
|
|
228
|
+
/** One `state` message, as `#bound` does it. */
|
|
229
|
+
#state(holds) {
|
|
230
|
+
const adoptions = [];
|
|
231
|
+
let oversized;
|
|
232
|
+
for (const entry of holds) {
|
|
233
|
+
const holder = this.#entries.get(entry.hold);
|
|
234
|
+
if (holder === undefined)
|
|
235
|
+
continue;
|
|
236
|
+
try {
|
|
237
|
+
adoptions.push(holder.prepare(entry, this.#link));
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (!isChordError(error, "too_large"))
|
|
241
|
+
throw error;
|
|
242
|
+
oversized ??= [];
|
|
243
|
+
oversized.push([holder, error]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
this.#adopt(adoptions);
|
|
247
|
+
for (const [holder, error] of oversized ?? [])
|
|
248
|
+
holder.tooLarge(error);
|
|
249
|
+
this.#link.send({ kind: "ack" });
|
|
250
|
+
}
|
|
251
|
+
/** Applies prepared entries in one batch of this host, so no watch or derive sees half a provider commit (W1). */
|
|
252
|
+
#adopt(adoptions) {
|
|
253
|
+
if (adoptions.length === 0)
|
|
254
|
+
return;
|
|
255
|
+
this.#link.host.batch.commit(() => {
|
|
256
|
+
for (const adopt of adoptions)
|
|
257
|
+
adopt();
|
|
258
|
+
}, this.#link.context);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* `loading`: the hold's object, or its relay's upstream, starts over; its calls still waiting for a slot reject
|
|
262
|
+
* `unavailable` (they may name a method of the old variant).
|
|
263
|
+
*/
|
|
264
|
+
#loading(hold) {
|
|
265
|
+
const holder = this.#entries.get(hold);
|
|
266
|
+
if (holder === undefined)
|
|
267
|
+
return;
|
|
268
|
+
const error = new ChordError({ code: "unavailable", message: `hold ${hold}: rebinding` });
|
|
269
|
+
for (const call of this.#window.removeHold(hold))
|
|
270
|
+
call.reject(error);
|
|
271
|
+
holder.loading();
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* `failed`: its holder fails; its calls still waiting for a slot reject with the cause (a bound hold is unbound by it,
|
|
275
|
+
* slice 7b; its calls in flight are rejected by the provider).
|
|
276
|
+
*/
|
|
277
|
+
#failed(message) {
|
|
278
|
+
const holder = this.#entries.get(message.hold);
|
|
279
|
+
if (holder === undefined)
|
|
280
|
+
return;
|
|
281
|
+
const error = asChordError(errorFromWire(message.cause.error), `hold ${message.hold}`);
|
|
282
|
+
for (const call of this.#window.removeHold(message.hold))
|
|
283
|
+
call.reject(error);
|
|
284
|
+
holder.failed(message);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* `gone`: one for a hold this side gave up is ignored (Q1); the holder ends, which forgets its hold here and fails
|
|
288
|
+
* its calls.
|
|
289
|
+
*/
|
|
290
|
+
#gone(message) {
|
|
291
|
+
const holder = this.#entries.get(message.hold);
|
|
292
|
+
if (holder === undefined)
|
|
293
|
+
return;
|
|
294
|
+
holder.lost(asChordError(errorFromWire(message.error), `hold ${message.hold}`));
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* A reply: its call settles with the parsed result or the error. A result past the link's limits rejects the call
|
|
298
|
+
* `too_large/part`. A malformed part rejects the call `unavailable` and throws (a protocol error: the link closes).
|
|
299
|
+
* A result to inflate asynchronously is inflated first (for a call still waiting), then handled again.
|
|
300
|
+
*/
|
|
301
|
+
#reply(reply) {
|
|
302
|
+
const call = this.#calls.get(reply.call);
|
|
303
|
+
if (call === undefined)
|
|
304
|
+
return;
|
|
305
|
+
const link = this.#link;
|
|
306
|
+
if (reply.kind === "result" && link.inflates(reply.value, link.limits)) {
|
|
307
|
+
return link.inflate([[reply.value, link.limits.decoded]], () => this.#reply(reply));
|
|
308
|
+
}
|
|
309
|
+
this.#calls.delete(reply.call);
|
|
310
|
+
this.#window.freed();
|
|
311
|
+
try {
|
|
312
|
+
if (reply.kind === "error")
|
|
313
|
+
call.reject(errorFromWire(reply.error));
|
|
314
|
+
else if (reply.value === undefined)
|
|
315
|
+
call.resolve(null);
|
|
316
|
+
else
|
|
317
|
+
call.resolve(parsePayload(link.openPart(reply.value, link.limits, link.context), reply.segments));
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
if (isChordError(error, "too_large")) {
|
|
321
|
+
call.reject(error);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
call.reject(new ChordError({ code: "unavailable", message: `call ${reply.call}: a malformed reply` }));
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** Fails `hold`'s calls in flight and waiting with `error`; each in-flight one frees its slot. */
|
|
329
|
+
#failCalls(hold, error) {
|
|
330
|
+
// Waiting ones first: a freed slot must not send one of them.
|
|
331
|
+
const failed = this.#window.removeHold(hold);
|
|
332
|
+
for (const [id, call] of this.#calls) {
|
|
333
|
+
if (call.hold !== hold)
|
|
334
|
+
continue;
|
|
335
|
+
this.#calls.delete(id);
|
|
336
|
+
this.#window.freed();
|
|
337
|
+
failed.push(call);
|
|
338
|
+
}
|
|
339
|
+
for (const call of failed)
|
|
340
|
+
call.reject(error);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.js","sourceRoot":"","sources":["../../../src/next/remote/consumer.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,mHAAmH;AACnH,mHAAmH;AACnH,oHAAoH;AACpH,2EAA2E;AAG3E,OAAO,EAAmB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAIN,aAAa,EAGb,YAAY,EACZ,WAAW,GAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAuBtC;;;GAGG;AACH,MAAM,OAAO,YAAY;IACf,KAAK,CAAW;IAChB,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3C,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IACzC,OAAO,GAAG,IAAI,UAAU,EAAgB,CAAC;IAClD,SAAS,GAAG,CAAC,CAAC;IACd,SAAS,GAAG,CAAC,CAAC;IAEd,YAAY,IAAc;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAoB,EAAE,KAA2B;QACvD,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,SA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AAK,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC,CAAC;YACvG,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,kGAAkG;IAClG,UAAU,CAAC,IAAY,EAAE,KAAiB;QACzC,8DAA8D;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;gBAAE,SAAS;YACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["// The consumer side of a link (§7, §22, W1): the holds this host's own remote references sent on it, by this side's\n// ids, the calls through them within the peer's call window, and each `bound` and `state` message applied to their\n// replicas as one batch, then acknowledged. Messages with an origin answer holds this host relays: they go to that\n// origin's provider side. On a host without a compressor, the deflated parts of this host's own holds and calls are\n// inflated asynchronously first, and the message is handled once they are.\n\nimport type { Context } from \"../../context/index.ts\";\nimport { type MethodData, takesNoArgs } from \"../contracts/internal.ts\";\nimport { ChordError, isChordError } from \"../data/index.ts\";\nimport { asChordError } from \"../data/internal.ts\";\nimport {\n\ttype BoundEntry,\n\ttype ConsumerMessage,\n\ttype DeflatedPart,\n\terrorFromWire,\n\ttype Message,\n\ttype Part,\n\tparsePayload,\n\tpayloadPart,\n\ttype StateEntry,\n} from \"../link/internal.ts\";\nimport { CallWindow } from \"./calls.ts\";\nimport { actingFor } from \"./hold.ts\";\nimport type { HostLink } from \"./host-link.ts\";\nimport type { RemoteObject } from \"./remote-object.ts\";\n\n/** A reply to a call. */\ntype Reply = Extract<Message, { readonly kind: \"result\" | \"error\" }>;\n\n/**\n * A call through this side: waiting for a slot of the call window (no id yet), then in flight under its id until its\n * reply, its abort, its hold's release or `gone`, or the link's close.\n */\ntype OutgoingCall = {\n\treadonly hold: number;\n\t/** The method's index in the bound variant and its arguments' part. */\n\treadonly method: number;\n\treadonly args: Part | undefined;\n\treadonly segments: readonly Uint8Array[] | undefined;\n\treadonly resolve: (value: unknown) => void;\n\treadonly reject: (error: unknown) => void;\n\tid: number | undefined;\n\tsend(): void;\n};\n\n/**\n * The consumer side of one link. Ids are its own counters, from 0; a reply naming an id this side gave up is ignored\n * (Q1). When the link closes, every call rejects `unavailable` (never resent) and its path tells every holder.\n */\nexport class ConsumerSide {\n\treadonly #link: HostLink;\n\treadonly #entries = new Map<number, RemoteObject>();\n\treadonly #calls = new Map<number, OutgoingCall>();\n\treadonly #window = new CallWindow<OutgoingCall>();\n\t#nextHold = 0;\n\t#nextCall = 0;\n\n\tconstructor(link: HostLink) {\n\t\tthis.#link = link;\n\t}\n\n\t/**\n\t * Holds `holder` on this link and returns its new id: its first hold, or a re-hold on a new link; `chain`: the\n\t * activation chain it is held for, if any (Q5).\n\t */\n\tattach(holder: RemoteObject, chain: string[] | undefined): number {\n\t\tconst id = this.#nextHold++;\n\t\tthis.#entries.set(id, holder);\n\t\tconst acting = actingFor(this.#link, holder.caller);\n\t\tthis.#link.send({\n\t\t\tkind: \"hold\",\n\t\t\thold: id,\n\t\t\t...holder.request,\n\t\t\t...acting,\n\t\t\t...(chain === undefined ? {} : { chain }),\n\t\t});\n\t\treturn id;\n\t}\n\n\t/**\n\t * Calls method `method` (an index into the bound variant) on hold `hold` with `args`: left out for a method without\n\t * arguments, with byte segments when its argument schema has a `bytes()` leaf, deflated above the threshold except on\n\t * the parent link. The result is parsed here. The caller's cancellation rejects it at once and sends `abort` when it\n\t * is in flight.\n\t */\n\tcall(hold: number, method: number, data: MethodData, args: unknown, context: Context): Promise<unknown> {\n\t\tconst signal = context.abortSignal;\n\t\tsignal?.throwIfAborted();\n\t\tconst payload = takesNoArgs(data) ? undefined : payloadPart(args, data.args.bytes);\n\t\t// Up a parent link they travel uncompressed: the parent may have accepted this host as a child, and child links\n\t\t// refuse compressed parts (§22).\n\t\tconst link = this.#link;\n\t\tconst part =\n\t\t\tpayload === undefined ? undefined : link.role === \"parent\" ? payload.json : link.part(payload.json, context);\n\t\tconst { promise, resolve, reject } = Promise.withResolvers<unknown>();\n\t\tconst cancel = (): void => {\n\t\t\tthis.#cancel(call);\n\t\t\treject(signal!.reason);\n\t\t};\n\t\tconst done = (): void => signal?.removeEventListener(\"abort\", cancel);\n\t\tconst call: OutgoingCall = {\n\t\t\thold,\n\t\t\tmethod,\n\t\t\targs: part,\n\t\t\tsegments: payload?.segments,\n\t\t\tresolve: (value) => {\n\t\t\t\tdone();\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\treject: (error) => {\n\t\t\t\tdone();\n\t\t\t\treject(error);\n\t\t\t},\n\t\t\tid: undefined,\n\t\t\tsend: () => this.#send(call),\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", cancel, { once: true });\n\t\tthis.#window.submit(call);\n\t\treturn promise;\n\t}\n\n\t/** Hold `hold` was released: the provider is told, its calls fail with `error`. */\n\trelease(hold: number, error: ChordError): void {\n\t\tthis.#link.send({ kind: \"release\", hold });\n\t\tthis.forget(hold, error);\n\t}\n\n\t/** `ref.retry()` on a failed hold, with `hops` left of its budget: the provider is asked for an attempt now. */\n\tretry(hold: number, hops: number): void {\n\t\tthis.#link.send({ kind: \"retry\", hold, hops });\n\t}\n\n\t/** Drops hold `hold` from the tables; its calls, in flight and waiting, fail with `error` and free their slots. */\n\tforget(hold: number, error: ChordError): void {\n\t\tthis.#entries.delete(hold);\n\t\tthis.#failCalls(hold, error);\n\t}\n\n\t/** The peer's `hello` arrived: calls go out within its window. */\n\topened(calls: number): void {\n\t\tthis.#window.opened(calls);\n\t}\n\n\t/**\n\t * Handles one message from the provider: this host's own, or (with an origin) one for a relayed hold. A `bound`,\n\t * `state` or `result` with deflated parts to inflate asynchronously returns that promise and is handled after it.\n\t */\n\tmessage(message: ConsumerMessage): void | Promise<void> {\n\t\tif (message.origin !== undefined) {\n\t\t\tthis.#link.host.relays.get(message.origin)?.forward(message, this.#link);\n\t\t\treturn;\n\t\t}\n\t\tswitch (message.kind) {\n\t\t\tcase \"bound\":\n\t\t\tcase \"state\": {\n\t\t\t\tconst deflated = this.#deflated(message.holds);\n\t\t\t\tif (deflated !== undefined) return this.#link.inflate(deflated, () => this.message(message));\n\t\t\t\tif (message.kind === \"bound\") this.#bound(message.holds);\n\t\t\t\telse this.#state(message.holds);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"failed\":\n\t\t\t\tthis.#failed(message);\n\t\t\t\tbreak;\n\t\t\tcase \"loading\":\n\t\t\t\tthis.#loading(message.hold);\n\t\t\t\tbreak;\n\t\t\tcase \"result\":\n\t\t\tcase \"error\":\n\t\t\t\treturn this.#reply(message);\n\t\t\tcase \"gone\":\n\t\t\t\tthis.#gone(message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t/** The link closed: calls in flight and waiting reject `unavailable` (never resent, §7); the tables are dropped. */\n\tclosed(): void {\n\t\tconst error = new ChordError({ code: \"unavailable\", message: \"the link closed\" });\n\t\tconst calls = [...this.#calls.values(), ...this.#window.clear()];\n\t\tthis.#calls.clear();\n\t\tthis.#entries.clear();\n\t\tfor (const call of calls) call.reject(error);\n\t}\n\n\t/** Sends a call that got its slot, with the next id. */\n\t#send(call: OutgoingCall): void {\n\t\tconst id = this.#nextCall++;\n\t\tcall.id = id;\n\t\tthis.#calls.set(id, call);\n\t\tconst { hold, method, args, segments } = call;\n\t\tthis.#link.send({\n\t\t\tkind: \"call\",\n\t\t\tcall: id,\n\t\t\thold,\n\t\t\tmethod,\n\t\t\t...(args === undefined ? {} : { args }),\n\t\t\t...(segments === undefined ? {} : { segments }),\n\t\t});\n\t}\n\n\t/**\n\t * Cancels `call`: a waiting one leaves the window and nothing is sent; one in flight sends `abort` and frees its\n\t * slot. Settling the caller is the caller's.\n\t */\n\t#cancel(call: OutgoingCall): void {\n\t\tif (call.id === undefined) {\n\t\t\tthis.#window.remove(call);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.#calls.delete(call.id)) return;\n\t\tthis.#link.send({ kind: \"abort\", call: call.id });\n\t\tthis.#window.freed();\n\t}\n\n\t/**\n\t * The deflated parts of this side's own holds in `entries` that wait for an asynchronous inflate, each with the\n\t * link's decoded limit; `undefined` when none does (nothing allocated). Entries of holds this side gave up are not\n\t * inflated (Q1).\n\t */\n\t#deflated(entries: readonly (BoundEntry | StateEntry)[]): [DeflatedPart, number][] | undefined {\n\t\tconst { limits } = this.#link;\n\t\tlet deflated: [DeflatedPart, number][] | undefined;\n\t\tfor (const entry of entries) {\n\t\t\tif (!this.#entries.has(entry.hold)) continue;\n\t\t\tfor (const member of entry.members) {\n\t\t\t\tconst part = \"value\" in member ? member.value : member.ops;\n\t\t\t\tif (!this.#link.inflates(part, limits)) continue;\n\t\t\t\tdeflated ??= [];\n\t\t\t\tdeflated.push([part, limits.decoded]);\n\t\t\t}\n\t\t}\n\t\treturn deflated;\n\t}\n\n\t/**\n\t * One `bound` message: every entry prepared first (one that does not fit closes the link before anything changed)\n\t * and applied in one batch; then the references go live, and the message is acknowledged. An entry with a part past\n\t * the link's limits fails only its hold (`too_large/part`); the others apply.\n\t */\n\t#bound(holds: readonly BoundEntry[]): void {\n\t\tconst adoptions: (() => void)[] = [];\n\t\tconst bound: RemoteObject[] = [];\n\t\tlet oversized: [RemoteObject, ChordError][] | undefined;\n\t\tfor (const entry of holds) {\n\t\t\tconst holder = this.#entries.get(entry.hold);\n\t\t\tif (holder === undefined) continue;\n\t\t\ttry {\n\t\t\t\tadoptions.push(holder.prepareBound(entry, this.#link));\n\t\t\t} catch (error) {\n\t\t\t\tif (!isChordError(error, \"too_large\")) throw error;\n\t\t\t\toversized ??= [];\n\t\t\t\toversized.push([holder, error]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbound.push(holder);\n\t\t}\n\t\tthis.#adopt(adoptions);\n\t\t// After the batch: the references go live with every replica of the message in place.\n\t\tfor (const holder of bound) holder.wentLive();\n\t\tfor (const [holder, error] of oversized ?? []) holder.tooLarge(error);\n\t\tthis.#link.send({ kind: \"ack\" });\n\t}\n\n\t/** One `state` message, as `#bound` does it. */\n\t#state(holds: readonly StateEntry[]): void {\n\t\tconst adoptions: (() => void)[] = [];\n\t\tlet oversized: [RemoteObject, ChordError][] | undefined;\n\t\tfor (const entry of holds) {\n\t\t\tconst holder = this.#entries.get(entry.hold);\n\t\t\tif (holder === undefined) continue;\n\t\t\ttry {\n\t\t\t\tadoptions.push(holder.prepare(entry, this.#link));\n\t\t\t} catch (error) {\n\t\t\t\tif (!isChordError(error, \"too_large\")) throw error;\n\t\t\t\toversized ??= [];\n\t\t\t\toversized.push([holder, error]);\n\t\t\t}\n\t\t}\n\t\tthis.#adopt(adoptions);\n\t\tfor (const [holder, error] of oversized ?? []) holder.tooLarge(error);\n\t\tthis.#link.send({ kind: \"ack\" });\n\t}\n\n\t/** Applies prepared entries in one batch of this host, so no watch or derive sees half a provider commit (W1). */\n\t#adopt(adoptions: readonly (() => void)[]): void {\n\t\tif (adoptions.length === 0) return;\n\t\tthis.#link.host.batch.commit(() => {\n\t\t\tfor (const adopt of adoptions) adopt();\n\t\t}, this.#link.context);\n\t}\n\n\t/**\n\t * `loading`: the hold's object, or its relay's upstream, starts over; its calls still waiting for a slot reject\n\t * `unavailable` (they may name a method of the old variant).\n\t */\n\t#loading(hold: number): void {\n\t\tconst holder = this.#entries.get(hold);\n\t\tif (holder === undefined) return;\n\t\tconst error = new ChordError({ code: \"unavailable\", message: `hold ${hold}: rebinding` });\n\t\tfor (const call of this.#window.removeHold(hold)) call.reject(error);\n\t\tholder.loading();\n\t}\n\n\t/**\n\t * `failed`: its holder fails; its calls still waiting for a slot reject with the cause (a bound hold is unbound by it,\n\t * slice 7b; its calls in flight are rejected by the provider).\n\t */\n\t#failed(message: Extract<Message, { readonly kind: \"failed\" }>): void {\n\t\tconst holder = this.#entries.get(message.hold);\n\t\tif (holder === undefined) return;\n\t\tconst error = asChordError(errorFromWire(message.cause.error), `hold ${message.hold}`);\n\t\tfor (const call of this.#window.removeHold(message.hold)) call.reject(error);\n\t\tholder.failed(message);\n\t}\n\n\t/**\n\t * `gone`: one for a hold this side gave up is ignored (Q1); the holder ends, which forgets its hold here and fails\n\t * its calls.\n\t */\n\t#gone(message: Extract<Message, { readonly kind: \"gone\" }>): void {\n\t\tconst holder = this.#entries.get(message.hold);\n\t\tif (holder === undefined) return;\n\t\tholder.lost(asChordError(errorFromWire(message.error), `hold ${message.hold}`));\n\t}\n\n\t/**\n\t * A reply: its call settles with the parsed result or the error. A result past the link's limits rejects the call\n\t * `too_large/part`. A malformed part rejects the call `unavailable` and throws (a protocol error: the link closes).\n\t * A result to inflate asynchronously is inflated first (for a call still waiting), then handled again.\n\t */\n\t#reply(reply: Reply): void | Promise<void> {\n\t\tconst call = this.#calls.get(reply.call);\n\t\tif (call === undefined) return;\n\t\tconst link = this.#link;\n\t\tif (reply.kind === \"result\" && link.inflates(reply.value, link.limits)) {\n\t\t\treturn link.inflate([[reply.value, link.limits.decoded]], () => this.#reply(reply));\n\t\t}\n\t\tthis.#calls.delete(reply.call);\n\t\tthis.#window.freed();\n\t\ttry {\n\t\t\tif (reply.kind === \"error\") call.reject(errorFromWire(reply.error));\n\t\t\telse if (reply.value === undefined) call.resolve(null);\n\t\t\telse call.resolve(parsePayload(link.openPart(reply.value, link.limits, link.context), reply.segments));\n\t\t} catch (error) {\n\t\t\tif (isChordError(error, \"too_large\")) {\n\t\t\t\tcall.reject(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcall.reject(new ChordError({ code: \"unavailable\", message: `call ${reply.call}: a malformed reply` }));\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Fails `hold`'s calls in flight and waiting with `error`; each in-flight one frees its slot. */\n\t#failCalls(hold: number, error: ChordError): void {\n\t\t// Waiting ones first: a freed slot must not send one of them.\n\t\tconst failed = this.#window.removeHold(hold);\n\t\tfor (const [id, call] of this.#calls) {\n\t\t\tif (call.hold !== hold) continue;\n\t\t\tthis.#calls.delete(id);\n\t\t\tthis.#window.freed();\n\t\t\tfailed.push(call);\n\t\t}\n\t\tfor (const call of failed) call.reject(error);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { Context } from "../../context/index.ts";
|
|
2
|
+
import { ChordError, type Principal } from "../data/index.ts";
|
|
3
|
+
import { type Caller, type Holder, type Removal, type UnboundRequest } from "../host/internal.ts";
|
|
4
|
+
import { type BoundEntry, type Limits, type Message, type StateEntry } from "../link/internal.ts";
|
|
5
|
+
import type { HostLink } from "./host-link.ts";
|
|
6
|
+
import type { ProviderSide } from "./provider.ts";
|
|
7
|
+
/** A `hold` message. */
|
|
8
|
+
type HoldMessage = Extract<Message, {
|
|
9
|
+
readonly kind: "hold";
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* What a `hold` message asks for. Whom it acts for is not part of it: a host takes that from the message once, as its
|
|
13
|
+
* link allows (`ProviderSide`), and names it again only on a route link (`actingFor`). Its `chain` and `limit` are the
|
|
14
|
+
* ones this host honours, sent on as they are when it relays the hold.
|
|
15
|
+
*/
|
|
16
|
+
export type HoldRequest = Omit<HoldMessage, "kind" | "origin" | "hold" | "principal" | "incarnation">;
|
|
17
|
+
/**
|
|
18
|
+
* One hold served here: a reference to its object acting as its caller (the hold's principal). While pending, each
|
|
19
|
+
* failure of its object is sent as `failed` (with the rest of its backoff window) and the next attempt as `loading`; a
|
|
20
|
+
* hold that cannot be taken holds nothing: `failed { waiting }` (not served, another version) until a publication
|
|
21
|
+
* re-runs its start, `failed { broken }` (invalid params, a cycle) until a `retry` does. Once live it binds when its
|
|
22
|
+
* link's window has a slot, then sends a part per batch that changed its members (or keeps their ops pending while the
|
|
23
|
+
* window is full), and `gone` when its object ends. It counts as one of the host's references from its arrival to its
|
|
24
|
+
* end, bound or not.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Hold implements Holder, UnboundRequest {
|
|
27
|
+
#private;
|
|
28
|
+
readonly kind = "served";
|
|
29
|
+
readonly id: number;
|
|
30
|
+
/** A hold is declared by no object on this host. */
|
|
31
|
+
readonly dependent: undefined;
|
|
32
|
+
/** Whom the hold acts for: its calls run as it, with its origin's incarnation. */
|
|
33
|
+
readonly caller: Caller;
|
|
34
|
+
/** The limits per part of its params and its calls' arguments: its link's, the decoded one smaller when stamped (Q2). */
|
|
35
|
+
readonly limits: Limits;
|
|
36
|
+
constructor(id: number, provider: ProviderSide, caller: Caller, limits: Limits);
|
|
37
|
+
/** Whether the hold is bound: its members' changes are sent. */
|
|
38
|
+
get bound(): boolean;
|
|
39
|
+
/** Whether calls on it reach its object: bound, or binding afresh after a swap in place (its `bound` not sent yet). */
|
|
40
|
+
get callable(): boolean;
|
|
41
|
+
/** Whom it acts for (the unbound index's revocation). */
|
|
42
|
+
get principal(): Principal | undefined;
|
|
43
|
+
/** Its consumer's contract version and fingerprint (its request's): the provider binds them or it waits. */
|
|
44
|
+
get contract(): HoldRequest;
|
|
45
|
+
/** Whether the hold holds no object: before the publication, or refused (revocation ends it, §4). */
|
|
46
|
+
get unbound(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Admits the hold: before the host's publication it waits in the unbound index, placed by the publication.
|
|
49
|
+
* Then its params within the link's part limit (`too_large/part`), then relayed (it is replaced by a relayed hold),
|
|
50
|
+
* or served here, its params opened and parsed (a malformed part is a protocol error), its object taken and followed
|
|
51
|
+
* (`moved`) in the turn it arrived. A hold that cannot be served here waits refused (`#refuse`).
|
|
52
|
+
*/
|
|
53
|
+
start(request: HoldRequest): void;
|
|
54
|
+
/**
|
|
55
|
+
* Woken by the unbound index (out of it already): before the publication, placed now; refused `waiting`, its start
|
|
56
|
+
* runs again, announced with `loading` (then `bound` or `failed`).
|
|
57
|
+
*/
|
|
58
|
+
wake(): void;
|
|
59
|
+
/**
|
|
60
|
+
* The object's state changed, or the hold took it: a pending hold binds once it is live (when a slot is free),
|
|
61
|
+
* sends each failure, and announces the attempt after a failure with `loading`. A bound hold (or one whose `bound`
|
|
62
|
+
* waits for a slot) whose object leaves `live` goes back to pending (slice 7b §6), except while a reload's swap runs
|
|
63
|
+
* in place; a bound one whose object went live with another attempt (a swap) gets a fresh `bound` (audit A9).
|
|
64
|
+
*/
|
|
65
|
+
moved(): void;
|
|
66
|
+
/**
|
|
67
|
+
* A `retry` message with `hops` left of its budget: the object is asked for an attempt now (it ignores this unless
|
|
68
|
+
* failed; parked, it passes it on, to other hosts with one hop less); a refused hold is started again (a route's
|
|
69
|
+
* `authorize` may admit it now).
|
|
70
|
+
*/
|
|
71
|
+
retry({ hops }: Extract<Message, {
|
|
72
|
+
readonly kind: "retry";
|
|
73
|
+
}>): void;
|
|
74
|
+
/** Calls a method of the held object as the hold's caller. */
|
|
75
|
+
call(method: string, args: unknown, context: Context): Promise<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* The method at `index` of the bound variant and whether its result carries byte segments (its schema has a
|
|
78
|
+
* `bytes()` leaf). Throws on an index outside the variant (a protocol error); a hold that is not bound has none.
|
|
79
|
+
*/
|
|
80
|
+
method(index: number): {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly resultBytes: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The hold's binding, sent when a slot is free. The snapshot of every member, as a value or failed, and the
|
|
86
|
+
* subscription are taken in this synchronous step (race 2), so each member's next ops continue exactly from it.
|
|
87
|
+
* Names travel as indexes into the bound version (2b). Counts one encode (`chord.link.encodes`).
|
|
88
|
+
*/
|
|
89
|
+
boundEntry(context: Context): BoundEntry;
|
|
90
|
+
/**
|
|
91
|
+
* This batch's entry of the `state` message: the members it changed with their ops, each encoded once with its
|
|
92
|
+
* member's encoder, and the members that failed; resets both. Counts one encode per hold (`chord.link.encodes`).
|
|
93
|
+
*/
|
|
94
|
+
entry(context: Context): StateEntry;
|
|
95
|
+
/** The window is full: this batch's ops join the members' pending queues (raw, never mutated). */
|
|
96
|
+
queue(): void;
|
|
97
|
+
/**
|
|
98
|
+
* The entry of a freed slot's `state` message: each member's pending ops encoded once, or `[["r", value]]` after an
|
|
99
|
+
* overflow, all reflecting the latest commit; and the members that failed meanwhile. Counts one encode per hold.
|
|
100
|
+
*/
|
|
101
|
+
pendingEntry(context: Context): StateEntry;
|
|
102
|
+
/** The consumer released the hold, or its link closed: its waits stop and its object loses this reference. */
|
|
103
|
+
release(): void;
|
|
104
|
+
/** Ends the hold without releasing its object (the host closes and ends its objects itself). */
|
|
105
|
+
drop(): void;
|
|
106
|
+
/**
|
|
107
|
+
* The object ended while held (revocation; a reload, slice 7b), or the hold was revoked (or its host closed) while it
|
|
108
|
+
* held no object: the hold sends `gone` with `error`.
|
|
109
|
+
*/
|
|
110
|
+
end(error: ChordError): void;
|
|
111
|
+
/** A hold over a link follows its object's instances in `moved` (a fresh `bound` for a new one). */
|
|
112
|
+
retarget(): void;
|
|
113
|
+
/** It moves nothing in `retarget`. */
|
|
114
|
+
readonly following = false;
|
|
115
|
+
/**
|
|
116
|
+
* Its object left it (slice 7b §6): its type was removed (`not_served`) or its provider no longer binds the hold's
|
|
117
|
+
* version (`version`): no longer subscribed, its calls in flight rejected, it waits refused with `removal.cause` in
|
|
118
|
+
* the host's index (a publication starts it again) and the consumer is sent `failed`, which unbinds a bound hold.
|
|
119
|
+
*/
|
|
120
|
+
removed(removal: Removal): void;
|
|
121
|
+
}
|
|
122
|
+
/** A `hold` message's fields naming whom it acts for. */
|
|
123
|
+
type ActingFor = Pick<HoldMessage, "principal" | "incarnation">;
|
|
124
|
+
/**
|
|
125
|
+
* The fields of a `hold` message naming whom it acts for (`caller`): sent only on a route link, whose child honours
|
|
126
|
+
* them (§4); none elsewhere.
|
|
127
|
+
*/
|
|
128
|
+
export declare function actingFor(link: HostLink, { principal, incarnation }: Caller): ActingFor;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=hold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hold.d.ts","sourceRoot":"","sources":["../../../src/next/remote/hold.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAItD,OAAO,EAAE,UAAU,EAAmC,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EACN,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,OAAO,EAGZ,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,UAAU,EAGf,KAAK,MAAM,EACX,KAAK,OAAO,EAIZ,KAAK,UAAU,EAEf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,wBAAwB;AACxB,KAAK,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,CAAC;AAwDtG;;;;;;;;GAQG;AACH,qBAAa,IAAK,YAAW,MAAM,EAAE,cAAc;;IAClD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,QAAQ,CAAC,SAAS,YAAa;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yHAAyH;IAC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