@fluixi/compiler 1.0.0-alpha.93 → 1.0.0-alpha.94

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 (90) hide show
  1. package/dist/analyze/intrinsics.cjs +13 -1
  2. package/dist/analyze/intrinsics.d.cts +14 -0
  3. package/dist/analyze/intrinsics.d.ts +14 -0
  4. package/dist/analyze/intrinsics.d.ts.map +1 -1
  5. package/dist/analyze/intrinsics.js +17 -0
  6. package/dist/analyze/intrinsics.mjs +13 -1
  7. package/dist/analyze/static-graph.cjs +1 -1
  8. package/dist/analyze/static-graph.mjs +1 -1
  9. package/dist/{babel-RJHJQVEM.mjs → babel-RJFQVFJW.mjs} +4 -4
  10. package/dist/{chunk-56QSOVVL.mjs → chunk-DP2QDWWH.mjs} +1 -1
  11. package/dist/{chunk-R7PPFBCL.mjs → chunk-E2RWTIYE.mjs} +21 -15
  12. package/dist/{chunk-OD53TMER.mjs → chunk-HCCBEJEZ.mjs} +13 -1
  13. package/dist/{chunk-TJIH7TLX.mjs → chunk-HIZU7WI2.mjs} +1 -1
  14. package/dist/{chunk-U7HCFLZ2.mjs → chunk-ZR2QHTEX.mjs} +356 -24
  15. package/dist/codegen/backends/imperative.cjs +1 -1
  16. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  17. package/dist/codegen/backends/imperative.js +2 -1
  18. package/dist/codegen/backends/imperative.mjs +1 -1
  19. package/dist/frontend/babel/build-ir-lit.cjs +352 -22
  20. package/dist/frontend/babel/build-ir-lit.mjs +352 -22
  21. package/dist/frontend/babel/build-ir.cjs +352 -22
  22. package/dist/frontend/babel/build-ir.mjs +352 -22
  23. package/dist/frontend/babel/index.cjs +353 -23
  24. package/dist/frontend/babel/index.mjs +353 -23
  25. package/dist/frontend/babel/lower-template.cjs +352 -22
  26. package/dist/frontend/babel/lower-template.mjs +352 -22
  27. package/dist/frontend/babel/plugin.cjs +352 -22
  28. package/dist/frontend/babel/plugin.mjs +352 -22
  29. package/dist/index.cjs +321 -22
  30. package/dist/index.mjs +333 -22
  31. package/dist/integrations.cjs +1174 -49
  32. package/dist/integrations.d.ts.map +1 -1
  33. package/dist/integrations.js +44 -2
  34. package/dist/integrations.mjs +205 -19
  35. package/dist/lower/compile-template.cjs +315 -21
  36. package/dist/lower/compile-template.d.cts +13 -0
  37. package/dist/lower/compile-template.d.ts +13 -0
  38. package/dist/lower/compile-template.d.ts.map +1 -1
  39. package/dist/lower/compile-template.js +3 -0
  40. package/dist/lower/compile-template.mjs +327 -21
  41. package/dist/lower/entities.cjs +288 -0
  42. package/dist/lower/entities.d.cts +1 -0
  43. package/dist/lower/entities.d.ts +2 -0
  44. package/dist/lower/entities.d.ts.map +1 -0
  45. package/dist/lower/entities.js +54 -0
  46. package/dist/lower/entities.mjs +267 -0
  47. package/dist/lower/jsx.cjs +104 -47
  48. package/dist/lower/jsx.d.cts +8 -0
  49. package/dist/lower/jsx.d.ts +8 -0
  50. package/dist/lower/jsx.d.ts.map +1 -1
  51. package/dist/lower/jsx.js +92 -2
  52. package/dist/lower/jsx.mjs +104 -47
  53. package/dist/lower/template.cjs +293 -20
  54. package/dist/lower/template.d.ts.map +1 -1
  55. package/dist/lower/template.js +35 -19
  56. package/dist/lower/template.mjs +293 -20
  57. package/dist/resolve/builtins.cjs +1 -1
  58. package/dist/resolve/builtins.mjs +1 -1
  59. package/dist/resolve/component-globals.cjs +6 -1
  60. package/dist/resolve/component-globals.js +2 -2
  61. package/dist/resolve/component-globals.mjs +6 -1
  62. package/dist/resolve/write-globals.cjs +6 -1
  63. package/dist/resolve/write-globals.mjs +6 -1
  64. package/dist/{server-fns-ZFRDIQ2X.mjs → server-fns-JLSTKWPS.mjs} +4 -4
  65. package/dist/{server-functions-CTDXX67X.mjs → server-functions-BGY3RD4R.mjs} +3 -3
  66. package/dist/transform/index.cjs +956 -33
  67. package/dist/transform/index.mjs +974 -47
  68. package/dist/transform/props.mjs +19 -14
  69. package/dist/transform/server-fns.mjs +19 -14
  70. package/dist/transform/styles.cjs +588 -0
  71. package/dist/transform/styles.d.cts +211 -0
  72. package/dist/transform/styles.d.ts +212 -0
  73. package/dist/transform/styles.d.ts.map +1 -0
  74. package/dist/transform/styles.js +714 -0
  75. package/dist/transform/styles.mjs +653 -0
  76. package/dist/transform/templates.cjs +955 -32
  77. package/dist/transform/templates.d.cts +13 -0
  78. package/dist/transform/templates.d.ts +13 -0
  79. package/dist/transform/templates.d.ts.map +1 -1
  80. package/dist/transform/templates.js +49 -12
  81. package/dist/transform/templates.mjs +973 -46
  82. package/dist/{transform-QWWQDCXE.mjs → transform-GBP6Y4UI.mjs} +601 -17
  83. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  84. package/dist/vite-styles.cjs +180 -0
  85. package/dist/vite-styles.d.cts +59 -0
  86. package/dist/vite-styles.d.ts +60 -0
  87. package/dist/vite-styles.d.ts.map +1 -0
  88. package/dist/vite-styles.js +198 -0
  89. package/dist/vite-styles.mjs +159 -0
  90. package/package.json +4 -3
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @fluixi/compiler v1.0.0-alpha.93 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/compiler v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -355,6 +355,11 @@ var INTRINSICS = {
355
355
  // An environment variable, public or server-only; the browser build refuses a secret.
356
356
  $env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
357
357
  };
