@fluixi/compiler 1.0.0-alpha.92 → 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 +31 -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 +35 -0
- package/dist/analyze/intrinsics.mjs +31 -1
- package/dist/analyze/reactive-bindings.cjs +18 -0
- package/dist/analyze/reactive-bindings.mjs +18 -0
- package/dist/analyze/static-graph.cjs +22 -4
- package/dist/analyze/static-graph.d.ts.map +1 -1
- package/dist/analyze/static-graph.js +6 -4
- package/dist/analyze/static-graph.mjs +22 -4
- package/dist/{babel-GI375YZ2.mjs → babel-RJFQVFJW.mjs} +4 -4
- package/dist/{chunk-QZ4CJPYP.mjs → chunk-DP2QDWWH.mjs} +1 -1
- package/dist/{chunk-DWNWN5RH.mjs → chunk-E2RWTIYE.mjs} +21 -15
- package/dist/{chunk-XJ5H2MXY.mjs → chunk-HCCBEJEZ.mjs} +31 -1
- package/dist/{chunk-VOUI6XPV.mjs → chunk-HIZU7WI2.mjs} +1 -1
- package/dist/{chunk-VC6X44FS.mjs → chunk-ZR2QHTEX.mjs} +505 -68
- package/dist/codegen/backends/imperative.cjs +24 -6
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +20 -4
- package/dist/codegen/backends/imperative.mjs +24 -6
- package/dist/frontend/babel/build-ir-lit.cjs +470 -63
- package/dist/frontend/babel/build-ir-lit.mjs +470 -63
- package/dist/frontend/babel/build-ir.cjs +470 -63
- package/dist/frontend/babel/build-ir.mjs +470 -63
- package/dist/frontend/babel/index.cjs +471 -64
- package/dist/frontend/babel/index.mjs +471 -64
- package/dist/frontend/babel/lower-template.cjs +470 -63
- package/dist/frontend/babel/lower-template.mjs +470 -63
- package/dist/frontend/babel/plugin.cjs +470 -63
- package/dist/frontend/babel/plugin.mjs +470 -63
- package/dist/index.cjs +360 -58
- package/dist/index.mjs +372 -58
- package/dist/integrations.cjs +1347 -98
- 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 +354 -57
- 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 +366 -57
- 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 +567 -7
- 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 +205 -7
- package/dist/lower/jsx.mjs +567 -7
- package/dist/lower/template.cjs +332 -56
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +57 -49
- package/dist/lower/template.mjs +332 -56
- package/dist/resolve/builtins.cjs +1 -1
- package/dist/resolve/builtins.mjs +1 -1
- package/dist/resolve/component-globals.cjs +20 -1
- package/dist/resolve/component-globals.js +2 -2
- package/dist/resolve/component-globals.mjs +20 -1
- package/dist/resolve/write-globals.cjs +20 -1
- package/dist/resolve/write-globals.mjs +20 -1
- package/dist/{server-fns-BBZRZUPP.mjs → server-fns-JLSTKWPS.mjs} +4 -4
- package/dist/{server-functions-VEGLIFCE.mjs → server-functions-BGY3RD4R.mjs} +3 -3
- package/dist/transform/index.cjs +1123 -77
- package/dist/transform/index.mjs +1141 -91
- package/dist/transform/intrinsics.cjs +18 -0
- package/dist/transform/intrinsics.mjs +18 -0
- package/dist/transform/props.mjs +19 -14
- package/dist/transform/server-fns.mjs +19 -14
- package/dist/transform/source-locations.cjs +64 -3
- package/dist/transform/source-locations.d.cts +7 -2
- package/dist/transform/source-locations.d.ts +7 -2
- package/dist/transform/source-locations.d.ts.map +1 -1
- package/dist/transform/source-locations.js +68 -3
- package/dist/transform/source-locations.mjs +64 -3
- 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 +1122 -76
- 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 +51 -14
- package/dist/transform/templates.mjs +1140 -90
- package/dist/{transform-UWZ7ZGJ2.mjs → transform-GBP6Y4UI.mjs} +603 -19
- 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 +10 -3
|
@@ -237,6 +237,7 @@ var INTRINSICS = {
|
|
|
237
237
|
$effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
|
|
238
238
|
$store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
|
|
239
239
|
$resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
|
|
240
|
+
$cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
|
|
240
241
|
// No short runtime form for these yet, so the intrinsic stands for the `create*`
|
|
241
242
|
// name. Still worth having: no import to write, and when a shorter form is
|
|
242
243
|
// designed, the change is this line rather than a compiler pass.
|
|
@@ -247,6 +248,19 @@ var INTRINSICS = {
|
|
|
247
248
|
// dependency analysis must not guess at.
|
|
248
249
|
$untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
|
|
249
250
|
$untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
|
|
251
|
+
// Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
|
|
252
|
+
// no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
|
|
253
|
+
$batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
|
|
254
|
+
$cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
|
|
255
|
+
$root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
|
|
256
|
+
$context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
|
|
257
|
+
$renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
|
|
258
|
+
$computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
|
|
259
|
+
// Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
|
|
260
|
+
// handle as far as reads go: the same accessor with `set` on it.
|
|
261
|
+
$storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
262
|
+
$asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
263
|
+
$persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
|
|
250
264
|
// An environment variable, public or server-only; the browser build refuses a secret.
|
|
251
265
|
$env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
|
|
252
266
|
};
|
|
@@ -424,13 +438,16 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
424
438
|
used.add("createComponent");
|
|
425
439
|
const spreads = props.filter((p) => p.kind === "spread");
|
|
426
440
|
const normal = props.filter((p) => p.kind !== "spread");
|
|
427
|
-
const
|
|
428
|
-
(p) => `get ${propKey(p.name)}() { return ${componentPropValue(p)}; }`
|
|
429
|
-
);
|
|
441
|
+
const bodies = normal.map((p) => [p.name, componentPropValue(p)]);
|
|
430
442
|
if (children.length > 0) {
|
|
431
|
-
|
|
443
|
+
bodies.push(["children", emitChildren(children, used, templates)]);
|
|
444
|
+
}
|
|
445
|
+
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
446
|
+
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
447
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
448
|
+
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
449
|
+
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
432
450
|
}
|
|
433
|
-
let obj = `{ ${entries.join(", ")} }`;
|
|
434
451
|
if (spreads.length > 0) {
|
|
435
452
|
used.add("mergeProps");
|
|
436
453
|
obj = `mergeProps(${spreads.map((s) => s.expr).join(", ")}, ${obj})`;
|
|
@@ -512,7 +529,8 @@ function emitNode(node, used, templates) {
|
|
|
512
529
|
} else {
|
|
513
530
|
used.add("spread");
|
|
514
531
|
const svgFlag = node.svg ? ", isSVG: true" : "";
|
|
515
|
-
const
|
|
532
|
+
const accessors = node.props.filter((p) => p.kind !== "spread" && p.expr !== void 0 && p.reactive && p.name !== "ref").map((p) => p.name);
|
|
533
|
+
const customFlag = node.tag.includes("-") ? `, isCustomElement: true, accessors: ${JSON.stringify(accessors)}` : "";
|
|
516
534
|
parts.push(
|
|
517
535
|
`spread({ element: ${el}, props: ${emitProps(node.props, null, used)}${svgFlag}${customFlag} });`
|
|
518
536
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imperative.d.ts","sourceRoot":"","sources":["../../../src/codegen/backends/imperative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"imperative.d.ts","sourceRoot":"","sources":["../../../src/codegen/backends/imperative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,cAAc,EAAE,MAAM,eAAe,CAAC;AAmVnF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,SAAS,GAAG,MAAM,CAK7F;AAED,eAAO,MAAM,iBAAiB,EAAE,cAgB/B,CAAC"}
|
|
@@ -101,15 +101,26 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
101
101
|
// on every change (a <Portal> then piles up). As getters the component is built ONCE and
|
|
102
102
|
// reactivity flows through the getter into its own effects. Static props as getters are
|
|
103
103
|
// harmless (they return the same value). Matches lazyProps() in the inline codegen.
|
|
104
|
-
|
|
104
|
+
// Each body emitted once: emitting children registers their templates.
|
|
105
|
+
const bodies = normal.map((p) => [p.name, componentPropValue(p)]);
|
|
105
106
|
if (children.length > 0) {
|
|
106
107
|
// Children are a LAZY getter: evaluated inside the component's execution, so
|
|
107
108
|
// child components are created in the component's owner scope (preserves owner
|
|
108
109
|
// nesting for context/Suspense), after the component runs (correct provider
|
|
109
110
|
// ordering), and lazily (ErrorBoundary can still catch a throwing child).
|
|
110
|
-
|
|
111
|
+
bodies.push(['children', emitChildren(children, used, templates)]);
|
|
112
|
+
}
|
|
113
|
+
let obj = `{ ${bodies.map(([name, body]) => `get ${propKey(name)}() { return ${body}; }`).join(', ')} }`;
|
|
114
|
+
// A getter is a method: `this` inside it is the props object. Written in a class method
|
|
115
|
+
// (a custom element's render), `title={() => this.name}` then read the props, not the
|
|
116
|
+
// element. Arrows keep the enclosing `this`, so those props go out as arrow thunks and the
|
|
117
|
+
// getters call them. Only when some prop mentions `this`; everything else is unchanged.
|
|
118
|
+
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
119
|
+
// Parenthesised: an object literal body would otherwise parse as a block.
|
|
120
|
+
const thunks = bodies.map(([name, body]) => `${JSON.stringify(name)}: () => (${body})`);
|
|
121
|
+
const getters = bodies.map(([name]) => `get ${propKey(name)}() { return _$t[${JSON.stringify(name)}](); }`);
|
|
122
|
+
obj = `((_$t) => ({ ${getters.join(', ')} }))({ ${thunks.join(', ')} })`;
|
|
111
123
|
}
|
|
112
|
-
let obj = `{ ${entries.join(', ')} }`;
|
|
113
124
|
if (spreads.length > 0) {
|
|
114
125
|
used.add('mergeProps');
|
|
115
126
|
obj = `mergeProps(${spreads.map((s) => s.expr).join(', ')}, ${obj})`;
|
|
@@ -268,7 +279,12 @@ function emitNode(node, used, templates) {
|
|
|
268
279
|
// here, so the runtime does not have to read it back off the node. It falls
|
|
269
280
|
// back to that check when the flag is absent, which is how a hand-written
|
|
270
281
|
// `spread` call still behaves.
|
|
271
|
-
|
|
282
|
+
// For a custom element it also names the props wrapped as accessors: any other
|
|
283
|
+
// function is a property value (an action, a callback) and must not be called.
|
|
284
|
+
const accessors = node.props
|
|
285
|
+
.filter((p) => p.kind !== 'spread' && p.expr !== undefined && p.reactive && p.name !== 'ref')
|
|
286
|
+
.map((p) => p.name);
|
|
287
|
+
const customFlag = node.tag.includes('-') ? `, isCustomElement: true, accessors: ${JSON.stringify(accessors)}` : '';
|
|
272
288
|
parts.push(`spread({ element: ${el}, props: ${emitProps(node.props, null, used)}${svgFlag}${customFlag} });`);
|
|
273
289
|
}
|
|
274
290
|
}
|
|
@@ -210,6 +210,7 @@ var INTRINSICS = {
|
|
|
210
210
|
$effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
|
|
211
211
|
$store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
|
|
212
212
|
$resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
|
|
213
|
+
$cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
|
|
213
214
|
// No short runtime form for these yet, so the intrinsic stands for the `create*`
|
|
214
215
|
// name. Still worth having: no import to write, and when a shorter form is
|
|
215
216
|
// designed, the change is this line rather than a compiler pass.
|
|
@@ -220,6 +221,19 @@ var INTRINSICS = {
|
|
|
220
221
|
// dependency analysis must not guess at.
|
|
221
222
|
$untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
|
|
222
223
|
$untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
|
|
224
|
+
// Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
|
|
225
|
+
// no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
|
|
226
|
+
$batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
|
|
227
|
+
$cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
|
|
228
|
+
$root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
|
|
229
|
+
$context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
|
|
230
|
+
$renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
|
|
231
|
+
$computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
|
|
232
|
+
// Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
|
|
233
|
+
// handle as far as reads go: the same accessor with `set` on it.
|
|
234
|
+
$storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
235
|
+
$asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
236
|
+
$persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
|
|
223
237
|
// An environment variable, public or server-only; the browser build refuses a secret.
|
|
224
238
|
$env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
|
|
225
239
|
};
|
|
@@ -397,13 +411,16 @@ function emitComponent(name, props, children, used, templates, at) {
|
|
|
397
411
|
used.add("createComponent");
|
|
398
412
|
const spreads = props.filter((p) => p.kind === "spread");
|
|
399
413
|
const normal = props.filter((p) => p.kind !== "spread");
|
|
400
|
-
const
|
|
401
|
-
(p) => `get ${propKey(p.name)}() { return ${componentPropValue(p)}; }`
|
|
402
|
-
);
|
|
414
|
+
const bodies = normal.map((p) => [p.name, componentPropValue(p)]);
|
|
403
415
|
if (children.length > 0) {
|
|
404
|
-
|
|
416
|
+
bodies.push(["children", emitChildren(children, used, templates)]);
|
|
417
|
+
}
|
|
418
|
+
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
419
|
+
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
420
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
421
|
+
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
422
|
+
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
405
423
|
}
|
|
406
|
-
let obj = `{ ${entries.join(", ")} }`;
|
|
407
424
|
if (spreads.length > 0) {
|
|
408
425
|
used.add("mergeProps");
|
|
409
426
|
obj = `mergeProps(${spreads.map((s) => s.expr).join(", ")}, ${obj})`;
|
|
@@ -485,7 +502,8 @@ function emitNode(node, used, templates) {
|
|
|
485
502
|
} else {
|
|
486
503
|
used.add("spread");
|
|
487
504
|
const svgFlag = node.svg ? ", isSVG: true" : "";
|
|
488
|
-
const
|
|
505
|
+
const accessors = node.props.filter((p) => p.kind !== "spread" && p.expr !== void 0 && p.reactive && p.name !== "ref").map((p) => p.name);
|
|
506
|
+
const customFlag = node.tag.includes("-") ? `, isCustomElement: true, accessors: ${JSON.stringify(accessors)}` : "";
|
|
489
507
|
parts.push(
|
|
490
508
|
`spread({ element: ${el}, props: ${emitProps(node.props, null, used)}${svgFlag}${customFlag} });`
|
|
491
509
|
);
|