@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 __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,6 +26,26 @@ __export(compile_template_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(compile_template_exports);
|
|
28
28
|
|
|
29
|
+
// src/transform/styles.ts
|
|
30
|
+
var import_sourcemap_codec = require("@jridgewell/sourcemap-codec");
|
|
31
|
+
var SCOPE_ATTR = "data-fx-s";
|
|
32
|
+
function applyTemplateStyles(ir, t) {
|
|
33
|
+
const walk2 = (node) => {
|
|
34
|
+
const children = node.children;
|
|
35
|
+
if (children) {
|
|
36
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
37
|
+
const child = children[i];
|
|
38
|
+
if (child.kind === "element" && child.tag === "style" && t.owner) children.splice(i, 1);
|
|
39
|
+
else walk2(child);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (t.scope && node.kind === "element" && node.tag !== "style" && node.props && !node.props.some((p) => p.name === SCOPE_ATTR)) {
|
|
43
|
+
node.props.unshift({ name: SCOPE_ATTR, kind: "attr", literal: t.scope });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
walk2(ir);
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
// src/optimize/analyze-static.ts
|
|
30
50
|
function propReason(prop) {
|
|
31
51
|
switch (prop.kind) {
|
|
@@ -675,7 +695,7 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
675
695
|
}
|
|
676
696
|
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
677
697
|
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
678
|
-
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
|
|
698
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
679
699
|
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
680
700
|
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
681
701
|
}
|
|
@@ -874,6 +894,271 @@ function cleanTemplateText(value) {
|
|
|
874
894
|
return out;
|
|
875
895
|
}
|
|
876
896
|
|
|
897
|
+
// src/lower/entities.ts
|
|
898
|
+
var NAMED = {
|
|
899
|
+
quot: 34,
|
|
900
|
+
amp: 38,
|
|
901
|
+
apos: 39,
|
|
902
|
+
lt: 60,
|
|
903
|
+
gt: 62,
|
|
904
|
+
nbsp: 160,
|
|
905
|
+
iexcl: 161,
|
|
906
|
+
cent: 162,
|
|
907
|
+
pound: 163,
|
|
908
|
+
curren: 164,
|
|
909
|
+
yen: 165,
|
|
910
|
+
brvbar: 166,
|
|
911
|
+
sect: 167,
|
|
912
|
+
uml: 168,
|
|
913
|
+
copy: 169,
|
|
914
|
+
ordf: 170,
|
|
915
|
+
laquo: 171,
|
|
916
|
+
not: 172,
|
|
917
|
+
shy: 173,
|
|
918
|
+
reg: 174,
|
|
919
|
+
macr: 175,
|
|
920
|
+
deg: 176,
|
|
921
|
+
plusmn: 177,
|
|
922
|
+
sup2: 178,
|
|
923
|
+
sup3: 179,
|
|
924
|
+
acute: 180,
|
|
925
|
+
micro: 181,
|
|
926
|
+
para: 182,
|
|
927
|
+
middot: 183,
|
|
928
|
+
cedil: 184,
|
|
929
|
+
sup1: 185,
|
|
930
|
+
ordm: 186,
|
|
931
|
+
raquo: 187,
|
|
932
|
+
frac14: 188,
|
|
933
|
+
frac12: 189,
|
|
934
|
+
frac34: 190,
|
|
935
|
+
iquest: 191,
|
|
936
|
+
Agrave: 192,
|
|
937
|
+
Aacute: 193,
|
|
938
|
+
Acirc: 194,
|
|
939
|
+
Atilde: 195,
|
|
940
|
+
Auml: 196,
|
|
941
|
+
Aring: 197,
|
|
942
|
+
AElig: 198,
|
|
943
|
+
Ccedil: 199,
|
|
944
|
+
Egrave: 200,
|
|
945
|
+
Eacute: 201,
|
|
946
|
+
Ecirc: 202,
|
|
947
|
+
Euml: 203,
|
|
948
|
+
Igrave: 204,
|
|
949
|
+
Iacute: 205,
|
|
950
|
+
Icirc: 206,
|
|
951
|
+
Iuml: 207,
|
|
952
|
+
ETH: 208,
|
|
953
|
+
Ntilde: 209,
|
|
954
|
+
Ograve: 210,
|
|
955
|
+
Oacute: 211,
|
|
956
|
+
Ocirc: 212,
|
|
957
|
+
Otilde: 213,
|
|
958
|
+
Ouml: 214,
|
|
959
|
+
times: 215,
|
|
960
|
+
Oslash: 216,
|
|
961
|
+
Ugrave: 217,
|
|
962
|
+
Uacute: 218,
|
|
963
|
+
Ucirc: 219,
|
|
964
|
+
Uuml: 220,
|
|
965
|
+
Yacute: 221,
|
|
966
|
+
THORN: 222,
|
|
967
|
+
szlig: 223,
|
|
968
|
+
agrave: 224,
|
|
969
|
+
aacute: 225,
|
|
970
|
+
acirc: 226,
|
|
971
|
+
atilde: 227,
|
|
972
|
+
auml: 228,
|
|
973
|
+
aring: 229,
|
|
974
|
+
aelig: 230,
|
|
975
|
+
ccedil: 231,
|
|
976
|
+
egrave: 232,
|
|
977
|
+
eacute: 233,
|
|
978
|
+
ecirc: 234,
|
|
979
|
+
euml: 235,
|
|
980
|
+
igrave: 236,
|
|
981
|
+
iacute: 237,
|
|
982
|
+
icirc: 238,
|
|
983
|
+
iuml: 239,
|
|
984
|
+
eth: 240,
|
|
985
|
+
ntilde: 241,
|
|
986
|
+
ograve: 242,
|
|
987
|
+
oacute: 243,
|
|
988
|
+
ocirc: 244,
|
|
989
|
+
otilde: 245,
|
|
990
|
+
ouml: 246,
|
|
991
|
+
divide: 247,
|
|
992
|
+
oslash: 248,
|
|
993
|
+
ugrave: 249,
|
|
994
|
+
uacute: 250,
|
|
995
|
+
ucirc: 251,
|
|
996
|
+
uuml: 252,
|
|
997
|
+
yacute: 253,
|
|
998
|
+
thorn: 254,
|
|
999
|
+
yuml: 255,
|
|
1000
|
+
OElig: 338,
|
|
1001
|
+
oelig: 339,
|
|
1002
|
+
Scaron: 352,
|
|
1003
|
+
scaron: 353,
|
|
1004
|
+
Yuml: 376,
|
|
1005
|
+
fnof: 402,
|
|
1006
|
+
circ: 710,
|
|
1007
|
+
tilde: 732,
|
|
1008
|
+
Alpha: 913,
|
|
1009
|
+
Beta: 914,
|
|
1010
|
+
Gamma: 915,
|
|
1011
|
+
Delta: 916,
|
|
1012
|
+
Epsilon: 917,
|
|
1013
|
+
Zeta: 918,
|
|
1014
|
+
Eta: 919,
|
|
1015
|
+
Theta: 920,
|
|
1016
|
+
Iota: 921,
|
|
1017
|
+
Kappa: 922,
|
|
1018
|
+
Lambda: 923,
|
|
1019
|
+
Mu: 924,
|
|
1020
|
+
Nu: 925,
|
|
1021
|
+
Xi: 926,
|
|
1022
|
+
Omicron: 927,
|
|
1023
|
+
Pi: 928,
|
|
1024
|
+
Rho: 929,
|
|
1025
|
+
Sigma: 931,
|
|
1026
|
+
Tau: 932,
|
|
1027
|
+
Upsilon: 933,
|
|
1028
|
+
Phi: 934,
|
|
1029
|
+
Chi: 935,
|
|
1030
|
+
Psi: 936,
|
|
1031
|
+
Omega: 937,
|
|
1032
|
+
alpha: 945,
|
|
1033
|
+
beta: 946,
|
|
1034
|
+
gamma: 947,
|
|
1035
|
+
delta: 948,
|
|
1036
|
+
epsilon: 949,
|
|
1037
|
+
zeta: 950,
|
|
1038
|
+
eta: 951,
|
|
1039
|
+
theta: 952,
|
|
1040
|
+
iota: 953,
|
|
1041
|
+
kappa: 954,
|
|
1042
|
+
lambda: 955,
|
|
1043
|
+
mu: 956,
|
|
1044
|
+
nu: 957,
|
|
1045
|
+
xi: 958,
|
|
1046
|
+
omicron: 959,
|
|
1047
|
+
pi: 960,
|
|
1048
|
+
rho: 961,
|
|
1049
|
+
sigmaf: 962,
|
|
1050
|
+
sigma: 963,
|
|
1051
|
+
tau: 964,
|
|
1052
|
+
upsilon: 965,
|
|
1053
|
+
phi: 966,
|
|
1054
|
+
chi: 967,
|
|
1055
|
+
psi: 968,
|
|
1056
|
+
omega: 969,
|
|
1057
|
+
thetasym: 977,
|
|
1058
|
+
upsih: 978,
|
|
1059
|
+
piv: 982,
|
|
1060
|
+
ensp: 8194,
|
|
1061
|
+
emsp: 8195,
|
|
1062
|
+
thinsp: 8201,
|
|
1063
|
+
zwnj: 8204,
|
|
1064
|
+
zwj: 8205,
|
|
1065
|
+
lrm: 8206,
|
|
1066
|
+
rlm: 8207,
|
|
1067
|
+
ndash: 8211,
|
|
1068
|
+
mdash: 8212,
|
|
1069
|
+
lsquo: 8216,
|
|
1070
|
+
rsquo: 8217,
|
|
1071
|
+
sbquo: 8218,
|
|
1072
|
+
ldquo: 8220,
|
|
1073
|
+
rdquo: 8221,
|
|
1074
|
+
bdquo: 8222,
|
|
1075
|
+
dagger: 8224,
|
|
1076
|
+
Dagger: 8225,
|
|
1077
|
+
bull: 8226,
|
|
1078
|
+
hellip: 8230,
|
|
1079
|
+
permil: 8240,
|
|
1080
|
+
prime: 8242,
|
|
1081
|
+
Prime: 8243,
|
|
1082
|
+
lsaquo: 8249,
|
|
1083
|
+
rsaquo: 8250,
|
|
1084
|
+
oline: 8254,
|
|
1085
|
+
frasl: 8260,
|
|
1086
|
+
euro: 8364,
|
|
1087
|
+
image: 8465,
|
|
1088
|
+
weierp: 8472,
|
|
1089
|
+
real: 8476,
|
|
1090
|
+
trade: 8482,
|
|
1091
|
+
alefsym: 8501,
|
|
1092
|
+
larr: 8592,
|
|
1093
|
+
uarr: 8593,
|
|
1094
|
+
rarr: 8594,
|
|
1095
|
+
darr: 8595,
|
|
1096
|
+
harr: 8596,
|
|
1097
|
+
crarr: 8629,
|
|
1098
|
+
lArr: 8656,
|
|
1099
|
+
uArr: 8657,
|
|
1100
|
+
rArr: 8658,
|
|
1101
|
+
dArr: 8659,
|
|
1102
|
+
hArr: 8660,
|
|
1103
|
+
forall: 8704,
|
|
1104
|
+
part: 8706,
|
|
1105
|
+
exist: 8707,
|
|
1106
|
+
empty: 8709,
|
|
1107
|
+
nabla: 8711,
|
|
1108
|
+
isin: 8712,
|
|
1109
|
+
notin: 8713,
|
|
1110
|
+
ni: 8715,
|
|
1111
|
+
prod: 8719,
|
|
1112
|
+
sum: 8721,
|
|
1113
|
+
minus: 8722,
|
|
1114
|
+
lowast: 8727,
|
|
1115
|
+
radic: 8730,
|
|
1116
|
+
prop: 8733,
|
|
1117
|
+
infin: 8734,
|
|
1118
|
+
ang: 8736,
|
|
1119
|
+
and: 8743,
|
|
1120
|
+
or: 8744,
|
|
1121
|
+
cap: 8745,
|
|
1122
|
+
cup: 8746,
|
|
1123
|
+
int: 8747,
|
|
1124
|
+
there4: 8756,
|
|
1125
|
+
sim: 8764,
|
|
1126
|
+
cong: 8773,
|
|
1127
|
+
asymp: 8776,
|
|
1128
|
+
ne: 8800,
|
|
1129
|
+
equiv: 8801,
|
|
1130
|
+
le: 8804,
|
|
1131
|
+
ge: 8805,
|
|
1132
|
+
sub: 8834,
|
|
1133
|
+
sup: 8835,
|
|
1134
|
+
nsub: 8836,
|
|
1135
|
+
sube: 8838,
|
|
1136
|
+
supe: 8839,
|
|
1137
|
+
oplus: 8853,
|
|
1138
|
+
otimes: 8855,
|
|
1139
|
+
perp: 8869,
|
|
1140
|
+
sdot: 8901,
|
|
1141
|
+
lceil: 8968,
|
|
1142
|
+
rceil: 8969,
|
|
1143
|
+
lfloor: 8970,
|
|
1144
|
+
rfloor: 8971,
|
|
1145
|
+
lang: 9001,
|
|
1146
|
+
rang: 9002,
|
|
1147
|
+
loz: 9674,
|
|
1148
|
+
spades: 9824,
|
|
1149
|
+
clubs: 9827,
|
|
1150
|
+
hearts: 9829,
|
|
1151
|
+
diams: 9830
|
|
1152
|
+
};
|
|
1153
|
+
var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
|
|
1154
|
+
function decodeEntities(value) {
|
|
1155
|
+
if (!value.includes("&")) return value;
|
|
1156
|
+
return value.replace(REFERENCE, (match, hex, dec, name) => {
|
|
1157
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
|
|
1158
|
+
return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
|
|
877
1162
|
// src/lower/template.ts
|
|
878
1163
|
var DELEGATED = /* @__PURE__ */ new Set([
|
|
879
1164
|
"click",
|
|
@@ -960,7 +1245,7 @@ var Lowerer = class {
|
|
|
960
1245
|
switch (node.kind) {
|
|
961
1246
|
case "Text": {
|
|
962
1247
|
if (node.raw) return { kind: "text", value: node.value };
|
|
963
|
-
const cleaned = cleanTemplateText(node.value);
|
|
1248
|
+
const cleaned = decodeEntities(cleanTemplateText(node.value));
|
|
964
1249
|
return cleaned ? { kind: "text", value: cleaned } : null;
|
|
965
1250
|
}
|
|
966
1251
|
case "Comment":
|
|
@@ -996,7 +1281,7 @@ var Lowerer = class {
|
|
|
996
1281
|
kind: "element",
|
|
997
1282
|
tag: el.tag,
|
|
998
1283
|
svg: el.namespace === "svg",
|
|
999
|
-
props: this.lowerAttributes(el.attributes),
|
|
1284
|
+
props: this.lowerAttributes(el.attributes, true),
|
|
1000
1285
|
children,
|
|
1001
1286
|
static: false,
|
|
1002
1287
|
...at ? { at } : {}
|
|
@@ -1109,13 +1394,22 @@ var Lowerer = class {
|
|
|
1109
1394
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1110
1395
|
}
|
|
1111
1396
|
// --- attributes ---------------------------------------------------------
|
|
1112
|
-
|
|
1397
|
+
/**
|
|
1398
|
+
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1399
|
+
* A component gets the object as before, rebuilt whole when any value moves.
|
|
1400
|
+
*/
|
|
1401
|
+
lowerAttributes(attrs, element = false) {
|
|
1402
|
+
let anyReactive = false;
|
|
1403
|
+
const entry = (name, h) => {
|
|
1404
|
+
anyReactive ||= h.reactive;
|
|
1405
|
+
if (!element || !h.reactive) return `${JSON.stringify(name)}: ${h.code}`;
|
|
1406
|
+
const accessor = `() => ${paren(h.code, "arrowBody")}`;
|
|
1407
|
+
return `${JSON.stringify(name)}: ${h.at ? markHole(accessor, h.at.line, h.at.column) : accessor}`;
|
|
1408
|
+
};
|
|
1113
1409
|
const props = [];
|
|
1114
1410
|
const classEntries = [];
|
|
1115
|
-
let classReactive = false;
|
|
1116
1411
|
let classAt;
|
|
1117
1412
|
const styleEntries = [];
|
|
1118
|
-
let styleReactive = false;
|
|
1119
1413
|
let styleAt;
|
|
1120
1414
|
const usePairs = [];
|
|
1121
1415
|
for (const a of attrs) {
|
|
@@ -1155,15 +1449,13 @@ var Lowerer = class {
|
|
|
1155
1449
|
break;
|
|
1156
1450
|
case "ClassDirective": {
|
|
1157
1451
|
const h = this.hole(a.hole);
|
|
1158
|
-
classEntries.push(
|
|
1159
|
-
classReactive = classReactive || h.reactive;
|
|
1452
|
+
classEntries.push(entry(a.name, h));
|
|
1160
1453
|
classAt ??= h.at;
|
|
1161
1454
|
break;
|
|
1162
1455
|
}
|
|
1163
1456
|
case "StyleDirective": {
|
|
1164
1457
|
const h = this.hole(a.hole);
|
|
1165
|
-
styleEntries.push(
|
|
1166
|
-
styleReactive = styleReactive || h.reactive;
|
|
1458
|
+
styleEntries.push(entry(a.name, h));
|
|
1167
1459
|
styleAt ??= h.at;
|
|
1168
1460
|
break;
|
|
1169
1461
|
}
|
|
@@ -1183,18 +1475,19 @@ var Lowerer = class {
|
|
|
1183
1475
|
name: "classList",
|
|
1184
1476
|
kind: "attr",
|
|
1185
1477
|
expr: `{ ${classEntries.join(", ")} }`,
|
|
1186
|
-
reactive:
|
|
1478
|
+
reactive: !element && anyReactive,
|
|
1187
1479
|
...classAt ? { at: classAt } : {}
|
|
1188
1480
|
});
|
|
1189
1481
|
}
|
|
1190
1482
|
if (styleEntries.length > 0) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1483
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
1484
|
+
const base = props.findIndex((p) => p.name === "style");
|
|
1485
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: !element && anyReactive, ...styleAt ? { at: styleAt } : {} });
|
|
1486
|
+
else {
|
|
1487
|
+
const prop = props[base];
|
|
1488
|
+
const value = prop.expr === void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
1489
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
1490
|
+
}
|
|
1198
1491
|
}
|
|
1199
1492
|
if (usePairs.length > 0) {
|
|
1200
1493
|
props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
@@ -1283,7 +1576,7 @@ var Lowerer = class {
|
|
|
1283
1576
|
return base;
|
|
1284
1577
|
}
|
|
1285
1578
|
if (v.kind === "static") {
|
|
1286
|
-
base.literal = v.value;
|
|
1579
|
+
base.literal = decodeEntities(v.value);
|
|
1287
1580
|
return base;
|
|
1288
1581
|
}
|
|
1289
1582
|
if (v.kind === "hole") {
|
|
@@ -1296,7 +1589,7 @@ var Lowerer = class {
|
|
|
1296
1589
|
let reactive = false;
|
|
1297
1590
|
let at;
|
|
1298
1591
|
const body = v.parts.map((p) => {
|
|
1299
|
-
if ("text" in p) return escapeTemplate(p.text);
|
|
1592
|
+
if ("text" in p) return escapeTemplate(decodeEntities(p.text));
|
|
1300
1593
|
const h = this.hole(p.hole);
|
|
1301
1594
|
reactive = reactive || h.reactive;
|
|
1302
1595
|
at ??= h.at;
|
|
@@ -1343,6 +1636,7 @@ function compilePieces(pieces, holes, options = {}) {
|
|
|
1343
1636
|
...options.sourceFile ? { sourceFile: options.sourceFile } : {},
|
|
1344
1637
|
...options.positionAt ? { positionAt: options.positionAt } : {}
|
|
1345
1638
|
});
|
|
1639
|
+
if (options.templateStyles) applyTemplateStyles(ir, options.templateStyles);
|
|
1346
1640
|
analyzeStatic(ir);
|
|
1347
1641
|
resolveComponentSources(ir, {
|
|
1348
1642
|
resolver: createComponentResolver(options.resolve ?? []),
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile a `` html`...` `` template to runtime calls, with no JS toolchain in
|
|
3
|
+
* the path.
|
|
4
|
+
*
|
|
5
|
+
* statics + holes → parseTemplate → IR → resolve → optimize → codegen → code
|
|
6
|
+
*
|
|
7
|
+
* Finding templates in a module and describing each hole still needs a front-end;
|
|
8
|
+
* everything after that point is here. Passes run in the same order as
|
|
9
|
+
* `emitLitViaIR`: compile-template.spec.ts compares the two.
|
|
10
|
+
*/
|
|
11
|
+
import { type TemplateStyles } from '../transform/styles.cjs';
|
|
1
12
|
import { type ComponentResolverRule } from '../resolve/component-resolver.cjs';
|
|
2
13
|
import type { IRNode } from '../ir/nodes.cjs';
|
|
3
14
|
import { type TemplateHole } from './template.cjs';
|
|
@@ -45,6 +56,8 @@ export interface CompileTemplateOptions {
|
|
|
45
56
|
line: number;
|
|
46
57
|
column: number;
|
|
47
58
|
};
|
|
59
|
+
/** `<style>` blocks and scope stamping for this template (see transform/styles.ts). */
|
|
60
|
+
templateStyles?: TemplateStyles;
|
|
48
61
|
}
|
|
49
62
|
export interface CompileTemplateResult {
|
|
50
63
|
/** A JavaScript expression that builds the DOM when evaluated. */
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile a `` html`...` `` template to runtime calls, with no JS toolchain in
|
|
3
|
+
* the path.
|
|
4
|
+
*
|
|
5
|
+
* statics + holes → parseTemplate → IR → resolve → optimize → codegen → code
|
|
6
|
+
*
|
|
7
|
+
* Finding templates in a module and describing each hole still needs a front-end;
|
|
8
|
+
* everything after that point is here. Passes run in the same order as
|
|
9
|
+
* `emitLitViaIR`: compile-template.spec.ts compares the two.
|
|
10
|
+
*/
|
|
11
|
+
import { type TemplateStyles } from '../transform/styles.js';
|
|
1
12
|
import { type ComponentResolverRule } from '../resolve/component-resolver.js';
|
|
2
13
|
import type { IRNode } from '../ir/nodes.js';
|
|
3
14
|
import { type TemplateHole } from './template.js';
|
|
@@ -45,6 +56,8 @@ export interface CompileTemplateOptions {
|
|
|
45
56
|
line: number;
|
|
46
57
|
column: number;
|
|
47
58
|
};
|
|
59
|
+
/** `<style>` blocks and scope stamping for this template (see transform/styles.ts). */
|
|
60
|
+
templateStyles?: TemplateStyles;
|
|
48
61
|
}
|
|
49
62
|
export interface CompileTemplateResult {
|
|
50
63
|
/** A JavaScript expression that builds the DOM when evaluated. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-template.d.ts","sourceRoot":"","sources":["../../src/lower/compile-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-template.d.ts","sourceRoot":"","sources":["../../src/lower/compile-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKlF,OAAO,EAA2B,KAAK,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACvG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,kDAAkD;IAClD,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iEAAiE;IACjE,OAAO,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC3C,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,uFAAuF;IACvF,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sFAAsF;IACtF,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAqBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CASvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,KAAK,EAAE,EACf,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CA+BvB"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* everything after that point is here. Passes run in the same order as
|
|
9
9
|
* `emitLitViaIR`: compile-template.spec.ts compares the two.
|
|
10
10
|
*/
|
|
11
|
+
import { applyTemplateStyles } from '../transform/styles.js';
|
|
11
12
|
import { analyzeStatic } from '../optimize/analyze-static.js';
|
|
12
13
|
import { collapseStrategies } from '../optimize/collapse-strategies.js';
|
|
13
14
|
import { imperativeBackend, inlineTemplates } from '../codegen/backends/imperative.js';
|
|
@@ -51,6 +52,8 @@ export function compilePieces(pieces, holes, options = {}) {
|
|
|
51
52
|
...(options.sourceFile ? { sourceFile: options.sourceFile } : {}),
|
|
52
53
|
...(options.positionAt ? { positionAt: options.positionAt } : {}),
|
|
53
54
|
});
|
|
55
|
+
if (options.templateStyles)
|
|
56
|
+
applyTemplateStyles(ir, options.templateStyles);
|
|
54
57
|
analyzeStatic(ir);
|
|
55
58
|
// Same order as the Babel front-end: decide where each component reference
|
|
56
59
|
// comes from, then drop deferred boundaries around modules already in the chunk.
|