358
+ var TAG_INTRINSICS = {
359
+ $html: { export: "html", module: "@fluixi/core" },
360
+ $svg: { export: "svg", module: "@fluixi/core" },
361
+ $css: { export: "css", module: "@fluixi/core" }
362
+ };
358
363
  var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
359
364
 
360
365
  // src/transform/source-locations.ts
@@ -535,7 +540,7 @@ function emitComponent(name, props, children, used, templates, at) {
535
540
  }
536
541
  let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
537
542
  if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
538
- const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
543
+ const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
539
544
  const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
540
545
  obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
541
546
  }
@@ -674,6 +679,271 @@ function cleanTemplateText(value) {
674
679
  return out;
675
680
  }
676
681
 
682
+ // src/lower/entities.ts
683
+ var NAMED = {
684
+ quot: 34,
685
+ amp: 38,
686
+ apos: 39,
687
+ lt: 60,
688
+ gt: 62,
689
+ nbsp: 160,
690
+ iexcl: 161,
691
+ cent: 162,
692
+ pound: 163,
693
+ curren: 164,
694
+ yen: 165,
695
+ brvbar: 166,
696
+ sect: 167,
697
+ uml: 168,
698
+ copy: 169,
699
+ ordf: 170,
700
+ laquo: 171,
701
+ not: 172,
702
+ shy: 173,
703
+ reg: 174,
704
+ macr: 175,
705
+ deg: 176,
706
+ plusmn: 177,
707
+ sup2: 178,
708
+ sup3: 179,
709
+ acute: 180,
710
+ micro: 181,
711
+ para: 182,
712
+ middot: 183,
713
+ cedil: 184,
714
+ sup1: 185,
715
+ ordm: 186,
716
+ raquo: 187,
717
+ frac14: 188,
718
+ frac12: 189,
719
+ frac34: 190,
720
+ iquest: 191,
721
+ Agrave: 192,
722
+ Aacute: 193,
723
+ Acirc: 194,
724
+ Atilde: 195,
725
+ Auml: 196,
726
+ Aring: 197,
727
+ AElig: 198,
728
+ Ccedil: 199,
729
+ Egrave: 200,
730
+ Eacute: 201,
731
+ Ecirc: 202,
732
+ Euml: 203,
733
+ Igrave: 204,
734
+ Iacute: 205,
735
+ Icirc: 206,
736
+ Iuml: 207,
737
+ ETH: 208,
738
+ Ntilde: 209,
739
+ Ograve: 210,
740
+ Oacute: 211,
741
+ Ocirc: 212,
742
+ Otilde: 213,
743
+ Ouml: 214,
744
+ times: 215,
745
+ Oslash: 216,
746
+ Ugrave: 217,
747
+ Uacute: 218,
748
+ Ucirc: 219,
749
+ Uuml: 220,
750
+ Yacute: 221,
751
+ THORN: 222,
752
+ szlig: 223,
753
+ agrave: 224,
754
+ aacute: 225,
755
+ acirc: 226,
756
+ atilde: 227,
757
+ auml: 228,
758
+ aring: 229,
759
+ aelig: 230,
760
+ ccedil: 231,
761
+ egrave: 232,
762
+ eacute: 233,
763
+ ecirc: 234,
764
+ euml: 235,
765
+ igrave: 236,
766
+ iacute: 237,
767
+ icirc: 238,
768
+ iuml: 239,
769
+ eth: 240,
770
+ ntilde: 241,
771
+ ograve: 242,
772
+ oacute: 243,
773
+ ocirc: 244,
774
+ otilde: 245,
775
+ ouml: 246,
776
+ divide: 247,
777
+ oslash: 248,
778
+ ugrave: 249,
779
+ uacute: 250,
780
+ ucirc: 251,
781
+ uuml: 252,
782
+ yacute: 253,
783
+ thorn: 254,
784
+ yuml: 255,
785
+ OElig: 338,
786
+ oelig: 339,
787
+ Scaron: 352,
788
+ scaron: 353,
789
+ Yuml: 376,
790
+ fnof: 402,
791
+ circ: 710,
792
+ tilde: 732,
793
+ Alpha: 913,
794
+ Beta: 914,
795
+ Gamma: 915,
796
+ Delta: 916,
797
+ Epsilon: 917,
798
+ Zeta: 918,
799
+ Eta: 919,
800
+ Theta: 920,
801
+ Iota: 921,
802
+ Kappa: 922,
803
+ Lambda: 923,
804
+ Mu: 924,
805
+ Nu: 925,
806
+ Xi: 926,
807
+ Omicron: 927,
808
+ Pi: 928,
809
+ Rho: 929,
810
+ Sigma: 931,
811
+ Tau: 932,
812
+ Upsilon: 933,
813
+ Phi: 934,
814
+ Chi: 935,
815
+ Psi: 936,
816
+ Omega: 937,
817
+ alpha: 945,
818
+ beta: 946,
819
+ gamma: 947,
820
+ delta: 948,
821
+ epsilon: 949,
822
+ zeta: 950,
823
+ eta: 951,
824
+ theta: 952,
825
+ iota: 953,
826
+ kappa: 954,
827
+ lambda: 955,
828
+ mu: 956,
829
+ nu: 957,
830
+ xi: 958,
831
+ omicron: 959,
832
+ pi: 960,
833
+ rho: 961,
834
+ sigmaf: 962,
835
+ sigma: 963,
836
+ tau: 964,
837
+ upsilon: 965,
838
+ phi: 966,
839
+ chi: 967,
840
+ psi: 968,
841
+ omega: 969,
842
+ thetasym: 977,
843
+ upsih: 978,
844
+ piv: 982,
845
+ ensp: 8194,
846
+ emsp: 8195,
847
+ thinsp: 8201,
848
+ zwnj: 8204,
849
+ zwj: 8205,
850
+ lrm: 8206,
851
+ rlm: 8207,
852
+ ndash: 8211,
853
+ mdash: 8212,
854
+ lsquo: 8216,
855
+ rsquo: 8217,
856
+ sbquo: 8218,
857
+ ldquo: 8220,
858
+ rdquo: 8221,
859
+ bdquo: 8222,
860
+ dagger: 8224,
861
+ Dagger: 8225,
862
+ bull: 8226,
863
+ hellip: 8230,
864
+ permil: 8240,
865
+ prime: 8242,
866
+ Prime: 8243,
867
+ lsaquo: 8249,
868
+ rsaquo: 8250,
869
+ oline: 8254,
870
+ frasl: 8260,
871
+ euro: 8364,
872
+ image: 8465,
873
+ weierp: 8472,
874
+ real: 8476,
875
+ trade: 8482,
876
+ alefsym: 8501,
877
+ larr: 8592,
878
+ uarr: 8593,
879
+ rarr: 8594,
880
+ darr: 8595,
881
+ harr: 8596,
882
+ crarr: 8629,
883
+ lArr: 8656,
884
+ uArr: 8657,
885
+ rArr: 8658,
886
+ dArr: 8659,
887
+ hArr: 8660,
888
+ forall: 8704,
889
+ part: 8706,
890
+ exist: 8707,
891
+ empty: 8709,
892
+ nabla: 8711,
893
+ isin: 8712,
894
+ notin: 8713,
895
+ ni: 8715,
896
+ prod: 8719,
897
+ sum: 8721,
898
+ minus: 8722,
899
+ lowast: 8727,
900
+ radic: 8730,
901
+ prop: 8733,
902
+ infin: 8734,
903
+ ang: 8736,
904
+ and: 8743,
905
+ or: 8744,
906
+ cap: 8745,
907
+ cup: 8746,
908
+ int: 8747,
909
+ there4: 8756,
910
+ sim: 8764,
911
+ cong: 8773,
912
+ asymp: 8776,
913
+ ne: 8800,
914
+ equiv: 8801,
915
+ le: 8804,
916
+ ge: 8805,
917
+ sub: 8834,
918
+ sup: 8835,
919
+ nsub: 8836,
920
+ sube: 8838,
921
+ supe: 8839,
922
+ oplus: 8853,
923
+ otimes: 8855,
924
+ perp: 8869,
925
+ sdot: 8901,
926
+ lceil: 8968,
927
+ rceil: 8969,
928
+ lfloor: 8970,
929
+ rfloor: 8971,
930
+ lang: 9001,
931
+ rang: 9002,
932
+ loz: 9674,
933
+ spades: 9824,
934
+ clubs: 9827,
935
+ hearts: 9829,
936
+ diams: 9830
937
+ };
938
+ var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
939
+ function decodeEntities(value) {
940
+ if (!value.includes("&")) return value;
941
+ return value.replace(REFERENCE, (match, hex, dec, name) => {
942
+ const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
943
+ return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
944
+ });
945
+ }
946
+
677
947
  // src/lower/template.ts
