@earendil-works/chord 1.4.0 → 1.5.1
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 +92 -0
- package/README.md +115 -90
- 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/contracts/accepts.d.ts +81 -0
- package/dist/contracts/accepts.d.ts.map +1 -0
- package/dist/contracts/accepts.js +123 -0
- package/dist/contracts/accepts.js.map +1 -0
- package/dist/contracts/contract.d.ts +121 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +50 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/declare.d.ts +107 -0
- package/dist/contracts/declare.d.ts.map +1 -0
- package/dist/contracts/declare.js +136 -0
- package/dist/contracts/declare.js.map +1 -0
- package/dist/contracts/evolve.d.ts +92 -0
- package/dist/contracts/evolve.d.ts.map +1 -0
- package/dist/contracts/evolve.js +179 -0
- package/dist/contracts/evolve.js.map +1 -0
- package/dist/contracts/fingerprint.d.ts +16 -0
- package/dist/contracts/fingerprint.d.ts.map +1 -0
- package/dist/contracts/fingerprint.js +50 -0
- package/dist/contracts/fingerprint.js.map +1 -0
- package/dist/contracts/history.d.ts +71 -0
- package/dist/contracts/history.d.ts.map +1 -0
- package/dist/contracts/history.js +3 -0
- package/dist/contracts/history.js.map +1 -0
- package/dist/contracts/host-kind.d.ts +40 -0
- package/dist/contracts/host-kind.d.ts.map +1 -0
- package/dist/contracts/host-kind.js +37 -0
- package/dist/contracts/host-kind.js.map +1 -0
- package/dist/contracts/index.d.ts +7 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +6 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/internal.d.ts +10 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/internal.js +9 -0
- package/dist/contracts/internal.js.map +1 -0
- package/dist/contracts/names.d.ts +3 -0
- package/dist/contracts/names.d.ts.map +1 -0
- package/dist/contracts/names.js +13 -0
- package/dist/contracts/names.js.map +1 -0
- package/dist/contracts/params.d.ts +28 -0
- package/dist/contracts/params.d.ts.map +1 -0
- package/dist/contracts/params.js +50 -0
- package/dist/contracts/params.js.map +1 -0
- package/dist/contracts/schema.d.ts +102 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +103 -0
- package/dist/contracts/schema.js.map +1 -0
- package/dist/contracts/snapshot.d.ts +16 -0
- package/dist/contracts/snapshot.d.ts.map +1 -0
- package/dist/contracts/snapshot.js +167 -0
- package/dist/contracts/snapshot.js.map +1 -0
- package/dist/data/args.d.ts +50 -0
- package/dist/data/args.d.ts.map +1 -0
- package/dist/data/args.js +83 -0
- package/dist/data/args.js.map +1 -0
- package/dist/data/errors.d.ts +80 -0
- package/dist/data/errors.d.ts.map +1 -0
- package/dist/data/errors.js +116 -0
- package/dist/data/errors.js.map +1 -0
- package/dist/data/failure.d.ts +26 -0
- package/dist/data/failure.d.ts.map +1 -0
- package/dist/data/failure.js +77 -0
- package/dist/data/failure.js.map +1 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +5 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/internal.d.ts +7 -0
- package/dist/data/internal.d.ts.map +1 -0
- package/dist/data/internal.js +8 -0
- package/dist/data/internal.js.map +1 -0
- package/dist/data/params.d.ts +20 -0
- package/dist/data/params.d.ts.map +1 -0
- package/dist/data/params.js +31 -0
- package/dist/data/params.js.map +1 -0
- package/dist/data/principal.d.ts +22 -0
- package/dist/data/principal.d.ts.map +1 -0
- package/dist/data/principal.js +49 -0
- package/dist/data/principal.js.map +1 -0
- package/dist/data/validator.d.ts +12 -0
- package/dist/data/validator.d.ts.map +1 -0
- package/dist/data/validator.js +35 -0
- package/dist/data/validator.js.map +1 -0
- 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/documents/address-source.d.ts +20 -0
- package/dist/documents/address-source.d.ts.map +1 -0
- package/dist/documents/address-source.js +44 -0
- package/dist/documents/address-source.js.map +1 -0
- package/dist/documents/definition.d.ts +84 -0
- package/dist/documents/definition.d.ts.map +1 -0
- package/dist/documents/definition.js +74 -0
- package/dist/documents/definition.js.map +1 -0
- package/dist/documents/documents.d.ts +126 -0
- package/dist/documents/documents.d.ts.map +1 -0
- package/dist/documents/documents.js +248 -0
- package/dist/documents/documents.js.map +1 -0
- package/dist/documents/fence.d.ts +9 -0
- package/dist/documents/fence.d.ts.map +1 -0
- package/dist/documents/fence.js +15 -0
- package/dist/documents/fence.js.map +1 -0
- package/dist/documents/handles.d.ts +76 -0
- package/dist/documents/handles.d.ts.map +1 -0
- package/dist/documents/handles.js +66 -0
- package/dist/documents/handles.js.map +1 -0
- package/dist/documents/index.d.ts +4 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +3 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/internal.d.ts +9 -0
- package/dist/documents/internal.d.ts.map +1 -0
- package/dist/documents/internal.js +9 -0
- package/dist/documents/internal.js.map +1 -0
- package/dist/documents/keyed-slot.d.ts +103 -0
- package/dist/documents/keyed-slot.d.ts.map +1 -0
- package/dist/documents/keyed-slot.js +395 -0
- package/dist/documents/keyed-slot.js.map +1 -0
- package/dist/documents/line.d.ts +7 -0
- package/dist/documents/line.d.ts.map +1 -0
- package/dist/documents/line.js +14 -0
- package/dist/documents/line.js.map +1 -0
- package/dist/documents/persistence.d.ts +104 -0
- package/dist/documents/persistence.d.ts.map +1 -0
- package/dist/documents/persistence.js +129 -0
- package/dist/documents/persistence.js.map +1 -0
- package/dist/documents/residency.d.ts +31 -0
- package/dist/documents/residency.d.ts.map +1 -0
- package/dist/documents/residency.js +93 -0
- package/dist/documents/residency.js.map +1 -0
- package/dist/documents/slot.d.ts +109 -0
- package/dist/documents/slot.d.ts.map +1 -0
- package/dist/documents/slot.js +181 -0
- package/dist/documents/slot.js.map +1 -0
- package/dist/documents/transaction.d.ts +143 -0
- package/dist/documents/transaction.d.ts.map +1 -0
- package/dist/documents/transaction.js +442 -0
- package/dist/documents/transaction.js.map +1 -0
- package/dist/host/activity.d.ts +31 -0
- package/dist/host/activity.d.ts.map +1 -0
- package/dist/host/activity.js +40 -0
- package/dist/host/activity.js.map +1 -0
- package/dist/host/adapted.d.ts +49 -0
- package/dist/host/adapted.d.ts.map +1 -0
- package/dist/host/adapted.js +214 -0
- package/dist/host/adapted.js.map +1 -0
- package/dist/host/attempt.d.ts +308 -0
- package/dist/host/attempt.d.ts.map +1 -0
- package/dist/host/attempt.js +1199 -0
- package/dist/host/attempt.js.map +1 -0
- package/dist/host/backoff.d.ts +29 -0
- package/dist/host/backoff.d.ts.map +1 -0
- package/dist/host/backoff.js +69 -0
- package/dist/host/backoff.js.map +1 -0
- package/dist/host/ctx.d.ts +94 -0
- package/dist/host/ctx.d.ts.map +1 -0
- package/dist/host/ctx.js +200 -0
- package/dist/host/ctx.js.map +1 -0
- package/dist/host/deadline.d.ts +12 -0
- package/dist/host/deadline.d.ts.map +1 -0
- package/dist/host/deadline.js +40 -0
- package/dist/host/deadline.js.map +1 -0
- package/dist/host/dependencies.d.ts +65 -0
- package/dist/host/dependencies.d.ts.map +1 -0
- package/dist/host/dependencies.js +115 -0
- package/dist/host/dependencies.js.map +1 -0
- package/dist/host/destination.d.ts +48 -0
- package/dist/host/destination.d.ts.map +1 -0
- package/dist/host/destination.js +101 -0
- package/dist/host/destination.js.map +1 -0
- package/dist/host/facet.d.ts +84 -0
- package/dist/host/facet.d.ts.map +1 -0
- package/dist/host/facet.js +55 -0
- package/dist/host/facet.js.map +1 -0
- package/dist/host/follow.d.ts +52 -0
- package/dist/host/follow.d.ts.map +1 -0
- package/dist/host/follow.js +207 -0
- package/dist/host/follow.js.map +1 -0
- package/dist/host/host.d.ts +571 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +1318 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +17 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +6 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/internal.d.ts +11 -0
- package/dist/host/internal.d.ts.map +1 -0
- package/dist/host/internal.js +9 -0
- package/dist/host/internal.js.map +1 -0
- package/dist/host/members.d.ts +50 -0
- package/dist/host/members.d.ts.map +1 -0
- package/dist/host/members.js +107 -0
- package/dist/host/members.js.map +1 -0
- package/dist/host/native.d.ts +64 -0
- package/dist/host/native.d.ts.map +1 -0
- package/dist/host/native.js +126 -0
- package/dist/host/native.js.map +1 -0
- package/dist/host/object.d.ts +331 -0
- package/dist/host/object.d.ts.map +1 -0
- package/dist/host/object.js +1296 -0
- package/dist/host/object.js.map +1 -0
- package/dist/host/old-work.d.ts +34 -0
- package/dist/host/old-work.d.ts.map +1 -0
- package/dist/host/old-work.js +52 -0
- package/dist/host/old-work.js.map +1 -0
- package/dist/host/parked.d.ts +23 -0
- package/dist/host/parked.d.ts.map +1 -0
- package/dist/host/parked.js +79 -0
- package/dist/host/parked.js.map +1 -0
- package/dist/host/presence.d.ts +34 -0
- package/dist/host/presence.d.ts.map +1 -0
- package/dist/host/presence.js +117 -0
- package/dist/host/presence.js.map +1 -0
- package/dist/host/readiness.d.ts +27 -0
- package/dist/host/readiness.d.ts.map +1 -0
- package/dist/host/readiness.js +134 -0
- package/dist/host/readiness.js.map +1 -0
- package/dist/host/ref-state.d.ts +53 -0
- package/dist/host/ref-state.d.ts.map +1 -0
- package/dist/host/ref-state.js +83 -0
- package/dist/host/ref-state.js.map +1 -0
- package/dist/host/reference-keys.d.ts +36 -0
- package/dist/host/reference-keys.d.ts.map +1 -0
- package/dist/host/reference-keys.js +168 -0
- package/dist/host/reference-keys.js.map +1 -0
- package/dist/host/reference-source.d.ts +65 -0
- package/dist/host/reference-source.d.ts.map +1 -0
- package/dist/host/reference-source.js +285 -0
- package/dist/host/reference-source.js.map +1 -0
- package/dist/host/reference.d.ts +321 -0
- package/dist/host/reference.d.ts.map +1 -0
- package/dist/host/reference.js +797 -0
- package/dist/host/reference.js.map +1 -0
- package/dist/host/reload-cycle.d.ts +16 -0
- package/dist/host/reload-cycle.d.ts.map +1 -0
- package/dist/host/reload-cycle.js +81 -0
- package/dist/host/reload-cycle.js.map +1 -0
- package/dist/host/retry-on.d.ts +28 -0
- package/dist/host/retry-on.d.ts.map +1 -0
- package/dist/host/retry-on.js +52 -0
- package/dist/host/retry-on.js.map +1 -0
- package/dist/host/revocation.d.ts +16 -0
- package/dist/host/revocation.d.ts.map +1 -0
- package/dist/host/revocation.js +27 -0
- package/dist/host/revocation.js.map +1 -0
- package/dist/host/root.d.ts +37 -0
- package/dist/host/root.d.ts.map +1 -0
- package/dist/host/root.js +68 -0
- package/dist/host/root.js.map +1 -0
- package/dist/host/route.d.ts +64 -0
- package/dist/host/route.d.ts.map +1 -0
- package/dist/host/route.js +227 -0
- package/dist/host/route.js.map +1 -0
- package/dist/host/routines.d.ts +78 -0
- package/dist/host/routines.d.ts.map +1 -0
- package/dist/host/routines.js +398 -0
- package/dist/host/routines.js.map +1 -0
- package/dist/host/sleep.d.ts +9 -0
- package/dist/host/sleep.d.ts.map +1 -0
- package/dist/host/sleep.js +40 -0
- package/dist/host/sleep.js.map +1 -0
- package/dist/host/staging.d.ts +94 -0
- package/dist/host/staging.d.ts.map +1 -0
- package/dist/host/staging.js +304 -0
- package/dist/host/staging.js.map +1 -0
- package/dist/host/unbound-clock.d.ts +23 -0
- package/dist/host/unbound-clock.d.ts.map +1 -0
- package/dist/host/unbound-clock.js +58 -0
- package/dist/host/unbound-clock.js.map +1 -0
- package/dist/host/unbound.d.ts +37 -0
- package/dist/host/unbound.d.ts.map +1 -0
- package/dist/host/unbound.js +88 -0
- package/dist/host/unbound.js.map +1 -0
- package/dist/host/uuid.d.ts +3 -0
- package/dist/host/uuid.d.ts.map +1 -0
- package/dist/host/uuid.js +38 -0
- package/dist/host/uuid.js.map +1 -0
- package/dist/index.d.ts +29 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/jobs/definition.d.ts +96 -0
- package/dist/jobs/definition.d.ts.map +1 -0
- package/dist/jobs/definition.js +83 -0
- package/dist/jobs/definition.js.map +1 -0
- package/dist/jobs/index.d.ts +5 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +3 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/internal.d.ts +3 -0
- package/dist/jobs/internal.d.ts.map +1 -0
- package/dist/jobs/internal.js +4 -0
- package/dist/jobs/internal.js.map +1 -0
- package/dist/jobs/job.d.ts +149 -0
- package/dist/jobs/job.d.ts.map +1 -0
- package/dist/jobs/job.js +387 -0
- package/dist/jobs/job.js.map +1 -0
- package/dist/jobs/persisted.d.ts +38 -0
- package/dist/jobs/persisted.d.ts.map +1 -0
- package/dist/jobs/persisted.js +95 -0
- package/dist/jobs/persisted.js.map +1 -0
- package/dist/jobs/records.d.ts +231 -0
- package/dist/jobs/records.d.ts.map +1 -0
- package/dist/jobs/records.js +871 -0
- package/dist/jobs/records.js.map +1 -0
- package/dist/jobs/run-states.d.ts +69 -0
- package/dist/jobs/run-states.d.ts.map +1 -0
- package/dist/jobs/run-states.js +228 -0
- package/dist/jobs/run-states.js.map +1 -0
- package/dist/jobs/run.d.ts +117 -0
- package/dist/jobs/run.d.ts.map +1 -0
- package/dist/jobs/run.js +204 -0
- package/dist/jobs/run.js.map +1 -0
- package/dist/jobs/running.d.ts +44 -0
- package/dist/jobs/running.d.ts.map +1 -0
- package/dist/jobs/running.js +117 -0
- package/dist/jobs/running.js.map +1 -0
- package/dist/jobs/stored.d.ts +63 -0
- package/dist/jobs/stored.d.ts.map +1 -0
- package/dist/jobs/stored.js +55 -0
- package/dist/jobs/stored.js.map +1 -0
- package/dist/link/binary.d.ts +4 -0
- package/dist/link/binary.d.ts.map +1 -0
- package/dist/link/binary.js +544 -0
- package/dist/link/binary.js.map +1 -0
- package/dist/link/channel.d.ts +68 -0
- package/dist/link/channel.d.ts.map +1 -0
- package/dist/link/channel.js +215 -0
- package/dist/link/channel.js.map +1 -0
- package/dist/link/errors.d.ts +7 -0
- package/dist/link/errors.d.ts.map +1 -0
- package/dist/link/errors.js +21 -0
- package/dist/link/errors.js.map +1 -0
- package/dist/link/index.d.ts +8 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +8 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/internal.d.ts +9 -0
- package/dist/link/internal.d.ts.map +1 -0
- package/dist/link/internal.js +10 -0
- package/dist/link/internal.js.map +1 -0
- package/dist/link/ipc.d.ts +22 -0
- package/dist/link/ipc.d.ts.map +1 -0
- package/dist/link/ipc.js +64 -0
- package/dist/link/ipc.js.map +1 -0
- package/dist/link/link.d.ts +34 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +87 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/message.d.ts +262 -0
- package/dist/link/message.d.ts.map +1 -0
- package/dist/link/message.js +156 -0
- package/dist/link/message.js.map +1 -0
- package/dist/link/part.d.ts +80 -0
- package/dist/link/part.d.ts.map +1 -0
- package/dist/link/part.js +165 -0
- package/dist/link/part.js.map +1 -0
- package/dist/link/text.d.ts +6 -0
- package/dist/link/text.d.ts.map +1 -0
- package/dist/link/text.js +355 -0
- package/dist/link/text.js.map +1 -0
- package/dist/link/values.d.ts +40 -0
- package/dist/link/values.d.ts.map +1 -0
- package/dist/link/values.js +121 -0
- package/dist/link/values.js.map +1 -0
- package/dist/link/websocket.d.ts +26 -0
- package/dist/link/websocket.d.ts.map +1 -0
- package/dist/link/websocket.js +91 -0
- package/dist/link/websocket.js.map +1 -0
- package/dist/node/app/app.d.ts +269 -0
- package/dist/node/app/app.d.ts.map +1 -0
- package/dist/node/app/app.js +513 -0
- package/dist/node/app/app.js.map +1 -0
- package/dist/node/app/archive.d.ts +37 -0
- package/dist/node/app/archive.d.ts.map +1 -0
- package/dist/node/app/archive.js +204 -0
- package/dist/node/app/archive.js.map +1 -0
- package/dist/node/app/blobs.d.ts +23 -0
- package/dist/node/app/blobs.d.ts.map +1 -0
- package/dist/node/app/blobs.js +64 -0
- package/dist/node/app/blobs.js.map +1 -0
- package/dist/node/app/data.d.ts +35 -0
- package/dist/node/app/data.d.ts.map +1 -0
- package/dist/node/app/data.js +44 -0
- package/dist/node/app/data.js.map +1 -0
- package/dist/node/app/ephemeral-sessions.d.ts +20 -0
- package/dist/node/app/ephemeral-sessions.d.ts.map +1 -0
- package/dist/node/app/ephemeral-sessions.js +69 -0
- package/dist/node/app/ephemeral-sessions.js.map +1 -0
- package/dist/node/app/ephemeral.d.ts +11 -0
- package/dist/node/app/ephemeral.d.ts.map +1 -0
- package/dist/node/app/ephemeral.js +34 -0
- package/dist/node/app/ephemeral.js.map +1 -0
- package/dist/node/app/files-copy.d.ts +13 -0
- package/dist/node/app/files-copy.d.ts.map +1 -0
- package/dist/node/app/files-copy.js +86 -0
- package/dist/node/app/files-copy.js.map +1 -0
- package/dist/node/app/files-entry.d.ts +4 -0
- package/dist/node/app/files-entry.d.ts.map +1 -0
- package/dist/node/app/files-entry.js +7 -0
- package/dist/node/app/files-entry.js.map +1 -0
- package/dist/node/app/files-index.d.ts +180 -0
- package/dist/node/app/files-index.d.ts.map +1 -0
- package/dist/node/app/files-index.js +535 -0
- package/dist/node/app/files-index.js.map +1 -0
- package/dist/node/app/files.d.ts +363 -0
- package/dist/node/app/files.d.ts.map +1 -0
- package/dist/node/app/files.js +368 -0
- package/dist/node/app/files.js.map +1 -0
- package/dist/node/app/folder-views.d.ts +21 -0
- package/dist/node/app/folder-views.d.ts.map +1 -0
- package/dist/node/app/folder-views.js +55 -0
- package/dist/node/app/folder-views.js.map +1 -0
- package/dist/node/app/index.d.ts +12 -0
- package/dist/node/app/index.d.ts.map +1 -0
- package/dist/node/app/index.js +15 -0
- package/dist/node/app/index.js.map +1 -0
- package/dist/node/app/info.d.ts +66 -0
- package/dist/node/app/info.d.ts.map +1 -0
- package/dist/node/app/info.js +37 -0
- package/dist/node/app/info.js.map +1 -0
- package/dist/node/app/invite.d.ts +5 -0
- package/dist/node/app/invite.d.ts.map +1 -0
- package/dist/node/app/invite.js +64 -0
- package/dist/node/app/invite.js.map +1 -0
- package/dist/node/app/layout.d.ts +36 -0
- package/dist/node/app/layout.d.ts.map +1 -0
- package/dist/node/app/layout.js +87 -0
- package/dist/node/app/layout.js.map +1 -0
- package/dist/node/app/owner.d.ts +31 -0
- package/dist/node/app/owner.d.ts.map +1 -0
- package/dist/node/app/owner.js +104 -0
- package/dist/node/app/owner.js.map +1 -0
- package/dist/node/app/pairing.d.ts +55 -0
- package/dist/node/app/pairing.d.ts.map +1 -0
- package/dist/node/app/pairing.js +183 -0
- package/dist/node/app/pairing.js.map +1 -0
- package/dist/node/app/secrets.d.ts +16 -0
- package/dist/node/app/secrets.d.ts.map +1 -0
- package/dist/node/app/secrets.js +72 -0
- package/dist/node/app/secrets.js.map +1 -0
- package/dist/node/app/sessions.d.ts +72 -0
- package/dist/node/app/sessions.d.ts.map +1 -0
- package/dist/node/app/sessions.js +222 -0
- package/dist/node/app/sessions.js.map +1 -0
- package/dist/node/app/tar.d.ts +24 -0
- package/dist/node/app/tar.d.ts.map +1 -0
- package/dist/node/app/tar.js +167 -0
- package/dist/node/app/tar.js.map +1 -0
- package/dist/node/app/uploads.d.ts +37 -0
- package/dist/node/app/uploads.d.ts.map +1 -0
- package/dist/node/app/uploads.js +157 -0
- package/dist/node/app/uploads.js.map +1 -0
- package/dist/node/app/users.d.ts +37 -0
- package/dist/node/app/users.d.ts.map +1 -0
- package/dist/node/app/users.js +62 -0
- package/dist/node/app/users.js.map +1 -0
- package/dist/node/app/worker.d.ts +18 -0
- package/dist/node/app/worker.d.ts.map +1 -0
- package/dist/node/app/worker.js +84 -0
- package/dist/node/app/worker.js.map +1 -0
- package/dist/node/compression.d.ts +7 -0
- package/dist/node/compression.d.ts.map +1 -0
- package/dist/node/compression.js +25 -0
- package/dist/node/compression.js.map +1 -0
- package/dist/node/http/admission.d.ts +63 -0
- package/dist/node/http/admission.d.ts.map +1 -0
- package/dist/node/http/admission.js +134 -0
- package/dist/node/http/admission.js.map +1 -0
- package/dist/node/http/authenticate.d.ts +21 -0
- package/dist/node/http/authenticate.d.ts.map +1 -0
- package/dist/node/http/authenticate.js +34 -0
- package/dist/node/http/authenticate.js.map +1 -0
- package/dist/node/http/cookies.d.ts +32 -0
- package/dist/node/http/cookies.d.ts.map +1 -0
- package/dist/node/http/cookies.js +70 -0
- package/dist/node/http/cookies.js.map +1 -0
- package/dist/node/http/file.d.ts +23 -0
- package/dist/node/http/file.d.ts.map +1 -0
- package/dist/node/http/file.js +94 -0
- package/dist/node/http/file.js.map +1 -0
- package/dist/node/http/headers.d.ts +37 -0
- package/dist/node/http/headers.d.ts.map +1 -0
- package/dist/node/http/headers.js +136 -0
- package/dist/node/http/headers.js.map +1 -0
- package/dist/node/http/http.d.ts +111 -0
- package/dist/node/http/http.d.ts.map +1 -0
- package/dist/node/http/http.js +524 -0
- package/dist/node/http/http.js.map +1 -0
- package/dist/node/http/incoming.d.ts +19 -0
- package/dist/node/http/incoming.d.ts.map +1 -0
- package/dist/node/http/incoming.js +31 -0
- package/dist/node/http/incoming.js.map +1 -0
- package/dist/node/http/index.d.ts +11 -0
- package/dist/node/http/index.d.ts.map +1 -0
- package/dist/node/http/index.js +12 -0
- package/dist/node/http/index.js.map +1 -0
- package/dist/node/http/node.d.ts +78 -0
- package/dist/node/http/node.d.ts.map +1 -0
- package/dist/node/http/node.js +291 -0
- package/dist/node/http/node.js.map +1 -0
- package/dist/node/http/request.d.ts +60 -0
- package/dist/node/http/request.d.ts.map +1 -0
- package/dist/node/http/request.js +118 -0
- package/dist/node/http/request.js.map +1 -0
- package/dist/node/http/response.d.ts +63 -0
- package/dist/node/http/response.d.ts.map +1 -0
- package/dist/node/http/response.js +202 -0
- package/dist/node/http/response.js.map +1 -0
- package/dist/node/http/router.d.ts +132 -0
- package/dist/node/http/router.d.ts.map +1 -0
- package/dist/node/http/router.js +267 -0
- package/dist/node/http/router.js.map +1 -0
- package/dist/node/http/upgrades.d.ts +61 -0
- package/dist/node/http/upgrades.d.ts.map +1 -0
- package/dist/node/http/upgrades.js +192 -0
- package/dist/node/http/upgrades.js.map +1 -0
- package/dist/node/plugins/base-inputs.d.ts +14 -0
- package/dist/node/plugins/base-inputs.d.ts.map +1 -0
- package/dist/node/plugins/base-inputs.js +33 -0
- package/dist/node/plugins/base-inputs.js.map +1 -0
- package/dist/node/plugins/build.d.ts +77 -0
- package/dist/node/plugins/build.d.ts.map +1 -0
- package/dist/node/plugins/build.js +576 -0
- package/dist/node/plugins/build.js.map +1 -0
- package/dist/node/plugins/css-modules.d.ts +13 -0
- package/dist/node/plugins/css-modules.d.ts.map +1 -0
- package/dist/node/plugins/css-modules.js +58 -0
- package/dist/node/plugins/css-modules.js.map +1 -0
- package/dist/node/plugins/discover.d.ts +67 -0
- package/dist/node/plugins/discover.d.ts.map +1 -0
- package/dist/node/plugins/discover.js +369 -0
- package/dist/node/plugins/discover.js.map +1 -0
- package/dist/node/plugins/evaluate.d.ts +33 -0
- package/dist/node/plugins/evaluate.d.ts.map +1 -0
- package/dist/node/plugins/evaluate.js +121 -0
- package/dist/node/plugins/evaluate.js.map +1 -0
- package/dist/node/plugins/index.d.ts +11 -0
- package/dist/node/plugins/index.d.ts.map +1 -0
- package/dist/node/plugins/index.js +13 -0
- package/dist/node/plugins/index.js.map +1 -0
- package/dist/node/plugins/install.d.ts +38 -0
- package/dist/node/plugins/install.d.ts.map +1 -0
- package/dist/node/plugins/install.js +213 -0
- package/dist/node/plugins/install.js.map +1 -0
- package/dist/node/plugins/plugins.d.ts +162 -0
- package/dist/node/plugins/plugins.d.ts.map +1 -0
- package/dist/node/plugins/plugins.js +244 -0
- package/dist/node/plugins/plugins.js.map +1 -0
- package/dist/node/plugins/runtime.d.ts +57 -0
- package/dist/node/plugins/runtime.d.ts.map +1 -0
- package/dist/node/plugins/runtime.js +92 -0
- package/dist/node/plugins/runtime.js.map +1 -0
- package/dist/node/plugins/stack.d.ts +16 -0
- package/dist/node/plugins/stack.d.ts.map +1 -0
- package/dist/node/plugins/stack.js +61 -0
- package/dist/node/plugins/stack.js.map +1 -0
- package/dist/node/plugins/testing.d.ts +58 -0
- package/dist/node/plugins/testing.d.ts.map +1 -0
- package/dist/node/plugins/testing.js +210 -0
- package/dist/node/plugins/testing.js.map +1 -0
- package/dist/node/plugins/watcher.d.ts +69 -0
- package/dist/node/plugins/watcher.d.ts.map +1 -0
- package/dist/node/plugins/watcher.js +622 -0
- package/dist/node/plugins/watcher.js.map +1 -0
- package/dist/node/surfaces/bundle.d.ts +31 -0
- package/dist/node/surfaces/bundle.d.ts.map +1 -0
- package/dist/node/surfaces/bundle.js +118 -0
- package/dist/node/surfaces/bundle.js.map +1 -0
- package/dist/node/surfaces/current.d.ts +17 -0
- package/dist/node/surfaces/current.d.ts.map +1 -0
- package/dist/node/surfaces/current.js +54 -0
- package/dist/node/surfaces/current.js.map +1 -0
- package/dist/node/surfaces/index.d.ts +6 -0
- package/dist/node/surfaces/index.d.ts.map +1 -0
- package/dist/node/surfaces/index.js +6 -0
- package/dist/node/surfaces/index.js.map +1 -0
- package/dist/node/surfaces/published.d.ts +27 -0
- package/dist/node/surfaces/published.d.ts.map +1 -0
- package/dist/node/surfaces/published.js +142 -0
- package/dist/node/surfaces/published.js.map +1 -0
- package/dist/node/surfaces/served.d.ts +15 -0
- package/dist/node/surfaces/served.d.ts.map +1 -0
- package/dist/node/surfaces/served.js +42 -0
- package/dist/node/surfaces/served.js.map +1 -0
- package/dist/node/surfaces/surface-build.d.ts +53 -0
- package/dist/node/surfaces/surface-build.d.ts.map +1 -0
- package/dist/node/surfaces/surface-build.js +105 -0
- package/dist/node/surfaces/surface-build.js.map +1 -0
- package/dist/node/surfaces/tui.d.ts +40 -0
- package/dist/node/surfaces/tui.d.ts.map +1 -0
- package/dist/node/surfaces/tui.js +55 -0
- package/dist/node/surfaces/tui.js.map +1 -0
- package/dist/node/surfaces/web.d.ts +56 -0
- package/dist/node/surfaces/web.d.ts.map +1 -0
- package/dist/node/surfaces/web.js +108 -0
- package/dist/node/surfaces/web.js.map +1 -0
- package/dist/node/tui/actions.d.ts +49 -0
- package/dist/node/tui/actions.d.ts.map +1 -0
- package/dist/node/tui/actions.js +195 -0
- package/dist/node/tui/actions.js.map +1 -0
- package/dist/node/tui/credentials.d.ts +17 -0
- package/dist/node/tui/credentials.d.ts.map +1 -0
- package/dist/node/tui/credentials.js +54 -0
- package/dist/node/tui/credentials.js.map +1 -0
- package/dist/node/tui/filter.d.ts +5 -0
- package/dist/node/tui/filter.d.ts.map +1 -0
- package/dist/node/tui/filter.js +79 -0
- package/dist/node/tui/filter.js.map +1 -0
- package/dist/node/tui/index.d.ts +6 -0
- package/dist/node/tui/index.d.ts.map +1 -0
- package/dist/node/tui/index.js +6 -0
- package/dist/node/tui/index.js.map +1 -0
- package/dist/node/tui/launcher.d.ts +40 -0
- package/dist/node/tui/launcher.d.ts.map +1 -0
- package/dist/node/tui/launcher.js +439 -0
- package/dist/node/tui/launcher.js.map +1 -0
- package/dist/node/tui/pipe.d.ts +18 -0
- package/dist/node/tui/pipe.d.ts.map +1 -0
- package/dist/node/tui/pipe.js +134 -0
- package/dist/node/tui/pipe.js.map +1 -0
- package/dist/node/tui/sandbox.d.ts +54 -0
- package/dist/node/tui/sandbox.d.ts.map +1 -0
- package/dist/node/tui/sandbox.js +431 -0
- package/dist/node/tui/sandbox.js.map +1 -0
- package/dist/node/workers/base.d.ts +30 -0
- package/dist/node/workers/base.d.ts.map +1 -0
- package/dist/node/workers/base.js +255 -0
- package/dist/node/workers/base.js.map +1 -0
- package/dist/node/workers/child.d.ts +4 -0
- package/dist/node/workers/child.d.ts.map +1 -0
- package/dist/node/workers/child.js +6 -0
- package/dist/node/workers/child.js.map +1 -0
- package/dist/node/workers/control.d.ts +83 -0
- package/dist/node/workers/control.d.ts.map +1 -0
- package/dist/node/workers/control.js +77 -0
- package/dist/node/workers/control.js.map +1 -0
- package/dist/node/workers/index.d.ts +4 -0
- package/dist/node/workers/index.d.ts.map +1 -0
- package/dist/node/workers/index.js +7 -0
- package/dist/node/workers/index.js.map +1 -0
- package/dist/node/workers/lock.d.ts +30 -0
- package/dist/node/workers/lock.d.ts.map +1 -0
- package/dist/node/workers/lock.js +180 -0
- package/dist/node/workers/lock.js.map +1 -0
- package/dist/node/workers/main.d.ts +46 -0
- package/dist/node/workers/main.d.ts.map +1 -0
- package/dist/node/workers/main.js +230 -0
- package/dist/node/workers/main.js.map +1 -0
- package/dist/node/workers/process.d.ts +42 -0
- package/dist/node/workers/process.d.ts.map +1 -0
- package/dist/node/workers/process.js +125 -0
- package/dist/node/workers/process.js.map +1 -0
- package/dist/node/workers/workers.d.ts +122 -0
- package/dist/node/workers/workers.d.ts.map +1 -0
- package/dist/node/workers/workers.js +677 -0
- package/dist/node/workers/workers.js.map +1 -0
- 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/react/hooks.d.ts +43 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +82 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +4 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/stores.d.ts +9 -0
- package/dist/react/stores.d.ts.map +1 -0
- package/dist/react/stores.js +37 -0
- package/dist/react/stores.js.map +1 -0
- package/dist/registries/contribution.d.ts +50 -0
- package/dist/registries/contribution.d.ts.map +1 -0
- package/dist/registries/contribution.js +129 -0
- package/dist/registries/contribution.js.map +1 -0
- package/dist/registries/entries.d.ts +18 -0
- package/dist/registries/entries.d.ts.map +1 -0
- package/dist/registries/entries.js +42 -0
- package/dist/registries/entries.js.map +1 -0
- package/dist/registries/index.d.ts +3 -0
- package/dist/registries/index.d.ts.map +1 -0
- package/dist/registries/index.js +5 -0
- package/dist/registries/index.js.map +1 -0
- package/dist/registries/internal.d.ts +4 -0
- package/dist/registries/internal.d.ts.map +1 -0
- package/dist/registries/internal.js +5 -0
- package/dist/registries/internal.js.map +1 -0
- package/dist/registries/record.d.ts +115 -0
- package/dist/registries/record.d.ts.map +1 -0
- package/dist/registries/record.js +283 -0
- package/dist/registries/record.js.map +1 -0
- package/dist/registries/registry.d.ts +74 -0
- package/dist/registries/registry.d.ts.map +1 -0
- package/dist/registries/registry.js +14 -0
- package/dist/registries/registry.js.map +1 -0
- package/dist/registries/value.d.ts +48 -0
- package/dist/registries/value.d.ts.map +1 -0
- package/dist/registries/value.js +224 -0
- package/dist/registries/value.js.map +1 -0
- package/dist/remote/calls.d.ts +25 -0
- package/dist/remote/calls.d.ts.map +1 -0
- package/dist/remote/calls.js +62 -0
- package/dist/remote/calls.js.map +1 -0
- package/dist/remote/consumer.d.ts +43 -0
- package/dist/remote/consumer.d.ts.map +1 -0
- package/dist/remote/consumer.js +350 -0
- package/dist/remote/consumer.js.map +1 -0
- package/dist/remote/hold.d.ts +141 -0
- package/dist/remote/hold.d.ts.map +1 -0
- package/dist/remote/hold.js +579 -0
- package/dist/remote/hold.js.map +1 -0
- package/dist/remote/host-link.d.ts +77 -0
- package/dist/remote/host-link.d.ts.map +1 -0
- package/dist/remote/host-link.js +184 -0
- package/dist/remote/host-link.js.map +1 -0
- package/dist/remote/internal.d.ts +6 -0
- package/dist/remote/internal.d.ts.map +1 -0
- package/dist/remote/internal.js +6 -0
- package/dist/remote/internal.js.map +1 -0
- package/dist/remote/path.d.ts +46 -0
- package/dist/remote/path.d.ts.map +1 -0
- package/dist/remote/path.js +73 -0
- package/dist/remote/path.js.map +1 -0
- package/dist/remote/provider.d.ts +89 -0
- package/dist/remote/provider.d.ts.map +1 -0
- package/dist/remote/provider.js +597 -0
- package/dist/remote/provider.js.map +1 -0
- package/dist/remote/relay.d.ts +69 -0
- package/dist/remote/relay.d.ts.map +1 -0
- package/dist/remote/relay.js +219 -0
- package/dist/remote/relay.js.map +1 -0
- package/dist/remote/remote-object.d.ts +138 -0
- package/dist/remote/remote-object.d.ts.map +1 -0
- package/dist/remote/remote-object.js +492 -0
- package/dist/remote/remote-object.js.map +1 -0
- package/dist/remote/replica.d.ts +59 -0
- package/dist/remote/replica.d.ts.map +1 -0
- package/dist/remote/replica.js +125 -0
- package/dist/remote/replica.js.map +1 -0
- 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 +13 -2
- package/dist/sqlite/node.d.ts.map +1 -1
- package/dist/sqlite/node.js +31 -8
- package/dist/sqlite/node.js.map +1 -1
- package/dist/state/batch.d.ts +64 -0
- package/dist/state/batch.d.ts.map +1 -0
- package/dist/state/batch.js +164 -0
- package/dist/state/batch.js.map +1 -0
- package/dist/state/derive.d.ts +52 -0
- package/dist/state/derive.d.ts.map +1 -0
- package/dist/state/derive.js +182 -0
- package/dist/state/derive.js.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/internal.d.ts +6 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +8 -0
- package/dist/state/internal.js.map +1 -0
- package/dist/state/native-source.d.ts +106 -0
- package/dist/state/native-source.d.ts.map +1 -0
- package/dist/state/native-source.js +240 -0
- package/dist/state/native-source.js.map +1 -0
- package/dist/state/watchable.d.ts +114 -0
- package/dist/state/watchable.d.ts.map +1 -0
- package/dist/state/watchable.js +156 -0
- package/dist/state/watchable.js.map +1 -0
- package/dist/state/writable.d.ts +32 -0
- package/dist/state/writable.d.ts.map +1 -0
- package/dist/state/writable.js +49 -0
- package/dist/state/writable.js.map +1 -0
- package/dist/store/adapter.d.ts +67 -0
- package/dist/store/adapter.d.ts.map +1 -0
- package/dist/store/adapter.js +118 -0
- package/dist/store/adapter.js.map +1 -0
- package/dist/store/allocator.d.ts +17 -0
- package/dist/store/allocator.d.ts.map +1 -0
- package/dist/store/allocator.js +30 -0
- package/dist/store/allocator.js.map +1 -0
- package/dist/store/applier.d.ts +8 -0
- package/dist/store/applier.d.ts.map +1 -0
- package/dist/store/applier.js +375 -0
- package/dist/store/applier.js.map +1 -0
- package/dist/store/apply-batch.d.ts +12 -0
- package/dist/store/apply-batch.d.ts.map +1 -0
- package/dist/store/apply-batch.js +83 -0
- package/dist/store/apply-batch.js.map +1 -0
- package/dist/store/archive.d.ts +32 -0
- package/dist/store/archive.d.ts.map +1 -0
- package/dist/store/archive.js +130 -0
- package/dist/store/archive.js.map +1 -0
- package/dist/store/backend.d.ts +10 -0
- package/dist/store/backend.d.ts.map +1 -0
- package/dist/store/backend.js +15 -0
- package/dist/store/backend.js.map +1 -0
- package/dist/store/catalog.d.ts +24 -0
- package/dist/store/catalog.d.ts.map +1 -0
- package/dist/store/catalog.js +17 -0
- package/dist/store/catalog.js.map +1 -0
- package/dist/store/claims.d.ts +23 -0
- package/dist/store/claims.d.ts.map +1 -0
- package/dist/store/claims.js +65 -0
- package/dist/store/claims.js.map +1 -0
- package/dist/store/columns.d.ts +77 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +77 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/engine.d.ts +176 -0
- package/dist/store/engine.d.ts.map +1 -0
- package/dist/store/engine.js +283 -0
- package/dist/store/engine.js.map +1 -0
- package/dist/store/evaluate.d.ts +17 -0
- package/dist/store/evaluate.d.ts.map +1 -0
- package/dist/store/evaluate.js +128 -0
- package/dist/store/evaluate.js.map +1 -0
- package/dist/store/export.d.ts +17 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/export.js +200 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/expression.d.ts +150 -0
- package/dist/store/expression.d.ts.map +1 -0
- package/dist/store/expression.js +268 -0
- package/dist/store/expression.js.map +1 -0
- package/dist/store/import.d.ts +10 -0
- package/dist/store/import.d.ts.map +1 -0
- package/dist/store/import.js +276 -0
- package/dist/store/import.js.map +1 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +13 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/json-column.d.ts +33 -0
- package/dist/store/json-column.d.ts.map +1 -0
- package/dist/store/json-column.js +62 -0
- package/dist/store/json-column.js.map +1 -0
- package/dist/store/jsonl.d.ts +9 -0
- package/dist/store/jsonl.d.ts.map +1 -0
- package/dist/store/jsonl.js +61 -0
- package/dist/store/jsonl.js.map +1 -0
- package/dist/store/live-query.d.ts +108 -0
- package/dist/store/live-query.d.ts.map +1 -0
- package/dist/store/live-query.js +254 -0
- package/dist/store/live-query.js.map +1 -0
- package/dist/store/outbox.d.ts +26 -0
- package/dist/store/outbox.d.ts.map +1 -0
- package/dist/store/outbox.js +80 -0
- package/dist/store/outbox.js.map +1 -0
- package/dist/store/query.d.ts +39 -0
- package/dist/store/query.d.ts.map +1 -0
- package/dist/store/query.js +97 -0
- package/dist/store/query.js.map +1 -0
- package/dist/store/refusal.d.ts +15 -0
- package/dist/store/refusal.d.ts.map +1 -0
- package/dist/store/refusal.js +36 -0
- package/dist/store/refusal.js.map +1 -0
- package/dist/store/rows.d.ts +80 -0
- package/dist/store/rows.d.ts.map +1 -0
- package/dist/store/rows.js +183 -0
- package/dist/store/rows.js.map +1 -0
- package/dist/store/schema.d.ts +25 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +115 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/sql.d.ts +73 -0
- package/dist/store/sql.d.ts.map +1 -0
- package/dist/store/sql.js +234 -0
- package/dist/store/sql.js.map +1 -0
- package/dist/store/step.d.ts +50 -0
- package/dist/store/step.d.ts.map +1 -0
- package/dist/store/step.js +52 -0
- package/dist/store/step.js.map +1 -0
- package/dist/store/store.d.ts +171 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +818 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/table-changes.d.ts +29 -0
- package/dist/store/table-changes.d.ts.map +1 -0
- package/dist/store/table-changes.js +102 -0
- package/dist/store/table-changes.js.map +1 -0
- package/dist/store/table-evolve.d.ts +74 -0
- package/dist/store/table-evolve.d.ts.map +1 -0
- package/dist/store/table-evolve.js +201 -0
- package/dist/store/table-evolve.js.map +1 -0
- package/dist/store/table-handle.d.ts +73 -0
- package/dist/store/table-handle.d.ts.map +1 -0
- package/dist/store/table-handle.js +101 -0
- package/dist/store/table-handle.js.map +1 -0
- package/dist/store/table-history.d.ts +75 -0
- package/dist/store/table-history.d.ts.map +1 -0
- package/dist/store/table-history.js +42 -0
- package/dist/store/table-history.js.map +1 -0
- package/dist/store/table-migration.d.ts +16 -0
- package/dist/store/table-migration.d.ts.map +1 -0
- package/dist/store/table-migration.js +202 -0
- package/dist/store/table-migration.js.map +1 -0
- package/dist/store/table-writes.d.ts +125 -0
- package/dist/store/table-writes.d.ts.map +1 -0
- package/dist/store/table-writes.js +170 -0
- package/dist/store/table-writes.js.map +1 -0
- package/dist/store/table.d.ts +80 -0
- package/dist/store/table.d.ts.map +1 -0
- package/dist/store/table.js +103 -0
- package/dist/store/table.js.map +1 -0
- package/dist/store/text.d.ts +14 -0
- package/dist/store/text.d.ts.map +1 -0
- package/dist/store/text.js +51 -0
- package/dist/store/text.js.map +1 -0
- package/dist/store/writes.d.ts +5 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +4 -0
- package/dist/store/writes.js.map +1 -0
- package/dist/surfaces/active-language.d.ts +20 -0
- package/dist/surfaces/active-language.d.ts.map +1 -0
- package/dist/surfaces/active-language.js +78 -0
- package/dist/surfaces/active-language.js.map +1 -0
- package/dist/surfaces/active-theme.d.ts +16 -0
- package/dist/surfaces/active-theme.d.ts.map +1 -0
- package/dist/surfaces/active-theme.js +47 -0
- package/dist/surfaces/active-theme.js.map +1 -0
- package/dist/surfaces/client.d.ts +96 -0
- package/dist/surfaces/client.d.ts.map +1 -0
- package/dist/surfaces/client.js +264 -0
- package/dist/surfaces/client.js.map +1 -0
- package/dist/surfaces/connection.d.ts +49 -0
- package/dist/surfaces/connection.d.ts.map +1 -0
- package/dist/surfaces/connection.js +142 -0
- package/dist/surfaces/connection.js.map +1 -0
- package/dist/surfaces/format.d.ts +5 -0
- package/dist/surfaces/format.d.ts.map +1 -0
- package/dist/surfaces/format.js +37 -0
- package/dist/surfaces/format.js.map +1 -0
- package/dist/surfaces/index.d.ts +15 -0
- package/dist/surfaces/index.d.ts.map +1 -0
- package/dist/surfaces/index.js +18 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/language.d.ts +53 -0
- package/dist/surfaces/language.d.ts.map +1 -0
- package/dist/surfaces/language.js +74 -0
- package/dist/surfaces/language.js.map +1 -0
- package/dist/surfaces/loaded.d.ts +42 -0
- package/dist/surfaces/loaded.d.ts.map +1 -0
- package/dist/surfaces/loaded.js +116 -0
- package/dist/surfaces/loaded.js.map +1 -0
- package/dist/surfaces/locale-choice.d.ts +25 -0
- package/dist/surfaces/locale-choice.d.ts.map +1 -0
- package/dist/surfaces/locale-choice.js +14 -0
- package/dist/surfaces/locale-choice.js.map +1 -0
- package/dist/surfaces/messages.d.ts +67 -0
- package/dist/surfaces/messages.d.ts.map +1 -0
- package/dist/surfaces/messages.js +112 -0
- package/dist/surfaces/messages.js.map +1 -0
- package/dist/surfaces/page-state.d.ts +14 -0
- package/dist/surfaces/page-state.d.ts.map +1 -0
- package/dist/surfaces/page-state.js +43 -0
- package/dist/surfaces/page-state.js.map +1 -0
- package/dist/surfaces/preference.d.ts +32 -0
- package/dist/surfaces/preference.d.ts.map +1 -0
- package/dist/surfaces/preference.js +72 -0
- package/dist/surfaces/preference.js.map +1 -0
- package/dist/surfaces/registered.d.ts +33 -0
- package/dist/surfaces/registered.d.ts.map +1 -0
- package/dist/surfaces/registered.js +51 -0
- package/dist/surfaces/registered.js.map +1 -0
- package/dist/surfaces/scripts.d.ts +84 -0
- package/dist/surfaces/scripts.d.ts.map +1 -0
- package/dist/surfaces/scripts.js +28 -0
- package/dist/surfaces/scripts.js.map +1 -0
- package/dist/surfaces/theme-choice.d.ts +31 -0
- package/dist/surfaces/theme-choice.d.ts.map +1 -0
- package/dist/surfaces/theme-choice.js +18 -0
- package/dist/surfaces/theme-choice.js.map +1 -0
- package/dist/surfaces/themes.d.ts +43 -0
- package/dist/surfaces/themes.d.ts.map +1 -0
- package/dist/surfaces/themes.js +110 -0
- package/dist/surfaces/themes.js.map +1 -0
- package/dist/surfaces/translations.d.ts +29 -0
- package/dist/surfaces/translations.d.ts.map +1 -0
- package/dist/surfaces/translations.js +57 -0
- package/dist/surfaces/translations.js.map +1 -0
- package/dist/sync/batch.d.ts +18 -0
- package/dist/sync/batch.d.ts.map +1 -0
- package/dist/sync/batch.js +125 -0
- package/dist/sync/batch.js.map +1 -0
- package/dist/sync/client.d.ts +166 -0
- package/dist/sync/client.d.ts.map +1 -0
- package/dist/sync/client.js +438 -0
- package/dist/sync/client.js.map +1 -0
- package/dist/sync/files.d.ts +46 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +13 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/filesystem.d.ts +37 -0
- package/dist/sync/filesystem.d.ts.map +1 -0
- package/dist/sync/filesystem.js +185 -0
- package/dist/sync/filesystem.js.map +1 -0
- package/dist/sync/index.d.ts +8 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +9 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/lines.d.ts +18 -0
- package/dist/sync/lines.d.ts.map +1 -0
- package/dist/sync/lines.js +46 -0
- package/dist/sync/lines.js.map +1 -0
- package/dist/sync/remote.d.ts +130 -0
- package/dist/sync/remote.d.ts.map +1 -0
- package/dist/sync/remote.js +46 -0
- package/dist/sync/remote.js.map +1 -0
- package/dist/sync/state.d.ts +17 -0
- package/dist/sync/state.d.ts.map +1 -0
- package/dist/sync/state.js +40 -0
- package/dist/sync/state.js.map +1 -0
- package/dist/telemetry-ingest/batch.d.ts +70 -0
- package/dist/telemetry-ingest/batch.d.ts.map +1 -0
- package/dist/telemetry-ingest/batch.js +110 -0
- package/dist/telemetry-ingest/batch.js.map +1 -0
- package/dist/telemetry-ingest/facet.d.ts +21 -0
- package/dist/telemetry-ingest/facet.d.ts.map +1 -0
- package/dist/telemetry-ingest/facet.js +96 -0
- package/dist/telemetry-ingest/facet.js.map +1 -0
- package/dist/telemetry-ingest/index.d.ts +5 -0
- package/dist/telemetry-ingest/index.d.ts.map +1 -0
- package/dist/telemetry-ingest/index.js +8 -0
- package/dist/telemetry-ingest/index.js.map +1 -0
- package/dist/telemetry-ingest/recorder.d.ts +50 -0
- package/dist/telemetry-ingest/recorder.d.ts.map +1 -0
- package/dist/telemetry-ingest/recorder.js +298 -0
- package/dist/telemetry-ingest/recorder.js.map +1 -0
- package/dist/telemetry-ingest/sender.d.ts +14 -0
- package/dist/telemetry-ingest/sender.d.ts.map +1 -0
- package/dist/telemetry-ingest/sender.js +64 -0
- package/dist/telemetry-ingest/sender.js.map +1 -0
- package/dist/telemetry-sqlite/index.d.ts +13 -4
- package/dist/telemetry-sqlite/index.d.ts.map +1 -1
- package/dist/telemetry-sqlite/index.js +81 -241
- package/dist/telemetry-sqlite/index.js.map +1 -1
- package/dist/telemetry-sqlite/node.d.ts +13 -0
- package/dist/telemetry-sqlite/node.d.ts.map +1 -0
- package/dist/telemetry-sqlite/node.js +27 -0
- package/dist/telemetry-sqlite/node.js.map +1 -0
- package/dist/telemetry-sqlite/schema.d.ts +9 -0
- package/dist/telemetry-sqlite/schema.d.ts.map +1 -0
- package/dist/telemetry-sqlite/schema.js +61 -0
- package/dist/telemetry-sqlite/schema.js.map +1 -0
- package/dist/telemetry-sqlite/store.d.ts +3 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -1
- package/dist/telemetry-sqlite/store.js +24 -13
- package/dist/telemetry-sqlite/store.js.map +1 -1
- package/dist/telemetry.d.ts +937 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +470 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tui/bridge.d.ts +112 -0
- package/dist/tui/bridge.d.ts.map +1 -0
- package/dist/tui/bridge.js +9 -0
- package/dist/tui/bridge.js.map +1 -0
- package/dist/tui/channel.d.ts +44 -0
- package/dist/tui/channel.d.ts.map +1 -0
- package/dist/tui/channel.js +150 -0
- package/dist/tui/channel.js.map +1 -0
- package/dist/tui/frames.d.ts +5 -0
- package/dist/tui/frames.d.ts.map +1 -0
- package/dist/tui/frames.js +52 -0
- package/dist/tui/frames.js.map +1 -0
- package/dist/tui/index.d.ts +7 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/runtime.d.ts +46 -0
- package/dist/tui/runtime.d.ts.map +1 -0
- package/dist/tui/runtime.js +101 -0
- package/dist/tui/runtime.js.map +1 -0
- package/dist/tui/scope.d.ts +46 -0
- package/dist/tui/scope.d.ts.map +1 -0
- package/dist/tui/scope.js +141 -0
- package/dist/tui/scope.js.map +1 -0
- package/dist/tui/terminal.d.ts +15 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +37 -0
- package/dist/tui/terminal.js.map +1 -0
- package/dist/tui/theme.d.ts +17 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +38 -0
- package/dist/tui/theme.js.map +1 -0
- 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/web/environment.d.ts +4 -0
- package/dist/web/environment.d.ts.map +1 -0
- package/dist/web/environment.js +37 -0
- package/dist/web/environment.js.map +1 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +7 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/language.d.ts +7 -0
- package/dist/web/language.d.ts.map +1 -0
- package/dist/web/language.js +21 -0
- package/dist/web/language.js.map +1 -0
- package/dist/web/page.d.ts +29 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +92 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/scripts.d.ts +23 -0
- package/dist/web/scripts.d.ts.map +1 -0
- package/dist/web/scripts.js +50 -0
- package/dist/web/scripts.js.map +1 -0
- package/dist/web/styles.d.ts +17 -0
- package/dist/web/styles.d.ts.map +1 -0
- package/dist/web/styles.js +218 -0
- package/dist/web/styles.js.map +1 -0
- package/dist/web/themes.d.ts +6 -0
- package/dist/web/themes.d.ts.map +1 -0
- package/dist/web/themes.js +31 -0
- package/dist/web/themes.js.map +1 -0
- package/docs/benchmarks.md +1036 -0
- package/docs/decisions.md +3436 -0
- package/docs/dependencies/book.md +1671 -0
- package/docs/dependencies/index.html +2641 -0
- package/docs/dependencies/model.md +330 -0
- package/docs/design.md +3065 -0
- package/docs/durable-observers/book.md +432 -0
- package/docs/durable-observers/index.html +517 -0
- package/docs/flow-control/book.md +333 -0
- package/docs/flow-control/fold/index.html +265 -0
- package/docs/flow-control/index.html +548 -0
- package/docs/flow-control/window/index.html +228 -0
- package/docs/guide-plugins-hosts/book.md +957 -0
- package/docs/guide-plugins-hosts/index.html +952 -0
- package/docs/http-workers/book.md +378 -0
- package/docs/http-workers/index.html +515 -0
- package/docs/i18n/book.md +217 -0
- package/docs/i18n/index.html +344 -0
- package/docs/layer-1.md +311 -0
- package/docs/layer-2.md +216 -0
- package/docs/p3-features/README.md +6 -0
- package/docs/p3-features/book.md +478 -0
- package/docs/plugin-authoring.md +276 -0
- package/docs/plugin-model/book.md +186 -0
- package/docs/plugin-model/index.html +310 -0
- package/docs/plugin-primer/book.md +273 -0
- package/docs/plugin-primer/index.html +430 -0
- package/docs/slice-1.md +236 -0
- package/docs/slice-10.md +288 -0
- package/docs/slice-11.md +114 -0
- package/docs/slice-12.md +132 -0
- package/docs/slice-13.md +121 -0
- package/docs/slice-2.md +174 -0
- package/docs/slice-3a.md +296 -0
- package/docs/slice-3b.md +197 -0
- package/docs/slice-4.md +146 -0
- package/docs/slice-4a.md +418 -0
- package/docs/slice-4b.md +208 -0
- package/docs/slice-5.md +281 -0
- package/docs/slice-6a.md +676 -0
- package/docs/slice-6b.md +332 -0
- package/docs/slice-7a.md +130 -0
- package/docs/slice-7b/book.md +608 -0
- package/docs/slice-7b/index.html +842 -0
- package/docs/slice-7b.md +255 -0
- package/docs/slice-7c.md +165 -0
- package/docs/slice-8.md +194 -0
- package/docs/slice-9.md +110 -0
- package/docs/slices.md +241 -0
- package/docs/store/book.md +670 -0
- package/docs/store/index.html +861 -0
- package/docs/store/walkthrough.md +193 -0
- package/docs/theming/book.md +223 -0
- package/docs/theming/index.html +371 -0
- package/docs/tutorial/book.md +2169 -0
- package/docs/tutorial/index.html +2112 -0
- package/docs/tutorial/screens/click-after.png +0 -0
- package/docs/tutorial/screens/click-before.png +0 -0
- package/docs/tutorial/screens/edited.png +0 -0
- package/docs/tutorial/screens/french.png +0 -0
- package/docs/tutorial/screens/harbor.png +0 -0
- package/docs/tutorial/screens/page.png +0 -0
- package/docs/tutorial/screens/traces-ada.png +0 -0
- package/docs/tutorial/screens/traces.png +0 -0
- package/package.json +114 -20
- package/src/delta/README.md +69 -0
- package/dist/cell.d.ts +0 -122
- package/dist/cell.d.ts.map +0 -1
- package/dist/cell.js +0 -356
- package/dist/cell.js.map +0 -1
- package/dist/cluster.d.ts +0 -27
- package/dist/cluster.d.ts.map +0 -1
- package/dist/cluster.js +0 -230
- package/dist/cluster.js.map +0 -1
- package/dist/connection.d.ts +0 -270
- package/dist/connection.d.ts.map +0 -1
- package/dist/connection.js +0 -1216
- package/dist/connection.js.map +0 -1
- package/dist/contract.d.ts +0 -208
- package/dist/contract.d.ts.map +0 -1
- package/dist/contract.js +0 -246
- package/dist/contract.js.map +0 -1
- package/dist/declare.d.ts +0 -33
- package/dist/declare.d.ts.map +0 -1
- package/dist/declare.js +0 -2
- package/dist/declare.js.map +0 -1
- package/dist/errors.d.ts +0 -28
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -59
- package/dist/errors.js.map +0 -1
- package/dist/host.d.ts +0 -348
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -1000
- package/dist/host.js.map +0 -1
- package/dist/link.d.ts +0 -107
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js +0 -355
- package/dist/link.js.map +0 -1
- package/dist/loader.d.ts +0 -4
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -73
- package/dist/loader.js.map +0 -1
- package/dist/manager.d.ts +0 -115
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -345
- package/dist/manager.js.map +0 -1
- package/dist/node.d.ts +0 -4
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -4
- package/dist/node.js.map +0 -1
- package/dist/object.d.ts +0 -438
- package/dist/object.d.ts.map +0 -1
- package/dist/object.js +0 -1571
- package/dist/object.js.map +0 -1
- package/dist/publish.d.ts +0 -5
- package/dist/publish.d.ts.map +0 -1
- package/dist/publish.js +0 -40
- package/dist/publish.js.map +0 -1
- package/dist/registry.d.ts +0 -25
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -6
- package/dist/registry.js.map +0 -1
- package/dist/reload.d.ts +0 -126
- package/dist/reload.d.ts.map +0 -1
- package/dist/reload.js +0 -653
- package/dist/reload.js.map +0 -1
- package/dist/remote.d.ts +0 -165
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -612
- package/dist/remote.js.map +0 -1
- package/dist/schema.d.ts +0 -21
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -228
- package/dist/schema.js.map +0 -1
- package/dist/state.d.ts +0 -92
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -287
- package/dist/state.js.map +0 -1
- package/dist/types.d.ts +0 -88
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/websocket.d.ts +0 -15
- package/dist/websocket.d.ts.map +0 -1
- package/dist/websocket.js +0 -16
- package/dist/websocket.js.map +0 -1
- package/dist/wire.d.ts +0 -216
- package/dist/wire.d.ts.map +0 -1
- package/dist/wire.js +0 -165
- package/dist/wire.js.map +0 -1
- package/docs/guide.md +0 -814
- package/docs/spec.md +0 -288
- package/docs/tutorial.md +0 -931
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Native sources (W4, slice 8 §2): in-process values that change, compared by identity (a `writable`, a registry's
|
|
2
|
+
// composed value, `ref.state`). Derives and registry tables depend on them and the batch marks them; the followed
|
|
3
|
+
// ones (writables, registry values) give their watches and observers one call per batch that changed them.
|
|
4
|
+
import { NativeWatch, } from "../watch.js";
|
|
5
|
+
import { handedOut } from "./watchable.js";
|
|
6
|
+
/**
|
|
7
|
+
* A native source as derives and registry tables read it: its value (`start()` while it may fail), the dependents a
|
|
8
|
+
* change marks (`changed()`, inside a batch), and the host's batch until it ended. How its watches get their calls is
|
|
9
|
+
* the subclass's (`FollowedSource` for writables and registry values; `ref.state` gives each state to its watches).
|
|
10
|
+
*/
|
|
11
|
+
export class NativeSource {
|
|
12
|
+
/** Derives and registry tables reading this source; each removes itself when it stops. */
|
|
13
|
+
dependents = new Set();
|
|
14
|
+
/** The host's batch; dropped when the source ended, so an ended source keeps no host. */
|
|
15
|
+
#batch;
|
|
16
|
+
/** `batch` undefined: made ended (a released reference's state). */
|
|
17
|
+
constructor(batch) {
|
|
18
|
+
this.#batch = batch;
|
|
19
|
+
}
|
|
20
|
+
/** What a new watch starts at; a source that can fail and recover tells its failure. */
|
|
21
|
+
start() {
|
|
22
|
+
return { kind: "value", value: this.value };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Its value now as a contribution reads it: throws its failure while it is failed, where `.value` keeps the last good
|
|
26
|
+
* value for readers (a registry whose `compose` threw).
|
|
27
|
+
*/
|
|
28
|
+
current() {
|
|
29
|
+
return this.value;
|
|
30
|
+
}
|
|
31
|
+
/** The host's batch, `undefined` once the source ended. */
|
|
32
|
+
get batch() {
|
|
33
|
+
return this.#batch;
|
|
34
|
+
}
|
|
35
|
+
/** Records a change inside the current batch: every dependent marked. */
|
|
36
|
+
changed() {
|
|
37
|
+
for (const dependent of this.dependents)
|
|
38
|
+
dependent.invalidate();
|
|
39
|
+
}
|
|
40
|
+
/** Ends the source for good: its dependents dropped, the batch let go. */
|
|
41
|
+
end() {
|
|
42
|
+
this.#batch = undefined;
|
|
43
|
+
this.dependents.clear();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const ENDED = { kind: "ended" };
|
|
47
|
+
const ABORTED = { kind: "aborted" };
|
|
48
|
+
const FAILED = { kind: "failed" };
|
|
49
|
+
const NONE = { kind: "none" };
|
|
50
|
+
const NOTHING = () => { };
|
|
51
|
+
/**
|
|
52
|
+
* A native source its followers get through the batch (a writable, a registry value): a change lists it for one frame
|
|
53
|
+
* when someone follows it; the frame is its value then, delivered only when it is another value (identity) than the
|
|
54
|
+
* one its followers have, or after a failure, whose call comes once per episode.
|
|
55
|
+
*/
|
|
56
|
+
export class FollowedSource extends NativeSource {
|
|
57
|
+
#watches = new Set();
|
|
58
|
+
/** Synchronous observers and Chord's own subscribers (`retryOn`), fed inside the batch, each with its cleanup. */
|
|
59
|
+
#observers = new Map();
|
|
60
|
+
/** What the followers have; `undefined` while nobody follows (so no old value is kept). */
|
|
61
|
+
#shown;
|
|
62
|
+
/** Listed for a frame in the current batch. */
|
|
63
|
+
#listed = false;
|
|
64
|
+
/** Whether a watch or an observer follows it (a registry value also while readers wait for its first value). */
|
|
65
|
+
get watched() {
|
|
66
|
+
return this.#watches.size > 0 || this.#observers.size > 0;
|
|
67
|
+
}
|
|
68
|
+
async watch(context) {
|
|
69
|
+
return this.openWatch(context);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `watch` without the Promise. On a failed source it opens at the last good value and its first call is the
|
|
73
|
+
* failure; with no value to start at it throws the failure. An ended source gives a watch that has ended.
|
|
74
|
+
*/
|
|
75
|
+
openWatch(context) {
|
|
76
|
+
const batch = this.batch;
|
|
77
|
+
if (batch === undefined) {
|
|
78
|
+
const ended = new NativeWatch(this.value, NOTHING, NOTHING);
|
|
79
|
+
ended.end(ENDED);
|
|
80
|
+
return ended;
|
|
81
|
+
}
|
|
82
|
+
batch.assertOutside("watch");
|
|
83
|
+
const start = this.start();
|
|
84
|
+
if (start.kind === "failed" && start.last === undefined)
|
|
85
|
+
throw start.error;
|
|
86
|
+
const value = start.kind === "value" ? start.value : start.last.value;
|
|
87
|
+
this.#follow(start);
|
|
88
|
+
const watch = new NativeWatch(value, () => this.#unfollow(watch), batch.reportListener);
|
|
89
|
+
this.#watches.add(watch);
|
|
90
|
+
if (context.abortSignal !== undefined)
|
|
91
|
+
watch.observeAbort(context.abortSignal);
|
|
92
|
+
if (start.kind === "failed")
|
|
93
|
+
watch.fail(handedOut(start.error), context);
|
|
94
|
+
return watch;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Attaches a synchronous observer at the current value (Durable's `observeXXX`); it counts as following, so a lazy
|
|
98
|
+
* value is computed in the batch that changed it. Throws the failure when there is no value to start at; aborting
|
|
99
|
+
* `context` detaches it (`aborted`); the source's end detaches it too (`ended`), its abort listener removed.
|
|
100
|
+
*/
|
|
101
|
+
observe(observer, context) {
|
|
102
|
+
this.batch?.assertOutside("observe");
|
|
103
|
+
const start = this.start();
|
|
104
|
+
if (start.kind === "failed" && start.last === undefined)
|
|
105
|
+
throw start.error;
|
|
106
|
+
const value = start.kind === "value" ? start.value : start.last.value;
|
|
107
|
+
if (this.batch === undefined) {
|
|
108
|
+
observer.end(ENDED);
|
|
109
|
+
return { value, detach: NOTHING };
|
|
110
|
+
}
|
|
111
|
+
const signal = context.abortSignal;
|
|
112
|
+
if (signal?.aborted) {
|
|
113
|
+
observer.end(ABORTED);
|
|
114
|
+
return { value, detach: NOTHING };
|
|
115
|
+
}
|
|
116
|
+
const aborted = () => {
|
|
117
|
+
if (!this.#observers.has(observer))
|
|
118
|
+
return;
|
|
119
|
+
this.unsubscribe(observer);
|
|
120
|
+
observer.end(ABORTED);
|
|
121
|
+
};
|
|
122
|
+
const cleanup = signal === undefined ? NOTHING : () => signal.removeEventListener("abort", aborted);
|
|
123
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
124
|
+
this.#follow(start);
|
|
125
|
+
this.#observers.set(observer, cleanup);
|
|
126
|
+
return { value, detach: () => this.unsubscribe(observer) };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Feeds `observer` every call from now on, inside each batch, also while the source has no value (Chord's own
|
|
130
|
+
* followers: `retryOn`). Nothing is delivered for the current value.
|
|
131
|
+
*/
|
|
132
|
+
subscribe(observer) {
|
|
133
|
+
if (this.batch === undefined)
|
|
134
|
+
return;
|
|
135
|
+
this.#follow(this.#startOrNone());
|
|
136
|
+
this.#observers.set(observer, NOTHING);
|
|
137
|
+
}
|
|
138
|
+
unsubscribe(observer) {
|
|
139
|
+
const cleanup = this.#observers.get(observer);
|
|
140
|
+
if (cleanup === undefined)
|
|
141
|
+
return;
|
|
142
|
+
this.#observers.delete(observer);
|
|
143
|
+
cleanup();
|
|
144
|
+
this.#settleFollowers();
|
|
145
|
+
}
|
|
146
|
+
/** Delivers this batch's frame: the new value when the followers have another, or a failure once per episode. */
|
|
147
|
+
deliver(context) {
|
|
148
|
+
this.#listed = false;
|
|
149
|
+
const shown = this.#shown;
|
|
150
|
+
if (shown === undefined)
|
|
151
|
+
return;
|
|
152
|
+
this.#deliver(shown, context);
|
|
153
|
+
// Readers waiting for a first value pulled it through this delivery: nothing is kept for them.
|
|
154
|
+
this.#settleFollowers();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Records a change inside the current batch: every dependent marked, and the source listed for a frame when someone
|
|
158
|
+
* follows it (or `watched` says so).
|
|
159
|
+
*/
|
|
160
|
+
changed() {
|
|
161
|
+
super.changed();
|
|
162
|
+
this.list();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Lists the source for a frame in the current batch when someone follows it (or `watched` says so), its dependents
|
|
166
|
+
* left as they are (marked already).
|
|
167
|
+
*/
|
|
168
|
+
list() {
|
|
169
|
+
if (this.#listed || !this.watched || this.batch === undefined)
|
|
170
|
+
return;
|
|
171
|
+
this.#listed = true;
|
|
172
|
+
// Only readers waiting for a first value follow it without a follower's record: they have none. Not computed
|
|
173
|
+
// here: marking runs inside adoptions, the value is pulled in the delivery.
|
|
174
|
+
this.#shown ??= NONE;
|
|
175
|
+
this.batch.changed(this);
|
|
176
|
+
}
|
|
177
|
+
/** Nothing follows it any more (no watch, no observer): a subclass drops what it kept for followers. */
|
|
178
|
+
unfollowed() { }
|
|
179
|
+
/** Ends the source for good: watches and observers end `ended` (their abort listeners removed). */
|
|
180
|
+
end() {
|
|
181
|
+
super.end();
|
|
182
|
+
this.#shown = undefined;
|
|
183
|
+
// Ending detaches, which deletes the current entry (safe while iterating) and runs no listener.
|
|
184
|
+
for (const watch of this.#watches)
|
|
185
|
+
watch.end(ENDED);
|
|
186
|
+
const observers = [...this.#observers];
|
|
187
|
+
this.#observers.clear();
|
|
188
|
+
for (const [observer, cleanup] of observers) {
|
|
189
|
+
cleanup();
|
|
190
|
+
observer.end(ENDED);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
#deliver(shown, context) {
|
|
194
|
+
const start = this.#startOrNone();
|
|
195
|
+
if (start.kind === "failed") {
|
|
196
|
+
// A failure reaches followers that had a value: those without one wait for the first.
|
|
197
|
+
if (shown.kind !== "value")
|
|
198
|
+
return;
|
|
199
|
+
this.#shown = FAILED;
|
|
200
|
+
const error = handedOut(start.error);
|
|
201
|
+
for (const watch of this.#watches)
|
|
202
|
+
watch.fail(error, context);
|
|
203
|
+
for (const observer of [...this.#observers.keys()])
|
|
204
|
+
observer.advance({ kind: "failed", error }, context);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (start.kind !== "value" || (shown.kind === "value" && shown.value === start.value))
|
|
208
|
+
return;
|
|
209
|
+
const { value } = start;
|
|
210
|
+
this.#shown = start;
|
|
211
|
+
for (const watch of this.#watches)
|
|
212
|
+
watch.advance(value, context);
|
|
213
|
+
// A copy: an observer may detach itself in its call.
|
|
214
|
+
for (const observer of [...this.#observers.keys()])
|
|
215
|
+
observer.advance({ kind: "value", value }, context);
|
|
216
|
+
}
|
|
217
|
+
/** Its start, `none` while it has no value. */
|
|
218
|
+
#startOrNone() {
|
|
219
|
+
const start = this.start();
|
|
220
|
+
return start.kind === "failed" && start.last === undefined ? NONE : start;
|
|
221
|
+
}
|
|
222
|
+
/** A follower comes: the first one records what followers have (a later one opened at the same current value). */
|
|
223
|
+
#follow(start) {
|
|
224
|
+
if (this.#shown !== undefined)
|
|
225
|
+
return;
|
|
226
|
+
this.#shown = start.kind === "failed" ? FAILED : start;
|
|
227
|
+
}
|
|
228
|
+
#unfollow(watch) {
|
|
229
|
+
this.#watches.delete(watch);
|
|
230
|
+
this.#settleFollowers();
|
|
231
|
+
}
|
|
232
|
+
/** No follower left: nothing is shown any more, so no old value is kept. */
|
|
233
|
+
#settleFollowers() {
|
|
234
|
+
if (this.#watches.size > 0 || this.#observers.size > 0)
|
|
235
|
+
return;
|
|
236
|
+
this.#shown = undefined;
|
|
237
|
+
this.unfollowed();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=native-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-source.js","sourceRoot":"","sources":["../../src/state/native-source.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,kHAAkH;AAClH,2GAA2G;AAG3G,OAAO,EACN,WAAW,GAKX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAkB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyB3D;;;;GAIG;AACH,MAAM,OAAgB,YAAY;IACjC,0FAA0F;IACjF,UAAU,GAAG,IAAI,GAAG,EAAa,CAAC;IAC3C,yFAAyF;IACzF,MAAM,CAAoB;IAE1B,oEAAoE;IACpE,YAAY,KAAwB;QACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAMD,wFAAwF;IACxF,KAAK;QACJ,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,2DAA2D;IAC3D,IAAc,KAAK;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,yEAAyE;IAC/D,OAAO;QAChB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU;YAAE,SAAS,CAAC,UAAU,EA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AAC,UAAU,CAAC,IAAI,GAAG,CAAC;YAAE,OAAO;QAC/D,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;CACD","sourcesContent":["// Native sources (W4, slice 8 §2): in-process values that change, compared by identity (a `writable`, a registry's\n// composed value, `ref.state`). Derives and registry tables depend on them and the batch marks them; the followed\n// ones (writables, registry values) give their watches and observers one call per batch that changed them.\n\nimport type { Context } from \"../context/index.ts\";\nimport {\n\tNativeWatch,\n\ttype NativeWatchable,\n\ttype NativeWatchCall,\n\ttype NativeWatchHandle,\n\ttype WatchEnd,\n} from \"../watch.ts\";\nimport type { Batch } from \"./batch.ts\";\nimport { type Dependent, handedOut } from \"./watchable.ts\";\n\n/**\n * A synchronous observer of a native source (Durable's observer shape): `advance` is called inside the batch that\n * changed the source, so it only records; `end` once, when the source ended (`ended`) or the observer's context was\n * aborted (`aborted`).\n */\nexport interface NativeObserver<T> {\n\t/** The source's call of this batch: its new value, or a failure it may recover from. */\n\tadvance(call: NativeWatchCall<T>, context: Context): void;\n\t/** The observer is detached for good with `end`. */\n\tend(end: WatchEnd): void;\n}\n\n/** What `observe` gives: the value the observer starts at, and how to detach it (Durable's `Observation`). */\nexport type NativeObservation<T> = { readonly value: T; detach(): void };\n\n/**\n * What a new watch of a native source starts at: its value, or while it is failed, the failure and its last good value\n * (`last` undefined when it never had one: a watch cannot start then).\n */\nexport type NativeStart<T> =\n\t| { readonly kind: \"value\"; readonly value: T }\n\t| { readonly kind: \"failed\"; readonly error: unknown; readonly last: { readonly value: T } | undefined };\n\n/**\n * A native source as derives and registry tables read it: its value (`start()` while it may fail), the dependents a\n * change marks (`changed()`, inside a batch), and the host's batch until it ended. How its watches get their calls is\n * the subclass's (`FollowedSource` for writables and registry values; `ref.state` gives each state to its watches).\n */\nexport abstract class NativeSource<T = unknown> implements NativeWatchable<T> {\n\t/** Derives and registry tables reading this source; each removes itself when it stops. */\n\treadonly dependents = new Set<Dependent>();\n\t/** The host's batch; dropped when the source ended, so an ended source keeps no host. */\n\t#batch: Batch | undefined;\n\n\t/** `batch` undefined: made ended (a released reference's state). */\n\tconstructor(batch: Batch | undefined) {\n\t\tthis.#batch = batch;\n\t}\n\n\tabstract get value(): T;\n\n\tabstract watch(context: Context): Promise<NativeWatchHandle<T>>;\n\n\t/** What a new watch starts at; a source that can fail and recover tells its failure. */\n\tstart(): NativeStart<T> {\n\t\treturn { kind: \"value\", value: this.value };\n\t}\n\n\t/**\n\t * Its value now as a contribution reads it: throws its failure while it is failed, where `.value` keeps the last good\n\t * value for readers (a registry whose `compose` threw).\n\t */\n\tcurrent(): T {\n\t\treturn this.value;\n\t}\n\n\t/** The host's batch, `undefined` once the source ended. */\n\tprotected get batch(): Batch | undefined {\n\t\treturn this.#batch;\n\t}\n\n\t/** Records a change inside the current batch: every dependent marked. */\n\tprotected changed(): void {\n\t\tfor (const dependent of this.dependents) dependent.invalidate();\n\t}\n\n\t/** Ends the source for good: its dependents dropped, the batch let go. */\n\tprotected end(): void {\n\t\tthis.#batch = undefined;\n\t\tthis.dependents.clear();\n\t}\n}\n\n/**\n * What the watches and observers were last given: a value, a failure (one call per failure episode), or nothing yet\n * (a source with no value, followed for its first one).\n */\ntype Shown<T> = { readonly kind: \"value\"; readonly value: T } | { readonly kind: \"failed\" } | { readonly kind: \"none\" };\n\nconst ENDED: WatchEnd = { kind: \"ended\" };\n\nconst ABORTED: WatchEnd = { kind: \"aborted\" };\n\nconst FAILED: Shown<never> = { kind: \"failed\" };\n\nconst NONE = { kind: \"none\" } as const;\n\nconst NOTHING = (): void => {};\n\n/**\n * A native source its followers get through the batch (a writable, a registry value): a change lists it for one frame\n * when someone follows it; the frame is its value then, delivered only when it is another value (identity) than the\n * one its followers have, or after a failure, whose call comes once per episode.\n */\nexport abstract class FollowedSource<T = unknown> extends NativeSource<T> {\n\treadonly #watches = new Set<NativeWatch<T>>();\n\t/** Synchronous observers and Chord's own subscribers (`retryOn`), fed inside the batch, each with its cleanup. */\n\treadonly #observers = new Map<NativeObserver<T>, () => void>();\n\t/** What the followers have; `undefined` while nobody follows (so no old value is kept). */\n\t#shown: Shown<T> | undefined;\n\t/** Listed for a frame in the current batch. */\n\t#listed = false;\n\n\t/** Whether a watch or an observer follows it (a registry value also while readers wait for its first value). */\n\tget watched(): boolean {\n\t\treturn this.#watches.size > 0 || this.#observers.size > 0;\n\t}\n\n\tasync watch(context: Context): Promise<NativeWatch<T>> {\n\t\treturn this.openWatch(context);\n\t}\n\n\t/**\n\t * `watch` without the Promise. On a failed source it opens at the last good value and its first call is the\n\t * failure; with no value to start at it throws the failure. An ended source gives a watch that has ended.\n\t */\n\topenWatch(context: Context): NativeWatch<T> {\n\t\tconst batch = this.batch;\n\t\tif (batch === undefined) {\n\t\t\tconst ended = new NativeWatch<T>(this.value, NOTHING, NOTHING);\n\t\t\tended.end(ENDED);\n\t\t\treturn ended;\n\t\t}\n\t\tbatch.assertOutside(\"watch\");\n\t\tconst start = this.start();\n\t\tif (start.kind === \"failed\" && start.last === undefined) throw start.error;\n\t\tconst value = start.kind === \"value\" ? start.value : start.last!.value;\n\t\tthis.#follow(start);\n\t\tconst watch: NativeWatch<T> = new NativeWatch(value, () => this.#unfollow(watch), batch.reportListener);\n\t\tthis.#watches.add(watch);\n\t\tif (context.abortSignal !== undefined) watch.observeAbort(context.abortSignal);\n\t\tif (start.kind === \"failed\") watch.fail(handedOut(start.error), context);\n\t\treturn watch;\n\t}\n\n\t/**\n\t * Attaches a synchronous observer at the current value (Durable's `observeXXX`); it counts as following, so a lazy\n\t * value is computed in the batch that changed it. Throws the failure when there is no value to start at; aborting\n\t * `context` detaches it (`aborted`); the source's end detaches it too (`ended`), its abort listener removed.\n\t */\n\tobserve(observer: NativeObserver<T>, context: Context): NativeObservation<T> {\n\t\tthis.batch?.assertOutside(\"observe\");\n\t\tconst start = this.start();\n\t\tif (start.kind === \"failed\" && start.last === undefined) throw start.error;\n\t\tconst value = start.kind === \"value\" ? start.value : start.last!.value;\n\t\tif (this.batch === undefined) {\n\t\t\tobserver.end(ENDED);\n\t\t\treturn { value, detach: NOTHING };\n\t\t}\n\t\tconst signal = context.abortSignal;\n\t\tif (signal?.aborted) {\n\t\t\tobserver.end(ABORTED);\n\t\t\treturn { value, detach: NOTHING };\n\t\t}\n\t\tconst aborted = (): void => {\n\t\t\tif (!this.#observers.has(observer)) return;\n\t\t\tthis.unsubscribe(observer);\n\t\t\tobserver.end(ABORTED);\n\t\t};\n\t\tconst cleanup = signal === undefined ? NOTHING : () => signal.removeEventListener(\"abort\", aborted);\n\t\tsignal?.addEventListener(\"abort\", aborted, { once: true });\n\t\tthis.#follow(start);\n\t\tthis.#observers.set(observer, cleanup);\n\t\treturn { value, detach: () => this.unsubscribe(observer) };\n\t}\n\n\t/**\n\t * Feeds `observer` every call from now on, inside each batch, also while the source has no value (Chord's own\n\t * followers: `retryOn`). Nothing is delivered for the current value.\n\t */\n\tsubscribe(observer: NativeObserver<T>): void {\n\t\tif (this.batch === undefined) return;\n\t\tthis.#follow(this.#startOrNone());\n\t\tthis.#observers.set(observer, NOTHING);\n\t}\n\n\tunsubscribe(observer: NativeObserver<T>): void {\n\t\tconst cleanup = this.#observers.get(observer);\n\t\tif (cleanup === undefined) return;\n\t\tthis.#observers.delete(observer);\n\t\tcleanup();\n\t\tthis.#settleFollowers();\n\t}\n\n\t/** Delivers this batch's frame: the new value when the followers have another, or a failure once per episode. */\n\tdeliver(context: Context): void {\n\t\tthis.#listed = false;\n\t\tconst shown = this.#shown;\n\t\tif (shown === undefined) return;\n\t\tthis.#deliver(shown, context);\n\t\t// Readers waiting for a first value pulled it through this delivery: nothing is kept for them.\n\t\tthis.#settleFollowers();\n\t}\n\n\t/**\n\t * Records a change inside the current batch: every dependent marked, and the source listed for a frame when someone\n\t * follows it (or `watched` says so).\n\t */\n\tprotected override changed(): void {\n\t\tsuper.changed();\n\t\tthis.list();\n\t}\n\n\t/**\n\t * Lists the source for a frame in the current batch when someone follows it (or `watched` says so), its dependents\n\t * left as they are (marked already).\n\t */\n\tprotected list(): void {\n\t\tif (this.#listed || !this.watched || this.batch === undefined) return;\n\t\tthis.#listed = true;\n\t\t// Only readers waiting for a first value follow it without a follower's record: they have none. Not computed\n\t\t// here: marking runs inside adoptions, the value is pulled in the delivery.\n\t\tthis.#shown ??= NONE;\n\t\tthis.batch.changed(this);\n\t}\n\n\t/** Nothing follows it any more (no watch, no observer): a subclass drops what it kept for followers. */\n\tprotected unfollowed(): void {}\n\n\t/** Ends the source for good: watches and observers end `ended` (their abort listeners removed). */\n\tprotected override end(): void {\n\t\tsuper.end();\n\t\tthis.#shown = undefined;\n\t\t// Ending detaches, which deletes the current entry (safe while iterating) and runs no listener.\n\t\tfor (const watch of this.#watches) watch.end(ENDED);\n\t\tconst observers = [...this.#observers];\n\t\tthis.#observers.clear();\n\t\tfor (const [observer, cleanup] of observers) {\n\t\t\tcleanup();\n\t\t\tobserver.end(ENDED);\n\t\t}\n\t}\n\n\t#deliver(shown: Shown<T>, context: Context): void {\n\t\tconst start = this.#startOrNone();\n\t\tif (start.kind === \"failed\") {\n\t\t\t// A failure reaches followers that had a value: those without one wait for the first.\n\t\t\tif (shown.kind !== \"value\") return;\n\t\t\tthis.#shown = FAILED;\n\t\t\tconst error = handedOut(start.error);\n\t\t\tfor (const watch of this.#watches) watch.fail(error, context);\n\t\t\tfor (const observer of [...this.#observers.keys()]) observer.advance({ kind: \"failed\", error }, context);\n\t\t\treturn;\n\t\t}\n\t\tif (start.kind !== \"value\" || (shown.kind === \"value\" && shown.value === start.value)) return;\n\t\tconst { value } = start;\n\t\tthis.#shown = start;\n\t\tfor (const watch of this.#watches) watch.advance(value, context);\n\t\t// A copy: an observer may detach itself in its call.\n\t\tfor (const observer of [...this.#observers.keys()]) observer.advance({ kind: \"value\", value }, context);\n\t}\n\n\t/** Its start, `none` while it has no value. */\n\t#startOrNone(): NativeStart<T> | { readonly kind: \"none\" } {\n\t\tconst start = this.start();\n\t\treturn start.kind === \"failed\" && start.last === undefined ? NONE : start;\n\t}\n\n\t/** A follower comes: the first one records what followers have (a later one opened at the same current value). */\n\t#follow(start: NativeStart<T> | { readonly kind: \"none\" }): void {\n\t\tif (this.#shown !== undefined) return;\n\t\tthis.#shown = start.kind === \"failed\" ? FAILED : start;\n\t}\n\n\t#unfollow(watch: NativeWatch<T>): void {\n\t\tthis.#watches.delete(watch);\n\t\tthis.#settleFollowers();\n\t}\n\n\t/** No follower left: nothing is shown any more, so no old value is kept. */\n\t#settleFollowers(): void {\n\t\tif (this.#watches.size > 0 || this.#observers.size > 0) return;\n\t\tthis.#shown = undefined;\n\t\tthis.unfollowed();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import type { Op } from "../delta/index.ts";
|
|
3
|
+
import type { JsonValue } from "../json.ts";
|
|
4
|
+
import { Watch, type Watchable, type WatchCall, type WatchEnd } from "../watch.ts";
|
|
5
|
+
import type { Batch } from "./batch.ts";
|
|
6
|
+
/**
|
|
7
|
+
* A synchronous subscriber of a source (a hold over a link, a reference's member): fed the source's call inside the batch
|
|
8
|
+
* that made it, before the batch ends, so everything one commit changed can leave in one message. The watch's own sink
|
|
9
|
+
* shape (`Watch.advance`, `Watch.end`).
|
|
10
|
+
*/
|
|
11
|
+
export interface Subscriber {
|
|
12
|
+
/**
|
|
13
|
+
* The source's call of this batch, in its batch's `context`: a value (the ops from the previous one, and whether its
|
|
14
|
+
* document was retired in it, or for a derive one of its sources' documents), or a failure it may recover from; the
|
|
15
|
+
* next value after a failure is `[["r", value]]`.
|
|
16
|
+
*/
|
|
17
|
+
advance(call: WatchCall<JsonValue>, context: Context): void;
|
|
18
|
+
/** The source ended for good with `end`; nothing follows, and the subscriber is dropped. */
|
|
19
|
+
end(end: WatchEnd): void;
|
|
20
|
+
/**
|
|
21
|
+
* The source ended for good after its last call (a followed runtime ended): a subscriber delivering later (a watch)
|
|
22
|
+
* ends `ended` once it delivered what it was given, others end now.
|
|
23
|
+
*/
|
|
24
|
+
endAfterDelivery(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* What a new watch of a source starts at (design §11): its value, or, while it is failed, the failure and its last good
|
|
28
|
+
* value (`undefined` when it never had one: a watch cannot start then, there is nothing to start at).
|
|
29
|
+
*/
|
|
30
|
+
export type WatchStart = {
|
|
31
|
+
readonly kind: "value";
|
|
32
|
+
readonly value: JsonValue;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "failed";
|
|
35
|
+
readonly error: unknown;
|
|
36
|
+
readonly last: JsonValue | undefined;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* An error Chord hands to apps (a failure call, a report), its stack made text first: until then V8 keeps the frames'
|
|
40
|
+
* receivers, which would keep the host behind the throw alive for as long as an app keeps the error.
|
|
41
|
+
*/
|
|
42
|
+
export declare function handedOut<E>(error: E): E;
|
|
43
|
+
/**
|
|
44
|
+
* What reads a source and is marked by its changes: a derive, or a reference's member forwarding to derives (`Source.
|
|
45
|
+
* dependents`).
|
|
46
|
+
*/
|
|
47
|
+
export interface Dependent {
|
|
48
|
+
/** The source changed in the current batch: flags only, no compute. */
|
|
49
|
+
invalidate(): void;
|
|
50
|
+
/** A source's document was retired in the current batch (rule 21); `visited` keeps a diamond walked once. */
|
|
51
|
+
sourceRetired(visited: Set<Dependent>): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A changing value on a host (a singleton document, a derive, a replica): its watches and subscribers get one frame
|
|
55
|
+
* per batch that changed it, and the derives reading it are marked dirty when it changes.
|
|
56
|
+
*/
|
|
57
|
+
export declare abstract class Source implements Watchable<JsonValue> {
|
|
58
|
+
#private;
|
|
59
|
+
/** Derives reading this source (and references' members forwarding to some); each removes itself when it stops. */
|
|
60
|
+
readonly dependents: Set<Dependent>;
|
|
61
|
+
protected readonly batch: Batch;
|
|
62
|
+
constructor(batch: Batch);
|
|
63
|
+
abstract get value(): JsonValue;
|
|
64
|
+
/** Whether a watch or a subscriber follows this source. */
|
|
65
|
+
get watched(): boolean;
|
|
66
|
+
watch(context: Context): Promise<Watch<JsonValue>>;
|
|
67
|
+
/**
|
|
68
|
+
* `watch` without the Promise, for references, which must register the watch before anything else runs. On a failed
|
|
69
|
+
* source it opens at the last good value and its first call is the failure; with no value to start at it throws the
|
|
70
|
+
* failure.
|
|
71
|
+
*/
|
|
72
|
+
openWatch(context: Context): Watch<JsonValue>;
|
|
73
|
+
/** What a new watch starts at; a source that can fail and recover tells its failure (`WatchStart`). */
|
|
74
|
+
start(): WatchStart;
|
|
75
|
+
/** Feeds `subscriber` every frame from now on, inside each batch; the caller took the current value first. */
|
|
76
|
+
subscribe(subscriber: Subscriber): void;
|
|
77
|
+
unsubscribe(subscriber: Subscriber): void;
|
|
78
|
+
/** Delivers this batch's frame to its watches; called once per batch that listed it with `changed`. */
|
|
79
|
+
abstract deliver(context: Context): void;
|
|
80
|
+
/** Records a change in the current batch: listed for a frame when watched, and every dependent marked dirty. */
|
|
81
|
+
protected changed(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Records a retirement of this source's document in the current batch: every derive reading it, directly or
|
|
84
|
+
* through other derives, carries the flag on in its frame (rule 21). Called after `changed`.
|
|
85
|
+
*/
|
|
86
|
+
protected retiredInBatch(): void;
|
|
87
|
+
/** Queues one frame on every watch and feeds it to every subscriber. */
|
|
88
|
+
protected publish(value: JsonValue, ops: readonly Op[], retired: boolean, context: Context): void;
|
|
89
|
+
/** Queues `call` on every watch and feeds it to every subscriber, as it is (a reference's member passes one on). */
|
|
90
|
+
protected forward(call: WatchCall<JsonValue>, context: Context): void;
|
|
91
|
+
/**
|
|
92
|
+
* Gives every watch and subscriber one failure call (design §11): the source cannot compute its value now and may
|
|
93
|
+
* recover; they stay open, and its next value is `[["r", value]]`.
|
|
94
|
+
*/
|
|
95
|
+
protected failWatches(error: unknown, context: Context): void;
|
|
96
|
+
/**
|
|
97
|
+
* Ends every watch and subscriber for good once what they were given is delivered (a followed runtime ended after a
|
|
98
|
+
* last call, Durable's `endAfterDelivery`): `ended`; nothing follows.
|
|
99
|
+
*/
|
|
100
|
+
protected endWatchesAfterDelivery(): void;
|
|
101
|
+
/** Ends every watch and subscriber for good (its owner ended): `ended`; nothing follows. */
|
|
102
|
+
protected endWatches(): void;
|
|
103
|
+
}
|
|
104
|
+
/** A watchable that never changes (start data, §18); usable as a state member and as a derive source. */
|
|
105
|
+
export declare function constant<const T extends JsonValue>(value: T): Watchable<T>;
|
|
106
|
+
/** The watchable behind `constant(value)`: its watches never get a frame and end only by stop or cancellation. */
|
|
107
|
+
export declare class Constant implements Watchable<JsonValue> {
|
|
108
|
+
readonly value: JsonValue;
|
|
109
|
+
constructor(value: JsonValue);
|
|
110
|
+
watch(context: Context): Promise<Watch<JsonValue>>;
|
|
111
|
+
/** As `Source.openWatch`; nothing is delivered, so nothing is reported. */
|
|
112
|
+
openWatch(context: Context): Watch<JsonValue>;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=watchable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchable.d.ts","sourceRoot":"","sources":["../../src/state/watchable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IA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AAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAQ5C;CACD"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Chord's JSON watchables: sources (documents and derives, with their watches and dependent derives) and constants.
|
|
2
|
+
import { Watch } from "../watch.js";
|
|
3
|
+
/**
|
|
4
|
+
* An error Chord hands to apps (a failure call, a report), its stack made text first: until then V8 keeps the frames'
|
|
5
|
+
* receivers, which would keep the host behind the throw alive for as long as an app keeps the error.
|
|
6
|
+
*/
|
|
7
|
+
export function handedOut(error) {
|
|
8
|
+
if (error instanceof Error)
|
|
9
|
+
void error.stack;
|
|
10
|
+
return error;
|
|
11
|
+
}
|
|
12
|
+
const ENDED = { kind: "ended" };
|
|
13
|
+
/**
|
|
14
|
+
* A changing value on a host (a singleton document, a derive, a replica): its watches and subscribers get one frame
|
|
15
|
+
* per batch that changed it, and the derives reading it are marked dirty when it changes.
|
|
16
|
+
*/
|
|
17
|
+
export class Source {
|
|
18
|
+
/** Derives reading this source (and references' members forwarding to some); each removes itself when it stops. */
|
|
19
|
+
dependents = new Set();
|
|
20
|
+
batch;
|
|
21
|
+
/** Its watches and subscribers, each made by its first: most sources (a reference's members) never have one. */
|
|
22
|
+
#watches;
|
|
23
|
+
#subscribers;
|
|
24
|
+
constructor(batch) {
|
|
25
|
+
this.batch = batch;
|
|
26
|
+
}
|
|
27
|
+
/** Whether a watch or a subscriber follows this source. */
|
|
28
|
+
get watched() {
|
|
29
|
+
return (this.#watches?.size ?? 0) > 0 || (this.#subscribers?.size ?? 0) > 0;
|
|
30
|
+
}
|
|
31
|
+
async watch(context) {
|
|
32
|
+
return this.openWatch(context);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `watch` without the Promise, for references, which must register the watch before anything else runs. On a failed
|
|
36
|
+
* source it opens at the last good value and its first call is the failure; with no value to start at it throws the
|
|
37
|
+
* failure.
|
|
38
|
+
*/
|
|
39
|
+
openWatch(context) {
|
|
40
|
+
this.batch.assertOutside("watch");
|
|
41
|
+
const start = this.start();
|
|
42
|
+
if (start.kind === "failed" && start.last === undefined)
|
|
43
|
+
throw start.error;
|
|
44
|
+
const value = start.kind === "value" ? start.value : start.last;
|
|
45
|
+
this.#watches ??= new Set();
|
|
46
|
+
const watches = this.#watches;
|
|
47
|
+
const watch = new Watch(value, () => watches.delete(watch), this.batch.reportListener);
|
|
48
|
+
watches.add(watch);
|
|
49
|
+
if (context.abortSignal !== undefined)
|
|
50
|
+
watch.observeAbort(context.abortSignal);
|
|
51
|
+
if (start.kind === "failed")
|
|
52
|
+
watch.fail(start.error, context);
|
|
53
|
+
return watch;
|
|
54
|
+
}
|
|
55
|
+
/** What a new watch starts at; a source that can fail and recover tells its failure (`WatchStart`). */
|
|
56
|
+
start() {
|
|
57
|
+
return { kind: "value", value: this.value };
|
|
58
|
+
}
|
|
59
|
+
/** Feeds `subscriber` every frame from now on, inside each batch; the caller took the current value first. */
|
|
60
|
+
subscribe(subscriber) {
|
|
61
|
+
this.#subscribers ??= new Set();
|
|
62
|
+
this.#subscribers.add(subscriber);
|
|
63
|
+
}
|
|
64
|
+
unsubscribe(subscriber) {
|
|
65
|
+
this.#subscribers?.delete(subscriber);
|
|
66
|
+
}
|
|
67
|
+
/** Records a change in the current batch: listed for a frame when watched, and every dependent marked dirty. */
|
|
68
|
+
changed() {
|
|
69
|
+
if (this.watched)
|
|
70
|
+
this.batch.changed(this);
|
|
71
|
+
for (const derive of this.dependents)
|
|
72
|
+
derive.invalidate();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Records a retirement of this source's document in the current batch: every derive reading it, directly or
|
|
76
|
+
* through other derives, carries the flag on in its frame (rule 21). Called after `changed`.
|
|
77
|
+
*/
|
|
78
|
+
retiredInBatch() {
|
|
79
|
+
// Allocated only for a retirement, which is rare.
|
|
80
|
+
const visited = new Set();
|
|
81
|
+
for (const derive of this.dependents)
|
|
82
|
+
derive.sourceRetired(visited);
|
|
83
|
+
}
|
|
84
|
+
/** Queues one frame on every watch and feeds it to every subscriber. */
|
|
85
|
+
publish(value, ops, retired, context) {
|
|
86
|
+
this.forward({ kind: "value", value, ops, retired }, context);
|
|
87
|
+
}
|
|
88
|
+
/** Queues `call` on every watch and feeds it to every subscriber, as it is (a reference's member passes one on). */
|
|
89
|
+
forward(call, context) {
|
|
90
|
+
if (this.#watches !== undefined)
|
|
91
|
+
for (const watch of this.#watches)
|
|
92
|
+
watch.advance(call, context);
|
|
93
|
+
if (this.#subscribers !== undefined)
|
|
94
|
+
for (const subscriber of this.#subscribers)
|
|
95
|
+
subscriber.advance(call, context);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gives every watch and subscriber one failure call (design §11): the source cannot compute its value now and may
|
|
99
|
+
* recover; they stay open, and its next value is `[["r", value]]`.
|
|
100
|
+
*/
|
|
101
|
+
failWatches(error, context) {
|
|
102
|
+
this.forward({ kind: "failed", error: handedOut(error) }, context);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Ends every watch and subscriber for good once what they were given is delivered (a followed runtime ended after a
|
|
106
|
+
* last call, Durable's `endAfterDelivery`): `ended`; nothing follows.
|
|
107
|
+
*/
|
|
108
|
+
endWatchesAfterDelivery() {
|
|
109
|
+
if (this.#watches !== undefined)
|
|
110
|
+
for (const watch of [...this.#watches])
|
|
111
|
+
watch.endAfterDelivery();
|
|
112
|
+
if (this.#subscribers === undefined || this.#subscribers.size === 0)
|
|
113
|
+
return;
|
|
114
|
+
const subscribers = [...this.#subscribers];
|
|
115
|
+
this.#subscribers.clear();
|
|
116
|
+
for (const subscriber of subscribers)
|
|
117
|
+
subscriber.endAfterDelivery();
|
|
118
|
+
}
|
|
119
|
+
/** Ends every watch and subscriber for good (its owner ended): `ended`; nothing follows. */
|
|
120
|
+
endWatches() {
|
|
121
|
+
// Ending detaches, which deletes the current entry (safe while iterating) and runs no listener.
|
|
122
|
+
if (this.#watches !== undefined)
|
|
123
|
+
for (const watch of this.#watches)
|
|
124
|
+
watch.end(ENDED);
|
|
125
|
+
if (this.#subscribers === undefined || this.#subscribers.size === 0)
|
|
126
|
+
return;
|
|
127
|
+
// A copy: a subscriber may unsubscribe as it ends.
|
|
128
|
+
const subscribers = [...this.#subscribers];
|
|
129
|
+
this.#subscribers.clear();
|
|
130
|
+
for (const subscriber of subscribers)
|
|
131
|
+
subscriber.end(ENDED);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** A watchable that never changes (start data, §18); usable as a state member and as a derive source. */
|
|
135
|
+
export function constant(value) {
|
|
136
|
+
// The constant holds `value` as it was given.
|
|
137
|
+
return new Constant(value);
|
|
138
|
+
}
|
|
139
|
+
/** The watchable behind `constant(value)`: its watches never get a frame and end only by stop or cancellation. */
|
|
140
|
+
export class Constant {
|
|
141
|
+
value;
|
|
142
|
+
constructor(value) {
|
|
143
|
+
this.value = value;
|
|
144
|
+
}
|
|
145
|
+
async watch(context) {
|
|
146
|
+
return this.openWatch(context);
|
|
147
|
+
}
|
|
148
|
+
/** As `Source.openWatch`; nothing is delivered, so nothing is reported. */
|
|
149
|
+
openWatch(context) {
|
|
150
|
+
const watch = new Watch(this.value, () => { }, () => { });
|
|
151
|
+
if (context.abortSignal !== undefined)
|
|
152
|
+
watch.observeAbort(context.abortSignal);
|
|
153
|
+
return watch;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=watchable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchable.js","sourceRoot":"","sources":["../../src/state/watchable.ts"],"names":[],"mappings":"AAAA,oHAAoH;AAKpH,OAAO,EAAE,KAAK,EAAiD,MAAM,aAAa,CAAC;AAgCnF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAI,KAAQ;IACpC,IAAI,KAAK,YAAY,KAAK;QAAE,KAAK,KAAK,CAAC,KAAK,CAAC;IAC7C,OAAO,KAAK,CAAC;AACd,CAAC;AAaD,MAAM,KAAK,GAAa,EAAE,IAAI,EAAE,OAAO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,IAAI,IAAI,CAAC,QAAQ;gBAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrF,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO;QAC5E,mDAAmD;QACnD,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,KAAK,MAAM,UAAU,IAAI,WAAW;YAAE,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACD;AAED,yGAAyG;AACzG,MAAM,UAAU,QAAQ,CAA4B,KAAQ;IAC3D,8CAA8C;IAC9C,OAAO,IAAI,QAAQ,CAAC,KAAK,CAA4B,CAAC;AACvD,CAAC;AAED,kHAAkH;AAClH,MAAM,OAAO,QAAQ;IACX,KAAK,CAAY;IAE1B,YAAY,KAAgB;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,2EAA2E;IAC3E,SAAS,CAAC,OAAgB;QACzB,MAAM,KAAK,GAAG,IAAI,KAAK,CACtB,IAAI,CAAC,KAAK,EACV,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,CACR,CAAC;QACF,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;YAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC/E,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["// Chord's JSON watchables: sources (documents and derives, with their watches and dependent derives) and constants.\n\nimport type { Context } from \"../context/index.ts\";\nimport type { Op } from \"../delta/index.ts\";\nimport type { JsonValue } from \"../json.ts\";\nimport { Watch, type Watchable, type WatchCall, type WatchEnd } from \"../watch.ts\";\nimport type { Batch } from \"./batch.ts\";\n\n/**\n * A synchronous subscriber of a source (a hold over a link, a reference's member): fed the source's call inside the batch\n * that made it, before the batch ends, so everything one commit changed can leave in one message. The watch's own sink\n * shape (`Watch.advance`, `Watch.end`).\n */\nexport interface Subscriber {\n\t/**\n\t * The source's call of this batch, in its batch's `context`: a value (the ops from the previous one, and whether its\n\t * document was retired in it, or for a derive one of its sources' documents), or a failure it may recover from; the\n\t * next value after a failure is `[[\"r\", value]]`.\n\t */\n\tadvance(call: WatchCall<JsonValue>, context: Context): void;\n\t/** The source ended for good with `end`; nothing follows, and the subscriber is dropped. */\n\tend(end: WatchEnd): void;\n\t/**\n\t * The source ended for good after its last call (a followed runtime ended): a subscriber delivering later (a watch)\n\t * ends `ended` once it delivered what it was given, others end now.\n\t */\n\tendAfterDelivery(): void;\n}\n\n/**\n * What a new watch of a source starts at (design §11): its value, or, while it is failed, the failure and its last good\n * value (`undefined` when it never had one: a watch cannot start then, there is nothing to start at).\n */\nexport type WatchStart =\n\t| { readonly kind: \"value\"; readonly value: JsonValue }\n\t| { readonly kind: \"failed\"; readonly error: unknown; readonly last: JsonValue | undefined };\n\n/**\n * An error Chord hands to apps (a failure call, a report), its stack made text first: until then V8 keeps the frames'\n * receivers, which would keep the host behind the throw alive for as long as an app keeps the error.\n */\nexport function handedOut<E>(error: E): E {\n\tif (error instanceof Error) void error.stack;\n\treturn error;\n}\n\n/**\n * What reads a source and is marked by its changes: a derive, or a reference's member forwarding to derives (`Source.\n * dependents`).\n */\nexport interface Dependent {\n\t/** The source changed in the current batch: flags only, no compute. */\n\tinvalidate(): void;\n\t/** A source's document was retired in the current batch (rule 21); `visited` keeps a diamond walked once. */\n\tsourceRetired(visited: Set<Dependent>): void;\n}\n\nconst ENDED: WatchEnd = { kind: \"ended\" };\n\n/**\n * A changing value on a host (a singleton document, a derive, a replica): its watches and subscribers get one frame\n * per batch that changed it, and the derives reading it are marked dirty when it changes.\n */\nexport abstract class Source implements Watchable<JsonValue> {\n\t/** Derives reading this source (and references' members forwarding to some); each removes itself when it stops. */\n\treadonly dependents = new Set<Dependent>();\n\tprotected readonly batch: Batch;\n\t/** Its watches and subscribers, each made by its first: most sources (a reference's members) never have one. */\n\t#watches: Set<Watch<JsonValue>> | undefined;\n\t#subscribers: Set<Subscriber> | undefined;\n\n\tconstructor(batch: Batch) {\n\t\tthis.batch = batch;\n\t}\n\n\tabstract get value(): JsonValue;\n\n\t/** Whether a watch or a subscriber follows this source. */\n\tget watched(): boolean {\n\t\treturn (this.#watches?.size ?? 0) > 0 || (this.#subscribers?.size ?? 0) > 0;\n\t}\n\n\tasync watch(context: Context): Promise<Watch<JsonValue>> {\n\t\treturn this.openWatch(context);\n\t}\n\n\t/**\n\t * `watch` without the Promise, for references, which must register the watch before anything else runs. On a failed\n\t * source it opens at the last good value and its first call is the failure; with no value to start at it throws the\n\t * failure.\n\t */\n\topenWatch(context: Context): Watch<JsonValue> {\n\t\tthis.batch.assertOutside(\"watch\");\n\t\tconst start = this.start();\n\t\tif (start.kind === \"failed\" && start.last === undefined) throw start.error;\n\t\tconst value = start.kind === \"value\" ? start.value : start.last!;\n\t\tthis.#watches ??= new Set();\n\t\tconst watches = this.#watches;\n\t\tconst watch: Watch<JsonValue> = new Watch(value, () => watches.delete(watch), this.batch.reportListener);\n\t\twatches.add(watch);\n\t\tif (context.abortSignal !== undefined) watch.observeAbort(context.abortSignal);\n\t\tif (start.kind === \"failed\") watch.fail(start.error, context);\n\t\treturn watch;\n\t}\n\n\t/** What a new watch starts at; a source that can fail and recover tells its failure (`WatchStart`). */\n\tstart(): WatchStart {\n\t\treturn { kind: \"value\", value: this.value };\n\t}\n\n\t/** Feeds `subscriber` every frame from now on, inside each batch; the caller took the current value first. */\n\tsubscribe(subscriber: Subscriber): void {\n\t\tthis.#subscribers ??= new Set();\n\t\tthis.#subscribers.add(subscriber);\n\t}\n\n\tunsubscribe(subscriber: Subscriber): void {\n\t\tthis.#subscribers?.delete(subscriber);\n\t}\n\n\t/** Delivers this batch's frame to its watches; called once per batch that listed it with `changed`. */\n\tabstract deliver(context: Context): void;\n\n\t/** Records a change in the current batch: listed for a frame when watched, and every dependent marked dirty. */\n\tprotected changed(): void {\n\t\tif (this.watched) this.batch.changed(this);\n\t\tfor (const derive of this.dependents) derive.invalidate();\n\t}\n\n\t/**\n\t * Records a retirement of this source's document in the current batch: every derive reading it, directly or\n\t * through other derives, carries the flag on in its frame (rule 21). Called after `changed`.\n\t */\n\tprotected retiredInBatch(): void {\n\t\t// Allocated only for a retirement, which is rare.\n\t\tconst visited = new Set<Dependent>();\n\t\tfor (const derive of this.dependents) derive.sourceRetired(visited);\n\t}\n\n\t/** Queues one frame on every watch and feeds it to every subscriber. */\n\tprotected publish(value: JsonValue, ops: readonly Op[], retired: boolean, context: Context): void {\n\t\tthis.forward({ kind: \"value\", value, ops, retired }, context);\n\t}\n\n\t/** Queues `call` on every watch and feeds it to every subscriber, as it is (a reference's member passes one on). */\n\tprotected forward(call: WatchCall<JsonValue>, context: Context): void {\n\t\tif (this.#watches !== undefined) for (const watch of this.#watches) watch.advance(call, context);\n\t\tif (this.#subscribers !== undefined)\n\t\t\tfor (const subscriber of this.#subscribers) subscriber.advance(call, context);\n\t}\n\n\t/**\n\t * Gives every watch and subscriber one failure call (design §11): the source cannot compute its value now and may\n\t * recover; they stay open, and its next value is `[[\"r\", value]]`.\n\t */\n\tprotected failWatches(error: unknown, context: Context): void {\n\t\tthis.forward({ kind: \"failed\", error: handedOut(error) }, context);\n\t}\n\n\t/**\n\t * Ends every watch and subscriber for good once what they were given is delivered (a followed runtime ended after a\n\t * last call, Durable's `endAfterDelivery`): `ended`; nothing follows.\n\t */\n\tprotected endWatchesAfterDelivery(): void {\n\t\tif (this.#watches !== undefined) for (const watch of [...this.#watches]) watch.endAfterDelivery();\n\t\tif (this.#subscribers === undefined || this.#subscribers.size === 0) return;\n\t\tconst subscribers = [...this.#subscribers];\n\t\tthis.#subscribers.clear();\n\t\tfor (const subscriber of subscribers) subscriber.endAfterDelivery();\n\t}\n\n\t/** Ends every watch and subscriber for good (its owner ended): `ended`; nothing follows. */\n\tprotected endWatches(): void {\n\t\t// Ending detaches, which deletes the current entry (safe while iterating) and runs no listener.\n\t\tif (this.#watches !== undefined) for (const watch of this.#watches) watch.end(ENDED);\n\t\tif (this.#subscribers === undefined || this.#subscribers.size === 0) return;\n\t\t// A copy: a subscriber may unsubscribe as it ends.\n\t\tconst subscribers = [...this.#subscribers];\n\t\tthis.#subscribers.clear();\n\t\tfor (const subscriber of subscribers) subscriber.end(ENDED);\n\t}\n}\n\n/** A watchable that never changes (start data, §18); usable as a state member and as a derive source. */\nexport function constant<const T extends JsonValue>(value: T): Watchable<T> {\n\t// The constant holds `value` as it was given.\n\treturn new Constant(value) as unknown as Watchable<T>;\n}\n\n/** The watchable behind `constant(value)`: its watches never get a frame and end only by stop or cancellation. */\nexport class Constant implements Watchable<JsonValue> {\n\treadonly value: JsonValue;\n\n\tconstructor(value: JsonValue) {\n\t\tthis.value = value;\n\t}\n\n\tasync watch(context: Context): Promise<Watch<JsonValue>> {\n\t\treturn this.openWatch(context);\n\t}\n\n\t/** As `Source.openWatch`; nothing is delivered, so nothing is reported. */\n\topenWatch(context: Context): Watch<JsonValue> {\n\t\tconst watch = new Watch<JsonValue>(\n\t\t\tthis.value,\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tif (context.abortSignal !== undefined) watch.observeAbort(context.abortSignal);\n\t\treturn watch;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import type { NativeWatchable } from "../watch.ts";
|
|
3
|
+
import type { Batch } from "./batch.ts";
|
|
4
|
+
import { FollowedSource } from "./native-source.ts";
|
|
5
|
+
/** An in-process value that changes when its owner sets it; `set` of the same value notifies nobody. */
|
|
6
|
+
export interface Writable<T> extends NativeWatchable<T> {
|
|
7
|
+
/**
|
|
8
|
+
* Sets the value: a new value (by identity) is a new frame for its watches and marks the derives and registry
|
|
9
|
+
* tables reading it, in the batch running now or in one of its own. Throws `released` once its attempt ended, and
|
|
10
|
+
* `invalid/reentrant` inside a derive compute or a `compose`.
|
|
11
|
+
*/
|
|
12
|
+
set(value: T): void;
|
|
13
|
+
}
|
|
14
|
+
/** Who owns a writable: the context its own batches run in, and the check that its attempt still runs. */
|
|
15
|
+
export type WritableOwner = {
|
|
16
|
+
readonly context: Context;
|
|
17
|
+
/** Throws `released` once the attempt that made it was sealed. */
|
|
18
|
+
assertUsable(): void;
|
|
19
|
+
};
|
|
20
|
+
/** A writable: its value, set by its owner's code, delivered through the host's batch. */
|
|
21
|
+
export declare class WritableSource<T> extends FollowedSource<T> implements Writable<T> {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(initial: T, owner: WritableOwner, batch: Batch);
|
|
24
|
+
get value(): T;
|
|
25
|
+
set(value: T): void;
|
|
26
|
+
/**
|
|
27
|
+
* Its attempt ended with `error`: its watches end `ended`, `set` throws `error`, its value stays readable; it keeps
|
|
28
|
+
* neither its attempt nor the host.
|
|
29
|
+
*/
|
|
30
|
+
detach(error: Error): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=writable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writable.d.ts","sourceRoot":"","sources":["../../src/state/writable.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wGAAwG;AACxG,MAAM,WAAW,QAAQ,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACpB;AAED,0GAA0G;AAC1G,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kEAAkE;IAClE,YAAY,IAAI,IAAI,CAAC;CACrB,CAAC;AAOF,0FAA0F;AAC1F,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;;IAI9E,YAAY,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAIzD;IAED,IAAI,KAAK,IAAI,CAAC,CAEb;IAED,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CASlB;IAaD;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAKzB;CACD"}
|