@valbuild/core 0.103.0 → 0.105.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.
Files changed (30) hide show
  1. package/dist/declarations/src/index.d.ts +2 -1
  2. package/dist/declarations/src/preview.d.ts +98 -0
  3. package/dist/declarations/src/render.d.ts +29 -91
  4. package/dist/declarations/src/schema/array.d.ts +22 -23
  5. package/dist/declarations/src/schema/boolean.d.ts +2 -2
  6. package/dist/declarations/src/schema/color.d.ts +2 -2
  7. package/dist/declarations/src/schema/date.d.ts +2 -2
  8. package/dist/declarations/src/schema/datetime.d.ts +2 -2
  9. package/dist/declarations/src/schema/file.d.ts +2 -2
  10. package/dist/declarations/src/schema/image.d.ts +2 -2
  11. package/dist/declarations/src/schema/index.d.ts +6 -6
  12. package/dist/declarations/src/schema/keyOf.d.ts +2 -2
  13. package/dist/declarations/src/schema/literal.d.ts +2 -2
  14. package/dist/declarations/src/schema/number.d.ts +2 -2
  15. package/dist/declarations/src/schema/object.d.ts +2 -2
  16. package/dist/declarations/src/schema/record.d.ts +19 -29
  17. package/dist/declarations/src/schema/richtext.d.ts +2 -2
  18. package/dist/declarations/src/schema/route.d.ts +2 -2
  19. package/dist/declarations/src/schema/string.d.ts +28 -17
  20. package/dist/declarations/src/schema/union.d.ts +2 -2
  21. package/dist/{index-2e40f2ae.cjs.dev.js → index-730a5254.cjs.dev.js} +177 -139
  22. package/dist/{index-267a8e9c.esm.js → index-d7cc2231.esm.js} +176 -139
  23. package/dist/{index-3572060f.cjs.prod.js → index-e990b6ad.cjs.prod.js} +177 -139
  24. package/dist/valbuild-core.cjs.dev.js +3 -2
  25. package/dist/valbuild-core.cjs.prod.js +3 -2
  26. package/dist/valbuild-core.esm.js +1 -1
  27. package/package.json +1 -1
  28. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  29. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  30. package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -581,10 +581,10 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
581
581
  }, {
582
582
  key: "executeSerialize",
583
583
  value: function executeSerialize() {
584
- var _this$options4, _this$options5, _this$options6, _this$customValidateF, _this$customValidateF2;
584
+ var _this$renderInput, _this$options4, _this$options5, _this$options6, _this$customValidateF, _this$customValidateF2;
585
585
  return {
586
586
  type: "string",
587
- render: this.renderInput ? true : undefined,
587
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
588
588
  options: {
589
589
  maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
590
590
  minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
@@ -603,36 +603,28 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
603
603
  description: this.description
604
604
  };
605
605
  }
606
+
607
+ /**
608
+ * How this field is laid out in the editor: a textarea, or a code editor for
609
+ * the given language.
610
+ *
611
+ * Static configuration, not a callback — see `render.ts`. What a CONTAINER
612
+ * shows for its items is a `preview`, which is a different thing entirely.
613
+ */
606
614
  }, {
607
615
  key: "render",
608
616
  value: function render(input) {
609
617
  return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description);
610
618
  }
619
+
620
+ /**
621
+ * Nothing: a string has no items, so there is nothing to preview. Its layout
622
+ * is a `render`, which travels in the serialized schema instead of through
623
+ * this pipeline.
624
+ */
611
625
  }, {
612
- key: "executeRender",
613
- value: function executeRender(sourcePath, src,
614
- // Accepted and unused: a string's render is a static layout hint
615
- // (`{as:"textarea"}` / `{as:"code",language}`) with no closure behind it, so
616
- // there is nothing a scope could prune. Declared so the signature is uniform
617
- // across every schema rather than something a reader has to check.
618
- _scope) {
619
- if (this.renderInput) {
620
- if (this.renderInput.as === "code") {
621
- return _defineProperty({}, sourcePath, {
622
- status: "success",
623
- data: {
624
- layout: this.renderInput.as,
625
- language: this.renderInput.language
626
- }
627
- });
628
- }
629
- return _defineProperty({}, sourcePath, {
630
- status: "success",
631
- data: {
632
- layout: this.renderInput.as
633
- }
634
- });
635
- }
626
+ key: "executePreview",
627
+ value: function executePreview() {
636
628
  return {};
637
629
  }
638
630
  }]);
