@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/compiler v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/frontend/babel/plugin.ts
|
|
4
4
|
import { declare } from "@babel/helper-plugin-utils";
|
|
@@ -644,7 +644,7 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
644
644
|
}
|
|
645
645
|
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
646
646
|
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
647
|
-
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
|
|
647
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
648
648
|
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
649
649
|
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
650
650
|
}
|
|
@@ -792,6 +792,271 @@ function cleanTemplateText(value) {
|
|
|
792
792
|
return out;
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
// src/lower/entities.ts
|
|
796
|
+
var NAMED = {
|
|
797
|
+
quot: 34,
|
|
798
|
+
amp: 38,
|
|
799
|
+
apos: 39,
|
|
800
|
+
lt: 60,
|
|
801
|
+
gt: 62,
|
|
802
|
+
nbsp: 160,
|
|
803
|
+
iexcl: 161,
|
|
804
|
+
cent: 162,
|
|
805
|
+
pound: 163,
|
|
806
|
+
curren: 164,
|
|
807
|
+
yen: 165,
|
|
808
|
+
brvbar: 166,
|
|
809
|
+
sect: 167,
|
|
810
|
+
uml: 168,
|
|
811
|
+
copy: 169,
|
|
812
|
+
ordf: 170,
|
|
813
|
+
laquo: 171,
|
|
814
|
+
not: 172,
|
|
815
|
+
shy: 173,
|
|
816
|
+
reg: 174,
|
|
817
|
+
macr: 175,
|
|
818
|
+
deg: 176,
|
|
819
|
+
plusmn: 177,
|
|
820
|
+
sup2: 178,
|
|
821
|
+
sup3: 179,
|
|
822
|
+
acute: 180,
|
|
823
|
+
micro: 181,
|
|
824
|
+
para: 182,
|
|
825
|
+
middot: 183,
|
|
826
|
+
cedil: 184,
|
|
827
|
+
sup1: 185,
|
|
828
|
+
ordm: 186,
|
|
829
|
+
raquo: 187,
|
|
830
|
+
frac14: 188,
|
|
831
|
+
frac12: 189,
|
|
832
|
+
frac34: 190,
|
|
833
|
+
iquest: 191,
|
|
834
|
+
Agrave: 192,
|
|
835
|
+
Aacute: 193,
|
|
836
|
+
Acirc: 194,
|
|
837
|
+
Atilde: 195,
|
|
838
|
+
Auml: 196,
|
|
839
|
+
Aring: 197,
|
|
840
|
+
AElig: 198,
|
|
841
|
+
Ccedil: 199,
|
|
842
|
+
Egrave: 200,
|
|
843
|
+
Eacute: 201,
|
|
844
|
+
Ecirc: 202,
|
|
845
|
+
Euml: 203,
|
|
846
|
+
Igrave: 204,
|
|
847
|
+
Iacute: 205,
|
|
848
|
+
Icirc: 206,
|
|
849
|
+
Iuml: 207,
|
|
850
|
+
ETH: 208,
|
|
851
|
+
Ntilde: 209,
|
|
852
|
+
Ograve: 210,
|
|
853
|
+
Oacute: 211,
|
|
854
|
+
Ocirc: 212,
|
|
855
|
+
Otilde: 213,
|
|
856
|
+
Ouml: 214,
|
|
857
|
+
times: 215,
|
|
858
|
+
Oslash: 216,
|
|
859
|
+
Ugrave: 217,
|
|
860
|
+
Uacute: 218,
|
|
861
|
+
Ucirc: 219,
|
|
862
|
+
Uuml: 220,
|
|
863
|
+
Yacute: 221,
|
|
864
|
+
THORN: 222,
|
|
865
|
+
szlig: 223,
|
|
866
|
+
agrave: 224,
|
|
867
|
+
aacute: 225,
|
|
868
|
+
acirc: 226,
|
|
869
|
+
atilde: 227,
|
|
870
|
+
auml: 228,
|
|
871
|
+
aring: 229,
|
|
872
|
+
aelig: 230,
|
|
873
|
+
ccedil: 231,
|
|
874
|
+
egrave: 232,
|
|
875
|
+
eacute: 233,
|
|
876
|
+
ecirc: 234,
|
|
877
|
+
euml: 235,
|
|
878
|
+
igrave: 236,
|
|
879
|
+
iacute: 237,
|
|
880
|
+
icirc: 238,
|
|
881
|
+
iuml: 239,
|
|
882
|
+
eth: 240,
|
|
883
|
+
ntilde: 241,
|
|
884
|
+
ograve: 242,
|
|
885
|
+
oacute: 243,
|
|
886
|
+
ocirc: 244,
|
|
887
|
+
otilde: 245,
|
|
888
|
+
ouml: 246,
|
|
889
|
+
divide: 247,
|
|
890
|
+
oslash: 248,
|
|
891
|
+
ugrave: 249,
|
|
892
|
+
uacute: 250,
|
|
893
|
+
ucirc: 251,
|
|
894
|
+
uuml: 252,
|
|
895
|
+
yacute: 253,
|
|
896
|
+
thorn: 254,
|
|
897
|
+
yuml: 255,
|
|
898
|
+
OElig: 338,
|
|
899
|
+
oelig: 339,
|
|
900
|
+
Scaron: 352,
|
|
901
|
+
scaron: 353,
|
|
902
|
+
Yuml: 376,
|
|
903
|
+
fnof: 402,
|
|
904
|
+
circ: 710,
|
|
905
|
+
tilde: 732,
|
|
906
|
+
Alpha: 913,
|
|
907
|
+
Beta: 914,
|
|
908
|
+
Gamma: 915,
|
|
909
|
+
Delta: 916,
|
|
910
|
+
Epsilon: 917,
|
|
911
|
+
Zeta: 918,
|
|
912
|
+
Eta: 919,
|
|
913
|
+
Theta: 920,
|
|
914
|
+
Iota: 921,
|
|
915
|
+
Kappa: 922,
|
|
916
|
+
Lambda: 923,
|
|
917
|
+
Mu: 924,
|
|
918
|
+
Nu: 925,
|
|
919
|
+
Xi: 926,
|
|
920
|
+
Omicron: 927,
|
|
921
|
+
Pi: 928,
|
|
922
|
+
Rho: 929,
|
|
923
|
+
Sigma: 931,
|
|
924
|
+
Tau: 932,
|
|
925
|
+
Upsilon: 933,
|
|
926
|
+
Phi: 934,
|
|
927
|
+
Chi: 935,
|
|
928
|
+
Psi: 936,
|
|
929
|
+
Omega: 937,
|
|
930
|
+
alpha: 945,
|
|
931
|
+
beta: 946,
|
|
932
|
+
gamma: 947,
|
|
933
|
+
delta: 948,
|
|
934
|
+
epsilon: 949,
|
|
935
|
+
zeta: 950,
|
|
936
|
+
eta: 951,
|
|
937
|
+
theta: 952,
|
|
938
|
+
iota: 953,
|
|
939
|
+
kappa: 954,
|
|
940
|
+
lambda: 955,
|
|
941
|
+
mu: 956,
|
|
942
|
+
nu: 957,
|
|
943
|
+
xi: 958,
|
|
944
|
+
omicron: 959,
|
|
945
|
+
pi: 960,
|
|
946
|
+
rho: 961,
|
|
947
|
+
sigmaf: 962,
|
|
948
|
+
sigma: 963,
|
|
949
|
+
tau: 964,
|
|
950
|
+
upsilon: 965,
|
|
951
|
+
phi: 966,
|
|
952
|
+
chi: 967,
|
|
953
|
+
psi: 968,
|
|
954
|
+
omega: 969,
|
|
955
|
+
thetasym: 977,
|
|
956
|
+
upsih: 978,
|
|
957
|
+
piv: 982,
|
|
958
|
+
ensp: 8194,
|
|
959
|
+
emsp: 8195,
|
|
960
|
+
thinsp: 8201,
|
|
961
|
+
zwnj: 8204,
|
|
962
|
+
zwj: 8205,
|
|
963
|
+
lrm: 8206,
|
|
964
|
+
rlm: 8207,
|
|
965
|
+
ndash: 8211,
|
|
966
|
+
mdash: 8212,
|
|
967
|
+
lsquo: 8216,
|
|
968
|
+
rsquo: 8217,
|
|
969
|
+
sbquo: 8218,
|
|
970
|
+
ldquo: 8220,
|
|
971
|
+
rdquo: 8221,
|
|
972
|
+
bdquo: 8222,
|
|
973
|
+
dagger: 8224,
|
|
974
|
+
Dagger: 8225,
|
|
975
|
+
bull: 8226,
|
|
976
|
+
hellip: 8230,
|
|
977
|
+
permil: 8240,
|
|
978
|
+
prime: 8242,
|
|
979
|
+
Prime: 8243,
|
|
980
|
+
lsaquo: 8249,
|
|
981
|
+
rsaquo: 8250,
|
|
982
|
+
oline: 8254,
|
|
983
|
+
frasl: 8260,
|
|
984
|
+
euro: 8364,
|
|
985
|
+
image: 8465,
|
|
986
|
+
weierp: 8472,
|
|
987
|
+
real: 8476,
|
|
988
|
+
trade: 8482,
|
|
989
|
+
alefsym: 8501,
|
|
990
|
+
larr: 8592,
|
|
991
|
+
uarr: 8593,
|
|
992
|
+
rarr: 8594,
|
|
993
|
+
darr: 8595,
|
|
994
|
+
harr: 8596,
|
|
995
|
+
crarr: 8629,
|
|
996
|
+
lArr: 8656,
|
|
997
|
+
uArr: 8657,
|
|
998
|
+
rArr: 8658,
|
|
999
|
+
dArr: 8659,
|
|
1000
|
+
hArr: 8660,
|
|
1001
|
+
forall: 8704,
|
|
1002
|
+
part: 8706,
|
|
1003
|
+
exist: 8707,
|
|
1004
|
+
empty: 8709,
|
|
1005
|
+
nabla: 8711,
|
|
1006
|
+
isin: 8712,
|
|
1007
|
+
notin: 8713,
|
|
1008
|
+
ni: 8715,
|
|
1009
|
+
prod: 8719,
|
|
1010
|
+
sum: 8721,
|
|
1011
|
+
minus: 8722,
|
|
1012
|
+
lowast: 8727,
|
|
1013
|
+
radic: 8730,
|
|
1014
|
+
prop: 8733,
|
|
1015
|
+
infin: 8734,
|
|
1016
|
+
ang: 8736,
|
|
1017
|
+
and: 8743,
|
|
1018
|
+
or: 8744,
|
|
1019
|
+
cap: 8745,
|
|
1020
|
+
cup: 8746,
|
|
1021
|
+
int: 8747,
|
|
1022
|
+
there4: 8756,
|
|
1023
|
+
sim: 8764,
|
|
1024
|
+
cong: 8773,
|
|
1025
|
+
asymp: 8776,
|
|
1026
|
+
ne: 8800,
|
|
1027
|
+
equiv: 8801,
|
|
1028
|
+
le: 8804,
|
|
1029
|
+
ge: 8805,
|
|
1030
|
+
sub: 8834,
|
|
1031
|
+
sup: 8835,
|
|
1032
|
+
nsub: 8836,
|
|
1033
|
+
sube: 8838,
|
|
1034
|
+
supe: 8839,
|
|
1035
|
+
oplus: 8853,
|
|
1036
|
+
otimes: 8855,
|
|
1037
|
+
perp: 8869,
|
|
1038
|
+
sdot: 8901,
|
|
1039
|
+
lceil: 8968,
|
|
1040
|
+
rceil: 8969,
|
|
1041
|
+
lfloor: 8970,
|
|
1042
|
+
rfloor: 8971,
|
|
1043
|
+
lang: 9001,
|
|
1044
|
+
rang: 9002,
|
|
1045
|
+
loz: 9674,
|
|
1046
|
+
spades: 9824,
|
|
1047
|
+
clubs: 9827,
|
|
1048
|
+
hearts: 9829,
|
|
1049
|
+
diams: 9830
|
|
1050
|
+
};
|
|
1051
|
+
var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
|
|
1052
|
+
function decodeEntities(value) {
|
|
1053
|
+
if (!value.includes("&")) return value;
|
|
1054
|
+
return value.replace(REFERENCE, (match, hex, dec, name) => {
|
|
1055
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
|
|
1056
|
+
return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
|
|
795
1060
|
// src/lower/template.ts
|
|
796
1061
|
var DELEGATED = /* @__PURE__ */ new Set([
|
|
797
1062
|
"click",
|
|
@@ -878,7 +1143,7 @@ var Lowerer = class {
|
|
|
878
1143
|
switch (node.kind) {
|
|
879
1144
|
case "Text": {
|
|
880
1145
|
if (node.raw) return { kind: "text", value: node.value };
|
|
881
|
-
const cleaned = cleanTemplateText(node.value);
|
|
1146
|
+
const cleaned = decodeEntities(cleanTemplateText(node.value));
|
|
882
1147
|
return cleaned ? { kind: "text", value: cleaned } : null;
|
|
883
1148
|
}
|
|
884
1149
|
case "Comment":
|
|
@@ -914,7 +1179,7 @@ var Lowerer = class {
|
|
|
914
1179
|
kind: "element",
|
|
915
1180
|
tag: el.tag,
|
|
916
1181
|
svg: el.namespace === "svg",
|
|
917
|
-
props: this.lowerAttributes(el.attributes),
|
|
1182
|
+
props: this.lowerAttributes(el.attributes, true),
|
|
918
1183
|
children,
|
|
919
1184
|
static: false,
|
|
920
1185
|
...at ? { at } : {}
|
|
@@ -1027,13 +1292,22 @@ var Lowerer = class {
|
|
|
1027
1292
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1028
1293
|
}
|
|
1029
1294
|
// --- attributes ---------------------------------------------------------
|
|
1030
|
-
|
|
1295
|
+
/**
|
|
1296
|
+
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1297
|
+
* A component gets the object as before, rebuilt whole when any value moves.
|
|
1298
|
+
*/
|
|
1299
|
+
lowerAttributes(attrs, element = false) {
|
|
1300
|
+
let anyReactive = false;
|
|
1301
|
+
const entry = (name, h) => {
|
|
1302
|
+
anyReactive ||= h.reactive;
|
|
1303
|
+
if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
|
|
1304
|
+
const accessor = `() => ${paren(h.code, "arrowBody")}`;
|
|
1305
|
+
return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
|
|
1306
|
+
};
|
|
1031
1307
|
const props = [];
|
|
1032
1308
|
const classEntries = [];
|
|
1033
|
-
let classReactive = false;
|
|
1034
1309
|
let classAt;
|
|
1035
1310
|
const styleEntries = [];
|
|
1036
|
-
let styleReactive = false;
|
|
1037
1311
|
let styleAt;
|
|
1038
1312
|
const usePairs = [];
|
|
1039
1313
|
for (const a of attrs) {
|
|
@@ -1073,15 +1347,13 @@ var Lowerer = class {
|
|
|
1073
1347
|
break;
|
|
1074
1348
|
case "ClassDirective": {
|
|
1075
1349
|
const h = this.hole(a.hole);
|
|
1076
|
-
classEntries.push(
|
|
1077
|
-
classReactive = classReactive || h.reactive;
|
|
1350
|
+
classEntries.push(entry(a.name, h));
|
|
1078
1351
|
classAt ??= h.at;
|
|
1079
1352
|
break;
|
|
1080
1353
|
}
|
|
1081
1354
|
case "StyleDirective": {
|
|
1082
1355
|
const h = this.hole(a.hole);
|
|
1083
|
-
styleEntries.push(
|
|
1084
|
-
styleReactive = styleReactive || h.reactive;
|
|
1356
|
+
styleEntries.push(entry(a.name, h));
|
|
1085
1357
|
styleAt ??= h.at;
|
|
1086
1358
|
break;
|
|
1087
1359
|
}
|
|
@@ -1101,18 +1373,19 @@ var Lowerer = class {
|
|
|
1101
1373
|
name: "classList",
|
|
1102
1374
|
kind: "attr",
|
|
1103
1375
|
expr: `{ ${classEntries.join(", ")} }`,
|
|
1104
|
-
reactive:
|
|
1376
|
+
reactive: !element && anyReactive,
|
|
1105
1377
|
...classAt ? { at: classAt } : {}
|
|
1106
1378
|
});
|
|
1107
1379
|
}
|
|
1108
1380
|
if (styleEntries.length > 0) {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1381
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1382
|
+
const base = props.findIndex((p) => p.name === "style");
|
|
1383
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
|
|
1384
|
+
else {
|
|
1385
|
+
const prop = props[base];
|
|
1386
|
+
const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1387
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1388
|
+
}
|
|
1116
1389
|
}
|
|
1117
1390
|
if (usePairs.length > 0) {
|
|
1118
1391
|
props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
@@ -1201,7 +1474,7 @@ var Lowerer = class {
|
|
|
1201
1474
|
return base;
|
|
1202
1475
|
}
|
|
1203
1476
|
if (v.kind === "static") {
|
|
1204
|
-
base.literal = v.value;
|
|
1477
|
+
base.literal = decodeEntities(v.value);
|
|
1205
1478
|
return base;
|
|
1206
1479
|
}
|
|
1207
1480
|
if (v.kind === "hole") {
|
|
@@ -1214,7 +1487,7 @@ var Lowerer = class {
|
|
|
1214
1487
|
let reactive = false;
|
|
1215
1488
|
let at;
|
|
1216
1489
|
const body = v.parts.map((p) => {
|
|
1217
|
-
if ("text" in p) return escapeTemplate(p.text);
|
|
1490
|
+
if ("text" in p) return escapeTemplate(decodeEntities(p.text));
|
|
1218
1491
|
const h = this.hole(p.hole);
|
|
1219
1492
|
reactive = reactive || h.reactive;
|
|
1220
1493
|
at ??= h.at;
|
|
@@ -1530,9 +1803,12 @@ function attrExprCode(attr, ctx) {
|
|
|
1530
1803
|
}
|
|
1531
1804
|
return null;
|
|
1532
1805
|
}
|
|
1533
|
-
function buildProps(attrs, ctx) {
|
|
1806
|
+
function buildProps(attrs, ctx, element = false) {
|
|
1534
1807
|
const props = [];
|
|
1535
1808
|
const usePairs = [];
|
|
1809
|
+
const classEntries = [];
|
|
1810
|
+
const styleEntries = [];
|
|
1811
|
+
let styleAt;
|
|
1536
1812
|
for (const a of attrs) {
|
|
1537
1813
|
if (a.type === "JSXSpreadAttribute") {
|
|
1538
1814
|
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
@@ -1548,6 +1824,27 @@ function buildProps(attrs, ctx) {
|
|
|
1548
1824
|
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
1549
1825
|
continue;
|
|
1550
1826
|
}
|
|
1827
|
+
if (element && (ns === "class" || ns === "style")) {
|
|
1828
|
+
const key = JSON.stringify(a.name.name.name);
|
|
1829
|
+
const v = a.value;
|
|
1830
|
+
let value;
|
|
1831
|
+
if (v == null) value = "true";
|
|
1832
|
+
else if (isString(v)) value = JSON.stringify(literalOf(v));
|
|
1833
|
+
else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
1834
|
+
value = keyValue(v.expression, ctx);
|
|
1835
|
+
if (ns === "style") styleAt ??= posOf(v.expression, ctx);
|
|
1836
|
+
} else continue;
|
|
1837
|
+
(ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
|
|
1841
|
+
const entries = objectEntries(a.value.expression, ctx);
|
|
1842
|
+
if (entries) {
|
|
1843
|
+
styleEntries.unshift(...entries);
|
|
1844
|
+
styleAt = posOf(a.value.expression, ctx);
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1551
1848
|
if (ns === "oncapture") {
|
|
1552
1849
|
const evt = a.name.name.name.toLowerCase();
|
|
1553
1850
|
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
@@ -1556,9 +1853,37 @@ function buildProps(attrs, ctx) {
|
|
|
1556
1853
|
}
|
|
1557
1854
|
props.push(buildAttr(a, ctx));
|
|
1558
1855
|
}
|
|
1856
|
+
if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
|
|
1857
|
+
if (styleEntries.length > 0) {
|
|
1858
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1859
|
+
const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
|
|
1860
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
|
|
1861
|
+
else {
|
|
1862
|
+
const prop = props[base];
|
|
1863
|
+
const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1864
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1559
1867
|
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
1560
1868
|
return props;
|
|
1561
1869
|
}
|
|
1870
|
+
function keyValue(expr, ctx) {
|
|
1871
|
+
const code = ctx.code(expr);
|
|
1872
|
+
if (!isReactive(expr)) return code;
|
|
1873
|
+
const accessor = `() => ${paren(code, "arrowBody")}`;
|
|
1874
|
+
const at = posOf(expr, ctx);
|
|
1875
|
+
return at ? markHole(accessor, at.line, at.column) : accessor;
|
|
1876
|
+
}
|
|
1877
|
+
function objectEntries(expr, ctx) {
|
|
1878
|
+
if (expr?.type !== "ObjectExpression") return null;
|
|
1879
|
+
const entries = [];
|
|
1880
|
+
for (const p of expr.properties) {
|
|
1881
|
+
if (p.type !== "ObjectProperty") return null;
|
|
1882
|
+
const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
|
|
1883
|
+
entries.push(`${key}: ${keyValue(p.value, ctx)}`);
|
|
1884
|
+
}
|
|
1885
|
+
return entries;
|
|
1886
|
+
}
|
|
1562
1887
|
function buildChildren(children, ctx) {
|
|
1563
1888
|
const out = [];
|
|
1564
1889
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -1586,6 +1911,7 @@ function buildChildren(children, ctx) {
|
|
|
1586
1911
|
});
|
|
1587
1912
|
}
|
|
1588
1913
|
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
1914
|
+
if (ctx.dropStyles?.has(child.start)) continue;
|
|
1589
1915
|
out.push(buildNode(child, ctx));
|
|
1590
1916
|
} else if (child.type === "JSXSpreadChild") {
|
|
1591
1917
|
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
@@ -1655,13 +1981,17 @@ function buildElement(node, ctx, handled) {
|
|
|
1655
1981
|
const children = each ? [each] : buildChildren(node.children, ctx);
|
|
1656
1982
|
if (tag === CONTAINER2) return children.length === 1 ? children[0] : { kind: "fragment", children };
|
|
1657
1983
|
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
1658
|
-
|
|
1984
|
+
const props = buildProps(attributes, ctx, true);
|
|
1985
|
+
const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
|
|
1986
|
+
if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
|
|
1987
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1659
1988
|
}
|
|
1660
1989
|
function buildNode(node, ctx) {
|
|
1661
1990
|
if (node.type === "JSXFragment") {
|
|
1662
1991
|
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
1663
1992
|
}
|
|
1664
1993
|
if (directive(node, "if")) return buildIf(node, null, ctx);
|
|
1994
|
+
if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
|
|
1665
1995
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
1666
1996
|
if (!component) return buildElement(node, ctx, []);
|
|
1667
1997
|
const props = buildProps(node.openingElement.attributes, ctx);
|