@rolldown/browser 1.0.0-beta.8-commit.baf6ca1 → 1.0.0-beta.8-commit.101b994
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/browser.mjs +1368 -396
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/experimental-index.cjs +1 -1
- package/dist/experimental-index.d.cts +1 -1
- package/dist/experimental-index.d.mts +1 -1
- package/dist/experimental-index.mjs +1 -1
- package/dist/filter-index.d.cts +1 -1
- package/dist/filter-index.d.mts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/parallel-plugin-worker.cjs +1 -1
- package/dist/parallel-plugin-worker.mjs +1 -1
- package/dist/parallel-plugin.d.cts +1 -1
- package/dist/parallel-plugin.d.mts +1 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{input-options.d-BFt2wKBM.d.cts → input-options.d-CBiF1NIG.d.cts} +9 -8
- package/dist/shared/{input-options.d-9IzFBPMw.d.mts → input-options.d-LWRQj-14.d.mts} +9 -8
- package/dist/shared/{src-glXqJCVJ.cjs → src-C7uewwtc.cjs} +1702 -391
- package/dist/shared/{src-DN1_B1_m.mjs → src-o_UI5Uda.mjs} +1709 -393
- package/package.json +3 -5
|
@@ -4,23 +4,21 @@ const require_filter_index = require('./filter-index-ChddWdsi.cjs');
|
|
|
4
4
|
const require_parse_ast_index = require('./parse-ast-index-DTWvag1h.cjs');
|
|
5
5
|
const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
|
|
6
6
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
|
-
const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
|
|
8
7
|
const ansis = require_chunk.__toESM(require("ansis"));
|
|
9
|
-
const valibot = require_chunk.__toESM(require("valibot"));
|
|
10
8
|
const node_os = require_chunk.__toESM(require("node:os"));
|
|
11
9
|
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
12
10
|
|
|
13
11
|
//#region package.json
|
|
14
|
-
var version = "1.0.0-beta.8-commit.
|
|
15
|
-
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
12
|
+
var version = "1.0.0-beta.8-commit.101b994";
|
|
13
|
+
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
16
14
|
|
|
17
15
|
//#endregion
|
|
18
16
|
//#region src/builtin-plugin/utils.ts
|
|
19
17
|
function makeBuiltinPluginCallable(plugin) {
|
|
20
18
|
let callablePlugin = new src_rolldown_binding_wasi_cjs.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
21
19
|
const wrappedPlugin = plugin;
|
|
22
|
-
for (const key in callablePlugin) wrappedPlugin[key] = function(...args) {
|
|
23
|
-
return callablePlugin[key](...args);
|
|
20
|
+
for (const key in callablePlugin) wrappedPlugin[key] = function(...args$1) {
|
|
21
|
+
return callablePlugin[key](...args$1);
|
|
24
22
|
};
|
|
25
23
|
return wrappedPlugin;
|
|
26
24
|
}
|
|
@@ -293,11 +291,11 @@ const DEFINED_HOOK_NAMES = {
|
|
|
293
291
|
|
|
294
292
|
//#endregion
|
|
295
293
|
//#region src/utils/async-flatten.ts
|
|
296
|
-
async function asyncFlatten(array) {
|
|
294
|
+
async function asyncFlatten(array$1) {
|
|
297
295
|
do
|
|
298
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
299
|
-
while (array.some((v) => v?.then));
|
|
300
|
-
return array;
|
|
296
|
+
array$1 = (await Promise.all(array$1)).flat(Infinity);
|
|
297
|
+
while (array$1.some((v) => v?.then));
|
|
298
|
+
return array$1;
|
|
301
299
|
}
|
|
302
300
|
|
|
303
301
|
//#endregion
|
|
@@ -412,201 +410,1509 @@ function getSortedPlugins(hookName, plugins) {
|
|
|
412
410
|
];
|
|
413
411
|
}
|
|
414
412
|
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
|
|
415
|
+
var store;
|
|
416
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
417
|
+
function getGlobalConfig(config2) {
|
|
418
|
+
return {
|
|
419
|
+
lang: config2?.lang ?? store?.lang,
|
|
420
|
+
message: config2?.message,
|
|
421
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
422
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
var store2;
|
|
426
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
427
|
+
function getGlobalMessage(lang) {
|
|
428
|
+
return store2?.get(lang);
|
|
429
|
+
}
|
|
430
|
+
var store3;
|
|
431
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
432
|
+
function getSchemaMessage(lang) {
|
|
433
|
+
return store3?.get(lang);
|
|
434
|
+
}
|
|
435
|
+
var store4;
|
|
436
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
437
|
+
function getSpecificMessage(reference, lang) {
|
|
438
|
+
return store4?.get(reference)?.get(lang);
|
|
439
|
+
}
|
|
440
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
441
|
+
function _stringify(input) {
|
|
442
|
+
const type = typeof input;
|
|
443
|
+
if (type === "string") return `"${input}"`;
|
|
444
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
445
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
446
|
+
return type;
|
|
447
|
+
}
|
|
448
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
449
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
450
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
451
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
452
|
+
const issue = {
|
|
453
|
+
kind: context.kind,
|
|
454
|
+
type: context.type,
|
|
455
|
+
input,
|
|
456
|
+
expected,
|
|
457
|
+
received,
|
|
458
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
459
|
+
requirement: context.requirement,
|
|
460
|
+
path: other?.path,
|
|
461
|
+
issues: other?.issues,
|
|
462
|
+
lang: config2.lang,
|
|
463
|
+
abortEarly: config2.abortEarly,
|
|
464
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
465
|
+
};
|
|
466
|
+
const isSchema = context.kind === "schema";
|
|
467
|
+
const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
468
|
+
if (message !== void 0) issue.message = typeof message === "function" ? message(issue) : message;
|
|
469
|
+
if (isSchema) dataset.typed = false;
|
|
470
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
471
|
+
else dataset.issues = [issue];
|
|
472
|
+
}
|
|
473
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
474
|
+
function _getStandardProps(context) {
|
|
475
|
+
return {
|
|
476
|
+
version: 1,
|
|
477
|
+
vendor: "valibot",
|
|
478
|
+
validate(value2) {
|
|
479
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
484
|
+
function _isValidObjectKey(object2, key) {
|
|
485
|
+
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
486
|
+
}
|
|
487
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
488
|
+
function _joinExpects(values2, separator) {
|
|
489
|
+
const list = [...new Set(values2)];
|
|
490
|
+
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
491
|
+
return list[0] ?? "never";
|
|
492
|
+
}
|
|
493
|
+
var ValiError = class extends Error {
|
|
494
|
+
/**
|
|
495
|
+
* Creates a Valibot error with useful information.
|
|
496
|
+
*
|
|
497
|
+
* @param issues The error issues.
|
|
498
|
+
*/
|
|
499
|
+
constructor(issues) {
|
|
500
|
+
super(issues[0].message);
|
|
501
|
+
this.name = "ValiError";
|
|
502
|
+
this.issues = issues;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
506
|
+
function args(schema) {
|
|
507
|
+
return {
|
|
508
|
+
kind: "transformation",
|
|
509
|
+
type: "args",
|
|
510
|
+
reference: args,
|
|
511
|
+
async: false,
|
|
512
|
+
schema,
|
|
513
|
+
"~run"(dataset, config2) {
|
|
514
|
+
const func = dataset.value;
|
|
515
|
+
dataset.value = (...args_) => {
|
|
516
|
+
const argsDataset = this.schema["~run"]({ value: args_ }, config2);
|
|
517
|
+
if (argsDataset.issues) throw new ValiError(argsDataset.issues);
|
|
518
|
+
return func(...argsDataset.value);
|
|
519
|
+
};
|
|
520
|
+
return dataset;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
525
|
+
function awaitAsync() {
|
|
526
|
+
return {
|
|
527
|
+
kind: "transformation",
|
|
528
|
+
type: "await",
|
|
529
|
+
reference: awaitAsync,
|
|
530
|
+
async: true,
|
|
531
|
+
async "~run"(dataset) {
|
|
532
|
+
dataset.value = await dataset.value;
|
|
533
|
+
return dataset;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
538
|
+
function description(description_) {
|
|
539
|
+
return {
|
|
540
|
+
kind: "metadata",
|
|
541
|
+
type: "description",
|
|
542
|
+
reference: description,
|
|
543
|
+
description: description_
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
547
|
+
function returns(schema) {
|
|
548
|
+
return {
|
|
549
|
+
kind: "transformation",
|
|
550
|
+
type: "returns",
|
|
551
|
+
reference: returns,
|
|
552
|
+
async: false,
|
|
553
|
+
schema,
|
|
554
|
+
"~run"(dataset, config2) {
|
|
555
|
+
const func = dataset.value;
|
|
556
|
+
dataset.value = (...args_) => {
|
|
557
|
+
const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config2);
|
|
558
|
+
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
559
|
+
return returnsDataset.value;
|
|
560
|
+
};
|
|
561
|
+
return dataset;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
566
|
+
function returnsAsync(schema) {
|
|
567
|
+
return {
|
|
568
|
+
kind: "transformation",
|
|
569
|
+
type: "returns",
|
|
570
|
+
reference: returnsAsync,
|
|
571
|
+
async: false,
|
|
572
|
+
schema,
|
|
573
|
+
"~run"(dataset, config2) {
|
|
574
|
+
const func = dataset.value;
|
|
575
|
+
dataset.value = async (...args_) => {
|
|
576
|
+
const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config2);
|
|
577
|
+
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
578
|
+
return returnsDataset.value;
|
|
579
|
+
};
|
|
580
|
+
return dataset;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
585
|
+
function getFallback(schema, dataset, config2) {
|
|
586
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
587
|
+
}
|
|
588
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
589
|
+
function getDefault(schema, dataset, config2) {
|
|
590
|
+
return typeof schema.default === "function" ? schema.default(dataset, config2) : schema.default;
|
|
591
|
+
}
|
|
592
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
593
|
+
function any() {
|
|
594
|
+
return {
|
|
595
|
+
kind: "schema",
|
|
596
|
+
type: "any",
|
|
597
|
+
reference: any,
|
|
598
|
+
expects: "any",
|
|
599
|
+
async: false,
|
|
600
|
+
get "~standard"() {
|
|
601
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
602
|
+
},
|
|
603
|
+
"~run"(dataset) {
|
|
604
|
+
dataset.typed = true;
|
|
605
|
+
return dataset;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
610
|
+
function array(item, message) {
|
|
611
|
+
return {
|
|
612
|
+
kind: "schema",
|
|
613
|
+
type: "array",
|
|
614
|
+
reference: array,
|
|
615
|
+
expects: "Array",
|
|
616
|
+
async: false,
|
|
617
|
+
item,
|
|
618
|
+
message,
|
|
619
|
+
get "~standard"() {
|
|
620
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
621
|
+
},
|
|
622
|
+
"~run"(dataset, config2) {
|
|
623
|
+
const input = dataset.value;
|
|
624
|
+
if (Array.isArray(input)) {
|
|
625
|
+
dataset.typed = true;
|
|
626
|
+
dataset.value = [];
|
|
627
|
+
for (let key = 0; key < input.length; key++) {
|
|
628
|
+
const value2 = input[key];
|
|
629
|
+
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
630
|
+
if (itemDataset.issues) {
|
|
631
|
+
const pathItem = {
|
|
632
|
+
type: "array",
|
|
633
|
+
origin: "value",
|
|
634
|
+
input,
|
|
635
|
+
key,
|
|
636
|
+
value: value2
|
|
637
|
+
};
|
|
638
|
+
for (const issue of itemDataset.issues) {
|
|
639
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
640
|
+
else issue.path = [pathItem];
|
|
641
|
+
dataset.issues?.push(issue);
|
|
642
|
+
}
|
|
643
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
644
|
+
if (config2.abortEarly) {
|
|
645
|
+
dataset.typed = false;
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
650
|
+
dataset.value.push(itemDataset.value);
|
|
651
|
+
}
|
|
652
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
653
|
+
return dataset;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
658
|
+
function boolean(message) {
|
|
659
|
+
return {
|
|
660
|
+
kind: "schema",
|
|
661
|
+
type: "boolean",
|
|
662
|
+
reference: boolean,
|
|
663
|
+
expects: "boolean",
|
|
664
|
+
async: false,
|
|
665
|
+
message,
|
|
666
|
+
get "~standard"() {
|
|
667
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
668
|
+
},
|
|
669
|
+
"~run"(dataset, config2) {
|
|
670
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
671
|
+
else _addIssue(this, "type", dataset, config2);
|
|
672
|
+
return dataset;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
677
|
+
function custom(check2, message) {
|
|
678
|
+
return {
|
|
679
|
+
kind: "schema",
|
|
680
|
+
type: "custom",
|
|
681
|
+
reference: custom,
|
|
682
|
+
expects: "unknown",
|
|
683
|
+
async: false,
|
|
684
|
+
check: check2,
|
|
685
|
+
message,
|
|
686
|
+
get "~standard"() {
|
|
687
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
688
|
+
},
|
|
689
|
+
"~run"(dataset, config2) {
|
|
690
|
+
if (this.check(dataset.value)) dataset.typed = true;
|
|
691
|
+
else _addIssue(this, "type", dataset, config2);
|
|
692
|
+
return dataset;
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
697
|
+
function enum_(enum__, message) {
|
|
698
|
+
const options = [];
|
|
699
|
+
for (const key in enum__) if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) options.push(enum__[key]);
|
|
700
|
+
return {
|
|
701
|
+
kind: "schema",
|
|
702
|
+
type: "enum",
|
|
703
|
+
reference: enum_,
|
|
704
|
+
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
705
|
+
async: false,
|
|
706
|
+
enum: enum__,
|
|
707
|
+
options,
|
|
708
|
+
message,
|
|
709
|
+
get "~standard"() {
|
|
710
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
711
|
+
},
|
|
712
|
+
"~run"(dataset, config2) {
|
|
713
|
+
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
714
|
+
else _addIssue(this, "type", dataset, config2);
|
|
715
|
+
return dataset;
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
720
|
+
function function_(message) {
|
|
721
|
+
return {
|
|
722
|
+
kind: "schema",
|
|
723
|
+
type: "function",
|
|
724
|
+
reference: function_,
|
|
725
|
+
expects: "Function",
|
|
726
|
+
async: false,
|
|
727
|
+
message,
|
|
728
|
+
get "~standard"() {
|
|
729
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
730
|
+
},
|
|
731
|
+
"~run"(dataset, config2) {
|
|
732
|
+
if (typeof dataset.value === "function") dataset.typed = true;
|
|
733
|
+
else _addIssue(this, "type", dataset, config2);
|
|
734
|
+
return dataset;
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
739
|
+
function instance(class_, message) {
|
|
740
|
+
return {
|
|
741
|
+
kind: "schema",
|
|
742
|
+
type: "instance",
|
|
743
|
+
reference: instance,
|
|
744
|
+
expects: class_.name,
|
|
745
|
+
async: false,
|
|
746
|
+
class: class_,
|
|
747
|
+
message,
|
|
748
|
+
get "~standard"() {
|
|
749
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
750
|
+
},
|
|
751
|
+
"~run"(dataset, config2) {
|
|
752
|
+
if (dataset.value instanceof this.class) dataset.typed = true;
|
|
753
|
+
else _addIssue(this, "type", dataset, config2);
|
|
754
|
+
return dataset;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
759
|
+
function literal(literal_, message) {
|
|
760
|
+
return {
|
|
761
|
+
kind: "schema",
|
|
762
|
+
type: "literal",
|
|
763
|
+
reference: literal,
|
|
764
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
765
|
+
async: false,
|
|
766
|
+
literal: literal_,
|
|
767
|
+
message,
|
|
768
|
+
get "~standard"() {
|
|
769
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
770
|
+
},
|
|
771
|
+
"~run"(dataset, config2) {
|
|
772
|
+
if (dataset.value === this.literal) dataset.typed = true;
|
|
773
|
+
else _addIssue(this, "type", dataset, config2);
|
|
774
|
+
return dataset;
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
779
|
+
function looseObject(entries, message) {
|
|
780
|
+
return {
|
|
781
|
+
kind: "schema",
|
|
782
|
+
type: "loose_object",
|
|
783
|
+
reference: looseObject,
|
|
784
|
+
expects: "Object",
|
|
785
|
+
async: false,
|
|
786
|
+
entries,
|
|
787
|
+
message,
|
|
788
|
+
get "~standard"() {
|
|
789
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
790
|
+
},
|
|
791
|
+
"~run"(dataset, config2) {
|
|
792
|
+
const input = dataset.value;
|
|
793
|
+
if (input && typeof input === "object") {
|
|
794
|
+
dataset.typed = true;
|
|
795
|
+
dataset.value = {};
|
|
796
|
+
for (const key in this.entries) {
|
|
797
|
+
const valueSchema = this.entries[key];
|
|
798
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
799
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
800
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
801
|
+
if (valueDataset.issues) {
|
|
802
|
+
const pathItem = {
|
|
803
|
+
type: "object",
|
|
804
|
+
origin: "value",
|
|
805
|
+
input,
|
|
806
|
+
key,
|
|
807
|
+
value: value2
|
|
808
|
+
};
|
|
809
|
+
for (const issue of valueDataset.issues) {
|
|
810
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
811
|
+
else issue.path = [pathItem];
|
|
812
|
+
dataset.issues?.push(issue);
|
|
813
|
+
}
|
|
814
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
815
|
+
if (config2.abortEarly) {
|
|
816
|
+
dataset.typed = false;
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
821
|
+
dataset.value[key] = valueDataset.value;
|
|
822
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
823
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
824
|
+
_addIssue(this, "key", dataset, config2, {
|
|
825
|
+
input: void 0,
|
|
826
|
+
expected: `"${key}"`,
|
|
827
|
+
path: [{
|
|
828
|
+
type: "object",
|
|
829
|
+
origin: "key",
|
|
830
|
+
input,
|
|
831
|
+
key,
|
|
832
|
+
value: input[key]
|
|
833
|
+
}]
|
|
834
|
+
});
|
|
835
|
+
if (config2.abortEarly) break;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (!dataset.issues || !config2.abortEarly) {
|
|
839
|
+
for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
|
|
840
|
+
}
|
|
841
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
842
|
+
return dataset;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
847
|
+
function never(message) {
|
|
848
|
+
return {
|
|
849
|
+
kind: "schema",
|
|
850
|
+
type: "never",
|
|
851
|
+
reference: never,
|
|
852
|
+
expects: "never",
|
|
853
|
+
async: false,
|
|
854
|
+
message,
|
|
855
|
+
get "~standard"() {
|
|
856
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
857
|
+
},
|
|
858
|
+
"~run"(dataset, config2) {
|
|
859
|
+
_addIssue(this, "type", dataset, config2);
|
|
860
|
+
return dataset;
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
865
|
+
function nullish(wrapped, default_) {
|
|
866
|
+
return {
|
|
867
|
+
kind: "schema",
|
|
868
|
+
type: "nullish",
|
|
869
|
+
reference: nullish,
|
|
870
|
+
expects: `(${wrapped.expects} | null | undefined)`,
|
|
871
|
+
async: false,
|
|
872
|
+
wrapped,
|
|
873
|
+
default: default_,
|
|
874
|
+
get "~standard"() {
|
|
875
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
876
|
+
},
|
|
877
|
+
"~run"(dataset, config2) {
|
|
878
|
+
if (dataset.value === null || dataset.value === void 0) {
|
|
879
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
880
|
+
if (dataset.value === null || dataset.value === void 0) {
|
|
881
|
+
dataset.typed = true;
|
|
882
|
+
return dataset;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return this.wrapped["~run"](dataset, config2);
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
890
|
+
function number(message) {
|
|
891
|
+
return {
|
|
892
|
+
kind: "schema",
|
|
893
|
+
type: "number",
|
|
894
|
+
reference: number,
|
|
895
|
+
expects: "number",
|
|
896
|
+
async: false,
|
|
897
|
+
message,
|
|
898
|
+
get "~standard"() {
|
|
899
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
900
|
+
},
|
|
901
|
+
"~run"(dataset, config2) {
|
|
902
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
903
|
+
else _addIssue(this, "type", dataset, config2);
|
|
904
|
+
return dataset;
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
909
|
+
function object(entries, message) {
|
|
910
|
+
return {
|
|
911
|
+
kind: "schema",
|
|
912
|
+
type: "object",
|
|
913
|
+
reference: object,
|
|
914
|
+
expects: "Object",
|
|
915
|
+
async: false,
|
|
916
|
+
entries,
|
|
917
|
+
message,
|
|
918
|
+
get "~standard"() {
|
|
919
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
920
|
+
},
|
|
921
|
+
"~run"(dataset, config2) {
|
|
922
|
+
const input = dataset.value;
|
|
923
|
+
if (input && typeof input === "object") {
|
|
924
|
+
dataset.typed = true;
|
|
925
|
+
dataset.value = {};
|
|
926
|
+
for (const key in this.entries) {
|
|
927
|
+
const valueSchema = this.entries[key];
|
|
928
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
929
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
930
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
931
|
+
if (valueDataset.issues) {
|
|
932
|
+
const pathItem = {
|
|
933
|
+
type: "object",
|
|
934
|
+
origin: "value",
|
|
935
|
+
input,
|
|
936
|
+
key,
|
|
937
|
+
value: value2
|
|
938
|
+
};
|
|
939
|
+
for (const issue of valueDataset.issues) {
|
|
940
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
941
|
+
else issue.path = [pathItem];
|
|
942
|
+
dataset.issues?.push(issue);
|
|
943
|
+
}
|
|
944
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
945
|
+
if (config2.abortEarly) {
|
|
946
|
+
dataset.typed = false;
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
951
|
+
dataset.value[key] = valueDataset.value;
|
|
952
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
953
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
954
|
+
_addIssue(this, "key", dataset, config2, {
|
|
955
|
+
input: void 0,
|
|
956
|
+
expected: `"${key}"`,
|
|
957
|
+
path: [{
|
|
958
|
+
type: "object",
|
|
959
|
+
origin: "key",
|
|
960
|
+
input,
|
|
961
|
+
key,
|
|
962
|
+
value: input[key]
|
|
963
|
+
}]
|
|
964
|
+
});
|
|
965
|
+
if (config2.abortEarly) break;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
969
|
+
return dataset;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
974
|
+
function optional(wrapped, default_) {
|
|
975
|
+
return {
|
|
976
|
+
kind: "schema",
|
|
977
|
+
type: "optional",
|
|
978
|
+
reference: optional,
|
|
979
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
980
|
+
async: false,
|
|
981
|
+
wrapped,
|
|
982
|
+
default: default_,
|
|
983
|
+
get "~standard"() {
|
|
984
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
985
|
+
},
|
|
986
|
+
"~run"(dataset, config2) {
|
|
987
|
+
if (dataset.value === void 0) {
|
|
988
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
989
|
+
if (dataset.value === void 0) {
|
|
990
|
+
dataset.typed = true;
|
|
991
|
+
return dataset;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return this.wrapped["~run"](dataset, config2);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
999
|
+
function picklist(options, message) {
|
|
1000
|
+
return {
|
|
1001
|
+
kind: "schema",
|
|
1002
|
+
type: "picklist",
|
|
1003
|
+
reference: picklist,
|
|
1004
|
+
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
1005
|
+
async: false,
|
|
1006
|
+
options,
|
|
1007
|
+
message,
|
|
1008
|
+
get "~standard"() {
|
|
1009
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1010
|
+
},
|
|
1011
|
+
"~run"(dataset, config2) {
|
|
1012
|
+
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
1013
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1014
|
+
return dataset;
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1019
|
+
function promise(message) {
|
|
1020
|
+
return {
|
|
1021
|
+
kind: "schema",
|
|
1022
|
+
type: "promise",
|
|
1023
|
+
reference: promise,
|
|
1024
|
+
expects: "Promise",
|
|
1025
|
+
async: false,
|
|
1026
|
+
message,
|
|
1027
|
+
get "~standard"() {
|
|
1028
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1029
|
+
},
|
|
1030
|
+
"~run"(dataset, config2) {
|
|
1031
|
+
if (dataset.value instanceof Promise) dataset.typed = true;
|
|
1032
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1033
|
+
return dataset;
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1038
|
+
function record(key, value2, message) {
|
|
1039
|
+
return {
|
|
1040
|
+
kind: "schema",
|
|
1041
|
+
type: "record",
|
|
1042
|
+
reference: record,
|
|
1043
|
+
expects: "Object",
|
|
1044
|
+
async: false,
|
|
1045
|
+
key,
|
|
1046
|
+
value: value2,
|
|
1047
|
+
message,
|
|
1048
|
+
get "~standard"() {
|
|
1049
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1050
|
+
},
|
|
1051
|
+
"~run"(dataset, config2) {
|
|
1052
|
+
const input = dataset.value;
|
|
1053
|
+
if (input && typeof input === "object") {
|
|
1054
|
+
dataset.typed = true;
|
|
1055
|
+
dataset.value = {};
|
|
1056
|
+
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
1057
|
+
const entryValue = input[entryKey];
|
|
1058
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
1059
|
+
if (keyDataset.issues) {
|
|
1060
|
+
const pathItem = {
|
|
1061
|
+
type: "object",
|
|
1062
|
+
origin: "key",
|
|
1063
|
+
input,
|
|
1064
|
+
key: entryKey,
|
|
1065
|
+
value: entryValue
|
|
1066
|
+
};
|
|
1067
|
+
for (const issue of keyDataset.issues) {
|
|
1068
|
+
issue.path = [pathItem];
|
|
1069
|
+
dataset.issues?.push(issue);
|
|
1070
|
+
}
|
|
1071
|
+
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
1072
|
+
if (config2.abortEarly) {
|
|
1073
|
+
dataset.typed = false;
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
const valueDataset = this.value["~run"]({ value: entryValue }, config2);
|
|
1078
|
+
if (valueDataset.issues) {
|
|
1079
|
+
const pathItem = {
|
|
1080
|
+
type: "object",
|
|
1081
|
+
origin: "value",
|
|
1082
|
+
input,
|
|
1083
|
+
key: entryKey,
|
|
1084
|
+
value: entryValue
|
|
1085
|
+
};
|
|
1086
|
+
for (const issue of valueDataset.issues) {
|
|
1087
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1088
|
+
else issue.path = [pathItem];
|
|
1089
|
+
dataset.issues?.push(issue);
|
|
1090
|
+
}
|
|
1091
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1092
|
+
if (config2.abortEarly) {
|
|
1093
|
+
dataset.typed = false;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
1098
|
+
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
1099
|
+
}
|
|
1100
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1101
|
+
return dataset;
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1106
|
+
function strictObject(entries, message) {
|
|
1107
|
+
return {
|
|
1108
|
+
kind: "schema",
|
|
1109
|
+
type: "strict_object",
|
|
1110
|
+
reference: strictObject,
|
|
1111
|
+
expects: "Object",
|
|
1112
|
+
async: false,
|
|
1113
|
+
entries,
|
|
1114
|
+
message,
|
|
1115
|
+
get "~standard"() {
|
|
1116
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1117
|
+
},
|
|
1118
|
+
"~run"(dataset, config2) {
|
|
1119
|
+
const input = dataset.value;
|
|
1120
|
+
if (input && typeof input === "object") {
|
|
1121
|
+
dataset.typed = true;
|
|
1122
|
+
dataset.value = {};
|
|
1123
|
+
for (const key in this.entries) {
|
|
1124
|
+
const valueSchema = this.entries[key];
|
|
1125
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
1126
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
1127
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
1128
|
+
if (valueDataset.issues) {
|
|
1129
|
+
const pathItem = {
|
|
1130
|
+
type: "object",
|
|
1131
|
+
origin: "value",
|
|
1132
|
+
input,
|
|
1133
|
+
key,
|
|
1134
|
+
value: value2
|
|
1135
|
+
};
|
|
1136
|
+
for (const issue of valueDataset.issues) {
|
|
1137
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1138
|
+
else issue.path = [pathItem];
|
|
1139
|
+
dataset.issues?.push(issue);
|
|
1140
|
+
}
|
|
1141
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1142
|
+
if (config2.abortEarly) {
|
|
1143
|
+
dataset.typed = false;
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
1148
|
+
dataset.value[key] = valueDataset.value;
|
|
1149
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
1150
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
1151
|
+
_addIssue(this, "key", dataset, config2, {
|
|
1152
|
+
input: void 0,
|
|
1153
|
+
expected: `"${key}"`,
|
|
1154
|
+
path: [{
|
|
1155
|
+
type: "object",
|
|
1156
|
+
origin: "key",
|
|
1157
|
+
input,
|
|
1158
|
+
key,
|
|
1159
|
+
value: input[key]
|
|
1160
|
+
}]
|
|
1161
|
+
});
|
|
1162
|
+
if (config2.abortEarly) break;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
if (!dataset.issues || !config2.abortEarly) {
|
|
1166
|
+
for (const key in input) if (!(key in this.entries)) {
|
|
1167
|
+
_addIssue(this, "key", dataset, config2, {
|
|
1168
|
+
input: key,
|
|
1169
|
+
expected: "never",
|
|
1170
|
+
path: [{
|
|
1171
|
+
type: "object",
|
|
1172
|
+
origin: "key",
|
|
1173
|
+
input,
|
|
1174
|
+
key,
|
|
1175
|
+
value: input[key]
|
|
1176
|
+
}]
|
|
1177
|
+
});
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1182
|
+
return dataset;
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1187
|
+
function string(message) {
|
|
1188
|
+
return {
|
|
1189
|
+
kind: "schema",
|
|
1190
|
+
type: "string",
|
|
1191
|
+
reference: string,
|
|
1192
|
+
expects: "string",
|
|
1193
|
+
async: false,
|
|
1194
|
+
message,
|
|
1195
|
+
get "~standard"() {
|
|
1196
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1197
|
+
},
|
|
1198
|
+
"~run"(dataset, config2) {
|
|
1199
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
1200
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1201
|
+
return dataset;
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1206
|
+
function tuple(items, message) {
|
|
1207
|
+
return {
|
|
1208
|
+
kind: "schema",
|
|
1209
|
+
type: "tuple",
|
|
1210
|
+
reference: tuple,
|
|
1211
|
+
expects: "Array",
|
|
1212
|
+
async: false,
|
|
1213
|
+
items,
|
|
1214
|
+
message,
|
|
1215
|
+
get "~standard"() {
|
|
1216
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1217
|
+
},
|
|
1218
|
+
"~run"(dataset, config2) {
|
|
1219
|
+
const input = dataset.value;
|
|
1220
|
+
if (Array.isArray(input)) {
|
|
1221
|
+
dataset.typed = true;
|
|
1222
|
+
dataset.value = [];
|
|
1223
|
+
for (let key = 0; key < this.items.length; key++) {
|
|
1224
|
+
const value2 = input[key];
|
|
1225
|
+
const itemDataset = this.items[key]["~run"]({ value: value2 }, config2);
|
|
1226
|
+
if (itemDataset.issues) {
|
|
1227
|
+
const pathItem = {
|
|
1228
|
+
type: "array",
|
|
1229
|
+
origin: "value",
|
|
1230
|
+
input,
|
|
1231
|
+
key,
|
|
1232
|
+
value: value2
|
|
1233
|
+
};
|
|
1234
|
+
for (const issue of itemDataset.issues) {
|
|
1235
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1236
|
+
else issue.path = [pathItem];
|
|
1237
|
+
dataset.issues?.push(issue);
|
|
1238
|
+
}
|
|
1239
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
1240
|
+
if (config2.abortEarly) {
|
|
1241
|
+
dataset.typed = false;
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
1246
|
+
dataset.value.push(itemDataset.value);
|
|
1247
|
+
}
|
|
1248
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1249
|
+
return dataset;
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1254
|
+
function _subIssues(datasets) {
|
|
1255
|
+
let issues;
|
|
1256
|
+
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
1257
|
+
else issues = dataset.issues;
|
|
1258
|
+
return issues;
|
|
1259
|
+
}
|
|
1260
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1261
|
+
function union(options, message) {
|
|
1262
|
+
return {
|
|
1263
|
+
kind: "schema",
|
|
1264
|
+
type: "union",
|
|
1265
|
+
reference: union,
|
|
1266
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1267
|
+
async: false,
|
|
1268
|
+
options,
|
|
1269
|
+
message,
|
|
1270
|
+
get "~standard"() {
|
|
1271
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1272
|
+
},
|
|
1273
|
+
"~run"(dataset, config2) {
|
|
1274
|
+
let validDataset;
|
|
1275
|
+
let typedDatasets;
|
|
1276
|
+
let untypedDatasets;
|
|
1277
|
+
for (const schema of this.options) {
|
|
1278
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
1279
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1280
|
+
else typedDatasets = [optionDataset];
|
|
1281
|
+
else {
|
|
1282
|
+
validDataset = optionDataset;
|
|
1283
|
+
break;
|
|
1284
|
+
}
|
|
1285
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1286
|
+
else untypedDatasets = [optionDataset];
|
|
1287
|
+
}
|
|
1288
|
+
if (validDataset) return validDataset;
|
|
1289
|
+
if (typedDatasets) {
|
|
1290
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1291
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1292
|
+
dataset.typed = true;
|
|
1293
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1294
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1295
|
+
return dataset;
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1300
|
+
function unionAsync(options, message) {
|
|
1301
|
+
return {
|
|
1302
|
+
kind: "schema",
|
|
1303
|
+
type: "union",
|
|
1304
|
+
reference: unionAsync,
|
|
1305
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1306
|
+
async: true,
|
|
1307
|
+
options,
|
|
1308
|
+
message,
|
|
1309
|
+
get "~standard"() {
|
|
1310
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1311
|
+
},
|
|
1312
|
+
async "~run"(dataset, config2) {
|
|
1313
|
+
let validDataset;
|
|
1314
|
+
let typedDatasets;
|
|
1315
|
+
let untypedDatasets;
|
|
1316
|
+
for (const schema of this.options) {
|
|
1317
|
+
const optionDataset = await schema["~run"]({ value: dataset.value }, config2);
|
|
1318
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1319
|
+
else typedDatasets = [optionDataset];
|
|
1320
|
+
else {
|
|
1321
|
+
validDataset = optionDataset;
|
|
1322
|
+
break;
|
|
1323
|
+
}
|
|
1324
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1325
|
+
else untypedDatasets = [optionDataset];
|
|
1326
|
+
}
|
|
1327
|
+
if (validDataset) return validDataset;
|
|
1328
|
+
if (typedDatasets) {
|
|
1329
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1330
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1331
|
+
dataset.typed = true;
|
|
1332
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1333
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1334
|
+
return dataset;
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1339
|
+
function keyof(schema, message) {
|
|
1340
|
+
return /* @__PURE__ */ picklist(Object.keys(schema.entries), message);
|
|
1341
|
+
}
|
|
1342
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1343
|
+
function omit(schema, keys) {
|
|
1344
|
+
const entries = { ...schema.entries };
|
|
1345
|
+
for (const key of keys) delete entries[key];
|
|
1346
|
+
return {
|
|
1347
|
+
...schema,
|
|
1348
|
+
entries,
|
|
1349
|
+
get "~standard"() {
|
|
1350
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1355
|
+
function pipe(...pipe2) {
|
|
1356
|
+
return {
|
|
1357
|
+
...pipe2[0],
|
|
1358
|
+
pipe: pipe2,
|
|
1359
|
+
get "~standard"() {
|
|
1360
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1361
|
+
},
|
|
1362
|
+
"~run"(dataset, config2) {
|
|
1363
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1364
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1365
|
+
dataset.typed = false;
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = item["~run"](dataset, config2);
|
|
1369
|
+
}
|
|
1370
|
+
return dataset;
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1375
|
+
function pipeAsync(...pipe2) {
|
|
1376
|
+
return {
|
|
1377
|
+
...pipe2[0],
|
|
1378
|
+
pipe: pipe2,
|
|
1379
|
+
async: true,
|
|
1380
|
+
get "~standard"() {
|
|
1381
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1382
|
+
},
|
|
1383
|
+
async "~run"(dataset, config2) {
|
|
1384
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1385
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1386
|
+
dataset.typed = false;
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = await item["~run"](dataset, config2);
|
|
1390
|
+
}
|
|
1391
|
+
return dataset;
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1396
|
+
function safeParse(schema, input, config2) {
|
|
1397
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
1398
|
+
return {
|
|
1399
|
+
typed: dataset.typed,
|
|
1400
|
+
success: !dataset.issues,
|
|
1401
|
+
output: dataset.value,
|
|
1402
|
+
issues: dataset.issues
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.0.0_valibot@1.0.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
|
|
1408
|
+
function handleError(message, config) {
|
|
1409
|
+
switch (config?.errorMode) {
|
|
1410
|
+
case "ignore": break;
|
|
1411
|
+
case "warn": {
|
|
1412
|
+
console.warn(message);
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
default: throw new Error(message);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
function convertAction(jsonSchema, valibotAction, config) {
|
|
1419
|
+
switch (valibotAction.type) {
|
|
1420
|
+
case "base64": {
|
|
1421
|
+
jsonSchema.contentEncoding = "base64";
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
case "bic":
|
|
1425
|
+
case "cuid2":
|
|
1426
|
+
case "decimal":
|
|
1427
|
+
case "digits":
|
|
1428
|
+
case "emoji":
|
|
1429
|
+
case "hexadecimal":
|
|
1430
|
+
case "hex_color":
|
|
1431
|
+
case "nanoid":
|
|
1432
|
+
case "octal":
|
|
1433
|
+
case "ulid": {
|
|
1434
|
+
jsonSchema.pattern = valibotAction.requirement.source;
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
case "description": {
|
|
1438
|
+
jsonSchema.description = valibotAction.description;
|
|
1439
|
+
break;
|
|
1440
|
+
}
|
|
1441
|
+
case "email": {
|
|
1442
|
+
jsonSchema.format = "email";
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1445
|
+
case "empty": {
|
|
1446
|
+
if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
|
|
1447
|
+
else {
|
|
1448
|
+
if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1449
|
+
jsonSchema.maxLength = 0;
|
|
1450
|
+
}
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
case "integer": {
|
|
1454
|
+
jsonSchema.type = "integer";
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
case "ipv4": {
|
|
1458
|
+
jsonSchema.format = "ipv4";
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
case "ipv6": {
|
|
1462
|
+
jsonSchema.format = "ipv6";
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
case "iso_date": {
|
|
1466
|
+
jsonSchema.format = "date";
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
case "iso_date_time":
|
|
1470
|
+
case "iso_timestamp": {
|
|
1471
|
+
jsonSchema.format = "date-time";
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
case "iso_time": {
|
|
1475
|
+
jsonSchema.format = "time";
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
case "length": {
|
|
1479
|
+
if (jsonSchema.type === "array") {
|
|
1480
|
+
jsonSchema.minItems = valibotAction.requirement;
|
|
1481
|
+
jsonSchema.maxItems = valibotAction.requirement;
|
|
1482
|
+
} else {
|
|
1483
|
+
if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1484
|
+
jsonSchema.minLength = valibotAction.requirement;
|
|
1485
|
+
jsonSchema.maxLength = valibotAction.requirement;
|
|
1486
|
+
}
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
case "max_length": {
|
|
1490
|
+
if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
|
|
1491
|
+
else {
|
|
1492
|
+
if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1493
|
+
jsonSchema.maxLength = valibotAction.requirement;
|
|
1494
|
+
}
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
case "max_value": {
|
|
1498
|
+
if (jsonSchema.type !== "number") handleError(`The "max_value" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1499
|
+
jsonSchema.maximum = valibotAction.requirement;
|
|
1500
|
+
break;
|
|
1501
|
+
}
|
|
1502
|
+
case "min_length": {
|
|
1503
|
+
if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
|
|
1504
|
+
else {
|
|
1505
|
+
if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1506
|
+
jsonSchema.minLength = valibotAction.requirement;
|
|
1507
|
+
}
|
|
1508
|
+
break;
|
|
1509
|
+
}
|
|
1510
|
+
case "min_value": {
|
|
1511
|
+
if (jsonSchema.type !== "number") handleError(`The "min_value" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1512
|
+
jsonSchema.minimum = valibotAction.requirement;
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
case "multiple_of": {
|
|
1516
|
+
jsonSchema.multipleOf = valibotAction.requirement;
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
case "non_empty": {
|
|
1520
|
+
if (jsonSchema.type === "array") jsonSchema.minItems = 1;
|
|
1521
|
+
else {
|
|
1522
|
+
if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
|
|
1523
|
+
jsonSchema.minLength = 1;
|
|
1524
|
+
}
|
|
1525
|
+
break;
|
|
1526
|
+
}
|
|
1527
|
+
case "regex": {
|
|
1528
|
+
if (valibotAction.requirement.flags) handleError("RegExp flags are not supported by JSON Schema.", config);
|
|
1529
|
+
jsonSchema.pattern = valibotAction.requirement.source;
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
case "title": {
|
|
1533
|
+
jsonSchema.title = valibotAction.title;
|
|
1534
|
+
break;
|
|
1535
|
+
}
|
|
1536
|
+
case "url": {
|
|
1537
|
+
jsonSchema.format = "uri";
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
case "uuid": {
|
|
1541
|
+
jsonSchema.format = "uuid";
|
|
1542
|
+
break;
|
|
1543
|
+
}
|
|
1544
|
+
case "value": {
|
|
1545
|
+
jsonSchema.const = valibotAction.requirement;
|
|
1546
|
+
break;
|
|
1547
|
+
}
|
|
1548
|
+
default: handleError(
|
|
1549
|
+
// @ts-expect-error
|
|
1550
|
+
`The "${valibotAction.type}" action cannot be converted to JSON Schema.`,
|
|
1551
|
+
config
|
|
1552
|
+
);
|
|
1553
|
+
}
|
|
1554
|
+
return jsonSchema;
|
|
1555
|
+
}
|
|
1556
|
+
var refCount = 0;
|
|
1557
|
+
function convertSchema(jsonSchema, valibotSchema, config, context) {
|
|
1558
|
+
const referenceId = context.referenceMap.get(valibotSchema);
|
|
1559
|
+
if (referenceId && referenceId in context.definitions) {
|
|
1560
|
+
jsonSchema.$ref = `#/$defs/${referenceId}`;
|
|
1561
|
+
return jsonSchema;
|
|
1562
|
+
}
|
|
1563
|
+
if ("pipe" in valibotSchema) {
|
|
1564
|
+
for (let index = 0; index < valibotSchema.pipe.length; index++) {
|
|
1565
|
+
const valibotPipeItem = valibotSchema.pipe[index];
|
|
1566
|
+
if (valibotPipeItem.kind === "schema") {
|
|
1567
|
+
if (index > 0) handleError("A \"pipe\" with multiple schemas cannot be converted to JSON Schema.", config);
|
|
1568
|
+
const tempJsonSchema = convertSchema({}, valibotPipeItem, config, context);
|
|
1569
|
+
if (tempJsonSchema.$ref) {
|
|
1570
|
+
const referenceId2 = tempJsonSchema.$ref.split("/")[2];
|
|
1571
|
+
Object.assign(jsonSchema, context.definitions[referenceId2]);
|
|
1572
|
+
} else Object.assign(jsonSchema, tempJsonSchema);
|
|
1573
|
+
} else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
|
|
1574
|
+
}
|
|
1575
|
+
return jsonSchema;
|
|
1576
|
+
}
|
|
1577
|
+
switch (valibotSchema.type) {
|
|
1578
|
+
case "boolean": {
|
|
1579
|
+
jsonSchema.type = "boolean";
|
|
1580
|
+
break;
|
|
1581
|
+
}
|
|
1582
|
+
case "null": {
|
|
1583
|
+
jsonSchema.type = "null";
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1586
|
+
case "number": {
|
|
1587
|
+
jsonSchema.type = "number";
|
|
1588
|
+
break;
|
|
1589
|
+
}
|
|
1590
|
+
case "string": {
|
|
1591
|
+
jsonSchema.type = "string";
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
case "array": {
|
|
1595
|
+
jsonSchema.type = "array";
|
|
1596
|
+
jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
case "tuple":
|
|
1600
|
+
case "tuple_with_rest":
|
|
1601
|
+
case "loose_tuple":
|
|
1602
|
+
case "strict_tuple": {
|
|
1603
|
+
jsonSchema.type = "array";
|
|
1604
|
+
jsonSchema.items = [];
|
|
1605
|
+
for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
|
|
1606
|
+
if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
|
|
1607
|
+
else jsonSchema.additionalItems = valibotSchema.type === "loose_tuple";
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
case "object":
|
|
1611
|
+
case "object_with_rest":
|
|
1612
|
+
case "loose_object":
|
|
1613
|
+
case "strict_object": {
|
|
1614
|
+
jsonSchema.type = "object";
|
|
1615
|
+
jsonSchema.properties = {};
|
|
1616
|
+
jsonSchema.required = [];
|
|
1617
|
+
for (const key in valibotSchema.entries) {
|
|
1618
|
+
const entry = valibotSchema.entries[key];
|
|
1619
|
+
jsonSchema.properties[key] = convertSchema({}, entry, config, context);
|
|
1620
|
+
if (entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
|
|
1621
|
+
}
|
|
1622
|
+
if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
|
|
1623
|
+
else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
case "record": {
|
|
1627
|
+
if ("pipe" in valibotSchema.key) handleError("The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.", config);
|
|
1628
|
+
if (valibotSchema.key.type !== "string") handleError(`The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`, config);
|
|
1629
|
+
jsonSchema.type = "object";
|
|
1630
|
+
jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
case "any":
|
|
1634
|
+
case "unknown": break;
|
|
1635
|
+
case "nullable":
|
|
1636
|
+
case "nullish": {
|
|
1637
|
+
jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
|
|
1638
|
+
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
1639
|
+
break;
|
|
1640
|
+
}
|
|
1641
|
+
case "exact_optional":
|
|
1642
|
+
case "optional":
|
|
1643
|
+
case "undefinedable": {
|
|
1644
|
+
jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
|
|
1645
|
+
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
case "literal": {
|
|
1649
|
+
if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") handleError("The value of the \"literal\" schema is not JSON compatible.", config);
|
|
1650
|
+
jsonSchema.const = valibotSchema.literal;
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
case "enum": {
|
|
1654
|
+
jsonSchema.enum = valibotSchema.options;
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
case "picklist": {
|
|
1658
|
+
if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) handleError("An option of the \"picklist\" schema is not JSON compatible.", config);
|
|
1659
|
+
jsonSchema.enum = valibotSchema.options;
|
|
1660
|
+
break;
|
|
1661
|
+
}
|
|
1662
|
+
case "union":
|
|
1663
|
+
case "variant": {
|
|
1664
|
+
jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
case "intersect": {
|
|
1668
|
+
jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
1669
|
+
break;
|
|
1670
|
+
}
|
|
1671
|
+
case "lazy": {
|
|
1672
|
+
let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
|
|
1673
|
+
if (!wrappedValibotSchema) {
|
|
1674
|
+
wrappedValibotSchema = valibotSchema.getter(void 0);
|
|
1675
|
+
context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
|
|
1676
|
+
}
|
|
1677
|
+
let referenceId2 = context.referenceMap.get(wrappedValibotSchema);
|
|
1678
|
+
if (!referenceId2) {
|
|
1679
|
+
referenceId2 = `${refCount++}`;
|
|
1680
|
+
context.referenceMap.set(wrappedValibotSchema, referenceId2);
|
|
1681
|
+
context.definitions[referenceId2] = convertSchema({}, wrappedValibotSchema, config, context);
|
|
1682
|
+
}
|
|
1683
|
+
jsonSchema.$ref = `#/$defs/${referenceId2}`;
|
|
1684
|
+
break;
|
|
1685
|
+
}
|
|
1686
|
+
default: handleError(
|
|
1687
|
+
// @ts-expect-error
|
|
1688
|
+
`The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`,
|
|
1689
|
+
config
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
return jsonSchema;
|
|
1693
|
+
}
|
|
1694
|
+
function toJsonSchema(schema, config) {
|
|
1695
|
+
const context = {
|
|
1696
|
+
definitions: {},
|
|
1697
|
+
referenceMap: /* @__PURE__ */ new Map(),
|
|
1698
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
1699
|
+
};
|
|
1700
|
+
if (config?.definitions) {
|
|
1701
|
+
for (const key in config.definitions) context.referenceMap.set(config.definitions[key], key);
|
|
1702
|
+
for (const key in config.definitions) context.definitions[key] = convertSchema(
|
|
1703
|
+
{},
|
|
1704
|
+
// @ts-expect-error
|
|
1705
|
+
config.definitions[key],
|
|
1706
|
+
config,
|
|
1707
|
+
context
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
const jsonSchema = convertSchema(
|
|
1711
|
+
{ $schema: "http://json-schema.org/draft-07/schema#" },
|
|
1712
|
+
// @ts-expect-error
|
|
1713
|
+
schema,
|
|
1714
|
+
config,
|
|
1715
|
+
context
|
|
1716
|
+
);
|
|
1717
|
+
if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
|
|
1718
|
+
return jsonSchema;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
415
1721
|
//#endregion
|
|
416
1722
|
//#region src/utils/validator.ts
|
|
417
|
-
const StringOrRegExpSchema =
|
|
418
|
-
const LogLevelSchema =
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
1723
|
+
const StringOrRegExpSchema = union([string(), instance(RegExp)]);
|
|
1724
|
+
const LogLevelSchema = union([
|
|
1725
|
+
literal("debug"),
|
|
1726
|
+
literal("info"),
|
|
1727
|
+
literal("warn")
|
|
422
1728
|
]);
|
|
423
|
-
const LogLevelOptionSchema =
|
|
424
|
-
const LogLevelWithErrorSchema =
|
|
425
|
-
const RollupLogSchema =
|
|
426
|
-
const RollupLogWithStringSchema =
|
|
427
|
-
const InputOptionSchema =
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
1729
|
+
const LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
|
|
1730
|
+
const LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
|
|
1731
|
+
const RollupLogSchema = any();
|
|
1732
|
+
const RollupLogWithStringSchema = union([RollupLogSchema, string()]);
|
|
1733
|
+
const InputOptionSchema = union([
|
|
1734
|
+
string(),
|
|
1735
|
+
array(string()),
|
|
1736
|
+
record(string(), string())
|
|
431
1737
|
]);
|
|
432
|
-
const ExternalSchema =
|
|
1738
|
+
const ExternalSchema = union([
|
|
433
1739
|
StringOrRegExpSchema,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
])),
|
|
1740
|
+
array(StringOrRegExpSchema),
|
|
1741
|
+
pipe(function_(), args(tuple([
|
|
1742
|
+
string(),
|
|
1743
|
+
optional(string()),
|
|
1744
|
+
boolean()
|
|
1745
|
+
])), returns(nullish(boolean())))
|
|
440
1746
|
]);
|
|
441
|
-
const ModuleTypesSchema =
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
1747
|
+
const ModuleTypesSchema = record(string(), union([
|
|
1748
|
+
literal("base64"),
|
|
1749
|
+
literal("binary"),
|
|
1750
|
+
literal("css"),
|
|
1751
|
+
literal("dataurl"),
|
|
1752
|
+
literal("empty"),
|
|
1753
|
+
literal("js"),
|
|
1754
|
+
literal("json"),
|
|
1755
|
+
literal("jsx"),
|
|
1756
|
+
literal("text"),
|
|
1757
|
+
literal("ts"),
|
|
1758
|
+
literal("tsx")
|
|
453
1759
|
]));
|
|
454
|
-
const JsxOptionsSchema =
|
|
455
|
-
development:
|
|
456
|
-
factory:
|
|
457
|
-
fragment:
|
|
458
|
-
importSource:
|
|
459
|
-
jsxImportSource:
|
|
460
|
-
mode:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
])),
|
|
465
|
-
refresh:
|
|
1760
|
+
const JsxOptionsSchema = strictObject({
|
|
1761
|
+
development: pipe(optional(boolean()), description("Development specific information")),
|
|
1762
|
+
factory: pipe(optional(string()), description("Jsx element transformation")),
|
|
1763
|
+
fragment: pipe(optional(string()), description("Jsx fragment transformation")),
|
|
1764
|
+
importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
|
|
1765
|
+
jsxImportSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is automatic")),
|
|
1766
|
+
mode: pipe(optional(union([
|
|
1767
|
+
literal("classic"),
|
|
1768
|
+
literal("automatic"),
|
|
1769
|
+
literal("preserve")
|
|
1770
|
+
])), description("Jsx transformation mode")),
|
|
1771
|
+
refresh: pipe(optional(boolean()), description("React refresh transformation"))
|
|
466
1772
|
});
|
|
467
|
-
const HelperModeSchema =
|
|
468
|
-
const DecoratorOptionSchema =
|
|
469
|
-
legacy:
|
|
470
|
-
emitDecoratorMetadata:
|
|
1773
|
+
const HelperModeSchema = union([literal("Runtime"), literal("External")]);
|
|
1774
|
+
const DecoratorOptionSchema = object({
|
|
1775
|
+
legacy: optional(boolean()),
|
|
1776
|
+
emitDecoratorMetadata: optional(boolean())
|
|
471
1777
|
});
|
|
472
|
-
const HelpersSchema =
|
|
473
|
-
const RewriteImportExtensionsSchema =
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
1778
|
+
const HelpersSchema = object({ mode: optional(HelperModeSchema) });
|
|
1779
|
+
const RewriteImportExtensionsSchema = union([
|
|
1780
|
+
literal("rewrite"),
|
|
1781
|
+
literal("remove"),
|
|
1782
|
+
boolean()
|
|
477
1783
|
]);
|
|
478
|
-
const TypescriptSchema =
|
|
479
|
-
jsxPragma:
|
|
480
|
-
jsxPragmaFrag:
|
|
481
|
-
onlyRemoveTypeImports:
|
|
482
|
-
allowNamespaces:
|
|
483
|
-
allowDeclareFields:
|
|
484
|
-
declaration:
|
|
485
|
-
stripInternal:
|
|
486
|
-
sourcemap:
|
|
1784
|
+
const TypescriptSchema = object({
|
|
1785
|
+
jsxPragma: optional(string()),
|
|
1786
|
+
jsxPragmaFrag: optional(string()),
|
|
1787
|
+
onlyRemoveTypeImports: optional(boolean()),
|
|
1788
|
+
allowNamespaces: optional(boolean()),
|
|
1789
|
+
allowDeclareFields: optional(boolean()),
|
|
1790
|
+
declaration: optional(object({
|
|
1791
|
+
stripInternal: optional(boolean()),
|
|
1792
|
+
sourcemap: optional(boolean())
|
|
487
1793
|
})),
|
|
488
|
-
rewriteImportExtensions:
|
|
1794
|
+
rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
|
|
489
1795
|
});
|
|
490
|
-
const AssumptionsSchema =
|
|
491
|
-
ignoreFunctionLength:
|
|
492
|
-
noDocumentAll:
|
|
493
|
-
objectRestNoSymbols:
|
|
494
|
-
pureGetters:
|
|
495
|
-
setPublicClassFields:
|
|
1796
|
+
const AssumptionsSchema = object({
|
|
1797
|
+
ignoreFunctionLength: optional(boolean()),
|
|
1798
|
+
noDocumentAll: optional(boolean()),
|
|
1799
|
+
objectRestNoSymbols: optional(boolean()),
|
|
1800
|
+
pureGetters: optional(boolean()),
|
|
1801
|
+
setPublicClassFields: optional(boolean())
|
|
496
1802
|
});
|
|
497
|
-
const TransformOptionsSchema =
|
|
498
|
-
assumptions:
|
|
499
|
-
typescript:
|
|
500
|
-
helpers:
|
|
501
|
-
decorators:
|
|
1803
|
+
const TransformOptionsSchema = object({
|
|
1804
|
+
assumptions: optional(AssumptionsSchema),
|
|
1805
|
+
typescript: optional(TypescriptSchema),
|
|
1806
|
+
helpers: optional(HelpersSchema),
|
|
1807
|
+
decorators: optional(DecoratorOptionSchema)
|
|
502
1808
|
});
|
|
503
|
-
const WatchOptionsSchema =
|
|
504
|
-
chokidar:
|
|
505
|
-
exclude:
|
|
506
|
-
include:
|
|
507
|
-
notify:
|
|
508
|
-
compareContents:
|
|
509
|
-
pollInterval:
|
|
510
|
-
})),
|
|
511
|
-
skipWrite:
|
|
512
|
-
buildDelay:
|
|
1809
|
+
const WatchOptionsSchema = strictObject({
|
|
1810
|
+
chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
|
|
1811
|
+
exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1812
|
+
include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1813
|
+
notify: pipe(optional(strictObject({
|
|
1814
|
+
compareContents: optional(boolean()),
|
|
1815
|
+
pollInterval: optional(number())
|
|
1816
|
+
})), description("Notify options")),
|
|
1817
|
+
skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
|
|
1818
|
+
buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
|
|
513
1819
|
});
|
|
514
|
-
const ChecksOptionsSchema =
|
|
515
|
-
circularDependency:
|
|
516
|
-
eval:
|
|
517
|
-
missingGlobalName:
|
|
518
|
-
missingNameOptionForIifeExport:
|
|
519
|
-
mixedExport:
|
|
520
|
-
unresolvedEntry:
|
|
521
|
-
unresolvedImport:
|
|
522
|
-
filenameConflict:
|
|
523
|
-
commonJsVariableInEsm:
|
|
524
|
-
importIsUndefined:
|
|
525
|
-
configurationFieldConflict:
|
|
1820
|
+
const ChecksOptionsSchema = strictObject({
|
|
1821
|
+
circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
|
|
1822
|
+
eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
|
|
1823
|
+
missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
|
|
1824
|
+
missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
|
|
1825
|
+
mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
|
|
1826
|
+
unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
|
|
1827
|
+
unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
|
|
1828
|
+
filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
|
|
1829
|
+
commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
|
|
1830
|
+
importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
|
|
1831
|
+
configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
|
|
526
1832
|
});
|
|
527
|
-
const MinifyOptionsSchema =
|
|
528
|
-
mangle:
|
|
529
|
-
compress:
|
|
530
|
-
removeWhitespace:
|
|
1833
|
+
const MinifyOptionsSchema = strictObject({
|
|
1834
|
+
mangle: optional(boolean()),
|
|
1835
|
+
compress: optional(boolean()),
|
|
1836
|
+
removeWhitespace: optional(boolean())
|
|
531
1837
|
});
|
|
532
|
-
const ResolveOptionsSchema =
|
|
533
|
-
alias:
|
|
534
|
-
aliasFields:
|
|
535
|
-
conditionNames:
|
|
536
|
-
extensionAlias:
|
|
537
|
-
exportsFields:
|
|
538
|
-
extensions:
|
|
539
|
-
mainFields:
|
|
540
|
-
mainFiles:
|
|
541
|
-
modules:
|
|
542
|
-
symlinks:
|
|
543
|
-
tsconfigFilename:
|
|
1838
|
+
const ResolveOptionsSchema = strictObject({
|
|
1839
|
+
alias: optional(record(string(), union([string(), array(string())]))),
|
|
1840
|
+
aliasFields: optional(array(array(string()))),
|
|
1841
|
+
conditionNames: optional(array(string())),
|
|
1842
|
+
extensionAlias: optional(record(string(), array(string()))),
|
|
1843
|
+
exportsFields: optional(array(array(string()))),
|
|
1844
|
+
extensions: optional(array(string())),
|
|
1845
|
+
mainFields: optional(array(string())),
|
|
1846
|
+
mainFiles: optional(array(string())),
|
|
1847
|
+
modules: optional(array(string())),
|
|
1848
|
+
symlinks: optional(boolean()),
|
|
1849
|
+
tsconfigFilename: optional(string())
|
|
544
1850
|
});
|
|
545
|
-
const TreeshakingOptionsSchema =
|
|
546
|
-
annotations:
|
|
547
|
-
manualPureFunctions:
|
|
548
|
-
unknownGlobalSideEffects:
|
|
1851
|
+
const TreeshakingOptionsSchema = union([boolean(), looseObject({
|
|
1852
|
+
annotations: optional(boolean()),
|
|
1853
|
+
manualPureFunctions: optional(array(string())),
|
|
1854
|
+
unknownGlobalSideEffects: optional(boolean())
|
|
549
1855
|
})]);
|
|
550
|
-
const OnLogSchema =
|
|
1856
|
+
const OnLogSchema = pipe(function_(), args(tuple([
|
|
551
1857
|
LogLevelSchema,
|
|
552
1858
|
RollupLogSchema,
|
|
553
|
-
|
|
1859
|
+
pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
|
|
554
1860
|
])));
|
|
555
|
-
const OnwarnSchema =
|
|
556
|
-
const HmrSchema =
|
|
557
|
-
port:
|
|
558
|
-
host:
|
|
559
|
-
implement:
|
|
1861
|
+
const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
|
|
1862
|
+
const HmrSchema = union([boolean(), strictObject({
|
|
1863
|
+
port: optional(number()),
|
|
1864
|
+
host: optional(string()),
|
|
1865
|
+
implement: optional(string())
|
|
560
1866
|
})]);
|
|
561
|
-
const InputOptionsSchema =
|
|
562
|
-
input:
|
|
563
|
-
plugins:
|
|
564
|
-
external:
|
|
565
|
-
resolve:
|
|
566
|
-
cwd:
|
|
567
|
-
platform:
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
])),
|
|
572
|
-
shimMissingExports:
|
|
573
|
-
treeshake:
|
|
574
|
-
logLevel:
|
|
575
|
-
onLog:
|
|
576
|
-
onwarn:
|
|
577
|
-
moduleTypes:
|
|
578
|
-
experimental:
|
|
579
|
-
disableLiveBindings:
|
|
580
|
-
enableComposingJsPlugins:
|
|
581
|
-
resolveNewUrlToAsset:
|
|
582
|
-
strictExecutionOrder:
|
|
583
|
-
hmr:
|
|
1867
|
+
const InputOptionsSchema = strictObject({
|
|
1868
|
+
input: optional(InputOptionSchema),
|
|
1869
|
+
plugins: optional(custom(() => true)),
|
|
1870
|
+
external: optional(ExternalSchema),
|
|
1871
|
+
resolve: optional(ResolveOptionsSchema),
|
|
1872
|
+
cwd: pipe(optional(string()), description("Current working directory")),
|
|
1873
|
+
platform: pipe(optional(union([
|
|
1874
|
+
literal("browser"),
|
|
1875
|
+
literal("neutral"),
|
|
1876
|
+
literal("node")
|
|
1877
|
+
])), description(`Platform for which the code should be generated (node, ${ansis.default.underline("browser")}, neutral)`)),
|
|
1878
|
+
shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
|
|
1879
|
+
treeshake: optional(TreeshakingOptionsSchema),
|
|
1880
|
+
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${ansis.default.dim("silent")}, ${ansis.default.underline(ansis.default.gray("info"))}, debug, ${ansis.default.yellow("warn")})`)),
|
|
1881
|
+
onLog: optional(OnLogSchema),
|
|
1882
|
+
onwarn: optional(OnwarnSchema),
|
|
1883
|
+
moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
|
|
1884
|
+
experimental: optional(strictObject({
|
|
1885
|
+
disableLiveBindings: optional(boolean()),
|
|
1886
|
+
enableComposingJsPlugins: optional(boolean()),
|
|
1887
|
+
resolveNewUrlToAsset: optional(boolean()),
|
|
1888
|
+
strictExecutionOrder: optional(boolean()),
|
|
1889
|
+
hmr: optional(HmrSchema)
|
|
584
1890
|
})),
|
|
585
|
-
define:
|
|
586
|
-
inject:
|
|
587
|
-
profilerNames:
|
|
588
|
-
jsx:
|
|
589
|
-
|
|
1891
|
+
define: pipe(optional(record(string(), string())), description("Define global variables")),
|
|
1892
|
+
inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
|
|
1893
|
+
profilerNames: optional(boolean()),
|
|
1894
|
+
jsx: optional(union([
|
|
1895
|
+
boolean(),
|
|
590
1896
|
JsxOptionsSchema,
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
1897
|
+
string("react"),
|
|
1898
|
+
string("react-jsx"),
|
|
1899
|
+
string("preserve")
|
|
594
1900
|
])),
|
|
595
|
-
transform:
|
|
596
|
-
watch:
|
|
597
|
-
dropLabels:
|
|
598
|
-
checks:
|
|
599
|
-
keepNames:
|
|
600
|
-
debug:
|
|
1901
|
+
transform: optional(TransformOptionsSchema),
|
|
1902
|
+
watch: optional(union([WatchOptionsSchema, literal(false)])),
|
|
1903
|
+
dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
|
|
1904
|
+
checks: optional(ChecksOptionsSchema),
|
|
1905
|
+
keepNames: pipe(optional(boolean()), description("Keep function/class name")),
|
|
1906
|
+
debug: pipe(optional(object({ sessionId: pipe(optional(string()), description("Used to name the build.")) })), description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly."))
|
|
601
1907
|
});
|
|
602
|
-
const InputCliOverrideSchema =
|
|
603
|
-
input:
|
|
604
|
-
external:
|
|
605
|
-
inject:
|
|
606
|
-
treeshake:
|
|
607
|
-
jsx:
|
|
1908
|
+
const InputCliOverrideSchema = strictObject({
|
|
1909
|
+
input: pipe(optional(array(string())), description("Entry file")),
|
|
1910
|
+
external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
|
|
1911
|
+
inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
|
|
1912
|
+
treeshake: pipe(optional(boolean()), description("enable treeshaking")),
|
|
1913
|
+
jsx: pipe(optional(JsxOptionsSchema), description("enable jsx"))
|
|
608
1914
|
});
|
|
609
|
-
const InputCliOptionsSchema =
|
|
1915
|
+
const InputCliOptionsSchema = omit(strictObject({
|
|
610
1916
|
...InputOptionsSchema.entries,
|
|
611
1917
|
...InputCliOverrideSchema.entries
|
|
612
1918
|
}), [
|
|
@@ -633,87 +1939,87 @@ var ESTarget = /* @__PURE__ */ function(ESTarget$1) {
|
|
|
633
1939
|
ESTarget$1["ESNext"] = "esnext";
|
|
634
1940
|
return ESTarget$1;
|
|
635
1941
|
}(ESTarget || {});
|
|
636
|
-
const ModuleFormatSchema =
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1942
|
+
const ModuleFormatSchema = union([
|
|
1943
|
+
literal("es"),
|
|
1944
|
+
literal("cjs"),
|
|
1945
|
+
literal("esm"),
|
|
1946
|
+
literal("module"),
|
|
1947
|
+
literal("commonjs"),
|
|
1948
|
+
literal("iife"),
|
|
1949
|
+
literal("umd")
|
|
644
1950
|
]);
|
|
645
|
-
const AddonFunctionSchema =
|
|
646
|
-
const ChunkFileNamesSchema =
|
|
647
|
-
const AssetFileNamesSchema =
|
|
648
|
-
const SanitizeFileNameSchema =
|
|
649
|
-
const GlobalsFunctionSchema =
|
|
650
|
-
const AdvancedChunksSchema =
|
|
651
|
-
minSize:
|
|
652
|
-
maxSize:
|
|
653
|
-
minModuleSize:
|
|
654
|
-
maxModuleSize:
|
|
655
|
-
minShareCount:
|
|
656
|
-
groups:
|
|
657
|
-
name:
|
|
658
|
-
test:
|
|
659
|
-
priority:
|
|
660
|
-
minSize:
|
|
661
|
-
minShareCount:
|
|
662
|
-
maxSize:
|
|
663
|
-
minModuleSize:
|
|
664
|
-
maxModuleSize:
|
|
1951
|
+
const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
|
|
1952
|
+
const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
1953
|
+
const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
1954
|
+
const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
|
|
1955
|
+
const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
|
|
1956
|
+
const AdvancedChunksSchema = strictObject({
|
|
1957
|
+
minSize: optional(number()),
|
|
1958
|
+
maxSize: optional(number()),
|
|
1959
|
+
minModuleSize: optional(number()),
|
|
1960
|
+
maxModuleSize: optional(number()),
|
|
1961
|
+
minShareCount: optional(number()),
|
|
1962
|
+
groups: optional(array(strictObject({
|
|
1963
|
+
name: string(),
|
|
1964
|
+
test: optional(union([string(), instance(RegExp)])),
|
|
1965
|
+
priority: optional(number()),
|
|
1966
|
+
minSize: optional(number()),
|
|
1967
|
+
minShareCount: optional(number()),
|
|
1968
|
+
maxSize: optional(number()),
|
|
1969
|
+
minModuleSize: optional(number()),
|
|
1970
|
+
maxModuleSize: optional(number())
|
|
665
1971
|
})))
|
|
666
1972
|
});
|
|
667
|
-
const OutputOptionsSchema =
|
|
668
|
-
dir:
|
|
669
|
-
file:
|
|
670
|
-
exports:
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
])),
|
|
676
|
-
hashCharacters:
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
])),
|
|
681
|
-
format:
|
|
682
|
-
sourcemap:
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
])),
|
|
687
|
-
sourcemapDebugIds:
|
|
688
|
-
sourcemapIgnoreList:
|
|
689
|
-
sourcemapPathTransform:
|
|
690
|
-
banner:
|
|
691
|
-
footer:
|
|
692
|
-
intro:
|
|
693
|
-
outro:
|
|
694
|
-
extend:
|
|
695
|
-
esModule:
|
|
696
|
-
assetFileNames:
|
|
697
|
-
entryFileNames:
|
|
698
|
-
chunkFileNames:
|
|
699
|
-
cssEntryFileNames:
|
|
700
|
-
cssChunkFileNames:
|
|
701
|
-
sanitizeFileName:
|
|
702
|
-
minify:
|
|
703
|
-
|
|
704
|
-
|
|
1973
|
+
const OutputOptionsSchema = strictObject({
|
|
1974
|
+
dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
|
|
1975
|
+
file: pipe(optional(string()), description("Single output file")),
|
|
1976
|
+
exports: pipe(optional(union([
|
|
1977
|
+
literal("auto"),
|
|
1978
|
+
literal("named"),
|
|
1979
|
+
literal("default"),
|
|
1980
|
+
literal("none")
|
|
1981
|
+
])), description(`Specify a export mode (${ansis.default.underline("auto")}, named, default, none)`)),
|
|
1982
|
+
hashCharacters: pipe(optional(union([
|
|
1983
|
+
literal("base64"),
|
|
1984
|
+
literal("base36"),
|
|
1985
|
+
literal("hex")
|
|
1986
|
+
])), description("Use the specified character set for file hashes")),
|
|
1987
|
+
format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${ansis.default.underline("esm")}, cjs, and iife)`)),
|
|
1988
|
+
sourcemap: pipe(optional(union([
|
|
1989
|
+
boolean(),
|
|
1990
|
+
literal("inline"),
|
|
1991
|
+
literal("hidden")
|
|
1992
|
+
])), description(`Generate sourcemap (\`-s inline\` for inline, or ${ansis.default.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
1993
|
+
sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
|
|
1994
|
+
sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
|
|
1995
|
+
sourcemapPathTransform: optional(custom(() => true)),
|
|
1996
|
+
banner: optional(union([string(), AddonFunctionSchema])),
|
|
1997
|
+
footer: optional(union([string(), AddonFunctionSchema])),
|
|
1998
|
+
intro: optional(union([string(), AddonFunctionSchema])),
|
|
1999
|
+
outro: optional(union([string(), AddonFunctionSchema])),
|
|
2000
|
+
extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
|
|
2001
|
+
esModule: optional(union([boolean(), literal("if-default-prop")])),
|
|
2002
|
+
assetFileNames: optional(AssetFileNamesSchema),
|
|
2003
|
+
entryFileNames: optional(ChunkFileNamesSchema),
|
|
2004
|
+
chunkFileNames: optional(ChunkFileNamesSchema),
|
|
2005
|
+
cssEntryFileNames: optional(ChunkFileNamesSchema),
|
|
2006
|
+
cssChunkFileNames: optional(ChunkFileNamesSchema),
|
|
2007
|
+
sanitizeFileName: optional(SanitizeFileNameSchema),
|
|
2008
|
+
minify: pipe(optional(union([
|
|
2009
|
+
boolean(),
|
|
2010
|
+
string("dce-only"),
|
|
705
2011
|
MinifyOptionsSchema
|
|
706
|
-
])),
|
|
707
|
-
name:
|
|
708
|
-
globals:
|
|
709
|
-
externalLiveBindings:
|
|
710
|
-
inlineDynamicImports:
|
|
711
|
-
advancedChunks:
|
|
712
|
-
comments:
|
|
713
|
-
plugins:
|
|
714
|
-
polyfillRequire:
|
|
715
|
-
target:
|
|
716
|
-
hoistTransitiveImports:
|
|
2012
|
+
])), description("Minify the bundled file")),
|
|
2013
|
+
name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
|
|
2014
|
+
globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2015
|
+
externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
|
|
2016
|
+
inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
|
|
2017
|
+
advancedChunks: optional(AdvancedChunksSchema),
|
|
2018
|
+
comments: pipe(optional(union([literal("none"), literal("preserve-legal")])), description("Control comments in the output")),
|
|
2019
|
+
plugins: optional(custom(() => true)),
|
|
2020
|
+
polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
|
|
2021
|
+
target: pipe(optional(enum_(ESTarget)), description("The JavaScript target environment")),
|
|
2022
|
+
hoistTransitiveImports: optional(custom((input) => {
|
|
717
2023
|
if (input) return false;
|
|
718
2024
|
return true;
|
|
719
2025
|
}, () => `The 'true' value is not supported`))
|
|
@@ -721,26 +2027,26 @@ const OutputOptionsSchema = valibot.strictObject({
|
|
|
721
2027
|
const getAddonDescription = (placement, wrapper) => {
|
|
722
2028
|
return `Code to insert the ${ansis.default.bold(placement)} of the bundled file (${ansis.default.bold(wrapper)} the wrapper function)`;
|
|
723
2029
|
};
|
|
724
|
-
const OutputCliOverrideSchema =
|
|
725
|
-
assetFileNames:
|
|
726
|
-
entryFileNames:
|
|
727
|
-
chunkFileNames:
|
|
728
|
-
cssEntryFileNames:
|
|
729
|
-
cssChunkFileNames:
|
|
730
|
-
sanitizeFileName:
|
|
731
|
-
banner:
|
|
732
|
-
footer:
|
|
733
|
-
intro:
|
|
734
|
-
outro:
|
|
735
|
-
esModule:
|
|
736
|
-
globals:
|
|
737
|
-
advancedChunks:
|
|
738
|
-
minSize:
|
|
739
|
-
minShareCount:
|
|
740
|
-
})),
|
|
741
|
-
minify:
|
|
2030
|
+
const OutputCliOverrideSchema = strictObject({
|
|
2031
|
+
assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
|
|
2032
|
+
entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
|
|
2033
|
+
chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
|
|
2034
|
+
cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
|
|
2035
|
+
cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
|
|
2036
|
+
sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
|
|
2037
|
+
banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
|
|
2038
|
+
footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
|
|
2039
|
+
intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
|
|
2040
|
+
outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
|
|
2041
|
+
esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
|
|
2042
|
+
globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2043
|
+
advancedChunks: pipe(optional(strictObject({
|
|
2044
|
+
minSize: pipe(optional(number()), description("Minimum size of the chunk")),
|
|
2045
|
+
minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
|
|
2046
|
+
})), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2047
|
+
minify: pipe(optional(boolean()), description("Minify the bundled file"))
|
|
742
2048
|
});
|
|
743
|
-
const OutputCliOptionsSchema =
|
|
2049
|
+
const OutputCliOptionsSchema = omit(strictObject({
|
|
744
2050
|
...OutputOptionsSchema.entries,
|
|
745
2051
|
...OutputCliOverrideSchema.entries
|
|
746
2052
|
}), [
|
|
@@ -749,16 +2055,16 @@ const OutputCliOptionsSchema = valibot.omit(valibot.strictObject({
|
|
|
749
2055
|
"plugins",
|
|
750
2056
|
"hoistTransitiveImports"
|
|
751
2057
|
]);
|
|
752
|
-
const CliOptionsSchema =
|
|
753
|
-
config:
|
|
754
|
-
help:
|
|
755
|
-
version:
|
|
756
|
-
watch:
|
|
2058
|
+
const CliOptionsSchema = strictObject({
|
|
2059
|
+
config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
|
|
2060
|
+
help: pipe(optional(boolean()), description("Show help")),
|
|
2061
|
+
version: pipe(optional(boolean()), description("Show version number")),
|
|
2062
|
+
watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
|
|
757
2063
|
...InputCliOptionsSchema.entries,
|
|
758
2064
|
...OutputCliOptionsSchema.entries
|
|
759
2065
|
});
|
|
760
2066
|
function validateCliOptions(options) {
|
|
761
|
-
let parsed =
|
|
2067
|
+
let parsed = safeParse(CliOptionsSchema, options);
|
|
762
2068
|
return [parsed.output, parsed.issues?.map((issue) => {
|
|
763
2069
|
const option = issue.path?.map((pathItem) => pathItem.key).join(" ");
|
|
764
2070
|
return `Invalid value for option ${option}: ${issue.message}`;
|
|
@@ -768,7 +2074,7 @@ const inputHelperMsgRecord = { output: { ignored: true } };
|
|
|
768
2074
|
const outputHelperMsgRecord = {};
|
|
769
2075
|
function validateOption(key, options) {
|
|
770
2076
|
if (globalThis.process?.env?.ROLLDOWN_OPTIONS_VALIDATION === "loose") return;
|
|
771
|
-
let parsed =
|
|
2077
|
+
let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
|
|
772
2078
|
if (!parsed.success) {
|
|
773
2079
|
const errors = parsed.issues.map((issue) => {
|
|
774
2080
|
const issuePaths = issue.path.map((path$2) => path$2.key);
|
|
@@ -789,13 +2095,13 @@ function validateOption(key, options) {
|
|
|
789
2095
|
}
|
|
790
2096
|
}
|
|
791
2097
|
function getInputCliKeys() {
|
|
792
|
-
return
|
|
2098
|
+
return keyof(InputCliOptionsSchema).options;
|
|
793
2099
|
}
|
|
794
2100
|
function getOutputCliKeys() {
|
|
795
|
-
return
|
|
2101
|
+
return keyof(OutputCliOptionsSchema).options;
|
|
796
2102
|
}
|
|
797
2103
|
function getJsonSchema() {
|
|
798
|
-
return
|
|
2104
|
+
return toJsonSchema(CliOptionsSchema);
|
|
799
2105
|
}
|
|
800
2106
|
|
|
801
2107
|
//#endregion
|
|
@@ -932,9 +2238,9 @@ function bindingifySideEffects(sideEffects) {
|
|
|
932
2238
|
|
|
933
2239
|
//#endregion
|
|
934
2240
|
//#region src/utils/transform-sourcemap.ts
|
|
935
|
-
function isEmptySourcemapFiled(array) {
|
|
936
|
-
if (!array) return true;
|
|
937
|
-
if (array.length === 0 || !array[0]) return true;
|
|
2241
|
+
function isEmptySourcemapFiled(array$1) {
|
|
2242
|
+
if (!array$1) return true;
|
|
2243
|
+
if (array$1.length === 0 || !array$1[0]) return true;
|
|
938
2244
|
return false;
|
|
939
2245
|
}
|
|
940
2246
|
function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
|
|
@@ -984,14 +2290,16 @@ function t(...n) {
|
|
|
984
2290
|
//#endregion
|
|
985
2291
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
986
2292
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
987
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [require_filter_index.include(
|
|
988
|
-
if (Array.isArray(matcher)) return matcher.map((m) => require_filter_index.include(
|
|
2293
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return [require_filter_index.include(generateAtomMatcher(stringKind, matcher))];
|
|
2294
|
+
if (Array.isArray(matcher)) return matcher.map((m) => require_filter_index.include(generateAtomMatcher(stringKind, m)));
|
|
989
2295
|
let ret = [];
|
|
990
|
-
|
|
991
|
-
if (matcher.
|
|
992
|
-
if (matcher.include) ret.push(...require_filter_index.arraify(matcher.include).map((m) => require_filter_index.include(isCode ? require_filter_index.code(m) : require_filter_index.id(m))));
|
|
2296
|
+
if (matcher.exclude) ret.push(...require_filter_index.arraify(matcher.exclude).map((m) => require_filter_index.exclude(generateAtomMatcher(stringKind, m))));
|
|
2297
|
+
if (matcher.include) ret.push(...require_filter_index.arraify(matcher.include).map((m) => require_filter_index.include(generateAtomMatcher(stringKind, m))));
|
|
993
2298
|
return ret;
|
|
994
2299
|
}
|
|
2300
|
+
function generateAtomMatcher(kind, matcher) {
|
|
2301
|
+
return kind === "code" ? require_filter_index.code(matcher) : require_filter_index.id(matcher);
|
|
2302
|
+
}
|
|
995
2303
|
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
996
2304
|
if (!filterOption) return void 0;
|
|
997
2305
|
if (Array.isArray(filterOption)) return filterOption;
|
|
@@ -1029,20 +2337,20 @@ function bindingifyFilterExpr(expr) {
|
|
|
1029
2337
|
function bindingifyFilterExprImpl(expr, list) {
|
|
1030
2338
|
switch (expr.kind) {
|
|
1031
2339
|
case "and": {
|
|
1032
|
-
let args = expr.args;
|
|
1033
|
-
for (let i$1 = args.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args[i$1], list);
|
|
2340
|
+
let args$1 = expr.args;
|
|
2341
|
+
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
1034
2342
|
list.push({
|
|
1035
2343
|
kind: "And",
|
|
1036
|
-
payload: args.length
|
|
2344
|
+
payload: args$1.length
|
|
1037
2345
|
});
|
|
1038
2346
|
break;
|
|
1039
2347
|
}
|
|
1040
2348
|
case "or": {
|
|
1041
|
-
let args = expr.args;
|
|
1042
|
-
for (let i$1 = args.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args[i$1], list);
|
|
2349
|
+
let args$1 = expr.args;
|
|
2350
|
+
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
1043
2351
|
list.push({
|
|
1044
2352
|
kind: "Or",
|
|
1045
|
-
payload: args.length
|
|
2353
|
+
payload: args$1.length
|
|
1046
2354
|
});
|
|
1047
2355
|
break;
|
|
1048
2356
|
}
|
|
@@ -1159,10 +2467,10 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
|
1159
2467
|
async function createLoadModulePromise(context, data) {
|
|
1160
2468
|
const loadPromise = data.loadModulePromiseMap.get(id$1);
|
|
1161
2469
|
if (loadPromise) return loadPromise;
|
|
1162
|
-
const promise = new Promise((resolve, _) => {
|
|
2470
|
+
const promise$1 = new Promise((resolve, _) => {
|
|
1163
2471
|
data.loadModulePromiseResolveFnMap.set(id$1, resolve);
|
|
1164
2472
|
});
|
|
1165
|
-
data.loadModulePromiseMap.set(id$1, promise);
|
|
2473
|
+
data.loadModulePromiseMap.set(id$1, promise$1);
|
|
1166
2474
|
try {
|
|
1167
2475
|
await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
|
|
1168
2476
|
} catch (e) {
|
|
@@ -1170,7 +2478,7 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
|
1170
2478
|
data.loadModulePromiseResolveFnMap.delete(id$1);
|
|
1171
2479
|
throw e;
|
|
1172
2480
|
}
|
|
1173
|
-
return promise;
|
|
2481
|
+
return promise$1;
|
|
1174
2482
|
}
|
|
1175
2483
|
await createLoadModulePromise(this.context, this.data);
|
|
1176
2484
|
return this.data.getModuleInfo(id$1, this.context);
|
|
@@ -1257,41 +2565,41 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
|
1257
2565
|
|
|
1258
2566
|
//#endregion
|
|
1259
2567
|
//#region src/plugin/bindingify-build-hooks.ts
|
|
1260
|
-
function bindingifyBuildStart(args) {
|
|
1261
|
-
const hook = args.plugin.buildStart;
|
|
2568
|
+
function bindingifyBuildStart(args$1) {
|
|
2569
|
+
const hook = args$1.plugin.buildStart;
|
|
1262
2570
|
if (!hook) return {};
|
|
1263
2571
|
const { handler, meta } = normalizeHook(hook);
|
|
1264
2572
|
return {
|
|
1265
2573
|
plugin: async (ctx, opts) => {
|
|
1266
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
2574
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedInputOptionsImpl(opts, args$1.onLog));
|
|
1267
2575
|
},
|
|
1268
2576
|
meta: bindingifyPluginHookMeta(meta)
|
|
1269
2577
|
};
|
|
1270
2578
|
}
|
|
1271
|
-
function bindingifyBuildEnd(args) {
|
|
1272
|
-
const hook = args.plugin.buildEnd;
|
|
2579
|
+
function bindingifyBuildEnd(args$1) {
|
|
2580
|
+
const hook = args$1.plugin.buildEnd;
|
|
1273
2581
|
if (!hook) return {};
|
|
1274
2582
|
const { handler, meta } = normalizeHook(hook);
|
|
1275
2583
|
return {
|
|
1276
2584
|
plugin: async (ctx, err) => {
|
|
1277
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? normalizeErrors(err) : void 0);
|
|
2585
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), err ? normalizeErrors(err) : void 0);
|
|
1278
2586
|
},
|
|
1279
2587
|
meta: bindingifyPluginHookMeta(meta)
|
|
1280
2588
|
};
|
|
1281
2589
|
}
|
|
1282
|
-
function bindingifyResolveId(args) {
|
|
1283
|
-
const hook = args.plugin.resolveId;
|
|
2590
|
+
function bindingifyResolveId(args$1) {
|
|
2591
|
+
const hook = args$1.plugin.resolveId;
|
|
1284
2592
|
if (!hook) return {};
|
|
1285
2593
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1286
2594
|
return {
|
|
1287
2595
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
1288
|
-
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2596
|
+
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
1289
2597
|
const newExtraOptions = {
|
|
1290
2598
|
...extraOptions,
|
|
1291
2599
|
custom: contextResolveOptions?.custom,
|
|
1292
2600
|
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
|
|
1293
2601
|
};
|
|
1294
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0, newExtraOptions);
|
|
2602
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0, newExtraOptions);
|
|
1295
2603
|
if (ret == null) return;
|
|
1296
2604
|
if (ret === false) return {
|
|
1297
2605
|
id: specifier,
|
|
@@ -1302,7 +2610,7 @@ function bindingifyResolveId(args) {
|
|
|
1302
2610
|
id: ret,
|
|
1303
2611
|
normalizeExternalId: true
|
|
1304
2612
|
};
|
|
1305
|
-
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
2613
|
+
let exist = args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
1306
2614
|
meta: ret.meta || {},
|
|
1307
2615
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1308
2616
|
invalidate: false
|
|
@@ -1318,13 +2626,13 @@ function bindingifyResolveId(args) {
|
|
|
1318
2626
|
filter: bindingifyResolveIdFilter(options.filter)
|
|
1319
2627
|
};
|
|
1320
2628
|
}
|
|
1321
|
-
function bindingifyResolveDynamicImport(args) {
|
|
1322
|
-
const hook = args.plugin.resolveDynamicImport;
|
|
2629
|
+
function bindingifyResolveDynamicImport(args$1) {
|
|
2630
|
+
const hook = args$1.plugin.resolveDynamicImport;
|
|
1323
2631
|
if (!hook) return {};
|
|
1324
2632
|
const { handler, meta } = normalizeHook(hook);
|
|
1325
2633
|
return {
|
|
1326
2634
|
plugin: async (ctx, specifier, importer) => {
|
|
1327
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
|
|
2635
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0);
|
|
1328
2636
|
if (ret == null) return;
|
|
1329
2637
|
if (ret === false) return {
|
|
1330
2638
|
id: specifier,
|
|
@@ -1336,7 +2644,7 @@ function bindingifyResolveDynamicImport(args) {
|
|
|
1336
2644
|
external: ret.external
|
|
1337
2645
|
};
|
|
1338
2646
|
if (ret.moduleSideEffects !== null) result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1339
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
2647
|
+
args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
1340
2648
|
meta: ret.meta || {},
|
|
1341
2649
|
moduleSideEffects: ret.moduleSideEffects || null,
|
|
1342
2650
|
invalidate: false
|
|
@@ -1346,16 +2654,16 @@ function bindingifyResolveDynamicImport(args) {
|
|
|
1346
2654
|
meta: bindingifyPluginHookMeta(meta)
|
|
1347
2655
|
};
|
|
1348
2656
|
}
|
|
1349
|
-
function bindingifyTransform(args) {
|
|
1350
|
-
const hook = args.plugin.transform;
|
|
2657
|
+
function bindingifyTransform(args$1) {
|
|
2658
|
+
const hook = args$1.plugin.transform;
|
|
1351
2659
|
if (!hook) return {};
|
|
1352
2660
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1353
2661
|
return {
|
|
1354
2662
|
plugin: async (ctx, code$1, id$1, meta$1) => {
|
|
1355
|
-
const ret = await handler.call(new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id$1, code$1, args.onLog, args.logLevel, args.watchMode), code$1, id$1, meta$1);
|
|
2663
|
+
const ret = await handler.call(new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id$1, code$1, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, id$1, meta$1);
|
|
1356
2664
|
if (ret == null) return void 0;
|
|
1357
2665
|
if (typeof ret === "string") return { code: ret };
|
|
1358
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
|
|
2666
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
1359
2667
|
meta: ret.meta ?? {},
|
|
1360
2668
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1361
2669
|
invalidate: false
|
|
@@ -1371,16 +2679,16 @@ function bindingifyTransform(args) {
|
|
|
1371
2679
|
filter: bindingifyTransformFilter(options.filter)
|
|
1372
2680
|
};
|
|
1373
2681
|
}
|
|
1374
|
-
function bindingifyLoad(args) {
|
|
1375
|
-
const hook = args.plugin.load;
|
|
2682
|
+
function bindingifyLoad(args$1) {
|
|
2683
|
+
const hook = args$1.plugin.load;
|
|
1376
2684
|
if (!hook) return {};
|
|
1377
2685
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1378
2686
|
return {
|
|
1379
2687
|
plugin: async (ctx, id$1) => {
|
|
1380
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id$1), id$1);
|
|
2688
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode, id$1), id$1);
|
|
1381
2689
|
if (ret == null) return;
|
|
1382
2690
|
if (typeof ret === "string") return { code: ret };
|
|
1383
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
|
|
2691
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
1384
2692
|
meta: ret.meta || {},
|
|
1385
2693
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1386
2694
|
invalidate: false
|
|
@@ -1407,13 +2715,13 @@ function preProcessSourceMap(ret, id$1) {
|
|
|
1407
2715
|
}
|
|
1408
2716
|
return map;
|
|
1409
2717
|
}
|
|
1410
|
-
function bindingifyModuleParsed(args) {
|
|
1411
|
-
const hook = args.plugin.moduleParsed;
|
|
2718
|
+
function bindingifyModuleParsed(args$1) {
|
|
2719
|
+
const hook = args$1.plugin.moduleParsed;
|
|
1412
2720
|
if (!hook) return {};
|
|
1413
2721
|
const { handler, meta } = normalizeHook(hook);
|
|
1414
2722
|
return {
|
|
1415
2723
|
plugin: async (ctx, moduleInfo) => {
|
|
1416
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
2724
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformModuleInfo(moduleInfo, args$1.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
1417
2725
|
},
|
|
1418
2726
|
meta: bindingifyPluginHookMeta(meta)
|
|
1419
2727
|
};
|
|
@@ -1811,25 +3119,25 @@ function collectChangedBundle(changed, bundle) {
|
|
|
1811
3119
|
|
|
1812
3120
|
//#endregion
|
|
1813
3121
|
//#region src/plugin/bindingify-output-hooks.ts
|
|
1814
|
-
function bindingifyRenderStart(args) {
|
|
1815
|
-
const hook = args.plugin.renderStart;
|
|
3122
|
+
function bindingifyRenderStart(args$1) {
|
|
3123
|
+
const hook = args$1.plugin.renderStart;
|
|
1816
3124
|
if (!hook) return {};
|
|
1817
3125
|
const { handler, meta } = normalizeHook(hook);
|
|
1818
3126
|
return {
|
|
1819
3127
|
plugin: async (ctx, opts) => {
|
|
1820
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
3128
|
+
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args$1.onLog));
|
|
1821
3129
|
},
|
|
1822
3130
|
meta: bindingifyPluginHookMeta(meta)
|
|
1823
3131
|
};
|
|
1824
3132
|
}
|
|
1825
|
-
function bindingifyRenderChunk(args) {
|
|
1826
|
-
const hook = args.plugin.renderChunk;
|
|
3133
|
+
function bindingifyRenderChunk(args$1) {
|
|
3134
|
+
const hook = args$1.plugin.renderChunk;
|
|
1827
3135
|
if (!hook) return {};
|
|
1828
3136
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1829
3137
|
return {
|
|
1830
3138
|
plugin: async (ctx, code$1, chunk, opts, meta$1) => {
|
|
1831
|
-
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
1832
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), args.pluginContextData.getRenderChunkMeta());
|
|
3139
|
+
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3140
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), args$1.pluginContextData.getRenderChunkMeta());
|
|
1833
3141
|
if (ret == null) return;
|
|
1834
3142
|
if (typeof ret === "string") return { code: ret };
|
|
1835
3143
|
if (!ret.map) return { code: ret.code };
|
|
@@ -1842,30 +3150,30 @@ function bindingifyRenderChunk(args) {
|
|
|
1842
3150
|
filter: bindingifyRenderChunkFilter(options.filter)
|
|
1843
3151
|
};
|
|
1844
3152
|
}
|
|
1845
|
-
function bindingifyAugmentChunkHash(args) {
|
|
1846
|
-
const hook = args.plugin.augmentChunkHash;
|
|
3153
|
+
function bindingifyAugmentChunkHash(args$1) {
|
|
3154
|
+
const hook = args$1.plugin.augmentChunkHash;
|
|
1847
3155
|
if (!hook) return {};
|
|
1848
3156
|
const { handler, meta } = normalizeHook(hook);
|
|
1849
3157
|
return {
|
|
1850
3158
|
plugin: async (ctx, chunk) => {
|
|
1851
|
-
return await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3159
|
+
return await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
1852
3160
|
},
|
|
1853
3161
|
meta: bindingifyPluginHookMeta(meta)
|
|
1854
3162
|
};
|
|
1855
3163
|
}
|
|
1856
|
-
function bindingifyRenderError(args) {
|
|
1857
|
-
const hook = args.plugin.renderError;
|
|
3164
|
+
function bindingifyRenderError(args$1) {
|
|
3165
|
+
const hook = args$1.plugin.renderError;
|
|
1858
3166
|
if (!hook) return {};
|
|
1859
3167
|
const { handler, meta } = normalizeHook(hook);
|
|
1860
3168
|
return {
|
|
1861
3169
|
plugin: async (ctx, err) => {
|
|
1862
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), normalizeErrors(err));
|
|
3170
|
+
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), normalizeErrors(err));
|
|
1863
3171
|
},
|
|
1864
3172
|
meta: bindingifyPluginHookMeta(meta)
|
|
1865
3173
|
};
|
|
1866
3174
|
}
|
|
1867
|
-
function bindingifyGenerateBundle(args) {
|
|
1868
|
-
const hook = args.plugin.generateBundle;
|
|
3175
|
+
function bindingifyGenerateBundle(args$1) {
|
|
3176
|
+
const hook = args$1.plugin.generateBundle;
|
|
1869
3177
|
if (!hook) return {};
|
|
1870
3178
|
const { handler, meta } = normalizeHook(hook);
|
|
1871
3179
|
return {
|
|
@@ -1875,14 +3183,14 @@ function bindingifyGenerateBundle(args) {
|
|
|
1875
3183
|
deleted: new Set()
|
|
1876
3184
|
};
|
|
1877
3185
|
const output = transformToOutputBundle(bundle, changed);
|
|
1878
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), output, isWrite);
|
|
3186
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
|
|
1879
3187
|
return collectChangedBundle(changed, output);
|
|
1880
3188
|
},
|
|
1881
3189
|
meta: bindingifyPluginHookMeta(meta)
|
|
1882
3190
|
};
|
|
1883
3191
|
}
|
|
1884
|
-
function bindingifyWriteBundle(args) {
|
|
1885
|
-
const hook = args.plugin.writeBundle;
|
|
3192
|
+
function bindingifyWriteBundle(args$1) {
|
|
3193
|
+
const hook = args$1.plugin.writeBundle;
|
|
1886
3194
|
if (!hook) return {};
|
|
1887
3195
|
const { handler, meta } = normalizeHook(hook);
|
|
1888
3196
|
return {
|
|
@@ -1892,67 +3200,67 @@ function bindingifyWriteBundle(args) {
|
|
|
1892
3200
|
deleted: new Set()
|
|
1893
3201
|
};
|
|
1894
3202
|
const output = transformToOutputBundle(bundle, changed);
|
|
1895
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), output);
|
|
3203
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
|
|
1896
3204
|
return collectChangedBundle(changed, output);
|
|
1897
3205
|
},
|
|
1898
3206
|
meta: bindingifyPluginHookMeta(meta)
|
|
1899
3207
|
};
|
|
1900
3208
|
}
|
|
1901
|
-
function bindingifyCloseBundle(args) {
|
|
1902
|
-
const hook = args.plugin.closeBundle;
|
|
3209
|
+
function bindingifyCloseBundle(args$1) {
|
|
3210
|
+
const hook = args$1.plugin.closeBundle;
|
|
1903
3211
|
if (!hook) return {};
|
|
1904
3212
|
const { handler, meta } = normalizeHook(hook);
|
|
1905
3213
|
return {
|
|
1906
3214
|
plugin: async (ctx) => {
|
|
1907
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
3215
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
1908
3216
|
},
|
|
1909
3217
|
meta: bindingifyPluginHookMeta(meta)
|
|
1910
3218
|
};
|
|
1911
3219
|
}
|
|
1912
|
-
function bindingifyBanner(args) {
|
|
1913
|
-
const hook = args.plugin.banner;
|
|
3220
|
+
function bindingifyBanner(args$1) {
|
|
3221
|
+
const hook = args$1.plugin.banner;
|
|
1914
3222
|
if (!hook) return {};
|
|
1915
3223
|
const { handler, meta } = normalizeHook(hook);
|
|
1916
3224
|
return {
|
|
1917
3225
|
plugin: async (ctx, chunk) => {
|
|
1918
3226
|
if (typeof handler === "string") return handler;
|
|
1919
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3227
|
+
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
1920
3228
|
},
|
|
1921
3229
|
meta: bindingifyPluginHookMeta(meta)
|
|
1922
3230
|
};
|
|
1923
3231
|
}
|
|
1924
|
-
function bindingifyFooter(args) {
|
|
1925
|
-
const hook = args.plugin.footer;
|
|
3232
|
+
function bindingifyFooter(args$1) {
|
|
3233
|
+
const hook = args$1.plugin.footer;
|
|
1926
3234
|
if (!hook) return {};
|
|
1927
3235
|
const { handler, meta } = normalizeHook(hook);
|
|
1928
3236
|
return {
|
|
1929
3237
|
plugin: async (ctx, chunk) => {
|
|
1930
3238
|
if (typeof handler === "string") return handler;
|
|
1931
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3239
|
+
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
1932
3240
|
},
|
|
1933
3241
|
meta: bindingifyPluginHookMeta(meta)
|
|
1934
3242
|
};
|
|
1935
3243
|
}
|
|
1936
|
-
function bindingifyIntro(args) {
|
|
1937
|
-
const hook = args.plugin.intro;
|
|
3244
|
+
function bindingifyIntro(args$1) {
|
|
3245
|
+
const hook = args$1.plugin.intro;
|
|
1938
3246
|
if (!hook) return {};
|
|
1939
3247
|
const { handler, meta } = normalizeHook(hook);
|
|
1940
3248
|
return {
|
|
1941
3249
|
plugin: async (ctx, chunk) => {
|
|
1942
3250
|
if (typeof handler === "string") return handler;
|
|
1943
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3251
|
+
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
1944
3252
|
},
|
|
1945
3253
|
meta: bindingifyPluginHookMeta(meta)
|
|
1946
3254
|
};
|
|
1947
3255
|
}
|
|
1948
|
-
function bindingifyOutro(args) {
|
|
1949
|
-
const hook = args.plugin.outro;
|
|
3256
|
+
function bindingifyOutro(args$1) {
|
|
3257
|
+
const hook = args$1.plugin.outro;
|
|
1950
3258
|
if (!hook) return {};
|
|
1951
3259
|
const { handler, meta } = normalizeHook(hook);
|
|
1952
3260
|
return {
|
|
1953
3261
|
plugin: async (ctx, chunk) => {
|
|
1954
3262
|
if (typeof handler === "string") return handler;
|
|
1955
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3263
|
+
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
1956
3264
|
},
|
|
1957
3265
|
meta: bindingifyPluginHookMeta(meta)
|
|
1958
3266
|
};
|
|
@@ -1960,24 +3268,24 @@ function bindingifyOutro(args) {
|
|
|
1960
3268
|
|
|
1961
3269
|
//#endregion
|
|
1962
3270
|
//#region src/plugin/bindingify-watch-hooks.ts
|
|
1963
|
-
function bindingifyWatchChange(args) {
|
|
1964
|
-
const hook = args.plugin.watchChange;
|
|
3271
|
+
function bindingifyWatchChange(args$1) {
|
|
3272
|
+
const hook = args$1.plugin.watchChange;
|
|
1965
3273
|
if (!hook) return {};
|
|
1966
3274
|
const { handler, meta } = normalizeHook(hook);
|
|
1967
3275
|
return {
|
|
1968
3276
|
plugin: async (ctx, id$1, event) => {
|
|
1969
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id$1, { event });
|
|
3277
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), id$1, { event });
|
|
1970
3278
|
},
|
|
1971
3279
|
meta: bindingifyPluginHookMeta(meta)
|
|
1972
3280
|
};
|
|
1973
3281
|
}
|
|
1974
|
-
function bindingifyCloseWatcher(args) {
|
|
1975
|
-
const hook = args.plugin.closeWatcher;
|
|
3282
|
+
function bindingifyCloseWatcher(args$1) {
|
|
3283
|
+
const hook = args$1.plugin.closeWatcher;
|
|
1976
3284
|
if (!hook) return {};
|
|
1977
3285
|
const { handler, meta } = normalizeHook(hook);
|
|
1978
3286
|
return {
|
|
1979
3287
|
plugin: async (ctx) => {
|
|
1980
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
3288
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
1981
3289
|
},
|
|
1982
3290
|
meta: bindingifyPluginHookMeta(meta)
|
|
1983
3291
|
};
|
|
@@ -2047,7 +3355,7 @@ function extractHookUsage(plugin) {
|
|
|
2047
3355
|
//#endregion
|
|
2048
3356
|
//#region src/plugin/bindingify-plugin.ts
|
|
2049
3357
|
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
2050
|
-
const args = {
|
|
3358
|
+
const args$1 = {
|
|
2051
3359
|
plugin,
|
|
2052
3360
|
options,
|
|
2053
3361
|
outputOptions,
|
|
@@ -2057,26 +3365,26 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
|
|
|
2057
3365
|
watchMode,
|
|
2058
3366
|
normalizedOutputPlugins
|
|
2059
3367
|
};
|
|
2060
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
2061
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
2062
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
2063
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
2064
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
2065
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
2066
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
2067
|
-
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
|
|
2068
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
2069
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
2070
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
2071
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
2072
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
2073
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
2074
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
2075
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
2076
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
2077
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
2078
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
2079
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
3368
|
+
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args$1);
|
|
3369
|
+
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args$1);
|
|
3370
|
+
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args$1);
|
|
3371
|
+
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
|
|
3372
|
+
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
|
|
3373
|
+
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
|
|
3374
|
+
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
|
|
3375
|
+
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
|
|
3376
|
+
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
|
|
3377
|
+
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
|
|
3378
|
+
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args$1);
|
|
3379
|
+
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args$1);
|
|
3380
|
+
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args$1);
|
|
3381
|
+
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args$1);
|
|
3382
|
+
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args$1);
|
|
3383
|
+
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args$1);
|
|
3384
|
+
const { plugin: intro, meta: introMeta } = bindingifyIntro(args$1);
|
|
3385
|
+
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args$1);
|
|
3386
|
+
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args$1);
|
|
3387
|
+
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args$1);
|
|
2080
3388
|
let hookUsage = extractHookUsage(plugin).inner();
|
|
2081
3389
|
const result = {
|
|
2082
3390
|
name: plugin.name,
|
|
@@ -2152,13 +3460,13 @@ function wrapHandlers(plugin) {
|
|
|
2152
3460
|
"closeWatcher"
|
|
2153
3461
|
]) {
|
|
2154
3462
|
const handler = plugin[hookName];
|
|
2155
|
-
if (handler) plugin[hookName] = async (...args) => {
|
|
3463
|
+
if (handler) plugin[hookName] = async (...args$1) => {
|
|
2156
3464
|
try {
|
|
2157
|
-
return await handler(...args);
|
|
3465
|
+
return await handler(...args$1);
|
|
2158
3466
|
} catch (e) {
|
|
2159
3467
|
return require_parse_ast_index.error(require_parse_ast_index.logPluginError(e, plugin.name, {
|
|
2160
3468
|
hook: hookName,
|
|
2161
|
-
id: hookName === "transform" ? args[2] : void 0
|
|
3469
|
+
id: hookName === "transform" ? args$1[2] : void 0
|
|
2162
3470
|
}));
|
|
2163
3471
|
}
|
|
2164
3472
|
};
|
|
@@ -2917,6 +4225,9 @@ var RolldownBuild = class {
|
|
|
2917
4225
|
async generateHmrPatch(changedFiles) {
|
|
2918
4226
|
return this.#bundler?.bundler.generateHmrPatch(changedFiles);
|
|
2919
4227
|
}
|
|
4228
|
+
async hmrInvalidate(file, firstInvalidatedBy) {
|
|
4229
|
+
return this.#bundler?.bundler.hmrInvalidate(file, firstInvalidatedBy);
|
|
4230
|
+
}
|
|
2920
4231
|
get watchFiles() {
|
|
2921
4232
|
return this.#bundler?.bundler.watchFiles ?? [];
|
|
2922
4233
|
}
|
|
@@ -3137,7 +4448,7 @@ Object.defineProperty(exports, 'defineConfig', {
|
|
|
3137
4448
|
Object.defineProperty(exports, 'description', {
|
|
3138
4449
|
enumerable: true,
|
|
3139
4450
|
get: function () {
|
|
3140
|
-
return description;
|
|
4451
|
+
return description$1;
|
|
3141
4452
|
}
|
|
3142
4453
|
});
|
|
3143
4454
|
Object.defineProperty(exports, 'dynamicImportVarsPlugin', {
|