@valbuild/shared 0.123.0 → 0.123.3

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.
@@ -3,130 +3,21 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
- var utils = require('../../dist/utils-d3d8b4b5.cjs.dev.js');
6
+ var getSitemapTree = require('../../dist/getSitemapTree-a0c9a0e3.cjs.dev.js');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
9
9
  var FlexSearch = require('flexsearch');
10
+ var utils = require('../../dist/utils-d3d8b4b5.cjs.dev.js');
10
11
 
11
12
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
12
13
 
13
14
  var FlexSearch__default = /*#__PURE__*/_interopDefault(FlexSearch);
14
15
 
15
- function _toPrimitive(t, r) {
16
- if ("object" != typeof t || !t) return t;
17
- var e = t[Symbol.toPrimitive];
18
- if (void 0 !== e) {
19
- var i = e.call(t, r || "default");
20
- if ("object" != typeof i) return i;
21
- throw new TypeError("@@toPrimitive must return a primitive value.");
22
- }
23
- return ("string" === r ? String : Number)(t);
24
- }
25
-
26
- function _toPropertyKey(t) {
27
- var i = _toPrimitive(t, "string");
28
- return "symbol" == typeof i ? i : i + "";
29
- }
30
-
31
- function _defineProperty(e, r, t) {
32
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
- value: t,
34
- enumerable: !0,
35
- configurable: !0,
36
- writable: !0
37
- }) : e[r] = t, e;
38
- }
39
-
40
- function ownKeys(e, r) {
41
- var t = Object.keys(e);
42
- if (Object.getOwnPropertySymbols) {
43
- var o = Object.getOwnPropertySymbols(e);
44
- r && (o = o.filter(function (r) {
45
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
46
- })), t.push.apply(t, o);
47
- }
48
- return t;
49
- }
50
- function _objectSpread2(e) {
51
- for (var r = 1; r < arguments.length; r++) {
52
- var t = null != arguments[r] ? arguments[r] : {};
53
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
54
- _defineProperty(e, r, t[r]);
55
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
56
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
57
- });
58
- }
59
- return e;
60
- }
61
-
62
- function _arrayLikeToArray(r, a) {
63
- (null == a || a > r.length) && (a = r.length);
64
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
65
- return n;
66
- }
67
-
68
- function _unsupportedIterableToArray(r, a) {
69
- if (r) {
70
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
71
- var t = {}.toString.call(r).slice(8, -1);
72
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
73
- }
74
- }
75
-
76
- function _createForOfIteratorHelper(r, e) {
77
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
78
- if (!t) {
79
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
80
- t && (r = t);
81
- var n = 0,
82
- F = function () {};
83
- return {
84
- s: F,
85
- n: function () {
86
- return n >= r.length ? {
87
- done: !0
88
- } : {
89
- done: !1,
90
- value: r[n++]
91
- };
92
- },
93
- e: function (r) {
94
- throw r;
95
- },
96
- f: F
97
- };
98
- }
99
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
100
- }
101
- var o,
102
- a = !0,
103
- u = !1;
104
- return {
105
- s: function () {
106
- t = t.call(r);
107
- },
108
- n: function () {
109
- var r = t.next();
110
- return a = r.done, r;
111
- },
112
- e: function (r) {
113
- u = !0, o = r;
114
- },
115
- f: function () {
116
- try {
117
- a || null == t.return || t.return();
118
- } finally {
119
- if (u) throw o;
120
- }
121
- }
122
- };
123
- }
124
-
125
16
  function remirrorToRichTextSource(node, configDirectory, remoteOptions) {
126
17
  var files = {};
127
18
  var blocks = [];
128
19
  var i = 0;
129
- var _iterator = _createForOfIteratorHelper((node === null || node === void 0 ? void 0 : node.content) || []),
20
+ var _iterator = getSitemapTree._createForOfIteratorHelper((node === null || node === void 0 ? void 0 : node.content) || []),
130
21
  _step;
131
22
  try {
132
23
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -331,7 +222,7 @@ function convertImageNode(path, node, files, configDirectory, remoteOptions) {
331
222
  // file is added as src (see below):
332
223
  .concat("src");
333
224
  var remoteFileHash = core.Internal.remote.hashToRemoteFileHash(fullFileHash);
334
- var ref = remoteOptions ? core.Internal.remote.createRemoteRef(remoteOptions.remoteHost, _objectSpread2(_objectSpread2({}, remoteOptions), {}, {
225
+ var ref = remoteOptions ? core.Internal.remote.createRemoteRef(remoteOptions.remoteHost, getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, remoteOptions), {}, {
335
226
  fileHash: remoteFileHash,
336
227
  validationHash: core.Internal.remote.getValidationHash(remoteOptions.coreVersion, remoteOptions.schema, mimeType, {
337
228
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
@@ -389,7 +280,7 @@ function convertImageNode(path, node, files, configDirectory, remoteOptions) {
389
280
  }
390
281
  var tag = {
391
282
  tag: "img",
392
- src: _objectSpread2({
283
+ src: getSitemapTree._objectSpread2({
393
284
  path: noParamsUrl,
394
285
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
395
286
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
@@ -499,7 +390,7 @@ var RemirrorJSON = zod.z.object({
499
390
  });
500
391
 
501
392
  function _arrayWithoutHoles(r) {
502
- if (Array.isArray(r)) return _arrayLikeToArray(r);
393
+ if (Array.isArray(r)) return getSitemapTree._arrayLikeToArray(r);
503
394
  }
504
395
 
505
396
  function _iterableToArray(r) {
@@ -511,7 +402,7 @@ function _nonIterableSpread() {
511
402
  }
512
403
 
513
404
  function _toConsumableArray(r) {
514
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
405
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || getSitemapTree._unsupportedIterableToArray(r) || _nonIterableSpread();
515
406
  }
516
407
 
517
408
  function richTextToRemirror(richtext) {
@@ -661,7 +552,7 @@ function convertLinkNodeToRemirror(linkNode) {
661
552
  if (remirrorNode.type !== "text") {
662
553
  return remirrorNode;
663
554
  }
664
- return _objectSpread2(_objectSpread2({}, remirrorNode), {}, {
555
+ return getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, remirrorNode), {}, {
665
556
  marks: (remirrorNode.marks || []).concat({
666
557
  type: "link",
667
558
  attrs: {
@@ -708,7 +599,7 @@ function convertListItemToRemirror(liNode) {
708
599
  }
709
600
  function convertListItemToRemirrorParagraph(rtChildren) {
710
601
  var children = [];
711
- var _iterator = _createForOfIteratorHelper(rtChildren),
602
+ var _iterator = getSitemapTree._createForOfIteratorHelper(rtChildren),
712
603
  _step;
713
604
  try {
714
605
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -1020,97 +911,96 @@ var InlineRender = zod.z.object({
1020
911
  as: zod.z.literal("inline")
1021
912
  });
1022
913
  var FieldRender = InlineRender.optional();
1023
- var SerializedStringSchema = zod.z.object({
1024
- type: zod.z.literal("string"),
914
+
915
+ /**
916
+ * The fields EVERY serialized schema carries, in one place.
917
+ *
918
+ * Spread into each schema below rather than retyped, because retyping them is
919
+ * exactly how they went missing: `customValidate` and `description` were
920
+ * declared on six of the eighteen schemas and silently dropped by the other
921
+ * twelve. A field added to the base of `SerializedSchema` needs adding here and
922
+ * nowhere else.
923
+ *
924
+ * `type`, `opt` and whatever is particular to the schema stay at the call site
925
+ * - those differ per schema, so there is nothing to share.
926
+ */
927
+ var commonSchemaFields = {
1025
928
  render: FieldRender,
929
+ preview: zod.z.literal(true).optional(),
930
+ // Whether the schema declares a `.validate()`. The function cannot serialize,
931
+ // so this flag is what tells the Studio to run the custom validators on the
932
+ // main thread against the real instance - dropped, and they never run at all.
933
+ // See `hasCustomValidate` in `ui/spa/validation/customValidate.ts`.
934
+ customValidate: zod.z["boolean"]().optional(),
935
+ readonly: zod.z["boolean"]().optional(),
936
+ hidden: zod.z["boolean"]().optional(),
937
+ description: zod.z.string().optional()
938
+ };
939
+ var SerializedStringSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
940
+ type: zod.z.literal("string"),
1026
941
  // `.multiline()`. Stripped like any undeclared key if it goes missing here,
1027
942
  // which is a single-line input where the author asked for a text box.
1028
943
  multiline: zod.z["boolean"]().optional(),
1029
- preview: zod.z.literal(true).optional(),
1030
944
  options: zod.z.object({
1031
945
  maxLength: zod.z.number().optional(),
1032
946
  minLength: zod.z.number().optional(),
1033
947
  regexp: zod.z.object({
948
+ // `.regexp(re, message)`'s message. Written by
949
+ // `StringSchema.executeSerialize`, so omitting it here strips the
950
+ // author's own wording and leaves the generic "Expected string to
951
+ // match reg exp: …" in its place.
952
+ message: zod.z.string().optional(),
1034
953
  source: zod.z.string(),
1035
954
  flags: zod.z.string()
1036
- }).optional()
955
+ }).optional(),
956
+ customValidate: zod.z["boolean"]().optional()
1037
957
  }).optional(),
1038
958
  opt: zod.z["boolean"](),
1039
- raw: zod.z["boolean"](),
1040
- readonly: zod.z["boolean"]().optional(),
1041
- hidden: zod.z["boolean"]().optional()
1042
- });
1043
- var SerializedLiteralSchema = zod.z.object({
959
+ raw: zod.z["boolean"]()
960
+ }));
961
+ var SerializedLiteralSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1044
962
  type: zod.z.literal("literal"),
1045
- render: FieldRender,
1046
- preview: zod.z.literal(true).optional(),
1047
963
  value: zod.z.string(),
1048
- opt: zod.z["boolean"](),
1049
- readonly: zod.z["boolean"]().optional(),
1050
- hidden: zod.z["boolean"]().optional()
1051
- });
1052
- var SerializedBooleanSchema = zod.z.object({
964
+ opt: zod.z["boolean"]()
965
+ }));
966
+ var SerializedBooleanSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1053
967
  type: zod.z.literal("boolean"),
1054
- render: FieldRender,
1055
- preview: zod.z.literal(true).optional(),
1056
- opt: zod.z["boolean"](),
1057
- readonly: zod.z["boolean"]().optional(),
1058
- hidden: zod.z["boolean"]().optional()
1059
- });
1060
- var SerializedNumberSchema = zod.z.object({
968
+ opt: zod.z["boolean"]()
969
+ }));
970
+ var SerializedNumberSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1061
971
  type: zod.z.literal("number"),
1062
- render: FieldRender,
1063
- preview: zod.z.literal(true).optional(),
1064
972
  options: zod.z.object({
1065
973
  max: zod.z.number().optional(),
1066
974
  min: zod.z.number().optional()
1067
975
  }).optional(),
1068
- opt: zod.z["boolean"](),
1069
- readonly: zod.z["boolean"]().optional(),
1070
- hidden: zod.z["boolean"]().optional()
1071
- });
976
+ opt: zod.z["boolean"]()
977
+ }));
1072
978
  var SerializedObjectSchema = zod.z.lazy(function () {
1073
- return zod.z.object({
979
+ return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1074
980
  type: zod.z.literal("object"),
1075
- render: FieldRender,
1076
- preview: zod.z.literal(true).optional(),
1077
981
  items: zod.z.record(zod.z.string(), SerializedSchema),
1078
- opt: zod.z["boolean"](),
1079
- readonly: zod.z["boolean"]().optional(),
1080
- hidden: zod.z["boolean"]().optional()
1081
- });
982
+ opt: zod.z["boolean"]()
983
+ }));
1082
984
  });
1083
985
  var SerializedArraySchema = zod.z.lazy(function () {
1084
- return zod.z.object({
986
+ return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1085
987
  type: zod.z.literal("array"),
1086
- render: FieldRender,
1087
- preview: zod.z.literal(true).optional(),
1088
988
  item: SerializedSchema,
1089
- opt: zod.z["boolean"](),
1090
- readonly: zod.z["boolean"]().optional(),
1091
- hidden: zod.z["boolean"]().optional()
1092
- });
989
+ opt: zod.z["boolean"]()
990
+ }));
1093
991
  });
1094
992
  var SerializedUnionSchema = zod.z.lazy(function () {
1095
- return zod.z.union([zod.z.object({
993
+ return zod.z.union([zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1096
994
  type: zod.z.literal("union"),
1097
- render: FieldRender,
1098
- preview: zod.z.literal(true).optional(),
1099
995
  key: SerializedLiteralSchema,
1100
996
  items: zod.z.array(SerializedLiteralSchema),
1101
- opt: zod.z["boolean"](),
1102
- readonly: zod.z["boolean"]().optional(),
1103
- hidden: zod.z["boolean"]().optional()
1104
- }), zod.z.object({
997
+ opt: zod.z["boolean"]()
998
+ })), zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1105
999
  type: zod.z.literal("union"),
1106
- render: FieldRender,
1107
- preview: zod.z.literal(true).optional(),
1108
1000
  key: zod.z.string(),
1109
1001
  items: zod.z.array(SerializedObjectSchema),
1110
- opt: zod.z["boolean"](),
1111
- readonly: zod.z["boolean"]().optional(),
1112
- hidden: zod.z["boolean"]().optional()
1113
- })]);
1002
+ opt: zod.z["boolean"]()
1003
+ }))]);
1114
1004
  });
