@jbpark/live-editor 1.18.1 → 2.0.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/dist/{ast-Cyi-jw9Z.js → ast-CrSMBsL4.js} +117 -37
- package/dist/ast-CrSMBsL4.js.map +1 -0
- package/dist/{boundary-DUTt8lXq.js → boundary-b-U70XU_.js} +2 -2
- package/dist/{boundary-DUTt8lXq.js.map → boundary-b-U70XU_.js.map} +1 -1
- package/dist/{context-fLmciLSw.js → context-Yb81ZxnN.js} +3 -3
- package/dist/{context-fLmciLSw.js.map → context-Yb81ZxnN.js.map} +1 -1
- package/dist/{core-ttOtjNaX.js → core-mdFWxqB2.js} +2 -2
- package/dist/{core-ttOtjNaX.js.map → core-mdFWxqB2.js.map} +1 -1
- package/dist/dnd/index.d.ts +1 -1
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-l2V0EmfS.js → dnd-DMh9mSaU.js} +67 -59
- package/dist/dnd-DMh9mSaU.js.map +1 -0
- package/dist/{document-DhMip8lL.js → document-DEx4WyCn.js} +7 -1
- package/dist/document-DEx4WyCn.js.map +1 -0
- package/dist/editor/index.js +2 -2
- package/dist/{editor-Du55469f.js → editor-jzeeLkwi.js} +3 -3
- package/dist/{editor-Du55469f.js.map → editor-jzeeLkwi.js.map} +1 -1
- package/dist/error/index.js +2 -2
- package/dist/{error-BbOmgZDR.js → error-C47PVZgY.js} +2 -2
- package/dist/{error-BbOmgZDR.js.map → error-C47PVZgY.js.map} +1 -1
- package/dist/{index-soMhswGI.d.ts → index-7J3AYBNK.d.ts} +7 -5
- package/dist/{index-Ly0DcdIH.d.ts → index-Wh6AGoXW.d.ts} +35 -36
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/preview/index.js +1 -1
- package/dist/{preview-CQf0nwE6.js → preview-8OZDsfGT.js} +4 -4
- package/dist/{preview-CQf0nwE6.js.map → preview-8OZDsfGT.js.map} +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/{use-dynamic-tailwind-DkK3r-as.js → use-dynamic-tailwind-_3tC-S5j.js} +2 -2
- package/dist/{use-dynamic-tailwind-DkK3r-as.js.map → use-dynamic-tailwind-_3tC-S5j.js.map} +1 -1
- package/dist/utils/ast/index.d.ts +2 -2
- package/dist/utils/ast/index.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/{utils-CCrTYGUG.js → utils-CXq1KaM3.js} +2 -2
- package/dist/{utils-CCrTYGUG.js.map → utils-CXq1KaM3.js.map} +1 -1
- package/package.json +1 -1
- package/dist/ast-Cyi-jw9Z.js.map +0 -1
- package/dist/dnd-l2V0EmfS.js.map +0 -1
- package/dist/document-DhMip8lL.js.map +0 -1
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-mdFWxqB2.js";
|
|
2
|
+
import { t as Editor } from "../editor-jzeeLkwi.js";
|
|
3
3
|
export { Core, Editor as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as DEFAULT_TEMPLATE } from "./document-
|
|
1
|
+
import { y as DEFAULT_TEMPLATE } from "./document-DEx4WyCn.js";
|
|
2
2
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
3
|
-
import { n as useFormatCode, t as Core } from "./core-
|
|
3
|
+
import { n as useFormatCode, t as Core } from "./core-mdFWxqB2.js";
|
|
4
4
|
import { useCallback, useEffect } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { useDebouncedValue } from "@jbpark/use-hooks";
|
|
@@ -48,4 +48,4 @@ Editor.Core = Core;
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { Editor as t };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=editor-
|
|
51
|
+
//# sourceMappingURL=editor-jzeeLkwi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-
|
|
1
|
+
{"version":3,"file":"editor-jzeeLkwi.js","names":["Editor","EditorImpl"],"sources":["../src/components/editor/editor.tsx","../src/components/editor/index.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\n\nimport { useDebouncedValue } from '@jbpark/use-hooks';\n\nimport { useError, usePreview } from '~/components/context/states';\nimport { DEFAULT_TEMPLATE } from '~/constants';\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, 'onSave' | 'onError'> {\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 { setCode } = usePreview();\n const { setError } = useError();\n\n const value =\n _value.trim() === '' ? defaultValue || DEFAULT_TEMPLATE : _value;\n\n const onChange = useCallback(\n (value: string) => {\n _onChange?.(value);\n },\n [_onChange],\n );\n\n const onSave = useCallback(\n (formattedCode: string) => {\n setCode(formattedCode);\n },\n [setCode],\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 const debouncedValue = useDebouncedValue(value, debounce);\n\n useEffect(() => {\n setCode(debouncedValue);\n }, [debouncedValue, setCode]);\n\n if (renderEditor) {\n return renderEditor({ value, onChange, formatCode });\n }\n\n return (\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};\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,YAAY,WAAW;CAC/B,MAAM,EAAE,aAAa,SAAS;CAE9B,MAAM,QACJ,OAAO,KAAK,MAAM,KAAK,gBAAgB,mBAAmB;CAE5D,MAAM,WAAW,aACd,UAAkB;EACjB,YAAY,KAAK;CACnB,GACA,CAAC,SAAS,CACZ;CAEA,MAAM,SAAS,aACZ,kBAA0B;EACzB,QAAQ,aAAa;CACvB,GACA,CAAC,OAAO,CACV;CAEA,MAAM,UAAU,aACb,UAAyB;EACxB,SAAS,KAAK;CAChB,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,aAAa,cAAc;EAAE;EAAU;CAAgB,CAAC;CAE9D,MAAM,iBAAiB,kBAAkB,OAAO,QAAQ;CAExD,gBAAgB;EACd,QAAQ,cAAc;CACxB,GAAG,CAAC,gBAAgB,OAAO,CAAC;CAE5B,IAAI,cACF,OAAO,aAAa;EAAE;EAAO;EAAU;CAAW,CAAC;CAGrD,OACE,oBAAC,MAAD;EACS;EACG;EACF;EACC;EACC;EACO;EACjB,GAAI;CACL,CAAA;AAEL;;;ACnFA,MAAM,SAASC;AAEf,OAAO,OAAO"}
|
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-b-U70XU_.js";
|
|
2
|
+
import { n as Runtime, r as Guard, t as Error } from "../error-C47PVZgY.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-b-U70XU_.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-C47PVZgY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-
|
|
1
|
+
{"version":3,"file":"error-C47PVZgY.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,5 +1,5 @@
|
|
|
1
1
|
import { v as Section } from "./document-J9Lo9p81.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as BindingRenderMap, O as BindingOption, j as BindingType } from "./index-Wh6AGoXW.js";
|
|
3
3
|
import { t as FrameProps } from "./index-DpDU1IAw.js";
|
|
4
4
|
import { LucideIcon } from "lucide-react";
|
|
5
5
|
//#region src/components/dnd/draggable.d.ts
|
|
@@ -43,8 +43,10 @@ interface PanelBinding {
|
|
|
43
43
|
max?: number;
|
|
44
44
|
pattern?: string;
|
|
45
45
|
required?: boolean;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
meta?: Record<string, unknown>;
|
|
47
|
+
value: unknown;
|
|
48
|
+
rawValue: string;
|
|
49
|
+
onChange: (value: unknown) => void;
|
|
48
50
|
}
|
|
49
51
|
interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
|
|
50
52
|
value?: string;
|
|
@@ -80,7 +82,7 @@ interface PanelProps {
|
|
|
80
82
|
id: string;
|
|
81
83
|
label: string;
|
|
82
84
|
property: string;
|
|
83
|
-
value:
|
|
85
|
+
value: unknown;
|
|
84
86
|
}) => void;
|
|
85
87
|
}
|
|
86
88
|
declare const Panel: ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp, canMoveDown, bindings, onNodeChange }: PanelProps) => import("react").JSX.Element;
|
|
@@ -93,4 +95,4 @@ type DndComponent = typeof Dnd$1 & {
|
|
|
93
95
|
declare const Dnd: DndComponent;
|
|
94
96
|
//#endregion
|
|
95
97
|
export { ICON_OPTIONS as a, PanelRenderData as c, DraggableItemDragState as d, DraggableItemProps as f, ICON_MAP as i, Props as l, Panel as n, PaletteRenderData as o, PanelProps as r, PanelBinding as s, Dnd as t, DraggableItem as u };
|
|
96
|
-
//# sourceMappingURL=index-
|
|
98
|
+
//# sourceMappingURL=index-7J3AYBNK.d.ts.map
|
|
@@ -33,7 +33,7 @@ interface BindingOption {
|
|
|
33
33
|
declare const BINDING_TYPES: readonly ["array", "object", "string", "number", "boolean", "color", "jsx", "richtext", "date", "url", "icon-picker", "asset-picker"];
|
|
34
34
|
type BindingType = (typeof BINDING_TYPES)[number];
|
|
35
35
|
interface BindingRenderLeaf {
|
|
36
|
-
type
|
|
36
|
+
type?: BindingType;
|
|
37
37
|
property?: string;
|
|
38
38
|
render?: BindingRenderMap;
|
|
39
39
|
}
|
|
@@ -51,6 +51,7 @@ interface BindingItem {
|
|
|
51
51
|
max?: number;
|
|
52
52
|
pattern?: string;
|
|
53
53
|
required?: boolean;
|
|
54
|
+
meta?: Record<string, unknown>;
|
|
54
55
|
}
|
|
55
56
|
type NodeValueType = 'boolean' | 'number' | 'string' | 'null' | 'array' | 'object' | 'unknown';
|
|
56
57
|
type EditableNodeValueType = 'boolean' | 'number' | 'string' | 'null';
|
|
@@ -61,35 +62,11 @@ interface ExtractedNodeValue {
|
|
|
61
62
|
//#endregion
|
|
62
63
|
//#region src/utils/ast/binding.d.ts
|
|
63
64
|
declare const parseBinding: (bindingValue: string | null) => BindingItem[];
|
|
65
|
+
declare const parseBindingExpression: (expression: ArrayExpression) => BindingItem[];
|
|
64
66
|
declare const getCurrentValue: (node: DataAttrNode, property: string) => string;
|
|
67
|
+
declare const getStructuredValue: (node: DataAttrNode, property: string, type?: BindingType) => unknown;
|
|
65
68
|
declare const findEditableChildren: (node: DataAttrNode) => DataAttrNode[];
|
|
66
69
|
//#endregion
|
|
67
|
-
//#region node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser/typings/babel-parser.d.ts
|
|
68
|
-
declare class Position {
|
|
69
|
-
line: number;
|
|
70
|
-
column: number;
|
|
71
|
-
index: number;
|
|
72
|
-
constructor(line: number, col: number, index: number);
|
|
73
|
-
}
|
|
74
|
-
type SyntaxPlugin = "flow" | "typescript" | "jsx" | "functionBind" | "pipelineOperator" | "placeholders";
|
|
75
|
-
type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
|
|
76
|
-
interface ParseErrorSpecification<ErrorDetails> {
|
|
77
|
-
code: ParseErrorCode;
|
|
78
|
-
reasonCode: string;
|
|
79
|
-
syntaxPlugin?: SyntaxPlugin;
|
|
80
|
-
missingPlugin?: string | string[];
|
|
81
|
-
loc: Position;
|
|
82
|
-
details: ErrorDetails;
|
|
83
|
-
pos: number;
|
|
84
|
-
}
|
|
85
|
-
type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>;
|
|
86
|
-
type ParseError = ParseError$1<object>;
|
|
87
|
-
type ParseResult<Result extends File | Expression = File> = Result & {
|
|
88
|
-
comments: File["comments"];
|
|
89
|
-
errors: null | ParseError[];
|
|
90
|
-
tokens?: File["tokens"];
|
|
91
|
-
};
|
|
92
|
-
//#endregion
|
|
93
70
|
//#region src/utils/ast/value.d.ts
|
|
94
71
|
declare const parseValue: (value: unknown) => unknown;
|
|
95
72
|
type EditablePathSegment = string | number;
|
|
@@ -102,11 +79,7 @@ declare const flattenEditableValue: (value: string) => EditableValueEntry[] | nu
|
|
|
102
79
|
declare const setEditableValue: (value: string, path: EditablePathSegment[], next: EditablePrimitive) => string;
|
|
103
80
|
declare const extractNodeValue: (node: Node) => ExtractedNodeValue;
|
|
104
81
|
declare const createNodeFromValue: (type: NodeValueType, value: unknown) => Expression | null;
|
|
105
|
-
declare const parseArrayExpression: (value: string) =>
|
|
106
|
-
comments: File["comments"];
|
|
107
|
-
errors: null | ParseError[];
|
|
108
|
-
tokens?: File["tokens"];
|
|
109
|
-
}) | null;
|
|
82
|
+
declare const parseArrayExpression: (value: string) => ArrayExpression | null;
|
|
110
83
|
declare const extractObjectProperties: (element: ObjectExpression) => Record<string, ExtractedNodeValue & {
|
|
111
84
|
astNode: Node;
|
|
112
85
|
}>;
|
|
@@ -124,14 +97,40 @@ interface UpdateResult {
|
|
|
124
97
|
code: string;
|
|
125
98
|
success: boolean;
|
|
126
99
|
}
|
|
127
|
-
declare const update: (code: string, dataId: string, label: string, value:
|
|
100
|
+
declare const update: (code: string, dataId: string, label: string, value: unknown, property?: string) => UpdateResult;
|
|
128
101
|
declare const bulkUpdate: (raw: string, entries: {
|
|
129
102
|
dataId: string;
|
|
130
103
|
label: string;
|
|
131
|
-
value:
|
|
104
|
+
value: unknown;
|
|
132
105
|
property?: string;
|
|
133
106
|
}[]) => UpdateResult;
|
|
134
107
|
//#endregion
|
|
108
|
+
//#region node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser/typings/babel-parser.d.ts
|
|
109
|
+
declare class Position {
|
|
110
|
+
line: number;
|
|
111
|
+
column: number;
|
|
112
|
+
index: number;
|
|
113
|
+
constructor(line: number, col: number, index: number);
|
|
114
|
+
}
|
|
115
|
+
type SyntaxPlugin = "flow" | "typescript" | "jsx" | "functionBind" | "pipelineOperator" | "placeholders";
|
|
116
|
+
type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
|
|
117
|
+
interface ParseErrorSpecification<ErrorDetails> {
|
|
118
|
+
code: ParseErrorCode;
|
|
119
|
+
reasonCode: string;
|
|
120
|
+
syntaxPlugin?: SyntaxPlugin;
|
|
121
|
+
missingPlugin?: string | string[];
|
|
122
|
+
loc: Position;
|
|
123
|
+
details: ErrorDetails;
|
|
124
|
+
pos: number;
|
|
125
|
+
}
|
|
126
|
+
type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>;
|
|
127
|
+
type ParseError = ParseError$1<object>;
|
|
128
|
+
type ParseResult<Result extends File | Expression = File> = Result & {
|
|
129
|
+
comments: File["comments"];
|
|
130
|
+
errors: null | ParseError[];
|
|
131
|
+
tokens?: File["tokens"];
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
135
134
|
//#region src/utils/ast/tree.d.ts
|
|
136
135
|
declare const replaceIds: (code: string, generateId?: () => string) => string;
|
|
137
136
|
declare const fillIds: (code: string, generateId?: () => string) => string;
|
|
@@ -144,5 +143,5 @@ interface ValidationResult {
|
|
|
144
143
|
}
|
|
145
144
|
declare const validateBindingValue: (binding: BindingItem, value: unknown) => ValidationResult;
|
|
146
145
|
//#endregion
|
|
147
|
-
export {
|
|
148
|
-
//# sourceMappingURL=index-
|
|
146
|
+
export { BindingRenderMap as A, getCurrentValue as C, BindingItem as D, parseBindingExpression as E, NodeValueType as F, DataAttrNode as M, EditableNodeValueType as N, BindingOption as O, ExtractedNodeValue as P, findEditableChildren as S, parseBinding as T, extractObjectProperties as _, replaceIds as a, parseValue as b, clearExtractCache as c, EditablePathSegment as d, EditablePrimitive as f, extractNodeValue as g, createNodeFromValue as h, fillIds as i, BindingType as j, BindingRenderLeaf as k, extract as l, arrayExpressionToCode as m, validateBindingValue as n, bulkUpdate as o, EditableValueEntry as p, clone as r, update as s, ValidationResult as t, generateCode as u, flattenEditableValue as v, getStructuredValue as w, setEditableValue as x, parseArrayExpression as y };
|
|
147
|
+
//# sourceMappingURL=index-Wh6AGoXW.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v as Section } from "./document-J9Lo9p81.js";
|
|
2
2
|
import { t as FrameProps } from "./index-DpDU1IAw.js";
|
|
3
|
-
import { c as PanelRenderData, f as DraggableItemProps, l as Props, o as PaletteRenderData, r as PanelProps, s as PanelBinding, t as Dnd } from "./index-
|
|
3
|
+
import { c as PanelRenderData, f as DraggableItemProps, l as Props, o as PaletteRenderData, r as PanelProps, s as PanelBinding, t as Dnd } from "./index-7J3AYBNK.js";
|
|
4
4
|
import { a as Props$2, n as EditorRenderData, r as Props$1, t as Editor } from "./index-C4TBkJBG.js";
|
|
5
5
|
import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-CCynrS6c.js";
|
|
6
6
|
import { n as Props$6, t as Preview } from "./index-lgHdCda5.js";
|
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-Yb81ZxnN.js";
|
|
2
|
+
import { t as Dnd } from "./dnd-DMh9mSaU.js";
|
|
3
|
+
import { t as Editor } from "./editor-jzeeLkwi.js";
|
|
4
|
+
import { t as Error } from "./error-C47PVZgY.js";
|
|
5
|
+
import { t as Preview } from "./preview-8OZDsfGT.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/index.tsx
|
|
8
8
|
const App = ({ children }) => {
|
package/dist/preview/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Preview } from "../preview-
|
|
1
|
+
import { t as Preview } from "../preview-8OZDsfGT.js";
|
|
2
2
|
export { Preview as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as cn } from "./utils-
|
|
1
|
+
import { r as cn } from "./utils-CXq1KaM3.js";
|
|
2
2
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
3
|
-
import { n as useCompiledModule, r as Frame, t as useDynamicTailwind } from "./use-dynamic-tailwind-
|
|
4
|
-
import { t as Error } from "./error-
|
|
3
|
+
import { n as useCompiledModule, r as Frame, t as useDynamicTailwind } from "./use-dynamic-tailwind-_3tC-S5j.js";
|
|
4
|
+
import { t as Error } from "./error-C47PVZgY.js";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/preview/client.tsx
|
|
@@ -79,4 +79,4 @@ const Preview = ({ code, props = {}, modules = {}, dynamicTailwind = false, prov
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { Preview as t };
|
|
81
81
|
|
|
82
|
-
//# sourceMappingURL=preview-
|
|
82
|
+
//# sourceMappingURL=preview-8OZDsfGT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-
|
|
1
|
+
{"version":3,"file":"preview-8OZDsfGT.js","names":["LiveError"],"sources":["../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["'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';\n\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 = {},\n 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 || 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';\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 = {},\n 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":";;;;;;;AAaA,MAAM,UAAU,EACd,MAAM,QAAQ,IACd,WACA,WACA,QAAQ,CAAC,GACT,UAAU,CAAC,GACX,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,SAAS;CAE/B,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,CAAC,GACT,UAAU,CAAC,GACX,kBAAkB,OAClB,UACA,GAAG,gBACQ;CACX,OACE,oBAAC,QAAD;EACQ;EACC;EACE;EACQ;EACP;EACV,GAAI;CACL,CAAA;AAEL"}
|
package/dist/provider/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ContextProvider } from "../context-
|
|
1
|
+
import { t as ContextProvider } from "../context-Yb81ZxnN.js";
|
|
2
2
|
export { ContextProvider as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as compile, l as getCachedScriptBlob, t as baseModules } from "./utils-
|
|
1
|
+
import { i as compile, l as getCachedScriptBlob, t as baseModules } from "./utils-CXq1KaM3.js";
|
|
2
2
|
import { t as generateTailwindCSSFromDOM } from "./tailwind-CbjdLyVX.js";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -456,4 +456,4 @@ const useDynamicTailwind = (code, enabled) => {
|
|
|
456
456
|
//#endregion
|
|
457
457
|
export { useCompiledModule as n, Frame as r, useDynamicTailwind as t };
|
|
458
458
|
|
|
459
|
-
//# sourceMappingURL=use-dynamic-tailwind-
|
|
459
|
+
//# sourceMappingURL=use-dynamic-tailwind-_3tC-S5j.js.map
|