@zeus-js/compiler-shared 0.1.0 → 0.1.1-beta.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * compiler-shared v0.1.0
2
+ * compiler-shared v0.1.1-beta.1
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) {
@@ -38,6 +40,7 @@ function elementIR(input) {
38
40
  tagName: input.tagName,
39
41
  attrs: (_input$attrs = input.attrs) !== null && _input$attrs !== void 0 ? _input$attrs : [],
40
42
  children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : [],
43
+ ...input.span === void 0 ? {} : { span: input.span },
41
44
  flags: {
42
45
  isSVG: false,
43
46
  isVoid: false,
@@ -69,43 +72,50 @@ function fragmentIR(children) {
69
72
  children
70
73
  };
71
74
  }
72
- function staticAttrIR(name, value) {
75
+ function staticAttrIR(name, value, span) {
73
76
  return {
74
77
  id: id(),
75
78
  kind: "StaticAttribute",
76
79
  name,
77
- value
80
+ value,
81
+ span
78
82
  };
79
83
  }
80
- function attrBindingIR(name, expr) {
84
+ function attrBindingIR(name, expr, span, once = false) {
81
85
  return {
82
86
  id: id(),
83
87
  kind: "AttrBinding",
84
88
  name,
85
- expr
89
+ expr,
90
+ once,
91
+ span
86
92
  };
87
93
  }
88
- function propBindingIR(name, expr) {
94
+ function propBindingIR(name, expr, span, once = false) {
89
95
  return {
90
96
  id: id(),
91
97
  kind: "PropBinding",
92
98
  name,
93
- expr
99
+ expr,
100
+ once,
101
+ span
94
102
  };
95
103
  }
96
- function eventBindingIR(eventName, handler) {
104
+ function eventBindingIR(eventName, handler, span) {
97
105
  return {
98
106
  id: id(),
99
107
  kind: "EventBinding",
100
108
  eventName,
101
- handler
109
+ handler,
110
+ span
102
111
  };
103
112
  }
104
- function refBindingIR(expr) {
113
+ function refBindingIR(expr, span) {
105
114
  return {
106
115
  id: id(),
107
116
  kind: "RefBinding",
108
- expr
117
+ expr,
118
+ span
109
119
  };
110
120
  }
111
121
  function componentIR(input) {
@@ -114,7 +124,8 @@ function componentIR(input) {
114
124
  kind: "Component",
115
125
  ref: input.ref,
116
126
  callee: input.callee,
117
- props: input.props
127
+ props: input.props,
128
+ ...input.span === void 0 ? {} : { span: input.span }
118
129
  };
119
130
  }
120
131
  function showIR(input) {
@@ -1,7 +1,7 @@
1
1
  export interface SourcePosition {
2
2
  line: number;
3
3
  column: number;
4
- offset?: number;
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?: SourceSpan;
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?: boolean;
94
+ once: boolean;
84
95
  domPath?: DomPath;
85
96
  physicalDomPath?: PhysicalDomPath;
86
97
  };
87
- export type StaticAttributeIR = SemanticBaseIRNode & {
98
+ export type StaticAttributeIR = AttributeBaseIRNode & {
88
99
  kind: 'StaticAttribute';
89
100
  name: string;
90
101
  value: string | true;
91
102
  };
92
- export type AttrBindingIR = SemanticBaseIRNode & {
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 = SemanticBaseIRNode & {
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 = SemanticBaseIRNode & {
115
+ export type EventBindingIR = AttributeBaseIRNode & {
103
116
  kind: 'EventBinding';
104
117
  eventName: string;
105
118
  handler: ExpressionIR;
106
119
  };
107
- export type RefBindingIR = SemanticBaseIRNode & {
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?: SourceSpan): ExpressionIR;
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;
@@ -175,19 +188,21 @@ export declare function elementIR(input: {
175
188
  attrs?: ElementIR['attrs'];
176
189
  children?: ZeusIRNode[];
177
190
  flags?: Partial<ElementIR['flags']>;
191
+ span?: SourceSpan;
178
192
  }): ElementIR;
179
193
  export declare function textIR(value: string): TextIR;
180
194
  export declare function dynamicTextIR(expr: ExpressionIR, nodeRef: IRRef, once?: boolean): DynamicTextIR;
181
195
  export declare function fragmentIR(children: ZeusIRNode[]): FragmentIR;
182
- export declare function staticAttrIR(name: string, value: string | true): StaticAttributeIR;
183
- export declare function attrBindingIR(name: string, expr: ExpressionIR): AttrBindingIR;
184
- export declare function propBindingIR(name: string, expr: ExpressionIR): PropBindingIR;
185
- export declare function eventBindingIR(eventName: string, handler: ExpressionIR): EventBindingIR;
186
- 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;
187
201
  export declare function componentIR(input: {
188
202
  ref: IRRef;
189
203
  callee: ExpressionIR;
190
204
  props: ComponentIR['props'];
205
+ span?: SourceSpan;
191
206
  }): ComponentIR;
192
207
  export declare function showIR(input: {
193
208
  ref: IRRef;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * compiler-shared v0.1.0
2
+ * compiler-shared v0.1.1-beta.1
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) {
@@ -88,19 +90,18 @@ function identifierIR(name, span) {
88
90
  }
89
91
  function elementIR(input) {
90
92
  var _input$attrs, _input$children;
91
- return {
93
+ return _objectSpread2(_objectSpread2({
92
94
  id: id(),
93
95
  kind: "Element",
94
96
  ref: input.ref,
95
97
  tagName: input.tagName,
96
98
  attrs: (_input$attrs = input.attrs) !== null && _input$attrs !== void 0 ? _input$attrs : [],
97
- children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : [],
98
- flags: _objectSpread2({
99
- isSVG: false,
100
- isVoid: false,
101
- isCustomElement: input.tagName.includes("-")
102
- }, input.flags)
103
- };
99
+ children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : []
100
+ }, input.span === void 0 ? {} : { span: input.span }), {}, { flags: _objectSpread2({
101
+ isSVG: false,
102
+ isVoid: false,
103
+ isCustomElement: input.tagName.includes("-")
104
+ }, input.flags) });
104
105
  }
105
106
  function textIR(value) {
106
107
  return {
@@ -125,53 +126,60 @@ function fragmentIR(children) {
125
126
  children
126
127
  };
127
128
  }
128
- function staticAttrIR(name, value) {
129
+ function staticAttrIR(name, value, span) {
129
130
  return {
130
131
  id: id(),
131
132
  kind: "StaticAttribute",
132
133
  name,
133
- value
134
+ value,
135
+ span
134
136
  };
135
137
  }
136
- function attrBindingIR(name, expr) {
138
+ function attrBindingIR(name, expr, span, once = false) {
137
139
  return {
138
140
  id: id(),
139
141
  kind: "AttrBinding",
140
142
  name,
141
- expr
143
+ expr,
144
+ once,
145
+ span
142
146
  };
143
147
  }
144
- function propBindingIR(name, expr) {
148
+ function propBindingIR(name, expr, span, once = false) {
145
149
  return {
146
150
  id: id(),
147
151
  kind: "PropBinding",
148
152
  name,
149
- expr
153
+ expr,
154
+ once,
155
+ span
150
156
  };
151
157
  }
152
- function eventBindingIR(eventName, handler) {
158
+ function eventBindingIR(eventName, handler, span) {
153
159
  return {
154
160
  id: id(),
155
161
  kind: "EventBinding",
156
162
  eventName,
157
- handler
163
+ handler,
164
+ span
158
165
  };
159
166
  }
160
- function refBindingIR(expr) {
167
+ function refBindingIR(expr, span) {
161
168
  return {
162
169
  id: id(),
163
170
  kind: "RefBinding",
164
- expr
171
+ expr,
172
+ span
165
173
  };
166
174
  }
167
175
  function componentIR(input) {
168
- return {
176
+ return _objectSpread2({
169
177
  id: id(),
170
178
  kind: "Component",
171
179
  ref: input.ref,
172
180
  callee: input.callee,
173
181
  props: input.props
174
- };
182
+ }, input.span === void 0 ? {} : { span: input.span });
175
183
  }
176
184
  function showIR(input) {
177
185
  return {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * compiler-shared v0.1.0
2
+ * compiler-shared v0.1.1-beta.1
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) {
@@ -38,6 +40,7 @@ function elementIR(input) {
38
40
  tagName: input.tagName,
39
41
  attrs: (_input$attrs = input.attrs) !== null && _input$attrs !== void 0 ? _input$attrs : [],
40
42
  children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : [],
43
+ ...input.span === void 0 ? {} : { span: input.span },
41
44
  flags: {
42
45
  isSVG: false,
43
46
  isVoid: false,
@@ -69,43 +72,50 @@ function fragmentIR(children) {
69
72
  children
70
73
  };
71
74
  }
72
- function staticAttrIR(name, value) {
75
+ function staticAttrIR(name, value, span) {
73
76
  return {
74
77
  id: id(),
75
78
  kind: "StaticAttribute",
76
79
  name,
77
- value
80
+ value,
81
+ span
78
82
  };
79
83
  }
80
- function attrBindingIR(name, expr) {
84
+ function attrBindingIR(name, expr, span, once = false) {
81
85
  return {
82
86
  id: id(),
83
87
  kind: "AttrBinding",
84
88
  name,
85
- expr
89
+ expr,
90
+ once,
91
+ span
86
92
  };
87
93
  }
88
- function propBindingIR(name, expr) {
94
+ function propBindingIR(name, expr, span, once = false) {
89
95
  return {
90
96
  id: id(),
91
97
  kind: "PropBinding",
92
98
  name,
93
- expr
99
+ expr,
100
+ once,
101
+ span
94
102
  };
95
103
  }
96
- function eventBindingIR(eventName, handler) {
104
+ function eventBindingIR(eventName, handler, span) {
97
105
  return {
98
106
  id: id(),
99
107
  kind: "EventBinding",
100
108
  eventName,
101
- handler
109
+ handler,
110
+ span
102
111
  };
103
112
  }
104
- function refBindingIR(expr) {
113
+ function refBindingIR(expr, span) {
105
114
  return {
106
115
  id: id(),
107
116
  kind: "RefBinding",
108
- expr
117
+ expr,
118
+ span
109
119
  };
110
120
  }
111
121
  function componentIR(input) {
@@ -114,7 +124,8 @@ function componentIR(input) {
114
124
  kind: "Component",
115
125
  ref: input.ref,
116
126
  callee: input.callee,
117
- props: input.props
127
+ props: input.props,
128
+ ...input.span === void 0 ? {} : { span: input.span }
118
129
  };
119
130
  }
120
131
  function showIR(input) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zeus-js/compiler-shared",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1-beta.1",
5
5
  "description": "Babel-independent Zeus compiler IR contracts",
6
6
  "license": "MIT",
7
7
  "repository": {