@@ -827,8 +819,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
827
819
  };
828
820
  }
829
821
  }, {
830
- key: "executeRender",
831
- value: function executeRender(sourcePath, src, scope) {
822
+ key: "executePreview",
823
+ value: function executePreview(sourcePath, src, scope) {
832
824
  var res = {};
833
825
  if (src === null) {
834
826
  return res;
@@ -839,13 +831,13 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
839
831
  continue;
840
832
  }
841
833
  var subPath = unsafeCreateSourcePath(sourcePath, _key3);
842
- // An object produces no render of its own, so it is pure recursion — and
834
+ // An object produces no preview of its own, so it is pure recursion — and
843
835
  // pruning it is the whole contribution: a field deep in one branch stops
844
- // paying for every sibling branch's renders.
836
+ // paying for every sibling branch's previews.
845
837
  if (scope !== undefined && !scope.wantsUnder(subPath)) {
846
838
  continue;
847
839
  }
848
- var itemResult = this.items[_key3]["executeRender"](subPath, itemSrc, scope);
840
+ var itemResult = this.items[_key3]["executePreview"](subPath, itemSrc, scope);
849
841
  for (var keyS in itemResult) {
850
842
  var _key4 = keyS;
851
843
  res[_key4] = itemResult[_key4];
@@ -872,7 +864,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
872
864
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
873
865
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
874
866
  var description = arguments.length > 5 ? arguments[5] : undefined;
875
- var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
867
+ var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
876
868
  _classCallCheck(this, ArraySchema);
877
869
  _this = _callSuper(this, ArraySchema);
878
870
  _this.item = item;
@@ -881,19 +873,19 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
881
873
  _this.isReadonly = isReadonly;
882
874
  _this.isHidden = isHidden;
883
875
  _this.description = description;
884
- _this.renderInput = renderInput;
876
+ _this.previewInput = previewInput;
885
877
  return _this;
886
878
  }
887
879
  _inherits(ArraySchema, _Schema);
888
880
  return _createClass(ArraySchema, [{
889
881
  key: "describe",
890
882
  value: function describe(description) {
891
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput);
883
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
892
884
  }
893
885
  }, {
894
886
  key: "validate",
895
887
  value: function validate(validationFunction) {
896
- return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput);
888
+ return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
897
889
  }
898
890
  }, {
899
891
  key: "executeValidate",
@@ -960,17 +952,17 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
960
952
  }, {
961
953
  key: "nullable",
962
954
  value: function nullable() {
963
- return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput);
955
+ return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.previewInput);
964
956
  }
965
957
  }, {
966
958
  key: "readonly",
967
959
  value: function readonly() {
968
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput);
960
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.previewInput);
969
961
  }
970
962
  }, {
971
963
  key: "hidden",
972
964
  value: function hidden() {
973
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput);
965
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.previewInput);
974
966
  }
975
967
  }, {
976
968
  key: "executeCustomValidateAt",
@@ -987,7 +979,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
987
979
  type: "array",
988
980
  item: this.item["executeSerialize"](),
989
981
  opt: this.opt,
990
- render: this.renderInput ? true : undefined,
982
+ preview: this.previewInput ? true : undefined,
991
983
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
992
984
  readonly: this.isReadonly,
993
985
  hidden: this.isHidden,
@@ -995,8 +987,8 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
995
987
  };
996
988
  }
