@jbpark/live-editor 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +2 -7
- package/README.md +2 -7
- package/dist/{ast-BFbDWO-l.js → ast-dYb78955.js} +128 -38
- package/dist/ast-dYb78955.js.map +1 -0
- package/dist/{compile-0Dvp8zp5.js → compile-DDfk5P25.js} +3 -3
- package/dist/{compile-0Dvp8zp5.js.map → compile-DDfk5P25.js.map} +1 -1
- package/dist/{constants-CKvdqZtO.js → constants-h1JAgOeW.js} +4 -2
- package/dist/constants-h1JAgOeW.js.map +1 -0
- package/dist/{context-93X3gyfJ.js → context-DB5kW3qe.js} +2 -2
- package/dist/{context-93X3gyfJ.js.map → context-DB5kW3qe.js.map} +1 -1
- package/dist/{core-B3ruccKb.js → core-CRsAGpei.js} +2 -2
- package/dist/{core-B3ruccKb.js.map → core-CRsAGpei.js.map} +1 -1
- package/dist/{detect-typescript-5MV4mCM7.js → detect-typescript-CCj9ALXc.js} +2 -2
- package/dist/{detect-typescript-5MV4mCM7.js.map → detect-typescript-CCj9ALXc.js.map} +1 -1
- package/dist/dnd/index.d.ts +2 -2
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-Z1KS16Fy.js → dnd-BE5ZizqX.js} +168 -44
- package/dist/dnd-BE5ZizqX.js.map +1 -0
- package/dist/{document-cEEdFERz.js → document-BDn_f08_.js} +42 -41
- package/dist/document-BDn_f08_.js.map +1 -0
- package/dist/editor/index.js +2 -2
- package/dist/{editor-DvMruljw.js → editor-DQ8Q--qR.js} +2 -2
- package/dist/{editor-DvMruljw.js.map → editor-DQ8Q--qR.js.map} +1 -1
- package/dist/{index-CtlUYnWq.d.ts → index-Dgh1JTX3.d.ts} +13 -4
- package/dist/{index-w3kLcCXl.d.ts → index-f7ijuNTa.d.ts} +17 -5
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/preview/index.js +2 -2
- package/dist/{preview-C_UzpGWh.js → preview-BnaCEFsF.js} +2 -2
- package/dist/{preview-C_UzpGWh.js.map → preview-BnaCEFsF.js.map} +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/{sections-GJQ63uEB.js → sections-CBVMO8Jl.js} +3 -3
- package/dist/{sections-GJQ63uEB.js.map → sections-CBVMO8Jl.js.map} +1 -1
- package/dist/{use-dynamic-tailwind-DpbjmATF.js → use-dynamic-tailwind-Bcipc1hL.js} +43 -2
- package/dist/use-dynamic-tailwind-Bcipc1hL.js.map +1 -0
- package/dist/utils/ast/index.d.ts +2 -2
- package/dist/utils/ast/index.js +3 -3
- package/dist/utils/index.js +4 -4
- package/package.json +6 -6
- package/dist/ast-BFbDWO-l.js.map +0 -1
- package/dist/constants-CKvdqZtO.js.map +0 -1
- package/dist/dnd-Z1KS16Fy.js.map +0 -1
- package/dist/document-cEEdFERz.js.map +0 -1
- package/dist/use-dynamic-tailwind-DpbjmATF.js.map +0 -1
package/README.ko.md
CHANGED
|
@@ -140,18 +140,13 @@ export default function Example() {
|
|
|
140
140
|
|
|
141
141
|
### pnpm 설정 (권장)
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
pnpm 버전은 `package.json`(그리고 `website/package.json`)의 `packageManager` 필드에 고정되어 있습니다. [Corepack](https://nodejs.org/api/corepack.html)을 활성화하면 저장소에서 `pnpm`을 실행할 때 그 버전을 그대로 쓰고, 처음 실행할 때 내려받습니다:
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
146
|
corepack enable
|
|
147
|
-
corepack prepare pnpm@10.29.3 --activate
|
|
148
147
|
```
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm install -g pnpm@10
|
|
154
|
-
```
|
|
149
|
+
직접 설치하려면 `packageManager`에 적힌 버전으로 설치하세요(`npm install -g pnpm@<버전>`). pnpm 11 이상은 Node.js 22 이상이 필요합니다.
|
|
155
150
|
|
|
156
151
|
### 설치
|
|
157
152
|
|
package/README.md
CHANGED
|
@@ -140,18 +140,13 @@ can avoid pulling in the rest (e.g. no CodeMirror in a preview-only build) — s
|
|
|
140
140
|
|
|
141
141
|
### pnpm Setup (Recommended)
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
The pnpm version is pinned by the `packageManager` field in `package.json` (and in `website/package.json`). With [Corepack](https://nodejs.org/api/corepack.html) enabled, running `pnpm` in the repo uses exactly that version, downloading it on first use:
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
146
|
corepack enable
|
|
147
|
-
corepack prepare pnpm@10.29.3 --activate
|
|
148
147
|
```
|
|
149
148
|
|
|
150
|
-
Or
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm install -g pnpm@10
|
|
154
|
-
```
|
|
149
|
+
Or install the pinned version yourself (`npm install -g pnpm@<version>`, with the version from `packageManager`). pnpm 11 and later need Node.js 22 or newer.
|
|
155
150
|
|
|
156
151
|
### Install
|
|
157
152
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as require_lib, S as require_lib$1, _ as nanoid, b as unwrap, d as traverse, g as getJSXTagName, v as attrValue, w as __toESM, x as wrap, y as generateCode } from "./document-
|
|
2
|
-
import { c as RESERVED_BINDING_PROPERTIES, n as CONFIG, r as DATA_ATTR, s as REGEX, t as BINDING_PROP } from "./constants-
|
|
1
|
+
import { C as require_lib, S as require_lib$1, _ as nanoid, b as unwrap, d as traverse, g as getJSXTagName, v as attrValue, w as __toESM, x as wrap, y as generateCode } from "./document-BDn_f08_.js";
|
|
2
|
+
import { c as RESERVED_BINDING_PROPERTIES, n as CONFIG, r as DATA_ATTR, s as REGEX, t as BINDING_PROP } from "./constants-h1JAgOeW.js";
|
|
3
3
|
import { n as registerEditorCache } from "./editor-caches-ClMvdcQF.js";
|
|
4
4
|
import { t as createBoundedCache } from "./cache-B0-XcIxJ.js";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -372,6 +372,63 @@ const buildBindingItems = (raw) => {
|
|
|
372
372
|
}];
|
|
373
373
|
});
|
|
374
374
|
};
|
|
375
|
+
const registryEntries = /* @__PURE__ */ new WeakMap();
|
|
376
|
+
const isComponentTagName = (tagName) => tagName !== "" && (tagName.includes(".") || !/^[a-z]/.test(tagName));
|
|
377
|
+
const getRegistryBindings = (registry, tagName) => {
|
|
378
|
+
if (!registry) return;
|
|
379
|
+
let entries = registryEntries.get(registry);
|
|
380
|
+
if (!entries) {
|
|
381
|
+
entries = /* @__PURE__ */ new Map();
|
|
382
|
+
registryEntries.set(registry, entries);
|
|
383
|
+
const ignored = Object.keys(registry).filter((key) => !isComponentTagName(key));
|
|
384
|
+
if (ignored.length > 0) console.warn(`Live.Dnd \`bindings\` only applies to components. Ignored: ${ignored.join(", ")}. Bind an HTML element with its own data-binding.`);
|
|
385
|
+
}
|
|
386
|
+
if (!isComponentTagName(tagName) || !Object.hasOwn(registry, tagName)) return;
|
|
387
|
+
let bindings = entries.get(tagName);
|
|
388
|
+
if (!bindings) {
|
|
389
|
+
bindings = buildBindingItems(registry[tagName]);
|
|
390
|
+
entries.set(tagName, bindings);
|
|
391
|
+
}
|
|
392
|
+
return bindings;
|
|
393
|
+
};
|
|
394
|
+
const keyEntries = /* @__PURE__ */ new WeakMap();
|
|
395
|
+
const warnedKeys = /* @__PURE__ */ new Set();
|
|
396
|
+
const warnOnce = (id, message) => {
|
|
397
|
+
if (!warnedKeys.has(id)) {
|
|
398
|
+
warnedKeys.add(id);
|
|
399
|
+
console.warn(message);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const getKeyBindings = (bindingKeys, key) => {
|
|
403
|
+
if (!bindingKeys || !Object.hasOwn(bindingKeys, key)) return;
|
|
404
|
+
let entries = keyEntries.get(bindingKeys);
|
|
405
|
+
if (!entries) {
|
|
406
|
+
entries = /* @__PURE__ */ new Map();
|
|
407
|
+
keyEntries.set(bindingKeys, entries);
|
|
408
|
+
}
|
|
409
|
+
let bindings = entries.get(key);
|
|
410
|
+
if (!bindings) {
|
|
411
|
+
bindings = buildBindingItems(bindingKeys[key]);
|
|
412
|
+
entries.set(key, bindings);
|
|
413
|
+
}
|
|
414
|
+
return bindings;
|
|
415
|
+
};
|
|
416
|
+
const resolveBindings = (own, key, tagName, options = {}) => {
|
|
417
|
+
if (own) {
|
|
418
|
+
if (key !== void 0) warnOnce(`both:${key}`, `Live.Dnd: an element has both data-binding and data-binding-key="${key ?? ""}". Its data-binding is used; remove one of them.`);
|
|
419
|
+
return own;
|
|
420
|
+
}
|
|
421
|
+
if (key === null) {
|
|
422
|
+
warnOnce("not-a-string", "Live.Dnd: data-binding-key must be a plain string, such as data-binding-key=\"hero-title\". The element has no fields.");
|
|
423
|
+
return [];
|
|
424
|
+
}
|
|
425
|
+
if (key !== void 0) {
|
|
426
|
+
const bindings = getKeyBindings(options.bindingKeys, key);
|
|
427
|
+
if (!bindings) warnOnce(`missing:${key}`, `Live.Dnd: data-binding-key="${key}" isn't in bindingKeys. The element has no fields.`);
|
|
428
|
+
return bindings ?? [];
|
|
429
|
+
}
|
|
430
|
+
return getRegistryBindings(options.bindings, tagName) ?? [];
|
|
431
|
+
};
|
|
375
432
|
const parseBinding = (bindingValue) => {
|
|
376
433
|
if (!bindingValue) return [];
|
|
377
434
|
const ast = parseArrayExpression(bindingValue);
|
|
@@ -420,11 +477,12 @@ const getStructuredValue = (node, property, type) => {
|
|
|
420
477
|
}
|
|
421
478
|
}
|
|
422
479
|
};
|
|
423
|
-
const
|
|
480
|
+
const readNodeBindings = (node) => {
|
|
481
|
+
if (node.bindings) return node.bindings;
|
|
424
482
|
const bindingAttr = node.dataAttributes.find((attr) => attr.name === DATA_ATTR.BINDING);
|
|
425
|
-
|
|
426
|
-
return (node.bindings || parseBinding(bindingAttr.value)).length > 0;
|
|
483
|
+
return bindingAttr?.value ? parseBinding(bindingAttr.value) : [];
|
|
427
484
|
};
|
|
485
|
+
const hasEditableBindings = (node) => readNodeBindings(node).length > 0;
|
|
428
486
|
const findEditableChildren = (node) => {
|
|
429
487
|
const editableChildren = [];
|
|
430
488
|
const traverse = (children) => {
|
|
@@ -781,6 +839,22 @@ const parseJSXName = (tagName) => {
|
|
|
781
839
|
return expr;
|
|
782
840
|
};
|
|
783
841
|
const extractCache = createBoundedCache(CONFIG.CACHE_LIMIT);
|
|
842
|
+
const NO_MAP = {};
|
|
843
|
+
let optionExtractCaches = /* @__PURE__ */ new WeakMap();
|
|
844
|
+
const cacheFor = ({ bindings, bindingKeys }) => {
|
|
845
|
+
if (!bindings && !bindingKeys) return extractCache;
|
|
846
|
+
let byKeys = optionExtractCaches.get(bindings ?? NO_MAP);
|
|
847
|
+
if (!byKeys) {
|
|
848
|
+
byKeys = /* @__PURE__ */ new WeakMap();
|
|
849
|
+
optionExtractCaches.set(bindings ?? NO_MAP, byKeys);
|
|
850
|
+
}
|
|
851
|
+
let cache = byKeys.get(bindingKeys ?? NO_MAP);
|
|
852
|
+
if (!cache) {
|
|
853
|
+
cache = createBoundedCache(CONFIG.CACHE_LIMIT);
|
|
854
|
+
byKeys.set(bindingKeys ?? NO_MAP, cache);
|
|
855
|
+
}
|
|
856
|
+
return cache;
|
|
857
|
+
};
|
|
784
858
|
const extractAttributes = (attributes, source) => {
|
|
785
859
|
const allAttrs = [];
|
|
786
860
|
const dataAttrs = [];
|
|
@@ -872,13 +946,13 @@ const createFragmentNode = (textContent, children) => ({
|
|
|
872
946
|
children,
|
|
873
947
|
isFragment: true
|
|
874
948
|
});
|
|
875
|
-
const processChildrenBinding = (jsxElement, processedNodes, shouldWrap = true, source) => {
|
|
949
|
+
const processChildrenBinding = (jsxElement, processedNodes, shouldWrap = true, source, options) => {
|
|
876
950
|
const jsxChildren = jsxElement.children.filter((child) => import_lib$1.isJSXElement(child) || import_lib$1.isJSXFragment(child));
|
|
877
951
|
if (!jsxChildren.length) return;
|
|
878
952
|
const childrenNodes = [];
|
|
879
953
|
jsxChildren.forEach((child) => {
|
|
880
954
|
if (import_lib$1.isJSXElement(child)) {
|
|
881
|
-
const childResults = extractFromNode(child, processedNodes, source);
|
|
955
|
+
const childResults = extractFromNode(child, processedNodes, source, options);
|
|
882
956
|
if (shouldWrap) {
|
|
883
957
|
const wrapperNode = createWrapperNode(collectText(child.children), childResults);
|
|
884
958
|
wrapperNode.source = source?.slice(child.start, child.end);
|
|
@@ -891,7 +965,7 @@ const processChildrenBinding = (jsxElement, processedNodes, shouldWrap = true, s
|
|
|
891
965
|
const fragmentChildren = [];
|
|
892
966
|
child.children.forEach((fragmentChild) => {
|
|
893
967
|
if (import_lib$1.isJSXElement(fragmentChild)) {
|
|
894
|
-
const childResults = extractFromNode(fragmentChild, processedNodes, source);
|
|
968
|
+
const childResults = extractFromNode(fragmentChild, processedNodes, source, options);
|
|
895
969
|
fragmentChildren.push(...childResults);
|
|
896
970
|
}
|
|
897
971
|
});
|
|
@@ -928,13 +1002,14 @@ const getBindingExpression = (opening) => {
|
|
|
928
1002
|
}
|
|
929
1003
|
return null;
|
|
930
1004
|
};
|
|
931
|
-
const readNodeBindingInfo = (node, source) => {
|
|
1005
|
+
const readNodeBindingInfo = (node, source, options) => {
|
|
932
1006
|
const opening = node.openingElement;
|
|
933
1007
|
const tagName = getJSXTagName(opening);
|
|
934
1008
|
const { allAttrs, dataAttrs } = extractAttributes(opening.attributes, source);
|
|
935
1009
|
const bindingAttr = dataAttrs.find((attr) => attr.name === DATA_ATTR.BINDING);
|
|
936
1010
|
const bindingExpr = getBindingExpression(opening);
|
|
937
|
-
const
|
|
1011
|
+
const keyAttr = dataAttrs.find((attr) => attr.name === DATA_ATTR.BINDING_KEY);
|
|
1012
|
+
const bindings = resolveBindings(bindingExpr ? parseBindingExpression(bindingExpr) : bindingAttr ? parseBinding(bindingAttr.value) : void 0, keyAttr && (keyAttr.isStringLiteral ? keyAttr.value : null), tagName, options);
|
|
938
1013
|
const childrenBinding = bindings.find((b) => b.property === BINDING_PROP.CHILDREN);
|
|
939
1014
|
const arrayBindings = bindings.filter((b) => b.property === BINDING_PROP.ITEMS || b.type === "array");
|
|
940
1015
|
const innerHtmlBinding = bindings.find((b) => b.property === BINDING_PROP.INNER_HTML);
|
|
@@ -950,7 +1025,7 @@ const readNodeBindingInfo = (node, source) => {
|
|
|
950
1025
|
rawChildren
|
|
951
1026
|
};
|
|
952
1027
|
};
|
|
953
|
-
const parseToNodes = (raw) => {
|
|
1028
|
+
const parseToNodes = (raw, options) => {
|
|
954
1029
|
const wrapped = wrap(raw);
|
|
955
1030
|
const ast = (0, import_lib.parse)(wrapped, {
|
|
956
1031
|
sourceType: "module",
|
|
@@ -961,10 +1036,10 @@ const parseToNodes = (raw) => {
|
|
|
961
1036
|
const processedNodes = /* @__PURE__ */ new WeakSet();
|
|
962
1037
|
traverse(ast, { JSXElement(path) {
|
|
963
1038
|
if (processedNodes.has(path.node)) return;
|
|
964
|
-
const { tagName, allAttrs, dataAttrs, bindings, childrenBinding, arrayBindings, rawChildren } = readNodeBindingInfo(path.node, wrapped);
|
|
1039
|
+
const { tagName, allAttrs, dataAttrs, bindings, childrenBinding, arrayBindings, rawChildren } = readNodeBindingInfo(path.node, wrapped, options);
|
|
965
1040
|
if (!tagName || !dataAttrs.length) return;
|
|
966
1041
|
let childrenNodes;
|
|
967
|
-
if (childrenBinding) childrenNodes = processChildrenBinding(path.node, processedNodes, true, wrapped);
|
|
1042
|
+
if (childrenBinding) childrenNodes = processChildrenBinding(path.node, processedNodes, true, wrapped, options);
|
|
968
1043
|
for (const arrayBinding of arrayBindings) skipItemsChildren(path.node, processedNodes, arrayBinding.property);
|
|
969
1044
|
results.push({
|
|
970
1045
|
tagName,
|
|
@@ -988,18 +1063,19 @@ const parseToNodes = (raw) => {
|
|
|
988
1063
|
} });
|
|
989
1064
|
return results;
|
|
990
1065
|
};
|
|
991
|
-
function extract(raw) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1066
|
+
function extract(raw, options = {}) {
|
|
1067
|
+
const cache = cacheFor(options);
|
|
1068
|
+
if (cache.has(raw)) return cache.get(raw);
|
|
1069
|
+
const results = parseToNodes(raw, options);
|
|
1070
|
+
cache.set(raw, results);
|
|
995
1071
|
return results;
|
|
996
1072
|
}
|
|
997
|
-
function extractFromNode(node, processedNodes, source) {
|
|
1073
|
+
function extractFromNode(node, processedNodes, source, options) {
|
|
998
1074
|
processedNodes?.add(node);
|
|
999
|
-
const { tagName, allAttrs, dataAttrs, bindings, childrenBinding, rawChildren } = readNodeBindingInfo(node, source);
|
|
1075
|
+
const { tagName, allAttrs, dataAttrs, bindings, childrenBinding, rawChildren } = readNodeBindingInfo(node, source, options);
|
|
1000
1076
|
let childrenNodes;
|
|
1001
|
-
if (childrenBinding) childrenNodes = processChildrenBinding(node, processedNodes, true, source);
|
|
1002
|
-
if (!childrenNodes) childrenNodes = processChildrenBinding(node, processedNodes, false, source);
|
|
1077
|
+
if (childrenBinding) childrenNodes = processChildrenBinding(node, processedNodes, true, source, options);
|
|
1078
|
+
if (!childrenNodes) childrenNodes = processChildrenBinding(node, processedNodes, false, source, options);
|
|
1003
1079
|
return [{
|
|
1004
1080
|
tagName,
|
|
1005
1081
|
attributes: allAttrs,
|
|
@@ -1012,6 +1088,7 @@ function extractFromNode(node, processedNodes, source) {
|
|
|
1012
1088
|
}
|
|
1013
1089
|
function clearExtractCache() {
|
|
1014
1090
|
extractCache.clear();
|
|
1091
|
+
optionExtractCaches = /* @__PURE__ */ new WeakMap();
|
|
1015
1092
|
}
|
|
1016
1093
|
registerEditorCache(clearExtractCache);
|
|
1017
1094
|
//#endregion
|
|
@@ -1061,13 +1138,13 @@ const copySource = (source, usedIds) => {
|
|
|
1061
1138
|
});
|
|
1062
1139
|
return applyEdits(source, edits);
|
|
1063
1140
|
};
|
|
1064
|
-
const editChildrenSource = (source, parent, input) => {
|
|
1141
|
+
const editChildrenSource = (source, parent, input, options) => {
|
|
1065
1142
|
try {
|
|
1066
1143
|
if (!parent.closingElement || parent.start == null || parent.end == null) return null;
|
|
1067
1144
|
const value = typeof input === "string" ? JSON.parse(input) : input;
|
|
1068
1145
|
const children = parent.children.filter((child) => import_lib$1.isJSXElement(child) || import_lib$1.isJSXFragment(child));
|
|
1069
1146
|
const raw = children.map((child) => source.slice(child.start, child.end));
|
|
1070
|
-
const models = extract(source.slice(parent.start, parent.end))[0]?.children ?? [];
|
|
1147
|
+
const models = extract(source.slice(parent.start, parent.end), options)[0]?.children ?? [];
|
|
1071
1148
|
if (models.length !== children.length) return null;
|
|
1072
1149
|
const signatures = modeledSignatures(models);
|
|
1073
1150
|
const replaceSlots = (next) => {
|
|
@@ -1340,7 +1417,7 @@ const canEditAttributeValue = (attribute, value, type) => {
|
|
|
1340
1417
|
if (!import_lib$1.isJSXExpressionContainer(attribute.value) || import_lib$1.isJSXEmptyExpression(attribute.value.expression) || isLosslesslyEvaluable(attribute.value.expression)) return true;
|
|
1341
1418
|
return typeof value === "string" && holdsStructuralExpression(attribute.value) && !(type && STRING_VALUED_TYPES.has(type)) && structuralSource(value) !== null;
|
|
1342
1419
|
};
|
|
1343
|
-
const update = (code, dataId, label, value, property) => {
|
|
1420
|
+
const update = (code, dataId, label, value, property, options = {}) => {
|
|
1344
1421
|
try {
|
|
1345
1422
|
const wrapped = wrap(code);
|
|
1346
1423
|
const ast = (0, import_lib.parse)(wrapped, {
|
|
@@ -1364,25 +1441,38 @@ const update = (code, dataId, label, value, property) => {
|
|
|
1364
1441
|
return import_lib$1.isJSXAttribute(attr) && import_lib$1.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.ID && attr.value && import_lib$1.isStringLiteral(attr.value) && attr.value.value === dataId;
|
|
1365
1442
|
})) return;
|
|
1366
1443
|
const bindingAttr = opening.attributes.find((attr) => import_lib$1.isJSXAttribute(attr) && import_lib$1.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.BINDING);
|
|
1367
|
-
if (!bindingAttr
|
|
1444
|
+
if (bindingAttr && !bindingAttr.value) {
|
|
1368
1445
|
failure = {
|
|
1369
1446
|
reason: "no-binding",
|
|
1370
1447
|
dataId
|
|
1371
1448
|
};
|
|
1372
1449
|
return;
|
|
1373
1450
|
}
|
|
1374
|
-
let
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1377
|
-
bindingValue =
|
|
1378
|
-
|
|
1451
|
+
let own;
|
|
1452
|
+
if (bindingAttr?.value) {
|
|
1453
|
+
let bindingValue = "";
|
|
1454
|
+
if (import_lib$1.isStringLiteral(bindingAttr.value)) bindingValue = bindingAttr.value.value;
|
|
1455
|
+
else if (import_lib$1.isJSXExpressionContainer(bindingAttr.value)) try {
|
|
1456
|
+
bindingValue = generateCode(bindingAttr.value.expression);
|
|
1457
|
+
} catch (error) {
|
|
1458
|
+
failure = {
|
|
1459
|
+
reason: "parse-error",
|
|
1460
|
+
error
|
|
1461
|
+
};
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
own = parseBinding(bindingValue);
|
|
1465
|
+
}
|
|
1466
|
+
const keyAttr = opening.attributes.find((attr) => import_lib$1.isJSXAttribute(attr) && import_lib$1.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.BINDING_KEY);
|
|
1467
|
+
const bindings = resolveBindings(own, keyAttr && (keyAttr.value && import_lib$1.isStringLiteral(keyAttr.value) ? keyAttr.value.value : null), getJSXTagName(opening), options);
|
|
1468
|
+
if (!own && bindings.length === 0) {
|
|
1379
1469
|
failure = {
|
|
1380
|
-
reason: "
|
|
1381
|
-
|
|
1470
|
+
reason: "no-binding",
|
|
1471
|
+
dataId
|
|
1382
1472
|
};
|
|
1383
1473
|
return;
|
|
1384
1474
|
}
|
|
1385
|
-
const matches =
|
|
1475
|
+
const matches = bindings.filter((binding) => property !== void 0 ? binding.property === property : binding.label === label);
|
|
1386
1476
|
if (matches.length === 0) {
|
|
1387
1477
|
failure = {
|
|
1388
1478
|
reason: "binding-not-declared",
|
|
@@ -1443,7 +1533,7 @@ const update = (code, dataId, label, value, property) => {
|
|
|
1443
1533
|
};
|
|
1444
1534
|
break;
|
|
1445
1535
|
}
|
|
1446
|
-
collect(editChildrenSource(wrapped, path.node, value), () => ({
|
|
1536
|
+
collect(editChildrenSource(wrapped, path.node, value, options), () => ({
|
|
1447
1537
|
reason: "parse-error",
|
|
1448
1538
|
error: /* @__PURE__ */ new Error("Unsupported or stale children edit; source was preserved")
|
|
1449
1539
|
}));
|
|
@@ -1506,10 +1596,10 @@ const update = (code, dataId, label, value, property) => {
|
|
|
1506
1596
|
};
|
|
1507
1597
|
}
|
|
1508
1598
|
};
|
|
1509
|
-
const updateAll = (raw, entries) => {
|
|
1599
|
+
const updateAll = (raw, entries, options = {}) => {
|
|
1510
1600
|
let current = raw;
|
|
1511
1601
|
for (const [index, entry] of entries.entries()) {
|
|
1512
|
-
const result = update(current, entry.dataId, entry.label, entry.value, entry.property);
|
|
1602
|
+
const result = update(current, entry.dataId, entry.label, entry.value, entry.property, options);
|
|
1513
1603
|
if (!result.success) return {
|
|
1514
1604
|
success: false,
|
|
1515
1605
|
code: raw,
|
|
@@ -1598,6 +1688,6 @@ const validateBindingValue = (binding, value) => {
|
|
|
1598
1688
|
return VALID;
|
|
1599
1689
|
};
|
|
1600
1690
|
//#endregion
|
|
1601
|
-
export {
|
|
1691
|
+
export { createNodeFromValue as A, isComponentTagName as C, resolveBindings as D, readNodeBindings as E, parseValue as F, setEditableValue as I, extractObjectProperties as M, flattenEditableValue as N, arrayExpressionToCode as O, parseArrayExpression as P, getStructuredValue as S, parseBindingExpression as T, moveSelectedIndices as _, getChildrenSignatures as a, getKeyBindings as b, appendArrayItem as c, moveArrayItems as d, parseItems as f, canStructurallyEditArray as g, updateArrayItemValue as h, updateAll as i, extractNodeValue as j, canLosslesslyEvaluateSource as k, duplicateArrayItems as l, updateArrayItemProperty as m, bulkUpdate as n, clearExtractCache as o, removeArrayItems as p, update as r, extract as s, validateBindingValue as t, moveArrayItem as u, findEditableChildren as v, parseBinding as w, getRegistryBindings as x, getCurrentValue as y };
|
|
1602
1692
|
|
|
1603
|
-
//# sourceMappingURL=ast-
|
|
1693
|
+
//# sourceMappingURL=ast-dYb78955.js.map
|