@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.
Files changed (90) hide show
  1. package/dist/analyze/intrinsics.cjs +13 -1
  2. package/dist/analyze/intrinsics.d.cts +14 -0
  3. package/dist/analyze/intrinsics.d.ts +14 -0
  4. package/dist/analyze/intrinsics.d.ts.map +1 -1
  5. package/dist/analyze/intrinsics.js +17 -0
  6. package/dist/analyze/intrinsics.mjs +13 -1
  7. package/dist/analyze/static-graph.cjs +1 -1
  8. package/dist/analyze/static-graph.mjs +1 -1
  9. package/dist/{babel-RJHJQVEM.mjs → babel-RJFQVFJW.mjs} +4 -4
  10. package/dist/{chunk-56QSOVVL.mjs → chunk-DP2QDWWH.mjs} +1 -1
  11. package/dist/{chunk-R7PPFBCL.mjs → chunk-E2RWTIYE.mjs} +21 -15
  12. package/dist/{chunk-OD53TMER.mjs → chunk-HCCBEJEZ.mjs} +13 -1
  13. package/dist/{chunk-TJIH7TLX.mjs → chunk-HIZU7WI2.mjs} +1 -1
  14. package/dist/{chunk-U7HCFLZ2.mjs → chunk-ZR2QHTEX.mjs} +356 -24
  15. package/dist/codegen/backends/imperative.cjs +1 -1
  16. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  17. package/dist/codegen/backends/imperative.js +2 -1
  18. package/dist/codegen/backends/imperative.mjs +1 -1
  19. package/dist/frontend/babel/build-ir-lit.cjs +352 -22
  20. package/dist/frontend/babel/build-ir-lit.mjs +352 -22
  21. package/dist/frontend/babel/build-ir.cjs +352 -22
  22. package/dist/frontend/babel/build-ir.mjs +352 -22
  23. package/dist/frontend/babel/index.cjs +353 -23
  24. package/dist/frontend/babel/index.mjs +353 -23
  25. package/dist/frontend/babel/lower-template.cjs +352 -22
  26. package/dist/frontend/babel/lower-template.mjs +352 -22
  27. package/dist/frontend/babel/plugin.cjs +352 -22
  28. package/dist/frontend/babel/plugin.mjs +352 -22
  29. package/dist/index.cjs +321 -22
  30. package/dist/index.mjs +333 -22
  31. package/dist/integrations.cjs +1174 -49
  32. package/dist/integrations.d.ts.map +1 -1
  33. package/dist/integrations.js +44 -2
  34. package/dist/integrations.mjs +205 -19
  35. package/dist/lower/compile-template.cjs +315 -21
  36. package/dist/lower/compile-template.d.cts +13 -0
  37. package/dist/lower/compile-template.d.ts +13 -0
  38. package/dist/lower/compile-template.d.ts.map +1 -1
  39. package/dist/lower/compile-template.js +3 -0
  40. package/dist/lower/compile-template.mjs +327 -21
  41. package/dist/lower/entities.cjs +288 -0
  42. package/dist/lower/entities.d.cts +1 -0
  43. package/dist/lower/entities.d.ts +2 -0
  44. package/dist/lower/entities.d.ts.map +1 -0
  45. package/dist/lower/entities.js +54 -0
  46. package/dist/lower/entities.mjs +267 -0
  47. package/dist/lower/jsx.cjs +104 -47
  48. package/dist/lower/jsx.d.cts +8 -0
  49. package/dist/lower/jsx.d.ts +8 -0
  50. package/dist/lower/jsx.d.ts.map +1 -1
  51. package/dist/lower/jsx.js +92 -2
  52. package/dist/lower/jsx.mjs +104 -47
  53. package/dist/lower/template.cjs +293 -20
  54. package/dist/lower/template.d.ts.map +1 -1
  55. package/dist/lower/template.js +35 -19
  56. package/dist/lower/template.mjs +293 -20
  57. package/dist/resolve/builtins.cjs +1 -1
  58. package/dist/resolve/builtins.mjs +1 -1
  59. package/dist/resolve/component-globals.cjs +6 -1
  60. package/dist/resolve/component-globals.js +2 -2
  61. package/dist/resolve/component-globals.mjs +6 -1
  62. package/dist/resolve/write-globals.cjs +6 -1
  63. package/dist/resolve/write-globals.mjs +6 -1
  64. package/dist/{server-fns-ZFRDIQ2X.mjs → server-fns-JLSTKWPS.mjs} +4 -4
  65. package/dist/{server-functions-CTDXX67X.mjs → server-functions-BGY3RD4R.mjs} +3 -3
  66. package/dist/transform/index.cjs +956 -33
  67. package/dist/transform/index.mjs +974 -47
  68. package/dist/transform/props.mjs +19 -14
  69. package/dist/transform/server-fns.mjs +19 -14
  70. package/dist/transform/styles.cjs +588 -0
  71. package/dist/transform/styles.d.cts +211 -0
  72. package/dist/transform/styles.d.ts +212 -0
  73. package/dist/transform/styles.d.ts.map +1 -0
  74. package/dist/transform/styles.js +714 -0
  75. package/dist/transform/styles.mjs +653 -0
  76. package/dist/transform/templates.cjs +955 -32
  77. package/dist/transform/templates.d.cts +13 -0
  78. package/dist/transform/templates.d.ts +13 -0
  79. package/dist/transform/templates.d.ts.map +1 -1
  80. package/dist/transform/templates.js +49 -12
  81. package/dist/transform/templates.mjs +973 -46
  82. package/dist/{transform-QWWQDCXE.mjs → transform-GBP6Y4UI.mjs} +601 -17
  83. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  84. package/dist/vite-styles.cjs +180 -0
  85. package/dist/vite-styles.d.cts +59 -0
  86. package/dist/vite-styles.d.ts +60 -0
  87. package/dist/vite-styles.d.ts.map +1 -0
  88. package/dist/vite-styles.js +198 -0
  89. package/dist/vite-styles.mjs +159 -0
  90. package/package.json +4 -3
