@jbpark/live-editor 4.1.0 → 4.2.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.
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/dist/ast-CMD20ykx.js +1613 -0
- package/dist/ast-CMD20ykx.js.map +1 -0
- package/dist/{boundary-C90q3YsT.js → boundary-D2IFja-3.js} +2 -2
- package/dist/boundary-D2IFja-3.js.map +1 -0
- package/dist/cache-B0-XcIxJ.js +51 -0
- package/dist/cache-B0-XcIxJ.js.map +1 -0
- package/dist/{utils-BQ7WL7Jh.js → cn-CAnad2vL.js} +3 -128
- package/dist/cn-CAnad2vL.js.map +1 -0
- package/dist/compile-0Dvp8zp5.js +135 -0
- package/dist/compile-0Dvp8zp5.js.map +1 -0
- package/dist/constants-CKvdqZtO.js +1457 -0
- package/dist/constants-CKvdqZtO.js.map +1 -0
- package/dist/{context-Y-M9fViD.js → context-93X3gyfJ.js} +3 -3
- package/dist/context-93X3gyfJ.js.map +1 -0
- package/dist/{core-Co8Nlq16.js → core-B3ruccKb.js} +3 -2
- package/dist/core-B3ruccKb.js.map +1 -0
- package/dist/detect-typescript-5MV4mCM7.js +10 -0
- package/dist/detect-typescript-5MV4mCM7.js.map +1 -0
- package/dist/dnd/index.d.ts +2 -2
- package/dist/dnd/index.js +2 -2
- package/dist/{dnd-D_rG92-R.js → dnd-DBaH2L8N.js} +548 -137
- package/dist/dnd-DBaH2L8N.js.map +1 -0
- package/dist/{extract-abHYmNsu.js → document-C3eCRQlj.js} +6791 -8938
- package/dist/document-C3eCRQlj.js.map +1 -0
- package/dist/{document-J9Lo9p81.d.ts → document-Ct4jW78J.d.ts} +42 -22
- package/dist/editor/index.js +2 -2
- package/dist/{editor-aNRx7hRY.js → editor-DvMruljw.js} +2 -2
- package/dist/{editor-aNRx7hRY.js.map → editor-DvMruljw.js.map} +1 -1
- package/dist/editor-caches-ClMvdcQF.js +23 -0
- package/dist/editor-caches-ClMvdcQF.js.map +1 -0
- package/dist/error/index.js +2 -2
- package/dist/{error-o0SBwtTv.js → error-KW8XCcjH.js} +2 -2
- package/dist/{error-o0SBwtTv.js.map → error-KW8XCcjH.js.map} +1 -1
- package/dist/{index-Doh4VTXr.d.ts → index-DVgwXnPa.d.ts} +109 -34
- package/dist/{index-B_p74BRM.d.ts → index-w3kLcCXl.d.ts} +29 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/preview/index.js +2 -2
- package/dist/{preview-CS6Rsppd.js → preview-B9Jhv1Up.js} +4 -4
- package/dist/preview-B9Jhv1Up.js.map +1 -0
- package/dist/provider/index.js +1 -1
- package/dist/sections-A4TAXUP8.js +24 -0
- package/dist/sections-A4TAXUP8.js.map +1 -0
- package/dist/{use-dynamic-tailwind-SOgrb2qc.js → use-dynamic-tailwind-BDfytfYC.js} +33 -9
- package/dist/use-dynamic-tailwind-BDfytfYC.js.map +1 -0
- package/dist/utils/ast/index.d.ts +3 -3
- package/dist/utils/ast/index.js +3 -3
- package/dist/utils/index.d.ts +20 -9
- package/dist/utils/index.js +7 -3
- package/package.json +1 -1
- package/dist/ast-CZwpVrJv.js +0 -851
- package/dist/ast-CZwpVrJv.js.map +0 -1
- package/dist/boundary-C90q3YsT.js.map +0 -1
- package/dist/context-Y-M9fViD.js.map +0 -1
- package/dist/core-Co8Nlq16.js.map +0 -1
- package/dist/dnd-D_rG92-R.js.map +0 -1
- package/dist/extract-abHYmNsu.js.map +0 -1
- package/dist/preview-CS6Rsppd.js.map +0 -1
- package/dist/use-dynamic-tailwind-SOgrb2qc.js.map +0 -1
- package/dist/utils-BQ7WL7Jh.js.map +0 -1
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
//#region src/types/index.d.ts
|
|
2
|
-
interface Module {
|
|
3
|
-
exports: {
|
|
4
|
-
default?: React.ComponentType<Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
error?: string;
|
|
7
|
-
}
|
|
8
|
-
interface Section {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
code: string;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
1
|
//#region node_modules/.pnpm/@babel+types@7.29.8/node_modules/@babel/types/lib/index-legacy.d.ts
|
|
15
2
|
// NOTE: This file is autogenerated. Do not modify.
|
|
16
3
|
// See packages/babel-types/scripts/generators/typescript-legacy.ts for script used.
|
|
@@ -1507,27 +1494,60 @@ type TSType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKey
|
|
|
1507
1494
|
type TSBaseType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSTemplateLiteralType | TSLiteralType;
|
|
1508
1495
|
type ModuleDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration;
|
|
1509
1496
|
//#endregion
|
|
1497
|
+
//#region src/types/index.d.ts
|
|
1498
|
+
interface Module {
|
|
1499
|
+
exports: {
|
|
1500
|
+
default?: React.ComponentType<Record<string, unknown>>;
|
|
1501
|
+
};
|
|
1502
|
+
error?: string;
|
|
1503
|
+
}
|
|
1504
|
+
interface Section {
|
|
1505
|
+
id: string;
|
|
1506
|
+
name: string;
|
|
1507
|
+
code: string;
|
|
1508
|
+
}
|
|
1509
|
+
//#endregion
|
|
1510
1510
|
//#region src/utils/ast/document.d.ts
|
|
1511
|
+
interface DocumentOptions {
|
|
1512
|
+
containerId?: string;
|
|
1513
|
+
}
|
|
1514
|
+
interface SectionOptions extends DocumentOptions {
|
|
1515
|
+
sectionNameFallback?: (index: number) => string;
|
|
1516
|
+
}
|
|
1517
|
+
type DocumentProblem = {
|
|
1518
|
+
reason: 'parse-error';
|
|
1519
|
+
error: unknown;
|
|
1520
|
+
} | {
|
|
1521
|
+
reason: 'container-not-found';
|
|
1522
|
+
containerId: string;
|
|
1523
|
+
};
|
|
1524
|
+
type DocumentInspection = {
|
|
1525
|
+
ok: true;
|
|
1526
|
+
doc: DocumentTree;
|
|
1527
|
+
} | ({
|
|
1528
|
+
ok: false;
|
|
1529
|
+
} & DocumentProblem);
|
|
1511
1530
|
interface DocumentTree {
|
|
1512
1531
|
code: string;
|
|
1513
1532
|
ast: File;
|
|
1514
1533
|
container: JSXElement;
|
|
1515
1534
|
}
|
|
1516
|
-
declare const
|
|
1535
|
+
declare const inspectDocument: (code: string, { containerId }?: DocumentOptions) => DocumentInspection;
|
|
1536
|
+
declare const parseDocument: (code: string, options?: DocumentOptions) => DocumentTree | undefined;
|
|
1517
1537
|
declare const clearDocumentParseCache: () => void;
|
|
1518
|
-
declare const getSections: (doc: DocumentTree) => Section[];
|
|
1519
|
-
declare const fillSectionIds: (code: string, generateId?: () => string) => string;
|
|
1538
|
+
declare const getSections: (doc: DocumentTree, { sectionNameFallback }?: SectionOptions) => Section[];
|
|
1539
|
+
declare const fillSectionIds: (code: string, generateId?: () => string, options?: DocumentOptions) => string;
|
|
1520
1540
|
declare const generateDocumentCode: (doc: DocumentTree) => string;
|
|
1521
|
-
declare const replaceDocumentSections: (fullCode: string, sectionCodes: string[]) => string;
|
|
1522
|
-
declare const generateSectionPreview: (fullCode: string, sectionCode: string) => string;
|
|
1523
|
-
declare const generateSectionPreviews: (fullCode: string, sectionCodes: string[]) => string[];
|
|
1541
|
+
declare const replaceDocumentSections: (fullCode: string, sectionCodes: string[], options?: DocumentOptions) => string;
|
|
1542
|
+
declare const generateSectionPreview: (fullCode: string, sectionCode: string, options?: DocumentOptions) => string;
|
|
1543
|
+
declare const generateSectionPreviews: (fullCode: string, sectionCodes: string[], options?: DocumentOptions) => string[];
|
|
1524
1544
|
interface SectionPreviewCache {
|
|
1525
1545
|
compute: (fullCode: string, sections: {
|
|
1526
1546
|
id: string;
|
|
1527
1547
|
code: string;
|
|
1528
|
-
}[]) => string[];
|
|
1548
|
+
}[], options?: DocumentOptions) => string[];
|
|
1529
1549
|
}
|
|
1530
1550
|
declare const createSectionPreviewCache: () => SectionPreviewCache;
|
|
1531
1551
|
//#endregion
|
|
1532
|
-
export { Module as _,
|
|
1533
|
-
//# sourceMappingURL=document-
|
|
1552
|
+
export { ObjectExpression as C, Node as S, Module as _, SectionOptions as a, Expression as b, createSectionPreviewCache as c, generateSectionPreview as d, generateSectionPreviews as f, replaceDocumentSections as g, parseDocument as h, DocumentTree as i, fillSectionIds as l, inspectDocument as m, DocumentOptions as n, SectionPreviewCache as o, getSections as p, DocumentProblem as r, clearDocumentParseCache as s, DocumentInspection as t, generateDocumentCode as u, Section as v, File as x, ArrayExpression as y };
|
|
1553
|
+
//# sourceMappingURL=document-Ct4jW78J.d.ts.map
|
package/dist/editor/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as Core } from "../core-
|
|
2
|
-
import { t as Editor } from "../editor-
|
|
1
|
+
import { t as Core } from "../core-B3ruccKb.js";
|
|
2
|
+
import { t as Editor } from "../editor-DvMruljw.js";
|
|
3
3
|
export { Core, Editor as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
2
|
-
import { n as useFormatCode, t as Core } from "./core-
|
|
2
|
+
import { n as useFormatCode, t as Core } from "./core-B3ruccKb.js";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useDebouncedCallback } from "@jbpark/use-hooks";
|
|
@@ -63,4 +63,4 @@ Editor.Core = Core;
|
|
|
63
63
|
//#endregion
|
|
64
64
|
export { Editor as t };
|
|
65
65
|
|
|
66
|
-
//# sourceMappingURL=editor-
|
|
66
|
+
//# sourceMappingURL=editor-DvMruljw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-
|
|
1
|
+
{"version":3,"file":"editor-DvMruljw.js","names":["Editor","EditorImpl"],"sources":["../src/components/editor/editor.tsx","../src/components/editor/index.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nimport { useDebouncedCallback } from '@jbpark/use-hooks';\n\nimport { useError, usePreview } from '~/components/context/states';\n\nimport Core, { type Props as CoreProps } from './core';\nimport { useFormatCode } from './use-format-code';\n\nexport interface EditorRenderData {\n value: string;\n onChange: (value: string) => void;\n // Same prettier-based formatting Core's own Cmd+S uses - reused rather\n // than reimplemented, so a custom editor can offer equivalent\n // format-on-save behavior without duplicating the prettier wiring.\n formatCode: (code: string) => Promise<string>;\n}\n\nexport interface Props extends Omit<CoreProps, 'value' | 'onSave' | 'onError'> {\n value?: string;\n defaultValue?: string;\n debounce?: number;\n // Full replacement for the built-in CodeMirror editor. Editor still owns\n // syncing `value` to the shared preview code (debounced), regardless of\n // which UI renders it - only the editing surface itself is customizable.\n renderEditor?: (data: EditorRenderData) => React.ReactNode;\n}\n\nconst Editor = ({\n defaultValue,\n value: _value,\n debounce = 1000,\n onChange: _onChange,\n renderEditor,\n fragment,\n prettierOptions,\n ...props\n}: Props) => {\n const { code, setCode } = usePreview();\n const { setError } = useError();\n\n // Controlled, the host owns the document. Uncontrolled, the provider does\n // (#341): `draft` shows each keystroke at once, while the provider only\n // hears about it after `debounce`. Without a draft, the editor had nowhere\n // to keep what was typed, so an uncontrolled editor dropped every edit.\n const controlled = _value !== undefined;\n const [draft, setDraft] = useState(() => defaultValue ?? code);\n\n // The last code this editor pushed, and the provider code it has already\n // seen. A provider change that isn't this editor's own push came from\n // somewhere else sharing the provider — an uncontrolled DnD, say — and the\n // draft follows it. Adjusted during render so no frame shows the old one.\n const [pushed, setPushed] = useState<string | null>(null);\n const [seenCode, setSeenCode] = useState(code);\n\n if (code !== seenCode) {\n setSeenCode(code);\n\n if (!controlled && code !== pushed) {\n setDraft(code);\n }\n }\n\n const value = controlled ? _value : draft;\n\n const pushCode = useCallback(\n (next: string) => {\n setPushed(next);\n setCode(next);\n },\n [setCode],\n );\n\n const onChange = useCallback(\n (next: string) => {\n if (!controlled) {\n setDraft(next);\n }\n\n _onChange?.(next);\n },\n [_onChange, controlled],\n );\n\n // Formatting on save reaches the provider at once, ahead of the debounce.\n const onSave = useCallback(\n (formattedCode: string) => {\n pushCode(formattedCode);\n },\n [pushCode],\n );\n\n const onError = useCallback(\n (error: string | null) => {\n setError(error);\n },\n [setError],\n );\n\n const formatCode = useFormatCode({ fragment, prettierOptions });\n\n // Pushes `value` to the provider `debounce` ms after it stops changing,\n // and at once on mount. A pending push is never dropped: it runs when the\n // editor unmounts, and when focus leaves it — so clicking into another\n // surface right after typing edits a document that includes the typing.\n const push = useDebouncedCallback(\n () => pushCode(value),\n { delay: debounce, flushOnUnmount: true },\n [value],\n );\n\n // `display: contents` so the wrapper adds a blur listener without adding a\n // box: the editor lays out against this element's parent, as before.\n return (\n <div style={{ display: 'contents' }} onBlur={push.flush}>\n {renderEditor ? (\n renderEditor({ value, onChange, formatCode })\n ) : (\n <Core\n value={value}\n onChange={onChange}\n onSave={onSave}\n onError={onError}\n fragment={fragment}\n prettierOptions={prettierOptions}\n {...props}\n />\n )}\n </div>\n );\n};\n\nexport default Editor;\n","import Core, { type Props as CoreProps } from './core';\nimport EditorImpl, { type EditorRenderData, type Props } from './editor';\n\ntype EditorComponent = typeof EditorImpl & { Core: typeof Core };\n\nconst Editor = EditorImpl as EditorComponent;\n\nEditor.Core = Core;\n\nexport { Core };\nexport type { Props, CoreProps, EditorRenderData };\nexport default Editor;\n"],"mappings":";;;;;;AA4BA,MAAMA,YAAU,EACd,cACA,OAAO,QACP,WAAW,KACX,UAAU,WACV,cACA,UACA,iBACA,GAAG,YACQ;CACX,MAAM,EAAE,MAAM,YAAY,WAAW;CACrC,MAAM,EAAE,aAAa,SAAS;CAM9B,MAAM,aAAa,WAAW,KAAA;CAC9B,MAAM,CAAC,OAAO,YAAY,eAAe,gBAAgB,IAAI;CAM7D,MAAM,CAAC,QAAQ,aAAa,SAAwB,IAAI;CACxD,MAAM,CAAC,UAAU,eAAe,SAAS,IAAI;CAE7C,IAAI,SAAS,UAAU;EACrB,YAAY,IAAI;EAEhB,IAAI,CAAC,cAAc,SAAS,QAC1B,SAAS,IAAI;CAEjB;CAEA,MAAM,QAAQ,aAAa,SAAS;CAEpC,MAAM,WAAW,aACd,SAAiB;EAChB,UAAU,IAAI;EACd,QAAQ,IAAI;CACd,GACA,CAAC,OAAO,CACV;CAEA,MAAM,WAAW,aACd,SAAiB;EAChB,IAAI,CAAC,YACH,SAAS,IAAI;EAGf,YAAY,IAAI;CAClB,GACA,CAAC,WAAW,UAAU,CACxB;CAGA,MAAM,SAAS,aACZ,kBAA0B;EACzB,SAAS,aAAa;CACxB,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,UAAU,aACb,UAAyB;EACxB,SAAS,KAAK;CAChB,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,aAAa,cAAc;EAAE;EAAU;CAAgB,CAAC;CAM9D,MAAM,OAAO,2BACL,SAAS,KAAK,GACpB;EAAE,OAAO;EAAU,gBAAgB;CAAK,GACxC,CAAC,KAAK,CACR;CAIA,OACE,oBAAC,OAAD;EAAK,OAAO,EAAE,SAAS,WAAW;EAAG,QAAQ,KAAK;EAC/C,UAAA,eACC,aAAa;GAAE;GAAO;GAAU;EAAW,CAAC,IAE5C,oBAAC,MAAD;GACS;GACG;GACF;GACC;GACC;GACO;GACjB,GAAI;EACL,CAAA;CAEA,CAAA;AAET;;;AC7HA,MAAM,SAASC;AAEf,OAAO,OAAO"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/utils/editor-caches.ts
|
|
2
|
+
const editorCaches = /* @__PURE__ */ new Set();
|
|
3
|
+
const registerEditorCache = (clear) => {
|
|
4
|
+
editorCaches.add(clear);
|
|
5
|
+
};
|
|
6
|
+
const clearEditorCaches = () => {
|
|
7
|
+
editorCaches.forEach((clear) => clear());
|
|
8
|
+
};
|
|
9
|
+
let activeEditorSessions = 0;
|
|
10
|
+
const registerEditorSession = () => {
|
|
11
|
+
activeEditorSessions += 1;
|
|
12
|
+
let released = false;
|
|
13
|
+
return () => {
|
|
14
|
+
if (released) return;
|
|
15
|
+
released = true;
|
|
16
|
+
activeEditorSessions -= 1;
|
|
17
|
+
if (activeEditorSessions === 0) clearEditorCaches();
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { registerEditorCache as n, registerEditorSession as r, clearEditorCaches as t };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=editor-caches-ClMvdcQF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-caches-ClMvdcQF.js","names":[],"sources":["../src/utils/editor-caches.ts"],"sourcesContent":["// Every editor-owned cache that lives for the whole page: the compilation\n// cache, the script blob cache, and the AST parse caches. Each registers its\n// own `clear` here when its module loads, so this module imports none of\n// them. The provider only needs `registerEditorSession`, and importing the\n// caches directly would pull `@babel/standalone` and Babel's AST packages\n// into every bundle that mounts `Live`, whether or not it compiles or edits\n// a document (#407). A cache whose module never loaded is empty anyway.\n//\n// Deliberately not exhaustive of every cache in the library: an instance\n// from `createSectionPreviewCache` is owned by the component that holds it\n// (`useState(() => createSectionPreviewCache())`), so it is already released\n// with that component and there is nothing global to clear.\nconst editorCaches = new Set<() => void>();\n\nexport const registerEditorCache = (clear: () => void) => {\n editorCaches.add(clear);\n};\n\nexport const clearEditorCaches = () => {\n editorCaches.forEach(clear => clear());\n};\n\n// These caches are shared across every editor session in the page, so they\n// can only be released once the *last* one is gone. Clearing on any single\n// unmount would reach into siblings that are still mounted — harmless when\n// the only casualty was a compilation cache (a cache miss costs time, not\n// correctness), but not once revoking blob URLs is part of it: a sibling\n// could be handed a URL that is dead before its iframe loads it.\nlet activeEditorSessions = 0;\n\n// Returns the release function rather than exposing the counter, so a caller\n// cannot release a session it never acquired. Idempotent, so React calling\n// an effect's cleanup twice cannot drive the count negative.\nexport const registerEditorSession = (): (() => void) => {\n activeEditorSessions += 1;\n\n let released = false;\n\n return () => {\n if (released) {\n return;\n }\n\n released = true;\n activeEditorSessions -= 1;\n\n if (activeEditorSessions === 0) {\n clearEditorCaches();\n }\n };\n};\n"],"mappings":";AAYA,MAAM,+BAAe,IAAI,IAAgB;AAEzC,MAAa,uBAAuB,UAAsB;CACxD,aAAa,IAAI,KAAK;AACxB;AAEA,MAAa,0BAA0B;CACrC,aAAa,SAAQ,UAAS,MAAM,CAAC;AACvC;AAQA,IAAI,uBAAuB;AAK3B,MAAa,8BAA4C;CACvD,wBAAwB;CAExB,IAAI,WAAW;CAEf,aAAa;EACX,IAAI,UACF;EAGF,WAAW;EACX,wBAAwB;EAExB,IAAI,yBAAyB,GAC3B,kBAAkB;CAEtB;AACF"}
|
package/dist/error/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as ErrorBoundary } from "../boundary-
|
|
2
|
-
import { n as Runtime, r as Guard, t as Error } from "../error-
|
|
1
|
+
import { t as ErrorBoundary } from "../boundary-D2IFja-3.js";
|
|
2
|
+
import { n as Runtime, r as Guard, t as Error } from "../error-KW8XCcjH.js";
|
|
3
3
|
export { ErrorBoundary, Guard as ErrorGuard, Runtime as ErrorRuntime, Error as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useError } from "./states-Ci1AvoQ9.js";
|
|
2
|
-
import { n as Error$1, t as ErrorBoundary } from "./boundary-
|
|
2
|
+
import { n as Error$1, t as ErrorBoundary } from "./boundary-D2IFja-3.js";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useEventListener } from "@jbpark/use-hooks";
|
|
@@ -79,4 +79,4 @@ Error.Guard = Guard;
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { Runtime as n, Guard as r, Error as t };
|
|
81
81
|
|
|
82
|
-
//# sourceMappingURL=error-
|
|
82
|
+
//# sourceMappingURL=error-KW8XCcjH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-
|
|
1
|
+
{"version":3,"file":"error-KW8XCcjH.js","names":["ErrorComponent","Error","ErrorImpl","ErrorRuntime","ErrorGuard"],"sources":["../src/components/error/guard.tsx","../src/components/error/runtime.tsx","../src/components/error/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { useEventListener } from '@jbpark/use-hooks';\n\nimport ErrorComponent from './error';\n\nexport interface Props {\n children: React.ReactNode;\n onError?: (error: Error) => void;\n}\n\nconst Guard = ({ children, onError }: Props) => {\n const [error, setError] = useState<string | null>(null);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const errorHandled = useRef(false);\n\n useEventListener(\n 'error',\n event => {\n if (errorHandled.current) {\n return;\n }\n\n errorHandled.current = true;\n\n const errorMessage =\n event.error?.message || event.message || 'Unknown error';\n\n console.error('⚡ [Guard] Event handler error:', errorMessage);\n\n event.preventDefault();\n\n setError(errorMessage);\n onError?.(event.error || new window.Error(errorMessage));\n\n setTimeout(() => {\n errorHandled.current = false;\n }, 100);\n },\n { capture: true },\n );\n\n useEffect(() => {\n const container = containerRef.current;\n\n if (!container) {\n return;\n }\n\n const handleUnhandledRejection = (event: PromiseRejectionEvent) => {\n if (errorHandled.current) {\n return;\n }\n\n errorHandled.current = true;\n\n const errorMessage = event.reason?.message || 'Promise rejection';\n\n event.preventDefault();\n setError(errorMessage);\n onError?.(event.reason || new window.Error(errorMessage));\n\n setTimeout(() => {\n errorHandled.current = false;\n }, 100);\n };\n\n window.addEventListener(\n 'unhandledrejection',\n handleUnhandledRejection,\n true,\n );\n\n return () => {\n window.removeEventListener(\n 'unhandledrejection',\n handleUnhandledRejection,\n true,\n );\n };\n }, [onError]);\n\n if (error) {\n return (\n <ErrorComponent\n title=\"Runtime Error\"\n message={error}\n className=\"m-4\"\n onReset={() => {\n setError(null);\n errorHandled.current = false;\n }}\n />\n );\n }\n\n return <div ref={containerRef}>{children}</div>;\n};\n\nexport default Guard;\n","import { useEffect } from 'react';\n\nimport { useEventListener } from '@jbpark/use-hooks';\n\nimport { useError } from '~/components/context/states';\n\nimport Error from './error';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n open?: boolean;\n reset?: () => void;\n}\n\nconst Runtime = ({ open = true, reset }: Props) => {\n const { error: message, setError } = useError();\n\n useEventListener('error', e => {\n setError(e.message);\n e.preventDefault();\n });\n\n useEffect(() => {\n return () => setError(null);\n }, [setError]);\n\n if (!open) {\n return null;\n }\n\n return <Error message={message} onReset={reset} title=\"Runtime Error\" />;\n};\n\nexport default Runtime;\n","import ErrorBoundary from './boundary';\nimport ErrorImpl, { type Props } from './error';\nimport ErrorGuard from './guard';\nimport ErrorRuntime from './runtime';\n\ntype ErrorComponent = typeof ErrorImpl & {\n Boundary: typeof ErrorBoundary;\n Runtime: typeof ErrorRuntime;\n Guard: typeof ErrorGuard;\n};\n\nconst Error = ErrorImpl as ErrorComponent;\n\nError.Boundary = ErrorBoundary;\nError.Runtime = ErrorRuntime;\nError.Guard = ErrorGuard;\n\nexport { ErrorBoundary, ErrorRuntime, ErrorGuard };\nexport type { Props };\nexport default Error;\n"],"mappings":";;;;;;AAWA,MAAM,SAAS,EAAE,UAAU,cAAqB;CAC9C,MAAM,CAAC,OAAO,YAAY,SAAwB,IAAI;CAEtD,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,eAAe,OAAO,KAAK;CAEjC,iBACE,UACA,UAAS;EACP,IAAI,aAAa,SACf;EAGF,aAAa,UAAU;EAEvB,MAAM,eACJ,MAAM,OAAO,WAAW,MAAM,WAAW;EAE3C,QAAQ,MAAM,kCAAkC,YAAY;EAE5D,MAAM,eAAe;EAErB,SAAS,YAAY;EACrB,UAAU,MAAM,SAAS,IAAI,OAAO,MAAM,YAAY,CAAC;EAEvD,iBAAiB;GACf,aAAa,UAAU;EACzB,GAAG,GAAG;CACR,GACA,EAAE,SAAS,KAAK,CAClB;CAEA,gBAAgB;EAGd,IAAI,CAFc,aAAa,SAG7B;EAGF,MAAM,4BAA4B,UAAiC;GACjE,IAAI,aAAa,SACf;GAGF,aAAa,UAAU;GAEvB,MAAM,eAAe,MAAM,QAAQ,WAAW;GAE9C,MAAM,eAAe;GACrB,SAAS,YAAY;GACrB,UAAU,MAAM,UAAU,IAAI,OAAO,MAAM,YAAY,CAAC;GAExD,iBAAiB;IACf,aAAa,UAAU;GACzB,GAAG,GAAG;EACR;EAEA,OAAO,iBACL,sBACA,0BACA,IACF;EAEA,aAAa;GACX,OAAO,oBACL,sBACA,0BACA,IACF;EACF;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,IAAI,OACF,OACE,oBAACA,SAAD;EACE,OAAM;EACN,SAAS;EACT,WAAU;EACV,eAAe;GACb,SAAS,IAAI;GACb,aAAa,UAAU;EACzB;CACD,CAAA;CAIL,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAe;CAAc,CAAA;AAChD;;;ACrFA,MAAM,WAAW,EAAE,OAAO,MAAM,YAAmB;CACjD,MAAM,EAAE,OAAO,SAAS,aAAa,SAAS;CAE9C,iBAAiB,UAAS,MAAK;EAC7B,SAAS,EAAE,OAAO;EAClB,EAAE,eAAe;CACnB,CAAC;CAED,gBAAgB;EACd,aAAa,SAAS,IAAI;CAC5B,GAAG,CAAC,QAAQ,CAAC;CAEb,IAAI,CAAC,MACH,OAAO;CAGT,OAAO,oBAACC,SAAD;EAAgB;EAAS,SAAS;EAAO,OAAM;CAAiB,CAAA;AACzE;;;ACnBA,MAAM,QAAQC;AAEd,MAAM,WAAW;AACjB,MAAM,UAAUC;AAChB,MAAM,QAAQC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as BindingWidget, Q as BindingType, Y as BindingOption, Z as BindingRenderMap, et as DataAttrNode, f as UpdateFailure } from "./index-w3kLcCXl.js";
|
|
2
|
+
import { v as Section } from "./document-Ct4jW78J.js";
|
|
2
3
|
import { t as FrameProps } from "./index-DpDU1IAw.js";
|
|
3
|
-
import { J as BindingRenderMap, K as BindingOption, X as BindingWidget, Y as BindingType, Z as DataAttrNode, u as UpdateFailure } from "./index-B_p74BRM.js";
|
|
4
4
|
import { useMultiSelect } from "@jbpark/use-hooks";
|
|
5
5
|
//#region src/components/dnd/panel/field.d.ts
|
|
6
6
|
interface FieldProps {
|
|
@@ -24,6 +24,20 @@ type DndEditError = {
|
|
|
24
24
|
error?: unknown;
|
|
25
25
|
title: string;
|
|
26
26
|
description?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'parse';
|
|
29
|
+
target: 'document';
|
|
30
|
+
reason: 'parse-error';
|
|
31
|
+
error: unknown;
|
|
32
|
+
title: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'parse';
|
|
36
|
+
target: 'document';
|
|
37
|
+
reason: 'container-not-found';
|
|
38
|
+
containerId: string;
|
|
39
|
+
title: string;
|
|
40
|
+
description?: string;
|
|
27
41
|
} | {
|
|
28
42
|
type: 'items';
|
|
29
43
|
title: string;
|
|
@@ -40,6 +54,9 @@ interface PanelNodeChange {
|
|
|
40
54
|
value: unknown;
|
|
41
55
|
}): void;
|
|
42
56
|
}
|
|
57
|
+
interface PanelNodesChange {
|
|
58
|
+
(changes: Parameters<PanelNodeChange>[0][]): void;
|
|
59
|
+
}
|
|
43
60
|
interface PanelBinding {
|
|
44
61
|
id: string;
|
|
45
62
|
label: string;
|
|
@@ -56,8 +73,17 @@ interface PanelBinding {
|
|
|
56
73
|
value: unknown;
|
|
57
74
|
rawValue: string;
|
|
58
75
|
canEditValue?: boolean;
|
|
76
|
+
present?: boolean;
|
|
59
77
|
onChange: (value: unknown) => void;
|
|
60
78
|
}
|
|
79
|
+
type PanelBindingData = Omit<PanelBinding, 'onChange'>;
|
|
80
|
+
interface PanelBindingSource {
|
|
81
|
+
id: string;
|
|
82
|
+
tagName: string;
|
|
83
|
+
bindings: PanelBindingData[];
|
|
84
|
+
}
|
|
85
|
+
declare const resolvePanelBindings: (node: DataAttrNode) => PanelBindingSource | null;
|
|
86
|
+
declare const withPanelCommit: (bindings: PanelBindingData[], commit: PanelNodeChange | undefined) => PanelBinding[];
|
|
61
87
|
//#endregion
|
|
62
88
|
//#region src/components/dnd/section-fallback-context.d.ts
|
|
63
89
|
interface DndSectionFallbackArgs {
|
|
@@ -82,6 +108,8 @@ interface DndPanel {
|
|
|
82
108
|
canMoveDown: boolean;
|
|
83
109
|
bindings: PanelBinding[];
|
|
84
110
|
onNodeChange: PanelNodeChange;
|
|
111
|
+
onNodesChange: PanelNodesChange;
|
|
112
|
+
readOnly: boolean;
|
|
85
113
|
}
|
|
86
114
|
interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
|
|
87
115
|
value?: string;
|
|
@@ -96,9 +124,12 @@ interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
|
|
|
96
124
|
onEditError?: (error: DndEditError) => void;
|
|
97
125
|
renderSectionFallback?: DndRenderSectionFallback;
|
|
98
126
|
shouldForceSectionFallback?: (section: Section) => boolean;
|
|
127
|
+
onBeforeDelete?: (section: Section) => boolean | Promise<boolean>;
|
|
128
|
+
sectionNameFallback?: (index: number) => string;
|
|
129
|
+
containerId?: string;
|
|
99
130
|
children?: React.ReactNode;
|
|
100
131
|
}
|
|
101
|
-
declare const Dnd$1: ({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, children, ...restProps }: Props) => import("react").JSX.Element;
|
|
132
|
+
declare const Dnd$1: ({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, children, ...restProps }: Props) => import("react").JSX.Element;
|
|
102
133
|
//#endregion
|
|
103
134
|
//#region src/components/dnd/draggable.d.ts
|
|
104
135
|
interface DraggableItemDragState {
|
|
@@ -130,31 +161,56 @@ interface DndLayout {
|
|
|
130
161
|
clearSelection: () => void;
|
|
131
162
|
paletteOpen: boolean;
|
|
132
163
|
setPaletteOpen: (open: boolean) => void;
|
|
164
|
+
documentError: 'parse-error' | 'container-not-found' | null;
|
|
133
165
|
}
|
|
134
166
|
declare const useDndPalette: () => DndPalette;
|
|
135
167
|
declare const useDndPanel: () => DndPanel;
|
|
136
168
|
declare const useDndLayout: () => DndLayout;
|
|
137
169
|
//#endregion
|
|
138
|
-
//#region src/components/dnd/panel/use-
|
|
139
|
-
interface
|
|
170
|
+
//#region src/components/dnd/panel/use-dnd-children.d.ts
|
|
171
|
+
interface DndChildrenOptions {
|
|
172
|
+
onChange?: (value: string) => void;
|
|
173
|
+
}
|
|
174
|
+
declare const useDndChildren: (items: DataAttrNode[], { onChange }?: DndChildrenOptions) => {
|
|
175
|
+
items: DataAttrNode[];
|
|
176
|
+
selection: {
|
|
177
|
+
readonly selected: Set<number>;
|
|
178
|
+
readonly isSelected: (index: number) => boolean;
|
|
179
|
+
readonly toggle: (index: number, shiftKey?: boolean) => void;
|
|
180
|
+
readonly clear: () => void;
|
|
181
|
+
readonly replace: (indices: Set<number>) => void;
|
|
182
|
+
};
|
|
183
|
+
actions: {
|
|
184
|
+
move: (from: number, to: number) => void;
|
|
185
|
+
remove: (index: number) => void;
|
|
186
|
+
add: () => void;
|
|
187
|
+
duplicateSelected: () => void;
|
|
188
|
+
moveSelected: (direction: "up" | "down") => void;
|
|
189
|
+
removeSelected: () => void;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
type DndChildren = ReturnType<typeof useDndChildren>;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/components/dnd/panel/use-dnd-items.d.ts
|
|
195
|
+
interface DndItemsNestedElement {
|
|
140
196
|
id: string;
|
|
141
197
|
tagName: string;
|
|
142
198
|
bindings: PanelBinding[];
|
|
143
199
|
}
|
|
144
|
-
interface
|
|
200
|
+
interface DndItemsNestedGroup {
|
|
145
201
|
property: string;
|
|
146
|
-
elements:
|
|
202
|
+
elements: DndItemsNestedElement[];
|
|
147
203
|
fallback?: PanelBinding;
|
|
148
204
|
}
|
|
149
|
-
interface
|
|
205
|
+
interface DndItemsItem {
|
|
150
206
|
id: string;
|
|
151
207
|
index: number;
|
|
152
208
|
elementIndex: number;
|
|
153
209
|
properties: PanelBinding[];
|
|
154
|
-
nested:
|
|
210
|
+
nested: DndItemsNestedGroup[];
|
|
155
211
|
value?: PanelBinding;
|
|
156
212
|
}
|
|
157
|
-
interface
|
|
213
|
+
interface DndItemsActions {
|
|
158
214
|
add: () => void;
|
|
159
215
|
move: (elementIndex: number, toIndex: number) => void;
|
|
160
216
|
remove: (elementIndex: number) => void;
|
|
@@ -162,26 +218,41 @@ interface ItemsEditorActions {
|
|
|
162
218
|
moveSelected: (direction: 'up' | 'down') => void;
|
|
163
219
|
removeSelected: () => void;
|
|
164
220
|
}
|
|
165
|
-
interface
|
|
221
|
+
interface DndItems {
|
|
166
222
|
kind: 'object' | 'primitive';
|
|
167
|
-
items:
|
|
223
|
+
items: DndItemsItem[];
|
|
168
224
|
selection: ReturnType<typeof useMultiSelect>;
|
|
169
|
-
actions:
|
|
225
|
+
actions: DndItemsActions;
|
|
170
226
|
canEditStructure: boolean;
|
|
171
227
|
parseError: boolean;
|
|
172
228
|
}
|
|
173
|
-
interface
|
|
229
|
+
interface DndItemsOptions {
|
|
174
230
|
render?: BindingRenderMap;
|
|
175
231
|
onChange?: (value: string) => void;
|
|
176
232
|
onNodeChange?: PanelNodeChange;
|
|
177
233
|
}
|
|
178
|
-
declare const
|
|
234
|
+
declare const useDndItems: (value: string, { render, onChange, onNodeChange }?: DndItemsOptions) => DndItems;
|
|
179
235
|
//#endregion
|
|
180
|
-
//#region src/components/dnd/panel/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
declare const
|
|
236
|
+
//#region src/components/dnd/panel/field-kind.d.ts
|
|
237
|
+
type FieldKind = 'readonly' | 'items' | 'children' | 'richtext' | 'jsx' | 'html' | 'object' | 'boolean' | 'select' | 'color' | 'date' | 'url' | 'number' | 'text';
|
|
238
|
+
type FieldKindBinding = Pick<PanelBinding, 'property' | 'type' | 'value' | 'options' | 'canEditValue'>;
|
|
239
|
+
declare const getFieldKind: (binding: FieldKindBinding) => FieldKind;
|
|
240
|
+
declare const isStructuralFieldKind: (kind: FieldKind) => kind is "items" | "children";
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/components/dnd/index.d.ts
|
|
243
|
+
type DndComponent = typeof Dnd$1 & {
|
|
244
|
+
DraggableItem: typeof DraggableItem;
|
|
245
|
+
Field: typeof Field;
|
|
246
|
+
Palette: typeof Palette;
|
|
247
|
+
Canvas: typeof Canvas;
|
|
248
|
+
Panel: typeof Panel;
|
|
249
|
+
Layout: typeof Layout;
|
|
250
|
+
};
|
|
251
|
+
declare const Dnd: DndComponent;
|
|
252
|
+
/** @deprecated Renamed to `useDndItems`. */
|
|
253
|
+
declare const useItemsEditor: (value: string, { render, onChange, onNodeChange }?: DndItemsOptions) => DndItems;
|
|
254
|
+
/** @deprecated Renamed to `useDndChildren`. */
|
|
255
|
+
declare const useChildrenEditor: (items: DataAttrNode[], { onChange }?: DndChildrenOptions) => {
|
|
185
256
|
items: DataAttrNode[];
|
|
186
257
|
selection: {
|
|
187
258
|
readonly selected: Set<number>;
|
|
@@ -199,18 +270,22 @@ declare const useChildrenEditor: (items: DataAttrNode[], { onChange }?: Children
|
|
|
199
270
|
removeSelected: () => void;
|
|
200
271
|
};
|
|
201
272
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
type
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
273
|
+
/** @deprecated Renamed to `DndItems`. */
|
|
274
|
+
type ItemsEditor = DndItems;
|
|
275
|
+
/** @deprecated Renamed to `DndItemsActions`. */
|
|
276
|
+
type ItemsEditorActions = DndItemsActions;
|
|
277
|
+
/** @deprecated Renamed to `DndItemsItem`. */
|
|
278
|
+
type ItemsEditorItem = DndItemsItem;
|
|
279
|
+
/** @deprecated Renamed to `DndItemsNestedElement`. */
|
|
280
|
+
type ItemsEditorNestedElement = DndItemsNestedElement;
|
|
281
|
+
/** @deprecated Renamed to `DndItemsNestedGroup`. */
|
|
282
|
+
type ItemsEditorNestedGroup = DndItemsNestedGroup;
|
|
283
|
+
/** @deprecated Renamed to `DndItemsOptions`. */
|
|
284
|
+
type ItemsEditorOptions = DndItemsOptions;
|
|
285
|
+
/** @deprecated Renamed to `DndChildren`. */
|
|
286
|
+
type ChildrenEditor = DndChildren;
|
|
287
|
+
/** @deprecated Renamed to `DndChildrenOptions`. */
|
|
288
|
+
type ChildrenEditorOptions = DndChildrenOptions;
|
|
214
289
|
//#endregion
|
|
215
|
-
export {
|
|
216
|
-
//# sourceMappingURL=index-
|
|
290
|
+
export { Field as $, Canvas as A, DndPanel as B, DndChildren as C, useDndLayout as D, DndLayout as E, Panel as F, PanelBindingData as G, DndRenderSectionFallback as H, DraggableItem as I, PanelNodesChange as J, PanelBindingSource as K, DraggableItemDragState as L, DndRegionProps as M, Layout as N, useDndPalette as O, Palette as P, DndRenderField as Q, DraggableItemProps as R, useDndItems as S, useDndChildren as T, DndSectionFallbackArgs as U, Props as V, PanelBinding as W, withPanelCommit as X, resolvePanelBindings as Y, DndEditError as Z, DndItemsActions as _, ItemsEditorActions as a, DndItemsNestedGroup as b, ItemsEditorNestedGroup as c, useItemsEditor as d, FieldProps as et, FieldKind as f, DndItems as g, isStructuralFieldKind as h, ItemsEditor as i, DndLayoutProps as j, useDndPanel as k, ItemsEditorOptions as l, getFieldKind as m, ChildrenEditorOptions as n, ItemsEditorItem as o, FieldKindBinding as p, PanelNodeChange as q, Dnd as r, ItemsEditorNestedElement as s, ChildrenEditor as t, useChildrenEditor as u, DndItemsItem as v, DndChildrenOptions as w, DndItemsOptions as x, DndItemsNestedElement as y, DndPalette as z };
|
|
291
|
+
//# sourceMappingURL=index-DVgwXnPa.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ObjectExpression, S as Node, b as Expression, x as File, y as ArrayExpression } from "./document-Ct4jW78J.js";
|
|
2
2
|
//#region src/utils/ast/types.d.ts
|
|
3
3
|
interface Attribute {
|
|
4
4
|
name: string;
|
|
@@ -127,6 +127,14 @@ type UpdateFailure = {
|
|
|
127
127
|
} | {
|
|
128
128
|
reason: 'no-binding';
|
|
129
129
|
dataId: string;
|
|
130
|
+
} | {
|
|
131
|
+
reason: 'reserved-property';
|
|
132
|
+
dataId: string;
|
|
133
|
+
property: string;
|
|
134
|
+
} | {
|
|
135
|
+
reason: 'required-property';
|
|
136
|
+
dataId: string;
|
|
137
|
+
property: string;
|
|
130
138
|
} | {
|
|
131
139
|
reason: 'binding-not-declared';
|
|
132
140
|
dataId: string;
|
|
@@ -157,12 +165,28 @@ interface UpdateResult {
|
|
|
157
165
|
failures?: UpdateFailure[];
|
|
158
166
|
}
|
|
159
167
|
declare const update: (code: string, dataId: string, label: string, value: unknown, property?: string) => UpdateResult;
|
|
160
|
-
|
|
168
|
+
interface UpdateEntry {
|
|
161
169
|
dataId: string;
|
|
162
170
|
label: string;
|
|
163
171
|
value: unknown;
|
|
164
172
|
property?: string;
|
|
165
|
-
}
|
|
173
|
+
}
|
|
174
|
+
type UpdateAllResult = {
|
|
175
|
+
success: true;
|
|
176
|
+
code: string;
|
|
177
|
+
} | {
|
|
178
|
+
success: false;
|
|
179
|
+
code: string;
|
|
180
|
+
failure: UpdateFailure;
|
|
181
|
+
index: number;
|
|
182
|
+
};
|
|
183
|
+
declare const updateAll: (raw: string, entries: UpdateEntry[]) => UpdateAllResult;
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated Not atomic: when an entry fails, the ones before and after it
|
|
186
|
+
* are still applied, and the returned `code` carries them. Use `updateAll`,
|
|
187
|
+
* which applies every entry or none. Will be removed in the next major.
|
|
188
|
+
*/
|
|
189
|
+
declare const bulkUpdate: (raw: string, entries: UpdateEntry[]) => UpdateResult;
|
|
166
190
|
//#endregion
|
|
167
191
|
//#region src/utils/ast/children.d.ts
|
|
168
192
|
type ChildrenAction = {
|
|
@@ -227,5 +251,5 @@ interface ValidationResult {
|
|
|
227
251
|
}
|
|
228
252
|
declare const validateBindingValue: (binding: BindingItem, value: unknown) => ValidationResult;
|
|
229
253
|
//#endregion
|
|
230
|
-
export {
|
|
231
|
-
//# sourceMappingURL=index-
|
|
254
|
+
export { BindingWidget as $, EditablePathSegment as A, parseValue as B, moveArrayItem as C, updateArrayItemProperty as D, removeArrayItems as E, createNodeFromValue as F, parseBinding as G, findEditableChildren as H, extractNodeValue as I, BindingItem as J, parseBindingExpression as K, extractObjectProperties as L, EditableValueEntry as M, arrayExpressionToCode as N, updateArrayItemValue as O, canLosslesslyEvaluateSource as P, BindingType as Q, flattenEditableValue as R, duplicateArrayItems as S, parseItems as T, getCurrentValue as U, setEditableValue as V, getStructuredValue as W, BindingRenderLeaf as X, BindingOption as Y, BindingRenderMap as Z, clearExtractCache as _, replaceIds as a, ItemKind as b, ChildrenEdit as c, UpdateEntry as d, DataAttrNode as et, UpdateFailure as f, updateAll as g, update as h, fillIds as i, EditablePrimitive as j, generateCode as k, getChildrenSignatures as l, bulkUpdate as m, validateBindingValue as n, ExtractedNodeValue as nt, canStructurallyEditArray as o, UpdateResult as p, BindingFieldSpec as q, clone as r, NodeValueType as rt, ChildrenAction as s, ValidationResult as t, EditableNodeValueType as tt, UpdateAllResult as u, extract as v, moveArrayItems as w, appendArrayItem as x, ArrayItem as y, parseArrayExpression as z };
|
|
255
|
+
//# sourceMappingURL=index-w3kLcCXl.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { v as Section } from "./document-
|
|
1
|
+
import { v as Section } from "./document-Ct4jW78J.js";
|
|
2
2
|
import { t as FrameProps } from "./index-DpDU1IAw.js";
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as Canvas, B as DndPanel, E as DndLayout, F as Panel, H as DndRenderSectionFallback, J as PanelNodesChange, N as Layout, P as Palette, Q as DndRenderField, R as DraggableItemProps, U as DndSectionFallbackArgs, V as Props, W as PanelBinding, Z as DndEditError, et as FieldProps, g as DndItems, i as ItemsEditor, l as ItemsEditorOptions, o as ItemsEditorItem, q as PanelNodeChange, r as Dnd, v as DndItemsItem, x as DndItemsOptions, z as DndPalette } from "./index-DVgwXnPa.js";
|
|
4
4
|
import { a as Props$2, n as EditorRenderData, r as Props$1, t as Editor } from "./index-13BDSrQc.js";
|
|
5
5
|
import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-DNNj_0ba.js";
|
|
6
6
|
import { n as Preview, r as Props$6 } from "./index-DQkL37eL.js";
|
|
@@ -19,7 +19,7 @@ declare const App: {
|
|
|
19
19
|
Editor: (({ defaultValue, value: _value, debounce, onChange: _onChange, renderEditor, fragment, prettierOptions, ...props }: Props$1) => import("react").JSX.Element) & {
|
|
20
20
|
Core: ({ value, theme, height, className, prettierOptions, fragment, raw, onChange, onSave, onError, ...props }: Props$2) => import("react").JSX.Element;
|
|
21
21
|
};
|
|
22
|
-
Dnd: (({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, children, ...restProps }: Props) => import("react").JSX.Element) & {
|
|
22
|
+
Dnd: (({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, children, ...restProps }: Props) => import("react").JSX.Element) & {
|
|
23
23
|
DraggableItem: ({ item, children }: DraggableItemProps) => import("react").ReactNode;
|
|
24
24
|
Field: (props: FieldProps) => import("react").JSX.Element;
|
|
25
25
|
Palette: typeof Palette;
|
|
@@ -30,5 +30,5 @@ declare const App: {
|
|
|
30
30
|
};
|
|
31
31
|
declare const LiveRenderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$6) => import("react").JSX.Element;
|
|
32
32
|
//#endregion
|
|
33
|
-
export { type DndEditError, type DndLayout, type DndPalette, type DndPanel, type DndRenderField, type DndRenderSectionFallback, type DndSectionFallbackArgs, type EditorRenderData, type FieldProps, type FrameProps, type ItemsEditor, type ItemsEditorItem, type ItemsEditorOptions, Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, type PanelBinding, type PanelNodeChange, type Section };
|
|
33
|
+
export { type DndEditError, type DndItems, type DndItemsItem, type DndItemsOptions, type DndLayout, type DndPalette, type DndPanel, type DndRenderField, type DndRenderSectionFallback, type DndSectionFallbackArgs, type EditorRenderData, type FieldProps, type FrameProps, type ItemsEditor, type ItemsEditorItem, type ItemsEditorOptions, Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, type PanelBinding, type PanelNodeChange, type PanelNodesChange, type Section };
|
|
34
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as ContextProvider } from "./context-
|
|
2
|
-
import { t as Dnd } from "./dnd-
|
|
3
|
-
import { t as Editor } from "./editor-
|
|
4
|
-
import { t as Error } from "./error-
|
|
5
|
-
import { t as Preview } from "./preview-
|
|
1
|
+
import { t as ContextProvider } from "./context-93X3gyfJ.js";
|
|
2
|
+
import { t as Dnd } from "./dnd-DBaH2L8N.js";
|
|
3
|
+
import { t as Editor } from "./editor-DvMruljw.js";
|
|
4
|
+
import { t as Error } from "./error-KW8XCcjH.js";
|
|
5
|
+
import { t as Preview } from "./preview-B9Jhv1Up.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/index.tsx
|
|
8
8
|
const App = ({ children }) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Context","LivePreview","LiveError","LiveEditor","LiveDnd"],"sources":["../src/index.tsx"],"sourcesContent":["import './index.css';\n\nimport Context from './components/context';\nimport LiveDnd, {\n type DndEditError,\n type DndLayout,\n type DndPalette,\n type DndPanel,\n type DndRenderField,\n type DndRenderSectionFallback,\n type DndSectionFallbackArgs,\n type FieldProps,\n type ItemsEditor,\n type ItemsEditorItem,\n type ItemsEditorOptions,\n type PanelBinding,\n type PanelNodeChange,\n} from './components/dnd';\nimport LiveEditor, { type EditorRenderData } from './components/editor';\nimport LiveError from './components/error';\nimport { type FrameProps } from './components/frame';\nimport LivePreview from './components/preview';\nimport type { Section } from './types';\n\nconst App = ({ children }: { children?: React.ReactNode }) => {\n return <Context>{children}</Context>;\n};\n\nconst LiveRenderer = LivePreview;\n\nexport {\n LivePreview,\n LiveError,\n LiveEditor,\n LiveDnd,\n LiveRenderer,\n App as LiveProvider,\n //\n};\n\nexport type {\n DndEditError,\n DndRenderField,\n DndRenderSectionFallback,\n DndSectionFallbackArgs,\n DndPalette,\n DndPanel,\n DndLayout,\n PanelBinding,\n PanelNodeChange,\n FieldProps,\n ItemsEditor,\n ItemsEditorItem,\n ItemsEditorOptions,\n EditorRenderData,\n FrameProps,\n Section,\n};\n\nApp.Preview = LivePreview;\nApp.Renderer = LiveRenderer;\nApp.Error = LiveError;\nApp.Editor = LiveEditor;\nApp.Dnd = LiveDnd;\n\nexport default App;\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["Context","LivePreview","LiveError","LiveEditor","LiveDnd"],"sources":["../src/index.tsx"],"sourcesContent":["import './index.css';\n\nimport Context from './components/context';\nimport LiveDnd, {\n type DndEditError,\n type DndItems,\n type DndItemsItem,\n type DndItemsOptions,\n type DndLayout,\n type DndPalette,\n type DndPanel,\n type DndRenderField,\n type DndRenderSectionFallback,\n type DndSectionFallbackArgs,\n type FieldProps,\n type ItemsEditor,\n type ItemsEditorItem,\n type ItemsEditorOptions,\n type PanelBinding,\n type PanelNodeChange,\n type PanelNodesChange,\n} from './components/dnd';\nimport LiveEditor, { type EditorRenderData } from './components/editor';\nimport LiveError from './components/error';\nimport { type FrameProps } from './components/frame';\nimport LivePreview from './components/preview';\nimport type { Section } from './types';\n\nconst App = ({ children }: { children?: React.ReactNode }) => {\n return <Context>{children}</Context>;\n};\n\nconst LiveRenderer = LivePreview;\n\nexport {\n LivePreview,\n LiveError,\n LiveEditor,\n LiveDnd,\n LiveRenderer,\n App as LiveProvider,\n //\n};\n\nexport type {\n DndEditError,\n DndRenderField,\n DndRenderSectionFallback,\n DndSectionFallbackArgs,\n DndPalette,\n DndPanel,\n DndLayout,\n PanelBinding,\n PanelNodeChange,\n PanelNodesChange,\n FieldProps,\n DndItems,\n DndItemsItem,\n DndItemsOptions,\n // Deprecated aliases of the three above, kept until the next major.\n ItemsEditor,\n ItemsEditorItem,\n ItemsEditorOptions,\n EditorRenderData,\n FrameProps,\n Section,\n};\n\nApp.Preview = LivePreview;\nApp.Renderer = LiveRenderer;\nApp.Error = LiveError;\nApp.Editor = LiveEditor;\nApp.Dnd = LiveDnd;\n\nexport default App;\n"],"mappings":";;;;;;;AA4BA,MAAM,OAAO,EAAE,eAA+C;CAC5D,OAAO,oBAACA,iBAAD,EAAU,SAAkB,CAAA;AACrC;AAEA,MAAM,eAAeC;AAoCrB,IAAI,UAAUA;AACd,IAAI,WAAW;AACf,IAAI,QAAQC;AACZ,IAAI,SAASC;AACb,IAAI,MAAMC"}
|
package/dist/preview/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as baseModules } from "../use-dynamic-tailwind-
|
|
2
|
-
import { t as Preview } from "../preview-
|
|
1
|
+
import { r as baseModules } from "../use-dynamic-tailwind-BDfytfYC.js";
|
|
2
|
+
import { t as Preview } from "../preview-B9Jhv1Up.js";
|
|
3
3
|
export { baseModules, Preview as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as cn } from "./utils-BQ7WL7Jh.js";
|
|
2
1
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
2
|
+
import { t as cn } from "./cn-CAnad2vL.js";
|
|
3
|
+
import { a as Frame, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-BDfytfYC.js";
|
|
4
|
+
import { t as Error } from "./error-KW8XCcjH.js";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/preview/defaults.ts
|
|
@@ -83,4 +83,4 @@ const Preview = ({ code, props = NO_PROPS, modules = NO_MODULES, dynamicTailwind
|
|
|
83
83
|
//#endregion
|
|
84
84
|
export { Preview as t };
|
|
85
85
|
|
|
86
|
-
//# sourceMappingURL=preview-
|
|
86
|
+
//# sourceMappingURL=preview-B9Jhv1Up.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-B9Jhv1Up.js","names":["LiveError"],"sources":["../src/components/preview/defaults.ts","../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["// Stable defaults for optional object props. A `= {}` default is a new\n// object on every render, which re-runs every memo keyed on it — the merged\n// module map, and so `compile()` — even when the caller passed nothing (#348).\nexport const NO_PROPS: Record<string, unknown> = {};\nexport const NO_MODULES: Record<string, unknown> = {};\n","'use client';\n\nimport { useMemo } from 'react';\n\nimport { useError, usePreview } from '~/components/context/states';\nimport LiveError from '~/components/error';\nimport Frame, { type FrameProps } from '~/components/frame';\nimport { cn } from '~/utils/cn';\n\nimport { NO_MODULES, NO_PROPS } from './defaults';\nimport { type Props } from './preview';\nimport { useCompiledModule } from './use-compiled-module';\nimport { useDynamicTailwind } from './use-dynamic-tailwind';\n\nconst Client = ({\n code: _code,\n className,\n showError,\n props = NO_PROPS,\n modules = NO_MODULES,\n frame,\n dynamicTailwind = false,\n provider,\n}: Props) => {\n const { code } = usePreview();\n const { error, setError } = useError();\n const isError = !!showError && !!error;\n\n const classNames = cn(isError && 'hidden', className);\n\n const effectiveCode = _code === undefined ? code : _code;\n\n const module = useCompiledModule(effectiveCode, modules);\n\n // Attached to the wrapper below; scans the rendered DOM so classes coming\n // from an imported component are picked up too. See the hook for details.\n const { ref: contentRef, css: dynamicCSS } = useDynamicTailwind(\n effectiveCode,\n dynamicTailwind,\n );\n\n const componentProps = useMemo(\n () => ({\n ...props,\n }),\n [props],\n );\n\n const renderProvider = (component: React.ReactNode) => {\n return provider ? provider(component) : component;\n };\n\n if (module && module.error) {\n return (\n <>\n <div className={cn('relative h-full w-full', classNames)}>\n <LiveError message={module.error} title=\"Compile Error\" />\n </div>\n <LiveError.Runtime open={isError} />\n </>\n );\n }\n\n const Component = module?.exports?.default;\n\n if (!Component) {\n return null;\n }\n\n return (\n <>\n {frame ? (\n <div className={cn('h-full w-full', classNames)}>\n <Frame {...(frame as FrameProps)}>\n {container => (\n <div ref={contentRef} style={{ display: 'contents' }}>\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={(e: Error) => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} container={container} />\n {dynamicTailwind && dynamicCSS && (\n <style>{dynamicCSS}</style>\n )}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n </Frame>\n </div>\n ) : (\n <div\n ref={contentRef}\n className={cn(\n 'relative h-full w-full overflow-x-hidden overflow-y-auto',\n classNames,\n )}\n style={{\n isolation: 'isolate',\n transform: 'translateZ(0)',\n containerType: 'inline-size',\n }}\n >\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={e => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} />\n {dynamicTailwind && dynamicCSS && <style>{dynamicCSS}</style>}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n <LiveError.Runtime open={isError} />\n </>\n );\n};\n\nexport default Client;\n","import type React from 'react';\n\nimport type { FrameProps } from '../frame';\nimport Client from './client';\nimport { NO_MODULES, NO_PROPS } from './defaults';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n code?: string;\n showError?: boolean;\n props?: Record<string, unknown>;\n container?: HTMLElement | null;\n frame?: boolean | FrameProps;\n modules?: Record<string, unknown>;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n}\n\n// A thin wrapper around Client, which does the actual compiling, error\n// handling, and frame wrapping. This used to have its own duplicate\n// compile-and-render branch for the `code` prop that never wrapped its\n// output in <Frame>, so `frame` was silently ignored whenever `code` was\n// passed — see #187. Client already handles `code` (falling back to\n// context when absent) and `frame`, so there is only one render path now.\nconst Preview = ({\n code,\n props = NO_PROPS,\n modules = NO_MODULES,\n dynamicTailwind = false,\n provider,\n ...restProps\n}: Props) => {\n return (\n <Client\n code={code}\n props={props}\n modules={modules}\n dynamicTailwind={dynamicTailwind}\n provider={provider}\n {...restProps}\n />\n );\n};\n\nexport default Preview;\n"],"mappings":";;;;;;;AAGA,MAAa,WAAoC,CAAC;AAClD,MAAa,aAAsC,CAAC;;;ACUpD,MAAM,UAAU,EACd,MAAM,OACN,WACA,WACA,QAAQ,UACR,UAAU,YACV,OACA,kBAAkB,OAClB,eACW;CACX,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,EAAE,OAAO,aAAa,SAAS;CACrC,MAAM,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CAEjC,MAAM,aAAa,GAAG,WAAW,UAAU,SAAS;CAEpD,MAAM,gBAAgB,UAAU,KAAA,IAAY,OAAO;CAEnD,MAAM,SAAS,kBAAkB,eAAe,OAAO;CAIvD,MAAM,EAAE,KAAK,YAAY,KAAK,eAAe,mBAC3C,eACA,eACF;CAEA,MAAM,iBAAiB,eACd,EACL,GAAG,MACL,IACA,CAAC,KAAK,CACR;CAEA,MAAM,kBAAkB,cAA+B;EACrD,OAAO,WAAW,SAAS,SAAS,IAAI;CAC1C;CAEA,IAAI,UAAU,OAAO,OACnB,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAW,GAAG,0BAA0B,UAAU;EACrD,UAAA,oBAACA,OAAD;GAAW,SAAS,OAAO;GAAO,OAAM;EAAiB,CAAA;CACtD,CAAA,GACL,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;CAIN,MAAM,YAAY,QAAQ,SAAS;CAEnC,IAAI,CAAC,WACH,OAAO;CAGT,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,QACC,oBAAC,OAAD;EAAK,WAAW,GAAG,iBAAiB,UAAU;EAC5C,UAAA,oBAAC,OAAD;GAAO,GAAK;GACT,WAAA,cACC,oBAAC,OAAD;IAAK,KAAK;IAAY,OAAO,EAAE,SAAS,WAAW;IACjD,UAAA,oBAACA,MAAU,UAAX;KACE,WAAW,CAAC,aAAa;KACzB,UAAU,MAAa,SAAS,EAAE,OAAO;KAExC,UAAA,eACC,qBAACA,MAAU,OAAX;MAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;MAAjD,UAAA,CACE,oBAAC,WAAD;OAAW,GAAI;OAA2B;MAAY,CAAA,GACrD,mBAAmB,cAClB,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAEb;KACnB,CAAA,CAAA;IACkB,CAAA;GACjB,CAAA;EAEF,CAAA;CACJ,CAAA,IAEL,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,4DACA,UACF;EACA,OAAO;GACL,WAAW;GACX,WAAW;GACX,eAAe;EACjB;EAEA,UAAA,oBAACA,MAAU,UAAX;GACE,WAAW,CAAC,aAAa;GACzB,UAAS,MAAK,SAAS,EAAE,OAAO;GAE/B,UAAA,eACC,qBAACA,MAAU,OAAX;IAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;IAAjD,UAAA,CACE,oBAAC,WAAD,EAAW,GAAI,eAAiB,CAAA,GAC/B,mBAAmB,cAAc,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAC7C;GACnB,CAAA,CAAA;EACkB,CAAA;CACjB,CAAA,GAEP,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;AAEN;;;ACnGA,MAAM,WAAW,EACf,MACA,QAAQ,UACR,UAAU,YACV,kBAAkB,OAClB,UACA,GAAG,gBACQ;CACX,OACE,oBAAC,QAAD;EACQ;EACC;EACE;EACQ;EACP;EACV,GAAI;CACL,CAAA;AAEL"}
|