997
989
  }, {
998
- key: "executeRender",
999
- value: function executeRender(sourcePath, src, scope) {
990
+ key: "executePreview",
991
+ value: function executePreview(sourcePath, src, scope) {
1000
992
  var res = {};
1001
993
  if (src === null) {
1002
994
  return res;
@@ -1011,26 +1003,18 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1011
1003
  if (scope !== undefined && !scope.wantsUnder(subPath)) {
1012
1004
  continue;
1013
1005
  }
1014
- var itemResult = this.item["executeRender"](subPath, itemSrc, scope);
1006
+ var itemResult = this.item["executePreview"](subPath, itemSrc, scope);
1015
1007
  for (var keyS in itemResult) {
1016
1008
  var _key = keyS;
1017
1009
  res[_key] = itemResult[_key];
1018
1010
  }
1019
1011
  }
1020
- if (this.renderInput) {
1021
- var _this$renderInput = this.renderInput,
1022
- select = _this$renderInput.select,
1023
- layout = _this$renderInput.as;
1024
- if (layout !== "list") {
1025
- res[sourcePath] = {
1026
- status: "error",
1027
- message: "Unknown layout type: " + layout
1028
- };
1029
- }
1012
+ if (this.previewInput) {
1013
+ var select = this.previewInput;
1030
1014
  // The whole list when the LIST is what is being shown; only the wanted
1031
- // rows when it is not. `select` is the user's closure and the real expense
1032
- // — a list view asks for the container and gets every row, a single field
1033
- // asks for its own path and costs one call.
1015
+ // rows when it is not. The user's closure is the real expense — a list
1016
+ // view asks for the container and gets every row, a single field asks for
1017
+ // its own path and costs one call.
1034
1018
  // Non-null once, as a value, rather than a boolean the compiler cannot
1035
1019
  // tie back to `scope`: no scope and a scope that wants this exact path
1036
1020
  // both mean the whole list, and anything else is a window.
@@ -1040,10 +1024,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1040
1024
  if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, index))) {
1041
1025
  continue;
1042
1026
  }
1043
- // Per ITEM, not per list, matching what `record` already does: `select`
1044
- // is user code, and one row whose data trips it up must not take out the
1045
- // whole list. Before scoping, one throwing row produced an error at the
1046
- // container and no items at all.
1027
+ // Per ITEM, not per list, matching what `record` already does: the
1028
+ // closure is user code, and one row whose data trips it up must not take
1029
+ // out the whole list. Before scoping, one throwing row produced an error
1030
+ // at the container and no items at all.
1047
1031
  try {
1048
1032
  // NB NB: display is actually defined by the user
1049
1033
  var _select = select({
@@ -1067,7 +1051,6 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1067
1051
  res[sourcePath] = {
1068
1052
  status: "success",
1069
1053
  data: {
1070
- layout: "list",
1071
1054
  parent: "array",
1072
1055
  items: items
1073
1056
  }
@@ -1075,10 +1058,18 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1075
1058
  }
1076
1059
  return res;
1077
1060
  }
1061
+
1062
+ /**
1063
+ * What the editor shows for each ITEM of this array: a title, and optionally a
1064
+ * subtitle and an image.
1065
+ *
1066
+ * `select` is your own code over the item's source, so it is run on demand for
1067
+ * the rows that are actually being looked at — see `PreviewScope`.
1068
+ */
1078
1069
  }, {
1079
- key: "render",
1080
- value: function render(input) {
1081
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input);
1070
+ key: "preview",
1071
+ value: function preview(select) {
1072
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
1082
1073
  }
1083
1074
  }]);
1084
1075
  }(Schema);
@@ -1210,8 +1201,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1210
1201
  };
1211
1202
  }
1212
1203
  }, {
1213
- key: "executeRender",
1214
- value: function executeRender() {
1204
+ key: "executePreview",
1205
+ value: function executePreview() {
1215
1206
  return {};
1216
1207
  }
1217
1208
  }]);
