@valbuild/shared 0.143.0 → 0.144.2

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.
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@valbuild/core');
6
5
  var getSitemapTree = require('../../dist/getSitemapTree-0ed3deac.cjs.prod.js');
6
+ var core = require('@valbuild/core');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
9
9
  var FlexSearch = require('flexsearch');
@@ -657,6 +657,105 @@ function convertListItemToRemirrorParagraph(rtChildren) {
657
657
  return children;
658
658
  }
659
659
 
660
+ /**
661
+ * The one way to build a child's source path.
662
+ *
663
+ * There were five hand-rolled versions of this, three of them subtly different
664
+ * and two of them wrong, and the wrong ones were wrong in a way that hid: a
665
+ * module path segment has to be JSON-quoted if it is a string and bare if it is
666
+ * an array index, and both broken copies appended the raw key at the module
667
+ * root. An unquoted key parses fine as long as it contains no `.` — so every
668
+ * object field and every ordinary record key still resolved, and only a key with
669
+ * a dot in it broke. That is exactly what a media gallery is keyed by, so
670
+ * clicking a file in the Media panel navigated to
671
+ * `?p=/public/val/red-8x8_bfbd0.png`, which `splitModulePath` reads as the two
672
+ * segments `/public/val/red-8x8_bfbd0` and `png`, and the studio said the module
673
+ * was not found.
674
+ *
675
+ * So: one function, and never a template string. `Internal.createValPathOfItem`
676
+ * is the rule itself — `JSON.stringify` quotes a string and leaves a number
677
+ * bare, which is precisely the module-path grammar — and everything here defers
678
+ * to it rather than restating it.
679
+ */
680
+ function sourcePathOfChild(parent, key) {
681
+ /**
682
+ * A parent that is already `…?p=` gets the key with no separator.
683
+ *
684
+ * The search index walks from `moduleFilePath + "?p="` rather than from the
685
+ * module file path, so that every path it produces has a module path — and
686
+ * `createValPathOfItem` would see the separator and join with a `.`, giving
687
+ * `?p=."title"`.
688
+ */
689
+ if (parent.endsWith(core.Internal.ModuleFilePathSep)) {
690
+ return "".concat(parent).concat(JSON.stringify(key));
691
+ }
692
+ var path = core.Internal.createValPathOfItem(parent, key);
693
+ if (path === undefined) {
694
+ // Only when the parent is empty, which callers cannot produce: every walk
695
+ // starts from a module file path. Thrown rather than skipped so a future
696
+ // change that breaks that assumption is loud.
697
+ throw new Error("Could not build a source path for '".concat(key, "' under ").concat(parent));
698
+ }
699
+ return path;
700
+ }
701
+
702
+ /**
703
+ * The same thing, for callers holding the module file path and module path apart.
704
+ *
705
+ * `ModulePath` is empty at the module root, which is the case both broken copies
706
+ * got wrong: there is no separator in the path yet, so the key is the first
707
+ * segment and still has to be quoted.
708
+ */
709
+ function concatModulePath(moduleFilePath, modulePath, key) {
710
+ return sourcePathOfChild(modulePath ? core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, modulePath) : moduleFilePath, key);
711
+ }
712
+
713
+ /**
714
+ * The image schema a rich text field's inline `img` nodes are validated with,
715
+ * when it is a real schema rather than `img: true`.
716
+ *
717
+ * It is the only way a rich text field can point INTO a gallery
718
+ * (`s.richtext({ img: s.image(galleryVal) })`), which is why every reference
719
+ * scan has to ask: the field's own schema is `richtext`, not `image`, so a walk
720
+ * that only looks for image leaves walks straight past the images in it.
721
+ */
722
+ function richTextImageSchema(schema) {
723
+ var _schema$options;
724
+ var img = (_schema$options = schema.options) === null || _schema$options === void 0 ? void 0 : _schema$options.img;
725
+ return getSitemapTree._typeof(img) === "object" && img !== null ? img : null;
726
+ }
727
+
728
+ /**
729
+ * Every inline image in a rich text value, at the path of its `src`.
730
+ *
731
+ * `src` is a media value (`{ path, … }`), so the path handed out is one a
732
+ * patch can address — `field.0."children".1."src"` — and a rename rewrites
733
+ * `[…, "src", "path"]` there with the same op it uses on an image field.
734
+ * Images nest (a list item holds a paragraph holds the image), so the walk
735
+ * follows `children` all the way down.
736
+ */
737
+ function forEachRichTextImage(path, source, visit) {
738
+ if (!Array.isArray(source)) {
739
+ return;
740
+ }
741
+ for (var index = 0; index < source.length; index++) {
742
+ var node = source[index];
743
+ if (getSitemapTree._typeof(node) !== "object" || node === null || Array.isArray(node)) {
744
+ continue;
745
+ }
746
+ var nodePath = sourcePathOfChild(path, index);
747
+ if ("tag" in node && node.tag === "img" && "src" in node) {
748
+ var src = node.src;
749
+ if (getSitemapTree._typeof(src) === "object" && src !== null && !Array.isArray(src)) {
750
+ visit(sourcePathOfChild(nodePath, "src"), getSitemapTree._objectSpread2({}, src));
751
+ }
752
+ }
753
+ if ("children" in node) {
754
+ forEachRichTextImage(sourcePathOfChild(nodePath, "children"), node.children, visit);
755
+ }
756
+ }
757
+ }
758
+
660
759
  var VAL_SESSION_COOKIE = core.Internal.VAL_SESSION_COOKIE;
