@matthesketh/utopia-compiler 0.5.0 → 0.7.1
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/index.cjs +26 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -1
- package/package.json +5 -5
- package/LICENSE +0 -21
package/dist/index.cjs
CHANGED
|
@@ -418,7 +418,7 @@ function classifyDirective(name, value) {
|
|
|
418
418
|
return null;
|
|
419
419
|
}
|
|
420
420
|
function isDirectiveKind(s) {
|
|
421
|
-
return s === "on" || s === "bind" || s === "if" || s === "else" || s === "else-if" || s === "for" || s === "model";
|
|
421
|
+
return s === "on" || s === "bind" || s === "if" || s === "else" || s === "else-if" || s === "for" || s === "model" || s === "html" || s === "transition";
|
|
422
422
|
}
|
|
423
423
|
var CodeGenerator = class {
|
|
424
424
|
constructor(options) {
|
|
@@ -547,6 +547,12 @@ ${fnBody}
|
|
|
547
547
|
case "model":
|
|
548
548
|
this.genModel(elVar, dir, scope);
|
|
549
549
|
break;
|
|
550
|
+
case "html":
|
|
551
|
+
this.genHtml(elVar, dir, scope);
|
|
552
|
+
break;
|
|
553
|
+
case "transition":
|
|
554
|
+
this.genTransition(elVar, dir);
|
|
555
|
+
break;
|
|
550
556
|
}
|
|
551
557
|
}
|
|
552
558
|
genOn(elVar, dir, scope) {
|
|
@@ -595,6 +601,25 @@ ${fnBody}
|
|
|
595
601
|
this.emit(`createEffect(() => setAttr(${elVar}, 'value', ${signalRef}()))`);
|
|
596
602
|
this.emit(`addEventListener(${elVar}, 'input', (e) => ${signalRef}.set(e.target.value))`);
|
|
597
603
|
}
|
|
604
|
+
// ---- u-html ---------------------------------------------------------------
|
|
605
|
+
genHtml(elVar, dir, scope) {
|
|
606
|
+
this.helpers.add("setHtml");
|
|
607
|
+
const expr = this.resolveExpression(dir.expression, scope);
|
|
608
|
+
this.emit(`setHtml(${elVar}, () => ${expr})`);
|
|
609
|
+
}
|
|
610
|
+
// ---- u-transition ---------------------------------------------------------
|
|
611
|
+
genTransition(elVar, dir) {
|
|
612
|
+
this.helpers.add("createTransition");
|
|
613
|
+
const name = dir.arg || dir.expression || "fade";
|
|
614
|
+
let durationOpt = "";
|
|
615
|
+
for (const mod of dir.modifiers) {
|
|
616
|
+
if (mod.startsWith("duration-")) {
|
|
617
|
+
const ms = mod.slice("duration-".length);
|
|
618
|
+
durationOpt = `, duration: ${ms}`;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
this.emit(`createTransition(${elVar}, { name: '${escapeStr(name)}'${durationOpt} })`);
|
|
622
|
+
}
|
|
598
623
|
// ---- Structural: u-if ---------------------------------------------------
|
|
599
624
|
genIf(node, dir, scope, elseIfChain, elseNode) {
|
|
600
625
|
this.helpers.add("createIf");
|
package/dist/index.d.cts
CHANGED
|
@@ -85,7 +85,7 @@ interface Directive {
|
|
|
85
85
|
expression: string;
|
|
86
86
|
modifiers: string[];
|
|
87
87
|
}
|
|
88
|
-
type DirectiveKind = 'on' | 'bind' | 'if' | 'else' | 'else-if' | 'for' | 'model';
|
|
88
|
+
type DirectiveKind = 'on' | 'bind' | 'if' | 'else' | 'else-if' | 'for' | 'model' | 'html' | 'transition';
|
|
89
89
|
/** Exported for testing — parse a template string into an AST. */
|
|
90
90
|
declare function parseTemplate(source: string): TemplateNode[];
|
|
91
91
|
|
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ interface Directive {
|
|
|
85
85
|
expression: string;
|
|
86
86
|
modifiers: string[];
|
|
87
87
|
}
|
|
88
|
-
type DirectiveKind = 'on' | 'bind' | 'if' | 'else' | 'else-if' | 'for' | 'model';
|
|
88
|
+
type DirectiveKind = 'on' | 'bind' | 'if' | 'else' | 'else-if' | 'for' | 'model' | 'html' | 'transition';
|
|
89
89
|
/** Exported for testing — parse a template string into an AST. */
|
|
90
90
|
declare function parseTemplate(source: string): TemplateNode[];
|
|
91
91
|
|
package/dist/index.js
CHANGED
|
@@ -385,7 +385,7 @@ function classifyDirective(name, value) {
|
|
|
385
385
|
return null;
|
|
386
386
|
}
|
|
387
387
|
function isDirectiveKind(s) {
|
|
388
|
-
return s === "on" || s === "bind" || s === "if" || s === "else" || s === "else-if" || s === "for" || s === "model";
|
|
388
|
+
return s === "on" || s === "bind" || s === "if" || s === "else" || s === "else-if" || s === "for" || s === "model" || s === "html" || s === "transition";
|
|
389
389
|
}
|
|
390
390
|
var CodeGenerator = class {
|
|
391
391
|
constructor(options) {
|
|
@@ -514,6 +514,12 @@ ${fnBody}
|
|
|
514
514
|
case "model":
|
|
515
515
|
this.genModel(elVar, dir, scope);
|
|
516
516
|
break;
|
|
517
|
+
case "html":
|
|
518
|
+
this.genHtml(elVar, dir, scope);
|
|
519
|
+
break;
|
|
520
|
+
case "transition":
|
|
521
|
+
this.genTransition(elVar, dir);
|
|
522
|
+
break;
|
|
517
523
|
}
|
|
518
524
|
}
|
|
519
525
|
genOn(elVar, dir, scope) {
|
|
@@ -562,6 +568,25 @@ ${fnBody}
|
|
|
562
568
|
this.emit(`createEffect(() => setAttr(${elVar}, 'value', ${signalRef}()))`);
|
|
563
569
|
this.emit(`addEventListener(${elVar}, 'input', (e) => ${signalRef}.set(e.target.value))`);
|
|
564
570
|
}
|
|
571
|
+
// ---- u-html ---------------------------------------------------------------
|
|
572
|
+
genHtml(elVar, dir, scope) {
|
|
573
|
+
this.helpers.add("setHtml");
|
|
574
|
+
const expr = this.resolveExpression(dir.expression, scope);
|
|
575
|
+
this.emit(`setHtml(${elVar}, () => ${expr})`);
|
|
576
|
+
}
|
|
577
|
+
// ---- u-transition ---------------------------------------------------------
|
|
578
|
+
genTransition(elVar, dir) {
|
|
579
|
+
this.helpers.add("createTransition");
|
|
580
|
+
const name = dir.arg || dir.expression || "fade";
|
|
581
|
+
let durationOpt = "";
|
|
582
|
+
for (const mod of dir.modifiers) {
|
|
583
|
+
if (mod.startsWith("duration-")) {
|
|
584
|
+
const ms = mod.slice("duration-".length);
|
|
585
|
+
durationOpt = `, duration: ${ms}`;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
this.emit(`createTransition(${elVar}, { name: '${escapeStr(name)}'${durationOpt} })`);
|
|
589
|
+
}
|
|
565
590
|
// ---- Structural: u-if ---------------------------------------------------
|
|
566
591
|
genIf(node, dir, scope, elseIfChain, elseNode) {
|
|
567
592
|
this.helpers.add("createIf");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthesketh/utopia-compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Compiler for .utopia single-file components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"files": [
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@matthesketh/utopia-core": "0.5.0"
|
|
43
|
-
},
|
|
44
41
|
"scripts": {
|
|
45
42
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
46
43
|
"dev": "tsup src/index.ts --format esm,cjs --dts --watch"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@matthesketh/utopia-core": "^0.7.0"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Matt Hesketh
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|