@@ -1644,8 +1635,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1644
1635
  };
1645
1636
  }
1646
1637
  }, {
1647
- key: "executeRender",
1648
- value: function executeRender(sourcePath, src, scope) {
1638
+ key: "executePreview",
1639
+ value: function executePreview(sourcePath, src, scope) {
1649
1640
  var res = {};
1650
1641
  if (src === null) {
1651
1642
  return res;
@@ -1667,7 +1658,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1667
1658
  return false;
1668
1659
  });
1669
1660
  if (thisSchema) {
1670
- var itemResult = thisSchema["executeRender"](sourcePath, src, scope);
1661
+ var itemResult = thisSchema["executePreview"](sourcePath, src, scope);
1671
1662
  for (var keyS in itemResult) {
1672
1663
  var _key3 = keyS;
1673
1664
  res[_key3] = itemResult[_key3];
@@ -2130,8 +2121,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
2130
2121
  };
2131
2122
  }
2132
2123
  }, {
2133
- key: "executeRender",
2134
- value: function executeRender() {
2124
+ key: "executePreview",
2125
+ value: function executePreview() {
2135
2126
  return {};
2136
2127
  }
2137
2128
  }]);
@@ -2327,8 +2318,8 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2327
2318
  };
2328
2319
  }
2329
2320
  }, {
2330
- key: "executeRender",
2331
- value: function executeRender() {
2321
+ key: "executePreview",
2322
+ value: function executePreview() {
2332
2323
  return {};
2333
2324
  }
2334
2325
  }]);
@@ -2886,8 +2877,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2886
2877
  };
2887
2878
  }
2888
2879
  }, {
2889
- key: "executeRender",
2890
- value: function executeRender() {
2880
+ key: "executePreview",
2881
+ value: function executePreview() {
2891
2882
  return {};
2892
2883
  }
2893
2884
  }]);
@@ -3220,7 +3211,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3220
3211
  var isHidden = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
3221
3212
  var description = arguments.length > 8 ? arguments[8] : undefined;
3222
3213
  var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
3223
- var renderInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
3214
+ var previewInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
3224
3215
  _classCallCheck(this, RecordSchema);
3225
3216
  _this = _callSuper(this, RecordSchema);
3226
3217
  _this.item = item;
@@ -3233,19 +3224,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3233
3224
  _this.isHidden = isHidden;
3234
3225
  _this.description = description;
3235
3226
  _this.isJsonValues = isJsonValues;
3236
- _this.renderInput = renderInput;
3227
+ _this.previewInput = previewInput;
3237
3228
  return _this;
3238
3229
  }
3239
3230
  _inherits(RecordSchema, _Schema);
3240
3231
  return _createClass(RecordSchema, [{
3241
3232
  key: "describe",
3242
3233
  value: function describe(description) {
3243
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.renderInput);
3234
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.previewInput);
3244
3235
  }
3245
3236
  }, {
3246
3237
  key: "validate",
3247
3238
  value: function validate(validationFunction) {
3248
- return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
3239
+ return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3249
3240
  }
3250
3241
  }, {
3251
3242
  key: "executeValidate",
@@ -3604,29 +3595,29 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3604
3595
  }, {
3605
3596
  key: "nullable",
3606
3597
  value: function nullable() {
3607
- return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
3598
+ return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3608
3599
  }
3609
3600
  }, {
3610
3601
  key: "readonly",
3611
3602
  value: function readonly() {
3612
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.renderInput);
3603
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3613
3604
  }
3614
3605
  }, {
3615
3606
  key: "hidden",
3616
3607
  value: function hidden() {
3617
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.renderInput);
3608
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.previewInput);
3618
3609
  }
3619
3610
  }, {
3620
3611
  key: "router",
3621
3612
  value: function router(_router) {
3622
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
3613
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3623
3614
  }
3624
3615
  }, {
3625
3616
  key: "remote",
3626
3617
  value: function remote() {
3627
3618
  return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
3628
3619
  remote: true
3629
- }) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
3620
+ }) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3630
3621
  }
