@storystick/preview 0.0.0-stage → 0.2.0-rc.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 +112 -0
- package/PUBLIC-API.md +55 -0
- package/README.md +42 -2
- package/dist/.source-hash +1 -0
- package/dist/authoring/runtime-contract.d.ts +89 -0
- package/dist/authoring/runtime-contract.js +28 -0
- package/dist/channel-taxonomy.d.ts +17 -0
- package/dist/channel-taxonomy.js +46 -0
- package/dist/context-command.d.ts +18 -0
- package/dist/context-command.js +38 -0
- package/dist/dev/suspicious-codeword-detector.d.ts +15 -0
- package/dist/dev/suspicious-codeword-detector.js +220 -0
- package/dist/dev/suspicious-codeword-detector.noop.d.ts +3 -0
- package/dist/dev/suspicious-codeword-detector.noop.js +4 -0
- package/dist/framework/browser-context.d.ts +2 -0
- package/dist/framework/browser-context.js +2 -0
- package/dist/framework/generation-refresh.d.ts +23 -0
- package/dist/framework/generation-refresh.js +82 -0
- package/dist/framework/generation-signal.d.ts +8 -0
- package/dist/framework/generation-signal.js +17 -0
- package/dist/framework/projection-generation-watch.d.ts +5 -0
- package/dist/framework/projection-generation-watch.js +53 -0
- package/dist/framework/render-receipt.d.ts +8 -0
- package/dist/framework/render-receipt.js +10 -0
- package/dist/framework/runtime-adapter-store.d.ts +30 -0
- package/dist/framework/runtime-adapter-store.js +81 -0
- package/dist/grant-coordinator.d.ts +53 -0
- package/dist/grant-coordinator.js +329 -0
- package/dist/grant-lifecycle.d.ts +52 -0
- package/dist/grant-lifecycle.js +74 -0
- package/dist/identity/__test-adapter.d.ts +34 -0
- package/dist/identity/__test-adapter.js +59 -0
- package/dist/identity/browser-context-gate.d.ts +4 -0
- package/dist/identity/browser-context-gate.js +22 -0
- package/dist/identity/browser-context.d.ts +13 -0
- package/dist/identity/browser-context.js +22 -0
- package/dist/identity/carriers/postmessage.d.ts +84 -0
- package/dist/identity/carriers/postmessage.js +177 -0
- package/dist/identity/carriers/storage-state.d.ts +41 -0
- package/dist/identity/carriers/storage-state.js +99 -0
- package/dist/identity/carriers/storage.d.ts +39 -0
- package/dist/identity/carriers/storage.js +182 -0
- package/dist/identity/carriers/url.d.ts +19 -0
- package/dist/identity/carriers/url.js +38 -0
- package/dist/identity/identity-state-machine.d.ts +70 -0
- package/dist/identity/identity-state-machine.js +244 -0
- package/dist/identity/identity-types.d.ts +192 -0
- package/dist/identity/identity-types.js +22 -0
- package/dist/identity/index.d.ts +18 -0
- package/dist/identity/index.js +16 -0
- package/dist/identity/preview-cookie.d.ts +9 -0
- package/dist/identity/preview-cookie.js +12 -0
- package/dist/identity/preview-draft.d.ts +6 -0
- package/dist/identity/preview-draft.js +25 -0
- package/dist/identity/preview-identity.d.ts +28 -0
- package/dist/identity/preview-identity.js +84 -0
- package/dist/identity/preview-scope.d.ts +28 -0
- package/dist/identity/preview-scope.js +47 -0
- package/dist/identity/resolver.d.ts +110 -0
- package/dist/identity/resolver.js +334 -0
- package/dist/identity/session-query.d.ts +4 -0
- package/dist/identity/session-query.js +19 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +788 -0
- package/dist/interaction-mode.d.ts +58 -0
- package/dist/interaction-mode.js +93 -0
- package/dist/nav-handler.d.ts +95 -0
- package/dist/nav-handler.js +84 -0
- package/dist/overlay-label.d.ts +79 -0
- package/dist/overlay-label.js +73 -0
- package/dist/provenance/anchor-map.d.ts +95 -0
- package/dist/provenance/anchor-map.js +177 -0
- package/dist/provenance/carrier-plan.d.ts +51 -0
- package/dist/provenance/carrier-plan.js +90 -0
- package/dist/provenance/coded-text.d.ts +20 -0
- package/dist/provenance/coded-text.js +302 -0
- package/dist/provenance/direct-edit-locator.d.ts +29 -0
- package/dist/provenance/direct-edit-locator.js +218 -0
- package/dist/provenance/editable-leaf.d.ts +134 -0
- package/dist/provenance/editable-leaf.js +483 -0
- package/dist/provenance/editor-target.d.ts +29 -0
- package/dist/provenance/editor-target.js +46 -0
- package/dist/provenance/field-leaf-walker.d.ts +21 -0
- package/dist/provenance/field-leaf-walker.js +98 -0
- package/dist/provenance/frame-dependencies.d.ts +212 -0
- package/dist/provenance/frame-dependencies.js +550 -0
- package/dist/provenance/index.d.ts +26 -0
- package/dist/provenance/index.js +26 -0
- package/dist/provenance/local-events.d.ts +1 -0
- package/dist/provenance/local-events.js +1 -0
- package/dist/provenance/markers.d.ts +21 -0
- package/dist/provenance/markers.js +70 -0
- package/dist/provenance/multi-frame-anchor-map.d.ts +54 -0
- package/dist/provenance/multi-frame-anchor-map.js +109 -0
- package/dist/provenance/normalize.d.ts +2 -0
- package/dist/provenance/normalize.js +19 -0
- package/dist/provenance/overlay-focus-echo.d.ts +17 -0
- package/dist/provenance/overlay-focus-echo.js +16 -0
- package/dist/provenance/overlay-projection.d.ts +65 -0
- package/dist/provenance/overlay-projection.js +201 -0
- package/dist/provenance/owner-map.d.ts +55 -0
- package/dist/provenance/owner-map.js +239 -0
- package/dist/provenance/read-carrier.d.ts +22 -0
- package/dist/provenance/read-carrier.js +92 -0
- package/dist/provenance/recorder.d.ts +38 -0
- package/dist/provenance/recorder.js +82 -0
- package/dist/provenance/render-context.d.ts +106 -0
- package/dist/provenance/render-context.js +338 -0
- package/dist/provenance/reveal-contract.d.ts +44 -0
- package/dist/provenance/reveal-contract.js +1 -0
- package/dist/provenance/richtext-slice-embed-address.d.ts +20 -0
- package/dist/provenance/richtext-slice-embed-address.js +35 -0
- package/dist/provenance/runtime-script.d.ts +1 -0
- package/dist/provenance/runtime-script.js +2217 -0
- package/dist/provenance/sidecar-store.d.ts +63 -0
- package/dist/provenance/sidecar-store.js +151 -0
- package/dist/provenance/sidecar.d.ts +34 -0
- package/dist/provenance/sidecar.js +227 -0
- package/dist/provenance/slice-model.d.ts +28 -0
- package/dist/provenance/slice-model.js +86 -0
- package/dist/provenance/source-identity.d.ts +3 -0
- package/dist/provenance/source-identity.js +7 -0
- package/dist/provenance/source-map-materializer.d.ts +76 -0
- package/dist/provenance/source-map-materializer.js +286 -0
- package/dist/provenance/source-registry.d.ts +103 -0
- package/dist/provenance/source-registry.js +562 -0
- package/dist/provenance/transformed-output-gate.d.ts +161 -0
- package/dist/provenance/transformed-output-gate.js +171 -0
- package/dist/provenance/types.d.ts +102 -0
- package/dist/provenance/types.js +1 -0
- package/dist/refresh-policy.d.ts +11 -0
- package/dist/refresh-policy.js +14 -0
- package/dist/reveal-target.d.ts +8 -0
- package/dist/reveal-target.js +47 -0
- package/dist/route-paths.d.ts +11 -0
- package/dist/route-paths.js +14 -0
- package/dist/router-subscriber.d.ts +92 -0
- package/dist/router-subscriber.js +44 -0
- package/dist/runtime/anchor-types.d.ts +5 -0
- package/dist/runtime/anchor-types.js +1 -0
- package/dist/runtime/authority-store.d.ts +31 -0
- package/dist/runtime/authority-store.js +56 -0
- package/dist/runtime/boot.d.ts +52 -0
- package/dist/runtime/boot.js +379 -0
- package/dist/runtime/content-refresh.d.ts +30 -0
- package/dist/runtime/content-refresh.js +68 -0
- package/dist/runtime/emit-runtime-error.d.ts +51 -0
- package/dist/runtime/emit-runtime-error.js +64 -0
- package/dist/runtime/field-proxy.d.ts +112 -0
- package/dist/runtime/field-proxy.js +471 -0
- package/dist/runtime/form-contract-reporter.d.ts +99 -0
- package/dist/runtime/form-contract-reporter.js +391 -0
- package/dist/runtime/invalidation-adapter.d.ts +17 -0
- package/dist/runtime/invalidation-adapter.js +42 -0
- package/dist/runtime/live-query-overlay.d.ts +39 -0
- package/dist/runtime/live-query-overlay.js +345 -0
- package/dist/runtime/momentary-navigate.d.ts +16 -0
- package/dist/runtime/momentary-navigate.js +106 -0
- package/dist/runtime/observation-scheduler.d.ts +15 -0
- package/dist/runtime/observation-scheduler.js +42 -0
- package/dist/runtime/perf-metrics.d.ts +28 -0
- package/dist/runtime/perf-metrics.js +90 -0
- package/dist/runtime/preview-interaction-policy.d.ts +1 -0
- package/dist/runtime/preview-interaction-policy.js +103 -0
- package/dist/runtime/preview-overlay-painter.d.ts +27 -0
- package/dist/runtime/preview-overlay-painter.js +1732 -0
- package/dist/runtime/preview-overlay-sidecar.d.ts +26 -0
- package/dist/runtime/preview-overlay-sidecar.js +45 -0
- package/dist/runtime/preview-perspective-alignment.d.ts +15 -0
- package/dist/runtime/preview-perspective-alignment.js +40 -0
- package/dist/runtime/preview-perspective-intent-state.d.ts +23 -0
- package/dist/runtime/preview-perspective-intent-state.js +5 -0
- package/dist/runtime/preview-transition-state.d.ts +142 -0
- package/dist/runtime/preview-transition-state.js +257 -0
- package/dist/runtime/render-mode-state.d.ts +51 -0
- package/dist/runtime/render-mode-state.js +76 -0
- package/dist/runtime/request-id.d.ts +4 -0
- package/dist/runtime/request-id.js +8 -0
- package/dist/runtime/resolve-schema-field.d.ts +99 -0
- package/dist/runtime/resolve-schema-field.js +356 -0
- package/dist/runtime/runtime-error-dispatch.d.ts +23 -0
- package/dist/runtime/runtime-error-dispatch.js +75 -0
- package/dist/runtime/schema-store.d.ts +121 -0
- package/dist/runtime/schema-store.js +667 -0
- package/dist/runtime/snapshot-assembly.d.ts +104 -0
- package/dist/runtime/snapshot-assembly.js +553 -0
- package/dist/runtime/snapshot-reporter.d.ts +55 -0
- package/dist/runtime/snapshot-reporter.js +375 -0
- package/dist/runtime/standalone-overlay-controller.d.ts +33 -0
- package/dist/runtime/standalone-overlay-controller.js +281 -0
- package/dist/runtime/store.d.ts +307 -0
- package/dist/runtime/store.js +1026 -0
- package/dist/runtime/windowed-minimap-projection.d.ts +28 -0
- package/dist/runtime/windowed-minimap-projection.js +189 -0
- package/dist/runtime/workspace-shortcuts.d.ts +30 -0
- package/dist/runtime/workspace-shortcuts.js +188 -0
- package/dist/sdk-error-copy.d.ts +48 -0
- package/dist/sdk-error-copy.js +182 -0
- package/dist/select-cursor.d.ts +2 -0
- package/dist/select-cursor.js +23 -0
- package/dist/server/admission-cookie.d.ts +38 -0
- package/dist/server/admission-cookie.js +122 -0
- package/dist/server/control-client.d.ts +29 -0
- package/dist/server/control-client.js +22 -0
- package/dist/server/control-errors.d.ts +22 -0
- package/dist/server/control-errors.js +165 -0
- package/dist/server/draft-route.d.ts +12 -0
- package/dist/server/draft-route.js +45 -0
- package/dist/server/extract-token.d.ts +30 -0
- package/dist/server/extract-token.js +98 -0
- package/dist/server/grant.d.ts +128 -0
- package/dist/server/grant.js +395 -0
- package/dist/server/ordinary-read-provenance.d.ts +11 -0
- package/dist/server/ordinary-read-provenance.js +124 -0
- package/dist/server/preview-read-metadata.d.ts +10 -0
- package/dist/server/preview-read-metadata.js +27 -0
- package/dist/server/provenance-frame-builder.d.ts +53 -0
- package/dist/server/provenance-frame-builder.js +102 -0
- package/dist/server/provenance-runtime.d.ts +70 -0
- package/dist/server/provenance-runtime.js +46 -0
- package/dist/server/read-context-command.d.ts +11 -0
- package/dist/server/read-context-command.js +53 -0
- package/dist/server/read-identity.d.ts +3 -0
- package/dist/server/read-identity.js +63 -0
- package/dist/server/read-lifecycle.d.ts +17 -0
- package/dist/server/read-lifecycle.js +52 -0
- package/dist/server/render-frame-provenance.d.ts +133 -0
- package/dist/server/render-frame-provenance.js +676 -0
- package/dist/server/render-id.d.ts +15 -0
- package/dist/server/render-id.js +22 -0
- package/dist/server/route-document-provenance.d.ts +77 -0
- package/dist/server/route-document-provenance.js +1327 -0
- package/dist/server/route-session-cookie.d.ts +33 -0
- package/dist/server/route-session-cookie.js +54 -0
- package/dist/session-projections.d.ts +33 -0
- package/dist/session-projections.js +43 -0
- package/dist/session-subscriber.d.ts +124 -0
- package/dist/session-subscriber.js +79 -0
- package/dist/sha256-fallback.d.ts +30 -0
- package/dist/sha256-fallback.js +126 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.js +85 -0
- package/dist/validators.d.ts +61 -0
- package/dist/validators.js +110 -0
- package/package.json +206 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-131 Amendment 002 — iframe-side schema store.
|
|
3
|
+
*
|
|
4
|
+
* Caches the project schema fetched via the existing
|
|
5
|
+
* `/api/q/schemas/current` HTTP route. Two storage layers :
|
|
6
|
+
*
|
|
7
|
+
* 1. In-memory `inMemory` cell (sync read for the resolver hot path).
|
|
8
|
+
* 2. IndexedDB cache, keyed by
|
|
9
|
+
* `(projectId, codeVersion, wireFormatVersion)`, TTL 5 min.
|
|
10
|
+
*
|
|
11
|
+
* Hot path (`peekSchema`) is synchronous — returns the in-memory record
|
|
12
|
+
* or `null`. The async `bootSchema` is idempotent : concurrent callers
|
|
13
|
+
* share a single in-flight promise ; tag mismatches (different
|
|
14
|
+
* projectId or codeVersion) invalidate the fast path and refetch ;
|
|
15
|
+
* TTL expiry triggers refetch ; network failures preserve the last
|
|
16
|
+
* good record (degraded mode).
|
|
17
|
+
*
|
|
18
|
+
* Race contracts :
|
|
19
|
+
* - Provider mounts AFTER iframe runtime starts → bootSchema returns
|
|
20
|
+
* `null` until `previewRuntime.httpClient` is set. Resolver retries
|
|
21
|
+
* next rAF cycle. Cost : ~1-2 rAF (~32 ms).
|
|
22
|
+
* - codeVersion drift mid-session → resolver detects mismatch, calls
|
|
23
|
+
* `resetSchemaStore()` then `bootSchema()` ; null SnapshotItems for
|
|
24
|
+
* the cycle, fresh fetch next.
|
|
25
|
+
* - Concurrent callers → `inflight` promise serialises ; IDB + HTTP
|
|
26
|
+
* caches absorb the rare double-fetch.
|
|
27
|
+
*
|
|
28
|
+
* TTL+codeVersion tradeoff (amendment §6.3) : a `storystick push`
|
|
29
|
+
* without code rebuild leaves the codeVersion unchanged. The iframe
|
|
30
|
+
* may serve a stale schema for up to 5 min in that edge case. The
|
|
31
|
+
* normal dev workflow (push → generate types → rebuild → bundle hash
|
|
32
|
+
* changes → codeVersion bumps) invalidates immediately.
|
|
33
|
+
*/
|
|
34
|
+
import { type RawSchemaRow } from '@storystick/client/adapter';
|
|
35
|
+
export interface CachedSchemaRecord {
|
|
36
|
+
projectId: string;
|
|
37
|
+
codeVersion: string;
|
|
38
|
+
schema: RawSchemaRow;
|
|
39
|
+
fetchedAt: number;
|
|
40
|
+
}
|
|
41
|
+
export interface SchemaDeliveryFailure {
|
|
42
|
+
readonly kind: 'transient' | 'incompatible';
|
|
43
|
+
readonly code: string;
|
|
44
|
+
readonly message: string;
|
|
45
|
+
readonly retryable: boolean;
|
|
46
|
+
readonly projectId: string;
|
|
47
|
+
readonly codeVersion: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Synchronous accessor — the resolver §D6.1 calls this every rAF cycle.
|
|
51
|
+
* Returns `null` until `bootSchema()` has resolved at least once with
|
|
52
|
+
* a non-null gateway response.
|
|
53
|
+
*
|
|
54
|
+
* Tag-aware (codex R3 P1) : returns the in-memory record only when its
|
|
55
|
+
* tags still match the current `(projectId, codeVersion)`. Without
|
|
56
|
+
* this gate, an identity Replace or codeVersion bump would leak the
|
|
57
|
+
* prior tenant's / prior bundle's schema to the resolver hot path
|
|
58
|
+
* until `bootSchema()` has had a chance to overwrite or null-out the
|
|
59
|
+
* slot. Returning `null` under stale tags is the same surface the
|
|
60
|
+
* resolver already handles (degraded mode, retry next rAF).
|
|
61
|
+
*/
|
|
62
|
+
export declare function peekSchema(): CachedSchemaRecord | null;
|
|
63
|
+
/**
|
|
64
|
+
* Boot or refresh the iframe-side schema cache. Returns the in-memory
|
|
65
|
+
* record (possibly stale, if a refetch failed) OR `null` if no record
|
|
66
|
+
* has ever been established AND the current attempt cannot proceed
|
|
67
|
+
* (missing httpClient / identity / codeVersion / network failure).
|
|
68
|
+
*
|
|
69
|
+
* Idempotent : concurrent callers await the same `inflight` promise.
|
|
70
|
+
*
|
|
71
|
+
* Tag-stability invariant (codex R1 fix) : we re-read the current
|
|
72
|
+
* projectId + codeVersion AFTER each await and discard the result
|
|
73
|
+
* if the tags drifted. Without this, an identity Replace mid-flight
|
|
74
|
+
* could install a wrong-tenant schema OR keep a stale prior record
|
|
75
|
+
* referenced under the wrong tags.
|
|
76
|
+
*/
|
|
77
|
+
export declare function bootSchema(): Promise<CachedSchemaRecord | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Drop the in-memory record. Used by the resolver when it detects a
|
|
80
|
+
* codeVersion drift — the next `bootSchema()` refetches against the
|
|
81
|
+
* new tag. Does NOT clear IDB ; the IDB entry under the new tag is
|
|
82
|
+
* separate and the old tag's row is harmless until it ages out.
|
|
83
|
+
*/
|
|
84
|
+
export declare function invalidateSchema(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Test hook — clears in-memory, in-flight, AND IDB. Never invoked in
|
|
87
|
+
* production code.
|
|
88
|
+
*/
|
|
89
|
+
export declare function _resetSchemaStoreForTestsOnly(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Test hook — expose the current in-flight promise so tests can assert
|
|
92
|
+
* concurrent callers share it. Returns null when no fetch is pending.
|
|
93
|
+
*/
|
|
94
|
+
export declare function _peekInflightForTestsOnly(): Promise<CachedSchemaRecord | null> | null;
|
|
95
|
+
export declare function _peekSchemaFailureForTestsOnly(): SchemaDeliveryFailure | null;
|
|
96
|
+
/**
|
|
97
|
+
* Start the schema-retry orchestrator. Idempotent — calling a second
|
|
98
|
+
* time before stop returns the same teardown. Wired by `boot.ts` once
|
|
99
|
+
* per runtime boot.
|
|
100
|
+
*
|
|
101
|
+
* Behaviour per §9.T7 :
|
|
102
|
+
* - Subscribes to `previewRuntime` ; resets the cycle whenever
|
|
103
|
+
* `httpClient` or `identity.projectId` changes ; kicks off attempt
|
|
104
|
+
* 1 (after the 1s grace delay) when both preconditions are met.
|
|
105
|
+
* - If preconditions are ALREADY met at start, schedules attempt 1
|
|
106
|
+
* immediately via the same delay path (no fast-track).
|
|
107
|
+
* - On success at any attempt, resets the counter ; on attempt 5
|
|
108
|
+
* failure, emits the error envelope and stops retrying for the
|
|
109
|
+
* current cycle (waiting for the next identity change to rearm).
|
|
110
|
+
*/
|
|
111
|
+
export declare function startSchemaRetryLoop(): () => void;
|
|
112
|
+
export declare function stopSchemaRetryLoop(): void;
|
|
113
|
+
/** Test hook — read the current attempt count. */
|
|
114
|
+
export declare function _peekRetryAttemptForTestsOnly(): number;
|
|
115
|
+
/**
|
|
116
|
+
* Test hook — directly install an in-memory schema record. Used by
|
|
117
|
+
* orchestrator tests that need `bootSchema()` to return a record via
|
|
118
|
+
* the fast path without going through the IDB+transport stack (which
|
|
119
|
+
* doesn't compose with `vi.useFakeTimers`).
|
|
120
|
+
*/
|
|
121
|
+
export declare function _setInMemoryForTestsOnly(record: CachedSchemaRecord | null): void;
|