@storystick/preview 0.2.0-rc.4 → 0.2.0-rc.6
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/PUBLIC-API.md +4 -2
- package/dist/.source-hash +1 -1
- package/dist/authoring/runtime-contract.d.ts +13 -2
- package/dist/authoring/runtime-contract.js +1 -1
- package/dist/channel-taxonomy.js +1 -0
- package/dist/framework/preview-copy.d.ts +42 -30
- package/dist/framework/preview-copy.js +19 -16
- package/dist/framework/preview-feedback.js +4 -1
- package/dist/identity/carriers/postmessage.js +7 -16
- package/dist/index.js +12 -17
- package/dist/overlay-label.d.ts +75 -1
- package/dist/overlay-label.js +93 -1
- package/dist/page-presentation.d.ts +11 -21
- package/dist/page-presentation.js +86 -8
- package/dist/provenance/comment-markers.d.ts +23 -0
- package/dist/provenance/comment-markers.js +65 -0
- package/dist/provenance/markers.js +2 -2
- package/dist/provenance/runtime-script.js +3 -0
- package/dist/query-render.d.ts +13 -0
- package/dist/query-render.js +33 -0
- package/dist/runtime/boot.js +15 -1
- package/dist/runtime/live-query-overlay.js +113 -4
- package/dist/runtime/preview-interaction-policy.js +4 -2
- package/dist/runtime/preview-overlay-painter.d.ts +1 -0
- package/dist/runtime/preview-overlay-painter.js +465 -64
- package/dist/runtime/standalone-overlay-controller.d.ts +3 -1
- package/dist/runtime/standalone-overlay-controller.js +11 -4
- package/dist/server/ordinary-read-provenance.js +4 -3
- package/dist/sha256.d.ts +3 -0
- package/dist/sha256.js +13 -0
- package/package.json +12 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PreviewCommentMarkers } from '../provenance/comment-markers.js';
|
|
1
2
|
import type { PreviewV2RevealSourceRequest, PreviewV2RevealSliceRequest } from '../provenance/reveal-contract.js';
|
|
2
3
|
import type { PreviewOverlayClickPayload } from '@storystick/transport-allowlist';
|
|
3
4
|
import { type PreviewOverlayClickTarget, type PreviewProvenanceOverlayProjection, type ProvenanceOwnerRejection } from '../provenance/index.js';
|
|
@@ -10,7 +11,8 @@ export interface StandaloneOverlaySnapshot {
|
|
|
10
11
|
}
|
|
11
12
|
export declare function readStandaloneOverlaySnapshot(win?: Window): StandaloneOverlaySnapshot;
|
|
12
13
|
export declare function subscribeStandaloneOverlaySnapshot(listener: () => void, win?: Window): () => void;
|
|
13
|
-
export declare function subscribeStandaloneOverlayIntent(listener: (target: PreviewOverlayClickTarget) => void, win?: Window): () => void;
|
|
14
|
+
export declare function subscribeStandaloneOverlayIntent(listener: (target: PreviewOverlayClickTarget, action?: "comment" | "view-comments") => void, win?: Window): () => void;
|
|
15
|
+
export declare function setStandaloneCommentMarkers(comments: PreviewCommentMarkers | null, win?: Window): void;
|
|
14
16
|
export declare function setStandaloneOverlayMode(mode: StandaloneOverlayMode, win?: Window): void;
|
|
15
17
|
/** Paint and route the same validated projection used by Studio. The active
|
|
16
18
|
* projection is re-read on every click; a stale generation cannot become an
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withPreviewCommentMarkers } from '../provenance/comment-markers.js';
|
|
1
2
|
import { createPreviewRequestId } from './request-id.js';
|
|
2
3
|
import { expectPreviewOverlayFocusEcho, consumePreviewOverlayFocusEcho, } from '../provenance/overlay-focus-echo.js';
|
|
3
4
|
import { createPreviewV2SourceRegistry, } from '../provenance/source-registry.js';
|
|
@@ -10,6 +11,7 @@ const serverState = createState();
|
|
|
10
11
|
function createState() {
|
|
11
12
|
return {
|
|
12
13
|
mode: 'edit',
|
|
14
|
+
comments: null,
|
|
13
15
|
suspended: false,
|
|
14
16
|
focusEcho: null,
|
|
15
17
|
anchorMap: null,
|
|
@@ -46,6 +48,11 @@ export function subscribeStandaloneOverlayIntent(listener, win) {
|
|
|
46
48
|
state.intentListeners.add(listener);
|
|
47
49
|
return () => state.intentListeners.delete(listener);
|
|
48
50
|
}
|
|
51
|
+
export function setStandaloneCommentMarkers(comments, win) {
|
|
52
|
+
const state = stateFor(win);
|
|
53
|
+
state.comments = comments;
|
|
54
|
+
state.repaint?.();
|
|
55
|
+
}
|
|
49
56
|
export function setStandaloneOverlayMode(mode, win) {
|
|
50
57
|
const state = stateFor(win);
|
|
51
58
|
state.mode = mode;
|
|
@@ -61,7 +68,7 @@ export function startStandaloneOverlayController(args) {
|
|
|
61
68
|
const state = stateFor(win);
|
|
62
69
|
const repaint = () => {
|
|
63
70
|
const projection = state.projection;
|
|
64
|
-
if (state.mode !== 'edit' ||
|
|
71
|
+
if ((state.mode !== 'edit' && state.comments === null) ||
|
|
65
72
|
state.suspended ||
|
|
66
73
|
projection === null ||
|
|
67
74
|
projection.payload.items.length === 0) {
|
|
@@ -72,7 +79,7 @@ export function startStandaloneOverlayController(args) {
|
|
|
72
79
|
...projection.payload,
|
|
73
80
|
display: 'hover',
|
|
74
81
|
};
|
|
75
|
-
applyPreviewOverlayMap(payload, win, {
|
|
82
|
+
applyPreviewOverlayMap(withPreviewCommentMarkers(payload, projection.clickTargets, state.comments, state.anchorMap ? previewPaintRenderIdentityFromAnchorMap(state.anchorMap)?.readContext?.perspective ?? null : null), win, {
|
|
76
83
|
onClick: (click) => emitIntent(state, click),
|
|
77
84
|
});
|
|
78
85
|
};
|
|
@@ -141,13 +148,13 @@ function emitIntent(state, click) {
|
|
|
141
148
|
state.focusEcho = expectPreviewOverlayFocusEcho(state.activePaint);
|
|
142
149
|
}
|
|
143
150
|
for (const listener of [...state.intentListeners])
|
|
144
|
-
listener(target);
|
|
151
|
+
listener(target, click.action);
|
|
145
152
|
}
|
|
146
153
|
/** The click identity and its owner are resolved from one current projection.
|
|
147
154
|
* A host never receives an intent from stale paint or browse mode. */
|
|
148
155
|
export function resolveStandaloneOverlayIntent(args) {
|
|
149
156
|
const { projection, click } = args;
|
|
150
|
-
if (args.mode !== 'edit' ||
|
|
157
|
+
if ((args.mode !== 'edit' && args.click.action !== 'view-comments') ||
|
|
151
158
|
projection === null ||
|
|
152
159
|
click.routeHash !== projection.payload.routeHash ||
|
|
153
160
|
click.codeVersion !== projection.payload.codeVersion ||
|
|
@@ -4,6 +4,7 @@ import { attachPreviewFrameDependencies, collectPreviewFrameDependencies, attach
|
|
|
4
4
|
import { withPreviewProvenanceContext } from '../provenance/render-context.js';
|
|
5
5
|
import { unstable_attachPreviewRouteRenderContext, unstable_buildPreviewRouteDocumentFrameWithRuntime } from './route-document-provenance.js';
|
|
6
6
|
import { bindPreviewRuntimeToReads } from './provenance-runtime.js';
|
|
7
|
+
import { sha256Hex } from '../sha256.js';
|
|
7
8
|
/** Encode after the raw request cache. Reads stay native and need no render publisher. */
|
|
8
9
|
export async function prepareOrdinaryPreviewRead(raw, runtime, options = {}) {
|
|
9
10
|
if (!runtime.config.isEnabled())
|
|
@@ -18,11 +19,11 @@ export async function prepareOrdinaryPreviewRead(raw, runtime, options = {}) {
|
|
|
18
19
|
if ('documentId' in value && 'storyType' in value && 'fields' in value) {
|
|
19
20
|
const document = value;
|
|
20
21
|
const observation = getPreviewReadObservation(value);
|
|
21
|
-
const
|
|
22
|
+
const digest = await sha256Hex(JSON.stringify([
|
|
22
23
|
document.documentId, observation?.receiptId ?? null,
|
|
23
24
|
observation?.readContext ?? null, document._locale ?? null,
|
|
24
|
-
]))
|
|
25
|
-
const frameId = 'read_' +
|
|
25
|
+
]));
|
|
26
|
+
const frameId = 'read_' + digest.slice(0, 24);
|
|
26
27
|
const plan = document._render;
|
|
27
28
|
const dependencies = isContentRenderPlan(plan) ? plan.dependencies : undefined;
|
|
28
29
|
// Hidden render dependencies participate in coding but remain outside the
|
package/dist/sha256.d.ts
ADDED
package/dist/sha256.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Byte-identical SHA-256 for HTTPS and local HTTP iframe contexts. */
|
|
2
|
+
export async function sha256Hex(input) {
|
|
3
|
+
if (typeof crypto !== 'undefined' && typeof crypto.subtle?.digest === 'function') {
|
|
4
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(input));
|
|
5
|
+
return Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('');
|
|
6
|
+
}
|
|
7
|
+
const { sha256HexFallback } = await import('./sha256-fallback.js');
|
|
8
|
+
return sha256HexFallback(input);
|
|
9
|
+
}
|
|
10
|
+
export async function sha256Bytes(input) {
|
|
11
|
+
const hex = await sha256Hex(input);
|
|
12
|
+
return Uint8Array.from(hex.match(/../g), pair => Number.parseInt(pair, 16));
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storystick/preview",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.6",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
+
"./provenance/comment-markers": {
|
|
10
|
+
"types": "./dist/provenance/comment-markers.d.ts",
|
|
11
|
+
"import": "./dist/provenance/comment-markers.js"
|
|
12
|
+
},
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./dist/index.d.ts",
|
|
11
15
|
"import": "./dist/index.js"
|
|
@@ -166,6 +170,10 @@
|
|
|
166
170
|
"./provenance/slice-model": {
|
|
167
171
|
"types": "./dist/provenance/slice-model.d.ts",
|
|
168
172
|
"import": "./dist/provenance/slice-model.js"
|
|
173
|
+
},
|
|
174
|
+
"./query-render": {
|
|
175
|
+
"types": "./dist/query-render.d.ts",
|
|
176
|
+
"import": "./dist/query-render.js"
|
|
169
177
|
}
|
|
170
178
|
},
|
|
171
179
|
"files": [
|
|
@@ -181,9 +189,9 @@
|
|
|
181
189
|
},
|
|
182
190
|
"dependencies": {
|
|
183
191
|
"convex": "1.42.3",
|
|
184
|
-
"@storystick/
|
|
185
|
-
"@storystick/types": "0.1.0-rc.
|
|
186
|
-
"@storystick/
|
|
192
|
+
"@storystick/transport-allowlist": "0.1.0-rc.5",
|
|
193
|
+
"@storystick/types": "0.1.0-rc.5",
|
|
194
|
+
"@storystick/client": "0.2.0-rc.6"
|
|
187
195
|
},
|
|
188
196
|
"devDependencies": {
|
|
189
197
|
"fake-indexeddb": "^6.2.5",
|