@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
package/dist/lower/jsx.cjs
CHANGED
|
@@ -332,6 +332,435 @@ function paren(code, position) {
|
|
|
332
332
|
return topLevelComma(src) === false ? code : `(${code})`;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
// src/analyze/intrinsics.ts
|
|
336
|
+
var REACTIVE_MODULE = "@fluixi/reactive/signal";
|
|
337
|
+
var INTRINSICS = {
|
|
338
|
+
$signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
|
|
339
|
+
$memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
|
|
340
|
+
$effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
|
|
341
|
+
$store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
|
|
342
|
+
$resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
|
|
343
|
+
$cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
|
|
344
|
+
// No short runtime form for these yet, so the intrinsic stands for the `create*`
|
|
345
|
+
// name. Still worth having: no import to write, and when a shorter form is
|
|
346
|
+
// designed, the change is this line rather than a compiler pass.
|
|
347
|
+
$selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
348
|
+
$deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
349
|
+
// Not value constructors, but the compiler has to know them: they change what a read
|
|
350
|
+
// does. `untrack` suppresses dependency collection, which is exactly the kind of thing
|
|
351
|
+
// dependency analysis must not guess at.
|
|
352
|
+
$untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
|
|
353
|
+
$untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
|
|
354
|
+
// Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
|
|
355
|
+
// no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
|
|
356
|
+
$batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
|
|
357
|
+
$cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
|
|
358
|
+
$root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
|
|
359
|
+
$context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
|
|
360
|
+
$renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
|
|
361
|
+
$computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
|
|
362
|
+
// Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
|
|
363
|
+
// handle as far as reads go: the same accessor with `set` on it.
|
|
364
|
+
$storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
365
|
+
$asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
366
|
+
$persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
|
|
367
|
+
// An environment variable, public or server-only; the browser build refuses a secret.
|
|
368
|
+
$env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
|
|
369
|
+
};
|
|
370
|
+
var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
|
|
371
|
+
|
|
372
|
+
// src/transform/source-locations.ts
|
|
373
|
+
var SOURCE_MARKER = "__fx_source";
|
|
374
|
+
var HOLE_MARKER = "__fx_hole";
|
|
375
|
+
var markHole = (accessor, line, column, name) => `(globalThis.${HOLE_MARKER} ?? ((f) => f))(${accessor},${line},${column}${name === void 0 ? "" : `,${JSON.stringify(name)}`})`;
|
|
376
|
+
var PROPS_MARKER = "__fx_props";
|
|
377
|
+
var markProps = (object, at) => `(globalThis.${PROPS_MARKER} ?? ((p) => p))(${object},${JSON.stringify(at)})`;
|
|
378
|
+
|
|
379
|
+
// src/codegen/serialize-static.ts
|
|
380
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
381
|
+
"area",
|
|
382
|
+
"base",
|
|
383
|
+
"br",
|
|
384
|
+
"col",
|
|
385
|
+
"embed",
|
|
386
|
+
"hr",
|
|
387
|
+
"img",
|
|
388
|
+
"input",
|
|
389
|
+
"link",
|
|
390
|
+
"meta",
|
|
391
|
+
"param",
|
|
392
|
+
"source",
|
|
393
|
+
"track",
|
|
394
|
+
"wbr"
|
|
395
|
+
]);
|
|
396
|
+
var HTML_NAME = {
|
|
397
|
+
className: "class",
|
|
398
|
+
htmlFor: "for"
|
|
399
|
+
};
|
|
400
|
+
var PROPERTY_ONLY = /* @__PURE__ */ new Set([
|
|
401
|
+
"innerHTML",
|
|
402
|
+
"outerHTML",
|
|
403
|
+
"innerText",
|
|
404
|
+
"textContent",
|
|
405
|
+
"value",
|
|
406
|
+
"checked",
|
|
407
|
+
"selected",
|
|
408
|
+
"muted",
|
|
409
|
+
"defaultValue",
|
|
410
|
+
"defaultChecked",
|
|
411
|
+
"children",
|
|
412
|
+
"ref"
|
|
413
|
+
]);
|
|
414
|
+
var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["script", "style", "textarea", "title"]);
|
|
415
|
+
function isRawTextElement(tag) {
|
|
416
|
+
return RAW_TEXT_ELEMENTS.has(tag);
|
|
417
|
+
}
|
|
418
|
+
function htmlAttrName(name) {
|
|
419
|
+
return HTML_NAME[name] ?? name;
|
|
420
|
+
}
|
|
421
|
+
function isPlainLiteralAttr(prop) {
|
|
422
|
+
if (prop.kind !== "attr") return false;
|
|
423
|
+
if (prop.expr !== void 0) return false;
|
|
424
|
+
if (prop.name.includes(":")) return false;
|
|
425
|
+
return !PROPERTY_ONLY.has(prop.name);
|
|
426
|
+
}
|
|
427
|
+
function isSerializable(node) {
|
|
428
|
+
if (!node.static) return false;
|
|
429
|
+
if (isRawTextElement(node.tag)) return false;
|
|
430
|
+
for (const prop of node.props) {
|
|
431
|
+
if (!isPlainLiteralAttr(prop)) return false;
|
|
432
|
+
}
|
|
433
|
+
for (const child of node.children) {
|
|
434
|
+
if (child.kind === "text") continue;
|
|
435
|
+
if (child.kind === "element" && isSerializable(child)) continue;
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
function serializeStatic(node) {
|
|
441
|
+
const attrs = node.props.map(serializeProp).filter(Boolean).join("");
|
|
442
|
+
const open = `<${node.tag}${attrs}>`;
|
|
443
|
+
if (VOID_ELEMENTS.has(node.tag)) return open;
|
|
444
|
+
return `${open}${node.children.map(serializeChild).join("")}</${node.tag}>`;
|
|
445
|
+
}
|
|
446
|
+
function serializeChild(child) {
|
|
447
|
+
if (child.kind === "text") return escapeText(child.value);
|
|
448
|
+
if (child.kind !== "element") throw new Error(`serializeStatic: unexpected ${child.kind}`);
|
|
449
|
+
return serializeStatic(child);
|
|
450
|
+
}
|
|
451
|
+
function serializeProp(prop) {
|
|
452
|
+
const name = HTML_NAME[prop.name] ?? prop.name;
|
|
453
|
+
const value = prop.literal;
|
|
454
|
+
if (value === true || value === void 0) return ` ${name}`;
|
|
455
|
+
if (value === false || value === null) return "";
|
|
456
|
+
return ` ${name}="${escapeAttr(String(value))}"`;
|
|
457
|
+
}
|
|
458
|
+
function escapeAttr(value) {
|
|
459
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
460
|
+
}
|
|
461
|
+
function escapeText(value) {
|
|
462
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
463
|
+
}
|
|
464
|
+
function templatePositions(root) {
|
|
465
|
+
const pos = [];
|
|
466
|
+
let file;
|
|
467
|
+
const walk = (el) => {
|
|
468
|
+
file ??= el.at?.file;
|
|
469
|
+
pos.push(el.at?.line ?? 0, el.at?.column ?? 0);
|
|
470
|
+
for (const child of el.children) if (child.kind === "element") walk(child);
|
|
471
|
+
};
|
|
472
|
+
walk(root);
|
|
473
|
+
return file && pos.some((n) => n !== 0) ? { file, pos } : void 0;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/codegen/partial-template.ts
|
|
477
|
+
var HOLE_START = "<!--fx-->";
|
|
478
|
+
var HOLE_END = "<!--fx/-->";
|
|
479
|
+
function isHole(node) {
|
|
480
|
+
return node.kind === "expr" || node.kind === "component" || node.kind === "control";
|
|
481
|
+
}
|
|
482
|
+
function isTemplateChild(node) {
|
|
483
|
+
return node.kind === "text" || node.kind === "element" && isTemplateElement(node);
|
|
484
|
+
}
|
|
485
|
+
function isTemplateElement(node) {
|
|
486
|
+
if (node.svg) return false;
|
|
487
|
+
if (isRawTextElement(node.tag)) return false;
|
|
488
|
+
if (!node.props.every((p) => isPlainLiteralAttr(p))) return false;
|
|
489
|
+
return node.children.every((c) => isTemplateChild(c) || isHole(c));
|
|
490
|
+
}
|
|
491
|
+
function containsHole(node) {
|
|
492
|
+
if (isHole(node)) return true;
|
|
493
|
+
const children = node.children;
|
|
494
|
+
return children ? children.some(containsHole) : false;
|
|
495
|
+
}
|
|
496
|
+
function addressable(el) {
|
|
497
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
498
|
+
const child = el.children[i];
|
|
499
|
+
if (child.kind === "text") {
|
|
500
|
+
if (child.value === "") return false;
|
|
501
|
+
if (el.children[i + 1]?.kind === "text") return false;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return el.children.every((c) => c.kind !== "element" || addressable(c));
|
|
505
|
+
}
|
|
506
|
+
function planPartialTemplate(root) {
|
|
507
|
+
if (!isTemplateElement(root)) return null;
|
|
508
|
+
if (!addressable(root)) return null;
|
|
509
|
+
if (!root.children.some(containsHole)) return null;
|
|
510
|
+
const steps = [];
|
|
511
|
+
const holes = [];
|
|
512
|
+
let refCount = 0;
|
|
513
|
+
const declare = (expr) => {
|
|
514
|
+
const ref = `_n$${refCount++}`;
|
|
515
|
+
steps.push({ ref, expr });
|
|
516
|
+
return ref;
|
|
517
|
+
};
|
|
518
|
+
walk(root, "_el$");
|
|
519
|
+
return { html: serializeWithMarkers(root), tag: root.tag, steps, holes };
|
|
520
|
+
function walk(el, elementRef) {
|
|
521
|
+
let last = -1;
|
|
522
|
+
el.children.forEach((child, i) => {
|
|
523
|
+
if (containsHole(child)) last = i;
|
|
524
|
+
});
|
|
525
|
+
let previous = null;
|
|
526
|
+
for (let i = 0; i <= last; i++) {
|
|
527
|
+
const child = el.children[i];
|
|
528
|
+
const expr = previous ? `${previous}.nextSibling` : `${elementRef}.firstChild`;
|
|
529
|
+
if (isHole(child)) {
|
|
530
|
+
const startRef = declare(expr);
|
|
531
|
+
const endRef = declare(`holeEnd(${startRef})`);
|
|
532
|
+
holes.push({ parentRef: elementRef, startRef, endRef, node: child });
|
|
533
|
+
previous = endRef;
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
const ref = declare(expr);
|
|
537
|
+
if (child.kind === "element" && containsHole(child)) walk(child, ref);
|
|
538
|
+
previous = ref;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function serializeWithMarkers(el) {
|
|
543
|
+
return serializeStatic(withSentinels(el)).split(SENTINEL).join(HOLE_START + HOLE_END);
|
|
544
|
+
}
|
|
545
|
+
function withSentinels(el) {
|
|
546
|
+
return {
|
|
547
|
+
...el,
|
|
548
|
+
children: el.children.map(
|
|
549
|
+
(child) => isHole(child) ? { kind: "text", value: SENTINEL } : child.kind === "element" ? withSentinels(child) : child
|
|
550
|
+
)
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
var SENTINEL = "\0fx-hole\0";
|
|
554
|
+
|
|
555
|
+
// src/codegen/contract.ts
|
|
556
|
+
var RUNTIME_CONTRACT_V1 = {
|
|
557
|
+
version: 1,
|
|
558
|
+
module: "@fluixi/dom",
|
|
559
|
+
symbols: [
|
|
560
|
+
"createNativeElement",
|
|
561
|
+
"insert",
|
|
562
|
+
"spread",
|
|
563
|
+
"setAttribute",
|
|
564
|
+
"delegateEvents",
|
|
565
|
+
"createComponent",
|
|
566
|
+
"createMemo",
|
|
567
|
+
"untrack",
|
|
568
|
+
"Show",
|
|
569
|
+
"For",
|
|
570
|
+
"Index",
|
|
571
|
+
"Switch",
|
|
572
|
+
"Match",
|
|
573
|
+
"Dynamic",
|
|
574
|
+
"ErrorBoundary"
|
|
575
|
+
]
|
|
576
|
+
};
|
|
577
|
+
var RUNTIME_CONTRACT_V2 = {
|
|
578
|
+
version: 2,
|
|
579
|
+
module: "@fluixi/dom",
|
|
580
|
+
symbols: [...RUNTIME_CONTRACT_V1.symbols, "template", "cloneTemplate", "walk"]
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// src/codegen/backends/imperative.ts
|
|
584
|
+
var CONTROL_COMPONENT = {
|
|
585
|
+
show: "Show",
|
|
586
|
+
for: "For",
|
|
587
|
+
index: "Index",
|
|
588
|
+
switch: "Switch",
|
|
589
|
+
match: "Match",
|
|
590
|
+
dynamic: "Dynamic",
|
|
591
|
+
errorBoundary: "ErrorBoundary",
|
|
592
|
+
suspense: "Suspense"
|
|
593
|
+
};
|
|
594
|
+
function isIdent(name) {
|
|
595
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
596
|
+
}
|
|
597
|
+
function propKey(name) {
|
|
598
|
+
return isIdent(name) ? name : JSON.stringify(name);
|
|
599
|
+
}
|
|
600
|
+
function propValue(p) {
|
|
601
|
+
if (p.expr !== void 0) {
|
|
602
|
+
if (p.name === "ref" && p.at)
|
|
603
|
+
return markHole(paren(p.expr, "value"), p.at.line, p.at.column, p.expr);
|
|
604
|
+
if (!p.reactive) return paren(p.expr, "value");
|
|
605
|
+
const accessor = `() => ${paren(p.expr, "arrowBody")}`;
|
|
606
|
+
return p.at ? markHole(accessor, p.at.line, p.at.column, p.directive) : accessor;
|
|
607
|
+
}
|
|
608
|
+
return JSON.stringify(p.literal ?? true);
|
|
609
|
+
}
|
|
610
|
+
function componentPropValue(p) {
|
|
611
|
+
if (p.expr !== void 0) return paren(p.expr, "value");
|
|
612
|
+
return JSON.stringify(p.literal ?? true);
|
|
613
|
+
}
|
|
614
|
+
function emitProps(props, childrenExpr, used) {
|
|
615
|
+
const spreads = props.filter((p) => p.kind === "spread");
|
|
616
|
+
const normal = props.filter((p) => p.kind !== "spread");
|
|
617
|
+
const entries = normal.map((p) => `${propKey(p.name)}: ${propValue(p)}`);
|
|
618
|
+
if (childrenExpr != null) entries.push(`children: ${childrenExpr}`);
|
|
619
|
+
const obj = `{ ${entries.join(", ")} }`;
|
|
620
|
+
if (spreads.length > 0) {
|
|
621
|
+
used.add("mergeProps");
|
|
622
|
+
return `mergeProps(${spreads.map((s) => s.expr).join(", ")}, ${obj})`;
|
|
623
|
+
}
|
|
624
|
+
return obj;
|
|
625
|
+
}
|
|
626
|
+
function markBind(code, at) {
|
|
627
|
+
return at ? markHole(code, at.line, at.column) : code;
|
|
628
|
+
}
|
|
629
|
+
function emitChildren(children, used, templates) {
|
|
630
|
+
if (children.length === 1) return emitNode(children[0], used, templates);
|
|
631
|
+
return `[${children.map((c) => emitNode(c, used, templates)).join(", ")}]`;
|
|
632
|
+
}
|
|
633
|
+
function emitComponent(name, props, children, used, templates, at) {
|
|
634
|
+
used.add("createMemo");
|
|
635
|
+
used.add("createComponent");
|
|
636
|
+
const spreads = props.filter((p) => p.kind === "spread");
|
|
637
|
+
const normal = props.filter((p) => p.kind !== "spread");
|
|
638
|
+
const bodies = normal.map((p) => [p.name, componentPropValue(p)]);
|
|
639
|
+
if (children.length > 0) {
|
|
640
|
+
bodies.push(["children", emitChildren(children, used, templates)]);
|
|
641
|
+
}
|
|
642
|
+
let obj = `{ ${bodies.map(([name2, body]) => `get ${propKey(name2)}() { return ${body}; }`).join(", ")} }`;
|
|
643
|
+
if (bodies.some(([, body]) => /\bthis\b/.test(body))) {
|
|
644
|
+
const thunks = bodies.map(([name2, body]) => `${JSON.stringify(name2)}: () => (${body})`);
|
|
645
|
+
const getters = bodies.map(([name2]) => `get ${propKey(name2)}() { return _$t[${JSON.stringify(name2)}](); }`);
|
|
646
|
+
obj = `((_$t) => ({ ${getters.join(", ")} }))({ ${thunks.join(", ")} })`;
|
|
647
|
+
}
|
|
648
|
+
if (spreads.length > 0) {
|
|
649
|
+
used.add("mergeProps");
|
|
650
|
+
obj = `mergeProps(${spreads.map((s) => s.expr).join(", ")}, ${obj})`;
|
|
651
|
+
}
|
|
652
|
+
const propAt = {};
|
|
653
|
+
for (const p of normal) if (p.at) propAt[p.name] = [p.at.line, p.at.column];
|
|
654
|
+
if (Object.keys(propAt).length) obj = markProps(obj, propAt);
|
|
655
|
+
const mark = at ? `globalThis.${SOURCE_MARKER}?.(${JSON.stringify(at.file)},${at.line},${at.column},${JSON.stringify(name)}), ` : "";
|
|
656
|
+
return `createMemo(${paren(`${mark}() => createComponent(${name}, ${obj})`, "value")})`;
|
|
657
|
+
}
|
|
658
|
+
function staticAttrAssignment(el, prop) {
|
|
659
|
+
const name = htmlAttrName(prop.name);
|
|
660
|
+
const value = prop.literal;
|
|
661
|
+
if (value === true || value === void 0) return `${el}.setAttribute(${JSON.stringify(name)}, "");`;
|
|
662
|
+
if (value === false || value === null) return "";
|
|
663
|
+
return `${el}.setAttribute(${JSON.stringify(name)}, ${JSON.stringify(String(value))});`;
|
|
664
|
+
}
|
|
665
|
+
var partial = false;
|
|
666
|
+
function emitNode(node, used, templates) {
|
|
667
|
+
switch (node.kind) {
|
|
668
|
+
case "text":
|
|
669
|
+
return JSON.stringify(node.value);
|
|
670
|
+
case "expr": {
|
|
671
|
+
if (!node.reactive) return paren(node.code, "value");
|
|
672
|
+
const accessor = `() => ${paren(node.code, "arrowBody")}`;
|
|
673
|
+
return node.at ? markHole(accessor, node.at.line, node.at.column) : accessor;
|
|
674
|
+
}
|
|
675
|
+
case "fragment":
|
|
676
|
+
if (node.children.length === 0) return "null";
|
|
677
|
+
return emitChildren(node.children, used, templates);
|
|
678
|
+
case "component":
|
|
679
|
+
return markBind(emitComponent(node.name, node.props, node.children, used, templates, node.at), node.bindAt ?? node.at);
|
|
680
|
+
case "control": {
|
|
681
|
+
const name = CONTROL_COMPONENT[node.control] ?? node.control;
|
|
682
|
+
used.add(name);
|
|
683
|
+
return markBind(emitComponent(name, node.props, node.children, used, templates), node.bindAt);
|
|
684
|
+
}
|
|
685
|
+
case "element": {
|
|
686
|
+
if (templates && node.static && !node.svg && isSerializable(node)) {
|
|
687
|
+
used.add("templateNode");
|
|
688
|
+
const id = `_tmpl$${templates.length}`;
|
|
689
|
+
templates.push({ id, html: serializeStatic(node), tag: node.tag, svg: false });
|
|
690
|
+
const at = templatePositions(node);
|
|
691
|
+
return at ? `templateNode(${id}, ${JSON.stringify(node.tag)}, false, false, ${JSON.stringify(at)})` : `templateNode(${id}, ${JSON.stringify(node.tag)})`;
|
|
692
|
+
}
|
|
693
|
+
if (templates && partial) {
|
|
694
|
+
const plan = planPartialTemplate(node);
|
|
695
|
+
if (plan) {
|
|
696
|
+
used.add("templateNode");
|
|
697
|
+
used.add("insert");
|
|
698
|
+
used.add("holeEnd");
|
|
699
|
+
used.add("holeContent");
|
|
700
|
+
used.add("holeScope");
|
|
701
|
+
const id = `_tmpl$${templates.length}`;
|
|
702
|
+
templates.push({ id, html: plan.html, tag: plan.tag, svg: false });
|
|
703
|
+
const at = templatePositions(node);
|
|
704
|
+
const lines = [
|
|
705
|
+
`const _el$ = templateNode(${id}, ${JSON.stringify(plan.tag)}, true${at ? `, false, ${JSON.stringify(at)}` : ""});`
|
|
706
|
+
];
|
|
707
|
+
for (const step of plan.steps) lines.push(`const ${step.ref} = ${step.expr};`);
|
|
708
|
+
for (const hole of plan.holes) {
|
|
709
|
+
lines.push(
|
|
710
|
+
`insert(${hole.parentRef}, holeScope(${hole.startRef}, () => ${paren(emitNode(hole.node, used, templates), "arrowBody")}), ${hole.endRef}, holeContent(${hole.startRef}, ${hole.endRef}));`
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
lines.push("return _el$;");
|
|
714
|
+
return `(() => { ${lines.join(" ")} })()`;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
used.add("createNativeElement");
|
|
718
|
+
const tag = JSON.stringify(node.tag);
|
|
719
|
+
const el = "_el$";
|
|
720
|
+
const parts = [];
|
|
721
|
+
const createArgs = node.at ? `${tag}, ${node.svg}, ${JSON.stringify(node.at)}` : node.svg ? `${tag}, true` : tag;
|
|
722
|
+
parts.push(`const ${el} = createNativeElement(${createArgs});`);
|
|
723
|
+
if (node.props.length > 0) {
|
|
724
|
+
if (!node.svg && node.props.every(isPlainLiteralAttr)) {
|
|
725
|
+
for (const p of node.props) parts.push(staticAttrAssignment(el, p));
|
|
726
|
+
} else {
|
|
727
|
+
used.add("spread");
|
|
728
|
+
const svgFlag = node.svg ? ", isSVG: true" : "";
|
|
729
|
+
const accessors = node.props.filter((p) => p.kind !== "spread" && p.expr !== void 0 && p.reactive && p.name !== "ref").map((p) => p.name);
|
|
730
|
+
const customFlag = node.tag.includes("-") ? `, isCustomElement: true, accessors: ${JSON.stringify(accessors)}` : "";
|
|
731
|
+
parts.push(
|
|
732
|
+
`spread({ element: ${el}, props: ${emitProps(node.props, null, used)}${svgFlag}${customFlag} });`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
for (const child of node.children) {
|
|
737
|
+
used.add("insert");
|
|
738
|
+
const childCode = emitNode(child, used, templates);
|
|
739
|
+
const isFn = child.kind === "expr" && child.reactive || child.kind === "component" || child.kind === "control";
|
|
740
|
+
parts.push(isFn ? `insert(${el}, ${childCode}, null);` : `insert(${el}, ${childCode});`);
|
|
741
|
+
}
|
|
742
|
+
parts.push(`return ${el};`);
|
|
743
|
+
return `(() => { ${parts.join(" ")} })()`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function inlineTemplates(code, templates) {
|
|
748
|
+
if (!templates || templates.length === 0) return code;
|
|
749
|
+
const byId = new Map(templates.map((t) => [t.id, JSON.stringify(t.html)]));
|
|
750
|
+
return code.replace(/_tmpl\$\d+/g, (id) => byId.get(id) ?? id);
|
|
751
|
+
}
|
|
752
|
+
var imperativeBackend = {
|
|
753
|
+
name: "imperative",
|
|
754
|
+
contract: RUNTIME_CONTRACT_V1,
|
|
755
|
+
emit(node, options) {
|
|
756
|
+
const used = /* @__PURE__ */ new Set();
|
|
757
|
+
const templates = options?.templateClone !== false ? [] : void 0;
|
|
758
|
+
partial = options?.partialTemplates === true;
|
|
759
|
+
const code = emitNode(node, used, templates);
|
|
760
|
+
return { code, imports: Array.from(used), templates };
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
|
|
335
764
|
// src/lower/jsx.ts
|
|
336
765
|
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
337
766
|
"svg",
|
|
@@ -363,6 +792,22 @@ var DELEGATED = /* @__PURE__ */ new Set([
|
|
|
363
792
|
"mouseup"
|
|
364
793
|
]);
|
|
365
794
|
var isReactive = (node) => isReactiveShape(shapeOf(node));
|
|
795
|
+
var CONTAINER = "container";
|
|
796
|
+
function directive(node, name) {
|
|
797
|
+
if (node.type !== "JSXElement") return void 0;
|
|
798
|
+
const opening = node.openingElement;
|
|
799
|
+
if (opening.name.type !== "JSXIdentifier" || opening.name.name[0] !== opening.name.name[0].toLowerCase()) return void 0;
|
|
800
|
+
return opening.attributes.find((a) => a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" && a.name.name === name);
|
|
801
|
+
}
|
|
802
|
+
function directiveExpr(attr) {
|
|
803
|
+
const v = attr.value;
|
|
804
|
+
return v?.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression" ? v.expression : void 0;
|
|
805
|
+
}
|
|
806
|
+
function emitIR(ir, ctx) {
|
|
807
|
+
const { code, imports, templates } = imperativeBackend.emit(ir, {});
|
|
808
|
+
for (const s of imports) ctx.used.add(s);
|
|
809
|
+
return inlineTemplates(code, templates);
|
|
810
|
+
}
|
|
366
811
|
var posOf = (node, ctx) => {
|
|
367
812
|
if (!ctx.sourceFile) return void 0;
|
|
368
813
|
const at = node.loc?.start;
|
|
@@ -440,9 +885,12 @@ function attrExprCode(attr, ctx) {
|
|
|
440
885
|
}
|
|
441
886
|
return null;
|
|
442
887
|
}
|
|
443
|
-
function buildProps(attrs, ctx) {
|
|
888
|
+
function buildProps(attrs, ctx, element = false) {
|
|
444
889
|
const props = [];
|
|
445
890
|
const usePairs = [];
|
|
891
|
+
const classEntries = [];
|
|
892
|
+
const styleEntries = [];
|
|
893
|
+
let styleAt;
|
|
446
894
|
for (const a of attrs) {
|
|
447
895
|
if (a.type === "JSXSpreadAttribute") {
|
|
448
896
|
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
@@ -458,6 +906,27 @@ function buildProps(attrs, ctx) {
|
|
|
458
906
|
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
459
907
|
continue;
|
|
460
908
|
}
|
|
909
|
+
if (element && (ns === "class" || ns === "style")) {
|
|
910
|
+
const key = JSON.stringify(a.name.name.name);
|
|
911
|
+
const v = a.value;
|
|
912
|
+
let value;
|
|
913
|
+
if (v == null) value = "true";
|
|
914
|
+
else if (isString(v)) value = JSON.stringify(literalOf(v));
|
|
915
|
+
else if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
916
|
+
value = keyValue(v.expression, ctx);
|
|
917
|
+
if (ns === "style") styleAt ??= posOf(v.expression, ctx);
|
|
918
|
+
} else continue;
|
|
919
|
+
(ns === "class" ? classEntries : styleEntries).push(`${key}: ${value}`);
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
if (element && a.name.type === "JSXIdentifier" && a.name.name === "style" && a.value?.type === "JSXExpressionContainer") {
|
|
923
|
+
const entries = objectEntries(a.value.expression, ctx);
|
|
924
|
+
if (entries) {
|
|
925
|
+
styleEntries.unshift(...entries);
|
|
926
|
+
styleAt = posOf(a.value.expression, ctx);
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
461
930
|
if (ns === "oncapture") {
|
|
462
931
|
const evt = a.name.name.name.toLowerCase();
|
|
463
932
|
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
@@ -466,12 +935,49 @@ function buildProps(attrs, ctx) {
|
|
|
466
935
|
}
|
|
467
936
|
props.push(buildAttr(a, ctx));
|
|
468
937
|
}
|
|
938
|
+
if (classEntries.length > 0) props.push({ name: "classList", kind: "attr", expr: `{ ${classEntries.join(", ")} }`, reactive: false });
|
|
939
|
+
if (styleEntries.length > 0) {
|
|
940
|
+
const entries = `{ ${styleEntries.join(", ")} }`;
|
|
941
|
+
const base = props.findIndex((p) => p.name === "style" && p.kind === "attr");
|
|
942
|
+
if (base === -1) props.push({ name: "style", kind: "attr", expr: entries, reactive: false, ...styleAt ? { at: styleAt } : {} });
|
|
943
|
+
else {
|
|
944
|
+
const prop = props[base];
|
|
945
|
+
const value = prop.literal !== void 0 ? JSON.stringify(prop.literal) : prop.reactive ? `() => ${paren(prop.expr, "arrowBody")}` : prop.expr;
|
|
946
|
+
props[base] = { name: "style", kind: "attr", expr: `[${value}, ${entries}]`, reactive: false, ...prop.at ? { at: prop.at } : {} };
|
|
947
|
+
}
|
|
948
|
+
}
|
|
469
949
|
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
470
950
|
return props;
|
|
471
951
|
}
|
|
952
|
+
function keyValue(expr, ctx) {
|
|
953
|
+
const code = ctx.code(expr);
|
|
954
|
+
if (!isReactive(expr)) return code;
|
|
955
|
+
const accessor = `() => ${paren(code, "arrowBody")}`;
|
|
956
|
+
const at = posOf(expr, ctx);
|
|
957
|
+
return at ? markHole(accessor, at.line, at.column) : accessor;
|
|
958
|
+
}
|
|
959
|
+
function objectEntries(expr, ctx) {
|
|
960
|
+
if (expr?.type !== "ObjectExpression") return null;
|
|
961
|
+
const entries = [];
|
|
962
|
+
for (const p of expr.properties) {
|
|
963
|
+
if (p.type !== "ObjectProperty") return null;
|
|
964
|
+
const key = p.computed ? `[${ctx.code(p.key)}]` : p.key.type === "Identifier" ? JSON.stringify(p.key.name) : JSON.stringify(String(p.key.value));
|
|
965
|
+
entries.push(`${key}: ${keyValue(p.value, ctx)}`);
|
|
966
|
+
}
|
|
967
|
+
return entries;
|
|
968
|
+
}
|
|
472
969
|
function buildChildren(children, ctx) {
|
|
473
970
|
const out = [];
|
|
474
|
-
for (
|
|
971
|
+
for (let i = 0; i < children.length; i++) {
|
|
972
|
+
const child = children[i];
|
|
973
|
+
if (directive(child, "if")) {
|
|
974
|
+
let next = i + 1;
|
|
975
|
+
while (next < children.length && children[next].type === "JSXText" && !cleanTemplateText(children[next].value)) next++;
|
|
976
|
+
const fallback = directive(children[next], "else") ? children[next] : null;
|
|
977
|
+
out.push(buildIf(child, fallback, ctx));
|
|
978
|
+
if (fallback) i = next;
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
475
981
|
if (child.type === "JSXText") {
|
|
476
982
|
const text = cleanTemplateText(child.value);
|
|
477
983
|
if (text) out.push({ kind: "text", value: text });
|
|
@@ -487,6 +993,7 @@ function buildChildren(children, ctx) {
|
|
|
487
993
|
});
|
|
488
994
|
}
|
|
489
995
|
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
996
|
+
if (ctx.dropStyles?.has(child.start)) continue;
|
|
490
997
|
out.push(buildNode(child, ctx));
|
|
491
998
|
} else if (child.type === "JSXSpreadChild") {
|
|
492
999
|
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
@@ -508,19 +1015,72 @@ function readLoad(attrs) {
|
|
|
508
1015
|
}
|
|
509
1016
|
return void 0;
|
|
510
1017
|
}
|
|
1018
|
+
function buildIf(node, fallback, ctx) {
|
|
1019
|
+
const cond = directiveExpr(directive(node, "if"));
|
|
1020
|
+
const props = [
|
|
1021
|
+
cond ? { name: "when", kind: "attr", expr: ctx.code(cond), reactive: isReactive(cond), at: posOf(cond, ctx) } : { name: "when", kind: "attr", literal: true }
|
|
1022
|
+
];
|
|
1023
|
+
if (fallback) {
|
|
1024
|
+
props.push({ name: "fallback", kind: "attr", expr: emitIR(buildElement(fallback, ctx, ["else"]), ctx), jsxElement: true });
|
|
1025
|
+
}
|
|
1026
|
+
return { kind: "component", name: "Show", props, children: [buildElement(node, ctx, ["if"])] };
|
|
1027
|
+
}
|
|
1028
|
+
function buildEach(node, ctx) {
|
|
1029
|
+
const attr = directive(node, "each");
|
|
1030
|
+
if (!attr) return null;
|
|
1031
|
+
const list = directiveExpr(attr);
|
|
1032
|
+
const props = [
|
|
1033
|
+
list ? { name: "each", kind: "attr", expr: ctx.code(list), reactive: isReactive(list), at: posOf(list, ctx) } : { name: "each", kind: "attr", expr: "[]" }
|
|
1034
|
+
];
|
|
1035
|
+
const key = directive(node, "key");
|
|
1036
|
+
if (key) {
|
|
1037
|
+
const keyExpr = directiveExpr(key);
|
|
1038
|
+
const by = isString(key.value) ? `(item) => item[${JSON.stringify(literalOf(key.value))}]` : keyExpr ? ctx.code(keyExpr) : void 0;
|
|
1039
|
+
if (by) props.push({ name: "by", kind: "attr", expr: by });
|
|
1040
|
+
}
|
|
1041
|
+
const content = node.children.filter((c) => !(c.type === "JSXText" && !cleanTemplateText(c.value)));
|
|
1042
|
+
const only = content.length === 1 && content[0].type === "JSXExpressionContainer" ? content[0].expression : null;
|
|
1043
|
+
let render;
|
|
1044
|
+
if (only && (only.type === "ArrowFunctionExpression" || only.type === "FunctionExpression")) {
|
|
1045
|
+
const fn = ctx.code(only);
|
|
1046
|
+
const live = only.type === "ArrowFunctionExpression" && only.body.type !== "BlockStatement" && isReactive(only.body);
|
|
1047
|
+
render = live ? `(...args) => () => (${fn})(...args)` : fn;
|
|
1048
|
+
} else {
|
|
1049
|
+
const built = buildChildren(node.children, ctx);
|
|
1050
|
+
const ir = built.length === 1 ? built[0] : { kind: "fragment", children: built };
|
|
1051
|
+
render = `() => ${paren(emitIR(ir, ctx), "arrowBody")}`;
|
|
1052
|
+
}
|
|
1053
|
+
return { kind: "component", name: "For", props, children: [{ kind: "expr", code: render, reactive: false }] };
|
|
1054
|
+
}
|
|
1055
|
+
function buildElement(node, ctx, handled) {
|
|
1056
|
+
const skip = new Set(handled);
|
|
1057
|
+
const directives = /* @__PURE__ */ new Set(["if", "else", "each", ...directive(node, "each") ? ["key"] : []]);
|
|
1058
|
+
const attributes = node.openingElement.attributes.filter(
|
|
1059
|
+
(a) => !(a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" && (skip.has(a.name.name) || directives.has(a.name.name)))
|
|
1060
|
+
);
|
|
1061
|
+
const { tag } = tagInfo(node.openingElement.name, ctx);
|
|
1062
|
+
const each = buildEach(node, ctx);
|
|
1063
|
+
const children = each ? [each] : buildChildren(node.children, ctx);
|
|
1064
|
+
if (tag === CONTAINER) return children.length === 1 ? children[0] : { kind: "fragment", children };
|
|
1065
|
+
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
1066
|
+
const props = buildProps(attributes, ctx, true);
|
|
1067
|
+
const scope = ctx.scopes?.find((s) => node.start >= s.start && node.end <= s.end);
|
|
1068
|
+
if (scope) props.unshift({ name: "data-fx-s", kind: "attr", literal: scope.value });
|
|
1069
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1070
|
+
}
|
|
511
1071
|
function buildNode(node, ctx) {
|
|
512
1072
|
if (node.type === "JSXFragment") {
|
|
513
1073
|
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
514
1074
|
}
|
|
1075
|
+
if (directive(node, "if")) return buildIf(node, null, ctx);
|
|
1076
|
+
if (ctx.dropStyles?.has(node.start)) return { kind: "fragment", children: [] };
|
|
515
1077
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
1078
|
+
if (!component) return buildElement(node, ctx, []);
|
|
516
1079
|
const props = buildProps(node.openingElement.attributes, ctx);
|
|
517
1080
|
const children = buildChildren(node.children, ctx);
|
|
518
1081
|
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
return { kind: "component", name: tag, props, children, ...load ? { load } : {}, ...at ? { at } : {} };
|
|
522
|
-
}
|
|
523
|
-
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
1082
|
+
const load = readLoad(node.openingElement.attributes);
|
|
1083
|
+
return { kind: "component", name: tag, props, children, ...load ? { load } : {}, ...at ? { at } : {} };
|
|
524
1084
|
}
|
|
525
1085
|
function buildJsxIR(node, ctx) {
|
|
526
1086
|
const ir = buildNode(node, ctx);
|
package/dist/lower/jsx.d.cts
CHANGED
|
@@ -18,6 +18,14 @@ export interface JsxContext {
|
|
|
18
18
|
used: Set<string>;
|
|
19
19
|
/** The file being compiled, when component usage sites are to be recorded. */
|
|
20
20
|
sourceFile?: string;
|
|
21
|
+
/** Scoped styles: intrinsic elements inside a range get `data-fx-s` set to its value. */
|
|
22
|
+
scopes?: {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
/** Start offsets of `<style>` elements the compiler took out of the template. */
|
|
28
|
+
dropStyles?: Set<number>;
|
|
21
29
|
}
|
|
22
30
|
export declare const SVG_TAGS: Set<string>;
|
|
23
31
|
/** Build IR from a JSXElement or JSXFragment. */
|
package/dist/lower/jsx.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ export interface JsxContext {
|
|
|
18
18
|
used: Set<string>;
|
|
19
19
|
/** The file being compiled, when component usage sites are to be recorded. */
|
|
20
20
|
sourceFile?: string;
|
|
21
|
+
/** Scoped styles: intrinsic elements inside a range get `data-fx-s` set to its value. */
|
|
22
|
+
scopes?: {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
/** Start offsets of `<style>` elements the compiler took out of the template. */
|
|
28
|
+
dropStyles?: Set<number>;
|
|
21
29
|
}
|
|
22
30
|
export declare const SVG_TAGS: Set<string>;
|
|
23
31
|
/** Build IR from a JSXElement or JSXFragment. */
|
package/dist/lower/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAUjF,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,mFAAmF;IACnF,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,iFAAiF;IACjF,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,eAAO,MAAM,QAAQ,aAGnB,CAAC;AAoYH,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAM9D"}
|