@storystick/next 0.0.0-stage → 0.2.0-rc.0

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.
Files changed (121) hide show
  1. package/LICENSE +112 -0
  2. package/PUBLIC-API.md +31 -0
  3. package/README.md +522 -2
  4. package/dist/.source-hash +1 -0
  5. package/dist/cache-tags.d.ts +2 -0
  6. package/dist/cache-tags.js +12 -0
  7. package/dist/clean.d.ts +1 -0
  8. package/dist/clean.js +1 -0
  9. package/dist/code-version.d.ts +29 -0
  10. package/dist/code-version.js +48 -0
  11. package/dist/file.d.ts +1 -0
  12. package/dist/file.js +1 -0
  13. package/dist/i18n-seo.d.ts +1 -0
  14. package/dist/i18n-seo.js +1 -0
  15. package/dist/image.d.ts +11 -0
  16. package/dist/image.js +22 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +3 -0
  19. package/dist/index.react-server.d.ts +3 -0
  20. package/dist/index.react-server.js +12 -0
  21. package/dist/link.d.ts +10 -0
  22. package/dist/link.js +8 -0
  23. package/dist/preview/index.d.ts +29 -0
  24. package/dist/preview/index.js +24 -0
  25. package/dist/preview/internal.d.ts +61 -0
  26. package/dist/preview/internal.js +97 -0
  27. package/dist/preview/preview-request-identity.d.ts +4 -0
  28. package/dist/preview/preview-request-identity.js +63 -0
  29. package/dist/preview/provenance-config.d.ts +42 -0
  30. package/dist/preview/provenance-config.js +132 -0
  31. package/dist/preview/provenance-frame-builder.d.ts +6 -0
  32. package/dist/preview/provenance-frame-builder.js +10 -0
  33. package/dist/preview/provenance-response.d.ts +5 -0
  34. package/dist/preview/provenance-response.js +9 -0
  35. package/dist/preview/provenance-runtime-adapter.d.ts +9 -0
  36. package/dist/preview/provenance-runtime-adapter.js +42 -0
  37. package/dist/preview/render-frame-provenance.d.ts +23 -0
  38. package/dist/preview/render-frame-provenance.js +47 -0
  39. package/dist/preview/route-authoring.d.ts +3 -0
  40. package/dist/preview/route-authoring.js +80 -0
  41. package/dist/preview/route-context.d.ts +3 -0
  42. package/dist/preview/route-context.js +38 -0
  43. package/dist/preview/route-disable.d.ts +7 -0
  44. package/dist/preview/route-disable.js +63 -0
  45. package/dist/preview/route-document-provenance.d.ts +23 -0
  46. package/dist/preview/route-document-provenance.js +46 -0
  47. package/dist/preview/route-errors.d.ts +1 -0
  48. package/dist/preview/route-errors.js +1 -0
  49. package/dist/preview/route-handler.d.ts +36 -0
  50. package/dist/preview/route-handler.js +139 -0
  51. package/dist/preview/route-initial.d.ts +9 -0
  52. package/dist/preview/route-initial.js +141 -0
  53. package/dist/preview/route-provenance-runtime.d.ts +34 -0
  54. package/dist/preview/route-provenance-runtime.js +90 -0
  55. package/dist/preview/route-token.d.ts +6 -0
  56. package/dist/preview/route-token.js +46 -0
  57. package/dist/preview/server-preview-internals.d.ts +3 -0
  58. package/dist/preview/server-preview-internals.js +3 -0
  59. package/dist/preview/slice-locale.d.ts +5 -0
  60. package/dist/preview/slice-locale.js +15 -0
  61. package/dist/preview-error-surface.d.ts +7 -0
  62. package/dist/preview-error-surface.js +24 -0
  63. package/dist/preview-exit.d.ts +7 -0
  64. package/dist/preview-exit.js +71 -0
  65. package/dist/preview-metadata.d.ts +15 -0
  66. package/dist/preview-metadata.js +13 -0
  67. package/dist/preview-mode-latch.d.ts +133 -0
  68. package/dist/preview-mode-latch.js +231 -0
  69. package/dist/preview-nav-location.d.ts +12 -0
  70. package/dist/preview-nav-location.js +149 -0
  71. package/dist/preview-nav.d.ts +94 -0
  72. package/dist/preview-nav.js +523 -0
  73. package/dist/preview-refresh-coordinator.d.ts +26 -0
  74. package/dist/preview-refresh-coordinator.js +93 -0
  75. package/dist/preview-render-error.d.ts +11 -0
  76. package/dist/preview-render-error.js +36 -0
  77. package/dist/preview-render-recovery.d.ts +9 -0
  78. package/dist/preview-render-recovery.js +42 -0
  79. package/dist/preview-session-recovery.d.ts +1 -0
  80. package/dist/preview-session-recovery.js +1 -0
  81. package/dist/preview-standalone-host.d.ts +3 -0
  82. package/dist/preview-standalone-host.js +55 -0
  83. package/dist/preview-text.d.ts +2 -0
  84. package/dist/preview-text.js +1 -0
  85. package/dist/preview-view-bootstrap.d.ts +5 -0
  86. package/dist/preview-view-bootstrap.js +13 -0
  87. package/dist/public-delivery.d.ts +6 -0
  88. package/dist/public-delivery.js +7 -0
  89. package/dist/query-fetch-options.d.ts +7 -0
  90. package/dist/query-fetch-options.js +193 -0
  91. package/dist/query.d.ts +2 -0
  92. package/dist/query.js +1 -0
  93. package/dist/rendering.d.ts +33 -0
  94. package/dist/rendering.js +42 -0
  95. package/dist/revalidate.d.ts +12 -0
  96. package/dist/revalidate.js +33 -0
  97. package/dist/rich-text.d.ts +2 -0
  98. package/dist/rich-text.js +1 -0
  99. package/dist/server-runtime.d.ts +208 -0
  100. package/dist/server-runtime.js +1584 -0
  101. package/dist/server.d.ts +8 -0
  102. package/dist/server.js +6 -0
  103. package/dist/slice-zone.d.ts +2 -0
  104. package/dist/slice-zone.js +1 -0
  105. package/dist/storystick-component-types.d.ts +26 -0
  106. package/dist/storystick-component-types.js +1 -0
  107. package/dist/storystick-component.d.ts +10 -0
  108. package/dist/storystick-component.js +45 -0
  109. package/dist/storystick-error-recovery.d.ts +12 -0
  110. package/dist/storystick-error-recovery.js +11 -0
  111. package/dist/storystick-preview-runtime.d.ts +30 -0
  112. package/dist/storystick-preview-runtime.js +561 -0
  113. package/dist/storystick.d.ts +24 -0
  114. package/dist/storystick.js +23 -0
  115. package/dist/testing.d.ts +9 -0
  116. package/dist/testing.js +40 -0
  117. package/dist/video.d.ts +1 -0
  118. package/dist/video.js +1 -0
  119. package/package.json +128 -3
  120. package/recipes/README.md +91 -0
  121. package/recipes/resource-mirror.ts +49 -0