661
760
  var VAL_STATE_COOKIE = core.Internal.VAL_STATE_COOKIE;
662
761
  var VAL_ENABLE_COOKIE_NAME = core.Internal.VAL_ENABLE_COOKIE_NAME;
@@ -1172,7 +1271,7 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1172
1271
  dir: zod.z.string().optional(),
1173
1272
  remote: zod.z["boolean"]().optional(),
1174
1273
  encode: ImageEncodeOption.optional(),
1175
- // A videoset's: see `VideoStreamOption` below for why it is spelled
1274
+ // A videodir's: see `VideoStreamOption` below for why it is spelled
1176
1275
  // out rather than passed through.
1177
1276
  stream: VideoStreamOption.optional(),
1178
1277
  alt: SerializedSchema.optional(),
@@ -1228,7 +1327,7 @@ var SerializedVideoSchema = zod.z.object(getSitemapTree._objectSpread2(getSitema
1228
1327
  options: VideoOptions.optional(),
1229
1328
  opt: zod.z["boolean"](),
1230
1329
  remote: zod.z["boolean"]().optional(),
1231
- // The `s.videoset()` a set-backed field picks from.
1330
+ // The `s.videodir()` a set-backed field picks from.
1232
1331
  referencedModule: zod.z.string().optional()
1233
1332
  }));
