@storystick/react 0.2.0-rc.6 → 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 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.4` after registry bootstrap and publication. This repository alone does not make the candidate or beta channel available on npm.
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.4, cohort `sdk-0.2.0-rc.4`. ESM distribution; no CommonJS or universal Edge compatibility is promised.
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
- 353d7b8f246c83216b28d05c27361ee10632bc5776be8a75404a22d7053703d3
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 === 'editor' || surface === 'assistant' ? surface : null);
80
+ runtimeHandle.current?.setSurface(surface);
78
81
  rememberAssistant(surface === 'assistant');
79
82
  }, [surface, rememberAssistant]);
80
83
  const [editorStatus, setEditorStatus] = useState('idle');
@@ -82,6 +85,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
82
85
  const target = targetRequest?.target ?? null;
83
86
  const [connectAttempt, setConnectAttempt] = useState(0);
84
87
  const [error, setError] = useState(null);
88
+ const needsReopen = error?.kind === 'reopen';
85
89
  useEffect(() => {
86
90
  const next = readPreviewEditorNavigation(projectId, state.sessionId);
87
91
  if (!next || runtimeHandle.current)
@@ -266,13 +270,30 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
266
270
  // The editor still obtains a fresh admission through its normal mount.
267
271
  openEditor(continuation.target);
268
272
  }, [continuation, canEdit, page, perspective, openEditor]);
269
- useEffect(() => subscribeStandaloneOverlayIntent((intent) => {
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) => {
270
281
  if (interactionSuspendedRef.current)
271
282
  return;
272
283
  const next = targetForOverlay(intent, state.readContext?.perspective ?? null, page?.locale);
273
- 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
274
295
  openEditor(next);
275
- }), [openEditor, state.readContext?.perspective, page?.locale]);
296
+ }), [openEditor, openComments, state.readContext?.perspective, page?.locale]);
276
297
  const wantsRuntime = surface !== null || menuOpen;
277
298
  useEffect(() => {
278
299
  if (!wantsRuntime ||
@@ -318,6 +339,9 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
318
339
  header: { leading: headerLeading, title: headerTitle, trailing: headerTrailing },
319
340
  target: targetRef.current ?? undefined,
320
341
  surface,
342
+ commentRequest,
343
+ onCommentMarkers: markers => { if (runtimeOwner.current === owner)
344
+ setStandaloneCommentMarkers(markers); },
321
345
  assistantThreadId: assistantThreadId.current,
322
346
  onSurface: next => { if (runtimeOwner.current === owner) {
323
347
  setMenuOpen(false);
@@ -398,6 +422,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
398
422
  if (runtimeOwner.current !== owner)
399
423
  return;
400
424
  if (status === 'disposed') {
425
+ setStandaloneCommentMarkers(null);
401
426
  runtimeOwner.current = null;
402
427
  runtimeHandle.current = null;
403
428
  admission.current = null;
@@ -408,7 +433,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
408
433
  setEditorStatus('connecting');
409
434
  if (status === 'unauthorized') {
410
435
  setEditorStatus('error');
411
- setError(PREVIEW_COPY['editing-forbidden'].title);
436
+ setError({ kind: 'unavailable', message: PREVIEW_COPY['editing-forbidden'].title });
412
437
  }
413
438
  },
414
439
  });
@@ -419,7 +444,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
419
444
  return;
420
445
  }
421
446
  runtimeHandle.current = handle;
422
- handle.setSurface(surface === 'editor' || surface === 'assistant' ? surface : null);
447
+ handle.setSurface(surface);
423
448
  }
424
449
  catch (cause) {
425
450
  if (!cancelled) {
@@ -432,7 +457,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
432
457
  return () => {
433
458
  cancelled = true;
434
459
  };
435
- }, [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]);
436
461
  useEffect(() => {
437
462
  if (!targetRequest || !runtimeHandle.current)
438
463
  return;
@@ -464,6 +489,7 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
464
489
  useEffect(() => {
465
490
  mounted.current = true;
466
491
  const dispose = () => {
492
+ setStandaloneCommentMarkers(null);
467
493
  mounted.current = false;
468
494
  runtimeOwner.current = null;
469
495
  void runtimeHandle.current?.dispose();
@@ -475,16 +501,19 @@ export function PreviewStandaloneControls({ state, projectId, recovery, basePath
475
501
  dispose();
476
502
  };
477
503
  }, []);
478
- 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)
479
505
  preloadPanel('editor'); }, onFocus: () => { if (canEdit)
480
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)
481
507
  preloadPanel('assistant'); }, onFocus: () => { if (connected)
482
- preloadPanel('assistant'); }, onClick: () => { setError(null); setMenuOpen(false); setSurface('assistant'); }, children: [_jsx(ChatIcon, {}), _jsx("span", { children: "Assistant" })] }), destination && (_jsxs("a", { className: "menu-action", href: destination.href, children: [_jsx(StudioIcon, {}), _jsx("span", { children: "Open in Studio" })] })), (connectionNotice || notice ||
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 ||
483
512
  overlayNotice ||
484
513
  (!rendered && connected) ||
485
514
  recovery?.error ||
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: () => {
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') &&
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: () => {
488
517
  setError(null);
489
518
  if (runtimeHandle.current && (committedTarget ?? target))
490
519
  requestEditorTarget({ ...(committedTarget ?? target) });
@@ -522,10 +551,10 @@ function authoringErrorMessage(error) {
522
551
  const code = error instanceof Error ? error.message : '';
523
552
  console.warn('[storystick] Preview authoring connection failed:', /^[A-Z][A-Z0-9_]{0,80}$/.test(code) ? code : 'AUTHORING_RUNTIME_ERROR');
524
553
  if (code.includes('AUTHORING_WRITE_FORBIDDEN')) {
525
- return PREVIEW_COPY['editing-forbidden'].title;
554
+ return { kind: 'unavailable', message: PREVIEW_COPY['editing-forbidden'].title };
526
555
  }
527
556
  if (code.includes('CONTENT_SHAPE_RELOAD_REQUIRED')) {
528
- return PREVIEW_COPY['deployment-changed'].body;
557
+ return { kind: 'reopen', message: 'The project or site has changed since this Preview was opened. Open a new Preview from Studio to continue editing.' };
529
558
  }
530
- return PREVIEW_COPY['editor-unavailable'].body;
559
+ return { kind: 'unavailable', message: PREVIEW_COPY['editor-unavailable'].body };
531
560
  }
@@ -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 {};
@@ -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" }) }); }
@@ -1,5 +1,5 @@
1
1
  export type PreviewInteractionMode = "edit" | "browse";
2
- /** Lightweight common control: available before loading the authoring runtime. */
2
+ /** Shared toolbar control, also available before loading the authoring theme. */
3
3
  export declare function PreviewInteractionControl({ interactionMode, onChange, }: {
4
4
  interactionMode: PreviewInteractionMode;
5
5
  onChange(mode: PreviewInteractionMode): void;
@@ -2,17 +2,19 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Radio } from "@base-ui/react/radio";
4
4
  import { RadioGroup } from "@base-ui/react/radio-group";
5
- /** Lightweight common control: available before loading the authoring runtime. */
5
+ /** Shared toolbar control, also available before loading the authoring theme. */
6
6
  export function PreviewInteractionControl({ interactionMode, onChange, }) {
7
7
  return (_jsx(RadioGroup, { value: interactionMode, onValueChange: onChange, "aria-label": "Preview interaction mode", "data-slot": "preview-frame-interaction-mode", style: {
8
8
  display: "inline-flex",
9
9
  alignItems: "center",
10
- padding: 4,
11
- gap: 2,
10
+ boxSizing: "border-box",
11
+ height: 36,
12
+ padding: "var(--ss-space-2, 2px)",
13
+ gap: "var(--ss-space-2, 2px)",
12
14
  borderRadius: 999,
13
- background: "var(--color-surface-card, #fff)",
14
- color: "var(--color-text-primary, #17191b)",
15
- boxShadow: "var(--ss-shadow-control, 0 0 0 1px rgb(0 0 0 / 8%), 0 2px 4px rgb(0 0 0 / 5%))",
15
+ background: "var(--ss-surface-card, #fff)",
16
+ color: "var(--ss-text-primary, oklch(0.2 0.007 258.364))",
17
+ boxShadow: "var(--ss-shadow-hub, 0 0 0 1px rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05), 0 6px 16px -10px rgb(0 0 0 / 0.1), 0 16px 34px -24px rgb(0 0 0 / 0.12))",
16
18
  }, children: ["edit", "browse"].map((mode) => (_jsx(Radio.Root, { value: mode, nativeButton: true, render: _jsx("button", { type: "button" }), "data-slot": `preview-frame-interaction-${mode}`, "aria-label": mode === "edit"
17
19
  ? "Inspect: select content to edit"
18
20
  : "Navigate: use site links", title: mode === "edit"
@@ -22,18 +24,26 @@ export function PreviewInteractionControl({ interactionMode, onChange, }) {
22
24
  display: "inline-flex",
23
25
  alignItems: "center",
24
26
  justifyContent: "center",
25
- height: 28,
26
- padding: "0 8px",
27
+ boxSizing: "border-box",
28
+ flexShrink: 0,
29
+ height: 32,
30
+ width: mode === "edit" ? 32 : undefined,
31
+ margin: 0,
32
+ padding: mode === "edit" ? 0 : "0 var(--ss-space-8, 8px)",
27
33
  border: 0,
28
34
  borderRadius: 999,
29
35
  cursor: "pointer",
30
36
  background: interactionMode === mode
31
- ? "var(--color-surface-field, #f0f0f1)"
37
+ ? "var(--ss-surface-field, oklch(0.958 0.001 255))"
32
38
  : "transparent",
33
- color: "inherit",
39
+ color: interactionMode === mode
40
+ ? "inherit"
41
+ : "var(--ss-text-secondary, oklch(0.471 0.006 258.364))",
34
42
  fontFamily: "inherit",
35
43
  fontSize: 13,
36
44
  fontWeight: 500,
37
45
  lineHeight: "17px",
46
+ whiteSpace: "nowrap",
47
+ outlineOffset: -2,
38
48
  }, children: mode === "edit" ? (_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: (1.25 * 24) / 14, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M2 10h6V4" }), _jsx("path", { d: "m2 4 6 6" }), _jsx("path", { d: "M21 10V7a2 2 0 0 0-2-2h-7" }), _jsx("path", { d: "M3 14v2a2 2 0 0 0 2 2h3" }), _jsx("rect", { x: "12", y: "14", width: "10", height: "7", rx: "1" })] })) : ("Navigate") }, mode))) }));
39
49
  }
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { PREVIEW_PAGE_STYLES } from '@storystick/preview/page-presentation';
3
- import { StorystickMark } from './storystick-mark.js';
3
+ import { StorystickWordmark } from './storystick-mark.js';
4
4
  /** One page composition for launch, activation and terminal Preview feedback.
5
5
  * Actions and progress belong to the caller's existing lifecycle. */
6
6
  export function PreviewPageState({ title, description, role, indicator, actions, children }) {
7
- return _jsxs(_Fragment, { children: [_jsx("style", { children: PREVIEW_PAGE_STYLES }), _jsx("main", { "data-ss-preview-page": "", children: _jsxs("div", { "data-ss-preview-page-content": "", children: [_jsxs("div", { "data-ss-preview-page-brand": "", children: [_jsx(StorystickMark, {}), _jsx("span", { children: "Storystick" })] }), _jsxs("div", { role: role, children: [_jsxs("div", { "data-ss-preview-page-heading": "", children: [indicator, _jsx("h1", { "data-ss-preview-page-title": "", children: title })] }), _jsx("p", { "data-ss-preview-page-description": "", children: description })] }), actions ? _jsx("div", { "data-ss-preview-page-actions": "", children: actions }) : null, children] }) })] });
7
+ return _jsxs(_Fragment, { children: [_jsx("style", { children: PREVIEW_PAGE_STYLES }), _jsx("main", { "data-ss-preview-page": "", children: _jsxs("div", { "data-ss-preview-page-content": "", children: [_jsx("div", { "data-ss-preview-page-brand": "", children: _jsx(StorystickWordmark, {}) }), _jsxs("div", { role: role, children: [_jsxs("div", { "data-ss-preview-page-heading": "", children: [indicator, _jsx("h1", { "data-ss-preview-page-title": "", children: title })] }), _jsx("p", { "data-ss-preview-page-description": "", children: description })] }), actions ? _jsx("div", { "data-ss-preview-page-actions": "", children: actions }) : null, children] }) })] });
8
8
  }
9
9
  export function PreviewPageProgress() {
10
10
  return _jsx("span", { "data-ss-preview-page-progress": "", "aria-hidden": "true" });
@@ -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
  }
@@ -79,7 +82,7 @@ const CONTROL_STYLES = `
79
82
  .bubble { pointer-events: auto; touch-action: none; user-select: none; position: fixed; top: 0; left: 0; z-index: 2; width: 40px; height: 40px; display: grid; place-items: center; color: inherit; background: var(--ss-surface-card, #fff); border: 0; border-radius: 999px; transition: background-color 140ms ease, transform 180ms ease-out; }
80
83
  .bubble:hover { background: var(--ss-surface-field, oklch(0.958 0.001 255)); }
81
84
  .bubble:focus-visible, .menu-action:focus-visible, .panel-close:focus-visible, .panel-drag-handle:focus-visible { outline: 2px solid var(--ss-focus-color, oklch(0.614 0.194 257)); outline-offset: -2px; }
82
- .storystick-brand { width: 14px; height: 13px; transform: rotate(90deg); }
85
+ .storystick-brand { width: 13px; height: 13px; }
83
86
  .menu-positioner { z-index: 3; pointer-events: auto; }
84
87
  .menu { width: min(240px, calc(100vw - ${TOOLBAR_GAP * 2}px)); max-height: min(var(--available-height), calc(100dvh - ${TOOLBAR_GAP * 2}px)); overflow: auto; overscroll-behavior: contain; padding: 5px; }
85
88
  /* Keep the bubble's relief stable before and after the authoring styles load. */
@@ -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,3 +1,3 @@
1
1
  import type { ComponentPropsWithoutRef } from 'react';
2
- /** Canonical brand geometry, shared by Studio and the lightweight preview host. */
3
2
  export declare function StorystickMark(props: ComponentPropsWithoutRef<'svg'>): import("react").JSX.Element;
3
+ export declare function StorystickWordmark(props: ComponentPropsWithoutRef<'svg'>): import("react").JSX.Element;
@@ -1,6 +1,15 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { STORYSTICK_MARK_RECTS, STORYSTICK_MARK_VIEW_BOX } from '@storystick/preview/page-presentation';
3
- /** Canonical brand geometry, shared by Studio and the lightweight preview host. */
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { STORYSTICK_MARK_PATHS, STORYSTICK_MARK_RECT, STORYSTICK_MARK_VIEW_BOX, STORYSTICK_WORDMARK_LETTERING, STORYSTICK_WORDMARK_VIEW_BOX, } from '@storystick/preview/page-presentation';
3
+ // The social image renderer only accepts native SVG nodes inside an SVG.
4
+ function renderMark() {
5
+ return [
6
+ _jsx("rect", { ...STORYSTICK_MARK_RECT }, "middle"),
7
+ ...STORYSTICK_MARK_PATHS.map(path => _jsx("path", { d: path }, path)),
8
+ ];
9
+ }
4
10
  export function StorystickMark(props) {
5
- return (_jsx("svg", { ...props, "data-slot": "storystick-mark", viewBox: STORYSTICK_MARK_VIEW_BOX, fill: "currentColor", focusable: "false", "aria-hidden": "true", children: STORYSTICK_MARK_RECTS.map(rect => _jsx("rect", { ...rect }, rect.x)) }));
11
+ return (_jsx("svg", { fill: "currentColor", ...props, "data-slot": "storystick-mark", viewBox: STORYSTICK_MARK_VIEW_BOX, focusable: "false", "aria-hidden": "true", children: renderMark() }));
12
+ }
13
+ export function StorystickWordmark(props) {
14
+ return (_jsxs("svg", { fill: "currentColor", role: "img", "aria-label": "Storystick", ...props, "data-slot": "storystick-wordmark", viewBox: STORYSTICK_WORDMARK_VIEW_BOX, focusable: "false", children: [renderMark(), _jsx("path", { d: STORYSTICK_WORDMARK_LETTERING })] }));
6
15
  }
@@ -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
- : client, [client, previewAuthority]);
71
- const contextEpoch = previewAuthority
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.6",
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/client": "0.2.0-rc.4",
120
- "@storystick/media": "0.2.0-rc.3",
121
- "@storystick/types": "0.1.0-rc.3",
122
- "@storystick/preview": "0.2.0-rc.4"
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",