@valbuild/shared 0.127.0 → 0.128.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.128.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`8b52b33`](https://github.com/valbuild/val/commit/8b52b33e1f629f14f66cc71dcc7cf415d210c7d4), [`362fb49`](https://github.com/valbuild/val/commit/362fb49f30d2b04c4ff78d54dca2bf5ad978a05c), [`c595799`](https://github.com/valbuild/val/commit/c59579977a436ec530c6c69f2b340ab9829d97ab)]:
8
+ - @valbuild/core@0.128.0
9
+
3
10
  ## 0.127.0
4
11
 
5
12
  ### Minor Changes
@@ -1,2 +1,2 @@
1
- export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
1
+ export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-6777bdfa.esm.js';
2
2
  import '@valbuild/core';
@@ -40,7 +40,7 @@ export type ResolveResult = {
40
40
  * Walks `schema` along `path`, returning a structured result:
41
41
  * - `leaf`: walked the full path; resolved schema at the end.
42
42
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
43
- * - `gallery-traversed`: hit an `s.images()` record and walked past it (i.e. the
43
+ * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
44
44
  * path tries to address an entry inside the gallery — a clue the AI should
45
45
  * have used the gallery tool instead).
46
46
  * - `unresolved`: the path could not be walked.
@@ -14,8 +14,8 @@ export declare const ImageEncodeOption: z.ZodUnion<readonly [z.ZodLiteral<false>
14
14
  maxWidth: z.ZodOptional<z.ZodNumber>;
15
15
  maxHeight: z.ZodOptional<z.ZodNumber>;
16
16
  }, z.core.$strip>]>;
17
- export declare const ImageOptions: z.ZodObject<{
18
- directory: z.ZodOptional<z.ZodString>;
17
+ export declare const ImageOptions: z.ZodPreprocess<z.ZodObject<{
18
+ dir: z.ZodOptional<z.ZodString>;
19
19
  accept: z.ZodOptional<z.ZodString>;
20
20
  encode: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
21
21
  type: z.ZodLiteral<"webp">;
@@ -23,7 +23,7 @@ export declare const ImageOptions: z.ZodObject<{
23
23
  maxWidth: z.ZodOptional<z.ZodNumber>;
24
24
  maxHeight: z.ZodOptional<z.ZodNumber>;
25
25
  }, z.core.$strip>]>>;
26
- }, z.core.$strip>;
26
+ }, z.core.$strip>>;
27
27
  export declare const SerializedImageSchema: z.ZodType<SerializedImageSchemaT>;
28
28
  export declare const RichTextOptions: z.ZodType<SerializedRichTextOptionsT>;
29
29
  export declare const SerializedRichTextSchema: z.ZodType<SerializedRichTextSchemaT>;
@@ -428,4 +428,4 @@ function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
428
428
  .replace("/page.val.ts", "").replace("/page.val.js", "");
429
429
  }
430
430
 
431
- export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g, getTanStackRouterSourceFolder as h, isValCanvasPageMessage as i, getPageRouterSourceFolder as j, isTanStackRoutesFolder as k, getPageRouterSitemapTree as l, getPatternFromModuleFilePath as m, _objectSpread2 as n, _arrayLikeToArray as o, parseRoutePattern as p, _unsupportedIterableToArray as q, _defineProperty as r, _typeof as s, withValCanvasParam as w };
431
+ export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g, getTanStackRouterSourceFolder as h, isValCanvasPageMessage as i, getPageRouterSourceFolder as j, isTanStackRoutesFolder as k, getPageRouterSitemapTree as l, getPatternFromModuleFilePath as m, _objectSpread2 as n, _arrayLikeToArray as o, parseRoutePattern as p, _unsupportedIterableToArray as q, _typeof as r, _defineProperty as s, withValCanvasParam as w };
@@ -897,10 +897,34 @@ var PatchBlock = zod.z.object({
897
897
  parentRef: ParentRef$1
898
898
  });
899
899
 