@@ -0,0 +1,8 @@
1
+ import 'server-only';
2
+ export { PublicDeliveryReceipt } from './public-delivery.js';
3
+ export { StorystickError } from '@storystick/client';
4
+ export type { StorystickErrorCategory, StorystickErrorOptions, ResolveRouteInput, ResolvedRoute } from '@storystick/client';
5
+ export { stripPreviewProvenance } from './clean.js';
6
+ export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
7
+ export { createSite, createServerClient, resolvePage, buildStorystickSitemap, buildStorystickSitemapShards, STORYSTICK_SITEMAP_MAX_URLS, storystickAlternates, } from './server-runtime.js';
8
+ export type { SiteDefinition, CreateSiteOptions, StorystickSitemapBuildOptions, ResolvePageDataCondition, ResolvePageDataDeclaration, ResolvePageDataDeclarations, ResolvedPageData, ResolvePageRouteInput, ResolvePageInput, ResolvedRouteForSchema, ResolvedRouteWithPageData, TypedResolvePageInput, ResolvedDocumentRoute, StorystickAlternatesOptions, StorystickPublishedLocaleRoute, StorystickSitemapOptions, } from './server-runtime.js';
package/dist/server.js ADDED
@@ -0,0 +1,6 @@
1
+ import 'server-only';
2
+ export { PublicDeliveryReceipt } from './public-delivery.js';
3
+ export { StorystickError } from '@storystick/client';
4
+ export { stripPreviewProvenance } from './clean.js';
5
+ export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
6
+ export { createSite, createServerClient, resolvePage, buildStorystickSitemap, buildStorystickSitemapShards, STORYSTICK_SITEMAP_MAX_URLS, storystickAlternates, } from './server-runtime.js';
@@ -0,0 +1,2 @@
1
+ export { SliceZone, ZoneSlot } from '@storystick/react/slice-zone';
2
+ export type { SliceComponentProps, SliceComponentRegistry, SliceData, SliceFallback, SliceRenderFailure, SliceZoneProps, ZoneSlotDescriptor, ZoneSlotKind, ZoneSlotProps, } from '@storystick/react/slice-zone';
@@ -0,0 +1 @@
1
+ export { SliceZone, ZoneSlot } from '@storystick/react/slice-zone';
@@ -0,0 +1,26 @@
1
+ export interface StorystickClientProps {
2
+ /** Defaults to `process.env.NEXT_PUBLIC_STORYSTICK_PROJECT_ID`. */
3
+ projectId?: string;
4
+ /** Deploy/build signature exposed to the Preview iframe runtime. */
5
+ codeVersion?: string;
6
+ /** Explicit iframe Convex sync URL for self-hosted deployments. */
7
+ gatewaySyncUrl?: string;
8
+ /** Explicit iframe HTTP gateway URL for self-hosted deployments. */
9
+ endpoint?: string;
10
+ /** Publishable key used to construct the Preview HTTP client. */
11
+ publishableKey?: string;
12
+ /** Customer Next.js basePath, for example `/admin`. */
13
+ basePath?: string;
14
+ }
15
+ /** @internal Props resolved by the server wrapper before the iframe runtime loads. */
16
+ export interface StorystickPreviewRuntimeProps extends StorystickClientProps {
17
+ readonly previewServerRenderReceipt?: import('@storystick/preview/framework/render-receipt').PreviewFrameworkRenderReceipt | null;
18
+ /** @internal Client error-boundary reset; never passed across an RSC boundary. */
19
+ readonly resetRenderError?: () => void;
20
+ /** @internal Safe Next server-error classification, including production redaction. */
21
+ readonly renderErrorDigest?: string;
22
+ readonly previewProvenanceRuntimeEnabled?: boolean;
23
+ readonly previewProvenanceRuntimeSrc?: string;
24
+ /** @internal Bilateral dogfood gate; false unless the server wrapper arms it. */
25
+ readonly previewLiveQueryOverlayEnabled?: boolean;
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from "react";
2
+ import type { StorystickClientProps, StorystickPreviewRuntimeProps } from "./storystick-component-types.js";
3
+ export type StorystickProps = StorystickClientProps;
4
+ /**
5
+ * Tiny client boundary present in every customer layout. The Preview runtime
6
+ * is loaded only inside an iframe or an explicitly activated standalone
7
+ * preview tab. A normal top-level customer page still returns `null` and never
8
+ * downloads the runtime chunk.
9
+ */
10
+ export declare function Storystick(props?: StorystickPreviewRuntimeProps): ReactElement | null;
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { isPreviewBrowserContext } from "@storystick/preview/framework/browser-context";
4
+ import { useEffect, useLayoutEffect, useState, useSyncExternalStore } from "react";
5
+ import { commitPreviewRenderReceipt } from '@storystick/preview/framework/render-receipt';
6
+ function subscribeEmbeddingContext() {
7
+ // A browsing context cannot move in or out of its parent without a new
8
+ // document, so there is no live event source to subscribe to.
9
+ return () => { };
10
+ }
11
+ function getServerEmbeddingContext() {
12
+ return false;
13
+ }
14
+ // The mount-time gate knows the project supplied through props. A module-scope
15
+ // preload cannot safely identify a stored view when that prop overrides env.
16
+ /**
17
+ * Tiny client boundary present in every customer layout. The Preview runtime
18
+ * is loaded only inside an iframe or an explicitly activated standalone
19
+ * preview tab. A normal top-level customer page still returns `null` and never
20
+ * downloads the runtime chunk.
21
+ */
22
+ export function Storystick(props = {}) {
23
+ useLayoutEffect(() => {
24
+ if (props.previewServerRenderReceipt)
25
+ return commitPreviewRenderReceipt(props.previewServerRenderReceipt);
26
+ }, [props.previewServerRenderReceipt]);
27
+ const active = useSyncExternalStore(subscribeEmbeddingContext, () => isPreviewBrowserContext(props.projectId ?? process.env.NEXT_PUBLIC_STORYSTICK_PROJECT_ID), getServerEmbeddingContext);
28
+ const [runtime, setRuntime] = useState({ module: null, failed: false });
29
+ useEffect(() => {
30
+ if (!active)
31
+ return;
32
+ let mounted = true;
33
+ // The ESM module loader owns download deduplication. No second module store.
34
+ void import("./storystick-preview-runtime.js").then(module => { if (mounted)
35
+ setRuntime({ module, failed: false }); }, () => { if (mounted)
36
+ setRuntime({ module: null, failed: true }); });
37
+ return () => { mounted = false; };
38
+ }, [active]);
39
+ if (!active)
40
+ return null;
41
+ if (runtime.failed)
42
+ return (_jsxs("aside", { role: "alert", children: ["Preview could not start because its runtime could not be loaded.", _jsx("button", { type: "button", onClick: () => window.location.reload(), children: "Reload Preview" })] }));
43
+ const Runtime = runtime.module?.StorystickPreviewRuntime;
44
+ return Runtime ? _jsx(Runtime, { ...props }) : null;
45
+ }
@@ -0,0 +1,12 @@
1
+ import type { StorystickClientProps } from './storystick-component-types.js';
2
+ /**
3
+ * Mount beside the customer's error UI in Next's error.tsx. Keeps Preview
4
+ * controllable even when that boundary replaces the layout's Storystick.
5
+ * A normal public visit does not load the Preview runtime.
6
+ */
7
+ export declare function StorystickErrorRecovery({ error, reset, ...props }: StorystickClientProps & {
8
+ error: Error & {
9
+ digest?: string;
10
+ };
11
+ reset: () => void;
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Storystick } from './storystick-component.js';
4
+ /**
5
+ * Mount beside the customer's error UI in Next's error.tsx. Keeps Preview
6
+ * controllable even when that boundary replaces the layout's Storystick.
7
+ * A normal public visit does not load the Preview runtime.
8
+ */
9
+ export function StorystickErrorRecovery({ error, reset, ...props }) {
10
+ return _jsx(Storystick, { ...props, resetRenderError: reset, renderErrorDigest: error.digest });
11
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `<Storystick />` — Client Component sibling that initializes the
3
+ * preview runtime singleton (ADR-099 D11).
4
+ *
5
+ * Customer layouts keep their native children and mount <Storystick /> once.
6
+ * Independent layout reads use site.client(); they never replace the page subtree.
7
+ *
8
+ * Responsibilities:
9
+ * - Initialize the singleton on mount (idempotent under StrictMode).
10
+ * - Subscribe via `useSyncExternalStore` to surface state changes
11
+ * (mainly so React tears the fence on `'error'` for adapters that
12
+ * consume the state via context, future-compat).
13
+ * - Coalesce ready projected generations into native server refreshes,
14
+ * preserving the current tree while a React transition is pending.
15
+ * - Render nothing in non-preview mode (state stays `'idle'`).
16
+ * - Render the self-contained error UI when state goes terminal
17
+ * (CSO-PREVIEW-1 visible failure).
18
+ *
19
+ * The component is `'use client'` — server contexts that import it
20
+ * via the Next package's main entry get the client boundary
21
+ * automatically. Server-only helpers (`resolvePreviewDraft`,
22
+ * `isPreviewDraftActive`) live behind the `./server` subpath which
23
+ * is `'server-only'`. The two paths cannot be imported into the
24
+ * same module, but the customer's layout (a Server Component) imports
25
+ * `Storystick` from the main entry and Next renders it as a Client
26
+ * Boundary at runtime.
27
+ */
28
+ import type { ReactElement } from "react";
29
+ import type { StorystickPreviewRuntimeProps } from "./storystick-component-types.js";
30
+ export declare function StorystickPreviewRuntime(props?: StorystickPreviewRuntimeProps): ReactElement | null;