@coxwave/tap-kit-types 2.0.0 → 2.0.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/index.d.ts +1986 -400
- package/dist/index.js +699 -134
- package/dist/index.js.map +1 -1
- package/package.json +13 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -161,178 +159,745 @@ var MaterialViewerError = class _MaterialViewerError extends TapKitError {
|
|
|
161
159
|
|
|
162
160
|
// src/protocol/alarm.ts
|
|
163
161
|
var ALARM_DURATION = 18e3;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
|
|
163
|
+
// ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.2/node_modules/valibot/dist/index.js
|
|
164
|
+
var store;
|
|
165
|
+
// @__NO_SIDE_EFFECTS__
|
|
166
|
+
function getGlobalConfig(config2) {
|
|
167
|
+
return {
|
|
168
|
+
lang: config2?.lang ?? store?.lang,
|
|
169
|
+
message: config2?.message,
|
|
170
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
171
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
var store2;
|
|
175
|
+
// @__NO_SIDE_EFFECTS__
|
|
176
|
+
function getGlobalMessage(lang) {
|
|
177
|
+
return store2?.get(lang);
|
|
178
|
+
}
|
|
179
|
+
var store3;
|
|
180
|
+
// @__NO_SIDE_EFFECTS__
|
|
181
|
+
function getSchemaMessage(lang) {
|
|
182
|
+
return store3?.get(lang);
|
|
183
|
+
}
|
|
184
|
+
var store4;
|
|
185
|
+
// @__NO_SIDE_EFFECTS__
|
|
186
|
+
function getSpecificMessage(reference, lang) {
|
|
187
|
+
return store4?.get(reference)?.get(lang);
|
|
188
|
+
}
|
|
189
|
+
// @__NO_SIDE_EFFECTS__
|
|
190
|
+
function _stringify(input) {
|
|
191
|
+
const type = typeof input;
|
|
192
|
+
if (type === "string") {
|
|
193
|
+
return `"${input}"`;
|
|
194
|
+
}
|
|
195
|
+
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
196
|
+
return `${input}`;
|
|
197
|
+
}
|
|
198
|
+
if (type === "object" || type === "function") {
|
|
199
|
+
return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
200
|
+
}
|
|
201
|
+
return type;
|
|
202
|
+
}
|
|
203
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
204
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
205
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
206
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
207
|
+
const issue = {
|
|
208
|
+
kind: context.kind,
|
|
209
|
+
type: context.type,
|
|
210
|
+
input,
|
|
211
|
+
expected,
|
|
212
|
+
received,
|
|
213
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
214
|
+
requirement: context.requirement,
|
|
215
|
+
path: other?.path,
|
|
216
|
+
issues: other?.issues,
|
|
217
|
+
lang: config2.lang,
|
|
218
|
+
abortEarly: config2.abortEarly,
|
|
219
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
220
|
+
};
|
|
221
|
+
const isSchema = context.kind === "schema";
|
|
222
|
+
const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
223
|
+
if (message2 !== void 0) {
|
|
224
|
+
issue.message = typeof message2 === "function" ? (
|
|
225
|
+
// @ts-expect-error
|
|
226
|
+
message2(issue)
|
|
227
|
+
) : message2;
|
|
228
|
+
}
|
|
229
|
+
if (isSchema) {
|
|
230
|
+
dataset.typed = false;
|
|
231
|
+
}
|
|
232
|
+
if (dataset.issues) {
|
|
233
|
+
dataset.issues.push(issue);
|
|
234
|
+
} else {
|
|
235
|
+
dataset.issues = [issue];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// @__NO_SIDE_EFFECTS__
|
|
239
|
+
function _getStandardProps(context) {
|
|
240
|
+
return {
|
|
241
|
+
version: 1,
|
|
242
|
+
vendor: "valibot",
|
|
243
|
+
validate(value2) {
|
|
244
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// @__NO_SIDE_EFFECTS__
|
|
249
|
+
function _isValidObjectKey(object2, key) {
|
|
250
|
+
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
251
|
+
}
|
|
252
|
+
// @__NO_SIDE_EFFECTS__
|
|
253
|
+
function _joinExpects(values2, separator) {
|
|
254
|
+
const list = [...new Set(values2)];
|
|
255
|
+
if (list.length > 1) {
|
|
256
|
+
return `(${list.join(` ${separator} `)})`;
|
|
257
|
+
}
|
|
258
|
+
return list[0] ?? "never";
|
|
259
|
+
}
|
|
260
|
+
// @__NO_SIDE_EFFECTS__
|
|
261
|
+
function getFallback(schema, dataset, config2) {
|
|
262
|
+
return typeof schema.fallback === "function" ? (
|
|
263
|
+
// @ts-expect-error
|
|
264
|
+
schema.fallback(dataset, config2)
|
|
265
|
+
) : (
|
|
266
|
+
// @ts-expect-error
|
|
267
|
+
schema.fallback
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
// @__NO_SIDE_EFFECTS__
|
|
271
|
+
function getDefault(schema, dataset, config2) {
|
|
272
|
+
return typeof schema.default === "function" ? (
|
|
273
|
+
// @ts-expect-error
|
|
274
|
+
schema.default(dataset, config2)
|
|
275
|
+
) : (
|
|
276
|
+
// @ts-expect-error
|
|
277
|
+
schema.default
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
// @__NO_SIDE_EFFECTS__
|
|
281
|
+
function any() {
|
|
282
|
+
return {
|
|
283
|
+
kind: "schema",
|
|
284
|
+
type: "any",
|
|
285
|
+
reference: any,
|
|
286
|
+
expects: "any",
|
|
287
|
+
async: false,
|
|
288
|
+
get "~standard"() {
|
|
289
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
290
|
+
},
|
|
291
|
+
"~run"(dataset) {
|
|
292
|
+
dataset.typed = true;
|
|
293
|
+
return dataset;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// @__NO_SIDE_EFFECTS__
|
|
298
|
+
function array(item, message2) {
|
|
299
|
+
return {
|
|
300
|
+
kind: "schema",
|
|
301
|
+
type: "array",
|
|
302
|
+
reference: array,
|
|
303
|
+
expects: "Array",
|
|
304
|
+
async: false,
|
|
305
|
+
item,
|
|
306
|
+
message: message2,
|
|
307
|
+
get "~standard"() {
|
|
308
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
309
|
+
},
|
|
310
|
+
"~run"(dataset, config2) {
|
|
311
|
+
const input = dataset.value;
|
|
312
|
+
if (Array.isArray(input)) {
|
|
313
|
+
dataset.typed = true;
|
|
314
|
+
dataset.value = [];
|
|
315
|
+
for (let key = 0; key < input.length; key++) {
|
|
316
|
+
const value2 = input[key];
|
|
317
|
+
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
318
|
+
if (itemDataset.issues) {
|
|
319
|
+
const pathItem = {
|
|
320
|
+
type: "array",
|
|
321
|
+
origin: "value",
|
|
322
|
+
input,
|
|
323
|
+
key,
|
|
324
|
+
value: value2
|
|
325
|
+
};
|
|
326
|
+
for (const issue of itemDataset.issues) {
|
|
327
|
+
if (issue.path) {
|
|
328
|
+
issue.path.unshift(pathItem);
|
|
329
|
+
} else {
|
|
330
|
+
issue.path = [pathItem];
|
|
331
|
+
}
|
|
332
|
+
dataset.issues?.push(issue);
|
|
333
|
+
}
|
|
334
|
+
if (!dataset.issues) {
|
|
335
|
+
dataset.issues = itemDataset.issues;
|
|
336
|
+
}
|
|
337
|
+
if (config2.abortEarly) {
|
|
338
|
+
dataset.typed = false;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (!itemDataset.typed) {
|
|
343
|
+
dataset.typed = false;
|
|
344
|
+
}
|
|
345
|
+
dataset.value.push(itemDataset.value);
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
_addIssue(this, "type", dataset, config2);
|
|
349
|
+
}
|
|
350
|
+
return dataset;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
// @__NO_SIDE_EFFECTS__
|
|
355
|
+
function boolean(message2) {
|
|
356
|
+
return {
|
|
357
|
+
kind: "schema",
|
|
358
|
+
type: "boolean",
|
|
359
|
+
reference: boolean,
|
|
360
|
+
expects: "boolean",
|
|
361
|
+
async: false,
|
|
362
|
+
message: message2,
|
|
363
|
+
get "~standard"() {
|
|
364
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
365
|
+
},
|
|
366
|
+
"~run"(dataset, config2) {
|
|
367
|
+
if (typeof dataset.value === "boolean") {
|
|
368
|
+
dataset.typed = true;
|
|
369
|
+
} else {
|
|
370
|
+
_addIssue(this, "type", dataset, config2);
|
|
371
|
+
}
|
|
372
|
+
return dataset;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
// @__NO_SIDE_EFFECTS__
|
|
377
|
+
function lazy(getter) {
|
|
378
|
+
return {
|
|
379
|
+
kind: "schema",
|
|
380
|
+
type: "lazy",
|
|
381
|
+
reference: lazy,
|
|
382
|
+
expects: "unknown",
|
|
383
|
+
async: false,
|
|
384
|
+
getter,
|
|
385
|
+
get "~standard"() {
|
|
386
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
387
|
+
},
|
|
388
|
+
"~run"(dataset, config2) {
|
|
389
|
+
return this.getter(dataset.value)["~run"](dataset, config2);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
// @__NO_SIDE_EFFECTS__
|
|
394
|
+
function literal(literal_, message2) {
|
|
395
|
+
return {
|
|
396
|
+
kind: "schema",
|
|
397
|
+
type: "literal",
|
|
398
|
+
reference: literal,
|
|
399
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
400
|
+
async: false,
|
|
401
|
+
literal: literal_,
|
|
402
|
+
message: message2,
|
|
403
|
+
get "~standard"() {
|
|
404
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
405
|
+
},
|
|
406
|
+
"~run"(dataset, config2) {
|
|
407
|
+
if (dataset.value === this.literal) {
|
|
408
|
+
dataset.typed = true;
|
|
409
|
+
} else {
|
|
410
|
+
_addIssue(this, "type", dataset, config2);
|
|
411
|
+
}
|
|
412
|
+
return dataset;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
// @__NO_SIDE_EFFECTS__
|
|
417
|
+
function number(message2) {
|
|
418
|
+
return {
|
|
419
|
+
kind: "schema",
|
|
420
|
+
type: "number",
|
|
421
|
+
reference: number,
|
|
422
|
+
expects: "number",
|
|
423
|
+
async: false,
|
|
424
|
+
message: message2,
|
|
425
|
+
get "~standard"() {
|
|
426
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
427
|
+
},
|
|
428
|
+
"~run"(dataset, config2) {
|
|
429
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
|
|
430
|
+
dataset.typed = true;
|
|
431
|
+
} else {
|
|
432
|
+
_addIssue(this, "type", dataset, config2);
|
|
433
|
+
}
|
|
434
|
+
return dataset;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
// @__NO_SIDE_EFFECTS__
|
|
439
|
+
function object(entries2, message2) {
|
|
440
|
+
return {
|
|
441
|
+
kind: "schema",
|
|
442
|
+
type: "object",
|
|
443
|
+
reference: object,
|
|
444
|
+
expects: "Object",
|
|
445
|
+
async: false,
|
|
446
|
+
entries: entries2,
|
|
447
|
+
message: message2,
|
|
448
|
+
get "~standard"() {
|
|
449
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
450
|
+
},
|
|
451
|
+
"~run"(dataset, config2) {
|
|
452
|
+
const input = dataset.value;
|
|
453
|
+
if (input && typeof input === "object") {
|
|
454
|
+
dataset.typed = true;
|
|
455
|
+
dataset.value = {};
|
|
456
|
+
for (const key in this.entries) {
|
|
457
|
+
const valueSchema = this.entries[key];
|
|
458
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
|
|
459
|
+
valueSchema.default !== void 0) {
|
|
460
|
+
const value2 = key in input ? (
|
|
461
|
+
// @ts-expect-error
|
|
462
|
+
input[key]
|
|
463
|
+
) : /* @__PURE__ */ getDefault(valueSchema);
|
|
464
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
465
|
+
if (valueDataset.issues) {
|
|
466
|
+
const pathItem = {
|
|
467
|
+
type: "object",
|
|
468
|
+
origin: "value",
|
|
469
|
+
input,
|
|
470
|
+
key,
|
|
471
|
+
value: value2
|
|
472
|
+
};
|
|
473
|
+
for (const issue of valueDataset.issues) {
|
|
474
|
+
if (issue.path) {
|
|
475
|
+
issue.path.unshift(pathItem);
|
|
476
|
+
} else {
|
|
477
|
+
issue.path = [pathItem];
|
|
478
|
+
}
|
|
479
|
+
dataset.issues?.push(issue);
|
|
480
|
+
}
|
|
481
|
+
if (!dataset.issues) {
|
|
482
|
+
dataset.issues = valueDataset.issues;
|
|
483
|
+
}
|
|
484
|
+
if (config2.abortEarly) {
|
|
485
|
+
dataset.typed = false;
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (!valueDataset.typed) {
|
|
490
|
+
dataset.typed = false;
|
|
491
|
+
}
|
|
492
|
+
dataset.value[key] = valueDataset.value;
|
|
493
|
+
} else if (valueSchema.fallback !== void 0) {
|
|
494
|
+
dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
495
|
+
} else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
496
|
+
_addIssue(this, "key", dataset, config2, {
|
|
497
|
+
input: void 0,
|
|
498
|
+
expected: `"${key}"`,
|
|
499
|
+
path: [
|
|
500
|
+
{
|
|
501
|
+
type: "object",
|
|
502
|
+
origin: "key",
|
|
503
|
+
input,
|
|
504
|
+
key,
|
|
505
|
+
// @ts-expect-error
|
|
506
|
+
value: input[key]
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
});
|
|
510
|
+
if (config2.abortEarly) {
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
_addIssue(this, "type", dataset, config2);
|
|
517
|
+
}
|
|
518
|
+
return dataset;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
// @__NO_SIDE_EFFECTS__
|
|
523
|
+
function optional(wrapped, default_) {
|
|
524
|
+
return {
|
|
525
|
+
kind: "schema",
|
|
526
|
+
type: "optional",
|
|
527
|
+
reference: optional,
|
|
528
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
529
|
+
async: false,
|
|
530
|
+
wrapped,
|
|
531
|
+
default: default_,
|
|
532
|
+
get "~standard"() {
|
|
533
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
534
|
+
},
|
|
535
|
+
"~run"(dataset, config2) {
|
|
536
|
+
if (dataset.value === void 0) {
|
|
537
|
+
if (this.default !== void 0) {
|
|
538
|
+
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
539
|
+
}
|
|
540
|
+
if (dataset.value === void 0) {
|
|
541
|
+
dataset.typed = true;
|
|
542
|
+
return dataset;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return this.wrapped["~run"](dataset, config2);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
// @__NO_SIDE_EFFECTS__
|
|
550
|
+
function record(key, value2, message2) {
|
|
551
|
+
return {
|
|
552
|
+
kind: "schema",
|
|
553
|
+
type: "record",
|
|
554
|
+
reference: record,
|
|
555
|
+
expects: "Object",
|
|
556
|
+
async: false,
|
|
557
|
+
key,
|
|
558
|
+
value: value2,
|
|
559
|
+
message: message2,
|
|
560
|
+
get "~standard"() {
|
|
561
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
562
|
+
},
|
|
563
|
+
"~run"(dataset, config2) {
|
|
564
|
+
const input = dataset.value;
|
|
565
|
+
if (input && typeof input === "object") {
|
|
566
|
+
dataset.typed = true;
|
|
567
|
+
dataset.value = {};
|
|
568
|
+
for (const entryKey in input) {
|
|
569
|
+
if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
570
|
+
const entryValue = input[entryKey];
|
|
571
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
572
|
+
if (keyDataset.issues) {
|
|
573
|
+
const pathItem = {
|
|
574
|
+
type: "object",
|
|
575
|
+
origin: "key",
|
|
576
|
+
input,
|
|
577
|
+
key: entryKey,
|
|
578
|
+
value: entryValue
|
|
579
|
+
};
|
|
580
|
+
for (const issue of keyDataset.issues) {
|
|
581
|
+
issue.path = [pathItem];
|
|
582
|
+
dataset.issues?.push(issue);
|
|
583
|
+
}
|
|
584
|
+
if (!dataset.issues) {
|
|
585
|
+
dataset.issues = keyDataset.issues;
|
|
586
|
+
}
|
|
587
|
+
if (config2.abortEarly) {
|
|
588
|
+
dataset.typed = false;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const valueDataset = this.value["~run"](
|
|
593
|
+
{ value: entryValue },
|
|
594
|
+
config2
|
|
595
|
+
);
|
|
596
|
+
if (valueDataset.issues) {
|
|
597
|
+
const pathItem = {
|
|
598
|
+
type: "object",
|
|
599
|
+
origin: "value",
|
|
600
|
+
input,
|
|
601
|
+
key: entryKey,
|
|
602
|
+
value: entryValue
|
|
603
|
+
};
|
|
604
|
+
for (const issue of valueDataset.issues) {
|
|
605
|
+
if (issue.path) {
|
|
606
|
+
issue.path.unshift(pathItem);
|
|
607
|
+
} else {
|
|
608
|
+
issue.path = [pathItem];
|
|
609
|
+
}
|
|
610
|
+
dataset.issues?.push(issue);
|
|
611
|
+
}
|
|
612
|
+
if (!dataset.issues) {
|
|
613
|
+
dataset.issues = valueDataset.issues;
|
|
614
|
+
}
|
|
615
|
+
if (config2.abortEarly) {
|
|
616
|
+
dataset.typed = false;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (!keyDataset.typed || !valueDataset.typed) {
|
|
621
|
+
dataset.typed = false;
|
|
622
|
+
}
|
|
623
|
+
if (keyDataset.typed) {
|
|
624
|
+
dataset.value[keyDataset.value] = valueDataset.value;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
} else {
|
|
629
|
+
_addIssue(this, "type", dataset, config2);
|
|
630
|
+
}
|
|
631
|
+
return dataset;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
// @__NO_SIDE_EFFECTS__
|
|
636
|
+
function string(message2) {
|
|
637
|
+
return {
|
|
638
|
+
kind: "schema",
|
|
639
|
+
type: "string",
|
|
640
|
+
reference: string,
|
|
641
|
+
expects: "string",
|
|
642
|
+
async: false,
|
|
643
|
+
message: message2,
|
|
644
|
+
get "~standard"() {
|
|
645
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
646
|
+
},
|
|
647
|
+
"~run"(dataset, config2) {
|
|
648
|
+
if (typeof dataset.value === "string") {
|
|
649
|
+
dataset.typed = true;
|
|
650
|
+
} else {
|
|
651
|
+
_addIssue(this, "type", dataset, config2);
|
|
652
|
+
}
|
|
653
|
+
return dataset;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
// @__NO_SIDE_EFFECTS__
|
|
658
|
+
function _subIssues(datasets) {
|
|
659
|
+
let issues;
|
|
660
|
+
if (datasets) {
|
|
661
|
+
for (const dataset of datasets) {
|
|
662
|
+
if (issues) {
|
|
663
|
+
issues.push(...dataset.issues);
|
|
664
|
+
} else {
|
|
665
|
+
issues = dataset.issues;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return issues;
|
|
670
|
+
}
|
|
671
|
+
// @__NO_SIDE_EFFECTS__
|
|
672
|
+
function union(options, message2) {
|
|
673
|
+
return {
|
|
674
|
+
kind: "schema",
|
|
675
|
+
type: "union",
|
|
676
|
+
reference: union,
|
|
677
|
+
expects: /* @__PURE__ */ _joinExpects(
|
|
678
|
+
options.map((option) => option.expects),
|
|
679
|
+
"|"
|
|
680
|
+
),
|
|
681
|
+
async: false,
|
|
682
|
+
options,
|
|
683
|
+
message: message2,
|
|
684
|
+
get "~standard"() {
|
|
685
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
686
|
+
},
|
|
687
|
+
"~run"(dataset, config2) {
|
|
688
|
+
let validDataset;
|
|
689
|
+
let typedDatasets;
|
|
690
|
+
let untypedDatasets;
|
|
691
|
+
for (const schema of this.options) {
|
|
692
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
693
|
+
if (optionDataset.typed) {
|
|
694
|
+
if (optionDataset.issues) {
|
|
695
|
+
if (typedDatasets) {
|
|
696
|
+
typedDatasets.push(optionDataset);
|
|
697
|
+
} else {
|
|
698
|
+
typedDatasets = [optionDataset];
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
validDataset = optionDataset;
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
} else {
|
|
705
|
+
if (untypedDatasets) {
|
|
706
|
+
untypedDatasets.push(optionDataset);
|
|
707
|
+
} else {
|
|
708
|
+
untypedDatasets = [optionDataset];
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (validDataset) {
|
|
713
|
+
return validDataset;
|
|
714
|
+
}
|
|
715
|
+
if (typedDatasets) {
|
|
716
|
+
if (typedDatasets.length === 1) {
|
|
717
|
+
return typedDatasets[0];
|
|
718
|
+
}
|
|
719
|
+
_addIssue(this, "type", dataset, config2, {
|
|
720
|
+
issues: /* @__PURE__ */ _subIssues(typedDatasets)
|
|
721
|
+
});
|
|
722
|
+
dataset.typed = true;
|
|
723
|
+
} else if (untypedDatasets?.length === 1) {
|
|
724
|
+
return untypedDatasets[0];
|
|
725
|
+
} else {
|
|
726
|
+
_addIssue(this, "type", dataset, config2, {
|
|
727
|
+
issues: /* @__PURE__ */ _subIssues(untypedDatasets)
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
return dataset;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// src/protocol/schema.ts
|
|
736
|
+
var CSSStyleSchema = record(
|
|
737
|
+
string(),
|
|
738
|
+
union([string(), number()])
|
|
167
739
|
);
|
|
168
|
-
var AlarmElementPropsSchema =
|
|
169
|
-
style:
|
|
170
|
-
className:
|
|
171
|
-
id:
|
|
172
|
-
src:
|
|
173
|
-
alt:
|
|
174
|
-
href:
|
|
175
|
-
target:
|
|
176
|
-
type:
|
|
177
|
-
placeholder:
|
|
178
|
-
value:
|
|
179
|
-
disabled:
|
|
740
|
+
var AlarmElementPropsSchema = object({
|
|
741
|
+
style: optional(CSSStyleSchema),
|
|
742
|
+
className: optional(string()),
|
|
743
|
+
id: optional(string()),
|
|
744
|
+
src: optional(string()),
|
|
745
|
+
alt: optional(string()),
|
|
746
|
+
href: optional(string()),
|
|
747
|
+
target: optional(string()),
|
|
748
|
+
type: optional(string()),
|
|
749
|
+
placeholder: optional(string()),
|
|
750
|
+
value: optional(string()),
|
|
751
|
+
disabled: optional(boolean())
|
|
180
752
|
});
|
|
181
|
-
var AlarmElementSchema =
|
|
182
|
-
() =>
|
|
183
|
-
tag:
|
|
184
|
-
props:
|
|
185
|
-
children:
|
|
186
|
-
payload:
|
|
187
|
-
|
|
188
|
-
message:
|
|
189
|
-
pingMessageId:
|
|
753
|
+
var AlarmElementSchema = lazy(
|
|
754
|
+
() => object({
|
|
755
|
+
tag: string(),
|
|
756
|
+
props: optional(AlarmElementPropsSchema),
|
|
757
|
+
children: optional(array(union([AlarmElementSchema, string()]))),
|
|
758
|
+
payload: optional(
|
|
759
|
+
object({
|
|
760
|
+
message: string(),
|
|
761
|
+
pingMessageId: optional(string())
|
|
190
762
|
})
|
|
191
763
|
)
|
|
192
764
|
})
|
|
193
765
|
);
|
|
194
|
-
var AlarmMessageInstanceSchema =
|
|
766
|
+
var AlarmMessageInstanceSchema = object({
|
|
195
767
|
content: AlarmElementSchema,
|
|
196
|
-
duration:
|
|
768
|
+
duration: optional(number())
|
|
197
769
|
});
|
|
198
|
-
var TapReadySchema =
|
|
199
|
-
type:
|
|
200
|
-
gaId:
|
|
770
|
+
var TapReadySchema = object({
|
|
771
|
+
type: literal("tap:ready"),
|
|
772
|
+
gaId: string()
|
|
201
773
|
});
|
|
202
|
-
var TapCloseSchema =
|
|
203
|
-
type:
|
|
774
|
+
var TapCloseSchema = object({
|
|
775
|
+
type: literal("tap:close")
|
|
204
776
|
});
|
|
205
|
-
var TimelineSeekSchema =
|
|
206
|
-
type:
|
|
207
|
-
clipId:
|
|
208
|
-
clipPlayHead:
|
|
777
|
+
var TimelineSeekSchema = object({
|
|
778
|
+
type: literal("timeline:seek"),
|
|
779
|
+
clipId: string(),
|
|
780
|
+
clipPlayHead: number()
|
|
209
781
|
});
|
|
210
|
-
var AlarmClickSchema =
|
|
211
|
-
type:
|
|
782
|
+
var AlarmClickSchema = object({
|
|
783
|
+
type: literal("alarm:click"),
|
|
212
784
|
messageInfo: AlarmMessageInstanceSchema
|
|
213
785
|
});
|
|
214
|
-
var AlarmFadeInSchema =
|
|
215
|
-
type:
|
|
786
|
+
var AlarmFadeInSchema = object({
|
|
787
|
+
type: literal("alarm:fadeIn"),
|
|
216
788
|
messageInfo: AlarmMessageInstanceSchema
|
|
217
789
|
});
|
|
218
|
-
var PopUpOpenSchema =
|
|
219
|
-
type:
|
|
220
|
-
popUpInfo:
|
|
221
|
-
html:
|
|
222
|
-
requestId:
|
|
790
|
+
var PopUpOpenSchema = object({
|
|
791
|
+
type: literal("popUp:open"),
|
|
792
|
+
popUpInfo: object({
|
|
793
|
+
html: string(),
|
|
794
|
+
requestId: optional(string())
|
|
223
795
|
})
|
|
224
796
|
});
|
|
225
|
-
var PopUpCloseSchema =
|
|
226
|
-
type:
|
|
797
|
+
var PopUpCloseSchema = object({
|
|
798
|
+
type: literal("popUp:close")
|
|
227
799
|
});
|
|
228
|
-
var MaterialViewOpenSchema =
|
|
229
|
-
type:
|
|
230
|
-
materialId:
|
|
231
|
-
presignedUrl:
|
|
232
|
-
pageStart:
|
|
233
|
-
pageEnd:
|
|
234
|
-
nonce:
|
|
800
|
+
var MaterialViewOpenSchema = object({
|
|
801
|
+
type: literal("material:view:open"),
|
|
802
|
+
materialId: string(),
|
|
803
|
+
presignedUrl: string(),
|
|
804
|
+
pageStart: number(),
|
|
805
|
+
pageEnd: number(),
|
|
806
|
+
nonce: optional(union([string(), number()]))
|
|
235
807
|
});
|
|
236
|
-
var MaterialViewCloseSchema =
|
|
237
|
-
type:
|
|
808
|
+
var MaterialViewCloseSchema = object({
|
|
809
|
+
type: literal("material:view:close")
|
|
238
810
|
});
|
|
239
|
-
var MaterialViewErrorSchema =
|
|
240
|
-
type:
|
|
241
|
-
materialId:
|
|
242
|
-
error:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
811
|
+
var MaterialViewErrorSchema = object({
|
|
812
|
+
type: literal("material:view:error"),
|
|
813
|
+
materialId: string(),
|
|
814
|
+
error: union([
|
|
815
|
+
literal("fetch_failed"),
|
|
816
|
+
literal("expired_url"),
|
|
817
|
+
literal("extraction_failed"),
|
|
818
|
+
literal("unknown")
|
|
247
819
|
]),
|
|
248
|
-
message:
|
|
820
|
+
message: optional(string())
|
|
249
821
|
});
|
|
250
|
-
var ContainerModeChangeSchema =
|
|
251
|
-
type:
|
|
252
|
-
mode:
|
|
253
|
-
nonce:
|
|
822
|
+
var ContainerModeChangeSchema = object({
|
|
823
|
+
type: literal("container:mode:change"),
|
|
824
|
+
mode: union([literal("floating"), literal("sidebar")]),
|
|
825
|
+
nonce: optional(union([string(), number()]))
|
|
254
826
|
});
|
|
255
|
-
var ContainerModeChangeAckSchema =
|
|
256
|
-
type:
|
|
257
|
-
success:
|
|
258
|
-
currentMode:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
827
|
+
var ContainerModeChangeAckSchema = object({
|
|
828
|
+
type: literal("container:mode:change:ack"),
|
|
829
|
+
success: boolean(),
|
|
830
|
+
currentMode: union([
|
|
831
|
+
literal("floating"),
|
|
832
|
+
literal("sidebar"),
|
|
833
|
+
literal("floating-forced")
|
|
262
834
|
]),
|
|
263
|
-
nonce:
|
|
835
|
+
nonce: optional(union([string(), number()]))
|
|
264
836
|
});
|
|
265
|
-
var ContainerLayoutStateChangedSchema =
|
|
266
|
-
type:
|
|
267
|
-
layoutState:
|
|
268
|
-
|
|
269
|
-
v.literal("sidebar"),
|
|
270
|
-
v.literal("floating-forced")
|
|
271
|
-
])
|
|
837
|
+
var ContainerLayoutStateChangedSchema = object({
|
|
838
|
+
type: literal("container:layout:state:changed"),
|
|
839
|
+
layoutState: union([literal("floating"), literal("sidebar")]),
|
|
840
|
+
isNarrowViewport: optional(boolean())
|
|
272
841
|
});
|
|
273
|
-
var ViewportResizeSchema =
|
|
274
|
-
type:
|
|
275
|
-
viewportWidth:
|
|
842
|
+
var ViewportResizeSchema = object({
|
|
843
|
+
type: literal("viewport:resize"),
|
|
844
|
+
viewportWidth: number()
|
|
276
845
|
});
|
|
277
|
-
var ConfigUpdateSchema =
|
|
278
|
-
type:
|
|
279
|
-
apiKey:
|
|
280
|
-
hostOrigin:
|
|
281
|
-
tapUrl:
|
|
282
|
-
apiUrl:
|
|
283
|
-
environment:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
846
|
+
var ConfigUpdateSchema = object({
|
|
847
|
+
type: literal("config:update"),
|
|
848
|
+
apiKey: optional(string()),
|
|
849
|
+
hostOrigin: optional(string()),
|
|
850
|
+
tapUrl: optional(string()),
|
|
851
|
+
apiUrl: optional(string()),
|
|
852
|
+
environment: optional(
|
|
853
|
+
union([
|
|
854
|
+
literal("dev"),
|
|
855
|
+
literal("prod"),
|
|
856
|
+
literal("demo"),
|
|
857
|
+
literal("staging")
|
|
289
858
|
])
|
|
290
859
|
),
|
|
291
|
-
language:
|
|
292
|
-
userId:
|
|
293
|
-
courseId:
|
|
294
|
-
clipId:
|
|
295
|
-
clipPlayHead:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
top: v.optional(v.string()),
|
|
311
|
-
left: v.optional(v.string()),
|
|
312
|
-
right: v.optional(v.string()),
|
|
313
|
-
bottom: v.optional(v.string())
|
|
860
|
+
language: optional(string()),
|
|
861
|
+
userId: optional(string()),
|
|
862
|
+
courseId: optional(string()),
|
|
863
|
+
clipId: optional(string()),
|
|
864
|
+
clipPlayHead: optional(number()),
|
|
865
|
+
mode: optional(
|
|
866
|
+
union([literal("inline"), literal("floating"), literal("sidebar")])
|
|
867
|
+
),
|
|
868
|
+
allowLayoutToggle: optional(boolean()),
|
|
869
|
+
container: optional(
|
|
870
|
+
object({
|
|
871
|
+
floatingConfig: optional(
|
|
872
|
+
object({
|
|
873
|
+
position: optional(
|
|
874
|
+
object({
|
|
875
|
+
top: optional(string()),
|
|
876
|
+
left: optional(string()),
|
|
877
|
+
right: optional(string()),
|
|
878
|
+
bottom: optional(string())
|
|
314
879
|
})
|
|
315
880
|
),
|
|
316
|
-
width:
|
|
317
|
-
height:
|
|
318
|
-
borderRadius:
|
|
881
|
+
width: optional(string()),
|
|
882
|
+
height: optional(string()),
|
|
883
|
+
borderRadius: optional(string())
|
|
319
884
|
})
|
|
320
885
|
),
|
|
321
|
-
sidebarConfig:
|
|
322
|
-
|
|
323
|
-
maxWidth:
|
|
324
|
-
minViewportWidth:
|
|
886
|
+
sidebarConfig: optional(
|
|
887
|
+
object({
|
|
888
|
+
maxWidth: optional(string()),
|
|
889
|
+
minViewportWidth: optional(number())
|
|
325
890
|
})
|
|
326
891
|
)
|
|
327
892
|
})
|
|
328
893
|
)
|
|
329
894
|
});
|
|
330
|
-
var GAEventSchema =
|
|
331
|
-
type:
|
|
332
|
-
payload:
|
|
895
|
+
var GAEventSchema = object({
|
|
896
|
+
type: literal("GA_EVENT"),
|
|
897
|
+
payload: record(string(), any())
|
|
333
898
|
// 유연한 payload 구조
|
|
334
899
|
});
|
|
335
|
-
var TapMessageSchema =
|
|
900
|
+
var TapMessageSchema = union([
|
|
336
901
|
TapReadySchema,
|
|
337
902
|
TapCloseSchema,
|
|
338
903
|
TimelineSeekSchema,
|