900
+ function _objectWithoutPropertiesLoose(r, e) {
901
+ if (null == r) return {};
902
+ var t = {};
903
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
904
+ if (-1 !== e.indexOf(n)) continue;
905
+ t[n] = r[n];
906
+ }
907
+ return t;
908
+ }
909
+
910
+ function _objectWithoutProperties(e, t) {
911
+ if (null == e) return {};
912
+ var o,
913
+ r,
914
+ i = _objectWithoutPropertiesLoose(e, t);
915
+ if (Object.getOwnPropertySymbols) {
916
+ var n = Object.getOwnPropertySymbols(e);
917
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
918
+ }
919
+ return i;
920
+ }
921
+
900
922
  var SourcePath = zod.z.string().transform(function (path) {
901
923
  return path;
902
924
  });
903
925
 
926
+ var _excluded = ["directory"];
927
+
904
928
  // A render is static config, so unlike a `preview` it travels WHOLE — this
905
929
  // is the field the editor reads the layout from. See `core/src/render.ts`.
906
930
  // Every field can carry `{ as: "inline" }`, and that is all a render says.
@@ -1008,11 +1032,35 @@ var ImageEncodeOption = zod.z.union([zod.z.literal(false), zod.z.object({
1008
1032
  maxWidth: zod.z.number().optional(),
1009
1033
  maxHeight: zod.z.number().optional()
1010
1034
  })]);
1011
- var ImageOptions = zod.z.object({
1012
- directory: zod.z.string().optional(),
1035
+ /**
1036
+ * Accept the pre-rename `directory` key and read it as `dir`.
1037
+ *
1038
+ * Serialized schemas are not only computed from live code: a commit record
1039
+ * stores the schema each module was under (`StoredModuleVersion`), and the
1040
+ * history view parses those back. Commits made before `directory` became `dir`
1041
+ * therefore still carry the old key, and dropping it would show a historical
1042
+ * gallery with no directory at all — silently, since the rest of the schema
1043
+ * parses fine.
1044
+ *
1045
+ * Only fills `dir` when it is absent, so a schema carrying both (which should
1046
+ * not happen) keeps the current key.
1047
+ */
1048
+ var readLegacyDirectoryAsDir = function readLegacyDirectoryAsDir(value) {
1049
+ if (!value || getSitemapTree._typeof(value) !== "object" || Array.isArray(value) || !("directory" in value) || "dir" in value) {
1050
+ return value;
1051
+ }
1052
+ var _ref = value,
1053
+ directory = _ref.directory,
1054
+ rest = _objectWithoutProperties(_ref, _excluded);
1055
+ return getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, rest), {}, {
1056
+ dir: directory
1057
+ });
1058
+ };
1059
+ var ImageOptions = zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object({
1060
+ dir: zod.z.string().optional(),
1013
1061
  accept: zod.z.string().optional(),
1014
1062
  encode: ImageEncodeOption.optional()
1015
- });
1063
+ }));
1016
1064
  var SerializedImageSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1017
1065
  type: zod.z.literal("image"),
1018
1066
  options: ImageOptions.optional(),
@@ -1051,7 +1099,7 @@ var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSit
1051
1099
  opt: zod.z["boolean"]()
1052
1100
  }));
1053
1101
  var SerializedRecordSchema = zod.z.lazy(function () {
1054
- return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1102
+ return zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1055
1103
  type: zod.z.literal("record"),
1056
1104
  item: SerializedSchema,
1057
1105
  opt: zod.z["boolean"](),
@@ -1059,12 +1107,12 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1059
1107
  mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images")]).optional(),
1060
1108
  // Optional legacy gallery metadata
1061
1109
  accept: zod.z.string().optional(),
1062
- directory: zod.z.string().optional(),
1110
+ dir: zod.z.string().optional(),
1063
1111
  remote: zod.z["boolean"]().optional(),
1064
1112
  encode: ImageEncodeOption.optional(),
1065
1113
  alt: SerializedSchema.optional(),
1066
1114
  moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
1067
- })).passthrough();
1115
+ })).passthrough());
1068
1116
  });