3631
3622
 
3632
3623
  /**
@@ -3658,7 +3649,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3658
3649
  }
3659
3650
  return new RecordSchema(this.item, this.opt,
3660
3651
  // Empty by construction: the guard above rejects any that were registered.
3661
- [], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true, this.renderInput);
3652
+ [], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true, this.previewInput);
3662
3653
  }
3663
3654
  }, {
3664
3655
  key: "getRouterValidations",
@@ -3718,7 +3709,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3718
3709
  item: this.item["executeSerialize"](),
3719
3710
  key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
3720
3711
  opt: this.opt,
3721
- render: this.renderInput ? true : undefined,
3712
+ preview: this.previewInput ? true : undefined,
3722
3713
  router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
3723
3714
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
3724
3715
  jsonValues: this.isJsonValues ? true : undefined,
@@ -3750,8 +3741,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3750
3741
  return this.item["executeValidate"](path, content);
3751
3742
  }
3752
3743
  }, {
3753
- key: "executeRender",
3754
- value: function executeRender(sourcePath, src, scope) {
3744
+ key: "executePreview",
3745
+ value: function executePreview(sourcePath, src, scope) {
3755
3746
  var res = {};
3756
3747
  if (src === null) {
3757
3748
  return res;
@@ -3763,31 +3754,23 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3763
3754
  }
3764
3755
  if (isJson(itemSrc)) {
3765
3756
  // An un-loaded `.jsonValues()` entry: an opaque marker, not the item this
3766
- // schema describes. Skipping it is what makes rendering a partially
3757
+ // schema describes. Skipping it is what makes previewing a partially
3767
3758
  // loaded record work — the result comes out covering exactly the loaded
3768
- // keys, and the caller renders a placeholder for the rest.
3759
+ // keys, and the caller shows a placeholder for the rest.
3769
3760
  continue;
3770
3761
  }
3771
3762
  var subPath = unsafeCreateSourcePath(sourcePath, _key);
3772
3763
  if (scope !== undefined && !scope.wantsUnder(subPath)) {
3773
3764
  continue;
3774
3765
  }
3775
- var itemResult = this.item["executeRender"](subPath, itemSrc, scope);
3766
+ var itemResult = this.item["executePreview"](subPath, itemSrc, scope);
3776
3767
  for (var keyS in itemResult) {
3777
3768
  var _key2 = keyS;
3778
3769
  res[_key2] = itemResult[_key2];
3779
3770
  }
3780
3771
  }
3781
- if (this.renderInput) {
3782
- var _this$renderInput = this.renderInput,
3783
- prepare = _this$renderInput.select,
3784
- layout = _this$renderInput.layout;
3785
- if (layout !== "list") {
3786
- res[sourcePath] = {
3787
- status: "error",
3788
- message: "Unknown layout type: " + layout
3789
- };
3790
- }
3772
+ if (this.previewInput) {
3773
+ var prepare = this.previewInput;
3791
3774
  // See the same block in `array`: the whole record when the record is what
3792
3775
  // is being shown, only the wanted entries when it is not.
3793
3776
  var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
@@ -3802,7 +3785,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3802
3785
  if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, _key3))) {
3803
3786
  continue;
3804
3787
  }
3805
- // Per KEY, not per record: `select` is user code, and one entry whose
3788
+ // Per KEY, not per record: the closure is user code, and one entry whose
3806
3789
  // data trips it up must not take out the whole list.
3807
3790
  try {
3808
3791
  // NB NB: display is actually defined by the user
@@ -3828,7 +3811,6 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3828
3811
  res[sourcePath] = {
3829
3812
  status: "success",
3830
3813
  data: {
3831
- layout: "list",
3832
3814
  parent: "record",
3833
3815
  items: items
3834
3816
  }
@@ -3836,13 +3818,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3836
3818
  }
3837
3819
  return res;
3838
3820
  }
3821
+
3822
+ /**
3823
+ * What the editor shows for each ENTRY of this record: a title, and optionally
3824
+ * a subtitle and an image.
3825
+ *
3826
+ * `select` is your own code over the entry's key and source, so it is run on
3827
+ * demand for the entries that are actually being looked at — see
3828
+ * `PreviewScope`.
3829
+ */
3839
3830
  }, {
3840
- key: "render",
3841
- value: function render(input) {
3842
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, {
3843
- layout: input.as,
3844
- select: input.select
3845
- });
3831
+ key: "preview",
3832
+ value: function preview(select) {
3833
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, select);
3846
3834
  }
