@zeus-js/compiler-shared 0.1.1-beta.0 → 0.1.1-beta.2
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/compiler-shared.cjs +22 -13
- package/dist/compiler-shared.d.ts +27 -14
- package/dist/compiler-shared.esm-bundler.js +22 -13
- package/dist/compiler-shared.prod.cjs +22 -13
- package/package.json +1 -1
package/dist/compiler-shared.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* compiler-shared v0.1.1-beta.
|
|
2
|
+
* compiler-shared v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -15,11 +15,13 @@ function id() {
|
|
|
15
15
|
function ref(name) {
|
|
16
16
|
return { name };
|
|
17
17
|
}
|
|
18
|
-
function expressionIR(code, span) {
|
|
18
|
+
function expressionIR(code, span, form = "value", forAccessors = []) {
|
|
19
19
|
return {
|
|
20
20
|
kind: "Expression",
|
|
21
21
|
code,
|
|
22
|
-
span
|
|
22
|
+
span,
|
|
23
|
+
form,
|
|
24
|
+
forAccessors
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
function identifierIR(name, span) {
|
|
@@ -70,43 +72,50 @@ function fragmentIR(children) {
|
|
|
70
72
|
children
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
|
-
function staticAttrIR(name, value) {
|
|
75
|
+
function staticAttrIR(name, value, span) {
|
|
74
76
|
return {
|
|
75
77
|
id: id(),
|
|
76
78
|
kind: "StaticAttribute",
|
|
77
79
|
name,
|
|
78
|
-
value
|
|
80
|
+
value,
|
|
81
|
+
span
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
|
-
function attrBindingIR(name, expr) {
|
|
84
|
+
function attrBindingIR(name, expr, span, once = false) {
|
|
82
85
|
return {
|
|
83
86
|
id: id(),
|
|
84
87
|
kind: "AttrBinding",
|
|
85
88
|
name,
|
|
86
|
-
expr
|
|
89
|
+
expr,
|
|
90
|
+
once,
|
|
91
|
+
span
|
|
87
92
|
};
|
|
88
93
|
}
|
|
89
|
-
function propBindingIR(name, expr) {
|
|
94
|
+
function propBindingIR(name, expr, span, once = false) {
|
|
90
95
|
return {
|
|
91
96
|
id: id(),
|
|
92
97
|
kind: "PropBinding",
|
|
93
98
|
name,
|
|
94
|
-
expr
|
|
99
|
+
expr,
|
|
100
|
+
once,
|
|
101
|
+
span
|
|
95
102
|
};
|
|
96
103
|
}
|
|
97
|
-
function eventBindingIR(eventName, handler) {
|
|
104
|
+
function eventBindingIR(eventName, handler, span) {
|
|
98
105
|
return {
|
|
99
106
|
id: id(),
|
|
100
107
|
kind: "EventBinding",
|
|
101
108
|
eventName,
|
|
102
|
-
handler
|
|
109
|
+
handler,
|
|
110
|
+
span
|
|
103
111
|
};
|
|
104
112
|
}
|
|
105
|
-
function refBindingIR(expr) {
|
|
113
|
+
function refBindingIR(expr, span) {
|
|
106
114
|
return {
|
|
107
115
|
id: id(),
|
|
108
116
|
kind: "RefBinding",
|
|
109
|
-
expr
|
|
117
|
+
expr,
|
|
118
|
+
span
|
|
110
119
|
};
|
|
111
120
|
}
|
|
112
121
|
function componentIR(input) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface SourcePosition {
|
|
2
2
|
line: number;
|
|
3
3
|
column: number;
|
|
4
|
-
offset
|
|
4
|
+
offset: number;
|
|
5
5
|
}
|
|
6
6
|
export interface SourceSpan {
|
|
7
7
|
start: SourcePosition;
|
|
@@ -10,7 +10,15 @@ export interface SourceSpan {
|
|
|
10
10
|
export interface ExpressionIR {
|
|
11
11
|
kind: 'Expression';
|
|
12
12
|
code: string;
|
|
13
|
-
span
|
|
13
|
+
span: SourceSpan;
|
|
14
|
+
form: ExpressionForm;
|
|
15
|
+
forAccessors: ForAccessorIR[];
|
|
16
|
+
}
|
|
17
|
+
export type ExpressionForm = 'value' | 'getter' | 'member';
|
|
18
|
+
export interface ForAccessorIR {
|
|
19
|
+
forId: number;
|
|
20
|
+
item: boolean;
|
|
21
|
+
index: boolean;
|
|
14
22
|
}
|
|
15
23
|
export interface IdentifierIR {
|
|
16
24
|
kind: 'Identifier';
|
|
@@ -54,6 +62,9 @@ export interface SemanticBaseIRNode {
|
|
|
54
62
|
id: number;
|
|
55
63
|
span?: SourceSpan;
|
|
56
64
|
}
|
|
65
|
+
export type AttributeBaseIRNode = Omit<SemanticBaseIRNode, 'span'> & {
|
|
66
|
+
span: SourceSpan;
|
|
67
|
+
};
|
|
57
68
|
export type ProgramIR = SemanticBaseIRNode & {
|
|
58
69
|
kind: 'Program';
|
|
59
70
|
body: ZeusIRNode[];
|
|
@@ -80,31 +91,33 @@ export type DynamicTextIR = SemanticBaseIRNode & {
|
|
|
80
91
|
kind: 'DynamicText';
|
|
81
92
|
expr: ExpressionIR;
|
|
82
93
|
ref: IRRef;
|
|
83
|
-
once
|
|
94
|
+
once: boolean;
|
|
84
95
|
domPath?: DomPath;
|
|
85
96
|
physicalDomPath?: PhysicalDomPath;
|
|
86
97
|
};
|
|
87
|
-
export type StaticAttributeIR =
|
|
98
|
+
export type StaticAttributeIR = AttributeBaseIRNode & {
|
|
88
99
|
kind: 'StaticAttribute';
|
|
89
100
|
name: string;
|
|
90
101
|
value: string | true;
|
|
91
102
|
};
|
|
92
|
-
export type AttrBindingIR =
|
|
103
|
+
export type AttrBindingIR = AttributeBaseIRNode & {
|
|
93
104
|
kind: 'AttrBinding';
|
|
94
105
|
name: string;
|
|
95
106
|
expr: ExpressionIR;
|
|
107
|
+
once: boolean;
|
|
96
108
|
};
|
|
97
|
-
export type PropBindingIR =
|
|
109
|
+
export type PropBindingIR = AttributeBaseIRNode & {
|
|
98
110
|
kind: 'PropBinding';
|
|
99
111
|
name: string;
|
|
100
112
|
expr: ExpressionIR;
|
|
113
|
+
once: boolean;
|
|
101
114
|
};
|
|
102
|
-
export type EventBindingIR =
|
|
115
|
+
export type EventBindingIR = AttributeBaseIRNode & {
|
|
103
116
|
kind: 'EventBinding';
|
|
104
117
|
eventName: string;
|
|
105
118
|
handler: ExpressionIR;
|
|
106
119
|
};
|
|
107
|
-
export type RefBindingIR =
|
|
120
|
+
export type RefBindingIR = AttributeBaseIRNode & {
|
|
108
121
|
kind: 'RefBinding';
|
|
109
122
|
expr: ExpressionIR;
|
|
110
123
|
};
|
|
@@ -167,7 +180,7 @@ export type ZeusIRNode = ElementIR | TextIR | DynamicTextIR | ComponentIR | Frag
|
|
|
167
180
|
|
|
168
181
|
export declare function id(): number;
|
|
169
182
|
export declare function ref(name: string): IRRef;
|
|
170
|
-
export declare function expressionIR(code: string, span?:
|
|
183
|
+
export declare function expressionIR(code: string, span: SourceSpan, form?: ExpressionForm, forAccessors?: ExpressionIR['forAccessors']): ExpressionIR;
|
|
171
184
|
export declare function identifierIR(name: string, span?: SourceSpan): IdentifierIR;
|
|
172
185
|
export declare function elementIR(input: {
|
|
173
186
|
ref: IRRef;
|
|
@@ -180,11 +193,11 @@ export declare function elementIR(input: {
|
|
|
180
193
|
export declare function textIR(value: string): TextIR;
|
|
181
194
|
export declare function dynamicTextIR(expr: ExpressionIR, nodeRef: IRRef, once?: boolean): DynamicTextIR;
|
|
182
195
|
export declare function fragmentIR(children: ZeusIRNode[]): FragmentIR;
|
|
183
|
-
export declare function staticAttrIR(name: string, value: string | true): StaticAttributeIR;
|
|
184
|
-
export declare function attrBindingIR(name: string, expr: ExpressionIR): AttrBindingIR;
|
|
185
|
-
export declare function propBindingIR(name: string, expr: ExpressionIR): PropBindingIR;
|
|
186
|
-
export declare function eventBindingIR(eventName: string, handler: ExpressionIR): EventBindingIR;
|
|
187
|
-
export declare function refBindingIR(expr: ExpressionIR): RefBindingIR;
|
|
196
|
+
export declare function staticAttrIR(name: string, value: string | true, span: SourceSpan): StaticAttributeIR;
|
|
197
|
+
export declare function attrBindingIR(name: string, expr: ExpressionIR, span: SourceSpan, once?: boolean): AttrBindingIR;
|
|
198
|
+
export declare function propBindingIR(name: string, expr: ExpressionIR, span: SourceSpan, once?: boolean): PropBindingIR;
|
|
199
|
+
export declare function eventBindingIR(eventName: string, handler: ExpressionIR, span: SourceSpan): EventBindingIR;
|
|
200
|
+
export declare function refBindingIR(expr: ExpressionIR, span: SourceSpan): RefBindingIR;
|
|
188
201
|
export declare function componentIR(input: {
|
|
189
202
|
ref: IRRef;
|
|
190
203
|
callee: ExpressionIR;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* compiler-shared v0.1.1-beta.
|
|
2
|
+
* compiler-shared v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -72,11 +72,13 @@ function id() {
|
|
|
72
72
|
function ref(name) {
|
|
73
73
|
return { name };
|
|
74
74
|
}
|
|
75
|
-
function expressionIR(code, span) {
|
|
75
|
+
function expressionIR(code, span, form = "value", forAccessors = []) {
|
|
76
76
|
return {
|
|
77
77
|
kind: "Expression",
|
|
78
78
|
code,
|
|
79
|
-
span
|
|
79
|
+
span,
|
|
80
|
+
form,
|
|
81
|
+
forAccessors
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
function identifierIR(name, span) {
|
|
@@ -124,43 +126,50 @@ function fragmentIR(children) {
|
|
|
124
126
|
children
|
|
125
127
|
};
|
|
126
128
|
}
|
|
127
|
-
function staticAttrIR(name, value) {
|
|
129
|
+
function staticAttrIR(name, value, span) {
|
|
128
130
|
return {
|
|
129
131
|
id: id(),
|
|
130
132
|
kind: "StaticAttribute",
|
|
131
133
|
name,
|
|
132
|
-
value
|
|
134
|
+
value,
|
|
135
|
+
span
|
|
133
136
|
};
|
|
134
137
|
}
|
|
135
|
-
function attrBindingIR(name, expr) {
|
|
138
|
+
function attrBindingIR(name, expr, span, once = false) {
|
|
136
139
|
return {
|
|
137
140
|
id: id(),
|
|
138
141
|
kind: "AttrBinding",
|
|
139
142
|
name,
|
|
140
|
-
expr
|
|
143
|
+
expr,
|
|
144
|
+
once,
|
|
145
|
+
span
|
|
141
146
|
};
|
|
142
147
|
}
|
|
143
|
-
function propBindingIR(name, expr) {
|
|
148
|
+
function propBindingIR(name, expr, span, once = false) {
|
|
144
149
|
return {
|
|
145
150
|
id: id(),
|
|
146
151
|
kind: "PropBinding",
|
|
147
152
|
name,
|
|
148
|
-
expr
|
|
153
|
+
expr,
|
|
154
|
+
once,
|
|
155
|
+
span
|
|
149
156
|
};
|
|
150
157
|
}
|
|
151
|
-
function eventBindingIR(eventName, handler) {
|
|
158
|
+
function eventBindingIR(eventName, handler, span) {
|
|
152
159
|
return {
|
|
153
160
|
id: id(),
|
|
154
161
|
kind: "EventBinding",
|
|
155
162
|
eventName,
|
|
156
|
-
handler
|
|
163
|
+
handler,
|
|
164
|
+
span
|
|
157
165
|
};
|
|
158
166
|
}
|
|
159
|
-
function refBindingIR(expr) {
|
|
167
|
+
function refBindingIR(expr, span) {
|
|
160
168
|
return {
|
|
161
169
|
id: id(),
|
|
162
170
|
kind: "RefBinding",
|
|
163
|
-
expr
|
|
171
|
+
expr,
|
|
172
|
+
span
|
|
164
173
|
};
|
|
165
174
|
}
|
|
166
175
|
function componentIR(input) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* compiler-shared v0.1.1-beta.
|
|
2
|
+
* compiler-shared v0.1.1-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -15,11 +15,13 @@ function id() {
|
|
|
15
15
|
function ref(name) {
|
|
16
16
|
return { name };
|
|
17
17
|
}
|
|
18
|
-
function expressionIR(code, span) {
|
|
18
|
+
function expressionIR(code, span, form = "value", forAccessors = []) {
|
|
19
19
|
return {
|
|
20
20
|
kind: "Expression",
|
|
21
21
|
code,
|
|
22
|
-
span
|
|
22
|
+
span,
|
|
23
|
+
form,
|
|
24
|
+
forAccessors
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
function identifierIR(name, span) {
|
|
@@ -70,43 +72,50 @@ function fragmentIR(children) {
|
|
|
70
72
|
children
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
|
-
function staticAttrIR(name, value) {
|
|
75
|
+
function staticAttrIR(name, value, span) {
|
|
74
76
|
return {
|
|
75
77
|
id: id(),
|
|
76
78
|
kind: "StaticAttribute",
|
|
77
79
|
name,
|
|
78
|
-
value
|
|
80
|
+
value,
|
|
81
|
+
span
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
|
-
function attrBindingIR(name, expr) {
|
|
84
|
+
function attrBindingIR(name, expr, span, once = false) {
|
|
82
85
|
return {
|
|
83
86
|
id: id(),
|
|
84
87
|
kind: "AttrBinding",
|
|
85
88
|
name,
|
|
86
|
-
expr
|
|
89
|
+
expr,
|
|
90
|
+
once,
|
|
91
|
+
span
|
|
87
92
|
};
|
|
88
93
|
}
|
|
89
|
-
function propBindingIR(name, expr) {
|
|
94
|
+
function propBindingIR(name, expr, span, once = false) {
|
|
90
95
|
return {
|
|
91
96
|
id: id(),
|
|
92
97
|
kind: "PropBinding",
|
|
93
98
|
name,
|
|
94
|
-
expr
|
|
99
|
+
expr,
|
|
100
|
+
once,
|
|
101
|
+
span
|
|
95
102
|
};
|
|
96
103
|
}
|
|
97
|
-
function eventBindingIR(eventName, handler) {
|
|
104
|
+
function eventBindingIR(eventName, handler, span) {
|
|
98
105
|
return {
|
|
99
106
|
id: id(),
|
|
100
107
|
kind: "EventBinding",
|
|
101
108
|
eventName,
|
|
102
|
-
handler
|
|
109
|
+
handler,
|
|
110
|
+
span
|
|
103
111
|
};
|
|
104
112
|
}
|
|
105
|
-
function refBindingIR(expr) {
|
|
113
|
+
function refBindingIR(expr, span) {
|
|
106
114
|
return {
|
|
107
115
|
id: id(),
|
|
108
116
|
kind: "RefBinding",
|
|
109
|
-
expr
|
|
117
|
+
expr,
|
|
118
|
+
span
|
|
110
119
|
};
|
|
111
120
|
}
|
|
112
121
|
function componentIR(input) {
|