@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.
- package/dist/analyze/intrinsics.cjs +13 -1
- package/dist/analyze/intrinsics.d.cts +14 -0
- package/dist/analyze/intrinsics.d.ts +14 -0
- package/dist/analyze/intrinsics.d.ts.map +1 -1
- package/dist/analyze/intrinsics.js +17 -0
- package/dist/analyze/intrinsics.mjs +13 -1
- package/dist/analyze/static-graph.cjs +1 -1
- package/dist/analyze/static-graph.mjs +1 -1
- package/dist/{babel-RJHJQVEM.mjs → babel-RJFQVFJW.mjs} +4 -4
- package/dist/{chunk-56QSOVVL.mjs → chunk-DP2QDWWH.mjs} +1 -1
- package/dist/{chunk-R7PPFBCL.mjs → chunk-E2RWTIYE.mjs} +21 -15
- package/dist/{chunk-OD53TMER.mjs → chunk-HCCBEJEZ.mjs} +13 -1
- package/dist/{chunk-TJIH7TLX.mjs → chunk-HIZU7WI2.mjs} +1 -1
- package/dist/{chunk-U7HCFLZ2.mjs → chunk-ZR2QHTEX.mjs} +356 -24
- package/dist/codegen/backends/imperative.cjs +1 -1
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +2 -1
- package/dist/codegen/backends/imperative.mjs +1 -1
- package/dist/frontend/babel/build-ir-lit.cjs +352 -22
- package/dist/frontend/babel/build-ir-lit.mjs +352 -22
- package/dist/frontend/babel/build-ir.cjs +352 -22
- package/dist/frontend/babel/build-ir.mjs +352 -22
- package/dist/frontend/babel/index.cjs +353 -23
- package/dist/frontend/babel/index.mjs +353 -23
- package/dist/frontend/babel/lower-template.cjs +352 -22
- package/dist/frontend/babel/lower-template.mjs +352 -22
- package/dist/frontend/babel/plugin.cjs +352 -22
- package/dist/frontend/babel/plugin.mjs +352 -22
- package/dist/index.cjs +321 -22
- package/dist/index.mjs +333 -22
- package/dist/integrations.cjs +1174 -49
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +44 -2
- package/dist/integrations.mjs +205 -19
- package/dist/lower/compile-template.cjs +315 -21
- package/dist/lower/compile-template.d.cts +13 -0
- package/dist/lower/compile-template.d.ts +13 -0
- package/dist/lower/compile-template.d.ts.map +1 -1
- package/dist/lower/compile-template.js +3 -0
- package/dist/lower/compile-template.mjs +327 -21
- package/dist/lower/entities.cjs +288 -0
- package/dist/lower/entities.d.cts +1 -0
- package/dist/lower/entities.d.ts +2 -0
- package/dist/lower/entities.d.ts.map +1 -0
- package/dist/lower/entities.js +54 -0
- package/dist/lower/entities.mjs +267 -0
- package/dist/lower/jsx.cjs +104 -47
- package/dist/lower/jsx.d.cts +8 -0
- package/dist/lower/jsx.d.ts +8 -0
- package/dist/lower/jsx.d.ts.map +1 -1
- package/dist/lower/jsx.js +92 -2
- package/dist/lower/jsx.mjs +104 -47
- package/dist/lower/template.cjs +293 -20
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +35 -19
- package/dist/lower/template.mjs +293 -20
- package/dist/resolve/builtins.cjs +1 -1
- package/dist/resolve/builtins.mjs +1 -1
- package/dist/resolve/component-globals.cjs +6 -1
- package/dist/resolve/component-globals.js +2 -2
- package/dist/resolve/component-globals.mjs +6 -1
- package/dist/resolve/write-globals.cjs +6 -1
- package/dist/resolve/write-globals.mjs +6 -1
- package/dist/{server-fns-ZFRDIQ2X.mjs → server-fns-JLSTKWPS.mjs} +4 -4
- package/dist/{server-functions-CTDXX67X.mjs → server-functions-BGY3RD4R.mjs} +3 -3
- package/dist/transform/index.cjs +956 -33
- package/dist/transform/index.mjs +974 -47
- package/dist/transform/props.mjs +19 -14
- package/dist/transform/server-fns.mjs +19 -14
- package/dist/transform/styles.cjs +588 -0
- package/dist/transform/styles.d.cts +211 -0
- package/dist/transform/styles.d.ts +212 -0
- package/dist/transform/styles.d.ts.map +1 -0
- package/dist/transform/styles.js +714 -0
- package/dist/transform/styles.mjs +653 -0
- package/dist/transform/templates.cjs +955 -32
- package/dist/transform/templates.d.cts +13 -0
- package/dist/transform/templates.d.ts +13 -0
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +49 -12
- package/dist/transform/templates.mjs +973 -46
- package/dist/{transform-QWWQDCXE.mjs → transform-GBP6Y4UI.mjs} +601 -17
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/vite-styles.cjs +180 -0
- package/dist/vite-styles.d.cts +59 -0
- package/dist/vite-styles.d.ts +60 -0
- package/dist/vite-styles.d.ts.map +1 -0
- package/dist/vite-styles.js +198 -0
- package/dist/vite-styles.mjs +159 -0
- package/package.json +4 -3
|
@@ -507,7 +507,7 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
507
507
|
}
|
|
508
508
|
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
509
509
|
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
510
|
-
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
|
|
510
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
511
511
|
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
512
512
|
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
513
513
|
}
|
|
@@ -646,6 +646,271 @@ function cleanTemplateText(value) {
|
|
|
646
646
|
return out;
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
// src/lower/entities.ts
|
|
650
|
+
var NAMED = {
|
|
651
|
+
quot: 34,
|
|
652
|
+
amp: 38,
|
|
653
|
+
apos: 39,
|
|
654
|
+
lt: 60,
|
|
655
|
+
gt: 62,
|
|
656
|
+
nbsp: 160,
|
|
657
|
+
iexcl: 161,
|
|
658
|
+
cent: 162,
|
|
659
|
+
pound: 163,
|
|
660
|
+
curren: 164,
|
|
661
|
+
yen: 165,
|
|
662
|
+
brvbar: 166,
|
|
663
|
+
sect: 167,
|
|
664
|
+
uml: 168,
|
|
665
|
+
copy: 169,
|
|
666
|
+
ordf: 170,
|
|
667
|
+
laquo: 171,
|
|
668
|
+
not: 172,
|
|
669
|
+
shy: 173,
|
|
670
|
+
reg: 174,
|
|
671
|
+
macr: 175,
|
|
672
|
+
deg: 176,
|
|
673
|
+
plusmn: 177,
|
|
674
|
+
sup2: 178,
|
|
675
|
+
sup3: 179,
|
|
676
|
+
acute: 180,
|
|
677
|
+
micro: 181,
|
|
678
|
+
para: 182,
|
|
679
|
+
middot: 183,
|
|
680
|
+
cedil: 184,
|
|
681
|
+
sup1: 185,
|
|
682
|
+
ordm: 186,
|
|
683
|
+
raquo: 187,
|
|
684
|
+
frac14: 188,
|
|
685
|
+
frac12: 189,
|
|
686
|
+
frac34: 190,
|
|
687
|
+
iquest: 191,
|
|
688
|
+
Agrave: 192,
|
|
689
|
+
Aacute: 193,
|
|
690
|
+
Acirc: 194,
|
|
691
|
+
Atilde: 195,
|
|
692
|
+
Auml: 196,
|
|
693
|
+
Aring: 197,
|
|
694
|
+
AElig: 198,
|
|
695
|
+
Ccedil: 199,
|
|
696
|
+
Egrave: 200,
|
|
697
|
+
Eacute: 201,
|
|
698
|
+
Ecirc: 202,
|
|
699
|
+
Euml: 203,
|
|
700
|
+
Igrave: 204,
|
|
701
|
+
Iacute: 205,
|
|
702
|
+
Icirc: 206,
|
|
703
|
+
Iuml: 207,
|
|
704
|
+
ETH: 208,
|
|
705
|
+
Ntilde: 209,
|
|
706
|
+
Ograve: 210,
|
|
707
|
+
Oacute: 211,
|
|
708
|
+
Ocirc: 212,
|
|
709
|
+
Otilde: 213,
|
|
710
|
+
Ouml: 214,
|
|
711
|
+
times: 215,
|
|
712
|
+
Oslash: 216,
|
|
713
|
+
Ugrave: 217,
|
|
714
|
+
Uacute: 218,
|
|
715
|
+
Ucirc: 219,
|
|
716
|
+
Uuml: 220,
|
|
717
|
+
Yacute: 221,
|
|
718
|
+
THORN: 222,
|
|
719
|
+
szlig: 223,
|
|
720
|
+
agrave: 224,
|
|
721
|
+
aacute: 225,
|
|
722
|
+
acirc: 226,
|
|
723
|
+
atilde: 227,
|
|
724
|
+
auml: 228,
|
|
725
|
+
aring: 229,
|
|
726
|
+
aelig: 230,
|
|
727
|
+
ccedil: 231,
|
|
728
|
+
egrave: 232,
|
|
729
|
+
eacute: 233,
|
|
730
|
+
ecirc: 234,
|
|
731
|
+
euml: 235,
|
|
732
|
+
igrave: 236,
|
|
733
|
+
iacute: 237,
|
|
734
|
+
icirc: 238,
|
|
735
|
+
iuml: 239,
|
|
736
|
+
eth: 240,
|
|
737
|
+
ntilde: 241,
|
|
738
|
+
ograve: 242,
|
|
739
|
+
oacute: 243,
|
|
740
|
+
ocirc: 244,
|
|
741
|
+
otilde: 245,
|
|
742
|
+
ouml: 246,
|
|
743
|
+
divide: 247,
|
|
744
|
+
oslash: 248,
|
|
745
|
+
ugrave: 249,
|
|
746
|
+
uacute: 250,
|
|
747
|
+
ucirc: 251,
|
|
748
|
+
uuml: 252,
|
|
749
|
+
yacute: 253,
|
|
750
|
+
thorn: 254,
|
|
751
|
+
yuml: 255,
|
|
752
|
+
OElig: 338,
|
|
753
|
+
oelig: 339,
|
|
754
|
+
Scaron: 352,
|
|
755
|
+
scaron: 353,
|
|
756
|
+
Yuml: 376,
|
|
757
|
+
fnof: 402,
|
|
758
|
+
circ: 710,
|
|
759
|
+
tilde: 732,
|
|
760
|
+
Alpha: 913,
|
|
761
|
+
Beta: 914,
|
|
762
|
+
Gamma: 915,
|
|
763
|
+
Delta: 916,
|
|
764
|
+
Epsilon: 917,
|
|
765
|
+
Zeta: 918,
|
|
766
|
+
Eta: 919,
|
|
767
|
+
Theta: 920,
|
|
768
|
+
Iota: 921,
|
|
769
|
+
Kappa: 922,
|
|
770
|
+
Lambda: 923,
|
|
771
|
+
Mu: 924,
|
|
772
|
+
Nu: 925,
|
|
773
|
+
Xi: 926,
|
|
774
|
+
Omicron: 927,
|
|
775
|
+
Pi: 928,
|
|
776
|
+
Rho: 929,
|
|
777
|
+
Sigma: 931,
|
|
778
|
+
Tau: 932,
|
|
779
|
+
Upsilon: 933,
|
|
780
|
+
Phi: 934,
|
|
781
|
+
Chi: 935,
|
|
782
|
+
Psi: 936,
|
|
783
|
+
Omega: 937,
|
|
784
|
+
alpha: 945,
|
|
785
|
+
beta: 946,
|
|
786
|
+
gamma: 947,
|
|
787
|
+
delta: 948,
|
|
788
|
+
epsilon: 949,
|
|
789
|
+
zeta: 950,
|
|
790
|
+
eta: 951,
|
|
791
|
+
theta: 952,
|
|
792
|
+
iota: 953,
|
|
793
|
+
kappa: 954,
|
|
794
|
+
lambda: 955,
|
|
795
|
+
mu: 956,
|
|
796
|
+
nu: 957,
|
|
797
|
+
xi: 958,
|
|
798
|
+
omicron: 959,
|
|
799
|
+
pi: 960,
|
|
800
|
+
rho: 961,
|
|
801
|
+
sigmaf: 962,
|
|
802
|
+
sigma: 963,
|
|
803
|
+
tau: 964,
|
|
804
|
+
upsilon: 965,
|
|
805
|
+
phi: 966,
|
|
806
|
+
chi: 967,
|
|
807
|
+
psi: 968,
|
|
808
|
+
omega: 969,
|
|
809
|
+
thetasym: 977,
|
|
810
|
+
upsih: 978,
|
|
811
|
+
piv: 982,
|
|
812
|
+
ensp: 8194,
|
|
813
|
+
emsp: 8195,
|
|
814
|
+
thinsp: 8201,
|
|
815
|
+
zwnj: 8204,
|
|
816
|
+
zwj: 8205,
|
|
817
|
+
lrm: 8206,
|
|
818
|
+
rlm: 8207,
|
|
819
|
+
ndash: 8211,
|
|
820
|
+
mdash: 8212,
|
|
821
|
+
lsquo: 8216,
|
|
822
|
+
rsquo: 8217,
|
|
823
|
+
sbquo: 8218,
|
|
824
|
+
ldquo: 8220,
|
|
825
|
+
rdquo: 8221,
|
|
826
|
+
bdquo: 8222,
|
|
827
|
+
dagger: 8224,
|
|
828
|
+
Dagger: 8225,
|
|
829
|
+
bull: 8226,
|
|
830
|
+
hellip: 8230,
|
|
831
|
+
permil: 8240,
|
|
832
|
+
prime: 8242,
|
|
833
|
+
Prime: 8243,
|
|
834
|
+
lsaquo: 8249,
|
|
835
|
+
rsaquo: 8250,
|
|
836
|
+
oline: 8254,
|
|
837
|
+
frasl: 8260,
|
|
838
|
+
euro: 8364,
|
|
839
|
+
image: 8465,
|
|
840
|
+
weierp: 8472,
|
|
841
|
+
real: 8476,
|
|
842
|
+
trade: 8482,
|
|
843
|
+
alefsym: 8501,
|
|
844
|
+
larr: 8592,
|
|
845
|
+
uarr: 8593,
|
|
846
|
+
rarr: 8594,
|
|
847
|
+
darr: 8595,
|
|
848
|
+
harr: 8596,
|
|
849
|
+
crarr: 8629,
|
|
850
|
+
lArr: 8656,
|
|
851
|
+
uArr: 8657,
|
|
852
|
+
rArr: 8658,
|
|
853
|
+
dArr: 8659,
|
|
854
|
+
hArr: 8660,
|
|
855
|
+
forall: 8704,
|
|
856
|
+
part: 8706,
|
|
857
|
+
exist: 8707,
|
|
858
|
+
empty: 8709,
|
|
859
|
+
nabla: 8711,
|
|
860
|
+
isin: 8712,
|
|
861
|
+
notin: 8713,
|
|
862
|
+
ni: 8715,
|
|
863
|
+
prod: 8719,
|
|
864
|
+
sum: 8721,
|
|
865
|
+
minus: 8722,
|
|
866
|
+
lowast: 8727,
|
|
867
|
+
radic: 8730,
|
|
868
|
+
prop: 8733,
|
|
869
|
+
infin: 8734,
|
|
870
|
+
ang: 8736,
|
|
871
|
+
and: 8743,
|
|
872
|
+
or: 8744,
|
|
873
|
+
cap: 8745,
|
|
874
|
+
cup: 8746,
|
|
875
|
+
int: 8747,
|
|
876
|
+
there4: 8756,
|
|
877
|
+
sim: 8764,
|
|
878
|
+
cong: 8773,
|
|
879
|
+
asymp: 8776,
|
|
880
|
+
ne: 8800,
|
|
881
|
+
equiv: 8801,
|
|
882
|
+
le: 8804,
|
|
883
|
+
ge: 8805,
|
|
884
|
+
sub: 8834,
|
|
885
|
+
sup: 8835,
|
|
886
|
+
nsub: 8836,
|
|
887
|
+
sube: 8838,
|
|
888
|
+
supe: 8839,
|
|
889
|
+
oplus: 8853,
|
|
890
|
+
otimes: 8855,
|
|
891
|
+
perp: 8869,
|
|
892
|
+
sdot: 8901,
|
|
893
|
+
lceil: 8968,
|
|
894
|
+
rceil: 8969,
|
|
895
|
+
lfloor: 8970,
|
|
896
|
+
rfloor: 8971,
|
|
897
|
+
lang: 9001,
|
|
898
|
+
rang: 9002,
|
|
899
|
+
loz: 9674,
|
|
900
|
+
spades: 9824,
|
|
901
|
+
clubs: 9827,
|
|
902
|
+
hearts: 9829,
|
|
903
|
+
diams: 9830
|
|
904
|
+
};
|
|
905
|
+
var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
|
|
906
|
+
function decodeEntities(value) {
|
|
907
|
+
if (!value.includes("&")) return value;
|
|
908
|
+
return value.replace(REFERENCE, (match, hex, dec, name) => {
|
|
909
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
|
|
910
|
+
return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
649
914
|
// src/lower/template.ts
|
|
650
915
|
var DELEGATED = /* @__PURE__ */ new Set([
|
|
651
916
|
"click",
|
|
@@ -732,7 +997,7 @@ var Lowerer = class {
|
|
|
732
997
|
switch (node.kind) {
|
|
733
998
|
case "Text": {
|
|
734
999
|
if (node.raw) return { kind: "text", value: node.value };
|
|
735
|
-
const cleaned = cleanTemplateText(node.value);
|
|
1000
|
+
const cleaned = decodeEntities(cleanTemplateText(node.value));
|
|
736
1001
|
return cleaned ? { kind: "text", value: cleaned } : null;
|
|
737
1002
|
}
|
|
738
1003
|
case "Comment":
|
|
@@ -768,7 +1033,7 @@ var Lowerer = class {
|
|
|
768
1033
|
kind: "element",
|
|
769
1034
|
tag: el.tag,
|
|
770
1035
|
svg: el.namespace === "svg",
|
|
771
|
-
props: this.lowerAttributes(el.attributes),
|
|
1036
|
+
props: this.lowerAttributes(el.attributes, true),
|
|
772
1037
|
children,
|
|
773
1038
|
static: false,
|
|
774
1039
|
...at ? { at } : {}
|
|
@@ -881,13 +1146,22 @@ var Lowerer = class {
|
|
|
881
1146
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
882
1147
|
}
|
|
883
1148
|
// --- attributes ---------------------------------------------------------
|
|
884
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1151
|
+
* A component gets the object as before, rebuilt whole when any value moves.
|
|
1152
|
+
*/
|
|
1153
|
+
lowerAttributes(attrs, element = false) {
|
|
1154
|
+
let anyReactive = false;
|
|
1155
|
+
const entry = (name, h) => {
|
|
1156
|
+
anyReactive ||= h.reactive;
|
|
1157
|
+
if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
|
|
1158
|
+
const accessor = `() => ${paren(h.code, "arrowBody")}`;
|
|
1159
|
+
return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
|
|
1160
|
+
};
|
|
885
1161
|
const props = [];
|
|
886
1162
|
const classEntries = [];
|
|
887
|
-
let classReactive = false;
|
|
888
1163
|
let classAt;
|
|
889
1164
|
const styleEntries = [];
|
|
890
|
-
let styleReactive = false;
|
|
891
1165
|
let styleAt;
|
|
892
1166
|
const usePairs = [];
|
|
893
1167
|
for (const a of attrs) {
|
|
@@ -927,15 +1201,13 @@ var Lowerer = class {
|
|
|
927
1201
|
break;
|
|
928
1202
|
case "ClassDirective": {
|
|
929
1203
|
const h = this.hole(a.hole);
|
|
930
|
-
classEntries.push(
|
|
931
|
-
classReactive = classReactive || h.reactive;
|
|
1204
|
+
classEntries.push(entry(a.name, h));
|
|
932
1205
|
classAt ??= h.at;
|
|
933
1206
|
break;
|
|
934
1207
|
}
|
|
935
1208
|
case "StyleDirective": {
|
|
936
1209
|
const h = this.hole(a.hole);
|
|
937
|
-
styleEntries.push(
|
|
938
|
-
styleReactive = styleReactive || h.reactive;
|
|
1210
|
+
styleEntries.push(entry(a.name, h));
|
|
939
1211
|
styleAt ??= h.at;
|
|
940
1212
|
break;
|
|
941
1213
|
}
|
|
@@ -955,18 +1227,19 @@ var Lowerer = class {
|
|
|
955
1227
|
name: "classList",
|
|
956
1228
|
kind: "attr",
|
|
957
1229
|
expr: `{ ${classEntries.join(", ")} }`,
|
|
958
|
-
reactive:
|
|
1230
|
+
reactive: !element && anyReactive,
|
|
959
1231
|
...classAt ? { at: classAt } : {}
|
|
960
1232
|
});
|
|
961
1233
|
}
|
|
962
1234
|
if (styleEntries.length > 0) {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1235
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1236
|
+
const base = props.findIndex((p) => p.name === "style");
|
|
1237
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
|
|
1238
|
+
else {
|
|
1239
|
+
const prop = props[base];
|
|
1240
|
+
const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1241
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1242
|
+
}
|
|
970
1243
|
}
|
|
971
1244
|
if (usePairs.length > 0) {
|
|
972
1245
|
props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
@@ -1055,7 +1328,7 @@ var Lowerer = class {
|
|
|
1055
1328
|
return base;
|
|
1056
1329
|
}
|
|
1057
1330
|
if (v.kind === "static") {
|
|
1058
|
-
base.literal = v.value;
|
|
1331
|
+
base.literal = decodeEntities(v.value);
|
|
1059
1332
|
return base;
|
|
1060
1333
|
}
|
|
1061
1334
|
if (v.kind === "hole") {
|
|
@@ -1068,7 +1341,7 @@ var Lowerer = class {
|
|
|
1068
1341
|
let reactive = false;
|
|
1069
1342
|
let at;
|
|
1070
1343
|
const body = v.parts.map((p) => {
|
|
1071
|
-
if ("text" in p) return escapeTemplate(p.text);
|
|
1344
|
+
if ("text" in p) return escapeTemplate(decodeEntities(p.text));
|
|
1072
1345
|
const h = this.hole(p.hole);
|
|
1073
1346
|
reactive = reactive || h.reactive;
|
|
1074
1347
|
at ??= h.at;
|
|
@@ -1349,9 +1622,12 @@ function attrExprCode(attr, ctx) {
|
|
|
1349
1622
|
}
|
|
1350
1623
|
return null;
|
|
1351
1624
|
}
|
|
1352
|
-
function buildProps(attrs, ctx) {
|
|
1625
|
+
function buildProps(attrs, ctx, element = false) {
|
|
1353
1626
|
const props = [];
|
|
1354
1627
|
const usePairs = [];
|
|
1628
|
+
const classEntries = [];
|
|
1629
|
+
const styleEntries = [];
|
|
1630
|
+
let styleAt;
|
|
1355
1631
|
for (const a of attrs) {
|
|
1356
1632
|
if (a.type === "JSXSpreadAttribute") {
|
|
1357
1633
|
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
@@ -1367,6 +1643,27 @@ function buildProps(attrs, ctx) {
|
|
|
1367
1643
|
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
1368
1644
|
continue;
|
|
1369
1645
|
}
|
|
1646
|
+
if (element && (ns === "class" || ns === "style")) {
|
|
1647
|
+
const key = JSON.stringify(a.name.name.name);
|
|
1648
|
+
const v = a.value;
|
|
1649
|
+
let value;
|
|
1650
|
+
if (v == null) value = "true";
|
|
1651
|
+
else if (isString(v)) value = JSON.stringify(literalOf(v));
|
|
1652
|
+
else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
1653
|
+
value = keyValue(v.expression, ctx);
|
|
1654
|
+
if (ns === "style") styleAt ??= posOf(v.expression, ctx);
|
|
1655
|
+
} else continue;
|
|
1656
|
+
(ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
1657
|
+
continue;
|
|
1658
|
+
}
|
|
1659
|
+
if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
|
|
1660
|
+
const entries = objectEntries(a.value.expression, ctx);
|
|
1661
|
+
if (entries) {
|
|
1662
|
+
styleEntries.unshift(...entries);
|
|
1663
|
+
styleAt = posOf(a.value.expression, ctx);
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1370
1667
|
if (ns === "oncapture") {
|
|
1371
1668
|
const evt = a.name.name.name.toLowerCase();
|
|
1372
1669
|
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
@@ -1375,9 +1672,37 @@ function buildProps(attrs, ctx) {
|
|
|
1375
1672
|
}
|
|
1376
1673
|
props.push(buildAttr(a, ctx));
|
|
1377
1674
|
}
|
|
1675
|
+
if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
|
|
1676
|
+
if (styleEntries.length > 0) {
|
|
1677
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1678
|
+
const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
|
|
1679
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
|
|
1680
|
+
else {
|
|
1681
|
+
const prop = props[base];
|
|
1682
|
+
const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1683
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1378
1686
|
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
1379
1687
|
return props;
|
|
1380
1688
|
}
|
|
1689
|
+
function keyValue(expr, ctx) {
|
|
1690
|
+
const code = ctx.code(expr);
|
|
1691
|
+
if (!isReactive(expr)) return code;
|
|
1692
|
+
const accessor = `() => ${paren(code, "arrowBody")}`;
|
|
1693
|
+
const at = posOf(expr, ctx);
|
|
1694
|
+
return at ? markHole(accessor, at.line, at.column) : accessor;
|
|
1695
|
+
}
|
|
1696
|
+
function objectEntries(expr, ctx) {
|
|
1697
|
+
if (expr?.type !== "ObjectExpression") return null;
|
|
1698
|
+
const entries = [];
|
|
1699
|
+
for (const p of expr.properties) {
|
|
1700
|
+
if (p.type !== "ObjectProperty") return null;
|
|
1701
|
+
const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
|
|
1702
|
+
entries.push(`${key}: ${keyValue(p.value, ctx)}`);
|
|
1703
|
+
}
|
|
1704
|
+
return entries;
|
|
1705
|
+
}
|
|
1381
1706
|
function buildChildren(children, ctx) {
|
|
1382
1707
|
const out = [];
|
|
1383
1708
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -1405,6 +1730,7 @@ function buildChildren(children, ctx) {
|
|
|
1405
1730
|
});
|
|
1406
1731
|
}
|
|
1407
1732
|
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
1733
|
+
if (ctx.dropStyles?.has(child.start)) continue;
|
|
1408
1734
|
out.push(buildNode(child, ctx));
|
|
1409
1735
|
} else if (child.type === "JSXSpreadChild") {
|
|
1410
1736
|
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
@@ -1474,13 +1800,17 @@ function buildElement(node, ctx, handled) {
|
|
|
1474
1800
|
const children = each ? [each] : buildChildren(node.children, ctx);
|
|
1475
1801
|
if (tag === CONTAINER2) return children.length === 1 ? children[0] : { kind: "fragment", children };
|
|
1476
1802
|
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
1477
|
-
|
|
1803
|
+
const props = buildProps(attributes, ctx, true);
|
|
1804
|
+
const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
|
|
1805
|
+
if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
|
|
1806
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1478
1807
|
}
|
|
1479
1808
|
function buildNode(node, ctx) {
|
|
1480
1809
|
if (node.type === "JSXFragment") {
|
|
1481
1810
|
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
1482
1811
|
}
|
|
1483
1812
|
if (directive(node, "if")) return buildIf(node, null, ctx);
|
|
1813
|
+
if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
|
|
1484
1814
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
1485
1815
|
if (!component) return buildElement(node, ctx, []);
|
|
1486
1816
|
const props = buildProps(node.openingElement.attributes, ctx);
|