@jbpark/live-editor 1.14.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-DrqO0VVu.js +38 -0
- package/dist/context-DrqO0VVu.js.map +1 -0
- package/dist/core-B7igZRDs.js +11195 -0
- package/dist/core-B7igZRDs.js.map +1 -0
- package/dist/dnd/index.d.ts +2 -0
- package/dist/dnd/index.js +2 -0
- package/dist/dnd-BRQKM3fk.js +1717 -0
- package/dist/dnd-BRQKM3fk.js.map +1 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +3 -0
- package/dist/editor-DmgTeTcG.js +51 -0
- package/dist/editor-DmgTeTcG.js.map +1 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +2 -0
- package/dist/error-DRMGumEj.js +168 -0
- package/dist/error-DRMGumEj.js.map +1 -0
- package/dist/frame-DQ_9RdeP.js +412 -0
- package/dist/frame-DQ_9RdeP.js.map +1 -0
- package/dist/index-BnncHZTt.d.ts +63 -0
- package/dist/index-C4TBkJBG.d.ts +37 -0
- package/dist/index-CCynrS6c.d.ts +52 -0
- package/dist/index-DpDU1IAw.d.ts +23 -0
- package/dist/index-lgHdCda5.d.ts +17 -0
- package/dist/index.d.ts +13 -185
- package/dist/index.js +8 -13614
- package/dist/index.js.map +1 -1
- package/dist/preview/index.d.ts +2 -0
- package/dist/preview/index.js +2 -0
- package/dist/preview-CgJE-pwO.js +113 -0
- package/dist/preview-CgJE-pwO.js.map +1 -0
- package/dist/provider/index.d.ts +8 -0
- package/dist/provider/index.js +2 -0
- package/dist/states-Ci1AvoQ9.js +18 -0
- package/dist/states-Ci1AvoQ9.js.map +1 -0
- package/dist/style.css +3830 -3
- package/dist/tailwind-CbjdLyVX.js +28 -0
- package/dist/tailwind-CbjdLyVX.js.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/tailwind/index.d.ts +2 -2
- package/dist/utils/tailwind/index.js +2 -2
- package/dist/{utils-B11t9ZYd.js → utils-BzfDKU6y.js} +10 -23
- package/dist/{utils-B11t9ZYd.js.map → utils-BzfDKU6y.js.map} +1 -1
- package/package.json +26 -12
- package/dist/tailwind-CzPhj3D9.js +0 -36
- package/dist/tailwind-CzPhj3D9.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { _ as DEFAULT_TEMPLATE } from "./document-CSIscFpL.js";
|
|
2
|
+
import { n as clearCompilationCache } from "./utils-BzfDKU6y.js";
|
|
3
|
+
import { n as PreviewContext, t as ErrorContext } from "./states-Ci1AvoQ9.js";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/context/context.tsx
|
|
7
|
+
const ContextProvider = ({ children }) => {
|
|
8
|
+
const [code, setCodeState] = useState(DEFAULT_TEMPLATE);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const setCode = useCallback((next) => {
|
|
11
|
+
setError(null);
|
|
12
|
+
setCodeState(next);
|
|
13
|
+
}, []);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return () => {
|
|
16
|
+
clearCompilationCache();
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
const previewValue = useMemo(() => ({
|
|
20
|
+
code,
|
|
21
|
+
setCode
|
|
22
|
+
}), [code, setCode]);
|
|
23
|
+
const errorValue = useMemo(() => ({
|
|
24
|
+
error,
|
|
25
|
+
setError
|
|
26
|
+
}), [error, setError]);
|
|
27
|
+
return /* @__PURE__ */ jsx(PreviewContext.Provider, {
|
|
28
|
+
value: previewValue,
|
|
29
|
+
children: /* @__PURE__ */ jsx(ErrorContext.Provider, {
|
|
30
|
+
value: errorValue,
|
|
31
|
+
children
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ContextProvider as t };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=context-DrqO0VVu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-DrqO0VVu.js","names":[],"sources":["../src/components/context/context.tsx"],"sourcesContent":["'use client';\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { DEFAULT_TEMPLATE } from '~/constants';\nimport { clearCompilationCache } from '~/utils';\n\nimport type { ErrorContextType, PreviewContextType } from './states';\nimport { ErrorContext, PreviewContext } from './states';\n\nconst ContextProvider = ({ children }: { children?: React.ReactNode }) => {\n const [code, setCodeState] = useState(DEFAULT_TEMPLATE);\n const [error, setError] = useState<ErrorContextType['error']>(null);\n\n // Clears any stale runtime/compile error in the same update batch that\n // changes `code`, rather than in a separate useEffect — a useEffect here\n // would race with componentDidCatch/Guard's onError firing for the *new*\n // code's own errors within the same commit (layout effects run before\n // passive effects, so a passive-effect reset could wipe out an error the\n // new code just threw). Batching setError(null) into the same update as\n // setCode guarantees stale errors are gone by the time the new code even\n // renders, with nothing left afterward that could clobber a fresh one.\n const setCode = useCallback<PreviewContextType['setCode']>(next => {\n setError(null);\n setCodeState(next);\n }, []);\n\n useEffect(() => {\n return () => {\n clearCompilationCache();\n };\n }, []);\n\n // Without this, a new object identity on every ContextProvider render\n // (even ones that don't touch code/error at all, e.g. a parent\n // re-rendering) meant every usePreview()/useError() consumer re-rendered\n // too, regardless of whether the values they care about actually changed.\n const previewValue = useMemo<PreviewContextType>(\n () => ({ code, setCode }),\n [code, setCode],\n );\n\n const errorValue = useMemo<ErrorContextType>(\n () => ({ error, setError }),\n [error, setError],\n );\n\n return (\n <PreviewContext.Provider value={previewValue}>\n <ErrorContext.Provider value={errorValue}>\n {children}\n </ErrorContext.Provider>\n </PreviewContext.Provider>\n );\n};\n\nexport default ContextProvider;\n"],"mappings":";;;;;;AAUA,MAAM,mBAAmB,EAAE,eAA+C;CACxE,MAAM,CAAC,MAAM,gBAAgB,SAAS,gBAAgB;CACtD,MAAM,CAAC,OAAO,YAAY,SAAoC,IAAI;CAUlE,MAAM,UAAU,aAA2C,SAAQ;EACjE,SAAS,IAAI;EACb,aAAa,IAAI;CACnB,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,aAAa;GACX,sBAAsB;EACxB;CACF,GAAG,CAAC,CAAC;CAML,MAAM,eAAe,eACZ;EAAE;EAAM;CAAQ,IACvB,CAAC,MAAM,OAAO,CAChB;CAEA,MAAM,aAAa,eACV;EAAE;EAAO;CAAS,IACzB,CAAC,OAAO,QAAQ,CAClB;CAEA,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC9B,UAAA,oBAAC,aAAa,UAAd;GAAuB,OAAO;GAC3B;EACoB,CAAA;CACA,CAAA;AAE7B"}
|