1234
1333
  var DateOptions = zod.z.object({
@@ -5567,7 +5666,7 @@ function getSourceAt(source, path) {
5567
5666
  * Walks `schema` along `path`, returning a structured result:
5568
5667
  * - `leaf`: walked the full path; resolved schema at the end.
5569
5668
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
5570
- * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
5669
+ * - `gallery-traversed`: hit an `s.imagedir()` record and walked past it (i.e. the
5571
5670
  * path tries to address an entry inside the gallery — a clue the AI should
5572
5671
  * have used the gallery tool instead).
5573
5672
  * - `unresolved`: the path could not be walked.
@@ -5675,7 +5774,7 @@ function checkGallerySchema(moduleSchema) {
5675
5774
  // looks like a gallery from here, and the tool can do nothing with one.
5676
5775
  return {
5677
5776
  kind: "error",
5678
- message: "Module is a video set (s.videoset()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5777
+ message: "Module is a video set (s.videodir()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5679
5778
  };
5680
5779
  }
5681
5780
  if (moduleSchema.type === "image") {
@@ -5706,7 +5805,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
5706
5805
  op: "add",
5707
5806
  path: [args.filePath],
5708
5807
  value: getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, args.metadata), {}, {
5709
- // `alt` is a REQUIRED field of a gallery entry (`s.imageset()` gives it a
5808
+ // `alt` is a REQUIRED field of a gallery entry (`s.imagedir()` gives it a
5710
5809
  // nullable string schema), so an entry written without one is invalid
5711
5810
  // the moment it lands — and the caller that had no alt to give is the
5712
5811
  // common case, not the odd one. Null is what the Studio's own upload
@@ -5769,7 +5868,7 @@ function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
5769
5868
  var GALLERY_REDIRECT = {
5770
5869
  kind: "wrong-tool",
5771
5870
  suggestedTool: "add_session_image_to_gallery",
5772
- 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."
5871
+ reason: "Destination is a media gallery (s.imagedir() / s.filedir()). 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."
5773
5872
  };
5774
5873
 
5775
5874
  /**
@@ -5779,10 +5878,10 @@ var GALLERY_REDIRECT = {
5779
5878
  */
5780
5879
  var VIDEOSET_REFUSAL = {
5781
5880
  kind: "error",
5782
- message: "Destination is a video set (s.videoset()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5881
+ message: "Destination is a video set (s.videodir()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5783
5882
  };
5784
5883
 
5785
- /** An `s.imageset()` / `s.fileset()` / `s.videoset()` record: a gallery, not an ordinary record. */
5884
+ /** An `s.imagedir()` / `s.filedir()` / `s.videodir()` record: a gallery, not an ordinary record. */
5786
5885
  function isGallery(schema) {
5787
5886
  return schema.type === "record" && schema.mediaType !== undefined;
5788
5887
  }
@@ -6097,7 +6196,8 @@ function describeContainerAtPath(moduleSchema, moduleSource, path) {
6097
6196
  * `skipped` errors carry only fix codes the user can't (or shouldn't) act on
6098
6197
  * in the browser:
6099
6198
  * - image/file metadata checks (need to read bytes from disk)
6100
- * - remote upload/download/check (need a personal access token + network)
6199
+ * - remote upload/download, and the singular remote check (need a personal
6200
+ * access token + network)
6101
6201
  * - gallery directory uniqueness + untracked-files checks (need fs traversal)
6102
6202
  *
6103
6203
  * The server (ValOps + createFixPatch) resolves all of these automatically on
@@ -6157,20 +6257,17 @@ function isSkippableFixCode(fix) {
6157
6257
  case "image:upload-remote":
6158
6258
  case "image:download-remote":
6159
6259
  case "image:check-remote":
6160
- case "images:check-remote":
6161
6260
  case "images:upload-remote":
6162
6261
  case "file:add-metadata":
6163
6262
  case "file:check-metadata":
6164
6263
  case "file:upload-remote":
6165
6264
  case "file:download-remote":
6166
6265
  case "file:check-remote":
6167
- case "files:check-remote":
6168
6266
  case "files:upload-remote":
6169
6267
  case "video:add-metadata": // the Studio writes it on upload; --fix for the rest
6170
6268
  case "video:upload-remote":
6171
6269
  case "video:download-remote":
6172
6270
  case "videos:add-metadata": // as `video:add-metadata`, for a set's entry
6173
- case "videos:check-remote":
6174
6271
  case "videos:upload-remote":
6175
6272
  case "videos:check-unique-folder":
6176
6273
  case "videos:check-all-files":
@@ -6181,6 +6278,18 @@ function isSkippableFixCode(fix) {
6181
6278
  case "view:check-module":
6182
6279
  // schema is code: nothing for an editor to do
6183
6280
  return true;
6281
+ case "images:check-remote":
6282
+ case "files:check-remote":
6283
+ case "videos:check-remote":
6284
+ // A collection KEY that is wrong as a key: a remote URL in a gallery that
6285
+ // is not `.remote()`, one that does not parse, one outside the gallery's
6286
+ // directory. Unlike the singular `image:check-remote` above (core's "not
6287
+ // checked" marker on EVERY remote value, which the server does check),
6288
+ // core emits these only when the key is wrong, and nothing repairs that
6289
+ // on save -- not the server, not `val validate --fix`. Only a person knows
6290
+ // whether the key or the gallery's options are the mistake. Skipping them
6291
+ // also took them off the publish gate, so a broken key published unseen.
6292
+ return false;
6184
6293
  case "keyof:check-keys":
6185
6294
  case "router:check-route":
6186
6295
  case "locale:check-locale":
@@ -6374,59 +6483,6 @@ function withExtension(filename, ext) {
6374
6483
  return "".concat(base, ".").concat(ext);
6375
6484
  }
6376
6485
 
6377
- /**
6378
- * The one way to build a child's source path.
6379
- *
6380
- * There were five hand-rolled versions of this, three of them subtly different
6381
- * and two of them wrong, and the wrong ones were wrong in a way that hid: a
6382
- * module path segment has to be JSON-quoted if it is a string and bare if it is
6383
- * an array index, and both broken copies appended the raw key at the module
6384
- * root. An unquoted key parses fine as long as it contains no `.` — so every
6385
- * object field and every ordinary record key still resolved, and only a key with
6386
- * a dot in it broke. That is exactly what a media gallery is keyed by, so
6387
- * clicking a file in the Media panel navigated to
6388
- * `?p=/public/val/red-8x8_bfbd0.png`, which `splitModulePath` reads as the two
6389
- * segments `/public/val/red-8x8_bfbd0` and `png`, and the studio said the module
6390
- * was not found.
6391
- *
6392
- * So: one function, and never a template string. `Internal.createValPathOfItem`
6393
- * is the rule itself — `JSON.stringify` quotes a string and leaves a number
6394
- * bare, which is precisely the module-path grammar — and everything here defers
6395
- * to it rather than restating it.
6396
- */
6397
- function sourcePathOfChild(parent, key) {
6398
- /**
6399
- * A parent that is already `…?p=` gets the key with no separator.
6400
- *
6401
- * The search index walks from `moduleFilePath + "?p="` rather than from the
6402
- * module file path, so that every path it produces has a module path — and
6403
- * `createValPathOfItem` would see the separator and join with a `.`, giving
6404
- * `?p=."title"`.
6405
- */
6406
- if (parent.endsWith(core.Internal.ModuleFilePathSep)) {
6407
- return "".concat(parent).concat(JSON.stringify(key));
6408
- }
6409
- var path = core.Internal.createValPathOfItem(parent, key);
6410
- if (path === undefined) {
6411
- // Only when the parent is empty, which callers cannot produce: every walk
6412
- // starts from a module file path. Thrown rather than skipped so a future
6413
- // change that breaks that assumption is loud.
6414
- throw new Error("Could not build a source path for '".concat(key, "' under ").concat(parent));
6415
- }
6416
- return path;
6417
- }
6418
-
6419
- /**
6420
- * The same thing, for callers holding the module file path and module path apart.
6421
- *
6422
- * `ModulePath` is empty at the module root, which is the case both broken copies
6423
- * got wrong: there is no separator in the path yet, so the key is the first
6424
- * segment and still has to be quoted.
6425
- */
6426
- function concatModulePath(moduleFilePath, modulePath, key) {
6427
- return sourcePathOfChild(modulePath ? core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, modulePath) : moduleFilePath, key);
6428
- }
6429
-
6430
6486
  /**
6431
6487
  * Traverses a schema and source pair, calling a callback for each leaf node.
6432
6488
  * Handles all schema types including primitives, objects, arrays, records, unions, richtext, files, images, etc.
@@ -7865,7 +7921,8 @@ var tabJob = zod.z.object({
7865
7921
  id: zod.z.string(),
7866
7922
  step: zod.z["enum"](["prepare", "build", "upload"]).nullable(),
7867
7923
  base: zod.z.string().nullable(),
7868
- patches: zod.z.array(zod.z.string())
7924
+ patches: zod.z.array(zod.z.string()),
7925
+ contentOnly: zod.z.literal(true).optional()
7869
7926
  });
7870
7927
  var pressResponse = zod.z.object({
7871
7928
  request: requestStatus,
@@ -8056,6 +8113,7 @@ exports.filterRoutesByPatterns = filterRoutesByPatterns;
8056
8113
  exports.findSimilar = findSimilar;
8057
8114
  exports.fitWithin = fitWithin;
8058
8115
  exports.flattenRichText = flattenRichText;
8116
+ exports.forEachRichTextImage = forEachRichTextImage;
8059
8117
  exports.getErrorMessageFromUnknownJson = getErrorMessageFromUnknownJson;
8060
8118
  exports.getFilenameFromRef = getFilenameFromRef;
8061
8119
  exports.getInlineImgInfo = getInlineImgInfo;
@@ -8101,6 +8159,7 @@ exports.resolvePairGround = resolvePairGround;
8101
8159
  exports.resolveSchemaSourceFixForError = resolveSchemaSourceFixForError;
8102
8160
  exports.resolveSchemaSourceFixes = resolveSchemaSourceFixes;
8103
8161
  exports.resolveSerializedSchemaAtPath = resolveSerializedSchemaAtPath;
8162
+ exports.richTextImageSchema = richTextImageSchema;
8104
8163
  exports.richTextToRemirror = richTextToRemirror;
8105
8164
  exports.safeParsePatch = safeParsePatch;
8106
8165
  exports.sourcePathOfChild = sourcePathOfChild;
@@ -1,6 +1,6 @@
1
- import { Internal, CODE_LANGUAGES, resolveSettingsModule, missingDeclaredKeys, localeOfValue, discriminatedUnionBranchOf, DEFAULT_COLOR_FORMAT, declaredKeySetOf } from '@valbuild/core';
2
1
  import { _ as _createForOfIteratorHelper, o as _objectSpread2, q as _arrayLikeToArray, r as _unsupportedIterableToArray, s as _typeof, t as _defineProperty, u as _toPropertyKey } from '../../dist/getSitemapTree-6fcdf745.esm.js';
3
2
  export { D as DEFAULT_CANVAS_SELECTION, e as DEFAULT_CANVAS_SELECTION_SOFT, 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, h as getNextAppRouterSourceFolder, m as getPageRouterSitemapTree, k as getPageRouterSourceFolder, n as getPatternFromModuleFilePath, j as getTanStackRouterSourceFolder, l as isTanStackRoutesFolder, g as isValCanvasFrame, i as isValCanvasPageMessage, f as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-6fcdf745.esm.js';
3
+ import { Internal, CODE_LANGUAGES, resolveSettingsModule, missingDeclaredKeys, localeOfValue, discriminatedUnionBranchOf, DEFAULT_COLOR_FORMAT, declaredKeySetOf } from '@valbuild/core';
4
4
  import { z } from 'zod';
5
5
  import { fromError } from 'zod-validation-error';
6
6
  import FlexSearch from 'flexsearch';
@@ -650,6 +650,105 @@ function convertListItemToRemirrorParagraph(rtChildren) {
650
650
  return children;
651
651
  }
652
652
 
653
+ /**
654
+ * The one way to build a child's source path.
655
+ *
656
+ * There were five hand-rolled versions of this, three of them subtly different
657
+ * and two of them wrong, and the wrong ones were wrong in a way that hid: a
658
+ * module path segment has to be JSON-quoted if it is a string and bare if it is
659
+ * an array index, and both broken copies appended the raw key at the module
660
+ * root. An unquoted key parses fine as long as it contains no `.` — so every
661
+ * object field and every ordinary record key still resolved, and only a key with
662
+ * a dot in it broke. That is exactly what a media gallery is keyed by, so
663
+ * clicking a file in the Media panel navigated to
664
+ * `?p=/public/val/red-8x8_bfbd0.png`, which `splitModulePath` reads as the two
665
+ * segments `/public/val/red-8x8_bfbd0` and `png`, and the studio said the module
666
+ * was not found.
667
+ *
668
+ * So: one function, and never a template string. `Internal.createValPathOfItem`
669
+ * is the rule itself — `JSON.stringify` quotes a string and leaves a number
670
+ * bare, which is precisely the module-path grammar — and everything here defers
671
+ * to it rather than restating it.
672
+ */
673
+ function sourcePathOfChild(parent, key) {
674
+ /**
675
+ * A parent that is already `…?p=` gets the key with no separator.
676
+ *
677
+ * The search index walks from `moduleFilePath + "?p="` rather than from the
678
+ * module file path, so that every path it produces has a module path — and
679
+ * `createValPathOfItem` would see the separator and join with a `.`, giving
680
+ * `?p=."title"`.
681
+ */
682
+ if (parent.endsWith(Internal.ModuleFilePathSep)) {
683
+ return "".concat(parent).concat(JSON.stringify(key));
684
+ }
685
+ var path = Internal.createValPathOfItem(parent, key);
686
+ if (path === undefined) {
687
+ // Only when the parent is empty, which callers cannot produce: every walk
688
+ // starts from a module file path. Thrown rather than skipped so a future
689
+ // change that breaks that assumption is loud.
690
+ throw new Error("Could not build a source path for '".concat(key, "' under ").concat(parent));
691
+ }
692
+ return path;
693
+ }
694
+
695
+ /**
696
+ * The same thing, for callers holding the module file path and module path apart.
697
+ *
698
+ * `ModulePath` is empty at the module root, which is the case both broken copies
699
+ * got wrong: there is no separator in the path yet, so the key is the first
700
+ * segment and still has to be quoted.
701
+ */
702
+ function concatModulePath(moduleFilePath, modulePath, key) {
703
+ return sourcePathOfChild(modulePath ? Internal.joinModuleFilePathAndModulePath(moduleFilePath, modulePath) : moduleFilePath, key);
704
+ }
705
+
706
+ /**
707
+ * The image schema a rich text field's inline `img` nodes are validated with,
708
+ * when it is a real schema rather than `img: true`.
709
+ *
710
+ * It is the only way a rich text field can point INTO a gallery
711
+ * (`s.richtext({ img: s.image(galleryVal) })`), which is why every reference
712
+ * scan has to ask: the field's own schema is `richtext`, not `image`, so a walk
713
+ * that only looks for image leaves walks straight past the images in it.
714
+ */
715
+ function richTextImageSchema(schema) {
716
+ var _schema$options;
717
+ var img = (_schema$options = schema.options) === null || _schema$options === void 0 ? void 0 : _schema$options.img;
718
+ return _typeof(img) === "object" && img !== null ? img : null;
719
+ }
720
+
721
+ /**
722
+ * Every inline image in a rich text value, at the path of its `src`.
723
+ *
724
+ * `src` is a media value (`{ path, … }`), so the path handed out is one a
725
+ * patch can address — `field.0."children".1."src"` — and a rename rewrites
726
+ * `[…, "src", "path"]` there with the same op it uses on an image field.
727
+ * Images nest (a list item holds a paragraph holds the image), so the walk
728
+ * follows `children` all the way down.
729
+ */
730
+ function forEachRichTextImage(path, source, visit) {
731
+ if (!Array.isArray(source)) {
732
+ return;
733
+ }
734
+ for (var index = 0; index < source.length; index++) {
735
+ var node = source[index];
736
+ if (_typeof(node) !== "object" || node === null || Array.isArray(node)) {
737
+ continue;
738
+ }
739
+ var nodePath = sourcePathOfChild(path, index);
740
+ if ("tag" in node && node.tag === "img" && "src" in node) {
741
+ var src = node.src;
742
+ if (_typeof(src) === "object" && src !== null && !Array.isArray(src)) {
743
+ visit(sourcePathOfChild(nodePath, "src"), _objectSpread2({}, src));
744
+ }
745
+ }
746
+ if ("children" in node) {
747
+ forEachRichTextImage(sourcePathOfChild(nodePath, "children"), node.children, visit);
748
+ }
749
+ }
750
+ }
751
+
653
752
  var VAL_SESSION_COOKIE = Internal.VAL_SESSION_COOKIE;
654
753
  var VAL_STATE_COOKIE = Internal.VAL_STATE_COOKIE;
655
754
  var VAL_ENABLE_COOKIE_NAME = Internal.VAL_ENABLE_COOKIE_NAME;
@@ -1165,7 +1264,7 @@ var SerializedRecordSchema = z.lazy(function () {
1165
1264
  dir: z.string().optional(),
1166
1265
  remote: z["boolean"]().optional(),
1167
1266
  encode: ImageEncodeOption.optional(),
1168
- // A videoset's: see `VideoStreamOption` below for why it is spelled
1267
+ // A videodir's: see `VideoStreamOption` below for why it is spelled
1169
1268
  // out rather than passed through.
1170
1269
  stream: VideoStreamOption.optional(),
1171
1270
  alt: SerializedSchema.optional(),
@@ -1221,7 +1320,7 @@ var SerializedVideoSchema = z.object(_objectSpread2(_objectSpread2({}, commonSch
1221
1320
  options: VideoOptions.optional(),
1222
1321
  opt: z["boolean"](),
1223
1322
  remote: z["boolean"]().optional(),
1224
- // The `s.videoset()` a set-backed field picks from.
1323
+ // The `s.videodir()` a set-backed field picks from.
1225
1324
  referencedModule: z.string().optional()
1226
1325
  }));
1227
1326
  var DateOptions = z.object({
@@ -5560,7 +5659,7 @@ function getSourceAt(source, path) {
5560
5659
  * Walks `schema` along `path`, returning a structured result:
5561
5660
  * - `leaf`: walked the full path; resolved schema at the end.
5562
5661
  * - `richtext`: hit a richtext mid-walk; richtext is the resolved schema.
5563
- * - `gallery-traversed`: hit an `s.imageset()` record and walked past it (i.e. the
5662
+ * - `gallery-traversed`: hit an `s.imagedir()` record and walked past it (i.e. the
5564
5663
  * path tries to address an entry inside the gallery — a clue the AI should
5565
5664
  * have used the gallery tool instead).
5566
5665
  * - `unresolved`: the path could not be walked.
@@ -5668,7 +5767,7 @@ function checkGallerySchema(moduleSchema) {
5668
5767
  // looks like a gallery from here, and the tool can do nothing with one.
5669
5768
  return {
5670
5769
  kind: "error",
5671
- message: "Module is a video set (s.videoset()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5770
+ message: "Module is a video set (s.videodir()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5672
5771
  };
5673
5772
  }
5674
5773
  if (moduleSchema.type === "image") {
@@ -5699,7 +5798,7 @@ function buildImageGalleryPatch(args, moduleSchema) {
5699
5798
  op: "add",
5700
5799
  path: [args.filePath],
5701
5800
  value: _objectSpread2(_objectSpread2({}, args.metadata), {}, {
5702
- // `alt` is a REQUIRED field of a gallery entry (`s.imageset()` gives it a
5801
+ // `alt` is a REQUIRED field of a gallery entry (`s.imagedir()` gives it a
5703
5802
  // nullable string schema), so an entry written without one is invalid
5704
5803
  // the moment it lands — and the caller that had no alt to give is the
5705
5804
  // common case, not the odd one. Null is what the Studio's own upload
@@ -5762,7 +5861,7 @@ function buildRemoveImageGalleryEntryPatch(args, moduleSchema, moduleSource) {
5762
5861
  var GALLERY_REDIRECT = {
5763
5862
  kind: "wrong-tool",
5764
5863
  suggestedTool: "add_session_image_to_gallery",
5765
- 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."
5864
+ reason: "Destination is a media gallery (s.imagedir() / s.filedir()). 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."
5766
5865
  };
5767
5866
 
5768
5867
  /**
@@ -5772,10 +5871,10 @@ var GALLERY_REDIRECT = {
5772
5871
  */
5773
5872
  var VIDEOSET_REFUSAL = {
5774
5873
  kind: "error",
5775
- message: "Destination is a video set (s.videoset()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5874
+ message: "Destination is a video set (s.videodir()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5776
5875
  };
5777
5876
 
5778
- /** An `s.imageset()` / `s.fileset()` / `s.videoset()` record: a gallery, not an ordinary record. */
5877
+ /** An `s.imagedir()` / `s.filedir()` / `s.videodir()` record: a gallery, not an ordinary record. */
5779
5878
  function isGallery(schema) {
5780
5879
  return schema.type === "record" && schema.mediaType !== undefined;
5781
5880
  }
@@ -6090,7 +6189,8 @@ function describeContainerAtPath(moduleSchema, moduleSource, path) {
6090
6189
  * `skipped` errors carry only fix codes the user can't (or shouldn't) act on
6091
6190
  * in the browser:
6092
6191
  * - image/file metadata checks (need to read bytes from disk)
6093
- * - remote upload/download/check (need a personal access token + network)
6192
+ * - remote upload/download, and the singular remote check (need a personal
6193
+ * access token + network)
6094
6194
  * - gallery directory uniqueness + untracked-files checks (need fs traversal)
6095
6195
  *
6096
6196
  * The server (ValOps + createFixPatch) resolves all of these automatically on
@@ -6150,20 +6250,17 @@ function isSkippableFixCode(fix) {
6150
6250
  case "image:upload-remote":
6151
6251
  case "image:download-remote":
6152
6252
  case "image:check-remote":
6153
- case "images:check-remote":
6154
6253
  case "images:upload-remote":
6155
6254
  case "file:add-metadata":
6156
6255
  case "file:check-metadata":
6157
6256
  case "file:upload-remote":
6158
6257
  case "file:download-remote":
6159
6258
  case "file:check-remote":
6160
- case "files:check-remote":
6161
6259
  case "files:upload-remote":
6162
6260
  case "video:add-metadata": // the Studio writes it on upload; --fix for the rest
6163
6261
  case "video:upload-remote":
6164
6262
  case "video:download-remote":
6165
6263
  case "videos:add-metadata": // as `video:add-metadata`, for a set's entry
6166
- case "videos:check-remote":
6167
6264
  case "videos:upload-remote":
6168
6265
  case "videos:check-unique-folder":
6169
6266
  case "videos:check-all-files":
@@ -6174,6 +6271,18 @@ function isSkippableFixCode(fix) {
6174
6271
  case "view:check-module":
6175
6272
  // schema is code: nothing for an editor to do
6176
6273
  return true;
6274
+ case "images:check-remote":
6275
+ case "files:check-remote":
6276
+ case "videos:check-remote":
6277
+ // A collection KEY that is wrong as a key: a remote URL in a gallery that
6278
+ // is not `.remote()`, one that does not parse, one outside the gallery's
6279
+ // directory. Unlike the singular `image:check-remote` above (core's "not
6280
+ // checked" marker on EVERY remote value, which the server does check),
6281
+ // core emits these only when the key is wrong, and nothing repairs that
6282
+ // on save -- not the server, not `val validate --fix`. Only a person knows
6283
+ // whether the key or the gallery's options are the mistake. Skipping them
6284
+ // also took them off the publish gate, so a broken key published unseen.
6285
+ return false;
6177
6286
  case "keyof:check-keys":
6178
6287
  case "router:check-route":
6179
6288
  case "locale:check-locale":
@@ -6367,59 +6476,6 @@ function withExtension(filename, ext) {
6367
6476
  return "".concat(base, ".").concat(ext);
6368
6477
  }
6369
6478
 
6370
- /**
6371
- * The one way to build a child's source path.
6372
- *
6373
- * There were five hand-rolled versions of this, three of them subtly different
6374
- * and two of them wrong, and the wrong ones were wrong in a way that hid: a
6375
- * module path segment has to be JSON-quoted if it is a string and bare if it is
6376
- * an array index, and both broken copies appended the raw key at the module
6377
- * root. An unquoted key parses fine as long as it contains no `.` — so every
6378
- * object field and every ordinary record key still resolved, and only a key with
6379
- * a dot in it broke. That is exactly what a media gallery is keyed by, so
6380
- * clicking a file in the Media panel navigated to
6381
- * `?p=/public/val/red-8x8_bfbd0.png`, which `splitModulePath` reads as the two
6382
- * segments `/public/val/red-8x8_bfbd0` and `png`, and the studio said the module
6383
- * was not found.
6384
- *
6385
- * So: one function, and never a template string. `Internal.createValPathOfItem`
6386
- * is the rule itself — `JSON.stringify` quotes a string and leaves a number
6387
- * bare, which is precisely the module-path grammar — and everything here defers
6388
- * to it rather than restating it.
6389
- */
6390
- function sourcePathOfChild(parent, key) {
6391
- /**
6392
- * A parent that is already `…?p=` gets the key with no separator.
6393
- *
6394
- * The search index walks from `moduleFilePath + "?p="` rather than from the
6395
- * module file path, so that every path it produces has a module path — and
6396
- * `createValPathOfItem` would see the separator and join with a `.`, giving
6397
- * `?p=."title"`.
6398
- */
6399
- if (parent.endsWith(Internal.ModuleFilePathSep)) {
6400
- return "".concat(parent).concat(JSON.stringify(key));
6401
- }
6402
- var path = Internal.createValPathOfItem(parent, key);
6403
- if (path === undefined) {
6404
- // Only when the parent is empty, which callers cannot produce: every walk
6405
- // starts from a module file path. Thrown rather than skipped so a future
6406
- // change that breaks that assumption is loud.
6407
- throw new Error("Could not build a source path for '".concat(key, "' under ").concat(parent));
6408
- }
6409
- return path;
6410
- }
6411
-
6412
- /**
6413
- * The same thing, for callers holding the module file path and module path apart.
6414
- *
6415
- * `ModulePath` is empty at the module root, which is the case both broken copies
6416
- * got wrong: there is no separator in the path yet, so the key is the first
6417
- * segment and still has to be quoted.
6418
- */
6419
- function concatModulePath(moduleFilePath, modulePath, key) {
6420
- return sourcePathOfChild(modulePath ? Internal.joinModuleFilePathAndModulePath(moduleFilePath, modulePath) : moduleFilePath, key);
6421
- }
6422
-
6423
6479
  /**
6424
6480
  * Traverses a schema and source pair, calling a callback for each leaf node.
6425
6481
  * Handles all schema types including primitives, objects, arrays, records, unions, richtext, files, images, etc.
@@ -7858,7 +7914,8 @@ var tabJob = z.object({
7858
7914
  id: z.string(),
7859
7915
  step: z["enum"](["prepare", "build", "upload"]).nullable(),
7860
7916
  base: z.string().nullable(),
7861
- patches: z.array(z.string())
7917
+ patches: z.array(z.string()),
7918
+ contentOnly: z.literal(true).optional()
7862
7919
  });
7863
7920
  var pressResponse = z.object({
7864
7921
  request: requestStatus,
@@ -7930,4 +7987,4 @@ function parse(schema, body, call) {
7930
7987
  return parsed.data;
7931
7988
  }
7932
7989
 
7933
- export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SerializedVideoSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, VideoOptions, VideoStreamOption, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
7990
+ export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SerializedVideoSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, VideoOptions, VideoStreamOption, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, forEachRichTextImage, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextImageSchema, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.143.0",
3
+ "version": "0.144.2",
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.143.0"
40
+ "@valbuild/core": "0.144.0"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",