@wildwinter/toolkit 0.2.7 → 0.3.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/CHANGELOG.md +9 -0
- package/conformance/extensions/defaults.json +1 -1
- package/conformance/extensions/manifest.json +46 -172
- package/conformance/extensions/values.json +0 -86
- package/dist/extensions.cjs +19 -131
- package/dist/extensions.cjs.map +1 -1
- package/dist/extensions.d.cts +2 -48
- package/dist/extensions.d.ts +2 -48
- package/dist/extensions.js +20 -128
- package/dist/extensions.js.map +1 -1
- package/extensions.md +11 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @wildwinter/toolkit
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Removed
|
|
6
|
+
|
|
7
|
+
- **Claims and settings** (`./extensions`): a manifest's `settings` and a target's `claims`, and with them
|
|
8
|
+
`ClaimDecl`, `SettingDecl`, `HostSpec.claimable`, `settingValues`, `resolvedClaims`, `claimClashes`, and
|
|
9
|
+
`effectiveClaim`. An extension's data is always its own; a project-wide value is a field on the `project` target.
|
|
10
|
+
A manifest that still has `settings` or `claims` is warned of by name (`removed-key`), and the key is ignored.
|
|
11
|
+
|
|
3
12
|
## 0.2.7
|
|
4
13
|
|
|
5
14
|
### Added
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
{ "name": "tone", "type": "enum", "values": ["calm", "tense"], "valueHelp": { "calm": "x" } },
|
|
29
29
|
{ "name": "act", "type": "quality", "stages": ["setup", "turn"], "renamedStages": { "opening": "setup" } },
|
|
30
30
|
{ "name": "cue", "type": "record", "fields": [{ "name": "gain", "type": "number", "min": 0, "help": "Loudness." }] }
|
|
31
|
-
]
|
|
31
|
+
] },
|
|
32
32
|
"compiled": [
|
|
33
33
|
{ "name": "note", "type": "text", "default": "", "required": true },
|
|
34
34
|
{ "name": "tone", "type": "enum", "values": ["calm", "tense"], "default": "calm" },
|
|
@@ -24,20 +24,13 @@
|
|
|
24
24
|
"problems": []
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
"name": "every type
|
|
27
|
+
"name": "every type passes together",
|
|
28
28
|
"manifest": {
|
|
29
29
|
"schema": "wildwinter/extension@0",
|
|
30
30
|
"id": "probe",
|
|
31
31
|
"name": "Probe",
|
|
32
32
|
"version": "2.1.0",
|
|
33
33
|
"docs": "https://example.com/probe",
|
|
34
|
-
"settings": [
|
|
35
|
-
{
|
|
36
|
-
"name": "moodField",
|
|
37
|
-
"label": "Mood field",
|
|
38
|
-
"default": "mood"
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
34
|
"targets": {
|
|
42
35
|
"storylets": {
|
|
43
36
|
"card": {
|
|
@@ -170,17 +163,6 @@
|
|
|
170
163
|
"type": "text"
|
|
171
164
|
}
|
|
172
165
|
}
|
|
173
|
-
],
|
|
174
|
-
"claims": [
|
|
175
|
-
{
|
|
176
|
-
"setting": "moodField",
|
|
177
|
-
"type": "enum",
|
|
178
|
-
"values": [
|
|
179
|
-
"calm",
|
|
180
|
-
"tense"
|
|
181
|
-
],
|
|
182
|
-
"help": "The card's mood."
|
|
183
|
-
}
|
|
184
166
|
]
|
|
185
167
|
},
|
|
186
168
|
"project": {
|
|
@@ -1013,159 +995,6 @@
|
|
|
1013
995
|
}
|
|
1014
996
|
]
|
|
1015
997
|
},
|
|
1016
|
-
{
|
|
1017
|
-
"name": "claims: a claimable kind, a declared setting, a scalar, once per setting",
|
|
1018
|
-
"manifest": {
|
|
1019
|
-
"schema": "wildwinter/extension@0",
|
|
1020
|
-
"id": "probe",
|
|
1021
|
-
"name": "Probe",
|
|
1022
|
-
"version": "1.0.0",
|
|
1023
|
-
"settings": [
|
|
1024
|
-
{
|
|
1025
|
-
"name": "moodField",
|
|
1026
|
-
"default": "mood"
|
|
1027
|
-
}
|
|
1028
|
-
],
|
|
1029
|
-
"targets": {
|
|
1030
|
-
"storylets": {
|
|
1031
|
-
"deck": {
|
|
1032
|
-
"claims": [
|
|
1033
|
-
{
|
|
1034
|
-
"setting": "moodField",
|
|
1035
|
-
"type": "text"
|
|
1036
|
-
}
|
|
1037
|
-
]
|
|
1038
|
-
},
|
|
1039
|
-
"card": {
|
|
1040
|
-
"claims": [
|
|
1041
|
-
{
|
|
1042
|
-
"setting": "moodField",
|
|
1043
|
-
"type": "text"
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
"setting": "moodField",
|
|
1047
|
-
"type": "text"
|
|
1048
|
-
},
|
|
1049
|
-
{
|
|
1050
|
-
"setting": "nope",
|
|
1051
|
-
"type": "text"
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
"setting": "moodField",
|
|
1055
|
-
"type": "record",
|
|
1056
|
-
"fields": [
|
|
1057
|
-
{
|
|
1058
|
-
"name": "a",
|
|
1059
|
-
"type": "text"
|
|
1060
|
-
}
|
|
1061
|
-
]
|
|
1062
|
-
}
|
|
1063
|
-
]
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
},
|
|
1068
|
-
"problems": [
|
|
1069
|
-
{
|
|
1070
|
-
"path": "targets.storylets.deck.claims[0]",
|
|
1071
|
-
"code": "claim-kind"
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
"path": "targets.storylets.card.claims[1].setting",
|
|
1075
|
-
"code": "claim-duplicate"
|
|
1076
|
-
},
|
|
1077
|
-
{
|
|
1078
|
-
"path": "targets.storylets.card.claims[2].setting",
|
|
1079
|
-
"code": "claim-setting"
|
|
1080
|
-
},
|
|
1081
|
-
{
|
|
1082
|
-
"path": "targets.storylets.card.claims[3].type",
|
|
1083
|
-
"code": "claim-type"
|
|
1084
|
-
},
|
|
1085
|
-
{
|
|
1086
|
-
"path": "targets.storylets.card.claims[3].setting",
|
|
1087
|
-
"code": "claim-duplicate"
|
|
1088
|
-
}
|
|
1089
|
-
]
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
"name": "settings: named once each, defaulting to a field name",
|
|
1093
|
-
"manifest": {
|
|
1094
|
-
"schema": "wildwinter/extension@0",
|
|
1095
|
-
"id": "probe",
|
|
1096
|
-
"name": "Probe",
|
|
1097
|
-
"version": "1.0.0",
|
|
1098
|
-
"settings": [
|
|
1099
|
-
{
|
|
1100
|
-
"name": "a",
|
|
1101
|
-
"default": "x"
|
|
1102
|
-
},
|
|
1103
|
-
{
|
|
1104
|
-
"name": "a",
|
|
1105
|
-
"default": "y"
|
|
1106
|
-
},
|
|
1107
|
-
{
|
|
1108
|
-
"name": "b"
|
|
1109
|
-
},
|
|
1110
|
-
{
|
|
1111
|
-
"name": "c",
|
|
1112
|
-
"default": "not a name"
|
|
1113
|
-
}
|
|
1114
|
-
],
|
|
1115
|
-
"targets": {
|
|
1116
|
-
"storylets": {
|
|
1117
|
-
"card": {}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
},
|
|
1121
|
-
"problems": [
|
|
1122
|
-
{
|
|
1123
|
-
"path": "settings[1].name",
|
|
1124
|
-
"code": "setting-duplicate"
|
|
1125
|
-
},
|
|
1126
|
-
{
|
|
1127
|
-
"path": "settings[2].default",
|
|
1128
|
-
"code": "setting-default"
|
|
1129
|
-
},
|
|
1130
|
-
{
|
|
1131
|
-
"path": "settings[3].default",
|
|
1132
|
-
"code": "setting-default"
|
|
1133
|
-
}
|
|
1134
|
-
]
|
|
1135
|
-
},
|
|
1136
|
-
{
|
|
1137
|
-
"name": "an enum claim may leave out its values, and its value help may describe values the host does not declare",
|
|
1138
|
-
"manifest": {
|
|
1139
|
-
"schema": "wildwinter/extension@0",
|
|
1140
|
-
"id": "probe",
|
|
1141
|
-
"name": "Probe",
|
|
1142
|
-
"version": "1.0.0",
|
|
1143
|
-
"settings": [
|
|
1144
|
-
{
|
|
1145
|
-
"name": "moodField",
|
|
1146
|
-
"default": "mood"
|
|
1147
|
-
}
|
|
1148
|
-
],
|
|
1149
|
-
"targets": {
|
|
1150
|
-
"storylets": {
|
|
1151
|
-
"card": {
|
|
1152
|
-
"claims": [
|
|
1153
|
-
{
|
|
1154
|
-
"setting": "moodField",
|
|
1155
|
-
"type": "enum",
|
|
1156
|
-
"label": "Mood",
|
|
1157
|
-
"valueHelp": {
|
|
1158
|
-
"calm": "Unhurried.",
|
|
1159
|
-
"wild": "Not one the host has."
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
]
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
},
|
|
1167
|
-
"problems": []
|
|
1168
|
-
},
|
|
1169
998
|
{
|
|
1170
999
|
"name": "an enum field of the extension's own still lists its values",
|
|
1171
1000
|
"manifest": {
|
|
@@ -1745,6 +1574,51 @@
|
|
|
1745
1574
|
"code": "not-a-list"
|
|
1746
1575
|
}
|
|
1747
1576
|
]
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
"name": "settings and claims were removed: each warned of by name, and ignored",
|
|
1580
|
+
"manifest": {
|
|
1581
|
+
"schema": "wildwinter/extension@0",
|
|
1582
|
+
"id": "probe",
|
|
1583
|
+
"name": "Probe",
|
|
1584
|
+
"version": "1.0.0",
|
|
1585
|
+
"settings": [
|
|
1586
|
+
{
|
|
1587
|
+
"name": "moodField",
|
|
1588
|
+
"default": "mood"
|
|
1589
|
+
}
|
|
1590
|
+
],
|
|
1591
|
+
"targets": {
|
|
1592
|
+
"storylets": {
|
|
1593
|
+
"card": {
|
|
1594
|
+
"fields": [
|
|
1595
|
+
{
|
|
1596
|
+
"name": "tone",
|
|
1597
|
+
"type": "text"
|
|
1598
|
+
}
|
|
1599
|
+
],
|
|
1600
|
+
"claims": [
|
|
1601
|
+
{
|
|
1602
|
+
"setting": "moodField",
|
|
1603
|
+
"type": "enum"
|
|
1604
|
+
}
|
|
1605
|
+
]
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
},
|
|
1610
|
+
"problems": [
|
|
1611
|
+
{
|
|
1612
|
+
"path": "settings",
|
|
1613
|
+
"code": "removed-key",
|
|
1614
|
+
"severity": "warning"
|
|
1615
|
+
},
|
|
1616
|
+
{
|
|
1617
|
+
"path": "targets.storylets.card.claims",
|
|
1618
|
+
"code": "removed-key",
|
|
1619
|
+
"severity": "warning"
|
|
1620
|
+
}
|
|
1621
|
+
]
|
|
1748
1622
|
}
|
|
1749
1623
|
]
|
|
1750
1624
|
}
|
|
@@ -937,92 +937,6 @@
|
|
|
937
937
|
]
|
|
938
938
|
}
|
|
939
939
|
],
|
|
940
|
-
"claims": [
|
|
941
|
-
{
|
|
942
|
-
"name": "a claim without values takes the host's, and keeps its own label, help and value help",
|
|
943
|
-
"claim": {
|
|
944
|
-
"setting": "moodField",
|
|
945
|
-
"type": "enum",
|
|
946
|
-
"label": "Mood",
|
|
947
|
-
"help": "How it feels.",
|
|
948
|
-
"valueHelp": {
|
|
949
|
-
"calm": "Unhurried.",
|
|
950
|
-
"wild": "Unused."
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
"host": {
|
|
954
|
-
"type": "enum",
|
|
955
|
-
"values": [
|
|
956
|
-
"calm",
|
|
957
|
-
"tense"
|
|
958
|
-
],
|
|
959
|
-
"default": "calm"
|
|
960
|
-
},
|
|
961
|
-
"effective": {
|
|
962
|
-
"setting": "moodField",
|
|
963
|
-
"type": "enum",
|
|
964
|
-
"label": "Mood",
|
|
965
|
-
"help": "How it feels.",
|
|
966
|
-
"valueHelp": {
|
|
967
|
-
"calm": "Unhurried.",
|
|
968
|
-
"wild": "Unused."
|
|
969
|
-
},
|
|
970
|
-
"values": [
|
|
971
|
-
"calm",
|
|
972
|
-
"tense"
|
|
973
|
-
],
|
|
974
|
-
"default": "calm"
|
|
975
|
-
}
|
|
976
|
-
},
|
|
977
|
-
{
|
|
978
|
-
"name": "a claim's own values stand",
|
|
979
|
-
"claim": {
|
|
980
|
-
"setting": "moodField",
|
|
981
|
-
"type": "enum",
|
|
982
|
-
"values": [
|
|
983
|
-
"calm"
|
|
984
|
-
]
|
|
985
|
-
},
|
|
986
|
-
"host": {
|
|
987
|
-
"type": "enum",
|
|
988
|
-
"values": [
|
|
989
|
-
"calm",
|
|
990
|
-
"tense"
|
|
991
|
-
]
|
|
992
|
-
},
|
|
993
|
-
"effective": {
|
|
994
|
-
"setting": "moodField",
|
|
995
|
-
"type": "enum",
|
|
996
|
-
"values": [
|
|
997
|
-
"calm"
|
|
998
|
-
]
|
|
999
|
-
}
|
|
1000
|
-
},
|
|
1001
|
-
{
|
|
1002
|
-
"name": "a quality claim takes the host's ladder, as a claimed field keeps the host's",
|
|
1003
|
-
"claim": {
|
|
1004
|
-
"setting": "actField",
|
|
1005
|
-
"type": "quality",
|
|
1006
|
-
"label": "Act"
|
|
1007
|
-
},
|
|
1008
|
-
"host": {
|
|
1009
|
-
"type": "quality",
|
|
1010
|
-
"stages": [
|
|
1011
|
-
"setup",
|
|
1012
|
-
"turn"
|
|
1013
|
-
]
|
|
1014
|
-
},
|
|
1015
|
-
"effective": {
|
|
1016
|
-
"setting": "actField",
|
|
1017
|
-
"type": "quality",
|
|
1018
|
-
"label": "Act",
|
|
1019
|
-
"stages": [
|
|
1020
|
-
"setup",
|
|
1021
|
-
"turn"
|
|
1022
|
-
]
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
],
|
|
1026
940
|
"picks": [
|
|
1027
941
|
{
|
|
1028
942
|
"name": "choices in source order, each source's in its own",
|
package/dist/extensions.cjs
CHANGED
|
@@ -14,13 +14,11 @@ var MANIFEST_FILE_SUFFIX = ".extension.json";
|
|
|
14
14
|
var HOSTS = {
|
|
15
15
|
patter: {
|
|
16
16
|
kinds: ["scene", "block", "snippet", "line", "text", "gameEvent", "option", "project"],
|
|
17
|
-
references: ["cast", "scene", "block", "snippet", "line"]
|
|
18
|
-
claimable: ["scene", "block", "snippet", "line", "text", "gameEvent", "option"]
|
|
17
|
+
references: ["cast", "scene", "block", "snippet", "line"]
|
|
19
18
|
},
|
|
20
19
|
storylets: {
|
|
21
20
|
kinds: ["box", "tagGroup", "tag", "deck", "card", "outcome", "handTemplate", "hand", "project"],
|
|
22
|
-
references: ["box", "deck", "card", "outcome", "tag"]
|
|
23
|
-
claimable: ["card", "outcome"]
|
|
21
|
+
references: ["box", "deck", "card", "outcome", "tag"]
|
|
24
22
|
}
|
|
25
23
|
};
|
|
26
24
|
var SCALAR_TYPES = ["text", "multiline", "number", "boolean", "enum", "flags", "quality"];
|
|
@@ -368,9 +366,14 @@ var VERSION = /^\d+\.\d+\.\d+$/;
|
|
|
368
366
|
var NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
369
367
|
var TYPE_KEYS = ["type", "values", "stages", "renamedStages", "to", "from", "fields", "key", "of", "id", "min", "max", "valueHelp", "default"];
|
|
370
368
|
var FIELD_KEYS = /* @__PURE__ */ new Set([...TYPE_KEYS, "name", "label", "help", "required", "group", "editorOnly"]);
|
|
371
|
-
var CLAIM_KEYS = /* @__PURE__ */ new Set([...TYPE_KEYS, "setting", "label", "help", "required"]);
|
|
372
369
|
var BARE_KEYS = new Set(TYPE_KEYS);
|
|
373
|
-
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["schema", "id", "name", "version", "docs", "
|
|
370
|
+
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["schema", "id", "name", "version", "docs", "targets", "views", "reads"]);
|
|
371
|
+
var REMOVED_MANIFEST_KEYS = {
|
|
372
|
+
settings: "settings were removed with claims; declare the extension's own fields, or a project field for a project-wide value"
|
|
373
|
+
};
|
|
374
|
+
var REMOVED_TARGET_KEYS = {
|
|
375
|
+
claims: "claims on host fields were removed; declare a field of the extension's own, which the runtimes hand the game"
|
|
376
|
+
};
|
|
374
377
|
var VIEW_KEYS = /* @__PURE__ */ new Set(["id", "name", "entry", "element", "hosts"]);
|
|
375
378
|
var ELEMENT = /^[a-z][a-z0-9._]*-[a-z0-9._-]*$/;
|
|
376
379
|
var err2 = (code, path, message) => ({ severity: "error", code, path, message });
|
|
@@ -381,7 +384,7 @@ function manifestProblems(manifest) {
|
|
|
381
384
|
const out = [];
|
|
382
385
|
if (!isObject(manifest)) return [err2("not-an-object", "", "a manifest is a JSON object")];
|
|
383
386
|
const m = manifest;
|
|
384
|
-
unknownKeys(m, MANIFEST_KEYS, "", out);
|
|
387
|
+
unknownKeys(m, MANIFEST_KEYS, "", out, REMOVED_MANIFEST_KEYS);
|
|
385
388
|
if (m["schema"] !== MANIFEST_SCHEMA) {
|
|
386
389
|
out.push(err2("schema", "schema", `the schema tag is ${JSON.stringify(m["schema"])}, not "${MANIFEST_SCHEMA}"`));
|
|
387
390
|
}
|
|
@@ -393,7 +396,6 @@ function manifestProblems(manifest) {
|
|
|
393
396
|
out.push(err2("version", "version", "the version is major.minor.patch, such as 1.0.0"));
|
|
394
397
|
}
|
|
395
398
|
if (m["docs"] !== void 0 && typeof m["docs"] !== "string") out.push(err2("docs", "docs", "docs is a link, as text"));
|
|
396
|
-
const settings = settingsProblems(m["settings"], out);
|
|
397
399
|
viewsProblems(m["views"], m["targets"], out);
|
|
398
400
|
readsProblems(m["reads"], m["id"], out);
|
|
399
401
|
const targets = m["targets"];
|
|
@@ -418,7 +420,7 @@ function manifestProblems(manifest) {
|
|
|
418
420
|
out.push(err2("unknown-kind", kindPath, `"${kind}" is not a node kind of ${host}; it has ${spec.kinds.join(", ")}`));
|
|
419
421
|
continue;
|
|
420
422
|
}
|
|
421
|
-
targetProblems(host,
|
|
423
|
+
targetProblems(host, target, kindPath, out);
|
|
422
424
|
}
|
|
423
425
|
pickListProblems(kinds, hostPath, out);
|
|
424
426
|
}
|
|
@@ -564,81 +566,23 @@ function viewsFor(manifest, host) {
|
|
|
564
566
|
const targeted = Object.keys(manifest.targets ?? {});
|
|
565
567
|
return (Array.isArray(manifest.views) ? manifest.views : []).filter((v) => isObject(v) && typeof v.id === "string" && ID.test(v.id) && typeof v.name === "string" && isViewEntry(v.entry) && typeof v.element === "string" && ELEMENT.test(v.element) && (v.hosts === void 0 ? targeted.includes(host) : Array.isArray(v.hosts) && v.hosts.includes(host)));
|
|
566
568
|
}
|
|
567
|
-
function unknownKeys(obj, known, path, out) {
|
|
569
|
+
function unknownKeys(obj, known, path, out, removed = {}) {
|
|
568
570
|
for (const k of Object.keys(obj)) {
|
|
569
|
-
if (
|
|
571
|
+
if (own(removed, k)) {
|
|
572
|
+
out.push({ severity: "warning", code: "removed-key", path: atKey(path, k), message: `"${k}" is ignored: ${removed[k]}` });
|
|
573
|
+
} else if (!known.has(k)) {
|
|
570
574
|
out.push({ severity: "warning", code: "unknown-key", path: atKey(path, k), message: `"${k}" means nothing here; it is ignored` });
|
|
571
575
|
}
|
|
572
576
|
}
|
|
573
577
|
}
|
|
574
|
-
function
|
|
575
|
-
const names = /* @__PURE__ */ new Set();
|
|
576
|
-
if (settings === void 0) return names;
|
|
577
|
-
if (!Array.isArray(settings)) {
|
|
578
|
-
out.push(err2("not-a-list", "settings", "settings are a list"));
|
|
579
|
-
return names;
|
|
580
|
-
}
|
|
581
|
-
settings.forEach((s, i) => {
|
|
582
|
-
const at = atIndex("settings", i);
|
|
583
|
-
if (!isObject(s)) {
|
|
584
|
-
out.push(err2("not-an-object", at, "a setting is an object"));
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
const name = s["name"];
|
|
588
|
-
if (typeof name !== "string" || !NAME.test(name)) {
|
|
589
|
-
out.push(err2("setting-name", atKey(at, "name"), "a setting's name is an identifier"));
|
|
590
|
-
} else if (names.has(name)) {
|
|
591
|
-
out.push(err2("setting-duplicate", atKey(at, "name"), `setting "${name}" is declared twice`));
|
|
592
|
-
} else {
|
|
593
|
-
names.add(name);
|
|
594
|
-
}
|
|
595
|
-
const dflt = s.default;
|
|
596
|
-
if (typeof dflt !== "string" || !NAME.test(dflt)) {
|
|
597
|
-
out.push(err2("setting-default", atKey(at, "default"), "a setting names a host field by default, so its default is a field name"));
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
return names;
|
|
601
|
-
}
|
|
602
|
-
function targetProblems(host, kind, target, path, settings, out) {
|
|
578
|
+
function targetProblems(host, target, path, out) {
|
|
603
579
|
if (!isObject(target)) {
|
|
604
580
|
out.push(err2("not-an-object", path, "a target is an object"));
|
|
605
581
|
return;
|
|
606
582
|
}
|
|
607
|
-
unknownKeys(target, /* @__PURE__ */ new Set(["fields"
|
|
583
|
+
unknownKeys(target, /* @__PURE__ */ new Set(["fields"]), path, out, REMOVED_TARGET_KEYS);
|
|
608
584
|
const t = target;
|
|
609
585
|
if (t.fields !== void 0) fieldListProblems(host, t.fields, atKey(path, "fields"), true, out);
|
|
610
|
-
if (t.claims === void 0) return;
|
|
611
|
-
if (!Array.isArray(t.claims)) {
|
|
612
|
-
out.push(err2("not-a-list", atKey(path, "claims"), "claims are a list"));
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const claimable = HOSTS[host].claimable.includes(kind);
|
|
616
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
617
|
-
t.claims.forEach((c, i) => {
|
|
618
|
-
const at = atIndex(atKey(path, "claims"), i);
|
|
619
|
-
if (!claimable) {
|
|
620
|
-
out.push(err2("claim-kind", at, `a ${kind} has no host fields to claim; ${host} has them on ${HOSTS[host].claimable.join(", ")}`));
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
if (!isObject(c)) {
|
|
624
|
-
out.push(err2("not-an-object", at, "a claim is an object"));
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
const claim = c;
|
|
628
|
-
unknownKeys(c, CLAIM_KEYS, at, out);
|
|
629
|
-
if (!SCALAR_TYPES.includes(claim.type)) {
|
|
630
|
-
out.push(err2("claim-type", atKey(at, "type"), "a claim presents a host field, which is a scalar"));
|
|
631
|
-
} else {
|
|
632
|
-
typeProblems(host, claim, at, false, out, true);
|
|
633
|
-
}
|
|
634
|
-
if (typeof claim.setting !== "string" || !settings.has(claim.setting)) {
|
|
635
|
-
out.push(err2("claim-setting", atKey(at, "setting"), `a claim names its field through a setting, and "${String(claim.setting)}" is not one of the manifest's settings`));
|
|
636
|
-
} else if (claimed.has(claim.setting)) {
|
|
637
|
-
out.push(err2("claim-duplicate", atKey(at, "setting"), `setting "${claim.setting}" is claimed twice for one kind`));
|
|
638
|
-
} else {
|
|
639
|
-
claimed.add(claim.setting);
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
586
|
}
|
|
643
587
|
function fieldListProblems(host, fields, path, topLevel, out) {
|
|
644
588
|
if (!Array.isArray(fields)) {
|
|
@@ -672,7 +616,7 @@ function fieldListProblems(host, fields, path, topLevel, out) {
|
|
|
672
616
|
}
|
|
673
617
|
});
|
|
674
618
|
}
|
|
675
|
-
function typeProblems(host, decl, path, named, out
|
|
619
|
+
function typeProblems(host, decl, path, named, out) {
|
|
676
620
|
const typeAt = atKey(path, "type");
|
|
677
621
|
if (decl.type === "string") {
|
|
678
622
|
out.push(err2("string-type", typeAt, 'the text type is spelled "text"'));
|
|
@@ -688,7 +632,6 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
688
632
|
case "enum":
|
|
689
633
|
case "flags": {
|
|
690
634
|
const values = decl.values;
|
|
691
|
-
if (claim && values === void 0) break;
|
|
692
635
|
if (!Array.isArray(values) || values.length === 0) {
|
|
693
636
|
out.push(err2("values-empty", at("values"), `an ${decl.type === "enum" ? "enum" : "flags field"} lists its values`));
|
|
694
637
|
sound = false;
|
|
@@ -707,7 +650,6 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
707
650
|
break;
|
|
708
651
|
}
|
|
709
652
|
case "quality": {
|
|
710
|
-
if (claim && decl.stages === void 0) break;
|
|
711
653
|
for (const p of expr.qualityDeclarationProblems(decl.stages)) {
|
|
712
654
|
out.push(err2(
|
|
713
655
|
`quality-${p.kind === "default-not-a-stage" ? "default" : p.kind}`,
|
|
@@ -770,11 +712,7 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
770
712
|
}
|
|
771
713
|
}
|
|
772
714
|
if (decl.renamedStages !== void 0) renamedStagesProblems(decl, at("renamedStages"), out);
|
|
773
|
-
if (decl.valueHelp !== void 0
|
|
774
|
-
if (!isObject(decl.valueHelp) || !["enum", "flags", "quality"].includes(decl.type)) {
|
|
775
|
-
out.push(err2("value-help", at("valueHelp"), "value help describes the values of an enum or flags field, or a quality's stages"));
|
|
776
|
-
}
|
|
777
|
-
} else if (decl.valueHelp !== void 0) {
|
|
715
|
+
if (decl.valueHelp !== void 0) {
|
|
778
716
|
const vocabulary = decl.type === "quality" ? decl.stages : decl.type === "enum" || decl.type === "flags" ? decl.values : decl.type === "pick" ? pickWords(decl.from) : void 0;
|
|
779
717
|
if (vocabulary === void 0 || !isObject(decl.valueHelp)) {
|
|
780
718
|
out.push(err2("value-help", at("valueHelp"), "value help describes the values of an enum or flags field, a quality's stages, or a pick's words"));
|
|
@@ -815,56 +753,10 @@ function renamedStagesProblems(decl, path, out) {
|
|
|
815
753
|
}
|
|
816
754
|
}
|
|
817
755
|
}
|
|
818
|
-
function settingValues(manifest, chosen) {
|
|
819
|
-
const out = {};
|
|
820
|
-
for (const s of manifest.settings ?? []) {
|
|
821
|
-
const v = chosen !== void 0 && own(chosen, s.name) ? chosen[s.name] : void 0;
|
|
822
|
-
out[s.name] = typeof v === "string" && v !== "" ? v : s.default;
|
|
823
|
-
}
|
|
824
|
-
return out;
|
|
825
|
-
}
|
|
826
|
-
function resolvedClaims(manifest, host, chosen) {
|
|
827
|
-
const settings = settingValues(manifest, chosen);
|
|
828
|
-
const out = [];
|
|
829
|
-
for (const [kind, target] of Object.entries(manifest.targets[host] ?? {})) {
|
|
830
|
-
for (const claim of target.claims ?? []) {
|
|
831
|
-
const field = settings[claim.setting];
|
|
832
|
-
if (field !== void 0) out.push({ extension: manifest.id, host, kind, field, claim });
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return out;
|
|
836
|
-
}
|
|
837
|
-
function claimClashes(claims) {
|
|
838
|
-
const out = [];
|
|
839
|
-
const first = /* @__PURE__ */ new Map();
|
|
840
|
-
for (const c of claims) {
|
|
841
|
-
const key = `${c.host}\0${c.kind}\0${c.field}`;
|
|
842
|
-
const prior = first.get(key);
|
|
843
|
-
if (prior === void 0) {
|
|
844
|
-
first.set(key, c);
|
|
845
|
-
continue;
|
|
846
|
-
}
|
|
847
|
-
if (prior.extension === c.extension) continue;
|
|
848
|
-
out.push(err2(
|
|
849
|
-
"claim-clash",
|
|
850
|
-
`${c.kind}.${c.field}`,
|
|
851
|
-
`extensions "${prior.extension}" and "${c.extension}" both claim the ${c.kind} field "${c.field}"`
|
|
852
|
-
));
|
|
853
|
-
}
|
|
854
|
-
return out;
|
|
855
|
-
}
|
|
856
756
|
function targetOf(manifest, host, kind) {
|
|
857
757
|
const kinds = manifest?.targets[host];
|
|
858
758
|
return kinds !== void 0 && own(kinds, kind) ? kinds[kind] : void 0;
|
|
859
759
|
}
|
|
860
|
-
function effectiveClaim(claim, hostDecl) {
|
|
861
|
-
return {
|
|
862
|
-
...claim,
|
|
863
|
-
...claim.values === void 0 && hostDecl.values !== void 0 ? { values: hostDecl.values } : {},
|
|
864
|
-
...claim.stages === void 0 && hostDecl.stages !== void 0 ? { stages: hostDecl.stages } : {},
|
|
865
|
-
...claim.default === void 0 && hostDecl.default !== void 0 ? { default: hostDecl.default } : {}
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
760
|
|
|
869
761
|
// src/extensions/merge.ts
|
|
870
762
|
var ATOMIC = { kind: "atomic" };
|
|
@@ -1214,11 +1106,9 @@ exports.UNRESOLVED_KEY = UNRESOLVED_KEY;
|
|
|
1214
1106
|
exports.VALUE_TYPES = VALUE_TYPES;
|
|
1215
1107
|
exports.atIndex = atIndex;
|
|
1216
1108
|
exports.atKey = atKey;
|
|
1217
|
-
exports.claimClashes = claimClashes;
|
|
1218
1109
|
exports.compileEntry = compileEntry;
|
|
1219
1110
|
exports.compiledTarget = compiledTarget;
|
|
1220
1111
|
exports.defaultOf = defaultOf;
|
|
1221
|
-
exports.effectiveClaim = effectiveClaim;
|
|
1222
1112
|
exports.entryProblems = entryProblems;
|
|
1223
1113
|
exports.extensionDataStrategy = extensionDataStrategy;
|
|
1224
1114
|
exports.isTextList = isTextList;
|
|
@@ -1237,8 +1127,6 @@ exports.pickChoices = pickChoices;
|
|
|
1237
1127
|
exports.pickClashes = pickClashes;
|
|
1238
1128
|
exports.pickLists = pickLists;
|
|
1239
1129
|
exports.renameStages = renameStages;
|
|
1240
|
-
exports.resolvedClaims = resolvedClaims;
|
|
1241
|
-
exports.settingValues = settingValues;
|
|
1242
1130
|
exports.stableStringify = stableStringify;
|
|
1243
1131
|
exports.strategyForTarget = strategyForTarget;
|
|
1244
1132
|
exports.strategyForType = strategyForType;
|