1069
1117
  var SerializedKeyOfSchema = zod.z.lazy(function () {
1070
1118
  return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
@@ -4704,7 +4752,7 @@ function getSourceAt(source, path) {
4704
4752
  * Walks `schema` along `path`, returning a structured result:
4705
4753
  * - `leaf`: walked the full path; resolved schema at the end.
4706
4754
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
4707
- * - `gallery-traversed`: hit an `s.images()` record and walked past it (i.e. the
4755
+ * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
4708
4756
  * path tries to address an entry inside the gallery — a clue the AI should
4709
4757
  * have used the gallery tool instead).
4710
4758
  * - `unresolved`: the path could not be walked.
@@ -4835,7 +4883,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
4835
4883
  op: "add",
4836
4884
  path: [args.filePath],
4837
4885
  value: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, args.metadata), {}, {
4838
- // `alt` is a REQUIRED field of a gallery entry (`s.images()` gives it a
4886
+ // `alt` is a REQUIRED field of a gallery entry (`s.imageset()` gives it a
4839
4887
  // nullable string schema), so an entry written without one is invalid
4840
4888
  // the moment it lands — and the caller that had no alt to give is the
4841
4889
  // common case, not the odd one. Null is what the Studio's own upload
@@ -4898,10 +4946,10 @@ function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
4898
4946
  var GALLERY_REDIRECT = {
4899
4947
  kind: "wrong-tool",
4900
4948
  suggestedTool: "add_session_image_to_gallery",
4901
- reason: "Destination is a media gallery (s.images() / s.files()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4949
+ reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4902
4950
  };
4903
4951
 
4904
- /** An `s.images()` / `s.files()` record: a gallery, not an ordinary record. */
4952
+ /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
4905
4953
  function isGallery(schema) {
4906
4954
  return schema.type === "record" && schema.mediaType !== undefined;
4907
4955
  }
@@ -897,10 +897,34 @@ var PatchBlock = zod.z.object({
897
897
  parentRef: ParentRef$1
898
898
  });
899
899
 
900
+ function _objectWithoutPropertiesLoose(r, e) {
901
+ if (null == r) return {};
902
+ var t = {};
903
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
904
+ if (-1 !== e.indexOf(n)) continue;
905
+ t[n] = r[n];
906
+ }
907
+ return t;
908
+ }
909
+
910
+ function _objectWithoutProperties(e, t) {
911
+ if (null == e) return {};
912
+ var o,
913
+ r,
914
+ i = _objectWithoutPropertiesLoose(e, t);
915
+ if (Object.getOwnPropertySymbols) {
916
+ var n = Object.getOwnPropertySymbols(e);
917
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
918
+ }
919
+ return i;
920
+ }
921
+
900
922
  var SourcePath = zod.z.string().transform(function (path) {
901
923
  return path;
902
924
  });
903
925
 
926
+ var _excluded = ["directory"];
927
+
904
928
  // A render is static config, so unlike a `preview` it travels WHOLE — this
905
929
  // is the field the editor reads the layout from. See `core/src/render.ts`.
906
930
  // Every field can carry `{ as: "inline" }`, and that is all a render says.
@@ -1008,11 +1032,35 @@ var ImageEncodeOption = zod.z.union([zod.z.literal(false), zod.z.object({
1008
1032
  maxWidth: zod.z.number().optional(),
1009
1033
  maxHeight: zod.z.number().optional()
1010
1034
  })]);
1011
- var ImageOptions = zod.z.object({
1012
- directory: zod.z.string().optional(),
1035
+ /**
1036
+ * Accept the pre-rename `directory` key and read it as `dir`.
1037
+ *
1038
+ * Serialized schemas are not only computed from live code: a commit record
1039
+ * stores the schema each module was under (`StoredModuleVersion`), and the
1040
+ * history view parses those back. Commits made before `directory` became `dir`
1041
+ * therefore still carry the old key, and dropping it would show a historical
1042
+ * gallery with no directory at all — silently, since the rest of the schema
1043
+ * parses fine.
1044
+ *
1045
+ * Only fills `dir` when it is absent, so a schema carrying both (which should
1046
+ * not happen) keeps the current key.
1047
+ */
1048
+ var readLegacyDirectoryAsDir = function readLegacyDirectoryAsDir(value) {
1049
+ if (!value || getSitemapTree._typeof(value) !== "object" || Array.isArray(value) || !("directory" in value) || "dir" in value) {
1050
+ return value;
1051
+ }
1052
+ var _ref = value,
1053
+ directory = _ref.directory,
1054
+ rest = _objectWithoutProperties(_ref, _excluded);
1055
+ return getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, rest), {}, {
1056
+ dir: directory
1057
+ });
1058
+ };
1059
+ var ImageOptions = zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object({
1060
+ dir: zod.z.string().optional(),
1013
1061
  accept: zod.z.string().optional(),
1014
1062
  encode: ImageEncodeOption.optional()
1015
- });
1063
+ }));
1016
1064
  var SerializedImageSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1017