678
948
  var DELEGATED = /* @__PURE__ */ new Set([
679
949
  "click",
@@ -760,7 +1030,7 @@ var Lowerer = class {
760
1030
  switch (node.kind) {
761
1031
  case "Text": {
762
1032
  if (node.raw) return { kind: "text", value: node.value };
763
- const cleaned = cleanTemplateText(node.value);
1033
+ const cleaned = decodeEntities(cleanTemplateText(node.value));
764
1034
  return cleaned ? { kind: "text", value: cleaned } : null;
765
1035
  }
766
1036
  case "Comment":
@@ -796,7 +1066,7 @@ var Lowerer = class {
796
1066
  kind: "element",
797
1067
  tag: el.tag,
798
1068
  svg: el.namespace === "svg",
799
- props: this.lowerAttributes(el.attributes),
1069
+ props: this.lowerAttributes(el.attributes, true),
800
1070
  children,
801
1071
  static: false,
802
1072
  ...at ? { at } : {}
@@ -909,13 +1179,22 @@ var Lowerer = class {
909
1179
  return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
910
1180
  }
911
1181
  // --- attributes ---------------------------------------------------------
912
- lowerAttributes(attrs) {
1182
+ /**
1183
+ * `element`: a DOM element, where each class:/style: value that moves is its own accessor.
1184
+ * A component gets the object as before, rebuilt whole when any value moves.
1185
+ */
1186
+ lowerAttributes(attrs, element = false) {
1187
+ let anyReactive = false;
1188
+ const entry = (name, h) => {
1189
+ anyReactive ||= h.reactive;
1190
+ if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
1191
+ const accessor = `() => ${paren(h.code, "arrowBody")}`;
1192
+ return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
1193
+ };
913
1194
  const props = [];
914
1195
  const classEntries = [];
915
- let classReactive = false;
916
1196
  let classAt;
917
1197
  const styleEntries = [];
918
- let styleReactive = false;
919
1198
  let styleAt;
920
1199
  const usePairs = [];
921
1200
  for (const a of attrs) {
@@ -955,15 +1234,13 @@ var Lowerer = class {
955
1234
  break;
956
1235
  case "ClassDirective": {
957
1236
  const h = this.hole(a.hole);
958
- classEntries.push(`${JSON.stringify(a.name)}: ${h.code}`);
959
- classReactive = classReactive || h.reactive;
1237
+ classEntries.push(entry(a.name, h));
960
1238
  classAt ??= h.at;
961
1239
  break;
962
1240
  }
963
1241
  case "StyleDirective": {
964
1242
  const h = this.hole(a.hole);
965
- styleEntries.push(`${JSON.stringify(a.name)}: ${h.code}`);
966
- styleReactive = styleReactive || h.reactive;
1243
+ styleEntries.push(entry(a.name, h));
967
1244
  styleAt ??= h.at;
968
1245
  break;
969
1246
  }
@@ -983,18 +1260,19 @@ var Lowerer = class {
983
1260
  name: "classList",
984
1261
  kind: "attr",
985
1262
  expr: `{ ${classEntries.join(", ")} }`,
986
- reactive: classReactive,
1263
+ reactive: !element && anyReactive,
987
1264
  ...classAt ? { at: classAt } : {}
988
1265
  });
989
1266
  }
990
1267
  if (styleEntries.length > 0) {
991
- props.push({
992
- name: "style",
993
- kind: "attr",
994
- expr: `{ ${styleEntries.join(", ")} }`,
995
- reactive: styleReactive,
996
- ...styleAt ? { at: styleAt } : {}
997
- });
1268
+ const entries = `{ ${styleEntries.join(", ")} }`;
1269
+ const base = props.findIndex((p) => p.name === "style");
1270
+ if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
1271
+ else {
1272
+ const prop = props[base];
1273
+ const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
1274
+ props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
1275
+ }
998
1276
  }
999
1277
  if (usePairs.length > 0) {
1000
1278
  props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
@@ -1083,7 +1361,7 @@ var Lowerer = class {
1083
1361
  return base;
1084
1362
  }
1085
1363
  if (v.kind === "static") {
1086
- base.literal = v.value;
1364
+ base.literal = decodeEntities(v.value);
1087
1365
  return base;
1088
1366
  }
1089
1367
  if (v.kind === "hole") {
@@ -1096,7 +1374,7 @@ var Lowerer = class {
1096
1374
  let reactive = false;
1097
1375
  let at;
1098
1376
  const body = v.parts.map((p) => {
1099
- if ("text" in p) return escapeTemplate(p.text);
1377
+ if ("text" in p) return escapeTemplate(decodeEntities(p.text));
1100
1378
  const h = this.hole(p.hole);
1101
1379
  reactive = reactive || h.reactive;
1102
1380
  at ??= h.at;
@@ -1113,6 +1391,26 @@ function lowerTemplate(pieces, holes, used, opts = {}) {
1113
1391
  return new Lowerer(holes, used, opts.sourceFile, opts.positionAt).lowerRoot(root.children);
1114
1392
  }
1115
1393
 
1394
+ // src/transform/styles.ts
1395
+ var import_sourcemap_codec = require("@jridgewell/sourcemap-codec");
1396
+ var SCOPE_ATTR = "data-fx-s";
1397
+ function applyTemplateStyles(ir, t) {
1398
+ const walk2 = (node) => {
1399
+ const children = node.children;
1400
+ if (children) {
1401
+ for (let i = children.length - 1; i >= 0; i--) {
1402
+ const child = children[i];
1403
+ if (child.kind === "element" && child.tag === "style" && t.owner) children.splice(i, 1);
1404
+ else walk2(child);
1405
+ }
1406
+ }
1407
+ if (t.scope && node.kind === "element" && node.tag !== "style" && node.props && !node.props.some((p) => p.name === SCOPE_ATTR)) {
1408
+ node.props.unshift({ name: SCOPE_ATTR, kind: "attr", literal: t.scope });
1409
+ }
1410
+ };
1411
+ walk2(ir);
1412
+ }
1413
+
1116
1414
  // src/optimize/analyze-static.ts
1117
1415
  function propReason(prop) {
1118
1416
  switch (prop.kind) {
@@ -1388,6 +1686,7 @@ function compilePieces(pieces, holes, options = {}) {
1388
1686
  ...options.sourceFile ? { sourceFile: options.sourceFile } : {},
1389
1687
  ...options.positionAt ? { positionAt: options.positionAt } : {}
1390
1688
  });
1689
+ if (options.templateStyles) applyTemplateStyles(ir, options.templateStyles);
1391
1690
  analyzeStatic(ir);
1392
1691
  resolveComponentSources(ir, {
1393
1692
  resolver: createComponentResolver(options.resolve ?? []),
@@ -1471,7 +1770,7 @@ function componentGlobals(rules, options = {}) {
1471
1770
  resolved.set(name, target);
1472
1771
  }
1473
1772
  }
1474
- const usableIntrinsics = intrinsics ? Object.entries(INTRINSICS).filter(([, i]) => {
1773
+ const usableIntrinsics = intrinsics ? Object.entries({ ...INTRINSICS, ...TAG_INTRINSICS }).filter(([, i]) => {
1475
1774
  const pkg = packageOf(i.module);
1476
1775
  return !available || !pkg || available.has(pkg);
1477
1776
  }) : [];