@storystick/next 0.2.0-rc.0 → 0.2.0-rc.1
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/preview/route-initial.js +21 -6
- package/dist/preview-error-surface.js +3 -7
- package/package.json +6 -6
package/PUBLIC-API.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @storystick/next API contract
|
|
2
2
|
|
|
3
|
-
Install this candidate explicitly with `@storystick/next@0.2.0-rc.
|
|
3
|
+
Install this candidate explicitly with `@storystick/next@0.2.0-rc.1` 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.1, cohort `sdk-0.2.0-rc.1`. 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
|
+
20e8248dcde770c1a3966e62bbd395af132defa0ac1ada5c01ce32f486997919
|
|
@@ -6,7 +6,7 @@ import { getPreviewTransport, resolvePreviewRequestOrigin } from './internal.js'
|
|
|
6
6
|
import { primePreviewGrantAccess } from '@storystick/preview/server/extract-token';
|
|
7
7
|
import { resolveStorystickApplicationBuildId } from '../code-version.js';
|
|
8
8
|
import { buildPreviewGrantCookieFromActivation, setPreviewGrantCookieOnResponse, } from '@storystick/preview/server/route-session-cookie';
|
|
9
|
-
import {
|
|
9
|
+
import { previewInitialRouteErrorResponse, } from './route-errors.js';
|
|
10
10
|
import { PREVIEW_SESSION_QUERY_PARAM, PREVIEW_VARIANT_QUERY_PARAM, PREVIEW_RELEASE_QUERY_PARAM, PreviewScopeConflictError, createPreviewScope, writePreviewScopeToSearchParams, } from '@storystick/preview/identity';
|
|
11
11
|
const DEFAULTS = {
|
|
12
12
|
redirectParam: 'redirect',
|
|
@@ -19,7 +19,10 @@ export function createStorystickPreviewHandler(options = {}) {
|
|
|
19
19
|
const url = request.nextUrl;
|
|
20
20
|
const sessionId = url.searchParams.get(PREVIEW_SESSION_QUERY_PARAM);
|
|
21
21
|
if (!isSafePreviewSessionId(sessionId)) {
|
|
22
|
-
return withNoReferrer(
|
|
22
|
+
return withNoReferrer(previewInitialRouteErrorResponse(request, {
|
|
23
|
+
status: 400, code: 'PREVIEW_SESSION_MISSING', message: 'preview session selector is required',
|
|
24
|
+
category: 'validation', recoverable: true, retryable: false,
|
|
25
|
+
}));
|
|
23
26
|
}
|
|
24
27
|
let activation;
|
|
25
28
|
try {
|
|
@@ -27,7 +30,10 @@ export function createStorystickPreviewHandler(options = {}) {
|
|
|
27
30
|
}
|
|
28
31
|
catch (error) {
|
|
29
32
|
if (error instanceof PreviewActivationError) {
|
|
30
|
-
return withNoReferrer(
|
|
33
|
+
return withNoReferrer(previewInitialRouteErrorResponse(request, {
|
|
34
|
+
status: 400, code: 'PREVIEW_ACTIVATION_INVALID', message: 'preview activation is missing or malformed',
|
|
35
|
+
category: 'validation', recoverable: true, retryable: false,
|
|
36
|
+
}));
|
|
31
37
|
}
|
|
32
38
|
throw error;
|
|
33
39
|
}
|
|
@@ -38,7 +44,10 @@ export function createStorystickPreviewHandler(options = {}) {
|
|
|
38
44
|
catch (error) {
|
|
39
45
|
if (error instanceof PreviewRedirectError) {
|
|
40
46
|
console.warn('[storystick/preview] unsafe redirect rejected');
|
|
41
|
-
return withNoReferrer(
|
|
47
|
+
return withNoReferrer(previewInitialRouteErrorResponse(request, {
|
|
48
|
+
status: 400, code: 'PREVIEW_REDIRECT_UNSAFE', message: 'unsafe redirect',
|
|
49
|
+
category: 'validation', recoverable: true, retryable: false,
|
|
50
|
+
}));
|
|
42
51
|
}
|
|
43
52
|
throw error;
|
|
44
53
|
}
|
|
@@ -51,7 +60,10 @@ export function createStorystickPreviewHandler(options = {}) {
|
|
|
51
60
|
}
|
|
52
61
|
catch (error) {
|
|
53
62
|
if (error instanceof PreviewScopeConflictError) {
|
|
54
|
-
return withNoReferrer(
|
|
63
|
+
return withNoReferrer(previewInitialRouteErrorResponse(request, {
|
|
64
|
+
status: 400, code: 'PREVIEW_SCOPE_CONFLICT', message: 'preview cannot select a variant and a release together',
|
|
65
|
+
category: 'validation', recoverable: true, retryable: false,
|
|
66
|
+
}));
|
|
55
67
|
}
|
|
56
68
|
throw error;
|
|
57
69
|
}
|
|
@@ -89,7 +101,10 @@ export function createStorystickPreviewHandler(options = {}) {
|
|
|
89
101
|
exchange.previewOrigin !== requestOrigin ||
|
|
90
102
|
exchange.projectId !== (await getPreviewTransport()).projectId ||
|
|
91
103
|
exchange.grantExpiresAt <= Date.now()) {
|
|
92
|
-
return withNoReferrer(
|
|
104
|
+
return withNoReferrer(previewInitialRouteErrorResponse(request, {
|
|
105
|
+
status: 502, code: 'PREVIEW_GRANT_BINDING_MISMATCH', message: 'preview unavailable',
|
|
106
|
+
category: 'auth', recoverable: true, retryable: false,
|
|
107
|
+
}));
|
|
93
108
|
}
|
|
94
109
|
const cookie = buildPreviewGrantCookieFromActivation(exchange, Date.now(), resolveStorystickApplicationBuildId());
|
|
95
110
|
const draft = await draftMode();
|
|
@@ -3,8 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { lookupSdkCopy } from '@storystick/preview/sdk-error-copy';
|
|
6
|
-
import {
|
|
7
|
-
import { StorystickMark } from '@storystick/react/internal/storystick-mark';
|
|
6
|
+
import { PreviewPageState } from '@storystick/react/internal/preview-page-state';
|
|
8
7
|
/** A terminal Preview state owns its viewport, without changing customer DOM.
|
|
9
8
|
* Isolate product styling from the customer's page and its error boundary. */
|
|
10
9
|
export function PreviewErrorSurface({ code, studioUrl }) {
|
|
@@ -16,9 +15,6 @@ export function PreviewErrorSurface({ code, studioUrl }) {
|
|
|
16
15
|
setRoot(host.current.shadowRoot ?? host.current.attachShadow({ mode: 'open' }));
|
|
17
16
|
}, []);
|
|
18
17
|
return _jsx("div", { ref: host, "data-storystick-preview-error": "", "data-storystick-preview-controls": "", style: {
|
|
19
|
-
all: 'initial', position: 'fixed', inset: 0, zIndex: 2147483646, background: '#
|
|
20
|
-
}, children: root ? createPortal(_jsxs("
|
|
21
|
-
boxSizing: 'border-box', minHeight: '100%', display: 'flex', flexDirection: 'column',
|
|
22
|
-
alignItems: 'center', justifyContent: 'center', padding: 24, color: '#18181b',
|
|
23
|
-
}, children: [_jsx(StorystickMark, { style: { width: 18, height: 18, marginBottom: 16, transform: 'rotate(90deg)' } }), _jsx(PreviewPanelMessage, { title: copy.title, description: copy.body, actions: studioUrl ? _jsx("a", { "data-ss-panel-action": "", href: studioUrl, children: "Return to Studio" }) : null, children: code || copy.commonCauses.length ? _jsxs("details", { children: [_jsx("summary", { children: "Technical details" }), code ? _jsx("pre", { children: code }) : 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 });
|
|
18
|
+
all: 'initial', position: 'fixed', inset: 0, zIndex: 2147483646, background: '#fff',
|
|
19
|
+
}, children: root ? createPortal(_jsx(PreviewPageState, { title: copy.title, description: copy.body, role: "alert", actions: studioUrl ? _jsx("a", { "data-ss-preview-page-action": "", href: studioUrl, children: "Return to Studio" }) : null, children: code || copy.commonCauses.length ? _jsxs("details", { children: [_jsx("summary", { children: "Technical details" }), code ? _jsx("pre", { children: code }) : 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 });
|
|
24
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storystick/next",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.1",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"server-only": "^0.0.1",
|
|
91
|
-
"@storystick/
|
|
92
|
-
"@storystick/
|
|
93
|
-
"@storystick/
|
|
94
|
-
"@storystick/
|
|
95
|
-
"@storystick/
|
|
91
|
+
"@storystick/client": "0.2.0-rc.1",
|
|
92
|
+
"@storystick/media": "0.2.0-rc.1",
|
|
93
|
+
"@storystick/react": "0.2.0-rc.1",
|
|
94
|
+
"@storystick/preview": "0.2.0-rc.1",
|
|
95
|
+
"@storystick/types": "0.1.0-rc.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@testing-library/react": "^16.3.2",
|