@jbpark/live-editor 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ast-BKQmEBj9.js → ast-BhbOxomw.js} +2 -2
- package/dist/{ast-BKQmEBj9.js.map → ast-BhbOxomw.js.map} +1 -1
- package/dist/{boundary-b-U70XU_.js → boundary-DOBK2HnX.js} +2 -2
- package/dist/{boundary-b-U70XU_.js.map → boundary-DOBK2HnX.js.map} +1 -1
- package/dist/{context-Yb81ZxnN.js → context-DOMX_RsU.js} +3 -3
- package/dist/{context-Yb81ZxnN.js.map → context-DOMX_RsU.js.map} +1 -1
- package/dist/{core-mdFWxqB2.js → core-D-ZvVhdn.js} +2 -2
- package/dist/{core-mdFWxqB2.js.map → core-D-ZvVhdn.js.map} +1 -1
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-Cyuif73L.js → dnd-E8LbmRfE.js} +26 -12
- package/dist/dnd-E8LbmRfE.js.map +1 -0
- package/dist/{document-DEx4WyCn.js → document-Ddw-tfnt.js} +37 -155
- package/dist/{document-DEx4WyCn.js.map → document-Ddw-tfnt.js.map} +1 -1
- package/dist/editor/index.js +2 -2
- package/dist/{editor-jzeeLkwi.js → editor-ka05eWyz.js} +3 -3
- package/dist/{editor-jzeeLkwi.js.map → editor-ka05eWyz.js.map} +1 -1
- package/dist/error/index.js +2 -2
- package/dist/{error-C47PVZgY.js → error-fzPGTaFe.js} +2 -2
- package/dist/{error-C47PVZgY.js.map → error-fzPGTaFe.js.map} +1 -1
- package/dist/index.js +5 -5
- package/dist/preview/index.js +1 -1
- package/dist/{preview-8OZDsfGT.js → preview-EsfzEjis.js} +4 -4
- package/dist/{preview-8OZDsfGT.js.map → preview-EsfzEjis.js.map} +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/{use-dynamic-tailwind-_3tC-S5j.js → use-dynamic-tailwind-CRMGuKnH.js} +2 -2
- package/dist/{use-dynamic-tailwind-_3tC-S5j.js.map → use-dynamic-tailwind-CRMGuKnH.js.map} +1 -1
- package/dist/utils/ast/index.js +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/{utils-CXq1KaM3.js → utils-B6zpA7mT.js} +2 -2
- package/dist/{utils-CXq1KaM3.js.map → utils-B6zpA7mT.js.map} +1 -1
- package/package.json +7 -2
- package/dist/dnd-Cyuif73L.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as cn } from "./utils-
|
|
1
|
+
import { r as cn } from "./utils-B6zpA7mT.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/error/error.tsx
|
|
@@ -89,4 +89,4 @@ var ErrorBoundary = class extends React.Component {
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { Error as n, ErrorBoundary as t };
|
|
91
91
|
|
|
92
|
-
//# sourceMappingURL=boundary-
|
|
92
|
+
//# sourceMappingURL=boundary-DOBK2HnX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundary-
|
|
1
|
+
{"version":3,"file":"boundary-DOBK2HnX.js","names":[],"sources":["../src/components/error/error.tsx","../src/components/error/boundary.tsx"],"sourcesContent":["import { cn } from '~/utils';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n message?: string | null;\n title?: string;\n onReset?: () => void;\n}\n\nconst Error = ({\n message,\n title = 'An error occurred',\n className,\n onReset,\n}: Props) => {\n if (!message) {\n return null;\n }\n\n return (\n <div\n className={cn(className)}\n style={{\n padding: '16px',\n backgroundColor: '#fee2e2',\n border: '1px solid #fca5a5',\n borderRadius: '6px',\n color: '#7f1d1d',\n }}\n >\n <h3 style={{ fontSize: '14px', fontWeight: 'bold', margin: 0 }}>\n {title}\n </h3>\n <pre\n style={{\n marginTop: '8px',\n fontSize: '12px',\n whiteSpace: 'pre-wrap',\n margin: '8px 0 0 0',\n }}\n >\n {message}\n </pre>\n {onReset && (\n <button\n style={{\n marginTop: '8px',\n padding: '4px 12px',\n fontSize: '12px',\n color: 'white',\n backgroundColor: '#dc2626',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n }}\n onClick={onReset}\n >\n Try Again\n </button>\n )}\n </div>\n );\n};\n\nexport default Error;\n","import React from 'react';\n\nimport Error from './error';\n\ninterface Props {\n children: React.ReactNode;\n fallback?: (message?: string) => React.ReactNode;\n onError?: (e: Error, info: React.ErrorInfo) => void;\n // Values whose identity changing (typically the code/module that produced\n // `children`) should auto-recover a caught error without needing a\n // remount — compared shallowly, one entry at a time, same idea as\n // react-error-boundary's resetKeys. Without this, once tripped, render()\n // never even attempts `children` again (see below), so a fix to the\n // underlying code has no way to reach the screen until this array changes\n // or something remounts the boundary via `key`.\n resetKeys?: readonly unknown[];\n}\n\ninterface State {\n hasError: boolean;\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error('🚨 [Boundary] Rendering error:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n // Safe to reset unconditionally here (no race with a freshly-thrown\n // error): while hasError is true, render() below never attempts\n // `children` at all, so resetting just schedules a follow-up render where\n // `children` gets its first real chance to run with the new resetKeys —\n // if that throws too, getDerivedStateFromError catches it fresh in that\n // later, separate commit.\n componentDidUpdate(prevProps: Props) {\n if (!this.state.hasError) {\n return;\n }\n\n const prevKeys = prevProps.resetKeys ?? [];\n const nextKeys = this.props.resetKeys ?? [];\n const changed =\n prevKeys.length !== nextKeys.length ||\n nextKeys.some((key, i) => key !== prevKeys[i]);\n\n if (changed) {\n this.setState({ hasError: false, error: undefined });\n }\n }\n\n render() {\n if (this.state.hasError) {\n return this.props.fallback ? (\n <>{this.props.fallback(this.state.error?.message)}</>\n ) : (\n <Error\n message={this.state.error?.message}\n onReset={() => this.setState({ hasError: false, error: undefined })}\n title=\"Rendering Error\"\n />\n );\n }\n\n return this.props.children;\n }\n}\n\nexport default ErrorBoundary;\n"],"mappings":";;;;AAQA,MAAM,SAAS,EACb,SACA,QAAQ,qBACR,WACA,cACW;CACX,IAAI,CAAC,SACH,OAAO;CAGT,OACE,qBAAC,OAAD;EACE,WAAW,GAAG,SAAS;EACvB,OAAO;GACL,SAAS;GACT,iBAAiB;GACjB,QAAQ;GACR,cAAc;GACd,OAAO;EACT;EARF,UAAA;GAUE,oBAAC,MAAD;IAAI,OAAO;KAAE,UAAU;KAAQ,YAAY;KAAQ,QAAQ;IAAE;IAC1D,UAAA;GACC,CAAA;GACJ,oBAAC,OAAD;IACE,OAAO;KACL,WAAW;KACX,UAAU;KACV,YAAY;KACZ,QAAQ;IACV;IAEC,UAAA;GACE,CAAA;GACJ,WACC,oBAAC,UAAD;IACE,OAAO;KACL,WAAW;KACX,SAAS;KACT,UAAU;KACV,OAAO;KACP,iBAAiB;KACjB,QAAQ;KACR,cAAc;KACd,QAAQ;IACV;IACA,SAAS;IACV,UAAA;GAEO,CAAA;EAEP;;AAET;;;ACtCA,IAAM,gBAAN,cAA4B,MAAM,UAAwB;CACxD,YAAY,OAAc;EACxB,MAAM,KAAK;EACX,KAAK,QAAQ,EAAE,UAAU,MAAM;CACjC;CAEA,OAAO,yBAAyB,OAAqB;EACnD,OAAO;GAAE,UAAU;GAAM;EAAM;CACjC;CAEA,kBAAkB,OAAc,WAA4B;EAC1D,QAAQ,MAAM,kCAAkC,OAAO,SAAS;EAChE,KAAK,MAAM,UAAU,OAAO,SAAS;CACvC;CAQA,mBAAmB,WAAkB;EACnC,IAAI,CAAC,KAAK,MAAM,UACd;EAGF,MAAM,WAAW,UAAU,aAAa,CAAC;EACzC,MAAM,WAAW,KAAK,MAAM,aAAa,CAAC;EAK1C,IAHE,SAAS,WAAW,SAAS,UAC7B,SAAS,MAAM,KAAK,MAAM,QAAQ,SAAS,EAAE,GAG7C,KAAK,SAAS;GAAE,UAAU;GAAO,OAAO,KAAA;EAAU,CAAC;CAEvD;CAEA,SAAS;EACP,IAAI,KAAK,MAAM,UACb,OAAO,KAAK,MAAM,WAChB,oBAAA,UAAA,EAAA,UAAG,KAAK,MAAM,SAAS,KAAK,MAAM,OAAO,OAAO,EAAI,CAAA,IAEpD,oBAAC,OAAD;GACE,SAAS,KAAK,MAAM,OAAO;GAC3B,eAAe,KAAK,SAAS;IAAE,UAAU;IAAO,OAAO,KAAA;GAAU,CAAC;GAClE,OAAM;EACP,CAAA;EAIL,OAAO,KAAK,MAAM;CACpB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { y as DEFAULT_TEMPLATE } from "./document-
|
|
2
|
-
import { n as clearCompilationCache } from "./utils-
|
|
1
|
+
import { y as DEFAULT_TEMPLATE } from "./document-Ddw-tfnt.js";
|
|
2
|
+
import { n as clearCompilationCache } from "./utils-B6zpA7mT.js";
|
|
3
3
|
import { n as PreviewContext, t as ErrorContext } from "./states-Ci1AvoQ9.js";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -35,4 +35,4 @@ const ContextProvider = ({ children }) => {
|
|
|
35
35
|
//#endregion
|
|
36
36
|
export { ContextProvider as t };
|
|
37
37
|
|
|
38
|
-
//# sourceMappingURL=context-
|
|
38
|
+
//# sourceMappingURL=context-DOMX_RsU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
1
|
+
{"version":3,"file":"context-DOMX_RsU.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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as detectTypeScript, r as cn } from "./utils-
|
|
1
|
+
import { a as detectTypeScript, r as cn } from "./utils-B6zpA7mT.js";
|
|
2
2
|
import { useCallback, useMemo, useRef } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { javascript } from "@codemirror/lang-javascript";
|
|
@@ -11192,4 +11192,4 @@ const Core = ({ value, theme, height, className, prettierOptions, fragment, raw,
|
|
|
11192
11192
|
//#endregion
|
|
11193
11193
|
export { useFormatCode as n, Core as t };
|
|
11194
11194
|
|
|
11195
|
-
//# sourceMappingURL=core-
|
|
11195
|
+
//# sourceMappingURL=core-D-ZvVhdn.js.map
|