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