1065
  type: zod.z.literal("image"),
1018
1066
  options: ImageOptions.optional(),
@@ -1051,7 +1099,7 @@ var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSit
1051
1099
  opt: zod.z["boolean"]()
1052
1100
  }));
1053
1101
  var SerializedRecordSchema = zod.z.lazy(function () {
1054
- return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1102
+ return zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1055
1103
  type: zod.z.literal("record"),
1056
1104
  item: SerializedSchema,
1057
1105
  opt: zod.z["boolean"](),
@@ -1059,12 +1107,12 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1059
1107
  mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images")]).optional(),
1060
1108
  // Optional legacy gallery metadata
1061
1109
  accept: zod.z.string().optional(),
1062
- directory: zod.z.string().optional(),
1110
+ dir: zod.z.string().optional(),
1063
1111
  remote: zod.z["boolean"]().optional(),
1064
1112
  encode: ImageEncodeOption.optional(),
1065
1113
  alt: SerializedSchema.optional(),
1066
1114
  moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
1067
- })).passthrough();
1115
+ })).passthrough());
1068
1116
  });
1069
1117
  var SerializedKeyOfSchema = zod.z.lazy(function () {
1070
1118
  return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
@@ -4704,7 +4752,7 @@ function getSourceAt(source, path) {
4704
4752
  * Walks `schema` along `path`, returning a structured result:
4705
4753
  * - `leaf`: walked the full path; resolved schema at the end.
4706
4754
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
4707
- * - `gallery-traversed`: hit an `s.images()` record and walked past it (i.e. the
4755
+ * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
4708
4756
  * path tries to address an entry inside the gallery — a clue the AI should
4709
4757
  * have used the gallery tool instead).
4710
4758
  * - `unresolved`: the path could not be walked.
@@ -4835,7 +4883,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
4835
4883
  op: "add",
4836
4884
  path: [args.filePath],
4837
4885
  value: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, args.metadata), {}, {
4838
- // `alt` is a REQUIRED field of a gallery entry (`s.images()` gives it a
4886
+ // `alt` is a REQUIRED field of a gallery entry (`s.imageset()` gives it a
4839
4887
  // nullable string schema), so an entry written without one is invalid
4840
4888
  // the moment it lands — and the caller that had no alt to give is the
4841
4889
  // common case, not the odd one. Null is what the Studio's own upload
@@ -4898,10 +4946,10 @@ function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
4898
4946
  var GALLERY_REDIRECT = {
4899
4947
  kind: "wrong-tool",
4900
4948
  suggestedTool: "add_session_image_to_gallery",
4901
- reason: "Destination is a media gallery (s.images() / s.files()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4949
+ reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4902
4950
  };
4903
4951
 
4904
- /** An `s.images()` / `s.files()` record: a gallery, not an ordinary record. */
4952
+ /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
4905
4953
  function isGallery(schema) {
4906
4954
  return schema.type === "record" && schema.mediaType !== undefined;
4907
4955
  }
@@ -1,6 +1,6 @@
1
1
  import { Internal, CODE_LANGUAGES, resolveSettingsModule, missingDeclaredKeys, localeOfValue, discriminatedUnionBranchOf, DEFAULT_COLOR_FORMAT, declaredKeySetOf } from '@valbuild/core';
2
- import { _ as _createForOfIteratorHelper, n as _objectSpread2, o as _arrayLikeToArray, q as _unsupportedIterableToArray, r as _defineProperty, s as _typeof } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
3
- export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
2
+ import { _ as _createForOfIteratorHelper, n as _objectSpread2, o as _arrayLikeToArray, q as _unsupportedIterableToArray, r as _typeof, s as _defineProperty } from '../../dist/getSitemapTree-6777bdfa.esm.js';
3
+ export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-6777bdfa.esm.js';
4
4
  import { z } from 'zod';
5
5
  import { fromError } from 'zod-validation-error';
6
6
  import FlexSearch from 'flexsearch';
@@ -890,10 +890,34 @@ var PatchBlock = z.object({
890
890
  parentRef: ParentRef$1
891
891
  });
892
892
 
893
+ function _objectWithoutPropertiesLoose(r, e) {
894
+ if (null == r) return {};
895
+ var t = {};
896
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
897
+ if (-1 !== e.indexOf(n)) continue;
898
+ t[n] = r[n];
899
+ }
900
+ return t;
901
+ }
902
+
903
+ function _objectWithoutProperties(e, t) {
904
+ if (null == e) return {};
905
+ var o,
906
+ r,
907
+ i = _objectWithoutPropertiesLoose(e, t);
908
+ if (Object.getOwnPropertySymbols) {
909
+ var n = Object.getOwnPropertySymbols(e);
910
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
911
+ }
912
+ return i;
913
+ }
914
+
893
915
  var SourcePath = z.string().transform(function (path) {
894
916
  return path;
895
917
  });
896
918
 
919
+ var _excluded = ["directory"];
920
+
897
921
  // A render is static config, so unlike a `preview` it travels WHOLE — this
898
922
  // is the field the editor reads the layout from. See `core/src/render.ts`.
899
923
  // Every field can carry `{ as: "inline" }`, and that is all a render says.
@@ -1001,11 +1025,35 @@ var ImageEncodeOption = z.union([z.literal(false), z.object({
1001
1025
  maxWidth: z.number().optional(),
1002
1026
  maxHeight: z.number().optional()
1003
1027
  })]);
1004
- var ImageOptions = z.object({
1005
- directory: z.string().optional(),
1028
+ /**
1029
+ * Accept the pre-rename `directory` key and read it as `dir`.
1030
+ *
1031
+ * Serialized schemas are not only computed from live code: a commit record
1032
+ * stores the schema each module was under (`StoredModuleVersion`), and the
1033
+ * history view parses those back. Commits made before `directory` became `dir`
1034
+ * therefore still carry the old key, and dropping it would show a historical
1035
+ * gallery with no directory at all — silently, since the rest of the schema
1036
+ * parses fine.
1037
+ *
1038
+ * Only fills `dir` when it is absent, so a schema carrying both (which should
1039
+ * not happen) keeps the current key.
1040
+ */
1041
+ var readLegacyDirectoryAsDir = function readLegacyDirectoryAsDir(value) {
1042
+ if (!value || _typeof(value) !== "object" || Array.isArray(value) || !("directory" in value) || "dir" in value) {
1043
+ return value;
1044
+ }
1045
+ var _ref = value,
1046
+ directory = _ref.directory,
1047
+ rest = _objectWithoutProperties(_ref, _excluded);
1048
+ return _objectSpread2(_objectSpread2({}, rest), {}, {
1049
+ dir: directory
1050
+ });
1051
+ };
1052
+ var ImageOptions = z.preprocess(readLegacyDirectoryAsDir, z.object({
1053
+ dir: z.string().optional(),
1006
1054
  accept: z.string().optional(),
1007
1055
  encode: ImageEncodeOption.optional()
1008
- });
1056
+ }));
1009
1057
  var SerializedImageSchema = z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
1010
1058
  type: z.literal("image"),
1011
1059
  options: ImageOptions.optional(),
@@ -1044,7 +1092,7 @@ var SerializedRichTextSchema = z.object(_objectSpread2(_objectSpread2({}, common
1044
1092
  opt: z["boolean"]()
1045
1093
  }));
1046
1094
  var SerializedRecordSchema = z.lazy(function () {
1047
- return z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
1095
+ return z.preprocess(readLegacyDirectoryAsDir, z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
1048
1096
  type: z.literal("record"),
1049
1097
  item: SerializedSchema,
1050
1098
  opt: z["boolean"](),
@@ -1052,12 +1100,12 @@ var SerializedRecordSchema = z.lazy(function () {
1052
1100
  mediaType: z.union([z.literal("files"), z.literal("images")]).optional(),
1053
1101
  // Optional legacy gallery metadata
1054
1102
  accept: z.string().optional(),
1055
- directory: z.string().optional(),
1103
+ dir: z.string().optional(),
1056
1104
  remote: z["boolean"]().optional(),
1057
1105
  encode: ImageEncodeOption.optional(),
1058
1106
  alt: SerializedSchema.optional(),
1059
1107
  moduleMetadata: z.record(z.string(), z.record(z.string(), z.any())).optional()
1060
- })).passthrough();
1108
+ })).passthrough());
1061
1109
  });
