@reforma/site 0.0.5 → 0.1.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.
@@ -0,0 +1,14 @@
1
+ /** Detail of the `reforma:fix-error` window event the editor bridge forwards to a new chat. */
2
+ export type FixErrorDetail = {
3
+ message: string;
4
+ digest: string | null;
5
+ stack: string | null;
6
+ };
7
+ /**
8
+ * Fallback for `error.tsx` and `global-error.tsx`. Details and Fix with AI show in development only.
9
+ * `data-reforma-error-page` tells the editor to lift its design overlay so the buttons take clicks.
10
+ */
11
+ export declare function ErrorState({ error }: {
12
+ error: unknown;
13
+ }): import("react").JSX.Element;
14
+ //# sourceMappingURL=error-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-state.d.ts","sourceRoot":"","sources":["../src/error-state.tsx"],"names":[],"mappings":"AAIA,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AA+CF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,+BAmCvD"}
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useSyncExternalStore } from 'react';
4
+ const button = {
5
+ height: '32px',
6
+ padding: '0 12px',
7
+ fontSize: '14px',
8
+ fontWeight: 500,
9
+ borderRadius: '6px',
10
+ cursor: 'pointer',
11
+ };
12
+ const styles = {
13
+ main: {
14
+ fontFamily: 'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
15
+ minHeight: '100vh',
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ padding: '64px 24px',
20
+ boxSizing: 'border-box',
21
+ },
22
+ card: { width: '100%', maxWidth: '448px' },
23
+ title: { fontSize: '24px', fontWeight: 500, lineHeight: '32px', margin: '0 0 12px' },
24
+ message: { fontSize: '14px', lineHeight: '21px', margin: '0 0 20px', opacity: 0.7 },
25
+ details: {
26
+ fontFamily: 'ui-monospace, Menlo, monospace',
27
+ fontSize: '12px',
28
+ whiteSpace: 'pre-wrap',
29
+ overflowX: 'auto',
30
+ margin: '0 0 20px',
31
+ padding: '12px',
32
+ borderRadius: '8px',
33
+ background: 'color-mix(in srgb, currentColor 6%, transparent)',
34
+ },
35
+ buttons: { display: 'flex', gap: '8px' },
36
+ button: { ...button, color: 'Canvas', background: 'CanvasText', border: 'none' },
37
+ secondary: {
38
+ ...button,
39
+ color: 'inherit',
40
+ background: 'transparent',
41
+ border: '1px solid color-mix(in srgb, currentColor 20%, transparent)',
42
+ },
43
+ digest: { fontFamily: 'ui-monospace, Menlo, monospace', fontSize: '12px', margin: '20px 0 0', opacity: 0.6 },
44
+ };
45
+ const subscribe = () => () => { };
46
+ /**
47
+ * Fallback for `error.tsx` and `global-error.tsx`. Details and Fix with AI show in development only.
48
+ * `data-reforma-error-page` tells the editor to lift its design overlay so the buttons take clicks.
49
+ */
50
+ export function ErrorState({ error }) {
51
+ const isDev = process.env.NODE_ENV === 'development';
52
+ // Server snapshot is false, so hydration matches and the button appears right after.
53
+ const isEmbedded = useSyncExternalStore(subscribe, () => window !== window.parent, () => false);
54
+ const digest = error instanceof Error && 'digest' in error ? String(error.digest) : null;
55
+ const message = error instanceof Error ? error.message : String(error);
56
+ const fixWithAi = () => {
57
+ const detail = {
58
+ message,
59
+ digest,
60
+ stack: error instanceof Error ? error.stack ?? null : null,
61
+ };
62
+ window.dispatchEvent(new CustomEvent('reforma:fix-error', { detail }));
63
+ };
64
+ return (_jsx("main", { "data-reforma-error-page": "", style: styles.main, children: _jsxs("div", { style: styles.card, children: [_jsx("h1", { style: styles.title, children: "Something went wrong" }), _jsx("p", { style: styles.message, children: "This page didn't load." }), isDev && message ? _jsx("pre", { style: styles.details, children: message }) : null, _jsxs("div", { style: styles.buttons, children: [_jsx("button", { type: "button", style: styles.button, onClick: () => window.location.reload(), children: "Reload" }), isDev && isEmbedded
65
+ ? _jsx("button", { type: "button", style: styles.secondary, onClick: fixWithAi, children: "Fix with AI" })
66
+ : null] }), digest ? _jsxs("p", { style: styles.digest, children: ["Error ID: ", digest] }) : null] }) }));
67
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { initAnalytics, track } from './analytics.js';
2
+ export { ErrorState } from './error-state.js';
2
3
  export { projectMetadata, projectRobots } from './metadata.js';
3
4
  export { SiteRoot, useMode } from './root.js';
5
+ export type { FixErrorDetail } from './error-state.js';
4
6
  export type { Appearance, ModeAppearances, ModeDocument, SystemModes } from './root.js';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { initAnalytics, track } from './analytics.js';
2
+ export { ErrorState } from './error-state.js';
2
3
  export { projectMetadata, projectRobots } from './metadata.js';
3
4
  export { SiteRoot, useMode } from './root.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reforma/site",
3
- "version": "0.0.5",
3
+ "version": "0.1.1",
4
4
  "description": "Visitor runtime for a Reforma site: mode, publish metadata, and the PostCSS url guard.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -44,17 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "react": "^19.2.8",
46
46
  "react-dom": "^19.2.8"
47
- },
48
- "devDependencies": {
49
- "@reforma/config-typescript": "workspace:*",
50
- "@reforma/eslint-config": "workspace:*",
51
- "@types/node": "^24",
52
- "@types/react": "^19",
53
- "@types/react-dom": "^19",
54
- "happy-dom": "20.10.6",
55
- "react": "^19.2.8",
56
- "react-dom": "^19.2.8",
57
- "typescript": "^7",
58
- "vitest": "^5.0.1"
59
47
  }
60
48
  }