regor 1.4.6 → 1.4.8
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/README.md +28 -4
- package/dist/regor.d.ts +47 -14
- package/dist/regor.es2015.cjs.js +220 -149
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +220 -149
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +220 -149
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +220 -149
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +220 -149
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +220 -149
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +218 -148
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +218 -148
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +218 -148
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2015.esm.js
CHANGED
|
@@ -180,9 +180,184 @@ var callUnmounted = (context) => {
|
|
|
180
180
|
(_b = context.unmounted) == null ? void 0 : _b.call(context);
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
+
// src/log/warnings.ts
|
|
184
|
+
var warnings = {
|
|
185
|
+
[8 /* ModelRequiresRef */]: (el) => `Model binding requires a ref at ${el.outerHTML}`,
|
|
186
|
+
[7 /* ModelNotSupportOnElement */]: (el) => `Model binding is not supported on ${el.tagName} element at ${el.outerHTML}`,
|
|
187
|
+
[0 /* MissingBindingExpression */]: (name, el) => `${name} binding expression is missing at ${el.outerHTML}`,
|
|
188
|
+
[1 /* InvalidForExpression */]: (name, forPath, el) => `invalid ${name} expression: ${forPath} at ${el.outerHTML}`,
|
|
189
|
+
[2 /* BindingRequiresObjectExpressions */]: (name, el) => `${name} requires object expression at ${el.outerHTML}`,
|
|
190
|
+
[3 /* KeyIsEmpty */]: (name, el) => `${name} binder: key is empty on ${el.outerHTML}.`,
|
|
191
|
+
[4 /* PropertyAssignmentFailed */]: (key, tag, value, e) => ({
|
|
192
|
+
msg: `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
|
193
|
+
args: [e]
|
|
194
|
+
}),
|
|
195
|
+
[5 /* MissingEventType */]: (name, el) => `${name} binding missing event type at ${el.outerHTML}`,
|
|
196
|
+
[6 /* ErrorLog */]: (msg, e) => ({ msg, args: [e] })
|
|
197
|
+
};
|
|
198
|
+
var warning = (type, ...args) => {
|
|
199
|
+
const msg = warnings[type];
|
|
200
|
+
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
201
|
+
const handler = warningHandler.warning;
|
|
202
|
+
if (!handler) return;
|
|
203
|
+
if (isString(item)) handler(item);
|
|
204
|
+
else handler(item, ...item.args);
|
|
205
|
+
};
|
|
206
|
+
var warningHandler = {
|
|
207
|
+
warning: console.warn
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// src/reactivity/refSymbols.ts
|
|
211
|
+
var refSymbol = Symbol("ref");
|
|
212
|
+
var srefSymbol = Symbol("sref");
|
|
213
|
+
var rawSymbol = Symbol("raw");
|
|
214
|
+
|
|
215
|
+
// src/reactivity/isRef.ts
|
|
216
|
+
var isRef = (value) => {
|
|
217
|
+
return value != null && value[srefSymbol] === 1;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// src/app/propValidators.ts
|
|
221
|
+
var PropValidationError = class extends Error {
|
|
222
|
+
constructor(propPath, detail) {
|
|
223
|
+
super(detail);
|
|
224
|
+
__publicField(this, "propPath");
|
|
225
|
+
__publicField(this, "detail");
|
|
226
|
+
this.name = "PropValidationError";
|
|
227
|
+
this.propPath = propPath;
|
|
228
|
+
this.detail = detail;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var fail = (name, message) => {
|
|
232
|
+
throw new PropValidationError(name, `${message}.`);
|
|
233
|
+
};
|
|
234
|
+
var describeValue = (value) => {
|
|
235
|
+
var _a;
|
|
236
|
+
if (value === null) return "null";
|
|
237
|
+
if (value === void 0) return "undefined";
|
|
238
|
+
if (typeof value === "string") return "string";
|
|
239
|
+
if (typeof value === "number") return "number";
|
|
240
|
+
if (typeof value === "boolean") return "boolean";
|
|
241
|
+
if (typeof value === "bigint") return "bigint";
|
|
242
|
+
if (typeof value === "symbol") return "symbol";
|
|
243
|
+
if (typeof value === "function") return "function";
|
|
244
|
+
if (isArray(value)) return "array";
|
|
245
|
+
if (value instanceof Date) return "Date";
|
|
246
|
+
if (value instanceof RegExp) return "RegExp";
|
|
247
|
+
if (value instanceof Map) return "Map";
|
|
248
|
+
if (value instanceof Set) return "Set";
|
|
249
|
+
const ctorName = (_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name;
|
|
250
|
+
return ctorName && ctorName !== "Object" ? ctorName : "object";
|
|
251
|
+
};
|
|
252
|
+
var formatLiteral = (value) => {
|
|
253
|
+
if (typeof value === "string") return `"${value}"`;
|
|
254
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
255
|
+
return String(value);
|
|
256
|
+
}
|
|
257
|
+
if (value === null) return "null";
|
|
258
|
+
if (value === void 0) return "undefined";
|
|
259
|
+
return describeValue(value);
|
|
260
|
+
};
|
|
261
|
+
var isString2 = (value, name) => {
|
|
262
|
+
if (typeof value !== "string") fail(name, "expected string");
|
|
263
|
+
};
|
|
264
|
+
var isNumber = (value, name) => {
|
|
265
|
+
if (typeof value !== "number") fail(name, "expected number");
|
|
266
|
+
};
|
|
267
|
+
var isBoolean = (value, name) => {
|
|
268
|
+
if (typeof value !== "boolean") fail(name, "expected boolean");
|
|
269
|
+
};
|
|
270
|
+
var isClass = (ctor) => {
|
|
271
|
+
return (value, name) => {
|
|
272
|
+
if (!(value instanceof ctor)) {
|
|
273
|
+
fail(name, `expected instance of ${ctor.name || "provided class"}`);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
var optional = (validator) => {
|
|
278
|
+
return (value, name, head) => {
|
|
279
|
+
if (value === void 0) return;
|
|
280
|
+
validator(value, name, head);
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
var nullable = (validator) => {
|
|
284
|
+
return (value, name, head) => {
|
|
285
|
+
if (value === null) return;
|
|
286
|
+
validator(value, name, head);
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
var oneOf = (values) => {
|
|
290
|
+
return (value, name) => {
|
|
291
|
+
if (values.includes(value)) return;
|
|
292
|
+
fail(
|
|
293
|
+
name,
|
|
294
|
+
`expected one of ${values.map((x) => formatLiteral(x)).join(", ")}`
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
var arrayOf = (validator) => {
|
|
299
|
+
return (value, name, head) => {
|
|
300
|
+
if (!isArray(value)) fail(name, "expected array");
|
|
301
|
+
const items = value;
|
|
302
|
+
for (let i = 0; i < items.length; ++i) {
|
|
303
|
+
validator(items[i], `${name}[${i}]`, head);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
var shape = (schema) => {
|
|
308
|
+
return (value, name, head) => {
|
|
309
|
+
if (!isObject(value)) fail(name, "expected object");
|
|
310
|
+
const record = value;
|
|
311
|
+
for (const key in schema) {
|
|
312
|
+
const validator = schema[key];
|
|
313
|
+
validator(record[key], `${name}.${key}`, head);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
var refOf = (validator) => {
|
|
318
|
+
return (value, name, head) => {
|
|
319
|
+
if (!isRef(value)) fail(name, "expected ref");
|
|
320
|
+
const refValue = value;
|
|
321
|
+
validator(refValue(), `${name}.value`, head);
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
var pval = {
|
|
325
|
+
fail,
|
|
326
|
+
isString: isString2,
|
|
327
|
+
isNumber,
|
|
328
|
+
isBoolean,
|
|
329
|
+
isClass,
|
|
330
|
+
optional,
|
|
331
|
+
nullable,
|
|
332
|
+
oneOf,
|
|
333
|
+
arrayOf,
|
|
334
|
+
shape,
|
|
335
|
+
refOf
|
|
336
|
+
};
|
|
337
|
+
|
|
183
338
|
// src/app/ComponentHead.ts
|
|
339
|
+
var formatComponentValidationError = (element, propName, error) => {
|
|
340
|
+
var _a, _b;
|
|
341
|
+
const tagName = ((_b = (_a = element.tagName) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a)) || "unknown";
|
|
342
|
+
const finalPropName = error instanceof PropValidationError ? error.propPath : propName;
|
|
343
|
+
const detail = error instanceof PropValidationError ? error.detail : error instanceof Error ? error.message : String(error);
|
|
344
|
+
if (error instanceof Error) {
|
|
345
|
+
return new Error(
|
|
346
|
+
`Invalid prop "${finalPropName}" on <${tagName}>: ${detail}`,
|
|
347
|
+
{
|
|
348
|
+
cause: error
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
return new Error(
|
|
353
|
+
`Invalid prop "${finalPropName}" on <${tagName}>: ${detail}`,
|
|
354
|
+
{
|
|
355
|
+
cause: error
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
184
359
|
var ComponentHead = class {
|
|
185
|
-
constructor(props, element, ctx, start, end) {
|
|
360
|
+
constructor(props, element, ctx, start, end, propValidationMode) {
|
|
186
361
|
/**
|
|
187
362
|
* Values provided by parent for this component instance.
|
|
188
363
|
*
|
|
@@ -269,6 +444,11 @@ var ComponentHead = class {
|
|
|
269
444
|
* @internal
|
|
270
445
|
*/
|
|
271
446
|
__publicField(this, "__element");
|
|
447
|
+
/**
|
|
448
|
+
* Runtime behavior used when `validateProps(...)` encounters invalid input.
|
|
449
|
+
* Defaults to `'throw'`.
|
|
450
|
+
*/
|
|
451
|
+
__publicField(this, "__propValidationMode");
|
|
272
452
|
/**
|
|
273
453
|
* Emits a custom DOM event from the component host element.
|
|
274
454
|
*
|
|
@@ -292,6 +472,7 @@ var ComponentHead = class {
|
|
|
292
472
|
this.ctx = ctx;
|
|
293
473
|
this.start = start;
|
|
294
474
|
this.end = end;
|
|
475
|
+
this.__propValidationMode = propValidationMode;
|
|
295
476
|
}
|
|
296
477
|
/**
|
|
297
478
|
* Finds a parent context instance by constructor type from the captured
|
|
@@ -354,7 +535,7 @@ var ComponentHead = class {
|
|
|
354
535
|
);
|
|
355
536
|
}
|
|
356
537
|
/**
|
|
357
|
-
* Validates selected incoming props
|
|
538
|
+
* Validates selected incoming props at runtime.
|
|
358
539
|
*
|
|
359
540
|
* Only keys listed in `schema` are checked. Validation throws immediately
|
|
360
541
|
* on the first invalid prop and does not mutate `head.props`.
|
|
@@ -363,7 +544,8 @@ var ComponentHead = class {
|
|
|
363
544
|
* known prop names while still allowing you to validate only a subset.
|
|
364
545
|
*
|
|
365
546
|
* Validators typically come from `pval`, but custom user validators are also
|
|
366
|
-
* supported.
|
|
547
|
+
* supported. Custom validators may throw their own `Error`, though `pval.fail(...)`
|
|
548
|
+
* is recommended so nested validators can preserve the exact failing prop path.
|
|
367
549
|
*
|
|
368
550
|
* Example:
|
|
369
551
|
* ```ts
|
|
@@ -373,15 +555,38 @@ var ComponentHead = class {
|
|
|
373
555
|
* })
|
|
374
556
|
* ```
|
|
375
557
|
*
|
|
558
|
+
* Example with a custom validator:
|
|
559
|
+
* ```ts
|
|
560
|
+
* const isNonEmptyString: PropValidator<string> = (value, name) => {
|
|
561
|
+
* if (typeof value !== 'string' || value.trim() === '') {
|
|
562
|
+
* pval.fail(name, 'expected non-empty string')
|
|
563
|
+
* }
|
|
564
|
+
* }
|
|
565
|
+
* ```
|
|
566
|
+
*
|
|
376
567
|
* @param schema - Validators to apply to selected incoming props.
|
|
377
568
|
*/
|
|
378
569
|
validateProps(schema) {
|
|
570
|
+
if (this.__propValidationMode === "off") return;
|
|
379
571
|
const props = this.props;
|
|
380
572
|
for (const name in schema) {
|
|
381
573
|
const validator = schema[name];
|
|
382
574
|
if (!validator) continue;
|
|
383
575
|
const validateProp = validator;
|
|
384
|
-
|
|
576
|
+
try {
|
|
577
|
+
validateProp(props[name], name, this);
|
|
578
|
+
} catch (error) {
|
|
579
|
+
const enrichedError = formatComponentValidationError(
|
|
580
|
+
this.__element,
|
|
581
|
+
name,
|
|
582
|
+
error
|
|
583
|
+
);
|
|
584
|
+
if (this.__propValidationMode === "warn") {
|
|
585
|
+
warningHandler.warning(enrichedError.message, enrichedError);
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
throw enrichedError;
|
|
589
|
+
}
|
|
385
590
|
}
|
|
386
591
|
}
|
|
387
592
|
/**
|
|
@@ -417,33 +622,6 @@ var addUnbinder = (node, unbinder) => {
|
|
|
417
622
|
getBindData(node).unbinders.push(unbinder);
|
|
418
623
|
};
|
|
419
624
|
|
|
420
|
-
// src/log/warnings.ts
|
|
421
|
-
var warnings = {
|
|
422
|
-
[8 /* ModelRequiresRef */]: (el) => `Model binding requires a ref at ${el.outerHTML}`,
|
|
423
|
-
[7 /* ModelNotSupportOnElement */]: (el) => `Model binding is not supported on ${el.tagName} element at ${el.outerHTML}`,
|
|
424
|
-
[0 /* MissingBindingExpression */]: (name, el) => `${name} binding expression is missing at ${el.outerHTML}`,
|
|
425
|
-
[1 /* InvalidForExpression */]: (name, forPath, el) => `invalid ${name} expression: ${forPath} at ${el.outerHTML}`,
|
|
426
|
-
[2 /* BindingRequiresObjectExpressions */]: (name, el) => `${name} requires object expression at ${el.outerHTML}`,
|
|
427
|
-
[3 /* KeyIsEmpty */]: (name, el) => `${name} binder: key is empty on ${el.outerHTML}.`,
|
|
428
|
-
[4 /* PropertyAssignmentFailed */]: (key, tag, value, e) => ({
|
|
429
|
-
msg: `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
|
430
|
-
args: [e]
|
|
431
|
-
}),
|
|
432
|
-
[5 /* MissingEventType */]: (name, el) => `${name} binding missing event type at ${el.outerHTML}`,
|
|
433
|
-
[6 /* ErrorLog */]: (msg, e) => ({ msg, args: [e] })
|
|
434
|
-
};
|
|
435
|
-
var warning = (type, ...args) => {
|
|
436
|
-
const msg = warnings[type];
|
|
437
|
-
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
438
|
-
const handler = warningHandler.warning;
|
|
439
|
-
if (!handler) return;
|
|
440
|
-
if (isString(item)) handler(item);
|
|
441
|
-
else handler(item, ...item.args);
|
|
442
|
-
};
|
|
443
|
-
var warningHandler = {
|
|
444
|
-
warning: console.warn
|
|
445
|
-
};
|
|
446
|
-
|
|
447
625
|
// src/bind/switch.ts
|
|
448
626
|
var switches = {};
|
|
449
627
|
var switchCounter = {};
|
|
@@ -849,16 +1027,6 @@ var isScope = (value) => {
|
|
|
849
1027
|
return scopeSymbol2 in value;
|
|
850
1028
|
};
|
|
851
1029
|
|
|
852
|
-
// src/reactivity/refSymbols.ts
|
|
853
|
-
var refSymbol = Symbol("ref");
|
|
854
|
-
var srefSymbol = Symbol("sref");
|
|
855
|
-
var rawSymbol = Symbol("raw");
|
|
856
|
-
|
|
857
|
-
// src/reactivity/isRef.ts
|
|
858
|
-
var isRef = (value) => {
|
|
859
|
-
return value != null && value[srefSymbol] === 1;
|
|
860
|
-
};
|
|
861
|
-
|
|
862
1030
|
// src/directives/context.ts
|
|
863
1031
|
var contextDirective = {
|
|
864
1032
|
collectRefObj: true,
|
|
@@ -1431,7 +1599,8 @@ var ComponentBinder = class {
|
|
|
1431
1599
|
component,
|
|
1432
1600
|
capturedContext,
|
|
1433
1601
|
startOfComponent,
|
|
1434
|
-
endOfComponent
|
|
1602
|
+
endOfComponent,
|
|
1603
|
+
binder.__config.propValidationMode
|
|
1435
1604
|
);
|
|
1436
1605
|
const componentCtx2 = useScope(() => {
|
|
1437
1606
|
var _a2;
|
|
@@ -3859,6 +4028,15 @@ var _RegorConfig = class _RegorConfig {
|
|
|
3859
4028
|
__publicField(this, "forGrowThreshold", 10);
|
|
3860
4029
|
__publicField(this, "globalContext");
|
|
3861
4030
|
__publicField(this, "useInterpolation", true);
|
|
4031
|
+
/**
|
|
4032
|
+
* Controls how `head.validateProps(...)` behaves when a validator fails.
|
|
4033
|
+
*
|
|
4034
|
+
* - `'throw'` (default): rethrows the validation error immediately.
|
|
4035
|
+
* - `'warn'`: forwards the validation error to `warningHandler.warning(...)`
|
|
4036
|
+
* and continues.
|
|
4037
|
+
* - `'off'`: skips runtime prop validation entirely.
|
|
4038
|
+
*/
|
|
4039
|
+
__publicField(this, "propValidationMode", "throw");
|
|
3862
4040
|
this.setDirectives("r-");
|
|
3863
4041
|
if (globalContext) {
|
|
3864
4042
|
this.globalContext = globalContext;
|
|
@@ -6140,113 +6318,6 @@ var defineComponent = (template, options = {}) => {
|
|
|
6140
6318
|
};
|
|
6141
6319
|
};
|
|
6142
6320
|
|
|
6143
|
-
// src/app/propValidators.ts
|
|
6144
|
-
var fail = (name, message) => {
|
|
6145
|
-
throw new Error(`Invalid prop "${name}": ${message}.`);
|
|
6146
|
-
};
|
|
6147
|
-
var describeValue = (value) => {
|
|
6148
|
-
var _a;
|
|
6149
|
-
if (value === null) return "null";
|
|
6150
|
-
if (value === void 0) return "undefined";
|
|
6151
|
-
if (typeof value === "string") return "string";
|
|
6152
|
-
if (typeof value === "number") return "number";
|
|
6153
|
-
if (typeof value === "boolean") return "boolean";
|
|
6154
|
-
if (typeof value === "bigint") return "bigint";
|
|
6155
|
-
if (typeof value === "symbol") return "symbol";
|
|
6156
|
-
if (typeof value === "function") return "function";
|
|
6157
|
-
if (isArray(value)) return "array";
|
|
6158
|
-
if (value instanceof Date) return "Date";
|
|
6159
|
-
if (value instanceof RegExp) return "RegExp";
|
|
6160
|
-
if (value instanceof Map) return "Map";
|
|
6161
|
-
if (value instanceof Set) return "Set";
|
|
6162
|
-
const ctorName = (_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name;
|
|
6163
|
-
return ctorName && ctorName !== "Object" ? ctorName : "object";
|
|
6164
|
-
};
|
|
6165
|
-
var formatLiteral = (value) => {
|
|
6166
|
-
if (typeof value === "string") return `"${value}"`;
|
|
6167
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
6168
|
-
return String(value);
|
|
6169
|
-
}
|
|
6170
|
-
if (value === null) return "null";
|
|
6171
|
-
if (value === void 0) return "undefined";
|
|
6172
|
-
return describeValue(value);
|
|
6173
|
-
};
|
|
6174
|
-
var isString2 = (value, name) => {
|
|
6175
|
-
if (typeof value !== "string") fail(name, "expected string");
|
|
6176
|
-
};
|
|
6177
|
-
var isNumber = (value, name) => {
|
|
6178
|
-
if (typeof value !== "number") fail(name, "expected number");
|
|
6179
|
-
};
|
|
6180
|
-
var isBoolean = (value, name) => {
|
|
6181
|
-
if (typeof value !== "boolean") fail(name, "expected boolean");
|
|
6182
|
-
};
|
|
6183
|
-
var isClass = (ctor) => {
|
|
6184
|
-
return (value, name) => {
|
|
6185
|
-
if (!(value instanceof ctor)) {
|
|
6186
|
-
fail(name, `expected instance of ${ctor.name || "provided class"}`);
|
|
6187
|
-
}
|
|
6188
|
-
};
|
|
6189
|
-
};
|
|
6190
|
-
var optional = (validator) => {
|
|
6191
|
-
return (value, name, head) => {
|
|
6192
|
-
if (value === void 0) return;
|
|
6193
|
-
validator(value, name, head);
|
|
6194
|
-
};
|
|
6195
|
-
};
|
|
6196
|
-
var nullable = (validator) => {
|
|
6197
|
-
return (value, name, head) => {
|
|
6198
|
-
if (value === null) return;
|
|
6199
|
-
validator(value, name, head);
|
|
6200
|
-
};
|
|
6201
|
-
};
|
|
6202
|
-
var oneOf = (values) => {
|
|
6203
|
-
return (value, name) => {
|
|
6204
|
-
if (values.includes(value)) return;
|
|
6205
|
-
fail(
|
|
6206
|
-
name,
|
|
6207
|
-
`expected one of ${values.map((x) => formatLiteral(x)).join(", ")}`
|
|
6208
|
-
);
|
|
6209
|
-
};
|
|
6210
|
-
};
|
|
6211
|
-
var arrayOf = (validator) => {
|
|
6212
|
-
return (value, name, head) => {
|
|
6213
|
-
if (!isArray(value)) fail(name, "expected array");
|
|
6214
|
-
const items = value;
|
|
6215
|
-
for (let i = 0; i < items.length; ++i) {
|
|
6216
|
-
validator(items[i], `${name}[${i}]`, head);
|
|
6217
|
-
}
|
|
6218
|
-
};
|
|
6219
|
-
};
|
|
6220
|
-
var shape = (schema) => {
|
|
6221
|
-
return (value, name, head) => {
|
|
6222
|
-
if (!isObject(value)) fail(name, "expected object");
|
|
6223
|
-
const record = value;
|
|
6224
|
-
for (const key in schema) {
|
|
6225
|
-
const validator = schema[key];
|
|
6226
|
-
validator(record[key], `${name}.${key}`, head);
|
|
6227
|
-
}
|
|
6228
|
-
};
|
|
6229
|
-
};
|
|
6230
|
-
var refOf = (validator) => {
|
|
6231
|
-
return (value, name, head) => {
|
|
6232
|
-
if (!isRef(value)) fail(name, "expected ref");
|
|
6233
|
-
const refValue = value;
|
|
6234
|
-
validator(refValue(), `${name}.value`, head);
|
|
6235
|
-
};
|
|
6236
|
-
};
|
|
6237
|
-
var pval = {
|
|
6238
|
-
isString: isString2,
|
|
6239
|
-
isNumber,
|
|
6240
|
-
isBoolean,
|
|
6241
|
-
isClass,
|
|
6242
|
-
optional,
|
|
6243
|
-
nullable,
|
|
6244
|
-
oneOf,
|
|
6245
|
-
arrayOf,
|
|
6246
|
-
shape,
|
|
6247
|
-
refOf
|
|
6248
|
-
};
|
|
6249
|
-
|
|
6250
6321
|
// src/composition/ContextRegistry.ts
|
|
6251
6322
|
var ContextRegistry = class {
|
|
6252
6323
|
constructor() {
|