@@ -0,0 +1,54 @@
1
+ /**
2
+ * HTML character references in template text and static attributes. Templates accept the
3
+ * entities JSX accepts: the XHTML 1.0 set (the list Babel decodes) and numeric references,
4
+ * each ended by a semicolon. Anything else is left as written.
5
+ */
6
+ const NAMED = {
7
+ quot: 0x22, amp: 0x26, apos: 0x27, lt: 0x3c, gt: 0x3e, nbsp: 0xa0, iexcl: 0xa1, cent: 0xa2,
8
+ pound: 0xa3, curren: 0xa4, yen: 0xa5, brvbar: 0xa6, sect: 0xa7, uml: 0xa8, copy: 0xa9,
9
+ ordf: 0xaa, laquo: 0xab, not: 0xac, shy: 0xad, reg: 0xae, macr: 0xaf, deg: 0xb0, plusmn: 0xb1,
10
+ sup2: 0xb2, sup3: 0xb3, acute: 0xb4, micro: 0xb5, para: 0xb6, middot: 0xb7, cedil: 0xb8,
11
+ sup1: 0xb9, ordm: 0xba, raquo: 0xbb, frac14: 0xbc, frac12: 0xbd, frac34: 0xbe, iquest: 0xbf,
12
+ Agrave: 0xc0, Aacute: 0xc1, Acirc: 0xc2, Atilde: 0xc3, Auml: 0xc4, Aring: 0xc5, AElig: 0xc6,
13
+ Ccedil: 0xc7, Egrave: 0xc8, Eacute: 0xc9, Ecirc: 0xca, Euml: 0xcb, Igrave: 0xcc, Iacute: 0xcd,
14
+ Icirc: 0xce, Iuml: 0xcf, ETH: 0xd0, Ntilde: 0xd1, Ograve: 0xd2, Oacute: 0xd3, Ocirc: 0xd4,
15
+ Otilde: 0xd5, Ouml: 0xd6, times: 0xd7, Oslash: 0xd8, Ugrave: 0xd9, Uacute: 0xda, Ucirc: 0xdb,
16
+ Uuml: 0xdc, Yacute: 0xdd, THORN: 0xde, szlig: 0xdf, agrave: 0xe0, aacute: 0xe1, acirc: 0xe2,
17
+ atilde: 0xe3, auml: 0xe4, aring: 0xe5, aelig: 0xe6, ccedil: 0xe7, egrave: 0xe8, eacute: 0xe9,
18
+ ecirc: 0xea, euml: 0xeb, igrave: 0xec, iacute: 0xed, icirc: 0xee, iuml: 0xef, eth: 0xf0,
19
+ ntilde: 0xf1, ograve: 0xf2, oacute: 0xf3, ocirc: 0xf4, otilde: 0xf5, ouml: 0xf6, divide: 0xf7,
20
+ oslash: 0xf8, ugrave: 0xf9, uacute: 0xfa, ucirc: 0xfb, uuml: 0xfc, yacute: 0xfd, thorn: 0xfe,
21
+ yuml: 0xff, OElig: 0x152, oelig: 0x153, Scaron: 0x160, scaron: 0x161, Yuml: 0x178, fnof: 0x192,
22
+ circ: 0x2c6, tilde: 0x2dc, Alpha: 0x391, Beta: 0x392, Gamma: 0x393, Delta: 0x394,
23
+ Epsilon: 0x395, Zeta: 0x396, Eta: 0x397, Theta: 0x398, Iota: 0x399, Kappa: 0x39a,
24
+ Lambda: 0x39b, Mu: 0x39c, Nu: 0x39d, Xi: 0x39e, Omicron: 0x39f, Pi: 0x3a0, Rho: 0x3a1,
25
+ Sigma: 0x3a3, Tau: 0x3a4, Upsilon: 0x3a5, Phi: 0x3a6, Chi: 0x3a7, Psi: 0x3a8, Omega: 0x3a9,
26
+ alpha: 0x3b1, beta: 0x3b2, gamma: 0x3b3, delta: 0x3b4, epsilon: 0x3b5, zeta: 0x3b6, eta: 0x3b7,
27
+ theta: 0x3b8, iota: 0x3b9, kappa: 0x3ba, lambda: 0x3bb, mu: 0x3bc, nu: 0x3bd, xi: 0x3be,
28
+ omicron: 0x3bf, pi: 0x3c0, rho: 0x3c1, sigmaf: 0x3c2, sigma: 0x3c3, tau: 0x3c4, upsilon: 0x3c5,
29
+ phi: 0x3c6, chi: 0x3c7, psi: 0x3c8, omega: 0x3c9, thetasym: 0x3d1, upsih: 0x3d2, piv: 0x3d6,
30
+ ensp: 0x2002, emsp: 0x2003, thinsp: 0x2009, zwnj: 0x200c, zwj: 0x200d, lrm: 0x200e,
31
+ rlm: 0x200f, ndash: 0x2013, mdash: 0x2014, lsquo: 0x2018, rsquo: 0x2019, sbquo: 0x201a,
32
+ ldquo: 0x201c, rdquo: 0x201d, bdquo: 0x201e, dagger: 0x2020, Dagger: 0x2021, bull: 0x2022,
33
+ hellip: 0x2026, permil: 0x2030, prime: 0x2032, Prime: 0x2033, lsaquo: 0x2039, rsaquo: 0x203a,
34
+ oline: 0x203e, frasl: 0x2044, euro: 0x20ac, image: 0x2111, weierp: 0x2118, real: 0x211c,
35
+ trade: 0x2122, alefsym: 0x2135, larr: 0x2190, uarr: 0x2191, rarr: 0x2192, darr: 0x2193,
36
+ harr: 0x2194, crarr: 0x21b5, lArr: 0x21d0, uArr: 0x21d1, rArr: 0x21d2, dArr: 0x21d3,
37
+ hArr: 0x21d4, forall: 0x2200, part: 0x2202, exist: 0x2203, empty: 0x2205, nabla: 0x2207,
38
+ isin: 0x2208, notin: 0x2209, ni: 0x220b, prod: 0x220f, sum: 0x2211, minus: 0x2212,
39
+ lowast: 0x2217, radic: 0x221a, prop: 0x221d, infin: 0x221e, ang: 0x2220, and: 0x2227,
40
+ or: 0x2228, cap: 0x2229, cup: 0x222a, int: 0x222b, there4: 0x2234, sim: 0x223c, cong: 0x2245,
41
+ asymp: 0x2248, ne: 0x2260, equiv: 0x2261, le: 0x2264, ge: 0x2265, sub: 0x2282, sup: 0x2283,
42
+ nsub: 0x2284, sube: 0x2286, supe: 0x2287, oplus: 0x2295, otimes: 0x2297, perp: 0x22a5,
43
+ sdot: 0x22c5, lceil: 0x2308, rceil: 0x2309, lfloor: 0x230a, rfloor: 0x230b, lang: 0x2329,
44
+ rang: 0x232a, loz: 0x25ca, spades: 0x2660, clubs: 0x2663, hearts: 0x2665, diams: 0x2666,
45
+ };
46
+ const REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
47
+ export function decodeEntities(value) {
48
+ if (!value.includes('&'))
49
+ return value;
50
+ return value.replace(REFERENCE, (match, hex, dec, name) => {
51
+ const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : undefined;
52
+ return code !== undefined && code <= 0x10ffff ? String.fromCodePoint(code) : match;
53
+ });
54
+ }
@@ -0,0 +1,267 @@
1
+ // src/lower/entities.ts
2
+ var NAMED = {
3
+ quot: 34,
4
+ amp: 38,
5
+ apos: 39,
6
+ lt: 60,
7
+ gt: 62,
8
+ nbsp: 160,
9
+ iexcl: 161,
10
+ cent: 162,
11
+ pound: 163,
12
+ curren: 164,
13
+ yen: 165,
14
+ brvbar: 166,
15
+ sect: 167,
16
+ uml: 168,
17
+ copy: 169,
18
+ ordf: 170,
19
+ laquo: 171,
20
+ not: 172,
21
+ shy: 173,
22
+ reg: 174,
23
+ macr: 175,
24
+ deg: 176,
25
+ plusmn: 177,
26
+ sup2: 178,
27
+ sup3: 179,
28
+ acute: 180,
29
+ micro: 181,
30
+ para: 182,
31
+ middot: 183,
32
+ cedil: 184,
33
+ sup1: 185,
34
+ ordm: 186,
35
+ raquo: 187,
36
+ frac14: 188,
37
+ frac12: 189,
38
+ frac34: 190,
39
+ iquest: 191,
40
+ Agrave: 192,
41
+ Aacute: 193,
42
+ Acirc: 194,
43
+ Atilde: 195,
44
+ Auml: 196,
45
+ Aring: 197,
46
+ AElig: 198,
47
+ Ccedil: 199,
48
+ Egrave: 200,
49
+ Eacute: 201,
50
+ Ecirc: 202,
51
+ Euml: 203,
52
+ Igrave: 204,
53
+ Iacute: 205,
54
+ Icirc: 206,
55
+ Iuml: 207,
56
+ ETH: 208,
57
+ Ntilde: 209,
58
+ Ograve: 210,
59
+ Oacute: 211,
60
+ Ocirc: 212,
61
+ Otilde: 213,
62
+ Ouml: 214,
63
+ times: 215,
64
+ Oslash: 216,
65
+ Ugrave: 217,
66
+ Uacute: 218,
67
+ Ucirc: 219,
68
+ Uuml: 220,
69
+ Yacute: 221,
70
+ THORN: 222,
71
+ szlig: 223,
72
+ agrave: 224,
73
+ aacute: 225,
74
+ acirc: 226,
75
+ atilde: 227,
76
+ auml: 228,
77
+ aring: 229,
78
+ aelig: 230,
79
+ ccedil: 231,
80
+ egrave: 232,
81
+ eacute: 233,
82
+ ecirc: 234,
83
+ euml: 235,
84
+ igrave: 236,
85
+ iacute: 237,
86
+ icirc: 238,
87
+ iuml: 239,
88
+ eth: 240,
89
+ ntilde: 241,
90
+ ograve: 242,
91
+ oacute: 243,
92
+ ocirc: 244,
93
+ otilde: 245,
94
+ ouml: 246,
95
+ divide: 247,
96
+ oslash: 248,
97
+ ugrave: 249,
98
+ uacute: 250,
99
+ ucirc: 251,
100
+ uuml: 252,
101
+ yacute: 253,
102
+ thorn: 254,
103
+ yuml: 255,
104
+ OElig: 338,
105
+ oelig: 339,
106
+ Scaron: 352,
107
+ scaron: 353,
108
+ Yuml: 376,
109
+ fnof: 402,
110
+ circ: 710,
111
+ tilde: 732,
112
+ Alpha: 913,
113
+ Beta: 914,
114
+ Gamma: 915,
115
+ Delta: 916,
116
+ Epsilon: 917,
117
+ Zeta: 918,
118
+ Eta: 919,
119
+ Theta: 920,
120
+ Iota: 921,
121
+ Kappa: 922,
122
+ Lambda: 923,
123
+ Mu: 924,
124
+ Nu: 925,
125
+ Xi: 926,
126
+ Omicron: 927,
127
+ Pi: 928,
128
+ Rho: 929,
129
+ Sigma: 931,
130
+ Tau: 932,
131
+ Upsilon: 933,
132
+ Phi: 934,
133
+ Chi: 935,
134
+ Psi: 936,
135
+ Omega: 937,
136
+ alpha: 945,
137
+ beta: 946,
138
+ gamma: 947,
139
+ delta: 948,
140
+ epsilon: 949,
141
+ zeta: 950,
142
+ eta: 951,
143
+ theta: 952,
144
+ iota: 953,
145
+ kappa: 954,
146
+ lambda: 955,
147
+ mu: 956,
148
+ nu: 957,
149
+ xi: 958,
150
+ omicron: 959,
151
+ pi: 960,
152
+ rho: 961,
153
+ sigmaf: 962,
154
+ sigma: 963,
155
+ tau: 964,
156
+ upsilon: 965,
157
+ phi: 966,
158
+ chi: 967,
159
+ psi: 968,
160
+ omega: 969,
161
+ thetasym: 977,
162
+ upsih: 978,
163
+ piv: 982,
164
+ ensp: 8194,
165
+ emsp: 8195,
166
+ thinsp: 8201,
167
+ zwnj: 8204,
168
+ zwj: 8205,
169
+ lrm: 8206,
170
+ rlm: 8207,
171
+ ndash: 8211,
172
+ mdash: 8212,
173
+ lsquo: 8216,
174
+ rsquo: 8217,
175
+ sbquo: 8218,
176
+ ldquo: 8220,
177
+ rdquo: 8221,
178
+ bdquo: 8222,
179
+ dagger: 8224,
180
+ Dagger: 8225,
181
+ bull: 8226,
182
+ hellip: 8230,
183
+ permil: 8240,
184
+ prime: 8242,
185
+ Prime: 8243,
186
+ lsaquo: 8249,
187
+ rsaquo: 8250,
188
+ oline: 8254,
189
+ frasl: 8260,
190
+ euro: 8364,
191
+ image: 8465,
192
+ weierp: 8472,
193
+ real: 8476,
194
+ trade: 8482,
195
+ alefsym: 8501,
196
+ larr: 8592,
197
+ uarr: 8593,
198
+ rarr: 8594,
199
+ darr: 8595,
200
+ harr: 8596,
201
+ crarr: 8629,
202
+ lArr: 8656,
203
+ uArr: 8657,
204
+ rArr: 8658,
205
+ dArr: 8659,
206
+ hArr: 8660,
207
+ forall: 8704,
208
+ part: 8706,
209
+ exist: 8707,
210
+ empty: 8709,
211
+ nabla: 8711,
212
+ isin: 8712,
213
+ notin: 8713,
214
+ ni: 8715,
215
+ prod: 8719,
216
+ sum: 8721,
217
+ minus: 8722,
218
+ lowast: 8727,
219
+ radic: 8730,
220
+ prop: 8733,
221
+ infin: 8734,
222
+ ang: 8736,
223
+ and: 8743,
224
+ or: 8744,
225
+ cap: 8745,
226
+ cup: 8746,
227
+ int: 8747,
228
+ there4: 8756,
229
+ sim: 8764,
230
+ cong: 8773,
231
+ asymp: 8776,
232
+ ne: 8800,
233
+ equiv: 8801,
234
+ le: 8804,
235
+ ge: 8805,
236
+ sub: 8834,
237
+ sup: 8835,
238
+ nsub: 8836,
239
+ sube: 8838,
240
+ supe: 8839,
241
+ oplus: 8853,
242
+ otimes: 8855,
243
+ perp: 8869,
244
+ sdot: 8901,
245
+ lceil: 8968,
246
+ rceil: 8969,
247
+ lfloor: 8970,
248
+ rfloor: 8971,
249
+ lang: 9001,
250
+ rang: 9002,
251
+ loz: 9674,
252
+ spades: 9824,
253
+ clubs: 9827,
254
+ hearts: 9829,
255
+ diams: 9830
256
+ };
257
+ var REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g;
258
+ function decodeEntities(value) {
259
+ if (!value.includes("&")) return value;
260
+ return value.replace(REFERENCE, (match, hex, dec, name) => {
261
+ const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : void 0;
262
+ return code !== void 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
263
+ });
264
+ }
265
+ export {
266
+ decodeEntities
267
+ };
@@ -332,6 +332,50 @@ function paren(code, position) {
332
332
  return topLevelComma(src) === false ? code : `(${code})`;
333
333
  }
