@rolldown/browser 1.0.0-beta.8-commit.360c072 → 1.0.0-beta.9

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.
@@ -8,7 +8,7 @@ const node_os = require_chunk.__toESM(require("node:os"));
8
8
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
9
9
 
10
10
  //#region package.json
11
- var version = "1.0.0-beta.8-commit.360c072";
11
+ var version = "1.0.0-beta.9";
12
12
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
13
 
14
14
  //#endregion
@@ -416,15 +416,15 @@ function getSortedPlugins(hookName, plugins) {
416
416
  }
417
417
 
418
418
  //#endregion
419
- //#region ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
420
- var store;
419
+ //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
420
+ var store$1;
421
421
  /* @__NO_SIDE_EFFECTS__ */
422
422
  function getGlobalConfig(config2) {
423
423
  return {
424
- lang: config2?.lang ?? store?.lang,
424
+ lang: config2?.lang ?? store$1?.lang,
425
425
  message: config2?.message,
426
- abortEarly: config2?.abortEarly ?? store?.abortEarly,
427
- abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
426
+ abortEarly: config2?.abortEarly ?? store$1?.abortEarly,
427
+ abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
428
428
  };
429
429
  }
430
430
  var store2;
@@ -469,8 +469,8 @@ function _addIssue(context, label, dataset, config2, other) {
469
469
  abortPipeEarly: config2.abortPipeEarly
470
470
  };
471
471
  const isSchema = context.kind === "schema";
472
- const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
473
- if (message !== void 0) issue.message = typeof message === "function" ? message(issue) : message;
472
+ const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
473
+ if (message2 !== void 0) issue.message = typeof message2 === "function" ? message2(issue) : message2;
474
474
  if (isSchema) dataset.typed = false;
475
475
  if (dataset.issues) dataset.issues.push(issue);
476
476
  else dataset.issues = [issue];
@@ -612,7 +612,7 @@ function any() {
612
612
  };
613
613
  }
614
614
  /* @__NO_SIDE_EFFECTS__ */
