@jbpark/live-editor 4.1.1 → 4.3.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-jab6hQrT.js → ast-BFbDWO-l.js} +288 -229
- package/dist/ast-BFbDWO-l.js.map +1 -0
- package/dist/{boundary-D2IFja-3.js → boundary-B17cepvm.js} +12 -9
- package/dist/boundary-B17cepvm.js.map +1 -0
- package/dist/{compile-CBOAtQMz.js → compile-0Dvp8zp5.js} +37 -5
- package/dist/compile-0Dvp8zp5.js.map +1 -0
- package/dist/{constants-BD3FZKWE.js → constants-CKvdqZtO.js} +11 -4
- package/dist/constants-CKvdqZtO.js.map +1 -0
- package/dist/{context-DQ-UtoyS.js → context-93X3gyfJ.js} +2 -2
- package/dist/{context-DQ-UtoyS.js.map → context-93X3gyfJ.js.map} +1 -1
- package/dist/{core-DaXVtvH5.js → core-B3ruccKb.js} +2 -2
- package/dist/{core-DaXVtvH5.js.map → core-B3ruccKb.js.map} +1 -1
- package/dist/{detect-typescript-b0A751v2.js → detect-typescript-5MV4mCM7.js} +2 -2
- package/dist/{detect-typescript-b0A751v2.js.map → detect-typescript-5MV4mCM7.js.map} +1 -1
- package/dist/dnd/index.d.ts +2 -2
- package/dist/dnd/index.js +2 -2
- package/dist/{dnd-CMrXfD8O.js → dnd-Z1KS16Fy.js} +969 -322
- package/dist/dnd-Z1KS16Fy.js.map +1 -0
- package/dist/{document-J9Lo9p81.d.ts → document-Ct4jW78J.d.ts} +42 -22
- package/dist/{document-C5Dypv4_.js → document-cEEdFERz.js} +138 -46
- package/dist/document-cEEdFERz.js.map +1 -0
- package/dist/editor/index.js +2 -2
- package/dist/{editor-C3tQaMlU.js → editor-DvMruljw.js} +2 -2
- package/dist/{editor-C3tQaMlU.js.map → editor-DvMruljw.js.map} +1 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +2 -2
- package/dist/{error-KW8XCcjH.js → error-DWhxQEom.js} +2 -2
- package/dist/{error-KW8XCcjH.js.map → error-DWhxQEom.js.map} +1 -1
- package/dist/{index-DNNj_0ba.d.ts → index-C4SGQ3Ci.d.ts} +4 -3
- package/dist/{index-C4t0OawE.d.ts → index-CtlUYnWq.d.ts} +131 -34
- package/dist/{index-B_p74BRM.d.ts → index-w3kLcCXl.d.ts} +29 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/preview/index.js +2 -2
- package/dist/{preview-BwEfltgi.js → preview-C_UzpGWh.js} +3 -3
- package/dist/{preview-BwEfltgi.js.map → preview-C_UzpGWh.js.map} +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/sections-GJQ63uEB.js +24 -0
- package/dist/sections-GJQ63uEB.js.map +1 -0
- package/dist/{use-dynamic-tailwind-DuGLeDR3.js → use-dynamic-tailwind-DpbjmATF.js} +20 -11
- package/dist/use-dynamic-tailwind-DpbjmATF.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 +7 -6
- package/dist/utils/index.js +5 -5
- package/package.json +1 -1
- package/dist/ast-jab6hQrT.js.map +0 -1
- package/dist/boundary-D2IFja-3.js.map +0 -1
- package/dist/compile-CBOAtQMz.js.map +0 -1
- package/dist/constants-BD3FZKWE.js.map +0 -1
- package/dist/dnd-CMrXfD8O.js.map +0 -1
- package/dist/document-C5Dypv4_.js.map +0 -1
- package/dist/sections-B7dWoNVJ.js +0 -19
- package/dist/sections-B7dWoNVJ.js.map +0 -1
- package/dist/use-dynamic-tailwind-DuGLeDR3.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-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"}
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as Guard, o as Props, r as Runtime, s as ErrorBoundary, t as Error } from "../index-
|
|
1
|
+
import { i as Guard, o as Props, r as Runtime, s as ErrorBoundary, t as Error } from "../index-C4SGQ3Ci.js";
|
|
2
2
|
export { ErrorBoundary, Guard as ErrorGuard, Runtime as ErrorRuntime, type Props, Error as default };
|
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-B17cepvm.js";
|
|
2
|
+
import { n as Runtime, r as Guard, t as Error } from "../error-DWhxQEom.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-B17cepvm.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-DWhxQEom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-
|
|
1
|
+
{"version":3,"file":"error-DWhxQEom.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"}
|
|
@@ -9,12 +9,13 @@ interface Props$3 {
|
|
|
9
9
|
interface State {
|
|
10
10
|
hasError: boolean;
|
|
11
11
|
error?: Error;
|
|
12
|
+
resetKeys?: readonly unknown[];
|
|
12
13
|
}
|
|
13
14
|
declare class ErrorBoundary extends React$1.Component<Props$3, State> {
|
|
14
15
|
constructor(props: Props$3);
|
|
15
|
-
static getDerivedStateFromError(error: Error): State
|
|
16
|
+
static getDerivedStateFromError(error: Error): Partial<State>;
|
|
16
17
|
componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
|
|
17
|
-
|
|
18
|
+
static getDerivedStateFromProps(props: Props$3, state: State): Partial<State> | null;
|
|
18
19
|
reset: () => void;
|
|
19
20
|
render(): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | React$1.JSX.Element | null | undefined;
|
|
20
21
|
}
|
|
@@ -50,4 +51,4 @@ type ErrorComponent = typeof Error$2 & {
|
|
|
50
51
|
declare const Error$1: ErrorComponent;
|
|
51
52
|
//#endregion
|
|
52
53
|
export { Props$1 as a, Guard as i, Props as n, Props$2 as o, Runtime as r, ErrorBoundary as s, Error$1 as t };
|
|
53
|
-
//# sourceMappingURL=index-
|
|
54
|
+
//# sourceMappingURL=index-C4SGQ3Ci.d.ts.map
|
|
@@ -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;
|
|
@@ -31,6 +45,20 @@ type DndEditError = {
|
|
|
31
45
|
};
|
|
32
46
|
type DndRenderField = (props: FieldProps, builtin: React.ReactElement) => React.ReactNode | undefined;
|
|
33
47
|
//#endregion
|
|
48
|
+
//#region src/components/dnd/inspector.d.ts
|
|
49
|
+
interface DndNodePick {
|
|
50
|
+
id: string;
|
|
51
|
+
sectionId: string;
|
|
52
|
+
}
|
|
53
|
+
interface DndInspector {
|
|
54
|
+
active: boolean;
|
|
55
|
+
activate: () => void;
|
|
56
|
+
deactivate: () => void;
|
|
57
|
+
toggle: () => void;
|
|
58
|
+
picked: DndNodePick | null;
|
|
59
|
+
}
|
|
60
|
+
declare const useDndInspector: () => DndInspector;
|
|
61
|
+
//#endregion
|
|
34
62
|
//#region src/components/dnd/panel-binding.d.ts
|
|
35
63
|
interface PanelNodeChange {
|
|
36
64
|
(params: {
|
|
@@ -40,6 +68,9 @@ interface PanelNodeChange {
|
|
|
40
68
|
value: unknown;
|
|
41
69
|
}): void;
|
|
42
70
|
}
|
|
71
|
+
interface PanelNodesChange {
|
|
72
|
+
(changes: Parameters<PanelNodeChange>[0][]): void;
|
|
73
|
+
}
|
|
43
74
|
interface PanelBinding {
|
|
44
75
|
id: string;
|
|
45
76
|
label: string;
|
|
@@ -56,8 +87,17 @@ interface PanelBinding {
|
|
|
56
87
|
value: unknown;
|
|
57
88
|
rawValue: string;
|
|
58
89
|
canEditValue?: boolean;
|
|
90
|
+
present?: boolean;
|
|
59
91
|
onChange: (value: unknown) => void;
|
|
60
92
|
}
|
|
93
|
+
type PanelBindingData = Omit<PanelBinding, 'onChange'>;
|
|
94
|
+
interface PanelBindingSource {
|
|
95
|
+
id: string;
|
|
96
|
+
tagName: string;
|
|
97
|
+
bindings: PanelBindingData[];
|
|
98
|
+
}
|
|
99
|
+
declare const resolvePanelBindings: (node: DataAttrNode) => PanelBindingSource | null;
|
|
100
|
+
declare const withPanelCommit: (bindings: PanelBindingData[], commit: PanelNodeChange | undefined) => PanelBinding[];
|
|
61
101
|
//#endregion
|
|
62
102
|
//#region src/components/dnd/section-fallback-context.d.ts
|
|
63
103
|
interface DndSectionFallbackArgs {
|
|
@@ -82,6 +122,8 @@ interface DndPanel {
|
|
|
82
122
|
canMoveDown: boolean;
|
|
83
123
|
bindings: PanelBinding[];
|
|
84
124
|
onNodeChange: PanelNodeChange;
|
|
125
|
+
onNodesChange: PanelNodesChange;
|
|
126
|
+
readOnly: boolean;
|
|
85
127
|
}
|
|
86
128
|
interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
|
|
87
129
|
value?: string;
|
|
@@ -96,9 +138,13 @@ interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
|
|
|
96
138
|
onEditError?: (error: DndEditError) => void;
|
|
97
139
|
renderSectionFallback?: DndRenderSectionFallback;
|
|
98
140
|
shouldForceSectionFallback?: (section: Section) => boolean;
|
|
141
|
+
onBeforeDelete?: (section: Section) => boolean | Promise<boolean>;
|
|
142
|
+
sectionNameFallback?: (index: number) => string;
|
|
143
|
+
containerId?: string;
|
|
144
|
+
onNodePick?: (pick: DndNodePick) => void;
|
|
99
145
|
children?: React.ReactNode;
|
|
100
146
|
}
|
|
101
|
-
declare const Dnd$1: ({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, children, ...restProps }: Props) => import("react").JSX.Element;
|
|
147
|
+
declare const Dnd$1: ({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, onNodePick, children, ...restProps }: Props) => import("react").JSX.Element;
|
|
102
148
|
//#endregion
|
|
103
149
|
//#region src/components/dnd/draggable.d.ts
|
|
104
150
|
interface DraggableItemDragState {
|
|
@@ -130,31 +176,56 @@ interface DndLayout {
|
|
|
130
176
|
clearSelection: () => void;
|
|
131
177
|
paletteOpen: boolean;
|
|
132
178
|
setPaletteOpen: (open: boolean) => void;
|
|
179
|
+
documentError: 'parse-error' | 'container-not-found' | null;
|
|
133
180
|
}
|
|
134
181
|
declare const useDndPalette: () => DndPalette;
|
|
135
182
|
declare const useDndPanel: () => DndPanel;
|
|
136
183
|
declare const useDndLayout: () => DndLayout;
|
|
137
184
|
//#endregion
|
|
138
|
-
//#region src/components/dnd/panel/use-
|
|
139
|
-
interface
|
|
185
|
+
//#region src/components/dnd/panel/use-dnd-children.d.ts
|
|
186
|
+
interface DndChildrenOptions {
|
|
187
|
+
onChange?: (value: string) => void;
|
|
188
|
+
}
|
|
189
|
+
declare const useDndChildren: (items: DataAttrNode[], { onChange }?: DndChildrenOptions) => {
|
|
190
|
+
items: DataAttrNode[];
|
|
191
|
+
selection: {
|
|
192
|
+
readonly selected: Set<number>;
|
|
193
|
+
readonly isSelected: (index: number) => boolean;
|
|
194
|
+
readonly toggle: (index: number, shiftKey?: boolean) => void;
|
|
195
|
+
readonly clear: () => void;
|
|
196
|
+
readonly replace: (indices: Set<number>) => void;
|
|
197
|
+
};
|
|
198
|
+
actions: {
|
|
199
|
+
move: (from: number, to: number) => void;
|
|
200
|
+
remove: (index: number) => void;
|
|
201
|
+
add: () => void;
|
|
202
|
+
duplicateSelected: () => void;
|
|
203
|
+
moveSelected: (direction: "up" | "down") => void;
|
|
204
|
+
removeSelected: () => void;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
type DndChildren = ReturnType<typeof useDndChildren>;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/components/dnd/panel/use-dnd-items.d.ts
|
|
210
|
+
interface DndItemsNestedElement {
|
|
140
211
|
id: string;
|
|
141
212
|
tagName: string;
|
|
142
213
|
bindings: PanelBinding[];
|
|
143
214
|
}
|
|
144
|
-
interface
|
|
215
|
+
interface DndItemsNestedGroup {
|
|
145
216
|
property: string;
|
|
146
|
-
elements:
|
|
217
|
+
elements: DndItemsNestedElement[];
|
|
147
218
|
fallback?: PanelBinding;
|
|
148
219
|
}
|
|
149
|
-
interface
|
|
220
|
+
interface DndItemsItem {
|
|
150
221
|
id: string;
|
|
151
222
|
index: number;
|
|
152
223
|
elementIndex: number;
|
|
153
224
|
properties: PanelBinding[];
|
|
154
|
-
nested:
|
|
225
|
+
nested: DndItemsNestedGroup[];
|
|
155
226
|
value?: PanelBinding;
|
|
156
227
|
}
|
|
157
|
-
interface
|
|
228
|
+
interface DndItemsActions {
|
|
158
229
|
add: () => void;
|
|
159
230
|
move: (elementIndex: number, toIndex: number) => void;
|
|
160
231
|
remove: (elementIndex: number) => void;
|
|
@@ -162,26 +233,48 @@ interface ItemsEditorActions {
|
|
|
162
233
|
moveSelected: (direction: 'up' | 'down') => void;
|
|
163
234
|
removeSelected: () => void;
|
|
164
235
|
}
|
|
165
|
-
interface
|
|
236
|
+
interface DndItemsExpansion {
|
|
237
|
+
expandedIds: string[];
|
|
238
|
+
isExpanded: (id: string) => boolean;
|
|
239
|
+
toggle: (id: string) => void;
|
|
240
|
+
setExpanded: (ids: string[]) => void;
|
|
241
|
+
}
|
|
242
|
+
interface DndItems {
|
|
166
243
|
kind: 'object' | 'primitive';
|
|
167
|
-
items:
|
|
244
|
+
items: DndItemsItem[];
|
|
168
245
|
selection: ReturnType<typeof useMultiSelect>;
|
|
169
|
-
|
|
246
|
+
expansion: DndItemsExpansion;
|
|
247
|
+
actions: DndItemsActions;
|
|
170
248
|
canEditStructure: boolean;
|
|
171
249
|
parseError: boolean;
|
|
172
250
|
}
|
|
173
|
-
interface
|
|
251
|
+
interface DndItemsOptions {
|
|
174
252
|
render?: BindingRenderMap;
|
|
175
253
|
onChange?: (value: string) => void;
|
|
176
254
|
onNodeChange?: PanelNodeChange;
|
|
177
255
|
}
|
|
178
|
-
declare const
|
|
256
|
+
declare const useDndItems: (value: string, { render, onChange, onNodeChange }?: DndItemsOptions) => DndItems;
|
|
179
257
|
//#endregion
|
|
180
|
-
//#region src/components/dnd/panel/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
declare const
|
|
258
|
+
//#region src/components/dnd/panel/field-kind.d.ts
|
|
259
|
+
type FieldKind = 'readonly' | 'items' | 'children' | 'richtext' | 'jsx' | 'html' | 'object' | 'boolean' | 'select' | 'color' | 'date' | 'url' | 'number' | 'text';
|
|
260
|
+
type FieldKindBinding = Pick<PanelBinding, 'property' | 'type' | 'value' | 'options' | 'canEditValue'>;
|
|
261
|
+
declare const getFieldKind: (binding: FieldKindBinding) => FieldKind;
|
|
262
|
+
declare const isStructuralFieldKind: (kind: FieldKind) => kind is "items" | "children";
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/components/dnd/index.d.ts
|
|
265
|
+
type DndComponent = typeof Dnd$1 & {
|
|
266
|
+
DraggableItem: typeof DraggableItem;
|
|
267
|
+
Field: typeof Field;
|
|
268
|
+
Palette: typeof Palette;
|
|
269
|
+
Canvas: typeof Canvas;
|
|
270
|
+
Panel: typeof Panel;
|
|
271
|
+
Layout: typeof Layout;
|
|
272
|
+
};
|
|
273
|
+
declare const Dnd: DndComponent;
|
|
274
|
+
/** @deprecated Renamed to `useDndItems`. */
|
|
275
|
+
declare const useItemsEditor: (value: string, { render, onChange, onNodeChange }?: DndItemsOptions) => DndItems;
|
|
276
|
+
/** @deprecated Renamed to `useDndChildren`. */
|
|
277
|
+
declare const useChildrenEditor: (items: DataAttrNode[], { onChange }?: DndChildrenOptions) => {
|
|
185
278
|
items: DataAttrNode[];
|
|
186
279
|
selection: {
|
|
187
280
|
readonly selected: Set<number>;
|
|
@@ -199,18 +292,22 @@ declare const useChildrenEditor: (items: DataAttrNode[], { onChange }?: Children
|
|
|
199
292
|
removeSelected: () => void;
|
|
200
293
|
};
|
|
201
294
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
type
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
295
|
+
/** @deprecated Renamed to `DndItems`. */
|
|
296
|
+
type ItemsEditor = DndItems;
|
|
297
|
+
/** @deprecated Renamed to `DndItemsActions`. */
|
|
298
|
+
type ItemsEditorActions = DndItemsActions;
|
|
299
|
+
/** @deprecated Renamed to `DndItemsItem`. */
|
|
300
|
+
type ItemsEditorItem = DndItemsItem;
|
|
301
|
+
/** @deprecated Renamed to `DndItemsNestedElement`. */
|
|
302
|
+
type ItemsEditorNestedElement = DndItemsNestedElement;
|
|
303
|
+
/** @deprecated Renamed to `DndItemsNestedGroup`. */
|
|
304
|
+
type ItemsEditorNestedGroup = DndItemsNestedGroup;
|
|
305
|
+
/** @deprecated Renamed to `DndItemsOptions`. */
|
|
306
|
+
type ItemsEditorOptions = DndItemsOptions;
|
|
307
|
+
/** @deprecated Renamed to `DndChildren`. */
|
|
308
|
+
type ChildrenEditor = DndChildren;
|
|
309
|
+
/** @deprecated Renamed to `DndChildrenOptions`. */
|
|
310
|
+
type ChildrenEditorOptions = DndChildrenOptions;
|
|
214
311
|
//#endregion
|
|
215
|
-
export {
|
|
216
|
-
//# sourceMappingURL=index-
|
|
312
|
+
export { DndNodePick as $, useDndPanel as A, DndPalette as B, useDndItems as C, DndLayout as D, useDndChildren as E, Palette as F, PanelBinding as G, Props as H, Panel as I, PanelNodeChange as J, PanelBindingData as K, DraggableItem as L, DndLayoutProps as M, DndRegionProps as N, useDndLayout as O, Layout as P, DndInspector as Q, DraggableItemDragState as R, DndItemsOptions as S, DndChildrenOptions as T, DndRenderSectionFallback as U, DndPanel as V, DndSectionFallbackArgs as W, resolvePanelBindings as X, PanelNodesChange as Y, withPanelCommit as Z, DndItemsActions as _, ItemsEditorActions as a, DndItemsNestedElement as b, ItemsEditorNestedGroup as c, useItemsEditor as d, useDndInspector as et, FieldKind as f, DndItems as g, isStructuralFieldKind as h, ItemsEditor as i, FieldProps as it, Canvas as j, useDndPalette as k, ItemsEditorOptions as l, getFieldKind as m, ChildrenEditorOptions as n, DndRenderField as nt, ItemsEditorItem as o, FieldKindBinding as p, PanelBindingSource as q, Dnd as r, Field as rt, ItemsEditorNestedElement as s, ChildrenEditor as t, DndEditError as tt, useChildrenEditor as u, DndItemsExpansion as v, DndChildren as w, DndItemsNestedGroup as x, DndItemsItem as y, DraggableItemProps as z };
|
|
313
|
+
//# sourceMappingURL=index-CtlUYnWq.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,8 +1,8 @@
|
|
|
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 {
|
|
3
|
+
import { $ as DndNodePick, B as DndPalette, D as DndLayout, F as Palette, G as PanelBinding, H as Props, I as Panel, J as PanelNodeChange, P as Layout, Q as DndInspector, S as DndItemsOptions, U as DndRenderSectionFallback, V as DndPanel, W as DndSectionFallbackArgs, Y as PanelNodesChange, g as DndItems, i as ItemsEditor, it as FieldProps, j as Canvas, l as ItemsEditorOptions, nt as DndRenderField, o as ItemsEditorItem, r as Dnd, tt as DndEditError, y as DndItemsItem, z as DraggableItemProps } from "./index-CtlUYnWq.js";
|
|
4
4
|
import { a as Props$2, n as EditorRenderData, r as Props$1, t as Editor } from "./index-13BDSrQc.js";
|
|
5
|
-
import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-
|
|
5
|
+
import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-C4SGQ3Ci.js";
|
|
6
6
|
import { n as Preview, r as Props$6 } from "./index-DQkL37eL.js";
|
|
7
7
|
//#region src/index.d.ts
|
|
8
8
|
declare const App: {
|
|
@@ -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: _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, onNodePick, 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 DndInspector, type DndItems, type DndItemsItem, type DndItemsOptions, type DndLayout, type DndNodePick, 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-Z1KS16Fy.js";
|
|
3
|
+
import { t as Editor } from "./editor-DvMruljw.js";
|
|
4
|
+
import { t as Error } from "./error-DWhxQEom.js";
|
|
5
|
+
import { t as Preview } from "./preview-C_UzpGWh.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 DndInspector,\n type DndItems,\n type DndItemsItem,\n type DndItemsOptions,\n type DndLayout,\n type DndNodePick,\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 DndInspector,\n DndNodePick,\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":";;;;;;;AA8BA,MAAM,OAAO,EAAE,eAA+C;CAC5D,OAAO,oBAACA,iBAAD,EAAU,SAAkB,CAAA;AACrC;AAEA,MAAM,eAAeC;AAsCrB,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-DpbjmATF.js";
|
|
2
|
+
import { t as Preview } from "../preview-C_UzpGWh.js";
|
|
3
3
|
export { baseModules, Preview as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
2
2
|
import { t as cn } from "./cn-CAnad2vL.js";
|
|
3
|
-
import { a as Frame, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-
|
|
4
|
-
import { t as Error } from "./error-
|
|
3
|
+
import { a as Frame, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-DpbjmATF.js";
|
|
4
|
+
import { t as Error } from "./error-DWhxQEom.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-C_UzpGWh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-
|
|
1
|
+
{"version":3,"file":"preview-C_UzpGWh.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"}
|
package/dist/provider/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ContextProvider } from "../context-
|
|
1
|
+
import { t as ContextProvider } from "../context-93X3gyfJ.js";
|
|
2
2
|
export { ContextProvider as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { a as generateSectionPreview, l as parseDocument, o as generateSectionPreviews, s as getSections, u as replaceDocumentSections } from "./document-cEEdFERz.js";
|
|
2
|
+
import { i as DEFAULT_CONTAINER_ID, u as documentTemplate } from "./constants-CKvdqZtO.js";
|
|
3
|
+
//#region src/utils/sections.ts
|
|
4
|
+
const extractSections = (code, options) => {
|
|
5
|
+
const doc = parseDocument(code, options);
|
|
6
|
+
return doc ? getSections(doc, options) : [];
|
|
7
|
+
};
|
|
8
|
+
const replaceSections = (code, sections, options) => {
|
|
9
|
+
return replaceDocumentSections(code, sections, options);
|
|
10
|
+
};
|
|
11
|
+
const generateSection = (code, fullCode, options) => {
|
|
12
|
+
return generateSectionPreview(fullCode, code, options);
|
|
13
|
+
};
|
|
14
|
+
const generateSections = (codes, fullCode, options) => {
|
|
15
|
+
return generateSectionPreviews(fullCode, codes, options);
|
|
16
|
+
};
|
|
17
|
+
const createDocument = ({ containerId = DEFAULT_CONTAINER_ID } = {}) => {
|
|
18
|
+
if (!/^[^\s"'<>{}]+$/.test(containerId)) throw new Error(`createDocument: containerId must be a plain element id, got ${JSON.stringify(containerId)}`);
|
|
19
|
+
return documentTemplate(containerId);
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { replaceSections as a, generateSections as i, extractSections as n, generateSection as r, createDocument as t };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=sections-GJQ63uEB.js.map
|