334
334
 
335
+ // src/analyze/intrinsics.ts
336
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
337
+ var INTRINSICS = {
338
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
339
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
340
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
341
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
342
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
343
+ $cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
344
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
345
+ // name. Still worth having: no import to write, and when a shorter form is
346
+ // designed, the change is this line rather than a compiler pass.
347
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
348
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
349
+ // Not value constructors, but the compiler has to know them: they change what a read
350
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
351
+ // dependency analysis must not guess at.
352
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
353
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
354
+ // Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
355
+ // no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
356
+ $batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
357
+ $cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
358
+ $root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
359
+ $context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
360
+ $renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
361
+ $computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
362
+ // Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
363
+ // handle as far as reads go: the same accessor with `set` on it.
364
+ $storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
365
+ $asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
366
+ $persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
367
+ // An environment variable, public or server-only; the browser build refuses a secret.
368
+ $env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
369
+ };
370
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
371
+
372
+ // src/transform/source-locations.ts
373
+ var SOURCE_MARKER = "__fx_source";
374
+ var HOLE_MARKER = "__fx_hole";
375
+ var markHole = (accessor, line, column, name) => `(globalThis.${HOLE_MARKER} ?? ((f) => f))(${accessor},${line},${column}${name === void 0 ? "" : `,${JSON.stringify(name)}`})`;
376
+ var PROPS_MARKER = "__fx_props";
377
+ var markProps = (object, at) => `(globalThis.${PROPS_MARKER} ?? ((p) => p))(${object},${JSON.stringify(at)})`;
378
+
335
379
  // src/codegen/serialize-static.ts
