@weave-framework/compiler 0.2.0
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/LICENSE +21 -0
- package/dist/ast.d.ts +243 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +3 -0
- package/dist/ast.js.map +1 -0
- package/dist/codegen.d.ts +25 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +543 -0
- package/dist/codegen.js.map +1 -0
- package/dist/component.d.ts +60 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +116 -0
- package/dist/component.js.map +1 -0
- package/dist/css.d.ts +26 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +344 -0
- package/dist/css.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/infer.d.ts +13 -0
- package/dist/infer.d.ts.map +1 -0
- package/dist/infer.js +113 -0
- package/dist/infer.js.map +1 -0
- package/dist/parser.d.ts +15 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +721 -0
- package/dist/parser.js.map +1 -0
- package/dist/scope.d.ts +71 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +233 -0
- package/dist/scope.js.map +1 -0
- package/dist/sources.d.ts +52 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +163 -0
- package/dist/sources.js.map +1 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aidas Josas
|
|
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.
|
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/** Weave template AST. */
|
|
2
|
+
export type TemplateNode = ElementNode | TextNode | InterpNode | IfNode | ForNode | SwitchNode | LetNode | DeferNode | AwaitNode | SnippetNode | RenderNode | KeyNode;
|
|
3
|
+
/**
|
|
4
|
+
* Source offset of an expression's first character within the template string
|
|
5
|
+
* passed to {@link parseTemplate}. Populated by the parser for every template
|
|
6
|
+
* expression; consumed by `@weave-framework/check` to map type errors back to the
|
|
7
|
+
* original `.weave`/`.html` line:col. Optional so codegen and existing callers
|
|
8
|
+
* (which only read the expression text) are unaffected.
|
|
9
|
+
*/
|
|
10
|
+
export type Offset = number | undefined;
|
|
11
|
+
/** `@if (cond) {…} @else if (cond2) {…} @else {…}`; optional `@if (expr; as alias)`. */
|
|
12
|
+
export interface IfNode {
|
|
13
|
+
type: 'if';
|
|
14
|
+
branches: IfBranch[];
|
|
15
|
+
}
|
|
16
|
+
export interface IfBranch {
|
|
17
|
+
/** undefined ⇒ the `@else` branch */
|
|
18
|
+
cond?: string;
|
|
19
|
+
/** offset of `cond` */
|
|
20
|
+
condOffset?: Offset;
|
|
21
|
+
/** alias from `@if (expr; as alias)` (only on the leading branch) */
|
|
22
|
+
alias?: string;
|
|
23
|
+
children: TemplateNode[];
|
|
24
|
+
}
|
|
25
|
+
/** `@for (item of list; track key) {…} @empty {…}` */
|
|
26
|
+
export interface ForNode {
|
|
27
|
+
type: 'for';
|
|
28
|
+
item: string;
|
|
29
|
+
list: string;
|
|
30
|
+
listOffset?: Offset;
|
|
31
|
+
track?: string;
|
|
32
|
+
trackOffset?: Offset;
|
|
33
|
+
children: TemplateNode[];
|
|
34
|
+
empty?: TemplateNode[];
|
|
35
|
+
}
|
|
36
|
+
/** `@switch (expr) { @case (test) {…} @default {…} }` */
|
|
37
|
+
export interface SwitchNode {
|
|
38
|
+
type: 'switch';
|
|
39
|
+
expr: string;
|
|
40
|
+
exprOffset?: Offset;
|
|
41
|
+
cases: SwitchCase[];
|
|
42
|
+
}
|
|
43
|
+
export interface SwitchCase {
|
|
44
|
+
/** undefined ⇒ `@default` */
|
|
45
|
+
test?: string;
|
|
46
|
+
testOffset?: Offset;
|
|
47
|
+
children: TemplateNode[];
|
|
48
|
+
}
|
|
49
|
+
/** `@let name = expr;` */
|
|
50
|
+
export interface LetNode {
|
|
51
|
+
type: 'let';
|
|
52
|
+
name: string;
|
|
53
|
+
expr: string;
|
|
54
|
+
exprOffset?: Offset;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `@defer (trigger) {…} @placeholder {…}` — gate the content's *rendering* until a
|
|
58
|
+
* trigger fires, showing the optional `@placeholder` until then. Code-splitting is
|
|
59
|
+
* opt-in via a `lazy()` component inside the content.
|
|
60
|
+
*/
|
|
61
|
+
export interface DeferNode {
|
|
62
|
+
type: 'defer';
|
|
63
|
+
trigger: DeferTrigger;
|
|
64
|
+
children: TemplateNode[];
|
|
65
|
+
placeholder?: TemplateNode[];
|
|
66
|
+
}
|
|
67
|
+
/** A `@defer` trigger. `when` is reactive; the rest are one-shot DOM/timing events. */
|
|
68
|
+
export type DeferTrigger = {
|
|
69
|
+
kind: 'when';
|
|
70
|
+
expr: string;
|
|
71
|
+
exprOffset?: Offset;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'idle';
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'viewport';
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'timer';
|
|
78
|
+
ms: string;
|
|
79
|
+
msOffset?: Offset;
|
|
80
|
+
} | {
|
|
81
|
+
kind: 'interaction';
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'hover';
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'immediate';
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* `@await (src) { pending } @then (val) { … } @catch (err) { … }` — render based on
|
|
89
|
+
* the settle state of a Promise OR a `@weave-framework/data` resource. All three parts are
|
|
90
|
+
* optional; `@then`/`@catch` may bind an alias to the resolved value / error.
|
|
91
|
+
*/
|
|
92
|
+
export interface AwaitNode {
|
|
93
|
+
type: 'await';
|
|
94
|
+
/** the awaited source — a Promise or a resource */
|
|
95
|
+
expr: string;
|
|
96
|
+
exprOffset?: Offset;
|
|
97
|
+
/** content shown while pending (the block right after `@await (src) { … }`) */
|
|
98
|
+
pending?: TemplateNode[];
|
|
99
|
+
/** `@then (alias?) { … }` — fulfilled */
|
|
100
|
+
then?: AwaitBranch;
|
|
101
|
+
/** `@catch (alias?) { … }` — rejected */
|
|
102
|
+
catch?: AwaitBranch;
|
|
103
|
+
}
|
|
104
|
+
export interface AwaitBranch {
|
|
105
|
+
/** optional alias bound to the resolved value (`@then`) or error (`@catch`) */
|
|
106
|
+
alias?: string;
|
|
107
|
+
children: TemplateNode[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `@snippet name(p1, p2) { … }` — a reusable, parameterized template fragment.
|
|
111
|
+
* Compiles to a function `(p1, p2) => Node`; `name` is a template-local value, so
|
|
112
|
+
* it can be `@render (name(args))`-ed locally or passed to a child as a prop.
|
|
113
|
+
*/
|
|
114
|
+
export interface SnippetNode {
|
|
115
|
+
type: 'snippet';
|
|
116
|
+
name: string;
|
|
117
|
+
/** parameter names (bare locals inside the body) */
|
|
118
|
+
params: string[];
|
|
119
|
+
children: TemplateNode[];
|
|
120
|
+
}
|
|
121
|
+
/** `@render (expr)` — render a snippet (or any expression resolving to a Node). */
|
|
122
|
+
export interface RenderNode {
|
|
123
|
+
type: 'render';
|
|
124
|
+
expr: string;
|
|
125
|
+
exprOffset?: Offset;
|
|
126
|
+
}
|
|
127
|
+
/** `@key (expr) { … }` — tear down + re-create the content whenever `expr` changes. */
|
|
128
|
+
export interface KeyNode {
|
|
129
|
+
type: 'key';
|
|
130
|
+
expr: string;
|
|
131
|
+
exprOffset?: Offset;
|
|
132
|
+
children: TemplateNode[];
|
|
133
|
+
}
|
|
134
|
+
export interface ElementNode {
|
|
135
|
+
type: 'element';
|
|
136
|
+
tag: string;
|
|
137
|
+
/** offset of the tag name's first char (after `<`); lets a `<Component>` tag map
|
|
138
|
+
* to its `.ts` import for go-to-definition and "unknown component" errors. */
|
|
139
|
+
tagOffset?: Offset;
|
|
140
|
+
attrs: Attr[];
|
|
141
|
+
children: TemplateNode[];
|
|
142
|
+
/** true for void elements (input, br, …) — no children, no closing tag */
|
|
143
|
+
selfClosing: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface TextNode {
|
|
146
|
+
type: 'text';
|
|
147
|
+
value: string;
|
|
148
|
+
}
|
|
149
|
+
/** `{{ expr }}` */
|
|
150
|
+
export interface InterpNode {
|
|
151
|
+
type: 'interp';
|
|
152
|
+
expr: string;
|
|
153
|
+
offset?: Offset;
|
|
154
|
+
}
|
|
155
|
+
export type Attr = StaticAttr | ExprAttr | PropAttr | EventAttr | ClassAttr | BindAttr | RefAttr | UseAttr | ShowAttr | TransitionAttr;
|
|
156
|
+
/** name="value" or bare name */
|
|
157
|
+
export interface StaticAttr {
|
|
158
|
+
type: 'static';
|
|
159
|
+
name: string;
|
|
160
|
+
value: string;
|
|
161
|
+
}
|
|
162
|
+
/** name={expr} */
|
|
163
|
+
export interface ExprAttr {
|
|
164
|
+
type: 'attr';
|
|
165
|
+
name: string;
|
|
166
|
+
expr: string;
|
|
167
|
+
offset?: Offset;
|
|
168
|
+
}
|
|
169
|
+
/** .prop={expr} */
|
|
170
|
+
export interface PropAttr {
|
|
171
|
+
type: 'prop';
|
|
172
|
+
name: string;
|
|
173
|
+
expr: string;
|
|
174
|
+
offset?: Offset;
|
|
175
|
+
}
|
|
176
|
+
/** on:event|mod1|mod2={expr} */
|
|
177
|
+
export interface EventAttr {
|
|
178
|
+
type: 'event';
|
|
179
|
+
name: string;
|
|
180
|
+
modifiers: string[];
|
|
181
|
+
expr: string;
|
|
182
|
+
offset?: Offset;
|
|
183
|
+
}
|
|
184
|
+
/** class:name={expr} */
|
|
185
|
+
export interface ClassAttr {
|
|
186
|
+
type: 'class';
|
|
187
|
+
name: string;
|
|
188
|
+
expr: string;
|
|
189
|
+
offset?: Offset;
|
|
190
|
+
}
|
|
191
|
+
/** bind:name={expr} (two-way) */
|
|
192
|
+
export interface BindAttr {
|
|
193
|
+
type: 'bind';
|
|
194
|
+
name: string;
|
|
195
|
+
expr: string;
|
|
196
|
+
offset?: Offset;
|
|
197
|
+
}
|
|
198
|
+
/** ref={expr} or bind:this={expr} */
|
|
199
|
+
export interface RefAttr {
|
|
200
|
+
type: 'ref';
|
|
201
|
+
expr: string;
|
|
202
|
+
offset?: Offset;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* `use:action` or `use:action={arg}` — an attribute directive. `name` is the
|
|
206
|
+
* action identifier (resolved against ctx, e.g. `tooltip` → `ctx.tooltip`);
|
|
207
|
+
* `expr` is the optional argument. The action runs after the element is inserted
|
|
208
|
+
* (onMount timing) and may return a cleanup fn or use `onCleanup`/`effect`.
|
|
209
|
+
*/
|
|
210
|
+
export interface UseAttr {
|
|
211
|
+
type: 'use';
|
|
212
|
+
name: string;
|
|
213
|
+
/** offset of the action identifier `name` (for `weave check`) */
|
|
214
|
+
nameOffset?: Offset;
|
|
215
|
+
/** optional argument expression */
|
|
216
|
+
expr?: string;
|
|
217
|
+
/** offset of the argument `expr` */
|
|
218
|
+
offset?: Offset;
|
|
219
|
+
}
|
|
220
|
+
/** `show={expr}` — toggle visibility via `display` (kept in the DOM, unlike `@if`). */
|
|
221
|
+
export interface ShowAttr {
|
|
222
|
+
type: 'show';
|
|
223
|
+
expr: string;
|
|
224
|
+
offset?: Offset;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* `transition:fn` / `in:fn` / `out:fn` (+ optional `={params}`) — play an enter
|
|
228
|
+
* (`in`) / leave (`out`) / both (`transition`) animation. `name` is the transition
|
|
229
|
+
* function (resolved against ctx); leave animations defer DOM removal until done.
|
|
230
|
+
*/
|
|
231
|
+
export interface TransitionAttr {
|
|
232
|
+
type: 'transition';
|
|
233
|
+
name: string;
|
|
234
|
+
/** which directions to animate */
|
|
235
|
+
mode: 'both' | 'in' | 'out';
|
|
236
|
+
/** offset of the transition-function identifier `name` (for `weave check`) */
|
|
237
|
+
nameOffset?: Offset;
|
|
238
|
+
/** optional params expression */
|
|
239
|
+
expr?: string;
|
|
240
|
+
/** offset of the params `expr` */
|
|
241
|
+
offset?: Offset;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,QAAQ,GACR,UAAU,GACV,MAAM,GACN,OAAO,GACP,UAAU,GACV,OAAO,GACP,SAAS,GACT,SAAS,GACT,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,MA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;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;IAC5B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/ast.js
ADDED
package/dist/ast.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,0BAA0B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weave codegen — turns a template AST into JS that creates DOM once and wires
|
|
3
|
+
* fine-grained signal bindings via the `@weave-framework/runtime/dom` helpers.
|
|
4
|
+
*
|
|
5
|
+
* Static structure becomes hoisted `<template>` strings with `<!---->` comment
|
|
6
|
+
* anchors at dynamic positions; dynamic nodes are reached by compile-time
|
|
7
|
+
* child-index paths. Control-flow blocks compile to `ifBlock`/`eachBlock` calls
|
|
8
|
+
* whose branch/row bodies are nested render functions (so they close over `ctx`
|
|
9
|
+
* and any template locals), keeping every block's effects in its own scope.
|
|
10
|
+
*/
|
|
11
|
+
export interface CompileOptions {
|
|
12
|
+
/** binding names (from setup()) to resolve via `ctx.*` */
|
|
13
|
+
scope?: string[];
|
|
14
|
+
/** 'module' → importable ES module (default); 'function' → body for `new Function('ctx','rt', …)` */
|
|
15
|
+
mode?: 'module' | 'function';
|
|
16
|
+
runtimeImport?: string;
|
|
17
|
+
/** Scoped-CSS attribute (e.g. `data-w-a1b2c3`) stamped on every emitted element. */
|
|
18
|
+
scopeAttr?: string;
|
|
19
|
+
/** `:host` attribute (e.g. `data-w-a1b2c3-h`) stamped on the template's root element(s). */
|
|
20
|
+
hostAttr?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function compileTemplate(input: string, options?: CompileOptions): {
|
|
23
|
+
code: string;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,qGAAqG;IACrG,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAqCD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAoB7F"}
|