@mostra/protocol 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +38 -2
- package/dist/actions.d.ts +273 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +154 -0
- package/dist/actions.js.map +1 -0
- package/dist/artifact.d.ts +113 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +79 -0
- package/dist/artifact.js.map +1 -0
- package/dist/bridge.d.ts +295 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +343 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser.d.ts +195 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +156 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.d.ts +155 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +130 -0
- package/dist/bundle.js.map +1 -0
- package/dist/canonical.d.ts +23 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +45 -0
- package/dist/canonical.js.map +1 -0
- package/dist/capability.d.ts +38 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +61 -0
- package/dist/capability.js.map +1 -0
- package/dist/diagnostics/codes/a11y.d.ts +8 -0
- package/dist/diagnostics/codes/a11y.d.ts.map +1 -0
- package/dist/diagnostics/codes/a11y.js +30 -0
- package/dist/diagnostics/codes/a11y.js.map +1 -0
- package/dist/diagnostics/codes/action.d.ts +8 -0
- package/dist/diagnostics/codes/action.d.ts.map +1 -0
- package/dist/diagnostics/codes/action.js +110 -0
- package/dist/diagnostics/codes/action.js.map +1 -0
- package/dist/diagnostics/codes/artifact.d.ts +8 -0
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -0
- package/dist/diagnostics/codes/artifact.js +121 -0
- package/dist/diagnostics/codes/artifact.js.map +1 -0
- package/dist/diagnostics/codes/build.d.ts +8 -0
- package/dist/diagnostics/codes/build.d.ts.map +1 -0
- package/dist/diagnostics/codes/build.js +55 -0
- package/dist/diagnostics/codes/build.js.map +1 -0
- package/dist/diagnostics/codes/cli.d.ts +8 -0
- package/dist/diagnostics/codes/cli.d.ts.map +1 -0
- package/dist/diagnostics/codes/cli.js +44 -0
- package/dist/diagnostics/codes/cli.js.map +1 -0
- package/dist/diagnostics/codes/console.d.ts +8 -0
- package/dist/diagnostics/codes/console.d.ts.map +1 -0
- package/dist/diagnostics/codes/console.js +30 -0
- package/dist/diagnostics/codes/console.js.map +1 -0
- package/dist/diagnostics/codes/dep.d.ts +8 -0
- package/dist/diagnostics/codes/dep.d.ts.map +1 -0
- package/dist/diagnostics/codes/dep.js +88 -0
- package/dist/diagnostics/codes/dep.js.map +1 -0
- package/dist/diagnostics/codes/env.d.ts +8 -0
- package/dist/diagnostics/codes/env.d.ts.map +1 -0
- package/dist/diagnostics/codes/env.js +132 -0
- package/dist/diagnostics/codes/env.js.map +1 -0
- package/dist/diagnostics/codes/field.d.ts +8 -0
- package/dist/diagnostics/codes/field.d.ts.map +1 -0
- package/dist/diagnostics/codes/field.js +99 -0
- package/dist/diagnostics/codes/field.js.map +1 -0
- package/dist/diagnostics/codes/home.d.ts +8 -0
- package/dist/diagnostics/codes/home.d.ts.map +1 -0
- package/dist/diagnostics/codes/home.js +132 -0
- package/dist/diagnostics/codes/home.js.map +1 -0
- package/dist/diagnostics/codes/host.d.ts +8 -0
- package/dist/diagnostics/codes/host.d.ts.map +1 -0
- package/dist/diagnostics/codes/host.js +176 -0
- package/dist/diagnostics/codes/host.js.map +1 -0
- package/dist/diagnostics/codes/hygiene.d.ts +8 -0
- package/dist/diagnostics/codes/hygiene.d.ts.map +1 -0
- package/dist/diagnostics/codes/hygiene.js +154 -0
- package/dist/diagnostics/codes/hygiene.js.map +1 -0
- package/dist/diagnostics/codes/index.d.ts +51 -0
- package/dist/diagnostics/codes/index.d.ts.map +1 -0
- package/dist/diagnostics/codes/index.js +72 -0
- package/dist/diagnostics/codes/index.js.map +1 -0
- package/dist/diagnostics/codes/live.d.ts +8 -0
- package/dist/diagnostics/codes/live.d.ts.map +1 -0
- package/dist/diagnostics/codes/live.js +30 -0
- package/dist/diagnostics/codes/live.js.map +1 -0
- package/dist/diagnostics/codes/manifest.d.ts +8 -0
- package/dist/diagnostics/codes/manifest.d.ts.map +1 -0
- package/dist/diagnostics/codes/manifest.js +44 -0
- package/dist/diagnostics/codes/manifest.js.map +1 -0
- package/dist/diagnostics/codes/network.d.ts +8 -0
- package/dist/diagnostics/codes/network.d.ts.map +1 -0
- package/dist/diagnostics/codes/network.js +30 -0
- package/dist/diagnostics/codes/network.js.map +1 -0
- package/dist/diagnostics/codes/platform.d.ts +8 -0
- package/dist/diagnostics/codes/platform.d.ts.map +1 -0
- package/dist/diagnostics/codes/platform.js +18 -0
- package/dist/diagnostics/codes/platform.js.map +1 -0
- package/dist/diagnostics/codes/publish.d.ts +8 -0
- package/dist/diagnostics/codes/publish.d.ts.map +1 -0
- package/dist/diagnostics/codes/publish.js +44 -0
- package/dist/diagnostics/codes/publish.js.map +1 -0
- package/dist/diagnostics/codes/regression.d.ts +8 -0
- package/dist/diagnostics/codes/regression.d.ts.map +1 -0
- package/dist/diagnostics/codes/regression.js +77 -0
- package/dist/diagnostics/codes/regression.js.map +1 -0
- package/dist/diagnostics/codes/runtime.d.ts +8 -0
- package/dist/diagnostics/codes/runtime.d.ts.map +1 -0
- package/dist/diagnostics/codes/runtime.js +66 -0
- package/dist/diagnostics/codes/runtime.js.map +1 -0
- package/dist/diagnostics/codes/secret.d.ts +8 -0
- package/dist/diagnostics/codes/secret.d.ts.map +1 -0
- package/dist/diagnostics/codes/secret.js +18 -0
- package/dist/diagnostics/codes/secret.js.map +1 -0
- package/dist/diagnostics/codes/smoke.d.ts +8 -0
- package/dist/diagnostics/codes/smoke.d.ts.map +1 -0
- package/dist/diagnostics/codes/smoke.js +30 -0
- package/dist/diagnostics/codes/smoke.js.map +1 -0
- package/dist/diagnostics/codes/submit.d.ts +8 -0
- package/dist/diagnostics/codes/submit.d.ts.map +1 -0
- package/dist/diagnostics/codes/submit.js +99 -0
- package/dist/diagnostics/codes/submit.js.map +1 -0
- package/dist/diagnostics/codes/target.d.ts +8 -0
- package/dist/diagnostics/codes/target.d.ts.map +1 -0
- package/dist/diagnostics/codes/target.js +18 -0
- package/dist/diagnostics/codes/target.js.map +1 -0
- package/dist/diagnostics/codes/type.d.ts +8 -0
- package/dist/diagnostics/codes/type.d.ts.map +1 -0
- package/dist/diagnostics/codes/type.js +30 -0
- package/dist/diagnostics/codes/type.js.map +1 -0
- package/dist/diagnostics/codes/verify.d.ts +8 -0
- package/dist/diagnostics/codes/verify.d.ts.map +1 -0
- package/dist/diagnostics/codes/verify.js +99 -0
- package/dist/diagnostics/codes/verify.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +79 -0
- package/dist/diagnostics/diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic.js +131 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/spec.d.ts +49 -0
- package/dist/diagnostics/spec.d.ts.map +1 -0
- package/dist/diagnostics/spec.js +31 -0
- package/dist/diagnostics/spec.js.map +1 -0
- package/dist/hygiene.d.ts +66 -0
- package/dist/hygiene.d.ts.map +1 -0
- package/dist/hygiene.js +134 -0
- package/dist/hygiene.js.map +1 -0
- package/dist/ids.d.ts +119 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +135 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +86 -0
- package/dist/interaction.d.ts +391 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +306 -0
- package/dist/interaction.js.map +1 -0
- package/dist/manifest.d.ts +97 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +101 -0
- package/dist/manifest.js.map +1 -0
- package/dist/method.d.ts +26 -0
- package/dist/method.d.ts.map +1 -0
- package/dist/method.js +10 -0
- package/dist/method.js.map +1 -0
- package/dist/methods/artifact/create.d.ts +29 -0
- package/dist/methods/artifact/create.d.ts.map +1 -0
- package/dist/methods/artifact/create.js +31 -0
- package/dist/methods/artifact/create.js.map +1 -0
- package/dist/methods/artifact/get.d.ts +17 -0
- package/dist/methods/artifact/get.d.ts.map +1 -0
- package/dist/methods/artifact/get.js +21 -0
- package/dist/methods/artifact/get.js.map +1 -0
- package/dist/methods/artifact/list.d.ts +22 -0
- package/dist/methods/artifact/list.d.ts.map +1 -0
- package/dist/methods/artifact/list.js +19 -0
- package/dist/methods/artifact/list.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +28 -0
- package/dist/methods/artifact/publish.d.ts.map +1 -0
- package/dist/methods/artifact/publish.js +28 -0
- package/dist/methods/artifact/publish.js.map +1 -0
- package/dist/methods/artifact/verify.d.ts +29 -0
- package/dist/methods/artifact/verify.d.ts.map +1 -0
- package/dist/methods/artifact/verify.js +27 -0
- package/dist/methods/artifact/verify.js.map +1 -0
- package/dist/methods/deps/add.d.ts +43 -0
- package/dist/methods/deps/add.d.ts.map +1 -0
- package/dist/methods/deps/add.js +40 -0
- package/dist/methods/deps/add.js.map +1 -0
- package/dist/methods/dev/start.d.ts +52 -0
- package/dist/methods/dev/start.d.ts.map +1 -0
- package/dist/methods/dev/start.js +56 -0
- package/dist/methods/dev/start.js.map +1 -0
- package/dist/methods/dev/stop.d.ts +16 -0
- package/dist/methods/dev/stop.d.ts.map +1 -0
- package/dist/methods/dev/stop.js +21 -0
- package/dist/methods/dev/stop.js.map +1 -0
- package/dist/methods/events/ack.d.ts +20 -0
- package/dist/methods/events/ack.d.ts.map +1 -0
- package/dist/methods/events/ack.js +26 -0
- package/dist/methods/events/ack.js.map +1 -0
- package/dist/methods/events/read.d.ts +40 -0
- package/dist/methods/events/read.d.ts.map +1 -0
- package/dist/methods/events/read.js +35 -0
- package/dist/methods/events/read.js.map +1 -0
- package/dist/methods/events/subscribe.d.ts +54 -0
- package/dist/methods/events/subscribe.d.ts.map +1 -0
- package/dist/methods/events/subscribe.js +44 -0
- package/dist/methods/events/subscribe.js.map +1 -0
- package/dist/methods/events/unsubscribe.d.ts +16 -0
- package/dist/methods/events/unsubscribe.d.ts.map +1 -0
- package/dist/methods/events/unsubscribe.js +21 -0
- package/dist/methods/events/unsubscribe.js.map +1 -0
- package/dist/methods/gc/run.d.ts +76 -0
- package/dist/methods/gc/run.d.ts.map +1 -0
- package/dist/methods/gc/run.js +56 -0
- package/dist/methods/gc/run.js.map +1 -0
- package/dist/methods/index.d.ts +6 -0
- package/dist/methods/index.d.ts.map +1 -0
- package/dist/methods/index.js +78 -0
- package/dist/methods/index.js.map +1 -0
- package/dist/methods/instance/check.d.ts +30 -0
- package/dist/methods/instance/check.d.ts.map +1 -0
- package/dist/methods/instance/check.js +34 -0
- package/dist/methods/instance/check.js.map +1 -0
- package/dist/methods/instance/status.d.ts +102 -0
- package/dist/methods/instance/status.d.ts.map +1 -0
- package/dist/methods/instance/status.js +83 -0
- package/dist/methods/instance/status.js.map +1 -0
- package/dist/methods/live/push.d.ts +28 -0
- package/dist/methods/live/push.d.ts.map +1 -0
- package/dist/methods/live/push.js +35 -0
- package/dist/methods/live/push.js.map +1 -0
- package/dist/methods/mostra/initialize.d.ts +143 -0
- package/dist/methods/mostra/initialize.d.ts.map +1 -0
- package/dist/methods/mostra/initialize.js +97 -0
- package/dist/methods/mostra/initialize.js.map +1 -0
- package/dist/methods/mostra/shutdown.d.ts +14 -0
- package/dist/methods/mostra/shutdown.d.ts.map +1 -0
- package/dist/methods/mostra/shutdown.js +22 -0
- package/dist/methods/mostra/shutdown.js.map +1 -0
- package/dist/methods/port/drafts-mirror.d.ts +30 -0
- package/dist/methods/port/drafts-mirror.d.ts.map +1 -0
- package/dist/methods/port/drafts-mirror.js +33 -0
- package/dist/methods/port/drafts-mirror.js.map +1 -0
- package/dist/methods/port/secrets-get.d.ts +19 -0
- package/dist/methods/port/secrets-get.d.ts.map +1 -0
- package/dist/methods/port/secrets-get.js +31 -0
- package/dist/methods/port/secrets-get.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +38 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -0
- package/dist/methods/port/submissions-deliver.js +38 -0
- package/dist/methods/port/submissions-deliver.js.map +1 -0
- package/dist/methods/port/trusted-controls-activated.d.ts +27 -0
- package/dist/methods/port/trusted-controls-activated.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-activated.js +33 -0
- package/dist/methods/port/trusted-controls-activated.js.map +1 -0
- package/dist/methods/port/trusted-controls-policy.d.ts +21 -0
- package/dist/methods/port/trusted-controls-policy.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-policy.js +27 -0
- package/dist/methods/port/trusted-controls-policy.js.map +1 -0
- package/dist/methods/results/get.d.ts +32 -0
- package/dist/methods/results/get.d.ts.map +1 -0
- package/dist/methods/results/get.js +36 -0
- package/dist/methods/results/get.js.map +1 -0
- package/dist/methods/secret/delete.d.ts +22 -0
- package/dist/methods/secret/delete.d.ts.map +1 -0
- package/dist/methods/secret/delete.js +32 -0
- package/dist/methods/secret/delete.js.map +1 -0
- package/dist/methods/secret/list.d.ts +21 -0
- package/dist/methods/secret/list.d.ts.map +1 -0
- package/dist/methods/secret/list.js +29 -0
- package/dist/methods/secret/list.js.map +1 -0
- package/dist/methods/secret/set.d.ts +37 -0
- package/dist/methods/secret/set.d.ts.map +1 -0
- package/dist/methods/secret/set.js +41 -0
- package/dist/methods/secret/set.js.map +1 -0
- package/dist/methods/state/get.d.ts +25 -0
- package/dist/methods/state/get.d.ts.map +1 -0
- package/dist/methods/state/get.js +29 -0
- package/dist/methods/state/get.js.map +1 -0
- package/dist/methods/state/patch.d.ts +32 -0
- package/dist/methods/state/patch.d.ts.map +1 -0
- package/dist/methods/state/patch.js +29 -0
- package/dist/methods/state/patch.js.map +1 -0
- package/dist/methods/view/default.d.ts +19 -0
- package/dist/methods/view/default.d.ts.map +1 -0
- package/dist/methods/view/default.js +23 -0
- package/dist/methods/view/default.js.map +1 -0
- package/dist/methods/view/launch.d.ts +27 -0
- package/dist/methods/view/launch.d.ts.map +1 -0
- package/dist/methods/view/launch.js +30 -0
- package/dist/methods/view/launch.js.map +1 -0
- package/dist/methods/view/revoke.d.ts +19 -0
- package/dist/methods/view/revoke.d.ts.map +1 -0
- package/dist/methods/view/revoke.js +26 -0
- package/dist/methods/view/revoke.js.map +1 -0
- package/dist/methods/view/rotate.d.ts +21 -0
- package/dist/methods/view/rotate.d.ts.map +1 -0
- package/dist/methods/view/rotate.js +27 -0
- package/dist/methods/view/rotate.js.map +1 -0
- package/dist/methods/view/url.d.ts +52 -0
- package/dist/methods/view/url.d.ts.map +1 -0
- package/dist/methods/view/url.js +43 -0
- package/dist/methods/view/url.js.map +1 -0
- package/dist/methods/wait/wait.d.ts +37 -0
- package/dist/methods/wait/wait.d.ts.map +1 -0
- package/dist/methods/wait/wait.js +39 -0
- package/dist/methods/wait/wait.js.map +1 -0
- package/dist/revision.d.ts +43 -0
- package/dist/revision.d.ts.map +1 -0
- package/dist/revision.js +69 -0
- package/dist/revision.js.map +1 -0
- package/dist/rpc/error.d.ts +47 -0
- package/dist/rpc/error.d.ts.map +1 -0
- package/dist/rpc/error.js +77 -0
- package/dist/rpc/error.js.map +1 -0
- package/dist/rpc/lines.d.ts +30 -0
- package/dist/rpc/lines.d.ts.map +1 -0
- package/dist/rpc/lines.js +63 -0
- package/dist/rpc/lines.js.map +1 -0
- package/dist/rpc/messages.d.ts +92 -0
- package/dist/rpc/messages.d.ts.map +1 -0
- package/dist/rpc/messages.js +133 -0
- package/dist/rpc/messages.js.map +1 -0
- package/dist/rpc/peer.d.ts +81 -0
- package/dist/rpc/peer.d.ts.map +1 -0
- package/dist/rpc/peer.js +208 -0
- package/dist/rpc/peer.js.map +1 -0
- package/dist/serializer.d.ts +178 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +929 -0
- package/dist/serializer.js.map +1 -0
- package/dist/verify.d.ts +254 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +243 -0
- package/dist/verify.js.map +1 -0
- package/dist/view.d.ts +103 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +110 -0
- package/dist/view.js.map +1 -0
- package/dist/wire-registry.js +11 -0
- package/dist/wire-registry.js.map +1 -0
- package/dist/worker.d.ts +249 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +158 -0
- package/dist/worker.js.map +1 -0
- package/package.json +114 -3
- package/schemas/protocol.draft-07.json +5120 -0
- package/schemas/protocol.schema.json +4964 -0
- package/src/actions.ts +418 -0
- package/src/artifact.ts +187 -0
- package/src/bridge.ts +618 -0
- package/src/browser.ts +374 -0
- package/src/bundle.ts +264 -0
- package/src/canonical.ts +49 -0
- package/src/capability.ts +92 -0
- package/src/diagnostics/codes/a11y.ts +41 -0
- package/src/diagnostics/codes/action.ts +125 -0
- package/src/diagnostics/codes/artifact.ts +137 -0
- package/src/diagnostics/codes/build.ts +65 -0
- package/src/diagnostics/codes/cli.ts +53 -0
- package/src/diagnostics/codes/console.ts +41 -0
- package/src/diagnostics/codes/dep.ts +101 -0
- package/src/diagnostics/codes/env.ts +149 -0
- package/src/diagnostics/codes/field.ts +113 -0
- package/src/diagnostics/codes/home.ts +150 -0
- package/src/diagnostics/codes/host.ts +197 -0
- package/src/diagnostics/codes/hygiene.ts +175 -0
- package/src/diagnostics/codes/index.ts +142 -0
- package/src/diagnostics/codes/live.ts +41 -0
- package/src/diagnostics/codes/manifest.ts +53 -0
- package/src/diagnostics/codes/network.ts +41 -0
- package/src/diagnostics/codes/platform.ts +30 -0
- package/src/diagnostics/codes/publish.ts +53 -0
- package/src/diagnostics/codes/regression.ts +89 -0
- package/src/diagnostics/codes/runtime.ts +77 -0
- package/src/diagnostics/codes/secret.ts +29 -0
- package/src/diagnostics/codes/smoke.ts +41 -0
- package/src/diagnostics/codes/submit.ts +113 -0
- package/src/diagnostics/codes/target.ts +29 -0
- package/src/diagnostics/codes/type.ts +41 -0
- package/src/diagnostics/codes/verify.ts +113 -0
- package/src/diagnostics/diagnostic.ts +240 -0
- package/src/diagnostics/spec.ts +90 -0
- package/src/hygiene.ts +224 -0
- package/src/ids.ts +279 -0
- package/src/index.ts +576 -0
- package/src/interaction.ts +728 -0
- package/src/manifest.ts +206 -0
- package/src/method.ts +42 -0
- package/src/methods/artifact/create.ts +56 -0
- package/src/methods/artifact/get.ts +30 -0
- package/src/methods/artifact/list.ts +42 -0
- package/src/methods/artifact/publish.ts +46 -0
- package/src/methods/artifact/verify.ts +46 -0
- package/src/methods/deps/add.ts +72 -0
- package/src/methods/dev/start.ts +84 -0
- package/src/methods/dev/stop.ts +32 -0
- package/src/methods/events/ack.ts +41 -0
- package/src/methods/events/read.ts +67 -0
- package/src/methods/events/subscribe.ts +91 -0
- package/src/methods/events/unsubscribe.ts +35 -0
- package/src/methods/gc/run.ts +125 -0
- package/src/methods/index.ts +81 -0
- package/src/methods/instance/check.ts +61 -0
- package/src/methods/instance/status.ts +172 -0
- package/src/methods/live/push.ts +54 -0
- package/src/methods/mostra/initialize.ts +249 -0
- package/src/methods/mostra/shutdown.ts +31 -0
- package/src/methods/port/drafts-mirror.ts +52 -0
- package/src/methods/port/secrets-get.ts +40 -0
- package/src/methods/port/submissions-deliver.ts +70 -0
- package/src/methods/port/trusted-controls-activated.ts +51 -0
- package/src/methods/port/trusted-controls-policy.ts +38 -0
- package/src/methods/results/get.ts +59 -0
- package/src/methods/secret/delete.ts +43 -0
- package/src/methods/secret/list.ts +40 -0
- package/src/methods/secret/set.ts +69 -0
- package/src/methods/state/get.ts +44 -0
- package/src/methods/state/patch.ts +51 -0
- package/src/methods/view/default.ts +32 -0
- package/src/methods/view/launch.ts +47 -0
- package/src/methods/view/revoke.ts +39 -0
- package/src/methods/view/rotate.ts +37 -0
- package/src/methods/view/url.ts +84 -0
- package/src/methods/wait/wait.ts +58 -0
- package/src/revision.ts +101 -0
- package/src/rpc/error.ts +107 -0
- package/src/rpc/lines.ts +70 -0
- package/src/rpc/messages.ts +188 -0
- package/src/rpc/peer.ts +341 -0
- package/src/serializer.ts +1217 -0
- package/src/timers.d.ts +8 -0
- package/src/verify.ts +458 -0
- package/src/view.ts +200 -0
- package/src/web-crypto.d.ts +9 -0
- package/src/web-platform.d.ts +35 -0
- package/src/wire-registry.ts +14 -0
- package/src/worker.ts +374 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","names":[],"sources":["../src/serializer.ts"],"sourcesContent":["/**\n * The serializer of server-function arguments and results (D19 seam 2, D54): exactly the type set\n * React documents for Server Functions, plus `AsyncIterable` results, in one JSON wire form the\n * browser, the gateway and the worker share. It has no I/O and no Node built-ins.\n *\n * A value is written as a series of **batches**, each a JSON array of {@link Frame}s. The first\n * batch holds the value's root (chunk 0); a promise or an async iterable in it is a reference whose\n * settlement or items arrive in later batches, so a result streams as it settles. Shared objects\n * and cycles are kept: an object met twice is written once, in a chunk of its own.\n *\n * ```ts\n * const batches: Frame[][] = [];\n * const writer = new ValueWriter({ mode: \"result\", onBatch: (batch) => batches.push(batch) });\n * await writer.write({ when: new Date(), items: new Map([[\"a\", 1]]) });\n * await writer.done;\n * const reader = new ValueReader();\n * for (const batch of batches) reader.push(batch);\n * const value = await reader.root;\n * ```\n *\n * What it accepts (react.dev, `'use server'`, \"Serializable arguments and return values\"):\n * strings, numbers (`NaN`, infinities and `-0` too), bigints, booleans, `undefined`, `null`,\n * symbols registered with `Symbol.for`, arrays, `Map`, `Set`, typed arrays, `DataView`,\n * `ArrayBuffer`, `Date`, `FormData` (with string and file values), plain objects, Server Functions\n * and promises; results may also be async iterables. Anything else (class instances, objects with\n * a null prototype, other functions, unregistered symbols, React elements) is refused with a\n * {@link SerializationError} naming where it is.\n */\n\n/** One step of a written value. */\nexport type Frame =\n /** An outlined chunk: chunk 0 is the root; others hold shared objects, maps, sets and bytes. */\n | { readonly c: number; readonly v: unknown }\n /** A promise settled: with its value, or rejected with an error. */\n | { readonly p: number; readonly v: unknown }\n | { readonly p: number; readonly e: WireError }\n /** An async iterable's item, its end, or its failure. */\n | { readonly i: number; readonly v: unknown }\n | { readonly i: number; readonly end: true }\n | { readonly i: number; readonly e: WireError };\n\n/** A frame about a promise or an async iterable. */\ntype AsyncFrame = Exclude<Frame, { readonly c: number }>;\n\n/** An error as the wire carries it: a rejected promise, a failed iteration. */\nexport interface WireError {\n /** The error's message. */\n readonly message: string;\n /** Its diagnostic code, when it carried one (`MOSTRA_SECRET_MISSING`, say). */\n readonly code?: string;\n}\n\n/** Any function: a Server Function as the serializer sees it. */\nexport type AnyFunction = (...args: never) => unknown;\n\n/** Whether a value is written as a call's arguments or as its result. */\nexport type SerializeMode = \"argument\" | \"result\";\n\n/**\n * The most digits a bigint argument may have. A page's arguments are decoded before the action\n * runs, and parsing a bigint takes time that grows faster than its length: 16 M digits held a\n * worker's event loop for seconds. Results aren't limited; server code writes them.\n */\nexport const ARGUMENT_BIGINT_DIGITS_MAX = 10_000;\n\n/** The diagnostic code of a value outside the type set (INTERFACES §2.4). */\nexport const UNSERIALIZABLE_CODE = \"MOSTRA_ACTION_UNSERIALIZABLE\";\n\n/** A value outside the type set, or a malformed written value. */\nexport class SerializationError extends Error {\n /** Always `MOSTRA_ACTION_UNSERIALIZABLE`. */\n readonly code: string = UNSERIALIZABLE_CODE;\n /** Where in the value: `.items[2].when`, or empty for the value itself. */\n readonly path: string;\n constructor(message: string, path = \"\") {\n super(path === \"\" ? message : `${where(path)} ${message}`);\n this.name = \"SerializationError\";\n this.path = path;\n }\n}\n\n/** A path as people read it: `[1].when` is \"argument 2's .when\". */\nfunction where(path: string): string {\n const argument = /^\\[(\\d+)\\](.*)$/.exec(path);\n if (argument) {\n const rest = argument[2] ?? \"\";\n return `Argument ${Number(argument[1]) + 1}${rest === \"\" ? \"\" : ` at ${rest}`}`;\n }\n return path.startsWith(\"result\") ? `The ${path}` : `The value at ${path}`;\n}\n\n/** The error a rejected promise or a failed iteration carries on the wire. */\nexport function wireError(error: unknown): WireError {\n if (error instanceof Error) {\n const code = (error as Error & { code?: unknown }).code;\n return { message: error.message, ...(typeof code === \"string\" ? { code } : {}) };\n }\n return { message: String(error) };\n}\n\n/** An error read back from the wire, as the reader's promises and iterables reject with it. */\nexport class RemoteError extends Error {\n /** The diagnostic code the error carried, if any. */\n readonly code: string | undefined;\n constructor(error: WireError) {\n super(error.message);\n this.name = \"RemoteError\";\n this.code = error.code;\n }\n}\n\n// ── Base64, without Node's Buffer ──────────────────────────────────────────────────────────\n\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst LOOKUP = new Int16Array(128).fill(-1);\nfor (let index = 0; index < ALPHABET.length; index += 1) LOOKUP[ALPHABET.charCodeAt(index)] = index;\n\n/** Standard base64 of `bytes`, with padding. */\nexport function toBase64(bytes: Uint8Array): string {\n let out = \"\";\n let index = 0;\n for (; index + 2 < bytes.length; index += 3) {\n const n =\n ((bytes[index] ?? 0) << 16) | ((bytes[index + 1] ?? 0) << 8) | (bytes[index + 2] ?? 0);\n out +=\n ALPHABET.charAt((n >> 18) & 63) +\n ALPHABET.charAt((n >> 12) & 63) +\n ALPHABET.charAt((n >> 6) & 63) +\n ALPHABET.charAt(n & 63);\n }\n const rest = bytes.length - index;\n if (rest === 1) {\n const n = (bytes[index] ?? 0) << 16;\n out += `${ALPHABET[(n >> 18) & 63]}${ALPHABET[(n >> 12) & 63]}==`;\n } else if (rest === 2) {\n const n = ((bytes[index] ?? 0) << 16) | ((bytes[index + 1] ?? 0) << 8);\n out += `${ALPHABET[(n >> 18) & 63]}${ALPHABET[(n >> 12) & 63]}${ALPHABET[(n >> 6) & 63]}=`;\n }\n return out;\n}\n\n/** The bytes of standard base64 text; throws a {@link SerializationError} on anything else. */\nexport function fromBase64(text: string): Uint8Array {\n if (text.length % 4 !== 0) throw new SerializationError(\"Malformed base64 bytes.\");\n const padding = text.endsWith(\"==\") ? 2 : text.endsWith(\"=\") ? 1 : 0;\n const out = new Uint8Array((text.length / 4) * 3 - padding);\n let at = 0;\n for (let index = 0; index < text.length; index += 4) {\n const quad = [0, 1, 2, 3].map((offset) => {\n const char = text.charCodeAt(index + offset);\n if (char === 61 && index + offset >= text.length - padding) return 0;\n const value = char < 128 ? (LOOKUP[char] ?? -1) : -1;\n if (value < 0) throw new SerializationError(\"Malformed base64 bytes.\");\n return value;\n });\n const n =\n ((quad[0] ?? 0) << 18) | ((quad[1] ?? 0) << 12) | ((quad[2] ?? 0) << 6) | (quad[3] ?? 0);\n if (at < out.length) out[at++] = (n >> 16) & 255;\n if (at < out.length) out[at++] = (n >> 8) & 255;\n if (at < out.length) out[at++] = n & 255;\n }\n return out;\n}\n\n// ── Kinds ──────────────────────────────────────────────────────────────────────────────────\n\n/** The typed-array kinds, by the tag the wire uses. */\nconst TYPED_ARRAYS = {\n Int8Array: \"i8\",\n Uint8Array: \"u8\",\n Uint8ClampedArray: \"u8c\",\n Int16Array: \"i16\",\n Uint16Array: \"u16\",\n Int32Array: \"i32\",\n Uint32Array: \"u32\",\n Float32Array: \"f32\",\n Float64Array: \"f64\",\n BigInt64Array: \"i64\",\n BigUint64Array: \"u64\",\n DataView: \"dv\",\n} as const;\n\ntype TypedKind = (typeof TYPED_ARRAYS)[keyof typeof TYPED_ARRAYS];\n\nconst TYPED_CONSTRUCTORS: Readonly<Record<TypedKind, (buffer: ArrayBuffer) => ArrayBufferView>> = {\n i8: (b) => new Int8Array(b),\n u8: (b) => new Uint8Array(b),\n u8c: (b) => new Uint8ClampedArray(b),\n i16: (b) => new Int16Array(b),\n u16: (b) => new Uint16Array(b),\n i32: (b) => new Int32Array(b),\n u32: (b) => new Uint32Array(b),\n f32: (b) => new Float32Array(b),\n f64: (b) => new Float64Array(b),\n i64: (b) => new BigInt64Array(b),\n u64: (b) => new BigUint64Array(b),\n dv: (b) => new DataView(b),\n};\n\n/**\n * The wire tag of a typed array or `DataView`, or `undefined` for anything else. A subclass is\n * its built-in base (Node's `Buffer` is a `Uint8Array`), found along the prototype chain, so\n * what Node's file and crypto APIs return crosses as the bytes it holds.\n */\nfunction typedKind(value: object): TypedKind | undefined {\n if (!ArrayBuffer.isView(value)) return undefined;\n for (\n let proto = Object.getPrototypeOf(value) as { constructor?: { name?: string } } | null;\n proto !== null;\n proto = Object.getPrototypeOf(proto) as { constructor?: { name?: string } } | null\n ) {\n const name = Object.hasOwn(proto, \"constructor\") ? proto.constructor?.name : undefined;\n if (name !== undefined && name in TYPED_ARRAYS) {\n return TYPED_ARRAYS[name as keyof typeof TYPED_ARRAYS];\n }\n }\n return undefined;\n}\n\nconst isPlainObject = (value: object): boolean => Object.getPrototypeOf(value) === Object.prototype;\n\nconst isBlob = (value: unknown): value is Blob =>\n typeof Blob !== \"undefined\" && value instanceof Blob;\n\nconst isFormData = (value: unknown): value is FormData =>\n typeof FormData !== \"undefined\" && value instanceof FormData;\n\nconst isPromiseLike = (value: object): value is PromiseLike<unknown> =>\n value instanceof Promise ||\n (typeof (value as { then?: unknown }).then === \"function\" && !isPlainObject(value));\n\nconst isAsyncIterable = (value: object): value is AsyncIterable<unknown> =>\n typeof (value as { [Symbol.asyncIterator]?: unknown })[Symbol.asyncIterator] === \"function\";\n\n/** React's element marker: elements are refused (they belong to the `rsc` mode, D19). */\nconst REACT_ELEMENT = Symbol.for(\"react.transitional.element\");\nconst REACT_LEGACY_ELEMENT = Symbol.for(\"react.element\");\n\nfunction describe(value: object): string {\n const proto = Object.getPrototypeOf(value) as { constructor?: { name?: string } } | null;\n if (proto === null) return \"an object with a null prototype\";\n const name = proto.constructor?.name;\n return name ? `an instance of ${name}` : \"an object that isn't plain\";\n}\n\nconst pathKey = (key: string): string =>\n /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;\n\n// ── Writing ────────────────────────────────────────────────────────────────────────────────\n\n/** Options for {@link ValueWriter}. */\nexport interface ValueWriterOptions {\n /** `argument`: no async iterables. `result`: everything. */\n readonly mode: SerializeMode;\n /** Receives each batch, in order. */\n readonly onBatch: (batch: Frame[]) => void;\n /**\n * The ID of a function that is a Server Function, or `undefined` for any other function. The\n * client's stubs carry their ID; the worker knows its registry.\n */\n readonly serverFunctionId?: (fn: AnyFunction) => string | undefined;\n}\n\n/**\n * Writes one value as batches. `write` throws a {@link SerializationError} when the value, or\n * anything it holds synchronously, is outside the type set; a promise that later settles with such\n * a value is written as rejected with that error. `done` settles once every promise and iterable\n * in the value has settled or ended; `abort` stops iterables early (the reader went away).\n */\nexport class ValueWriter {\n readonly #options: ValueWriterOptions;\n #nextId = 1;\n #pending = 0;\n #aborted = false;\n #cutShort = false;\n #wroteRoot = false;\n readonly #rootPath: string;\n #queue: Promise<void> = Promise.resolve();\n readonly #iterators = new Set<AsyncIterator<unknown>>();\n #resolveDone!: () => void;\n #rejectDone!: (error: unknown) => void;\n /** Settles once every async part of the value has been written. */\n readonly done: Promise<void>;\n\n constructor(options: ValueWriterOptions) {\n this.#options = options;\n this.#rootPath = options.mode === \"result\" ? \"result\" : \"\";\n this.done = new Promise((resolve, reject) => {\n this.#resolveDone = resolve;\n this.#rejectDone = reject;\n });\n // `done` may be awaited by nobody when `write` fails.\n this.done.catch(() => {});\n }\n\n /** Writes the value's first batch; async parts follow in later batches. */\n async write(value: unknown): Promise<void> {\n if (this.#wroteRoot) throw new Error(\"A ValueWriter writes one value.\");\n this.#wroteRoot = true;\n // The root goes first: batches of promises that settle while it is still being encoded (it\n // may read files) queue behind it.\n this.#pending += 1;\n const root = this.#encodeBatch(value, this.#rootPath, (json, frames) => {\n frames.unshift({ c: 0, v: json });\n });\n this.#queue = root.then(\n (batch) => this.#emit(batch),\n () => {},\n );\n try {\n await root;\n } catch (error) {\n this.#aborted = true;\n this.#rejectDone(error);\n throw error;\n } finally {\n this.#pending -= 1;\n }\n await this.#queue;\n this.#settleIfIdle();\n }\n\n /**\n * Whether {@link ValueWriter.abort} stopped the value before all of it was written: a promise\n * still unsettled, an iterable not yet ended.\n */\n get cutShort(): boolean {\n return this.#cutShort;\n }\n\n /** Stops every iterable still being read, and settles `done`. */\n abort(): void {\n if (this.#aborted) return;\n this.#cutShort = this.#pending > 0;\n this.#aborted = true;\n for (const iterator of this.#iterators) void iterator.return?.()?.catch?.(() => {});\n this.#iterators.clear();\n this.#resolveDone();\n }\n\n #emit(batch: Frame[]): void {\n if (this.#aborted) return;\n this.#options.onBatch(batch);\n }\n\n #settleIfIdle(): void {\n if (this.#pending === 0) this.#resolveDone();\n }\n\n /** Runs batch production one at a time, so batches leave in the order they were started. */\n #serial(task: () => Promise<Frame[] | undefined>): void {\n this.#pending += 1;\n this.#queue = this.#queue\n .then(async () => {\n const batch = await task();\n if (batch) this.#emit(batch);\n })\n .catch((error: unknown) => {\n this.#aborted = true;\n this.#rejectDone(error);\n })\n .finally(() => {\n this.#pending -= 1;\n this.#settleIfIdle();\n });\n }\n\n /**\n * Encodes `value` into a batch: `place` puts the encoded root into the batch, whose other\n * frames are the chunks it needs.\n */\n async #encodeBatch(\n value: unknown,\n path: string,\n place: (json: unknown, frames: Frame[]) => void,\n ): Promise<Frame[]> {\n const frames: Frame[] = [];\n const shared = countShared(value);\n const outlined = new Map<object, number>();\n const blobs: { id: number; blob: Blob }[] = [];\n const encode = (item: unknown, at: string, depth: number): unknown => {\n if (depth > MAX_DEPTH) throw new SerializationError(\"The value nests too deeply.\", at);\n switch (typeof item) {\n case \"string\":\n return item.startsWith(\"$\") ? `$${item}` : item;\n case \"number\":\n if (Number.isNaN(item)) return \"$NaN\";\n if (item === Number.POSITIVE_INFINITY) return \"$Infinity\";\n if (item === Number.NEGATIVE_INFINITY) return \"$-Infinity\";\n if (Object.is(item, -0)) return \"$-0\";\n return item;\n case \"boolean\":\n return item;\n case \"undefined\":\n return \"$undefined\";\n case \"bigint\": {\n const digits = item.toString();\n if (\n this.#options.mode === \"argument\" &&\n digits.replace(\"-\", \"\").length > ARGUMENT_BIGINT_DIGITS_MAX\n ) {\n throw new SerializationError(\n `is a bigint of more than ${ARGUMENT_BIGINT_DIGITS_MAX} digits; send a larger number as a string.`,\n at,\n );\n }\n return `$n${digits}`;\n }\n case \"symbol\": {\n if (this.#options.mode === \"argument\") {\n // React 19.3's reply codec refuses symbols in arguments too (VERIFIED_FACTS, WP-08):\n // a registered symbol lives as long as the process, so a page could fill the\n // worker's memory with them.\n throw new SerializationError(\n \"is a symbol; an argument can't be one, only a result can (a registered symbol).\",\n at,\n );\n }\n const key = Symbol.keyFor(item);\n if (key === undefined) {\n throw new SerializationError(\n \"is a symbol not registered with Symbol.for; only registered symbols can be sent.\",\n at,\n );\n }\n return `$S${key}`;\n }\n case \"function\": {\n const id = this.#options.serverFunctionId?.(item as AnyFunction);\n if (id === undefined) {\n throw new SerializationError(\n \"is a function that isn't a Server Function; only Server Functions can be sent.\",\n at,\n );\n }\n return `$h${id}`;\n }\n case \"object\":\n break;\n }\n if (item === null) return null;\n const object = item as object;\n const known = outlined.get(object);\n if (known !== undefined) return `$${known}`;\n if (\n (object as { $$typeof?: unknown }).$$typeof === REACT_ELEMENT ||\n (object as { $$typeof?: unknown }).$$typeof === REACT_LEGACY_ELEMENT\n ) {\n throw new SerializationError(\n \"is a React element; JSX can't cross a server call in the SPA render mode.\",\n at,\n );\n }\n if (object instanceof Date) {\n return Number.isNaN(object.getTime()) ? \"$DInvalid\" : `$D${object.toISOString()}`;\n }\n if (isPromiseLike(object)) {\n const id = this.#nextId++;\n this.#watchPromise(id, object, `${at}.then`);\n return `$@${id}`;\n }\n if (isFormData(object)) {\n const id = this.#nextId++;\n const entries: unknown[] = [];\n for (const [name, entry] of object.entries()) {\n if (typeof entry === \"string\") entries.push([name, encode(entry, at, depth + 1)]);\n else {\n const blobId = this.#nextId++;\n blobs.push({ id: blobId, blob: entry });\n entries.push([name, `$B${blobId}`]);\n }\n }\n frames.push({ c: id, v: entries });\n return `$K${id}`;\n }\n if (object instanceof ArrayBuffer) {\n const id = this.#nextId++;\n frames.push({ c: id, v: toBase64(new Uint8Array(object)) });\n return `$A${id}`;\n }\n const typed = typedKind(object);\n if (typed !== undefined) {\n const view = object as ArrayBufferView;\n const id = this.#nextId++;\n const bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n frames.push({ c: id, v: [typed, toBase64(bytes)] });\n return `$T${id}`;\n }\n const outline = (encoded: () => unknown, tag: string): string => {\n const id = this.#nextId++;\n outlined.set(object, id);\n const frame: { c: number; v: unknown } = { c: id, v: null };\n frames.push(frame);\n frame.v = encoded();\n return `${tag}${id}`;\n };\n if (object instanceof Map) {\n return outline(\n () =>\n [...object.entries()].map(([key, entry], index) => [\n encode(key, `${at}.<map key ${index}>`, depth + 1),\n encode(entry, `${at}.<map value ${index}>`, depth + 1),\n ]),\n \"$Q\",\n );\n }\n if (object instanceof Set) {\n return outline(\n () =>\n [...object].map((entry, index) =>\n encode(entry, `${at}.<set item ${index}>`, depth + 1),\n ),\n \"$W\",\n );\n }\n if (Array.isArray(object)) {\n const build = (): unknown[] => {\n const out: unknown[] = [];\n for (let index = 0; index < object.length; index += 1) {\n out.push(encode(object[index], `${at}[${index}]`, depth + 1));\n }\n return out;\n };\n return shared.has(object) ? outline(build, \"$\") : build();\n }\n if (this.#options.mode === \"result\" && isAsyncIterable(object)) {\n const id = this.#nextId++;\n this.#watchIterable(id, object, at);\n return `$x${id}`;\n }\n if (isBlob(object)) {\n throw new SerializationError(\n \"is a Blob or File; send files inside a FormData, as React's Server Functions take them.\",\n at,\n );\n }\n if (!isPlainObject(object)) {\n if (isAsyncIterable(object)) {\n throw new SerializationError(\n \"is an async iterable; only a result may be one, never an argument.\",\n at,\n );\n }\n throw new SerializationError(\n `is ${describe(object)}; only plain objects and the built-ins React's Server Functions accept can be sent.`,\n at,\n );\n }\n const build = (): Record<string, unknown> => {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(object)) {\n const encoded = encode(\n (object as Record<string, unknown>)[key],\n `${at}${pathKey(key)}`,\n depth + 1,\n );\n Object.defineProperty(out, key, {\n value: encoded,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n };\n return shared.has(object) ? outline(build, \"$\") : build();\n };\n const root = encode(value, path, 0);\n for (const { id, blob } of blobs) {\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const file = blob as Blob & { name?: unknown; lastModified?: unknown };\n frames.push({\n c: id,\n v: {\n type: blob.type,\n data: toBase64(bytes),\n ...(typeof file.name === \"string\" ? { name: file.name } : {}),\n ...(typeof file.lastModified === \"number\" ? { lastModified: file.lastModified } : {}),\n },\n });\n }\n place(root, frames);\n return frames;\n }\n\n #watchPromise(id: number, promise: PromiseLike<unknown>, path: string): void {\n this.#pending += 1;\n Promise.resolve(promise).then(\n (settled) => {\n this.#serial(() =>\n this.#encodeBatch(settled, path, (json, frames) => frames.push({ p: id, v: json })).catch(\n (error: unknown) => [{ p: id, e: wireError(error) }],\n ),\n );\n this.#pending -= 1;\n },\n (error: unknown) => {\n // React's `encodeReply` fails the call when an argument's promise rejects; only a result\n // carries a rejection to the other side.\n if (this.#options.mode === \"argument\") {\n this.#serial(async () => {\n throw error;\n });\n } else this.#serial(async () => [{ p: id, e: wireError(error) }]);\n this.#pending -= 1;\n },\n );\n }\n\n #watchIterable(id: number, iterable: AsyncIterable<unknown>, path: string): void {\n let iterator: AsyncIterator<unknown>;\n try {\n iterator = iterable[Symbol.asyncIterator]();\n } catch (error) {\n this.#serial(async () => [{ i: id, e: wireError(error) }]);\n return;\n }\n this.#iterators.add(iterator);\n this.#pending += 1;\n const step = async (): Promise<void> => {\n for (let index = 0; ; index += 1) {\n if (this.#aborted) return;\n let next: IteratorResult<unknown>;\n try {\n next = await iterator.next();\n } catch (error) {\n this.#serial(async () => [{ i: id, e: wireError(error) }]);\n return;\n }\n if (next.done) {\n this.#serial(async () => [{ i: id, end: true }]);\n return;\n }\n const item = next.value;\n const at = `${path}<item ${index}>`;\n let failed = false;\n this.#serial(() =>\n this.#encodeBatch(item, at, (json, frames) => frames.push({ i: id, v: json })).catch(\n (error: unknown) => {\n failed = true;\n return [{ i: id, e: wireError(error) }];\n },\n ),\n );\n // Wait for the item to be written before pulling the next, so a slow reader paces it.\n await this.#queue;\n if (failed) {\n void iterator.return?.()?.catch?.(() => {});\n return;\n }\n }\n };\n void step().finally(() => {\n this.#iterators.delete(iterator);\n this.#pending -= 1;\n this.#settleIfIdle();\n });\n }\n}\n\n/** The deepest nesting a value may have, so a hostile value can't exhaust the stack. */\nconst MAX_DEPTH = 512;\n\n/** The objects and arrays `value` reaches more than once (shared, or part of a cycle). */\nfunction countShared(value: unknown): Set<object> {\n const seen = new Set<object>();\n const shared = new Set<object>();\n const stack: unknown[] = [value];\n while (stack.length > 0) {\n const item = stack.pop();\n if (typeof item !== \"object\" || item === null) continue;\n if (seen.has(item)) {\n shared.add(item);\n continue;\n }\n seen.add(item);\n if (Array.isArray(item)) {\n for (const entry of item) stack.push(entry);\n } else if (item instanceof Map) {\n for (const [key, entry] of item) stack.push(key, entry);\n } else if (item instanceof Set) {\n for (const entry of item) stack.push(entry);\n } else if (Object.getPrototypeOf(item) === Object.prototype) {\n for (const key of Object.keys(item)) stack.push((item as Record<string, unknown>)[key]);\n }\n }\n return shared;\n}\n\n/**\n * Writes `value` completely: every promise settled, so the batches can be sent at once. For\n * arguments, which a browser sends in one request.\n */\nexport async function serializeAll(\n value: unknown,\n options: Omit<ValueWriterOptions, \"onBatch\">,\n): Promise<Frame[][]> {\n const batches: Frame[][] = [];\n const writer = new ValueWriter({ ...options, onBatch: (batch) => batches.push(batch) });\n await writer.write(value);\n await writer.done;\n return batches;\n}\n\n// ── Reading ────────────────────────────────────────────────────────────────────────────────\n\n/** Options for {@link ValueReader}. */\nexport interface ValueReaderOptions {\n /** The function a Server Function ID stands for; absent: a reference is refused. */\n readonly serverFunction?: (id: string) => AnyFunction;\n /**\n * `argument`: what a page sent, read where server code runs: no symbols, no async iterables,\n * bigints of at most {@link ARGUMENT_BIGINT_DIGITS_MAX} digits, the writer's own limits. Default\n * `result`: everything the writer writes.\n */\n readonly mode?: SerializeMode;\n}\n\ninterface Deferred {\n promise: Promise<unknown>;\n resolve(value: unknown): void;\n reject(error: unknown): void;\n settled: boolean;\n}\n\nfunction deferred(): Deferred {\n let resolve!: (value: unknown) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<unknown>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n promise.catch(() => {});\n const entry: Deferred = {\n promise,\n resolve: (value) => {\n entry.settled = true;\n resolve(value);\n },\n reject: (error) => {\n entry.settled = true;\n reject(error);\n },\n settled: false,\n };\n return entry;\n}\n\n/** An async iterable fed by frames: one reader, items buffered until taken. */\nclass FedIterable implements AsyncIterable<unknown> {\n readonly #items: unknown[] = [];\n #ended = false;\n #error: unknown;\n #wake: (() => void) | undefined;\n #taken = false;\n\n push(value: unknown): void {\n this.#items.push(value);\n this.#wake?.();\n }\n end(): void {\n this.#ended = true;\n this.#wake?.();\n }\n fail(error: unknown): void {\n if (this.#ended) return;\n this.#error = error;\n this.#ended = true;\n this.#wake?.();\n }\n get ended(): boolean {\n return this.#ended;\n }\n\n [Symbol.asyncIterator](): AsyncIterator<unknown> {\n if (this.#taken) throw new Error(\"This async iterable can be read once.\");\n this.#taken = true;\n return {\n next: async (): Promise<IteratorResult<unknown>> => {\n for (;;) {\n if (this.#items.length > 0) return { done: false, value: this.#items.shift() };\n if (this.#ended) {\n if (this.#error !== undefined) throw this.#error;\n return { done: true, value: undefined };\n }\n await new Promise<void>((resolve) => {\n this.#wake = resolve;\n });\n this.#wake = undefined;\n }\n },\n return: async (): Promise<IteratorResult<unknown>> => {\n this.#ended = true;\n this.#items.length = 0;\n return { done: true, value: undefined };\n },\n };\n }\n}\n\nconst malformed = (what: string): SerializationError =>\n new SerializationError(`The written value is malformed: ${what}.`);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * Reads batches back into a value. `root` resolves once the first batch arrived; promises and\n * async iterables in it settle and yield as later batches arrive. A malformed batch throws a\n * {@link SerializationError} from `push`; `fail` rejects everything still open, for a stream that\n * broke before its end.\n */\nexport class ValueReader {\n readonly #options: ValueReaderOptions;\n /** Raw chunks by ID, and what each became. */\n readonly #raw = new Map<number, unknown>();\n readonly #decoded = new Map<number, unknown>();\n readonly #promises = new Map<number, Deferred>();\n readonly #iterables = new Map<number, FedIterable>();\n /** Frames for promises or iterables not referenced yet. */\n readonly #early: AsyncFrame[] = [];\n readonly #root = deferred();\n #hasRoot = false;\n /** The value, once the first batch arrived. */\n readonly root: Promise<unknown> = this.#root.promise;\n\n constructor(options: ValueReaderOptions = {}) {\n this.#options = options;\n }\n\n /** Whether every promise and iterable read so far has settled or ended. */\n get complete(): boolean {\n return (\n this.#hasRoot &&\n [...this.#promises.values()].every((entry) => entry.settled) &&\n [...this.#iterables.values()].every((entry) => entry.ended)\n );\n }\n\n /** Takes one batch. */\n push(batch: unknown): void {\n if (!Array.isArray(batch)) throw malformed(\"a batch isn't an array\");\n const ordered: AsyncFrame[] = [];\n for (const frame of batch) {\n if (!isRecord(frame)) throw malformed(\"a frame isn't an object\");\n if (typeof frame[\"c\"] === \"number\") {\n if (!Number.isSafeInteger(frame[\"c\"]) || frame[\"c\"] < 0) throw malformed(\"a chunk ID\");\n if (this.#raw.has(frame[\"c\"])) throw malformed(`chunk ${frame[\"c\"]} was written twice`);\n this.#raw.set(frame[\"c\"], frame[\"v\"]);\n } else if (typeof frame[\"p\"] === \"number\" || typeof frame[\"i\"] === \"number\") {\n ordered.push(frame as unknown as AsyncFrame);\n } else {\n throw malformed(\"a frame has no chunk, promise or iterable ID\");\n }\n }\n if (!this.#hasRoot && this.#raw.has(0)) {\n this.#hasRoot = true;\n try {\n this.#root.resolve(this.#decode(this.#raw.get(0), 0));\n } catch (error) {\n this.#root.reject(error);\n throw error;\n }\n }\n for (const frame of ordered) this.#apply(frame);\n }\n\n /**\n * Ends the value: every frame taken so far is applied, and the value must be complete. Throws a\n * {@link SerializationError} when a promise or iterable it holds is still open or a frame names\n * one the value never refers to, so a reader that has all the batches (a page's arguments)\n * never hands on a promise that can't settle.\n */\n finish(): void {\n if (!this.#hasRoot) throw malformed(\"the value has no root\");\n for (;;) {\n const before = this.#early.length;\n if (before === 0) break;\n this.#flush();\n if (this.#early.length === before) break;\n }\n if (this.#early.length > 0) throw malformed(\"a frame names a promise the value doesn't hold\");\n if (!this.complete) throw malformed(\"the value ended before its promises settled\");\n }\n\n /** Rejects every promise and iterable still open: the stream broke. */\n fail(error: unknown): void {\n if (!this.#hasRoot) this.#root.reject(error);\n for (const entry of this.#promises.values()) if (!entry.settled) entry.reject(error);\n for (const entry of this.#iterables.values()) entry.fail(error);\n }\n\n #apply(frame: AsyncFrame): void {\n if (\"p\" in frame) {\n const entry = this.#promises.get(frame.p);\n if (!entry) {\n this.#early.push(frame);\n return;\n }\n if (entry.settled) throw malformed(`promise ${frame.p} settled twice`);\n if (\"e\" in frame) entry.reject(new RemoteError(readError(frame.e)));\n else entry.resolve(this.#decode(frame.v, 0));\n return;\n }\n const entry = this.#iterables.get(frame.i);\n if (!entry) {\n this.#early.push(frame);\n return;\n }\n if (\"e\" in frame) entry.fail(new RemoteError(readError(frame.e)));\n else if (\"end\" in frame) entry.end();\n else entry.push(this.#decode(frame.v, 0));\n }\n\n #chunk(id: number): unknown {\n if (!this.#raw.has(id)) throw malformed(`chunk ${id} is missing`);\n return this.#raw.get(id);\n }\n\n #take(id: number, build: (raw: unknown) => unknown): unknown {\n if (this.#decoded.has(id)) return this.#decoded.get(id);\n const value = build(this.#chunk(id));\n if (!this.#decoded.has(id)) this.#decoded.set(id, value);\n return value;\n }\n\n #flush(): void {\n const early = this.#early.splice(0);\n for (const frame of early) this.#apply(frame);\n }\n\n #decode(json: unknown, depth: number): unknown {\n if (depth > MAX_DEPTH) throw malformed(\"the value nests too deeply\");\n if (json === null || typeof json === \"boolean\") return json;\n if (typeof json === \"number\") {\n if (!Number.isFinite(json)) throw malformed(\"a number isn't finite\");\n return json;\n }\n if (typeof json === \"string\") return this.#string(json, depth);\n if (Array.isArray(json)) return json.map((item) => this.#decode(item, depth + 1));\n if (isRecord(json)) {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(json)) {\n Object.defineProperty(out, key, {\n value: this.#decode(json[key], depth + 1),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n }\n throw malformed(\"a value isn't JSON\");\n }\n\n #id(text: string, at: number): number {\n const id = Number(text.slice(at));\n if (!/^[0-9]+$/.test(text.slice(at)) || !Number.isSafeInteger(id)) {\n throw malformed(`the reference ${JSON.stringify(text.slice(0, 40))}`);\n }\n return id;\n }\n\n #string(text: string, depth: number): unknown {\n if (!text.startsWith(\"$\")) return text;\n if (text.startsWith(\"$$\")) return text.slice(1);\n switch (text) {\n case \"$undefined\":\n return undefined;\n case \"$NaN\":\n return Number.NaN;\n case \"$Infinity\":\n return Number.POSITIVE_INFINITY;\n case \"$-Infinity\":\n return Number.NEGATIVE_INFINITY;\n case \"$-0\":\n return -0;\n case \"$DInvalid\":\n return new Date(Number.NaN);\n }\n const tag = text[1];\n switch (tag) {\n case \"n\":\n if (!/^-?[0-9]+$/.test(text.slice(2))) throw malformed(\"a bigint\");\n if (\n this.#options.mode === \"argument\" &&\n text.replace(\"-\", \"\").length - 2 > ARGUMENT_BIGINT_DIGITS_MAX\n ) {\n throw malformed(`a bigint argument has more than ${ARGUMENT_BIGINT_DIGITS_MAX} digits`);\n }\n return BigInt(text.slice(2));\n case \"S\":\n // Symbol.for keeps every name it is given for the life of the process.\n if (this.#options.mode === \"argument\") throw malformed(\"an argument is a symbol\");\n return Symbol.for(text.slice(2));\n case \"D\": {\n const date = new Date(text.slice(2));\n if (Number.isNaN(date.getTime())) throw malformed(\"a date\");\n return date;\n }\n case \"h\": {\n const id = text.slice(2);\n if (!this.#options.serverFunction) throw malformed(`a Server Function reference ${id}`);\n return this.#options.serverFunction(id);\n }\n case \"@\": {\n const id = this.#id(text, 2);\n let entry = this.#promises.get(id);\n if (!entry) {\n entry = deferred();\n this.#promises.set(id, entry);\n queueMicrotask(() => this.#flushSafely());\n }\n return entry.promise;\n }\n case \"x\": {\n if (this.#options.mode === \"argument\") throw malformed(\"an argument is an async iterable\");\n const id = this.#id(text, 2);\n let entry = this.#iterables.get(id);\n if (!entry) {\n entry = new FedIterable();\n this.#iterables.set(id, entry);\n queueMicrotask(() => this.#flushSafely());\n }\n return entry;\n }\n case \"Q\": {\n const id = this.#id(text, 2);\n if (this.#decoded.has(id)) return this.#decoded.get(id);\n const map = new Map<unknown, unknown>();\n this.#decoded.set(id, map);\n const raw = this.#chunk(id);\n if (!Array.isArray(raw)) throw malformed(\"a map\");\n for (const pair of raw) {\n if (!Array.isArray(pair) || pair.length !== 2) throw malformed(\"a map entry\");\n map.set(this.#decode(pair[0], depth + 1), this.#decode(pair[1], depth + 1));\n }\n return map;\n }\n case \"W\": {\n const id = this.#id(text, 2);\n if (this.#decoded.has(id)) return this.#decoded.get(id);\n const set = new Set<unknown>();\n this.#decoded.set(id, set);\n const raw = this.#chunk(id);\n if (!Array.isArray(raw)) throw malformed(\"a set\");\n for (const item of raw) set.add(this.#decode(item, depth + 1));\n return set;\n }\n case \"A\":\n return this.#take(this.#id(text, 2), (raw) => {\n if (typeof raw !== \"string\") throw malformed(\"an ArrayBuffer\");\n const bytes = fromBase64(raw);\n return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n });\n case \"T\":\n return this.#take(this.#id(text, 2), (raw) => {\n if (!Array.isArray(raw) || typeof raw[1] !== \"string\") throw malformed(\"a typed array\");\n const make = TYPED_CONSTRUCTORS[raw[0] as TypedKind];\n if (!make) throw malformed(\"a typed array's kind\");\n const bytes = fromBase64(raw[1]);\n const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n try {\n return make(buffer as ArrayBuffer);\n } catch {\n throw malformed(\"a typed array's length\");\n }\n });\n case \"B\":\n return this.#take(this.#id(text, 2), (raw) => {\n if (\n !isRecord(raw) ||\n typeof raw[\"data\"] !== \"string\" ||\n typeof raw[\"type\"] !== \"string\"\n ) {\n throw malformed(\"a file\");\n }\n const bytes = fromBase64(raw[\"data\"]);\n const parts = [bytes as Uint8Array<ArrayBuffer>];\n if (typeof raw[\"name\"] === \"string\" && typeof File !== \"undefined\") {\n return new File(parts, raw[\"name\"], {\n type: raw[\"type\"],\n ...(typeof raw[\"lastModified\"] === \"number\"\n ? { lastModified: raw[\"lastModified\"] }\n : {}),\n });\n }\n return new Blob(parts, { type: raw[\"type\"] });\n });\n case \"K\":\n return this.#take(this.#id(text, 2), (raw) => {\n if (!Array.isArray(raw)) throw malformed(\"a FormData\");\n const form = new FormData();\n for (const entry of raw) {\n if (!Array.isArray(entry) || typeof entry[0] !== \"string\")\n throw malformed(\"a FormData entry\");\n const value = this.#decode(entry[1], depth + 1);\n if (typeof value === \"string\") form.append(entry[0], value);\n else if (isBlob(value)) form.append(entry[0], value);\n else throw malformed(\"a FormData value\");\n }\n return form;\n });\n default: {\n // `$<id>`: a shared object or array, outlined.\n const id = this.#id(text, 1);\n if (this.#decoded.has(id)) return this.#decoded.get(id);\n const raw = this.#chunk(id);\n if (Array.isArray(raw)) {\n const array: unknown[] = [];\n this.#decoded.set(id, array);\n for (const item of raw) array.push(this.#decode(item, depth + 1));\n return array;\n }\n if (!isRecord(raw)) throw malformed(\"a shared object\");\n const object: Record<string, unknown> = {};\n this.#decoded.set(id, object);\n for (const key of Object.keys(raw)) {\n Object.defineProperty(object, key, {\n value: this.#decode(raw[key], depth + 1),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return object;\n }\n }\n }\n\n #flushSafely(): void {\n try {\n this.#flush();\n } catch (error) {\n this.fail(error);\n }\n }\n}\n\nfunction readError(value: unknown): WireError {\n if (!isRecord(value) || typeof value[\"message\"] !== \"string\") throw malformed(\"an error\");\n return {\n message: value[\"message\"],\n ...(typeof value[\"code\"] === \"string\" ? { code: value[\"code\"] } : {}),\n };\n}\n\n/**\n * Reads complete batches back into a value: every promise in it settled from the batches, every\n * async iterable replaying its items. For arguments and stored results.\n */\nexport async function deserializeAll(\n batches: readonly unknown[],\n options: ValueReaderOptions = {},\n): Promise<unknown> {\n const reader = new ValueReader(options);\n for (const batch of batches) reader.push(batch);\n // Arguments arrive whole: one that can't be finished is refused before anything runs.\n if (options.mode === \"argument\") reader.finish();\n if (!reader.complete) {\n // Settle whatever the batches never settled: nothing more will come.\n queueMicrotask(() => reader.fail(new SerializationError(\"The written value ended early.\")));\n }\n return reader.root;\n}\n\n/**\n * Checks a page's argument batches without decoding them, before they reach server code: no\n * symbol (`$S`), no async iterable (`$x`), no bigint of more than\n * {@link ARGUMENT_BIGINT_DIGITS_MAX} digits. The supervisor runs it so such arguments are refused\n * before any worker sees them (Opus review 1); the worker's reader refuses them again.\n *\n * @throws SerializationError naming what was found.\n */\nexport function checkArgumentFrames(batches: readonly unknown[]): void {\n const check = (text: string): void => {\n if (text.length < 2 || text[0] !== \"$\" || text[1] === \"$\") return;\n if (text[1] === \"S\") throw malformed(\"an argument is a symbol\");\n if (text[1] === \"x\") throw malformed(\"an argument is an async iterable\");\n if (text[1] === \"n\" && text.replace(\"-\", \"\").length - 2 > ARGUMENT_BIGINT_DIGITS_MAX) {\n throw malformed(`a bigint argument has more than ${ARGUMENT_BIGINT_DIGITS_MAX} digits`);\n }\n };\n const scan = (value: unknown, visit: (text: string) => void): void => {\n const stack: unknown[] = [value];\n while (stack.length > 0) {\n const item = stack.pop();\n if (typeof item === \"string\") visit(item);\n else if (Array.isArray(item)) for (const entry of item) stack.push(entry);\n else if (item !== null && typeof item === \"object\") {\n for (const entry of Object.values(item)) stack.push(entry);\n }\n }\n };\n // A FormData chunk's entry names are written as they are, never escaped: only its values are\n // encoded strings, so those chunks are checked value by value.\n const forms = new Set<number>();\n scan(batches, (text) => {\n const match = /^\\$K([0-9]+)$/.exec(text);\n if (match) forms.add(Number(match[1]));\n });\n for (const batch of batches) {\n if (!Array.isArray(batch)) continue;\n for (const frame of batch) {\n const record = frame as { c?: unknown; v?: unknown } | null;\n if (\n record !== null &&\n typeof record === \"object\" &&\n typeof record.c === \"number\" &&\n forms.has(record.c) &&\n Array.isArray(record.v)\n ) {\n for (const entry of record.v) scan(Array.isArray(entry) ? entry[1] : entry, check);\n } else scan(frame, check);\n }\n }\n}\n"],"mappings":";;;;;;AA+DA,MAAa,6BAA6B;;AAG1C,MAAa,sBAAsB;;AAGnC,IAAa,qBAAb,cAAwC,MAAM;;CAE5C,OAAwB;;CAExB;CACA,YAAY,SAAiB,OAAO,IAAI;EACtC,MAAM,SAAS,KAAK,UAAU,GAAG,MAAM,IAAI,EAAE,GAAG,SAAS;EACzD,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;AAGA,SAAS,MAAM,MAAsB;CACnC,MAAM,WAAW,kBAAkB,KAAK,IAAI;CAC5C,IAAI,UAAU;EACZ,MAAM,OAAO,SAAS,MAAM;EAC5B,OAAO,YAAY,OAAO,SAAS,EAAE,IAAI,IAAI,SAAS,KAAK,KAAK,OAAO;CACzE;CACA,OAAO,KAAK,WAAW,QAAQ,IAAI,OAAO,SAAS,gBAAgB;AACrE;;AAGA,SAAgB,UAAU,OAA2B;CACnD,IAAI,iBAAiB,OAAO;EAC1B,MAAM,OAAQ,MAAqC;EACnD,OAAO;GAAE,SAAS,MAAM;GAAS,GAAI,OAAO,SAAS,WAAW,EAAE,KAAK,IAAI,CAAC;EAAG;CACjF;CACA,OAAO,EAAE,SAAS,OAAO,KAAK,EAAE;AAClC;;AAGA,IAAa,cAAb,cAAiC,MAAM;;CAErC;CACA,YAAY,OAAkB;EAC5B,MAAM,MAAM,OAAO;EACnB,KAAK,OAAO;EACZ,KAAK,OAAO,MAAM;CACpB;AACF;AAIA,MAAM,WAAW;AACjB,MAAM,0BAAS,IAAI,WAAW,GAAG,EAAA,CAAE,KAAK,EAAE;AAC1C,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAiB,SAA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,MAAM,QAAQ,IAAI,GAAG,KAAK,MAAM,SAAS,MAAM,MAAM,KAAK,KAAK;QACnE,IAAI,SAAS,QAAQ,OAAO,SAAS,UACxC,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG,MAAM,KAAK,KAAK;EAE7D;CACF;CAGA,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,UAAU,SAAS;EACtB,MAAM,QAAQ,gBAAgB,KAAK,IAAI;EACvC,IAAI,OAAO,MAAM,IAAI,OAAO,MAAM,EAAE,CAAC;CACvC,CAAC;CACD,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;EAC3B,KAAK,MAAM,SAAS,OAAO;GACzB,MAAM,SAAS;GACf,IACE,WAAW,QACX,OAAO,WAAW,YAClB,OAAO,OAAO,MAAM,YACpB,MAAM,IAAI,OAAO,CAAC,KAClB,MAAM,QAAQ,OAAO,CAAC,GAEtB,KAAK,MAAM,SAAS,OAAO,GAAG,KAAK,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,OAAO,KAAK;QAC5E,KAAK,OAAO,KAAK;EAC1B;CACF;AACF"}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Diagnostic } from "./diagnostics/diagnostic.js";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
//#region src/verify.d.ts
|
|
4
|
+
/** When a verdict's screenshots are handed to the caller (AX-05): images cost tokens. */
|
|
5
|
+
export type ScreenshotPolicy = "on-failure" | "always" | "never";
|
|
6
|
+
/** The Zod schema of the `ScreenshotPolicy` type. */
|
|
7
|
+
export declare const ScreenshotPolicy: z.ZodType<ScreenshotPolicy, string>;
|
|
8
|
+
/** One viewport verify renders at device pixel ratio 1. */
|
|
9
|
+
export interface VerifyViewport {
|
|
10
|
+
/** Its name in the verdict: `desktop`, `mobile`, `tablet`, or `<width>x<height>`. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** Its width in CSS pixels, which at DPR 1 are the screenshot's pixels. */
|
|
13
|
+
readonly width: number;
|
|
14
|
+
/** Its height in CSS pixels. */
|
|
15
|
+
readonly height: number;
|
|
16
|
+
}
|
|
17
|
+
/** The viewports verify renders when the manifest names none (ROUND-3 §9): desktop and mobile. */
|
|
18
|
+
export declare const DEFAULT_VIEWPORTS: readonly VerifyViewport[];
|
|
19
|
+
/**
|
|
20
|
+
* The viewports a manifest's `verify.viewports` names (`desktop`, `mobile`, `tablet`, or
|
|
21
|
+
* `<width>x<height>` from 200 to 4000 px), in its order and without repeats; the defaults when it
|
|
22
|
+
* names none. Returns the names it couldn't read beside them.
|
|
23
|
+
*/
|
|
24
|
+
export declare function viewportsFor(names: readonly string[] | undefined): {
|
|
25
|
+
readonly viewports: readonly VerifyViewport[];
|
|
26
|
+
readonly unknown: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
/** What one image costs each model family to read (D138 item 9). */
|
|
29
|
+
export interface TokenEstimate {
|
|
30
|
+
/** Claude's high-resolution tier (Claude 4.7 and later). */
|
|
31
|
+
readonly claude: number;
|
|
32
|
+
/** GPT at `detail: "high"` (gpt-5.5, gpt-5.6, gpt-6-astra). */
|
|
33
|
+
readonly gpt: number;
|
|
34
|
+
/** Gemini 3 and 4 at the default media resolution. */
|
|
35
|
+
readonly gemini: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What an image of `width` × `height` pixels costs Claude, GPT and Gemini to read, by each
|
|
39
|
+
* provider's published rule as verified on 2026-10-17 (VERIFIED_FACTS, WP-09). Estimates: harnesses
|
|
40
|
+
* use them to budget, and each provider may round differently by a token.
|
|
41
|
+
*/
|
|
42
|
+
export declare function estimateImageTokens(width: number, height: number): TokenEstimate;
|
|
43
|
+
/** One screenshot in a verdict (AX-05). */
|
|
44
|
+
export interface VerdictScreenshot {
|
|
45
|
+
/** The viewport's name. */
|
|
46
|
+
readonly viewport: string;
|
|
47
|
+
/** The PNG, at device pixel ratio 1. */
|
|
48
|
+
readonly path: string;
|
|
49
|
+
/** The image's width in pixels. */
|
|
50
|
+
readonly width: number;
|
|
51
|
+
/** The image's height in pixels. */
|
|
52
|
+
readonly height: number;
|
|
53
|
+
/** What reading the image costs each model family ({@link estimateImageTokens}). */
|
|
54
|
+
readonly tokensEstimate: TokenEstimate;
|
|
55
|
+
/** Whether the caller is handed the image: on failure, or when asked (`screenshots`). */
|
|
56
|
+
readonly returned: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** One ARIA snapshot in a verdict: the text-only picture of what a viewport shows. */
|
|
59
|
+
export interface VerdictAria {
|
|
60
|
+
/** The viewport's name. */
|
|
61
|
+
readonly viewport: string;
|
|
62
|
+
/** The snapshot's YAML. */
|
|
63
|
+
readonly path: string;
|
|
64
|
+
/** A one-line count of what it holds: headings, controls, landmarks. */
|
|
65
|
+
readonly summary: string;
|
|
66
|
+
}
|
|
67
|
+
/** The verdict of one `verify` run (INTERFACES §13). `status` is `fail` exactly when an error exists. */
|
|
68
|
+
export interface VerifyVerdict {
|
|
69
|
+
/** `fail` when any diagnostic is an error, else `pass`. */
|
|
70
|
+
readonly status: "pass" | "fail";
|
|
71
|
+
/** What was verified. */
|
|
72
|
+
readonly artifact: {
|
|
73
|
+
/** The artifact, when it has one already: a manifest `id` or a published path. */
|
|
74
|
+
readonly id?: string;
|
|
75
|
+
/** The source path as the request named it. */
|
|
76
|
+
readonly path: string;
|
|
77
|
+
/** The snapshot's digest (DATA_MODEL §2); empty when verify couldn't read the source. */
|
|
78
|
+
readonly sourceDigest: string;
|
|
79
|
+
/** The environment's digest, `lockDigest` included (DATA_MODEL §2); empty likewise. */
|
|
80
|
+
readonly envDigest: string;
|
|
81
|
+
/** The version this source would publish as, when the artifact is known (D89). */
|
|
82
|
+
readonly versionId?: string;
|
|
83
|
+
};
|
|
84
|
+
/** Every finding, errors first, identical ones folded with a `count`. */
|
|
85
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
86
|
+
/** One per viewport rendered. */
|
|
87
|
+
readonly screenshots: readonly VerdictScreenshot[];
|
|
88
|
+
/** One per viewport rendered. */
|
|
89
|
+
readonly aria: readonly VerdictAria[];
|
|
90
|
+
/** What the smoke test did. */
|
|
91
|
+
readonly smoke: {
|
|
92
|
+
/** Controls the smoke test used. */
|
|
93
|
+
readonly interactions: number;
|
|
94
|
+
/** Server functions that don't check `dryRun()` and were refused instead of run (D55). */
|
|
95
|
+
readonly skippedActions: readonly string[];
|
|
96
|
+
/** Field writes the interactions caused. */
|
|
97
|
+
readonly stateChanges: number;
|
|
98
|
+
};
|
|
99
|
+
/** What changed since the last passing version; empty when there is none. */
|
|
100
|
+
readonly regressions: {
|
|
101
|
+
/**
|
|
102
|
+
* The last passing version: the newest whose recorded verdict passed (D138 item 4). When it is
|
|
103
|
+
* this very source, nothing needed comparing.
|
|
104
|
+
*/
|
|
105
|
+
readonly against?: string;
|
|
106
|
+
/** Controls and landmarks the baseline had and this source doesn't, in brief. */
|
|
107
|
+
readonly aria?: string;
|
|
108
|
+
/** The share of pixels that differ from the baseline, per viewport. */
|
|
109
|
+
readonly pixels?: readonly {
|
|
110
|
+
readonly viewport: string;
|
|
111
|
+
readonly ratio: number;
|
|
112
|
+
}[];
|
|
113
|
+
/** Contracts the baseline had that this source drops: fields, actions, live sources, pages. */
|
|
114
|
+
readonly contracts?: readonly string[];
|
|
115
|
+
};
|
|
116
|
+
/** How long each stage took, in milliseconds, and `total`. */
|
|
117
|
+
readonly timingsMs: Readonly<Record<string, number>>;
|
|
118
|
+
}
|
|
119
|
+
/** The Zod schema of the `VerifyVerdict` type. */
|
|
120
|
+
export declare const VerifyVerdict: z.ZodType<VerifyVerdict>;
|
|
121
|
+
/** The notification `artifact/verify` sends while it runs, when the client accepts it. */
|
|
122
|
+
export declare const ARTIFACT_PROGRESS = "artifact/progress";
|
|
123
|
+
/** `artifact/progress`: one stage of a long request started or ended. */
|
|
124
|
+
export interface ArtifactProgressParams {
|
|
125
|
+
/** The `progressToken` the request carried. */
|
|
126
|
+
readonly progressToken: string;
|
|
127
|
+
/** The stage that started: `prepare`, `compile`, `boot`, `render`, `smoke`, `regression`. */
|
|
128
|
+
readonly stage: string;
|
|
129
|
+
/** How much of the request is done, from 0 to 1, when known. */
|
|
130
|
+
readonly fraction?: number;
|
|
131
|
+
}
|
|
132
|
+
/** The Zod schema of the `ArtifactProgressParams` type. */
|
|
133
|
+
export declare const ArtifactProgressParams: z.ZodType<ArtifactProgressParams>;
|
|
134
|
+
/**
|
|
135
|
+
* The global the verify runner's recorder installs in every frame of a render: a page in the
|
|
136
|
+
* `verify` target reports errors its React error boundaries caught through it, with their
|
|
137
|
+
* `cause` chains, so the runner judges each by its cause (D138 items 2 and 3, Opus review finding
|
|
138
|
+
* 3). Viewers' pages never have it.
|
|
139
|
+
*/
|
|
140
|
+
export declare const VERIFY_REPORT = "__mostraVerifyReport";
|
|
141
|
+
/**
|
|
142
|
+
* What a verify run's page tells the runner about its fields (D138 item 3), on
|
|
143
|
+
* `globalThis[VERIFY_PROBE]` in the `verify` target only: every field it mounted, how, and with
|
|
144
|
+
* which initial value's type; internal to Mostra.
|
|
145
|
+
*/
|
|
146
|
+
export declare const VERIFY_PROBE = "__mostraVerify";
|
|
147
|
+
/** One mounted field, as the probe reports it; internal to Mostra. */
|
|
148
|
+
export interface ProbedField {
|
|
149
|
+
/** The field ID. */
|
|
150
|
+
readonly id: string;
|
|
151
|
+
/** Its scope, as first mounted. */
|
|
152
|
+
readonly scope: "viewer" | "artifact";
|
|
153
|
+
/** The hook that named it: `useField`, `useChoice`, `useForm` or `storage`. */
|
|
154
|
+
readonly hook: string;
|
|
155
|
+
/** `typeof` its initial value, `array` or `null`. */
|
|
156
|
+
readonly initialType: string;
|
|
157
|
+
/** How many components have it mounted now. */
|
|
158
|
+
readonly mounts: number;
|
|
159
|
+
/** Other hook kinds, scopes or initial types it was mounted with, if any. */
|
|
160
|
+
readonly conflicts: readonly string[];
|
|
161
|
+
}
|
|
162
|
+
/** The verify runner's methods (ARCHITECTURE §1): the supervisor asks, the runner answers; internal to Mostra. */
|
|
163
|
+
export declare const VERIFY_RUNNER_METHODS: {
|
|
164
|
+
/** Opens one capability link in a fresh browser context and reports what the page did. */
|
|
165
|
+
readonly render: "verify/render";
|
|
166
|
+
/** Compares two screenshots and writes their difference. */
|
|
167
|
+
readonly compare: "verify/compare";
|
|
168
|
+
};
|
|
169
|
+
/** `verify/render`'s params; internal to Mostra. */
|
|
170
|
+
export interface RenderRequest {
|
|
171
|
+
/** The capability link to open, as a viewer would (D138 item 1). */
|
|
172
|
+
readonly url: string;
|
|
173
|
+
/** The viewport to render at, DPR 1. */
|
|
174
|
+
readonly viewport: VerifyViewport;
|
|
175
|
+
/** The fixed time `Date` reports, in ms since the epoch: the same for every render of a run. */
|
|
176
|
+
readonly clockMs: number;
|
|
177
|
+
/** Where the screenshot and the ARIA snapshot are written, named after `name`. */
|
|
178
|
+
readonly outDir: string;
|
|
179
|
+
/** The render's name: its files are `<name>.png` and `<name>.aria.yml`. */
|
|
180
|
+
readonly name: string;
|
|
181
|
+
/** What to collect besides readiness and the page's own errors. */
|
|
182
|
+
readonly collect: {
|
|
183
|
+
/** A screenshot of the viewport. */
|
|
184
|
+
readonly screenshot: boolean;
|
|
185
|
+
/** The ARIA snapshot. */
|
|
186
|
+
readonly aria: boolean;
|
|
187
|
+
/** axe-core's violations. */
|
|
188
|
+
readonly axe: boolean;
|
|
189
|
+
/** The page's mounted fields, from the field probe. */
|
|
190
|
+
readonly fields: boolean;
|
|
191
|
+
/** Run the smoke test after rendering, within this budget. */
|
|
192
|
+
readonly smoke?: {
|
|
193
|
+
readonly maxInteractions: number;
|
|
194
|
+
readonly maxMs: number;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/** When this render must have ended, in ms since the epoch. */
|
|
198
|
+
readonly deadline: number;
|
|
199
|
+
}
|
|
200
|
+
/** `verify/render`'s answer; internal to Mostra. */
|
|
201
|
+
export interface RenderResult {
|
|
202
|
+
/** Whether the page reported `mostra/ready`. */
|
|
203
|
+
readonly ready: boolean;
|
|
204
|
+
/** What the runner found: page errors, console output, failed requests, axe, smoke, blank. */
|
|
205
|
+
readonly findings: readonly Diagnostic[];
|
|
206
|
+
/** The screenshot written, when asked for. */
|
|
207
|
+
readonly screenshot?: {
|
|
208
|
+
readonly path: string;
|
|
209
|
+
readonly width: number;
|
|
210
|
+
readonly height: number;
|
|
211
|
+
};
|
|
212
|
+
/** The ARIA snapshot written, and its text, when asked for. */
|
|
213
|
+
readonly aria?: {
|
|
214
|
+
readonly path: string;
|
|
215
|
+
readonly text: string;
|
|
216
|
+
};
|
|
217
|
+
/** The mounted fields the probe reported, when asked for. */
|
|
218
|
+
readonly fields?: readonly ProbedField[];
|
|
219
|
+
/** What the smoke test did, when asked for. */
|
|
220
|
+
readonly smoke?: {
|
|
221
|
+
/** Controls used. */
|
|
222
|
+
readonly interactions: number;
|
|
223
|
+
/** Field writes they caused. */
|
|
224
|
+
readonly stateChanges: number;
|
|
225
|
+
/** Server functions the sandbox refused during the smoke test. */
|
|
226
|
+
readonly skipped: readonly string[];
|
|
227
|
+
/** Whether it stopped at its budget. */
|
|
228
|
+
readonly budget: boolean;
|
|
229
|
+
};
|
|
230
|
+
/** Whether the render ran past its deadline and stopped where it was. */
|
|
231
|
+
readonly timedOut: boolean;
|
|
232
|
+
/** When each step ended, in ms after the render started. */
|
|
233
|
+
readonly timingsMs: Readonly<Record<string, number>>;
|
|
234
|
+
}
|
|
235
|
+
/** `verify/compare`'s params; internal to Mostra. */
|
|
236
|
+
export interface CompareRequest {
|
|
237
|
+
/** The baseline's screenshot. */
|
|
238
|
+
readonly a: string;
|
|
239
|
+
/** The source's screenshot. */
|
|
240
|
+
readonly b: string;
|
|
241
|
+
/** Where to write the difference image. */
|
|
242
|
+
readonly diff: string;
|
|
243
|
+
}
|
|
244
|
+
/** `verify/compare`'s answer; internal to Mostra. */
|
|
245
|
+
export interface CompareResult {
|
|
246
|
+
/** The share of pixels that differ beyond pixelmatch's perceptual threshold. */
|
|
247
|
+
readonly ratio: number;
|
|
248
|
+
/** Whether the two images had different sizes (then `ratio` is 1). */
|
|
249
|
+
readonly sizeChanged: boolean;
|
|
250
|
+
}
|
|
251
|
+
/** A one-line count of an ARIA snapshot: headings, controls and landmarks. */
|
|
252
|
+
export declare function ariaSummary(text: string): string;
|
|
253
|
+
//#endregion
|
|
254
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","names":[],"sources":["../src/verify.ts"],"mappings":";;;;YAUY;;qBAGC,kBAAkB,EAAE,QAAQ;;iBAQxB;;WAEN;;WAEA;;WAEA;;;qBAIE,4BAA4B;;;;;;wBAgBzB,aAAa;WAClB,oBAAoB;WACpB;;;iBA4BM;;WAEN;;WAEA;;WAEA;;;;;;;wBAkEK,oBAAoB,eAAe,iBAAiB;;iBAMnD;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,gBAAgB;;WAEhB;;;iBAIM;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;;aAEE;;aAEA;;aAEA;;aAEA;;aAEA;;;WAGF,sBAAsB;;WAEtB,sBAAsB;;WAEtB,eAAe;;WAEf;;aAEE;;aAEA;;aAEA;;;WAGF;;;;;aAKE;;aAEA;;aAEA;eAA6B;eAA2B;;;aAExD;;;WAGF,WAAW,SAAS;;;qBAUlB,eAAe,EAAE,QAAQ;;qBAiDzB;;iBAGI;;WAEN;;WAEA;;WAEA;;;qBAIE,wBAAwB,EAAE,QAAQ;;;;;;;qBAiBlC;;;;;;qBAOA;;iBAGI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;qBAIE;;WAEX;;WAEA;;;iBAIe;;WAEN;;WAEA,UAAU;;WAEV;;WAEA;;WAEA;;WAEA;;aAEE;;aAEA;;aAEA;;aAEA;;aAEA;eAAmB;eAAkC;;;;WAGvD;;;iBAIM;;WAEN;;WAEA,mBAAmB;;WAEnB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