336
380
  var VOID_ELEMENTS = /* @__PURE__ */ new Set([
337
381
  "area",
@@ -536,50 +580,6 @@ var RUNTIME_CONTRACT_V2 = {
536
580
  symbols: [...RUNTIME_CONTRACT_V1.symbols, "template", "cloneTemplate", "walk"]
537
581
  };
538
582
 
539
- // src/analyze/intrinsics.ts
540
- var REACTIVE_MODULE = "@fluixi/reactive/signal";
541
- var INTRINSICS = {
542
- $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
543
- $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
544
- $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
545
- $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
546
- $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
547
- $cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
548
- // No short runtime form for these yet, so the intrinsic stands for the `create*`
549
- // name. Still worth having: no import to write, and when a shorter form is
550
- // designed, the change is this line rather than a compiler pass.
551
- $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
552
- $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
553
- // Not value constructors, but the compiler has to know them: they change what a read
554
- // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
555
- // dependency analysis must not guess at.
556
- $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
557
- $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
558
- // Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
559
- // no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
560
- $batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
561
- $cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
562
- $root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
563
- $context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
564
- $renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
565
- $computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
566
- // Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
567
- // handle as far as reads go: the same accessor with `set` on it.
568
- $storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
569
- $asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
570
- $persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
571
- // An environment variable, public or server-only; the browser build refuses a secret.
572
- $env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
573
- };
574
- var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
575
-
576
- // src/transform/source-locations.ts
577
- var SOURCE_MARKER = "__fx_source";
578
- var HOLE_MARKER = "__fx_hole";
579
- var markHole = (accessor, line, column, name) => `(globalThis.${HOLE_MARKER} ?? ((f) => f))(${accessor},${line},${column}${name === void 0 ? "" : `,${JSON.stringify(name)}`})`;
580
- var PROPS_MARKER = "__fx_props";
581
- var markProps = (object, at) => `(globalThis.${PROPS_MARKER} ?? ((p) => p))(${object},${JSON.stringify(at)})`;
582
-
583
583
  // src/codegen/backends/imperative.ts
584
584
  var CONTROL_COMPONENT = {
585
585
  show: "Show",
@@ -641,7 +641,7 @@ function emitComponent(name, props, children, used, templates, at) {
641
641
  }
642
642
  let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
643
643
  if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
644
- const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => ${body}`);
644
+ const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
645
645
  const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
646
646
  obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
647
647
  }
@@ -885,9 +885,12 @@ function attrExprCode(attr, ctx) {
885
885
  }
886
886
  return null;
887
887
  }
888
- function buildProps(attrs, ctx) {
888
+ function buildProps(attrs, ctx, element = false) {
889
889
  const props = [];
890
890
  const usePairs = [];
891
+ const classEntries = [];
892
+ const styleEntries = [];
893
+ let styleAt;
891
894
  for (const a of attrs) {
892
895
  if (a.type === "JSXSpreadAttribute") {
893
896
  props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
@@ -903,6 +906,27 @@ function buildProps(attrs, ctx) {
903
906
  usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
904
907
  continue;
905
908
  }
909
+ if (element && (ns === "class" || ns === "style")) {
910
+ const key = JSON.stringify(a.name.name.name);
911
+ const v = a.value;
912
+ let value;
913
+ if (v == null) value = "true";
914
+ else if (isString(v)) value = JSON.stringify(literalOf(v));
915
+ else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
916
+ value = keyValue(v.expression, ctx);
917
+ if (ns === "style") styleAt ??= posOf(v.expression, ctx);
918
+ } else continue;
919
+ (ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
920
+ continue;
921
+ }
922
+ if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
923
+ const entries = objectEntries(a.value.expression, ctx);
924
+ if (entries) {
925
+ styleEntries.unshift(...entries);
926
+ styleAt = posOf(a.value.expression, ctx);
927
+ continue;
928
+ }
929
+ }
906
930
  if (ns === "oncapture") {
907
931
  const evt = a.name.name.name.toLowerCase();
908
932
  const h = attrExprCode(a, ctx) ?? "undefined";
@@ -911,9 +935,37 @@ function buildProps(attrs, ctx) {
911
935
  }
912
936
  props.push(buildAttr(a, ctx));
913
937
  }
938
+ if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
939
+ if (styleEntries.length > 0) {
940
+ const entries = `{ ${styleEntries.join(", ")} }`;
941
+ const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
942
+ if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
943
+ else {
944
+ const prop = props[base];
945
+ const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
946
+ props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
947
+ }
948
+ }
914
949
  if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
915
950
  return props;
916
951
  }
952
+ function keyValue(expr, ctx) {
953
+ const code = ctx.code(expr);
954
+ if (!isReactive(expr)) return code;
955
+ const accessor = `() => ${paren(code, "arrowBody")}`;
956
+ const at = posOf(expr, ctx);
957
+ return at ? markHole(accessor, at.line, at.column) : accessor;
958
+ }
959
+ function objectEntries(expr, ctx) {
960
+ if (expr?.type !== "ObjectExpression") return null;
961
+ const entries = [];
962
+ for (const p of expr.properties) {
963
+ if (p.type !== "ObjectProperty") return null;
964
+ const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
965
+ entries.push(`${key}: ${keyValue(p.value, ctx)}`);
966
+ }
967
+ return entries;
968
+ }
917
969
  function buildChildren(children, ctx) {
918
970
  const out = [];
919
971
  for (let i = 0; i < children.length; i++) {
@@ -941,6 +993,7 @@ function buildChildren(children, ctx) {
941
993
  });
942
994
  }
943
995
  } else if (child.type === "JSXElement" || child.type === "JSXFragment") {
996
+ if (ctx.dropStyles?.has(child.start)) continue;
944
997
  out.push(buildNode(child, ctx));
945
998
  } else if (child.type === "JSXSpreadChild") {
946
999
  out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
@@ -1010,13 +1063,17 @@ function buildElement(node, ctx, handled) {
1010
1063
  const children = each ? [each] : buildChildren(node.children, ctx);
1011
1064
  if (tag === CONTAINER) return children.length === 1 ? children[0] : { kind: "fragment", children };
1012
1065
  const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
1013
- return { kind: "element", tag, svg: SVG_TAGS.has(tag), props: buildProps(attributes, ctx), children, static: false, ...at ? { at } : {} };
1066
+ const props = buildProps(attributes, ctx, true);
1067
+ const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
1068
+ if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
1069
+ return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
1014
1070
  }
1015
1071
  function buildNode(node, ctx) {
1016
1072
  if (node.type === "JSXFragment") {
1017
1073
  return { kind: "fragment", children: buildChildren(node.children, ctx) };
1018
1074
  }
1019
1075
  if (directive(node, "if")) return buildIf(node, null, ctx);
1076
+ if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
1020
1077
  const { tag, component } = tagInfo(node.openingElement.name, ctx);
1021
1078
  if (!component) return buildElement(node, ctx, []);
1022
1079
  const props = buildProps(node.openingElement.attributes, ctx);
@@ -18,6 +18,14 @@ export interface JsxContext {
18
18
  used: Set<string>;
19
19
  /** The file being compiled, when component usage sites are to be recorded. */
20
20
  sourceFile?: string;
21
+ /** Scoped styles: intrinsic elements inside a range get `data-fx-s` set to its value. */
22
+ scopes?: {
23
+ start: number;
24
+ end: number;
25
+ value: string;
26
+ }[];
27
+ /** Start offsets of `<style>` elements the compiler took out of the template. */
28
+ dropStyles?: Set<number>;
21
29
  }
22
30
  export declare const SVG_TAGS: Set<string>;
23
31
  /** Build IR from a JSXElement or JSXFragment. */
@@ -18,6 +18,14 @@ export interface JsxContext {
18
18
  used: Set<string>;
19
19
  /** The file being compiled, when component usage sites are to be recorded. */
20
20
  sourceFile?: string;
21
+ /** Scoped styles: intrinsic elements inside a range get `data-fx-s` set to its value. */
22
+ scopes?: {
23
+ start: number;
24
+ end: number;
25
+ value: string;
26
+ }[];
27
+ /** Start offsets of `<style>` elements the compiler took out of the template. */
28
+ dropStyles?: Set<number>;
21
29
  }
22
30
  export declare const SVG_TAGS: Set<string>;
23
31
  /** Build IR from a JSXElement or JSXFragment. */
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AASjF,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,mFAAmF;IACnF,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,aAGnB,CAAC;AAsTH,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAM9D"}
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAUjF,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,mFAAmF;IACnF,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,iFAAiF;IACjF,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,eAAO,MAAM,QAAQ,aAGnB,CAAC;AAoYH,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAM9D"}