@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
package/dist/browser.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { BindingHookSideEffects, BindingLogLevel, BindingPluginOrder, BindingWatcher, Bundler, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import "@valibot/to-json-schema";
|
|
4
3
|
import colors from "ansis";
|
|
5
|
-
import * as v from "valibot";
|
|
6
4
|
|
|
7
5
|
//#region package.json
|
|
8
|
-
var version = "1.0.0-beta.8-commit.
|
|
6
|
+
var version = "1.0.0-beta.8-commit.101b994";
|
|
9
7
|
|
|
10
8
|
//#endregion
|
|
11
9
|
//#region src/builtin-plugin/utils.ts
|
|
@@ -421,11 +419,11 @@ const DEFINED_HOOK_NAMES = {
|
|
|
421
419
|
|
|
422
420
|
//#endregion
|
|
423
421
|
//#region src/utils/async-flatten.ts
|
|
424
|
-
async function asyncFlatten(array) {
|
|
422
|
+
async function asyncFlatten(array$1) {
|
|
425
423
|
do
|
|
426
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
427
|
-
while (array.some((v
|
|
428
|
-
return array;
|
|
424
|
+
array$1 = (await Promise.all(array$1)).flat(Infinity);
|
|
425
|
+
while (array$1.some((v) => v?.then));
|
|
426
|
+
return array$1;
|
|
429
427
|
}
|
|
430
428
|
|
|
431
429
|
//#endregion
|
|
@@ -540,201 +538,1170 @@ function getSortedPlugins(hookName, plugins) {
|
|
|
540
538
|
];
|
|
541
539
|
}
|
|
542
540
|
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
|
|
543
|
+
var store;
|
|
544
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
545
|
+
function getGlobalConfig(config2) {
|
|
546
|
+
return {
|
|
547
|
+
lang: config2?.lang ?? store?.lang,
|
|
548
|
+
message: config2?.message,
|
|
549
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
550
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
var store2;
|
|
554
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
555
|
+
function getGlobalMessage(lang) {
|
|
556
|
+
return store2?.get(lang);
|
|
557
|
+
}
|
|
558
|
+
var store3;
|
|
559
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
560
|
+
function getSchemaMessage(lang) {
|
|
561
|
+
return store3?.get(lang);
|
|
562
|
+
}
|
|
563
|
+
var store4;
|
|
564
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
565
|
+
function getSpecificMessage(reference, lang) {
|
|
566
|
+
return store4?.get(reference)?.get(lang);
|
|
567
|
+
}
|
|
568
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
569
|
+
function _stringify(input) {
|
|
570
|
+
const type = typeof input;
|
|
571
|
+
if (type === "string") return `"${input}"`;
|
|
572
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
573
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
574
|
+
return type;
|
|
575
|
+
}
|
|
576
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
577
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
578
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
579
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
580
|
+
const issue = {
|
|
581
|
+
kind: context.kind,
|
|
582
|
+
type: context.type,
|
|
583
|
+
input,
|
|
584
|
+
expected,
|
|
585
|
+
received,
|
|
586
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
587
|
+
requirement: context.requirement,
|
|
588
|
+
path: other?.path,
|
|
589
|
+
issues: other?.issues,
|
|
590
|
+
lang: config2.lang,
|
|
591
|
+
abortEarly: config2.abortEarly,
|
|
592
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
593
|
+
};
|
|
594
|
+
const isSchema = context.kind === "schema";
|
|
595
|
+
const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
596
|
+
if (message !== void 0) issue.message = typeof message === "function" ? message(issue) : message;
|
|
597
|
+
if (isSchema) dataset.typed = false;
|
|
598
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
599
|
+
else dataset.issues = [issue];
|
|
600
|
+
}
|
|
601
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
602
|
+
function _getStandardProps(context) {
|
|
603
|
+
return {
|
|
604
|
+
version: 1,
|
|
605
|
+
vendor: "valibot",
|
|
606
|
+
validate(value2) {
|
|
607
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
612
|
+
function _isValidObjectKey(object2, key) {
|
|
613
|
+
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
614
|
+
}
|
|
615
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
616
|
+
function _joinExpects(values2, separator) {
|
|
617
|
+
const list = [...new Set(values2)];
|
|
618
|
+
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
619
|
+
return list[0] ?? "never";
|
|
620
|
+
}
|
|
621
|
+
var ValiError = class extends Error {
|
|
622
|
+
/**
|
|
623
|
+
* Creates a Valibot error with useful information.
|
|
624
|
+
*
|
|
625
|
+
* @param issues The error issues.
|
|
626
|
+
*/
|
|
627
|
+
constructor(issues) {
|
|
628
|
+
super(issues[0].message);
|
|
629
|
+
this.name = "ValiError";
|
|
630
|
+
this.issues = issues;
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
634
|
+
function args(schema) {
|
|
635
|
+
return {
|
|
636
|
+
kind: "transformation",
|
|
637
|
+
type: "args",
|
|
638
|
+
reference: args,
|
|
639
|
+
async: false,
|
|
640
|
+
schema,
|
|
641
|
+
"~run"(dataset, config2) {
|
|
642
|
+
const func = dataset.value;
|
|
643
|
+
dataset.value = (...args_) => {
|
|
644
|
+
const argsDataset = this.schema["~run"]({ value: args_ }, config2);
|
|
645
|
+
if (argsDataset.issues) throw new ValiError(argsDataset.issues);
|
|
646
|
+
return func(...argsDataset.value);
|
|
647
|
+
};
|
|
648
|
+
return dataset;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
653
|
+
function awaitAsync() {
|
|
654
|
+
return {
|
|
655
|
+
kind: "transformation",
|
|
656
|
+
type: "await",
|
|
657
|
+
reference: awaitAsync,
|
|
658
|
+
async: true,
|
|
659
|
+
async "~run"(dataset) {
|
|
660
|
+
dataset.value = await dataset.value;
|
|
661
|
+
return dataset;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
666
|
+
function description(description_) {
|
|
667
|
+
return {
|
|
668
|
+
kind: "metadata",
|
|
669
|
+
type: "description",
|
|
670
|
+
reference: description,
|
|
671
|
+
description: description_
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
675
|
+
function returns(schema) {
|
|
676
|
+
return {
|
|
677
|
+
kind: "transformation",
|
|
678
|
+
type: "returns",
|
|
679
|
+
reference: returns,
|
|
680
|
+
async: false,
|
|
681
|
+
schema,
|
|
682
|
+
"~run"(dataset, config2) {
|
|
683
|
+
const func = dataset.value;
|
|
684
|
+
dataset.value = (...args_) => {
|
|
685
|
+
const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config2);
|
|
686
|
+
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
687
|
+
return returnsDataset.value;
|
|
688
|
+
};
|
|
689
|
+
return dataset;
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
694
|
+
function returnsAsync(schema) {
|
|
695
|
+
return {
|
|
696
|
+
kind: "transformation",
|
|
697
|
+
type: "returns",
|
|
698
|
+
reference: returnsAsync,
|
|
699
|
+
async: false,
|
|
700
|
+
schema,
|
|
701
|
+
"~run"(dataset, config2) {
|
|
702
|
+
const func = dataset.value;
|
|
703
|
+
dataset.value = async (...args_) => {
|
|
704
|
+
const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config2);
|
|
705
|
+
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
706
|
+
return returnsDataset.value;
|
|
707
|
+
};
|
|
708
|
+
return dataset;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
713
|
+
function getFallback(schema, dataset, config2) {
|
|
714
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
715
|
+
}
|
|
716
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
717
|
+
function getDefault(schema, dataset, config2) {
|
|
718
|
+
return typeof schema.default === "function" ? schema.default(dataset, config2) : schema.default;
|
|
719
|
+
}
|
|
720
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
721
|
+
function any() {
|
|
722
|
+
return {
|
|
723
|
+
kind: "schema",
|
|
724
|
+
type: "any",
|
|
725
|
+
reference: any,
|
|
726
|
+
expects: "any",
|
|
727
|
+
async: false,
|
|
728
|
+
get "~standard"() {
|
|
729
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
730
|
+
},
|
|
731
|
+
"~run"(dataset) {
|
|
732
|
+
dataset.typed = true;
|
|
733
|
+
return dataset;
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
738
|
+
function array(item, message) {
|
|
739
|
+
return {
|
|
740
|
+
kind: "schema",
|
|
741
|
+
type: "array",
|
|
742
|
+
reference: array,
|
|
743
|
+
expects: "Array",
|
|
744
|
+
async: false,
|
|
745
|
+
item,
|
|
746
|
+
message,
|
|
747
|
+
get "~standard"() {
|
|
748
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
749
|
+
},
|
|
750
|
+
"~run"(dataset, config2) {
|
|
751
|
+
const input = dataset.value;
|
|
752
|
+
if (Array.isArray(input)) {
|
|
753
|
+
dataset.typed = true;
|
|
754
|
+
dataset.value = [];
|
|
755
|
+
for (let key = 0; key < input.length; key++) {
|
|
756
|
+
const value2 = input[key];
|
|
757
|
+
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
758
|
+
if (itemDataset.issues) {
|
|
759
|
+
const pathItem = {
|
|
760
|
+
type: "array",
|
|
761
|
+
origin: "value",
|
|
762
|
+
input,
|
|
763
|
+
key,
|
|
764
|
+
value: value2
|
|
765
|
+
};
|
|
766
|
+
for (const issue of itemDataset.issues) {
|
|
767
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
768
|
+
else issue.path = [pathItem];
|
|
769
|
+
dataset.issues?.push(issue);
|
|
770
|
+
}
|
|
771
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
772
|
+
if (config2.abortEarly) {
|
|
773
|
+
dataset.typed = false;
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
778
|
+
dataset.value.push(itemDataset.value);
|
|
779
|
+
}
|
|
780
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
781
|
+
return dataset;
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
786
|
+
function boolean(message) {
|
|
787
|
+
return {
|
|
788
|
+
kind: "schema",
|
|
789
|
+
type: "boolean",
|
|
790
|
+
reference: boolean,
|
|
791
|
+
expects: "boolean",
|
|
792
|
+
async: false,
|
|
793
|
+
message,
|
|
794
|
+
get "~standard"() {
|
|
795
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
796
|
+
},
|
|
797
|
+
"~run"(dataset, config2) {
|
|
798
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
799
|
+
else _addIssue(this, "type", dataset, config2);
|
|
800
|
+
return dataset;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
805
|
+
function custom(check2, message) {
|
|
806
|
+
return {
|
|
807
|
+
kind: "schema",
|
|
808
|
+
type: "custom",
|
|
809
|
+
reference: custom,
|
|
810
|
+
expects: "unknown",
|
|
811
|
+
async: false,
|
|
812
|
+
check: check2,
|
|
813
|
+
message,
|
|
814
|
+
get "~standard"() {
|
|
815
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
816
|
+
},
|
|
817
|
+
"~run"(dataset, config2) {
|
|
818
|
+
if (this.check(dataset.value)) dataset.typed = true;
|
|
819
|
+
else _addIssue(this, "type", dataset, config2);
|
|
820
|
+
return dataset;
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
825
|
+
function enum_(enum__, message) {
|
|
826
|
+
const options = [];
|
|
827
|
+
for (const key in enum__) if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) options.push(enum__[key]);
|
|
828
|
+
return {
|
|
829
|
+
kind: "schema",
|
|
830
|
+
type: "enum",
|
|
831
|
+
reference: enum_,
|
|
832
|
+
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
833
|
+
async: false,
|
|
834
|
+
enum: enum__,
|
|
835
|
+
options,
|
|
836
|
+
message,
|
|
837
|
+
get "~standard"() {
|
|
838
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
839
|
+
},
|
|
840
|
+
"~run"(dataset, config2) {
|
|
841
|
+
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
842
|
+
else _addIssue(this, "type", dataset, config2);
|
|
843
|
+
return dataset;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
848
|
+
function function_(message) {
|
|
849
|
+
return {
|
|
850
|
+
kind: "schema",
|
|
851
|
+
type: "function",
|
|
852
|
+
reference: function_,
|
|
853
|
+
expects: "Function",
|
|
854
|
+
async: false,
|
|
855
|
+
message,
|
|
856
|
+
get "~standard"() {
|
|
857
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
858
|
+
},
|
|
859
|
+
"~run"(dataset, config2) {
|
|
860
|
+
if (typeof dataset.value === "function") dataset.typed = true;
|
|
861
|
+
else _addIssue(this, "type", dataset, config2);
|
|
862
|
+
return dataset;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
867
|
+
function instance(class_, message) {
|
|
868
|
+
return {
|
|
869
|
+
kind: "schema",
|
|
870
|
+
type: "instance",
|
|
871
|
+
reference: instance,
|
|
872
|
+
expects: class_.name,
|
|
873
|
+
async: false,
|
|
874
|
+
class: class_,
|
|
875
|
+
message,
|
|
876
|
+
get "~standard"() {
|
|
877
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
878
|
+
},
|
|
879
|
+
"~run"(dataset, config2) {
|
|
880
|
+
if (dataset.value instanceof this.class) dataset.typed = true;
|
|
881
|
+
else _addIssue(this, "type", dataset, config2);
|
|
882
|
+
return dataset;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
887
|
+
function literal(literal_, message) {
|
|
888
|
+
return {
|
|
889
|
+
kind: "schema",
|
|
890
|
+
type: "literal",
|
|
891
|
+
reference: literal,
|
|
892
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
893
|
+
async: false,
|
|
894
|
+
literal: literal_,
|
|
895
|
+
message,
|
|
896
|
+
get "~standard"() {
|
|
897
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
898
|
+
},
|
|
899
|
+
"~run"(dataset, config2) {
|
|
900
|
+
if (dataset.value === this.literal) dataset.typed = true;
|
|
901
|
+
else _addIssue(this, "type", dataset, config2);
|
|
902
|
+
return dataset;
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
907
|
+
function looseObject(entries, message) {
|
|
908
|
+
return {
|
|
909
|
+
kind: "schema",
|
|
910
|
+
type: "loose_object",
|
|
911
|
+
reference: looseObject,
|
|
912
|
+
expects: "Object",
|
|
913
|
+
async: false,
|
|
914
|
+
entries,
|
|
915
|
+
message,
|
|
916
|
+
get "~standard"() {
|
|
917
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
918
|
+
},
|
|
919
|
+
"~run"(dataset, config2) {
|
|
920
|
+
const input = dataset.value;
|
|
921
|
+
if (input && typeof input === "object") {
|
|
922
|
+
dataset.typed = true;
|
|
923
|
+
dataset.value = {};
|
|
924
|
+
for (const key in this.entries) {
|
|
925
|
+
const valueSchema = this.entries[key];
|
|
926
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
927
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
928
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
929
|
+
if (valueDataset.issues) {
|
|
930
|
+
const pathItem = {
|
|
931
|
+
type: "object",
|
|
932
|
+
origin: "value",
|
|
933
|
+
input,
|
|
934
|
+
key,
|
|
935
|
+
value: value2
|
|
936
|
+
};
|
|
937
|
+
for (const issue of valueDataset.issues) {
|
|
938
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
939
|
+
else issue.path = [pathItem];
|
|
940
|
+
dataset.issues?.push(issue);
|
|
941
|
+
}
|
|
942
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
943
|
+
if (config2.abortEarly) {
|
|
944
|
+
dataset.typed = false;
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
949
|
+
dataset.value[key] = valueDataset.value;
|
|
950
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
951
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
952
|
+
_addIssue(this, "key", dataset, config2, {
|
|
953
|
+
input: void 0,
|
|
954
|
+
expected: `"${key}"`,
|
|
955
|
+
path: [{
|
|
956
|
+
type: "object",
|
|
957
|
+
origin: "key",
|
|
958
|
+
input,
|
|
959
|
+
key,
|
|
960
|
+
value: input[key]
|
|
961
|
+
}]
|
|
962
|
+
});
|
|
963
|
+
if (config2.abortEarly) break;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (!dataset.issues || !config2.abortEarly) {
|
|
967
|
+
for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
|
|
968
|
+
}
|
|
969
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
970
|
+
return dataset;
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
975
|
+
function never(message) {
|
|
976
|
+
return {
|
|
977
|
+
kind: "schema",
|
|
978
|
+
type: "never",
|
|
979
|
+
reference: never,
|
|
980
|
+
expects: "never",
|
|
981
|
+
async: false,
|
|
982
|
+
message,
|
|
983
|
+
get "~standard"() {
|
|
984
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
985
|
+
},
|
|
986
|
+
"~run"(dataset, config2) {
|
|
987
|
+
_addIssue(this, "type", dataset, config2);
|
|
988
|
+
return dataset;
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
993
|
+
function nullish(wrapped, default_) {
|
|
994
|
+
return {
|
|
995
|
+
kind: "schema",
|
|
996
|
+
type: "nullish",
|
|
997
|
+
reference: nullish,
|
|
998
|
+
expects: `(${wrapped.expects} | null | undefined)`,
|
|
999
|
+
async: false,
|
|
1000
|
+
wrapped,
|
|
1001
|
+
default: default_,
|
|
1002
|
+
get "~standard"() {
|
|
1003
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1004
|
+
},
|
|
1005
|
+
"~run"(dataset, config2) {
|
|
1006
|
+
if (dataset.value === null || dataset.value === void 0) {
|
|
1007
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
1008
|
+
if (dataset.value === null || dataset.value === void 0) {
|
|
1009
|
+
dataset.typed = true;
|
|
1010
|
+
return dataset;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return this.wrapped["~run"](dataset, config2);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1018
|
+
function number(message) {
|
|
1019
|
+
return {
|
|
1020
|
+
kind: "schema",
|
|
1021
|
+
type: "number",
|
|
1022
|
+
reference: number,
|
|
1023
|
+
expects: "number",
|
|
1024
|
+
async: false,
|
|
1025
|
+
message,
|
|
1026
|
+
get "~standard"() {
|
|
1027
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1028
|
+
},
|
|
1029
|
+
"~run"(dataset, config2) {
|
|
1030
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
1031
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1032
|
+
return dataset;
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1037
|
+
function object(entries, message) {
|
|
1038
|
+
return {
|
|
1039
|
+
kind: "schema",
|
|
1040
|
+
type: "object",
|
|
1041
|
+
reference: object,
|
|
1042
|
+
expects: "Object",
|
|
1043
|
+
async: false,
|
|
1044
|
+
entries,
|
|
1045
|
+
message,
|
|
1046
|
+
get "~standard"() {
|
|
1047
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1048
|
+
},
|
|
1049
|
+
"~run"(dataset, config2) {
|
|
1050
|
+
const input = dataset.value;
|
|
1051
|
+
if (input && typeof input === "object") {
|
|
1052
|
+
dataset.typed = true;
|
|
1053
|
+
dataset.value = {};
|
|
1054
|
+
for (const key in this.entries) {
|
|
1055
|
+
const valueSchema = this.entries[key];
|
|
1056
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
1057
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
1058
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
1059
|
+
if (valueDataset.issues) {
|
|
1060
|
+
const pathItem = {
|
|
1061
|
+
type: "object",
|
|
1062
|
+
origin: "value",
|
|
1063
|
+
input,
|
|
1064
|
+
key,
|
|
1065
|
+
value: value2
|
|
1066
|
+
};
|
|
1067
|
+
for (const issue of valueDataset.issues) {
|
|
1068
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1069
|
+
else issue.path = [pathItem];
|
|
1070
|
+
dataset.issues?.push(issue);
|
|
1071
|
+
}
|
|
1072
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1073
|
+
if (config2.abortEarly) {
|
|
1074
|
+
dataset.typed = false;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
1079
|
+
dataset.value[key] = valueDataset.value;
|
|
1080
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
1081
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
1082
|
+
_addIssue(this, "key", dataset, config2, {
|
|
1083
|
+
input: void 0,
|
|
1084
|
+
expected: `"${key}"`,
|
|
1085
|
+
path: [{
|
|
1086
|
+
type: "object",
|
|
1087
|
+
origin: "key",
|
|
1088
|
+
input,
|
|
1089
|
+
key,
|
|
1090
|
+
value: input[key]
|
|
1091
|
+
}]
|
|
1092
|
+
});
|
|
1093
|
+
if (config2.abortEarly) break;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1097
|
+
return dataset;
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1102
|
+
function optional(wrapped, default_) {
|
|
1103
|
+
return {
|
|
1104
|
+
kind: "schema",
|
|
1105
|
+
type: "optional",
|
|
1106
|
+
reference: optional,
|
|
1107
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
1108
|
+
async: false,
|
|
1109
|
+
wrapped,
|
|
1110
|
+
default: default_,
|
|
1111
|
+
get "~standard"() {
|
|
1112
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1113
|
+
},
|
|
1114
|
+
"~run"(dataset, config2) {
|
|
1115
|
+
if (dataset.value === void 0) {
|
|
1116
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
1117
|
+
if (dataset.value === void 0) {
|
|
1118
|
+
dataset.typed = true;
|
|
1119
|
+
return dataset;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return this.wrapped["~run"](dataset, config2);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1127
|
+
function promise(message) {
|
|
1128
|
+
return {
|
|
1129
|
+
kind: "schema",
|
|
1130
|
+
type: "promise",
|
|
1131
|
+
reference: promise,
|
|
1132
|
+
expects: "Promise",
|
|
1133
|
+
async: false,
|
|
1134
|
+
message,
|
|
1135
|
+
get "~standard"() {
|
|
1136
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1137
|
+
},
|
|
1138
|
+
"~run"(dataset, config2) {
|
|
1139
|
+
if (dataset.value instanceof Promise) dataset.typed = true;
|
|
1140
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1141
|
+
return dataset;
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1146
|
+
function record(key, value2, message) {
|
|
1147
|
+
return {
|
|
1148
|
+
kind: "schema",
|
|
1149
|
+
type: "record",
|
|
1150
|
+
reference: record,
|
|
1151
|
+
expects: "Object",
|
|
1152
|
+
async: false,
|
|
1153
|
+
key,
|
|
1154
|
+
value: value2,
|
|
1155
|
+
message,
|
|
1156
|
+
get "~standard"() {
|
|
1157
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1158
|
+
},
|
|
1159
|
+
"~run"(dataset, config2) {
|
|
1160
|
+
const input = dataset.value;
|
|
1161
|
+
if (input && typeof input === "object") {
|
|
1162
|
+
dataset.typed = true;
|
|
1163
|
+
dataset.value = {};
|
|
1164
|
+
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
1165
|
+
const entryValue = input[entryKey];
|
|
1166
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
1167
|
+
if (keyDataset.issues) {
|
|
1168
|
+
const pathItem = {
|
|
1169
|
+
type: "object",
|
|
1170
|
+
origin: "key",
|
|
1171
|
+
input,
|
|
1172
|
+
key: entryKey,
|
|
1173
|
+
value: entryValue
|
|
1174
|
+
};
|
|
1175
|
+
for (const issue of keyDataset.issues) {
|
|
1176
|
+
issue.path = [pathItem];
|
|
1177
|
+
dataset.issues?.push(issue);
|
|
1178
|
+
}
|
|
1179
|
+
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
1180
|
+
if (config2.abortEarly) {
|
|
1181
|
+
dataset.typed = false;
|
|
1182
|
+
break;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
const valueDataset = this.value["~run"]({ value: entryValue }, config2);
|
|
1186
|
+
if (valueDataset.issues) {
|
|
1187
|
+
const pathItem = {
|
|
1188
|
+
type: "object",
|
|
1189
|
+
origin: "value",
|
|
1190
|
+
input,
|
|
1191
|
+
key: entryKey,
|
|
1192
|
+
value: entryValue
|
|
1193
|
+
};
|
|
1194
|
+
for (const issue of valueDataset.issues) {
|
|
1195
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1196
|
+
else issue.path = [pathItem];
|
|
1197
|
+
dataset.issues?.push(issue);
|
|
1198
|
+
}
|
|
1199
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1200
|
+
if (config2.abortEarly) {
|
|
1201
|
+
dataset.typed = false;
|
|
1202
|
+
break;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
1206
|
+
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
1207
|
+
}
|
|
1208
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1209
|
+
return dataset;
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1214
|
+
function strictObject(entries, message) {
|
|
1215
|
+
return {
|
|
1216
|
+
kind: "schema",
|
|
1217
|
+
type: "strict_object",
|
|
1218
|
+
reference: strictObject,
|
|
1219
|
+
expects: "Object",
|
|
1220
|
+
async: false,
|
|
1221
|
+
entries,
|
|
1222
|
+
message,
|
|
1223
|
+
get "~standard"() {
|
|
1224
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1225
|
+
},
|
|
1226
|
+
"~run"(dataset, config2) {
|
|
1227
|
+
const input = dataset.value;
|
|
1228
|
+
if (input && typeof input === "object") {
|
|
1229
|
+
dataset.typed = true;
|
|
1230
|
+
dataset.value = {};
|
|
1231
|
+
for (const key in this.entries) {
|
|
1232
|
+
const valueSchema = this.entries[key];
|
|
1233
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
1234
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
1235
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
1236
|
+
if (valueDataset.issues) {
|
|
1237
|
+
const pathItem = {
|
|
1238
|
+
type: "object",
|
|
1239
|
+
origin: "value",
|
|
1240
|
+
input,
|
|
1241
|
+
key,
|
|
1242
|
+
value: value2
|
|
1243
|
+
};
|
|
1244
|
+
for (const issue of valueDataset.issues) {
|
|
1245
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1246
|
+
else issue.path = [pathItem];
|
|
1247
|
+
dataset.issues?.push(issue);
|
|
1248
|
+
}
|
|
1249
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1250
|
+
if (config2.abortEarly) {
|
|
1251
|
+
dataset.typed = false;
|
|
1252
|
+
break;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
1256
|
+
dataset.value[key] = valueDataset.value;
|
|
1257
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
1258
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
1259
|
+
_addIssue(this, "key", dataset, config2, {
|
|
1260
|
+
input: void 0,
|
|
1261
|
+
expected: `"${key}"`,
|
|
1262
|
+
path: [{
|
|
1263
|
+
type: "object",
|
|
1264
|
+
origin: "key",
|
|
1265
|
+
input,
|
|
1266
|
+
key,
|
|
1267
|
+
value: input[key]
|
|
1268
|
+
}]
|
|
1269
|
+
});
|
|
1270
|
+
if (config2.abortEarly) break;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
if (!dataset.issues || !config2.abortEarly) {
|
|
1274
|
+
for (const key in input) if (!(key in this.entries)) {
|
|
1275
|
+
_addIssue(this, "key", dataset, config2, {
|
|
1276
|
+
input: key,
|
|
1277
|
+
expected: "never",
|
|
1278
|
+
path: [{
|
|
1279
|
+
type: "object",
|
|
1280
|
+
origin: "key",
|
|
1281
|
+
input,
|
|
1282
|
+
key,
|
|
1283
|
+
value: input[key]
|
|
1284
|
+
}]
|
|
1285
|
+
});
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1290
|
+
return dataset;
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1295
|
+
function string(message) {
|
|
1296
|
+
return {
|
|
1297
|
+
kind: "schema",
|
|
1298
|
+
type: "string",
|
|
1299
|
+
reference: string,
|
|
1300
|
+
expects: "string",
|
|
1301
|
+
async: false,
|
|
1302
|
+
message,
|
|
1303
|
+
get "~standard"() {
|
|
1304
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1305
|
+
},
|
|
1306
|
+
"~run"(dataset, config2) {
|
|
1307
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
1308
|
+
else _addIssue(this, "type", dataset, config2);
|
|
1309
|
+
return dataset;
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1314
|
+
function tuple(items, message) {
|
|
1315
|
+
return {
|
|
1316
|
+
kind: "schema",
|
|
1317
|
+
type: "tuple",
|
|
1318
|
+
reference: tuple,
|
|
1319
|
+
expects: "Array",
|
|
1320
|
+
async: false,
|
|
1321
|
+
items,
|
|
1322
|
+
message,
|
|
1323
|
+
get "~standard"() {
|
|
1324
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1325
|
+
},
|
|
1326
|
+
"~run"(dataset, config2) {
|
|
1327
|
+
const input = dataset.value;
|
|
1328
|
+
if (Array.isArray(input)) {
|
|
1329
|
+
dataset.typed = true;
|
|
1330
|
+
dataset.value = [];
|
|
1331
|
+
for (let key = 0; key < this.items.length; key++) {
|
|
1332
|
+
const value2 = input[key];
|
|
1333
|
+
const itemDataset = this.items[key]["~run"]({ value: value2 }, config2);
|
|
1334
|
+
if (itemDataset.issues) {
|
|
1335
|
+
const pathItem = {
|
|
1336
|
+
type: "array",
|
|
1337
|
+
origin: "value",
|
|
1338
|
+
input,
|
|
1339
|
+
key,
|
|
1340
|
+
value: value2
|
|
1341
|
+
};
|
|
1342
|
+
for (const issue of itemDataset.issues) {
|
|
1343
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
1344
|
+
else issue.path = [pathItem];
|
|
1345
|
+
dataset.issues?.push(issue);
|
|
1346
|
+
}
|
|
1347
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
1348
|
+
if (config2.abortEarly) {
|
|
1349
|
+
dataset.typed = false;
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
1354
|
+
dataset.value.push(itemDataset.value);
|
|
1355
|
+
}
|
|
1356
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
1357
|
+
return dataset;
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1362
|
+
function _subIssues(datasets) {
|
|
1363
|
+
let issues;
|
|
1364
|
+
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
1365
|
+
else issues = dataset.issues;
|
|
1366
|
+
return issues;
|
|
1367
|
+
}
|
|
1368
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1369
|
+
function union(options, message) {
|
|
1370
|
+
return {
|
|
1371
|
+
kind: "schema",
|
|
1372
|
+
type: "union",
|
|
1373
|
+
reference: union,
|
|
1374
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1375
|
+
async: false,
|
|
1376
|
+
options,
|
|
1377
|
+
message,
|
|
1378
|
+
get "~standard"() {
|
|
1379
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1380
|
+
},
|
|
1381
|
+
"~run"(dataset, config2) {
|
|
1382
|
+
let validDataset;
|
|
1383
|
+
let typedDatasets;
|
|
1384
|
+
let untypedDatasets;
|
|
1385
|
+
for (const schema of this.options) {
|
|
1386
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
1387
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1388
|
+
else typedDatasets = [optionDataset];
|
|
1389
|
+
else {
|
|
1390
|
+
validDataset = optionDataset;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1394
|
+
else untypedDatasets = [optionDataset];
|
|
1395
|
+
}
|
|
1396
|
+
if (validDataset) return validDataset;
|
|
1397
|
+
if (typedDatasets) {
|
|
1398
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1399
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1400
|
+
dataset.typed = true;
|
|
1401
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1402
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1403
|
+
return dataset;
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1408
|
+
function unionAsync(options, message) {
|
|
1409
|
+
return {
|
|
1410
|
+
kind: "schema",
|
|
1411
|
+
type: "union",
|
|
1412
|
+
reference: unionAsync,
|
|
1413
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1414
|
+
async: true,
|
|
1415
|
+
options,
|
|
1416
|
+
message,
|
|
1417
|
+
get "~standard"() {
|
|
1418
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1419
|
+
},
|
|
1420
|
+
async "~run"(dataset, config2) {
|
|
1421
|
+
let validDataset;
|
|
1422
|
+
let typedDatasets;
|
|
1423
|
+
let untypedDatasets;
|
|
1424
|
+
for (const schema of this.options) {
|
|
1425
|
+
const optionDataset = await schema["~run"]({ value: dataset.value }, config2);
|
|
1426
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1427
|
+
else typedDatasets = [optionDataset];
|
|
1428
|
+
else {
|
|
1429
|
+
validDataset = optionDataset;
|
|
1430
|
+
break;
|
|
1431
|
+
}
|
|
1432
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1433
|
+
else untypedDatasets = [optionDataset];
|
|
1434
|
+
}
|
|
1435
|
+
if (validDataset) return validDataset;
|
|
1436
|
+
if (typedDatasets) {
|
|
1437
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1438
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1439
|
+
dataset.typed = true;
|
|
1440
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1441
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1442
|
+
return dataset;
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1447
|
+
function omit(schema, keys) {
|
|
1448
|
+
const entries = { ...schema.entries };
|
|
1449
|
+
for (const key of keys) delete entries[key];
|
|
1450
|
+
return {
|
|
1451
|
+
...schema,
|
|
1452
|
+
entries,
|
|
1453
|
+
get "~standard"() {
|
|
1454
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1459
|
+
function pipe(...pipe2) {
|
|
1460
|
+
return {
|
|
1461
|
+
...pipe2[0],
|
|
1462
|
+
pipe: pipe2,
|
|
1463
|
+
get "~standard"() {
|
|
1464
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1465
|
+
},
|
|
1466
|
+
"~run"(dataset, config2) {
|
|
1467
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1468
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1469
|
+
dataset.typed = false;
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = item["~run"](dataset, config2);
|
|
1473
|
+
}
|
|
1474
|
+
return dataset;
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1479
|
+
function pipeAsync(...pipe2) {
|
|
1480
|
+
return {
|
|
1481
|
+
...pipe2[0],
|
|
1482
|
+
pipe: pipe2,
|
|
1483
|
+
async: true,
|
|
1484
|
+
get "~standard"() {
|
|
1485
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
1486
|
+
},
|
|
1487
|
+
async "~run"(dataset, config2) {
|
|
1488
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1489
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1490
|
+
dataset.typed = false;
|
|
1491
|
+
break;
|
|
1492
|
+
}
|
|
1493
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = await item["~run"](dataset, config2);
|
|
1494
|
+
}
|
|
1495
|
+
return dataset;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1500
|
+
function safeParse(schema, input, config2) {
|
|
1501
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
1502
|
+
return {
|
|
1503
|
+
typed: dataset.typed,
|
|
1504
|
+
success: !dataset.issues,
|
|
1505
|
+
output: dataset.value,
|
|
1506
|
+
issues: dataset.issues
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
|
|
543
1510
|
//#endregion
|
|
544
1511
|
//#region src/utils/validator.ts
|
|
545
|
-
const StringOrRegExpSchema =
|
|
546
|
-
const LogLevelSchema =
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
1512
|
+
const StringOrRegExpSchema = union([string(), instance(RegExp)]);
|
|
1513
|
+
const LogLevelSchema = union([
|
|
1514
|
+
literal("debug"),
|
|
1515
|
+
literal("info"),
|
|
1516
|
+
literal("warn")
|
|
550
1517
|
]);
|
|
551
|
-
const LogLevelOptionSchema =
|
|
552
|
-
const LogLevelWithErrorSchema =
|
|
553
|
-
const RollupLogSchema =
|
|
554
|
-
const RollupLogWithStringSchema =
|
|
555
|
-
const InputOptionSchema =
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
1518
|
+
const LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
|
|
1519
|
+
const LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
|
|
1520
|
+
const RollupLogSchema = any();
|
|
1521
|
+
const RollupLogWithStringSchema = union([RollupLogSchema, string()]);
|
|
1522
|
+
const InputOptionSchema = union([
|
|
1523
|
+
string(),
|
|
1524
|
+
array(string()),
|
|
1525
|
+
record(string(), string())
|
|
559
1526
|
]);
|
|
560
|
-
const ExternalSchema =
|
|
1527
|
+
const ExternalSchema = union([
|
|
561
1528
|
StringOrRegExpSchema,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
])),
|
|
1529
|
+
array(StringOrRegExpSchema),
|
|
1530
|
+
pipe(function_(), args(tuple([
|
|
1531
|
+
string(),
|
|
1532
|
+
optional(string()),
|
|
1533
|
+
boolean()
|
|
1534
|
+
])), returns(nullish(boolean())))
|
|
568
1535
|
]);
|
|
569
|
-
const ModuleTypesSchema =
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
1536
|
+
const ModuleTypesSchema = record(string(), union([
|
|
1537
|
+
literal("base64"),
|
|
1538
|
+
literal("binary"),
|
|
1539
|
+
literal("css"),
|
|
1540
|
+
literal("dataurl"),
|
|
1541
|
+
literal("empty"),
|
|
1542
|
+
literal("js"),
|
|
1543
|
+
literal("json"),
|
|
1544
|
+
literal("jsx"),
|
|
1545
|
+
literal("text"),
|
|
1546
|
+
literal("ts"),
|
|
1547
|
+
literal("tsx")
|
|
581
1548
|
]));
|
|
582
|
-
const JsxOptionsSchema =
|
|
583
|
-
development:
|
|
584
|
-
factory:
|
|
585
|
-
fragment:
|
|
586
|
-
importSource:
|
|
587
|
-
jsxImportSource:
|
|
588
|
-
mode:
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
])),
|
|
593
|
-
refresh:
|
|
1549
|
+
const JsxOptionsSchema = strictObject({
|
|
1550
|
+
development: pipe(optional(boolean()), description("Development specific information")),
|
|
1551
|
+
factory: pipe(optional(string()), description("Jsx element transformation")),
|
|
1552
|
+
fragment: pipe(optional(string()), description("Jsx fragment transformation")),
|
|
1553
|
+
importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
|
|
1554
|
+
jsxImportSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is automatic")),
|
|
1555
|
+
mode: pipe(optional(union([
|
|
1556
|
+
literal("classic"),
|
|
1557
|
+
literal("automatic"),
|
|
1558
|
+
literal("preserve")
|
|
1559
|
+
])), description("Jsx transformation mode")),
|
|
1560
|
+
refresh: pipe(optional(boolean()), description("React refresh transformation"))
|
|
594
1561
|
});
|
|
595
|
-
const HelperModeSchema =
|
|
596
|
-
const DecoratorOptionSchema =
|
|
597
|
-
legacy:
|
|
598
|
-
emitDecoratorMetadata:
|
|
1562
|
+
const HelperModeSchema = union([literal("Runtime"), literal("External")]);
|
|
1563
|
+
const DecoratorOptionSchema = object({
|
|
1564
|
+
legacy: optional(boolean()),
|
|
1565
|
+
emitDecoratorMetadata: optional(boolean())
|
|
599
1566
|
});
|
|
600
|
-
const HelpersSchema =
|
|
601
|
-
const RewriteImportExtensionsSchema =
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
1567
|
+
const HelpersSchema = object({ mode: optional(HelperModeSchema) });
|
|
1568
|
+
const RewriteImportExtensionsSchema = union([
|
|
1569
|
+
literal("rewrite"),
|
|
1570
|
+
literal("remove"),
|
|
1571
|
+
boolean()
|
|
605
1572
|
]);
|
|
606
|
-
const TypescriptSchema =
|
|
607
|
-
jsxPragma:
|
|
608
|
-
jsxPragmaFrag:
|
|
609
|
-
onlyRemoveTypeImports:
|
|
610
|
-
allowNamespaces:
|
|
611
|
-
allowDeclareFields:
|
|
612
|
-
declaration:
|
|
613
|
-
stripInternal:
|
|
614
|
-
sourcemap:
|
|
1573
|
+
const TypescriptSchema = object({
|
|
1574
|
+
jsxPragma: optional(string()),
|
|
1575
|
+
jsxPragmaFrag: optional(string()),
|
|
1576
|
+
onlyRemoveTypeImports: optional(boolean()),
|
|
1577
|
+
allowNamespaces: optional(boolean()),
|
|
1578
|
+
allowDeclareFields: optional(boolean()),
|
|
1579
|
+
declaration: optional(object({
|
|
1580
|
+
stripInternal: optional(boolean()),
|
|
1581
|
+
sourcemap: optional(boolean())
|
|
615
1582
|
})),
|
|
616
|
-
rewriteImportExtensions:
|
|
1583
|
+
rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
|
|
617
1584
|
});
|
|
618
|
-
const AssumptionsSchema =
|
|
619
|
-
ignoreFunctionLength:
|
|
620
|
-
noDocumentAll:
|
|
621
|
-
objectRestNoSymbols:
|
|
622
|
-
pureGetters:
|
|
623
|
-
setPublicClassFields:
|
|
1585
|
+
const AssumptionsSchema = object({
|
|
1586
|
+
ignoreFunctionLength: optional(boolean()),
|
|
1587
|
+
noDocumentAll: optional(boolean()),
|
|
1588
|
+
objectRestNoSymbols: optional(boolean()),
|
|
1589
|
+
pureGetters: optional(boolean()),
|
|
1590
|
+
setPublicClassFields: optional(boolean())
|
|
624
1591
|
});
|
|
625
|
-
const TransformOptionsSchema =
|
|
626
|
-
assumptions:
|
|
627
|
-
typescript:
|
|
628
|
-
helpers:
|
|
629
|
-
decorators:
|
|
1592
|
+
const TransformOptionsSchema = object({
|
|
1593
|
+
assumptions: optional(AssumptionsSchema),
|
|
1594
|
+
typescript: optional(TypescriptSchema),
|
|
1595
|
+
helpers: optional(HelpersSchema),
|
|
1596
|
+
decorators: optional(DecoratorOptionSchema)
|
|
630
1597
|
});
|
|
631
|
-
const WatchOptionsSchema =
|
|
632
|
-
chokidar:
|
|
633
|
-
exclude:
|
|
634
|
-
include:
|
|
635
|
-
notify:
|
|
636
|
-
compareContents:
|
|
637
|
-
pollInterval:
|
|
638
|
-
})),
|
|
639
|
-
skipWrite:
|
|
640
|
-
buildDelay:
|
|
1598
|
+
const WatchOptionsSchema = strictObject({
|
|
1599
|
+
chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
|
|
1600
|
+
exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1601
|
+
include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1602
|
+
notify: pipe(optional(strictObject({
|
|
1603
|
+
compareContents: optional(boolean()),
|
|
1604
|
+
pollInterval: optional(number())
|
|
1605
|
+
})), description("Notify options")),
|
|
1606
|
+
skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
|
|
1607
|
+
buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
|
|
641
1608
|
});
|
|
642
|
-
const ChecksOptionsSchema =
|
|
643
|
-
circularDependency:
|
|
644
|
-
eval:
|
|
645
|
-
missingGlobalName:
|
|
646
|
-
missingNameOptionForIifeExport:
|
|
647
|
-
mixedExport:
|
|
648
|
-
unresolvedEntry:
|
|
649
|
-
unresolvedImport:
|
|
650
|
-
filenameConflict:
|
|
651
|
-
commonJsVariableInEsm:
|
|
652
|
-
importIsUndefined:
|
|
653
|
-
configurationFieldConflict:
|
|
1609
|
+
const ChecksOptionsSchema = strictObject({
|
|
1610
|
+
circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
|
|
1611
|
+
eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
|
|
1612
|
+
missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
|
|
1613
|
+
missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
|
|
1614
|
+
mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
|
|
1615
|
+
unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
|
|
1616
|
+
unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
|
|
1617
|
+
filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
|
|
1618
|
+
commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
|
|
1619
|
+
importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
|
|
1620
|
+
configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
|
|
654
1621
|
});
|
|
655
|
-
const MinifyOptionsSchema =
|
|
656
|
-
mangle:
|
|
657
|
-
compress:
|
|
658
|
-
removeWhitespace:
|
|
1622
|
+
const MinifyOptionsSchema = strictObject({
|
|
1623
|
+
mangle: optional(boolean()),
|
|
1624
|
+
compress: optional(boolean()),
|
|
1625
|
+
removeWhitespace: optional(boolean())
|
|
659
1626
|
});
|
|
660
|
-
const ResolveOptionsSchema =
|
|
661
|
-
alias:
|
|
662
|
-
aliasFields:
|
|
663
|
-
conditionNames:
|
|
664
|
-
extensionAlias:
|
|
665
|
-
exportsFields:
|
|
666
|
-
extensions:
|
|
667
|
-
mainFields:
|
|
668
|
-
mainFiles:
|
|
669
|
-
modules:
|
|
670
|
-
symlinks:
|
|
671
|
-
tsconfigFilename:
|
|
1627
|
+
const ResolveOptionsSchema = strictObject({
|
|
1628
|
+
alias: optional(record(string(), union([string(), array(string())]))),
|
|
1629
|
+
aliasFields: optional(array(array(string()))),
|
|
1630
|
+
conditionNames: optional(array(string())),
|
|
1631
|
+
extensionAlias: optional(record(string(), array(string()))),
|
|
1632
|
+
exportsFields: optional(array(array(string()))),
|
|
1633
|
+
extensions: optional(array(string())),
|
|
1634
|
+
mainFields: optional(array(string())),
|
|
1635
|
+
mainFiles: optional(array(string())),
|
|
1636
|
+
modules: optional(array(string())),
|
|
1637
|
+
symlinks: optional(boolean()),
|
|
1638
|
+
tsconfigFilename: optional(string())
|
|
672
1639
|
});
|
|
673
|
-
const TreeshakingOptionsSchema =
|
|
674
|
-
annotations:
|
|
675
|
-
manualPureFunctions:
|
|
676
|
-
unknownGlobalSideEffects:
|
|
1640
|
+
const TreeshakingOptionsSchema = union([boolean(), looseObject({
|
|
1641
|
+
annotations: optional(boolean()),
|
|
1642
|
+
manualPureFunctions: optional(array(string())),
|
|
1643
|
+
unknownGlobalSideEffects: optional(boolean())
|
|
677
1644
|
})]);
|
|
678
|
-
const OnLogSchema =
|
|
1645
|
+
const OnLogSchema = pipe(function_(), args(tuple([
|
|
679
1646
|
LogLevelSchema,
|
|
680
1647
|
RollupLogSchema,
|
|
681
|
-
|
|
1648
|
+
pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
|
|
682
1649
|
])));
|
|
683
|
-
const OnwarnSchema =
|
|
684
|
-
const HmrSchema =
|
|
685
|
-
port:
|
|
686
|
-
host:
|
|
687
|
-
implement:
|
|
1650
|
+
const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
|
|
1651
|
+
const HmrSchema = union([boolean(), strictObject({
|
|
1652
|
+
port: optional(number()),
|
|
1653
|
+
host: optional(string()),
|
|
1654
|
+
implement: optional(string())
|
|
688
1655
|
})]);
|
|
689
|
-
const InputOptionsSchema =
|
|
690
|
-
input:
|
|
691
|
-
plugins:
|
|
692
|
-
external:
|
|
693
|
-
resolve:
|
|
694
|
-
cwd:
|
|
695
|
-
platform:
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
])),
|
|
700
|
-
shimMissingExports:
|
|
701
|
-
treeshake:
|
|
702
|
-
logLevel:
|
|
703
|
-
onLog:
|
|
704
|
-
onwarn:
|
|
705
|
-
moduleTypes:
|
|
706
|
-
experimental:
|
|
707
|
-
disableLiveBindings:
|
|
708
|
-
enableComposingJsPlugins:
|
|
709
|
-
resolveNewUrlToAsset:
|
|
710
|
-
strictExecutionOrder:
|
|
711
|
-
hmr:
|
|
1656
|
+
const InputOptionsSchema = strictObject({
|
|
1657
|
+
input: optional(InputOptionSchema),
|
|
1658
|
+
plugins: optional(custom(() => true)),
|
|
1659
|
+
external: optional(ExternalSchema),
|
|
1660
|
+
resolve: optional(ResolveOptionsSchema),
|
|
1661
|
+
cwd: pipe(optional(string()), description("Current working directory")),
|
|
1662
|
+
platform: pipe(optional(union([
|
|
1663
|
+
literal("browser"),
|
|
1664
|
+
literal("neutral"),
|
|
1665
|
+
literal("node")
|
|
1666
|
+
])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
|
|
1667
|
+
shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
|
|
1668
|
+
treeshake: optional(TreeshakingOptionsSchema),
|
|
1669
|
+
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
|
|
1670
|
+
onLog: optional(OnLogSchema),
|
|
1671
|
+
onwarn: optional(OnwarnSchema),
|
|
1672
|
+
moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
|
|
1673
|
+
experimental: optional(strictObject({
|
|
1674
|
+
disableLiveBindings: optional(boolean()),
|
|
1675
|
+
enableComposingJsPlugins: optional(boolean()),
|
|
1676
|
+
resolveNewUrlToAsset: optional(boolean()),
|
|
1677
|
+
strictExecutionOrder: optional(boolean()),
|
|
1678
|
+
hmr: optional(HmrSchema)
|
|
712
1679
|
})),
|
|
713
|
-
define:
|
|
714
|
-
inject:
|
|
715
|
-
profilerNames:
|
|
716
|
-
jsx:
|
|
717
|
-
|
|
1680
|
+
define: pipe(optional(record(string(), string())), description("Define global variables")),
|
|
1681
|
+
inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
|
|
1682
|
+
profilerNames: optional(boolean()),
|
|
1683
|
+
jsx: optional(union([
|
|
1684
|
+
boolean(),
|
|
718
1685
|
JsxOptionsSchema,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
1686
|
+
string("react"),
|
|
1687
|
+
string("react-jsx"),
|
|
1688
|
+
string("preserve")
|
|
722
1689
|
])),
|
|
723
|
-
transform:
|
|
724
|
-
watch:
|
|
725
|
-
dropLabels:
|
|
726
|
-
checks:
|
|
727
|
-
keepNames:
|
|
728
|
-
debug:
|
|
1690
|
+
transform: optional(TransformOptionsSchema),
|
|
1691
|
+
watch: optional(union([WatchOptionsSchema, literal(false)])),
|
|
1692
|
+
dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
|
|
1693
|
+
checks: optional(ChecksOptionsSchema),
|
|
1694
|
+
keepNames: pipe(optional(boolean()), description("Keep function/class name")),
|
|
1695
|
+
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."))
|
|
729
1696
|
});
|
|
730
|
-
const InputCliOverrideSchema =
|
|
731
|
-
input:
|
|
732
|
-
external:
|
|
733
|
-
inject:
|
|
734
|
-
treeshake:
|
|
735
|
-
jsx:
|
|
1697
|
+
const InputCliOverrideSchema = strictObject({
|
|
1698
|
+
input: pipe(optional(array(string())), description("Entry file")),
|
|
1699
|
+
external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
|
|
1700
|
+
inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
|
|
1701
|
+
treeshake: pipe(optional(boolean()), description("enable treeshaking")),
|
|
1702
|
+
jsx: pipe(optional(JsxOptionsSchema), description("enable jsx"))
|
|
736
1703
|
});
|
|
737
|
-
const InputCliOptionsSchema =
|
|
1704
|
+
const InputCliOptionsSchema = omit(strictObject({
|
|
738
1705
|
...InputOptionsSchema.entries,
|
|
739
1706
|
...InputCliOverrideSchema.entries
|
|
740
1707
|
}), [
|
|
@@ -761,87 +1728,87 @@ var ESTarget = /* @__PURE__ */ function(ESTarget$1) {
|
|
|
761
1728
|
ESTarget$1["ESNext"] = "esnext";
|
|
762
1729
|
return ESTarget$1;
|
|
763
1730
|
}(ESTarget || {});
|
|
764
|
-
const ModuleFormatSchema =
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1731
|
+
const ModuleFormatSchema = union([
|
|
1732
|
+
literal("es"),
|
|
1733
|
+
literal("cjs"),
|
|
1734
|
+
literal("esm"),
|
|
1735
|
+
literal("module"),
|
|
1736
|
+
literal("commonjs"),
|
|
1737
|
+
literal("iife"),
|
|
1738
|
+
literal("umd")
|
|
772
1739
|
]);
|
|
773
|
-
const AddonFunctionSchema =
|
|
774
|
-
const ChunkFileNamesSchema =
|
|
775
|
-
const AssetFileNamesSchema =
|
|
776
|
-
const SanitizeFileNameSchema =
|
|
777
|
-
const GlobalsFunctionSchema =
|
|
778
|
-
const AdvancedChunksSchema =
|
|
779
|
-
minSize:
|
|
780
|
-
maxSize:
|
|
781
|
-
minModuleSize:
|
|
782
|
-
maxModuleSize:
|
|
783
|
-
minShareCount:
|
|
784
|
-
groups:
|
|
785
|
-
name:
|
|
786
|
-
test:
|
|
787
|
-
priority:
|
|
788
|
-
minSize:
|
|
789
|
-
minShareCount:
|
|
790
|
-
maxSize:
|
|
791
|
-
minModuleSize:
|
|
792
|
-
maxModuleSize:
|
|
1740
|
+
const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
|
|
1741
|
+
const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
1742
|
+
const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
1743
|
+
const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
|
|
1744
|
+
const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
|
|
1745
|
+
const AdvancedChunksSchema = strictObject({
|
|
1746
|
+
minSize: optional(number()),
|
|
1747
|
+
maxSize: optional(number()),
|
|
1748
|
+
minModuleSize: optional(number()),
|
|
1749
|
+
maxModuleSize: optional(number()),
|
|
1750
|
+
minShareCount: optional(number()),
|
|
1751
|
+
groups: optional(array(strictObject({
|
|
1752
|
+
name: string(),
|
|
1753
|
+
test: optional(union([string(), instance(RegExp)])),
|
|
1754
|
+
priority: optional(number()),
|
|
1755
|
+
minSize: optional(number()),
|
|
1756
|
+
minShareCount: optional(number()),
|
|
1757
|
+
maxSize: optional(number()),
|
|
1758
|
+
minModuleSize: optional(number()),
|
|
1759
|
+
maxModuleSize: optional(number())
|
|
793
1760
|
})))
|
|
794
1761
|
});
|
|
795
|
-
const OutputOptionsSchema =
|
|
796
|
-
dir:
|
|
797
|
-
file:
|
|
798
|
-
exports:
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
])),
|
|
804
|
-
hashCharacters:
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
])),
|
|
809
|
-
format:
|
|
810
|
-
sourcemap:
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
])),
|
|
815
|
-
sourcemapDebugIds:
|
|
816
|
-
sourcemapIgnoreList:
|
|
817
|
-
sourcemapPathTransform:
|
|
818
|
-
banner:
|
|
819
|
-
footer:
|
|
820
|
-
intro:
|
|
821
|
-
outro:
|
|
822
|
-
extend:
|
|
823
|
-
esModule:
|
|
824
|
-
assetFileNames:
|
|
825
|
-
entryFileNames:
|
|
826
|
-
chunkFileNames:
|
|
827
|
-
cssEntryFileNames:
|
|
828
|
-
cssChunkFileNames:
|
|
829
|
-
sanitizeFileName:
|
|
830
|
-
minify:
|
|
831
|
-
|
|
832
|
-
|
|
1762
|
+
const OutputOptionsSchema = strictObject({
|
|
1763
|
+
dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
|
|
1764
|
+
file: pipe(optional(string()), description("Single output file")),
|
|
1765
|
+
exports: pipe(optional(union([
|
|
1766
|
+
literal("auto"),
|
|
1767
|
+
literal("named"),
|
|
1768
|
+
literal("default"),
|
|
1769
|
+
literal("none")
|
|
1770
|
+
])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
|
|
1771
|
+
hashCharacters: pipe(optional(union([
|
|
1772
|
+
literal("base64"),
|
|
1773
|
+
literal("base36"),
|
|
1774
|
+
literal("hex")
|
|
1775
|
+
])), description("Use the specified character set for file hashes")),
|
|
1776
|
+
format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
|
|
1777
|
+
sourcemap: pipe(optional(union([
|
|
1778
|
+
boolean(),
|
|
1779
|
+
literal("inline"),
|
|
1780
|
+
literal("hidden")
|
|
1781
|
+
])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
1782
|
+
sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
|
|
1783
|
+
sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
|
|
1784
|
+
sourcemapPathTransform: optional(custom(() => true)),
|
|
1785
|
+
banner: optional(union([string(), AddonFunctionSchema])),
|
|
1786
|
+
footer: optional(union([string(), AddonFunctionSchema])),
|
|
1787
|
+
intro: optional(union([string(), AddonFunctionSchema])),
|
|
1788
|
+
outro: optional(union([string(), AddonFunctionSchema])),
|
|
1789
|
+
extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
|
|
1790
|
+
esModule: optional(union([boolean(), literal("if-default-prop")])),
|
|
1791
|
+
assetFileNames: optional(AssetFileNamesSchema),
|
|
1792
|
+
entryFileNames: optional(ChunkFileNamesSchema),
|
|
1793
|
+
chunkFileNames: optional(ChunkFileNamesSchema),
|
|
1794
|
+
cssEntryFileNames: optional(ChunkFileNamesSchema),
|
|
1795
|
+
cssChunkFileNames: optional(ChunkFileNamesSchema),
|
|
1796
|
+
sanitizeFileName: optional(SanitizeFileNameSchema),
|
|
1797
|
+
minify: pipe(optional(union([
|
|
1798
|
+
boolean(),
|
|
1799
|
+
string("dce-only"),
|
|
833
1800
|
MinifyOptionsSchema
|
|
834
|
-
])),
|
|
835
|
-
name:
|
|
836
|
-
globals:
|
|
837
|
-
externalLiveBindings:
|
|
838
|
-
inlineDynamicImports:
|
|
839
|
-
advancedChunks:
|
|
840
|
-
comments:
|
|
841
|
-
plugins:
|
|
842
|
-
polyfillRequire:
|
|
843
|
-
target:
|
|
844
|
-
hoistTransitiveImports:
|
|
1801
|
+
])), description("Minify the bundled file")),
|
|
1802
|
+
name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
|
|
1803
|
+
globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
1804
|
+
externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
|
|
1805
|
+
inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
|
|
1806
|
+
advancedChunks: optional(AdvancedChunksSchema),
|
|
1807
|
+
comments: pipe(optional(union([literal("none"), literal("preserve-legal")])), description("Control comments in the output")),
|
|
1808
|
+
plugins: optional(custom(() => true)),
|
|
1809
|
+
polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
|
|
1810
|
+
target: pipe(optional(enum_(ESTarget)), description("The JavaScript target environment")),
|
|
1811
|
+
hoistTransitiveImports: optional(custom((input) => {
|
|
845
1812
|
if (input) return false;
|
|
846
1813
|
return true;
|
|
847
1814
|
}, () => `The 'true' value is not supported`))
|
|
@@ -849,26 +1816,26 @@ const OutputOptionsSchema = v.strictObject({
|
|
|
849
1816
|
const getAddonDescription = (placement, wrapper) => {
|
|
850
1817
|
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
851
1818
|
};
|
|
852
|
-
const OutputCliOverrideSchema =
|
|
853
|
-
assetFileNames:
|
|
854
|
-
entryFileNames:
|
|
855
|
-
chunkFileNames:
|
|
856
|
-
cssEntryFileNames:
|
|
857
|
-
cssChunkFileNames:
|
|
858
|
-
sanitizeFileName:
|
|
859
|
-
banner:
|
|
860
|
-
footer:
|
|
861
|
-
intro:
|
|
862
|
-
outro:
|
|
863
|
-
esModule:
|
|
864
|
-
globals:
|
|
865
|
-
advancedChunks:
|
|
866
|
-
minSize:
|
|
867
|
-
minShareCount:
|
|
868
|
-
})),
|
|
869
|
-
minify:
|
|
1819
|
+
const OutputCliOverrideSchema = strictObject({
|
|
1820
|
+
assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
|
|
1821
|
+
entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
|
|
1822
|
+
chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
|
|
1823
|
+
cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
|
|
1824
|
+
cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
|
|
1825
|
+
sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
|
|
1826
|
+
banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
|
|
1827
|
+
footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
|
|
1828
|
+
intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
|
|
1829
|
+
outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
|
|
1830
|
+
esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
|
|
1831
|
+
globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
1832
|
+
advancedChunks: pipe(optional(strictObject({
|
|
1833
|
+
minSize: pipe(optional(number()), description("Minimum size of the chunk")),
|
|
1834
|
+
minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
|
|
1835
|
+
})), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
1836
|
+
minify: pipe(optional(boolean()), description("Minify the bundled file"))
|
|
870
1837
|
});
|
|
871
|
-
const OutputCliOptionsSchema =
|
|
1838
|
+
const OutputCliOptionsSchema = omit(strictObject({
|
|
872
1839
|
...OutputOptionsSchema.entries,
|
|
873
1840
|
...OutputCliOverrideSchema.entries
|
|
874
1841
|
}), [
|
|
@@ -877,11 +1844,11 @@ const OutputCliOptionsSchema = v.omit(v.strictObject({
|
|
|
877
1844
|
"plugins",
|
|
878
1845
|
"hoistTransitiveImports"
|
|
879
1846
|
]);
|
|
880
|
-
const CliOptionsSchema =
|
|
881
|
-
config:
|
|
882
|
-
help:
|
|
883
|
-
version:
|
|
884
|
-
watch:
|
|
1847
|
+
const CliOptionsSchema = strictObject({
|
|
1848
|
+
config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
|
|
1849
|
+
help: pipe(optional(boolean()), description("Show help")),
|
|
1850
|
+
version: pipe(optional(boolean()), description("Show version number")),
|
|
1851
|
+
watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
|
|
885
1852
|
...InputCliOptionsSchema.entries,
|
|
886
1853
|
...OutputCliOptionsSchema.entries
|
|
887
1854
|
});
|
|
@@ -889,7 +1856,7 @@ const inputHelperMsgRecord = { output: { ignored: true } };
|
|
|
889
1856
|
const outputHelperMsgRecord = {};
|
|
890
1857
|
function validateOption(key, options) {
|
|
891
1858
|
if (globalThis.process?.env?.ROLLDOWN_OPTIONS_VALIDATION === "loose") return;
|
|
892
|
-
let parsed =
|
|
1859
|
+
let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
|
|
893
1860
|
if (!parsed.success) {
|
|
894
1861
|
const errors = parsed.issues.map((issue) => {
|
|
895
1862
|
const issuePaths = issue.path.map((path$1) => path$1.key);
|
|
@@ -1044,9 +2011,9 @@ function bindingifySideEffects(sideEffects) {
|
|
|
1044
2011
|
|
|
1045
2012
|
//#endregion
|
|
1046
2013
|
//#region src/utils/transform-sourcemap.ts
|
|
1047
|
-
function isEmptySourcemapFiled(array) {
|
|
1048
|
-
if (!array) return true;
|
|
1049
|
-
if (array.length === 0 || !array[0]) return true;
|
|
2014
|
+
function isEmptySourcemapFiled(array$1) {
|
|
2015
|
+
if (!array$1) return true;
|
|
2016
|
+
if (array$1.length === 0 || !array$1[0]) return true;
|
|
1050
2017
|
return false;
|
|
1051
2018
|
}
|
|
1052
2019
|
function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
|
|
@@ -1098,18 +2065,18 @@ function t(...n) {
|
|
|
1098
2065
|
var And = class {
|
|
1099
2066
|
kind;
|
|
1100
2067
|
args;
|
|
1101
|
-
constructor(...args) {
|
|
1102
|
-
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
|
1103
|
-
this.args = args;
|
|
2068
|
+
constructor(...args$1) {
|
|
2069
|
+
if (args$1.length === 0) throw new Error("`And` expects at least one operand");
|
|
2070
|
+
this.args = args$1;
|
|
1104
2071
|
this.kind = "and";
|
|
1105
2072
|
}
|
|
1106
2073
|
};
|
|
1107
2074
|
var Or = class {
|
|
1108
2075
|
kind;
|
|
1109
2076
|
args;
|
|
1110
|
-
constructor(...args) {
|
|
1111
|
-
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
|
1112
|
-
this.args = args;
|
|
2077
|
+
constructor(...args$1) {
|
|
2078
|
+
if (args$1.length === 0) throw new Error("`Or` expects at least one operand");
|
|
2079
|
+
this.args = args$1;
|
|
1113
2080
|
this.kind = "or";
|
|
1114
2081
|
}
|
|
1115
2082
|
};
|
|
@@ -1153,11 +2120,11 @@ var Exclude = class {
|
|
|
1153
2120
|
this.kind = "exclude";
|
|
1154
2121
|
}
|
|
1155
2122
|
};
|
|
1156
|
-
function and(...args) {
|
|
1157
|
-
return new And(...args);
|
|
2123
|
+
function and(...args$1) {
|
|
2124
|
+
return new And(...args$1);
|
|
1158
2125
|
}
|
|
1159
|
-
function or(...args) {
|
|
1160
|
-
return new Or(...args);
|
|
2126
|
+
function or(...args$1) {
|
|
2127
|
+
return new Or(...args$1);
|
|
1161
2128
|
}
|
|
1162
2129
|
function id(pattern) {
|
|
1163
2130
|
return new Id(pattern);
|
|
@@ -1178,14 +2145,16 @@ function exclude(expr) {
|
|
|
1178
2145
|
//#endregion
|
|
1179
2146
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
1180
2147
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
1181
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(
|
|
1182
|
-
if (Array.isArray(matcher)) return matcher.map((m) => include(
|
|
2148
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
|
|
2149
|
+
if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
|
|
1183
2150
|
let ret = [];
|
|
1184
|
-
|
|
1185
|
-
if (matcher.
|
|
1186
|
-
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(isCode ? code(m) : id(m))));
|
|
2151
|
+
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
|
|
2152
|
+
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
|
|
1187
2153
|
return ret;
|
|
1188
2154
|
}
|
|
2155
|
+
function generateAtomMatcher(kind, matcher) {
|
|
2156
|
+
return kind === "code" ? code(matcher) : id(matcher);
|
|
2157
|
+
}
|
|
1189
2158
|
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
1190
2159
|
if (!filterOption) return void 0;
|
|
1191
2160
|
if (Array.isArray(filterOption)) return filterOption;
|
|
@@ -1223,20 +2192,20 @@ function bindingifyFilterExpr(expr) {
|
|
|
1223
2192
|
function bindingifyFilterExprImpl(expr, list) {
|
|
1224
2193
|
switch (expr.kind) {
|
|
1225
2194
|
case "and": {
|
|
1226
|
-
let args = expr.args;
|
|
1227
|
-
for (let i$1 = args.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args[i$1], list);
|
|
2195
|
+
let args$1 = expr.args;
|
|
2196
|
+
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
1228
2197
|
list.push({
|
|
1229
2198
|
kind: "And",
|
|
1230
|
-
payload: args.length
|
|
2199
|
+
payload: args$1.length
|
|
1231
2200
|
});
|
|
1232
2201
|
break;
|
|
1233
2202
|
}
|
|
1234
2203
|
case "or": {
|
|
1235
|
-
let args = expr.args;
|
|
1236
|
-
for (let i$1 = args.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args[i$1], list);
|
|
2204
|
+
let args$1 = expr.args;
|
|
2205
|
+
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
1237
2206
|
list.push({
|
|
1238
2207
|
kind: "Or",
|
|
1239
|
-
payload: args.length
|
|
2208
|
+
payload: args$1.length
|
|
1240
2209
|
});
|
|
1241
2210
|
break;
|
|
1242
2211
|
}
|
|
@@ -1426,10 +2395,10 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
|
1426
2395
|
async function createLoadModulePromise(context, data) {
|
|
1427
2396
|
const loadPromise = data.loadModulePromiseMap.get(id$1);
|
|
1428
2397
|
if (loadPromise) return loadPromise;
|
|
1429
|
-
const promise = new Promise((resolve, _) => {
|
|
2398
|
+
const promise$1 = new Promise((resolve, _) => {
|
|
1430
2399
|
data.loadModulePromiseResolveFnMap.set(id$1, resolve);
|
|
1431
2400
|
});
|
|
1432
|
-
data.loadModulePromiseMap.set(id$1, promise);
|
|
2401
|
+
data.loadModulePromiseMap.set(id$1, promise$1);
|
|
1433
2402
|
try {
|
|
1434
2403
|
await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
|
|
1435
2404
|
} catch (e) {
|
|
@@ -1437,7 +2406,7 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
|
1437
2406
|
data.loadModulePromiseResolveFnMap.delete(id$1);
|
|
1438
2407
|
throw e;
|
|
1439
2408
|
}
|
|
1440
|
-
return promise;
|
|
2409
|
+
return promise$1;
|
|
1441
2410
|
}
|
|
1442
2411
|
await createLoadModulePromise(this.context, this.data);
|
|
1443
2412
|
return this.data.getModuleInfo(id$1, this.context);
|
|
@@ -1524,41 +2493,41 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
|
1524
2493
|
|
|
1525
2494
|
//#endregion
|
|
1526
2495
|
//#region src/plugin/bindingify-build-hooks.ts
|
|
1527
|
-
function bindingifyBuildStart(args) {
|
|
1528
|
-
const hook = args.plugin.buildStart;
|
|
2496
|
+
function bindingifyBuildStart(args$1) {
|
|
2497
|
+
const hook = args$1.plugin.buildStart;
|
|
1529
2498
|
if (!hook) return {};
|
|
1530
2499
|
const { handler, meta } = normalizeHook(hook);
|
|
1531
2500
|
return {
|
|
1532
2501
|
plugin: async (ctx, opts) => {
|
|
1533
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
2502
|
+
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));
|
|
1534
2503
|
},
|
|
1535
2504
|
meta: bindingifyPluginHookMeta(meta)
|
|
1536
2505
|
};
|
|
1537
2506
|
}
|
|
1538
|
-
function bindingifyBuildEnd(args) {
|
|
1539
|
-
const hook = args.plugin.buildEnd;
|
|
2507
|
+
function bindingifyBuildEnd(args$1) {
|
|
2508
|
+
const hook = args$1.plugin.buildEnd;
|
|
1540
2509
|
if (!hook) return {};
|
|
1541
2510
|
const { handler, meta } = normalizeHook(hook);
|
|
1542
2511
|
return {
|
|
1543
2512
|
plugin: async (ctx, err) => {
|
|
1544
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? normalizeErrors(err) : void 0);
|
|
2513
|
+
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);
|
|
1545
2514
|
},
|
|
1546
2515
|
meta: bindingifyPluginHookMeta(meta)
|
|
1547
2516
|
};
|
|
1548
2517
|
}
|
|
1549
|
-
function bindingifyResolveId(args) {
|
|
1550
|
-
const hook = args.plugin.resolveId;
|
|
2518
|
+
function bindingifyResolveId(args$1) {
|
|
2519
|
+
const hook = args$1.plugin.resolveId;
|
|
1551
2520
|
if (!hook) return {};
|
|
1552
2521
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1553
2522
|
return {
|
|
1554
2523
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
1555
|
-
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2524
|
+
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
1556
2525
|
const newExtraOptions = {
|
|
1557
2526
|
...extraOptions,
|
|
1558
2527
|
custom: contextResolveOptions?.custom,
|
|
1559
2528
|
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
|
|
1560
2529
|
};
|
|
1561
|
-
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);
|
|
2530
|
+
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);
|
|
1562
2531
|
if (ret == null) return;
|
|
1563
2532
|
if (ret === false) return {
|
|
1564
2533
|
id: specifier,
|
|
@@ -1569,7 +2538,7 @@ function bindingifyResolveId(args) {
|
|
|
1569
2538
|
id: ret,
|
|
1570
2539
|
normalizeExternalId: true
|
|
1571
2540
|
};
|
|
1572
|
-
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
2541
|
+
let exist = args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
1573
2542
|
meta: ret.meta || {},
|
|
1574
2543
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1575
2544
|
invalidate: false
|
|
@@ -1585,13 +2554,13 @@ function bindingifyResolveId(args) {
|
|
|
1585
2554
|
filter: bindingifyResolveIdFilter(options.filter)
|
|
1586
2555
|
};
|
|
1587
2556
|
}
|
|
1588
|
-
function bindingifyResolveDynamicImport(args) {
|
|
1589
|
-
const hook = args.plugin.resolveDynamicImport;
|
|
2557
|
+
function bindingifyResolveDynamicImport(args$1) {
|
|
2558
|
+
const hook = args$1.plugin.resolveDynamicImport;
|
|
1590
2559
|
if (!hook) return {};
|
|
1591
2560
|
const { handler, meta } = normalizeHook(hook);
|
|
1592
2561
|
return {
|
|
1593
2562
|
plugin: async (ctx, specifier, importer) => {
|
|
1594
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
|
|
2563
|
+
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);
|
|
1595
2564
|
if (ret == null) return;
|
|
1596
2565
|
if (ret === false) return {
|
|
1597
2566
|
id: specifier,
|
|
@@ -1603,7 +2572,7 @@ function bindingifyResolveDynamicImport(args) {
|
|
|
1603
2572
|
external: ret.external
|
|
1604
2573
|
};
|
|
1605
2574
|
if (ret.moduleSideEffects !== null) result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1606
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
2575
|
+
args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
1607
2576
|
meta: ret.meta || {},
|
|
1608
2577
|
moduleSideEffects: ret.moduleSideEffects || null,
|
|
1609
2578
|
invalidate: false
|
|
@@ -1613,16 +2582,16 @@ function bindingifyResolveDynamicImport(args) {
|
|
|
1613
2582
|
meta: bindingifyPluginHookMeta(meta)
|
|
1614
2583
|
};
|
|
1615
2584
|
}
|
|
1616
|
-
function bindingifyTransform(args) {
|
|
1617
|
-
const hook = args.plugin.transform;
|
|
2585
|
+
function bindingifyTransform(args$1) {
|
|
2586
|
+
const hook = args$1.plugin.transform;
|
|
1618
2587
|
if (!hook) return {};
|
|
1619
2588
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1620
2589
|
return {
|
|
1621
2590
|
plugin: async (ctx, code$1, id$1, meta$1) => {
|
|
1622
|
-
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);
|
|
2591
|
+
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);
|
|
1623
2592
|
if (ret == null) return void 0;
|
|
1624
2593
|
if (typeof ret === "string") return { code: ret };
|
|
1625
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
|
|
2594
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
1626
2595
|
meta: ret.meta ?? {},
|
|
1627
2596
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1628
2597
|
invalidate: false
|
|
@@ -1638,16 +2607,16 @@ function bindingifyTransform(args) {
|
|
|
1638
2607
|
filter: bindingifyTransformFilter(options.filter)
|
|
1639
2608
|
};
|
|
1640
2609
|
}
|
|
1641
|
-
function bindingifyLoad(args) {
|
|
1642
|
-
const hook = args.plugin.load;
|
|
2610
|
+
function bindingifyLoad(args$1) {
|
|
2611
|
+
const hook = args$1.plugin.load;
|
|
1643
2612
|
if (!hook) return {};
|
|
1644
2613
|
const { handler, meta, options } = normalizeHook(hook);
|
|
1645
2614
|
return {
|
|
1646
2615
|
plugin: async (ctx, id$1) => {
|
|
1647
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id$1), id$1);
|
|
2616
|
+
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);
|
|
1648
2617
|
if (ret == null) return;
|
|
1649
2618
|
if (typeof ret === "string") return { code: ret };
|
|
1650
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
|
|
2619
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
1651
2620
|
meta: ret.meta || {},
|
|
1652
2621
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1653
2622
|
invalidate: false
|
|
@@ -1674,13 +2643,13 @@ function preProcessSourceMap(ret, id$1) {
|
|
|
1674
2643
|
}
|
|
1675
2644
|
return map;
|
|
1676
2645
|
}
|
|
1677
|
-
function bindingifyModuleParsed(args) {
|
|
1678
|
-
const hook = args.plugin.moduleParsed;
|
|
2646
|
+
function bindingifyModuleParsed(args$1) {
|
|
2647
|
+
const hook = args$1.plugin.moduleParsed;
|
|
1679
2648
|
if (!hook) return {};
|
|
1680
2649
|
const { handler, meta } = normalizeHook(hook);
|
|
1681
2650
|
return {
|
|
1682
2651
|
plugin: async (ctx, moduleInfo) => {
|
|
1683
|
-
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)));
|
|
2652
|
+
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)));
|
|
1684
2653
|
},
|
|
1685
2654
|
meta: bindingifyPluginHookMeta(meta)
|
|
1686
2655
|
};
|
|
@@ -2078,25 +3047,25 @@ function collectChangedBundle(changed, bundle) {
|
|
|
2078
3047
|
|
|
2079
3048
|
//#endregion
|
|
2080
3049
|
//#region src/plugin/bindingify-output-hooks.ts
|
|
2081
|
-
function bindingifyRenderStart(args) {
|
|
2082
|
-
const hook = args.plugin.renderStart;
|
|
3050
|
+
function bindingifyRenderStart(args$1) {
|
|
3051
|
+
const hook = args$1.plugin.renderStart;
|
|
2083
3052
|
if (!hook) return {};
|
|
2084
3053
|
const { handler, meta } = normalizeHook(hook);
|
|
2085
3054
|
return {
|
|
2086
3055
|
plugin: async (ctx, opts) => {
|
|
2087
|
-
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));
|
|
3056
|
+
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));
|
|
2088
3057
|
},
|
|
2089
3058
|
meta: bindingifyPluginHookMeta(meta)
|
|
2090
3059
|
};
|
|
2091
3060
|
}
|
|
2092
|
-
function bindingifyRenderChunk(args) {
|
|
2093
|
-
const hook = args.plugin.renderChunk;
|
|
3061
|
+
function bindingifyRenderChunk(args$1) {
|
|
3062
|
+
const hook = args$1.plugin.renderChunk;
|
|
2094
3063
|
if (!hook) return {};
|
|
2095
3064
|
const { handler, meta, options } = normalizeHook(hook);
|
|
2096
3065
|
return {
|
|
2097
3066
|
plugin: async (ctx, code$1, chunk, opts, meta$1) => {
|
|
2098
|
-
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
2099
|
-
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());
|
|
3067
|
+
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3068
|
+
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());
|
|
2100
3069
|
if (ret == null) return;
|
|
2101
3070
|
if (typeof ret === "string") return { code: ret };
|
|
2102
3071
|
if (!ret.map) return { code: ret.code };
|
|
@@ -2109,30 +3078,30 @@ function bindingifyRenderChunk(args) {
|
|
|
2109
3078
|
filter: bindingifyRenderChunkFilter(options.filter)
|
|
2110
3079
|
};
|
|
2111
3080
|
}
|
|
2112
|
-
function bindingifyAugmentChunkHash(args) {
|
|
2113
|
-
const hook = args.plugin.augmentChunkHash;
|
|
3081
|
+
function bindingifyAugmentChunkHash(args$1) {
|
|
3082
|
+
const hook = args$1.plugin.augmentChunkHash;
|
|
2114
3083
|
if (!hook) return {};
|
|
2115
3084
|
const { handler, meta } = normalizeHook(hook);
|
|
2116
3085
|
return {
|
|
2117
3086
|
plugin: async (ctx, chunk) => {
|
|
2118
|
-
return await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3087
|
+
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));
|
|
2119
3088
|
},
|
|
2120
3089
|
meta: bindingifyPluginHookMeta(meta)
|
|
2121
3090
|
};
|
|
2122
3091
|
}
|
|
2123
|
-
function bindingifyRenderError(args) {
|
|
2124
|
-
const hook = args.plugin.renderError;
|
|
3092
|
+
function bindingifyRenderError(args$1) {
|
|
3093
|
+
const hook = args$1.plugin.renderError;
|
|
2125
3094
|
if (!hook) return {};
|
|
2126
3095
|
const { handler, meta } = normalizeHook(hook);
|
|
2127
3096
|
return {
|
|
2128
3097
|
plugin: async (ctx, err) => {
|
|
2129
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), normalizeErrors(err));
|
|
3098
|
+
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));
|
|
2130
3099
|
},
|
|
2131
3100
|
meta: bindingifyPluginHookMeta(meta)
|
|
2132
3101
|
};
|
|
2133
3102
|
}
|
|
2134
|
-
function bindingifyGenerateBundle(args) {
|
|
2135
|
-
const hook = args.plugin.generateBundle;
|
|
3103
|
+
function bindingifyGenerateBundle(args$1) {
|
|
3104
|
+
const hook = args$1.plugin.generateBundle;
|
|
2136
3105
|
if (!hook) return {};
|
|
2137
3106
|
const { handler, meta } = normalizeHook(hook);
|
|
2138
3107
|
return {
|
|
@@ -2142,14 +3111,14 @@ function bindingifyGenerateBundle(args) {
|
|
|
2142
3111
|
deleted: new Set()
|
|
2143
3112
|
};
|
|
2144
3113
|
const output = transformToOutputBundle(bundle, changed);
|
|
2145
|
-
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);
|
|
3114
|
+
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);
|
|
2146
3115
|
return collectChangedBundle(changed, output);
|
|
2147
3116
|
},
|
|
2148
3117
|
meta: bindingifyPluginHookMeta(meta)
|
|
2149
3118
|
};
|
|
2150
3119
|
}
|
|
2151
|
-
function bindingifyWriteBundle(args) {
|
|
2152
|
-
const hook = args.plugin.writeBundle;
|
|
3120
|
+
function bindingifyWriteBundle(args$1) {
|
|
3121
|
+
const hook = args$1.plugin.writeBundle;
|
|
2153
3122
|
if (!hook) return {};
|
|
2154
3123
|
const { handler, meta } = normalizeHook(hook);
|
|
2155
3124
|
return {
|
|
@@ -2159,67 +3128,67 @@ function bindingifyWriteBundle(args) {
|
|
|
2159
3128
|
deleted: new Set()
|
|
2160
3129
|
};
|
|
2161
3130
|
const output = transformToOutputBundle(bundle, changed);
|
|
2162
|
-
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);
|
|
3131
|
+
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);
|
|
2163
3132
|
return collectChangedBundle(changed, output);
|
|
2164
3133
|
},
|
|
2165
3134
|
meta: bindingifyPluginHookMeta(meta)
|
|
2166
3135
|
};
|
|
2167
3136
|
}
|
|
2168
|
-
function bindingifyCloseBundle(args) {
|
|
2169
|
-
const hook = args.plugin.closeBundle;
|
|
3137
|
+
function bindingifyCloseBundle(args$1) {
|
|
3138
|
+
const hook = args$1.plugin.closeBundle;
|
|
2170
3139
|
if (!hook) return {};
|
|
2171
3140
|
const { handler, meta } = normalizeHook(hook);
|
|
2172
3141
|
return {
|
|
2173
3142
|
plugin: async (ctx) => {
|
|
2174
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
3143
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
2175
3144
|
},
|
|
2176
3145
|
meta: bindingifyPluginHookMeta(meta)
|
|
2177
3146
|
};
|
|
2178
3147
|
}
|
|
2179
|
-
function bindingifyBanner(args) {
|
|
2180
|
-
const hook = args.plugin.banner;
|
|
3148
|
+
function bindingifyBanner(args$1) {
|
|
3149
|
+
const hook = args$1.plugin.banner;
|
|
2181
3150
|
if (!hook) return {};
|
|
2182
3151
|
const { handler, meta } = normalizeHook(hook);
|
|
2183
3152
|
return {
|
|
2184
3153
|
plugin: async (ctx, chunk) => {
|
|
2185
3154
|
if (typeof handler === "string") return handler;
|
|
2186
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3155
|
+
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));
|
|
2187
3156
|
},
|
|
2188
3157
|
meta: bindingifyPluginHookMeta(meta)
|
|
2189
3158
|
};
|
|
2190
3159
|
}
|
|
2191
|
-
function bindingifyFooter(args) {
|
|
2192
|
-
const hook = args.plugin.footer;
|
|
3160
|
+
function bindingifyFooter(args$1) {
|
|
3161
|
+
const hook = args$1.plugin.footer;
|
|
2193
3162
|
if (!hook) return {};
|
|
2194
3163
|
const { handler, meta } = normalizeHook(hook);
|
|
2195
3164
|
return {
|
|
2196
3165
|
plugin: async (ctx, chunk) => {
|
|
2197
3166
|
if (typeof handler === "string") return handler;
|
|
2198
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3167
|
+
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));
|
|
2199
3168
|
},
|
|
2200
3169
|
meta: bindingifyPluginHookMeta(meta)
|
|
2201
3170
|
};
|
|
2202
3171
|
}
|
|
2203
|
-
function bindingifyIntro(args) {
|
|
2204
|
-
const hook = args.plugin.intro;
|
|
3172
|
+
function bindingifyIntro(args$1) {
|
|
3173
|
+
const hook = args$1.plugin.intro;
|
|
2205
3174
|
if (!hook) return {};
|
|
2206
3175
|
const { handler, meta } = normalizeHook(hook);
|
|
2207
3176
|
return {
|
|
2208
3177
|
plugin: async (ctx, chunk) => {
|
|
2209
3178
|
if (typeof handler === "string") return handler;
|
|
2210
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3179
|
+
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));
|
|
2211
3180
|
},
|
|
2212
3181
|
meta: bindingifyPluginHookMeta(meta)
|
|
2213
3182
|
};
|
|
2214
3183
|
}
|
|
2215
|
-
function bindingifyOutro(args) {
|
|
2216
|
-
const hook = args.plugin.outro;
|
|
3184
|
+
function bindingifyOutro(args$1) {
|
|
3185
|
+
const hook = args$1.plugin.outro;
|
|
2217
3186
|
if (!hook) return {};
|
|
2218
3187
|
const { handler, meta } = normalizeHook(hook);
|
|
2219
3188
|
return {
|
|
2220
3189
|
plugin: async (ctx, chunk) => {
|
|
2221
3190
|
if (typeof handler === "string") return handler;
|
|
2222
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3191
|
+
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));
|
|
2223
3192
|
},
|
|
2224
3193
|
meta: bindingifyPluginHookMeta(meta)
|
|
2225
3194
|
};
|
|
@@ -2227,24 +3196,24 @@ function bindingifyOutro(args) {
|
|
|
2227
3196
|
|
|
2228
3197
|
//#endregion
|
|
2229
3198
|
//#region src/plugin/bindingify-watch-hooks.ts
|
|
2230
|
-
function bindingifyWatchChange(args) {
|
|
2231
|
-
const hook = args.plugin.watchChange;
|
|
3199
|
+
function bindingifyWatchChange(args$1) {
|
|
3200
|
+
const hook = args$1.plugin.watchChange;
|
|
2232
3201
|
if (!hook) return {};
|
|
2233
3202
|
const { handler, meta } = normalizeHook(hook);
|
|
2234
3203
|
return {
|
|
2235
3204
|
plugin: async (ctx, id$1, event) => {
|
|
2236
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id$1, { event });
|
|
3205
|
+
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 });
|
|
2237
3206
|
},
|
|
2238
3207
|
meta: bindingifyPluginHookMeta(meta)
|
|
2239
3208
|
};
|
|
2240
3209
|
}
|
|
2241
|
-
function bindingifyCloseWatcher(args) {
|
|
2242
|
-
const hook = args.plugin.closeWatcher;
|
|
3210
|
+
function bindingifyCloseWatcher(args$1) {
|
|
3211
|
+
const hook = args$1.plugin.closeWatcher;
|
|
2243
3212
|
if (!hook) return {};
|
|
2244
3213
|
const { handler, meta } = normalizeHook(hook);
|
|
2245
3214
|
return {
|
|
2246
3215
|
plugin: async (ctx) => {
|
|
2247
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
3216
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
2248
3217
|
},
|
|
2249
3218
|
meta: bindingifyPluginHookMeta(meta)
|
|
2250
3219
|
};
|
|
@@ -2314,7 +3283,7 @@ function extractHookUsage(plugin) {
|
|
|
2314
3283
|
//#endregion
|
|
2315
3284
|
//#region src/plugin/bindingify-plugin.ts
|
|
2316
3285
|
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
2317
|
-
const args = {
|
|
3286
|
+
const args$1 = {
|
|
2318
3287
|
plugin,
|
|
2319
3288
|
options,
|
|
2320
3289
|
outputOptions,
|
|
@@ -2324,26 +3293,26 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
|
|
|
2324
3293
|
watchMode,
|
|
2325
3294
|
normalizedOutputPlugins
|
|
2326
3295
|
};
|
|
2327
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
2328
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
2329
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
2330
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
2331
|
-
const { plugin: transform$1, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
2332
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
2333
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
2334
|
-
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
|
|
2335
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
2336
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
2337
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
2338
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
2339
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
2340
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
2341
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
2342
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
2343
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
2344
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
2345
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
2346
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
3296
|
+
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args$1);
|
|
3297
|
+
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args$1);
|
|
3298
|
+
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args$1);
|
|
3299
|
+
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
|
|
3300
|
+
const { plugin: transform$1, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
|
|
3301
|
+
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
|
|
3302
|
+
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
|
|
3303
|
+
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
|
|
3304
|
+
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
|
|
3305
|
+
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
|
|
3306
|
+
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args$1);
|
|
3307
|
+
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args$1);
|
|
3308
|
+
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args$1);
|
|
3309
|
+
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args$1);
|
|
3310
|
+
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args$1);
|
|
3311
|
+
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args$1);
|
|
3312
|
+
const { plugin: intro, meta: introMeta } = bindingifyIntro(args$1);
|
|
3313
|
+
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args$1);
|
|
3314
|
+
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args$1);
|
|
3315
|
+
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args$1);
|
|
2347
3316
|
let hookUsage = extractHookUsage(plugin).inner();
|
|
2348
3317
|
const result = {
|
|
2349
3318
|
name: plugin.name,
|
|
@@ -2419,13 +3388,13 @@ function wrapHandlers(plugin) {
|
|
|
2419
3388
|
"closeWatcher"
|
|
2420
3389
|
]) {
|
|
2421
3390
|
const handler = plugin[hookName];
|
|
2422
|
-
if (handler) plugin[hookName] = async (...args) => {
|
|
3391
|
+
if (handler) plugin[hookName] = async (...args$1) => {
|
|
2423
3392
|
try {
|
|
2424
|
-
return await handler(...args);
|
|
3393
|
+
return await handler(...args$1);
|
|
2425
3394
|
} catch (e) {
|
|
2426
3395
|
return error(logPluginError(e, plugin.name, {
|
|
2427
3396
|
hook: hookName,
|
|
2428
|
-
id: hookName === "transform" ? args[2] : void 0
|
|
3397
|
+
id: hookName === "transform" ? args$1[2] : void 0
|
|
2429
3398
|
}));
|
|
2430
3399
|
}
|
|
2431
3400
|
};
|
|
@@ -2479,13 +3448,13 @@ var PluginContextData = class {
|
|
|
2479
3448
|
get() {
|
|
2480
3449
|
return moduleSideEffects;
|
|
2481
3450
|
},
|
|
2482
|
-
set: (v
|
|
3451
|
+
set: (v) => {
|
|
2483
3452
|
this.updateModuleOption(id$1, {
|
|
2484
|
-
moduleSideEffects: v
|
|
3453
|
+
moduleSideEffects: v,
|
|
2485
3454
|
meta: info.meta,
|
|
2486
3455
|
invalidate: true
|
|
2487
3456
|
});
|
|
2488
|
-
moduleSideEffects = v
|
|
3457
|
+
moduleSideEffects = v;
|
|
2489
3458
|
}
|
|
2490
3459
|
});
|
|
2491
3460
|
return info;
|
|
@@ -3132,6 +4101,9 @@ var RolldownBuild = class {
|
|
|
3132
4101
|
async generateHmrPatch(changedFiles) {
|
|
3133
4102
|
return this.#bundler?.bundler.generateHmrPatch(changedFiles);
|
|
3134
4103
|
}
|
|
4104
|
+
async hmrInvalidate(file, firstInvalidatedBy) {
|
|
4105
|
+
return this.#bundler?.bundler.hmrInvalidate(file, firstInvalidatedBy);
|
|
4106
|
+
}
|
|
3135
4107
|
get watchFiles() {
|
|
3136
4108
|
return this.#bundler?.bundler.watchFiles ?? [];
|
|
3137
4109
|
}
|