1062
1110
  var SerializedKeyOfSchema = z.lazy(function () {
1063
1111
  return z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
@@ -4697,7 +4745,7 @@ function getSourceAt(source, path) {
4697
4745
  * Walks `schema` along `path`, returning a structured result:
4698
4746
  * - `leaf`: walked the full path; resolved schema at the end.
4699
4747
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
4700
- * - `gallery-traversed`: hit an `s.images()` record and walked past it (i.e. the
4748
+ * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
4701
4749
  * path tries to address an entry inside the gallery — a clue the AI should
4702
4750
  * have used the gallery tool instead).
4703
4751
  * - `unresolved`: the path could not be walked.
@@ -4828,7 +4876,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
4828
4876
  op: "add",
4829
4877
  path: [args.filePath],
4830
4878
  value: _objectSpread2(_objectSpread2({}, args.metadata), {}, {
4831
- // `alt` is a REQUIRED field of a gallery entry (`s.images()` gives it a
4879
+ // `alt` is a REQUIRED field of a gallery entry (`s.imageset()` gives it a
4832
4880
  // nullable string schema), so an entry written without one is invalid
4833
4881
  // the moment it lands — and the caller that had no alt to give is the
4834
4882
  // common case, not the odd one. Null is what the Studio's own upload
@@ -4891,10 +4939,10 @@ function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
4891
4939
  var GALLERY_REDIRECT = {
4892
4940
  kind: "wrong-tool",
4893
4941
  suggestedTool: "add_session_image_to_gallery",
4894
- reason: "Destination is a media gallery (s.images() / s.files()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4942
+ reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
4895
4943
  };
4896
4944
 
4897
- /** An `s.images()` / `s.files()` record: a gallery, not an ordinary record. */
4945
+ /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
4898
4946
  function isGallery(schema) {
4899
4947
  return schema.type === "record" && schema.mediaType !== undefined;
4900
4948
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.127.0",
3
+ "version": "0.128.0",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "flexsearch": "^0.8.212",
38
38
  "zod": "^4.4.3",
39
39
  "zod-validation-error": "^5.0.0",
40
- "@valbuild/core": "0.127.0"
40
+ "@valbuild/core": "0.128.0"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",