@fluixi/compiler 1.0.0-alpha.100 → 1.0.0-alpha.101
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/README.md +13 -13
- package/dist/analyze/props-destructure.d.cts +1 -1
- package/dist/analyze/props-destructure.d.ts +1 -1
- package/dist/analyze/props-destructure.js +1 -1
- package/dist/analyze/reactive-bindings.d.cts +1 -1
- package/dist/analyze/reactive-bindings.d.ts +1 -1
- package/dist/analyze/reactive-bindings.js +3 -3
- package/dist/analyze/static-graph.cjs +1 -1
- package/dist/analyze/static-graph.js +2 -2
- package/dist/analyze/static-graph.mjs +1 -1
- package/dist/{babel-I6BUWUCU.mjs → babel-4WLP2IRR.mjs} +23 -23
- package/dist/{chunk-SKAVY75W.mjs → chunk-46MIOLUB.mjs} +1 -1
- package/dist/{chunk-C3XPDB4Y.mjs → chunk-AIK66L2P.mjs} +1 -1
- package/dist/{chunk-3AICWNF7.mjs → chunk-B6GUZXJP.mjs} +1 -1
- package/dist/{chunk-HXEXPWJ2.mjs → chunk-BVY2ISKX.mjs} +2 -2
- package/dist/{chunk-6CWJWGE2.mjs → chunk-G2PQDYFN.mjs} +10 -10
- package/dist/{chunk-GX5XV6Z7.mjs → chunk-K4Q6GHV6.mjs} +1 -1
- package/dist/{chunk-NU3W67UZ.mjs → chunk-S3LT32LA.mjs} +2 -2
- package/dist/codegen/backends/imperative.js +2 -2
- package/dist/frontend/babel/{build-ir-lit.cjs → build-ir-html.cjs} +19 -19
- package/dist/frontend/babel/{build-ir-lit.d.cts → build-ir-html.d.cts} +5 -5
- package/dist/frontend/babel/{build-ir-lit.d.ts → build-ir-html.d.ts} +6 -6
- package/dist/frontend/babel/build-ir-html.d.ts.map +1 -0
- package/dist/frontend/babel/{build-ir-lit.js → build-ir-html.js} +4 -4
- package/dist/frontend/babel/{build-ir-lit.mjs → build-ir-html.mjs} +15 -15
- package/dist/frontend/babel/build-ir.cjs +14 -14
- package/dist/frontend/babel/build-ir.d.cts +1 -1
- package/dist/frontend/babel/build-ir.d.ts +1 -1
- package/dist/frontend/babel/build-ir.js +5 -5
- package/dist/frontend/babel/build-ir.mjs +14 -14
- package/dist/frontend/babel/index.cjs +28 -28
- package/dist/frontend/babel/index.d.cts +0 -11
- package/dist/frontend/babel/index.d.ts +0 -11
- package/dist/frontend/babel/index.d.ts.map +1 -1
- package/dist/frontend/babel/index.js +2 -14
- package/dist/frontend/babel/index.mjs +28 -28
- package/dist/frontend/babel/lower-template.cjs +15 -15
- package/dist/frontend/babel/lower-template.d.cts +3 -3
- package/dist/frontend/babel/lower-template.d.ts +3 -3
- package/dist/frontend/babel/lower-template.d.ts.map +1 -1
- package/dist/frontend/babel/lower-template.js +4 -4
- package/dist/frontend/babel/lower-template.mjs +15 -15
- package/dist/frontend/babel/plugin.cjs +25 -25
- package/dist/frontend/babel/plugin.d.cts +6 -22
- package/dist/frontend/babel/plugin.d.ts +6 -22
- package/dist/frontend/babel/plugin.d.ts.map +1 -1
- package/dist/frontend/babel/plugin.js +19 -42
- package/dist/frontend/babel/plugin.mjs +25 -25
- package/dist/frontend/babel/server-functions.js +2 -2
- package/dist/index.cjs +9 -9
- package/dist/index.mjs +9 -9
- package/dist/integrations.cjs +42 -42
- package/dist/integrations.d.cts +7 -22
- package/dist/integrations.d.ts +7 -22
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +3 -34
- package/dist/integrations.mjs +13 -13
- package/dist/ir/nodes.d.cts +1 -1
- package/dist/ir/nodes.d.ts +1 -1
- package/dist/lower/compile-template.cjs +9 -9
- package/dist/lower/compile-template.d.cts +2 -2
- package/dist/lower/compile-template.d.ts +2 -2
- package/dist/lower/compile-template.d.ts.map +1 -1
- package/dist/lower/compile-template.js +1 -1
- package/dist/lower/compile-template.mjs +9 -9
- package/dist/lower/jsx.js +2 -2
- package/dist/lower/template.cjs +8 -8
- package/dist/lower/template.d.cts +6 -6
- package/dist/lower/template.d.ts +6 -6
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +14 -14
- package/dist/lower/template.mjs +8 -8
- package/dist/resolve/builtins.cjs +1 -1
- package/dist/resolve/builtins.d.cts +2 -2
- package/dist/resolve/builtins.d.ts +2 -2
- package/dist/resolve/builtins.js +1 -1
- package/dist/resolve/builtins.mjs +1 -1
- package/dist/resolve/component-globals.d.cts +2 -2
- package/dist/resolve/component-globals.d.ts +2 -2
- package/dist/resolve/component-globals.js +1 -1
- package/dist/resolve/load-directive.d.cts +1 -1
- package/dist/resolve/load-directive.d.ts +1 -1
- package/dist/resolve/load-directive.js +1 -1
- package/dist/resolve/resolve-ir.d.cts +1 -1
- package/dist/resolve/resolve-ir.d.ts +1 -1
- package/dist/{server-fns-VZLHMQTC.mjs → server-fns-THMTJXV7.mjs} +5 -5
- package/dist/{server-functions-UAZKOLZW.mjs → server-functions-MP4I3DAX.mjs} +3 -3
- package/dist/transform/bindings.d.cts +1 -1
- package/dist/transform/bindings.d.ts +1 -1
- package/dist/transform/bindings.js +1 -1
- package/dist/transform/index.cjs +17 -17
- package/dist/transform/index.mjs +17 -17
- package/dist/transform/intrinsics.d.cts +1 -1
- package/dist/transform/intrinsics.d.ts +1 -1
- package/dist/transform/intrinsics.js +1 -1
- package/dist/transform/source-locations.d.cts +1 -1
- package/dist/transform/source-locations.d.ts +1 -1
- package/dist/transform/source-locations.d.ts.map +1 -1
- package/dist/transform/source-locations.js +6 -6
- package/dist/transform/styles.d.cts +2 -2
- package/dist/transform/styles.d.ts +2 -2
- package/dist/transform/styles.d.ts.map +1 -1
- package/dist/transform/styles.js +5 -5
- package/dist/transform/templates.cjs +16 -16
- package/dist/transform/templates.d.cts +2 -2
- package/dist/transform/templates.d.ts +2 -2
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +10 -10
- package/dist/transform/templates.mjs +16 -16
- package/dist/{transform-3W45L3EA.mjs → transform-27QH3X24.mjs} +15 -15
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/vite-styles.js +2 -2
- package/package.json +4 -4
- package/dist/frontend/babel/build-ir-lit.d.ts.map +0 -1
package/dist/integrations.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*! @fluixi/compiler v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.101 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
import {
|
|
3
3
|
styleIds
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-S3LT32LA.mjs";
|
|
5
5
|
import {
|
|
6
6
|
INTRINSICS,
|
|
7
7
|
TAG_INTRINSICS,
|
|
8
8
|
builtinComponentMap,
|
|
9
9
|
createComponentResolver
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-K4Q6GHV6.mjs";
|
|
11
|
+
import "./chunk-B6GUZXJP.mjs";
|
|
12
12
|
import {
|
|
13
13
|
__require
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-46MIOLUB.mjs";
|
|
15
15
|
|
|
16
16
|
// src/resolve/write-globals.ts
|
|
17
17
|
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -432,7 +432,7 @@ import { dirname as dirname3, join as _join, resolve as resolvePath2 } from "nod
|
|
|
432
432
|
async function createBabelPlugin(options = {}) {
|
|
433
433
|
let pluginModule = null;
|
|
434
434
|
try {
|
|
435
|
-
pluginModule = await import("./babel-
|
|
435
|
+
pluginModule = await import("./babel-4WLP2IRR.mjs");
|
|
436
436
|
} catch (e) {
|
|
437
437
|
console.warn("Could not load the babel front-end:", e);
|
|
438
438
|
}
|
|
@@ -451,7 +451,7 @@ async function createBabelPlugin(options = {}) {
|
|
|
451
451
|
...options.resolve ? { resolve: options.resolve } : {},
|
|
452
452
|
...options.templateClone !== void 0 ? { templateClone: options.templateClone } : {},
|
|
453
453
|
...options.partialTemplates !== void 0 ? { partialTemplates: options.partialTemplates } : {},
|
|
454
|
-
...options.
|
|
454
|
+
...options.htmlTag ? { htmlTag: options.htmlTag } : {},
|
|
455
455
|
...options.signalModule ? { signalModule: options.signalModule } : {},
|
|
456
456
|
...options.controlFlowModule ? { controlFlowModule: options.controlFlowModule } : {},
|
|
457
457
|
...options.routerModule ? { routerModule: options.routerModule } : {},
|
|
@@ -521,7 +521,7 @@ function createVitePlugin(options = {}) {
|
|
|
521
521
|
const entry = config?.command === "build" && config.build?.lib ? config.build.lib.entry : void 0;
|
|
522
522
|
const first = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : entry && typeof entry === "object" ? Object.values(entry)[0] : void 0;
|
|
523
523
|
if (typeof first === "string") componentStyles.setLibrary(dirname3(resolvePath2(config.root ?? process.cwd(), first)));
|
|
524
|
-
if (componentStyles.active) ({ transformTemplates } = await import("./transform-
|
|
524
|
+
if (componentStyles.active) ({ transformTemplates } = await import("./transform-27QH3X24.mjs"));
|
|
525
525
|
},
|
|
526
526
|
generateBundle() {
|
|
527
527
|
for (const [fileName, source] of componentStyles.libraryFiles()) this.emitFile({ type: "asset", fileName, source });
|
|
@@ -625,7 +625,7 @@ function marks(options, id) {
|
|
|
625
625
|
function transformOptions(options, id) {
|
|
626
626
|
return {
|
|
627
627
|
resolve: options.resolve,
|
|
628
|
-
|
|
628
|
+
htmlTag: options.htmlTag,
|
|
629
629
|
sourceLocations: marks(options, id),
|
|
630
630
|
sourceRoot: options.sourceRoot,
|
|
631
631
|
templateClone: options.templateClone,
|
|
@@ -639,7 +639,7 @@ function transformOptions(options, id) {
|
|
|
639
639
|
}
|
|
640
640
|
async function rewriteProps(code, id, options) {
|
|
641
641
|
if (options.propsDestructure === false) return code;
|
|
642
|
-
const { transformProps } = await import("./transform-
|
|
642
|
+
const { transformProps } = await import("./transform-27QH3X24.mjs");
|
|
643
643
|
const result = transformProps(code, id);
|
|
644
644
|
reportDiagnostics({ propsDiagnostics: result.diagnostics }, id);
|
|
645
645
|
return result.rewritten > 0 ? result.code : code;
|
|
@@ -663,7 +663,7 @@ function reportDiagnostics(result, id) {
|
|
|
663
663
|
}
|
|
664
664
|
async function compileModule(code, id, options) {
|
|
665
665
|
if (!options.babel) {
|
|
666
|
-
const { transformTemplates } = await import("./transform-
|
|
666
|
+
const { transformTemplates } = await import("./transform-27QH3X24.mjs");
|
|
667
667
|
const result2 = transformTemplates(code, id, transformOptions(options, id));
|
|
668
668
|
reportDiagnostics(result2, id);
|
|
669
669
|
return result2;
|
|
@@ -782,10 +782,10 @@ export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
|
|
|
782
782
|
if (!code.includes("use server")) return null;
|
|
783
783
|
const args = { ssr: !!opts?.ssr, filename: id, root };
|
|
784
784
|
if (options.babel) {
|
|
785
|
-
const { transformServerFunctions } = await import("./server-functions-
|
|
785
|
+
const { transformServerFunctions } = await import("./server-functions-MP4I3DAX.mjs");
|
|
786
786
|
return transformServerFunctions(code, args);
|
|
787
787
|
}
|
|
788
|
-
const { transformServerFns } = await import("./server-fns-
|
|
788
|
+
const { transformServerFns } = await import("./server-fns-THMTJXV7.mjs");
|
|
789
789
|
return transformServerFns(code, args);
|
|
790
790
|
}
|
|
791
791
|
};
|
package/dist/ir/nodes.d.cts
CHANGED
|
@@ -124,7 +124,7 @@ export interface IRComponent {
|
|
|
124
124
|
column: number;
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
127
|
-
* Where the `${
|
|
127
|
+
* Where the `${...}` that drives this subtree was written, the condition of an `if=`,
|
|
128
128
|
* the list of an `each=`. The insert that adds and removes the subtree is a reactive
|
|
129
129
|
* binding, and this is the position it reports. Distinct from `at`, which marks the
|
|
130
130
|
* node itself rather than the binding that places it.
|
package/dist/ir/nodes.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ export interface IRComponent {
|
|
|
124
124
|
column: number;
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
127
|
-
* Where the `${
|
|
127
|
+
* Where the `${...}` that drives this subtree was written, the condition of an `if=`,
|
|
128
128
|
* the list of an `each=`. The insert that adds and removes the subtree is a reactive
|
|
129
129
|
* binding, and this is the position it reports. Distinct from `at`, which marks the
|
|
130
130
|
* node itself rather than the binding that places it.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/compiler v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.101 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1222,7 +1222,7 @@ var Lowerer = class {
|
|
|
1222
1222
|
for (const s of imports) this.used.add(s);
|
|
1223
1223
|
return inlineTemplates(code, templates);
|
|
1224
1224
|
}
|
|
1225
|
-
//
|
|
1225
|
+
// content
|
|
1226
1226
|
lowerRoot(children) {
|
|
1227
1227
|
const nodes = this.lowerChildren(children);
|
|
1228
1228
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -1351,8 +1351,8 @@ var Lowerer = class {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
return { slots, rest };
|
|
1353
1353
|
}
|
|
1354
|
-
//
|
|
1355
|
-
/** `<el if=${cond}
|
|
1354
|
+
// control-flow sugar
|
|
1355
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
1356
1356
|
lowerIf(el, condHole, elseEl) {
|
|
1357
1357
|
const cond = this.hole(condHole);
|
|
1358
1358
|
const props = [
|
|
@@ -1367,8 +1367,8 @@ var Lowerer = class {
|
|
|
1367
1367
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
1368
1368
|
}
|
|
1369
1369
|
/**
|
|
1370
|
-
* `<el each=${items} key?>${item =>
|
|
1371
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
1370
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
1371
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
1372
1372
|
* it is. Null when the element has no `each`.
|
|
1373
1373
|
*/
|
|
1374
1374
|
lowerEach(el) {
|
|
@@ -1405,7 +1405,7 @@ var Lowerer = class {
|
|
|
1405
1405
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
1406
1406
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1407
1407
|
}
|
|
1408
|
-
//
|
|
1408
|
+
// attributes
|
|
1409
1409
|
/**
|
|
1410
1410
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1411
1411
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -1546,7 +1546,7 @@ var Lowerer = class {
|
|
|
1546
1546
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
1547
1547
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
1548
1548
|
}
|
|
1549
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
1549
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
1550
1550
|
bindProps(prop, h) {
|
|
1551
1551
|
const sigCode = h.code;
|
|
1552
1552
|
const checked = prop === "checked";
|
|
@@ -1572,7 +1572,7 @@ var Lowerer = class {
|
|
|
1572
1572
|
}
|
|
1573
1573
|
];
|
|
1574
1574
|
}
|
|
1575
|
-
/** A plain attribute (incl.
|
|
1575
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
1576
1576
|
plainAttr(a) {
|
|
1577
1577
|
const v = a.value;
|
|
1578
1578
|
let name = a.name;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Finding templates in a module and describing each hole still needs a front-end;
|
|
8
8
|
* everything after that point is here. Passes run in the same order as
|
|
9
|
-
* `
|
|
9
|
+
* `emitHtmlViaIR`: compile-template.spec.ts compares the two.
|
|
10
10
|
*/
|
|
11
11
|
import { type TemplateStyles } from '../transform/styles.cjs';
|
|
12
12
|
import { type ComponentResolverRule } from '../resolve/component-resolver.cjs';
|
|
@@ -21,7 +21,7 @@ export interface TemplateSource {
|
|
|
21
21
|
* before the first `${`, between each pair, and after the last `}`.
|
|
22
22
|
*/
|
|
23
23
|
statics: readonly string[];
|
|
24
|
-
/** One descriptor per `${
|
|
24
|
+
/** One descriptor per `${...}`, in source order. */
|
|
25
25
|
holes: readonly TemplateHole[];
|
|
26
26
|
}
|
|
27
27
|
export interface CompileTemplateOptions {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Finding templates in a module and describing each hole still needs a front-end;
|
|
8
8
|
* everything after that point is here. Passes run in the same order as
|
|
9
|
-
* `
|
|
9
|
+
* `emitHtmlViaIR`: compile-template.spec.ts compares the two.
|
|
10
10
|
*/
|
|
11
11
|
import { type TemplateStyles } from '../transform/styles.js';
|
|
12
12
|
import { type ComponentResolverRule } from '../resolve/component-resolver.js';
|
|
@@ -21,7 +21,7 @@ export interface TemplateSource {
|
|
|
21
21
|
* before the first `${`, between each pair, and after the last `}`.
|
|
22
22
|
*/
|
|
23
23
|
statics: readonly string[];
|
|
24
|
-
/** One descriptor per `${
|
|
24
|
+
/** One descriptor per `${...}`, in source order. */
|
|
25
25
|
holes: readonly TemplateHole[];
|
|
26
26
|
}
|
|
27
27
|
export interface CompileTemplateOptions {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,oDAAoD;IACpD,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"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Finding templates in a module and describing each hole still needs a front-end;
|
|
8
8
|
* everything after that point is here. Passes run in the same order as
|
|
9
|
-
* `
|
|
9
|
+
* `emitHtmlViaIR`: compile-template.spec.ts compares the two.
|
|
10
10
|
*/
|
|
11
11
|
import { applyTemplateStyles } from '../transform/styles.js';
|
|
12
12
|
import { analyzeStatic } from '../optimize/analyze-static.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/compiler v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.101 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
4
4
|
var comma = ",".charCodeAt(0);
|
|
@@ -1210,7 +1210,7 @@ var Lowerer = class {
|
|
|
1210
1210
|
for (const s of imports) this.used.add(s);
|
|
1211
1211
|
return inlineTemplates(code, templates);
|
|
1212
1212
|
}
|
|
1213
|
-
//
|
|
1213
|
+
// content
|
|
1214
1214
|
lowerRoot(children) {
|
|
1215
1215
|
const nodes = this.lowerChildren(children);
|
|
1216
1216
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -1339,8 +1339,8 @@ var Lowerer = class {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
return { slots, rest };
|
|
1341
1341
|
}
|
|
1342
|
-
//
|
|
1343
|
-
/** `<el if=${cond}
|
|
1342
|
+
// control-flow sugar
|
|
1343
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
1344
1344
|
lowerIf(el, condHole, elseEl) {
|
|
1345
1345
|
const cond = this.hole(condHole);
|
|
1346
1346
|
const props = [
|
|
@@ -1355,8 +1355,8 @@ var Lowerer = class {
|
|
|
1355
1355
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
1356
1356
|
}
|
|
1357
1357
|
/**
|
|
1358
|
-
* `<el each=${items} key?>${item =>
|
|
1359
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
1358
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
1359
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
1360
1360
|
* it is. Null when the element has no `each`.
|
|
1361
1361
|
*/
|
|
1362
1362
|
lowerEach(el) {
|
|
@@ -1393,7 +1393,7 @@ var Lowerer = class {
|
|
|
1393
1393
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
1394
1394
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1395
1395
|
}
|
|
1396
|
-
//
|
|
1396
|
+
// attributes
|
|
1397
1397
|
/**
|
|
1398
1398
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1399
1399
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -1534,7 +1534,7 @@ var Lowerer = class {
|
|
|
1534
1534
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
1535
1535
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
1536
1536
|
}
|
|
1537
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
1537
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
1538
1538
|
bindProps(prop, h) {
|
|
1539
1539
|
const sigCode = h.code;
|
|
1540
1540
|
const checked = prop === "checked";
|
|
@@ -1560,7 +1560,7 @@ var Lowerer = class {
|
|
|
1560
1560
|
}
|
|
1561
1561
|
];
|
|
1562
1562
|
}
|
|
1563
|
-
/** A plain attribute (incl.
|
|
1563
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
1564
1564
|
plainAttr(a) {
|
|
1565
1565
|
const v = a.value;
|
|
1566
1566
|
let name = a.name;
|
package/dist/lower/jsx.js
CHANGED
|
@@ -183,7 +183,7 @@ function buildProps(attrs, ctx, element = false) {
|
|
|
183
183
|
(ns === 'class' ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
184
184
|
continue;
|
|
185
185
|
}
|
|
186
|
-
// style={{
|
|
186
|
+
// style={{ ... }}: one entry per property, so `--gap` moving does not rewrite `margin`.
|
|
187
187
|
if (element && a.name.type === 'JSXIdentifier' && a.name.name === 'style' && a.value?.type === 'JSXExpressionContainer') {
|
|
188
188
|
const entries = objectEntries(a.value.expression, ctx);
|
|
189
189
|
if (entries) {
|
|
@@ -321,7 +321,7 @@ function buildIf(node, fallback, ctx) {
|
|
|
321
321
|
return { kind: 'component', name: 'Show', props, children: [buildElement(node, ctx, ['if'])] };
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
|
-
* `<el each={items} key?>{(item) =>
|
|
324
|
+
* `<el each={items} key?>{(item) => ...}</el>` → `<el><For each by>{...}</For></el>`: the
|
|
325
325
|
* content repeats, the element does not. Null when there is no `each`.
|
|
326
326
|
*/
|
|
327
327
|
function buildEach(node, ctx) {
|
package/dist/lower/template.cjs
CHANGED
|
@@ -957,7 +957,7 @@ var Lowerer = class {
|
|
|
957
957
|
for (const s of imports) this.used.add(s);
|
|
958
958
|
return inlineTemplates(code, templates);
|
|
959
959
|
}
|
|
960
|
-
//
|
|
960
|
+
// content
|
|
961
961
|
lowerRoot(children) {
|
|
962
962
|
const nodes = this.lowerChildren(children);
|
|
963
963
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -1086,8 +1086,8 @@ var Lowerer = class {
|
|
|
1086
1086
|
}
|
|
1087
1087
|
return { slots, rest };
|
|
1088
1088
|
}
|
|
1089
|
-
//
|
|
1090
|
-
/** `<el if=${cond}
|
|
1089
|
+
// control-flow sugar
|
|
1090
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
1091
1091
|
lowerIf(el, condHole, elseEl) {
|
|
1092
1092
|
const cond = this.hole(condHole);
|
|
1093
1093
|
const props = [
|
|
@@ -1102,8 +1102,8 @@ var Lowerer = class {
|
|
|
1102
1102
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
1103
1103
|
}
|
|
1104
1104
|
/**
|
|
1105
|
-
* `<el each=${items} key?>${item =>
|
|
1106
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
1105
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
1106
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
1107
1107
|
* it is. Null when the element has no `each`.
|
|
1108
1108
|
*/
|
|
1109
1109
|
lowerEach(el) {
|
|
@@ -1140,7 +1140,7 @@ var Lowerer = class {
|
|
|
1140
1140
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
1141
1141
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1142
1142
|
}
|
|
1143
|
-
//
|
|
1143
|
+
// attributes
|
|
1144
1144
|
/**
|
|
1145
1145
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1146
1146
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -1281,7 +1281,7 @@ var Lowerer = class {
|
|
|
1281
1281
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
1282
1282
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
1283
1283
|
}
|
|
1284
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
1284
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
1285
1285
|
bindProps(prop, h) {
|
|
1286
1286
|
const sigCode = h.code;
|
|
1287
1287
|
const checked = prop === "checked";
|
|
@@ -1307,7 +1307,7 @@ var Lowerer = class {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
];
|
|
1309
1309
|
}
|
|
1310
|
-
/** A plain attribute (incl.
|
|
1310
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
1311
1311
|
plainAttr(a) {
|
|
1312
1312
|
const v = a.value;
|
|
1313
1313
|
let name = a.name;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lower a parsed Template AST (`@fluixi/template-parser`) into the host-agnostic IR.
|
|
3
3
|
*
|
|
4
|
-
* No parser in here: the `${
|
|
4
|
+
* No parser in here: the `${...}` holes arrive already described as `TemplateHole`,
|
|
5
5
|
* since reading them means reading JavaScript and that belongs to a front-end.
|
|
6
6
|
*
|
|
7
7
|
* Pipeline: pieces → parseTemplate → Template AST → lowerTemplate → IRNode
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { type Piece } from '@fluixi/template-parser';
|
|
10
10
|
import type { HolePosition, IRNode } from '../ir/nodes.cjs';
|
|
11
11
|
/**
|
|
12
|
-
* One `${
|
|
12
|
+
* One `${...}` slot, as the front-end describes it. Conclusions about the
|
|
13
13
|
* expression only: never a syntax tree, or the parser dependency creeps back.
|
|
14
14
|
*/
|
|
15
15
|
export interface TemplateHole {
|
|
@@ -18,7 +18,7 @@ export interface TemplateHole {
|
|
|
18
18
|
/** Whether it must be wired reactively (see analyze/reactive-expr.ts). */
|
|
19
19
|
reactive: boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Set when the hole is a single-expression arrow, `${item =>
|
|
21
|
+
* Set when the hole is a single-expression arrow, `${item => ...}`. `each` turns
|
|
22
22
|
* that into `For`'s render function, so it needs the parameters and the body
|
|
23
23
|
* separately rather than the arrow as written.
|
|
24
24
|
*/
|
|
@@ -27,10 +27,10 @@ export interface TemplateHole {
|
|
|
27
27
|
body: string;
|
|
28
28
|
bodyReactive: boolean;
|
|
29
29
|
};
|
|
30
|
-
/** Whether the hole is an object literal: `class=${{
|
|
30
|
+
/** Whether the hole is an object literal: `class=${{...}}` lowers to classList. */
|
|
31
31
|
object?: boolean;
|
|
32
32
|
/**
|
|
33
|
-
* Where the `${
|
|
33
|
+
* Where the `${...}` was written. Only kept when the host asked for source locations.
|
|
34
34
|
*
|
|
35
35
|
* A template is emitted as one overwrite, so every hole in it traces back through the
|
|
36
36
|
* source map to the line the template opens at. Without this, every node a template makes
|
|
@@ -40,7 +40,7 @@ export interface TemplateHole {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Lower a parsed template to IR. `pieces` are the static runs and hole slots as
|
|
43
|
-
* the parser wants them; `holes` describes each `${
|
|
43
|
+
* the parser wants them; `holes` describes each `${...}` in the same order. `used`
|
|
44
44
|
* collects the runtime symbols the emitted code imports.
|
|
45
45
|
*/
|
|
46
46
|
export declare function lowerTemplate(pieces: Piece[], holes: TemplateHole[], used: Set<string>, opts?: {
|
package/dist/lower/template.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lower a parsed Template AST (`@fluixi/template-parser`) into the host-agnostic IR.
|
|
3
3
|
*
|
|
4
|
-
* No parser in here: the `${
|
|
4
|
+
* No parser in here: the `${...}` holes arrive already described as `TemplateHole`,
|
|
5
5
|
* since reading them means reading JavaScript and that belongs to a front-end.
|
|
6
6
|
*
|
|
7
7
|
* Pipeline: pieces → parseTemplate → Template AST → lowerTemplate → IRNode
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { type Piece } from '@fluixi/template-parser';
|
|
10
10
|
import type { HolePosition, IRNode } from '../ir/nodes.js';
|
|
11
11
|
/**
|
|
12
|
-
* One `${
|
|
12
|
+
* One `${...}` slot, as the front-end describes it. Conclusions about the
|
|
13
13
|
* expression only: never a syntax tree, or the parser dependency creeps back.
|
|
14
14
|
*/
|
|
15
15
|
export interface TemplateHole {
|
|
@@ -18,7 +18,7 @@ export interface TemplateHole {
|
|
|
18
18
|
/** Whether it must be wired reactively (see analyze/reactive-expr.ts). */
|
|
19
19
|
reactive: boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Set when the hole is a single-expression arrow, `${item =>
|
|
21
|
+
* Set when the hole is a single-expression arrow, `${item => ...}`. `each` turns
|
|
22
22
|
* that into `For`'s render function, so it needs the parameters and the body
|
|
23
23
|
* separately rather than the arrow as written.
|
|
24
24
|
*/
|
|
@@ -27,10 +27,10 @@ export interface TemplateHole {
|
|
|
27
27
|
body: string;
|
|
28
28
|
bodyReactive: boolean;
|
|
29
29
|
};
|
|
30
|
-
/** Whether the hole is an object literal: `class=${{
|
|
30
|
+
/** Whether the hole is an object literal: `class=${{...}}` lowers to classList. */
|
|
31
31
|
object?: boolean;
|
|
32
32
|
/**
|
|
33
|
-
* Where the `${
|
|
33
|
+
* Where the `${...}` was written. Only kept when the host asked for source locations.
|
|
34
34
|
*
|
|
35
35
|
* A template is emitted as one overwrite, so every hole in it traces back through the
|
|
36
36
|
* source map to the line the template opens at. Without this, every node a template makes
|
|
@@ -40,7 +40,7 @@ export interface TemplateHole {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Lower a parsed template to IR. `pieces` are the static runs and hole slots as
|
|
43
|
-
* the parser wants them; `holes` describes each `${
|
|
43
|
+
* the parser wants them; `holes` describes each `${...}` in the same order. `used`
|
|
44
44
|
* collects the runtime symbols the emitted code imports.
|
|
45
45
|
*/
|
|
46
46
|
export declare function lowerTemplate(pieces: Piece[], holes: TemplateHole[], used: Set<string>, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/lower/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,KAAK,KAAK,EAGX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAQ/E;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/lower/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,KAAK,KAAK,EAGX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAQ/E;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,mFAAmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,YAAY,CAAC;CACnB;AAohBD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,KAAK,EAAE,EACf,KAAK,EAAE,YAAY,EAAE,EACrB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,GACnH,MAAM,CAGR"}
|
package/dist/lower/template.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lower a parsed Template AST (`@fluixi/template-parser`) into the host-agnostic IR.
|
|
3
3
|
*
|
|
4
|
-
* No parser in here: the `${
|
|
4
|
+
* No parser in here: the `${...}` holes arrive already described as `TemplateHole`,
|
|
5
5
|
* since reading them means reading JavaScript and that belongs to a front-end.
|
|
6
6
|
*
|
|
7
7
|
* Pipeline: pieces → parseTemplate → Template AST → lowerTemplate → IRNode
|
|
@@ -64,7 +64,7 @@ class Lowerer {
|
|
|
64
64
|
// `createTemplate` caches by HTML, so this is a lookup rather than a re-parse.
|
|
65
65
|
return inlineTemplates(code, templates);
|
|
66
66
|
}
|
|
67
|
-
//
|
|
67
|
+
// content
|
|
68
68
|
lowerRoot(children) {
|
|
69
69
|
const nodes = this.lowerChildren(children);
|
|
70
70
|
if (nodes.length === 1)
|
|
@@ -128,7 +128,7 @@ class Lowerer {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
lowerElement(el) {
|
|
131
|
-
// `<component is=${C}
|
|
131
|
+
// `<component is=${C} ...>...</component>` → `<Dynamic component=${C} ...>` (a
|
|
132
132
|
// reactive component swap). Dynamic reads `component` via normalizeAccessor,
|
|
133
133
|
// so it must be an ACCESSOR `() => C` (a bare function would be mis-called).
|
|
134
134
|
const isAttr = el.attributes.find((a) => a.kind === 'Attribute' && a.name === 'is');
|
|
@@ -157,7 +157,7 @@ class Lowerer {
|
|
|
157
157
|
}
|
|
158
158
|
lowerComponent(el) {
|
|
159
159
|
// `<${Comp} />`: the tag is an interpolated expression, use the hole's code
|
|
160
|
-
// as the component identity, so `createComponent(<expr>,
|
|
160
|
+
// as the component identity, so `createComponent(<expr>, ...)` is emitted.
|
|
161
161
|
const name = el.tagHole != null ? this.hole(el.tagHole).code : el.tag;
|
|
162
162
|
const props = this.lowerAttributes(el.attributes);
|
|
163
163
|
// Named slots: a child with `slot="header"` becomes `props.header` (a lazy
|
|
@@ -190,7 +190,7 @@ class Lowerer {
|
|
|
190
190
|
: undefined;
|
|
191
191
|
// The parser's positions are relative to the template string, not the file, so the
|
|
192
192
|
// tag itself has none to give. The first hole is the closest thing that does, and for
|
|
193
|
-
// the control-flow components: `<Show when=${
|
|
193
|
+
// the control-flow components: `<Show when=${...}>`, `<For each=${...}>`, it is the
|
|
194
194
|
// expression driving the subtree anyway.
|
|
195
195
|
// A reactive one: a literal carries a position too now, and it drives nothing.
|
|
196
196
|
const bindAt = props.find((p) => p.at && p.reactive)?.at;
|
|
@@ -225,8 +225,8 @@ class Lowerer {
|
|
|
225
225
|
}
|
|
226
226
|
return { slots, rest };
|
|
227
227
|
}
|
|
228
|
-
//
|
|
229
|
-
/** `<el if=${cond}
|
|
228
|
+
// control-flow sugar
|
|
229
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
230
230
|
lowerIf(el, condHole, elseEl) {
|
|
231
231
|
const cond = this.hole(condHole);
|
|
232
232
|
const props = [
|
|
@@ -241,8 +241,8 @@ class Lowerer {
|
|
|
241
241
|
return { kind: 'component', name: 'Show', props, children: [child], ...(at ? { at } : {}), ...(cond.at ? { bindAt: cond.at } : {}) };
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
|
-
* `<el each=${items} key?>${item =>
|
|
245
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
244
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
245
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
246
246
|
* it is. Null when the element has no `each`.
|
|
247
247
|
*/
|
|
248
248
|
lowerEach(el) {
|
|
@@ -288,7 +288,7 @@ class Lowerer {
|
|
|
288
288
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
289
289
|
return clone.kind === 'Element' ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
290
290
|
}
|
|
291
|
-
//
|
|
291
|
+
// attributes
|
|
292
292
|
/**
|
|
293
293
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
294
294
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -387,7 +387,7 @@ class Lowerer {
|
|
|
387
387
|
// Each entry that moves is its own accessor, so the runtime updates that key alone.
|
|
388
388
|
if (styleEntries.length > 0) {
|
|
389
389
|
const entries = `{ ${styleEntries.join(', ')} }`;
|
|
390
|
-
// `style=${
|
|
390
|
+
// `style=${...}` as well: it goes first, the keys after it, applied in order.
|
|
391
391
|
const base = props.findIndex((p) => p.name === 'style');
|
|
392
392
|
if (base === -1)
|
|
393
393
|
props.push({ name: 'style', kind: 'attr', expr: entries, reactive: !element && anyReactive, ...(styleAt ? { at: styleAt } : {}) });
|
|
@@ -449,7 +449,7 @@ class Lowerer {
|
|
|
449
449
|
opts.push('passive: true');
|
|
450
450
|
return opts.length ? `{ ${opts.join(', ')} }` : null;
|
|
451
451
|
}
|
|
452
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
452
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
453
453
|
bindProps(prop, h) {
|
|
454
454
|
const sigCode = h.code;
|
|
455
455
|
const checked = prop === 'checked';
|
|
@@ -479,7 +479,7 @@ class Lowerer {
|
|
|
479
479
|
},
|
|
480
480
|
];
|
|
481
481
|
}
|
|
482
|
-
/** A plain attribute (incl.
|
|
482
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
483
483
|
plainAttr(a) {
|
|
484
484
|
const v = a.value;
|
|
485
485
|
// `class=${{...}}` (object literal) -> classList (Solid convention), so it
|
|
@@ -533,7 +533,7 @@ class Lowerer {
|
|
|
533
533
|
}
|
|
534
534
|
/**
|
|
535
535
|
* Lower a parsed template to IR. `pieces` are the static runs and hole slots as
|
|
536
|
-
* the parser wants them; `holes` describes each `${
|
|
536
|
+
* the parser wants them; `holes` describes each `${...}` in the same order. `used`
|
|
537
537
|
* collects the runtime symbols the emitted code imports.
|
|
538
538
|
*/
|
|
539
539
|
export function lowerTemplate(pieces, holes, used, opts = {}) {
|
package/dist/lower/template.mjs
CHANGED
|
@@ -935,7 +935,7 @@ var Lowerer = class {
|
|
|
935
935
|
for (const s of imports) this.used.add(s);
|
|
936
936
|
return inlineTemplates(code, templates);
|
|
937
937
|
}
|
|
938
|
-
//
|
|
938
|
+
// content
|
|
939
939
|
lowerRoot(children) {
|
|
940
940
|
const nodes = this.lowerChildren(children);
|
|
941
941
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -1064,8 +1064,8 @@ var Lowerer = class {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
return { slots, rest };
|
|
1066
1066
|
}
|
|
1067
|
-
//
|
|
1068
|
-
/** `<el if=${cond}
|
|
1067
|
+
// control-flow sugar
|
|
1068
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
1069
1069
|
lowerIf(el, condHole, elseEl) {
|
|
1070
1070
|
const cond = this.hole(condHole);
|
|
1071
1071
|
const props = [
|
|
@@ -1080,8 +1080,8 @@ var Lowerer = class {
|
|
|
1080
1080
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
1081
1081
|
}
|
|
1082
1082
|
/**
|
|
1083
|
-
* `<el each=${items} key?>${item =>
|
|
1084
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
1083
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
1084
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
1085
1085
|
* it is. Null when the element has no `each`.
|
|
1086
1086
|
*/
|
|
1087
1087
|
lowerEach(el) {
|
|
@@ -1118,7 +1118,7 @@ var Lowerer = class {
|
|
|
1118
1118
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
1119
1119
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
1120
1120
|
}
|
|
1121
|
-
//
|
|
1121
|
+
// attributes
|
|
1122
1122
|
/**
|
|
1123
1123
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
1124
1124
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -1259,7 +1259,7 @@ var Lowerer = class {
|
|
|
1259
1259
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
1260
1260
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
1261
1261
|
}
|
|
1262
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
1262
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
1263
1263
|
bindProps(prop, h) {
|
|
1264
1264
|
const sigCode = h.code;
|
|
1265
1265
|
const checked = prop === "checked";
|
|
@@ -1285,7 +1285,7 @@ var Lowerer = class {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
];
|
|
1287
1287
|
}
|
|
1288
|
-
/** A plain attribute (incl.
|
|
1288
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
1289
1289
|
plainAttr(a) {
|
|
1290
1290
|
const v = a.value;
|
|
1291
1291
|
let name = a.name;
|