1115
1005
  var ImageEncodeOption = zod.z.union([zod.z.literal(false), zod.z.object({
1116
1006
  type: zod.z.literal("webp"),
@@ -1123,15 +1013,16 @@ var ImageOptions = zod.z.object({
1123
1013
  accept: zod.z.string().optional(),
1124
1014
  encode: ImageEncodeOption.optional()
1125
1015
  });
1126
- var SerializedImageSchema = zod.z.object({
1016
+ var SerializedImageSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1127
1017
  type: zod.z.literal("image"),
1128
- render: FieldRender,
1129
- preview: zod.z.literal(true).optional(),
1130
1018
  options: ImageOptions.optional(),
1131
1019
  opt: zod.z["boolean"](),
1132
- readonly: zod.z["boolean"]().optional(),
1133
- hidden: zod.z["boolean"]().optional()
1134
- });
1020
+ // `.remote()`, and the gallery a gallery-backed field reads its metadata
1021
+ // from. Neither is cosmetic: dropped, a remote field looks local and a
1022
+ // gallery-backed one looks like it holds its own dimensions.
1023
+ remote: zod.z["boolean"]().optional(),
1024
+ referencedModule: zod.z.string().optional()
1025
+ }));
1135
1026
  var RichTextOptions = zod.z.lazy(function () {
1136
1027
  return zod.z.object({
1137
1028
  // Set by `.maxLength()` / `.minLength()`, not by the options argument.
@@ -1154,20 +1045,14 @@ var RichTextOptions = zod.z.lazy(function () {
1154
1045
  img: zod.z.union([zod.z["boolean"](), SerializedImageSchema]).optional()
1155
1046
  });
1156
1047
  });
1157
- var SerializedRichTextSchema = zod.z.object({
1048
+ var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1158
1049
  type: zod.z.literal("richtext"),
1159
- render: FieldRender,
1160
- preview: zod.z.literal(true).optional(),
1161
1050
  options: RichTextOptions.optional(),
1162
- opt: zod.z["boolean"](),
1163
- readonly: zod.z["boolean"]().optional(),
1164
- hidden: zod.z["boolean"]().optional()
1165
- });
1051
+ opt: zod.z["boolean"]()
1052
+ }));
1166
1053
  var SerializedRecordSchema = zod.z.lazy(function () {
1167
- return zod.z.object({
1054
+ return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1168
1055
  type: zod.z.literal("record"),
1169
- render: FieldRender,
1170
- preview: zod.z.literal(true).optional(),
1171
1056
  item: SerializedSchema,
1172
1057
  opt: zod.z["boolean"](),
1173
1058
  // Optional gallery marker for files/images
@@ -1178,16 +1063,12 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1178
1063
  remote: zod.z["boolean"]().optional(),
1179
1064
  encode: ImageEncodeOption.optional(),
1180
1065
  alt: SerializedSchema.optional(),
1181
- moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional(),
1182
- readonly: zod.z["boolean"]().optional(),
1183
- hidden: zod.z["boolean"]().optional()
1184
- }).passthrough();
1066
+ moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
1067
+ })).passthrough();
1185
1068
  });
1186
1069
  var SerializedKeyOfSchema = zod.z.lazy(function () {
1187
- return zod.z.object({
1070
+ return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1188
1071
  type: zod.z.literal("keyOf"),
1189
- render: FieldRender,
1190
- preview: zod.z.literal(true).optional(),
1191
1072
  path: SourcePath,
1192
1073
  schema: zod.z.union([zod.z.object({
1193
1074
  type: zod.z.literal("object"),
@@ -1198,82 +1079,54 @@ var SerializedKeyOfSchema = zod.z.lazy(function () {
1198
1079
  opt: zod.z["boolean"]().optional()
1199
1080
  })]).optional(),
1200
1081
  values: zod.z.union([zod.z.literal("string"), zod.z.array(zod.z.string())]),
1201
- opt: zod.z["boolean"](),
1202
- readonly: zod.z["boolean"]().optional(),
1203
- hidden: zod.z["boolean"]().optional()
1204
- });
1082
+ opt: zod.z["boolean"]()
1083
+ }));
1205
1084
  });
