@jbpark/live-editor 4.3.1 → 4.5.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.
Files changed (69) hide show
  1. package/README.md +2 -2
  2. package/dist/{boundary-B17cepvm.js → boundary-DnjGgsK6.js} +8 -5
  3. package/dist/boundary-DnjGgsK6.js.map +1 -0
  4. package/dist/{compile-0Dvp8zp5.js → compile-DDfk5P25.js} +3 -3
  5. package/dist/{compile-0Dvp8zp5.js.map → compile-DDfk5P25.js.map} +1 -1
  6. package/dist/{constants-CKvdqZtO.js → constants-h1JAgOeW.js} +4 -2
  7. package/dist/constants-h1JAgOeW.js.map +1 -0
  8. package/dist/{context-93X3gyfJ.js → context-DsEXJl4h.js} +11 -5
  9. package/dist/context-DsEXJl4h.js.map +1 -0
  10. package/dist/{core-B3ruccKb.js → core-CRsAGpei.js} +2 -2
  11. package/dist/{core-B3ruccKb.js.map → core-CRsAGpei.js.map} +1 -1
  12. package/dist/{detect-typescript-5MV4mCM7.js → detect-typescript-CCj9ALXc.js} +2 -2
  13. package/dist/{detect-typescript-5MV4mCM7.js.map → detect-typescript-CCj9ALXc.js.map} +1 -1
  14. package/dist/dnd/index.d.ts +2 -2
  15. package/dist/dnd/index.js +1 -1
  16. package/dist/{dnd-x8Mvj--6.js → dnd-DGNp20Nk.js} +496 -307
  17. package/dist/dnd-DGNp20Nk.js.map +1 -0
  18. package/dist/{document-C-hGKMkk.js → document-DGHTfrda.js} +7739 -7736
  19. package/dist/document-DGHTfrda.js.map +1 -0
  20. package/dist/editor/index.js +2 -2
  21. package/dist/{editor-DvMruljw.js → editor-DQ8Q--qR.js} +2 -2
  22. package/dist/{editor-DvMruljw.js.map → editor-DQ8Q--qR.js.map} +1 -1
  23. package/dist/error/index.d.ts +1 -1
  24. package/dist/error/index.js +2 -2
  25. package/dist/{error-DWhxQEom.js → error-DwqwjJ2C.js} +13 -6
  26. package/dist/error-DwqwjJ2C.js.map +1 -0
  27. package/dist/index-CHknA6k1.d.ts +221 -0
  28. package/dist/{index-CtlUYnWq.d.ts → index-P9Aifaui.d.ts} +14 -4
  29. package/dist/index-WQgFy510.d.ts +11 -0
  30. package/dist/{index-C4SGQ3Ci.d.ts → index-vtyggWy0.d.ts} +4 -1
  31. package/dist/index.d.ts +18 -17
  32. package/dist/index.js +12 -8
  33. package/dist/index.js.map +1 -1
  34. package/dist/{ast-CehbCXwh.js → items-DdrwGxJw.js} +467 -426
  35. package/dist/items-DdrwGxJw.js.map +1 -0
  36. package/dist/messages-Cp3g1mn1.d.ts +129 -0
  37. package/dist/messages-CzUPVnzH.js +132 -0
  38. package/dist/messages-CzUPVnzH.js.map +1 -0
  39. package/dist/preview/index.js +2 -2
  40. package/dist/{preview-BYck9mVK.js → preview-BKFgq_5u.js} +6 -4
  41. package/dist/preview-BKFgq_5u.js.map +1 -0
  42. package/dist/provider/index.d.ts +3 -8
  43. package/dist/provider/index.js +3 -2
  44. package/dist/{sections-Ce63wbtG.js → sections-BRH3KHYc.js} +9 -4
  45. package/dist/sections-BRH3KHYc.js.map +1 -0
  46. package/dist/style.css +505 -21
  47. package/dist/{use-dynamic-tailwind-QKcGvUJs.js → use-dynamic-tailwind-T9r9ExbR.js} +21 -4
  48. package/dist/use-dynamic-tailwind-T9r9ExbR.js.map +1 -0
  49. package/dist/utils/ast/index.d.ts +3 -2
  50. package/dist/utils/ast/index.js +66 -3
  51. package/dist/utils/ast/index.js.map +1 -0
  52. package/dist/utils/index.d.ts +30 -13
  53. package/dist/utils/index.js +26 -6
  54. package/dist/utils/index.js.map +1 -0
  55. package/dist/validate-DB59Z_Nx.d.ts +100 -0
  56. package/dist/validate-iLo8IONY.js +64 -0
  57. package/dist/validate-iLo8IONY.js.map +1 -0
  58. package/package.json +3 -3
  59. package/dist/ast-CehbCXwh.js.map +0 -1
  60. package/dist/boundary-B17cepvm.js.map +0 -1
  61. package/dist/constants-CKvdqZtO.js.map +0 -1
  62. package/dist/context-93X3gyfJ.js.map +0 -1
  63. package/dist/dnd-x8Mvj--6.js.map +0 -1
  64. package/dist/document-C-hGKMkk.js.map +0 -1
  65. package/dist/error-DWhxQEom.js.map +0 -1
  66. package/dist/index-w3kLcCXl.d.ts +0 -255
  67. package/dist/preview-BYck9mVK.js.map +0 -1
  68. package/dist/sections-Ce63wbtG.js.map +0 -1
  69. package/dist/use-dynamic-tailwind-QKcGvUJs.js.map +0 -1
