@seriousgaming/sdk-tools 1.1.0 → 1.2.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/cli.js +200 -14
- package/dist/client.js +199 -13
- package/dist/dev/brands.d.ts +20 -3
- package/dist/dev/console/assets/{index-qxHcu9fJ.js → index-BNLEVOQA.js} +9 -9
- package/dist/dev/console/index.html +1 -1
- package/dist/docs/api/index.md +1 -1
- package/dist/docs/api/sdk-ui-testing.md +1 -1
- package/dist/docs/api/sdk-ui.md +21 -2
- package/dist/docs/changelog.md +25 -0
- package/dist/docs/guides/guide.md +35 -4
- package/dist/docs/guides/production-constraints.md +1 -1
- package/dist/docs/guides/session.md +3 -1
- package/dist/docs/guides/theming-and-branding.md +18 -4
- package/dist/docs/guides/upgrading.md +8 -0
- package/dist/docs/recipes/create-guide.md +2 -2
- package/dist/docs/recipes/make-a-guide-follow-the-scenario.md +9 -9
- package/dist/guide/settings.d.ts +7 -0
- package/dist/guide/video-registry.d.ts +33 -1
- package/dist/host/index.d.ts +4 -2
- package/dist/host.js +131 -0
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/templates/package/CLAUDE.md.template +1 -1
- package/dist/templates/package/claude/rules/workflow-create-guide.md +8 -2
- package/dist/validation/facilitator-guide-validator.d.ts +5 -1
- package/dist/validation/schema-validation.d.ts +12 -4
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -3395,7 +3395,7 @@ function gameOverrideRefusal(overrides) {
|
|
|
3395
3395
|
|
|
3396
3396
|
// cli/runtime/manifest-version.ts
|
|
3397
3397
|
var MANIFEST_VERSION = 3;
|
|
3398
|
-
var SPEC_REVISION = "1.
|
|
3398
|
+
var SPEC_REVISION = "1.2";
|
|
3399
3399
|
var SUPPORTED_FEATURES = [
|
|
3400
3400
|
// A validator's `Scenario` gate (§15.8).
|
|
3401
3401
|
"scenario-validation"
|
|
@@ -4545,7 +4545,7 @@ function validateSettingsOverrides(overrides, schemas, sourceLabel) {
|
|
|
4545
4545
|
${errors.join("\n")}` } : { valid: true };
|
|
4546
4546
|
}
|
|
4547
4547
|
function validatePartialOverride(override2, settingsSchema) {
|
|
4548
|
-
const validator = settingsAjv.compile(withoutRequired(settingsSchema));
|
|
4548
|
+
const validator = settingsAjv.compile(closed(withoutRequired(settingsSchema)));
|
|
4549
4549
|
return validator(override2) ? null : validator.errors ?? [];
|
|
4550
4550
|
}
|
|
4551
4551
|
var SCHEMA_MAP_KEYWORDS = ["properties", "patternProperties", "definitions", "$defs"];
|
|
@@ -4573,6 +4573,53 @@ function withoutRequired(schema2) {
|
|
|
4573
4573
|
}
|
|
4574
4574
|
return copy;
|
|
4575
4575
|
}
|
|
4576
|
+
var COMBINATOR_KEYWORDS = ["allOf", "anyOf", "oneOf", "if", "not", "$ref"];
|
|
4577
|
+
function closed(schema2) {
|
|
4578
|
+
if (typeof schema2 !== "object" || schema2 === null) return schema2;
|
|
4579
|
+
const copy = { ...schema2 };
|
|
4580
|
+
for (const keyword of SCHEMA_MAP_KEYWORDS) {
|
|
4581
|
+
const map3 = schema2[keyword];
|
|
4582
|
+
if (map3 && typeof map3 === "object") {
|
|
4583
|
+
copy[keyword] = Object.fromEntries(
|
|
4584
|
+
Object.entries(map3).map(([key, value]) => [key, closed(value)])
|
|
4585
|
+
);
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
if (typeof schema2.additionalProperties === "object") {
|
|
4589
|
+
copy.additionalProperties = closed(schema2.additionalProperties);
|
|
4590
|
+
}
|
|
4591
|
+
if (Array.isArray(schema2.items)) copy.items = schema2.items.map(closed);
|
|
4592
|
+
else if (schema2.items !== void 0) copy.items = closed(schema2.items);
|
|
4593
|
+
if (isPlainOpen(schema2)) copy.additionalProperties = false;
|
|
4594
|
+
return copy;
|
|
4595
|
+
}
|
|
4596
|
+
function isPlainOpen(schema2) {
|
|
4597
|
+
return schema2.properties !== void 0 && schema2.additionalProperties === void 0 && schema2.patternProperties === void 0 && !COMBINATOR_KEYWORDS.some((keyword) => keyword in schema2);
|
|
4598
|
+
}
|
|
4599
|
+
function openSettingsObjects(schema2, at = "") {
|
|
4600
|
+
if (typeof schema2 !== "object" || schema2 === null) return [];
|
|
4601
|
+
const found = isPlainOpen(schema2) ? [at] : [];
|
|
4602
|
+
for (const keyword of SCHEMA_MAP_KEYWORDS) {
|
|
4603
|
+
const map3 = schema2[keyword];
|
|
4604
|
+
if (!map3 || typeof map3 !== "object") continue;
|
|
4605
|
+
for (const [key, value] of Object.entries(map3)) {
|
|
4606
|
+
found.push(...openSettingsObjects(value, `${at}/${keyword}/${key}`));
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
if (typeof schema2.additionalProperties === "object") {
|
|
4610
|
+
found.push(
|
|
4611
|
+
...openSettingsObjects(schema2.additionalProperties, `${at}/additionalProperties`)
|
|
4612
|
+
);
|
|
4613
|
+
}
|
|
4614
|
+
if (Array.isArray(schema2.items)) {
|
|
4615
|
+
schema2.items.forEach(
|
|
4616
|
+
(item, index3) => found.push(...openSettingsObjects(item, `${at}/items/${index3}`))
|
|
4617
|
+
);
|
|
4618
|
+
} else if (schema2.items !== void 0) {
|
|
4619
|
+
found.push(...openSettingsObjects(schema2.items, `${at}/items`));
|
|
4620
|
+
}
|
|
4621
|
+
return found;
|
|
4622
|
+
}
|
|
4576
4623
|
|
|
4577
4624
|
// cli/discovery/manifest-paths.ts
|
|
4578
4625
|
import { posix } from "path";
|
|
@@ -8184,7 +8231,42 @@ var VIDEO_PROVIDERS = {
|
|
|
8184
8231
|
embedHosts: ["www.youtube-nocookie.com"]
|
|
8185
8232
|
}
|
|
8186
8233
|
};
|
|
8187
|
-
var
|
|
8234
|
+
var FILE_VIDEO_PROVIDER = "file";
|
|
8235
|
+
var FILE_VIDEO_EXTENSIONS = {
|
|
8236
|
+
src: ["mp4", "webm"],
|
|
8237
|
+
poster: ["png", "jpg", "jpeg", "gif", "webp", "avif"],
|
|
8238
|
+
captions: ["vtt"]
|
|
8239
|
+
};
|
|
8240
|
+
var ALLOWED_KEYS = {
|
|
8241
|
+
youtube: /* @__PURE__ */ new Set(["provider", "id"]),
|
|
8242
|
+
[FILE_VIDEO_PROVIDER]: /* @__PURE__ */ new Set(["provider", "src", "title", "poster", "captions"])
|
|
8243
|
+
};
|
|
8244
|
+
var SUPPORTED_PROVIDERS = [...Object.keys(VIDEO_PROVIDERS), FILE_VIDEO_PROVIDER];
|
|
8245
|
+
var CHAPTER_BASE = "https://guide.invalid/content/locale/chapter.md";
|
|
8246
|
+
function guideAssetPath(reference) {
|
|
8247
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(reference) || reference.startsWith("/")) return void 0;
|
|
8248
|
+
if (reference.includes("\\") || /[?#]/.test(reference)) return void 0;
|
|
8249
|
+
let resolved;
|
|
8250
|
+
try {
|
|
8251
|
+
resolved = new URL(reference, CHAPTER_BASE);
|
|
8252
|
+
} catch {
|
|
8253
|
+
return void 0;
|
|
8254
|
+
}
|
|
8255
|
+
if (resolved.origin !== "https://guide.invalid" || !resolved.pathname.startsWith("/assets/")) {
|
|
8256
|
+
return void 0;
|
|
8257
|
+
}
|
|
8258
|
+
try {
|
|
8259
|
+
const path3 = decodeURIComponent(resolved.pathname.slice("/assets/".length));
|
|
8260
|
+
const segments = path3.split("/");
|
|
8261
|
+
return segments.some((s) => s === "" || s === "." || s === ".." || s.includes("\\")) ? void 0 : path3;
|
|
8262
|
+
} catch {
|
|
8263
|
+
return void 0;
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
function extensionOf(path3) {
|
|
8267
|
+
const dot = path3.lastIndexOf(".");
|
|
8268
|
+
return dot === -1 ? "" : path3.slice(dot + 1).toLowerCase();
|
|
8269
|
+
}
|
|
8188
8270
|
function parseVideoBlock(body) {
|
|
8189
8271
|
const entries = {};
|
|
8190
8272
|
for (const rawLine of body.split("\n")) {
|
|
@@ -8196,9 +8278,6 @@ function parseVideoBlock(body) {
|
|
|
8196
8278
|
}
|
|
8197
8279
|
const key = match2[1];
|
|
8198
8280
|
const value = match2[2].trim();
|
|
8199
|
-
if (!ALLOWED_KEYS.has(key)) {
|
|
8200
|
-
return { ok: false, error: `Unknown key "${key}" in video block` };
|
|
8201
|
-
}
|
|
8202
8281
|
if (key in entries) {
|
|
8203
8282
|
return { ok: false, error: `Duplicate key "${key}" in video block` };
|
|
8204
8283
|
}
|
|
@@ -8208,13 +8287,20 @@ function parseVideoBlock(body) {
|
|
|
8208
8287
|
if (!provider) {
|
|
8209
8288
|
return { ok: false, error: 'Video block is missing "provider"' };
|
|
8210
8289
|
}
|
|
8211
|
-
const
|
|
8212
|
-
if (!
|
|
8290
|
+
const allowed = ALLOWED_KEYS[provider];
|
|
8291
|
+
if (!allowed) {
|
|
8213
8292
|
return {
|
|
8214
8293
|
ok: false,
|
|
8215
|
-
error: `Unknown video provider "${provider}". Supported providers: ${
|
|
8294
|
+
error: `Unknown video provider "${provider}". Supported providers: ${SUPPORTED_PROVIDERS.join(", ")}`
|
|
8216
8295
|
};
|
|
8217
8296
|
}
|
|
8297
|
+
for (const key of Object.keys(entries)) {
|
|
8298
|
+
if (!allowed.has(key)) {
|
|
8299
|
+
return { ok: false, error: `Unknown key "${key}" in video block` };
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
if (provider === FILE_VIDEO_PROVIDER) return parseFileVideo(entries);
|
|
8303
|
+
const registered = VIDEO_PROVIDERS[provider];
|
|
8218
8304
|
const id = entries.id;
|
|
8219
8305
|
if (!id) {
|
|
8220
8306
|
return { ok: false, error: 'Video block is missing "id"' };
|
|
@@ -8225,7 +8311,43 @@ function parseVideoBlock(body) {
|
|
|
8225
8311
|
error: `Video id "${id}" is not a valid ${provider} id`
|
|
8226
8312
|
};
|
|
8227
8313
|
}
|
|
8228
|
-
return { ok: true, provider, id, embedUrl: registered.embedUrl(id) };
|
|
8314
|
+
return { ok: true, kind: "embed", provider, id, embedUrl: registered.embedUrl(id) };
|
|
8315
|
+
}
|
|
8316
|
+
function parseFileVideo(entries) {
|
|
8317
|
+
if (!entries.src) {
|
|
8318
|
+
return { ok: false, error: 'Video block is missing "src"' };
|
|
8319
|
+
}
|
|
8320
|
+
const files = {};
|
|
8321
|
+
for (const key of Object.keys(
|
|
8322
|
+
FILE_VIDEO_EXTENSIONS
|
|
8323
|
+
)) {
|
|
8324
|
+
const reference = entries[key];
|
|
8325
|
+
if (reference === void 0) continue;
|
|
8326
|
+
const path3 = guideAssetPath(reference);
|
|
8327
|
+
if (!path3) {
|
|
8328
|
+
return {
|
|
8329
|
+
ok: false,
|
|
8330
|
+
error: `Video ${key} "${reference}" must be a file in the guide's assets/ directory`
|
|
8331
|
+
};
|
|
8332
|
+
}
|
|
8333
|
+
const extensions = FILE_VIDEO_EXTENSIONS[key];
|
|
8334
|
+
if (!extensions.includes(extensionOf(path3))) {
|
|
8335
|
+
return {
|
|
8336
|
+
ok: false,
|
|
8337
|
+
error: `Video ${key} "${reference}" must be a ${extensions.map((e) => `.${e}`).join(", ")} file`
|
|
8338
|
+
};
|
|
8339
|
+
}
|
|
8340
|
+
files[key] = path3;
|
|
8341
|
+
}
|
|
8342
|
+
return {
|
|
8343
|
+
ok: true,
|
|
8344
|
+
kind: "file",
|
|
8345
|
+
provider: FILE_VIDEO_PROVIDER,
|
|
8346
|
+
src: files.src,
|
|
8347
|
+
...files.poster ? { poster: files.poster } : {},
|
|
8348
|
+
...files.captions ? { captions: files.captions } : {},
|
|
8349
|
+
...entries.title ? { title: entries.title } : {}
|
|
8350
|
+
};
|
|
8229
8351
|
}
|
|
8230
8352
|
|
|
8231
8353
|
// ../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
|
|
@@ -21436,6 +21558,16 @@ function settingReferences(markdown) {
|
|
|
21436
21558
|
walk3(parse2(markdown).children, false);
|
|
21437
21559
|
return references;
|
|
21438
21560
|
}
|
|
21561
|
+
function strayFences(markdown) {
|
|
21562
|
+
const lines = [];
|
|
21563
|
+
visit(parse2(markdown), "text", (node2) => {
|
|
21564
|
+
const start = node2.position?.start.line ?? 0;
|
|
21565
|
+
node2.value.split("\n").forEach((text5, offset) => {
|
|
21566
|
+
if (/^:{3,}\s*$/.test(text5)) lines.push(start + offset);
|
|
21567
|
+
});
|
|
21568
|
+
});
|
|
21569
|
+
return lines;
|
|
21570
|
+
}
|
|
21439
21571
|
|
|
21440
21572
|
// cli/validation/guide-settings-validator.ts
|
|
21441
21573
|
function typesOf2(schema2) {
|
|
@@ -21506,6 +21638,11 @@ function validateGuideSettings(chapters, context) {
|
|
|
21506
21638
|
const warnings = [];
|
|
21507
21639
|
const used = /* @__PURE__ */ new Set();
|
|
21508
21640
|
for (const chapter of chapters) {
|
|
21641
|
+
for (const line of strayFences(chapter.markdown)) {
|
|
21642
|
+
warnings.push(
|
|
21643
|
+
`${chapter.label}:${line}: this ::: closes nothing, so a block above it ended early; a :::when that holds another ::: block needs more colons than it, as in ::::when`
|
|
21644
|
+
);
|
|
21645
|
+
}
|
|
21509
21646
|
for (const reference of settingReferences(chapter.markdown)) {
|
|
21510
21647
|
const where3 = `${chapter.label}:${reference.line}`;
|
|
21511
21648
|
const directive2 = reference.kind === "value" ? ":setting" : ":::when";
|
|
@@ -21570,6 +21707,7 @@ function validateGuideSettings(chapters, context) {
|
|
|
21570
21707
|
}
|
|
21571
21708
|
|
|
21572
21709
|
// cli/validation/facilitator-guide-validator.ts
|
|
21710
|
+
var LARGE_VIDEO_FILE_BYTES = 25 * 1024 * 1024;
|
|
21573
21711
|
var VIDEO_BLOCK_PATTERN = /^[ \t]*```video[ \t]*\r?\n([\s\S]*?)^[ \t]*```[ \t]*$/gm;
|
|
21574
21712
|
var IMAGE_PATTERN = /!\[[^\]]*\]\(([^()\s]+)(?:\s+"[^"]*")?\)/g;
|
|
21575
21713
|
function listChapters(localeDir) {
|
|
@@ -21628,6 +21766,27 @@ function validateFacilitatorGuideContent(options) {
|
|
|
21628
21766
|
const parsed = parseVideoBlock(match2[1]);
|
|
21629
21767
|
if (!parsed.ok) {
|
|
21630
21768
|
errors.push(`${label4}: ${parsed.error}`);
|
|
21769
|
+
continue;
|
|
21770
|
+
}
|
|
21771
|
+
if (parsed.kind !== "file") continue;
|
|
21772
|
+
const assetsDir = join26(rootDirectory, "assets");
|
|
21773
|
+
for (const [key, path3] of [
|
|
21774
|
+
["src", parsed.src],
|
|
21775
|
+
["poster", parsed.poster],
|
|
21776
|
+
["captions", parsed.captions]
|
|
21777
|
+
]) {
|
|
21778
|
+
if (path3 === void 0) continue;
|
|
21779
|
+
const file = join26(assetsDir, path3);
|
|
21780
|
+
if (!existsSync12(file) || !statSync2(file).isFile()) {
|
|
21781
|
+
errors.push(
|
|
21782
|
+
`${label4}: video ${key} "assets/${path3}" does not resolve to a file`
|
|
21783
|
+
);
|
|
21784
|
+
} else if (key === "src" && statSync2(file).size > LARGE_VIDEO_FILE_BYTES) {
|
|
21785
|
+
const megabytes = Math.round(statSync2(file).size / (1024 * 1024));
|
|
21786
|
+
warnings.push(
|
|
21787
|
+
`${label4}: video "assets/${path3}" is ${megabytes} MB; every upload of the package carries it, so consider compressing it or embedding it from YouTube`
|
|
21788
|
+
);
|
|
21789
|
+
}
|
|
21631
21790
|
}
|
|
21632
21791
|
}
|
|
21633
21792
|
for (const match2 of content3.matchAll(IMAGE_PATTERN)) {
|
|
@@ -21924,6 +22083,7 @@ function validateGame(game, config) {
|
|
|
21924
22083
|
}
|
|
21925
22084
|
}
|
|
21926
22085
|
warnings.push(...namesBeyondMax("game", declared));
|
|
22086
|
+
warnings.push(...openSettingsObjectWarnings(config));
|
|
21927
22087
|
for (const scenario of config.scenarios ?? []) {
|
|
21928
22088
|
const overrides = scenarioGame(scenario);
|
|
21929
22089
|
if (!overrides?.teams) continue;
|
|
@@ -22286,6 +22446,13 @@ function collectMissingSettingsDefaults(config) {
|
|
|
22286
22446
|
}
|
|
22287
22447
|
return errors;
|
|
22288
22448
|
}
|
|
22449
|
+
function openSettingsObjectWarnings(config) {
|
|
22450
|
+
return (config.settings ?? []).flatMap(
|
|
22451
|
+
(settings) => openSettingsObjects(settings.definition.settingsSchema).map(
|
|
22452
|
+
(pointer) => `Settings "${settings.definition.identifier}" leaves the object at ${pointer === "" ? "the top of its settingsSchema" : `settingsSchema${pointer}`} open. A key it does not declare is refused all the same; add "additionalProperties": false so the schema says so.`
|
|
22453
|
+
)
|
|
22454
|
+
);
|
|
22455
|
+
}
|
|
22289
22456
|
function collectVestigialRequired(config) {
|
|
22290
22457
|
const errors = [];
|
|
22291
22458
|
for (const settings of config.settings ?? []) {
|
|
@@ -37430,7 +37597,16 @@ var BRAND_FILE_SCHEMA = {
|
|
|
37430
37597
|
properties: { onLight: { type: "string" }, onDark: { type: "string" } },
|
|
37431
37598
|
additionalProperties: false
|
|
37432
37599
|
},
|
|
37433
|
-
icon: {
|
|
37600
|
+
icon: {
|
|
37601
|
+
oneOf: [
|
|
37602
|
+
{ type: "string", minLength: 1 },
|
|
37603
|
+
{
|
|
37604
|
+
type: "object",
|
|
37605
|
+
properties: { onLight: { type: "string" }, onDark: { type: "string" } },
|
|
37606
|
+
additionalProperties: false
|
|
37607
|
+
}
|
|
37608
|
+
]
|
|
37609
|
+
},
|
|
37434
37610
|
fonts: {
|
|
37435
37611
|
type: "object",
|
|
37436
37612
|
properties: { heading: FONT_SCHEMA, body: FONT_SCHEMA },
|
|
@@ -37517,7 +37693,12 @@ function readBrandFile(path3, id, defaults) {
|
|
|
37517
37693
|
if (data.logo?.onDark) checkPath(path3, root2, data.logo.onDark, "/logo/onDark");
|
|
37518
37694
|
if (data.loader?.onLight) checkPath(path3, root2, data.loader.onLight, "/loader/onLight");
|
|
37519
37695
|
if (data.loader?.onDark) checkPath(path3, root2, data.loader.onDark, "/loader/onDark");
|
|
37520
|
-
|
|
37696
|
+
const icon = typeof data.icon === "string" ? { onLight: data.icon, onDark: data.icon } : data.icon;
|
|
37697
|
+
if (typeof data.icon === "string") checkPath(path3, root2, data.icon, "/icon");
|
|
37698
|
+
else {
|
|
37699
|
+
if (icon?.onLight) checkPath(path3, root2, icon.onLight, "/icon/onLight");
|
|
37700
|
+
if (icon?.onDark) checkPath(path3, root2, icon.onDark, "/icon/onDark");
|
|
37701
|
+
}
|
|
37521
37702
|
for (const slot3 of ["heading", "body"]) {
|
|
37522
37703
|
data.fonts?.[slot3]?.sources.forEach(
|
|
37523
37704
|
(source, index3) => checkPath(path3, root2, source.url, `/fonts/${slot3}/sources/${index3}/url`)
|
|
@@ -37533,7 +37714,7 @@ function readBrandFile(path3, id, defaults) {
|
|
|
37533
37714
|
brand: {
|
|
37534
37715
|
name: data.name,
|
|
37535
37716
|
...data.logo && (data.logo.onLight || data.logo.onDark) ? { logo: data.logo } : {},
|
|
37536
|
-
...
|
|
37717
|
+
...icon && (icon.onLight || icon.onDark) ? { icon } : {},
|
|
37537
37718
|
...data.fonts && (data.fonts.heading || data.fonts.body) ? { fonts: data.fonts } : {}
|
|
37538
37719
|
}
|
|
37539
37720
|
};
|
|
@@ -37628,7 +37809,12 @@ function summarise(brand, assetOrigin) {
|
|
|
37628
37809
|
...source.logo.onDark ? { onDark: url(source.logo.onDark) } : {}
|
|
37629
37810
|
}
|
|
37630
37811
|
} : {},
|
|
37631
|
-
...source.icon ? {
|
|
37812
|
+
...source.icon ? {
|
|
37813
|
+
icon: {
|
|
37814
|
+
...source.icon.onLight ? { onLight: url(source.icon.onLight) } : {},
|
|
37815
|
+
...source.icon.onDark ? { onDark: url(source.icon.onDark) } : {}
|
|
37816
|
+
}
|
|
37817
|
+
} : {},
|
|
37632
37818
|
...fonts ? { fonts } : {}
|
|
37633
37819
|
}
|
|
37634
37820
|
}
|
package/dist/client.js
CHANGED
|
@@ -4195,7 +4195,7 @@ function validateSettingsOverrides(overrides, schemas, sourceLabel) {
|
|
|
4195
4195
|
${errors.join("\n")}` } : { valid: true };
|
|
4196
4196
|
}
|
|
4197
4197
|
function validatePartialOverride(override, settingsSchema) {
|
|
4198
|
-
const validator = settingsAjv.compile(withoutRequired(settingsSchema));
|
|
4198
|
+
const validator = settingsAjv.compile(closed(withoutRequired(settingsSchema)));
|
|
4199
4199
|
return validator(override) ? null : validator.errors ?? [];
|
|
4200
4200
|
}
|
|
4201
4201
|
var SCHEMA_MAP_KEYWORDS = ["properties", "patternProperties", "definitions", "$defs"];
|
|
@@ -4223,6 +4223,53 @@ function withoutRequired(schema2) {
|
|
|
4223
4223
|
}
|
|
4224
4224
|
return copy;
|
|
4225
4225
|
}
|
|
4226
|
+
var COMBINATOR_KEYWORDS = ["allOf", "anyOf", "oneOf", "if", "not", "$ref"];
|
|
4227
|
+
function closed(schema2) {
|
|
4228
|
+
if (typeof schema2 !== "object" || schema2 === null) return schema2;
|
|
4229
|
+
const copy = { ...schema2 };
|
|
4230
|
+
for (const keyword of SCHEMA_MAP_KEYWORDS) {
|
|
4231
|
+
const map3 = schema2[keyword];
|
|
4232
|
+
if (map3 && typeof map3 === "object") {
|
|
4233
|
+
copy[keyword] = Object.fromEntries(
|
|
4234
|
+
Object.entries(map3).map(([key, value]) => [key, closed(value)])
|
|
4235
|
+
);
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
if (typeof schema2.additionalProperties === "object") {
|
|
4239
|
+
copy.additionalProperties = closed(schema2.additionalProperties);
|
|
4240
|
+
}
|
|
4241
|
+
if (Array.isArray(schema2.items)) copy.items = schema2.items.map(closed);
|
|
4242
|
+
else if (schema2.items !== void 0) copy.items = closed(schema2.items);
|
|
4243
|
+
if (isPlainOpen(schema2)) copy.additionalProperties = false;
|
|
4244
|
+
return copy;
|
|
4245
|
+
}
|
|
4246
|
+
function isPlainOpen(schema2) {
|
|
4247
|
+
return schema2.properties !== void 0 && schema2.additionalProperties === void 0 && schema2.patternProperties === void 0 && !COMBINATOR_KEYWORDS.some((keyword) => keyword in schema2);
|
|
4248
|
+
}
|
|
4249
|
+
function openSettingsObjects(schema2, at = "") {
|
|
4250
|
+
if (typeof schema2 !== "object" || schema2 === null) return [];
|
|
4251
|
+
const found = isPlainOpen(schema2) ? [at] : [];
|
|
4252
|
+
for (const keyword of SCHEMA_MAP_KEYWORDS) {
|
|
4253
|
+
const map3 = schema2[keyword];
|
|
4254
|
+
if (!map3 || typeof map3 !== "object") continue;
|
|
4255
|
+
for (const [key, value] of Object.entries(map3)) {
|
|
4256
|
+
found.push(...openSettingsObjects(value, `${at}/${keyword}/${key}`));
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
if (typeof schema2.additionalProperties === "object") {
|
|
4260
|
+
found.push(
|
|
4261
|
+
...openSettingsObjects(schema2.additionalProperties, `${at}/additionalProperties`)
|
|
4262
|
+
);
|
|
4263
|
+
}
|
|
4264
|
+
if (Array.isArray(schema2.items)) {
|
|
4265
|
+
schema2.items.forEach(
|
|
4266
|
+
(item, index3) => found.push(...openSettingsObjects(item, `${at}/items/${index3}`))
|
|
4267
|
+
);
|
|
4268
|
+
} else if (schema2.items !== void 0) {
|
|
4269
|
+
found.push(...openSettingsObjects(schema2.items, `${at}/items`));
|
|
4270
|
+
}
|
|
4271
|
+
return found;
|
|
4272
|
+
}
|
|
4226
4273
|
|
|
4227
4274
|
// cli/discovery/manifest-paths.ts
|
|
4228
4275
|
import { posix } from "path";
|
|
@@ -22075,6 +22122,16 @@ function settingReferences(markdown) {
|
|
|
22075
22122
|
walk3(parse2(markdown).children, false);
|
|
22076
22123
|
return references;
|
|
22077
22124
|
}
|
|
22125
|
+
function strayFences(markdown) {
|
|
22126
|
+
const lines = [];
|
|
22127
|
+
visit(parse2(markdown), "text", (node2) => {
|
|
22128
|
+
const start = node2.position?.start.line ?? 0;
|
|
22129
|
+
node2.value.split("\n").forEach((text5, offset) => {
|
|
22130
|
+
if (/^:{3,}\s*$/.test(text5)) lines.push(start + offset);
|
|
22131
|
+
});
|
|
22132
|
+
});
|
|
22133
|
+
return lines;
|
|
22134
|
+
}
|
|
22078
22135
|
|
|
22079
22136
|
// cli/guide/effective-guide.ts
|
|
22080
22137
|
function readEffectiveGuide(guide, root2, resolved) {
|
|
@@ -26846,7 +26903,42 @@ var VIDEO_PROVIDERS = {
|
|
|
26846
26903
|
embedHosts: ["www.youtube-nocookie.com"]
|
|
26847
26904
|
}
|
|
26848
26905
|
};
|
|
26849
|
-
var
|
|
26906
|
+
var FILE_VIDEO_PROVIDER = "file";
|
|
26907
|
+
var FILE_VIDEO_EXTENSIONS = {
|
|
26908
|
+
src: ["mp4", "webm"],
|
|
26909
|
+
poster: ["png", "jpg", "jpeg", "gif", "webp", "avif"],
|
|
26910
|
+
captions: ["vtt"]
|
|
26911
|
+
};
|
|
26912
|
+
var ALLOWED_KEYS = {
|
|
26913
|
+
youtube: /* @__PURE__ */ new Set(["provider", "id"]),
|
|
26914
|
+
[FILE_VIDEO_PROVIDER]: /* @__PURE__ */ new Set(["provider", "src", "title", "poster", "captions"])
|
|
26915
|
+
};
|
|
26916
|
+
var SUPPORTED_PROVIDERS = [...Object.keys(VIDEO_PROVIDERS), FILE_VIDEO_PROVIDER];
|
|
26917
|
+
var CHAPTER_BASE = "https://guide.invalid/content/locale/chapter.md";
|
|
26918
|
+
function guideAssetPath(reference) {
|
|
26919
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(reference) || reference.startsWith("/")) return void 0;
|
|
26920
|
+
if (reference.includes("\\") || /[?#]/.test(reference)) return void 0;
|
|
26921
|
+
let resolved;
|
|
26922
|
+
try {
|
|
26923
|
+
resolved = new URL(reference, CHAPTER_BASE);
|
|
26924
|
+
} catch {
|
|
26925
|
+
return void 0;
|
|
26926
|
+
}
|
|
26927
|
+
if (resolved.origin !== "https://guide.invalid" || !resolved.pathname.startsWith("/assets/")) {
|
|
26928
|
+
return void 0;
|
|
26929
|
+
}
|
|
26930
|
+
try {
|
|
26931
|
+
const path3 = decodeURIComponent(resolved.pathname.slice("/assets/".length));
|
|
26932
|
+
const segments = path3.split("/");
|
|
26933
|
+
return segments.some((s) => s === "" || s === "." || s === ".." || s.includes("\\")) ? void 0 : path3;
|
|
26934
|
+
} catch {
|
|
26935
|
+
return void 0;
|
|
26936
|
+
}
|
|
26937
|
+
}
|
|
26938
|
+
function extensionOf(path3) {
|
|
26939
|
+
const dot = path3.lastIndexOf(".");
|
|
26940
|
+
return dot === -1 ? "" : path3.slice(dot + 1).toLowerCase();
|
|
26941
|
+
}
|
|
26850
26942
|
function parseVideoBlock(body) {
|
|
26851
26943
|
const entries = {};
|
|
26852
26944
|
for (const rawLine of body.split("\n")) {
|
|
@@ -26858,9 +26950,6 @@ function parseVideoBlock(body) {
|
|
|
26858
26950
|
}
|
|
26859
26951
|
const key = match2[1];
|
|
26860
26952
|
const value = match2[2].trim();
|
|
26861
|
-
if (!ALLOWED_KEYS.has(key)) {
|
|
26862
|
-
return { ok: false, error: `Unknown key "${key}" in video block` };
|
|
26863
|
-
}
|
|
26864
26953
|
if (key in entries) {
|
|
26865
26954
|
return { ok: false, error: `Duplicate key "${key}" in video block` };
|
|
26866
26955
|
}
|
|
@@ -26870,13 +26959,20 @@ function parseVideoBlock(body) {
|
|
|
26870
26959
|
if (!provider) {
|
|
26871
26960
|
return { ok: false, error: 'Video block is missing "provider"' };
|
|
26872
26961
|
}
|
|
26873
|
-
const
|
|
26874
|
-
if (!
|
|
26962
|
+
const allowed = ALLOWED_KEYS[provider];
|
|
26963
|
+
if (!allowed) {
|
|
26875
26964
|
return {
|
|
26876
26965
|
ok: false,
|
|
26877
|
-
error: `Unknown video provider "${provider}". Supported providers: ${
|
|
26966
|
+
error: `Unknown video provider "${provider}". Supported providers: ${SUPPORTED_PROVIDERS.join(", ")}`
|
|
26878
26967
|
};
|
|
26879
26968
|
}
|
|
26969
|
+
for (const key of Object.keys(entries)) {
|
|
26970
|
+
if (!allowed.has(key)) {
|
|
26971
|
+
return { ok: false, error: `Unknown key "${key}" in video block` };
|
|
26972
|
+
}
|
|
26973
|
+
}
|
|
26974
|
+
if (provider === FILE_VIDEO_PROVIDER) return parseFileVideo(entries);
|
|
26975
|
+
const registered = VIDEO_PROVIDERS[provider];
|
|
26880
26976
|
const id = entries.id;
|
|
26881
26977
|
if (!id) {
|
|
26882
26978
|
return { ok: false, error: 'Video block is missing "id"' };
|
|
@@ -26887,7 +26983,43 @@ function parseVideoBlock(body) {
|
|
|
26887
26983
|
error: `Video id "${id}" is not a valid ${provider} id`
|
|
26888
26984
|
};
|
|
26889
26985
|
}
|
|
26890
|
-
return { ok: true, provider, id, embedUrl: registered.embedUrl(id) };
|
|
26986
|
+
return { ok: true, kind: "embed", provider, id, embedUrl: registered.embedUrl(id) };
|
|
26987
|
+
}
|
|
26988
|
+
function parseFileVideo(entries) {
|
|
26989
|
+
if (!entries.src) {
|
|
26990
|
+
return { ok: false, error: 'Video block is missing "src"' };
|
|
26991
|
+
}
|
|
26992
|
+
const files = {};
|
|
26993
|
+
for (const key of Object.keys(
|
|
26994
|
+
FILE_VIDEO_EXTENSIONS
|
|
26995
|
+
)) {
|
|
26996
|
+
const reference = entries[key];
|
|
26997
|
+
if (reference === void 0) continue;
|
|
26998
|
+
const path3 = guideAssetPath(reference);
|
|
26999
|
+
if (!path3) {
|
|
27000
|
+
return {
|
|
27001
|
+
ok: false,
|
|
27002
|
+
error: `Video ${key} "${reference}" must be a file in the guide's assets/ directory`
|
|
27003
|
+
};
|
|
27004
|
+
}
|
|
27005
|
+
const extensions = FILE_VIDEO_EXTENSIONS[key];
|
|
27006
|
+
if (!extensions.includes(extensionOf(path3))) {
|
|
27007
|
+
return {
|
|
27008
|
+
ok: false,
|
|
27009
|
+
error: `Video ${key} "${reference}" must be a ${extensions.map((e) => `.${e}`).join(", ")} file`
|
|
27010
|
+
};
|
|
27011
|
+
}
|
|
27012
|
+
files[key] = path3;
|
|
27013
|
+
}
|
|
27014
|
+
return {
|
|
27015
|
+
ok: true,
|
|
27016
|
+
kind: "file",
|
|
27017
|
+
provider: FILE_VIDEO_PROVIDER,
|
|
27018
|
+
src: files.src,
|
|
27019
|
+
...files.poster ? { poster: files.poster } : {},
|
|
27020
|
+
...files.captions ? { captions: files.captions } : {},
|
|
27021
|
+
...entries.title ? { title: entries.title } : {}
|
|
27022
|
+
};
|
|
26891
27023
|
}
|
|
26892
27024
|
|
|
26893
27025
|
// cli/validation/guide-settings-validator.ts
|
|
@@ -26959,6 +27091,11 @@ function validateGuideSettings(chapters, context) {
|
|
|
26959
27091
|
const warnings = [];
|
|
26960
27092
|
const used = /* @__PURE__ */ new Set();
|
|
26961
27093
|
for (const chapter of chapters) {
|
|
27094
|
+
for (const line of strayFences(chapter.markdown)) {
|
|
27095
|
+
warnings.push(
|
|
27096
|
+
`${chapter.label}:${line}: this ::: closes nothing, so a block above it ended early; a :::when that holds another ::: block needs more colons than it, as in ::::when`
|
|
27097
|
+
);
|
|
27098
|
+
}
|
|
26962
27099
|
for (const reference of settingReferences(chapter.markdown)) {
|
|
26963
27100
|
const where3 = `${chapter.label}:${reference.line}`;
|
|
26964
27101
|
const directive2 = reference.kind === "value" ? ":setting" : ":::when";
|
|
@@ -27023,6 +27160,7 @@ function validateGuideSettings(chapters, context) {
|
|
|
27023
27160
|
}
|
|
27024
27161
|
|
|
27025
27162
|
// cli/validation/facilitator-guide-validator.ts
|
|
27163
|
+
var LARGE_VIDEO_FILE_BYTES = 25 * 1024 * 1024;
|
|
27026
27164
|
var VIDEO_BLOCK_PATTERN = /^[ \t]*```video[ \t]*\r?\n([\s\S]*?)^[ \t]*```[ \t]*$/gm;
|
|
27027
27165
|
var IMAGE_PATTERN = /!\[[^\]]*\]\(([^()\s]+)(?:\s+"[^"]*")?\)/g;
|
|
27028
27166
|
function listChapters(localeDir) {
|
|
@@ -27081,6 +27219,27 @@ function validateFacilitatorGuideContent(options) {
|
|
|
27081
27219
|
const parsed = parseVideoBlock(match2[1]);
|
|
27082
27220
|
if (!parsed.ok) {
|
|
27083
27221
|
errors.push(`${label4}: ${parsed.error}`);
|
|
27222
|
+
continue;
|
|
27223
|
+
}
|
|
27224
|
+
if (parsed.kind !== "file") continue;
|
|
27225
|
+
const assetsDir = join11(rootDirectory, "assets");
|
|
27226
|
+
for (const [key, path3] of [
|
|
27227
|
+
["src", parsed.src],
|
|
27228
|
+
["poster", parsed.poster],
|
|
27229
|
+
["captions", parsed.captions]
|
|
27230
|
+
]) {
|
|
27231
|
+
if (path3 === void 0) continue;
|
|
27232
|
+
const file = join11(assetsDir, path3);
|
|
27233
|
+
if (!existsSync11(file) || !statSync2(file).isFile()) {
|
|
27234
|
+
errors.push(
|
|
27235
|
+
`${label4}: video ${key} "assets/${path3}" does not resolve to a file`
|
|
27236
|
+
);
|
|
27237
|
+
} else if (key === "src" && statSync2(file).size > LARGE_VIDEO_FILE_BYTES) {
|
|
27238
|
+
const megabytes = Math.round(statSync2(file).size / (1024 * 1024));
|
|
27239
|
+
warnings.push(
|
|
27240
|
+
`${label4}: video "assets/${path3}" is ${megabytes} MB; every upload of the package carries it, so consider compressing it or embedding it from YouTube`
|
|
27241
|
+
);
|
|
27242
|
+
}
|
|
27084
27243
|
}
|
|
27085
27244
|
}
|
|
27086
27245
|
for (const match2 of content3.matchAll(IMAGE_PATTERN)) {
|
|
@@ -27134,6 +27293,7 @@ function validateGame(game, config) {
|
|
|
27134
27293
|
}
|
|
27135
27294
|
}
|
|
27136
27295
|
warnings.push(...namesBeyondMax("game", declared));
|
|
27296
|
+
warnings.push(...openSettingsObjectWarnings(config));
|
|
27137
27297
|
for (const scenario of config.scenarios ?? []) {
|
|
27138
27298
|
const overrides = scenarioGame(scenario);
|
|
27139
27299
|
if (!overrides?.teams) continue;
|
|
@@ -27496,6 +27656,13 @@ function collectMissingSettingsDefaults(config) {
|
|
|
27496
27656
|
}
|
|
27497
27657
|
return errors;
|
|
27498
27658
|
}
|
|
27659
|
+
function openSettingsObjectWarnings(config) {
|
|
27660
|
+
return (config.settings ?? []).flatMap(
|
|
27661
|
+
(settings) => openSettingsObjects(settings.definition.settingsSchema).map(
|
|
27662
|
+
(pointer) => `Settings "${settings.definition.identifier}" leaves the object at ${pointer === "" ? "the top of its settingsSchema" : `settingsSchema${pointer}`} open. A key it does not declare is refused all the same; add "additionalProperties": false so the schema says so.`
|
|
27663
|
+
)
|
|
27664
|
+
);
|
|
27665
|
+
}
|
|
27499
27666
|
function collectVestigialRequired(config) {
|
|
27500
27667
|
const errors = [];
|
|
27501
27668
|
for (const settings of config.settings ?? []) {
|
|
@@ -28719,7 +28886,16 @@ var BRAND_FILE_SCHEMA = {
|
|
|
28719
28886
|
properties: { onLight: { type: "string" }, onDark: { type: "string" } },
|
|
28720
28887
|
additionalProperties: false
|
|
28721
28888
|
},
|
|
28722
|
-
icon: {
|
|
28889
|
+
icon: {
|
|
28890
|
+
oneOf: [
|
|
28891
|
+
{ type: "string", minLength: 1 },
|
|
28892
|
+
{
|
|
28893
|
+
type: "object",
|
|
28894
|
+
properties: { onLight: { type: "string" }, onDark: { type: "string" } },
|
|
28895
|
+
additionalProperties: false
|
|
28896
|
+
}
|
|
28897
|
+
]
|
|
28898
|
+
},
|
|
28723
28899
|
fonts: {
|
|
28724
28900
|
type: "object",
|
|
28725
28901
|
properties: { heading: FONT_SCHEMA, body: FONT_SCHEMA },
|
|
@@ -28806,7 +28982,12 @@ function readBrandFile(path3, id, defaults) {
|
|
|
28806
28982
|
if (data.logo?.onDark) checkPath(path3, root2, data.logo.onDark, "/logo/onDark");
|
|
28807
28983
|
if (data.loader?.onLight) checkPath(path3, root2, data.loader.onLight, "/loader/onLight");
|
|
28808
28984
|
if (data.loader?.onDark) checkPath(path3, root2, data.loader.onDark, "/loader/onDark");
|
|
28809
|
-
|
|
28985
|
+
const icon = typeof data.icon === "string" ? { onLight: data.icon, onDark: data.icon } : data.icon;
|
|
28986
|
+
if (typeof data.icon === "string") checkPath(path3, root2, data.icon, "/icon");
|
|
28987
|
+
else {
|
|
28988
|
+
if (icon?.onLight) checkPath(path3, root2, icon.onLight, "/icon/onLight");
|
|
28989
|
+
if (icon?.onDark) checkPath(path3, root2, icon.onDark, "/icon/onDark");
|
|
28990
|
+
}
|
|
28810
28991
|
for (const slot2 of ["heading", "body"]) {
|
|
28811
28992
|
data.fonts?.[slot2]?.sources.forEach(
|
|
28812
28993
|
(source, index3) => checkPath(path3, root2, source.url, `/fonts/${slot2}/sources/${index3}/url`)
|
|
@@ -28822,7 +29003,7 @@ function readBrandFile(path3, id, defaults) {
|
|
|
28822
29003
|
brand: {
|
|
28823
29004
|
name: data.name,
|
|
28824
29005
|
...data.logo && (data.logo.onLight || data.logo.onDark) ? { logo: data.logo } : {},
|
|
28825
|
-
...
|
|
29006
|
+
...icon && (icon.onLight || icon.onDark) ? { icon } : {},
|
|
28826
29007
|
...data.fonts && (data.fonts.heading || data.fonts.body) ? { fonts: data.fonts } : {}
|
|
28827
29008
|
}
|
|
28828
29009
|
};
|
|
@@ -28917,7 +29098,12 @@ function summarise(brand, assetOrigin) {
|
|
|
28917
29098
|
...source.logo.onDark ? { onDark: url(source.logo.onDark) } : {}
|
|
28918
29099
|
}
|
|
28919
29100
|
} : {},
|
|
28920
|
-
...source.icon ? {
|
|
29101
|
+
...source.icon ? {
|
|
29102
|
+
icon: {
|
|
29103
|
+
...source.icon.onLight ? { onLight: url(source.icon.onLight) } : {},
|
|
29104
|
+
...source.icon.onDark ? { onDark: url(source.icon.onDark) } : {}
|
|
29105
|
+
}
|
|
29106
|
+
} : {},
|
|
28921
29107
|
...fonts ? { fonts } : {}
|
|
28922
29108
|
}
|
|
28923
29109
|
}
|