@fuaran-ui/ops 0.9.0 → 0.21.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/index.cjs +1095 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -12
- package/dist/index.d.ts +123 -12
- package/dist/index.js +1093 -76
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FORM_FIELD_KIND_NAMES, NODE_KIND_GROUPS, defaults,
|
|
1
|
+
import { FORM_FIELD_KIND_NAMES, NODE_KIND_GROUPS, defaults, controlValueDefaults, MAX_NODE_DEPTH, MAX_NODES, MAX_STRING_LENGTH, MAX_JSON_DEPTH, MAX_ARRAY_LENGTH, narrows, admitAll, NODE_KIND_NAMES, admits, policyHint, projectSelectionField } from '@fuaran-ui/schema';
|
|
2
2
|
|
|
3
3
|
// src/encode.ts
|
|
4
4
|
var assertNever = (x) => {
|
|
@@ -78,10 +78,11 @@ var formatFiniteDouble = (n) => {
|
|
|
78
78
|
return neg ? "-" + out : out;
|
|
79
79
|
};
|
|
80
80
|
var num = (n) => {
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
if (
|
|
84
|
-
|
|
81
|
+
const v = Number(n);
|
|
82
|
+
if (Number.isNaN(v)) return '"NaN"';
|
|
83
|
+
if (v === Infinity) return '"Infinity"';
|
|
84
|
+
if (v === -Infinity) return '"-Infinity"';
|
|
85
|
+
return formatFiniteDouble(v);
|
|
85
86
|
};
|
|
86
87
|
var bool = (b) => b ? "true" : "false";
|
|
87
88
|
var jObject = (fields) => {
|
|
@@ -481,7 +482,9 @@ var action = (a) => {
|
|
|
481
482
|
case "CommitLocal":
|
|
482
483
|
return caseObj("CommitLocal", [["nodeId", str(a.nodeId)]]);
|
|
483
484
|
case "WriteToClipboard":
|
|
484
|
-
return caseObj("WriteToClipboard", [["text",
|
|
485
|
+
return caseObj("WriteToClipboard", [["text", textSource(a.text)]]);
|
|
486
|
+
case "Print":
|
|
487
|
+
return caseObj("Print", []);
|
|
485
488
|
case "ReadFileBody":
|
|
486
489
|
return caseObj("ReadFileBody", [
|
|
487
490
|
["encoding", str(a.encoding)],
|
|
@@ -591,6 +594,9 @@ var pushWeightOptional = (fields, w) => {
|
|
|
591
594
|
var pushEmphasisOptional = (fields, e) => {
|
|
592
595
|
if (e !== "Normal") fields.push(["emphasis", str(e)]);
|
|
593
596
|
};
|
|
597
|
+
var pushTrendPolarityOptional = (fields, p) => {
|
|
598
|
+
if (p !== "HigherIsBetter") fields.push(["trendPolarity", str(p)]);
|
|
599
|
+
};
|
|
594
600
|
var pushCellFormatOptional = (fields, key, f) => {
|
|
595
601
|
if (f.kind !== "None") fields.push([key, cellFormat(f)]);
|
|
596
602
|
};
|
|
@@ -608,6 +614,7 @@ var metricSpec = (s) => {
|
|
|
608
614
|
pushEmphasisOptional(fields, s.emphasis);
|
|
609
615
|
if (s.trend !== void 0) fields.push(["trend", binding(s.trend)]);
|
|
610
616
|
if (s.trendFormat !== void 0) fields.push(["trendFormat", cellFormat(s.trendFormat)]);
|
|
617
|
+
pushTrendPolarityOptional(fields, s.trendPolarity);
|
|
611
618
|
if (s.icon !== void 0) fields.push(["icon", str(s.icon)]);
|
|
612
619
|
if (s.subtext !== void 0) fields.push(["subtext", textSource(s.subtext)]);
|
|
613
620
|
return jObject(fields);
|
|
@@ -654,11 +661,76 @@ var linkSpec = (s) => {
|
|
|
654
661
|
if (s.protection !== void 0) fields.push(["protection", str(s.protection)]);
|
|
655
662
|
return jObject(fields);
|
|
656
663
|
};
|
|
657
|
-
var
|
|
658
|
-
["
|
|
659
|
-
["
|
|
660
|
-
["variant", str(s.variant)]
|
|
664
|
+
var srcSetEntry = (e) => jObject([
|
|
665
|
+
["src", binding(e.src)],
|
|
666
|
+
["width", num(e.width)]
|
|
661
667
|
]);
|
|
668
|
+
var imageSpec = (s) => {
|
|
669
|
+
const fields = [
|
|
670
|
+
["alt", textSource(s.alt)],
|
|
671
|
+
["src", binding(s.src)],
|
|
672
|
+
["variant", str(s.variant)]
|
|
673
|
+
];
|
|
674
|
+
if (s.fit !== "Natural") fields.push(["fit", str(s.fit)]);
|
|
675
|
+
if (s.aspectRatio !== "Natural") fields.push(["aspectRatio", str(s.aspectRatio)]);
|
|
676
|
+
if (s.loading !== "Eager") fields.push(["loading", str(s.loading)]);
|
|
677
|
+
if (s.caption !== void 0) fields.push(["caption", textSource(s.caption)]);
|
|
678
|
+
if (s.srcSet.length > 0) fields.push(["srcSet", jArray(s.srcSet.map(srcSetEntry))]);
|
|
679
|
+
if (s.expandable) fields.push(["expandable", bool(true)]);
|
|
680
|
+
return jObject(fields);
|
|
681
|
+
};
|
|
682
|
+
var mediaKind = (k) => {
|
|
683
|
+
if (k.$type === "Audio") return caseObj("Audio", []);
|
|
684
|
+
const fields = [];
|
|
685
|
+
if (k.autoplay) fields.push(["autoplay", bool(true)]);
|
|
686
|
+
if (k.poster !== void 0) fields.push(["poster", binding(k.poster)]);
|
|
687
|
+
return caseObj("Video", fields);
|
|
688
|
+
};
|
|
689
|
+
var mediaSpec = (s) => {
|
|
690
|
+
const fields = [];
|
|
691
|
+
if (!s.controls) fields.push(["controls", bool(false)]);
|
|
692
|
+
fields.push(["kind", mediaKind(s.kind)]);
|
|
693
|
+
fields.push(["label", textSource(s.label)]);
|
|
694
|
+
if (s.loop) fields.push(["loop", bool(true)]);
|
|
695
|
+
fields.push(["src", binding(s.src)]);
|
|
696
|
+
if (s.tracks.length > 0) fields.push(["tracks", jArray(s.tracks.map(trackEntry))]);
|
|
697
|
+
if (s.transcript !== void 0) fields.push(["transcript", textSource(s.transcript)]);
|
|
698
|
+
return jObject(fields);
|
|
699
|
+
};
|
|
700
|
+
var trackEntry = (t) => {
|
|
701
|
+
const fields = [];
|
|
702
|
+
if (t.default) fields.push(["default", bool(true)]);
|
|
703
|
+
fields.push(["kind", str(t.kind)]);
|
|
704
|
+
fields.push(["label", textSource(t.label)]);
|
|
705
|
+
fields.push(["src", binding(t.src)]);
|
|
706
|
+
fields.push(["srcLang", str(t.srcLang)]);
|
|
707
|
+
return jObject(fields);
|
|
708
|
+
};
|
|
709
|
+
var treeSpec = (s) => {
|
|
710
|
+
const fields = [["items", jArray(s.items.map(treeItem))]];
|
|
711
|
+
if (s.expandedStateKey !== void 0) fields.push(["expandedStateKey", str(s.expandedStateKey)]);
|
|
712
|
+
if (s.onSelect !== void 0) fields.push(["onSelect", CLOSURE]);
|
|
713
|
+
if (s.selectionStateKey !== void 0)
|
|
714
|
+
fields.push(["selectionStateKey", str(s.selectionStateKey)]);
|
|
715
|
+
return jObject(fields);
|
|
716
|
+
};
|
|
717
|
+
var treeItem = (t) => {
|
|
718
|
+
const fields = [];
|
|
719
|
+
if (t.children.length > 0) fields.push(["children", jArray(t.children.map(treeItem))]);
|
|
720
|
+
if (t.icon !== void 0) fields.push(["icon", str(t.icon)]);
|
|
721
|
+
fields.push(["id", str(t.id)]);
|
|
722
|
+
fields.push(["label", textSource(t.label)]);
|
|
723
|
+
return jObject(fields);
|
|
724
|
+
};
|
|
725
|
+
var embedSpec = (s) => {
|
|
726
|
+
const fields = [];
|
|
727
|
+
if (s.aspectRatio !== "Natural") fields.push(["aspectRatio", str(s.aspectRatio)]);
|
|
728
|
+
if (s.permissions.length > 0)
|
|
729
|
+
fields.push(["permissions", jArray(s.permissions.map((p) => str(p)))]);
|
|
730
|
+
fields.push(["src", binding(s.src)]);
|
|
731
|
+
fields.push(["title", textSource(s.title)]);
|
|
732
|
+
return jObject(fields);
|
|
733
|
+
};
|
|
662
734
|
var listSpec = (s) => jObject([
|
|
663
735
|
["items", jArray(s.items.map(textSource))],
|
|
664
736
|
["ordered", bool(s.ordered)]
|
|
@@ -867,6 +939,12 @@ var displayKind = (d) => {
|
|
|
867
939
|
return hoistSpec("Link", linkSpec(d.spec));
|
|
868
940
|
case "Image":
|
|
869
941
|
return hoistSpec("Image", imageSpec(d.spec));
|
|
942
|
+
case "Media":
|
|
943
|
+
return hoistSpec("Media", mediaSpec(d.spec));
|
|
944
|
+
case "Tree":
|
|
945
|
+
return hoistSpec("Tree", treeSpec(d.spec));
|
|
946
|
+
case "Embed":
|
|
947
|
+
return hoistSpec("Embed", embedSpec(d.spec));
|
|
870
948
|
case "List":
|
|
871
949
|
return hoistSpec("List", listSpec(d.spec));
|
|
872
950
|
case "Toast":
|
|
@@ -954,6 +1032,40 @@ var formFieldKind = (autoBind, k) => {
|
|
|
954
1032
|
["orientation", str(k.orientation)],
|
|
955
1033
|
...valueField(k.value, controlValueDefaults.choice, (v) => binding(v, staticStringOpt))
|
|
956
1034
|
]);
|
|
1035
|
+
case "Combobox": {
|
|
1036
|
+
const fields = [];
|
|
1037
|
+
if (k.allowFreeText) fields.push(["allowFreeText", bool(true)]);
|
|
1038
|
+
fields.push(...handlerField("onChange", k.onChange));
|
|
1039
|
+
fields.push(["options", binding(k.options, staticSelectOptions)]);
|
|
1040
|
+
fields.push(
|
|
1041
|
+
...valueField(k.value, controlValueDefaults.choice, (v) => binding(v, staticStringOpt))
|
|
1042
|
+
);
|
|
1043
|
+
return caseObj("Combobox", fields);
|
|
1044
|
+
}
|
|
1045
|
+
case "Tokens": {
|
|
1046
|
+
const fields = [];
|
|
1047
|
+
if (!k.allowFreeText) fields.push(["allowFreeText", bool(false)]);
|
|
1048
|
+
fields.push(...handlerField("onChange", k.onChange));
|
|
1049
|
+
if (k.suggestions !== void 0)
|
|
1050
|
+
fields.push(["suggestions", binding(k.suggestions, staticSelectOptions)]);
|
|
1051
|
+
fields.push(
|
|
1052
|
+
...valueField(k.value, controlValueDefaults.tokens, (v) => binding(v, staticStringList))
|
|
1053
|
+
);
|
|
1054
|
+
return caseObj("Tokens", fields);
|
|
1055
|
+
}
|
|
1056
|
+
case "Rating": {
|
|
1057
|
+
const fields = [];
|
|
1058
|
+
if (k.allowHalf) fields.push(["allowHalf", bool(true)]);
|
|
1059
|
+
fields.push(["max", num(k.max)]);
|
|
1060
|
+
fields.push(...handlerField("onChange", k.onChange));
|
|
1061
|
+
fields.push(...valueField(k.value, controlValueDefaults.number, (v) => binding(v)));
|
|
1062
|
+
return caseObj("Rating", fields);
|
|
1063
|
+
}
|
|
1064
|
+
case "Color":
|
|
1065
|
+
return caseObj("Color", [
|
|
1066
|
+
...handlerField("onChange", k.onChange),
|
|
1067
|
+
...valueField(k.value, controlValueDefaults.color, (v) => binding(v))
|
|
1068
|
+
]);
|
|
957
1069
|
case "TextArea":
|
|
958
1070
|
return caseObj("TextArea", [
|
|
959
1071
|
...handlerField("onChange", k.onChange),
|
|
@@ -994,6 +1106,20 @@ var formFieldKind = (autoBind, k) => {
|
|
|
994
1106
|
return assertNever(k);
|
|
995
1107
|
}
|
|
996
1108
|
};
|
|
1109
|
+
var compareRule = (c) => jObject([
|
|
1110
|
+
["against", binding(c.against)],
|
|
1111
|
+
["op", str(c.op)]
|
|
1112
|
+
]);
|
|
1113
|
+
var fieldRule = (r) => {
|
|
1114
|
+
const fields = [];
|
|
1115
|
+
if (r.compare !== void 0) fields.push(["compare", compareRule(r.compare)]);
|
|
1116
|
+
if (r.format !== void 0) fields.push(["format", str(r.format)]);
|
|
1117
|
+
if (r.maxLength !== void 0) fields.push(["maxLength", intLit(r.maxLength)]);
|
|
1118
|
+
if (r.message !== void 0) fields.push(["message", textSource(r.message)]);
|
|
1119
|
+
if (r.minLength !== void 0) fields.push(["minLength", intLit(r.minLength)]);
|
|
1120
|
+
if (r.pattern !== void 0) fields.push(["pattern", str(r.pattern)]);
|
|
1121
|
+
return jObject(fields);
|
|
1122
|
+
};
|
|
997
1123
|
var formField = (f) => {
|
|
998
1124
|
const fields = [
|
|
999
1125
|
["id", str(f.id)],
|
|
@@ -1002,6 +1128,7 @@ var formField = (f) => {
|
|
|
1002
1128
|
["required", bool(f.required)]
|
|
1003
1129
|
];
|
|
1004
1130
|
if (f.help !== void 0) fields.push(["help", textSource(f.help)]);
|
|
1131
|
+
if (f.rule !== void 0) fields.push(["rule", fieldRule(f.rule)]);
|
|
1005
1132
|
return jObject(fields);
|
|
1006
1133
|
};
|
|
1007
1134
|
var formSpec = (s) => {
|
|
@@ -1055,6 +1182,10 @@ var fileUploadSpec = (s) => {
|
|
|
1055
1182
|
["onSelect", CLOSURE]
|
|
1056
1183
|
];
|
|
1057
1184
|
if (s.disabled !== void 0) fields.push(["disabled", binding(s.disabled)]);
|
|
1185
|
+
if (s.acceptPaste) fields.push(["acceptPaste", bool(true)]);
|
|
1186
|
+
if (s.dropTarget) fields.push(["dropTarget", bool(true)]);
|
|
1187
|
+
if (s.capture !== void 0) fields.push(["capture", str(s.capture)]);
|
|
1188
|
+
if (s.destination !== void 0) fields.push(["destination", str(s.destination)]);
|
|
1058
1189
|
return jObject(fields);
|
|
1059
1190
|
};
|
|
1060
1191
|
var inputKind = (i) => {
|
|
@@ -1192,6 +1323,11 @@ var gridSpec = (s) => {
|
|
|
1192
1323
|
if (s.pageStateKey !== void 0) fields.push(["pageStateKey", str(s.pageStateKey)]);
|
|
1193
1324
|
if (s.defaultSort !== void 0) fields.push(["defaultSort", defaultSortJson(s.defaultSort)]);
|
|
1194
1325
|
if (s.editStateKey !== void 0) fields.push(["editStateKey", str(s.editStateKey)]);
|
|
1326
|
+
if (s.transferOutKey !== void 0) fields.push(["transferOutKey", str(s.transferOutKey)]);
|
|
1327
|
+
if (s.transferInKey !== void 0) fields.push(["transferInKey", str(s.transferInKey)]);
|
|
1328
|
+
if (s.exportable) fields.push(["exportable", bool(true)]);
|
|
1329
|
+
if (s.keepRowsTogether) fields.push(["keepRowsTogether", bool(true)]);
|
|
1330
|
+
if (s.repeatHeader) fields.push(["repeatHeader", bool(true)]);
|
|
1195
1331
|
if (s.staticRows !== void 0) {
|
|
1196
1332
|
const sr = s.staticRows;
|
|
1197
1333
|
const srFields = [
|
|
@@ -1269,6 +1405,11 @@ var boxLayout = (l) => {
|
|
|
1269
1405
|
if (l.templateColumns !== void 0) fields.push(["templateColumns", str(l.templateColumns)]);
|
|
1270
1406
|
return caseObj("Grid", fields);
|
|
1271
1407
|
}
|
|
1408
|
+
case "Masonry": {
|
|
1409
|
+
const fields = [["cols", intLit(l.cols)]];
|
|
1410
|
+
if (l.gap !== void 0) fields.push(["gap", intLit(l.gap)]);
|
|
1411
|
+
return caseObj("Masonry", fields);
|
|
1412
|
+
}
|
|
1272
1413
|
case "Auto":
|
|
1273
1414
|
return caseObj("Auto", []);
|
|
1274
1415
|
default:
|
|
@@ -1280,6 +1421,8 @@ var boxSpec = (s) => {
|
|
|
1280
1421
|
if (s.heading !== void 0) fields.push(["heading", textSource(s.heading)]);
|
|
1281
1422
|
fields.push(["layout", boxLayout(s.layout)]);
|
|
1282
1423
|
fields.push(["role", str(s.role)]);
|
|
1424
|
+
if (s.keepTogether) fields.push(["keepTogether", bool(true)]);
|
|
1425
|
+
if (s.breakBefore) fields.push(["breakBefore", bool(true)]);
|
|
1283
1426
|
return jObject(fields);
|
|
1284
1427
|
};
|
|
1285
1428
|
var splitPanelSpec = (s) => jObject([
|
|
@@ -1334,6 +1477,8 @@ var modalSpec = (s) => {
|
|
|
1334
1477
|
];
|
|
1335
1478
|
if (s.onDismiss !== void 0) fields.push(["onDismiss", action(s.onDismiss)]);
|
|
1336
1479
|
if (s.heading !== void 0) fields.push(["heading", textSource(s.heading)]);
|
|
1480
|
+
if (s.modality !== "Modal") fields.push(["modality", str(s.modality)]);
|
|
1481
|
+
if (s.anchor !== void 0) fields.push(["anchor", str(s.anchor)]);
|
|
1337
1482
|
return jObject(fields);
|
|
1338
1483
|
};
|
|
1339
1484
|
var scrollAreaSpec = (s) => {
|
|
@@ -1489,6 +1634,9 @@ var nodeKind = (k) => {
|
|
|
1489
1634
|
]);
|
|
1490
1635
|
case "Switch":
|
|
1491
1636
|
return caseObj("Switch", [
|
|
1637
|
+
// Phase 1122 — omitted when absent, so every pre-1122 switch stays
|
|
1638
|
+
// byte-identical.
|
|
1639
|
+
...k.spec.autoAdvanceMs !== void 0 ? [["autoAdvanceMs", num(k.spec.autoAdvanceMs)]] : [],
|
|
1492
1640
|
[
|
|
1493
1641
|
"cases",
|
|
1494
1642
|
jArray(
|
|
@@ -1563,6 +1711,8 @@ var semanticStyle = (s) => {
|
|
|
1563
1711
|
if (s.weight !== void 0 && s.weight !== "Standard") fields.push(["weight", str(s.weight)]);
|
|
1564
1712
|
if (s.role !== void 0 && s.role !== "None") fields.push(["role", str(s.role)]);
|
|
1565
1713
|
if (s.voice !== void 0 && s.voice !== "Default") fields.push(["voice", str(s.voice)]);
|
|
1714
|
+
if (s.direction !== void 0 && s.direction !== "auto")
|
|
1715
|
+
fields.push(["direction", str(s.direction)]);
|
|
1566
1716
|
return jObject(fields);
|
|
1567
1717
|
};
|
|
1568
1718
|
var accessibility = (a) => {
|
|
@@ -1576,7 +1726,9 @@ var accessibility = (a) => {
|
|
|
1576
1726
|
return jObject(fields);
|
|
1577
1727
|
};
|
|
1578
1728
|
var isEmptyState = (s) => s.onLoading === void 0 && s.onEmpty === void 0 && s.onError === void 0;
|
|
1579
|
-
var isDefaultStyle = (s) => (s.emphasis === void 0 || s.emphasis === "Normal") && (s.tone === void 0 || s.tone === "Default") && (s.weight === void 0 || s.weight === "Standard") && (s.role === void 0 || s.role === "None") && (s.voice === void 0 || s.voice === "Default")
|
|
1729
|
+
var isDefaultStyle = (s) => (s.emphasis === void 0 || s.emphasis === "Normal") && (s.tone === void 0 || s.tone === "Default") && (s.weight === void 0 || s.weight === "Standard") && (s.role === void 0 || s.role === "None") && (s.voice === void 0 || s.voice === "Default") && // Phase 1472 — `auto` is this member's identity, so a style that declares only
|
|
1730
|
+
// a direction is NOT all-default and the envelope must carry it.
|
|
1731
|
+
(s.direction === void 0 || s.direction === "auto");
|
|
1580
1732
|
var node = (n) => {
|
|
1581
1733
|
const fields = [
|
|
1582
1734
|
["id", str(n.id)],
|
|
@@ -1585,6 +1737,7 @@ var node = (n) => {
|
|
|
1585
1737
|
if (!isEmptyState(n.state)) fields.push(["state", stateBehaviour(n.state)]);
|
|
1586
1738
|
if (!isDefaultStyle(n.style)) fields.push(["style", semanticStyle(n.style)]);
|
|
1587
1739
|
if (n.accessibility !== void 0) fields.push(["accessibility", accessibility(n.accessibility)]);
|
|
1740
|
+
if (n.tooltip !== void 0) fields.push(["tooltip", textSource(n.tooltip)]);
|
|
1588
1741
|
return jObject(fields);
|
|
1589
1742
|
};
|
|
1590
1743
|
var treeOp = (op) => {
|
|
@@ -2681,8 +2834,65 @@ var stepParams = (t) => {
|
|
|
2681
2834
|
var pipelineParams = (pipeline) => [
|
|
2682
2835
|
...new Set(pipeline.flatMap((t) => stepParams(t)))
|
|
2683
2836
|
];
|
|
2684
|
-
|
|
2685
|
-
|
|
2837
|
+
var substituteListParamsExpr = (listEnv, e) => {
|
|
2838
|
+
switch (e.kind) {
|
|
2839
|
+
case "col":
|
|
2840
|
+
case "lit":
|
|
2841
|
+
case "param":
|
|
2842
|
+
return e;
|
|
2843
|
+
case "binary":
|
|
2844
|
+
return {
|
|
2845
|
+
kind: "binary",
|
|
2846
|
+
op: e.op,
|
|
2847
|
+
left: substituteListParamsExpr(listEnv, e.left),
|
|
2848
|
+
right: substituteListParamsExpr(listEnv, e.right)
|
|
2849
|
+
};
|
|
2850
|
+
case "not":
|
|
2851
|
+
return { kind: "not", expr: substituteListParamsExpr(listEnv, e.expr) };
|
|
2852
|
+
case "coalesce":
|
|
2853
|
+
return { kind: "coalesce", exprs: e.exprs.map((x) => substituteListParamsExpr(listEnv, x)) };
|
|
2854
|
+
case "case":
|
|
2855
|
+
return {
|
|
2856
|
+
kind: "case",
|
|
2857
|
+
cases: e.cases.map((br) => ({
|
|
2858
|
+
when: substituteListParamsExpr(listEnv, br.when),
|
|
2859
|
+
then: substituteListParamsExpr(listEnv, br.then)
|
|
2860
|
+
})),
|
|
2861
|
+
else: substituteListParamsExpr(listEnv, e.else)
|
|
2862
|
+
};
|
|
2863
|
+
case "cast":
|
|
2864
|
+
return { kind: "cast", type: e.type, expr: substituteListParamsExpr(listEnv, e.expr) };
|
|
2865
|
+
case "apply":
|
|
2866
|
+
return {
|
|
2867
|
+
kind: "apply",
|
|
2868
|
+
fn: e.fn,
|
|
2869
|
+
args: e.args.map((x) => substituteListParamsExpr(listEnv, x))
|
|
2870
|
+
};
|
|
2871
|
+
case "in":
|
|
2872
|
+
return {
|
|
2873
|
+
kind: "in",
|
|
2874
|
+
expr: substituteListParamsExpr(listEnv, e.expr),
|
|
2875
|
+
items: e.items.map((x) => substituteListParamsExpr(listEnv, x))
|
|
2876
|
+
};
|
|
2877
|
+
case "isNull":
|
|
2878
|
+
return { kind: "isNull", expr: substituteListParamsExpr(listEnv, e.expr) };
|
|
2879
|
+
case "inParam": {
|
|
2880
|
+
const expr = substituteListParamsExpr(listEnv, e.expr);
|
|
2881
|
+
const items = Object.prototype.hasOwnProperty.call(listEnv, e.param) ? listEnv[e.param] : void 0;
|
|
2882
|
+
return items === void 0 ? { kind: "inParam", expr, param: e.param } : { kind: "in", expr, items: items.map((c) => ({ kind: "lit", cell: c })) };
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
};
|
|
2886
|
+
var substituteListParams = (listEnv, pipeline) => pipeline.map((t) => {
|
|
2887
|
+
switch (t.kind) {
|
|
2888
|
+
case "filter":
|
|
2889
|
+
return { kind: "filter", pred: substituteListParamsExpr(listEnv, t.pred) };
|
|
2890
|
+
case "derive":
|
|
2891
|
+
return { kind: "derive", name: t.name, expr: substituteListParamsExpr(listEnv, t.expr) };
|
|
2892
|
+
default:
|
|
2893
|
+
return t;
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2686
2896
|
var peek = (s) => s.pos < s.text.length ? s.text[s.pos] : " ";
|
|
2687
2897
|
var advance = (s) => {
|
|
2688
2898
|
s.pos += 1;
|
|
@@ -2697,6 +2907,10 @@ var skipWs = (s) => {
|
|
|
2697
2907
|
}
|
|
2698
2908
|
}
|
|
2699
2909
|
};
|
|
2910
|
+
var failLimit = (s, message) => ({
|
|
2911
|
+
ok: false,
|
|
2912
|
+
error: { message, offset: s.pos, limit: true }
|
|
2913
|
+
});
|
|
2700
2914
|
var fail = (s, message) => ({
|
|
2701
2915
|
ok: false,
|
|
2702
2916
|
error: { message, offset: s.pos }
|
|
@@ -2719,7 +2933,14 @@ var parseStringRaw = (s) => {
|
|
|
2719
2933
|
advance(s);
|
|
2720
2934
|
if (c === '"') {
|
|
2721
2935
|
return { ok: true, value: out };
|
|
2722
|
-
}
|
|
2936
|
+
}
|
|
2937
|
+
if (out.length > MAX_STRING_LENGTH) {
|
|
2938
|
+
return failLimit(
|
|
2939
|
+
s,
|
|
2940
|
+
`string is longer than the wire limit MAX_STRING_LENGTH = ${MAX_STRING_LENGTH}`
|
|
2941
|
+
);
|
|
2942
|
+
}
|
|
2943
|
+
if (c === "\\") {
|
|
2723
2944
|
if (s.pos >= s.text.length) return fail(s, "unterminated escape");
|
|
2724
2945
|
const esc = s.text[s.pos];
|
|
2725
2946
|
advance(s);
|
|
@@ -2819,6 +3040,12 @@ var parseValue = (s) => {
|
|
|
2819
3040
|
}
|
|
2820
3041
|
};
|
|
2821
3042
|
var parseObjectValue = (s) => {
|
|
3043
|
+
if (s.depth >= MAX_JSON_DEPTH) {
|
|
3044
|
+
return failLimit(
|
|
3045
|
+
s,
|
|
3046
|
+
`JSON nesting deeper than the wire limit MAX_JSON_DEPTH = ${MAX_JSON_DEPTH}`
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
2822
3049
|
const open = expectChar(s, "{");
|
|
2823
3050
|
if (!open.ok) return open;
|
|
2824
3051
|
skipWs(s);
|
|
@@ -2827,15 +3054,34 @@ var parseObjectValue = (s) => {
|
|
|
2827
3054
|
advance(s);
|
|
2828
3055
|
return { ok: true, value: { kind: "JObject", fields } };
|
|
2829
3056
|
}
|
|
3057
|
+
s.depth += 1;
|
|
3058
|
+
let count = 0;
|
|
2830
3059
|
for (; ; ) {
|
|
2831
3060
|
skipWs(s);
|
|
2832
3061
|
const keyR = parseStringRaw(s);
|
|
2833
|
-
if (!keyR.ok)
|
|
3062
|
+
if (!keyR.ok) {
|
|
3063
|
+
s.depth -= 1;
|
|
3064
|
+
return keyR;
|
|
3065
|
+
}
|
|
2834
3066
|
skipWs(s);
|
|
2835
3067
|
const colon = expectChar(s, ":");
|
|
2836
|
-
if (!colon.ok)
|
|
3068
|
+
if (!colon.ok) {
|
|
3069
|
+
s.depth -= 1;
|
|
3070
|
+
return colon;
|
|
3071
|
+
}
|
|
2837
3072
|
const valR = parseValue(s);
|
|
2838
|
-
if (!valR.ok)
|
|
3073
|
+
if (!valR.ok) {
|
|
3074
|
+
s.depth -= 1;
|
|
3075
|
+
return valR;
|
|
3076
|
+
}
|
|
3077
|
+
count += 1;
|
|
3078
|
+
if (count > MAX_ARRAY_LENGTH) {
|
|
3079
|
+
s.depth -= 1;
|
|
3080
|
+
return failLimit(
|
|
3081
|
+
s,
|
|
3082
|
+
`object has more members than the wire limit MAX_ARRAY_LENGTH = ${MAX_ARRAY_LENGTH}`
|
|
3083
|
+
);
|
|
3084
|
+
}
|
|
2839
3085
|
fields.set(keyR.value, valR.value);
|
|
2840
3086
|
skipWs(s);
|
|
2841
3087
|
const c = peek(s);
|
|
@@ -2843,13 +3089,21 @@ var parseObjectValue = (s) => {
|
|
|
2843
3089
|
advance(s);
|
|
2844
3090
|
} else if (c === "}") {
|
|
2845
3091
|
advance(s);
|
|
3092
|
+
s.depth -= 1;
|
|
2846
3093
|
return { ok: true, value: { kind: "JObject", fields } };
|
|
2847
3094
|
} else {
|
|
3095
|
+
s.depth -= 1;
|
|
2848
3096
|
return fail(s, `expected ',' or '}' but found '${c}'`);
|
|
2849
3097
|
}
|
|
2850
3098
|
}
|
|
2851
3099
|
};
|
|
2852
3100
|
var parseArrayValue = (s) => {
|
|
3101
|
+
if (s.depth >= MAX_JSON_DEPTH) {
|
|
3102
|
+
return failLimit(
|
|
3103
|
+
s,
|
|
3104
|
+
`JSON nesting deeper than the wire limit MAX_JSON_DEPTH = ${MAX_JSON_DEPTH}`
|
|
3105
|
+
);
|
|
3106
|
+
}
|
|
2853
3107
|
const open = expectChar(s, "[");
|
|
2854
3108
|
if (!open.ok) return open;
|
|
2855
3109
|
skipWs(s);
|
|
@@ -2858,24 +3112,37 @@ var parseArrayValue = (s) => {
|
|
|
2858
3112
|
advance(s);
|
|
2859
3113
|
return { ok: true, value: { kind: "JArray", items } };
|
|
2860
3114
|
}
|
|
3115
|
+
s.depth += 1;
|
|
2861
3116
|
for (; ; ) {
|
|
2862
3117
|
const valR = parseValue(s);
|
|
2863
|
-
if (!valR.ok)
|
|
3118
|
+
if (!valR.ok) {
|
|
3119
|
+
s.depth -= 1;
|
|
3120
|
+
return valR;
|
|
3121
|
+
}
|
|
2864
3122
|
items.push(valR.value);
|
|
3123
|
+
if (items.length > MAX_ARRAY_LENGTH) {
|
|
3124
|
+
s.depth -= 1;
|
|
3125
|
+
return failLimit(
|
|
3126
|
+
s,
|
|
3127
|
+
`array is longer than the wire limit MAX_ARRAY_LENGTH = ${MAX_ARRAY_LENGTH}`
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
2865
3130
|
skipWs(s);
|
|
2866
3131
|
const c = peek(s);
|
|
2867
3132
|
if (c === ",") {
|
|
2868
3133
|
advance(s);
|
|
2869
3134
|
} else if (c === "]") {
|
|
2870
3135
|
advance(s);
|
|
3136
|
+
s.depth -= 1;
|
|
2871
3137
|
return { ok: true, value: { kind: "JArray", items } };
|
|
2872
3138
|
} else {
|
|
3139
|
+
s.depth -= 1;
|
|
2873
3140
|
return fail(s, `expected ',' or ']' but found '${c}'`);
|
|
2874
3141
|
}
|
|
2875
3142
|
}
|
|
2876
3143
|
};
|
|
2877
3144
|
var parse = (input) => {
|
|
2878
|
-
const s = { text: input, pos: 0 };
|
|
3145
|
+
const s = { text: input, pos: 0, depth: 0 };
|
|
2879
3146
|
skipWs(s);
|
|
2880
3147
|
if (s.pos >= s.text.length) {
|
|
2881
3148
|
return { ok: false, error: { message: "input is empty", offset: 0 } };
|
|
@@ -2893,6 +3160,7 @@ var makeError = (code, path, message, expectedShape) => ({
|
|
|
2893
3160
|
var missingField = (path, key, expected) => makeError("MISSING_FIELD", `${path}.${key}`, `missing required field '${key}'`, expected);
|
|
2894
3161
|
var wrongType = (path, expected) => makeError("WRONG_TYPE", path, `expected ${expected}`, expected);
|
|
2895
3162
|
var unknownDuCase = (path, got, expected) => makeError("UNKNOWN_DU_CASE", `${path}.$type`, `unknown discriminator '${got}'`, expected);
|
|
3163
|
+
var unknownEnumCase = (path, got, expected) => makeError("UNKNOWN_DU_CASE", path, `unknown discriminator '${got}'`, expected);
|
|
2896
3164
|
var CLOSURE2 = "<closure>";
|
|
2897
3165
|
var OPAQUE2 = "<opaque>";
|
|
2898
3166
|
var requireObject = (path, j) => j.kind === "JObject" ? ok(j.fields) : wrongType(path, "JSON object");
|
|
@@ -3045,7 +3313,7 @@ var decodeJValMap = (path, j) => {
|
|
|
3045
3313
|
var bareEnum = (path, j, valid, label) => {
|
|
3046
3314
|
if (j.kind !== "JString") return wrongType(path, `JSON string (${label})`);
|
|
3047
3315
|
if (valid.includes(j.value)) return ok(j.value);
|
|
3048
|
-
return
|
|
3316
|
+
return unknownEnumCase(path, j.value, valid.join(" | "));
|
|
3049
3317
|
};
|
|
3050
3318
|
var ORIENTATION_ALIASES = {
|
|
3051
3319
|
// CSS flex-direction prior: a row lays out horizontally, a column vertically.
|
|
@@ -3083,7 +3351,25 @@ var decodeHeadingVariant = (p, j) => {
|
|
|
3083
3351
|
return bareEnum(p, j, ["Standard", "Eyebrow", "Caption", "Lead"], "HeadingVariant");
|
|
3084
3352
|
};
|
|
3085
3353
|
var decodeImageVariant = (p, j) => bareEnum(p, j, ["Default", "Avatar", "Rounded"], "ImageVariant");
|
|
3354
|
+
var decodeImageFit = (p, j) => bareEnum(p, j, ["Natural", "Cover", "Contain"], "ImageFit");
|
|
3355
|
+
var decodeModalityKind = (p, j) => bareEnum(p, j, ["Modal", "Popover"], "ModalityKind");
|
|
3356
|
+
var decodeImageAspect = (p, j) => bareEnum(
|
|
3357
|
+
p,
|
|
3358
|
+
j,
|
|
3359
|
+
["Natural", "Square", "FourThree", "ThreeTwo", "SixteenNine"],
|
|
3360
|
+
"ImageAspect"
|
|
3361
|
+
);
|
|
3362
|
+
var decodeImageLoading = (p, j) => bareEnum(p, j, ["Eager", "Lazy"], "ImageLoading");
|
|
3363
|
+
var decodeEmbedPermission = (p, j) => bareEnum(
|
|
3364
|
+
p,
|
|
3365
|
+
j,
|
|
3366
|
+
["AllowScripts", "AllowSameOrigin", "AllowForms", "AllowFullscreen"],
|
|
3367
|
+
"EmbedPermission"
|
|
3368
|
+
);
|
|
3086
3369
|
var decodeScrollOrientation = (p, j) => bareEnum(p, j, ["Vertical", "Horizontal", "Both"], "ScrollOrientation");
|
|
3370
|
+
var decodeTrackKind = (p, j) => bareEnum(p, j, ["Subtitles", "Captions", "Descriptions", "Chapters"], "TrackKind");
|
|
3371
|
+
var decodeCaptureSource = (p, j) => bareEnum(p, j, ["Camera", "Microphone"], "CaptureSource");
|
|
3372
|
+
var decodeTextDirection = (p, j) => bareEnum(p, j, ["auto", "ltr", "rtl"], "TextDirection");
|
|
3087
3373
|
var decodeDateVariant = (p, j) => bareEnum(p, j, ["Date", "Time", "DateTime"], "DateVariant");
|
|
3088
3374
|
var decodeMathDisplay = (p, j) => bareEnum(p, j, ["Inline", "Block"], "MathDisplay");
|
|
3089
3375
|
var TONE_ALIASES = {
|
|
@@ -3116,6 +3402,7 @@ var decodeWeight = (p, j) => (
|
|
|
3116
3402
|
// Compact|Standard|Spacious means density (WIRE_FORMAT.md §3.6).
|
|
3117
3403
|
bareEnum(p, j, ["Compact", "Standard", "Spacious"], "StyleWeight")
|
|
3118
3404
|
);
|
|
3405
|
+
var decodeTrendPolarity = (p, j) => bareEnum(p, j, ["HigherIsBetter", "LowerIsBetter"], "TrendPolarity");
|
|
3119
3406
|
var decodeEmphasis = (p, j) => {
|
|
3120
3407
|
if (j.kind === "JString" && j.value in EMPHASIS_ALIASES) return ok(EMPHASIS_ALIASES[j.value]);
|
|
3121
3408
|
if (j.kind === "JBool") return ok(j.value ? "Loud" : "Normal");
|
|
@@ -4238,12 +4525,11 @@ var decodeBinding = (path, j, parseStatic = (_p, v) => ok(decodeAstValue(v)), pl
|
|
|
4238
4525
|
case "State": {
|
|
4239
4526
|
const key = reqField(path, f, "key", "state key string", requireString);
|
|
4240
4527
|
if (!key.ok) return key;
|
|
4241
|
-
const
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
}
|
|
4528
|
+
const dvRaw = fieldAliased(f, "defaultValue", ["initialValue", "default"]);
|
|
4529
|
+
const dv = dvRaw ?? { kind: "JNull" };
|
|
4530
|
+
let defaultValue = dvRaw === void 0 ? void 0 : placeholder;
|
|
4531
|
+
const parsed = parseStatic(`${path}.defaultValue`, dv);
|
|
4532
|
+
if (parsed.ok) defaultValue = parsed.value;
|
|
4247
4533
|
return ok({ kind: "State", key: key.value, defaultValue });
|
|
4248
4534
|
}
|
|
4249
4535
|
case "Computed":
|
|
@@ -4317,29 +4603,43 @@ var decodeBinding = (path, j, parseStatic = (_p, v) => ok(decodeAstValue(v)), pl
|
|
|
4317
4603
|
if (!pipeJ.ok) return pipeJ;
|
|
4318
4604
|
const liveTagAst = srcJ.value.kind === "JObject" ? srcJ.value.fields.get("$type") : void 0;
|
|
4319
4605
|
const liveTag = liveTagAst !== void 0 && liveTagAst.kind === "JString" && (liveTagAst.value === "State" || liveTagAst.value === "Selection" || liveTagAst.value === "Query") ? liveTagAst.value : void 0;
|
|
4320
|
-
const hasCarried = srcJ.value.kind === "JObject" && srcJ.value.fields.has("defaultValue");
|
|
4321
4606
|
let source;
|
|
4322
|
-
if (liveTag === void 0
|
|
4607
|
+
if (liveTag === void 0) {
|
|
4323
4608
|
const src = decodeDataSource(normaliseTransformSource(srcJ.value));
|
|
4324
4609
|
if (!src.ok) return makeError("WRONG_TYPE", `${path}.source`, src.error);
|
|
4325
4610
|
source = { kind: "Data", source: src.value };
|
|
4326
4611
|
} else {
|
|
4327
4612
|
const b2 = decodeBinding(`${path}.source`, srcJ.value, decodeJVal, void 0);
|
|
4328
4613
|
if (!b2.ok) return b2;
|
|
4614
|
+
const liveBinding = (() => {
|
|
4615
|
+
const raw = b2.value;
|
|
4616
|
+
const declared = srcJ.value.kind === "JObject" && srcJ.value.fields.has("defaultValue");
|
|
4617
|
+
return raw.kind === "State" && !declared ? { ...raw, defaultValue: void 0 } : raw;
|
|
4618
|
+
})();
|
|
4329
4619
|
if (liveTag === "State") {
|
|
4330
|
-
const
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4620
|
+
const carriedJ = srcJ.value.kind === "JObject" ? srcJ.value.fields.get("defaultValue") : void 0;
|
|
4621
|
+
const carriesNoData = carriedJ === void 0 || carriedJ.kind === "JArray" && carriedJ.items.length === 0;
|
|
4622
|
+
if (carriesNoData) {
|
|
4623
|
+
source = {
|
|
4624
|
+
kind: "Live",
|
|
4625
|
+
binding: liveBinding,
|
|
4626
|
+
initial: { kind: "Embedded", table: { schema: [], columns: [] } }
|
|
4627
|
+
};
|
|
4628
|
+
} else {
|
|
4629
|
+
const snap = decodeDataSource(normaliseTransformSource(srcJ.value));
|
|
4630
|
+
if (!snap.ok) return makeError("WRONG_TYPE", `${path}.source`, snap.error);
|
|
4631
|
+
source = {
|
|
4632
|
+
kind: "Live",
|
|
4633
|
+
binding: liveBinding,
|
|
4634
|
+
initial: snap.value
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4337
4637
|
} else {
|
|
4338
4638
|
const dv = srcJ.value.kind === "JObject" ? srcJ.value.fields.get("defaultValue") : void 0;
|
|
4339
4639
|
const snap = dv !== void 0 ? decodeDataSource(normaliseTransformSource(dv)) : void 0;
|
|
4340
4640
|
source = {
|
|
4341
4641
|
kind: "Live",
|
|
4342
|
-
binding:
|
|
4642
|
+
binding: liveBinding,
|
|
4343
4643
|
initial: snap !== void 0 && snap.ok ? snap.value : { kind: "Embedded", table: { schema: [], columns: [] } }
|
|
4344
4644
|
};
|
|
4345
4645
|
}
|
|
@@ -4496,8 +4796,10 @@ var decodeBindingArgs = (path, j) => {
|
|
|
4496
4796
|
}
|
|
4497
4797
|
return ok(out);
|
|
4498
4798
|
};
|
|
4499
|
-
var decodeBindingString = (p, j) => decodeBinding(p, j);
|
|
4500
|
-
var decodeBindingBool = (p, j) => decodeBinding(p, j);
|
|
4799
|
+
var decodeBindingString = (p, j) => decodeBinding(p, j, requireString, "");
|
|
4800
|
+
var decodeBindingBool = (p, j) => decodeBinding(p, j, requireBool, false);
|
|
4801
|
+
var decodeBindingFloat = (p, j) => decodeBinding(p, j, requireFloat, 0);
|
|
4802
|
+
var decodeBindingInt = (p, j) => decodeBinding(p, j, requireInt, 0);
|
|
4501
4803
|
var OPTIONS_PLACEHOLDER = [
|
|
4502
4804
|
{ value: OPAQUE2, label: { kind: "Literal", value: OPAQUE2 } }
|
|
4503
4805
|
];
|
|
@@ -4681,7 +4983,7 @@ var decodeAction = (path, j) => {
|
|
|
4681
4983
|
const s = j.value.length > 24 ? j.value.slice(0, 24) + "\u2026" : j.value;
|
|
4682
4984
|
return wrongType(
|
|
4683
4985
|
path,
|
|
4684
|
-
`JSON object, got the string '${s}' \u2014 an action is a $type-discriminated object (SetState | Navigate | Call | Notify | Chain | AiTool | WriteToClipboard | Invoke); "<closure>" is not authorable. Pick a real action, e.g. {"$type":"SetState","key":\u2026,"value":\u2026}`
|
|
4986
|
+
`JSON object, got the string '${s}' \u2014 an action is a $type-discriminated object (SetState | Navigate | Call | Notify | Chain | AiTool | WriteToClipboard | Print | Invoke); "<closure>" is not authorable. Pick a real action, e.g. {"$type":"SetState","key":\u2026,"value":\u2026}`
|
|
4685
4987
|
);
|
|
4686
4988
|
}
|
|
4687
4989
|
const fo = requireObject(path, j);
|
|
@@ -4801,9 +5103,19 @@ var decodeAction = (path, j) => {
|
|
|
4801
5103
|
return r.ok ? ok({ kind: "CommitLocal", nodeId: r.value }) : r;
|
|
4802
5104
|
}
|
|
4803
5105
|
case "WriteToClipboard": {
|
|
4804
|
-
const r = reqField(path, f, "text", "clipboard payload
|
|
5106
|
+
const r = reqField(path, f, "text", "clipboard payload TextSource", decodeTextSource);
|
|
4805
5107
|
return r.ok ? ok({ kind: "WriteToClipboard", text: r.value }) : r;
|
|
4806
5108
|
}
|
|
5109
|
+
case "Print": {
|
|
5110
|
+
for (const key of f.keys()) {
|
|
5111
|
+
if (key !== "$type")
|
|
5112
|
+
return wrongType(
|
|
5113
|
+
`${path}.${key}`,
|
|
5114
|
+
"no member beside $type \u2014 Print takes no payload (WIRE_FORMAT.md \xA73.6.14)"
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5117
|
+
return ok({ kind: "Print" });
|
|
5118
|
+
}
|
|
4807
5119
|
case "ReadFileBody": {
|
|
4808
5120
|
const fileId = reqField(path, f, "fileRef", "FileRef id string", requireString);
|
|
4809
5121
|
if (!fileId.ok) return fileId;
|
|
@@ -4828,7 +5140,7 @@ var decodeAction = (path, j) => {
|
|
|
4828
5140
|
return unknownDuCase(
|
|
4829
5141
|
path,
|
|
4830
5142
|
d.value,
|
|
4831
|
-
"Dispatch | Call | Notify | Navigate | SetState | AiTool | Chain | CommitLocal | WriteToClipboard | ReadFileBody | Invoke"
|
|
5143
|
+
"Dispatch | Call | Notify | Navigate | SetState | AiTool | Chain | CommitLocal | WriteToClipboard | Print | ReadFileBody | Invoke"
|
|
4832
5144
|
);
|
|
4833
5145
|
}
|
|
4834
5146
|
};
|
|
@@ -4840,7 +5152,14 @@ var decodeMetricSpec = (path, j) => {
|
|
|
4840
5152
|
const f = fo.value;
|
|
4841
5153
|
const label = reqField(path, f, "label", "Metric label TextSource", decodeTextSource);
|
|
4842
5154
|
if (!label.ok) return label;
|
|
4843
|
-
const source = reqFieldAliased(
|
|
5155
|
+
const source = reqFieldAliased(
|
|
5156
|
+
path,
|
|
5157
|
+
f,
|
|
5158
|
+
"value",
|
|
5159
|
+
["data"],
|
|
5160
|
+
"Metric value binding",
|
|
5161
|
+
decodeBindingFloat
|
|
5162
|
+
);
|
|
4844
5163
|
if (!source.ok) {
|
|
4845
5164
|
if (source.error.message.includes("expected JSON number")) {
|
|
4846
5165
|
return {
|
|
@@ -4861,10 +5180,12 @@ var decodeMetricSpec = (path, j) => {
|
|
|
4861
5180
|
if (!weight.ok) return weight;
|
|
4862
5181
|
const emphasis = optField(path, f, "emphasis", decodeEmphasis);
|
|
4863
5182
|
if (!emphasis.ok) return emphasis;
|
|
4864
|
-
const trend = optField(path, f, "trend",
|
|
5183
|
+
const trend = optField(path, f, "trend", decodeBindingFloat);
|
|
4865
5184
|
if (!trend.ok) return trend;
|
|
4866
5185
|
const trendFormat = optField(path, f, "trendFormat", decodeCellFormat);
|
|
4867
5186
|
if (!trendFormat.ok) return trendFormat;
|
|
5187
|
+
const trendPolarity = optField(path, f, "trendPolarity", decodeTrendPolarity);
|
|
5188
|
+
if (!trendPolarity.ok) return trendPolarity;
|
|
4868
5189
|
const icon = optField(path, f, "icon", decodeIconSource);
|
|
4869
5190
|
if (!icon.ok) return icon;
|
|
4870
5191
|
const subtext = optField(path, f, "subtext", decodeTextSource);
|
|
@@ -4878,6 +5199,7 @@ var decodeMetricSpec = (path, j) => {
|
|
|
4878
5199
|
emphasis: emphasis.value ?? "Normal",
|
|
4879
5200
|
...trend.value !== void 0 ? { trend: trend.value } : {},
|
|
4880
5201
|
...trendFormat.value !== void 0 ? { trendFormat: trendFormat.value } : {},
|
|
5202
|
+
trendPolarity: trendPolarity.value ?? "HigherIsBetter",
|
|
4881
5203
|
...icon.value !== void 0 ? { icon: icon.value } : {},
|
|
4882
5204
|
...subtext.value !== void 0 ? { subtext: subtext.value } : {}
|
|
4883
5205
|
});
|
|
@@ -4906,7 +5228,7 @@ var decodeLabelValueRowSpec = (path, j) => {
|
|
|
4906
5228
|
"value",
|
|
4907
5229
|
["data"],
|
|
4908
5230
|
"row Binding<float> value",
|
|
4909
|
-
|
|
5231
|
+
decodeBindingFloat
|
|
4910
5232
|
);
|
|
4911
5233
|
if (!source.ok) return source;
|
|
4912
5234
|
const format = optField(path, f, "format", decodeCellFormat);
|
|
@@ -4995,6 +5317,23 @@ var decodeLinkSpec = (path, j) => {
|
|
|
4995
5317
|
});
|
|
4996
5318
|
};
|
|
4997
5319
|
var decodeLinkProtection = (p, j) => bareEnum(p, j, ["email"], "LinkProtection");
|
|
5320
|
+
var decodeSrcSetEntry = (path, j) => {
|
|
5321
|
+
const fo = requireObject(path, j);
|
|
5322
|
+
if (!fo.ok) return fo;
|
|
5323
|
+
const src = reqField(
|
|
5324
|
+
path,
|
|
5325
|
+
fo.value,
|
|
5326
|
+
"src",
|
|
5327
|
+
"srcSet entry Binding<string> src",
|
|
5328
|
+
decodeBindingString
|
|
5329
|
+
);
|
|
5330
|
+
if (!src.ok) return src;
|
|
5331
|
+
const widthJ = tryField(fo.value, "width");
|
|
5332
|
+
if (widthJ === void 0) return missingField(path, "width", "positive intrinsic pixel width");
|
|
5333
|
+
if (widthJ.kind !== "JNumber" || widthJ.value <= 0 || !Number.isInteger(widthJ.value))
|
|
5334
|
+
return wrongType(`${path}.width`, "JSON number (positive integer pixel width)");
|
|
5335
|
+
return ok({ src: src.value, width: widthJ.value });
|
|
5336
|
+
};
|
|
4998
5337
|
var decodeImageSpec = (path, j) => {
|
|
4999
5338
|
const fo = requireObject(path, j);
|
|
5000
5339
|
if (!fo.ok) return fo;
|
|
@@ -5005,7 +5344,217 @@ var decodeImageSpec = (path, j) => {
|
|
|
5005
5344
|
if (!src.ok) return src;
|
|
5006
5345
|
const variant = reqField(path, f, "variant", "ImageVariant", decodeImageVariant);
|
|
5007
5346
|
if (!variant.ok) return variant;
|
|
5008
|
-
|
|
5347
|
+
const fitJ = tryField(f, "fit");
|
|
5348
|
+
const fit = fitJ === void 0 ? ok("Natural") : decodeImageFit(`${path}.fit`, fitJ);
|
|
5349
|
+
if (!fit.ok) return fit;
|
|
5350
|
+
const aspectJ = tryField(f, "aspectRatio");
|
|
5351
|
+
const aspectRatio = aspectJ === void 0 ? ok("Natural") : decodeImageAspect(`${path}.aspectRatio`, aspectJ);
|
|
5352
|
+
if (!aspectRatio.ok) return aspectRatio;
|
|
5353
|
+
const loadingJ = tryField(f, "loading");
|
|
5354
|
+
const loading = loadingJ === void 0 ? ok("Eager") : decodeImageLoading(`${path}.loading`, loadingJ);
|
|
5355
|
+
if (!loading.ok) return loading;
|
|
5356
|
+
const caption = optField(path, f, "caption", decodeTextSource);
|
|
5357
|
+
if (!caption.ok) return caption;
|
|
5358
|
+
const srcSetJ = tryField(f, "srcSet");
|
|
5359
|
+
const srcSet = srcSetJ === void 0 ? ok([]) : (() => {
|
|
5360
|
+
const arr = requireArray(`${path}.srcSet`, srcSetJ);
|
|
5361
|
+
if (!arr.ok) return arr;
|
|
5362
|
+
return traverseIndexed(
|
|
5363
|
+
arr.value,
|
|
5364
|
+
(i, el) => decodeSrcSetEntry(`${path}.srcSet[${i}]`, el)
|
|
5365
|
+
);
|
|
5366
|
+
})();
|
|
5367
|
+
if (!srcSet.ok) return srcSet;
|
|
5368
|
+
const expandableJ = tryField(f, "expandable");
|
|
5369
|
+
const expandable = expandableJ === void 0 ? ok(false) : requireBool(`${path}.expandable`, expandableJ);
|
|
5370
|
+
if (!expandable.ok) return expandable;
|
|
5371
|
+
return ok({
|
|
5372
|
+
alt: alt.value,
|
|
5373
|
+
src: src.value,
|
|
5374
|
+
variant: variant.value,
|
|
5375
|
+
fit: fit.value,
|
|
5376
|
+
aspectRatio: aspectRatio.value,
|
|
5377
|
+
loading: loading.value,
|
|
5378
|
+
srcSet: srcSet.value,
|
|
5379
|
+
expandable: expandable.value,
|
|
5380
|
+
...caption.value !== void 0 ? { caption: caption.value } : {}
|
|
5381
|
+
});
|
|
5382
|
+
};
|
|
5383
|
+
var decodeMediaKind = (path, j) => {
|
|
5384
|
+
const fo = requireObject(path, j);
|
|
5385
|
+
if (!fo.ok) return fo;
|
|
5386
|
+
const f = fo.value;
|
|
5387
|
+
const d = requireDiscriminator(path, f);
|
|
5388
|
+
if (!d.ok) return d;
|
|
5389
|
+
switch (d.value) {
|
|
5390
|
+
case "Video": {
|
|
5391
|
+
const autoplayJ = tryField(f, "autoplay");
|
|
5392
|
+
const autoplay = autoplayJ === void 0 ? ok(false) : requireBool(`${path}.autoplay`, autoplayJ);
|
|
5393
|
+
if (!autoplay.ok) return autoplay;
|
|
5394
|
+
const poster = optField(path, f, "poster", decodeBindingString);
|
|
5395
|
+
if (!poster.ok) return poster;
|
|
5396
|
+
return ok({
|
|
5397
|
+
$type: "Video",
|
|
5398
|
+
autoplay: autoplay.value,
|
|
5399
|
+
...poster.value !== void 0 ? { poster: poster.value } : {}
|
|
5400
|
+
});
|
|
5401
|
+
}
|
|
5402
|
+
case "Audio":
|
|
5403
|
+
return ok({ $type: "Audio" });
|
|
5404
|
+
default:
|
|
5405
|
+
return unknownDuCase(path, d.value, "Video | Audio");
|
|
5406
|
+
}
|
|
5407
|
+
};
|
|
5408
|
+
var decodeMediaSpec = (path, j) => {
|
|
5409
|
+
const fo = requireObject(path, j);
|
|
5410
|
+
if (!fo.ok) return fo;
|
|
5411
|
+
const f = fo.value;
|
|
5412
|
+
const src = reqField(path, f, "src", "Media Binding<string> Src", decodeBindingString);
|
|
5413
|
+
if (!src.ok) return src;
|
|
5414
|
+
const label = reqField(path, f, "label", "Media accessible label TextSource", decodeTextSource);
|
|
5415
|
+
if (!label.ok) return label;
|
|
5416
|
+
const kind = reqField(path, f, "kind", "MediaKind (Video | Audio)", decodeMediaKind);
|
|
5417
|
+
if (!kind.ok) return kind;
|
|
5418
|
+
const controlsJ = tryField(f, "controls");
|
|
5419
|
+
const controls = controlsJ === void 0 ? ok(true) : requireBool(`${path}.controls`, controlsJ);
|
|
5420
|
+
if (!controls.ok) return controls;
|
|
5421
|
+
const loopJ = tryField(f, "loop");
|
|
5422
|
+
const loop = loopJ === void 0 ? ok(false) : requireBool(`${path}.loop`, loopJ);
|
|
5423
|
+
if (!loop.ok) return loop;
|
|
5424
|
+
const tracksJ = tryField(f, "tracks");
|
|
5425
|
+
const tracks = tracksJ === void 0 ? ok([]) : (() => {
|
|
5426
|
+
const arr = requireArray(`${path}.tracks`, tracksJ);
|
|
5427
|
+
if (!arr.ok) return arr;
|
|
5428
|
+
return traverseIndexed(
|
|
5429
|
+
arr.value,
|
|
5430
|
+
(i, el) => decodeTrackEntry(`${path}.tracks[${i}]`, el)
|
|
5431
|
+
);
|
|
5432
|
+
})();
|
|
5433
|
+
if (!tracks.ok) return tracks;
|
|
5434
|
+
const transcript = optField(path, f, "transcript", decodeTextSource);
|
|
5435
|
+
if (!transcript.ok) return transcript;
|
|
5436
|
+
return ok({
|
|
5437
|
+
src: src.value,
|
|
5438
|
+
label: label.value,
|
|
5439
|
+
controls: controls.value,
|
|
5440
|
+
loop: loop.value,
|
|
5441
|
+
kind: kind.value,
|
|
5442
|
+
tracks: tracks.value,
|
|
5443
|
+
...transcript.value !== void 0 ? { transcript: transcript.value } : {}
|
|
5444
|
+
});
|
|
5445
|
+
};
|
|
5446
|
+
var decodeTrackEntry = (path, j) => {
|
|
5447
|
+
const fo = requireObject(path, j);
|
|
5448
|
+
if (!fo.ok) return fo;
|
|
5449
|
+
const f = fo.value;
|
|
5450
|
+
const kind = reqField(path, f, "kind", "TrackKind", decodeTrackKind);
|
|
5451
|
+
if (!kind.ok) return kind;
|
|
5452
|
+
const src = reqField(path, f, "src", "track Binding<string> Src", decodeBindingString);
|
|
5453
|
+
if (!src.ok) return src;
|
|
5454
|
+
const srcLang = reqField(path, f, "srcLang", "track srcLang string", requireString);
|
|
5455
|
+
if (!srcLang.ok) return srcLang;
|
|
5456
|
+
const label = reqField(path, f, "label", "track label TextSource", decodeTextSource);
|
|
5457
|
+
if (!label.ok) return label;
|
|
5458
|
+
const defaultJ = tryField(f, "default");
|
|
5459
|
+
const dflt = defaultJ === void 0 ? ok(false) : requireBool(`${path}.default`, defaultJ);
|
|
5460
|
+
if (!dflt.ok) return dflt;
|
|
5461
|
+
return ok({
|
|
5462
|
+
kind: kind.value,
|
|
5463
|
+
src: src.value,
|
|
5464
|
+
srcLang: srcLang.value,
|
|
5465
|
+
label: label.value,
|
|
5466
|
+
default: dflt.value
|
|
5467
|
+
});
|
|
5468
|
+
};
|
|
5469
|
+
var decodeTreeSpec = (path, j) => {
|
|
5470
|
+
const fo = requireObject(path, j);
|
|
5471
|
+
if (!fo.ok) return fo;
|
|
5472
|
+
const f = fo.value;
|
|
5473
|
+
const itemsJ = requireField(path, f, "items", "Tree items list");
|
|
5474
|
+
if (!itemsJ.ok) return itemsJ;
|
|
5475
|
+
const arr = requireArray(`${path}.items`, itemsJ.value);
|
|
5476
|
+
if (!arr.ok) return arr;
|
|
5477
|
+
const items = traverseIndexed(arr.value, (i, el) => decodeTreeItem(`${path}.items[${i}]`, el));
|
|
5478
|
+
if (!items.ok) return items;
|
|
5479
|
+
const expandedStateKey = optField(path, f, "expandedStateKey", requireString);
|
|
5480
|
+
if (!expandedStateKey.ok) return expandedStateKey;
|
|
5481
|
+
const selectionStateKey = optField(path, f, "selectionStateKey", requireString);
|
|
5482
|
+
if (!selectionStateKey.ok) return selectionStateKey;
|
|
5483
|
+
return ok({
|
|
5484
|
+
items: items.value,
|
|
5485
|
+
...expandedStateKey.value !== void 0 ? { expandedStateKey: expandedStateKey.value } : {},
|
|
5486
|
+
...selectionStateKey.value !== void 0 ? { selectionStateKey: selectionStateKey.value } : {},
|
|
5487
|
+
// Emitted only when present (rule 4); the value is the closure sentinel.
|
|
5488
|
+
...tryField(f, "onSelect") !== void 0 ? { onSelect: () => placeholderAction } : {}
|
|
5489
|
+
});
|
|
5490
|
+
};
|
|
5491
|
+
var decodeTreeItem = (path, j) => {
|
|
5492
|
+
if (itemDepth >= MAX_NODE_DEPTH) {
|
|
5493
|
+
return limitError(
|
|
5494
|
+
path,
|
|
5495
|
+
`tree-item nesting deeper than the wire limit MAX_NODE_DEPTH = ${MAX_NODE_DEPTH}`,
|
|
5496
|
+
`a tree nesting items no more than ${MAX_NODE_DEPTH} levels deep`
|
|
5497
|
+
);
|
|
5498
|
+
}
|
|
5499
|
+
itemDepth += 1;
|
|
5500
|
+
const r = decodeTreeItemInner(path, j);
|
|
5501
|
+
itemDepth -= 1;
|
|
5502
|
+
return r;
|
|
5503
|
+
};
|
|
5504
|
+
var decodeTreeItemInner = (path, j) => {
|
|
5505
|
+
const fo = requireObject(path, j);
|
|
5506
|
+
if (!fo.ok) return fo;
|
|
5507
|
+
const f = fo.value;
|
|
5508
|
+
const id = reqField(path, f, "id", "TreeItem id string", requireString);
|
|
5509
|
+
if (!id.ok) return id;
|
|
5510
|
+
const label = reqField(path, f, "label", "TreeItem label TextSource", decodeTextSource);
|
|
5511
|
+
if (!label.ok) return label;
|
|
5512
|
+
const childrenJ = tryField(f, "children");
|
|
5513
|
+
const children = childrenJ === void 0 ? ok([]) : (() => {
|
|
5514
|
+
const carr = requireArray(`${path}.children`, childrenJ);
|
|
5515
|
+
if (!carr.ok) return carr;
|
|
5516
|
+
return traverseIndexed(
|
|
5517
|
+
carr.value,
|
|
5518
|
+
(i, el) => decodeTreeItem(`${path}.children[${i}]`, el)
|
|
5519
|
+
);
|
|
5520
|
+
})();
|
|
5521
|
+
if (!children.ok) return children;
|
|
5522
|
+
const icon = optField(path, f, "icon", requireString);
|
|
5523
|
+
if (!icon.ok) return icon;
|
|
5524
|
+
return ok({
|
|
5525
|
+
id: id.value,
|
|
5526
|
+
label: label.value,
|
|
5527
|
+
children: children.value,
|
|
5528
|
+
...icon.value !== void 0 ? { icon: icon.value } : {}
|
|
5529
|
+
});
|
|
5530
|
+
};
|
|
5531
|
+
var decodeEmbedSpec = (path, j) => {
|
|
5532
|
+
const fo = requireObject(path, j);
|
|
5533
|
+
if (!fo.ok) return fo;
|
|
5534
|
+
const f = fo.value;
|
|
5535
|
+
const src = reqField(path, f, "src", "Embed Binding<string> Src", decodeBindingString);
|
|
5536
|
+
if (!src.ok) return src;
|
|
5537
|
+
const title = reqField(path, f, "title", "Embed accessible title TextSource", decodeTextSource);
|
|
5538
|
+
if (!title.ok) return title;
|
|
5539
|
+
const aspectJ = tryField(f, "aspectRatio");
|
|
5540
|
+
const aspectRatio = aspectJ === void 0 ? ok("Natural") : decodeImageAspect(`${path}.aspectRatio`, aspectJ);
|
|
5541
|
+
if (!aspectRatio.ok) return aspectRatio;
|
|
5542
|
+
const permissionsJ = tryField(f, "permissions");
|
|
5543
|
+
const permissions = permissionsJ === void 0 ? ok([]) : (() => {
|
|
5544
|
+
const arr = requireArray(`${path}.permissions`, permissionsJ);
|
|
5545
|
+
if (!arr.ok) return arr;
|
|
5546
|
+
return traverseIndexed(
|
|
5547
|
+
arr.value,
|
|
5548
|
+
(i, el) => decodeEmbedPermission(`${path}.permissions[${i}]`, el)
|
|
5549
|
+
);
|
|
5550
|
+
})();
|
|
5551
|
+
if (!permissions.ok) return permissions;
|
|
5552
|
+
return ok({
|
|
5553
|
+
src: src.value,
|
|
5554
|
+
title: title.value,
|
|
5555
|
+
aspectRatio: aspectRatio.value,
|
|
5556
|
+
permissions: permissions.value
|
|
5557
|
+
});
|
|
5009
5558
|
};
|
|
5010
5559
|
var decodeListSpec = (path, j) => {
|
|
5011
5560
|
const fo = requireObject(path, j);
|
|
@@ -5149,7 +5698,7 @@ var decodeProgressSpec = (path, j) => {
|
|
|
5149
5698
|
const fo = requireObject(path, j);
|
|
5150
5699
|
if (!fo.ok) return fo;
|
|
5151
5700
|
const f = fo.value;
|
|
5152
|
-
const fraction = reqField(path, f, "fraction", "Progress fraction binding",
|
|
5701
|
+
const fraction = reqField(path, f, "fraction", "Progress fraction binding", decodeBindingFloat);
|
|
5153
5702
|
if (!fraction.ok) return fraction;
|
|
5154
5703
|
const indeterminate = optField(path, f, "indeterminate", requireBool);
|
|
5155
5704
|
if (!indeterminate.ok) return indeterminate;
|
|
@@ -5199,9 +5748,9 @@ var decodeDrawStyle = (path, j) => {
|
|
|
5199
5748
|
if (!fill.ok) return fill;
|
|
5200
5749
|
const stroke = optField(path, f, "stroke", decodeBindingString);
|
|
5201
5750
|
if (!stroke.ok) return stroke;
|
|
5202
|
-
const strokeWidth = optField(path, f, "strokeWidth",
|
|
5751
|
+
const strokeWidth = optField(path, f, "strokeWidth", decodeBindingFloat);
|
|
5203
5752
|
if (!strokeWidth.ok) return strokeWidth;
|
|
5204
|
-
const opacity = optField(path, f, "opacity",
|
|
5753
|
+
const opacity = optField(path, f, "opacity", decodeBindingFloat);
|
|
5205
5754
|
if (!opacity.ok) return opacity;
|
|
5206
5755
|
const textAnchor = optField(path, f, "textAnchor", decodeTextAnchor);
|
|
5207
5756
|
if (!textAnchor.ok) return textAnchor;
|
|
@@ -5480,6 +6029,18 @@ var decodeDisplayKind = (path, j) => {
|
|
|
5480
6029
|
const r = decodeImageSpec(path, j);
|
|
5481
6030
|
return r.ok ? ok({ kind: "Image", spec: r.value }) : r;
|
|
5482
6031
|
}
|
|
6032
|
+
case "Embed": {
|
|
6033
|
+
const r = decodeEmbedSpec(path, j);
|
|
6034
|
+
return r.ok ? ok({ kind: "Embed", spec: r.value }) : r;
|
|
6035
|
+
}
|
|
6036
|
+
case "Media": {
|
|
6037
|
+
const r = decodeMediaSpec(path, j);
|
|
6038
|
+
return r.ok ? ok({ kind: "Media", spec: r.value }) : r;
|
|
6039
|
+
}
|
|
6040
|
+
case "Tree": {
|
|
6041
|
+
const r = decodeTreeSpec(path, j);
|
|
6042
|
+
return r.ok ? ok({ kind: "Tree", spec: r.value }) : r;
|
|
6043
|
+
}
|
|
5483
6044
|
case "List": {
|
|
5484
6045
|
const r = decodeListSpec(path, j);
|
|
5485
6046
|
return r.ok ? ok({ kind: "List", spec: r.value }) : r;
|
|
@@ -5504,7 +6065,7 @@ var decodeDisplayKind = (path, j) => {
|
|
|
5504
6065
|
return unknownDuCase(
|
|
5505
6066
|
path,
|
|
5506
6067
|
d.value,
|
|
5507
|
-
"Heading | Markdown | Metric | Badge | Link | Image | List | Toast | CodeBlock | Math | Drawing | Sparkline | Callout | Progress | Skeleton | LabelValueRow"
|
|
6068
|
+
"Heading | Markdown | Metric | Badge | Link | Image | Media | Embed | Tree | List | Toast | CodeBlock | Math | Drawing | Sparkline | Callout | Progress | Skeleton | LabelValueRow | Fact"
|
|
5508
6069
|
);
|
|
5509
6070
|
}
|
|
5510
6071
|
};
|
|
@@ -5531,7 +6092,11 @@ var decodeFormFieldKind = (autoBind, path, j) => {
|
|
|
5531
6092
|
return v.ok ? ok({ kind: "Text", value: v.value, ...onChangeField }) : v;
|
|
5532
6093
|
}
|
|
5533
6094
|
case "Number": {
|
|
5534
|
-
const v = valueOr(
|
|
6095
|
+
const v = valueOr(
|
|
6096
|
+
decodeBindingFloat,
|
|
6097
|
+
controlValueDefaults.number,
|
|
6098
|
+
"Number value binding"
|
|
6099
|
+
);
|
|
5535
6100
|
return v.ok ? ok({ kind: "Number", value: v.value, ...onChangeField }) : v;
|
|
5536
6101
|
}
|
|
5537
6102
|
case "Checkbox": {
|
|
@@ -5583,7 +6148,7 @@ var decodeFormFieldKind = (autoBind, path, j) => {
|
|
|
5583
6148
|
}
|
|
5584
6149
|
case "RangedNumber": {
|
|
5585
6150
|
const value = valueOr(
|
|
5586
|
-
|
|
6151
|
+
decodeBindingFloat,
|
|
5587
6152
|
controlValueDefaults.number,
|
|
5588
6153
|
"RangedNumber value binding"
|
|
5589
6154
|
);
|
|
@@ -5631,6 +6196,95 @@ var decodeFormFieldKind = (autoBind, path, j) => {
|
|
|
5631
6196
|
orientation: orientation.value
|
|
5632
6197
|
});
|
|
5633
6198
|
}
|
|
6199
|
+
case "Combobox": {
|
|
6200
|
+
const options = reqField(
|
|
6201
|
+
path,
|
|
6202
|
+
f,
|
|
6203
|
+
"options",
|
|
6204
|
+
"Combobox options binding",
|
|
6205
|
+
decodeBindingSelectOptions
|
|
6206
|
+
);
|
|
6207
|
+
if (!options.ok) return options;
|
|
6208
|
+
const allowFreeTextJ = tryField(f, "allowFreeText");
|
|
6209
|
+
const allowFreeText = allowFreeTextJ === void 0 ? ok(false) : requireBool(`${path}.allowFreeText`, allowFreeTextJ);
|
|
6210
|
+
if (!allowFreeText.ok) return allowFreeText;
|
|
6211
|
+
const value = valueOr(
|
|
6212
|
+
decodeBindingStringOpt,
|
|
6213
|
+
controlValueDefaults.choice,
|
|
6214
|
+
"Combobox value binding"
|
|
6215
|
+
);
|
|
6216
|
+
if (!value.ok) return value;
|
|
6217
|
+
return ok({
|
|
6218
|
+
kind: "Combobox",
|
|
6219
|
+
allowFreeText: allowFreeText.value,
|
|
6220
|
+
options: options.value,
|
|
6221
|
+
value: value.value,
|
|
6222
|
+
...onChangeField
|
|
6223
|
+
});
|
|
6224
|
+
}
|
|
6225
|
+
case "Tokens": {
|
|
6226
|
+
const allowFreeTextJ = tryField(f, "allowFreeText");
|
|
6227
|
+
const allowFreeText = allowFreeTextJ === void 0 ? ok(true) : requireBool(`${path}.allowFreeText`, allowFreeTextJ);
|
|
6228
|
+
if (!allowFreeText.ok) return allowFreeText;
|
|
6229
|
+
const suggestions = optField(path, f, "suggestions", decodeBindingSelectOptions);
|
|
6230
|
+
if (!suggestions.ok) return suggestions;
|
|
6231
|
+
if (!allowFreeText.value && suggestions.value === void 0)
|
|
6232
|
+
return wrongType(
|
|
6233
|
+
`${path}.allowFreeText`,
|
|
6234
|
+
"a suggestion source alongside allowFreeText:false \u2014 a closed token field with nothing to pick from admits no token at all (WIRE_FORMAT.md \xA73.6.19)"
|
|
6235
|
+
);
|
|
6236
|
+
const value = valueOr(
|
|
6237
|
+
decodeBindingStringList,
|
|
6238
|
+
controlValueDefaults.tokens,
|
|
6239
|
+
"Tokens Binding<string list> value"
|
|
6240
|
+
);
|
|
6241
|
+
if (!value.ok) return value;
|
|
6242
|
+
return ok({
|
|
6243
|
+
kind: "Tokens",
|
|
6244
|
+
allowFreeText: allowFreeText.value,
|
|
6245
|
+
value: value.value,
|
|
6246
|
+
...suggestions.value !== void 0 ? { suggestions: suggestions.value } : {},
|
|
6247
|
+
...onChangeField
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6250
|
+
case "Rating": {
|
|
6251
|
+
const maxJ = requireField(path, f, "max", "Rating max integer of 1 or more");
|
|
6252
|
+
if (!maxJ.ok) return maxJ;
|
|
6253
|
+
if (maxJ.value.kind !== "JNumber" || maxJ.value.value < 1 || !Number.isInteger(maxJ.value.value))
|
|
6254
|
+
return wrongType(`${path}.max`, "JSON number (an integer scale of 1 or more)");
|
|
6255
|
+
const max = maxJ.value.value;
|
|
6256
|
+
const allowHalfJ = tryField(f, "allowHalf");
|
|
6257
|
+
const allowHalf = allowHalfJ === void 0 ? ok(false) : requireBool(`${path}.allowHalf`, allowHalfJ);
|
|
6258
|
+
if (!allowHalf.ok) return allowHalf;
|
|
6259
|
+
const value = valueOr(
|
|
6260
|
+
decodeBindingFloat,
|
|
6261
|
+
controlValueDefaults.number,
|
|
6262
|
+
"Rating value binding"
|
|
6263
|
+
);
|
|
6264
|
+
if (!value.ok) return value;
|
|
6265
|
+
return ok({
|
|
6266
|
+
kind: "Rating",
|
|
6267
|
+
max,
|
|
6268
|
+
allowHalf: allowHalf.value,
|
|
6269
|
+
value: value.value,
|
|
6270
|
+
...onChangeField
|
|
6271
|
+
});
|
|
6272
|
+
}
|
|
6273
|
+
case "Color": {
|
|
6274
|
+
const value = valueOr(
|
|
6275
|
+
decodeBinding,
|
|
6276
|
+
controlValueDefaults.color,
|
|
6277
|
+
"Color value binding"
|
|
6278
|
+
);
|
|
6279
|
+
if (!value.ok) return value;
|
|
6280
|
+
const bound = value.value;
|
|
6281
|
+
if (bound.kind === "Static" && !(typeof bound.value === "string" && /^#[0-9a-fA-F]{6}$/.test(bound.value)))
|
|
6282
|
+
return wrongType(
|
|
6283
|
+
`${path}.value`,
|
|
6284
|
+
"a #rrggbb colour literal \u2014 six hexadecimal digits after a #, the one form a native colour input can hold (WIRE_FORMAT.md \xA73.6.17)"
|
|
6285
|
+
);
|
|
6286
|
+
return ok({ kind: "Color", value: value.value, ...onChangeField });
|
|
6287
|
+
}
|
|
5634
6288
|
case "TextArea": {
|
|
5635
6289
|
const rows = reqField(path, f, "rows", "textarea row count integer", requireInt);
|
|
5636
6290
|
if (!rows.ok) return rows;
|
|
@@ -5697,6 +6351,77 @@ var decodeFormFieldKind = (autoBind, path, j) => {
|
|
|
5697
6351
|
return unknownDuCase(path, d.value, WRONG_FORM_FIELD_KIND_HINT);
|
|
5698
6352
|
}
|
|
5699
6353
|
};
|
|
6354
|
+
var TEXT_FORMATS = ["email", "url", "tel"];
|
|
6355
|
+
var COMPARE_OPS = ["eq", "neq", "lt", "lte", "gt", "gte"];
|
|
6356
|
+
var decodeTextFormat = (path, j) => bareEnum(path, j, TEXT_FORMATS, "TextFormat");
|
|
6357
|
+
var decodeCompareOp = (path, j) => bareEnum(path, j, COMPARE_OPS, "CompareOp");
|
|
6358
|
+
var decodeCompareRule = (path, j) => {
|
|
6359
|
+
const fo = requireObject(path, j);
|
|
6360
|
+
if (!fo.ok) return fo;
|
|
6361
|
+
const f = fo.value;
|
|
6362
|
+
const op = reqField(path, f, "op", "CompareOp", decodeCompareOp);
|
|
6363
|
+
if (!op.ok) return op;
|
|
6364
|
+
const against = reqField(path, f, "against", "Binding", (p, v) => decodeBinding(p, v));
|
|
6365
|
+
if (!against.ok) return against;
|
|
6366
|
+
return ok({ op: op.value, against: against.value });
|
|
6367
|
+
};
|
|
6368
|
+
var decodeFieldRule = (path, j) => {
|
|
6369
|
+
const fo = requireObject(path, j);
|
|
6370
|
+
if (!fo.ok) return fo;
|
|
6371
|
+
const f = fo.value;
|
|
6372
|
+
const format = optField(path, f, "format", decodeTextFormat);
|
|
6373
|
+
if (!format.ok) return format;
|
|
6374
|
+
const pattern = optField(path, f, "pattern", requireString);
|
|
6375
|
+
if (!pattern.ok) return pattern;
|
|
6376
|
+
const minLength = optField(path, f, "minLength", requireInt);
|
|
6377
|
+
if (!minLength.ok) return minLength;
|
|
6378
|
+
const maxLength = optField(path, f, "maxLength", requireInt);
|
|
6379
|
+
if (!maxLength.ok) return maxLength;
|
|
6380
|
+
const compare = optField(path, f, "compare", decodeCompareRule);
|
|
6381
|
+
if (!compare.ok) return compare;
|
|
6382
|
+
const message = optField(path, f, "message", decodeTextSource);
|
|
6383
|
+
if (!message.ok) return message;
|
|
6384
|
+
const constrains = format.value !== void 0 || pattern.value !== void 0 || minLength.value !== void 0 || maxLength.value !== void 0 || compare.value !== void 0;
|
|
6385
|
+
if (!constrains)
|
|
6386
|
+
return makeError(
|
|
6387
|
+
"WRONG_TYPE",
|
|
6388
|
+
path,
|
|
6389
|
+
"a rule that constrains nothing is a defect, not a no-op \u2014 declare at least one of format / pattern / minLength / maxLength / compare, or omit 'rule' entirely",
|
|
6390
|
+
"FieldRule with at least one constraint slot"
|
|
6391
|
+
);
|
|
6392
|
+
if (minLength.value !== void 0 && maxLength.value !== void 0 && minLength.value > maxLength.value)
|
|
6393
|
+
return makeError(
|
|
6394
|
+
"WRONG_TYPE",
|
|
6395
|
+
path,
|
|
6396
|
+
`minLength ${minLength.value} is above maxLength ${maxLength.value} \u2014 an inverted length bound admits no value at all, so the field could never be submitted`,
|
|
6397
|
+
"minLength <= maxLength"
|
|
6398
|
+
);
|
|
6399
|
+
return ok({
|
|
6400
|
+
...format.value !== void 0 ? { format: format.value } : {},
|
|
6401
|
+
...pattern.value !== void 0 ? { pattern: pattern.value } : {},
|
|
6402
|
+
...minLength.value !== void 0 ? { minLength: minLength.value } : {},
|
|
6403
|
+
...maxLength.value !== void 0 ? { maxLength: maxLength.value } : {},
|
|
6404
|
+
...compare.value !== void 0 ? { compare: compare.value } : {},
|
|
6405
|
+
...message.value !== void 0 ? { message: message.value } : {}
|
|
6406
|
+
});
|
|
6407
|
+
};
|
|
6408
|
+
var FORM_FIELD_NEAR_MISSES = [
|
|
6409
|
+
["validation", "rule"],
|
|
6410
|
+
["constraints", "rule"],
|
|
6411
|
+
["validate", "rule"]
|
|
6412
|
+
];
|
|
6413
|
+
var checkFormFieldNearMisses = (path, f) => {
|
|
6414
|
+
for (const [name, canonical] of FORM_FIELD_NEAR_MISSES) {
|
|
6415
|
+
if (tryField(f, name) !== void 0)
|
|
6416
|
+
return makeError(
|
|
6417
|
+
"WRONG_TYPE",
|
|
6418
|
+
`${path}.${name}`,
|
|
6419
|
+
`'${name}' is not part of the form vocabulary \u2014 it would be ignored, not honoured, and the field would accept anything`,
|
|
6420
|
+
canonical
|
|
6421
|
+
);
|
|
6422
|
+
}
|
|
6423
|
+
return ok(void 0);
|
|
6424
|
+
};
|
|
5700
6425
|
var decodeFormField = (path, j) => {
|
|
5701
6426
|
const fo = requireObject(path, j);
|
|
5702
6427
|
if (!fo.ok) return fo;
|
|
@@ -5718,12 +6443,17 @@ var decodeFormField = (path, j) => {
|
|
|
5718
6443
|
if (!required.ok) return required;
|
|
5719
6444
|
const help = optField(path, f, "help", decodeTextSource);
|
|
5720
6445
|
if (!help.ok) return help;
|
|
6446
|
+
const nm = checkFormFieldNearMisses(path, f);
|
|
6447
|
+
if (!nm.ok) return nm;
|
|
6448
|
+
const rule = optField(path, f, "rule", decodeFieldRule);
|
|
6449
|
+
if (!rule.ok) return rule;
|
|
5721
6450
|
return ok({
|
|
5722
6451
|
id: id.value,
|
|
5723
6452
|
kind: kind.value,
|
|
5724
6453
|
label: label.value,
|
|
5725
6454
|
required: required.value,
|
|
5726
|
-
...help.value !== void 0 ? { help: help.value } : {}
|
|
6455
|
+
...help.value !== void 0 ? { help: help.value } : {},
|
|
6456
|
+
...rule.value !== void 0 ? { rule: rule.value } : {}
|
|
5727
6457
|
});
|
|
5728
6458
|
};
|
|
5729
6459
|
var decodeFormSpec = (path, j) => {
|
|
@@ -5851,12 +6581,31 @@ var decodeFileUploadSpec = (path, j) => {
|
|
|
5851
6581
|
if (!multiple.ok) return multiple;
|
|
5852
6582
|
const disabled = optField(path, f, "disabled", decodeBindingBool);
|
|
5853
6583
|
if (!disabled.ok) return disabled;
|
|
6584
|
+
const dropTargetJ = tryField(f, "dropTarget");
|
|
6585
|
+
const dropTarget = dropTargetJ === void 0 ? ok(false) : requireBool(`${path}.dropTarget`, dropTargetJ);
|
|
6586
|
+
if (!dropTarget.ok) return dropTarget;
|
|
6587
|
+
const acceptPasteJ = tryField(f, "acceptPaste");
|
|
6588
|
+
const acceptPaste = acceptPasteJ === void 0 ? ok(false) : requireBool(`${path}.acceptPaste`, acceptPasteJ);
|
|
6589
|
+
if (!acceptPaste.ok) return acceptPaste;
|
|
6590
|
+
const capture = optField(path, f, "capture", decodeCaptureSource);
|
|
6591
|
+
if (!capture.ok) return capture;
|
|
6592
|
+
const destinationJ = tryField(f, "destination");
|
|
6593
|
+
const destination = destinationJ === void 0 ? ok(void 0) : (() => {
|
|
6594
|
+
const str3 = requireString(`${path}.destination`, destinationJ);
|
|
6595
|
+
if (!str3.ok) return str3;
|
|
6596
|
+
return str3.value === "" ? wrongType(`${path}.destination`, "a non-empty host-registered destination id") : ok(str3.value);
|
|
6597
|
+
})();
|
|
6598
|
+
if (!destination.ok) return destination;
|
|
5854
6599
|
return ok({
|
|
5855
6600
|
accept: accept.value,
|
|
5856
6601
|
label: label.value,
|
|
5857
6602
|
multiple: multiple.value,
|
|
5858
6603
|
onSelect: () => placeholderAction,
|
|
5859
|
-
...disabled.value !== void 0 ? { disabled: disabled.value } : {}
|
|
6604
|
+
...disabled.value !== void 0 ? { disabled: disabled.value } : {},
|
|
6605
|
+
dropTarget: dropTarget.value,
|
|
6606
|
+
acceptPaste: acceptPaste.value,
|
|
6607
|
+
...capture.value !== void 0 ? { capture: capture.value } : {},
|
|
6608
|
+
...destination.value !== void 0 ? { destination: destination.value } : {}
|
|
5860
6609
|
});
|
|
5861
6610
|
};
|
|
5862
6611
|
var decodeInputKind = (path, j) => {
|
|
@@ -6274,6 +7023,16 @@ var decodeGridSpec = (path, j) => {
|
|
|
6274
7023
|
if (!pk.ok) return pk;
|
|
6275
7024
|
pageStateKey = pk.value;
|
|
6276
7025
|
}
|
|
7026
|
+
const transferOutKey = optField(path, f, "transferOutKey", requireString);
|
|
7027
|
+
if (!transferOutKey.ok) return transferOutKey;
|
|
7028
|
+
const transferInKey = optField(path, f, "transferInKey", requireString);
|
|
7029
|
+
if (!transferInKey.ok) return transferInKey;
|
|
7030
|
+
const exportable = optField(path, f, "exportable", requireBool);
|
|
7031
|
+
if (!exportable.ok) return exportable;
|
|
7032
|
+
const keepRowsTogether = optField(path, f, "keepRowsTogether", requireBool);
|
|
7033
|
+
if (!keepRowsTogether.ok) return keepRowsTogether;
|
|
7034
|
+
const repeatHeader = optField(path, f, "repeatHeader", requireBool);
|
|
7035
|
+
if (!repeatHeader.ok) return repeatHeader;
|
|
6277
7036
|
const staticRowsJ = tryField(f, "staticRows");
|
|
6278
7037
|
let staticRows;
|
|
6279
7038
|
if (staticRowsJ !== void 0) {
|
|
@@ -6294,6 +7053,11 @@ var decodeGridSpec = (path, j) => {
|
|
|
6294
7053
|
...pageStateKey !== void 0 ? { pageStateKey } : {},
|
|
6295
7054
|
...defaultSort !== void 0 ? { defaultSort } : {},
|
|
6296
7055
|
...editStateKey !== void 0 ? { editStateKey } : {},
|
|
7056
|
+
...transferOutKey.value !== void 0 ? { transferOutKey: transferOutKey.value } : {},
|
|
7057
|
+
...transferInKey.value !== void 0 ? { transferInKey: transferInKey.value } : {},
|
|
7058
|
+
exportable: exportable.value ?? false,
|
|
7059
|
+
keepRowsTogether: keepRowsTogether.value ?? false,
|
|
7060
|
+
repeatHeader: repeatHeader.value ?? false,
|
|
6297
7061
|
...staticRows !== void 0 ? { staticRows } : {}
|
|
6298
7062
|
});
|
|
6299
7063
|
};
|
|
@@ -6462,10 +7226,23 @@ var decodeBoxLayout = (path, j) => {
|
|
|
6462
7226
|
...templateColumns.value !== void 0 ? { templateColumns: templateColumns.value } : {}
|
|
6463
7227
|
});
|
|
6464
7228
|
}
|
|
7229
|
+
case "Masonry": {
|
|
7230
|
+
const colsJ = tryField(f, "cols") ?? tryField(f, "columns");
|
|
7231
|
+
if (colsJ === void 0) return missingField(path, "cols", "positive integer column count");
|
|
7232
|
+
if (colsJ.kind !== "JNumber" || colsJ.value <= 0 || !Number.isInteger(colsJ.value))
|
|
7233
|
+
return wrongType(`${path}.cols`, "JSON number (positive integer column count)");
|
|
7234
|
+
const masonryGap = optField(path, f, "gap", requireInt);
|
|
7235
|
+
if (!masonryGap.ok) return masonryGap;
|
|
7236
|
+
return ok({
|
|
7237
|
+
kind: "Masonry",
|
|
7238
|
+
cols: colsJ.value,
|
|
7239
|
+
...masonryGap.value !== void 0 ? { gap: masonryGap.value } : {}
|
|
7240
|
+
});
|
|
7241
|
+
}
|
|
6465
7242
|
case "Auto":
|
|
6466
7243
|
return ok({ kind: "Auto" });
|
|
6467
7244
|
default:
|
|
6468
|
-
return unknownDuCase(path, d.value, "Flex | Grid | Auto");
|
|
7245
|
+
return unknownDuCase(path, d.value, "Flex | Grid | Masonry | Auto");
|
|
6469
7246
|
}
|
|
6470
7247
|
};
|
|
6471
7248
|
var decodeBoxRole = (path, j) => {
|
|
@@ -6478,7 +7255,7 @@ var decodeBoxRole = (path, j) => {
|
|
|
6478
7255
|
case "Separator":
|
|
6479
7256
|
return ok(s.value);
|
|
6480
7257
|
default:
|
|
6481
|
-
return
|
|
7258
|
+
return unknownEnumCase(path, s.value, "Group | Card | Dashboard | Separator");
|
|
6482
7259
|
}
|
|
6483
7260
|
};
|
|
6484
7261
|
var decodeBox = (path, j) => {
|
|
@@ -6493,11 +7270,17 @@ var decodeBox = (path, j) => {
|
|
|
6493
7270
|
if (!layout.ok) return layout;
|
|
6494
7271
|
const role = reqField(path, f, "role", "role string", decodeBoxRole);
|
|
6495
7272
|
if (!role.ok) return role;
|
|
7273
|
+
const keepTogether = optField(path, f, "keepTogether", requireBool);
|
|
7274
|
+
if (!keepTogether.ok) return keepTogether;
|
|
7275
|
+
const breakBefore = optField(path, f, "breakBefore", requireBool);
|
|
7276
|
+
if (!breakBefore.ok) return breakBefore;
|
|
6496
7277
|
return ok({
|
|
6497
7278
|
children: children.value,
|
|
6498
7279
|
...heading.value !== void 0 ? { heading: heading.value } : {},
|
|
6499
7280
|
layout: layout.value,
|
|
6500
|
-
role: role.value
|
|
7281
|
+
role: role.value,
|
|
7282
|
+
keepTogether: keepTogether.value ?? false,
|
|
7283
|
+
breakBefore: breakBefore.value ?? false
|
|
6501
7284
|
});
|
|
6502
7285
|
};
|
|
6503
7286
|
var decodeSplitPanelSpec = (path, j) => {
|
|
@@ -6561,7 +7344,7 @@ var decodeTabsSpec = (path, j) => {
|
|
|
6561
7344
|
}
|
|
6562
7345
|
const activeTag = optField(path, f, "activeTag", decodeBindingString);
|
|
6563
7346
|
if (!activeTag.ok) return activeTag;
|
|
6564
|
-
const activeIndex = optField(path, f, "activeIndex",
|
|
7347
|
+
const activeIndex = optField(path, f, "activeIndex", decodeBindingInt);
|
|
6565
7348
|
if (!activeIndex.ok) return activeIndex;
|
|
6566
7349
|
return ok({
|
|
6567
7350
|
children: children.value,
|
|
@@ -6578,7 +7361,7 @@ var decodeStepperSpec = (path, j) => {
|
|
|
6578
7361
|
const fo = requireObject(path, j);
|
|
6579
7362
|
if (!fo.ok) return fo;
|
|
6580
7363
|
const f = fo.value;
|
|
6581
|
-
const activeStep = reqField(path, f, "activeStep", "activeStep binding",
|
|
7364
|
+
const activeStep = reqField(path, f, "activeStep", "activeStep binding", decodeBindingInt);
|
|
6582
7365
|
if (!activeStep.ok) return activeStep;
|
|
6583
7366
|
const children = decodeChildren(path, f);
|
|
6584
7367
|
if (!children.ok) return children;
|
|
@@ -6644,12 +7427,19 @@ var decodeModalSpec = (path, j) => {
|
|
|
6644
7427
|
if (!open.ok) return open;
|
|
6645
7428
|
const heading = optFieldAliased(path, f, "heading", ["title"], decodeTextSource);
|
|
6646
7429
|
if (!heading.ok) return heading;
|
|
7430
|
+
const modalityJ = tryField(f, "modality");
|
|
7431
|
+
const modality = modalityJ === void 0 ? ok("Modal") : decodeModalityKind(`${path}.modality`, modalityJ);
|
|
7432
|
+
if (!modality.ok) return modality;
|
|
7433
|
+
const anchor = optField(path, f, "anchor", requireString);
|
|
7434
|
+
if (!anchor.ok) return anchor;
|
|
6647
7435
|
return ok({
|
|
6648
7436
|
children: children.value,
|
|
6649
7437
|
dismissable: dismissable.value,
|
|
6650
7438
|
...onDismiss.value !== void 0 ? { onDismiss: onDismiss.value } : {},
|
|
6651
7439
|
open: open.value,
|
|
6652
|
-
...heading.value !== void 0 ? { heading: heading.value } : {}
|
|
7440
|
+
...heading.value !== void 0 ? { heading: heading.value } : {},
|
|
7441
|
+
modality: modality.value,
|
|
7442
|
+
...anchor.value !== void 0 ? { anchor: anchor.value } : {}
|
|
6653
7443
|
});
|
|
6654
7444
|
};
|
|
6655
7445
|
var decodeScrollAreaSpec = (path, j) => {
|
|
@@ -6743,7 +7533,7 @@ var decodeContentHash = (path, j) => {
|
|
|
6743
7533
|
if (!strictnessR.ok) return strictnessR;
|
|
6744
7534
|
const s = strictnessR.value;
|
|
6745
7535
|
if (s !== "StrictReplay" && s !== "AdvisoryWarning" && s !== "Enforced") {
|
|
6746
|
-
return
|
|
7536
|
+
return unknownEnumCase(`${path}.strictness`, s, "StrictReplay | AdvisoryWarning | Enforced");
|
|
6747
7537
|
}
|
|
6748
7538
|
return ok({ algorithm: algorithm.value, hash: hash.value, strictness: s });
|
|
6749
7539
|
};
|
|
@@ -6874,11 +7664,11 @@ var decodeEffectClass = (path, j) => {
|
|
|
6874
7664
|
const host = reqField(path, fo.value, "hostEffect", "EffectClass hostEffect", requireString);
|
|
6875
7665
|
if (!host.ok) return host;
|
|
6876
7666
|
if (host.value !== "Pure" && host.value !== "ReadsHost" && host.value !== "WritesHost")
|
|
6877
|
-
return
|
|
7667
|
+
return unknownEnumCase(`${path}.hostEffect`, host.value, "Pure | ReadsHost | WritesHost");
|
|
6878
7668
|
const det = reqField(path, fo.value, "determinism", "EffectClass determinism", requireString);
|
|
6879
7669
|
if (!det.ok) return det;
|
|
6880
7670
|
if (det.value !== "Deterministic" && det.value !== "Clock" && det.value !== "Random" && det.value !== "Network")
|
|
6881
|
-
return
|
|
7671
|
+
return unknownEnumCase(
|
|
6882
7672
|
`${path}.determinism`,
|
|
6883
7673
|
det.value,
|
|
6884
7674
|
"Deterministic | Clock | Random | Network"
|
|
@@ -6898,6 +7688,14 @@ var decodeNodeKind = (path, j) => {
|
|
|
6898
7688
|
const f = fo.value;
|
|
6899
7689
|
const d = requireDiscriminator(path, f);
|
|
6900
7690
|
if (!d.ok) return d;
|
|
7691
|
+
if (narrows(walkPolicy) && NODE_KIND_NAMES.includes(d.value) && !admits(walkPolicy, d.value)) {
|
|
7692
|
+
return makeError(
|
|
7693
|
+
"KIND_NOT_ADMITTED",
|
|
7694
|
+
`${path}.$type`,
|
|
7695
|
+
`node kind '${d.value}' is not admitted by decode policy '${walkPolicy.identity}'`,
|
|
7696
|
+
policyHint(walkPolicy)
|
|
7697
|
+
);
|
|
7698
|
+
}
|
|
6901
7699
|
switch (d.value) {
|
|
6902
7700
|
// The four behavioural categories are flat on the wire (WIRE_FORMAT §3.2):
|
|
6903
7701
|
// the `kind` object carries the primitive discriminator directly, so route
|
|
@@ -6927,6 +7725,9 @@ var decodeNodeKind = (path, j) => {
|
|
|
6927
7725
|
case "Fact":
|
|
6928
7726
|
case "Link":
|
|
6929
7727
|
case "Image":
|
|
7728
|
+
case "Media":
|
|
7729
|
+
case "Embed":
|
|
7730
|
+
case "Tree":
|
|
6930
7731
|
case "List":
|
|
6931
7732
|
case "Toast":
|
|
6932
7733
|
case "CodeBlock":
|
|
@@ -7026,9 +7827,24 @@ var decodeNodeKind = (path, j) => {
|
|
|
7026
7827
|
if (!cases.ok) return cases;
|
|
7027
7828
|
const def = reqField(path, f, "default", "Switch default Node", decodeNodeAst);
|
|
7028
7829
|
if (!def.ok) return def;
|
|
7830
|
+
const autoAdvanceMsJ = tryField(f, "autoAdvanceMs");
|
|
7831
|
+
let autoAdvanceMs;
|
|
7832
|
+
if (autoAdvanceMsJ !== void 0) {
|
|
7833
|
+
if (autoAdvanceMsJ.kind !== "JNumber" || autoAdvanceMsJ.value < 1 || !Number.isInteger(autoAdvanceMsJ.value))
|
|
7834
|
+
return wrongType(
|
|
7835
|
+
`${path}.autoAdvanceMs`,
|
|
7836
|
+
"JSON number (a positive whole number of milliseconds)"
|
|
7837
|
+
);
|
|
7838
|
+
autoAdvanceMs = autoAdvanceMsJ.value;
|
|
7839
|
+
}
|
|
7029
7840
|
return ok({
|
|
7030
7841
|
kind: "Switch",
|
|
7031
|
-
spec: {
|
|
7842
|
+
spec: {
|
|
7843
|
+
on: on.value,
|
|
7844
|
+
cases: cases.value,
|
|
7845
|
+
default: def.value,
|
|
7846
|
+
...autoAdvanceMs !== void 0 ? { autoAdvanceMs } : {}
|
|
7847
|
+
}
|
|
7032
7848
|
});
|
|
7033
7849
|
}
|
|
7034
7850
|
case "FragmentDecl": {
|
|
@@ -7194,18 +8010,65 @@ var decodeSemanticStyle = (path, j) => {
|
|
|
7194
8010
|
if (!role.ok) return role;
|
|
7195
8011
|
const voice = optField(path, f, "voice", decodeFontVoice);
|
|
7196
8012
|
if (!voice.ok) return voice;
|
|
8013
|
+
const direction = optField(path, f, "direction", decodeTextDirection);
|
|
8014
|
+
if (!direction.ok) return direction;
|
|
7197
8015
|
return ok({
|
|
7198
8016
|
tone: tone.value ?? "Default",
|
|
7199
8017
|
weight: weight.value ?? "Standard",
|
|
7200
8018
|
emphasis: emphasis.value ?? "Normal",
|
|
7201
8019
|
role: role.value ?? "None",
|
|
7202
|
-
voice: voice.value ?? "Default"
|
|
8020
|
+
voice: voice.value ?? "Default",
|
|
8021
|
+
direction: direction.value ?? "auto"
|
|
7203
8022
|
});
|
|
7204
8023
|
};
|
|
8024
|
+
var A11Y_NEAR_MISSES = [
|
|
8025
|
+
[
|
|
8026
|
+
"aria-label",
|
|
8027
|
+
"label \u2014 the accessible name, a Binding<string> (a bare string is the \xA73.6 shorthand)"
|
|
8028
|
+
],
|
|
8029
|
+
[
|
|
8030
|
+
"ariaLabel",
|
|
8031
|
+
"label \u2014 the accessible name, a Binding<string> (a bare string is the \xA73.6 shorthand)"
|
|
8032
|
+
],
|
|
8033
|
+
["aria-labelledby", "labelledBy \u2014 the id of a sibling node whose text carries the name"],
|
|
8034
|
+
["ariaLabelledBy", "labelledBy \u2014 the id of a sibling node whose text carries the name"],
|
|
8035
|
+
[
|
|
8036
|
+
"labelledby",
|
|
8037
|
+
"labelledBy \u2014 the slot name is camelCase on the wire, not the ARIA attribute spelling"
|
|
8038
|
+
],
|
|
8039
|
+
["aria-describedby", "describedBy \u2014 the id of a sibling node whose text carries the description"],
|
|
8040
|
+
["ariaDescribedBy", "describedBy \u2014 the id of a sibling node whose text carries the description"],
|
|
8041
|
+
[
|
|
8042
|
+
"describedby",
|
|
8043
|
+
"describedBy \u2014 the slot name is camelCase on the wire, not the ARIA attribute spelling"
|
|
8044
|
+
],
|
|
8045
|
+
["aria-role", "role \u2014 the ARIA role NAME as a bare string"],
|
|
8046
|
+
["ariaRole", "role \u2014 the ARIA role NAME as a bare string"],
|
|
8047
|
+
["aria-live", 'liveRegion \u2014 the closed token set "polite" / "assertive" / "off"'],
|
|
8048
|
+
["ariaLive", 'liveRegion \u2014 the closed token set "polite" / "assertive" / "off"'],
|
|
8049
|
+
["live", 'liveRegion \u2014 the closed token set "polite" / "assertive" / "off"'],
|
|
8050
|
+
["liveregion", 'liveRegion \u2014 the closed token set "polite" / "assertive" / "off"'],
|
|
8051
|
+
["aria-hidden", "hidden \u2014 a Binding<bool> (a bare bool is the \xA73.6 shorthand)"],
|
|
8052
|
+
["ariaHidden", "hidden \u2014 a Binding<bool> (a bare bool is the \xA73.6 shorthand)"]
|
|
8053
|
+
];
|
|
8054
|
+
var checkA11yNearMisses = (path, f) => {
|
|
8055
|
+
for (const [name, canonical] of A11Y_NEAR_MISSES) {
|
|
8056
|
+
if (tryField(f, name) !== void 0)
|
|
8057
|
+
return makeError(
|
|
8058
|
+
"WRONG_TYPE",
|
|
8059
|
+
`${path}.${name}`,
|
|
8060
|
+
`'${name}' is not part of the accessibility vocabulary \u2014 it would be ignored, not honoured, and the intent would reach assistive technology as nothing at all`,
|
|
8061
|
+
canonical
|
|
8062
|
+
);
|
|
8063
|
+
}
|
|
8064
|
+
return ok(void 0);
|
|
8065
|
+
};
|
|
7205
8066
|
var decodeAccessibility = (path, j) => {
|
|
7206
8067
|
const fo = requireObject(path, j);
|
|
7207
8068
|
if (!fo.ok) return fo;
|
|
7208
8069
|
const f = fo.value;
|
|
8070
|
+
const nearMiss2 = checkA11yNearMisses(path, f);
|
|
8071
|
+
if (!nearMiss2.ok) return nearMiss2;
|
|
7209
8072
|
const label = optField(path, f, "label", decodeBindingString);
|
|
7210
8073
|
if (!label.ok) return label;
|
|
7211
8074
|
const labelledBy = optField(path, f, "labelledBy", requireString);
|
|
@@ -7250,7 +8113,41 @@ var placeholderClosureNode = {
|
|
|
7250
8113
|
voice: "Default"
|
|
7251
8114
|
}
|
|
7252
8115
|
};
|
|
8116
|
+
var walkDepth = 0;
|
|
8117
|
+
var walkNodes = 0;
|
|
8118
|
+
var opDepth = 0;
|
|
8119
|
+
var itemDepth = 0;
|
|
8120
|
+
var walkPolicy = admitAll;
|
|
8121
|
+
var resetWalk = (policy = admitAll) => {
|
|
8122
|
+
walkDepth = 0;
|
|
8123
|
+
walkNodes = 0;
|
|
8124
|
+
opDepth = 0;
|
|
8125
|
+
itemDepth = 0;
|
|
8126
|
+
walkPolicy = policy;
|
|
8127
|
+
};
|
|
8128
|
+
var limitError = (path, message, expected) => makeError("LIMIT_EXCEEDED", path, message, expected);
|
|
7253
8129
|
var decodeNodeAst = (path, j) => {
|
|
8130
|
+
if (walkDepth >= MAX_NODE_DEPTH) {
|
|
8131
|
+
return limitError(
|
|
8132
|
+
path,
|
|
8133
|
+
`node nesting deeper than the wire limit MAX_NODE_DEPTH = ${MAX_NODE_DEPTH}`,
|
|
8134
|
+
`a tree nesting nodes no more than ${MAX_NODE_DEPTH} levels deep`
|
|
8135
|
+
);
|
|
8136
|
+
}
|
|
8137
|
+
walkNodes += 1;
|
|
8138
|
+
if (walkNodes > MAX_NODES) {
|
|
8139
|
+
return limitError(
|
|
8140
|
+
path,
|
|
8141
|
+
`the document holds more than the wire limit MAX_NODES = ${MAX_NODES} nodes`,
|
|
8142
|
+
`a tree of no more than ${MAX_NODES} nodes in total`
|
|
8143
|
+
);
|
|
8144
|
+
}
|
|
8145
|
+
walkDepth += 1;
|
|
8146
|
+
const r = decodeNodeAstInner(path, j);
|
|
8147
|
+
walkDepth -= 1;
|
|
8148
|
+
return r;
|
|
8149
|
+
};
|
|
8150
|
+
var decodeNodeAstInner = (path, j) => {
|
|
7254
8151
|
const fo = requireObject(path, j);
|
|
7255
8152
|
if (!fo.ok) return fo;
|
|
7256
8153
|
const f = fo.value;
|
|
@@ -7269,15 +8166,37 @@ var decodeNodeAst = (path, j) => {
|
|
|
7269
8166
|
if (!style.ok) return style;
|
|
7270
8167
|
const accessibility2 = optField(path, f, "accessibility", decodeAccessibility);
|
|
7271
8168
|
if (!accessibility2.ok) return accessibility2;
|
|
8169
|
+
const tooltip = optField(path, f, "tooltip", decodeTextSource);
|
|
8170
|
+
if (!tooltip.ok) return tooltip;
|
|
7272
8171
|
return ok({
|
|
7273
8172
|
id: idStr.value,
|
|
7274
8173
|
kind: kind.value,
|
|
7275
8174
|
state: state.value,
|
|
7276
8175
|
style: style.value,
|
|
7277
|
-
...accessibility2.value !== void 0 ? { accessibility: accessibility2.value } : {}
|
|
8176
|
+
...accessibility2.value !== void 0 ? { accessibility: accessibility2.value } : {},
|
|
8177
|
+
...tooltip.value !== void 0 ? { tooltip: tooltip.value } : {}
|
|
7278
8178
|
});
|
|
7279
8179
|
};
|
|
7280
8180
|
var decodeTreeOpAst = (path, j) => {
|
|
8181
|
+
if (opDepth >= MAX_NODE_DEPTH) {
|
|
8182
|
+
return limitError(
|
|
8183
|
+
path,
|
|
8184
|
+
`op nesting deeper than the wire limit MAX_NODE_DEPTH = ${MAX_NODE_DEPTH}`,
|
|
8185
|
+
`a Batch nesting ops no more than ${MAX_NODE_DEPTH} levels deep`
|
|
8186
|
+
);
|
|
8187
|
+
}
|
|
8188
|
+
opDepth += 1;
|
|
8189
|
+
const r = decodeTreeOpAstInner(path, j);
|
|
8190
|
+
opDepth -= 1;
|
|
8191
|
+
return r;
|
|
8192
|
+
};
|
|
8193
|
+
var retiredPositionalField = (path, f, name, opKind) => tryField(f, name) !== void 0 ? makeError(
|
|
8194
|
+
"WRONG_TYPE",
|
|
8195
|
+
`${path}.${name}`,
|
|
8196
|
+
`'${name}' was removed from the wire format \u2014 ${opKind} appends, and order is stated by naming ids with ReorderChildren`,
|
|
8197
|
+
"a Batch of the structural op followed by ReorderChildren"
|
|
8198
|
+
) : ok(void 0);
|
|
8199
|
+
var decodeTreeOpAstInner = (path, j) => {
|
|
7281
8200
|
const fo = requireObject(path, j);
|
|
7282
8201
|
if (!fo.ok) return fo;
|
|
7283
8202
|
const f = fo.value;
|
|
@@ -7330,6 +8249,8 @@ var decodeTreeOpAst = (path, j) => {
|
|
|
7330
8249
|
return state.ok ? ok({ kind: "UpdateState", target: t.value, state: state.value }) : state;
|
|
7331
8250
|
}
|
|
7332
8251
|
case "InsertChild": {
|
|
8252
|
+
const retired = retiredPositionalField(path, f, "position", "InsertChild");
|
|
8253
|
+
if (!retired.ok) return retired;
|
|
7333
8254
|
const parentJ = reqField(path, f, "parentId", "parent NodeId", requireString);
|
|
7334
8255
|
if (!parentJ.ok) return parentJ;
|
|
7335
8256
|
const child = reqField(path, f, "child", "child Node object", decodeNodeAst);
|
|
@@ -7344,6 +8265,8 @@ var decodeTreeOpAst = (path, j) => {
|
|
|
7344
8265
|
return t.ok ? ok({ kind: "RemoveNode", target: t.value }) : t;
|
|
7345
8266
|
}
|
|
7346
8267
|
case "MoveNode": {
|
|
8268
|
+
const retired = retiredPositionalField(path, f, "newPosition", "MoveNode");
|
|
8269
|
+
if (!retired.ok) return retired;
|
|
7347
8270
|
const t = target();
|
|
7348
8271
|
if (!t.ok) return t;
|
|
7349
8272
|
const newParent = reqField(path, f, "newParentId", "new parent NodeId", requireString);
|
|
@@ -7425,6 +8348,8 @@ var coerce = {
|
|
|
7425
8348
|
tone: (v) => viaAst(v, decodeTone),
|
|
7426
8349
|
weight: (v) => viaAst(v, decodeWeight),
|
|
7427
8350
|
emphasis: (v) => viaAst(v, decodeEmphasis),
|
|
8351
|
+
/** `Metric.TrendPolarity` (Phase 867) - the UpdateProp twin of `decodeTrendPolarity`. */
|
|
8352
|
+
trendPolarity: (v) => viaAst(v, decodeTrendPolarity),
|
|
7428
8353
|
/**
|
|
7429
8354
|
* The behavioural `emphasis` BOOL on Fact / LabelValueRow — the UpdateProp
|
|
7430
8355
|
* twin of `decodeEmphasisFlag`, so a TreeOp edit gets the same
|
|
@@ -7445,13 +8370,18 @@ var invalidJson = (parseMessage) => makeError(
|
|
|
7445
8370
|
`input is not valid JSON: ${parseMessage}`,
|
|
7446
8371
|
"well-formed JSON object per the canonical-JSON shape"
|
|
7447
8372
|
);
|
|
7448
|
-
var
|
|
8373
|
+
var parseFailure = (e) => e.limit === true ? makeError("LIMIT_EXCEEDED", "$", e.message, "a document within the WIRE_FORMAT \xA721 limits") : invalidJson(e.message);
|
|
8374
|
+
var decodeNode = (json, policy) => {
|
|
7449
8375
|
const parsed = parse(json);
|
|
7450
|
-
|
|
8376
|
+
if (!parsed.ok) return parseFailure(parsed.error);
|
|
8377
|
+
resetWalk(policy);
|
|
8378
|
+
return decodeNodeAst("$", parsed.value);
|
|
7451
8379
|
};
|
|
7452
|
-
var decodeOp = (json) => {
|
|
8380
|
+
var decodeOp = (json, policy) => {
|
|
7453
8381
|
const parsed = parse(json);
|
|
7454
|
-
|
|
8382
|
+
if (!parsed.ok) return parseFailure(parsed.error);
|
|
8383
|
+
resetWalk(policy);
|
|
8384
|
+
return decodeTreeOpAst("$", parsed.value);
|
|
7455
8385
|
};
|
|
7456
8386
|
|
|
7457
8387
|
// src/apply.ts
|
|
@@ -7618,6 +8548,11 @@ var updateField = (field2, value, kind) => {
|
|
|
7618
8548
|
coerce.cellFormat(value),
|
|
7619
8549
|
(x) => disp({ kind: "Metric", spec: { ...s, trendFormat: x } })
|
|
7620
8550
|
);
|
|
8551
|
+
case "TrendPolarity":
|
|
8552
|
+
return patch(
|
|
8553
|
+
coerce.trendPolarity(value),
|
|
8554
|
+
(x) => disp({ kind: "Metric", spec: { ...s, trendPolarity: x } })
|
|
8555
|
+
);
|
|
7621
8556
|
case "Icon":
|
|
7622
8557
|
return patch(
|
|
7623
8558
|
coerce.iconSource(value),
|
|
@@ -7901,6 +8836,12 @@ var updateField = (field2, value, kind) => {
|
|
|
7901
8836
|
(x) => lay({ kind: "Box", spec: { ...s, layout: { ...mode, cols: x } } })
|
|
7902
8837
|
);
|
|
7903
8838
|
}
|
|
8839
|
+
if (field2 === "Cols" && mode.kind === "Masonry") {
|
|
8840
|
+
return patch(
|
|
8841
|
+
coerce.int(value),
|
|
8842
|
+
(x) => lay({ kind: "Box", spec: { ...s, layout: { ...mode, cols: x } } })
|
|
8843
|
+
);
|
|
8844
|
+
}
|
|
7904
8845
|
if (field2 === "TemplateColumns" && mode.kind === "Grid") {
|
|
7905
8846
|
return patch(
|
|
7906
8847
|
coerce.string(value),
|
|
@@ -8688,10 +9629,12 @@ var str2 = (s) => {
|
|
|
8688
9629
|
}
|
|
8689
9630
|
return out + '"';
|
|
8690
9631
|
};
|
|
9632
|
+
var encodeActorValue = (a) => a.kind === "human" ? `{"kind":"human","id":${str2(a.id)}}` : `{"kind":"agent","model":${str2(a.model)},"version":${str2(a.version)},"id":${str2(a.id)}}`;
|
|
8691
9633
|
var encodeEnvelope = (e) => e.$type === "Success" ? '{"$type":"Success"}' : `{"$type":"Failure","code":${str2(e.code)},"message":${str2(e.message)}}`;
|
|
8692
9634
|
var encodeDagRecord = (record) => {
|
|
8693
9635
|
let out = "{";
|
|
8694
|
-
out += `"
|
|
9636
|
+
out += `"actor":${encodeActorValue(record.actor)}`;
|
|
9637
|
+
out += `,"hash":${str2(record.hash)}`;
|
|
8695
9638
|
out += `,"op":${encodeOp(record.op)}`;
|
|
8696
9639
|
if (record.outcomeHash !== void 0) out += `,"outcomeHash":${str2(record.outcomeHash)}`;
|
|
8697
9640
|
out += `,"parents":[${record.parents.map(str2).join(",")}]`;
|
|
@@ -8700,7 +9643,6 @@ var encodeDagRecord = (record) => {
|
|
|
8700
9643
|
out += `,"streamId":${str2(record.streamId)}`;
|
|
8701
9644
|
out += `,"timestamp":${record.timestamp}`;
|
|
8702
9645
|
out += `,"tombstoned":${record.tombstoned ? "true" : "false"}`;
|
|
8703
|
-
out += `,"userId":${str2(record.userId)}`;
|
|
8704
9646
|
return out + "}";
|
|
8705
9647
|
};
|
|
8706
9648
|
var astToJson = (ast) => {
|
|
@@ -8723,6 +9665,20 @@ var astToJson = (ast) => {
|
|
|
8723
9665
|
}
|
|
8724
9666
|
};
|
|
8725
9667
|
var asString = (ast) => ast !== void 0 && ast.kind === "JString" ? ast.value : void 0;
|
|
9668
|
+
var decodeActor = (ast) => {
|
|
9669
|
+
if (ast === void 0 || ast.kind !== "JObject") return void 0;
|
|
9670
|
+
const kind = asString(field(ast.fields, "kind"));
|
|
9671
|
+
const id = asString(field(ast.fields, "id"));
|
|
9672
|
+
if (id === void 0) return void 0;
|
|
9673
|
+
if (kind === "human") return { kind: "human", id };
|
|
9674
|
+
if (kind === "agent") {
|
|
9675
|
+
const model = asString(field(ast.fields, "model"));
|
|
9676
|
+
const version = asString(field(ast.fields, "version"));
|
|
9677
|
+
if (model === void 0 || version === void 0) return void 0;
|
|
9678
|
+
return { kind: "agent", model, version, id };
|
|
9679
|
+
}
|
|
9680
|
+
return void 0;
|
|
9681
|
+
};
|
|
8726
9682
|
var decodeDagRecord = (json) => {
|
|
8727
9683
|
const parsed = parse(json);
|
|
8728
9684
|
if (!parsed.ok) return { ok: false, error: `dag envelope parse: ${parsed.error.message}` };
|
|
@@ -8731,12 +9687,19 @@ var decodeDagRecord = (json) => {
|
|
|
8731
9687
|
const f = root.fields;
|
|
8732
9688
|
const hash = asString(field(f, "hash"));
|
|
8733
9689
|
const streamId = asString(field(f, "streamId"));
|
|
8734
|
-
const
|
|
9690
|
+
const actorAst = field(f, "actor");
|
|
8735
9691
|
const opAst = field(f, "op");
|
|
8736
9692
|
const parentsAst = field(f, "parents");
|
|
8737
9693
|
const tsAst = field(f, "timestamp");
|
|
8738
|
-
if (
|
|
8739
|
-
return {
|
|
9694
|
+
if (actorAst === void 0 && field(f, "userId") !== void 0)
|
|
9695
|
+
return {
|
|
9696
|
+
ok: false,
|
|
9697
|
+
error: "dag envelope: pre-1144 record \u2014 'userId' was replaced by the typed 'actor', and DAG content addresses do not carry forward"
|
|
9698
|
+
};
|
|
9699
|
+
if (hash === void 0 || streamId === void 0)
|
|
9700
|
+
return { ok: false, error: "dag envelope: missing hash/streamId" };
|
|
9701
|
+
const actor = decodeActor(actorAst);
|
|
9702
|
+
if (actor === void 0) return { ok: false, error: "dag envelope: missing/malformed 'actor'" };
|
|
8740
9703
|
if (opAst === void 0) return { ok: false, error: "dag envelope: missing op" };
|
|
8741
9704
|
if (parentsAst === void 0 || parentsAst.kind !== "JArray")
|
|
8742
9705
|
return { ok: false, error: "dag envelope: missing/!array parents" };
|
|
@@ -8772,7 +9735,7 @@ var decodeDagRecord = (json) => {
|
|
|
8772
9735
|
op: opResult.value,
|
|
8773
9736
|
...outcomeHash !== void 0 ? { outcomeHash } : {},
|
|
8774
9737
|
...promptId !== void 0 ? { promptId } : {},
|
|
8775
|
-
|
|
9738
|
+
actor,
|
|
8776
9739
|
timestamp: tsAst.value,
|
|
8777
9740
|
resultEnvelope,
|
|
8778
9741
|
tombstoned: tombAst !== void 0 && tombAst.kind === "JBool" && tombAst.value
|
|
@@ -9765,7 +10728,61 @@ var validateAnswerDocument = (json) => {
|
|
|
9765
10728
|
if (!answer.ok) return answer;
|
|
9766
10729
|
return validateAnswerAt("$.answer", contract.value, answer.value);
|
|
9767
10730
|
};
|
|
10731
|
+
var HOST_RESERVED_PREFIX = "host.";
|
|
10732
|
+
var isHostReserved = (key) => typeof key === "string" && key.startsWith(HOST_RESERVED_PREFIX);
|
|
10733
|
+
var isPlainObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
10734
|
+
var isStateDeclaration = (v) => isPlainObject(v) && v["kind"] === "State" && typeof v["key"] === "string" && "defaultValue" in v && v["defaultValue"] !== void 0;
|
|
10735
|
+
var controlDefaults = Object.values(controlValueDefaults);
|
|
10736
|
+
var deepEqual = (a, b) => {
|
|
10737
|
+
try {
|
|
10738
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
10739
|
+
} catch {
|
|
10740
|
+
return false;
|
|
10741
|
+
}
|
|
10742
|
+
};
|
|
10743
|
+
var isAutoBoundFieldValue = (binding2, fieldId) => binding2.key === fieldId && controlDefaults.some((d) => deepEqual(d, binding2.defaultValue));
|
|
10744
|
+
var isEmptyDeclaration = (value) => {
|
|
10745
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
10746
|
+
if (isPlainObject(value)) {
|
|
10747
|
+
const columns = value["columns"];
|
|
10748
|
+
if (isPlainObject(columns)) return Object.keys(columns).length === 0;
|
|
10749
|
+
}
|
|
10750
|
+
return false;
|
|
10751
|
+
};
|
|
10752
|
+
var collectStateSeeds = (tree) => {
|
|
10753
|
+
const seeds = {};
|
|
10754
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10755
|
+
const visit = (value, autoBindFieldId) => {
|
|
10756
|
+
if (value === null || typeof value !== "object") return;
|
|
10757
|
+
if (seen.has(value)) return;
|
|
10758
|
+
seen.add(value);
|
|
10759
|
+
if (Array.isArray(value)) {
|
|
10760
|
+
for (const item of value) visit(item, autoBindFieldId);
|
|
10761
|
+
return;
|
|
10762
|
+
}
|
|
10763
|
+
const obj = value;
|
|
10764
|
+
if (isStateDeclaration(obj)) {
|
|
10765
|
+
const key = obj.key;
|
|
10766
|
+
const shouldSkip = isHostReserved(key) || Object.prototype.hasOwnProperty.call(seeds, key) || isEmptyDeclaration(obj.defaultValue) || autoBindFieldId !== void 0 && isAutoBoundFieldValue(obj, autoBindFieldId);
|
|
10767
|
+
if (!shouldSkip) seeds[key] = obj.defaultValue;
|
|
10768
|
+
}
|
|
10769
|
+
const record = obj;
|
|
10770
|
+
const ownId = record["id"];
|
|
10771
|
+
const fieldId = typeof ownId === "string" && typeof record["required"] === "boolean" ? ownId : void 0;
|
|
10772
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
10773
|
+
const established = k === "kind" && fieldId !== void 0 ? fieldId : void 0;
|
|
10774
|
+
visit(v, established ?? autoBindFieldId);
|
|
10775
|
+
}
|
|
10776
|
+
};
|
|
10777
|
+
visit(tree, void 0);
|
|
10778
|
+
return seeds;
|
|
10779
|
+
};
|
|
10780
|
+
var withStateSeeds = (tree, sources) => {
|
|
10781
|
+
const seeds = collectStateSeeds(tree);
|
|
10782
|
+
if (Object.keys(seeds).length === 0) return sources;
|
|
10783
|
+
return { ...sources, state: { ...seeds, ...sources.state ?? {} } };
|
|
10784
|
+
};
|
|
9768
10785
|
|
|
9769
|
-
export { ELICITATION_KEY, ELICITATION_VERSION, PAYLOAD_KEY, PROFILE_KEY, REQUIRED_PROFILE_KEY, apply, canPlace, cellString, coerce, coreV1, decodeDagRecord, decodeElicitation, decodeElicitationOutcome, decodeEnvelope, decodeEnvelopeAst, decodeNode, decodeNodeTolerant, decodeOp, decodeTolerant, derivedFreshIds, duplicateOp, duplicateOpWith, encodeCell, encodeColExpr, encodeDagRecord, encodeDataSource, encodeElicitation, encodeElicitationOutcome, encodeEnvelope2 as encodeEnvelope, encodeNode, encodeOp, encodePipeline, evalErrorString, evalPipeline, evalPipelineInEnv, evalPipelineWith, evalPipelineWithInEnv, evalSource, field as jsonField, liveValueToTable, merge3Way, moveOp, negotiate, negotiateEnvelope, noResolve, nudgeOp, parse, pasteOp, pasteOpWith, pipelineParams, placeOp, reencodeNode, renderAstCanonical, renderProfile, sequentialFreshIds, stepParams, tryParseProfile, validateAnswer, validateAnswerAt, validateAnswerDocument };
|
|
10786
|
+
export { ELICITATION_KEY, ELICITATION_VERSION, HOST_RESERVED_PREFIX, PAYLOAD_KEY, PROFILE_KEY, REQUIRED_PROFILE_KEY, apply, canPlace, cellString, coerce, collectStateSeeds, coreV1, decodeDagRecord, decodeElicitation, decodeElicitationOutcome, decodeEnvelope, decodeEnvelopeAst, decodeNode, decodeNodeTolerant, decodeOp, decodeTolerant, derivedFreshIds, duplicateOp, duplicateOpWith, encodeCell, encodeColExpr, encodeDagRecord, encodeDataSource, encodeElicitation, encodeElicitationOutcome, encodeEnvelope2 as encodeEnvelope, encodeNode, encodeOp, encodePipeline, evalErrorString, evalPipeline, evalPipelineInEnv, evalPipelineWith, evalPipelineWithInEnv, evalSource, field as jsonField, liveValueToTable, merge3Way, moveOp, negotiate, negotiateEnvelope, noResolve, nudgeOp, parse, pasteOp, pasteOpWith, pipelineParams, placeOp, reencodeNode, renderAstCanonical, renderProfile, sequentialFreshIds, stepParams, substituteListParams, tryParseProfile, validateAnswer, validateAnswerAt, validateAnswerDocument, withStateSeeds };
|
|
9770
10787
|
//# sourceMappingURL=index.js.map
|
|
9771
10788
|
//# sourceMappingURL=index.js.map
|