@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
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -683,7 +683,7 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
683
683
|
}
|
|
684
684
|
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
685
685
|
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
686
|
-
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
|
|
686
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
687
687
|
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
688
688
|
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
689
689
|
}
|
|
@@ -829,6 +829,271 @@ function cleanTemplateText(value) {
|
|
|
829
829
|
return out;
|
|
830
830
|
}
|
|
831
831
|
|
|
832
|
+
// src/lower/entities.ts
|
|
833
|
+
var NAMED = {
|
|
834
|
+
quot: 34,
|
|
835
|
+
amp: 38,
|
|
836
|
+
apos: 39,
|
|
837
|
+
lt: 60,
|
|
838
|
+
gt: 62,
|
|
839
|
+
nbsp: 160,
|
|
840
|
+
iexcl: 161,
|
|
841
|
+
cent: 162,
|
|
842
|
+
pound: 163,
|
|
843
|
+
curren: 164,
|
|
844
|
+
yen: 165,
|
|
845
|
+
brvbar: 166,
|
|
846
|
+
sect: 167,
|
|
847
|
+
uml: 168,
|
|
848
|
+
copy: 169,
|
|
849
|
+
ordf: 170,
|
|
850
|
+
laquo: 171,
|
|
851
|
+
not: 172,
|
|
852
|
+
shy: 173,
|
|
853
|
+
reg: 174,
|
|
854
|
+
macr: 175,
|
|
855
|
+
deg: 176,
|
|
856
|
+
plusmn: 177,
|
|
857
|
+
sup2: 178,
|
|
858
|
+
sup3: 179,
|
|
859
|
+
acute: 180,
|
|
860
|
+
micro: 181,
|
|
861
|
+
para: 182,
|
|
862
|
+
middot: 183,
|
|
863
|
+
cedil: 184,
|
|
864
|
+
sup1: 185,
|
|
865
|
+
ordm: 186,
|
|
866
|
+
raquo: 187,
|
|
867
|
+
frac14: 188,
|
|
868
|
+
frac12: 189,
|
|
869
|
+
frac34: 190,
|
|
870
|
+
iquest: 191,
|
|
871
|
+
Agrave: 192,
|
|
872
|
+
Aacute: 193,
|
|
873
|
+
Acirc: 194,
|
|
874
|
+
Atilde: 195,
|
|
875
|
+
Auml: 196,
|
|
876
|
+
Aring: 197,
|
|
877
|
+
AElig: 198,
|
|
878
|
+
Ccedil: 199,
|
|
879
|
+
Egrave: 200,
|
|
880
|
+
Eacute: 201,
|
|
881
|
+
Ecirc: 202,
|
|
882
|
+
Euml: 203,
|
|
883
|
+
Igrave: 204,
|
|
884
|
+
Iacute: 205,
|
|
885
|
+
Icirc: 206,
|
|
886
|
+
Iuml: 207,
|
|
887
|
+
ETH: 208,
|
|
888
|
+
Ntilde: 209,
|
|
889
|
+
Ograve: 210,
|
|
890
|
+
Oacute: 211,
|
|
891
|
+
Ocirc: 212,
|
|
892
|
+
Otilde: 213,
|
|
893
|
+
Ouml: 214,
|
|
894
|
+
times: 215,
|
|
895
|
+
Oslash: 216,
|
|
896
|
+
Ugrave: 217,
|
|
897
|
+
Uacute: 218,
|
|
898
|
+
Ucirc: 219,
|
|
899
|
+
Uuml: 220,
|
|
900
|
+
Yacute: 221,
|
|
901
|
+
THORN: 222,
|
|
902
|
+
szlig: 223,
|
|
903
|
+
agrave: 224,
|
|
904
|
+
aacute: 225,
|
|
905
|
+
acirc: 226,
|
|
906
|
+
atilde: 227,
|
|
907
|
+
auml: 228,
|
|
908
|
+
aring: 229,
|
|
909
|
+
aelig: 230,
|
|
910
|
+
ccedil: 231,
|
|
911
|
+
egrave: 232,
|
|
912
|
+
eacute: 233,
|
|
913
|
+
ecirc: 234,
|
|
914
|
+
euml: 235,
|
|
915
|
+
igrave: 236,
|
|
916
|
+
iacute: 237,
|
|
917
|
+
icirc: 238,
|
|
918
|
+
iuml: 239,
|
|
919
|
+
eth: 240,
|
|
920
|
+
ntilde: 241,
|
|
921
|
+
ograve: 242,
|
|
922
|
+
oacute: 243,
|
|
923
|
+
ocirc: 244,
|
|
924
|
+
otilde: 245,
|
|
925
|
+
ouml: 246,
|
|
926
|
+
divide: 247,
|
|
927
|
+
oslash: 248,
|
|
928
|
+
ugrave: 249,
|
|
929
|
+
uacute: 250,
|
|
930
|
+
ucirc: 251,
|
|
931
|
+
uuml: 252,
|
|
932
|
+
yacute: 253,
|
|
933
|
+
thorn: 254,
|
|
934
|
+
yuml: 255,
|
|
935
|
+
OElig: 338,
|
|
936
|
+
oelig: 339,
|
|
937
|
+
Scaron: 352,
|
|
938
|
+
scaron: 353,
|
|
939
|
+
Yuml: 376,
|
|
940
|
+
fnof: 402,
|
|
941
|
+
circ: 710,
|
|
942
|
+
tilde: 732,
|
|
943
|
+
Alpha: 913,
|
|
944
|
+
Beta: 914,
|
|
945
|
+
Gamma: 915,
|
|
946
|
+
Delta: 916,
|
|
947
|
+
Epsilon: 917,
|
|
948
|
+
Zeta: 918,
|
|
949
|
+
Eta: 919,
|
|
950
|
+
Theta: 920,
|
|
951
|
+
Iota: 921,
|
|
952
|
+
Kappa: 922,
|
|
953
|
+
Lambda: 923,
|
|
954
|
+
Mu: 924,
|
|
955
|
+
Nu: 925,
|
|
956
|
+
Xi: 926,
|
|
957
|
+
Omicron: 927,
|
|
958
|
+
Pi: 928,
|
|
959
|
+
Rho: 929,
|
|
960
|
+
Sigma: 931,
|
|
961
|
+
Tau: 932,
|
|
962
|
+
Upsilon: 933,
|
|
963
|
+
Phi: 934,
|
|
964
|
+
Chi: 935,
|
|
965
|
+
Psi: 936,
|
|
966
|
+
Omega: 937,
|
|
967
|
+
alpha: 945,
|
|
968
|
+
beta: 946,
|
|
969
|
+
gamma: 947,
|
|
970
|
+
delta: 948,
|
|
971
|
+
epsilon: 949,
|
|
972
|
+
zeta: 950,
|
|
973
|
+
eta: 951,
|
|
974
|
+
theta: 952,
|
|
975
|
+
iota: 953,
|
|
976
|
+
kappa: 954,
|
|
977
|
+
lambda: 955,
|
|
978
|
+
mu: 956,
|
|
979
|
+
nu: 957,
|
|
980
|
+
xi: 958,
|
|
981
|
+
omicron: 959,
|
|
982
|
+
pi: 960,
|
|
983
|
+
rho: 961,
|
|
984
|
+
sigmaf: 962,
|
|
985
|
+
sigma: 963,
|
|
986
|
+
tau: 964,
|
|
987
|
+
upsilon: 965,
|
|
988
|
+
phi: 966,
|
|
989
|
+
chi: 967,
|
|
990
|
+
psi: 968,
|
|
991
|
+
omega: 969,
|
|
992
|
+
thetasym: 977,
|
|
993
|
+
upsih: 978,
|
|
994
|
+
piv: 982,
|
|
995
|
+
ensp: 8194,
|
|
996
|
+
emsp: 8195,
|
|
997
|
+
thinsp: 8201,
|
|
998
|
+
zwnj: 8204,
|
|
999
|
+
zwj: 8205,
|
|
1000
|
+
lrm: 8206,
|
|
1001
|
+
rlm: 8207,
|
|
1002
|
+
ndash: 8211,
|
|
1003
|
+
mdash: 8212,
|
|
1004
|
+
lsquo: 8216,
|
|
1005
|
+
rsquo: 8217,
|
|
1006
|
+
sbquo: 8218,
|
|
1007
|
+
ldquo: 8220,
|
|
1008
|
+
rdquo: 8221,
|
|
1009
|
+
bdquo: 8222,
|
|
1010
|
+
dagger: 8224,
|
|
1011
|
+
Dagger: 8225,
|
|
1012
|
+
bull: 8226,
|
|
1013
|
+
hellip: 8230,
|
|
1014
|
+
permil: 8240,
|
|
1015
|
+
prime: 8242,
|
|
1016
|
+
Prime: 8243,
|
|
1017
|
+
lsaquo: 8249,
|
|
1018
|
+
rsaquo: 8250,
|
|
1019
|
+
oline: 8254,
|
|
1020
|
+
frasl: 8260,
|
|
1021
|
+
euro: 8364,
|
|
1022
|
+
image: 8465,
|
|
1023
|
+
weierp: 8472,
|
|
1024
|
+
real: 8476,
|
|
1025
|
+
trade: 8482,
|
|
1026
|
+
alefsym: 8501,
|
|
1027
|
+
larr: 8592,
|
|
1028
|
+
uarr: 8593,
|
|
1029
|
+
rarr: 8594,
|
|
1030
|
+
darr: 8595,
|
|
1031
|
+
harr: 8596,
|
|
1032
|
+
crarr: 8629,
|
|
1033
|
+
lArr: 8656,
|
|
1034
|
+
uArr: 8657,
|
|
1035
|
+
rArr: 8658,
|
|
1036
|
+
dArr: 8659,
|
|
1037
|
+
hArr: 8660,
|
|
1038
|
+
forall: 8704,
|
|
1039
|
+
part: 8706,
|
|
1040
|
+
exist: 8707,
|
|
1041
|
+
empty: 8709,
|
|
1042
|
+
nabla: 8711,
|
|
1043
|
+
isin: 8712,
|
|
1044
|
+
notin: 8713,
|
|
1045
|
+
ni: 8715,
|
|
1046
|
+
prod: 8719,
|
|
1047
|
+
sum: 8721,
|
|
1048
|
+
minus: 8722,
|
|
1049
|
+
lowast: 8727,
|
|
1050
|
+
radic: 8730,
|
|
1051
|
+
prop: 8733,
|
|
1052
|
+
infin: 8734,
|
|
1053
|
+
ang: 8736,
|
|
1054
|
+
and: 8743,
|
|
1055
|
+
or: 8744,
|
|
1056
|
+
cap: 8745,
|
|
1057
|
+
cup: 8746,
|
|
1058
|
+
int: 8747,
|
|
1059
|
+
there4: 8756,
|
|
1060
|
+
sim: 8764,
|
|
1061
|
+
cong: 8773,
|
|
1062
|
+
asymp: 8776,
|
|
1063
|
+
ne: 8800,
|
|
1064
|
+
equiv: 8801,
|
|
1065
|
+
le: 8804,
|
|
1066
|
+
ge: 8805,
|
|
1067
|
+
sub: 8834,
|
|
1068
|
+
sup: 8835,
|
|
1069
|
+
nsub: 8836,
|
|
1070
|
+
sube: 8838,
|
|
1071
|
+
supe: 8839,
|
|
1072
|
+
oplus: 8853,
|
|
1073
|
+
otimes: 8855,
|
|
1074
|
+
perp: 8869,
|
|
1075
|
+
sdot: 8901,
|
|
1076
|
+
lceil: 8968,
|
|
1077
|
+
rceil: 8969,
|
|
1078
|
+
lfloor: 8970,
|
|
1079
|
+
rfloor: 8971,
|
|
1080
|
+
lang: 9001,
|
|
1081
|
+
rang: 9002,
|
|
1082
|
+
loz: 9674,
|
|
1083
|
+
spades: 9824,
|
|
1084
|
+
clubs: 9827,
|
|
1085
|
+
hearts: 9829,
|
|
1086
|
+
diams: 9830
|
|
1087
|
+
};
|
|
1088
|
+
var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
|
|
1089
|
+
function decodeEntities(value) {
|
|
1090
|
+
if (!value.includes("&")) return value;
|
|
1091
|
+
return value.replace(REFERENCE, (match, hex, dec, name) => {
|
|
1092
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
|
|
1093
|
+
return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
|
|
832
1097
|
// src/lower/template.ts
|
|
833
1098
|
var DELEGATED = /* @__PURE__ */ new Set([
|
|
834
1099
|
"click",
|
|
@@ -915,7 +1180,7 @@ var Lowerer = class {
|
|
|
915
1180
|
switch (node.kind) {
|
|
916
1181
|
case "Text": {
|
|
917
1182
|
if (node.raw) return { kind: "text", value: node.value };
|
|
918
|
-
const cleaned = cleanTemplateText(node.value);
|
|
1183
|
+
const cleaned = decodeEntities(cleanTemplateText(node.value));
|
|
919
1184
|
return cleaned ? { kind: "text", value: cleaned } : null;
|
|
920
1185
|
}
|
|
921
1186
|
case "Comment":
|
|
@@ -951,7 +1216,7 @@ var Lowerer = class {
|
|
|
951
1216
|
kind: "element",
|
|
952
1217
|
tag: el.tag,
|
|
953
1218
|
svg: el.namespace === "svg",
|
|
954
|
-
props: this.lowerAttributes(el.attributes),
|
|
1219
|
+
props: this.lowerAttributes(el.attributes, true),
|
|
955
1220
|
children,
|
|
956
1221
|
static: false,
|
|
957
1222
|
...at ? { at } : {}
|
|
@@ -1064,13 +1329,22 @@ var Lowerer = class {
|
|
|
1064
1329
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1065
1330
|
}
|
|
1066
1331
|
// --- attributes ---------------------------------------------------------
|
|
1067
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1334
|
+
* A component gets the object as before, rebuilt whole when any value moves.
|
|
1335
|
+
*/
|
|
1336
|
+
lowerAttributes(attrs, element = false) {
|
|
1337
|
+
let anyReactive = false;
|
|
1338
|
+
const entry = (name, h) => {
|
|
1339
|
+
anyReactive ||= h.reactive;
|
|
1340
|
+
if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
|
|
1341
|
+
const accessor = `() => ${paren(h.code, "arrowBody")}`;
|
|
1342
|
+
return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
|
|
1343
|
+
};
|
|
1068
1344
|
const props = [];
|
|
1069
1345
|
const classEntries = [];
|
|
1070
|
-
let classReactive = false;
|
|
1071
1346
|
let classAt;
|
|
1072
1347
|
const styleEntries = [];
|
|
1073
|
-
let styleReactive = false;
|
|
1074
1348
|
let styleAt;
|
|
1075
1349
|
const usePairs = [];
|
|
1076
1350
|
for (const a of attrs) {
|
|
@@ -1110,15 +1384,13 @@ var Lowerer = class {
|
|
|
1110
1384
|
break;
|
|
1111
1385
|
case "ClassDirective": {
|
|
1112
1386
|
const h = this.hole(a.hole);
|
|
1113
|
-
classEntries.push(
|
|
1114
|
-
classReactive = classReactive || h.reactive;
|
|
1387
|
+
classEntries.push(entry(a.name, h));
|
|
1115
1388
|
classAt ??= h.at;
|
|
1116
1389
|
break;
|
|
1117
1390
|
}
|
|
1118
1391
|
case "StyleDirective": {
|
|
1119
1392
|
const h = this.hole(a.hole);
|
|
1120
|
-
styleEntries.push(
|
|
1121
|
-
styleReactive = styleReactive || h.reactive;
|
|
1393
|
+
styleEntries.push(entry(a.name, h));
|
|
1122
1394
|
styleAt ??= h.at;
|
|
1123
1395
|
break;
|
|
1124
1396
|
}
|
|
@@ -1138,18 +1410,19 @@ var Lowerer = class {
|
|
|
1138
1410
|
name: "classList",
|
|
1139
1411
|
kind: "attr",
|
|
1140
1412
|
expr: `{ ${classEntries.join(", ")} }`,
|
|
1141
|
-
reactive:
|
|
1413
|
+
reactive: !element && anyReactive,
|
|
1142
1414
|
...classAt ? { at: classAt } : {}
|
|
1143
1415
|
});
|
|
1144
1416
|
}
|
|
1145
1417
|
if (styleEntries.length > 0) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1418
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1419
|
+
const base = props.findIndex((p) => p.name === "style");
|
|
1420
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
|
|
1421
|
+
else {
|
|
1422
|
+
const prop = props[base];
|
|
1423
|
+
const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1424
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1425
|
+
}
|
|
1153
1426
|
}
|
|
1154
1427
|
if (usePairs.length > 0) {
|
|
1155
1428
|
props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
@@ -1238,7 +1511,7 @@ var Lowerer = class {
|
|
|
1238
1511
|
return base;
|
|
1239
1512
|
}
|
|
1240
1513
|
if (v.kind === "static") {
|
|
1241
|
-
base.literal = v.value;
|
|
1514
|
+
base.literal = decodeEntities(v.value);
|
|
1242
1515
|
return base;
|
|
1243
1516
|
}
|
|
1244
1517
|
if (v.kind === "hole") {
|
|
@@ -1251,7 +1524,7 @@ var Lowerer = class {
|
|
|
1251
1524
|
let reactive = false;
|
|
1252
1525
|
let at;
|
|
1253
1526
|
const body = v.parts.map((p) => {
|
|
1254
|
-
if ("text" in p) return escapeTemplate(p.text);
|
|
1527
|
+
if ("text" in p) return escapeTemplate(decodeEntities(p.text));
|
|
1255
1528
|
const h = this.hole(p.hole);
|
|
1256
1529
|
reactive = reactive || h.reactive;
|
|
1257
1530
|
at ??= h.at;
|
|
@@ -1567,9 +1840,12 @@ function attrExprCode(attr, ctx) {
|
|
|
1567
1840
|
}
|
|
1568
1841
|
return null;
|
|
1569
1842
|
}
|
|
1570
|
-
function buildProps(attrs, ctx) {
|
|
1843
|
+
function buildProps(attrs, ctx, element = false) {
|
|
1571
1844
|
const props = [];
|
|
1572
1845
|
const usePairs = [];
|
|
1846
|
+
const classEntries = [];
|
|
1847
|
+
const styleEntries = [];
|
|
1848
|
+
let styleAt;
|
|
1573
1849
|
for (const a of attrs) {
|
|
1574
1850
|
if (a.type === "JSXSpreadAttribute") {
|
|
1575
1851
|
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
@@ -1585,6 +1861,27 @@ function buildProps(attrs, ctx) {
|
|
|
1585
1861
|
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
1586
1862
|
continue;
|
|
1587
1863
|
}
|
|
1864
|
+
if (element && (ns === "class" || ns === "style")) {
|
|
1865
|
+
const key = JSON.stringify(a.name.name.name);
|
|
1866
|
+
const v = a.value;
|
|
1867
|
+
let value;
|
|
1868
|
+
if (v == null) value = "true";
|
|
1869
|
+
else if (isString(v)) value = JSON.stringify(literalOf(v));
|
|
1870
|
+
else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
1871
|
+
value = keyValue(v.expression, ctx);
|
|
1872
|
+
if (ns === "style") styleAt ??= posOf(v.expression, ctx);
|
|
1873
|
+
} else continue;
|
|
1874
|
+
(ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
1875
|
+
continue;
|
|
1876
|
+
}
|
|
1877
|
+
if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
|
|
1878
|
+
const entries = objectEntries(a.value.expression, ctx);
|
|
1879
|
+
if (entries) {
|
|
1880
|
+
styleEntries.unshift(...entries);
|
|
1881
|
+
styleAt = posOf(a.value.expression, ctx);
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1588
1885
|
if (ns === "oncapture") {
|
|
1589
1886
|
const evt = a.name.name.name.toLowerCase();
|
|
1590
1887
|
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
@@ -1593,9 +1890,37 @@ function buildProps(attrs, ctx) {
|
|
|
1593
1890
|
}
|
|
1594
1891
|
props.push(buildAttr(a, ctx));
|
|
1595
1892
|
}
|
|
1893
|
+
if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
|
|
1894
|
+
if (styleEntries.length > 0) {
|
|
1895
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1896
|
+
const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
|
|
1897
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
|
|
1898
|
+
else {
|
|
1899
|
+
const prop = props[base];
|
|
1900
|
+
const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1901
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1596
1904
|
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
1597
1905
|
return props;
|
|
1598
1906
|
}
|
|
1907
|
+
function keyValue(expr, ctx) {
|
|
1908
|
+
const code = ctx.code(expr);
|
|
1909
|
+
if (!isReactive(expr)) return code;
|
|
1910
|
+
const accessor = `() => ${paren(code, "arrowBody")}`;
|
|
1911
|
+
const at = posOf(expr, ctx);
|
|
1912
|
+
return at ? markHole(accessor, at.line, at.column) : accessor;
|
|
1913
|
+
}
|
|
1914
|
+
function objectEntries(expr, ctx) {
|
|
1915
|
+
if (expr?.type !== "ObjectExpression") return null;
|
|
1916
|
+
const entries = [];
|
|
1917
|
+
for (const p of expr.properties) {
|
|
1918
|
+
if (p.type !== "ObjectProperty") return null;
|
|
1919
|
+
const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
|
|
1920
|
+
entries.push(`${key}: ${keyValue(p.value, ctx)}`);
|
|
1921
|
+
}
|
|
1922
|
+
return entries;
|
|
1923
|
+
}
|
|
1599
1924
|
function buildChildren(children, ctx) {
|
|
1600
1925
|
const out = [];
|
|
1601
1926
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -1623,6 +1948,7 @@ function buildChildren(children, ctx) {
|
|
|
1623
1948
|
});
|
|
1624
1949
|
}
|
|
1625
1950
|
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
1951
|
+
if (ctx.dropStyles?.has(child.start)) continue;
|
|
1626
1952
|
out.push(buildNode(child, ctx));
|
|
1627
1953
|
} else if (child.type === "JSXSpreadChild") {
|
|
1628
1954
|
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
@@ -1692,13 +2018,17 @@ function buildElement(node, ctx, handled) {
|
|
|
1692
2018
|
const children = each ? [each] : buildChildren(node.children, ctx);
|
|
1693
2019
|
if (tag === CONTAINER2) return children.length === 1 ? children[0] : { kind: "fragment", children };
|
|
1694
2020
|
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
1695
|
-
|
|
2021
|
+
const props = buildProps(attributes, ctx, true);
|
|
2022
|
+
const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
|
|
2023
|
+
if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
|
|
2024
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1696
2025
|
}
|
|
1697
2026
|
function buildNode(node, ctx) {
|
|
1698
2027
|
if (node.type === "JSXFragment") {
|
|
1699
2028
|
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
1700
2029
|
}
|
|
1701
2030
|
if (directive(node, "if")) return buildIf(node, null, ctx);
|
|
2031
|
+
if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
|
|
1702
2032
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
1703
2033
|
if (!component) return buildElement(node, ctx, []);
|
|
1704
2034
|
const props = buildProps(node.openingElement.attributes, ctx);
|