@valbuild/core 0.144.0 → 0.146.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.
@@ -3036,6 +3036,50 @@ function galleryKeyOf(path, isKey) {
3036
3036
  return null;
3037
3037
  }
3038
3038
 
3039
+ /**
3040
+ * A gallery-backed field whose path the gallery, as the schema holds it, does
3041
+ * not have: the `image:check-gallery` (`file:`, `video:`) marker.
3042
+ *
3043
+ * The schema holds the gallery as it was EVALUATED -- in a built site, the
3044
+ * gallery as it was built. An entry added since (a pending change, a save in
3045
+ * a proposal, a content-only publish that never rebuilt the site) is only in
3046
+ * the gallery's current Source, so whether the field is wrong is a question
3047
+ * for a project-wide snapshot (`resolveSchemaSourceFixes`), as a keyOf's key
3048
+ * is. The message is the answer when the gallery does not have it either, so
3049
+ * a consumer that does not resolve markers reports what it always did.
3050
+ */
3051
+ function galleryMarker(media, source, galleryModulePath) {
3052
+ var what = media === "image" ? "The gallery does not have an image" : media === "file" ? "The gallery does not have a file" : "The set does not have a video";
3053
+ return {
3054
+ message: "".concat(what, " at '").concat(source.path, "'."),
3055
+ value: {
3056
+ path: source.path,
3057
+ gallery: galleryModulePath,
3058
+ source: source
3059
+ },
3060
+ fixes: ["".concat(media, ":check-gallery")]
3061
+ };
3062
+ }
3063
+
3064
+ /** A {@link galleryMarker}'s fields, or `null` for any other error. */
3065
+ function galleryMarkerOf(error) {
3066
+ var _error$fixes;
3067
+ var fixes = (_error$fixes = error.fixes) !== null && _error$fixes !== void 0 ? _error$fixes : [];
3068
+ if (!fixes.includes("image:check-gallery") && !fixes.includes("file:check-gallery") && !fixes.includes("video:check-gallery")) {
3069
+ return null;
3070
+ }
3071
+ var value = error.value;
3072
+ if (_typeof(value) !== "object" || value === null) return null;
3073
+ var path = "path" in value ? value.path : undefined;
3074
+ var gallery = "gallery" in value ? value.gallery : undefined;
3075
+ if (typeof path !== "string" || typeof gallery !== "string") return null;
3076
+ return {
3077
+ path: path,
3078
+ gallery: gallery,
3079
+ source: "source" in value ? value.source : undefined
3080
+ };
3081
+ }
3082
+
3039
3083
  /**
3040
3084
  * What a gallery entry holds as a DEFAULT for the fields picked from it, in
3041
3085
  * the groups a field overrides together.
@@ -4228,10 +4272,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
4228
4272
  if (galleryKeyOf(src.path, function (key) {
4229
4273
  return key in galleryEntries;
4230
4274
  }) === null) {
4231
- return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
4232
- message: "The gallery does not have an image at '".concat(src.path, "'."),
4233
- value: src
4234
- }]));
4275
+ return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [galleryMarker("image", src, this.galleryModulePath())]));
4235
4276
  }
4236
4277
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
4237
4278
  }
@@ -4295,6 +4336,13 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
4295
4336
  * alt — it carries its own — so it only needs the entry keys and the
4296
4337
  * dimensions, and a gallery of any alt shape can back it.
4297
4338
  */
4339
+ /** The module path of the gallery this field points at. */
4340
+ }, {
4341
+ key: "galleryModulePath",
4342
+ value: function galleryModulePath() {
4343
+ var _Object$keys$;
4344
+ return (_Object$keys$ = Object.keys(this.moduleMetadata)[0]) !== null && _Object$keys$ !== void 0 ? _Object$keys$ : "";
4345
+ }
4298
4346
  }, {
4299
4347
  key: "galleryEntries",
4300
4348
  value: function galleryEntries() {
@@ -10187,6 +10235,87 @@ function patchPathToModulePath(patchPath) {
10187
10235
  }).join(".");
10188
10236
  }
10189
10237
 