3847
3835
  }]);
3848
3836
  }(Schema);
@@ -4535,8 +4523,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
4535
4523
  };
4536
4524
  }
4537
4525
  }, {
4538
- key: "executeRender",
4539
- value: function executeRender() {
4526
+ key: "executePreview",
4527
+ value: function executePreview() {
4540
4528
  return {};
4541
4529
  }
4542
4530
  }]);
@@ -4655,8 +4643,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
4655
4643
  };
4656
4644
  }
4657
4645
  }, {
4658
- key: "executeRender",
4659
- value: function executeRender() {
4646
+ key: "executePreview",
4647
+ value: function executePreview() {
4660
4648
  return {};
4661
4649
  }
4662
4650
  }]);
@@ -4879,8 +4867,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4879
4867
  };
4880
4868
  }
4881
4869
  }, {
4882
- key: "executeRender",
4883
- value: function executeRender() {
4870
+ key: "executePreview",
4871
+ value: function executePreview() {
4884
4872
  return {};
4885
4873
  }
4886
4874
  }]);
@@ -5163,8 +5151,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
5163
5151
  };
5164
5152
  }
5165
5153
  }, {
5166
- key: "executeRender",
5167
- value: function executeRender() {
5154
+ key: "executePreview",
5155
+ value: function executePreview() {
5168
5156
  return {};
5169
5157
  }
5170
5158
  }]);
@@ -5394,8 +5382,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
5394
5382
  };
5395
5383
  }
5396
5384
  }, {
5397
- key: "executeRender",
5398
- value: function executeRender() {
5385
+ key: "executePreview",
5386
+ value: function executePreview() {
5399
5387
  return {};
5400
5388
  }
5401
5389
  }]);
@@ -5598,8 +5586,8 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
5598
5586
  };
5599
5587
  }
5600
5588
  }, {
5601
- key: "executeRender",
5602
- value: function executeRender() {
5589
+ key: "executePreview",
5590
+ value: function executePreview() {
5603
5591
  return {};
5604
5592
  }
5605
5593
  }]);
@@ -6239,8 +6227,8 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
6239
6227
  };
6240
6228
  }
6241
6229
  }, {
6242
- key: "executeRender",
6243
- value: function executeRender() {
6230
+ key: "executePreview",
6231
+ value: function executePreview() {
6244
6232
  return {};
6245
6233
  }
6246
6234
  }]);
@@ -8019,13 +8007,16 @@ function deserializeSchema(serialized) {
8019
8007
  return schema;
8020
8008
  }
8021
8009
  function deserializeSchemaImpl(serialized) {
8022
- var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
8010
+ var _serialized$options, _serialized$options2, _serialized$render, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
8023
8011
  switch (serialized.type) {
8024
8012
  case "string":
8025
8013
  return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
8026
8014
  regexp: ((_serialized$options = serialized.options) === null || _serialized$options === void 0 ? void 0 : _serialized$options.regexp) && new RegExp(serialized.options.regexp.source, serialized.options.regexp.flags),
8027
8015
  regExpMessage: (_serialized$options2 = serialized.options) === null || _serialized$options2 === void 0 || (_serialized$options2 = _serialized$options2.regexp) === null || _serialized$options2 === void 0 ? void 0 : _serialized$options2.message
8028
- }), serialized.opt, serialized.raw, [], null, false, false, serialized.description);
8016
+ }), serialized.opt, serialized.raw, [], // A render is static data, so it survives serialization and must be
8017
+ // carried back: it is the schema's own configuration now, not something
8018
+ // recomputed from an instance.
8019
+ (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description);
8029
8020
  case "literal":
