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