@@ -1,3 +1,3 @@
1
- import { t as Core } from "../core-B3ruccKb.js";
2
- import { t as Editor } from "../editor-DvMruljw.js";
1
+ import { t as Core } from "../core-CRsAGpei.js";
2
+ import { t as Editor } from "../editor-DQ8Q--qR.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-B3ruccKb.js";
2
+ import { n as useFormatCode, t as Core } from "./core-CRsAGpei.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-DvMruljw.js.map
66
+ //# sourceMappingURL=editor-DQ8Q--qR.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"editor-DQ8Q--qR.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"}
@@ -1,2 +1,2 @@
1
- import { i as Guard, o as Props, r as Runtime, s as ErrorBoundary, t as Error } from "../index-C4SGQ3Ci.js";
1
+ import { i as Guard, o as Props, r as Runtime, s as ErrorBoundary, t as Error } from "../index-vtyggWy0.js";
2
2
  export { ErrorBoundary, Guard as ErrorGuard, Runtime as ErrorRuntime, type Props, Error as default };
@@ -1,3 +1,3 @@
1
- import { t as ErrorBoundary } from "../boundary-B17cepvm.js";
2
- import { n as Runtime, r as Guard, t as Error } from "../error-DWhxQEom.js";
1
+ import { t as ErrorBoundary } from "../boundary-DnjGgsK6.js";
2
+ import { n as Runtime, r as Guard, t as Error } from "../error-DwqwjJ2C.js";
3
3
  export { ErrorBoundary, Guard as ErrorGuard, Runtime as ErrorRuntime, Error as default };
@@ -1,17 +1,23 @@
1
+ import { i as useLiveMessages } from "./messages-CzUPVnzH.js";
1
2
  import { r as useError } from "./states-Ci1AvoQ9.js";
2
- import { n as Error$1, t as ErrorBoundary } from "./boundary-B17cepvm.js";
3
+ import { n as Error$1, t as ErrorBoundary } from "./boundary-DnjGgsK6.js";
3
4
  import { useEffect, useRef, useState } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  import { useEventListener } from "@jbpark/use-hooks";
6
7
  //#region src/components/error/guard.tsx
