@storystick/preview 0.0.0-stage → 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +112 -0
- package/PUBLIC-API.md +56 -0
- package/README.md +42 -2
- package/dist/.source-hash +1 -0
- package/dist/authoring/runtime-contract.d.ts +92 -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/page-presentation.d.ts +24 -0
- package/dist/page-presentation.js +32 -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 +182 -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 +210 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { getInteractionMode, subscribeInteractionMode, } from "../interaction-mode.js";
|
|
2
|
+
import { PREVIEW_SELECT_CURSOR } from "../select-cursor.js";
|
|
3
|
+
const STYLE_ID = "storystick-preview-interaction-policy-style";
|
|
4
|
+
const INTERACTION_ATTR = "data-ss-preview-interaction";
|
|
5
|
+
// `:root` is stable state-free specificity. It keeps the policy above common
|
|
6
|
+
// customer utility classes that also declare an `!important` cursor, without
|
|
7
|
+
// putting any mutable interaction state back on a React-owned singleton.
|
|
8
|
+
const EDIT_INTERACTION_CSS = `
|
|
9
|
+
html:root,
|
|
10
|
+
html:root body,
|
|
11
|
+
html:root body * {
|
|
12
|
+
cursor: ${PREVIEW_SELECT_CURSOR} !important;
|
|
13
|
+
-webkit-user-select: none !important;
|
|
14
|
+
user-select: none !important;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const POLICY_STATE_KEY = Symbol.for("storystick.preview.interaction-policy-state.v1");
|
|
18
|
+
export function installPreviewInteractionPolicy(win) {
|
|
19
|
+
const existing = getPolicyInstallation(win);
|
|
20
|
+
if (existing !== undefined) {
|
|
21
|
+
existing.count += 1;
|
|
22
|
+
// Installation ref-counting must not turn a repeated install into a
|
|
23
|
+
// no-op for the DOM. Framework head reconciliation can leave the
|
|
24
|
+
// in-memory mode intact while the runtime-owned style is absent.
|
|
25
|
+
applyInteractionMode(win.document, getInteractionMode());
|
|
26
|
+
return releasePreviewInteractionPolicy(win);
|
|
27
|
+
}
|
|
28
|
+
const doc = win.document;
|
|
29
|
+
ensureInteractionPolicyStyle(doc);
|
|
30
|
+
applyInteractionMode(doc, getInteractionMode());
|
|
31
|
+
const installation = {
|
|
32
|
+
count: 1,
|
|
33
|
+
unsubscribe: subscribeInteractionMode((mode) => {
|
|
34
|
+
applyInteractionMode(doc, mode);
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
Reflect.set(win, POLICY_STATE_KEY, installation);
|
|
38
|
+
return releasePreviewInteractionPolicy(win);
|
|
39
|
+
}
|
|
40
|
+
function releasePreviewInteractionPolicy(win) {
|
|
41
|
+
let released = false;
|
|
42
|
+
return () => {
|
|
43
|
+
if (released)
|
|
44
|
+
return;
|
|
45
|
+
released = true;
|
|
46
|
+
const installation = getPolicyInstallation(win);
|
|
47
|
+
if (installation === undefined)
|
|
48
|
+
return;
|
|
49
|
+
installation.count = Math.max(0, installation.count - 1);
|
|
50
|
+
if (installation.count > 0)
|
|
51
|
+
return;
|
|
52
|
+
installation.unsubscribe();
|
|
53
|
+
// The DOM contract belongs to the browsing realm, not to whichever
|
|
54
|
+
// component/session/runtime guard currently holds an installation ref.
|
|
55
|
+
// Keeping the last authoritative stylesheet state prevents transient
|
|
56
|
+
// teardown (StrictMode, route handoff, recovery-frame swap, duplicate SDK
|
|
57
|
+
// entrypoints) from exposing the customer's native cursor. A full document
|
|
58
|
+
// navigation naturally discards the entire Window and its policy.
|
|
59
|
+
Reflect.deleteProperty(win, POLICY_STATE_KEY);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getPolicyInstallation(win) {
|
|
63
|
+
return Reflect.get(win, POLICY_STATE_KEY);
|
|
64
|
+
}
|
|
65
|
+
function applyInteractionMode(doc, mode) {
|
|
66
|
+
const style = ensureInteractionPolicyStyle(doc);
|
|
67
|
+
// React 19 treats <html>, <head>, and <body> as singleton nodes. During an
|
|
68
|
+
// App Router segment swap it releases and reacquires those singletons,
|
|
69
|
+
// removing attributes that were not declared by the new React tree. The
|
|
70
|
+
// interaction mode therefore cannot live on documentElement: a doc-to-doc
|
|
71
|
+
// SPA navigation would erase it without producing an iframe `load` or a new
|
|
72
|
+
// Studio interaction-mode envelope.
|
|
73
|
+
//
|
|
74
|
+
// Keep both the state marker and the active rule on the runtime-owned style
|
|
75
|
+
// element instead. The style survives singleton reconciliation, so Select
|
|
76
|
+
// remains the default across every route commit. Browse opts out by leaving
|
|
77
|
+
// the policy stylesheet empty, preserving the customer's own cursor rules.
|
|
78
|
+
style.setAttribute(INTERACTION_ATTR, mode);
|
|
79
|
+
const nextCss = mode === "edit" ? EDIT_INTERACTION_CSS : "";
|
|
80
|
+
if (style.textContent !== nextCss)
|
|
81
|
+
style.textContent = nextCss;
|
|
82
|
+
}
|
|
83
|
+
function ensureInteractionPolicyStyle(doc) {
|
|
84
|
+
const existing = doc.getElementById(STYLE_ID);
|
|
85
|
+
if (existing?.tagName === "STYLE")
|
|
86
|
+
return existing;
|
|
87
|
+
existing?.remove();
|
|
88
|
+
const style = doc.createElement("style");
|
|
89
|
+
style.id = STYLE_ID;
|
|
90
|
+
// Product rule (owner arbitration 2026-08-05): in Select mode
|
|
91
|
+
// (`edit` interaction) the custom Select cursor applies ALWAYS,
|
|
92
|
+
// across the whole preview surface — independent of painter state,
|
|
93
|
+
// overlay presence, or render-mode. The former
|
|
94
|
+
// `body[data-render-mode="device"]` gate made the cursor vanish
|
|
95
|
+
// whenever the render-mode message had not (yet) stamped the body
|
|
96
|
+
// (fresh realm after a hard nav, painter dead, non-device stages) —
|
|
97
|
+
// exactly the states where the mode signal must stay readable.
|
|
98
|
+
// Navigation (minimap) stages are unaffected by the wider selector:
|
|
99
|
+
// their iframe wrapper is `pointerEvents: none`, so no pointer ever
|
|
100
|
+
// hovers iframe content there.
|
|
101
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
102
|
+
return style;
|
|
103
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-142 P1 — iframe-local field overlay painter.
|
|
3
|
+
*
|
|
4
|
+
* Paint stays iframe-local: no labels/handles, no high-z overlay root.
|
|
5
|
+
* Optional clicks report only opaque paint identity to Studio; Studio
|
|
6
|
+
* owns the private field routing table.
|
|
7
|
+
*/
|
|
8
|
+
import type { PreviewIframeInteractionPayload, PreviewOverlayClickPayload, PreviewOverlayMapPayload, PreviewV2RevealResultStatus, PreviewV2RevealSourcePayload } from "@storystick/transport-allowlist";
|
|
9
|
+
export interface PreviewOverlayPainterOptions {
|
|
10
|
+
onClick?: (payload: PreviewOverlayClickPayload) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface PreviewEditInteractionGuardOptions {
|
|
13
|
+
onInteraction?: (payload: PreviewIframeInteractionPayload) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface PreviewOverlayPaintResult {
|
|
16
|
+
generation: number;
|
|
17
|
+
paintedCount: number;
|
|
18
|
+
missingSnapshotItemKeys: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface PreviewV2RevealResult {
|
|
21
|
+
status: PreviewV2RevealResultStatus;
|
|
22
|
+
revealedCount: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function applyPreviewOverlayMap(payload: PreviewOverlayMapPayload, win: Window, options?: PreviewOverlayPainterOptions | ((payload: PreviewOverlayClickPayload) => void)): PreviewOverlayPaintResult;
|
|
25
|
+
export declare function clearPreviewOverlayPaint(): void;
|
|
26
|
+
export declare function installPreviewEditInteractionGuard(win: Window, options?: PreviewEditInteractionGuardOptions): () => void;
|
|
27
|
+
export declare function revealPreviewV2SourceInIframe(payload: PreviewV2RevealSourcePayload, win: Window): PreviewV2RevealResult;
|