@jbpark/live-editor 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-BvjEDo-x.js → dnd-COjjjuD7.js} +40 -8
- package/dist/dnd-COjjjuD7.js.map +1 -0
- package/dist/{document-uHqw0mvr.js → document-BkGWDZGc.js} +679 -525
- package/dist/document-BkGWDZGc.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/preview/index.js +1 -1
- package/dist/{preview-B05MkVIQ.js → preview-8ejC5VP2.js} +2 -2
- package/dist/{preview-B05MkVIQ.js.map → preview-8ejC5VP2.js.map} +1 -1
- package/dist/{sections-DhH_aVf5.js → sections-rD8NuRI8.js} +2 -2
- package/dist/{sections-DhH_aVf5.js.map → sections-rD8NuRI8.js.map} +1 -1
- package/dist/ui-kit/index.js +1 -1
- package/dist/{update-BuYQJqjq.js → update-DyFnX8yE.js} +2 -2
- package/dist/{update-BuYQJqjq.js.map → update-DyFnX8yE.js.map} +1 -1
- package/dist/{use-dynamic-tailwind-B3l1qZRW.js → use-dynamic-tailwind-0nuRN57N.js} +10 -17
- package/dist/{use-dynamic-tailwind-B3l1qZRW.js.map → use-dynamic-tailwind-0nuRN57N.js.map} +1 -1
- package/dist/utils/ast/index.js +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +2 -2
- package/dist/dnd-BvjEDo-x.js.map +0 -1
- package/dist/document-uHqw0mvr.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as Dnd } from "./dnd-
|
|
1
|
+
import { t as Dnd } from "./dnd-COjjjuD7.js";
|
|
2
2
|
import { i as useLiveMessages, n as defaultMessages } from "./messages-DrINcRdG.js";
|
|
3
3
|
import { t as ContextProvider } from "./context-Bjq0CvBE.js";
|
|
4
4
|
import { t as Editor } from "./editor-CvnzrM9J.js";
|
|
5
5
|
import { t as Error } from "./error-CFzvnLCf.js";
|
|
6
|
-
import { t as Preview } from "./preview-
|
|
6
|
+
import { t as Preview } from "./preview-8ejC5VP2.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/index.tsx
|
|
9
9
|
const App = ({ children, messages }) => {
|
package/dist/preview/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Preview } from "../preview-
|
|
1
|
+
import { t as Preview } from "../preview-8ejC5VP2.js";
|
|
2
2
|
export { Preview as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as useLiveMessages } from "./messages-DrINcRdG.js";
|
|
2
2
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
3
3
|
import { t as cn } from "./cn-CAnad2vL.js";
|
|
4
|
-
import { a as renderStableComponent, i as NO_PROPS, n as useCompiledModule, o as Frame, r as NO_MODULES, t as useDynamicTailwind } from "./use-dynamic-tailwind-
|
|
4
|
+
import { a as renderStableComponent, i as NO_PROPS, n as useCompiledModule, o as Frame, r as NO_MODULES, t as useDynamicTailwind } from "./use-dynamic-tailwind-0nuRN57N.js";
|
|
5
5
|
import { t as Error } from "./error-CFzvnLCf.js";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -88,4 +88,4 @@ const Preview = ({ code, props = NO_PROPS, modules = NO_MODULES, dynamicTailwind
|
|
|
88
88
|
//#endregion
|
|
89
89
|
export { Preview as t };
|
|
90
90
|
|
|
91
|
-
//# sourceMappingURL=preview-
|
|
91
|
+
//# sourceMappingURL=preview-8ejC5VP2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-
|
|
1
|
+
{"version":3,"file":"preview-8ejC5VP2.js","names":["styles","LiveError"],"sources":["../src/components/preview/preview.module.css","../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["@layer components {\n .fill {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .scroll {\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n /* Hides the preview while the runtime error overlay covers it. */\n .hidden {\n display: none;\n }\n}\n","'use client';\n\nimport { useMemo } from 'react';\n\nimport { useLiveMessages } from '~/components/context/messages';\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 styles from './preview.module.css';\n\nimport { NO_MODULES, NO_PROPS } from './defaults';\nimport { renderStableComponent } from './stable-component';\nimport type { Props } from './types';\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 messages = useLiveMessages();\n const isError = !!showError && !!error;\n\n const classNames = cn(isError && styles.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(styles.fill, classNames)}>\n <LiveError message={module.error} title={messages.errors.compile} />\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(styles.fill, 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 {/* Keeps the DOM when an edit leaves the hooks alone. */}\n {renderStableComponent(Component, effectiveCode, {\n ...componentProps,\n container,\n })}\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(styles.fill, styles.scroll, classNames)}\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 {renderStableComponent(\n Component,\n effectiveCode,\n componentProps,\n )}\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 Client from './client';\nimport { NO_MODULES, NO_PROPS } from './defaults';\nimport type { Props } from './types';\n\n// `Live.Preview`: a thin wrapper around `Client`, which compiles, handles\n// errors and wraps the frame. One render path for both `code` and the\n// provider's code (#187).\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":";;;;;;;;;;;;;;;ACkBA,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,WAAW,gBAAgB;CACjC,MAAM,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC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,CAAA,IAEL,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GAAGD,uBAAO,MAAMA,uBAAO,QAAQ,UAAU;EACpD,OAAO;GACL,WAAW;GACX,WAAW;GACX,eAAe;EACjB;EAEA,UAAA,oBAACC,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,CACG,sBACC,WACA,eACA,cACF,GACC,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;;;AC7HA,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as inspectDocument, i as getSections, o as parseDocument, r as generateSectionPreview, s as replaceDocumentSections } from "./document-
|
|
1
|
+
import { a as inspectDocument, i as getSections, o as parseDocument, r as generateSectionPreview, s as replaceDocumentSections } from "./document-BkGWDZGc.js";
|
|
2
2
|
import { i as DEFAULT_CONTAINER_ID, l as documentTemplate } from "./constants-st9gnJ5g.js";
|
|
3
3
|
//#region src/utils/sections.ts
|
|
4
4
|
const extractSections = (code, options) => {
|
|
@@ -23,4 +23,4 @@ const checkDocument = (code, options) => {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { replaceSections as a, generateSection as i, createDocument as n, extractSections as r, checkDocument as t };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=sections-
|
|
26
|
+
//# sourceMappingURL=sections-rD8NuRI8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sections-
|
|
1
|
+
{"version":3,"file":"sections-rD8NuRI8.js","names":[],"sources":["../src/utils/sections.ts"],"sourcesContent":["import { DEFAULT_CONTAINER_ID, documentTemplate } from '~/constants';\nimport type { Section } from '~/types';\n\nimport {\n type DocumentOptions,\n type DocumentProblem,\n type SectionOptions,\n createSectionPreviewCache,\n generateSectionPreview,\n getSections,\n inspectDocument,\n parseDocument,\n replaceDocumentSections,\n} from './ast/document';\n\nexport const extractSections = (\n code: string,\n options?: SectionOptions,\n): Section[] => {\n const doc = parseDocument(code, options);\n\n return doc ? getSections(doc, options) : [];\n};\n\nexport const replaceSections = (\n code: string,\n sections: string[],\n options?: DocumentOptions,\n): string => {\n return replaceDocumentSections(code, sections, options);\n};\n\nexport const generateSection = (\n code: string,\n fullCode: string,\n options?: DocumentOptions,\n) => {\n return generateSectionPreview(fullCode, code, options);\n};\n\n// A new, empty document `Live.Dnd` can add sections to: an `App` component\n// rendering the container element and nothing else. Start a controlled\n// `Live.Dnd` from this rather than an empty string, which has no container,\n// so nothing dropped on the canvas would land anywhere (#449). Pass the same\n// `containerId` you give `Live.Dnd`.\nexport const createDocument = ({\n containerId = DEFAULT_CONTAINER_ID,\n}: DocumentOptions = {}): string => {\n // The id is written into a JSX attribute as-is, so anything that could end\n // the attribute or the tag is refused rather than producing broken source.\n if (!/^[^\\s\"'<>{}]+$/.test(containerId)) {\n throw new Error(\n `createDocument: containerId must be a plain element id, got ${JSON.stringify(containerId)}`,\n );\n }\n\n return documentTemplate(containerId);\n};\n\n// Whether `Live.Dnd` can edit a document: it parses, and it has the\n// container. A host can check one before saving or loading it, and gets the\n// same reasons `Live.Dnd` reports through `onEditError` (#522).\nexport type DocumentCheck = { ok: true } | ({ ok: false } & DocumentProblem);\n\nexport const checkDocument = (\n code: string,\n options?: DocumentOptions,\n): DocumentCheck => {\n const inspection = inspectDocument(code, options);\n\n if (inspection.ok) {\n return { ok: true };\n }\n\n // A copy: the inspection is cached and shared with `Live.Dnd`.\n return { ...inspection };\n};\n\n// Generates every section's preview from one parse and reuses an unchanged\n// preview between calls (#131). Keep one instance per editor, as `Live.Dnd`\n// does.\nexport { createSectionPreviewCache };\nexport type {\n DocumentOptions,\n DocumentProblem,\n SectionOptions,\n} from './ast/document';\n"],"mappings":";;;AAeA,MAAa,mBACX,MACA,YACc;CACd,MAAM,MAAM,cAAc,MAAM,OAAO;CAEvC,OAAO,MAAM,YAAY,KAAK,OAAO,IAAI,CAAC;AAC5C;AAEA,MAAa,mBACX,MACA,UACA,YACW;CACX,OAAO,wBAAwB,MAAM,UAAU,OAAO;AACxD;AAEA,MAAa,mBACX,MACA,UACA,YACG;CACH,OAAO,uBAAuB,UAAU,MAAM,OAAO;AACvD;AAOA,MAAa,kBAAkB,EAC7B,cAAc,yBACK,CAAC,MAAc;CAGlC,IAAI,CAAC,iBAAiB,KAAK,WAAW,GACpC,MAAM,IAAI,MACR,+DAA+D,KAAK,UAAU,WAAW,GAC3F;CAGF,OAAO,iBAAiB,WAAW;AACrC;AAOA,MAAa,iBACX,MACA,YACkB;CAClB,MAAM,aAAa,gBAAgB,MAAM,OAAO;CAEhD,IAAI,WAAW,IACb,OAAO,EAAE,IAAI,KAAK;CAIpB,OAAO,EAAE,GAAG,WAAW;AACzB"}
|
package/dist/ui-kit/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createDocument } from "../sections-
|
|
1
|
+
import { n as createDocument } from "../sections-rD8NuRI8.js";
|
|
2
2
|
import { i as getFieldKind, o as FieldError, t as useFieldState } from "../use-field-state-iQGW0vc6.js";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as jsxOpeningFragment, A as isJSXText, B as isTSSatisfiesExpression, C as isJSXElement, D as isJSXIdentifier, E as isJSXFragment, F as isParenthesizedExpression, G as jsxClosingElement, H as isTemplateLiteral, J as jsxExpressionContainer, K as jsxClosingFragment, L as isStringLiteral, M as isNumericLiteral, N as isObjectExpression, O as isJSXOpeningElement, P as isObjectProperty, Q as jsxOpeningElement, R as isTSAsExpression, S as isJSXAttribute, T as isJSXExpressionContainer, U as isUnaryExpression, V as isTSTypeAssertion, W as jsxAttribute, X as jsxIdentifier, Y as jsxFragment, Z as jsxMemberExpression, _ as identifier, at as stringLiteral, c as traverse, ct as traverseFast, d as applyEdits, dt as parseExpression, et as jsxText, f as getJSXTagName, g as booleanLiteral, h as arrayExpression, it as objectProperty, j as isNullLiteral, k as isJSXSpreadAttribute, lt as unaryExpression, m as generate, nt as numericLiteral, p as nanoid, q as jsxElement, rt as objectExpression, tt as nullLiteral, ut as parse, v as isArrayExpression, w as isJSXEmptyExpression, x as isIdentifier, y as isBooleanLiteral, z as isTSNonNullExpression } from "./document-
|
|
1
|
+
import { $ as jsxOpeningFragment, A as isJSXText, B as isTSSatisfiesExpression, C as isJSXElement, D as isJSXIdentifier, E as isJSXFragment, F as isParenthesizedExpression, G as jsxClosingElement, H as isTemplateLiteral, J as jsxExpressionContainer, K as jsxClosingFragment, L as isStringLiteral, M as isNumericLiteral, N as isObjectExpression, O as isJSXOpeningElement, P as isObjectProperty, Q as jsxOpeningElement, R as isTSAsExpression, S as isJSXAttribute, T as isJSXExpressionContainer, U as isUnaryExpression, V as isTSTypeAssertion, W as jsxAttribute, X as jsxIdentifier, Y as jsxFragment, Z as jsxMemberExpression, _ as identifier, at as stringLiteral, c as traverse, ct as traverseFast, d as applyEdits, dt as parseExpression, et as jsxText, f as getJSXTagName, g as booleanLiteral, h as arrayExpression, it as objectProperty, j as isNullLiteral, k as isJSXSpreadAttribute, lt as unaryExpression, m as generate, nt as numericLiteral, p as nanoid, q as jsxElement, rt as objectExpression, tt as nullLiteral, ut as parse, v as isArrayExpression, w as isJSXEmptyExpression, x as isIdentifier, y as isBooleanLiteral, z as isTSNonNullExpression } from "./document-BkGWDZGc.js";
|
|
2
2
|
import { n as CONFIG, o as REGEX, r as DATA_ATTR, s as RESERVED_BINDING_PROPERTIES, t as BINDING_PROP } from "./constants-st9gnJ5g.js";
|
|
3
3
|
import { n as registerEditorCache } from "./editor-caches-ClMvdcQF.js";
|
|
4
4
|
import { t as createBoundedCache } from "./cache-B0-XcIxJ.js";
|
|
@@ -1309,4 +1309,4 @@ const updateAll = (raw, entries, options = {}) => {
|
|
|
1309
1309
|
//#endregion
|
|
1310
1310
|
export { parseArrayExpression as _, getChildrenSignatures as a, generateCode as b, removeIndices as c, getStructuredValue as d, readNodeBindings as f, isLosslesslyEvaluable as g, extractObjectProperties as h, valueToExpression as i, findEditableChildren as l, extractNodeValue as m, updateAll as n, extract as o, canLosslesslyEvaluateSource as p, createNodeFromValue as r, moveSelectedIndices as s, update as t, getCurrentValue as u, parseValue as v, unwrapExpression as y };
|
|
1311
1311
|
|
|
1312
|
-
//# sourceMappingURL=update-
|
|
1312
|
+
//# sourceMappingURL=update-DyFnX8yE.js.map
|