8030
8021
  return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description);
8031
8022
  case "boolean":
@@ -8102,31 +8093,46 @@ function deserializeSchemaImpl(serialized) {
8102
8093
  }
8103
8094
  }
8104
8095
 
8105
- // TODO: we want to change layout -> as to be more consistent across the board
8106
-
8107
- // Main render type:
8096
+ /**
8097
+ * What a container shows for ONE of its items: the user's `preview` callback
8098
+ * returns this, and the Studio draws a row from it.
8099
+ *
8100
+ * NB: {@link ArrayPreview} / {@link RecordPreview} name the DATA a container
8101
+ * previews with. The Studio also has React components called `ArrayPreview` /
8102
+ * `RecordPreview` (the fallback rendering of an array / record field, part of
8103
+ * the `<Type>Preview` convention in `components/Preview.tsx`). They do not
8104
+ * collide today because no file needs both - if one ever does, alias this type
8105
+ * at the import rather than renaming that convention.
8106
+ */
8108
8107
 
8109
- //
8108
+ /**
8109
+ * Main preview type.
8110
+ *
8111
+ * Deliberately not exported: `parent` is the discriminant, and every consumer
8112
+ * narrows on it rather than on the union as a whole. There is no `layout` here
8113
+ * on purpose - how a preview is laid out is the editor's business, not the
8114
+ * schema's.
8115
+ */
8110
8116
 
8111
8117
  /**
8112
- * Which paths a render is being computed FOR.
8118
+ * Which paths a preview is being computed FOR.
8113
8119
  *
8114
- * `executeRender` takes a whole module, so one request has always walked every
8115
- * node in it and run every `select` closure — for `handboka`, with `select` at
8120
+ * `executePreview` takes a whole module, so one request has always walked every
8121
+ * node in it and run every `preview` closure - for `handboka`, with `preview` at
8116
8122
  * two nested array levels, that is every chapter and every section to serve one
8117
8123
  * visible row. A scope is what makes the walk proportional to what is being
8118
8124
  * looked at instead of to the project.
8119
8125
  *
8120
8126
  * Two questions, because a container and its items need different answers:
8121
8127
  *
8122
- * - {@link RenderScope.wants} — is a render AT this exact path wanted? A
8128
+ * - {@link PreviewScope.wants} - is a preview AT this exact path wanted? A
8123
8129
  * container answers `true` here when the whole of it is being shown, and its
8124
- * list render is then computed in full.
8125
- * - {@link RenderScope.wantsUnder} — could anything at or below this path be
8130
+ * preview is then computed in full.
8131
+ * - {@link PreviewScope.wantsUnder} - could anything at or below this path be
8126
8132
  * wanted? Recursion is pruned where this is `false`, and a container whose own
8127
- * path is not wanted but which has wanted descendants renders a WINDOW: only
8133
+ * path is not wanted but which has wanted descendants previews a WINDOW: only
8128
8134
  * the items that were asked for. That is the case a single visible row is, and
8129
- * it is why {@link ListArrayRender} carries indices.
8135
+ * it is why {@link ArrayPreview} carries indices.
8130
8136
  *
8131
8137
  * Absent scope means the whole module, which is what every existing caller
8132
8138
  * passes and what every existing caller got.
@@ -8138,10 +8144,10 @@ function deserializeSchemaImpl(serialized) {
8138
8144
  * Compares SEGMENTS rather than string prefixes. A source path's module path is
8139
8145
  * a quoted, dot-joined encoding (`?p="a".1."b"`), so `startsWith` gets the
8140
8146
  * ancestor test wrong wherever a key is a prefix of a sibling key or contains a
8141
- * dot or a quote — `"title"` against `"titles"` being the cheapest example.
8147
+ * dot or a quote - `"title"` against `"titles"` being the cheapest example.
8142
8148
  * Segments are parsed once here, not per comparison.
8143
8149
  */
