@storystick/react 0.2.0-rc.7 → 0.2.0-rc.8
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 +2 -2
- package/dist/.source-hash +1 -1
- package/dist/authoring-skeleton.d.ts +1 -1
- package/dist/authoring-skeleton.js +1 -1
- package/dist/preview-host/preview-standalone-controls.js +38 -10
- package/dist/preview-icons.d.ts +1 -0
- package/dist/preview-icons.js +1 -0
- package/dist/preview-toolbar-shell.d.ts +1 -0
- package/dist/preview-toolbar-shell.js +4 -1
- package/dist/query-preview-runtime.d.ts +1 -0
- package/dist/query-preview-runtime.js +1 -0
- package/dist/use-generated-query.d.ts +4 -1
- package/dist/use-generated-query.js +12 -3
- package/package.json +5 -5
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.8` 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.8, cohort `sdk-0.2.0-rc.8`. 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
|
|
package/dist/.source-hash
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
0d6b55a2e690b860ed25495a2926bfa2ce24dffb079fb024b45d9a5eee4f8ae8
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The same outline covers admission and module loading, before either app's
|
|
2
2
|
* styles/providers exist. Only the owned panel receives these styles. */
|
|
3
3
|
export declare function AuthoringPanelSkeleton({ surface }: {
|
|
4
|
-
surface: 'editor' | 'assistant';
|
|
4
|
+
surface: 'editor' | 'assistant' | 'comments';
|
|
5
5
|
}): import("react").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
/** The same outline covers admission and module loading, before either app's
|
|
3
3
|
* styles/providers exist. Only the owned panel receives these styles. */
|
|
4
4
|
export function AuthoringPanelSkeleton({ surface }) {
|
|
5
|
-
return _jsxs("div", { "data-ss-panel-skeleton": surface, role: "status", "aria-label": surface === 'assistant' ? 'Loading assistant' : 'Loading document content', children: [_jsx("style", { children: STYLES }), _jsx("div", { "data-ss-panel-skeleton-body": "", "aria-hidden": "true", children: surface === 'assistant' ? _jsxs(_Fragment, { children: [_jsxs("div", { "data-ss-panel-skeleton-greeting": "", children: [_jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-composer": "", children: [_jsx("i", {}), _jsx("i", {})] })] }) : _jsxs(_Fragment, { children: [_jsxs("div", { "data-ss-panel-skeleton-title": "", children: [_jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-tabs": "", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-fields": "", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] })] }) })] });
|
|
5
|
+
return _jsxs("div", { "data-ss-panel-skeleton": surface, role: "status", "aria-label": surface === 'comments' ? 'Loading comments' : surface === 'assistant' ? 'Loading assistant' : 'Loading document content', children: [_jsx("style", { children: STYLES }), _jsx("div", { "data-ss-panel-skeleton-body": "", "aria-hidden": "true", children: surface === 'assistant' ? _jsxs(_Fragment, { children: [_jsxs("div", { "data-ss-panel-skeleton-greeting": "", children: [_jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-composer": "", children: [_jsx("i", {}), _jsx("i", {})] })] }) : _jsxs(_Fragment, { children: [_jsxs("div", { "data-ss-panel-skeleton-title": "", children: [_jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-tabs": "", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { "data-ss-panel-skeleton-fields": "", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] })] }) })] });
|
|
6
6
|
}
|
|
7
7
|
const STYLES = `
|
|
8
8
|
[data-ss-panel-skeleton] { box-sizing: border-box; width: 100%; height: 100%; min-height: 240px; background: var(--ss-surface-page, #fafafa); }
|
|
@@ -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 { editorialPathFromNavigation } from '@storystick/types/editorial-target';
|
|
4
|
+
import { setStandaloneCommentMarkers } from '@storystick/preview/runtime/standalone-overlays';
|
|
3
5
|
import { PREVIEW_COPY, previewCopy } from '@storystick/preview/framework/preview-copy';
|
|
4
6
|
import { lookupPreviewFeedback } from '@storystick/preview/framework/preview-feedback';
|
|
5
7
|
import { useMomentaryPreviewInteractionOverride } from '@storystick/react/internal/use-momentary-preview-navigate-mode';
|
|
@@ -7,7 +9,7 @@ import { PreviewPanelAction, PreviewPanelState } from '@storystick/react/interna
|
|
|
7
9
|
import { AuthoringPanelSkeleton } from '@storystick/react/internal/authoring-skeleton';
|
|
8
10
|
import { useStandalonePresentation } from './use-standalone-presentation.js';
|
|
9
11
|
import { PreviewInteractionControl } from '@storystick/react/internal/preview-interaction-control';
|
|
10
|
-
import { PreviewToolbarShell, PreviewEditIcon as EditIcon, PreviewAssistantIcon as ChatIcon, PreviewStudioIcon as StudioIcon, } from '@storystick/react/internal/preview-toolbar-shell';
|
|
12
|
+
import { PreviewToolbarShell, PreviewEditIcon as EditIcon, PreviewAssistantIcon as ChatIcon, PreviewCommentsIcon as CommentsIcon, PreviewStudioIcon as StudioIcon, } from '@storystick/react/internal/preview-toolbar-shell';
|
|
11
13
|
import { readStandaloneStudioUrl, readStandaloneInteractionMode, rememberStandaloneInteractionMode, } from '@storystick/preview/identity/browser-context';
|
|
12
14
|
import { readStandaloneOverlaySnapshot, revealStandaloneSource, revealStandaloneSlice, setStandaloneOverlayMode, setStandaloneOverlaySuspended, subscribeStandaloneOverlayIntent, subscribeStandaloneOverlaySnapshot, } from '@storystick/preview/runtime/standalone-overlays';
|
|
13
15
|
import { overlayEditorTarget, overlayEditorLocale, } from '@storystick/preview/provenance';
|
|
@@ -67,6 +69,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
67
69
|
const activeSurface = useRef(null);
|
|
68
70
|
const [surface, setSurface] = useState(continuation ? 'editor' : assistantNavigation?.open ? 'assistant' : null);
|
|
69
71
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
72
|
+
const [commentRequest, setCommentRequest] = useState();
|
|
70
73
|
activeSurface.current = surface;
|
|
71
74
|
const [committedTarget, setCommittedTarget] = useState(null);
|
|
72
75
|
const rememberAssistant = useCallback((open) => {
|
|
@@ -74,7 +77,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
74
77
|
rememberPreviewAssistantNavigation({ projectId, sessionId: state.sessionId, threadId: assistantThreadId.current, open });
|
|
75
78
|
}, [projectId, state.sessionId]);
|
|
76
79
|
useEffect(() => {
|
|
77
|
-
runtimeHandle.current?.setSurface(surface
|
|
80
|
+
runtimeHandle.current?.setSurface(surface);
|
|
78
81
|
rememberAssistant(surface === 'assistant');
|
|
79
82
|
}, [surface, rememberAssistant]);
|
|
80
83
|
const [editorStatus, setEditorStatus] = useState('idle');
|
|
@@ -267,13 +270,30 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
267
270
|
// The editor still obtains a fresh admission through its normal mount.
|
|
268
271
|
openEditor(continuation.target);
|
|
269
272
|
}, [continuation, canEdit, page, perspective, openEditor]);
|
|
270
|
-
|
|
273
|
+
const openComments = useCallback((request) => {
|
|
274
|
+
setError(null);
|
|
275
|
+
setMenuOpen(false);
|
|
276
|
+
setCommentRequest(request);
|
|
277
|
+
setSurface('comments');
|
|
278
|
+
runtimeHandle.current?.openComments(request);
|
|
279
|
+
}, []);
|
|
280
|
+
useEffect(() => subscribeStandaloneOverlayIntent((intent, action) => {
|
|
271
281
|
if (interactionSuspendedRef.current)
|
|
272
282
|
return;
|
|
273
283
|
const next = targetForOverlay(intent, state.readContext?.perspective ?? null, page?.locale);
|
|
274
|
-
if (next)
|
|
284
|
+
if (!next)
|
|
285
|
+
return;
|
|
286
|
+
if (action === 'view-comments' || action === 'comment') {
|
|
287
|
+
if (intent.sourceKind === 'model')
|
|
288
|
+
return;
|
|
289
|
+
const position = overlayEditorTarget(intent);
|
|
290
|
+
const path = position.kind === 'field' ? editorialPathFromNavigation(position.path, position.anchors) : null;
|
|
291
|
+
if (path)
|
|
292
|
+
openComments({ target: next, anchor: { kind: 'field', path }, intent: action === 'view-comments' ? 'view' : 'create' });
|
|
293
|
+
}
|
|
294
|
+
else
|
|
275
295
|
openEditor(next);
|
|
276
|
-
}), [openEditor, state.readContext?.perspective, page?.locale]);
|
|
296
|
+
}), [openEditor, openComments, state.readContext?.perspective, page?.locale]);
|
|
277
297
|
const wantsRuntime = surface !== null || menuOpen;
|
|
278
298
|
useEffect(() => {
|
|
279
299
|
if (!wantsRuntime ||
|
|
@@ -319,6 +339,9 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
319
339
|
header: { leading: headerLeading, title: headerTitle, trailing: headerTrailing },
|
|
320
340
|
target: targetRef.current ?? undefined,
|
|
321
341
|
surface,
|
|
342
|
+
commentRequest,
|
|
343
|
+
onCommentMarkers: markers => { if (runtimeOwner.current === owner)
|
|
344
|
+
setStandaloneCommentMarkers(markers); },
|
|
322
345
|
assistantThreadId: assistantThreadId.current,
|
|
323
346
|
onSurface: next => { if (runtimeOwner.current === owner) {
|
|
324
347
|
setMenuOpen(false);
|
|
@@ -399,6 +422,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
399
422
|
if (runtimeOwner.current !== owner)
|
|
400
423
|
return;
|
|
401
424
|
if (status === 'disposed') {
|
|
425
|
+
setStandaloneCommentMarkers(null);
|
|
402
426
|
runtimeOwner.current = null;
|
|
403
427
|
runtimeHandle.current = null;
|
|
404
428
|
admission.current = null;
|
|
@@ -420,7 +444,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
420
444
|
return;
|
|
421
445
|
}
|
|
422
446
|
runtimeHandle.current = handle;
|
|
423
|
-
handle.setSurface(surface
|
|
447
|
+
handle.setSurface(surface);
|
|
424
448
|
}
|
|
425
449
|
catch (cause) {
|
|
426
450
|
if (!cancelled) {
|
|
@@ -433,7 +457,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
433
457
|
return () => {
|
|
434
458
|
cancelled = true;
|
|
435
459
|
};
|
|
436
|
-
}, [authoringUrl, connectAttempt, targetRequest, root, contextContainer, headerLeading, headerTitle, headerTrailing, runtimeSource, surface, wantsRuntime, connected]);
|
|
460
|
+
}, [authoringUrl, connectAttempt, targetRequest, root, contextContainer, headerLeading, headerTitle, headerTrailing, runtimeSource, surface, wantsRuntime, connected, commentRequest]);
|
|
437
461
|
useEffect(() => {
|
|
438
462
|
if (!targetRequest || !runtimeHandle.current)
|
|
439
463
|
return;
|
|
@@ -465,6 +489,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
465
489
|
useEffect(() => {
|
|
466
490
|
mounted.current = true;
|
|
467
491
|
const dispose = () => {
|
|
492
|
+
setStandaloneCommentMarkers(null);
|
|
468
493
|
mounted.current = false;
|
|
469
494
|
runtimeOwner.current = null;
|
|
470
495
|
void runtimeHandle.current?.dispose();
|
|
@@ -476,16 +501,19 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
|
|
|
476
501
|
dispose();
|
|
477
502
|
};
|
|
478
503
|
}, []);
|
|
479
|
-
return _jsx(PreviewToolbarShell, { hostRef: host, onRoot: setRoot, menuOpen: menuOpen, onMenuOpenChange: setMenuOpen, panelOpen: surface !== null, onPanelClose: closePanel, panelTitle: _jsx("span", { ref: setHeaderTitle, className: "panel-title", "data-placeholder": surface === "assistant" ? "Assistant" : "Edit content" }), panelLeading: _jsx("div", { ref: setHeaderLeading, "data-ss-surface": "" }), panelTrailing: _jsx("div", { ref: setHeaderTrailing, "data-ss-surface": "" }), panelLabel: surface === "assistant" ? "Assistant" : "Edit content", menu: _jsxs(_Fragment, { children: [_jsxs("div", { className: "menu-group", role: "group", "aria-label": "Site view", children: [_jsx("span", { className: "menu-group-label", children: "Site view" }), _jsxs("div", { className: "menu-group-content", children: [_jsx("div", { ref: setContextContainer, "data-ss-surface": "" }), editorStatus === 'connecting' ? _jsxs("div", { className: "menu-context-loading", role: "status", "aria-label": "Loading site view", children: [_jsx("span", {}), _jsx("span", {})] }) : null] })] }), _jsx("div", { className: "menu-separator", "aria-hidden": "true" }), _jsxs("div", { className: "menu-group", role: "group", "aria-label": "Interaction", children: [_jsx("span", { className: "menu-group-label", children: "Interaction" }), _jsx("div", { className: "menu-group-content", children: _jsx(PreviewInteractionControl, { interactionMode: effectiveMode, onChange: chooseInteractionMode }) })] }), _jsx("div", { className: "menu-separator", "aria-hidden": "true" }), _jsxs("button", { type: "button", className: "menu-action", disabled: !canEdit, onMouseEnter: () => { if (canEdit)
|
|
504
|
+
return _jsx(PreviewToolbarShell, { hostRef: host, onRoot: setRoot, menuOpen: menuOpen, onMenuOpenChange: setMenuOpen, panelOpen: surface !== null, onPanelClose: closePanel, panelTitle: _jsx("span", { ref: setHeaderTitle, className: "panel-title", "data-placeholder": surface === "comments" ? "Comments" : surface === "assistant" ? "Assistant" : "Edit content" }), panelLeading: _jsx("div", { ref: setHeaderLeading, "data-ss-surface": "" }), panelTrailing: _jsx("div", { ref: setHeaderTrailing, "data-ss-surface": "" }), panelLabel: surface === "comments" ? "Comments" : surface === "assistant" ? "Assistant" : "Edit content", menu: _jsxs(_Fragment, { children: [_jsxs("div", { className: "menu-group", role: "group", "aria-label": "Site view", children: [_jsx("span", { className: "menu-group-label", children: "Site view" }), _jsxs("div", { className: "menu-group-content", children: [_jsx("div", { ref: setContextContainer, "data-ss-surface": "" }), editorStatus === 'connecting' ? _jsxs("div", { className: "menu-context-loading", role: "status", "aria-label": "Loading site view", children: [_jsx("span", {}), _jsx("span", {})] }) : null] })] }), _jsx("div", { className: "menu-separator", "aria-hidden": "true" }), _jsxs("div", { className: "menu-group", role: "group", "aria-label": "Interaction", children: [_jsx("span", { className: "menu-group-label", children: "Interaction" }), _jsx("div", { className: "menu-group-content", children: _jsx(PreviewInteractionControl, { interactionMode: effectiveMode, onChange: chooseInteractionMode }) })] }), _jsx("div", { className: "menu-separator", "aria-hidden": "true" }), _jsxs("button", { type: "button", className: "menu-action", disabled: !canEdit, onMouseEnter: () => { if (canEdit)
|
|
480
505
|
preloadPanel('editor'); }, onFocus: () => { if (canEdit)
|
|
481
506
|
preloadPanel('editor'); }, onClick: () => openEditor(currentPageTarget), children: [_jsx(EditIcon, {}), _jsx("span", { children: "Edit content" })] }), _jsxs("button", { type: "button", className: "menu-action", disabled: !connected || !runtimeSource, onMouseEnter: () => { if (connected)
|
|
482
507
|
preloadPanel('assistant'); }, onFocus: () => { if (connected)
|
|
483
|
-
preloadPanel('assistant'); }, onClick: () => { setError(null); setMenuOpen(false); setSurface('assistant'); }, children: [_jsx(ChatIcon, {}), _jsx("span", { children: "Assistant" })] }),
|
|
508
|
+
preloadPanel('assistant'); }, onClick: () => { setError(null); setMenuOpen(false); setSurface('assistant'); }, children: [_jsx(ChatIcon, {}), _jsx("span", { children: "Assistant" })] }), _jsxs("button", { type: "button", className: "menu-action", disabled: !connected || !rendered || !currentPageTarget || !runtimeSource, onMouseEnter: () => { if (connected)
|
|
509
|
+
preloadPanel('comments'); }, onFocus: () => { if (connected)
|
|
510
|
+
preloadPanel('comments'); }, onClick: () => { if (currentPageTarget)
|
|
511
|
+
openComments({ target: currentPageTarget, intent: 'view' }); }, children: [_jsx(CommentsIcon, {}), _jsx("span", { children: "Comments" })] }), destination && (_jsxs("a", { className: "menu-action", href: destination.href, children: [_jsx(StudioIcon, {}), _jsx("span", { children: "Open in Studio" })] })), (connectionNotice || notice ||
|
|
484
512
|
overlayNotice ||
|
|
485
513
|
(!rendered && connected) ||
|
|
486
514
|
recovery?.error ||
|
|
487
515
|
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.message, ' ', editorStatus === 'error' && !runtimeHandle.current && !needsReopen ? (_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') &&
|
|
488
|
-
(surface === 'assistant' || target || continuation) && (_jsx("div", { className: "editor-loading", children: _jsx(AuthoringPanelSkeleton, { surface: surface
|
|
516
|
+
(surface === 'assistant' || surface === 'comments' || target || continuation) && (_jsx("div", { className: "editor-loading", children: _jsx(AuthoringPanelSkeleton, { surface: surface ?? 'editor' }) })), editorStatus === 'error' && error && (_jsx("div", { className: "panel-state-overlay", children: _jsx(PreviewPanelState, { title: needsReopen ? 'Reopen Preview to edit' : surface === 'comments' ? 'Comments unavailable' : surface === 'assistant' ? 'Assistant unavailable' : PREVIEW_COPY['editor-unavailable'].title, description: error.message, actions: needsReopen ? destination && _jsx("a", { "data-ss-panel-action": "", href: destination.href, target: "_blank", rel: "noopener noreferrer", children: "Open in Studio" }) : _jsx(PreviewPanelAction, { onClick: () => {
|
|
489
517
|
setError(null);
|
|
490
518
|
if (runtimeHandle.current && (committedTarget ?? target))
|
|
491
519
|
requestEditorTarget({ ...(committedTarget ?? target) });
|
package/dist/preview-icons.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export declare function X(props: IconProps): import("react").JSX.Element;
|
|
|
7
7
|
export declare function ArrowUpRight(props: IconProps): import("react").JSX.Element;
|
|
8
8
|
export declare function MessageCircle(props: IconProps): import("react").JSX.Element;
|
|
9
9
|
export declare function SquarePen(props: IconProps): import("react").JSX.Element;
|
|
10
|
+
export declare function MessageSquare(props: IconProps): import("react").JSX.Element;
|
|
10
11
|
export {};
|
package/dist/preview-icons.js
CHANGED
|
@@ -6,3 +6,4 @@ export function X(props) { return _jsxs(Icon, { ...props, children: [_jsx("path"
|
|
|
6
6
|
export function ArrowUpRight(props) { return _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M7 7h10v10" }), _jsx("path", { d: "M7 17 17 7" })] }); }
|
|
7
7
|
export function MessageCircle(props) { return _jsx(Icon, { ...props, children: _jsx("path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z" }) }); }
|
|
8
8
|
export function SquarePen(props) { return _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), _jsx("path", { d: "M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z" })] }); }
|
|
9
|
+
export function MessageSquare(props) { return _jsx(Icon, { ...props, children: _jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) }); }
|
|
@@ -16,4 +16,5 @@ export declare function PreviewToolbarShell(props: {
|
|
|
16
16
|
}): import("react").JSX.Element;
|
|
17
17
|
export declare function PreviewEditIcon(): import("react").JSX.Element;
|
|
18
18
|
export declare function PreviewAssistantIcon(): import("react").JSX.Element;
|
|
19
|
+
export declare function PreviewCommentsIcon(): import("react").JSX.Element;
|
|
19
20
|
export declare function PreviewStudioIcon(): import("react").JSX.Element;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState, } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
import { ArrowUpRight, MessageCircle, SquarePen } from "./preview-icons.js";
|
|
5
|
+
import { ArrowUpRight, MessageCircle, MessageSquare, SquarePen } from "./preview-icons.js";
|
|
6
6
|
import { Popover } from "@base-ui/react/popover";
|
|
7
7
|
import { PreviewToolbarPanel } from "./preview-toolbar-panel.js";
|
|
8
8
|
import { PreviewToolbarResizeHandles } from "./preview-toolbar-resize-handles.js";
|
|
@@ -65,6 +65,9 @@ export function PreviewEditIcon() {
|
|
|
65
65
|
export function PreviewAssistantIcon() {
|
|
66
66
|
return _jsx(MessageCircle, { className: "storystick-control-icon", size: 16, absoluteStrokeWidth: true, strokeWidth: 1.25, "aria-hidden": "true" });
|
|
67
67
|
}
|
|
68
|
+
export function PreviewCommentsIcon() {
|
|
69
|
+
return _jsx(MessageSquare, { className: "storystick-control-icon", size: 16, absoluteStrokeWidth: true, strokeWidth: 1.25, "aria-hidden": "true" });
|
|
70
|
+
}
|
|
68
71
|
export function PreviewStudioIcon() {
|
|
69
72
|
return _jsx(ArrowUpRight, { className: "storystick-control-icon", size: 16, absoluteStrokeWidth: true, strokeWidth: 1.25, "aria-hidden": "true" });
|
|
70
73
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { previewRuntime } from '@storystick/preview/runtime/store';
|
|
2
2
|
export { applyPreviewLiveQueryProjection, previewLiveQueryOverlay } from '@storystick/preview/runtime/live-query-overlay';
|
|
3
3
|
export { estimatePreviewPayloadBytes, recordPreviewPerfMetric } from '@storystick/preview/runtime/perf-metrics';
|
|
4
|
+
export { createPreviewQueryReadLifecycle } from '@storystick/preview/query-render';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { previewRuntime } from '@storystick/preview/runtime/store';
|
|
2
2
|
export { applyPreviewLiveQueryProjection, previewLiveQueryOverlay } from '@storystick/preview/runtime/live-query-overlay';
|
|
3
3
|
export { estimatePreviewPayloadBytes, recordPreviewPerfMetric } from '@storystick/preview/runtime/perf-metrics';
|
|
4
|
+
export { createPreviewQueryReadLifecycle } from '@storystick/preview/query-render';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { StorystickError, type QuerySnapshot } from '@storystick/client';
|
|
2
|
+
import type { PreviewQueryRenderDefinition } from '@storystick/preview/query-render';
|
|
2
3
|
import type { CompiledQueryV2, QueryPageInfo, QueryResult } from '@storystick/types/query-contract';
|
|
3
4
|
export interface UseQueryOptions<TData = unknown, TPageInfo extends QueryPageInfo | null = QueryPageInfo | null> {
|
|
4
5
|
readonly enabled?: boolean;
|
|
5
6
|
/** An SSR render seed from preloadQuery. Browser reads still obtain their own authority. */
|
|
6
|
-
readonly initialData?: QuerySnapshot<TData, TPageInfo
|
|
7
|
+
readonly initialData?: QuerySnapshot<TData, TPageInfo> & {
|
|
8
|
+
readonly previewRender?: PreviewQueryRenderDefinition;
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
11
|
interface ExecutableQuery<TData, TPageInfo extends QueryPageInfo | null> {
|
|
9
12
|
compile(): {
|
|
@@ -66,11 +66,20 @@ export function useQuery(executableQuery, options = {}) {
|
|
|
66
66
|
const visibleInitial = seedIsCurrent ? initialSnapshot : SERVER_PENDING;
|
|
67
67
|
const currentInitialResult = seedIsCurrent ? initialResult : undefined;
|
|
68
68
|
const executionClient = useMemo(() => previewAuthority
|
|
69
|
-
? bindClientSchemaToAuthority(previewAuthority, client.schema
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
? bindClientSchemaToAuthority(previewAuthority, client.schema, options.initialData?.previewRender && previewModules.runtime && seedIsCurrent &&
|
|
70
|
+
previewState.readContext?.perspective.kind !== 'published'
|
|
71
|
+
? {
|
|
72
|
+
previewCodeVersion: options.initialData.previewRender.codeVersion,
|
|
73
|
+
unstable_previewProvenanceReadLifecycle: previewModules.runtime.createPreviewQueryReadLifecycle(options.initialData.previewRender, client.projectId),
|
|
74
|
+
}
|
|
75
|
+
: undefined)
|
|
76
|
+
: client, [client, previewAuthority, options.initialData?.previewRender, previewModules.runtime, seedIsCurrent, previewState.readContext?.perspective.kind]);
|
|
77
|
+
const authorityEpoch = previewAuthority
|
|
72
78
|
? `${currentQueryContextEpoch(client)}:authority:${authorityIdentity(previewAuthority)}`
|
|
73
79
|
: getInternalClientRuntime(client).contextEpoch;
|
|
80
|
+
const contextEpoch = options.initialData?.previewRender && previewAuthority && seedIsCurrent
|
|
81
|
+
? `${authorityEpoch}:render:${options.initialData.previewRender.codeVersion}`
|
|
82
|
+
: authorityEpoch;
|
|
74
83
|
const key = queryCacheKey(executionClient, compiled.canonical, compiled.query.locale.code, compiled.query.page?.after ?? null, contextEpoch);
|
|
75
84
|
const keyIdentity = JSON.stringify(key);
|
|
76
85
|
const store = useMemo(() => {
|
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.8",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -116,10 +116,10 @@
|
|
|
116
116
|
"dependencies": {
|
|
117
117
|
"@tanstack/query-core": "5.101.4",
|
|
118
118
|
"@base-ui/react": "1.3.0",
|
|
119
|
-
"@storystick/
|
|
120
|
-
"@storystick/
|
|
121
|
-
"@storystick/
|
|
122
|
-
"@storystick/
|
|
119
|
+
"@storystick/client": "0.2.0-rc.6",
|
|
120
|
+
"@storystick/preview": "0.2.0-rc.6",
|
|
121
|
+
"@storystick/media": "0.2.0-rc.5",
|
|
122
|
+
"@storystick/types": "0.1.0-rc.5"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"react": "^19.2.8",
|