@anweather/game-plugin-ssdk 1.26.0 → 1.28.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-cjs/runtime/index.js +4 -1
- package/dist-cjs/runtime/presentation.js +31 -2
- package/dist-cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist-es/runtime/index.js +1 -1
- package/dist-es/runtime/presentation.js +30 -1
- package/dist-es/tsconfig.es.tsbuildinfo +1 -1
- package/dist-types/runtime/index.d.ts +1 -1
- package/dist-types/runtime/presentation.d.ts +27 -0
- package/package.json +1 -1
package/dist-es/runtime/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { createGamePluginService } from "./defaultService";
|
|
|
3
3
|
export { servePlugin, createPluginApp } from "./servePlugin";
|
|
4
4
|
export { createRegistrationLoop } from "./registration";
|
|
5
5
|
export { runConformance, assertConformance } from "./conformance";
|
|
6
|
-
export { validatePresentation, assertPresentation, PRESENTATION_CATEGORIES, MAX_PRESENTATION_BYTES } from "./presentation";
|
|
6
|
+
export { validatePresentation, assertPresentation, PRESENTATION_CATEGORIES, MAX_PRESENTATION_BYTES, RESERVED_TUTORIAL_SLUGS, TUTORIAL_SLUG_PATTERN, MAX_TUTORIAL_PLAYERS, } from "./presentation";
|
|
7
7
|
export { PLUGIN_PROTOCOL_VERSION, runtimeVersion } from "./version";
|
|
8
8
|
export { createBlobClient, casUpdate, blobOwner, allBlobOwners, BlobStoreError, isVersionConflict } from "./blobClient";
|
|
9
9
|
export { attachLive } from "./live/server";
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export const PRESENTATION_CATEGORIES = ["classic", "strategy", "cards", "word", "wip"];
|
|
2
|
+
export const RESERVED_TUTORIAL_SLUGS = [
|
|
3
|
+
"api", "assets", "chats", "games", "health", "icons", "leaderboard", "nerdle",
|
|
4
|
+
"players", "plugins", "save-files", "saved-data", "spaces", "style-guide",
|
|
5
|
+
"tutorial", "tutorials", "wordle",
|
|
6
|
+
];
|
|
7
|
+
export const TUTORIAL_SLUG_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
8
|
+
export const MAX_TUTORIAL_PLAYERS = 16;
|
|
2
9
|
export const MAX_PRESENTATION_BYTES = 32 * 1024;
|
|
3
10
|
const str = { kind: "string" };
|
|
4
11
|
const bool = { kind: "boolean" };
|
|
5
12
|
const oneOf = (...values) => ({ kind: "oneOf", values });
|
|
6
|
-
const obj = (fields) => ({ kind: "object", fields });
|
|
13
|
+
const obj = (fields, required) => ({ kind: "object", fields, required });
|
|
7
14
|
const SCHEMA = obj({
|
|
8
15
|
catalogue: obj({
|
|
9
16
|
title: str,
|
|
@@ -21,6 +28,12 @@ const SCHEMA = obj({
|
|
|
21
28
|
host: obj({ overflowX: oneOf("auto", "hidden", "clip"), width: oneOf("fit", "full") }),
|
|
22
29
|
}),
|
|
23
30
|
rematch: obj({ seatNames: { kind: "strings", size: 2 } }),
|
|
31
|
+
tutorial: obj({
|
|
32
|
+
slug: { kind: "slug" },
|
|
33
|
+
config: { kind: "nonEmptyObject" },
|
|
34
|
+
players: { kind: "int", min: 1, max: MAX_TUTORIAL_PLAYERS },
|
|
35
|
+
title: str,
|
|
36
|
+
}, ["slug", "config"]),
|
|
24
37
|
});
|
|
25
38
|
const POSTER_TOKEN = /^([a-z]+-(50|[1-9]00|950)|white|black)$/;
|
|
26
39
|
export function validatePresentation(value) {
|
|
@@ -55,6 +68,18 @@ export function validatePresentation(value) {
|
|
|
55
68
|
if (typeof v !== "string" || !POSTER_TOKEN.test(v))
|
|
56
69
|
problems.push(`${path} is not a palette token like "amber-700"`);
|
|
57
70
|
return;
|
|
71
|
+
case "slug":
|
|
72
|
+
if (typeof v !== "string" || !TUTORIAL_SLUG_PATTERN.test(v)) {
|
|
73
|
+
problems.push(`${path} is not lowercase words joined by hyphens, like "spirit-island"`);
|
|
74
|
+
}
|
|
75
|
+
else if (RESERVED_TUTORIAL_SLUGS.includes(v)) {
|
|
76
|
+
problems.push(`${path} "${v}" is reserved for one of the site's own pages`);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
case "nonEmptyObject":
|
|
80
|
+
if (!isObject(v) || Object.keys(v).length === 0)
|
|
81
|
+
problems.push(`${path} is not an object with at least one field`);
|
|
82
|
+
return;
|
|
58
83
|
case "falseOr":
|
|
59
84
|
if (v === false)
|
|
60
85
|
return;
|
|
@@ -75,6 +100,10 @@ export function validatePresentation(value) {
|
|
|
75
100
|
else if (child !== undefined)
|
|
76
101
|
visit(child, childRule, `${path}.${key}`);
|
|
77
102
|
}
|
|
103
|
+
for (const key of rule.required ?? []) {
|
|
104
|
+
if (v[key] === undefined)
|
|
105
|
+
problems.push(`${path}.${key} is required`);
|
|
106
|
+
}
|
|
78
107
|
return;
|
|
79
108
|
}
|
|
80
109
|
};
|