@jbpark/live-editor 1.16.2 → 1.16.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.
Files changed (41) hide show
  1. package/dist/{ast-DK9INzeu.js → ast-B8j1_KHl.js} +3 -13
  2. package/dist/ast-B8j1_KHl.js.map +1 -0
  3. package/dist/{boundary-BWBdNmNi.js → boundary-D4D9lTGj.js} +2 -2
  4. package/dist/{boundary-BWBdNmNi.js.map → boundary-D4D9lTGj.js.map} +1 -1
  5. package/dist/{context-DrqO0VVu.js → context-Dp9_x2pr.js} +3 -3
  6. package/dist/{context-DrqO0VVu.js.map → context-Dp9_x2pr.js.map} +1 -1
  7. package/dist/{core-B7igZRDs.js → core-J-1gMmiH.js} +2 -2
  8. package/dist/{core-B7igZRDs.js.map → core-J-1gMmiH.js.map} +1 -1
  9. package/dist/dnd/index.d.ts +1 -1
  10. package/dist/dnd/index.js +1 -1
  11. package/dist/{dnd-CQDivnZZ.js → dnd-BLt8M5Ku.js} +103 -111
  12. package/dist/dnd-BLt8M5Ku.js.map +1 -0
  13. package/dist/{document-CSIscFpL.js → document-B5jioCvf.js} +43 -5
  14. package/dist/document-B5jioCvf.js.map +1 -0
  15. package/dist/{document-DXOwpvWM.d.ts → document-J9Lo9p81.d.ts} +3 -2
  16. package/dist/editor/index.js +2 -2
  17. package/dist/{editor-DmgTeTcG.js → editor-BquxydTJ.js} +3 -3
  18. package/dist/{editor-DmgTeTcG.js.map → editor-BquxydTJ.js.map} +1 -1
  19. package/dist/error/index.js +2 -2
  20. package/dist/{error-ClMPS96R.js → error-qjC08--G.js} +2 -2
  21. package/dist/{error-ClMPS96R.js.map → error-qjC08--G.js.map} +1 -1
  22. package/dist/{index-CfuDi3An.d.ts → index-C880EB6c.d.ts} +3 -3
  23. package/dist/{index-rlgLRNsK.d.ts → index-DB_TAhtd.d.ts} +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +5 -5
  26. package/dist/preview/index.js +1 -1
  27. package/dist/{preview-j-rIHbDN.js → preview-DS80nl6F.js} +4 -4
  28. package/dist/{preview-j-rIHbDN.js.map → preview-DS80nl6F.js.map} +1 -1
  29. package/dist/provider/index.js +1 -1
  30. package/dist/{use-dynamic-tailwind-D-EEKBIy.js → use-dynamic-tailwind-Biw9EHLI.js} +2 -2
  31. package/dist/{use-dynamic-tailwind-D-EEKBIy.js.map → use-dynamic-tailwind-Biw9EHLI.js.map} +1 -1
  32. package/dist/utils/ast/index.d.ts +3 -3
  33. package/dist/utils/ast/index.js +3 -3
  34. package/dist/utils/index.d.ts +1 -1
  35. package/dist/utils/index.js +2 -2
  36. package/dist/{utils-BzfDKU6y.js → utils-DPdkZJ4i.js} +2 -2
  37. package/dist/{utils-BzfDKU6y.js.map → utils-DPdkZJ4i.js.map} +1 -1
  38. package/package.json +1 -1
  39. package/dist/ast-DK9INzeu.js.map +0 -1
  40. package/dist/dnd-CQDivnZZ.js.map +0 -1
  41. package/dist/document-CSIscFpL.js.map +0 -1
@@ -39714,10 +39714,20 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
39714
39714
  traverse.cache = cache;
39715
39715
  }));
39716
39716
  //#endregion
39717
- //#region src/utils/cache.ts
39717
+ //#region node_modules/.pnpm/nanoid@3.3.18/node_modules/nanoid/index.browser.js
39718
39718
  var import_lib = require_lib$7();
39719
39719
  var import_lib$2 = /* @__PURE__ */ __toESM(require_lib$4(), 1);
39720
39720
  var import_lib$1 = /* @__PURE__ */ __toESM(require_lib(), 1);
