@fluixi/compiler 1.0.0-alpha.100 → 1.0.0-alpha.102
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-WBQWG5BI.mjs} +23 -23
- package/dist/{chunk-C3XPDB4Y.mjs → chunk-AOKTQGX3.mjs} +1 -1
- package/dist/{chunk-HXEXPWJ2.mjs → chunk-EEUWXI5C.mjs} +2 -2
- package/dist/{chunk-3AICWNF7.mjs → chunk-HUWJHS6T.mjs} +1 -1
- package/dist/{chunk-NU3W67UZ.mjs → chunk-KGXFUVHJ.mjs} +2 -2
- package/dist/{chunk-GX5XV6Z7.mjs → chunk-MASWFMPJ.mjs} +1 -1
- package/dist/{chunk-SKAVY75W.mjs → chunk-TFGOAGRI.mjs} +1 -1
- package/dist/{chunk-6CWJWGE2.mjs → chunk-WUV5ZIYZ.mjs} +10 -10
- 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-I6FKYS22.mjs} +5 -5
- package/dist/{server-functions-UAZKOLZW.mjs → server-functions-MATGYTBX.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-AP5PSRT7.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/transform/styles.js
CHANGED
|
@@ -110,7 +110,7 @@ module) {
|
|
|
110
110
|
}
|
|
111
111
|
const scopeOf = new Map();
|
|
112
112
|
const names = new Map();
|
|
113
|
-
// `const Card = () =>
|
|
113
|
+
// `const Card = () => ...`: the component's name is the variable's.
|
|
114
114
|
const named = new Map();
|
|
115
115
|
const visit = (node, owners) => {
|
|
116
116
|
if (!node || typeof node !== 'object')
|
|
@@ -257,7 +257,7 @@ function staticMember(cls, name) {
|
|
|
257
257
|
/**
|
|
258
258
|
* Where a component's style blocks and css`` values are served: next to the component, a path
|
|
259
259
|
* ending in `.css`. Every CSS tool in the bundler then sees CSS, and none sees TSX: Vite 8
|
|
260
|
-
* matches its transforms on the path without the query, so `card.tsx
|
|
260
|
+
* matches its transforms on the path without the query, so `card.tsx?...` would read as a .tsx.
|
|
261
261
|
* `?inline` (Vite's own) asks for the CSS as a string, for a shadow root.
|
|
262
262
|
*/
|
|
263
263
|
export const styleIds = {
|
|
@@ -341,7 +341,7 @@ function isScoped(node) {
|
|
|
341
341
|
/** The block's template pieces, a string counting as one piece; `null` when it is anything else. */
|
|
342
342
|
/**
|
|
343
343
|
* The `<style>` blocks of an html`` template, as pieces of its quasis: the CSS between the
|
|
344
|
-
* tags, with the `${
|
|
344
|
+
* tags, with the `${...}` that stand in it. Each piece keeps the position it starts at.
|
|
345
345
|
*/
|
|
346
346
|
function templateBlocks(quasi) {
|
|
347
347
|
const blocks = [];
|
|
@@ -479,7 +479,7 @@ export function hash(text) {
|
|
|
479
479
|
}
|
|
480
480
|
return (h >>> 0).toString(36);
|
|
481
481
|
}
|
|
482
|
-
//
|
|
482
|
+
// Scoping
|
|
483
483
|
// Selectors of these at-rules are not element selectors (`from`, `50%`) or there are none.
|
|
484
484
|
const OPAQUE = /(^|-)keyframes$|^font-face$|^property$|^counter-style$|^page$|^font-feature-values$/;
|
|
485
485
|
/** Adds the scope to every selector, through grouping at-rules; keyframes and the like are left. */
|
|
@@ -640,7 +640,7 @@ function splitTop(selector, separator) {
|
|
|
640
640
|
parts.push(selector.slice(start));
|
|
641
641
|
return parts.filter((p) => p.trim());
|
|
642
642
|
}
|
|
643
|
-
//
|
|
643
|
+
// Printing
|
|
644
644
|
function shiftLoc(node, source, start) {
|
|
645
645
|
const loc = node.loc && node.loc.source === source
|
|
646
646
|
? { source, line: start.line + node.loc.line - 1, column: node.loc.line === 1 ? start.column + node.loc.column : node.loc.column }
|
|
@@ -2147,7 +2147,7 @@ var Lowerer = class {
|
|
|
2147
2147
|
for (const s of imports) this.used.add(s);
|
|
2148
2148
|
return inlineTemplates(code, templates);
|
|
2149
2149
|
}
|
|
2150
|
-
//
|
|
2150
|
+
// content
|
|
2151
2151
|
lowerRoot(children) {
|
|
2152
2152
|
const nodes = this.lowerChildren(children);
|
|
2153
2153
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -2276,8 +2276,8 @@ var Lowerer = class {
|
|
|
2276
2276
|
}
|
|
2277
2277
|
return { slots, rest };
|
|
2278
2278
|
}
|
|
2279
|
-
//
|
|
2280
|
-
/** `<el if=${cond}
|
|
2279
|
+
// control-flow sugar
|
|
2280
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
2281
2281
|
lowerIf(el, condHole, elseEl) {
|
|
2282
2282
|
const cond = this.hole(condHole);
|
|
2283
2283
|
const props = [
|
|
@@ -2292,8 +2292,8 @@ var Lowerer = class {
|
|
|
2292
2292
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
2293
2293
|
}
|
|
2294
2294
|
/**
|
|
2295
|
-
* `<el each=${items} key?>${item =>
|
|
2296
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
2295
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
2296
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
2297
2297
|
* it is. Null when the element has no `each`.
|
|
2298
2298
|
*/
|
|
2299
2299
|
lowerEach(el) {
|
|
@@ -2330,7 +2330,7 @@ var Lowerer = class {
|
|
|
2330
2330
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
2331
2331
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
2332
2332
|
}
|
|
2333
|
-
//
|
|
2333
|
+
// attributes
|
|
2334
2334
|
/**
|
|
2335
2335
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
2336
2336
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -2471,7 +2471,7 @@ var Lowerer = class {
|
|
|
2471
2471
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
2472
2472
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
2473
2473
|
}
|
|
2474
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
2474
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
2475
2475
|
bindProps(prop, h) {
|
|
2476
2476
|
const sigCode = h.code;
|
|
2477
2477
|
const checked = prop === "checked";
|
|
@@ -2497,7 +2497,7 @@ var Lowerer = class {
|
|
|
2497
2497
|
}
|
|
2498
2498
|
];
|
|
2499
2499
|
}
|
|
2500
|
-
/** A plain attribute (incl.
|
|
2500
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
2501
2501
|
plainAttr(a) {
|
|
2502
2502
|
const v = a.value;
|
|
2503
2503
|
let name = a.name;
|
|
@@ -3452,7 +3452,7 @@ function outermost(list) {
|
|
|
3452
3452
|
(e) => !list.some(
|
|
3453
3453
|
(o) => o !== e && o.start <= e.start && o.end >= e.end && o.end - o.start > e.end - e.start && // An insertion at either edge of the container sits beside it, not inside it, so
|
|
3454
3454
|
// it is not something the container's code already folded in. A statement can
|
|
3455
|
-
// start where its callee starts (`$effect(
|
|
3455
|
+
// start where its callee starts (`$effect(...)`) and a declarator can end where its
|
|
3456
3456
|
// JSX ends (`const Row = () => <b/>`).
|
|
3457
3457
|
!(e.start === e.end && (e.start === o.start || e.start === o.end))
|
|
3458
3458
|
)
|
|
@@ -3469,7 +3469,7 @@ function bindHole(code, expr, edits, keepPosition = false) {
|
|
|
3469
3469
|
const hole = {
|
|
3470
3470
|
code: slice(code, expr.start, expr.end, edits),
|
|
3471
3471
|
reactive: isReactiveShape(shapeOf(expr)),
|
|
3472
|
-
// Where the `${
|
|
3472
|
+
// Where the `${...}` is, so a binding made from it can say so. The source map cannot:
|
|
3473
3473
|
// the whole template is one overwrite. Only when source locations were asked for.
|
|
3474
3474
|
...at ? { at: { line: at.line, column: at.column } } : {}
|
|
3475
3475
|
};
|
|
@@ -3585,11 +3585,11 @@ function relativeToRoot(id, root) {
|
|
|
3585
3585
|
return id.startsWith(base) ? id.slice(base.length) : id;
|
|
3586
3586
|
}
|
|
3587
3587
|
function transformTemplates(code, id, options = {}) {
|
|
3588
|
-
const
|
|
3588
|
+
const htmlTag = options.htmlTag ?? "html";
|
|
3589
3589
|
const format = options.format ?? "both";
|
|
3590
|
-
const
|
|
3591
|
-
const wantsJsx = format !== "
|
|
3592
|
-
const mayHaveTemplate =
|
|
3590
|
+
const wantsHtml = format !== "jsx";
|
|
3591
|
+
const wantsJsx = format !== "html";
|
|
3592
|
+
const mayHaveTemplate = wantsHtml && (code.includes(`${htmlTag}\``) || code.includes("svg`"));
|
|
3593
3593
|
const wantsIntrinsics = options.intrinsics !== false && mayHaveIntrinsic(code);
|
|
3594
3594
|
const wantsSources = options.sourceLocations === true && mayHaveSourceMarks(code);
|
|
3595
3595
|
const sourceName = relativeToRoot(id, options.sourceRoot);
|
|
@@ -3601,12 +3601,12 @@ function transformTemplates(code, id, options = {}) {
|
|
|
3601
3601
|
errorRecovery: true
|
|
3602
3602
|
});
|
|
3603
3603
|
const intrinsicTags = options.intrinsics === false ? /* @__PURE__ */ new Map() : tagIntrinsics(moduleBindings(ast.program));
|
|
3604
|
-
const templateTags = /* @__PURE__ */ new Map([[
|
|
3604
|
+
const templateTags = /* @__PURE__ */ new Map([[htmlTag, "html"], ["svg", "svg"]]);
|
|
3605
3605
|
for (const [name, tag] of intrinsicTags) if (tag !== "css") templateTags.set(name, tag);
|
|
3606
3606
|
const cssTags = [...intrinsicTags].filter(([, tag]) => tag === "css").map(([name]) => name);
|
|
3607
3607
|
const found = [];
|
|
3608
3608
|
walk7(ast.program, (n, parent, key) => {
|
|
3609
|
-
if (
|
|
3609
|
+
if (wantsHtml && isTemplateTag(n, templateTags)) found.push(n);
|
|
3610
3610
|
else if (wantsJsx && isJsxRoot(n, parent, key)) found.push(n);
|
|
3611
3611
|
});
|
|
3612
3612
|
const props = options.propsDestructure === false ? { edits: [], diagnostics: [], used: /* @__PURE__ */ new Set() } : collectPropsEdits(ast.program, code, { runtimeModule: options.runtimeModule });
|
|
@@ -10,9 +10,9 @@ export interface TransformOptions extends CompileTemplateOptions {
|
|
|
10
10
|
* about which source forms are touched, not about output.
|
|
11
11
|
* @default 'both'
|
|
12
12
|
*/
|
|
13
|
-
format?: 'jsx' | '
|
|
13
|
+
format?: 'jsx' | 'html' | 'both';
|
|
14
14
|
/** Tag marking a template for compilation. @default 'html' */
|
|
15
|
-
|
|
15
|
+
htmlTag?: string;
|
|
16
16
|
/** Module the emitted runtime symbols are imported from. @default '@fluixi/dom' */
|
|
17
17
|
runtimeModule?: string;
|
|
18
18
|
/** Where reactive primitives come from. @default '@fluixi/reactive/signal' */
|
|
@@ -10,9 +10,9 @@ export interface TransformOptions extends CompileTemplateOptions {
|
|
|
10
10
|
* about which source forms are touched, not about output.
|
|
11
11
|
* @default 'both'
|
|
12
12
|
*/
|
|
13
|
-
format?: 'jsx' | '
|
|
13
|
+
format?: 'jsx' | 'html' | 'both';
|
|
14
14
|
/** Tag marking a template for compilation. @default 'html' */
|
|
15
|
-
|
|
15
|
+
htmlTag?: string;
|
|
16
16
|
/** Module the emitted runtime symbols are imported from. @default '@fluixi/dom' */
|
|
17
17
|
runtimeModule?: string;
|
|
18
18
|
/** Where reactive primitives come from. @default '@fluixi/reactive/signal' */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/transform/templates.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG1F,OAAO,KAAK,EAAqB,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAWhF,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAgE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzH,OAAO,EAAqC,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAkB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAmBrL,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;IAC9D;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/transform/templates.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG1F,OAAO,KAAK,EAAqB,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAWhF,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAgE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzH,OAAO,EAAqC,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAkB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAmBrL,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;IAC9D;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,8DAA8D;IAC9D,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC/C,+FAA+F;IAC/F,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,6FAA6F;IAC7F,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,8EAA8E;IAC9E,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAoTD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,gBAAqB,GAC7B,eAAe,GAAG,IAAI,CAuPxB"}
|
|
@@ -79,7 +79,7 @@ function outermost(list) {
|
|
|
79
79
|
o.end - o.start > e.end - e.start &&
|
|
80
80
|
// An insertion at either edge of the container sits beside it, not inside it, so
|
|
81
81
|
// it is not something the container's code already folded in. A statement can
|
|
82
|
-
// start where its callee starts (`$effect(
|
|
82
|
+
// start where its callee starts (`$effect(...)`) and a declarator can end where its
|
|
83
83
|
// JSX ends (`const Row = () => <b/>`).
|
|
84
84
|
!(e.start === e.end && (e.start === o.start || e.start === o.end))));
|
|
85
85
|
}
|
|
@@ -98,13 +98,13 @@ function slice(code, start, end, edits) {
|
|
|
98
98
|
out = out.slice(0, e.start - start) + e.code + out.slice(e.end - start);
|
|
99
99
|
return out;
|
|
100
100
|
}
|
|
101
|
-
/** Describe one `${
|
|
101
|
+
/** Describe one `${...}` for the lowering, substituting any template already compiled inside it. */
|
|
102
102
|
function bindHole(code, expr, edits, keepPosition = false) {
|
|
103
103
|
const at = keepPosition ? expr.loc?.start : undefined;
|
|
104
104
|
const hole = {
|
|
105
105
|
code: slice(code, expr.start, expr.end, edits),
|
|
106
106
|
reactive: isReactiveShape(shapeOf(expr)),
|
|
107
|
-
// Where the `${
|
|
107
|
+
// Where the `${...}` is, so a binding made from it can say so. The source map cannot:
|
|
108
108
|
// the whole template is one overwrite. Only when source locations were asked for.
|
|
109
109
|
...(at ? { at: { line: at.line, column: at.column } } : {}),
|
|
110
110
|
};
|
|
@@ -292,11 +292,11 @@ function relativeToRoot(id, root) {
|
|
|
292
292
|
return id.startsWith(base) ? id.slice(base.length) : id;
|
|
293
293
|
}
|
|
294
294
|
export function transformTemplates(code, id, options = {}) {
|
|
295
|
-
const
|
|
295
|
+
const htmlTag = options.htmlTag ?? 'html';
|
|
296
296
|
const format = options.format ?? 'both';
|
|
297
|
-
const
|
|
298
|
-
const wantsJsx = format !== '
|
|
299
|
-
const mayHaveTemplate =
|
|
297
|
+
const wantsHtml = format !== 'jsx';
|
|
298
|
+
const wantsJsx = format !== 'html';
|
|
299
|
+
const mayHaveTemplate = wantsHtml && (code.includes(`${htmlTag}\``) || code.includes('svg`'));
|
|
300
300
|
// A module can be nothing but `$signal` calls, so the skip check has to look for those
|
|
301
301
|
// too or the file is never parsed.
|
|
302
302
|
const wantsIntrinsics = options.intrinsics !== false && mayHaveIntrinsic(code);
|
|
@@ -317,14 +317,14 @@ export function transformTemplates(code, id, options = {}) {
|
|
|
317
317
|
});
|
|
318
318
|
// `html`, `svg`, and in an app `$html`/`$svg`/`$css`, which need no import.
|
|
319
319
|
const intrinsicTags = options.intrinsics === false ? new Map() : tagIntrinsics(moduleBindings(ast.program));
|
|
320
|
-
const templateTags = new Map([[
|
|
320
|
+
const templateTags = new Map([[htmlTag, 'html'], ['svg', 'svg']]);
|
|
321
321
|
for (const [name, tag] of intrinsicTags)
|
|
322
322
|
if (tag !== 'css')
|
|
323
323
|
templateTags.set(name, tag);
|
|
324
324
|
const cssTags = [...intrinsicTags].filter(([, tag]) => tag === 'css').map(([name]) => name);
|
|
325
325
|
const found = [];
|
|
326
326
|
walk(ast.program, (n, parent, key) => {
|
|
327
|
-
if (
|
|
327
|
+
if (wantsHtml && isTemplateTag(n, templateTags))
|
|
328
328
|
found.push(n);
|
|
329
329
|
else if (wantsJsx && isJsxRoot(n, parent, key))
|
|
330
330
|
found.push(n);
|
|
@@ -334,7 +334,7 @@ export function transformTemplates(code, id, options = {}) {
|
|
|
334
334
|
const props = options.propsDestructure === false
|
|
335
335
|
? { edits: [], diagnostics: [], used: new Set() }
|
|
336
336
|
: collectPropsEdits(ast.program, code, { runtimeModule: options.runtimeModule });
|
|
337
|
-
// `$signal(
|
|
337
|
+
// `$signal(...)` → `createSignal(...)`. Same edit list, so the callee is already rewritten
|
|
338
338
|
// by the time a template slices a hole containing one.
|
|
339
339
|
const intrinsics = options.intrinsics === false
|
|
340
340
|
? { edits: [], diagnostics: [], imports: new Map() }
|
|
@@ -3191,7 +3191,7 @@ var Lowerer = class {
|
|
|
3191
3191
|
for (const s of imports) this.used.add(s);
|
|
3192
3192
|
return inlineTemplates(code, templates);
|
|
3193
3193
|
}
|
|
3194
|
-
//
|
|
3194
|
+
// content
|
|
3195
3195
|
lowerRoot(children) {
|
|
3196
3196
|
const nodes = this.lowerChildren(children);
|
|
3197
3197
|
if (nodes.length === 1) return nodes[0];
|
|
@@ -3320,8 +3320,8 @@ var Lowerer = class {
|
|
|
3320
3320
|
}
|
|
3321
3321
|
return { slots, rest };
|
|
3322
3322
|
}
|
|
3323
|
-
//
|
|
3324
|
-
/** `<el if=${cond}
|
|
3323
|
+
// control-flow sugar
|
|
3324
|
+
/** `<el if=${cond}>...</el>` (+ optional `<el else>`) → `<Show when fallback>`. */
|
|
3325
3325
|
lowerIf(el, condHole, elseEl) {
|
|
3326
3326
|
const cond = this.hole(condHole);
|
|
3327
3327
|
const props = [
|
|
@@ -3336,8 +3336,8 @@ var Lowerer = class {
|
|
|
3336
3336
|
return { kind: "component", name: "Show", props, children: [child], ...at ? { at } : {}, ...cond.at ? { bindAt: cond.at } : {} };
|
|
3337
3337
|
}
|
|
3338
3338
|
/**
|
|
3339
|
-
* `<el each=${items} key?>${item =>
|
|
3340
|
-
* content is repeated per item. Content that is not a `${item =>
|
|
3339
|
+
* `<el each=${items} key?>${item => ...}</el>` → `<el><For each>{item => ...}</For></el>`: the
|
|
3340
|
+
* content is repeated per item. Content that is not a `${item => ...}` arrow is repeated as
|
|
3341
3341
|
* it is. Null when the element has no `each`.
|
|
3342
3342
|
*/
|
|
3343
3343
|
lowerEach(el) {
|
|
@@ -3374,7 +3374,7 @@ var Lowerer = class {
|
|
|
3374
3374
|
const clone = { ...el, attributes: el.attributes.filter((a) => !drop(a)) };
|
|
3375
3375
|
return clone.kind === "Element" ? this.lowerElement(clone) : this.lowerComponent(clone);
|
|
3376
3376
|
}
|
|
3377
|
-
//
|
|
3377
|
+
// attributes
|
|
3378
3378
|
/**
|
|
3379
3379
|
* `element`: a DOM element, where each class:/style: value that moves is its own accessor.
|
|
3380
3380
|
* A component gets the object as before, rebuilt whole when any value moves.
|
|
@@ -3515,7 +3515,7 @@ var Lowerer = class {
|
|
|
3515
3515
|
if (mods.includes("passive")) opts.push("passive: true");
|
|
3516
3516
|
return opts.length ? `{ ${opts.join(", ")} }` : null;
|
|
3517
3517
|
}
|
|
3518
|
-
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e
|
|
3518
|
+
/** `bind:value=${sig}` → `value={read()}` + `onInput={e => write(e...value)}`. */
|
|
3519
3519
|
bindProps(prop, h) {
|
|
3520
3520
|
const sigCode = h.code;
|
|
3521
3521
|
const checked = prop === "checked";
|
|
@@ -3541,7 +3541,7 @@ var Lowerer = class {
|
|
|
3541
3541
|
}
|
|
3542
3542
|
];
|
|
3543
3543
|
}
|
|
3544
|
-
/** A plain attribute (incl.
|
|
3544
|
+
/** A plain attribute (incl. html `?bool`, mixed values), old `mkProp` behavior. */
|
|
3545
3545
|
plainAttr(a) {
|
|
3546
3546
|
const v = a.value;
|
|
3547
3547
|
let name = a.name;
|
|
@@ -4495,7 +4495,7 @@ function outermost(list) {
|
|
|
4495
4495
|
(e) => !list.some(
|
|
4496
4496
|
(o) => o !== e && o.start <= e.start && o.end >= e.end && o.end - o.start > e.end - e.start && // An insertion at either edge of the container sits beside it, not inside it, so
|
|
4497
4497
|
// it is not something the container's code already folded in. A statement can
|
|
4498
|
-
// start where its callee starts (`$effect(
|
|
4498
|
+
// start where its callee starts (`$effect(...)`) and a declarator can end where its
|
|
4499
4499
|
// JSX ends (`const Row = () => <b/>`).
|
|
4500
4500
|
!(e.start === e.end && (e.start === o.start || e.start === o.end))
|
|
4501
4501
|
)
|
|
@@ -4512,7 +4512,7 @@ function bindHole(code, expr, edits, keepPosition = false) {
|
|
|
4512
4512
|
const hole = {
|
|
4513
4513
|
code: slice(code, expr.start, expr.end, edits),
|
|
4514
4514
|
reactive: isReactiveShape(shapeOf(expr)),
|
|
4515
|
-
// Where the `${
|
|
4515
|
+
// Where the `${...}` is, so a binding made from it can say so. The source map cannot:
|
|
4516
4516
|
// the whole template is one overwrite. Only when source locations were asked for.
|
|
4517
4517
|
...at ? { at: { line: at.line, column: at.column } } : {}
|
|
4518
4518
|
};
|
|
@@ -4628,11 +4628,11 @@ function relativeToRoot(id, root) {
|
|
|
4628
4628
|
return id.startsWith(base) ? id.slice(base.length) : id;
|
|
4629
4629
|
}
|
|
4630
4630
|
function transformTemplates(code, id, options = {}) {
|
|
4631
|
-
const
|
|
4631
|
+
const htmlTag = options.htmlTag ?? "html";
|
|
4632
4632
|
const format = options.format ?? "both";
|
|
4633
|
-
const
|
|
4634
|
-
const wantsJsx = format !== "
|
|
4635
|
-
const mayHaveTemplate =
|
|
4633
|
+
const wantsHtml = format !== "jsx";
|
|
4634
|
+
const wantsJsx = format !== "html";
|
|
4635
|
+
const mayHaveTemplate = wantsHtml && (code.includes(`${htmlTag}\``) || code.includes("svg`"));
|
|
4636
4636
|
const wantsIntrinsics = options.intrinsics !== false && mayHaveIntrinsic(code);
|
|
4637
4637
|
const wantsSources = options.sourceLocations === true && mayHaveSourceMarks(code);
|
|
4638
4638
|
const sourceName = relativeToRoot(id, options.sourceRoot);
|
|
@@ -4644,12 +4644,12 @@ function transformTemplates(code, id, options = {}) {
|
|
|
4644
4644
|
errorRecovery: true
|
|
4645
4645
|
});
|
|
4646
4646
|
const intrinsicTags = options.intrinsics === false ? /* @__PURE__ */ new Map() : tagIntrinsics(moduleBindings(ast.program));
|
|
4647
|
-
const templateTags = /* @__PURE__ */ new Map([[
|
|
4647
|
+
const templateTags = /* @__PURE__ */ new Map([[htmlTag, "html"], ["svg", "svg"]]);
|
|
4648
4648
|
for (const [name, tag] of intrinsicTags) if (tag !== "css") templateTags.set(name, tag);
|
|
4649
4649
|
const cssTags = [...intrinsicTags].filter(([, tag]) => tag === "css").map(([name]) => name);
|
|
4650
4650
|
const found = [];
|
|
4651
4651
|
walk7(ast.program, (n2, parent, key) => {
|
|
4652
|
-
if (
|
|
4652
|
+
if (wantsHtml && isTemplateTag(n2, templateTags)) found.push(n2);
|
|
4653
4653
|
else if (wantsJsx && isJsxRoot(n2, parent, key)) found.push(n2);
|
|
4654
4654
|
});
|
|
4655
4655
|
const props = options.propsDestructure === false ? { edits: [], diagnostics: [], used: /* @__PURE__ */ new Set() } : collectPropsEdits(ast.program, code, { runtimeModule: options.runtimeModule });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @fluixi/compiler v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.102 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
import {
|
|
3
3
|
applyTemplateStyles,
|
|
4
4
|
collectStyles,
|
|
5
5
|
finishShadowStyles
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KGXFUVHJ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
analyzeStatic,
|
|
9
9
|
buildJsxIR,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveComponentSources,
|
|
20
20
|
resolveReactiveBindings,
|
|
21
21
|
shapeOf
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-WUV5ZIYZ.mjs";
|
|
23
23
|
import {
|
|
24
24
|
CORE_CONTROL_FLOW,
|
|
25
25
|
DOM_CONTROL_FLOW,
|
|
@@ -29,12 +29,12 @@ import {
|
|
|
29
29
|
isIntrinsicName,
|
|
30
30
|
mayHaveIntrinsic,
|
|
31
31
|
tagIntrinsics
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-MASWFMPJ.mjs";
|
|
33
33
|
import {
|
|
34
34
|
MagicString
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
37
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-EEUWXI5C.mjs";
|
|
36
|
+
import "./chunk-HUWJHS6T.mjs";
|
|
37
|
+
import "./chunk-TFGOAGRI.mjs";
|
|
38
38
|
|
|
39
39
|
// src/transform/templates.ts
|
|
40
40
|
import { parse as parse2 } from "@babel/parser";
|
|
@@ -589,7 +589,7 @@ function outermost(list) {
|
|
|
589
589
|
(e) => !list.some(
|
|
590
590
|
(o) => o !== e && o.start <= e.start && o.end >= e.end && o.end - o.start > e.end - e.start && // An insertion at either edge of the container sits beside it, not inside it, so
|
|
591
591
|
// it is not something the container's code already folded in. A statement can
|
|
592
|
-
// start where its callee starts (`$effect(
|
|
592
|
+
// start where its callee starts (`$effect(...)`) and a declarator can end where its
|
|
593
593
|
// JSX ends (`const Row = () => <b/>`).
|
|
594
594
|
!(e.start === e.end && (e.start === o.start || e.start === o.end))
|
|
595
595
|
)
|
|
@@ -606,7 +606,7 @@ function bindHole(code, expr, edits, keepPosition = false) {
|
|
|
606
606
|
const hole = {
|
|
607
607
|
code: slice(code, expr.start, expr.end, edits),
|
|
608
608
|
reactive: isReactiveShape(shapeOf(expr)),
|
|
609
|
-
// Where the `${
|
|
609
|
+
// Where the `${...}` is, so a binding made from it can say so. The source map cannot:
|
|
610
610
|
// the whole template is one overwrite. Only when source locations were asked for.
|
|
611
611
|
...at ? { at: { line: at.line, column: at.column } } : {}
|
|
612
612
|
};
|
|
@@ -722,11 +722,11 @@ function relativeToRoot(id, root) {
|
|
|
722
722
|
return id.startsWith(base) ? id.slice(base.length) : id;
|
|
723
723
|
}
|
|
724
724
|
function transformTemplates(code, id, options = {}) {
|
|
725
|
-
const
|
|
725
|
+
const htmlTag = options.htmlTag ?? "html";
|
|
726
726
|
const format = options.format ?? "both";
|
|
727
|
-
const
|
|
728
|
-
const wantsJsx = format !== "
|
|
729
|
-
const mayHaveTemplate =
|
|
727
|
+
const wantsHtml = format !== "jsx";
|
|
728
|
+
const wantsJsx = format !== "html";
|
|
729
|
+
const mayHaveTemplate = wantsHtml && (code.includes(`${htmlTag}\``) || code.includes("svg`"));
|
|
730
730
|
const wantsIntrinsics = options.intrinsics !== false && mayHaveIntrinsic(code);
|
|
731
731
|
const wantsSources = options.sourceLocations === true && mayHaveSourceMarks(code);
|
|
732
732
|
const sourceName = relativeToRoot(id, options.sourceRoot);
|
|
@@ -738,12 +738,12 @@ function transformTemplates(code, id, options = {}) {
|
|
|
738
738
|
errorRecovery: true
|
|
739
739
|
});
|
|
740
740
|
const intrinsicTags = options.intrinsics === false ? /* @__PURE__ */ new Map() : tagIntrinsics(moduleBindings(ast.program));
|
|
741
|
-
const templateTags = /* @__PURE__ */ new Map([[
|
|
741
|
+
const templateTags = /* @__PURE__ */ new Map([[htmlTag, "html"], ["svg", "svg"]]);
|
|
742
742
|
for (const [name, tag] of intrinsicTags) if (tag !== "css") templateTags.set(name, tag);
|
|
743
743
|
const cssTags = [...intrinsicTags].filter(([, tag]) => tag === "css").map(([name]) => name);
|
|
744
744
|
const found = [];
|
|
745
745
|
walk4(ast.program, (n, parent, key) => {
|
|
746
|
-
if (
|
|
746
|
+
if (wantsHtml && isTemplateTag(n, templateTags)) found.push(n);
|
|
747
747
|
else if (wantsJsx && isJsxRoot(n, parent, key)) found.push(n);
|
|
748
748
|
});
|
|
749
749
|
const props = options.propsDestructure === false ? { edits: [], diagnostics: [], used: /* @__PURE__ */ new Set() } : collectPropsEdits(ast.program, code, { runtimeModule: options.runtimeModule });
|