7
8
  const Guard = ({ children, onError }) => {
8
9
  const [error, setError] = useState(null);
10
+ const messages = useLiveMessages();
9
11
  const containerRef = useRef(null);
10
12
  const errorHandled = useRef(false);
13
+ const messagesRef = useRef(messages);
14
+ useEffect(() => {
15
+ messagesRef.current = messages;
16
+ });
11
17
  useEventListener("error", (event) => {
12
18
  if (errorHandled.current) return;
13
19
  errorHandled.current = true;
14
- const errorMessage = event.error?.message || event.message || "Unknown error";
20
+ const errorMessage = event.error?.message || event.message || messagesRef.current.errors.unknown;
15
21
  console.error("⚡ [Guard] Event handler error:", errorMessage);
16
22
  event.preventDefault();
17
23
  setError(errorMessage);
@@ -25,7 +31,7 @@ const Guard = ({ children, onError }) => {
25
31
  const handleUnhandledRejection = (event) => {
26
32
  if (errorHandled.current) return;
27
33
  errorHandled.current = true;
28
- const errorMessage = event.reason?.message || "Promise rejection";
34
+ const errorMessage = event.reason?.message || messagesRef.current.errors.unhandledRejection;
29
35
  event.preventDefault();
30
36
  setError(errorMessage);
31
37
  onError?.(event.reason || new window.Error(errorMessage));
@@ -39,7 +45,7 @@ const Guard = ({ children, onError }) => {
39
45
  };
40
46
  }, [onError]);
41
47
  if (error) return /* @__PURE__ */ jsx(Error$1, {
42
- title: "Runtime Error",
48
+ title: messages.errors.runtime,
43
49
  message: error,
44
50
  className: "m-4",
45
51
  onReset: () => {
@@ -56,6 +62,7 @@ const Guard = ({ children, onError }) => {
56
62
  //#region src/components/error/runtime.tsx
57
63
  const Runtime = ({ open = true, reset }) => {
58
64
  const { error: message, setError } = useError();
65
+ const messages = useLiveMessages();
59
66
  useEventListener("error", (e) => {
60
67
  setError(e.message);
61
68
  e.preventDefault();
@@ -67,7 +74,7 @@ const Runtime = ({ open = true, reset }) => {
67
74
  return /* @__PURE__ */ jsx(Error$1, {
68
75
  message,
69
76
  onReset: reset,
70
- title: "Runtime Error"
77
+ title: messages.errors.runtime
71
78
  });
72
79
  };
73
80
  //#endregion
@@ -79,4 +86,4 @@ Error.Guard = Guard;
79
86
  //#endregion
80
87
  export { Runtime as n, Guard as r, Error as t };
81
88
 
82
- //# sourceMappingURL=error-DWhxQEom.js.map
89
+ //# sourceMappingURL=error-DwqwjJ2C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-DwqwjJ2C.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 { useLiveMessages } from '~/components/context/messages';\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 const messages = useLiveMessages();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const errorHandled = useRef(false);\n // Read by the listeners, so new messages don't subscribe them again.\n const messagesRef = useRef(messages);\n\n useEffect(() => {\n messagesRef.current = messages;\n });\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 ||\n event.message ||\n messagesRef.current.errors.unknown;\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 =\n event.reason?.message || messagesRef.current.errors.unhandledRejection;\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={messages.errors.runtime}\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 { useLiveMessages } from '~/components/context/messages';\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 const messages = useLiveMessages();\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 (\n <Error message={message} onReset={reset} title={messages.errors.runtime} />\n );\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":";;;;;;;AAaA,MAAM,SAAS,EAAE,UAAU,cAAqB;CAC9C,MAAM,CAAC,OAAO,YAAY,SAAwB,IAAI;CACtD,MAAM,WAAW,gBAAgB;CAEjC,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,eAAe,OAAO,KAAK;CAEjC,MAAM,cAAc,OAAO,QAAQ;CAEnC,gBAAgB;EACd,YAAY,UAAU;CACxB,CAAC;CAED,iBACE,UACA,UAAS;EACP,IAAI,aAAa,SACf;EAGF,aAAa,UAAU;EAEvB,MAAM,eACJ,MAAM,OAAO,WACb,MAAM,WACN,YAAY,QAAQ,OAAO;EAE7B,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,eACJ,MAAM,QAAQ,WAAW,YAAY,QAAQ,OAAO;GAEtD,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,OAAO,SAAS,OAAO;EACvB,SAAS;EACT,WAAU;EACV,eAAe;GACb,SAAS,IAAI;GACb,aAAa,UAAU;EACzB;CACD,CAAA;CAIL,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAe;CAAc,CAAA;AAChD;;;AChGA,MAAM,WAAW,EAAE,OAAO,MAAM,YAAmB;CACjD,MAAM,EAAE,OAAO,SAAS,aAAa,SAAS;CAC9C,MAAM,WAAW,gBAAgB;CAEjC,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,OACE,oBAACC,SAAD;EAAgB;EAAS,SAAS;EAAO,OAAO,SAAS,OAAO;CAAU,CAAA;AAE9E;;;ACvBA,MAAM,QAAQC;AAEd,MAAM,WAAW;AACjB,MAAM,UAAUC;AAChB,MAAM,QAAQC"}
@@ -0,0 +1,221 @@
1
+ import { b as ExtractedNodeValue$1, c as BindingItem, d as BindingOptions, f as BindingRegistry, g as BindingType, l as BindingKeyMap, m as BindingRenderMap, v as DataAttrNode, x as NodeValueType$1, y as EditableNodeValueType$1 } from "./validate-DB59Z_Nx.js";
2
+ import { C as ObjectExpression, S as Node, b as Expression, x as File, y as ArrayExpression } from "./document-Ct4jW78J.js";
3
+ //#region node_modules/.pnpm/@babel+parser@7.29.9/node_modules/@babel/parser/typings/babel-parser.d.ts
4
+ declare class Position {
5
+ line: number;
6
+ column: number;
7
+ index: number;
8
+ constructor(line: number, col: number, index: number);
9
+ }
10
+ type SyntaxPlugin = "flow" | "typescript" | "jsx" | "functionBind" | "pipelineOperator" | "placeholders";
11
+ type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
12
+ interface ParseErrorSpecification<ErrorDetails> {
13
+ code: ParseErrorCode;
14
+ reasonCode: string;
15
+ syntaxPlugin?: SyntaxPlugin;
16
+ missingPlugin?: string | string[];
17
+ loc: Position;
18
+ details: ErrorDetails;
19
+ pos: number;
20
+ }
21
+ type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>;
22
+ type ParseError = ParseError$1<object>;
23
+ type ParseResult<Result extends File | Expression = File> = Result & {
24
+ comments: File["comments"];
25
+ errors: null | ParseError[];
26
+ tokens?: File["tokens"];
27
+ };
28
+ //#endregion
29
+ //#region src/utils/ast/extract.d.ts
30
+ declare function extract(raw: string, options?: BindingOptions): DataAttrNode[];
31
+ declare function clearExtractCache$1(): void;
32
+ //#endregion
33
+ //#region src/utils/ast/items.d.ts
34
+ type ItemKind$1 = 'object' | 'primitive';
35
+ interface ArrayItem$1 {
36
+ index: number;
37
+ kind: ItemKind$1;
38
+ node: Expression;
39
+ }
40
+ //#endregion
41
+ //#region src/utils/ast/binding.d.ts
42
+ declare const findEditableChildren: (node: DataAttrNode) => DataAttrNode[];
43
+ //#endregion
44
+ //#region src/utils/ast/value.d.ts
45
+ declare const parseValue: (value: unknown) => unknown;
46
+ type EditablePathSegment = string | number;
47
+ type EditablePrimitive = string | number | boolean;
48
+ interface EditableValueEntry {
49
+ path: EditablePathSegment[];
50
+ value: EditablePrimitive;
51
+ }
52
+ declare const flattenEditableValue: (value: string) => EditableValueEntry[] | null;
53
+ declare const setEditableValue: (value: string, path: EditablePathSegment[], next: EditablePrimitive) => string;
54
+ //#endregion
55
+ //#region src/utils/ast/update.d.ts
56
+ type UpdateFailure = {
57
+ reason: 'element-not-found';
58
+ dataId: string;
59
+ } | {
60
+ reason: 'no-binding';
61
+ dataId: string;
62
+ } | {
63
+ reason: 'reserved-property';
64
+ dataId: string;
65
+ property: string;
66
+ } | {
67
+ reason: 'required-property';
68
+ dataId: string;
69
+ property: string;
70
+ } | {
71
+ reason: 'binding-not-declared';
72
+ dataId: string;
73
+ label: string;
74
+ property?: string;
75
+ } | {
76
+ reason: 'duplicate-binding';
77
+ dataId: string;
78
+ label: string;
79
+ property?: string;
80
+ count: number;
81
+ } | {
82
+ reason: 'attribute-not-found';
83
+ dataId: string;
84
+ property: string;
85
+ } | {
86
+ reason: 'unsupported-syntax';
87
+ dataId: string;
88
+ property: string;
89
+ } | {
90
+ reason: 'parse-error';
91
+ error: unknown;
92
+ };
93
+ interface UpdateResult {
94
+ code: string;
95
+ success: boolean;
96
+ failure?: UpdateFailure;
97
+ failures?: UpdateFailure[];
98
+ }
99
+ declare const update: (code: string, dataId: string, label: string, value: unknown, property?: string, options?: BindingOptions) => UpdateResult;
100
+ interface UpdateEntry {
101
+ dataId: string;
102
+ label: string;
103
+ value: unknown;
104
+ property?: string;
105
+ }
106
+ type UpdateAllResult = {
107
+ success: true;
108
+ code: string;
109
+ } | {
110
+ success: false;
111
+ code: string;
112
+ failure: UpdateFailure;
113
+ index: number;
114
+ };
115
+ declare const updateAll: (raw: string, entries: UpdateEntry[], options?: BindingOptions) => UpdateAllResult;
116
+ /**
117
+ * @deprecated Not atomic: when an entry fails, the ones before and after it
118
+ * are still applied, and the returned `code` carries them. Use `updateAll`,
119
+ * which applies every entry or none. Will be removed in the next major.
120
+ */
121
+ declare const bulkUpdate: (raw: string, entries: UpdateEntry[]) => UpdateResult;
122
+ //#endregion
123
+ //#region src/utils/ast/children.d.ts
124
+ type ChildrenAction = {
125
+ type: 'move';
126
+ from: number;
127
+ to: number;
128
+ } | {
129
+ type: 'move-selected';
130
+ indices: number[];
131
+ direction: 'up' | 'down';
132
+ } | {
133
+ type: 'remove' | 'duplicate';
134
+ indices: number[];
135
+ } | {
136
+ type: 'append';
137
+ };
138
+ interface ChildrenEdit {
139
+ kind: 'children-edit';
140
+ expected: string[];
141
+ action: ChildrenAction;
142
+ }
143
+ declare const getChildrenSignatures: (nodes: DataAttrNode[]) => string[];
144
+ //#endregion
145
+ //#region src/utils/ast/index.d.ts
146
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
147
+ declare const appendArrayItem: (code: string, kind: ItemKind$1, generateId?: () => string) => string | null;
148
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
149
+ declare const duplicateArrayItems: (code: string, indices: Set<number>, generateId?: () => string) => string | null;
150
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
151
+ declare const moveArrayItem: (code: string, from: number, to: number) => string | null;
152
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
153
+ declare const moveArrayItems: (code: string, indices: Set<number>, direction: "up" | "down") => {
154
+ code: string;
155
+ indices: Set<number>;
156
+ } | null;
157
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
158
+ declare const parseItems: (code: string) => ArrayItem$1[] | null;
159
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
160
+ declare const removeArrayItems: (code: string, indices: Set<number>, kind?: ItemKind$1) => string | null;
161
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
162
+ declare const updateArrayItemProperty: (code: string, index: number, key: string, value: unknown, render?: BindingRenderMap) => string | null;
163
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
164
+ declare const updateArrayItemValue: (code: string, index: number, value: unknown) => string | null;
165
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
166
+ declare const parseArrayExpression: (value: string) => ArrayExpression | null;
167
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
168
+ declare const arrayExpressionToCode: (elements: ObjectExpression[]) => string;
169
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
170
+ declare const canStructurallyEditArray: (source: string) => boolean;
171
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
172
+ type ArrayItem = ArrayItem$1;
173
+ /** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */
174
+ type ItemKind = ItemKind$1;
175
+ /** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */
176
+ declare const extractNodeValue: (node: Node) => ExtractedNodeValue$1;
177
+ /** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */
178
+ declare const extractObjectProperties: (element: ObjectExpression) => Record<string, ExtractedNodeValue$1 & {
179
+ astNode: Node;
180
+ }>;
181
+ /** @deprecated Internal. Write values through `update` or `PanelBinding.onChange`. Removed in the next major. */
182
+ declare const createNodeFromValue: (type: NodeValueType$1, value: unknown) => Expression | null;
183
+ /** @deprecated Internal. Check `PanelBinding.canEditValue` instead. Removed in the next major. */
184
+ declare const canLosslesslyEvaluateSource: (source: string) => boolean;
185
+ /** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */
186
+ declare const getCurrentValue: (node: DataAttrNode, property: string) => string;
187
+ /** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */
188
+ declare const getStructuredValue: (node: DataAttrNode, property: string, type?: BindingType) => unknown;
189
+ /** @deprecated Internal. Removed in the next major. */
190
+ type ExtractedNodeValue = ExtractedNodeValue$1;
191
+ /** @deprecated Internal. Removed in the next major. */
192
+ type NodeValueType = NodeValueType$1;
193
+ /** @deprecated Internal. Removed in the next major. */
194
+ type EditableNodeValueType = EditableNodeValueType$1;
195
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
196
+ declare const parseBinding: (bindingValue: string | null) => BindingItem[];
197
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
198
+ declare const parseBindingExpression: (expression: ArrayExpression) => BindingItem[];
199
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
200
+ declare const readNodeBindings: (node: DataAttrNode) => BindingItem[];
201
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
202
+ declare const resolveBindings: (own: BindingItem[] | undefined, key: string | null | undefined, tagName: string, options?: BindingOptions) => BindingItem[];
203
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
204
+ declare const getKeyBindings: (bindingKeys: BindingKeyMap | undefined, key: string) => BindingItem[] | undefined;
205
+ /** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */
206
+ declare const getRegistryBindings: (registry: BindingRegistry | undefined, tagName: string) => BindingItem[] | undefined;
207
+ /** @deprecated Internal. Removed in the next major. */
208
+ declare const isComponentTagName: (tagName: string) => boolean;
209
+ /** @deprecated Internal. Removed in the next major. */
210
+ declare const fillIds: (code: string, generateId?: () => string) => string;
211
+ /** @deprecated Internal. Removed in the next major. */
212
+ declare const replaceIds: (code: string, generateId?: () => string) => string;
213
+ /** @deprecated Internal. Removed in the next major. */
214
+ declare const clone: (element: Node, generateId?: () => string) => ParseResult<Expression>;
215
+ /** @deprecated Internal. Removed in the next major. */
216
+ declare const generateCode: (node: Node) => string;
217
+ /** @deprecated Internal. Use `clearEditorCaches` from `./utils`. Removed in the next major. */
218
+ declare const clearExtractCache: typeof clearExtractCache$1;
219
+ //#endregion
220
+ export { removeArrayItems as A, UpdateFailure as B, moveArrayItem as C, parseBindingExpression as D, parseBinding as E, ChildrenAction as F, EditablePathSegment as G, bulkUpdate as H, ChildrenEdit as I, flattenEditableValue as J, EditablePrimitive as K, getChildrenSignatures as L, resolveBindings as M, updateArrayItemProperty as N, parseItems as O, updateArrayItemValue as P, extract as Q, UpdateAllResult as R, isComponentTagName as S, parseArrayExpression as T, update as U, UpdateResult as V, updateAll as W, setEditableValue as X, parseValue as Y, findEditableChildren as Z, generateCode as _, NodeValueType as a, getRegistryBindings as b, canLosslesslyEvaluateSource as c, clone as d, createNodeFromValue as f, fillIds as g, extractObjectProperties as h, ItemKind as i, replaceIds as j, readNodeBindings as k, canStructurallyEditArray as l, extractNodeValue as m, EditableNodeValueType as n, appendArrayItem as o, duplicateArrayItems as p, EditableValueEntry as q, ExtractedNodeValue as r, arrayExpressionToCode as s, ArrayItem as t, clearExtractCache as u, getCurrentValue as v, moveArrayItems as w, getStructuredValue as x, getKeyBindings as y, UpdateEntry as z };
221
+ //# sourceMappingURL=index-CHknA6k1.d.ts.map
@@ -1,5 +1,6 @@
1
- import { $ as BindingWidget, Q as BindingType, Y as BindingOption, Z as BindingRenderMap, et as DataAttrNode, f as UpdateFailure } from "./index-w3kLcCXl.js";
1
+ import { _ as BindingWidget, d as BindingOptions, f as BindingRegistry, g as BindingType, l as BindingKeyMap, m as BindingRenderMap, u as BindingOption, v as DataAttrNode } from "./validate-DB59Z_Nx.js";
2
2
  import { v as Section } from "./document-Ct4jW78J.js";
3
+ import { B as UpdateFailure } from "./index-CHknA6k1.js";
3
4
  import { t as FrameProps } from "./index-DpDU1IAw.js";
4
5
  import { useMultiSelect } from "@jbpark/use-hooks";
5
6
  //#region src/components/dnd/panel/field.d.ts
@@ -56,6 +57,7 @@ interface DndInspector {
56
57
  deactivate: () => void;
57
58
  toggle: () => void;
58
59
  picked: DndNodePick | null;
60
+ highlight: (id: string | null) => void;
59
61
  }
60
62
  declare const useDndInspector: () => DndInspector;
61
63
  //#endregion
@@ -88,8 +90,13 @@ interface PanelBinding {
88
90
  rawValue: string;
89
91
  canEditValue?: boolean;
90
92
  present?: boolean;
93
+ element?: PanelBindingElement;
91
94
  onChange: (value: unknown) => void;
92
95
  }
96
+ interface PanelBindingElement {
97
+ tagName: string;
98
+ text: string;
99
+ }
93
100
  type PanelBindingData = Omit<PanelBinding, 'onChange'>;
94
101
  interface PanelBindingSource {
95
102
  id: string;
@@ -124,6 +131,7 @@ interface DndPanel {
124
131
  onNodeChange: PanelNodeChange;
125
132
  onNodesChange: PanelNodesChange;
126
133
  readOnly: boolean;
134
+ bindingOptions: BindingOptions;
127
135
  }
128
136
  interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
129
137
  value?: string;
@@ -141,10 +149,12 @@ interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
141
149
  onBeforeDelete?: (section: Section) => boolean | Promise<boolean>;
142
150
  sectionNameFallback?: (index: number) => string;
143
151
  containerId?: string;
152
+ bindings?: BindingRegistry;
153
+ bindingKeys?: BindingKeyMap;
144
154
  onNodePick?: (pick: DndNodePick) => void;
145
155
  children?: React.ReactNode;
146
156
  }
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;
157
+ declare const Dnd$1: ({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, bindings: bindingRegistry, bindingKeys, onNodePick, children, ...restProps }: Props) => import("react").JSX.Element;
148
158
  //#endregion
149
159
  //#region src/components/dnd/draggable.d.ts
150
160
  interface DraggableItemDragState {
@@ -309,5 +319,5 @@ type ChildrenEditor = DndChildren;
309
319
  /** @deprecated Renamed to `DndChildrenOptions`. */
310
320
  type ChildrenEditorOptions = DndChildrenOptions;
311
321
  //#endregion
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
322
+ export { DndInspector 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, PanelBindingSource as J, PanelBindingData as K, DraggableItem as L, DndLayoutProps as M, DndRegionProps as N, useDndLayout as O, Layout as P, withPanelCommit as Q, DraggableItemDragState as R, DndItemsOptions as S, DndChildrenOptions as T, DndRenderSectionFallback as U, DndPanel as V, DndSectionFallbackArgs as W, PanelNodesChange as X, PanelNodeChange as Y, resolvePanelBindings as Z, DndItemsActions as _, ItemsEditorActions as a, FieldProps as at, DndItemsNestedElement as b, ItemsEditorNestedGroup as c, useItemsEditor as d, DndNodePick as et, FieldKind as f, DndItems as g, isStructuralFieldKind as h, ItemsEditor as i, Field as it, Canvas as j, useDndPalette as k, ItemsEditorOptions as l, getFieldKind as m, ChildrenEditorOptions as n, DndEditError as nt, ItemsEditorItem as o, FieldKindBinding as p, PanelBindingElement as q, Dnd as r, DndRenderField as rt, ItemsEditorNestedElement as s, ChildrenEditor as t, useDndInspector as tt, useChildrenEditor as u, DndItemsExpansion as v, DndChildren as w, DndItemsNestedGroup as x, DndItemsItem as y, DraggableItemProps as z };
323
+ //# sourceMappingURL=index-P9Aifaui.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { n as LiveMessagesInput } from "./messages-Cp3g1mn1.js";
2
+ import React from "react";
3
+ //#region src/components/context/context.d.ts
4
+ interface Props {
5
+ children?: React.ReactNode;
6
+ messages?: LiveMessagesInput;
7
+ }
8
+ declare const ContextProvider: ({ children, messages }: Props) => React.JSX.Element;
9
+ //#endregion
10
+ export { Props as n, ContextProvider as t };
11
+ //# sourceMappingURL=index-WQgFy510.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { t as LiveMessages } from "./messages-Cp3g1mn1.js";
1
2
  import React$1 from "react";
2
3
  //#region src/components/error/boundary.d.ts
3
4
  interface Props$3 {
@@ -12,6 +13,8 @@ interface State {
12
13
  resetKeys?: readonly unknown[];
13
14
  }
14
15
  declare class ErrorBoundary extends React$1.Component<Props$3, State> {
16
+ static contextType: React$1.Context<LiveMessages>;
17
+ context: LiveMessages;
15
18
  constructor(props: Props$3);
16
19
  static getDerivedStateFromError(error: Error): Partial<State>;
17
20
  componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
@@ -51,4 +54,4 @@ type ErrorComponent = typeof Error$2 & {
51
54
  declare const Error$1: ErrorComponent;
52
55
  //#endregion
53
56
  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 };
54
- //# sourceMappingURL=index-C4SGQ3Ci.d.ts.map
57
+ //# sourceMappingURL=index-vtyggWy0.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,25 +1,26 @@
1
+ import { d as BindingOptions, f as BindingRegistry, h as BindingSchema, l as BindingKeyMap } from "./validate-DB59Z_Nx.js";
2
+ import { i as useLiveMessages, n as LiveMessagesInput, r as defaultMessages, t as LiveMessages } from "./messages-Cp3g1mn1.js";
3
+ import { n as Props } from "./index-WQgFy510.js";
1
4
  import { v as Section } from "./document-Ct4jW78J.js";
2
5
  import { t as FrameProps } from "./index-DpDU1IAw.js";
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
- 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-C4SGQ3Ci.js";
6
- import { n as Preview, r as Props$6 } from "./index-DQkL37eL.js";
6
+ import { $ as DndInspector, B as DndPalette, D as DndLayout, F as Palette, G as PanelBinding, H as Props$1, I as Panel, P as Layout, S as DndItemsOptions, U as DndRenderSectionFallback, V as DndPanel, W as DndSectionFallbackArgs, X as PanelNodesChange, Y as PanelNodeChange, at as FieldProps, et as DndNodePick, g as DndItems, i as ItemsEditor, j as Canvas, l as ItemsEditorOptions, nt as DndEditError, o as ItemsEditorItem, r as Dnd, rt as DndRenderField, y as DndItemsItem, z as DraggableItemProps } from "./index-P9Aifaui.js";
7
+ import { a as Props$3, n as EditorRenderData, r as Props$2, t as Editor } from "./index-13BDSrQc.js";
8
+ import { a as Props$6, n as Props$5, o as Props$4, s as ErrorBoundary, t as Error } from "./index-vtyggWy0.js";
9
+ import { n as Preview, r as Props$7 } from "./index-DQkL37eL.js";
7
10
  //#region src/index.d.ts
8
11
  declare const App: {
9
- ({ children }: {
10
- children?: React.ReactNode;
11
- }): import("react").JSX.Element;
12
- Preview: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$6) => import("react").JSX.Element;
13
- Renderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$6) => import("react").JSX.Element;
14
- Error: (({ message, title, className, onReset }: Props$3) => import("react").JSX.Element | null) & {
12
+ ({ children, messages }: Props): import("react").JSX.Element;
13
+ Preview: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$7) => import("react").JSX.Element;
14
+ Renderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$7) => import("react").JSX.Element;
15
+ Error: (({ message, title, className, onReset }: Props$4) => import("react").JSX.Element | null) & {
15
16
  Boundary: typeof ErrorBoundary;
16
- Runtime: ({ open, reset }: Props$4) => import("react").JSX.Element | null;
17
- Guard: ({ children, onError }: Props$5) => import("react").JSX.Element;
17
+ Runtime: ({ open, reset }: Props$5) => import("react").JSX.Element | null;
18
+ Guard: ({ children, onError }: Props$6) => import("react").JSX.Element;
18
19
  };
19
- Editor: (({ defaultValue, value: _value, debounce, onChange: _onChange, renderEditor, fragment, prettierOptions, ...props }: Props$1) => import("react").JSX.Element) & {
20
- Core: ({ value, theme, height, className, prettierOptions, fragment, raw, onChange, onSave, onError, ...props }: Props$2) => import("react").JSX.Element;
20
+ Editor: (({ defaultValue, value: _value, debounce, onChange: _onChange, renderEditor, fragment, prettierOptions, ...props }: Props$2) => import("react").JSX.Element) & {
21
+ Core: ({ value, theme, height, className, prettierOptions, fragment, raw, onChange, onSave, onError, ...props }: Props$3) => import("react").JSX.Element;
21
22
  };
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
+ Dnd: (({ value: _value, props, modules: _modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, bindings: bindingRegistry, bindingKeys, onNodePick, children, ...restProps }: Props$1) => import("react").JSX.Element) & {
23
24
  DraggableItem: ({ item, children }: DraggableItemProps) => import("react").ReactNode;
24
25
  Field: (props: FieldProps) => import("react").JSX.Element;
25
26
  Palette: typeof Palette;
@@ -28,7 +29,7 @@ declare const App: {
28
29
  Layout: typeof Layout;
29
30
  };
30
31
  };
31
- declare const LiveRenderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$6) => import("react").JSX.Element;
32
+ declare const LiveRenderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$7) => import("react").JSX.Element;
32
33
  //#endregion
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
+ export { type BindingKeyMap, type BindingOptions, type BindingRegistry, type BindingSchema, 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, type LiveMessages, type LiveMessagesInput, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, type PanelBinding, type PanelNodeChange, type PanelNodesChange, type Section, defaultMessages, useLiveMessages };
34
35
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,12 +1,16 @@
1
- import { t as ContextProvider } from "./context-93X3gyfJ.js";
2
- import { t as Dnd } from "./dnd-x8Mvj--6.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-BYck9mVK.js";
1
+ import { i as useLiveMessages, n as defaultMessages } from "./messages-CzUPVnzH.js";
2
+ import { t as ContextProvider } from "./context-DsEXJl4h.js";
3
+ import { t as Dnd } from "./dnd-DGNp20Nk.js";
4
+ import { t as Editor } from "./editor-DQ8Q--qR.js";
5
+ import { t as Error } from "./error-DwqwjJ2C.js";
6
+ import { t as Preview } from "./preview-BKFgq_5u.js";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  //#region src/index.tsx
8
- const App = ({ children }) => {
9
- return /* @__PURE__ */ jsx(ContextProvider, { children });
9
+ const App = ({ children, messages }) => {
10
+ return /* @__PURE__ */ jsx(ContextProvider, {
11
+ messages,
12
+ children
13
+ });
10
14
  };
11
15
  const LiveRenderer = Preview;
12
16
  App.Preview = Preview;
@@ -15,6 +19,6 @@ App.Error = Error;
15
19
  App.Editor = Editor;
16
20
  App.Dnd = Dnd;
17
21
  //#endregion
18
- export { Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer };
22
+ export { Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, defaultMessages, useLiveMessages };
19
23
 
20
24
  //# sourceMappingURL=index.js.map
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 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"}
1
+ {"version":3,"file":"index.js","names":["Context","LivePreview","LiveError","LiveEditor","LiveDnd"],"sources":["../src/index.tsx"],"sourcesContent":["import './index.css';\n\nimport Context, {\n type Props as ContextProps,\n type LiveMessages,\n type LiveMessagesInput,\n} 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';\nimport type {\n BindingKeyMap,\n BindingOptions,\n BindingRegistry,\n BindingSchema,\n} from './utils/ast/types';\n\nconst App = ({ children, messages }: ContextProps) => {\n return <Context messages={messages}>{children}</Context>;\n};\n\nconst LiveRenderer = LivePreview;\n\n// The editor's text, for a host that translates it (#524). This is the\n// package entry, which Fast Refresh never reloads.\n// eslint-disable-next-line react-refresh/only-export-components\nexport { defaultMessages, useLiveMessages } from './components/context';\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 BindingRegistry,\n BindingKeyMap,\n BindingOptions,\n BindingSchema,\n LiveMessages,\n LiveMessagesInput,\n};\n\nApp.Preview = LivePreview;\nApp.Renderer = LiveRenderer;\nApp.Error = LiveError;\nApp.Editor = LiveEditor;\nApp.Dnd = LiveDnd;\n\nexport default App;\n"],"mappings":";;;;;;;;AAwCA,MAAM,OAAO,EAAE,UAAU,eAA6B;CACpD,OAAO,oBAACA,iBAAD;EAAmB;EAAW;CAAkB,CAAA;AACzD;AAEA,MAAM,eAAeC;AAiDrB,IAAI,UAAUA;AACd,IAAI,WAAW;AACf,IAAI,QAAQC;AACZ,IAAI,SAASC;AACb,IAAI,MAAMC"}