39721
+ let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
39722
+ byte &= 63;
39723
+ if (byte < 36) id += byte.toString(36);
39724
+ else if (byte < 62) id += (byte - 26).toString(36).toUpperCase();
39725
+ else if (byte > 62) id += "-";
39726
+ else id += "_";
39727
+ return id;
39728
+ }, "");
39729
+ //#endregion
39730
+ //#region src/utils/cache.ts
39721
39731
  const createBoundedCache = (limit, onEvict) => {
39722
39732
  const store = /* @__PURE__ */ new Map();
39723
39733
  const get = (key) => {
@@ -39774,8 +39784,9 @@ const getTagName = (element) => {
39774
39784
  const name = element.openingElement.name;
39775
39785
  return import_lib$2.isJSXIdentifier(name) ? name.name : "";
39776
39786
  };
39787
+ const getAttr = (element, attrName) => element.openingElement.attributes.find((a) => import_lib$2.isJSXAttribute(a) && import_lib$2.isJSXIdentifier(a.name) && a.name.name === attrName);
39777
39788
  const getAttrValue = (element, attrName) => {
39778
- const attr = element.openingElement.attributes.find((a) => import_lib$2.isJSXAttribute(a) && import_lib$2.isJSXIdentifier(a.name) && a.name.name === attrName);
39789
+ const attr = getAttr(element, attrName);
39779
39790
  return attr && import_lib$2.isStringLiteral(attr.value) ? attr.value.value : void 0;
39780
39791
  };
39781
39792
  const isSectionElement = (node) => import_lib$2.isJSXElement(node) && getTagName(node) === SECTION_TAG;
@@ -39829,10 +39840,37 @@ const clearDocumentParseCache = () => {
39829
39840
  documentCache.clear();
39830
39841
  };
39831
39842
  const getSections = (doc) => findOutermostSections(doc.container.children).map((node, index) => ({
39832
- id: `${index}`,
39843
+ id: getAttrValue(node, DATA_ATTR.ID) || `${index}`,
39833
39844
  name: getAttrValue(node, DATA_NAME_ATTR) || `${index + 1}번째 컴포넌트`,
39834
39845
  code: doc.code.slice(node.start, node.end)
39835
39846
  }));
39847
+ const fillSectionIds = (code, generateId = () => nanoid(6)) => {
39848
+ const doc = parseDocument(code);
39849
+ if (!doc) return code;
39850
+ const seen = /* @__PURE__ */ new Set();
39851
+ const edits = [];
39852
+ findOutermostSections(doc.container.children).forEach((node) => {
39853
+ const attr = getAttr(node, DATA_ATTR.ID);
39854
+ const id = attr && import_lib$2.isStringLiteral(attr.value) ? attr.value.value : void 0;
39855
+ if (id && !seen.has(id)) {
39856
+ seen.add(id);
39857
+ return;
39858
+ }
39859
+ const nextId = generateId();
39860
+ seen.add(nextId);
39861
+ edits.push(attr ? {
39862
+ start: attr.start,
39863
+ end: attr.end,
39864
+ text: `${DATA_ATTR.ID}="${nextId}"`
39865
+ } : {
39866
+ start: node.openingElement.name.end,
39867
+ end: node.openingElement.name.end,
39868
+ text: ` ${DATA_ATTR.ID}="${nextId}"`
39869
+ });
39870
+ });
39871
+ if (!edits.length) return code;
39872
+ return edits.reduceRight((acc, edit) => `${acc.slice(0, edit.start)}${edit.text}${acc.slice(edit.end)}`, code);
39873
+ };
39836
39874
  const generateDocumentCode = (doc) => doc.code;
39837
39875
  const getContainerInnerSpan = (container) => {
39838
39876
  if (!container.closingElement) return;
@@ -39925,6 +39963,6 @@ const createSectionPreviewCache = () => {
39925
39963
  return { compute };
39926
39964
  };
39927
39965
  //#endregion
39928
- export { DEFAULT_TEMPLATE as _, generateSectionPreviews as a, TS_PATTERNS as b, replaceDocumentSections as c, require_lib$3 as d, require_lib$4 as f, DATA_ATTR as g, CONFIG as h, generateSectionPreview as i, traverse as l, BINDING_PROP as m, createSectionPreviewCache as n, getSections as o, require_lib$7 as p, generateDocumentCode as r, parseDocument as s, clearDocumentParseCache as t, createBoundedCache as u, DRAGGABLE_ITEMS as v, __toESM as x, REGEX as y };
39966
+ export { __toESM as C, TS_PATTERNS as S, CONFIG as _, generateSectionPreview as a, DRAGGABLE_ITEMS as b, parseDocument as c, createBoundedCache as d, nanoid as f, BINDING_PROP as g, require_lib$7 as h, generateDocumentCode as i, replaceDocumentSections as l, require_lib$4 as m, createSectionPreviewCache as n, generateSectionPreviews as o, require_lib$3 as p, fillSectionIds as r, getSections as s, clearDocumentParseCache as t, traverse as u, DATA_ATTR as v, REGEX as x, DEFAULT_TEMPLATE as y };
39929
39967
 
39930
- //# sourceMappingURL=document-CSIscFpL.js.map
39968
+ //# sourceMappingURL=document-B5jioCvf.js.map