domflax 0.1.2 → 0.1.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 (46) hide show
  1. package/README.md +25 -8
  2. package/dist/{chunk-DNHOGPYV.js → chunk-3Z5ZWLXX.js} +407 -51
  3. package/dist/chunk-3Z5ZWLXX.js.map +1 -0
  4. package/dist/{chunk-DOQEBGWB.js → chunk-5FWENSD2.js} +63 -8
  5. package/dist/chunk-5FWENSD2.js.map +1 -0
  6. package/dist/chunk-EVENAJYI.js +336 -0
  7. package/dist/chunk-EVENAJYI.js.map +1 -0
  8. package/dist/{chunk-DWLB7FRR.js → chunk-H5KTGI3A.js} +153 -7
  9. package/dist/chunk-H5KTGI3A.js.map +1 -0
  10. package/dist/{chunk-6WVVF6AD.js → chunk-U5GOONKV.js} +5 -2
  11. package/dist/{chunk-6WVVF6AD.js.map → chunk-U5GOONKV.js.map} +1 -1
  12. package/dist/cli.cjs +995 -166
  13. package/dist/cli.cjs.map +1 -1
  14. package/dist/cli.js +245 -229
  15. package/dist/cli.js.map +1 -1
  16. package/dist/index.cjs +614 -68
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +34 -18
  19. package/dist/index.d.ts +34 -18
  20. package/dist/index.js +4 -4
  21. package/dist/{pattern-F5xBtIE-.d.cts → pattern-CP9_HpVK.d.cts} +1 -1
  22. package/dist/{pattern-CV607P87.d.ts → pattern-CYgsv-jO.d.ts} +1 -1
  23. package/dist/pattern-kit.cjs.map +1 -1
  24. package/dist/pattern-kit.d.cts +2 -2
  25. package/dist/pattern-kit.d.ts +2 -2
  26. package/dist/pattern-kit.js +2 -2
  27. package/dist/{resolve-ops-DIwEelH-.d.ts → resolve-ops-Ci7LgYHC.d.cts} +9 -0
  28. package/dist/{resolve-ops-DIwEelH-.d.cts → resolve-ops-Ci7LgYHC.d.ts} +9 -0
  29. package/dist/verify.d.cts +1 -1
  30. package/dist/verify.d.ts +1 -1
  31. package/dist/verify.js +1 -1
  32. package/dist/webpack-loader.cjs +614 -68
  33. package/dist/webpack-loader.cjs.map +1 -1
  34. package/dist/webpack-loader.d.cts +2 -2
  35. package/dist/webpack-loader.d.ts +2 -2
  36. package/dist/webpack-loader.js +4 -4
  37. package/dist/worker.cjs +5955 -0
  38. package/dist/worker.cjs.map +1 -0
  39. package/dist/worker.d.cts +2 -0
  40. package/dist/worker.d.ts +2 -0
  41. package/dist/worker.js +72 -0
  42. package/dist/worker.js.map +1 -0
  43. package/package.json +4 -2
  44. package/dist/chunk-DNHOGPYV.js.map +0 -1
  45. package/dist/chunk-DOQEBGWB.js.map +0 -1
  46. package/dist/chunk-DWLB7FRR.js.map +0 -1
@@ -4,6 +4,7 @@ import {
4
4
  and,
5
5
  computed,
6
6
  conditionKey,
7
+ createComment,
7
8
  createDocument,
8
9
  createElement,
9
10
  createExpr,
@@ -18,11 +19,11 @@ import {
18
19
  normalizer,
19
20
  not,
20
21
  targetedByCombinator
21
- } from "./chunk-DWLB7FRR.js";
22
+ } from "./chunk-H5KTGI3A.js";
22
23
  import {
23
24
  __filename,
24
25
  init_esm_shims
25
- } from "./chunk-6WVVF6AD.js";
26
+ } from "./chunk-U5GOONKV.js";
26
27
 
27
28
  // ../patterns/src/library/flatten/display-contents-wrapper.pattern.ts
28
29
  init_esm_shims();