1206
1085
  var FileOptions = zod.z.object({
1207
1086
  accept: zod.z.string().optional()
1208
1087
  });
1209
- var SerializedFileSchema = zod.z.object({
1088
+ var SerializedFileSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1210
1089
  type: zod.z.literal("file"),
1211
- render: FieldRender,
1212
- preview: zod.z.literal(true).optional(),
1213
1090
  options: FileOptions.optional(),
1214
1091
  opt: zod.z["boolean"](),
1215
- readonly: zod.z["boolean"]().optional(),
1216
- hidden: zod.z["boolean"]().optional()
1217
- });
1092
+ // See `SerializedImageSchema` above: `.remote()` and the gallery a
1093
+ // gallery-backed field reads from.
1094
+ remote: zod.z["boolean"]().optional(),
1095
+ referencedModule: zod.z.string().optional()
1096
+ }));
1218
1097
  var DateOptions = zod.z.object({
1219
1098
  from: zod.z.string().optional(),
1220
1099
  to: zod.z.string().optional()
1221
1100
  });
1222
- var SerializedDateSchema = zod.z.object({
1101
+ var SerializedDateSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1223
1102
  type: zod.z.literal("date"),
1224
- render: FieldRender,
1225
- preview: zod.z.literal(true).optional(),
1226
1103
  options: DateOptions.optional(),
1227
- opt: zod.z["boolean"](),
1228
- customValidate: zod.z["boolean"]().optional(),
1229
- readonly: zod.z["boolean"]().optional(),
1230
- hidden: zod.z["boolean"]().optional(),
1231
- description: zod.z.string().optional()
1232
- });
1233
- var SerializedDateTimeSchema = zod.z.object({
1104
+ opt: zod.z["boolean"]()
1105
+ }));
1106
+ var SerializedDateTimeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1234
1107
  type: zod.z.literal("dateTime"),
1235
- render: FieldRender,
1236
- preview: zod.z.literal(true).optional(),
1237
1108
  options: DateOptions.optional(),
1238
- opt: zod.z["boolean"](),
1239
- customValidate: zod.z["boolean"]().optional(),
1240
- readonly: zod.z["boolean"]().optional(),
1241
- hidden: zod.z["boolean"]().optional(),
1242
- description: zod.z.string().optional()
1243
- });
1109
+ opt: zod.z["boolean"]()
1110
+ }));
1244
1111
  var ColorOptions = zod.z.object({
1245
1112
  format: zod.z["enum"](["hex", "rgb", "hsl", "oklch"]).optional(),
1246
1113
  alpha: zod.z["boolean"]().optional()
1247
1114
  });
1248
- var SerializedColorSchema = zod.z.object({
1115
+ var SerializedColorSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1249
1116
  type: zod.z.literal("color"),
1250
- render: FieldRender,
1251
- preview: zod.z.literal(true).optional(),
1252
1117
  options: ColorOptions.optional(),
1253
- opt: zod.z["boolean"](),
1254
- customValidate: zod.z["boolean"]().optional(),
1255
- readonly: zod.z["boolean"]().optional(),
1256
- hidden: zod.z["boolean"]().optional(),
1257
- description: zod.z.string().optional()
1258
- });
1118
+ opt: zod.z["boolean"]()
1119
+ }));
1259
1120
  var CodeOptions = zod.z.object({
1260
1121
  language: zod.z["enum"](core.CODE_LANGUAGES).optional()
1261
1122
  });
1262
- var SerializedCodeSchema = zod.z.object({
1123
+ var SerializedCodeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1263
1124
  type: zod.z.literal("code"),
1264
- render: FieldRender,
1265
- preview: zod.z.literal(true).optional(),
1266
1125
  options: CodeOptions.optional(),
1267
- opt: zod.z["boolean"](),
1268
- customValidate: zod.z["boolean"]().optional(),
1269
- readonly: zod.z["boolean"]().optional(),
1270
- hidden: zod.z["boolean"]().optional(),
1271
- description: zod.z.string().optional()
1272
- });
1273
- var SerializedRouteSchema = zod.z.object({
1126
+ opt: zod.z["boolean"]()
1127
+ }));
1128
+ var SerializedRouteSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1274
1129
  type: zod.z.literal("route"),
1275
- render: FieldRender,
1276
- preview: zod.z.literal(true).optional(),
1277
1130
  options: zod.z.object({
1278
1131
  include: zod.z.object({
1279
1132
  source: zod.z.string(),
@@ -1285,11 +1138,8 @@ var SerializedRouteSchema = zod.z.object({
1285
1138
  }).optional(),
1286
1139
  customValidate: zod.z["boolean"]().optional()
1287
1140
  }).optional(),
1288
- opt: zod.z["boolean"](),
1289
- customValidate: zod.z["boolean"]().optional(),
1290
- readonly: zod.z["boolean"]().optional(),
1291
- hidden: zod.z["boolean"]().optional()
1292
- });
1141
+ opt: zod.z["boolean"]()
1142
+ }));
1293
1143
 
1294
1144
  // A settings module, and each section inside one, serialize as this - the
1295
1145
  // shape is recursive because `items` holds sections which are themselves
@@ -1297,17 +1147,11 @@ var SerializedRouteSchema = zod.z.object({
1297
1147
  // (see core/src/schema/settings.ts), but they are accepted here because they
1298
1148
  // are part of the declared type.
1299
1149
  var SerializedSettingsSchema = zod.z.lazy(function () {
1300
- return zod.z.object({
1150
+ return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1301
1151
  type: zod.z.literal("settings"),
1302
- render: FieldRender,
1303
- preview: zod.z.literal(true).optional(),
1304
1152
  items: zod.z.record(zod.z.string(), SerializedSchema),
1305
- opt: zod.z["boolean"](),
1306
- customValidate: zod.z["boolean"]().optional(),
1307
- readonly: zod.z["boolean"]().optional(),
1308
- hidden: zod.z["boolean"]().optional(),
1309
- description: zod.z.string().optional()
1310
- });
1153
+ opt: zod.z["boolean"]()
1154
+ }));
1311
1155
  });
1312
1156
  var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema]);
1313
1157
 
@@ -1543,7 +1387,7 @@ var Api = {
1543
1387
  query: {
1544
1388
  redirect_to: onlyOneStringQueryParam.optional()
1545
1389
  },
1546
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1390
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1547
1391
  },
