@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
|
@@ -475,7 +475,7 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
475
475
|
}
|
|
476
476
|
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
477
477
|
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
478
|
-
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
|
|
478
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
479
479
|
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
480
480
|
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
481
481
|
}
|
|
@@ -614,6 +614,271 @@ function cleanTemplateText(value) {
|
|
|
614
614
|
return out;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
// src/lower/entities.ts
|
|
618
|
+
var NAMED = {
|
|
619
|
+
quot: 34,
|
|
620
|
+
amp: 38,
|
|
621
|
+
apos: 39,
|
|
622
|
+
lt: 60,
|
|
623
|
+
gt: 62,
|
|
624
|
+
nbsp: 160,
|
|
625
|
+
iexcl: 161,
|
|
626
|
+
cent: 162,
|
|
627
|
+
pound: 163,
|
|
628
|
+
curren: 164,
|
|
629
|
+
yen: 165,
|
|
630
|
+
brvbar: 166,
|
|
631
|
+
sect: 167,
|
|
632
|
+
uml: 168,
|
|
633
|
+
copy: 169,
|
|
634
|
+
ordf: 170,
|
|
635
|
+
laquo: 171,
|
|
636
|
+
not: 172,
|
|
637
|
+
shy: 173,
|
|
638
|
+
reg: 174,
|
|
639
|
+
macr: 175,
|
|
640
|
+
deg: 176,
|
|
641
|
+
plusmn: 177,
|
|
642
|
+
sup2: 178,
|
|
643
|
+
sup3: 179,
|
|
644
|
+
acute: 180,
|
|
645
|
+
micro: 181,
|
|
646
|
+
para: 182,
|
|
647
|
+
middot: 183,
|
|
648
|
+
cedil: 184,
|
|
649
|
+
sup1: 185,
|
|
650
|
+
ordm: 186,
|
|
651
|
+
raquo: 187,
|
|
652
|
+
frac14: 188,
|
|
653
|
+
frac12: 189,
|
|
654
|
+
frac34: 190,
|
|
655
|
+
iquest: 191,
|
|
656
|
+
Agrave: 192,
|
|
657
|
+
Aacute: 193,
|
|
658
|
+
Acirc: 194,
|
|
659
|
+
Atilde: 195,
|
|
660
|
+
Auml: 196,
|
|
661
|
+
Aring: 197,
|
|
662
|
+
AElig: 198,
|
|
663
|
+
Ccedil: 199,
|
|
664
|
+
Egrave: 200,
|
|
665
|
+
Eacute: 201,
|
|
666
|
+
Ecirc: 202,
|
|
667
|
+
Euml: 203,
|
|
668
|
+
Igrave: 204,
|
|
669
|
+
Iacute: 205,
|
|
670
|
+
Icirc: 206,
|
|
671
|
+
Iuml: 207,
|
|
672
|
+
ETH: 208,
|
|
673
|
+
Ntilde: 209,
|
|
674
|
+
Ograve: 210,
|
|
675
|
+
Oacute: 211,
|
|
676
|
+
Ocirc: 212,
|
|
677
|
+
Otilde: 213,
|
|
678
|
+
Ouml: 214,
|
|
679
|
+
times: 215,
|
|
680
|
+
Oslash: 216,
|
|
681
|
+
Ugrave: 217,
|
|
682
|
+
Uacute: 218,
|
|
683
|
+
Ucirc: 219,
|
|
684
|
+
Uuml: 220,
|
|
685
|
+
Yacute: 221,
|
|
686
|
+
THORN: 222,
|
|
687
|
+
szlig: 223,
|
|
688
|
+
agrave: 224,
|
|
689
|
+
aacute: 225,
|
|
690
|
+
acirc: 226,
|
|
691
|
+
atilde: 227,
|
|
692
|
+
auml: 228,
|
|
693
|
+
aring: 229,
|
|
694
|
+
aelig: 230,
|
|
695
|
+
ccedil: 231,
|
|
696
|
+
egrave: 232,
|
|
697
|
+
eacute: 233,
|
|
698
|
+
ecirc: 234,
|
|
699
|
+
euml: 235,
|
|
700
|
+
igrave: 236,
|
|
701
|
+
iacute: 237,
|
|
702
|
+
icirc: 238,
|
|
703
|
+
iuml: 239,
|
|
704
|
+
eth: 240,
|
|
705
|
+
ntilde: 241,
|
|
706
|
+
ograve: 242,
|
|
707
|
+
oacute: 243,
|
|
708
|
+
ocirc: 244,
|
|
709
|
+
otilde: 245,
|
|
710
|
+
ouml: 246,
|
|
711
|
+
divide: 247,
|
|
712
|
+
oslash: 248,
|
|
713
|
+
ugrave: 249,
|
|
714
|
+
uacute: 250,
|
|
715
|
+
ucirc: 251,
|
|
716
|
+
uuml: 252,
|
|
717
|
+
yacute: 253,
|
|
718
|
+
thorn: 254,
|
|
719
|
+
yuml: 255,
|
|
720
|
+
OElig: 338,
|
|
721
|
+
oelig: 339,
|
|
722
|
+
Scaron: 352,
|
|
723
|
+
scaron: 353,
|
|
724
|
+
Yuml: 376,
|
|
725
|
+
fnof: 402,
|
|
726
|
+
circ: 710,
|
|
727
|
+
tilde: 732,
|
|
728
|
+
Alpha: 913,
|
|
729
|
+
Beta: 914,
|
|
730
|
+
Gamma: 915,
|
|
731
|
+
Delta: 916,
|
|
732
|
+
Epsilon: 917,
|
|
733
|
+
Zeta: 918,
|
|
734
|
+
Eta: 919,
|
|
735
|
+
Theta: 920,
|
|
736
|
+
Iota: 921,
|
|
737
|
+
Kappa: 922,
|
|
738
|
+
Lambda: 923,
|
|
739
|
+
Mu: 924,
|
|
740
|
+
Nu: 925,
|
|
741
|
+
Xi: 926,
|
|
742
|
+
Omicron: 927,
|
|
743
|
+
Pi: 928,
|
|
744
|
+
Rho: 929,
|
|
745
|
+
Sigma: 931,
|
|
746
|
+
Tau: 932,
|
|
747
|
+
Upsilon: 933,
|
|
748
|
+
Phi: 934,
|
|
749
|
+
Chi: 935,
|
|
750
|
+
Psi: 936,
|
|
751
|
+
Omega: 937,
|
|
752
|
+
alpha: 945,
|
|
753
|
+
beta: 946,
|
|
754
|
+
gamma: 947,
|
|
755
|
+
delta: 948,
|
|
756
|
+
epsilon: 949,
|
|
757
|
+
zeta: 950,
|
|
758
|
+
eta: 951,
|
|
759
|
+
theta: 952,
|
|
760
|
+
iota: 953,
|
|
761
|
+
kappa: 954,
|
|
762
|
+
lambda: 955,
|
|
763
|
+
mu: 956,
|
|
764
|
+
nu: 957,
|
|
765
|
+
xi: 958,
|
|
766
|
+
omicron: 959,
|
|
767
|
+
pi: 960,
|
|
768
|
+
rho: 961,
|
|
769
|
+
sigmaf: 962,
|
|
770
|
+
sigma: 963,
|
|
771
|
+
tau: 964,
|
|
772
|
+
upsilon: 965,
|
|
773
|
+
phi: 966,
|
|
774
|
+
chi: 967,
|
|
775
|
+
psi: 968,
|
|
776
|
+
omega: 969,
|
|
777
|
+
thetasym: 977,
|
|
778
|
+
upsih: 978,
|
|
779
|
+
piv: 982,
|
|
780
|
+
ensp: 8194,
|
|
781
|
+
emsp: 8195,
|
|
782
|
+
thinsp: 8201,
|
|
783
|
+
zwnj: 8204,
|
|
784
|
+
zwj: 8205,
|
|
785
|
+
lrm: 8206,
|
|
786
|
+
rlm: 8207,
|
|
787
|
+
ndash: 8211,
|
|
788
|
+
mdash: 8212,
|
|
789
|
+
lsquo: 8216,
|
|
790
|
+
rsquo: 8217,
|
|
791
|
+
sbquo: 8218,
|
|
792
|
+
ldquo: 8220,
|
|
793
|
+
rdquo: 8221,
|
|
794
|
+
bdquo: 8222,
|
|
795
|
+
dagger: 8224,
|
|
796
|
+
Dagger: 8225,
|
|
797
|
+
bull: 8226,
|
|
798
|
+
hellip: 8230,
|
|
799
|
+
permil: 8240,
|
|
800
|
+
prime: 8242,
|
|
801
|
+
Prime: 8243,
|
|
802
|
+
lsaquo: 8249,
|
|
803
|
+
rsaquo: 8250,
|
|
804
|
+
oline: 8254,
|
|
805
|
+
frasl: 8260,
|
|
806
|
+
euro: 8364,
|
|
807
|
+
image: 8465,
|
|
808
|
+
weierp: 8472,
|
|
809
|
+
real: 8476,
|
|
810
|
+
trade: 8482,
|
|
811
|
+
alefsym: 8501,
|
|
812
|
+
larr: 8592,
|
|
813
|
+
uarr: 8593,
|
|
814
|
+
rarr: 8594,
|
|
815
|
+
darr: 8595,
|
|
816
|
+
harr: 8596,
|
|
817
|
+
crarr: 8629,
|
|
818
|
+
lArr: 8656,
|
|
819
|
+
uArr: 8657,
|
|
820
|
+
rArr: 8658,
|
|
821
|
+
dArr: 8659,
|
|
822
|
+
hArr: 8660,
|
|
823
|
+
forall: 8704,
|
|
824
|
+
part: 8706,
|
|
825
|
+
exist: 8707,
|
|
826
|
+
empty: 8709,
|
|
827
|
+
nabla: 8711,
|
|
828
|
+
isin: 8712,
|
|
829
|
+
notin: 8713,
|
|
830
|
+
ni: 8715,
|
|
831
|
+
prod: 8719,
|
|
832
|
+
sum: 8721,
|
|
833
|
+
minus: 8722,
|
|
834
|
+
lowast: 8727,
|
|
835
|
+
radic: 8730,
|
|
836
|
+
prop: 8733,
|
|
837
|
+
infin: 8734,
|
|
838
|
+
ang: 8736,
|
|
839
|
+
and: 8743,
|
|
840
|
+
or: 8744,
|
|
841
|
+
cap: 8745,
|
|
842
|
+
cup: 8746,
|
|
843
|
+
int: 8747,
|
|
844
|
+
there4: 8756,
|
|
845
|
+
sim: 8764,
|
|
846
|
+
cong: 8773,
|
|
847
|
+
asymp: 8776,
|
|
848
|
+
ne: 8800,
|
|
849
|
+
equiv: 8801,
|
|
850
|
+
le: 8804,
|
|
851
|
+
ge: 8805,
|
|
852
|
+
sub: 8834,
|
|
853
|
+
sup: 8835,
|
|
854
|
+
nsub: 8836,
|
|
855
|
+
sube: 8838,
|
|
856
|
+
supe: 8839,
|
|
857
|
+
oplus: 8853,
|
|
858
|
+
otimes: 8855,
|
|
859
|
+
perp: 8869,
|
|
860
|
+
sdot: 8901,
|
|
861
|
+
lceil: 8968,
|
|
862
|
+
rceil: 8969,
|
|
863
|
+
lfloor: 8970,
|
|
864
|
+
rfloor: 8971,
|
|
865
|
+
lang: 9001,
|
|
866
|
+
rang: 9002,
|
|
867
|
+
loz: 9674,
|
|
868
|
+
spades: 9824,
|
|
869
|
+
clubs: 9827,
|
|
870
|
+
hearts: 9829,
|
|
871
|
+
diams: 9830
|
|
872
|
+
};
|
|
873
|
+
var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
|
|
874
|
+
function decodeEntities(value) {
|
|
875
|
+
if (!value.includes("&")) return value;
|
|
876
|
+
return value.replace(REFERENCE, (match, hex, dec, name) => {
|
|
877
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
|
|
878
|
+
return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
|
|
617
882
|
// src/lower/template.ts
|
|
618
883
|
var DELEGATED = /* @__PURE__ */ new Set([
|
|
619
884
|
"click",
|
|
@@ -700,7 +965,7 @@ var Lowerer = class {
|
|
|
700
965
|
switch (node.kind) {
|
|
701
966
|
case "Text": {
|
|
702
967
|
if (node.raw) return { kind: "text", value: node.value };
|
|
703
|
-
const cleaned = cleanTemplateText(node.value);
|
|
968
|
+
const cleaned = decodeEntities(cleanTemplateText(node.value));
|
|
704
969
|
return cleaned ? { kind: "text", value: cleaned } : null;
|
|
705
970
|
}
|
|
706
971
|
case "Comment":
|
|
@@ -736,7 +1001,7 @@ var Lowerer = class {
|
|
|
736
1001
|
kind: "element",
|
|
737
1002
|
tag: el.tag,
|
|
738
1003
|
svg: el.namespace === "svg",
|
|
739
|
-
props: this.lowerAttributes(el.attributes),
|
|
1004
|
+
props: this.lowerAttributes(el.attributes, true),
|
|
740
1005
|
children,
|
|
741
1006
|
static: false,
|
|
742
1007
|
...at ? { at } : {}
|
|
@@ -849,13 +1114,22 @@ var Lowerer = class {
|
|
|
849
1114
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
850
1115
|
}
|
|
851
1116
|
// --- attributes ---------------------------------------------------------
|
|
852
|
-
|
|
1117
|
+
/**
|
|
1118
|
+
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1119
|
+
* A component gets the object as before, rebuilt whole when any value moves.
|
|
1120
|
+
*/
|
|
1121
|
+
lowerAttributes(attrs, element = false) {
|
|
1122
|
+
let anyReactive = false;
|
|
1123
|
+
const entry = (name, h) => {
|
|
1124
|
+
anyReactive ||= h.reactive;
|
|
1125
|
+
if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
|
|
1126
|
+
const accessor = `() => ${paren(h.code, "arrowBody")}`;
|
|
1127
|
+
return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
|
|
1128
|
+
};
|
|
853
1129
|
const props = [];
|
|
854
1130
|
const classEntries = [];
|
|
855
|
-
let classReactive = false;
|
|
856
1131
|
let classAt;
|
|
857
1132
|
const styleEntries = [];
|
|
858
|
-
let styleReactive = false;
|
|
859
1133
|
let styleAt;
|
|
860
1134
|
const usePairs = [];
|
|
861
1135
|
for (const a of attrs) {
|
|
@@ -895,15 +1169,13 @@ var Lowerer = class {
|
|
|
895
1169
|
break;
|
|
896
1170
|
case "ClassDirective": {
|
|
897
1171
|
const h = this.hole(a.hole);
|
|
898
|
-
classEntries.push(
|
|
899
|
-
classReactive = classReactive || h.reactive;
|
|
1172
|
+
classEntries.push(entry(a.name, h));
|
|
900
1173
|
classAt ??= h.at;
|
|
901
1174
|
break;
|
|
902
1175
|
}
|
|
903
1176
|
case "StyleDirective": {
|
|
904
1177
|
const h = this.hole(a.hole);
|
|
905
|
-
styleEntries.push(
|
|
906
|
-
styleReactive = styleReactive || h.reactive;
|
|
1178
|
+
styleEntries.push(entry(a.name, h));
|
|
907
1179
|
styleAt ??= h.at;
|
|
908
1180
|
break;
|
|
909
1181
|
}
|
|
@@ -923,18 +1195,19 @@ var Lowerer = class {
|
|
|
923
1195
|
name: "classList",
|
|
924
1196
|
kind: "attr",
|
|
925
1197
|
expr: `{ ${classEntries.join(", ")} }`,
|
|
926
|
-
reactive:
|
|
1198
|
+
reactive: !element && anyReactive,
|
|
927
1199
|
...classAt ? { at: classAt } : {}
|
|
928
1200
|
});
|
|
929
1201
|
}
|
|
930
1202
|
if (styleEntries.length > 0) {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1203
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1204
|
+
const base = props.findIndex((p) => p.name === "style");
|
|
1205
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
|
|
1206
|
+
else {
|
|
1207
|
+
const prop = props[base];
|
|
1208
|
+
const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1209
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1210
|
+
}
|
|
938
1211
|
}
|
|
939
1212
|
if (usePairs.length > 0) {
|
|
940
1213
|
props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
@@ -1023,7 +1296,7 @@ var Lowerer = class {
|
|
|
1023
1296
|
return base;
|
|
1024
1297
|
}
|
|
1025
1298
|
if (v.kind === "static") {
|
|
1026
|
-
base.literal = v.value;
|
|
1299
|
+
base.literal = decodeEntities(v.value);
|
|
1027
1300
|
return base;
|
|
1028
1301
|
}
|
|
1029
1302
|
if (v.kind === "hole") {
|
|
@@ -1036,7 +1309,7 @@ var Lowerer = class {
|
|
|
1036
1309
|
let reactive = false;
|
|
1037
1310
|
let at;
|
|
1038
1311
|
const body = v.parts.map((p) => {
|
|
1039
|
-
if ("text" in p) return escapeTemplate(p.text);
|
|
1312
|
+
if ("text" in p) return escapeTemplate(decodeEntities(p.text));
|
|
1040
1313
|
const h = this.hole(p.hole);
|
|
1041
1314
|
reactive = reactive || h.reactive;
|
|
1042
1315
|
at ??= h.at;
|
|
@@ -1310,9 +1583,12 @@ function attrExprCode(attr, ctx) {
|
|
|
1310
1583
|
}
|
|
1311
1584
|
return null;
|
|
1312
1585
|
}
|
|
1313
|
-
function buildProps(attrs, ctx) {
|
|
1586
|
+
function buildProps(attrs, ctx, element = false) {
|
|
1314
1587
|
const props = [];
|
|
1315
1588
|
const usePairs = [];
|
|
1589
|
+
const classEntries = [];
|
|
1590
|
+
const styleEntries = [];
|
|
1591
|
+
let styleAt;
|
|
1316
1592
|
for (const a of attrs) {
|
|
1317
1593
|
if (a.type === "JSXSpreadAttribute") {
|
|
1318
1594
|
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
@@ -1328,6 +1604,27 @@ function buildProps(attrs, ctx) {
|
|
|
1328
1604
|
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
1329
1605
|
continue;
|
|
1330
1606
|
}
|
|
1607
|
+
if (element && (ns === "class" || ns === "style")) {
|
|
1608
|
+
const key = JSON.stringify(a.name.name.name);
|
|
1609
|
+
const v = a.value;
|
|
1610
|
+
let value;
|
|
1611
|
+
if (v == null) value = "true";
|
|
1612
|
+
else if (isString(v)) value = JSON.stringify(literalOf(v));
|
|
1613
|
+
else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
1614
|
+
value = keyValue(v.expression, ctx);
|
|
1615
|
+
if (ns === "style") styleAt ??= posOf(v.expression, ctx);
|
|
1616
|
+
} else continue;
|
|
1617
|
+
(ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
1618
|
+
continue;
|
|
1619
|
+
}
|
|
1620
|
+
if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
|
|
1621
|
+
const entries = objectEntries(a.value.expression, ctx);
|
|
1622
|
+
if (entries) {
|
|
1623
|
+
styleEntries.unshift(...entries);
|
|
1624
|
+
styleAt = posOf(a.value.expression, ctx);
|
|
1625
|
+
continue;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1331
1628
|
if (ns === "oncapture") {
|
|
1332
1629
|
const evt = a.name.name.name.toLowerCase();
|
|
1333
1630
|
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
@@ -1336,9 +1633,37 @@ function buildProps(attrs, ctx) {
|
|
|
1336
1633
|
}
|
|
1337
1634
|
props.push(buildAttr(a, ctx));
|
|
1338
1635
|
}
|
|
1636
|
+
if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
|
|
1637
|
+
if (styleEntries.length > 0) {
|
|
1638
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1639
|
+
const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
|
|
1640
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
|
|
1641
|
+
else {
|
|
1642
|
+
const prop = props[base];
|
|
1643
|
+
const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1644
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1339
1647
|
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
1340
1648
|
return props;
|
|
1341
1649
|
}
|
|
1650
|
+
function keyValue(expr, ctx) {
|
|
1651
|
+
const code = ctx.code(expr);
|
|
1652
|
+
if (!isReactive(expr)) return code;
|
|
1653
|
+
const accessor = `() => ${paren(code, "arrowBody")}`;
|
|
1654
|
+
const at = posOf(expr, ctx);
|
|
1655
|
+
return at ? markHole(accessor, at.line, at.column) : accessor;
|
|
1656
|
+
}
|
|
1657
|
+
function objectEntries(expr, ctx) {
|
|
1658
|
+
if (expr?.type !== "ObjectExpression") return null;
|
|
1659
|
+
const entries = [];
|
|
1660
|
+
for (const p of expr.properties) {
|
|
1661
|
+
if (p.type !== "ObjectProperty") return null;
|
|
1662
|
+
const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
|
|
1663
|
+
entries.push(`${key}: ${keyValue(p.value, ctx)}`);
|
|
1664
|
+
}
|
|
1665
|
+
return entries;
|
|
1666
|
+
}
|
|
1342
1667
|
function buildChildren(children, ctx) {
|
|
1343
1668
|
const out = [];
|
|
1344
1669
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -1366,6 +1691,7 @@ function buildChildren(children, ctx) {
|
|
|
1366
1691
|
});
|
|
1367
1692
|
}
|
|
1368
1693
|
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
1694
|
+
if (ctx.dropStyles?.has(child.start)) continue;
|
|
1369
1695
|
out.push(buildNode(child, ctx));
|
|
1370
1696
|
} else if (child.type === "JSXSpreadChild") {
|
|
1371
1697
|
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
@@ -1435,13 +1761,17 @@ function buildElement(node, ctx, handled) {
|
|
|
1435
1761
|
const children = each ? [each] : buildChildren(node.children, ctx);
|
|
1436
1762
|
if (tag === CONTAINER2) return children.length === 1 ? children[0] : { kind: "fragment", children };
|
|
1437
1763
|
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
1438
|
-
|
|
1764
|
+
const props = buildProps(attributes, ctx, true);
|
|
1765
|
+
const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
|
|
1766
|
+
if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
|
|
1767
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1439
1768
|
}
|
|
1440
1769
|
function buildNode(node, ctx) {
|
|
1441
1770
|
if (node.type === "JSXFragment") {
|
|
1442
1771
|
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
1443
1772
|
}
|
|
1444
1773
|
if (directive(node, "if")) return buildIf(node, null, ctx);
|
|
1774
|
+
if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
|
|
1445
1775
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
1446
1776
|
if (!component) return buildElement(node, ctx, []);
|
|
1447
1777
|
const props = buildProps(node.openingElement.attributes, ctx);
|