615
- function array(item, message) {
615
+ function array(item, message2) {
616
616
  return {
617
617
  kind: "schema",
618
618
  type: "array",
@@ -620,7 +620,7 @@ function array(item, message) {
620
620
  expects: "Array",
621
621
  async: false,
622
622
  item,
623
- message,
623
+ message: message2,
624
624
  get "~standard"() {
625
625
  return /* @__PURE__ */ _getStandardProps(this);
626
626
  },
@@ -660,14 +660,14 @@ function array(item, message) {
660
660
  };
661
661
  }
662
662
  /* @__NO_SIDE_EFFECTS__ */
663
- function boolean(message) {
663
+ function boolean(message2) {
664
664
  return {
665
665
  kind: "schema",
666
666
  type: "boolean",
667
667
  reference: boolean,
668
668
  expects: "boolean",
669
669
  async: false,
670
- message,
670
+ message: message2,
671
671
  get "~standard"() {
672
672
  return /* @__PURE__ */ _getStandardProps(this);
673
673
  },
@@ -679,7 +679,7 @@ function boolean(message) {
679
679
  };
680
680
  }
681
681
  /* @__NO_SIDE_EFFECTS__ */
682
- function custom(check2, message) {
682
+ function custom(check2, message2) {
683
683
  return {
684
684
  kind: "schema",
685
685
  type: "custom",
@@ -687,7 +687,7 @@ function custom(check2, message) {
687
687
  expects: "unknown",
688
688
  async: false,
689
689
  check: check2,
690
- message,
690
+ message: message2,
691
691
  get "~standard"() {
692
692
  return /* @__PURE__ */ _getStandardProps(this);
693
693
  },
@@ -699,14 +699,14 @@ function custom(check2, message) {
699
699
  };
700
700
  }
701
701
  /* @__NO_SIDE_EFFECTS__ */
702
- function function_(message) {
702
+ function function_(message2) {
703
703
  return {
704
704
  kind: "schema",
705
705
  type: "function",
706
706
  reference: function_,
707
707
  expects: "Function",
708
708
  async: false,
709
- message,
709
+ message: message2,
710
710
  get "~standard"() {
711
711
  return /* @__PURE__ */ _getStandardProps(this);
712
712
  },
@@ -718,7 +718,7 @@ function function_(message) {
718
718
  };
719
719
  }
720
720
  /* @__NO_SIDE_EFFECTS__ */
721
- function instance(class_, message) {
721
+ function instance(class_, message2) {
722
722
  return {
723
723
  kind: "schema",
724
724
  type: "instance",
@@ -726,7 +726,7 @@ function instance(class_, message) {
726
726
  expects: class_.name,
727
727
  async: false,
728
728
  class: class_,
729
- message,
729
+ message: message2,
730
730
  get "~standard"() {
731
731
  return /* @__PURE__ */ _getStandardProps(this);
732
732
  },
@@ -738,7 +738,7 @@ function instance(class_, message) {
738
738
  };
739
739
  }
740
740
  /* @__NO_SIDE_EFFECTS__ */
741
- function literal(literal_, message) {
741
+ function literal(literal_, message2) {
742
742
  return {
743
743
  kind: "schema",
744
744
  type: "literal",
@@ -746,7 +746,7 @@ function literal(literal_, message) {
746
746
  expects: /* @__PURE__ */ _stringify(literal_),
747
747
  async: false,
748
748
  literal: literal_,
749
- message,
749
+ message: message2,
750
750
  get "~standard"() {
751
751
  return /* @__PURE__ */ _getStandardProps(this);
752
752
  },
@@ -758,15 +758,15 @@ function literal(literal_, message) {
758
758
  };
759
759
  }
760
760
  /* @__NO_SIDE_EFFECTS__ */
761
- function looseObject(entries, message) {
761
+ function looseObject(entries2, message2) {
762
762
  return {
763
763
  kind: "schema",
764
764
  type: "loose_object",
765
765
  reference: looseObject,
766
766
  expects: "Object",
767
767
  async: false,
768
- entries,
769
- message,
768
+ entries: entries2,
769
+ message: message2,
770
770
  get "~standard"() {
771
771
  return /* @__PURE__ */ _getStandardProps(this);
772
772
  },
@@ -826,14 +826,14 @@ function looseObject(entries, message) {
826
826
  };
827
827
  }
828
828
  /* @__NO_SIDE_EFFECTS__ */
829
- function never(message) {
829
+ function never(message2) {
830
830
  return {
831
831
  kind: "schema",
832
832
  type: "never",
833
833
  reference: never,
834
834
  expects: "never",
835
835
  async: false,
836
- message,
836
+ message: message2,
837
837
  get "~standard"() {
838
838
  return /* @__PURE__ */ _getStandardProps(this);
839
839
  },
@@ -869,14 +869,14 @@ function nullish(wrapped, default_) {
869
869
  };
870
870
  }
871
871
  /* @__NO_SIDE_EFFECTS__ */
872
- function number(message) {
872
+ function number(message2) {
873
873
  return {
874
874
  kind: "schema",
875
875
  type: "number",
876
876
  reference: number,
877
877
  expects: "number",
878
878
  async: false,
879
- message,
879
+ message: message2,
880
880
  get "~standard"() {
881
881
  return /* @__PURE__ */ _getStandardProps(this);
882
882
  },
@@ -888,15 +888,15 @@ function number(message) {
888
888
  };
889
889
  }
890
890
  /* @__NO_SIDE_EFFECTS__ */
891
- function object(entries, message) {
891
+ function object(entries2, message2) {
892
892
  return {
893
893
  kind: "schema",
894
894
  type: "object",
895
895
  reference: object,
896
896
  expects: "Object",
897
897
  async: false,
898
- entries,
899
- message,
898
+ entries: entries2,
899
+ message: message2,
900
900
  get "~standard"() {
901
901
  return /* @__PURE__ */ _getStandardProps(this);
902
902
  },
@@ -978,7 +978,7 @@ function optional(wrapped, default_) {
978
978
  };
979
979
  }
980
980
  /* @__NO_SIDE_EFFECTS__ */
981
- function picklist(options, message) {
981
+ function picklist(options, message2) {
982
982
  return {
983
983
  kind: "schema",
984
984
  type: "picklist",
@@ -986,7 +986,7 @@ function picklist(options, message) {
986
986
  expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
987
987
  async: false,
988
988
  options,
989
- message,
989
+ message: message2,
990
990
  get "~standard"() {
991
991
  return /* @__PURE__ */ _getStandardProps(this);
992
992
  },
@@ -998,14 +998,14 @@ function picklist(options, message) {
998
998
  };
999
999
  }
1000
1000
  /* @__NO_SIDE_EFFECTS__ */
1001
- function promise(message) {
1001
+ function promise(message2) {
1002
1002
  return {
1003
1003
  kind: "schema",
1004
1004
  type: "promise",
1005
1005
  reference: promise,
1006
1006
  expects: "Promise",
1007
1007
  async: false,
1008
- message,
1008
+ message: message2,
1009
1009
  get "~standard"() {
1010
1010
  return /* @__PURE__ */ _getStandardProps(this);
1011
1011
  },
@@ -1017,7 +1017,7 @@ function promise(message) {
1017
1017
  };
1018
1018
  }
1019
1019
  /* @__NO_SIDE_EFFECTS__ */
1020
- function record(key, value2, message) {
1020
+ function record(key, value2, message2) {
1021
1021
  return {
1022
1022
  kind: "schema",
1023
1023
  type: "record",
@@ -1026,7 +1026,7 @@ function record(key, value2, message) {
1026
1026
  async: false,
1027
1027
  key,
1028
1028
  value: value2,
1029
- message,
1029
+ message: message2,
1030
1030
  get "~standard"() {
1031
1031
  return /* @__PURE__ */ _getStandardProps(this);
1032
1032
  },
@@ -1085,15 +1085,15 @@ function record(key, value2, message) {
1085
1085
  };
1086
1086
  }
1087
1087
  /* @__NO_SIDE_EFFECTS__ */
1088
- function strictObject(entries, message) {
1088
+ function strictObject(entries2, message2) {
1089
1089
  return {
1090
1090
  kind: "schema",
1091
1091
  type: "strict_object",
1092
1092
  reference: strictObject,
1093
1093
  expects: "Object",
1094
1094
  async: false,
1095
- entries,
1096
- message,
1095
+ entries: entries2,
1096
+ message: message2,
1097
1097
  get "~standard"() {
1098
1098
  return /* @__PURE__ */ _getStandardProps(this);
1099
1099
  },
@@ -1166,14 +1166,14 @@ function strictObject(entries, message) {
1166
1166
  };
1167
1167
  }
1168
1168
  /* @__NO_SIDE_EFFECTS__ */
1169
- function string(message) {
1169
+ function string(message2) {
1170
1170
  return {
1171
1171
  kind: "schema",
1172
1172
  type: "string",
1173
1173
  reference: string,
1174
1174
  expects: "string",
1175
1175
  async: false,
1176
- message,
1176
+ message: message2,
1177
1177
  get "~standard"() {
1178
1178
  return /* @__PURE__ */ _getStandardProps(this);
1179
1179
  },
@@ -1185,7 +1185,7 @@ function string(message) {
1185
1185
  };
1186
1186
  }
1187
1187
  /* @__NO_SIDE_EFFECTS__ */
1188
- function tuple(items, message) {
1188
+ function tuple(items, message2) {
1189
1189
  return {
1190
1190
  kind: "schema",
1191
1191
  type: "tuple",
@@ -1193,7 +1193,7 @@ function tuple(items, message) {
1193
1193
  expects: "Array",
1194
1194
  async: false,
1195
1195
  items,
1196
- message,
1196
+ message: message2,
1197
1197
  get "~standard"() {
1198
1198
  return /* @__PURE__ */ _getStandardProps(this);
1199
1199
  },
@@ -1240,7 +1240,7 @@ function _subIssues(datasets) {
1240
1240
  return issues;
1241
1241
  }
1242
1242
  /* @__NO_SIDE_EFFECTS__ */
1243
- function union(options, message) {
1243
+ function union(options, message2) {
1244
1244
  return {
1245
1245
  kind: "schema",
1246
1246
  type: "union",
@@ -1248,7 +1248,7 @@ function union(options, message) {
1248
1248
  expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1249
1249
  async: false,
1250
1250
  options,
1251
- message,
1251
+ message: message2,
1252
1252
  get "~standard"() {
1253
1253
  return /* @__PURE__ */ _getStandardProps(this);
1254
1254
  },
@@ -1279,7 +1279,7 @@ function union(options, message) {
1279
1279
  };
1280
1280
  }
1281
1281
  /* @__NO_SIDE_EFFECTS__ */
1282
- function unionAsync(options, message) {
1282
+ function unionAsync(options, message2) {
1283
1283
  return {
1284
1284
  kind: "schema",
1285
1285
  type: "union",
@@ -1287,7 +1287,7 @@ function unionAsync(options, message) {
1287
1287
  expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1288
1288
  async: true,
1289
1289
  options,
1290
- message,
1290
+ message: message2,
1291
1291
  get "~standard"() {
1292
1292
  return /* @__PURE__ */ _getStandardProps(this);
1293
1293
  },
@@ -1318,16 +1318,16 @@ function unionAsync(options, message) {
1318
1318
  };
1319
1319
  }
1320
1320
  /* @__NO_SIDE_EFFECTS__ */
1321
- function keyof(schema, message) {
1322
- return /* @__PURE__ */ picklist(Object.keys(schema.entries), message);
1321
+ function keyof(schema, message2) {
1322
+ return /* @__PURE__ */ picklist(Object.keys(schema.entries), message2);
1323
1323
  }
1324
1324
  /* @__NO_SIDE_EFFECTS__ */
1325
1325
  function omit(schema, keys) {
1326
- const entries = { ...schema.entries };
1327
- for (const key of keys) delete entries[key];
1326
+ const entries2 = { ...schema.entries };
1327
+ for (const key of keys) delete entries2[key];
1328
1328
  return {
1329
1329
  ...schema,
1330
- entries,
1330
+ entries: entries2,
1331
1331
  get "~standard"() {
1332
1332
  return /* @__PURE__ */ _getStandardProps(this);
1333
1333
  }
@@ -1386,7 +1386,18 @@ function safeParse(schema, input, config2) {
1386
1386
  }
1387
1387
 
1388
1388
  //#endregion
1389
- //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.0.0_valibot@1.0.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
1389
+ //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.2.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
1390
+ var store;
1391
+ function getGlobalDefs() {
1392
+ return store;
1393
+ }
1394
+ function addError(errors, message) {
1395
+ if (errors) {
1396
+ errors.push(message);
1397
+ return errors;
1398
+ }
1399
+ return [message];
1400
+ }
1390
1401
  function handleError(message, config) {
1391
1402
  switch (config?.errorMode) {
1392
1403
  case "ignore": break;
@@ -1398,6 +1409,7 @@ function handleError(message, config) {
1398
1409
  }
1399
1410
  }
1400
1411
  function convertAction(jsonSchema, valibotAction, config) {
1412
+ let errors;
1401
1413
  switch (valibotAction.type) {
1402
1414
  case "base64": {
1403
1415
  jsonSchema.contentEncoding = "base64";
@@ -1427,11 +1439,16 @@ function convertAction(jsonSchema, valibotAction, config) {
1427
1439
  case "empty": {
1428
1440
  if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1429
1441
  else {
1430
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1442
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1431
1443
  jsonSchema.maxLength = 0;
1432
1444
  }
1433
1445
  break;
1434
1446
  }
1447
+ case "entries": {
1448
+ jsonSchema.minProperties = valibotAction.requirement;
1449
+ jsonSchema.maxProperties = valibotAction.requirement;
1450
+ break;
1451
+ }
1435
1452
  case "integer": {
1436
1453
  jsonSchema.type = "integer";
1437
1454
  break;
@@ -1462,35 +1479,49 @@ function convertAction(jsonSchema, valibotAction, config) {
1462
1479
  jsonSchema.minItems = valibotAction.requirement;
1463
1480
  jsonSchema.maxItems = valibotAction.requirement;
1464
1481
  } else {
1465
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1482
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1466
1483
  jsonSchema.minLength = valibotAction.requirement;
1467
1484
  jsonSchema.maxLength = valibotAction.requirement;
1468
1485
  }
1469
1486
  break;
1470
1487
  }
1488
+ case "max_entries": {
1489
+ jsonSchema.maxProperties = valibotAction.requirement;
1490
+ break;
1491
+ }
1471
1492
  case "max_length": {
1472
1493
  if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
1473
1494
  else {
1474
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1495
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1475
1496
  jsonSchema.maxLength = valibotAction.requirement;
1476
1497
  }
1477
1498
  break;
1478
1499
  }
1479
1500
  case "max_value": {
1480
- if (jsonSchema.type !== "number") handleError(`The "max_value" action is not supported on type "${jsonSchema.type}".`, config);
1501
+ if (jsonSchema.type !== "number") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1481
1502
  jsonSchema.maximum = valibotAction.requirement;
1482
1503
  break;
1483
1504
  }
1505
+ case "metadata": {
1506
+ if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1507
+ if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1508
+ if (Array.isArray(valibotAction.metadata.examples)) jsonSchema.examples = valibotAction.metadata.examples;
1509
+ break;
1510
+ }
1511
+ case "min_entries": {
1512
+ jsonSchema.minProperties = valibotAction.requirement;
1513
+ break;
1514
+ }
1484
1515
  case "min_length": {
1485
1516
  if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
1486
1517
  else {
1487
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1518
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1488
1519
  jsonSchema.minLength = valibotAction.requirement;
1489
1520
  }
1490
1521
  break;
1491
1522
  }
1492
1523
  case "min_value": {
1493
- if (jsonSchema.type !== "number") handleError(`The "min_value" action is not supported on type "${jsonSchema.type}".`, config);
1524
+ if (jsonSchema.type !== "number") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1494
1525
  jsonSchema.minimum = valibotAction.requirement;
1495
1526
  break;
1496
1527
  }
@@ -1501,13 +1532,13 @@ function convertAction(jsonSchema, valibotAction, config) {
1501
1532
  case "non_empty": {
1502
1533
  if (jsonSchema.type === "array") jsonSchema.minItems = 1;
1503
1534
  else {
1504
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1535
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1505
1536
  jsonSchema.minLength = 1;
1506
1537
  }
1507
1538
  break;
1508
1539
  }
1509
1540
  case "regex": {
1510
- if (valibotAction.requirement.flags) handleError("RegExp flags are not supported by JSON Schema.", config);
1541
+ if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1511
1542
  jsonSchema.pattern = valibotAction.requirement.source;
1512
1543
  break;
1513
1544
  }
@@ -1527,31 +1558,48 @@ function convertAction(jsonSchema, valibotAction, config) {
1527
1558
  jsonSchema.const = valibotAction.requirement;
1528
1559
  break;
1529
1560
  }
1530
- default: handleError(`The "${valibotAction.type}" action cannot be converted to JSON Schema.`, config);
1561
+ default: errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1562
+ }
1563
+ if (config?.overrideAction) {
1564
+ const actionOverride = config.overrideAction({
1565
+ valibotAction,
1566
+ jsonSchema,
1567
+ errors
1568
+ });
1569
+ if (actionOverride) return { ...actionOverride };
1531
1570
  }
1571
+ if (errors) for (const message of errors) handleError(message, config);
1532
1572
  return jsonSchema;
1533
1573
  }
1534
1574
  var refCount = 0;
1535
- function convertSchema(jsonSchema, valibotSchema, config, context) {
1536
- const referenceId = context.referenceMap.get(valibotSchema);
1537
- if (referenceId && referenceId in context.definitions) {
1538
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1539
- return jsonSchema;
1575
+ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1576
+ if (!skipRef) {
1577
+ const referenceId = context.referenceMap.get(valibotSchema);
1578
+ if (referenceId) {
1579
+ jsonSchema.$ref = `#/$defs/${referenceId}`;
1580
+ if (config?.overrideRef) {
1581
+ const refOverride = config.overrideRef({
1582
+ ...context,
1583
+ referenceId,
1584
+ valibotSchema,
1585
+ jsonSchema
1586
+ });
1587
+ if (refOverride) jsonSchema.$ref = refOverride;
1588
+ }
1589
+ return jsonSchema;
1590
+ }
1540
1591
  }
1541
1592
  if ("pipe" in valibotSchema) {
1542
1593
  for (let index = 0; index < valibotSchema.pipe.length; index++) {
1543
1594
  const valibotPipeItem = valibotSchema.pipe[index];
1544
1595
  if (valibotPipeItem.kind === "schema") {
1545
1596
  if (index > 0) handleError("A \"pipe\" with multiple schemas cannot be converted to JSON Schema.", config);
1546
- const tempJsonSchema = convertSchema({}, valibotPipeItem, config, context);
1547
- if (tempJsonSchema.$ref) {
1548
- const referenceId2 = tempJsonSchema.$ref.split("/")[2];
1549
- Object.assign(jsonSchema, context.definitions[referenceId2]);
1550
- } else Object.assign(jsonSchema, tempJsonSchema);
1597
+ jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1551
1598
  } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1552
1599
  }
1553
1600
  return jsonSchema;
1554
1601
  }
1602
+ let errors;
1555
1603
  switch (valibotSchema.type) {
1556
1604
  case "boolean": {
1557
1605
  jsonSchema.type = "boolean";
@@ -1580,9 +1628,10 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1580
1628
  case "strict_tuple": {
1581
1629
  jsonSchema.type = "array";
1582
1630
  jsonSchema.items = [];
1631
+ jsonSchema.minItems = valibotSchema.items.length;
1583
1632
  for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1584
1633
  if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1585
- else jsonSchema.additionalItems = valibotSchema.type === "loose_tuple";
1634
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1586
1635
  break;
1587
1636
  }
1588
1637
  case "object":
@@ -1602,8 +1651,8 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1602
1651
  break;
1603
1652
  }
1604
1653
  case "record": {
1605
- if ("pipe" in valibotSchema.key) handleError("The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.", config);
1606
- if (valibotSchema.key.type !== "string") handleError(`The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`, config);
1654
+ if ("pipe" in valibotSchema.key) errors = addError(errors, "The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.");
1655
+ if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
1607
1656
  jsonSchema.type = "object";
1608
1657
  jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1609
1658
  break;
@@ -1624,7 +1673,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1624
1673
  break;
1625
1674
  }
1626
1675
  case "literal": {
1627
- if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") handleError("The value of the \"literal\" schema is not JSON compatible.", config);
1676
+ if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") errors = addError(errors, "The value of the \"literal\" schema is not JSON compatible.");
1628
1677
  jsonSchema.const = valibotSchema.literal;
1629
1678
  break;
1630
1679
  }
@@ -1633,7 +1682,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1633
1682
  break;
1634
1683
  }
1635
1684
  case "picklist": {
1636
- if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) handleError("An option of the \"picklist\" schema is not JSON compatible.", config);
1685
+ if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) errors = addError(errors, "An option of the \"picklist\" schema is not JSON compatible.");
1637
1686
  jsonSchema.enum = valibotSchema.options;
1638
1687
  break;
1639
1688
  }
@@ -1652,17 +1701,37 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1652
1701
  wrappedValibotSchema = valibotSchema.getter(void 0);
1653
1702
  context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1654
1703
  }
1655
- let referenceId2 = context.referenceMap.get(wrappedValibotSchema);
1656
- if (!referenceId2) {
1657
- referenceId2 = `${refCount++}`;
1658
- context.referenceMap.set(wrappedValibotSchema, referenceId2);
1659
- context.definitions[referenceId2] = convertSchema({}, wrappedValibotSchema, config, context);
1704
+ let referenceId = context.referenceMap.get(wrappedValibotSchema);
1705
+ if (!referenceId) {
1706
+ referenceId = `${refCount++}`;
1707
+ context.referenceMap.set(wrappedValibotSchema, referenceId);
1708
+ context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1709
+ }
1710
+ jsonSchema.$ref = `#/$defs/${referenceId}`;
1711
+ if (config?.overrideRef) {
1712
+ const refOverride = config.overrideRef({
1713
+ ...context,
1714
+ referenceId,
1715
+ valibotSchema,
1716
+ jsonSchema
1717
+ });
1718
+ if (refOverride) jsonSchema.$ref = refOverride;
1660
1719
  }
1661
- jsonSchema.$ref = `#/$defs/${referenceId2}`;
1662
1720
  break;
1663
1721
  }
1664
- default: handleError(`The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`, config);
1722
+ default: errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1723
+ }
1724
+ if (config?.overrideSchema) {
1725
+ const schemaOverride = config.overrideSchema({
1726
+ ...context,
1727
+ referenceId: context.referenceMap.get(valibotSchema),
1728
+ valibotSchema,
1729
+ jsonSchema,
1730
+ errors
1731
+ });
1732
+ if (schemaOverride) return { ...schemaOverride };
1665
1733
  }
1734
+ if (errors) for (const message of errors) handleError(message, config);
1666
1735
  return jsonSchema;
1667
1736
  }
1668
1737
  function toJsonSchema(schema, config) {
@@ -1671,9 +1740,10 @@ function toJsonSchema(schema, config) {
1671
1740
  referenceMap: /* @__PURE__ */ new Map(),
1672
1741
  getterMap: /* @__PURE__ */ new Map()
1673
1742
  };
1674
- if (config?.definitions) {
1675
- for (const key in config.definitions) context.referenceMap.set(config.definitions[key], key);
1676
- for (const key in config.definitions) context.definitions[key] = convertSchema({}, config.definitions[key], config, context);
1743
+ const definitions = config?.definitions ?? getGlobalDefs();
1744
+ if (definitions) {
1745
+ for (const key in definitions) context.referenceMap.set(definitions[key], key);
1746
+ for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1677
1747
  }
1678
1748
  const jsonSchema = convertSchema({ $schema: "http://json-schema.org/draft-07/schema#" }, schema, config, context);
1679
1749
  if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
@@ -2203,7 +2273,7 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2203
2273
  }
2204
2274
 
2205
2275
  //#endregion
2206
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-D6FCK2GA.js
2276
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-D6FCK2GA.js
2207
2277
  function u$1(o, n, a) {
2208
2278
  let t$1 = (r) => o(r, ...n);
2209
2279
  return a === void 0 ? t$1 : Object.assign(t$1, {
@@ -2213,7 +2283,7 @@ function u$1(o, n, a) {
2213
2283
  }
2214
2284
 
2215
2285
  //#endregion
2216
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-WIMGWYZL.js
2286
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-WIMGWYZL.js
2217
2287
  function u(r, n, o) {
2218
2288
  let a = r.length - n.length;
2219
2289
  if (a === 0) return r(...n);
@@ -2222,7 +2292,7 @@ function u(r, n, o) {
2222
2292
  }
2223
2293
 
2224
2294
  //#endregion
2225
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-3IFJP4R5.js
2295
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-3IFJP4R5.js
2226
2296
  function d(...r) {
2227
2297
  return u(i, r);
2228
2298
  }
@@ -2233,7 +2303,7 @@ var i = (r, t$1) => {
2233
2303
  };
2234
2304
 
2235
2305
  //#endregion
2236
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-5NQBDF4H.js
2306
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-5NQBDF4H.js
2237
2307
  function t(...n) {
2238
2308
  return u(Object.keys, n);
2239
2309
  }