8144
- function renderScope(paths) {
8150
+ function previewScope(paths) {
8145
8151
  var wanted = paths.map(function (path) {
8146
8152
  var _splitModuleFilePathA = splitModuleFilePathAndModulePath(path),
8147
8153
  _splitModuleFilePathA2 = _slicedToArray(_splitModuleFilePathA, 2),
@@ -8190,6 +8196,37 @@ function renderScope(paths) {
8190
8196
 
8191
8197
  // TODO: improve this so that we do not get RawString and string, only string. Are there other things?
8192
8198
 
8199
+ /**
8200
+ * A RENDER is how one field is laid out in the editor: `s.string().render({ as:
8201
+ * "textarea" })`, `.render({ as: "code", language })`.
8202
+ *
8203
+ * It is static configuration - plain data, with no closure behind it and no
8204
+ * dependency on source - which is why it lives in the SERIALIZED schema
8205
+ * (`SerializedStringSchema.render`) and is read straight off it where the field
8206
+ * is drawn. There is no render pipeline, no store and no host round-trip.
8207
+ *
8208
+ * That "static" is an ASSUMPTION we are taking deliberately, for simplicity,
8209
+ * not a law. A future render could plausibly want to depend on source - a
8210
+ * layout that varies with the value, a callback of its own. If that day comes,
8211
+ * the shape it needs back is `executePreview`'s, and the honest move is to give
8212
+ * `render` its own execute/store pair again. It is NOT to re-merge the two:
8213
+ * conflating them is what this file was split up to undo.
8214
+ *
8215
+ * The dynamic, source-dependent, demand-scoped thing - what a container shows
8216
+ * for its items - is a PREVIEW. See `preview.ts`.
8217
+ */
8218
+ /**
8219
+ * The list is the declaration and {@link CodeLanguage} is derived from it, so
8220
+ * that a validator elsewhere (`shared`'s zod schema) can enumerate the same
8221
+ * languages without a second copy that drifts. Same shape as `COLOR_FORMATS`.
8222
+ */
8223
+ var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
8224
+
8225
+ /**
8226
+ * What `s.string().render(...)` takes, and what the serialized schema carries
8227
+ * verbatim.
8228
+ */
8229
+
8193
8230
  var externalPageRouter = {
8194
8231
  getRouterId: function getRouterId() {
8195
8232
  return "external-url-router";
@@ -8553,4 +8590,4 @@ function tryJsonParse(str) {
8553
8590
  }
8554
8591
  }
8555
8592
 
8556
- export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, DEFAULT_VAL_REMOTE_HOST as g, hasRemoteFileSchema as h, initVal as i, derefPatch as j, StringSchema as k, ImageSchema as l, modules as m, FileSchema as n, DateSchema as o, COLOR_FORMATS as p, DEFAULT_COLOR_FORMAT as q, DateTimeSchema as r, splitModuleFilePathAndModulePath as s, RouteSchema as t, RichTextSchema as u, deserializeSchema as v, renderScope as w, getSourcePathFromRoute as x };
8593
+ export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, DEFAULT_VAL_REMOTE_HOST as g, hasRemoteFileSchema as h, initVal as i, derefPatch as j, StringSchema as k, ImageSchema as l, modules as m, FileSchema as n, DateSchema as o, COLOR_FORMATS as p, DEFAULT_COLOR_FORMAT as q, DateTimeSchema as r, splitModuleFilePathAndModulePath as s, RouteSchema as t, RichTextSchema as u, deserializeSchema as v, previewScope as w, CODE_LANGUAGES as x, getSourcePathFromRoute as y };