@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/dist/extensions.d.cts
CHANGED
|
@@ -9,10 +9,8 @@ interface HostSpec {
|
|
|
9
9
|
readonly kinds: readonly string[];
|
|
10
10
|
/** The node kinds a `reference` may point at. */
|
|
11
11
|
readonly references: readonly string[];
|
|
12
|
-
/** The node kinds with host fields of their own, which a claim may present. */
|
|
13
|
-
readonly claimable: readonly string[];
|
|
14
12
|
}
|
|
15
|
-
/** Each host's node kinds
|
|
13
|
+
/** Each host's node kinds and references. */
|
|
16
14
|
declare const HOSTS: Readonly<Record<HostName, HostSpec>>;
|
|
17
15
|
/** The family's seven scalar types, spelled as the family spells them. */
|
|
18
16
|
declare const SCALAR_TYPES: readonly ["text", "multiline", "number", "boolean", "enum", "flags", "quality"];
|
|
@@ -83,25 +81,9 @@ interface FieldDecl extends TypeDecl {
|
|
|
83
81
|
/** Stripped at compile: editor data, never in a bundle. A target's own fields only. */
|
|
84
82
|
readonly editorOnly?: boolean;
|
|
85
83
|
}
|
|
86
|
-
/** A claim on a host field, named through one of the manifest's settings. */
|
|
87
|
-
interface ClaimDecl extends TypeDecl {
|
|
88
|
-
readonly setting: string;
|
|
89
|
-
readonly label?: string;
|
|
90
|
-
readonly help?: string;
|
|
91
|
-
readonly required?: boolean;
|
|
92
|
-
}
|
|
93
84
|
/** What an extension declares for one node kind of one host. */
|
|
94
85
|
interface TargetDecl {
|
|
95
86
|
readonly fields?: readonly FieldDecl[];
|
|
96
|
-
readonly claims?: readonly ClaimDecl[];
|
|
97
|
-
}
|
|
98
|
-
/** A project setting, naming a host field a claim presents. */
|
|
99
|
-
interface SettingDecl {
|
|
100
|
-
readonly name: string;
|
|
101
|
-
readonly label?: string;
|
|
102
|
-
readonly help?: string;
|
|
103
|
-
/** The field name used when the project names none. */
|
|
104
|
-
readonly default: string;
|
|
105
87
|
}
|
|
106
88
|
interface Manifest {
|
|
107
89
|
readonly schema: string;
|
|
@@ -109,7 +91,6 @@ interface Manifest {
|
|
|
109
91
|
readonly name: string;
|
|
110
92
|
readonly version: string;
|
|
111
93
|
readonly docs?: string;
|
|
112
|
-
readonly settings?: readonly SettingDecl[];
|
|
113
94
|
readonly targets: Readonly<Partial<Record<HostName, Readonly<Record<string, TargetDecl>>>>>;
|
|
114
95
|
/** Views the extension's installed package supplies (tier 2), each a web component a host opens in a window. */
|
|
115
96
|
readonly views?: readonly ViewDecl[];
|
|
@@ -167,35 +148,8 @@ declare function isViewEntry(entry: unknown): entry is string;
|
|
|
167
148
|
/** The views a host offers from a manifest: those naming the host, or every view when it names none and the
|
|
168
149
|
* manifest targets the host. A view that fails its checks is left out. */
|
|
169
150
|
declare function viewsFor(manifest: Manifest, host: HostName): ViewDecl[];
|
|
170
|
-
/** The host field each of a manifest's settings names, the project's choice
|
|
171
|
-
* first, else the setting's default. */
|
|
172
|
-
declare function settingValues(manifest: Manifest, chosen?: Readonly<Record<string, unknown>>): Record<string, string>;
|
|
173
|
-
/** A claim as a project resolves it: the host field it presents, by name. */
|
|
174
|
-
interface ResolvedClaim {
|
|
175
|
-
readonly extension: string;
|
|
176
|
-
readonly host: HostName;
|
|
177
|
-
readonly kind: string;
|
|
178
|
-
/** The host field's name, through the setting. */
|
|
179
|
-
readonly field: string;
|
|
180
|
-
readonly claim: ClaimDecl;
|
|
181
|
-
}
|
|
182
|
-
/** Every claim of a manifest for one host, resolved through the project's settings. */
|
|
183
|
-
declare function resolvedClaims(manifest: Manifest, host: HostName, chosen?: Readonly<Record<string, unknown>>): ResolvedClaim[];
|
|
184
|
-
/** Two extensions claiming one host field: an error naming both, once per pair. */
|
|
185
|
-
declare function claimClashes(claims: readonly ResolvedClaim[]): Problem[];
|
|
186
151
|
/** One manifest's declarations for one host and node kind, or undefined. */
|
|
187
152
|
declare function targetOf(manifest: Manifest | undefined, host: HostName, kind: string): TargetDecl | undefined;
|
|
188
|
-
/**
|
|
189
|
-
* A claim as a host draws and checks its field: the claim's label, help, value help and constraints, over the
|
|
190
|
-
* host's own declaration for what the claim leaves out (an enum's or flags' values, a quality's stages, the
|
|
191
|
-
* default). The host's vocabulary stands when the claim names none, as the host's ladder always does.
|
|
192
|
-
*/
|
|
193
|
-
declare function effectiveClaim<C extends ClaimDecl>(claim: C, hostDecl: {
|
|
194
|
-
readonly type?: string;
|
|
195
|
-
readonly values?: readonly string[];
|
|
196
|
-
readonly stages?: readonly string[];
|
|
197
|
-
readonly default?: unknown;
|
|
198
|
-
}): C;
|
|
199
153
|
|
|
200
154
|
/** What the host knows about its nodes, for references, and about the extension's project lists, for picks. */
|
|
201
155
|
interface ValueContext {
|
|
@@ -418,4 +372,4 @@ declare const atKey: (base: string, key: string) => string;
|
|
|
418
372
|
/** `base` and then list position `i`. */
|
|
419
373
|
declare const atIndex: (base: string, i: number) => string;
|
|
420
374
|
|
|
421
|
-
export { ATOMIC, COMMENTS, type
|
|
375
|
+
export { ATOMIC, COMMENTS, type Conflict, type ConflictKind, type DataMergeResult, type ExtensionData, type FieldDecl, HOSTS, type HostName, type HostSpec, type JsonValue, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, type Manifest, type MergeWarning, type PickChoice, type PickSource, type PickSources, type Problem, SCALAR_TYPES, SET, type ScalarType, type StageRename, type Strategy, type TargetDecl, type TreeMergeOptions, type TreeMergeResult, type TypeDecl, UNRESOLVED_KEY, type UnresolvedEntry, VALUE_TYPES, type ValueContext, type ValueType, type ViewDecl, atIndex, atKey, compileEntry, compiledTarget, defaultOf, entryProblems, extensionDataStrategy, isTextList, isViewEntry, keyedBy, manifestProblems, mapOf, markUnresolved, mergeComments, mergeExtensionData, mergeTree, objectOf, orphanedEntries, parseManifest, pickChoices, pickClashes, pickLists, renameStages, stableStringify, strategyForTarget, strategyForType, targetOf, unresolvedOf, unresolvedProblems, valueProblems, viewsFor, withoutMark };
|
package/dist/extensions.d.ts
CHANGED
|
@@ -9,10 +9,8 @@ interface HostSpec {
|
|
|
9
9
|
readonly kinds: readonly string[];
|
|
10
10
|
/** The node kinds a `reference` may point at. */
|
|
11
11
|
readonly references: readonly string[];
|
|
12
|
-
/** The node kinds with host fields of their own, which a claim may present. */
|
|
13
|
-
readonly claimable: readonly string[];
|
|
14
12
|
}
|
|
15
|
-
/** Each host's node kinds
|
|
13
|
+
/** Each host's node kinds and references. */
|
|
16
14
|
declare const HOSTS: Readonly<Record<HostName, HostSpec>>;
|
|
17
15
|
/** The family's seven scalar types, spelled as the family spells them. */
|
|
18
16
|
declare const SCALAR_TYPES: readonly ["text", "multiline", "number", "boolean", "enum", "flags", "quality"];
|
|
@@ -83,25 +81,9 @@ interface FieldDecl extends TypeDecl {
|
|
|
83
81
|
/** Stripped at compile: editor data, never in a bundle. A target's own fields only. */
|
|
84
82
|
readonly editorOnly?: boolean;
|
|
85
83
|
}
|
|
86
|
-
/** A claim on a host field, named through one of the manifest's settings. */
|
|
87
|
-
interface ClaimDecl extends TypeDecl {
|
|
88
|
-
readonly setting: string;
|
|
89
|
-
readonly label?: string;
|
|
90
|
-
readonly help?: string;
|
|
91
|
-
readonly required?: boolean;
|
|
92
|
-
}
|
|
93
84
|
/** What an extension declares for one node kind of one host. */
|
|
94
85
|
interface TargetDecl {
|
|
95
86
|
readonly fields?: readonly FieldDecl[];
|
|
96
|
-
readonly claims?: readonly ClaimDecl[];
|
|
97
|
-
}
|
|
98
|
-
/** A project setting, naming a host field a claim presents. */
|
|
99
|
-
interface SettingDecl {
|
|
100
|
-
readonly name: string;
|
|
101
|
-
readonly label?: string;
|
|
102
|
-
readonly help?: string;
|
|
103
|
-
/** The field name used when the project names none. */
|
|
104
|
-
readonly default: string;
|
|
105
87
|
}
|
|
106
88
|
interface Manifest {
|
|
107
89
|
readonly schema: string;
|
|
@@ -109,7 +91,6 @@ interface Manifest {
|
|
|
109
91
|
readonly name: string;
|
|
110
92
|
readonly version: string;
|
|
111
93
|
readonly docs?: string;
|
|
112
|
-
readonly settings?: readonly SettingDecl[];
|
|
113
94
|
readonly targets: Readonly<Partial<Record<HostName, Readonly<Record<string, TargetDecl>>>>>;
|
|
114
95
|
/** Views the extension's installed package supplies (tier 2), each a web component a host opens in a window. */
|
|
115
96
|
readonly views?: readonly ViewDecl[];
|
|
@@ -167,35 +148,8 @@ declare function isViewEntry(entry: unknown): entry is string;
|
|
|
167
148
|
/** The views a host offers from a manifest: those naming the host, or every view when it names none and the
|
|
168
149
|
* manifest targets the host. A view that fails its checks is left out. */
|
|
169
150
|
declare function viewsFor(manifest: Manifest, host: HostName): ViewDecl[];
|
|
170
|
-
/** The host field each of a manifest's settings names, the project's choice
|
|
171
|
-
* first, else the setting's default. */
|
|
172
|
-
declare function settingValues(manifest: Manifest, chosen?: Readonly<Record<string, unknown>>): Record<string, string>;
|
|
173
|
-
/** A claim as a project resolves it: the host field it presents, by name. */
|
|
174
|
-
interface ResolvedClaim {
|
|
175
|
-
readonly extension: string;
|
|
176
|
-
readonly host: HostName;
|
|
177
|
-
readonly kind: string;
|
|
178
|
-
/** The host field's name, through the setting. */
|
|
179
|
-
readonly field: string;
|
|
180
|
-
readonly claim: ClaimDecl;
|
|
181
|
-
}
|
|
182
|
-
/** Every claim of a manifest for one host, resolved through the project's settings. */
|
|
183
|
-
declare function resolvedClaims(manifest: Manifest, host: HostName, chosen?: Readonly<Record<string, unknown>>): ResolvedClaim[];
|
|
184
|
-
/** Two extensions claiming one host field: an error naming both, once per pair. */
|
|
185
|
-
declare function claimClashes(claims: readonly ResolvedClaim[]): Problem[];
|
|
186
151
|
/** One manifest's declarations for one host and node kind, or undefined. */
|
|
187
152
|
declare function targetOf(manifest: Manifest | undefined, host: HostName, kind: string): TargetDecl | undefined;
|
|
188
|
-
/**
|
|
189
|
-
* A claim as a host draws and checks its field: the claim's label, help, value help and constraints, over the
|
|
190
|
-
* host's own declaration for what the claim leaves out (an enum's or flags' values, a quality's stages, the
|
|
191
|
-
* default). The host's vocabulary stands when the claim names none, as the host's ladder always does.
|
|
192
|
-
*/
|
|
193
|
-
declare function effectiveClaim<C extends ClaimDecl>(claim: C, hostDecl: {
|
|
194
|
-
readonly type?: string;
|
|
195
|
-
readonly values?: readonly string[];
|
|
196
|
-
readonly stages?: readonly string[];
|
|
197
|
-
readonly default?: unknown;
|
|
198
|
-
}): C;
|
|
199
153
|
|
|
200
154
|
/** What the host knows about its nodes, for references, and about the extension's project lists, for picks. */
|
|
201
155
|
interface ValueContext {
|
|
@@ -418,4 +372,4 @@ declare const atKey: (base: string, key: string) => string;
|
|
|
418
372
|
/** `base` and then list position `i`. */
|
|
419
373
|
declare const atIndex: (base: string, i: number) => string;
|
|
420
374
|
|
|
421
|
-
export { ATOMIC, COMMENTS, type
|
|
375
|
+
export { ATOMIC, COMMENTS, type Conflict, type ConflictKind, type DataMergeResult, type ExtensionData, type FieldDecl, HOSTS, type HostName, type HostSpec, type JsonValue, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, type Manifest, type MergeWarning, type PickChoice, type PickSource, type PickSources, type Problem, SCALAR_TYPES, SET, type ScalarType, type StageRename, type Strategy, type TargetDecl, type TreeMergeOptions, type TreeMergeResult, type TypeDecl, UNRESOLVED_KEY, type UnresolvedEntry, VALUE_TYPES, type ValueContext, type ValueType, type ViewDecl, atIndex, atKey, compileEntry, compiledTarget, defaultOf, entryProblems, extensionDataStrategy, isTextList, isViewEntry, keyedBy, manifestProblems, mapOf, markUnresolved, mergeComments, mergeExtensionData, mergeTree, objectOf, orphanedEntries, parseManifest, pickChoices, pickClashes, pickLists, renameStages, stableStringify, strategyForTarget, strategyForType, targetOf, unresolvedOf, unresolvedProblems, valueProblems, viewsFor, withoutMark };
|
package/dist/extensions.js
CHANGED
|
@@ -8,13 +8,11 @@ var MANIFEST_FILE_SUFFIX = ".extension.json";
|
|
|
8
8
|
var HOSTS = {
|
|
9
9
|
patter: {
|
|
10
10
|
kinds: ["scene", "block", "snippet", "line", "text", "gameEvent", "option", "project"],
|
|
11
|
-
references: ["cast", "scene", "block", "snippet", "line"]
|
|
12
|
-
claimable: ["scene", "block", "snippet", "line", "text", "gameEvent", "option"]
|
|
11
|
+
references: ["cast", "scene", "block", "snippet", "line"]
|
|
13
12
|
},
|
|
14
13
|
storylets: {
|
|
15
14
|
kinds: ["box", "tagGroup", "tag", "deck", "card", "outcome", "handTemplate", "hand", "project"],
|
|
16
|
-
references: ["box", "deck", "card", "outcome", "tag"]
|
|
17
|
-
claimable: ["card", "outcome"]
|
|
15
|
+
references: ["box", "deck", "card", "outcome", "tag"]
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
18
|
var SCALAR_TYPES = ["text", "multiline", "number", "boolean", "enum", "flags", "quality"];
|
|
@@ -358,9 +356,14 @@ var VERSION = /^\d+\.\d+\.\d+$/;
|
|
|
358
356
|
var NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
359
357
|
var TYPE_KEYS = ["type", "values", "stages", "renamedStages", "to", "from", "fields", "key", "of", "id", "min", "max", "valueHelp", "default"];
|
|
360
358
|
var FIELD_KEYS = /* @__PURE__ */ new Set([...TYPE_KEYS, "name", "label", "help", "required", "group", "editorOnly"]);
|
|
361
|
-
var CLAIM_KEYS = /* @__PURE__ */ new Set([...TYPE_KEYS, "setting", "label", "help", "required"]);
|
|
362
359
|
var BARE_KEYS = new Set(TYPE_KEYS);
|
|
363
|
-
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["schema", "id", "name", "version", "docs", "
|
|
360
|
+
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["schema", "id", "name", "version", "docs", "targets", "views", "reads"]);
|
|
361
|
+
var REMOVED_MANIFEST_KEYS = {
|
|
362
|
+
settings: "settings were removed with claims; declare the extension's own fields, or a project field for a project-wide value"
|
|
363
|
+
};
|
|
364
|
+
var REMOVED_TARGET_KEYS = {
|
|
365
|
+
claims: "claims on host fields were removed; declare a field of the extension's own, which the runtimes hand the game"
|
|
366
|
+
};
|
|
364
367
|
var VIEW_KEYS = /* @__PURE__ */ new Set(["id", "name", "entry", "element", "hosts"]);
|
|
365
368
|
var ELEMENT = /^[a-z][a-z0-9._]*-[a-z0-9._-]*$/;
|
|
366
369
|
var err2 = (code, path, message) => ({ severity: "error", code, path, message });
|
|
@@ -371,7 +374,7 @@ function manifestProblems(manifest) {
|
|
|
371
374
|
const out = [];
|
|
372
375
|
if (!isObject(manifest)) return [err2("not-an-object", "", "a manifest is a JSON object")];
|
|
373
376
|
const m = manifest;
|
|
374
|
-
unknownKeys(m, MANIFEST_KEYS, "", out);
|
|
377
|
+
unknownKeys(m, MANIFEST_KEYS, "", out, REMOVED_MANIFEST_KEYS);
|
|
375
378
|
if (m["schema"] !== MANIFEST_SCHEMA) {
|
|
376
379
|
out.push(err2("schema", "schema", `the schema tag is ${JSON.stringify(m["schema"])}, not "${MANIFEST_SCHEMA}"`));
|
|
377
380
|
}
|
|
@@ -383,7 +386,6 @@ function manifestProblems(manifest) {
|
|
|
383
386
|
out.push(err2("version", "version", "the version is major.minor.patch, such as 1.0.0"));
|
|
384
387
|
}
|
|
385
388
|
if (m["docs"] !== void 0 && typeof m["docs"] !== "string") out.push(err2("docs", "docs", "docs is a link, as text"));
|
|
386
|
-
const settings = settingsProblems(m["settings"], out);
|
|
387
389
|
viewsProblems(m["views"], m["targets"], out);
|
|
388
390
|
readsProblems(m["reads"], m["id"], out);
|
|
389
391
|
const targets = m["targets"];
|
|
@@ -408,7 +410,7 @@ function manifestProblems(manifest) {
|
|
|
408
410
|
out.push(err2("unknown-kind", kindPath, `"${kind}" is not a node kind of ${host}; it has ${spec.kinds.join(", ")}`));
|
|
409
411
|
continue;
|
|
410
412
|
}
|
|
411
|
-
targetProblems(host,
|
|
413
|
+
targetProblems(host, target, kindPath, out);
|
|
412
414
|
}
|
|
413
415
|
pickListProblems(kinds, hostPath, out);
|
|
414
416
|
}
|
|
@@ -554,81 +556,23 @@ function viewsFor(manifest, host) {
|
|
|
554
556
|
const targeted = Object.keys(manifest.targets ?? {});
|
|
555
557
|
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)));
|
|
556
558
|
}
|
|
557
|
-
function unknownKeys(obj, known, path, out) {
|
|
559
|
+
function unknownKeys(obj, known, path, out, removed = {}) {
|
|
558
560
|
for (const k of Object.keys(obj)) {
|
|
559
|
-
if (
|
|
561
|
+
if (own(removed, k)) {
|
|
562
|
+
out.push({ severity: "warning", code: "removed-key", path: atKey(path, k), message: `"${k}" is ignored: ${removed[k]}` });
|
|
563
|
+
} else if (!known.has(k)) {
|
|
560
564
|
out.push({ severity: "warning", code: "unknown-key", path: atKey(path, k), message: `"${k}" means nothing here; it is ignored` });
|
|
561
565
|
}
|
|
562
566
|
}
|
|
563
567
|
}
|
|
564
|
-
function
|
|
565
|
-
const names = /* @__PURE__ */ new Set();
|
|
566
|
-
if (settings === void 0) return names;
|
|
567
|
-
if (!Array.isArray(settings)) {
|
|
568
|
-
out.push(err2("not-a-list", "settings", "settings are a list"));
|
|
569
|
-
return names;
|
|
570
|
-
}
|
|
571
|
-
settings.forEach((s, i) => {
|
|
572
|
-
const at = atIndex("settings", i);
|
|
573
|
-
if (!isObject(s)) {
|
|
574
|
-
out.push(err2("not-an-object", at, "a setting is an object"));
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
const name = s["name"];
|
|
578
|
-
if (typeof name !== "string" || !NAME.test(name)) {
|
|
579
|
-
out.push(err2("setting-name", atKey(at, "name"), "a setting's name is an identifier"));
|
|
580
|
-
} else if (names.has(name)) {
|
|
581
|
-
out.push(err2("setting-duplicate", atKey(at, "name"), `setting "${name}" is declared twice`));
|
|
582
|
-
} else {
|
|
583
|
-
names.add(name);
|
|
584
|
-
}
|
|
585
|
-
const dflt = s.default;
|
|
586
|
-
if (typeof dflt !== "string" || !NAME.test(dflt)) {
|
|
587
|
-
out.push(err2("setting-default", atKey(at, "default"), "a setting names a host field by default, so its default is a field name"));
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
return names;
|
|
591
|
-
}
|
|
592
|
-
function targetProblems(host, kind, target, path, settings, out) {
|
|
568
|
+
function targetProblems(host, target, path, out) {
|
|
593
569
|
if (!isObject(target)) {
|
|
594
570
|
out.push(err2("not-an-object", path, "a target is an object"));
|
|
595
571
|
return;
|
|
596
572
|
}
|
|
597
|
-
unknownKeys(target, /* @__PURE__ */ new Set(["fields"
|
|
573
|
+
unknownKeys(target, /* @__PURE__ */ new Set(["fields"]), path, out, REMOVED_TARGET_KEYS);
|
|
598
574
|
const t = target;
|
|
599
575
|
if (t.fields !== void 0) fieldListProblems(host, t.fields, atKey(path, "fields"), true, out);
|
|
600
|
-
if (t.claims === void 0) return;
|
|
601
|
-
if (!Array.isArray(t.claims)) {
|
|
602
|
-
out.push(err2("not-a-list", atKey(path, "claims"), "claims are a list"));
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
const claimable = HOSTS[host].claimable.includes(kind);
|
|
606
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
607
|
-
t.claims.forEach((c, i) => {
|
|
608
|
-
const at = atIndex(atKey(path, "claims"), i);
|
|
609
|
-
if (!claimable) {
|
|
610
|
-
out.push(err2("claim-kind", at, `a ${kind} has no host fields to claim; ${host} has them on ${HOSTS[host].claimable.join(", ")}`));
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
if (!isObject(c)) {
|
|
614
|
-
out.push(err2("not-an-object", at, "a claim is an object"));
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
const claim = c;
|
|
618
|
-
unknownKeys(c, CLAIM_KEYS, at, out);
|
|
619
|
-
if (!SCALAR_TYPES.includes(claim.type)) {
|
|
620
|
-
out.push(err2("claim-type", atKey(at, "type"), "a claim presents a host field, which is a scalar"));
|
|
621
|
-
} else {
|
|
622
|
-
typeProblems(host, claim, at, false, out, true);
|
|
623
|
-
}
|
|
624
|
-
if (typeof claim.setting !== "string" || !settings.has(claim.setting)) {
|
|
625
|
-
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`));
|
|
626
|
-
} else if (claimed.has(claim.setting)) {
|
|
627
|
-
out.push(err2("claim-duplicate", atKey(at, "setting"), `setting "${claim.setting}" is claimed twice for one kind`));
|
|
628
|
-
} else {
|
|
629
|
-
claimed.add(claim.setting);
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
576
|
}
|
|
633
577
|
function fieldListProblems(host, fields, path, topLevel, out) {
|
|
634
578
|
if (!Array.isArray(fields)) {
|
|
@@ -662,7 +606,7 @@ function fieldListProblems(host, fields, path, topLevel, out) {
|
|
|
662
606
|
}
|
|
663
607
|
});
|
|
664
608
|
}
|
|
665
|
-
function typeProblems(host, decl, path, named, out
|
|
609
|
+
function typeProblems(host, decl, path, named, out) {
|
|
666
610
|
const typeAt = atKey(path, "type");
|
|
667
611
|
if (decl.type === "string") {
|
|
668
612
|
out.push(err2("string-type", typeAt, 'the text type is spelled "text"'));
|
|
@@ -678,7 +622,6 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
678
622
|
case "enum":
|
|
679
623
|
case "flags": {
|
|
680
624
|
const values = decl.values;
|
|
681
|
-
if (claim && values === void 0) break;
|
|
682
625
|
if (!Array.isArray(values) || values.length === 0) {
|
|
683
626
|
out.push(err2("values-empty", at("values"), `an ${decl.type === "enum" ? "enum" : "flags field"} lists its values`));
|
|
684
627
|
sound = false;
|
|
@@ -697,7 +640,6 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
697
640
|
break;
|
|
698
641
|
}
|
|
699
642
|
case "quality": {
|
|
700
|
-
if (claim && decl.stages === void 0) break;
|
|
701
643
|
for (const p of qualityDeclarationProblems(decl.stages)) {
|
|
702
644
|
out.push(err2(
|
|
703
645
|
`quality-${p.kind === "default-not-a-stage" ? "default" : p.kind}`,
|
|
@@ -760,11 +702,7 @@ function typeProblems(host, decl, path, named, out, claim = false) {
|
|
|
760
702
|
}
|
|
761
703
|
}
|
|
762
704
|
if (decl.renamedStages !== void 0) renamedStagesProblems(decl, at("renamedStages"), out);
|
|
763
|
-
if (decl.valueHelp !== void 0
|
|
764
|
-
if (!isObject(decl.valueHelp) || !["enum", "flags", "quality"].includes(decl.type)) {
|
|
765
|
-
out.push(err2("value-help", at("valueHelp"), "value help describes the values of an enum or flags field, or a quality's stages"));
|
|
766
|
-
}
|
|
767
|
-
} else if (decl.valueHelp !== void 0) {
|
|
705
|
+
if (decl.valueHelp !== void 0) {
|
|
768
706
|
const vocabulary = decl.type === "quality" ? decl.stages : decl.type === "enum" || decl.type === "flags" ? decl.values : decl.type === "pick" ? pickWords(decl.from) : void 0;
|
|
769
707
|
if (vocabulary === void 0 || !isObject(decl.valueHelp)) {
|
|
770
708
|
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"));
|
|
@@ -805,56 +743,10 @@ function renamedStagesProblems(decl, path, out) {
|
|
|
805
743
|
}
|
|
806
744
|
}
|
|
807
745
|
}
|
|
808
|
-
function settingValues(manifest, chosen) {
|
|
809
|
-
const out = {};
|
|
810
|
-
for (const s of manifest.settings ?? []) {
|
|
811
|
-
const v = chosen !== void 0 && own(chosen, s.name) ? chosen[s.name] : void 0;
|
|
812
|
-
out[s.name] = typeof v === "string" && v !== "" ? v : s.default;
|
|
813
|
-
}
|
|
814
|
-
return out;
|
|
815
|
-
}
|
|
816
|
-
function resolvedClaims(manifest, host, chosen) {
|
|
817
|
-
const settings = settingValues(manifest, chosen);
|
|
818
|
-
const out = [];
|
|
819
|
-
for (const [kind, target] of Object.entries(manifest.targets[host] ?? {})) {
|
|
820
|
-
for (const claim of target.claims ?? []) {
|
|
821
|
-
const field = settings[claim.setting];
|
|
822
|
-
if (field !== void 0) out.push({ extension: manifest.id, host, kind, field, claim });
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
return out;
|
|
826
|
-
}
|
|
827
|
-
function claimClashes(claims) {
|
|
828
|
-
const out = [];
|
|
829
|
-
const first = /* @__PURE__ */ new Map();
|
|
830
|
-
for (const c of claims) {
|
|
831
|
-
const key = `${c.host}\0${c.kind}\0${c.field}`;
|
|
832
|
-
const prior = first.get(key);
|
|
833
|
-
if (prior === void 0) {
|
|
834
|
-
first.set(key, c);
|
|
835
|
-
continue;
|
|
836
|
-
}
|
|
837
|
-
if (prior.extension === c.extension) continue;
|
|
838
|
-
out.push(err2(
|
|
839
|
-
"claim-clash",
|
|
840
|
-
`${c.kind}.${c.field}`,
|
|
841
|
-
`extensions "${prior.extension}" and "${c.extension}" both claim the ${c.kind} field "${c.field}"`
|
|
842
|
-
));
|
|
843
|
-
}
|
|
844
|
-
return out;
|
|
845
|
-
}
|
|
846
746
|
function targetOf(manifest, host, kind) {
|
|
847
747
|
const kinds = manifest?.targets[host];
|
|
848
748
|
return kinds !== void 0 && own(kinds, kind) ? kinds[kind] : void 0;
|
|
849
749
|
}
|
|
850
|
-
function effectiveClaim(claim, hostDecl) {
|
|
851
|
-
return {
|
|
852
|
-
...claim,
|
|
853
|
-
...claim.values === void 0 && hostDecl.values !== void 0 ? { values: hostDecl.values } : {},
|
|
854
|
-
...claim.stages === void 0 && hostDecl.stages !== void 0 ? { stages: hostDecl.stages } : {},
|
|
855
|
-
...claim.default === void 0 && hostDecl.default !== void 0 ? { default: hostDecl.default } : {}
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
750
|
|
|
859
751
|
// src/extensions/merge.ts
|
|
860
752
|
var ATOMIC = { kind: "atomic" };
|
|
@@ -1193,6 +1085,6 @@ function orphanedEntries(data, exists) {
|
|
|
1193
1085
|
return out;
|
|
1194
1086
|
}
|
|
1195
1087
|
|
|
1196
|
-
export { ATOMIC, COMMENTS, HOSTS, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, SCALAR_TYPES, SET, UNRESOLVED_KEY, VALUE_TYPES, atIndex, atKey,
|
|
1088
|
+
export { ATOMIC, COMMENTS, HOSTS, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, SCALAR_TYPES, SET, UNRESOLVED_KEY, VALUE_TYPES, atIndex, atKey, compileEntry, compiledTarget, defaultOf, entryProblems, extensionDataStrategy, isTextList, isViewEntry, keyedBy, manifestProblems, mapOf, markUnresolved, mergeComments, mergeExtensionData, mergeTree, objectOf, orphanedEntries, parseManifest, pickChoices, pickClashes, pickLists, renameStages, stableStringify, strategyForTarget, strategyForType, targetOf, unresolvedOf, unresolvedProblems, valueProblems, viewsFor, withoutMark };
|
|
1197
1089
|
//# sourceMappingURL=extensions.js.map
|
|
1198
1090
|
//# sourceMappingURL=extensions.js.map
|