10238
+ /**
10239
+ * What a number schema accepts, in one place, so the validator and the
10240
+ * Studio's "Round to …" / "Set to …" buttons cannot disagree about it.
10241
+ *
10242
+ * A button that offers a value the validator then rejects is worse than no
10243
+ * button, which is exactly what two copies of this arithmetic would drift into.
10244
+ */
10245
+
10246
+ /**
10247
+ * Division of decimals is not exact (`0.3 / 0.1` is `2.9999999999999996`), so a
10248
+ * value counts as on the grid when it is within this many steps of it.
10249
+ */
10250
+ var GRID_EPSILON = 1e-9;
10251
+
10252
+ /** Where the step grid starts: the schema's `min`, or 0 when it has none. */
10253
+ function stepOrigin(rules) {
10254
+ var _rules$min;
10255
+ return (_rules$min = rules.min) !== null && _rules$min !== void 0 ? _rules$min : 0;
10256
+ }
10257
+
10258
+ /** Is `value` one of `origin + n * step`? */
10259
+ function isOnStep(value, origin, step) {
10260
+ var steps = (value - origin) / step;
10261
+ return Math.abs(steps - Math.round(steps)) < GRID_EPSILON;
10262
+ }
10263
+
10264
+ /**
10265
+ * The allowed value closest to `value`: inside `min`/`max`, on the step grid,
10266
+ * and whole when the schema is an int.
10267
+ *
10268
+ * Returns `null` when the rules leave nothing to snap to — a `min` above
10269
+ * `max`, or a range too narrow to hold a single step or a single whole number.
10270
+ */
10271
+ function nearestAllowedNumber(value, rules) {
10272
+ var _rules$step;
10273
+ var step = (_rules$step = rules.step) !== null && _rules$step !== void 0 ? _rules$step : rules.integer ? 1 : undefined;
10274
+ var lo = rules.min;
10275
+ var hi = rules.max;
10276
+ if (lo !== undefined && hi !== undefined && lo > hi) {
10277
+ return null;
10278
+ }
10279
+ var clamp = function clamp(n) {
10280
+ return Math.min(hi !== null && hi !== void 0 ? hi : Infinity, Math.max(lo !== null && lo !== void 0 ? lo : -Infinity, n));
10281
+ };
10282
+ if (step === undefined) {
10283
+ return clamp(value);
10284
+ }
10285
+ var origin = rules.integer && rules.step === undefined ? 0 : stepOrigin(rules);
10286
+ var toGrid = function toGrid(n) {
10287
+ return roundToDecimals(origin + n * step);
10288
+ };
10289
+ var n = Math.round((clamp(value) - origin) / step);
10290
+ // Rounding can step outside the range by one; walk back in.
10291
+ if (lo !== undefined && toGrid(n) < lo) n += 1;
10292
+ if (hi !== undefined && toGrid(n) > hi) n -= 1;
10293
+ var snapped = toGrid(n);
10294
+ if (lo !== undefined && snapped < lo || hi !== undefined && snapped > hi) {
10295
+ return null;
10296
+ }
10297
+ if (rules.integer && !Number.isInteger(snapped)) {
10298
+ return null;
10299
+ }
10300
+ return snapped;
10301
+ }
10302
+
10303
+ /**
10304
+ * `0.1 + 0.2` is `0.30000000000000004`. A value offered to an editor should
10305
+ * read `0.3`, so grid values are rounded to 12 significant decimals — far below
10306
+ * any step anyone writes, far above floating point noise.
10307
+ */
10308
+ function roundToDecimals(n) {
10309
+ return Number.parseFloat(n.toFixed(12));
10310
+ }
10311
+
10312
+ /**
10313
+ * What the value has to be. `integer` is what makes a number schema an
10314
+ * `s.int()`: the source is a number either way, so an int is a number schema
10315
+ * with one more rule rather than a schema type of its own (which every walk
10316
+ * over a schema would have had to learn).
10317
+ */
10318
+
10190
10319
  var NumberSchema = /*#__PURE__*/function (_Schema) {
10191
10320
  function NumberSchema(options) {
10192
10321
  var _this;
@@ -10196,6 +10325,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10196
10325
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
10197
10326
  var description = arguments.length > 5 ? arguments[5] : undefined;
10198
10327
  var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
10328
+ var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
10199
10329
  _classCallCheck(this, NumberSchema);
10200
10330
  _this = _callSuper(this, NumberSchema);
10201
10331
  _this.options = options;
@@ -10205,6 +10335,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10205
10335
  _this.isHidden = isHidden;
10206
10336
  _this.description = description;
10207
10337
  _this.previewInput = previewInput;
10338
+ _this.renderInput = renderInput;
10339
+ assertNumberSchemaIsConsistent(_this.options, _this.renderInput);
10208
10340
  return _this;
10209
10341
  }
10210
10342
 
@@ -10229,7 +10361,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10229
10361
  return _createClass(NumberSchema, [{
10230
10362
  key: "describe",
10231
10363
  value: function describe(description) {
10232
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
10364
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
10233
10365
  }
10234
10366
 
10235
10367
  /**
@@ -10255,12 +10387,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10255
10387
  }, {
10256
10388
  key: "validate",
10257
10389
  value: function validate(validationFunction) {
10258
- return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
10390
+ return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10259
10391
  }
10260
10392
  }, {
10261
10393
  key: "executeValidate",
10262
10394
  value: function executeValidate(path, src) {
10263
- var _this$options, _this$options2;
10395
+ var _this$options;
10264
10396
  var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
10265
10397
  path: path
10266
10398
  });
@@ -10273,20 +10405,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10273
10405
  value: src
10274
10406
  }]));
10275
10407
  }
10276
- if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.max && src > this.options.max) {
10277
- return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10278
- message: "Expected 'number' less than ".concat(this.options.max),
10408
+ var errors = _toConsumableArray(customValidationErrors);
10409
+ var options = (_this$options = this.options) !== null && _this$options !== void 0 ? _this$options : {};
10410
+ // `!== undefined`, not truthiness: a bound of 0 is a bound. `.max(0)` and
10411
+ // `.min(0)` used to be ignored, which a slider from 0 makes common.
10412
+ if (options.max !== undefined && src > options.max) {
10413
+ errors.push({
10414
+ message: "Must be at most ".concat(options.max),
10279
10415
  value: src
10280
- }]));
10416
+ });
10281
10417
  }
10282
- if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.min && src < this.options.min) {
10283
- return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10284
- message: "Expected 'number' greater than ".concat(this.options.min),
10418
+ if (options.min !== undefined && src < options.min) {
10419
+ errors.push({
10420
+ message: "Must be at least ".concat(options.min),
10285
10421
  value: src
10286
- }]));
10422
+ });
10287
10423
  }
10288
- if (customValidationErrors.length > 0) {
10289
- return _defineProperty({}, path, customValidationErrors);
10424
+ if (options.integer && !Number.isInteger(src)) {
10425
+ errors.push({
10426
+ message: "Must be a whole number",
10427
+ value: src
10428
+ });
10429
+ } else if (options.step !== undefined && !isOnStep(src, stepOrigin(options), options.step)) {
10430
+ errors.push({
10431
+ message: "Must be a multiple of ".concat(options.step, ", counted from ").concat(stepOrigin(options)),
10432
+ value: src
10433
+ });
10434
+ }
10435
+ if (errors.length > 0) {
10436
+ return _defineProperty({}, path, errors);
10290
10437
  }
10291
10438
  return false;
10292
10439
  }
@@ -10325,19 +10472,19 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10325
10472
  }, {
10326
10473
  key: "nullable",
10327
10474
  value: function nullable() {
10328
- return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
10475
+ return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10329
10476
  }
10330
10477
  }, {
10331
10478
  key: "readonly",
10332
10479
  value: function readonly() {
10333
10480
  var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
10334
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput);
10481
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10335
10482
  }
10336
10483
  }, {
10337
10484
  key: "hidden",
10338
10485
  value: function hidden() {
10339
10486
  var isHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
10340
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput);
10487
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput, this.renderInput);
10341
10488
  }
10342
10489
 
10343
10490
  /**
@@ -10352,7 +10499,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10352
10499
  value: function max(_max) {
10353
10500
  return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
10354
10501
  max: _max
10355
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
10502
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10356
10503
  }
10357
10504
 
10358
10505
  /**
@@ -10367,7 +10514,50 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10367
10514
  value: function min(_min) {
10368
10515
  return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
10369
10516
  min: _min
10370
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
10517
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10518
+ }
10519
+
10520
+ /**
10521
+ * Validate that the number is on a grid of `step`: one of `min`, `min + step`,
10522
+ * `min + 2 * step` and so on, counted from 0 when there is no `.min()`.
10523
+ *
10524
+ * A slider rendered on this field moves in the same steps unless its render
10525
+ * says otherwise (and then its step has to be a multiple of this one).
10526
+ *
10527
+ * @example
10528
+ * const schema = s.int().min(0).max(100).step(5);
10529
+ * export default c.define("/example.val.ts", schema, 40);
10530
+ */
10531
+ }, {
10532
+ key: "step",
10533
+ value: function step(_step) {
10534
+ return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
10535
+ step: _step
10536
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
10537
+ }
10538
+
10539
+ /**
10540
+ * Choose how this field is edited. `{ as: "slider", min, max }` edits it with
10541
+ * a slider from `min` to `max`, next to a box for typing an exact value.
10542
+ *
10543
+ * `min` and `max` are required — a slider without ends is not a slider — and
10544
+ * they are the slider's, not validation: use `.min()` / `.max()` for what the
10545
+ * value may be. The slider can only produce values this schema accepts, so
10546
+ * its range must lie inside `.min()`/`.max()`, its `step` (which defaults to
10547
+ * `.step()`, then 1) must be a multiple of `.step()`, and on `s.int()` all of
10548
+ * them must be whole numbers. A schema that breaks this throws here.
10549
+ *
10550
+ * Static configuration, not a callback — see `render.ts`. A second
10551
+ * `.render(...)` replaces the first.
10552
+ *
10553
+ * @example
10554
+ * const schema = s.int().render({ as: "slider", min: 0, max: 100, step: 5 });
10555
+ * export default c.define("/example.val.ts", schema, 40);
10556
+ */
10557
+ }, {
10558
+ key: "render",
10559
+ value: function render(input) {
10560
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
10371
10561
  }
10372
10562
  }, {
10373
10563
  key: "executeCustomValidateAt",
@@ -10391,7 +10581,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10391
10581
  }, {
10392
10582
  key: "preview",
10393
10583
  value: function preview(select) {
10394
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
10584
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
10395
10585
  }
10396
10586
  }, {
10397
10587
  key: "executePreviewItem",
@@ -10411,11 +10601,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10411
10601
  }, {
10412
10602
  key: "executeSerialize",
10413
10603
  value: function executeSerialize() {
10414
- var _this$customValidateF;
10604
+ var _this$renderInput, _this$customValidateF;
10415
10605
  return {
10416
10606
  type: "number",
10417
10607
  preview: this.previewInput ? true : undefined,
10418
10608
  options: this.options,
10609
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
10419
10610
  opt: this.opt,
10420
10611
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
10421
10612
  readonly: this.isReadonly,
@@ -10428,6 +10619,63 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
10428
10619
  var number = function number(options) {
10429
10620
  return new NumberSchema(options);
10430
10621
  };
10622
+ var _int = function _int() {
10623
+ return new NumberSchema({
10624
+ integer: true
10625
+ });
10626
+ };
10627
+ function assertNumberSchemaIsConsistent(options, render) {
10628
+ var opts = options !== null && options !== void 0 ? options : {};
10629
+ var kind = opts.integer ? "s.int()" : "s.number()";
10630
+ if (opts.step !== undefined) {
10631
+ if (!(opts.step > 0) || !Number.isFinite(opts.step)) {
10632
+ throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step must be above 0"));
10633
+ }
10634
+ if (opts.integer && !Number.isInteger(opts.step)) {
10635
+ throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step of an int must be a whole number"));
10636
+ }
10637
+ }
10638
+ if (render === null) {
10639
+ return;
10640
+ }
10641
+ var where = "".concat(kind, ".render({ as: \"slider\", min: ").concat(render.min, ", max: ").concat(render.max, " })");
10642
+ if (!Number.isFinite(render.min) || !Number.isFinite(render.max)) {
10643
+ throw new Error("".concat(where, ": the slider needs a min and a max"));
10644
+ }
10645
+ if (!(render.min < render.max)) {
10646
+ throw new Error("".concat(where, ": the slider's min must be below its max"));
10647
+ }
10648
+ if (opts.min !== undefined && render.min < opts.min) {
10649
+ throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is below the schema's min ").concat(opts.min));
10650
+ }
10651
+ if (opts.max !== undefined && render.max > opts.max) {
10652
+ throw new Error("".concat(where, ": the slider's max ").concat(render.max, " is above the schema's max ").concat(opts.max));
10653
+ }
10654
+ if (render.step !== undefined && !(render.step > 0)) {
10655
+ throw new Error("".concat(where, ": the slider's step must be above 0"));
10656
+ }
10657
+ if (opts.integer) {
10658
+ var sliderNumbers = [["min", render.min], ["max", render.max], ["step", render.step]];
10659
+ for (var _i = 0, _sliderNumbers = sliderNumbers; _i < _sliderNumbers.length; _i++) {
10660
+ var _sliderNumbers$_i = _slicedToArray(_sliderNumbers[_i], 2),
10661
+ name = _sliderNumbers$_i[0],
10662
+ value = _sliderNumbers$_i[1];
10663
+ if (value !== undefined && !Number.isInteger(value)) {
10664
+ throw new Error("".concat(where, ": the slider's ").concat(name, " ").concat(value, " must be a whole number on an int"));
10665
+ }
10666
+ }
10667
+ }
10668
+ if (opts.step !== undefined) {
10669
+ var _render$step;
10670
+ var sliderStep = (_render$step = render.step) !== null && _render$step !== void 0 ? _render$step : opts.step;
10671
+ if (!isOnStep(sliderStep, 0, opts.step)) {
10672
+ throw new Error("".concat(where, ": the slider's step ").concat(sliderStep, " must be a multiple of the schema's step ").concat(opts.step));
10673
+ }
10674
+ if (!isOnStep(render.min, stepOrigin(opts), opts.step)) {
10675
+ throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is not one of the schema's steps (").concat(opts.step, ", counted from ").concat(stepOrigin(opts), ")"));
10676
+ }
10677
+ }
10678
+ }
10431
10679
 
10432
10680
  /**
10433
10681
  * @deprecated Use {@link SerializedDiscriminatedUnionSchema} or
@@ -11027,10 +11275,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
11027
11275
  if (galleryKeyOf(src.path, function (key) {
11028
11276
  return key in galleryEntries;
11029
11277
  }) === null) {
11030
- return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
11031
- message: "The gallery does not have a file at '".concat(src.path, "'."),
11032
- value: src
11033
- }]));
11278
+ var _Object$keys$;
11279
+ return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [galleryMarker("file", src, (_Object$keys$ = Object.keys(this.moduleMetadata)[0]) !== null && _Object$keys$ !== void 0 ? _Object$keys$ : "")]));
11034
11280
  }
11035
11281
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
11036
11282
  }
@@ -11486,10 +11732,7 @@ var VideoSchema = /*#__PURE__*/function (_Schema) {
11486
11732
  }
11487
11733
  var entry = gallery.entries === null ? null : gallery.entries[src.path];
11488
11734
  if (entry === undefined) {
11489
- return [{
11490
- message: "The set does not have a video at '".concat(src.path, "'."),
11491
- value: src
11492
- }];
11735
+ return [galleryMarker("video", src, gallery.modulePath)];
11493
11736
  }
11494
11737
  // The poster and the captions are the field's own files, and live where
11495
11738
  // the set keeps its videos. The video itself is the set's to move.
@@ -13206,6 +13449,7 @@ function initSchema(options) {
13206
13449
  array: array,
13207
13450
  object: object,
13208
13451
  number: number,
13452
+ "int": _int,
13209
13453
  discriminatedUnion: discriminatedUnion,
13210
13454
  "enum": enumSchema,
13211
13455
  union: union,
@@ -15116,7 +15360,7 @@ function deserializeSchema(serialized) {
15116
15360
  return schema;
15117
15361
  }
15118
15362
  function deserializeSchemaImpl(serialized) {
15119
- var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$render2, _serialized$external, _serialized$render3, _serialized$render4, _serialized$remote2, _serialized$readonly, _serialized$hidden;
15363
+ var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$render2, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$render3, _serialized$external, _serialized$render4, _serialized$render5, _serialized$remote2, _serialized$readonly, _serialized$hidden;
15120
15364
  switch (serialized.type) {
15121
15365
  case "string":
15122
15366
  return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
@@ -15128,7 +15372,7 @@ function deserializeSchemaImpl(serialized) {
15128
15372
  case "boolean":
15129
15373
  return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
15130
15374
  case "number":
15131
- return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
15375
+ return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, null, (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null);
15132
15376
  case "object":
15133
15377
  return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
15134
15378
  var _ref2 = _slicedToArray(_ref, 2),
@@ -15151,7 +15395,7 @@ function deserializeSchemaImpl(serialized) {
15151
15395
  case "array":
15152
15396
  return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
15153
15397
  // The preview closure cannot survive serialization; the render can.
15154
- null, (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null);
15398
+ null, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
15155
15399
  case "discriminated-union":
15156
15400
  return new DiscriminatedUnionSchema(serialized.key,
15157
15401
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -15180,12 +15424,12 @@ function deserializeSchemaImpl(serialized) {
15180
15424
  altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
15181
15425
  } : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
15182
15426
  // The preview closure cannot survive serialization; the render can.
15183
- null, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null, // The external label is static data, so it survives serialization and
15427
+ null, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null, // The external label is static data, so it survives serialization and
15184
15428
  // must be carried back: a deserialized schema that forgot it would walk
15185
15429
  // an external record as if its entries were local.
15186
15430
  (_serialized$external = serialized.external) !== null && _serialized$external !== void 0 ? _serialized$external : null);
15187
15431
  case "keyOf":
15188
- return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null);
15432
+ return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
15189
15433
  case "locale":
15190
15434
  {
15191
15435
  return new LocaleSchema(serialized.opt, [], false, false, serialized.description);
@@ -15203,7 +15447,7 @@ function deserializeSchemaImpl(serialized) {
15203
15447
  case "image":
15204
15448
  return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
15205
15449
  case "video":
15206
- return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null, null, serialized.referencedModule ? {
15450
+ return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null, null, serialized.referencedModule ? {
15207
15451
  modulePath: serialized.referencedModule,
15208
15452
  entries: null,
15209
15453
  remote: (_serialized$remote2 = serialized.remote) !== null && _serialized$remote2 !== void 0 ? _serialized$remote2 : false
@@ -15262,11 +15506,12 @@ function deserializeSchemaImpl(serialized) {
15262
15506
  */
15263
15507
  /**
15264
15508
  * A RENDER is how a field is laid out in the editor, and it applies only when
15265
- * you are looking at the field. It is declared by a CONTAINER about its
15266
- * children, never by a child about itself: `s.array(item).render({ as: "inline" })`
15267
- * and `s.record(item).render({ as: "inline" })`. The one other schema that takes
15268
- * a render is `s.keyOf(...)`, where it means something of its own (see
15269
- * `KeyOfSchema.render`).
15509
+ * you are looking at the field. On a list it is declared by the CONTAINER about
15510
+ * its children, never by a child about itself: `s.array(item).render({ as: "inline" })`
15511
+ * and `s.record(item).render({ as: "inline" })`. Two other schemas take a
15512
+ * render, each meaning something of its own: `s.keyOf(...)` (see
15513
+ * `KeyOfSchema.render`) and `s.number()` / `s.int()`, whose `{ as: "slider" }`
15514
+ * is a different input for the same value (see {@link SliderRender}).
15270
15515
  *
15271
15516
  * Why the container: inline is a property of the LIST — "my items are edited in
15272
15517
  * their rows" — and the item schema is the wrong place to say it. An item can be
@@ -15322,6 +15567,33 @@ function deserializeSchemaImpl(serialized) {
15322
15567
  * What `.render(...)` takes, and what the serialized schema carries verbatim.
15323
15568
  */
15324
15569
 
15570
+ /**
15571
+ * `{ as: "slider", min, max }` on `s.int()` or `s.number()`: the value is
15572
+ * edited with a slider from `min` to `max`, next to a box that takes a typed
15573
+ * value.
15574
+ *
15575
+ * `min` and `max` are REQUIRED, because a slider without ends is not a slider.
15576
+ * They are the slider's own and are not validation: a value outside them is
15577
+ * still valid content (if the schema allows it), and the field says it is out
15578
+ * of the slider's reach and offers to bring it back. What the schema accepts is
15579
+ * `.min()`, `.max()` and `.step()` on the schema itself.
15580
+ *
15581
+ * The one rule tying the two together: **the slider may only produce values
15582
+ * the schema accepts.** So its range has to lie inside the schema's, its step
15583
+ * has to be a multiple of the schema's step and its `min` on the schema's grid,
15584
+ * and on `s.int()` all of them have to be whole numbers. A schema that breaks
15585
+ * that throws where it is defined — see `NumberSchema`.
15586
+ *
15587
+ * `step` defaults to the schema's `.step()`, and to 1 when there is none.
15588
+ *
15589
+ * Unlike `inline` this is about the field itself — no list reads it, and
15590
+ * {@link isInlineRender} answers `false` for it.
15591
+ */
15592
+
15593
+ /**
15594
+ * What `s.number().render(...)` and `s.int().render(...)` take.
15595
+ */
15596
+
15325
15597
  /**
15326
15598
  * Does this CONTAINER edit its items inside their list rows, rather than behind
15327
15599
  * clickable preview rows that navigate to them?
@@ -15903,7 +16175,7 @@ function isPageRouter(routerId) {
15903
16175
 
15904
16176
  var corePackageJson = {
15905
16177
  name: "@valbuild/core",
15906
- version: "0.144.0",
16178
+ version: "0.146.2",
15907
16179
  "private": false,
15908
16180
  description: "Val - supercharged hard-coded content",
15909
16181
  repository: {
@@ -16010,6 +16282,7 @@ var Internal = {
16010
16282
  galleriesOf: galleriesOf,
16011
16283
  galleryEntryOf: galleryEntryOf,
16012
16284
  galleryKeyOf: galleryKeyOf,
16285
+ galleryMarkerOf: galleryMarkerOf,
16013
16286
  GALLERY_DEFAULT_GROUPS: GALLERY_DEFAULT_GROUPS,
16014
16287
  isHlsVideo: isHlsVideo,
16015
16288
  HLS_MIME_TYPE: HLS_MIME_TYPE
@@ -16030,6 +16303,11 @@ var Internal = {
16030
16303
  rejectScheme: rejectScheme,
16031
16304
  schemeOf: schemeOf,
16032
16305
  UNSAFE_URL_SCHEMES: UNSAFE_URL_SCHEMES,
16306
+ number: {
16307
+ nearestAllowedNumber: nearestAllowedNumber,
16308
+ isOnStep: isOnStep,
16309
+ stepOrigin: stepOrigin
16310
+ },
16033
16311
  color: {
16034
16312
  parseColor: parseColor,
16035
16313
  formatColor: formatColor,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-8b22b2c1.cjs.dev.js');
5
+ var dist_valbuildCore = require('./index-89993829.cjs.dev.js');
6
6
  require('./result-bb1f436e.cjs.dev.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-2d194c90.cjs.prod.js');
5
+ var dist_valbuildCore = require('./index-4bd4b62a.cjs.prod.js');
6
6
  require('./result-787e35f6.cjs.prod.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { H as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, a4 as CODE_LANGUAGES, a5 as COLOR_FORMATS, a3 as CodeSchema, a2 as ColorSchema, e as DEFAULT_APP_HOST, a6 as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, u as DEFAULT_FONT_ACCEPT, f as DEFAULT_STATIC_HOST, o as DEFAULT_VAL_REMOTE_HOST, x as DEFAULT_VIDEO_ACCEPT, y as DEFAULT_VIDEO_RENDITIONS, z as DEFAULT_VIDEO_SEGMENT_DURATION, C as DateSchema, a7 as DateTimeSchema, ad as DiscriminatedUnionSchema, ae as EnumSchema, F as FATAL_ERROR_TYPES, v as FONT_MIME_TYPES, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, a8 as KeyOfSchema, af as LiteralSchema, Z as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, ac as RichTextSchema, ab as RouteSchema, Q as SETTINGS_MODULE_CONVENTION, S as Schema, E as SettingsSchema, q as StringSchema, T as THEME_LOGO_DIRECTORY, K as THEME_RADIUS_LENGTHS, J as THEME_RADIUS_STEPS, at as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a9 as ValViewSchema, w as VideoSchema, L as assistantAvailability, k as computeSchemaSha, j as computeSourcesSha, h as computeValModuleShas, $ as declaredKeySetOf, p as derefPatch, ap as describeSchemeRejection, ag as deserializeSchema, a1 as discriminatedUnionBranchOf, g as extractValModules, an as getSourcePathFromRoute, n as hasMediaSchema, l as hasRemoteFileSchema, i as initVal, aq as isCheckableScheme, ai as isInlineRender, ao as isPageRouter, U as isRootModuleFilePath, aa as isValViewSource, Y as localeOfValue, X as localeTagError, a0 as missingDeclaredKeys, m as modules, aj as parseNextJsRoutePattern, ak as parseTanStackRoutePattern, ah as previewScope, ar as rejectScheme, W as resolveSettingsModule, as as schemeOf, al as tanStackSegmentsOfRoutePath, am as validateUrlAgainstPattern } from './index-aa16dd90.esm.js';
1
+ export { H as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, a4 as CODE_LANGUAGES, a5 as COLOR_FORMATS, a3 as CodeSchema, a2 as ColorSchema, e as DEFAULT_APP_HOST, a6 as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, u as DEFAULT_FONT_ACCEPT, f as DEFAULT_STATIC_HOST, o as DEFAULT_VAL_REMOTE_HOST, x as DEFAULT_VIDEO_ACCEPT, y as DEFAULT_VIDEO_RENDITIONS, z as DEFAULT_VIDEO_SEGMENT_DURATION, C as DateSchema, a7 as DateTimeSchema, ad as DiscriminatedUnionSchema, ae as EnumSchema, F as FATAL_ERROR_TYPES, v as FONT_MIME_TYPES, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, a8 as KeyOfSchema, af as LiteralSchema, Z as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, ac as RichTextSchema, ab as RouteSchema, Q as SETTINGS_MODULE_CONVENTION, S as Schema, E as SettingsSchema, q as StringSchema, T as THEME_LOGO_DIRECTORY, K as THEME_RADIUS_LENGTHS, J as THEME_RADIUS_STEPS, at as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a9 as ValViewSchema, w as VideoSchema, L as assistantAvailability, k as computeSchemaSha, j as computeSourcesSha, h as computeValModuleShas, $ as declaredKeySetOf, p as derefPatch, ap as describeSchemeRejection, ag as deserializeSchema, a1 as discriminatedUnionBranchOf, g as extractValModules, an as getSourcePathFromRoute, n as hasMediaSchema, l as hasRemoteFileSchema, i as initVal, aq as isCheckableScheme, ai as isInlineRender, ao as isPageRouter, U as isRootModuleFilePath, aa as isValViewSource, Y as localeOfValue, X as localeTagError, a0 as missingDeclaredKeys, m as modules, aj as parseNextJsRoutePattern, ak as parseTanStackRoutePattern, ah as previewScope, ar as rejectScheme, W as resolveSettingsModule, as as schemeOf, al as tanStackSegmentsOfRoutePath, am as validateUrlAgainstPattern } from './index-8519c554.esm.js';
2
2
  import './result-daff1cae.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.144.0",
3
+ "version": "0.146.2",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "repository": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-8b22b2c1.cjs.dev.js');
5
+ var dist_valbuildCore = require('../../dist/index-89993829.cjs.dev.js');
6
6
  var result = require('../../dist/result-bb1f436e.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-2d194c90.cjs.prod.js');
5
+ var dist_valbuildCore = require('../../dist/index-4bd4b62a.cjs.prod.js');
6
6
  var result = require('../../dist/result-787e35f6.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
8
 
@@ -1,5 +1,5 @@
1
- import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-aa16dd90.esm.js';
2
- export { P as PatchError } from '../../dist/index-aa16dd90.esm.js';
1
+ import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-8519c554.esm.js';
2
+ export { P as PatchError } from '../../dist/index-8519c554.esm.js';
3
3
  import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
4
4
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
5
5