1548
1392
  res: zod.z.union([zod.z.object({
1549
1393
  status: zod.z.literal(401),
@@ -1565,7 +1409,7 @@ var Api = {
1565
1409
  query: {
1566
1410
  redirect_to: onlyOneStringQueryParam.optional()
1567
1411
  },
1568
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1412
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1569
1413
  },
1570
1414
  res: zod.z.union([zod.z.object({
1571
1415
  status: zod.z.literal(401),
@@ -1584,7 +1428,7 @@ var Api = {
1584
1428
  "/draft/stat": {
1585
1429
  GET: {
1586
1430
  req: {
1587
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1431
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1588
1432
  },
1589
1433
  res: zod.z.union([zod.z.object({
1590
1434
  status: zod.z.literal(401),
@@ -1603,7 +1447,7 @@ var Api = {
1603
1447
  query: {
1604
1448
  redirect_to: onlyOneStringQueryParam.optional()
1605
1449
  },
1606
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1450
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1607
1451
  },
1608
1452
  res: zod.z.union([zod.z.object({
1609
1453
  status: zod.z.literal(401),
@@ -1611,7 +1455,7 @@ var Api = {
1611
1455
  }), zod.z.object({
1612
1456
  status: zod.z.literal(302),
1613
1457
  redirectTo: zod.z.string(),
1614
- cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue), VAL_STATE_COOKIE, zod.z.object({
1458
+ cookies: zod.z.object(getSitemapTree._defineProperty(getSitemapTree._defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue), VAL_STATE_COOKIE, zod.z.object({
1615
1459
  value: zod.z.string(),
1616
1460
  options: zod.z.object({
1617
1461
  httpOnly: zod.z.literal(true),
@@ -1622,7 +1466,7 @@ var Api = {
1622
1466
  }), zod.z.object({
1623
1467
  status: zod.z.literal(302),
1624
1468
  redirectTo: zod.z.string(),
1625
- cookies: zod.z.object(_defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue))
1469
+ cookies: zod.z.object(getSitemapTree._defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue))
1626
1470
  }), zod.z.object({
1627
1471
  status: zod.z.literal(400),
1628
1472
  json: zod.z.object({
@@ -1637,7 +1481,7 @@ var Api = {
1637
1481
  query: {
1638
1482
  redirect_to: onlyOneStringQueryParam.optional()
1639
1483
  },
1640
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1484
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1641
1485
  },
1642
1486
  res: zod.z.union([zod.z.object({
1643
1487
  status: zod.z.literal(401),
@@ -1645,7 +1489,7 @@ var Api = {
1645
1489
  }), zod.z.object({
1646
1490
  status: zod.z.literal(302),
1647
1491
  redirectTo: zod.z.string(),
1648
- cookies: zod.z.object(_defineProperty({}, VAL_ENABLE_COOKIE_NAME, zod.z.object({
1492
+ cookies: zod.z.object(getSitemapTree._defineProperty({}, VAL_ENABLE_COOKIE_NAME, zod.z.object({
1649
1493
  value: zod.z.literal("false")
1650
1494
  })))
1651
1495
  }), zod.z.object({
@@ -1666,7 +1510,7 @@ var Api = {
1666
1510
  res: zod.z.union([zod.z.object({
1667
1511
  status: zod.z.literal(302),
1668
1512
  redirectTo: zod.z.string(),
1669
- cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue), VAL_STATE_COOKIE, zod.z.object({
1513
+ cookies: zod.z.object(getSitemapTree._defineProperty(getSitemapTree._defineProperty({}, VAL_ENABLE_COOKIE_NAME, enableCookieValue), VAL_STATE_COOKIE, zod.z.object({
1670
1514
  value: zod.z.string(),
1671
1515
  options: zod.z.object({
1672
1516
  httpOnly: zod.z.literal(true),
@@ -1689,12 +1533,12 @@ var Api = {
1689
1533
  code: onlyOneStringQueryParam.optional(),
1690
1534
  state: onlyOneStringQueryParam.optional()
1691
1535
  },
1692
- cookies: _defineProperty({}, VAL_STATE_COOKIE, zod.z.string())
1536
+ cookies: getSitemapTree._defineProperty({}, VAL_STATE_COOKIE, zod.z.string())
1693
1537
  },
1694
1538
  res: zod.z.object({
1695
1539
  status: zod.z.literal(302),
1696
1540
  redirectTo: zod.z.string(),
1697
- cookies: zod.z.object(_defineProperty(_defineProperty(_defineProperty({}, VAL_STATE_COOKIE, zod.z.object({
1541
+ cookies: zod.z.object(getSitemapTree._defineProperty(getSitemapTree._defineProperty(getSitemapTree._defineProperty({}, VAL_STATE_COOKIE, zod.z.object({
1698
1542
  value: zod.z.literal(null)
1699
1543
  })), VAL_ENABLE_COOKIE_NAME, enableCookieValue.optional()), VAL_SESSION_COOKIE, zod.z.object({
1700
1544
  value: zod.z.string(),
@@ -1719,7 +1563,7 @@ var Api = {
1719
1563
  // TODO fix req types
1720
1564
  res: zod.z.union([zod.z.object({
1721
1565
  status: zod.z.literal(200),
1722
- cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
1566
+ cookies: zod.z.object(getSitemapTree._defineProperty(getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
1723
1567
  value: zod.z.string(),
1724
1568
  options: zod.z.object({
1725
1569
  httpOnly: zod.z.literal(true),
@@ -1741,7 +1585,7 @@ var Api = {
1741
1585
  }), zod.z.object({
1742
1586
  status: zod.z.literal(302),
1743
1587
  redirectTo: zod.z.string(),
1744
- cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
1588
+ cookies: zod.z.object(getSitemapTree._defineProperty(getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
1745
1589
  value: zod.z.string(),
1746
1590
  options: zod.z.object({
1747
1591
  httpOnly: zod.z.literal(true),
@@ -2702,7 +2546,7 @@ var Api = {
2702
2546
  */
2703
2547
  own_patch_groups_only: onlyOneBooleanQueryParam.optional()
2704
2548
  },
2705
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2549
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2706
2550
  },
2707
2551
  res: zod.z.union([unauthorizedResponse, notFoundResponse,
2708
2552
  // Shape (1): single `key`.
@@ -2749,7 +2593,7 @@ var Api = {
2749
2593
  "/ai/initialize": {
2750
2594
  POST: {
2751
2595
  req: {
2752
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2596
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2753
2597
  },
2754
2598
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2755
2599
  status: zod.z.literal(200),
@@ -2806,7 +2650,7 @@ var Api = {
2806
2650
  cursor_updatedAt: onlyOneStringQueryParam.optional(),
2807
2651
  cursor_id: onlyOneStringQueryParam.optional()
2808
2652
  },
2809
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2653
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2810
2654
  },
2811
2655
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2812
2656
  status: zod.z.literal(200),
@@ -2833,7 +2677,7 @@ var Api = {
2833
2677
  body: zod.z.object({
2834
2678
  name: zod.z.string()
2835
2679
  }),
2836
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2680
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2837
2681
  },
2838
2682
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2839
2683
  status: zod.z.literal(200),
@@ -2853,7 +2697,7 @@ var Api = {
2853
2697
  cursor_updatedAt: onlyOneStringQueryParam.optional(),
2854
2698
  cursor_id: onlyOneStringQueryParam.optional()
2855
2699
  },
2856
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2700
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2857
2701
  },
2858
2702
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2859
2703
  status: zod.z.literal(200),
@@ -2891,7 +2735,7 @@ var Api = {
2891
2735
  isRemote: zod.z["boolean"]().optional()
2892
2736
  })).min(1)
2893
2737
  }),
2894
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2738
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2895
2739
  },
2896
2740
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2897
2741
  status: zod.z.literal(200),
@@ -2928,7 +2772,7 @@ var Api = {
2928
2772
  metadata: zod.z.any(),
2929
2773
  contentType: zod.z.string()
2930
2774
  }),
2931
- cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2775
+ cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2932
2776
  },
2933
2777
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2934
2778
  status: zod.z.literal(200),
@@ -2971,18 +2815,8 @@ var Api = {
2971
2815
  // `number` is allowed because the client stringifies every query value before it
2972
2816
  // goes on the URL (see createValClient), so a numeric param round-trips fine.
2973
2817
 
2974
- function _typeof(o) {
2975
- "@babel/helpers - typeof";
2976
-
2977
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
2978
- return typeof o;
2979
- } : function (o) {
2980
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
2981
- }, _typeof(o);
2982
- }
2983
-
2984
2818
  function getErrorMessageFromUnknownJson(json, fallback) {
2985
- if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
2819
+ if (getSitemapTree._typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
2986
2820
  return json.message;
2987
2821
  }
2988
2822
  return fallback;
@@ -3011,7 +2845,7 @@ var createValClient = function createValClient(host, config // We want to use th
3011
2845
  for (_i = 0, _Object$keys = Object.keys(anyReq.query); _i < _Object$keys.length; _i++) {
3012
2846
  key = _Object$keys[_i];
3013
2847
  if (Array.isArray((_anyReq$query = anyReq.query) === null || _anyReq$query === void 0 ? void 0 : _anyReq$query[key])) {
3014
- _iterator = _createForOfIteratorHelper(((_anyReq$query2 = anyReq.query) === null || _anyReq$query2 === void 0 ? void 0 : _anyReq$query2[key]) || []);
2848
+ _iterator = getSitemapTree._createForOfIteratorHelper(((_anyReq$query2 = anyReq.query) === null || _anyReq$query2 === void 0 ? void 0 : _anyReq$query2[key]) || []);
3015
2849
  try {
3016
2850
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3017
2851
  value = _step.value;
@@ -3252,7 +3086,7 @@ function _nonIterableRest() {
3252
3086
  }
3253
3087
 
3254
3088
  function _slicedToArray(r, e) {
3255
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
3089
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || getSitemapTree._unsupportedIterableToArray(r, e) || _nonIterableRest();
3256
3090
  }
3257
3091
 
3258
3092
  var urlOf = function urlOf() {
@@ -3300,7 +3134,7 @@ var compatible = {
3300
3134
  * predicate is that check, said once.
3301
3135
  */
3302
3136
  function isJsonObject(value) {
3303
- return _typeof(value) === "object" && value !== null && !Array.isArray(value);
3137
+ return getSitemapTree._typeof(value) === "object" && value !== null && !Array.isArray(value);
3304
3138
  }
3305
3139
  function incompatible(reason) {
3306
3140
  return {
@@ -3407,7 +3241,7 @@ function checkCompatibility(from, to) {
3407
3241
  // wholesale would refuse a restore that is perfectly safe.
3408
3242
  if (to.schema.type === "union") {
3409
3243
  var key = typeof to.schema.key === "string" ? to.schema.key : "";
3410
- var _iterator = _createForOfIteratorHelper(to.schema.items),
3244
+ var _iterator = getSitemapTree._createForOfIteratorHelper(to.schema.items),
3411
3245
  _step;
3412
3246
  try {
3413
3247
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -3541,7 +3375,7 @@ function checkCompatibility(from, to) {
3541
3375
  });
3542
3376
  }
3543
3377
  var _unknown = null;
3544
- var _iterator2 = _createForOfIteratorHelper(from.value),
3378
+ var _iterator2 = getSitemapTree._createForOfIteratorHelper(from.value),
3545
3379
  _step2;
3546
3380
  try {
3547
3381
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -3643,7 +3477,7 @@ function checkCompatibility(from, to) {
3643
3477
  function newestCommitSha(commits) {
3644
3478
  var _newest$commitSha, _newest;
3645
3479
  var newest = null;
3646
- var _iterator = _createForOfIteratorHelper(commits !== null && commits !== void 0 ? commits : []),
3480
+ var _iterator = getSitemapTree._createForOfIteratorHelper(commits !== null && commits !== void 0 ? commits : []),
3647
3481
  _step;
3648
3482
  try {
3649
3483
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -3660,10 +3494,6 @@ function newestCommitSha(commits) {
3660
3494
  return (_newest$commitSha = (_newest = newest) === null || _newest === void 0 ? void 0 : _newest.commitSha) !== null && _newest$commitSha !== void 0 ? _newest$commitSha : null;
3661
3495
  }
3662
3496
 
3663
- var VAL_CONFIG_SESSION_STORAGE_KEY = "val-config";
3664
- var VAL_THEME_SESSION_STORAGE_KEY = "val-theme";
3665
- var VAL_AI_SESSION_STORAGE_KEY = "val-ai-session";
3666
-
3667
3497
  var SharedValConfig = zod.z.object({
3668
3498
  contentHostUrl: zod.z.string().optional(),
3669
3499
  appHostUrl: zod.z.string().optional(),
@@ -3691,170 +3521,6 @@ var ValDeployment = zod.z.object({
3691
3521
  createdAt: zod.z.string()
3692
3522
  });
3693
3523
 
3694
- // Strictly speaking this should be in the next package but it's shared, because we want to use it in the ui package. We want to resolve that somehow
3695
- function getNextAppRouterSitemapTree(srcFolder, paths) {
3696
- var root = {
3697
- type: "node",
3698
- name: "/",
3699
- children: []
3700
- };
3701
- var _iterator = _createForOfIteratorHelper(paths),
3702
- _step;
3703
- try {
3704
- var _loop = function _loop() {
3705
- var path = _step.value;
3706
- var urlPath = path.urlPath,
3707
- moduleFilePathS = path.moduleFilePath;
3708
- var moduleFilePath = moduleFilePathS;
3709
- if (!urlPath.startsWith("/")) {
3710
- console.error("urlPath must start with /: ".concat(urlPath));
3711
- return 0; // continue
3712
- }
3713
- var pattern = getPatternFromModuleFilePath(moduleFilePath, srcFolder);
3714
- if (urlPath === "/") {
3715
- var fullPath = "/";
3716
- root.pattern = getPatternFromModuleFilePath(moduleFilePath, srcFolder);
3717
- root.page = {
3718
- fullPath: fullPath
3719
- };
3720
- root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
3721
- root.moduleFilePath = moduleFilePath;
3722
- return 0; // continue
3723
- }
3724
- var pathParts = urlPath.split("/").slice(1).filter(Boolean);
3725
- var currentNode = root;
3726
- pathParts.forEach(function (part, index) {
3727
- var hasChildren = index < pathParts.length - 1;
3728
- var isLast = index === pathParts.length - 1;
3729
- var fullPath = "/" + pathParts.slice(0, index + 1).join("/");
3730
- var sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
3731
- var node = hasChildren ? _objectSpread2(_objectSpread2({
3732
- type: "node",
3733
- name: part,
3734
- pattern: pattern,
3735
- moduleFilePath: moduleFilePath
3736
- }, isLast ? {
3737
- page: {
3738
- fullPath: fullPath
3739
- },
3740
- sourcePath: sourcePath
3741
- } : {}), {}, {
3742
- children: []
3743
- }) : {
3744
- type: "leaf",
3745
- name: part,
3746
- pattern: pattern,
3747
- fullPath: fullPath,
3748
- moduleFilePath: moduleFilePath,
3749
- sourcePath: sourcePath,
3750
- children: []
3751
- };
3752
- var existingNodeIndex = currentNode.children.findIndex(function (node) {
3753
- return node.name === part;
3754
- });
3755
- if (existingNodeIndex === -1) {
3756
- currentNode.children.push(node);
3757
- if (currentNode.type === "node") {
3758
- currentNode.isLinear = true;
3759
- if (currentNode.children.length > 1) {
3760
- delete currentNode.isLinear;
3761
- }
3762
- }
3763
- currentNode = node;
3764
- } else {
3765
- var existingNode = currentNode.children[existingNodeIndex];
3766
- if (existingNode.type === "leaf" && hasChildren) {
3767
- var _sourcePath = existingNode.sourcePath;
3768
- // convert leaf to node
3769
- currentNode.children[existingNodeIndex] = {
3770
- type: "node",
3771
- name: part,
3772
- pattern: pattern,
3773
- page: {
3774
- fullPath: fullPath
3775
- },
3776
- sourcePath: _sourcePath,
3777
- children: existingNode.children,
3778
- moduleFilePath: moduleFilePath
3779
- };
3780
- currentNode = currentNode.children[existingNodeIndex];
3781
- } else if (existingNode.type === "node" && isLast) {
3782
- // add page, source path and module file path
3783
- existingNode.page = {
3784
- fullPath: fullPath
3785
- };
3786
- existingNode.sourcePath = sourcePath;
3787
- existingNode.moduleFilePath = moduleFilePath;
3788
- existingNode.pattern = pattern;
3789
- } else {
3790
- currentNode = currentNode.children[existingNodeIndex];
3791
- }
3792
- }
3793
- });
3794
- },
3795
- _ret;
3796
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3797
- _ret = _loop();
3798
- if (_ret === 0) continue;
3799
- }
3800
- } catch (err) {
3801
- _iterator.e(err);
3802
- } finally {
3803
- _iterator.f();
3804
- }
3805
- return root;
3806
- }
3807
- function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
3808
- return moduleFilePath.replace(srcFolder, "")
3809
- // TODO: hacky!
3810
- // remove route groups
3811
- .replace(/\/\([^/]+\)/g, "") // not sure we want to do this?
3812
- .replace("/page.val.ts", "").replace("/page.val.js", "");
3813
- }
3814
-
3815
- function parseRoutePattern(pattern) {
3816
- if (pattern === "" || pattern === "/") {
3817
- return [];
3818
- }
3819
- var p = pattern.startsWith("/") ? pattern.slice(1) : pattern;
3820
- return p.split("/").map(function (part) {
3821
- var isOptionalParam = part.startsWith("[[") && part.endsWith("]]");
3822
- var isNonOptionalParam = part.startsWith("[") && part.endsWith("]");
3823
- var nameStart = isOptionalParam ? 2 : isNonOptionalParam ? 1 : 0;
3824
- var nameEnd = part.indexOf("]", nameStart);
3825
- var isArrayParam = part.slice(nameStart, nameStart + 3) === "...";
3826
- var paramName = part.slice(nameStart + (isArrayParam ? 3 : 0), nameEnd);
3827
- if (isOptionalParam || isNonOptionalParam) {
3828
- if (isArrayParam) {
3829
- return {
3830
- type: "array-param",
3831
- paramName: paramName,
3832
- optional: isOptionalParam
3833
- };
3834
- } else {
3835
- return {
3836
- type: "string-param",
3837
- paramName: paramName,
3838
- optional: isOptionalParam
3839
- };
3840
- }
3841
- }
3842
- return {
3843
- type: "literal",
3844
- name: part
3845
- };
3846
- });
3847
- }
3848
-
3849
- function getNextAppRouterSourceFolder(moduleFilePath) {
3850
- if (moduleFilePath.startsWith("/app")) {
3851
- return "/app";
3852
- } else if (moduleFilePath.startsWith("/src/app")) {
3853
- return "/src/app";
3854
- }
3855
- return null;
3856
- }
3857
-
3858
3524
  /**
3859
3525
  * Shared route validation utilities
3860
3526
  */
@@ -3968,7 +3634,7 @@ function getRoutesWithModulePaths(schemas, sources) {
3968
3634
  var moduleFilePath = moduleFilePathS;
3969
3635
  var schema = schemas[moduleFilePath];
3970
3636
  var source = sources[moduleFilePath];
3971
- if (schema && schema.type === "record" && schema.router && source && _typeof(source) === "object" && !Array.isArray(source)) {
3637
+ if (schema && schema.type === "record" && schema.router && source && getSitemapTree._typeof(source) === "object" && !Array.isArray(source)) {
3972
3638
  for (var key in source) {
3973
3639
  if (!routeMap.has(key)) {
3974
3640
  routeMap.set(key, moduleFilePath);
@@ -4052,12 +3718,12 @@ function getKeyOfRecordAt(sourcePath, snapshot) {
4052
3718
  // returns undefined source on any mismatch.
4053
3719
  var source = moduleSource;
4054
3720
  var schema = moduleSchema;
4055
- var _iterator = _createForOfIteratorHelper(core.Internal.splitModulePath(modulePath)),
3721
+ var _iterator = getSitemapTree._createForOfIteratorHelper(core.Internal.splitModulePath(modulePath)),
4056
3722
  _step;
4057
3723
  try {
4058
3724
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
4059
3725
  var part = _step.value;
4060
- if (source && _typeof(source) === "object" && !Array.isArray(source) && part in source) {
3726
+ if (source && getSitemapTree._typeof(source) === "object" && !Array.isArray(source) && part in source) {
4061
3727
  source = source[part];
4062
3728
  } else {
4063
3729
  source = undefined;
@@ -4090,12 +3756,12 @@ function checkKeyIsValid(key, sourcePath, snapshot) {
4090
3756
  message: "Expected key at ".concat(sourcePath, " to be of type 'record'")
4091
3757
  };
4092
3758
  }
4093
- if (keyOfModuleSource && _typeof(keyOfModuleSource) === "object" && !Array.isArray(keyOfModuleSource) && key in keyOfModuleSource) {
3759
+ if (keyOfModuleSource && getSitemapTree._typeof(keyOfModuleSource) === "object" && !Array.isArray(keyOfModuleSource) && key in keyOfModuleSource) {
4094
3760
  return {
4095
3761
  error: false
4096
3762
  };
4097
3763
  }
4098
- if (!keyOfModuleSource || _typeof(keyOfModuleSource) !== "object" || Array.isArray(keyOfModuleSource)) {
3764
+ if (!keyOfModuleSource || getSitemapTree._typeof(keyOfModuleSource) !== "object" || Array.isArray(keyOfModuleSource)) {
4099
3765
  return {
4100
3766
  error: true,
4101
3767
  message: "Expected ".concat(sourcePath, " to be a truthy object")
@@ -4122,7 +3788,7 @@ function checkRouteIsValid(route, includePattern, excludePattern, snapshot) {
4122
3788
  var schema = snapshot.schemas[moduleFilePath];
4123
3789
  if ((schema === null || schema === void 0 ? void 0 : schema.type) === "record" && schema.router) {
4124
3790
  var source = snapshot.sources[moduleFilePath];
4125
- if (source && _typeof(source) === "object" && !Array.isArray(source)) {
3791
+ if (source && getSitemapTree._typeof(source) === "object" && !Array.isArray(source)) {
4126
3792
  routerModules[moduleFilePath] = Object.keys(source);
4127
3793
  }
4128
3794
  }
@@ -4184,18 +3850,18 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4184
3850
  if (!error.value) {
4185
3851
  return {
4186
3852
  status: "remaining",
4187
- error: _objectSpread2(_objectSpread2({}, error), {}, {
3853
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
4188
3854
  message: "Could not find a value for keyOf. ".concat(TYPE_ERROR_MESSAGE),
4189
3855
  typeError: true,
4190
3856
  fixes: undefined
4191
3857
  })
4192
3858
  };
4193
3859
  }
4194
- if (_typeof(error.value) !== "object") {
3860
+ if (getSitemapTree._typeof(error.value) !== "object") {
4195
3861
  return {
4196
3862
  status: "remaining",
4197
- error: _objectSpread2(_objectSpread2({}, error), {}, {
4198
- message: "Expected keyOf validation error to have a 'value' property of type 'object'. Found: ".concat(_typeof(error.value), ". ").concat(TYPE_ERROR_MESSAGE),
3863
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
3864
+ message: "Expected keyOf validation error to have a 'value' property of type 'object'. Found: ".concat(getSitemapTree._typeof(error.value), ". ").concat(TYPE_ERROR_MESSAGE),
4199
3865
  typeError: true,
4200
3866
  fixes: undefined
4201
3867
  })
@@ -4207,8 +3873,8 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4207
3873
  if (typeof key !== "string") {
4208
3874
  return {
4209
3875
  status: "remaining",
4210
- error: _objectSpread2(_objectSpread2({}, error), {}, {
4211
- message: "Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ".concat(_typeof(key), ". ").concat(TYPE_ERROR_MESSAGE),
3876
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
3877
+ message: "Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ".concat(getSitemapTree._typeof(key), ". ").concat(TYPE_ERROR_MESSAGE),
4212
3878
  typeError: true,
4213
3879
  fixes: undefined
4214
3880
  })
@@ -4217,8 +3883,8 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4217
3883
  if (typeof valueSourcePath !== "string") {
4218
3884
  return {
4219
3885
  status: "remaining",
4220
- error: _objectSpread2(_objectSpread2({}, error), {}, {
4221
- message: "Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ".concat(_typeof(valueSourcePath), ". ").concat(TYPE_ERROR_MESSAGE),
3886
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
3887
+ message: "Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ".concat(getSitemapTree._typeof(valueSourcePath), ". ").concat(TYPE_ERROR_MESSAGE),
4222
3888
  typeError: true,
4223
3889
  fixes: undefined
4224
3890
  })
@@ -4228,7 +3894,7 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4228
3894
  if (res.error) {
4229
3895
  return {
4230
3896
  status: "remaining",
4231
- error: _objectSpread2(_objectSpread2({}, error), {}, {
3897
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
4232
3898
  message: res.message,
4233
3899
  fixes: undefined
4234
3900
  })
@@ -4242,18 +3908,18 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4242
3908
  if (!error.value) {
4243
3909
  return {
4244
3910
  status: "remaining",
4245
- error: _objectSpread2(_objectSpread2({}, error), {}, {
3911
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
4246
3912
  message: "Could not find a value for route. ".concat(TYPE_ERROR_MESSAGE),
4247
3913
  typeError: true,
4248
3914
  fixes: undefined
4249
3915
  })
4250
3916
  };
4251
3917
  }
4252
- if (_typeof(error.value) !== "object") {
3918
+ if (getSitemapTree._typeof(error.value) !== "object") {
4253
3919
  return {
4254
3920
  status: "remaining",
4255
- error: _objectSpread2(_objectSpread2({}, error), {}, {
4256
- message: "Expected route validation error to have a 'value' property of type 'object'. Found: ".concat(_typeof(error.value), ". ").concat(TYPE_ERROR_MESSAGE),
3921
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
3922
+ message: "Expected route validation error to have a 'value' property of type 'object'. Found: ".concat(getSitemapTree._typeof(error.value), ". ").concat(TYPE_ERROR_MESSAGE),
4257
3923
  typeError: true,
4258
3924
  fixes: undefined
4259
3925
  })
@@ -4264,8 +3930,8 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4264
3930
  if (typeof route !== "string") {
4265
3931
  return {
4266
3932
  status: "remaining",
4267
- error: _objectSpread2(_objectSpread2({}, error), {}, {
4268
- message: "Expected route validation error 'value' to have property 'route' of type 'string'. Found: ".concat(_typeof(route), ". ").concat(TYPE_ERROR_MESSAGE),
3933
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
3934
+ message: "Expected route validation error 'value' to have property 'route' of type 'string'. Found: ".concat(getSitemapTree._typeof(route), ". ").concat(TYPE_ERROR_MESSAGE),
4269
3935
  typeError: true,
4270
3936
  fixes: undefined
4271
3937
  })
@@ -4277,7 +3943,7 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4277
3943
  if (_res.error) {
4278
3944
  return {
4279
3945
  status: "remaining",
4280
- error: _objectSpread2(_objectSpread2({}, error), {}, {
3946
+ error: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, error), {}, {
4281
3947
  message: _res.message,
4282
3948
  fixes: undefined
4283
3949
  })
@@ -4290,7 +3956,7 @@ function resolveSchemaSourceFixForError(error, snapshot) {
4290
3956
  return null;
4291
3957
  }
4292
3958
  function asRegExpPattern(value) {
4293
- if (value && _typeof(value) === "object" && "source" in value && "flags" in value && typeof value.source === "string" && typeof value.flags === "string") {
3959
+ if (value && getSitemapTree._typeof(value) === "object" && "source" in value && "flags" in value && typeof value.source === "string" && typeof value.flags === "string") {
4294
3960
  return value;
4295
3961
  }
4296
3962
  return undefined;
@@ -4312,7 +3978,7 @@ function resolveSchemaSourceFixes(validationErrors, snapshot) {
4312
3978
  for (var sourcePathS in validationErrors) {
4313
3979
  var sourcePath = sourcePathS;
4314
3980
  var remaining = [];
4315
- var _iterator2 = _createForOfIteratorHelper(validationErrors[sourcePath]),
3981
+ var _iterator2 = getSitemapTree._createForOfIteratorHelper(validationErrors[sourcePath]),
4316
3982
  _step2;
4317
3983
  try {
4318
3984
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -4336,84 +4002,6 @@ function resolveSchemaSourceFixes(validationErrors, snapshot) {
4336
4002
  return result;
4337
4003
  }
4338
4004
 
4339
- /**
4340
- * The protocol between the studio's canvas and the page inside it.
4341
- *
4342
- * The canvas shows the running site in a frame. That frame is a different
4343
- * document — the customer's app, rendered by their components — so the studio
4344
- * cannot reach into it, and it cannot reach out. Everything they say to each
4345
- * other goes through `postMessage`, and this is the vocabulary.
4346
- *
4347
- * It lives in `shared` because both halves have to agree on it: the page half
4348
- * ships in `@valbuild/next`, the studio half in `@valbuild/ui`, and a message
4349
- * shape defined twice is a message shape that will differ once.
4350
- *
4351
- * ## Why a query parameter turns it on
4352
- *
4353
- * The frame has to render the page as Val sees it — draft content, with
4354
- * `data-val-path` on every element Val tracks — while *not* showing Val's own
4355
- * overlay, because the studio is already the UI. Nothing about the cookies can
4356
- * express that: they are per-origin, and the studio and the page share an
4357
- * origin, so a cookie would change the customer's own tabs too. A parameter on
4358
- * the frame's URL is scoped to exactly the one document that needs it.
4359
- */
4360
-
4361
- /** Marks a page load as the studio's canvas frame. */
4362
- var VAL_CANVAS_PARAM = "val_canvas";
4363
-
4364
- /**
4365
- * Every message is tagged with this, and the tag is checked on receipt.
4366
- *
4367
- * A window receives messages from anything that has a handle on it —
4368
- * extensions, embeds, other frames — and `event.data` is whatever they chose to
4369
- * send. Checking a discriminator before reading anything else is what keeps a
4370
- * stray message from being read as a canvas instruction.
4371
- */
4372
- var VAL_CANVAS_MESSAGE = "val-canvas";
4373
-
4374
- /** One element on the page that Val has a path for. */
4375
-
4376
- /** What the page tells the studio. */
4377
-
4378
- /** What the studio tells the page. */
4379
-
4380
- /** Narrow an unknown `event.data` to a message from the page. */
4381
- function isValCanvasPageMessage(data) {
4382
- if (_typeof(data) !== "object" || data === null) return false;
4383
- var message = data;
4384
- if (message.val !== VAL_CANVAS_MESSAGE) return false;
4385
- return message.type === "ready" || message.type === "elements" || message.type === "clicked" || message.type === "pinch" || message.type === "zoom" || message.type === "refreshing";
4386
- }
4387
-
4388
- /** Narrow an unknown `event.data` to a message from the studio. */
4389
- function isValCanvasStudioMessage(data) {
4390
- if (_typeof(data) !== "object" || data === null) return false;
4391
- var message = data;
4392
- if (message.val !== VAL_CANVAS_MESSAGE) return false;
4393
- return message.type === "rescan" || message.type === "highlight" || message.type === "setPicking" || message.type === "sourceUpdate" || message.type === "sourcesSynced";
4394
- }
4395
-
4396
- /**
4397
- * Whether this document was loaded as the studio's canvas frame.
4398
- *
4399
- * Reads the location directly rather than taking it as an argument, because
4400
- * every caller wants the answer for the document it is running in, and passing
4401
- * it around is how one of them ends up asking about the wrong one.
4402
- */
4403
- function isValCanvasFrame(search) {
4404
- try {
4405
- return new URLSearchParams(search).get(VAL_CANVAS_PARAM) !== null;
4406
- } catch (_unused) {
4407
- return false;
4408
- }
4409
- }
4410
-
4411
- /** Add the canvas marker to a page URL. */
4412
- function withValCanvasParam(url) {
4413
- var separator = url.includes("?") ? "&" : "?";
4414
- return "".concat(url).concat(separator).concat(VAL_CANVAS_PARAM, "=1");
4415
- }
4416
-
4417
4005
  /**
4418
4006
  * Local `yyyy-MM-dd`, which is the one thing this module used `date-fns` for.
4419
4007
  *
@@ -4514,13 +4102,13 @@ function emptyOf(schema) {
4514
4102
  var toolNames = ["get_all_schema", "get_source", "search_content", "validate_content", "create_patch", "add_session_image_to_gallery", "remove_image_gallery_entry", "navigate_to", "get_current_context", "get_patches", "get_source_path_from_route", "set_session_name", "show_compare_view", "ask_user_question", "duplicate_source", "empty_at_path", "count_entries", "get_record_keys"];
4515
4103
 
4516
4104
  function buildFileRefValue(filePath, metadata) {
4517
- return _objectSpread2({
4105
+ return getSitemapTree._objectSpread2({
4518
4106
  path: filePath
4519
4107
  }, metadata);
4520
4108
  }
4521
4109
  function getSourceAt(source, path) {
4522
4110
  var current = source;
4523
- var _iterator = _createForOfIteratorHelper(path),
4111
+ var _iterator = getSitemapTree._createForOfIteratorHelper(path),
4524
4112
  _step;
4525
4113
  try {
4526
4114
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -4530,7 +4118,7 @@ function getSourceAt(source, path) {
4530
4118
  var idx = Number(part);
4531
4119
  if (!Number.isInteger(idx)) return undefined;
4532
4120
  current = current[idx];
4533
- } else if (_typeof(current) === "object") {
4121
+ } else if (getSitemapTree._typeof(current) === "object") {
4534
4122
  current = current[part];
4535
4123
  } else {
4536
4124
  return undefined;
@@ -4580,7 +4168,7 @@ function resolveSerializedSchemaAtPath(schema, path) {
4580
4168
  };
4581
4169
  } else if (current.type === "union") {
4582
4170
  if (typeof current.key === "string") {
4583
- var _iterator2 = _createForOfIteratorHelper(current.items),
4171
+ var _iterator2 = getSitemapTree._createForOfIteratorHelper(current.items),
4584
4172
  _step2;
4585
4173
  try {
4586
4174
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -4682,7 +4270,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
4682
4270
  var patch = [{
4683
4271
  op: "add",
4684
4272
  path: [args.filePath],
4685
- value: _objectSpread2(_objectSpread2({}, args.metadata), {}, {
4273
+ value: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, args.metadata), {}, {
4686
4274
  // `alt` is a REQUIRED field of a gallery entry (`s.images()` gives it a
4687
4275
  // nullable string schema), so an entry written without one is invalid
4688
4276
  // the moment it lands — and the caller that had no alt to give is the
@@ -4703,7 +4291,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
4703
4291
  function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
4704
4292
  var wrong = checkGallerySchema(moduleSchema);
4705
4293
  if (wrong) return wrong;
4706
- if (!moduleSource || _typeof(moduleSource) !== "object" || Array.isArray(moduleSource)) {
4294
+ if (!moduleSource || getSitemapTree._typeof(moduleSource) !== "object" || Array.isArray(moduleSource)) {
4707
4295
  return {
4708
4296
  kind: "error",
4709
4297
  message: "Cannot remove from gallery: module source is not an object."
@@ -5025,11 +4613,11 @@ function describeContainerAtPath(moduleSchema, moduleSource, path) {
5025
4613
  };
5026
4614
  }
5027
4615
  if (schema.type === "record" || schema.type === "object") {
5028
- if (value === null || _typeof(value) !== "object" || Array.isArray(value)) {
4616
+ if (value === null || getSitemapTree._typeof(value) !== "object" || Array.isArray(value)) {
5029
4617
  return {
5030
4618
  kind: "error",
5031
4619
  reason: "not-a-container",
5032
- message: "Path ".concat(JSON.stringify(path), " points to a ").concat(value === null ? "null" : Array.isArray(value) ? "array" : _typeof(value), " value, which has no entries to count or list.")
4620
+ message: "Path ".concat(JSON.stringify(path), " points to a ").concat(value === null ? "null" : Array.isArray(value) ? "array" : getSitemapTree._typeof(value), " value, which has no entries to count or list.")
5033
4621
  };
5034
4622
  }
5035
4623
  return {
@@ -5074,7 +4662,7 @@ function partitionValidationErrors(validationErrors) {
5074
4662
  var skipped = {};
5075
4663
  for (var sourcePathS in validationErrors) {
5076
4664
  var sourcePath = sourcePathS;
5077
- var _iterator = _createForOfIteratorHelper(validationErrors[sourcePath]),
4665
+ var _iterator = getSitemapTree._createForOfIteratorHelper(validationErrors[sourcePath]),
5078
4666
  _step;
5079
4667
  try {
5080
4668
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -5444,7 +5032,7 @@ function traverseSchemaSource(source, schema, path, callback) {
5444
5032
 
5445
5033
  // Handle file/image
5446
5034
  if (schema.type === "file" || schema.type === "image") {
5447
- if (source && _typeof(source) === "object" && "path" in source && typeof source.path === "string") {
5035
+ if (source && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
5448
5036
  callback({
5449
5037
  source: source,
5450
5038
  schema: schema,
@@ -5556,7 +5144,7 @@ function traverseSchemaSource(source, schema, path, callback) {
5556
5144
  // Settings walks like an object, and starting from the SOURCE is what makes
5557
5145
  // its optional keys work: an absent section has nothing to traverse.
5558
5146
  schema.type === "settings") {
5559
- if (_typeof(source) !== "object" || source === null || Array.isArray(source)) {
5147
+ if (getSitemapTree._typeof(source) !== "object" || source === null || Array.isArray(source)) {
5560
5148
  return;
5561
5149
  }
5562
5150
  for (var key in source) {
@@ -5576,7 +5164,7 @@ function traverseSchemaSource(source, schema, path, callback) {
5576
5164
  var schemaKey = schema.key;
5577
5165
  if (typeof schemaKey === "string") {
5578
5166
  // Tagged union - find matching sub-schema
5579
- if (source && _typeof(source) === "object" && !Array.isArray(source) && schemaKey in source) {
5167
+ if (source && getSitemapTree._typeof(source) === "object" && !Array.isArray(source) && schemaKey in source) {
5580
5168
  var itemKey = source[schemaKey];
5581
5169
  if (typeof itemKey === "string") {
5582
5170
  var schemaOfItem = schema.items.filter(function (item) {
@@ -5621,8 +5209,8 @@ function flattenRichText(source) {
5621
5209
  if (typeof child === "string") {
5622
5210
  res += child;
5623
5211
  } else {
5624
- if (child && _typeof(child) === "object" && "children" in child && Array.isArray(child.children)) {
5625
- var _iterator = _createForOfIteratorHelper(child.children),
5212
+ if (child && getSitemapTree._typeof(child) === "object" && "children" in child && Array.isArray(child.children)) {
5213
+ var _iterator = getSitemapTree._createForOfIteratorHelper(child.children),
5626
5214
  _step;
5627
5215
  try {
5628
5216
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -5694,6 +5282,28 @@ function getRefParts(ref) {
5694
5282
  * them — an agent and an editor searching the same project should find the same
5695
5283
  * things.
5696
5284
  */
5285
+ /**
5286
+ * The parts of FlexSearch's `Index` this module uses.
5287
+ *
5288
+ * Structural, rather than importing flexsearch's own `Index`, because
5289
+ * {@link SearchIndex} is EXPORTED — and a `.d.ts` that names `flexsearch` pulls
5290
+ * that package's `declare module "flexsearch"` into every consumer's TypeScript
5291
+ * program. Ambient module declarations are global to a program, so a consumer
5292
+ * with its own flexsearch at another version then checks its OWN calls against
5293
+ * the copy we dragged in, whichever of the two wins.
5294
+ *
5295
+ * That is not hypothetical: `@valbuild/shared` gained a flexsearch dependency
5296
+ * in 0.123.0 for `search_content`, and valbuild/web — which pins flexsearch
5297
+ * 0.7 and calls `new flexsearch.Document({ language: "en", … })` — stopped
5298
+ * building on 0.123.2, because 0.8's `DocumentOptions` has no `language`. Its
5299
+ * own resolved copy was still 0.7; only the types had been replaced.
5300
+ *
5301
+ * Three methods is all this module calls, and none of their signatures here is
5302
+ * a guess: `add` and `remove` are used in `indexModule`/`removeModule`, and
5303
+ * `search`'s result is only ever `.length`-ed, `.slice`-d and mapped over as
5304
+ * ids. `FlexSearch.Index` is still constructed with the real library in
5305
+ * {@link createSearchIndex} — a value import, which does not reach the `.d.ts`.
5306
+ */
5697
5307
 
5698
5308
  /** An index with nothing in it. Fill it with {@link indexModule}. */
5699
5309
  function createSearchIndex() {
@@ -5754,7 +5364,7 @@ function indexModule(searchIndex, moduleFilePath, source, schema) {
5754
5364
  }
5755
5365
  // Handle file/image
5756
5366
  else if (schema.type === "file" || schema.type === "image") {
5757
- if (source !== null && _typeof(source) === "object" && "path" in source && typeof source.path === "string") {
5367
+ if (source !== null && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
5758
5368
  // The label is the bare filename - the folder is shown separately in
5759
5369
  // the UI - but both are searchable.
5760
5370
  var _getRefParts = getRefParts(source.path),
@@ -5791,13 +5401,13 @@ function removeModule(searchIndex, moduleFilePath) {
5791
5401
  docsByModule = searchIndex.docsByModule;
5792
5402
  var existing = docsByModule.get(moduleFilePath);
5793
5403
  if (existing === undefined) return;
5794
- var _iterator = _createForOfIteratorHelper(existing),
5404
+ var _iterator = getSitemapTree._createForOfIteratorHelper(existing),
5795
5405
  _step;
5796
5406
  try {
5797
5407
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
5798
- var id = _step.value;
5799
- index.remove(id);
5800
- pathToLabel["delete"](id);
5408
+ var _id = _step.value;
5409
+ index.remove(_id);
5410
+ pathToLabel["delete"](_id);
5801
5411
  }
5802
5412
  } catch (err) {
5803
5413
  _iterator.e(err);
@@ -5879,6 +5489,19 @@ function performSearch(searchIndex, query) {
5879
5489
  };
5880
5490
  }
5881
5491
 
5492
+ exports.VAL_AI_SESSION_STORAGE_KEY = getSitemapTree.VAL_AI_SESSION_STORAGE_KEY;
5493
+ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
5494
+ exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
5495
+ exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
5496
+ exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
5497
+ exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
5498
+ exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
5499
+ exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
5500
+ exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
5501
+ exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
5502
+ exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
5503
+ exports.parseRoutePattern = getSitemapTree.parseRoutePattern;
5504
+ exports.withValCanvasParam = getSitemapTree.withValCanvasParam;
5882
5505
  exports.Api = Api;
5883
5506
  exports.BinaryFileRef = BinaryFileRef;
5884
5507
  exports.CodeOptions = CodeOptions;
@@ -5937,14 +5560,9 @@ exports.SerializedSettingsSchema = SerializedSettingsSchema;
5937
5560
  exports.SerializedStringSchema = SerializedStringSchema;
5938
5561
  exports.SerializedUnionSchema = SerializedUnionSchema;
5939
5562
  exports.SharedValConfig = SharedValConfig;
5940
- exports.VAL_AI_SESSION_STORAGE_KEY = VAL_AI_SESSION_STORAGE_KEY;
5941
- exports.VAL_CANVAS_MESSAGE = VAL_CANVAS_MESSAGE;
5942
- exports.VAL_CANVAS_PARAM = VAL_CANVAS_PARAM;
5943
- exports.VAL_CONFIG_SESSION_STORAGE_KEY = VAL_CONFIG_SESSION_STORAGE_KEY;
5944
5563
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
5945
5564
  exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
5946
5565
  exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
5947
- exports.VAL_THEME_SESSION_STORAGE_KEY = VAL_THEME_SESSION_STORAGE_KEY;
5948
5566
  exports.ValCommit = ValCommit;
5949
5567
  exports.ValDeployment = ValDeployment;
5950
5568
  exports.buildDuplicatePatch = buildDuplicatePatch;
@@ -5970,9 +5588,6 @@ exports.flattenRichText = flattenRichText;
5970
5588
  exports.getErrorMessageFromUnknownJson = getErrorMessageFromUnknownJson;
5971
5589
  exports.getFilenameFromRef = getFilenameFromRef;
5972
5590
  exports.getInlineImgInfo = getInlineImgInfo;
5973
- exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
5974
- exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
5975
- exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
5976
5591
  exports.getRefParts = getRefParts;
5977
5592
  exports.getRoutesOf = getRoutesOf;
5978
5593
  exports.getRoutesWithModulePaths = getRoutesWithModulePaths;
@@ -5981,12 +5596,8 @@ exports.indexModule = indexModule;
5981
5596
  exports.isMimeTypeAccepted = isMimeTypeAccepted;
5982
5597
  exports.isRemoteSchema = isRemoteSchema;
5983
5598
  exports.isSkippedSource = isSkippedSource;
5984
- exports.isValCanvasFrame = isValCanvasFrame;
5985
- exports.isValCanvasPageMessage = isValCanvasPageMessage;
5986
- exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
5987
5599
  exports.levenshtein = levenshtein;
5988
5600
  exports.newestCommitSha = newestCommitSha;
5989
- exports.parseRoutePattern = parseRoutePattern;
5990
5601
  exports.partitionValidationErrors = partitionValidationErrors;
5991
5602
  exports.performSearch = performSearch;
5992
5603
  exports.remirrorToRichTextSource = remirrorToRichTextSource;
@@ -6003,4 +5614,3 @@ exports.traverseSchemaSource = traverseSchemaSource;
6003
5614
  exports.urlOf = urlOf;
6004
5615
  exports.validateRoutePatterns = validateRoutePatterns;
6005
5616
  exports.withExtension = withExtension;
6006
- exports.withValCanvasParam = withValCanvasParam;