@storystick/react 0.2.0-rc.1 → 0.2.0-rc.3
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 -3
- package/README.md +4 -2
- package/dist/.source-hash +1 -1
- package/dist/preview-host/preview-standalone-controls.d.ts +1 -0
- package/dist/preview-host/preview-standalone-controls.js +18 -15
- package/dist/preview-terminal-state.d.ts +8 -0
- package/dist/preview-terminal-state.js +37 -0
- package/package.json +10 -6
package/PUBLIC-API.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @storystick/react API contract
|
|
2
2
|
|
|
3
|
-
Install this candidate explicitly with `@storystick/react@0.2.0-rc.
|
|
3
|
+
Install this candidate explicitly with `@storystick/react@0.2.0-rc.3` after registry bootstrap and publication. This repository alone does not make the candidate or beta channel available on npm.
|
|
4
4
|
|
|
5
|
-
Version 0.2.0-rc.
|
|
5
|
+
Version 0.2.0-rc.3, cohort `sdk-0.2.0-rc.3`. ESM distribution; no CommonJS or universal Edge compatibility is promised.
|
|
6
6
|
|
|
7
7
|
This package is a product integration facade. Reserved contracts are required between SDK packages and must be upgraded with the same cohort. Their public export paths do not promise independent stability.
|
|
8
8
|
|
|
@@ -27,11 +27,12 @@ This package is a product integration facade. Reserved contracts are required be
|
|
|
27
27
|
| `./internal/resize-edge` | Reserved SDK contract |
|
|
28
28
|
| `./internal/preview-toolbar-shell` | Reserved SDK contract |
|
|
29
29
|
| `./internal/preview-page-state` | Reserved SDK contract |
|
|
30
|
+
| `./internal/preview-terminal-state` | Reserved SDK contract |
|
|
30
31
|
| `./internal/authoring-skeleton` | Reserved SDK contract |
|
|
31
32
|
| `./internal/preview-panel-state` | Reserved SDK contract |
|
|
32
33
|
| `./internal/preview-host` | Reserved SDK contract |
|
|
33
34
|
|
|
34
|
-
The
|
|
35
|
+
Supported consumer Node versions: `^22.13.0 || ^24.19.0`. The release build toolchain remains Node 24.19.0 and pnpm 9.15.9. Next uses App Router 15.5.28, Sharp 0.35.5 and React/React DOM 19.2.8; Astro uses 7.4.4 with the Node adapter 11.1.9. Browser delivery is verified by bundling; hosted Preview activation and cross-browser behavior require the staging manual check. Source/CLI are Node tools, server entries belong on the server, and browser entries must never receive a server API key.
|
|
35
36
|
|
|
36
37
|
Use a generated Query V2 definition. A missing document/singleton returns null, an empty collection returns an empty array, and fetch throws on blocked/degraded execution. Execute exposes the complete result envelope. RSC metadata must remain plain JSON data; request authority must not be stored in shared module state.
|
|
37
38
|
|
package/README.md
CHANGED
|
@@ -223,5 +223,7 @@ do not need to model Content Plane convergence states.
|
|
|
223
223
|
## Candidate distribution contract
|
|
224
224
|
|
|
225
225
|
See [PUBLIC-API.md](./PUBLIC-API.md) for supported entries, reserved SDK contracts,
|
|
226
|
-
the qualified runtime matrix and the candidate cohort.
|
|
227
|
-
|
|
226
|
+
the qualified runtime matrix and the candidate cohort. Keep shared contracts
|
|
227
|
+
compatible. Use the [release guide](../../release/README.md) to select the
|
|
228
|
+
packages and consumers that need an update; an independent adapter fix does
|
|
229
|
+
not require republishing every package.
|
package/dist/.source-hash
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
cd953980c3d53fab939eb42eb894e0f0f2863a9790a73d70c830db6be353a266
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { PREVIEW_COPY, previewCopy } from '@storystick/preview/framework/preview-copy';
|
|
4
|
+
import { lookupPreviewFeedback } from '@storystick/preview/framework/preview-feedback';
|
|
3
5
|
import { useMomentaryPreviewInteractionOverride } from '@storystick/react/internal/use-momentary-preview-navigate-mode';
|
|
4
6
|
import { PreviewPanelAction, PreviewPanelState } from '@storystick/react/internal/preview-panel-state';
|
|
5
7
|
import { AuthoringPanelSkeleton } from '@storystick/react/internal/authoring-skeleton';
|
|
@@ -119,14 +121,15 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
119
121
|
state.renderedReadContext?.revision === state.readContext.revision;
|
|
120
122
|
const connected = state.state === 'authenticated' && state.readContextStatus === 'active';
|
|
121
123
|
const connectionNotice = state.state === 'error' || recovery?.error
|
|
122
|
-
?
|
|
123
|
-
:
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
? lookupPreviewFeedback(state.errorCode).title
|
|
125
|
+
: recovery?.pending ? PREVIEW_COPY['taking-longer'].title
|
|
126
|
+
: !connected
|
|
127
|
+
? PREVIEW_COPY.connecting.title
|
|
128
|
+
: null;
|
|
126
129
|
const notice = state.readContextNotice === 'release-published'
|
|
127
|
-
? '
|
|
130
|
+
? `${PREVIEW_COPY['release-follows-main'].title}. ${previewCopy('release-follows-main', { release: 'This release' }).body}`
|
|
128
131
|
: state.readContextNotice === 'release-archived'
|
|
129
|
-
? '
|
|
132
|
+
? `${PREVIEW_COPY['release-archived'].title}. ${previewCopy('release-archived', { release: 'This release' }).body}`
|
|
130
133
|
: null;
|
|
131
134
|
const interactionSuspended = !connected || !rendered || presentation.transition.kind !== 'idle';
|
|
132
135
|
// Render proof protects page overlays. An accepted editor gesture can load
|
|
@@ -147,8 +150,8 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
147
150
|
(currentPageTarget !== null || overlays.available);
|
|
148
151
|
const overlayNotice = overlays.rejections.length > 0
|
|
149
152
|
? overlays.rejections.some(rejection => rejection.reason === 'edit-locator-variant-mismatch')
|
|
150
|
-
? '
|
|
151
|
-
: '
|
|
153
|
+
? PREVIEW_COPY['visual-unavailable'].body
|
|
154
|
+
: PREVIEW_COPY['visual-limited'].body
|
|
152
155
|
: null;
|
|
153
156
|
const shouldPreloadRuntime = canEdit && (interactionMode === 'edit' || menuOpen);
|
|
154
157
|
useEffect(() => {
|
|
@@ -405,7 +408,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
405
408
|
setEditorStatus('connecting');
|
|
406
409
|
if (status === 'unauthorized') {
|
|
407
410
|
setEditorStatus('error');
|
|
408
|
-
setError('
|
|
411
|
+
setError(PREVIEW_COPY['editing-forbidden'].title);
|
|
409
412
|
}
|
|
410
413
|
},
|
|
411
414
|
});
|
|
@@ -480,14 +483,14 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
480
483
|
overlayNotice ||
|
|
481
484
|
(!rendered && connected) ||
|
|
482
485
|
recovery?.error ||
|
|
483
|
-
error) && (_jsxs("div", { className: "notices", children: [connectionNotice && _jsx("p", { role: "status", children: connectionNotice }), notice && _jsx("p", { children: notice }), overlayNotice && _jsx("p", { role: "status", children: overlayNotice }), connected && !rendered && (_jsxs("p", { children: [
|
|
484
|
-
(surface === 'assistant' || target || continuation) && (_jsx("div", { className: "editor-loading", children: _jsx(AuthoringPanelSkeleton, { surface: surface === 'assistant' ? 'assistant' : 'editor' }) })), editorStatus === 'error' && error && (_jsx("div", { className: "panel-state-overlay", children: _jsx(PreviewPanelState, { title: surface === 'assistant' ? 'Assistant unavailable' : '
|
|
486
|
+
error) && (_jsxs("div", { className: "notices", children: [connectionNotice && _jsx("p", { role: "status", children: connectionNotice }), notice && _jsx("p", { children: notice }), overlayNotice && _jsx("p", { role: "status", children: overlayNotice }), connected && !rendered && (_jsxs("p", { children: [PREVIEW_COPY.updating.body, ' ', _jsx("button", { type: "button", onClick: () => window.location.reload(), children: "Reload" })] })), recovery?.error && (_jsxs("p", { role: "alert", children: [PREVIEW_COPY['connection-interrupted'].body, ' ', _jsx("button", { type: "button", onClick: recovery.retry, disabled: false, children: "Retry" })] })), error && _jsxs("p", { role: "alert", children: [error, ' ', editorStatus === 'error' && !runtimeHandle.current ? (_jsx("button", { type: "button", onClick: () => setConnectAttempt(value => value + 1), children: "Retry" })) : null] })] }))] }), panel: _jsxs(_Fragment, { children: [surface === 'editor' && target === null && committedTarget === null && !continuation && (_jsxs("div", { className: "editor-empty", children: [_jsx(EditIcon, {}), _jsx("strong", { children: PREVIEW_COPY['element-empty'].title }), _jsx("p", { children: PREVIEW_COPY['element-empty'].body })] })), (editorStatus === 'idle' || editorStatus === 'connecting') &&
|
|
487
|
+
(surface === 'assistant' || target || continuation) && (_jsx("div", { className: "editor-loading", children: _jsx(AuthoringPanelSkeleton, { surface: surface === 'assistant' ? 'assistant' : 'editor' }) })), editorStatus === 'error' && error && (_jsx("div", { className: "panel-state-overlay", children: _jsx(PreviewPanelState, { title: surface === 'assistant' ? 'Assistant unavailable' : PREVIEW_COPY['editor-unavailable'].title, description: error, actions: _jsx(PreviewPanelAction, { onClick: () => {
|
|
485
488
|
setError(null);
|
|
486
489
|
if (runtimeHandle.current && (committedTarget ?? target))
|
|
487
490
|
requestEditorTarget({ ...(committedTarget ?? target) });
|
|
488
491
|
else
|
|
489
492
|
setConnectAttempt((value) => value + 1);
|
|
490
|
-
}, children: "Retry" }) }) })), surface === 'editor' && presentation.transition.kind === 'unconfirmed' && (_jsx("div", { className: "panel-state-overlay", children: _jsx(PreviewPanelState, { title:
|
|
493
|
+
}, children: "Retry" }) }) })), surface === 'editor' && presentation.transition.kind === 'unconfirmed' && (_jsx("div", { className: "panel-state-overlay", children: _jsx(PreviewPanelState, { title: PREVIEW_COPY['update-failed'].title, description: PREVIEW_COPY['update-failed'].body, actions: _jsx(PreviewPanelAction, { onClick: () => window.location.reload(), children: "Reload preview" }) }) })), _jsx("div", { ref: editorContainer, className: "editor-mount", inert: (surface === 'editor' ? editorSuspended : !connected) || editorStatus !== 'ready', "aria-busy": (surface === 'editor' && editorSuspended) || editorStatus === 'connecting' })] }) });
|
|
491
494
|
}
|
|
492
495
|
function targetForPage(page, perspective) {
|
|
493
496
|
return {
|
|
@@ -519,10 +522,10 @@ function authoringErrorMessage(error) {
|
|
|
519
522
|
const code = error instanceof Error ? error.message : '';
|
|
520
523
|
console.warn('[storystick] Preview authoring connection failed:', /^[A-Z][A-Z0-9_]{0,80}$/.test(code) ? code : 'AUTHORING_RUNTIME_ERROR');
|
|
521
524
|
if (code.includes('AUTHORING_WRITE_FORBIDDEN')) {
|
|
522
|
-
return '
|
|
525
|
+
return PREVIEW_COPY['editing-forbidden'].title;
|
|
523
526
|
}
|
|
524
527
|
if (code.includes('CONTENT_SHAPE_RELOAD_REQUIRED')) {
|
|
525
|
-
return '
|
|
528
|
+
return PREVIEW_COPY['deployment-changed'].body;
|
|
526
529
|
}
|
|
527
|
-
return '
|
|
530
|
+
return PREVIEW_COPY['editor-unavailable'].body;
|
|
528
531
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface PreviewTerminalStateProps {
|
|
2
|
+
code?: string | null;
|
|
3
|
+
studioUrl?: string | null;
|
|
4
|
+
onRetryExit?: () => void;
|
|
5
|
+
}
|
|
6
|
+
/** A terminal Preview state owns its viewport, without changing customer DOM.
|
|
7
|
+
* Isolate product styling from the customer's page and its error boundary. */
|
|
8
|
+
export declare function PreviewTerminalState({ code, studioUrl, onRetryExit }: PreviewTerminalStateProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { lookupSdkCopy } from '@storystick/preview/sdk-error-copy';
|
|
6
|
+
import { safePreviewCode, previewDiagnostic } from '@storystick/preview/framework/preview-diagnostic';
|
|
7
|
+
import { PreviewPageState } from './preview-page-state.js';
|
|
8
|
+
/** A terminal Preview state owns its viewport, without changing customer DOM.
|
|
9
|
+
* Isolate product styling from the customer's page and its error boundary. */
|
|
10
|
+
export function PreviewTerminalState({ code, studioUrl, onRetryExit }) {
|
|
11
|
+
const copy = lookupSdkCopy(code);
|
|
12
|
+
const [copyStatus, setCopyStatus] = useState('idle');
|
|
13
|
+
const copyRequest = useRef(0);
|
|
14
|
+
const host = useRef(null);
|
|
15
|
+
const [root, setRoot] = useState(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (host.current)
|
|
18
|
+
setRoot(host.current.shadowRoot ?? host.current.attachShadow({ mode: 'open' }));
|
|
19
|
+
return () => { copyRequest.current++; };
|
|
20
|
+
}, []);
|
|
21
|
+
return _jsx("div", { ref: host, "data-storystick-preview-error": "", "data-storystick-preview-controls": "", style: {
|
|
22
|
+
all: 'initial', position: 'fixed', inset: 0, zIndex: 2147483646, background: '#fff',
|
|
23
|
+
}, children: root ? createPortal(_jsx(PreviewPageState, { title: copy.title, description: copy.body, role: "status", actions: _jsxs(_Fragment, { children: [copy.action === 'exit' && onRetryExit ? _jsx("button", { type: "button", "data-ss-preview-page-action": "primary", onClick: onRetryExit, children: "Retry exit" }) : null, ['retry', 'retry-page'].includes(copy.action ?? '') ? _jsx("button", { type: "button", "data-ss-preview-page-action": "primary", onClick: () => window.location.reload(), children: copy.actionLabel }) : null, studioUrl ? _jsx("a", { "data-ss-preview-page-action": "", href: studioUrl, children: "Return to Studio" }) : null] }), children: copy.diagnostic ? _jsxs("details", { children: [_jsx("summary", { children: "Diagnostic" }), _jsx("pre", { children: safePreviewCode(code) }), _jsx("button", { type: "button", "data-ss-preview-page-action": "", onClick: async () => {
|
|
24
|
+
const request = ++copyRequest.current;
|
|
25
|
+
try {
|
|
26
|
+
if (!navigator.clipboard)
|
|
27
|
+
throw new Error('Clipboard unavailable');
|
|
28
|
+
await navigator.clipboard.writeText(previewDiagnostic({ code }));
|
|
29
|
+
if (request === copyRequest.current)
|
|
30
|
+
setCopyStatus('copied');
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
if (request === copyRequest.current)
|
|
34
|
+
setCopyStatus('failed');
|
|
35
|
+
}
|
|
36
|
+
}, children: copyStatus === 'copied' ? 'Diagnostic copied' : 'Copy diagnostic' }), copyStatus === 'failed' ? _jsx("p", { role: "status", children: "Diagnostic couldn\u2019t be copied. Select the code above to share it." }) : null, copy.commonCauses.length ? _jsx("ul", { style: { textAlign: 'left', paddingLeft: 18 }, children: copy.commonCauses.map(cause => _jsx("li", { children: cause }, cause)) }) : null] }) : null }), root) : null });
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storystick/react",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.3",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"types": "./dist/preview-page-state.d.ts",
|
|
85
85
|
"import": "./dist/preview-page-state.js"
|
|
86
86
|
},
|
|
87
|
+
"./internal/preview-terminal-state": {
|
|
88
|
+
"types": "./dist/preview-terminal-state.d.ts",
|
|
89
|
+
"import": "./dist/preview-terminal-state.js"
|
|
90
|
+
},
|
|
87
91
|
"./internal/authoring-skeleton": {
|
|
88
92
|
"types": "./dist/authoring-skeleton.d.ts",
|
|
89
93
|
"import": "./dist/authoring-skeleton.js"
|
|
@@ -112,10 +116,10 @@
|
|
|
112
116
|
"dependencies": {
|
|
113
117
|
"@tanstack/query-core": "5.101.4",
|
|
114
118
|
"@base-ui/react": "1.3.0",
|
|
115
|
-
"@storystick/
|
|
116
|
-
"@storystick/
|
|
117
|
-
"@storystick/types": "0.1.0-rc.
|
|
118
|
-
"@storystick/preview": "0.2.0-rc.
|
|
119
|
+
"@storystick/media": "0.2.0-rc.3",
|
|
120
|
+
"@storystick/client": "0.2.0-rc.3",
|
|
121
|
+
"@storystick/types": "0.1.0-rc.3",
|
|
122
|
+
"@storystick/preview": "0.2.0-rc.3"
|
|
119
123
|
},
|
|
120
124
|
"peerDependencies": {
|
|
121
125
|
"react": "^19.2.8",
|
|
@@ -133,7 +137,7 @@
|
|
|
133
137
|
"vitest": "^3.1.1"
|
|
134
138
|
},
|
|
135
139
|
"engines": {
|
|
136
|
-
"node": "
|
|
140
|
+
"node": "^22.13.0 || ^24.19.0"
|
|
137
141
|
},
|
|
138
142
|
"repository": {
|
|
139
143
|
"type": "git",
|