@zenithbuild/runtime 0.7.5 → 0.7.7
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/diagnostics-production.d.ts +11 -0
- package/dist/diagnostics-production.js +279 -0
- package/dist/events.js +2 -2
- package/dist/expressions.d.ts +0 -1
- package/dist/expressions.js +128 -150
- package/dist/hydrate.js +32 -67
- package/dist/markup.js +7 -7
- package/dist/payload.d.ts +9 -10
- package/dist/payload.js +128 -219
- package/dist/render.js +99 -117
- package/dist/runtime-template-profile.d.ts +20 -0
- package/dist/runtime-template-profile.js +141 -0
- package/dist/scanner.js +2 -2
- package/dist/template.d.ts +7 -1
- package/dist/template.js +25 -23
- package/package.json +1 -1
package/dist/payload.js
CHANGED
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
export function _validatePayload(payload) {
|
|
2
|
-
|
|
3
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires an object payload');
|
|
4
|
-
}
|
|
2
|
+
_ar(payload, 'hydrate(payload) requires an object payload');
|
|
5
3
|
if (payload.ir_version !== 1) {
|
|
6
|
-
|
|
4
|
+
_pe('unsupported ir_version (expected 1)');
|
|
7
5
|
}
|
|
8
6
|
const root = payload.root;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const markers = payload.markers;
|
|
18
|
-
if (!Array.isArray(markers)) {
|
|
19
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires markers[]');
|
|
20
|
-
}
|
|
21
|
-
const events = payload.events;
|
|
22
|
-
if (!Array.isArray(events)) {
|
|
23
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires events[]');
|
|
24
|
-
}
|
|
7
|
+
if (!root || typeof root.querySelectorAll !== 'function') {
|
|
8
|
+
_pe('hydrate(payload) requires payload.root with querySelectorAll');
|
|
9
|
+
}
|
|
10
|
+
const expressions = _aa(payload.expressions, 'hydrate(payload) requires expressions[]');
|
|
11
|
+
const markers = _aa(payload.markers, 'hydrate(payload) requires markers[]');
|
|
12
|
+
const events = _aa(payload.events, 'hydrate(payload) requires events[]');
|
|
13
|
+
const stateValues = _aa(payload.state_values, 'hydrate(payload) requires state_values[]');
|
|
14
|
+
const signals = _aa(payload.signals, 'hydrate(payload) requires signals[]');
|
|
25
15
|
const refs = Array.isArray(payload.refs) ? payload.refs : [];
|
|
26
|
-
const stateValues = payload.state_values;
|
|
27
|
-
if (!Array.isArray(stateValues)) {
|
|
28
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires state_values[]');
|
|
29
|
-
}
|
|
30
16
|
const stateKeys = Array.isArray(payload.state_keys) ? payload.state_keys : [];
|
|
31
|
-
if (!Array.isArray(stateKeys)) {
|
|
32
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires state_keys[] when provided');
|
|
33
|
-
}
|
|
34
|
-
for (let i = 0; i < stateKeys.length; i++) {
|
|
35
|
-
if (typeof stateKeys[i] !== 'string') {
|
|
36
|
-
throw new Error(`[Zenith Runtime] state_keys[${i}] must be a string`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const signals = payload.signals;
|
|
40
|
-
if (!Array.isArray(signals)) {
|
|
41
|
-
throw new Error('[Zenith Runtime] hydrate(payload) requires signals[]');
|
|
42
|
-
}
|
|
43
17
|
const components = Array.isArray(payload.components) ? payload.components : [];
|
|
44
|
-
const route = typeof payload.route === 'string' && payload.route.length > 0
|
|
45
|
-
? payload.route
|
|
46
|
-
: '<unknown>';
|
|
47
18
|
const params = payload.params && typeof payload.params === 'object'
|
|
48
19
|
? payload.params
|
|
49
20
|
: {};
|
|
@@ -51,200 +22,108 @@ export function _validatePayload(payload) {
|
|
|
51
22
|
? payload.ssr_data
|
|
52
23
|
: {};
|
|
53
24
|
const exprFns = Array.isArray(payload.expr_fns) ? payload.expr_fns : [];
|
|
25
|
+
for (let i = 0; i < stateKeys.length; i++) {
|
|
26
|
+
if (typeof stateKeys[i] !== 'string') {
|
|
27
|
+
_pe(`state_keys[${i}] must be a string`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
54
30
|
if (markers.length !== expressions.length) {
|
|
55
|
-
|
|
31
|
+
_pe(`marker/expression mismatch: markers=${markers.length}, expressions=${expressions.length}`);
|
|
56
32
|
}
|
|
57
33
|
for (let i = 0; i < expressions.length; i++) {
|
|
58
34
|
const expression = expressions[i];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (!Number.isInteger(expression.marker_index) || expression.marker_index < 0 || expression.marker_index >= expressions.length) {
|
|
63
|
-
throw new Error(`[Zenith Runtime] expression at position ${i} has invalid marker_index`);
|
|
64
|
-
}
|
|
35
|
+
_ar(expression, `expression at position ${i} must be an object`);
|
|
36
|
+
_air(expression.marker_index, expressions.length, `expression at position ${i} has invalid marker_index`);
|
|
65
37
|
if (expression.marker_index !== i) {
|
|
66
|
-
|
|
38
|
+
_pe(`expression table out of order at position ${i}: marker_index=${expression.marker_index}`);
|
|
67
39
|
}
|
|
68
|
-
if (expression.fn_index
|
|
69
|
-
|
|
70
|
-
throw new Error(`[Zenith Runtime] expression at position ${i} has invalid fn_index`);
|
|
71
|
-
}
|
|
40
|
+
if (expression.fn_index != null) {
|
|
41
|
+
_ani(expression.fn_index, `expression at position ${i} has invalid fn_index`);
|
|
72
42
|
}
|
|
73
43
|
_assertValidSourceSpan(expression.source, `expression[${i}]`);
|
|
74
44
|
if (expression.signal_indices !== undefined) {
|
|
75
45
|
if (!Array.isArray(expression.signal_indices)) {
|
|
76
|
-
|
|
46
|
+
_pe(`expression at position ${i} must provide signal_indices[]`);
|
|
77
47
|
}
|
|
78
48
|
for (let j = 0; j < expression.signal_indices.length; j++) {
|
|
79
|
-
|
|
80
|
-
throw new Error(`[Zenith Runtime] expression at position ${i} has invalid signal_indices[${j}]`);
|
|
81
|
-
}
|
|
49
|
+
_ani(expression.signal_indices[j], `expression at position ${i} has invalid signal_indices[${j}]`);
|
|
82
50
|
}
|
|
83
51
|
}
|
|
84
52
|
}
|
|
85
53
|
for (let i = 0; i < markers.length; i++) {
|
|
86
54
|
const marker = markers[i];
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
if (!Number.isInteger(marker.index) || marker.index < 0 || marker.index >= expressions.length) {
|
|
91
|
-
throw new Error(`[Zenith Runtime] marker at position ${i} has out-of-bounds index`);
|
|
92
|
-
}
|
|
55
|
+
_ar(marker, `marker at position ${i} must be an object`);
|
|
56
|
+
_air(marker.index, expressions.length, `marker at position ${i} has out-of-bounds index`);
|
|
93
57
|
if (marker.index !== i) {
|
|
94
|
-
|
|
58
|
+
_pe(`marker table out of order at position ${i}: index=${marker.index}`);
|
|
95
59
|
}
|
|
96
60
|
if (marker.kind !== 'text' && marker.kind !== 'attr' && marker.kind !== 'event') {
|
|
97
|
-
|
|
61
|
+
_pe(`marker at position ${i} has invalid kind`);
|
|
98
62
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (marker.kind === 'attr' && (typeof marker.attr !== 'string' || marker.attr.length === 0)) {
|
|
103
|
-
throw new Error(`[Zenith Runtime] attr marker at position ${i} requires attr name`);
|
|
63
|
+
_as(marker.selector, `marker at position ${i} requires selector`);
|
|
64
|
+
if (marker.kind === 'attr') {
|
|
65
|
+
_as(marker.attr, `attr marker at position ${i} requires attr name`);
|
|
104
66
|
}
|
|
105
67
|
_assertValidSourceSpan(marker.source, `marker[${i}]`);
|
|
106
68
|
}
|
|
107
69
|
for (let i = 0; i < events.length; i++) {
|
|
108
70
|
const eventBinding = events[i];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
throw new Error(`[Zenith Runtime] event binding at position ${i} has out-of-bounds index`);
|
|
114
|
-
}
|
|
115
|
-
if (typeof eventBinding.event !== 'string' || eventBinding.event.length === 0) {
|
|
116
|
-
throw new Error(`[Zenith Runtime] event binding at position ${i} requires event name`);
|
|
117
|
-
}
|
|
118
|
-
if (typeof eventBinding.selector !== 'string' || eventBinding.selector.length === 0) {
|
|
119
|
-
throw new Error(`[Zenith Runtime] event binding at position ${i} requires selector`);
|
|
120
|
-
}
|
|
71
|
+
_ar(eventBinding, `event binding at position ${i} must be an object`);
|
|
72
|
+
_air(eventBinding.index, expressions.length, `event binding at position ${i} has out-of-bounds index`);
|
|
73
|
+
_as(eventBinding.event, `event binding at position ${i} requires event name`);
|
|
74
|
+
_as(eventBinding.selector, `event binding at position ${i} requires selector`);
|
|
121
75
|
_assertValidSourceSpan(eventBinding.source, `event[${i}]`);
|
|
122
76
|
}
|
|
123
77
|
for (let i = 0; i < refs.length; i++) {
|
|
124
78
|
const refBinding = refs[i];
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
throw new Error(`[Zenith Runtime] ref binding at position ${i} requires non-negative index`);
|
|
130
|
-
}
|
|
131
|
-
if (!Number.isInteger(refBinding.state_index) ||
|
|
132
|
-
refBinding.state_index < 0 ||
|
|
133
|
-
refBinding.state_index >= stateValues.length) {
|
|
134
|
-
throw new Error(`[Zenith Runtime] ref binding at position ${i} has out-of-bounds state_index`);
|
|
135
|
-
}
|
|
136
|
-
if (typeof refBinding.selector !== 'string' || refBinding.selector.length === 0) {
|
|
137
|
-
throw new Error(`[Zenith Runtime] ref binding at position ${i} requires selector`);
|
|
138
|
-
}
|
|
79
|
+
_ar(refBinding, `ref binding at position ${i} must be an object`);
|
|
80
|
+
_ani(refBinding.index, `ref binding at position ${i} requires non-negative index`);
|
|
81
|
+
_air(refBinding.state_index, stateValues.length, `ref binding at position ${i} has out-of-bounds state_index`);
|
|
82
|
+
_as(refBinding.selector, `ref binding at position ${i} requires selector`);
|
|
139
83
|
_assertValidSourceSpan(refBinding.source, `ref[${i}]`);
|
|
140
84
|
const candidate = stateValues[refBinding.state_index];
|
|
141
85
|
if (!candidate || typeof candidate !== 'object' || !Object.prototype.hasOwnProperty.call(candidate, 'current')) {
|
|
142
|
-
|
|
86
|
+
_pe(`ref binding at position ${i} must resolve to a ref-like object`);
|
|
143
87
|
}
|
|
144
88
|
}
|
|
145
89
|
for (let i = 0; i < signals.length; i++) {
|
|
146
90
|
const signalDescriptor = signals[i];
|
|
147
|
-
|
|
148
|
-
throw new Error(`[Zenith Runtime] signal descriptor at position ${i} must be an object`);
|
|
149
|
-
}
|
|
91
|
+
_ar(signalDescriptor, `signal descriptor at position ${i} must be an object`);
|
|
150
92
|
if (signalDescriptor.kind !== 'signal') {
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
if (!Number.isInteger(signalDescriptor.id) || signalDescriptor.id < 0) {
|
|
154
|
-
throw new Error(`[Zenith Runtime] signal descriptor at position ${i} requires non-negative id`);
|
|
93
|
+
_pe(`signal descriptor at position ${i} requires kind="signal"`);
|
|
155
94
|
}
|
|
95
|
+
_ani(signalDescriptor.id, `signal descriptor at position ${i} requires non-negative id`);
|
|
156
96
|
if (signalDescriptor.id !== i) {
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
if (!Number.isInteger(signalDescriptor.state_index) || signalDescriptor.state_index < 0 || signalDescriptor.state_index >= stateValues.length) {
|
|
160
|
-
throw new Error(`[Zenith Runtime] signal descriptor at position ${i} has out-of-bounds state_index`);
|
|
97
|
+
_pe(`signal table out of order at position ${i}: id=${signalDescriptor.id}`);
|
|
161
98
|
}
|
|
99
|
+
_air(signalDescriptor.state_index, stateValues.length, `signal descriptor at position ${i} has out-of-bounds state_index`);
|
|
162
100
|
}
|
|
163
101
|
for (let i = 0; i < components.length; i++) {
|
|
164
102
|
const component = components[i];
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
if (typeof component.instance !== 'string' || component.instance.length === 0) {
|
|
169
|
-
throw new Error(`[Zenith Runtime] component at position ${i} requires instance`);
|
|
170
|
-
}
|
|
171
|
-
if (typeof component.selector !== 'string' || component.selector.length === 0) {
|
|
172
|
-
throw new Error(`[Zenith Runtime] component at position ${i} requires selector`);
|
|
173
|
-
}
|
|
103
|
+
_ar(component, `component at position ${i} must be an object`);
|
|
104
|
+
_as(component.instance, `component at position ${i} requires instance`);
|
|
105
|
+
_as(component.selector, `component at position ${i} requires selector`);
|
|
174
106
|
if (typeof component.create !== 'function') {
|
|
175
|
-
|
|
107
|
+
_pe(`component at position ${i} requires create() function`);
|
|
176
108
|
}
|
|
177
109
|
if (component.props !== undefined) {
|
|
178
110
|
if (!Array.isArray(component.props)) {
|
|
179
|
-
|
|
111
|
+
_pe(`component at position ${i} requires props to be an array`);
|
|
180
112
|
}
|
|
181
113
|
for (let j = 0; j < component.props.length; j++) {
|
|
182
|
-
|
|
183
|
-
if (!prop || typeof prop !== 'object' || Array.isArray(prop)) {
|
|
184
|
-
throw new Error(`[Zenith Runtime] component prop at position ${j} for component ${i} must be an object`);
|
|
185
|
-
}
|
|
186
|
-
if (typeof prop.name !== 'string' || prop.name.length === 0) {
|
|
187
|
-
throw new Error(`[Zenith Runtime] component prop at position ${j} for component ${i} requires a non-empty name`);
|
|
188
|
-
}
|
|
189
|
-
if (prop.type !== 'static' && prop.type !== 'signal') {
|
|
190
|
-
throw new Error(`[Zenith Runtime] component prop "${prop.name}" for component ${i} has unsupported type "${prop.type}"`);
|
|
191
|
-
}
|
|
192
|
-
if (prop.type === 'static' && !Object.prototype.hasOwnProperty.call(prop, 'value')) {
|
|
193
|
-
throw new Error(`[Zenith Runtime] component prop "${prop.name}" for component ${i} requires a value`);
|
|
194
|
-
}
|
|
195
|
-
if (prop.type === 'signal' && (!Number.isInteger(prop.index) || prop.index < 0)) {
|
|
196
|
-
throw new Error(`[Zenith Runtime] component prop "${prop.name}" for component ${i} requires a valid signal index`);
|
|
197
|
-
}
|
|
114
|
+
_avp(component.props[j], j, i);
|
|
198
115
|
}
|
|
199
116
|
}
|
|
200
117
|
_assertValidSourceSpan(component.source, `component[${i}]`);
|
|
201
118
|
}
|
|
202
|
-
if (payload.params !== undefined) {
|
|
203
|
-
|
|
204
|
-
throw new Error('[Zenith Runtime] hydrate() requires params object');
|
|
205
|
-
}
|
|
119
|
+
if (payload.params !== undefined && !_ir(payload.params)) {
|
|
120
|
+
_pe('hydrate() requires params object');
|
|
206
121
|
}
|
|
207
|
-
if (payload.ssr_data !== undefined) {
|
|
208
|
-
|
|
209
|
-
throw new Error('[Zenith Runtime] hydrate() requires ssr_data object');
|
|
210
|
-
}
|
|
122
|
+
if (payload.ssr_data !== undefined && !_ir(payload.ssr_data)) {
|
|
123
|
+
_pe('hydrate() requires ssr_data object');
|
|
211
124
|
}
|
|
212
|
-
const props = payload.props
|
|
213
|
-
|
|
214
|
-
: {};
|
|
215
|
-
for (let i = 0; i < expressions.length; i++)
|
|
216
|
-
Object.freeze(expressions[i]);
|
|
217
|
-
for (let i = 0; i < markers.length; i++)
|
|
218
|
-
Object.freeze(markers[i]);
|
|
219
|
-
for (let i = 0; i < events.length; i++)
|
|
220
|
-
Object.freeze(events[i]);
|
|
221
|
-
for (let i = 0; i < refs.length; i++)
|
|
222
|
-
Object.freeze(refs[i]);
|
|
223
|
-
for (let i = 0; i < signals.length; i++)
|
|
224
|
-
Object.freeze(signals[i]);
|
|
225
|
-
for (let i = 0; i < components.length; i++) {
|
|
226
|
-
const c = components[i];
|
|
227
|
-
if (Array.isArray(c.props)) {
|
|
228
|
-
for (let j = 0; j < c.props.length; j++) {
|
|
229
|
-
const propDesc = c.props[j];
|
|
230
|
-
if (propDesc &&
|
|
231
|
-
typeof propDesc === 'object' &&
|
|
232
|
-
_isHydrationFreezableContainer(propDesc.value)) {
|
|
233
|
-
Object.freeze(propDesc.value);
|
|
234
|
-
}
|
|
235
|
-
Object.freeze(propDesc);
|
|
236
|
-
}
|
|
237
|
-
Object.freeze(c.props);
|
|
238
|
-
}
|
|
239
|
-
Object.freeze(c);
|
|
240
|
-
}
|
|
241
|
-
Object.freeze(expressions);
|
|
242
|
-
Object.freeze(markers);
|
|
243
|
-
Object.freeze(events);
|
|
244
|
-
Object.freeze(refs);
|
|
245
|
-
Object.freeze(signals);
|
|
246
|
-
Object.freeze(components);
|
|
247
|
-
const validatedPayload = {
|
|
125
|
+
const props = _ir(payload.props) ? payload.props : {};
|
|
126
|
+
return {
|
|
248
127
|
root,
|
|
249
128
|
expressions,
|
|
250
129
|
markers,
|
|
@@ -254,82 +133,112 @@ export function _validatePayload(payload) {
|
|
|
254
133
|
stateKeys,
|
|
255
134
|
signals,
|
|
256
135
|
components,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
exprFns: Object.freeze(exprFns)
|
|
136
|
+
params: _f(params),
|
|
137
|
+
ssrData: _f(ssrData),
|
|
138
|
+
props: _f(props),
|
|
139
|
+
exprFns: _f(exprFns)
|
|
262
140
|
};
|
|
263
|
-
return Object.freeze(validatedPayload);
|
|
264
141
|
}
|
|
265
142
|
function _assertValidSourceSpan(source, contextLabel) {
|
|
266
143
|
if (source === undefined || source === null) {
|
|
267
144
|
return;
|
|
268
145
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
if (typeof source.file !== 'string' || source.file.length === 0) {
|
|
273
|
-
throw new Error(`[Zenith Runtime] ${contextLabel}.source.file must be a non-empty string`);
|
|
274
|
-
}
|
|
146
|
+
_ar(source, `${contextLabel}.source must be an object`);
|
|
147
|
+
_as(source.file, `${contextLabel}.source.file must be a non-empty string`);
|
|
275
148
|
const points = ['start', 'end'];
|
|
276
149
|
for (let i = 0; i < points.length; i++) {
|
|
277
150
|
const point = source[points[i]];
|
|
278
151
|
if (point === undefined || point === null) {
|
|
279
152
|
continue;
|
|
280
153
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
if (!Number.isInteger(point.line) || point.line < 1) {
|
|
285
|
-
throw new Error(`[Zenith Runtime] ${contextLabel}.source.${points[i]}.line must be >= 1`);
|
|
286
|
-
}
|
|
287
|
-
if (!Number.isInteger(point.column) || point.column < 1) {
|
|
288
|
-
throw new Error(`[Zenith Runtime] ${contextLabel}.source.${points[i]}.column must be >= 1`);
|
|
289
|
-
}
|
|
154
|
+
_ar(point, `${contextLabel}.source.${points[i]} must be an object`);
|
|
155
|
+
_api(point.line, `${contextLabel}.source.${points[i]}.line must be >= 1`);
|
|
156
|
+
_api(point.column, `${contextLabel}.source.${points[i]}.column must be >= 1`);
|
|
290
157
|
}
|
|
291
158
|
if (source.snippet !== undefined && source.snippet !== null && typeof source.snippet !== 'string') {
|
|
292
|
-
|
|
159
|
+
_pe(`${contextLabel}.source.snippet must be a string when provided`);
|
|
293
160
|
}
|
|
294
161
|
}
|
|
295
|
-
export function _resolveComponentProps(propTable, signalMap
|
|
162
|
+
export function _resolveComponentProps(propTable, signalMap) {
|
|
296
163
|
if (!Array.isArray(propTable)) {
|
|
297
|
-
|
|
164
|
+
_pe('component props must be an array');
|
|
298
165
|
}
|
|
299
166
|
const resolved = Object.create(null);
|
|
300
167
|
for (let i = 0; i < propTable.length; i++) {
|
|
301
168
|
const descriptor = propTable[i];
|
|
302
|
-
|
|
303
|
-
throw new Error(`[Zenith Runtime] component prop descriptor at index ${i} must be an object`);
|
|
304
|
-
}
|
|
305
|
-
if (typeof descriptor.name !== 'string' || descriptor.name.length === 0) {
|
|
306
|
-
throw new Error(`[Zenith Runtime] component prop descriptor at index ${i} requires non-empty name`);
|
|
307
|
-
}
|
|
169
|
+
const name = descriptor.name;
|
|
308
170
|
if (Object.prototype.hasOwnProperty.call(resolved, descriptor.name)) {
|
|
309
|
-
|
|
171
|
+
_pe(`duplicate component prop "${name}"`);
|
|
310
172
|
}
|
|
311
173
|
if (descriptor.type === 'static') {
|
|
312
|
-
|
|
313
|
-
throw new Error(`[Zenith Runtime] component prop "${descriptor.name}" static value is missing`);
|
|
314
|
-
}
|
|
315
|
-
resolved[descriptor.name] = descriptor.value;
|
|
174
|
+
resolved[name] = descriptor.value;
|
|
316
175
|
continue;
|
|
317
176
|
}
|
|
318
177
|
if (descriptor.type === 'signal') {
|
|
319
|
-
if (!Number.isInteger(descriptor.index)) {
|
|
320
|
-
throw new Error(`[Zenith Runtime] component prop "${descriptor.name}" signal index must be an integer`);
|
|
321
|
-
}
|
|
322
178
|
const signalValue = signalMap.get(descriptor.index);
|
|
323
179
|
if (!signalValue || typeof signalValue.get !== 'function') {
|
|
324
|
-
|
|
180
|
+
_pe(`signal index ${descriptor.index} did not resolve`);
|
|
325
181
|
}
|
|
326
|
-
resolved[
|
|
182
|
+
resolved[name] = signalValue;
|
|
327
183
|
continue;
|
|
328
184
|
}
|
|
329
|
-
|
|
185
|
+
_pe(`unsupported component prop type "${descriptor.type}" for "${name}"`);
|
|
330
186
|
}
|
|
331
187
|
return resolved;
|
|
332
188
|
}
|
|
189
|
+
function _pe(message) {
|
|
190
|
+
throw new Error(`[Zenith Runtime] ${message}`);
|
|
191
|
+
}
|
|
192
|
+
function _ir(value) {
|
|
193
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
194
|
+
}
|
|
195
|
+
function _ar(value, message) {
|
|
196
|
+
if (!_ir(value)) {
|
|
197
|
+
_pe(message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function _as(value, message) {
|
|
201
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
202
|
+
_pe(message);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function _ani(value, message) {
|
|
206
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
207
|
+
_pe(message);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function _api(value, message) {
|
|
211
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
212
|
+
_pe(message);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function _air(value, limit, message) {
|
|
216
|
+
if (!Number.isInteger(value) || value < 0 || value >= limit) {
|
|
217
|
+
_pe(message);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function _aa(value, message) {
|
|
221
|
+
if (!Array.isArray(value)) {
|
|
222
|
+
_pe(message);
|
|
223
|
+
}
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
function _f(value) {
|
|
227
|
+
return Object.freeze(value);
|
|
228
|
+
}
|
|
229
|
+
function _avp(prop, propIndex, componentIndex) {
|
|
230
|
+
_ar(prop, `component prop at position ${propIndex} for component ${componentIndex} must be an object`);
|
|
231
|
+
_as(prop.name, `component prop at position ${propIndex} for component ${componentIndex} requires a non-empty name`);
|
|
232
|
+
if (prop.type !== 'static' && prop.type !== 'signal') {
|
|
233
|
+
_pe(`component prop "${prop.name}" for component ${componentIndex} has unsupported type "${prop.type}"`);
|
|
234
|
+
}
|
|
235
|
+
if (prop.type === 'static' && !Object.prototype.hasOwnProperty.call(prop, 'value')) {
|
|
236
|
+
_pe(`component prop "${prop.name}" for component ${componentIndex} requires a value`);
|
|
237
|
+
}
|
|
238
|
+
if (prop.type === 'signal') {
|
|
239
|
+
_ani(prop.index, `component prop "${prop.name}" for component ${componentIndex} requires a valid signal index`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
333
242
|
export function _deepFreezePayload(obj) {
|
|
334
243
|
if (!_isHydrationFreezableContainer(obj) || Object.isFrozen(obj))
|
|
335
244
|
return;
|
|
@@ -337,7 +246,7 @@ export function _deepFreezePayload(obj) {
|
|
|
337
246
|
const keys = Object.keys(obj);
|
|
338
247
|
for (let i = 0; i < keys.length; i++) {
|
|
339
248
|
const val = obj[keys[i]];
|
|
340
|
-
if (val && typeof val === 'object'
|
|
249
|
+
if (val && typeof val === 'object') {
|
|
341
250
|
_deepFreezePayload(val);
|
|
342
251
|
}
|
|
343
252
|
}
|