@@ -184,19 +185,28 @@ var flexCenterWrapper = definePattern({
184
185
  flattenInto: "child",
185
186
  childGains: { placeSelf: "center" }
186
187
  },
187
- // Collapsing a flex-centering wrapper to `place-self:center` on the child only stays centered when
188
- // the child's NEW parent is flex/grid; moreover the wrapper's own `display:flex` establishes a
189
- // formatting context. Both make this a `needs-verification` flatten, which the conservative
190
- // production gate (`'provably-safe'`, used by the harness) intentionally REVERTSso every case
191
- // here is a no-match: the wrapper is preserved. Op-level rewrite correctness (purity, id-preserving
192
- // unwrap, opacity-barrier safety) is still asserted by the invariant suite over every pattern.
188
+ // Collapsing a flex-centering wrapper to `place-self:center` on the child is render-identical ONLY
189
+ // when the child's NEW parent is a statically-known GRID that lets the wrapper fill its area (there
190
+ // `place-self`'s align-self AND justify-self both take effect). Under that ONE context the flatten is
191
+ // classified `provably-safe` and commits; under a flex/block/unknown parentor when the wrapper
192
+ // drops any own style it stays `needs-verification` and the conservative production gate PRESERVES
193
+ // it. Op-level correctness (purity, id-preserving unwrap, opacity-barrier safety) is additionally
194
+ // asserted by the invariant suite over every pattern.
193
195
  test: {
196
+ cases: [
197
+ {
198
+ name: "grid parent \u2192 flattened (child gains place-self-center)",
199
+ before: '<div className="grid"><div className="flex items-center justify-center"><span className="bg-red-200">x</span></div></div>',
200
+ after: '<div className="grid"><span className="bg-red-200 place-self-center">x</span></div>'
201
+ }
202
+ ],
194
203
  noMatch: [
195
- // Even under a static flex/grid parent the centering flatten is not provably layout-neutral
196
- // (the wrapper itself establishes a flex formatting context) → left unchanged.
197
- '<div className="grid"><div className="flex items-center justify-center"><span className="bg-red-200">x</span></div></div>',
198
- // Non-flex/grid parent (document root): place-self centering would not hold → left unchanged.
204
+ // Non-grid (flex) parent (document root): `justify-self` is ignored in flex → not provably safe.
199
205
  '<div className="flex justify-center items-center"><div className="bg-red-200">Hello</div></div>',
206
+ // Grid parent, but the wrapper drops padding when removed → not layout-neutral (rule 3).
207
+ '<div className="grid"><div className="p-4 flex items-center justify-center"><span className="bg-red-200">x</span></div></div>',
208
+ // Grid parent forcing place-items-center: the wrapper would not fill its area → fill guard skips.
209
+ '<div className="grid place-items-center"><div className="flex items-center justify-center"><span className="bg-red-200">x</span></div></div>',
200
210
  // onClick is a hard opacity barrier → the wrapper is load-bearing regardless of the gate.
201
211
  '<div className="flex justify-center items-center" onClick={handleClick}><div className="bg-red-200">Hello</div></div>'
202
212
  ]
@@ -2695,6 +2705,350 @@ function createCssResolver(cssFiles = [], options) {
2695
2705
  // ../resolver-css/src/index.ts
2696
2706
  init_esm_shims();
2697
2707
 
2708
+ // ../frontend-html/src/index.ts
2709
+ init_esm_shims();
2710
+
2711
+ // ../frontend-html/src/backend.ts
2712
+ init_esm_shims();
2713
+ import MagicString from "magic-string";
2714
+ function staticTokensOf(classes) {
2715
+ const out = [];
2716
+ for (const seg of classes.segments) {
2717
+ if (seg.kind === "static") for (const t of seg.tokens) out.push(t.value);
2718
+ }
2719
+ return out;
2720
+ }
2721
+ function sameTokens(a, b) {
2722
+ if (a.length !== b.length) return false;
2723
+ for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
2724
+ return true;
2725
+ }
2726
+ function primarySource(doc) {
2727
+ for (const sf of doc.sources.values()) {
2728
+ if (typeof sf.text === "string" && sf.text.length > 0) return sf;
2729
+ }
2730
+ return null;
2731
+ }
2732
+ function collectKept(doc) {
2733
+ const out = [];
2734
+ const seen = /* @__PURE__ */ new Set();
2735
+ const visit = (id) => {
2736
+ if (seen.has(id)) return;
2737
+ seen.add(id);
2738
+ const n = doc.nodes.get(id);
2739
+ if (!n) return;
2740
+ out.push(n);
2741
+ if (n.kind === "element" || n.kind === "fragment") for (const c of n.children) visit(c);
2742
+ };
2743
+ visit(doc.root);
2744
+ return out;
2745
+ }
2746
+ function strictlyContains(a, b) {
2747
+ if (a.file !== b.file) return false;
2748
+ if (a.start <= b.start && b.end <= a.end) return !(a.start === b.start && a.end === b.end);
2749
+ return false;
2750
+ }
2751
+ function backrefIds(doc) {
2752
+ const out = [];
2753
+ const max = doc.alloc.peek;
2754
+ for (let i = 1; i < max; i += 1) {
2755
+ const id = i;
2756
+ if (doc.backref.get(id)) out.push(id);
2757
+ }
2758
+ return out;
2759
+ }
2760
+ function currentTokens(sf, valueSpan) {
2761
+ const raw = sf.text.slice(valueSpan.start, valueSpan.end).trim();
2762
+ const unquoted = raw.replace(/^['"]/, "").replace(/['"]$/, "");
2763
+ return unquoted.split(/\s+/).filter((t) => t.length > 0);
2764
+ }
2765
+ function editClasses(ms, doc, sf, el) {
2766
+ const classes = el.classes;
2767
+ if (classes.hasDynamic || classes.opaque) return false;
2768
+ const tokens = staticTokensOf(classes);
2769
+ const valueSpan = classes.valueSpan;
2770
+ if (valueSpan && valueSpan.file === sf.id) {
2771
+ if (sameTokens(currentTokens(sf, valueSpan), tokens)) return false;
2772
+ const current = sf.text.slice(valueSpan.start, valueSpan.end).trim();
2773
+ const quote = current.startsWith("'") ? "'" : '"';
2774
+ ms.overwrite(valueSpan.start, valueSpan.end, `${quote}${tokens.join(" ")}${quote}`);
2775
+ return true;
2776
+ }
2777
+ if (tokens.length === 0) return false;
2778
+ const openTag = doc.backref.get(el.id)?.openTagSpan;
2779
+ if (!openTag || openTag.file !== sf.id) return false;
2780
+ ms.appendLeft(openTag.start + 1 + el.tag.length, ` class="${tokens.join(" ")}"`);
2781
+ return true;
2782
+ }
2783
+ function surgicalPrint(doc) {
2784
+ const sf = primarySource(doc);
2785
+ if (!sf) return null;
2786
+ const ms = new MagicString(sf.text);
2787
+ const kept = collectKept(doc);
2788
+ const keptSpans = [];
2789
+ for (const n of kept) if (n.span && n.span.file === sf.id) keptSpans.push(n.span);
2790
+ const removed = [];
2791
+ for (const id of backrefIds(doc)) {
2792
+ if (doc.nodes.has(id)) continue;
2793
+ const back = doc.backref.get(id);
2794
+ if (!back || back.span.file !== sf.id) continue;
2795
+ const unwrapped = keptSpans.some((k) => strictlyContains(back.span, k));
2796
+ removed.push({ backref: back, unwrapped });
2797
+ }
2798
+ const fullRemovals = removed.filter((r) => !r.unwrapped).map((r) => r.backref.span);
2799
+ for (const r of removed) {
2800
+ const s = r.backref.span;
2801
+ if (fullRemovals.some((f) => f !== s && strictlyContains(f, s))) continue;
2802
+ if (r.unwrapped) {
2803
+ const open = r.backref.openTagSpan;
2804
+ const close = r.backref.closeTagSpan;
2805
+ if (open && open.file === sf.id && open.end > open.start) ms.remove(open.start, open.end);
2806
+ if (close && close.file === sf.id && close.end > close.start) ms.remove(close.start, close.end);
2807
+ } else {
2808
+ ms.remove(s.start, s.end);
2809
+ }
2810
+ }
2811
+ for (const n of kept) if (n.kind === "element") editClasses(ms, doc, sf, n);
2812
+ return ms.toString();
2813
+ }
2814
+ function doPrint(doc) {
2815
+ return surgicalPrint(doc) ?? "";
2816
+ }
2817
+
2818
+ // ../frontend-html/src/parse.ts
2819
+ init_esm_shims();
2820
+ import { createRequire as createRequire3 } from "module";
2821
+
2822
+ // ../frontend-html/src/walk.ts
2823
+ init_esm_shims();
2824
+ var HTML_LANGS = ["html"];
2825
+ var FILE_ID = 1;
2826
+ function looksLikeHtml(id, code) {
2827
+ if (/\.html?$/i.test(id)) return true;
2828
+ const head = code.slice(0, 256).trimStart().toLowerCase();
2829
+ return head.startsWith("<!doctype html") || head.startsWith("<html") || head.startsWith("<");
2830
+ }
2831
+ var OPAQUE_SUBTREE_TAGS = /* @__PURE__ */ new Set([
2832
+ "script",
2833
+ "style",
2834
+ "template",
2835
+ "svg",
2836
+ "pre",
2837
+ "textarea"
2838
+ ]);
2839
+ function isOpaqueSubtreeTag(tag) {
2840
+ return OPAQUE_SUBTREE_TAGS.has(tag);
2841
+ }
2842
+ function elementIsOpaque(attrs) {
2843
+ for (const a of attrs) {
2844
+ const n = a.name.toLowerCase();
2845
+ if (n === "id" || n === "contenteditable") return true;
2846
+ if (n.startsWith("on")) return true;
2847
+ }
2848
+ return false;
2849
+ }
2850
+ function hasEventHandler(attrs) {
2851
+ for (const a of attrs) if (/^on/i.test(a.name)) return true;
2852
+ return false;
2853
+ }
2854
+ function span(start, end) {
2855
+ return { file: FILE_ID, start, end };
2856
+ }
2857
+ function attrsLocOf(loc) {
2858
+ if (!loc) return void 0;
2859
+ return loc.startTag?.attrs ?? loc.attrs;
2860
+ }
2861
+ function classValueSpan(loc, source) {
2862
+ const attrsLoc = attrsLocOf(loc);
2863
+ const cl = attrsLoc?.["class"];
2864
+ if (!cl) return null;
2865
+ const text = source.slice(cl.startOffset, cl.endOffset);
2866
+ const eq = text.indexOf("=");
2867
+ if (eq === -1) return null;
2868
+ let i = eq + 1;
2869
+ while (i < text.length && /\s/.test(text[i])) i += 1;
2870
+ if (i >= text.length) return null;
2871
+ return span(cl.startOffset + i, cl.endOffset);
2872
+ }
2873
+
2874
+ // ../frontend-html/src/parse.ts
2875
+ var cachedParse5 = null;
2876
+ function loadParse5() {
2877
+ if (cachedParse5) return cachedParse5;
2878
+ const req = createRequire3(import.meta.url);
2879
+ cachedParse5 = req("parse5");
2880
+ return cachedParse5;
2881
+ }
2882
+ function doParse(code, ctx) {
2883
+ const diagnostics = [];
2884
+ const doc = createDocument("html");
2885
+ const backref = doc.backref;
2886
+ const parse5 = loadParse5();
2887
+ const document = parse5.parse(code, { sourceCodeLocationInfo: true });
2888
+ const eol = code.includes("\r\n") ? "\r\n" : "\n";
2889
+ const sourceFile = {
2890
+ id: FILE_ID,
2891
+ path: ctx.id,
2892
+ text: code,
2893
+ frontend: "html",
2894
+ eol,
2895
+ indentUnit: " ",
2896
+ native: document
2897
+ };
2898
+ doc.sources.set(FILE_ID, sourceFile);
2899
+ const resolveComputed = (tokens, tag, nodeId) => {
2900
+ if (tokens.length === 0) return emptyStyleMap();
2901
+ const res = ctx.resolver.resolve({ classes: tokens, element: { tagName: tag, namespace: "html" } });
2902
+ for (const w of res.warnings) {
2903
+ diagnostics.push({
2904
+ code: "DF_STYLE_CONFLICT_UNRESOLVED",
2905
+ severity: w.severity,
2906
+ message: w.message,
2907
+ nodeId
2908
+ });
2909
+ }
2910
+ return ctx.normalizer.normalizeStyleMap(res.styles);
2911
+ };
2912
+ const splitTokens = (raw) => raw.split(/\s+/).filter((t) => t.length > 0);
2913
+ const appendChild = (node, parentId, out) => {
2914
+ const name = node.nodeName;
2915
+ if (name === "#text") {
2916
+ const value = node.value ?? "";
2917
+ const id = doc.alloc.next();
2918
+ const loc = node.sourceCodeLocation ?? null;
2919
+ doc.nodes.set(
2920
+ id,
2921
+ createText(id, value, {
2922
+ parent: parentId,
2923
+ span: loc ? span(loc.startOffset, loc.endOffset) : null,
2924
+ collapsible: /^\s*$/.test(value)
2925
+ })
2926
+ );
2927
+ out.push(id);
2928
+ return;
2929
+ }
2930
+ if (name === "#comment") {
2931
+ const id = doc.alloc.next();
2932
+ const loc = node.sourceCodeLocation ?? null;
2933
+ doc.nodes.set(
2934
+ id,
2935
+ createComment(id, node.data ?? "", {
2936
+ parent: parentId,
2937
+ span: loc ? span(loc.startOffset, loc.endOffset) : null
2938
+ })
2939
+ );
2940
+ out.push(id);
2941
+ return;
2942
+ }
2943
+ if (name === "#documentType") return;
2944
+ if (name.startsWith("#")) {
2945
+ for (const c of node.childNodes ?? []) appendChild(c, parentId, out);
2946
+ return;
2947
+ }
2948
+ out.push(buildElement(node, parentId));
2949
+ };
2950
+ const buildElement = (node, parentId) => {
2951
+ const id = doc.alloc.next();
2952
+ const tag = (node.tagName ?? node.nodeName).toLowerCase();
2953
+ const loc = node.sourceCodeLocation ?? null;
2954
+ const attrsArr = node.attrs ?? [];
2955
+ const opaqueSubtree = isOpaqueSubtreeTag(tag);
2956
+ const synthetic = loc == null;
2957
+ const opaque = opaqueSubtree || synthetic || elementIsOpaque(attrsArr);
2958
+ const meta = defaultMeta();
2959
+ meta.hasEventHandlers = hasEventHandler(attrsArr);
2960
+ meta.safetyFloor = opaque ? 0 : 3;
2961
+ let classes = emptyClassList();
2962
+ let classTokens = [];
2963
+ const entries = /* @__PURE__ */ new Map();
2964
+ const order = [];
2965
+ for (const a of attrsArr) {
2966
+ if (a.name.toLowerCase() === "class") {
2967
+ classTokens = splitTokens(a.value);
2968
+ const valueSpan = classValueSpan(loc, code);
2969
+ const clAttr = attrsLocOf(loc)?.["class"];
2970
+ const seg = {
2971
+ kind: "static",
2972
+ span: valueSpan ?? void 0,
2973
+ tokens: classTokens.map((value) => ({ value }))
2974
+ };
2975
+ classes = {
2976
+ form: "string-literal",
2977
+ segments: [seg],
2978
+ valueSpan,
2979
+ attrSpan: clAttr ? span(clAttr.startOffset, clAttr.endOffset) : void 0,
2980
+ hasDynamic: false,
2981
+ opaque: false,
2982
+ rewritable: valueSpan != null
2983
+ };
2984
+ continue;
2985
+ }
2986
+ const v = a.value;
2987
+ entries.set(a.name, { kind: "static", value: v === "" ? true : v });
2988
+ order.push(a.name);
2989
+ }
2990
+ const attrs = { entries, spreads: [], order };
2991
+ const computed2 = resolveComputed(classTokens, tag, id);
2992
+ const children = [];
2993
+ if (!opaqueSubtree) {
2994
+ for (const c of node.childNodes ?? []) appendChild(c, id, children);
2995
+ }
2996
+ const el = createElement(id, {
2997
+ tag,
2998
+ namespace: "html",
2999
+ isComponent: false,
3000
+ selfClosing: loc ? loc.endTag == null : false,
3001
+ classes,
3002
+ computed: computed2,
3003
+ attrs,
3004
+ children,
3005
+ parent: parentId,
3006
+ span: loc ? span(loc.startOffset, loc.endOffset) : null,
3007
+ meta
3008
+ });
3009
+ doc.nodes.set(id, el);
3010
+ if (loc) {
3011
+ backref.set(id, {
3012
+ nodeId: id,
3013
+ span: span(loc.startOffset, loc.endOffset),
3014
+ openTagSpan: loc.startTag ? span(loc.startTag.startOffset, loc.startTag.endOffset) : null,
3015
+ closeTagSpan: loc.endTag ? span(loc.endTag.startOffset, loc.endTag.endOffset) : null,
3016
+ innerSpan: null,
3017
+ selfClosing: loc.endTag == null
3018
+ });
3019
+ }
3020
+ return id;
3021
+ };
3022
+ const rootFrag = doc.nodes.get(doc.root);
3023
+ appendChild(document, doc.root, rootFrag.children);
3024
+ return { doc, diagnostics };
3025
+ }
3026
+
3027
+ // ../frontend-html/src/index.ts
3028
+ var htmlFrontend = {
3029
+ name: "html",
3030
+ langs: HTML_LANGS,
3031
+ canParse(id, code) {
3032
+ return looksLikeHtml(id, code);
3033
+ },
3034
+ parse(code, ctx) {
3035
+ return doParse(code, ctx);
3036
+ }
3037
+ };
3038
+ function createHtmlFrontend() {
3039
+ return htmlFrontend;
3040
+ }
3041
+ var htmlBackend = {
3042
+ name: "html",
3043
+ langs: HTML_LANGS,
3044
+ print(doc, _plan, _ctx) {
3045
+ return { code: doPrint(doc), map: null, edits: [], diagnostics: [] };
3046
+ }
3047
+ };
3048
+ function createHtmlBackend() {
3049
+ return htmlBackend;
3050
+ }
3051
+
2698
3052
  // ../frontend-jsx/src/frontend.ts
2699
3053
  init_esm_shims();
2700
3054
 
@@ -2703,7 +3057,7 @@ init_esm_shims();
2703
3057
  import babelTraverse from "@babel/traverse";
2704
3058
  var traverse = typeof babelTraverse === "function" ? babelTraverse : babelTraverse.default;
2705
3059
  var JSX_LANGS = ["jsx", "tsx"];
2706
- var FILE_ID = 1;
3060
+ var FILE_ID2 = 1;
2707
3061
  function jsxName(node) {
2708
3062
  switch (node.type) {
2709
3063
  case "JSXIdentifier":
@@ -2828,7 +3182,7 @@ function looksLikeJsx(id, code) {
2828
3182
  // ../frontend-jsx/src/frontend-parse.ts
2829
3183
  init_esm_shims();
2830
3184
  import { parse as babelParse } from "@babel/parser";
2831
- function doParse(code, ctx) {
3185
+ function doParse2(code, ctx) {
2832
3186
  const diagnostics = [];
2833
3187
  const doc = createDocument("jsx");
2834
3188
  const backref = doc.backref;
@@ -2838,7 +3192,7 @@ function doParse(code, ctx) {
2838
3192
  });
2839
3193
  const eol = code.includes("\r\n") ? "\r\n" : "\n";
2840
3194
  const sourceFile = {
2841
- id: FILE_ID,
3195
+ id: FILE_ID2,
2842
3196
  path: ctx.id,
2843
3197
  text: code,
2844
3198
  frontend: "jsx",
@@ -2846,23 +3200,23 @@ function doParse(code, ctx) {
2846
3200
  indentUnit: " ",
2847
3201
  native: ast
2848
3202
  };
2849
- doc.sources.set(FILE_ID, sourceFile);
3203
+ doc.sources.set(FILE_ID2, sourceFile);
2850
3204
  const spanOf = (node) => {
2851
3205
  if (node.start == null || node.end == null) return null;
2852
- const span = {
2853
- file: FILE_ID,
3206
+ const span2 = {
3207
+ file: FILE_ID2,
2854
3208
  start: node.start,
2855
3209
  end: node.end,
2856
3210
  startLoc: node.loc ? { line: node.loc.start.line, column: node.loc.start.column } : void 0,
2857
3211
  endLoc: node.loc ? { line: node.loc.end.line, column: node.loc.end.column } : void 0
2858
3212
  };
2859
- return span;
3213
+ return span2;
2860
3214
  };
2861
3215
  const sliceOf = (node) => node.start == null || node.end == null ? "" : code.slice(node.start, node.end);
2862
3216
  const internExpr = (node, spread) => {
2863
3217
  const payload = { text: sliceOf(node), spread };
2864
3218
  return doc.exprs.intern({
2865
- span: spanOf(node) ?? { file: FILE_ID, start: 0, end: 0 },
3219
+ span: spanOf(node) ?? { file: FILE_ID2, start: 0, end: 0 },
2866
3220
  kind: exprKind(node),
2867
3221
  payload
2868
3222
  });
@@ -2908,7 +3262,7 @@ function doParse(code, ctx) {
2908
3262
  }
2909
3263
  return emptyClassList();
2910
3264
  };
2911
- const staticTokensOf2 = (classes) => {
3265
+ const staticTokensOf3 = (classes) => {
2912
3266
  const out = [];
2913
3267
  for (const seg of classes.segments) {
2914
3268
  if (seg.kind === "static") for (const t of seg.tokens) out.push(t.value);
@@ -2986,7 +3340,7 @@ function doParse(code, ctx) {
2986
3340
  doc.nodes.set(id, createFragment(id, { children, parent: parentId, span: spanOf(node) }));
2987
3341
  backref.set(id, {
2988
3342
  nodeId: id,
2989
- span: spanOf(node) ?? { file: FILE_ID, start: 0, end: 0 },
3343
+ span: spanOf(node) ?? { file: FILE_ID2, start: 0, end: 0 },
2990
3344
  openTagSpan: spanOf(node.openingFragment),
2991
3345
  closeTagSpan: spanOf(node.closingFragment),
2992
3346
  innerSpan: null,
@@ -3035,7 +3389,7 @@ function doParse(code, ctx) {
3035
3389
  }
3036
3390
  let computed2 = emptyStyleMap();
3037
3391
  if (!classes.hasDynamic) {
3038
- const tokens = staticTokensOf2(classes);
3392
+ const tokens = staticTokensOf3(classes);
3039
3393
  if (tokens.length > 0) {
3040
3394
  const res = ctx.resolver.resolve({
3041
3395
  classes: tokens,
@@ -3068,13 +3422,13 @@ function doParse(code, ctx) {
3068
3422
  });
3069
3423
  doc.nodes.set(id, el);
3070
3424
  const inner = children.length > 0 ? spanOf(node.children[0]) && spanOf(node.children.at(-1)) ? {
3071
- file: FILE_ID,
3425
+ file: FILE_ID2,
3072
3426
  start: spanOf(node.children[0]).start,
3073
3427
  end: spanOf(node.children.at(-1)).end
3074
3428
  } : null : null;
3075
3429
  backref.set(id, {
3076
3430
  nodeId: id,
3077
- span: spanOf(node) ?? { file: FILE_ID, start: 0, end: 0 },
3431
+ span: spanOf(node) ?? { file: FILE_ID2, start: 0, end: 0 },
3078
3432
  openTagSpan: spanOf(opening),
3079
3433
  closeTagSpan: node.closingElement ? spanOf(node.closingElement) : null,
3080
3434
  innerSpan: inner,
@@ -3109,7 +3463,7 @@ var jsxFrontend = {
3109
3463
  return looksLikeJsx(id, code);
3110
3464
  },
3111
3465
  parse(code, ctx) {
3112
- return doParse(code, ctx);
3466
+ return doParse2(code, ctx);
3113
3467
  }
3114
3468
  };
3115
3469
  function createJsxFrontend() {
@@ -3118,7 +3472,7 @@ function createJsxFrontend() {
3118
3472
 
3119
3473
  // ../frontend-jsx/src/backend.ts
3120
3474
  init_esm_shims();
3121
- import MagicString from "magic-string";
3475
+ import MagicString2 from "magic-string";
3122
3476
  var JSX_LANGS2 = ["jsx", "tsx"];
3123
3477
  function exprText(doc, ref) {
3124
3478
  const rec = doc.exprs.get(ref);
@@ -3132,20 +3486,20 @@ function exprText(doc, ref) {
3132
3486
  }
3133
3487
  return { text: "", spread: false };
3134
3488
  }
3135
- function staticTokensOf(classes) {
3489
+ function staticTokensOf2(classes) {
3136
3490
  const out = [];
3137
3491
  for (const seg of classes.segments) {
3138
3492
  if (seg.kind === "static") for (const t of seg.tokens) out.push(t.value);
3139
3493
  }
3140
3494
  return out;
3141
3495
  }
3142
- function primarySource(doc) {
3496
+ function primarySource2(doc) {
3143
3497
  for (const sf of doc.sources.values()) {
3144
3498
  if (typeof sf.text === "string" && sf.text.length > 0) return sf;
3145
3499
  }
3146
3500
  return null;
3147
3501
  }
3148
- function collectKept(doc) {
3502
+ function collectKept2(doc) {
3149
3503
  const out = [];
3150
3504
  const seen = /* @__PURE__ */ new Set();
3151
3505
  const visit = (id) => {
@@ -3159,15 +3513,15 @@ function collectKept(doc) {
3159
3513
  visit(doc.root);
3160
3514
  return out;
3161
3515
  }
3162
- function strictlyContains(a, b) {
3516
+ function strictlyContains2(a, b) {
3163
3517
  if (a.file !== b.file) return false;
3164
3518
  if (a.start <= b.start && b.end <= a.end) return !(a.start === b.start && a.end === b.end);
3165
3519
  return false;
3166
3520
  }
3167
- function editClasses(ms, doc, sf, el) {
3521
+ function editClasses2(ms, doc, sf, el) {
3168
3522
  const classes = el.classes;
3169
3523
  if (classes.hasDynamic || classes.opaque) return false;
3170
- const tokens = staticTokensOf(classes);
3524
+ const tokens = staticTokensOf2(classes);
3171
3525
  const valueSpan = classes.valueSpan;
3172
3526
  if (valueSpan && valueSpan.file === sf.id) {
3173
3527
  const current = sf.text.slice(valueSpan.start, valueSpan.end);
@@ -3231,10 +3585,10 @@ function transferKeyOnUnwrap(ms, doc, sf, region, kept) {
3231
3585
  const inside = [];
3232
3586
  for (const n of kept) {
3233
3587
  if (n.kind !== "element" || !n.span || n.span.file !== sf.id) continue;
3234
- if (strictlyContains(region.span, n.span)) inside.push(n);
3588
+ if (strictlyContains2(region.span, n.span)) inside.push(n);
3235
3589
  }
3236
3590
  const maximal = inside.filter(
3237
- (n) => !inside.some((o) => o !== n && o.span && n.span && strictlyContains(o.span, n.span))
3591
+ (n) => !inside.some((o) => o !== n && o.span && n.span && strictlyContains2(o.span, n.span))
3238
3592
  );
3239
3593
  if (maximal.length !== 1) return;
3240
3594
  const child = maximal[0];
@@ -3243,25 +3597,25 @@ function transferKeyOnUnwrap(ms, doc, sf, region, kept) {
3243
3597
  if (extractKeyAttr(sf.text.slice(childOpen.start, childOpen.end))) return;
3244
3598
  ms.appendLeft(childOpen.start + 1 + child.tag.length, ` ${keyAttr}`);
3245
3599
  }
3246
- function surgicalPrint(doc) {
3247
- const sf = primarySource(doc);
3600
+ function surgicalPrint2(doc) {
3601
+ const sf = primarySource2(doc);
3248
3602
  if (!sf) return null;
3249
- const ms = new MagicString(sf.text);
3250
- const kept = collectKept(doc);
3603
+ const ms = new MagicString2(sf.text);
3604
+ const kept = collectKept2(doc);
3251
3605
  const keptSpans = [];
3252
3606
  for (const n of kept) if (n.span && n.span.file === sf.id) keptSpans.push(n.span);
3253
3607
  const removed = [];
3254
- for (const id of backrefIds(doc)) {
3608
+ for (const id of backrefIds2(doc)) {
3255
3609
  if (doc.nodes.has(id)) continue;
3256
3610
  const back = doc.backref.get(id);
3257
3611
  if (!back || back.span.file !== sf.id) continue;
3258
- const unwrapped = keptSpans.some((k) => strictlyContains(back.span, k));
3612
+ const unwrapped = keptSpans.some((k) => strictlyContains2(back.span, k));
3259
3613
  removed.push({ backref: back, unwrapped });
3260
3614
  }
3261
3615
  const fullRemovals = removed.filter((r) => !r.unwrapped).map((r) => r.backref.span);
3262
3616
  for (const r of removed) {
3263
- const span = r.backref.span;
3264
- const coveredByFull = fullRemovals.some((f) => f !== span && strictlyContains(f, span));
3617
+ const span2 = r.backref.span;
3618
+ const coveredByFull = fullRemovals.some((f) => f !== span2 && strictlyContains2(f, span2));
3265
3619
  if (coveredByFull) continue;
3266
3620
  if (r.unwrapped) {
3267
3621
  transferKeyOnUnwrap(ms, doc, sf, r.backref, kept);
@@ -3272,15 +3626,15 @@ function surgicalPrint(doc) {
3272
3626
  ms.remove(close.start, close.end);
3273
3627
  }
3274
3628
  } else {
3275
- ms.remove(span.start, span.end);
3629
+ ms.remove(span2.start, span2.end);
3276
3630
  }
3277
3631
  }
3278
3632
  for (const n of kept) {
3279
- if (n.kind === "element") editClasses(ms, doc, sf, n);
3633
+ if (n.kind === "element") editClasses2(ms, doc, sf, n);
3280
3634
  }
3281
3635
  return ms.toString();
3282
3636
  }
3283
- function backrefIds(doc) {
3637
+ function backrefIds2(doc) {
3284
3638
  const out = [];
3285
3639
  const max = doc.alloc.peek;
3286
3640
  for (let i = 1; i < max; i += 1) {
@@ -3295,7 +3649,7 @@ function classText(doc, classes) {
3295
3649
  if (dynamic && dynamic.kind === "dynamic") {
3296
3650
  return `className={${exprText(doc, dynamic.expr).text}}`;
3297
3651
  }
3298
- const tokens = staticTokensOf(classes);
3652
+ const tokens = staticTokensOf2(classes);
3299
3653
  return `className="${tokens.join(" ")}"`;
3300
3654
  }
3301
3655
  function attrText(doc, name, value) {
@@ -3348,15 +3702,15 @@ function rePrint(doc) {
3348
3702
  if (!root || root.kind !== "fragment") return printNode(doc, doc.root);
3349
3703
  return root.children.map((c) => printNode(doc, c)).join("");
3350
3704
  }
3351
- function doPrint(doc) {
3352
- const surgical = surgicalPrint(doc);
3705
+ function doPrint2(doc) {
3706
+ const surgical = surgicalPrint2(doc);
3353
3707
  return surgical ?? rePrint(doc);
3354
3708
  }
3355
3709
  var jsxBackend = {
3356
3710
  name: "babel-jsx",
3357
3711
  langs: JSX_LANGS2,
3358
3712
  print(doc, _plan, _ctx) {
3359
- const code = doPrint(doc);
3713
+ const code = doPrint2(doc);
3360
3714
  return { code, map: null, edits: [], diagnostics: [] };
3361
3715
  }
3362
3716
  };
@@ -3393,7 +3747,9 @@ export {
3393
3747
  builtinPatterns,
3394
3748
  createTailwindResolver,
3395
3749
  createCssResolver,
3750
+ createHtmlFrontend,
3751
+ createHtmlBackend,
3396
3752
  createJsxFrontend,
3397
3753
  createJsxBackend
3398
3754
  };
3399
- //# sourceMappingURL=chunk-DNHOGPYV.js.map
3755
+ //# sourceMappingURL=chunk-3Z5ZWLXX.js.map