@gameslate/sdk 0.3.15 → 0.3.17

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.
@@ -57,13 +57,14 @@ async function validate(builtDir) {
57
57
  log: line => console.error(line),
58
58
  });
59
59
  if (typeof result === 'string') return [result];
60
- const { live, assets, warnings } = result;
60
+ const { live, assets, registryGames, warnings } = result;
61
61
  console.log(`${manifest.id} ${manifest.version} (contract ${manifest.sdkApi}): OK`);
62
62
  console.log(` packs: ${live.packs.map(p => p.id).join(', ') || 'none'}`);
63
63
  console.log(
64
64
  ` sources: ${live.sources.map(s => `${s.gameId} (${s.supportedBuildIds.size} builds)`).join(', ') || 'none'}`,
65
65
  );
66
66
  console.log(` assets: ${assets?.games.join(', ') || 'none'}`);
67
+ console.log(` registry: ${registryGames.join(', ') || 'none'}`);
67
68
  for (const w of warnings) console.log(` warning: ${w}`);
68
69
  return [];
69
70
  }
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
3
3
  import fs from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
5
  import path from 'node:path';
6
+ import { renderLicences } from './third-party-licences.mjs';
6
7
 
7
8
  /*
8
9
  * Builds one plugin folder (manifest.json, live.ts, optionally assets.ts and extract.ts) into what
@@ -10,12 +11,19 @@ import path from 'node:path';
10
11
  * live.js live.ts's default export behind `exposeToHost`, for the core's QuickJS sandbox
11
12
  * assets.js assets.ts's default export behind `exposeAssetsToHost`, for extraction jobs
12
13
  * extract.mjs extract.ts, Node code the core runs unsandboxed (legacy hooks; avoid)
14
+ * THIRD_PARTY_LICENSES.txt the licence of every npm package the code files bundle (one
15
+ * without a licence file fails the build), and THIRD_PARTY_NOTICES.md copied from
16
+ * the plugin's repository (beside its plugin folder) when it has one
17
+ * registry/ the plugin's registry data, copied as it is (the core checks it on load:
18
+ * src/host/plugin-registry.ts; `gameslate-plugin validate` runs the same check)
13
19
  * Sandbox scripts are built for a neutral platform, so a Node API in them fails the build.
14
20
  */
15
21
 
16
22
  const LIVE_FILE = 'live.js';
17
23
  const ASSETS_FILE = 'assets.js';
18
24
  const EXTRACT_FILE = 'extract.mjs';
25
+ const LICENCES_FILE = 'THIRD_PARTY_LICENSES.txt';
26
+ const NOTICES_FILE = 'THIRD_PARTY_NOTICES.md';
19
27
 
20
28
  /*
21
29
  * Resolves bare imports (`@gameslate/sdk`, `earcut`) the way Node does, from the importing file's
@@ -41,8 +49,12 @@ const nodeResolution = {
41
49
  const hashOf = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
42
50
 
43
51
  /* a sandbox script: `entry`'s default export handed to the sdk's `expose` function */
52
+ /* the absolute paths of the modules an esbuild result bundled */
53
+ const inputsOf = (srcDir, result) =>
54
+ Object.keys(result.metafile.inputs).map(input => path.resolve(srcDir, input));
55
+
44
56
  async function buildSandboxed({ srcDir, entry, expose, outfile, alias }) {
45
- await esbuild.build({
57
+ const result = await esbuild.build({
46
58
  absWorkingDir: srcDir,
47
59
  stdin: {
48
60
  contents: [
@@ -63,12 +75,14 @@ async function buildSandboxed({ srcDir, entry, expose, outfile, alias }) {
63
75
  target: 'es2022',
64
76
  alias,
65
77
  plugins: Object.keys(alias).length ? [] : [nodeResolution],
78
+ metafile: true,
66
79
  logLevel: 'warning',
67
80
  });
81
+ return inputsOf(srcDir, result);
68
82
  }
69
83
 
70
84
  async function buildNode(srcDir, entry, outfile, alias) {
71
- await esbuild.build({
85
+ const result = await esbuild.build({
72
86
  absWorkingDir: srcDir,
73
87
  entryPoints: [path.join(srcDir, entry)],
74
88
  outfile,
@@ -84,8 +98,10 @@ async function buildNode(srcDir, entry, outfile, alias) {
84
98
  'const require = __gsCreateRequire(import.meta.url);',
85
99
  ].join('\n'),
86
100
  },
101
+ metafile: true,
87
102
  logLevel: 'warning',
88
103
  });
104
+ return inputsOf(srcDir, result);
89
105
  }
90
106
 
91
107
  /**
@@ -98,7 +114,7 @@ export async function buildPlugin({ srcDir, outDir, testedWith, alias = {}, node
98
114
  fs.rmSync(outDir, { recursive: true, force: true });
99
115
  fs.mkdirSync(outDir, { recursive: true });
100
116
  const live = path.join(outDir, LIVE_FILE);
101
- await buildSandboxed({
117
+ const bundled = await buildSandboxed({
102
118
  srcDir,
103
119
  entry: 'live.ts',
104
120
  expose: 'exposeToHost',
@@ -108,20 +124,31 @@ export async function buildPlugin({ srcDir, outDir, testedWith, alias = {}, node
108
124
  const built = { ...manifest, testedWith, code: { file: LIVE_FILE, sha256: hashOf(live) } };
109
125
  if (fs.existsSync(path.join(srcDir, 'assets.ts'))) {
110
126
  const out = path.join(outDir, ASSETS_FILE);
111
- await buildSandboxed({
112
- srcDir,
113
- entry: 'assets.ts',
114
- expose: 'exposeAssetsToHost',
115
- outfile: out,
116
- alias,
117
- });
127
+ bundled.push(
128
+ ...(await buildSandboxed({
129
+ srcDir,
130
+ entry: 'assets.ts',
131
+ expose: 'exposeAssetsToHost',
132
+ outfile: out,
133
+ alias,
134
+ })),
135
+ );
118
136
  built.assets = { file: ASSETS_FILE, sha256: hashOf(out) };
119
137
  }
120
138
  if (fs.existsSync(path.join(srcDir, 'extract.ts'))) {
121
139
  const out = path.join(outDir, EXTRACT_FILE);
122
- await buildNode(srcDir, 'extract.ts', out, nodeAlias);
140
+ bundled.push(...(await buildNode(srcDir, 'extract.ts', out, nodeAlias)));
123
141
  built.extract = { file: EXTRACT_FILE, sha256: hashOf(out) };
124
142
  }
143
+ fs.writeFileSync(
144
+ path.join(outDir, LICENCES_FILE),
145
+ renderLicences(`${manifest.id} ${manifest.version}: third-party licences`, bundled),
146
+ );
147
+ const notices = path.join(srcDir, '..', NOTICES_FILE);
148
+ if (fs.existsSync(notices)) fs.copyFileSync(notices, path.join(outDir, NOTICES_FILE));
149
+ const registry = path.join(srcDir, 'registry');
150
+ if (fs.existsSync(registry))
151
+ fs.cpSync(registry, path.join(outDir, 'registry'), { recursive: true });
125
152
  fs.writeFileSync(path.join(outDir, 'manifest.json'), `${JSON.stringify(built, null, 4)}\n`);
126
153
  return built;
127
154
  }
@@ -0,0 +1,7 @@
1
+ export function packageOf(modulePath: string): { name: string; dir: string } | undefined;
2
+ export function licenceOf(pkg: { name: string; dir: string }): {
3
+ name: string;
4
+ version: string;
5
+ text: string;
6
+ };
7
+ export function renderLicences(title: string, modulePaths: readonly string[]): string;
@@ -0,0 +1,52 @@
1
+ /*
2
+ * The licence texts of the packages a plugin bundle includes. live.js and assets.js inline npm
3
+ * packages (zod, earcut, this sdk), and MIT, ISC and BSD all require their notice to travel with
4
+ * the copy, so each built plugin ships a THIRD_PARTY_LICENSES.txt made from the modules esbuild
5
+ * actually used. The same logic as the GameSlate core's tools/third-party-licences.mjs; the sdk
6
+ * ships on its own, so it keeps its own copy.
7
+ */
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+
11
+ const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
12
+ const LICENCE_FILE = /^(licen[cs]e|copying)(\.(md|txt))?$/i;
13
+
14
+ /** The package a bundled module came from, or undefined for the plugin's own code. */
15
+ export function packageOf(modulePath) {
16
+ const file = modulePath.replace(/^\0/, '').replace(/\?.*$/, '');
17
+ const at = file.lastIndexOf(NODE_MODULES);
18
+ if (at < 0) return undefined;
19
+ const rest = file.slice(at + NODE_MODULES.length).split(path.sep);
20
+ const nameParts = rest[0]?.startsWith('@') ? rest.slice(0, 2) : rest.slice(0, 1);
21
+ const dir = file.slice(0, at + NODE_MODULES.length) + nameParts.join(path.sep);
22
+ return { name: nameParts.join('/'), dir };
23
+ }
24
+
25
+ /** One package's licence text: from its licence file, which must exist. */
26
+ export function licenceOf(pkg) {
27
+ const file = fs.readdirSync(pkg.dir).find(name => LICENCE_FILE.test(name));
28
+ if (!file) {
29
+ throw new Error(
30
+ `${pkg.name} (${pkg.dir}) has no LICENSE file, so its notice can't ship with the bundle`,
31
+ );
32
+ }
33
+ const { version } = JSON.parse(fs.readFileSync(path.join(pkg.dir, 'package.json'), 'utf8'));
34
+ return { name: pkg.name, version, text: fs.readFileSync(path.join(pkg.dir, file), 'utf8') };
35
+ }
36
+
37
+ /** THIRD_PARTY_LICENSES.txt for a bundle made of `modulePaths`, one entry per package by name. */
38
+ export function renderLicences(title, modulePaths) {
39
+ const packages = new Map();
40
+ for (const modulePath of modulePaths) {
41
+ const pkg = packageOf(modulePath);
42
+ if (pkg) packages.set(pkg.name, pkg);
43
+ }
44
+ const entries = [...packages.values()]
45
+ .sort((a, b) => a.name.localeCompare(b.name))
46
+ .map(licenceOf)
47
+ .map(
48
+ l =>
49
+ `${'='.repeat(72)}\n${l.name} ${l.version}\n${'='.repeat(72)}\n\n${l.text.trim()}\n`,
50
+ );
51
+ return `${title}\n\n${entries.join('\n')}`;
52
+ }
@@ -120,11 +120,12 @@ export function parseGameSupportReadme(markdown) {
120
120
  }
121
121
  function checkMapAgainstCode(support, ctx, problems) {
122
122
  const hasMapCap = ctx.sources.some(s => s.capabilities.includes('map_2d'));
123
- if ((support.map.status === 'done' || support.map.status === 'partial') && !hasMapCap) {
123
+ const drawn = support.map.status === 'done' || support.map.status === 'partial';
124
+ if (drawn && !hasMapCap) {
124
125
  problems.push(`map.status is "${support.map.status}" but no source declares map_2d`);
125
126
  }
126
127
  /* "partial" means some map is drawn: a live position alone leaves the game owed a map */
127
- if (support.map.status !== 'open' && support.map.geometry === 'none') {
128
+ if (drawn && support.map.geometry === 'none') {
128
129
  problems.push(`map.status is "${support.map.status}" but map.geometry is "none": nothing is drawn, so it stays "open"`);
129
130
  }
130
131
  if (support.map.status === 'open' && hasMapCap) {
@@ -2,6 +2,7 @@ export * from './quickjs-guest.js';
2
2
  export * from './live-sandbox.js';
3
3
  export * from './asset-sandbox.js';
4
4
  export * from './inspect.js';
5
+ export * from './plugin-registry.js';
5
6
  export * from './verify.js';
6
7
  export * from './addresses.js';
7
8
  export * from './udp-ports.js';
package/lib/host/index.js CHANGED
@@ -6,6 +6,7 @@ export * from './quickjs-guest.js';
6
6
  export * from './live-sandbox.js';
7
7
  export * from './asset-sandbox.js';
8
8
  export * from './inspect.js';
9
+ export * from './plugin-registry.js';
9
10
  export * from './verify.js';
10
11
  export * from './addresses.js';
11
12
  export * from './udp-ports.js';
@@ -16,6 +16,8 @@ export interface InspectedPlugin {
16
16
  code: string;
17
17
  games: string[];
18
18
  } | null;
19
+ /** the games it carries registry data for (`registry/games/<gameId>/`) */
20
+ registryGames: string[];
19
21
  /** things that don't stop it loading (built for other core versions) */
20
22
  warnings: string[];
21
23
  }
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { PluginManifestSchema, SDK_API } from '../plugin-manifest.js';
5
5
  import { AssetSandbox, InputSet } from './asset-sandbox.js';
6
6
  import { PluginSandbox } from './live-sandbox.js';
7
+ import { inspectPluginRegistry } from './plugin-registry.js';
7
8
  export function readPluginManifest(dir) {
8
9
  let raw;
9
10
  try {
@@ -82,6 +83,9 @@ export function inspectPlugin(quickJs, dir, manifest, opts) {
82
83
  .find(reason => reason !== null);
83
84
  if (bad)
84
85
  return bad;
86
+ const registry = inspectPluginRegistry(dir, manifest);
87
+ if (typeof registry === 'string')
88
+ return registry;
85
89
  const warnings = manifest.testedWith.includes(opts.coreVersion)
86
90
  ? []
87
91
  : [
@@ -93,5 +97,5 @@ export function inspectPlugin(quickJs, dir, manifest, opts) {
93
97
  const assets = loadAssets(quickJs, dir, manifest, opts.log);
94
98
  if (typeof assets === 'string')
95
99
  return assets;
96
- return { manifest, live, assets, warnings };
100
+ return { manifest, live, assets, registryGames: registry.games, warnings };
97
101
  }
@@ -0,0 +1,11 @@
1
+ import type { PluginManifest } from '../plugin-manifest.js';
2
+ export declare const REGISTRY_DIR = "registry";
3
+ /** Why an SVG can't be served (a tag outside the set, a script hook, a bare `&`), or null. */
4
+ export declare function svgProblem(text: string): string | null;
5
+ /**
6
+ * The games a built (or source) plugin folder carries registry data for, or why it can't be used:
7
+ * a game its manifest doesn't list, a file that fails its schema, an SVG outside the safe set.
8
+ */
9
+ export declare function inspectPluginRegistry(dir: string, manifest: PluginManifest): {
10
+ games: string[];
11
+ } | string;
@@ -0,0 +1,130 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { GameManifestSchema, HintGraphSchema } from '../registry.js';
4
+ /*
5
+ * A plugin's registry data: the committed, simplified map data for its games, served by the core
6
+ * at `/registry/games/<gameId>/…` (docs/plugin-architecture.md). In a plugin folder and in its
7
+ * build it is
8
+ *
9
+ * registry/games/<gameId>/manifest.json GameManifestSchema (a layer's `svg` is
10
+ * `games/<gameId>/maps/<file>.svg`)
11
+ * registry/games/<gameId>/hints.json HintGraphSchema, optional
12
+ * registry/games/<gameId>/maps/*.svg schematic floorplans, from a fixed set of tags
13
+ *
14
+ * Nothing else. It is untrusted input, so the core checks it here before serving any of it.
15
+ */
16
+ export const REGISTRY_DIR = 'registry';
17
+ /* Shapes and text only: the web app draws these, so no script, links, styles or embedded content. */
18
+ const SVG_TAGS = new Set([
19
+ 'svg',
20
+ 'g',
21
+ 'path',
22
+ 'polygon',
23
+ 'polyline',
24
+ 'rect',
25
+ 'circle',
26
+ 'line',
27
+ 'text',
28
+ 'title',
29
+ ]);
30
+ const UNSAFE_SVG = [/\son[a-z]+\s*=/i, /javascript:/i, /<!DOCTYPE/i, /<!ENTITY/i, /href\s*=/i];
31
+ const BARE_AMPERSAND = /&(?!(?:amp|lt|gt|quot|apos|#\d+|#x[0-9a-fA-F]+);)/;
32
+ /** Why an SVG can't be served (a tag outside the set, a script hook, a bare `&`), or null. */
33
+ export function svgProblem(text) {
34
+ const unsafe = UNSAFE_SVG.find(re => re.test(text));
35
+ if (unsafe)
36
+ return `matches ${unsafe.source}`;
37
+ if (BARE_AMPERSAND.test(text))
38
+ return 'has a bare &';
39
+ for (const m of text.matchAll(/<\/?([a-zA-Z][\w:.-]*)/g)) {
40
+ const tag = m[1] ?? '';
41
+ if (!SVG_TAGS.has(tag))
42
+ return `has a <${tag}> tag`;
43
+ }
44
+ return null;
45
+ }
46
+ function readJson(file, schema) {
47
+ let raw;
48
+ try {
49
+ raw = JSON.parse(fs.readFileSync(file, 'utf8'));
50
+ }
51
+ catch (e) {
52
+ return `unreadable (${e instanceof Error ? e.message : String(e)})`;
53
+ }
54
+ const parsed = schema.safeParse(raw);
55
+ if (parsed.success)
56
+ return parsed.data;
57
+ return parsed.error.issues.map(i => `${i.path.join('.')} ${i.message}`).join('; ');
58
+ }
59
+ const entriesOf = (dir) => fs.readdirSync(dir, { withFileTypes: true });
60
+ /** Why a game's maps can't be served (an unsafe SVG, a layer naming one that isn't there), or null. */
61
+ function mapsProblem(dir, manifest) {
62
+ const mapsDir = path.join(dir, 'maps');
63
+ const maps = fs.existsSync(mapsDir) ? entriesOf(mapsDir) : [];
64
+ for (const e of maps) {
65
+ if (!e.isFile() || !e.name.endsWith('.svg'))
66
+ return `unexpected maps/${e.name}`;
67
+ const problem = svgProblem(fs.readFileSync(path.join(mapsDir, e.name), 'utf8'));
68
+ if (problem)
69
+ return `maps/${e.name} ${problem}`;
70
+ }
71
+ const svgs = new Set(maps.map(e => `games/${manifest.gameId}/maps/${e.name}`));
72
+ for (const [locationId, location] of Object.entries(manifest.locations)) {
73
+ const missing = location.map?.layers.find(layer => !svgs.has(layer.svg));
74
+ if (missing) {
75
+ return `${locationId}'s layer ${missing.id} names ${missing.svg}, which isn't in its maps/`;
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+ /** Why one game's folder can't be served, or null. */
81
+ function gameProblem(gamesDir, gameId) {
82
+ const dir = path.join(gamesDir, gameId);
83
+ const stray = entriesOf(dir)
84
+ .filter(e => e.isDirectory() ? e.name !== 'maps' : !['manifest.json', 'hints.json'].includes(e.name))
85
+ .map(e => e.name);
86
+ if (stray.length)
87
+ return `unexpected ${stray.join(', ')}`;
88
+ const manifest = readJson(path.join(dir, 'manifest.json'), GameManifestSchema);
89
+ if (typeof manifest === 'string')
90
+ return `manifest.json: ${manifest}`;
91
+ if (manifest.gameId !== gameId)
92
+ return `manifest.json says it is ${manifest.gameId}`;
93
+ if (fs.existsSync(path.join(dir, 'hints.json'))) {
94
+ const hints = readJson(path.join(dir, 'hints.json'), HintGraphSchema);
95
+ if (typeof hints === 'string')
96
+ return `hints.json: ${hints}`;
97
+ if (hints.gameId !== gameId)
98
+ return `hints.json says it is ${hints.gameId}`;
99
+ }
100
+ return mapsProblem(dir, manifest);
101
+ }
102
+ /**
103
+ * The games a built (or source) plugin folder carries registry data for, or why it can't be used:
104
+ * a game its manifest doesn't list, a file that fails its schema, an SVG outside the safe set.
105
+ */
106
+ export function inspectPluginRegistry(dir, manifest) {
107
+ const root = path.join(dir, REGISTRY_DIR);
108
+ if (!fs.existsSync(root))
109
+ return { games: [] };
110
+ const stray = entriesOf(root)
111
+ .filter(e => !(e.isDirectory() && e.name === 'games'))
112
+ .map(e => e.name);
113
+ if (stray.length)
114
+ return `registry: unexpected ${stray.join(', ')}`;
115
+ const gamesDir = path.join(root, 'games');
116
+ const listed = new Set(manifest.games.map(g => g.id));
117
+ const games = [];
118
+ for (const e of entriesOf(gamesDir)) {
119
+ if (!e.isDirectory())
120
+ return `registry: unexpected games/${e.name}`;
121
+ if (!listed.has(e.name)) {
122
+ return `registry: carries ${e.name}, which its manifest doesn't list`;
123
+ }
124
+ const problem = gameProblem(gamesDir, e.name);
125
+ if (problem)
126
+ return `registry/games/${e.name}: ${problem}`;
127
+ games.push(e.name);
128
+ }
129
+ return { games: games.sort() };
130
+ }
package/lib/pack.d.ts CHANGED
@@ -990,7 +990,7 @@ export declare const PackDataSchema: z.ZodObject<{
990
990
  }>;
991
991
  export type PackData = z.infer<typeof PackDataSchema>;
992
992
  /**
993
- * Everything about one game, as a plugin exports it (games/<id>/pack.ts): its data, plus code the
993
+ * Everything about one game, as a plugin exports it from its live.ts: its data, plus code the
994
994
  * daemon runs over the live state to produce `PackViews`.
995
995
  */
996
996
  export interface GamePack extends PackData {
@@ -43,7 +43,7 @@ export interface BuildSupport {
43
43
  region: string;
44
44
  ramAnchor?: N64RamAnchor;
45
45
  }
46
- /** A memory-read state source for one game. Packs export theirs from games/<id>/source.ts. */
46
+ /** A memory-read state source for one game. A plugin lists its sources in its live.ts. */
47
47
  export interface GamePlugin {
48
48
  readonly gameId: string;
49
49
  readonly stateSchemaVersion: number;
@@ -96,6 +96,9 @@ export declare const PluginManifestSchema: z.ZodObject<{
96
96
  };
97
97
  id: string;
98
98
  name: string;
99
+ version: string;
100
+ sdkApi: number;
101
+ testedWith: string[];
99
102
  games: {
100
103
  id: string;
101
104
  title: string;
@@ -106,9 +109,6 @@ export declare const PluginManifestSchema: z.ZodObject<{
106
109
  }[];
107
110
  aliases?: string[] | undefined;
108
111
  }[];
109
- version: string;
110
- sdkApi: number;
111
- testedWith: string[];
112
112
  extract?: {
113
113
  file: string;
114
114
  sha256: string;
@@ -124,6 +124,8 @@ export declare const PluginManifestSchema: z.ZodObject<{
124
124
  };
125
125
  id: string;
126
126
  name: string;
127
+ version: string;
128
+ sdkApi: number;
127
129
  games: {
128
130
  id: string;
129
131
  title: string;
@@ -134,8 +136,6 @@ export declare const PluginManifestSchema: z.ZodObject<{
134
136
  subfolders?: string[] | undefined;
135
137
  }[] | undefined;
136
138
  }[];
137
- version: string;
138
- sdkApi: number;
139
139
  extract?: {
140
140
  file: string;
141
141
  sha256: string;
@@ -77,6 +77,7 @@ export declare const PluginViewSchema: z.ZodObject<{
77
77
  }, "strip", z.ZodTypeAny, {
78
78
  id: string;
79
79
  name: string;
80
+ version: string;
80
81
  games: {
81
82
  id: string;
82
83
  title: string;
@@ -85,7 +86,6 @@ export declare const PluginViewSchema: z.ZodObject<{
85
86
  folder: string;
86
87
  }[];
87
88
  }[];
88
- version: string;
89
89
  untested: boolean;
90
90
  features: {
91
91
  assets: {
@@ -100,6 +100,7 @@ export declare const PluginViewSchema: z.ZodObject<{
100
100
  }, {
101
101
  id: string;
102
102
  name: string;
103
+ version: string;
103
104
  games: {
104
105
  id: string;
105
106
  title: string;
@@ -108,7 +109,6 @@ export declare const PluginViewSchema: z.ZodObject<{
108
109
  folder: string;
109
110
  }[];
110
111
  }[];
111
- version: string;
112
112
  untested: boolean;
113
113
  features: {
114
114
  assets: {
@@ -267,6 +267,7 @@ export declare const PluginsResponseSchema: z.ZodObject<{
267
267
  }, "strip", z.ZodTypeAny, {
268
268
  id: string;
269
269
  name: string;
270
+ version: string;
270
271
  games: {
271
272
  id: string;
272
273
  title: string;
@@ -275,7 +276,6 @@ export declare const PluginsResponseSchema: z.ZodObject<{
275
276
  folder: string;
276
277
  }[];
277
278
  }[];
278
- version: string;
279
279
  untested: boolean;
280
280
  features: {
281
281
  assets: {
@@ -290,6 +290,7 @@ export declare const PluginsResponseSchema: z.ZodObject<{
290
290
  }, {
291
291
  id: string;
292
292
  name: string;
293
+ version: string;
293
294
  games: {
294
295
  id: string;
295
296
  title: string;
@@ -298,7 +299,6 @@ export declare const PluginsResponseSchema: z.ZodObject<{
298
299
  folder: string;
299
300
  }[];
300
301
  }[];
301
- version: string;
302
302
  untested: boolean;
303
303
  features: {
304
304
  assets: {
@@ -379,6 +379,7 @@ export declare const PluginsResponseSchema: z.ZodObject<{
379
379
  plugins: {
380
380
  id: string;
381
381
  name: string;
382
+ version: string;
382
383
  games: {
383
384
  id: string;
384
385
  title: string;
@@ -387,7 +388,6 @@ export declare const PluginsResponseSchema: z.ZodObject<{
387
388
  folder: string;
388
389
  }[];
389
390
  }[];
390
- version: string;
391
391
  untested: boolean;
392
392
  features: {
393
393
  assets: {
@@ -423,6 +423,7 @@ export declare const PluginsResponseSchema: z.ZodObject<{
423
423
  plugins: {
424
424
  id: string;
425
425
  name: string;
426
+ version: string;
426
427
  games: {
427
428
  id: string;
428
429
  title: string;
@@ -431,7 +432,6 @@ export declare const PluginsResponseSchema: z.ZodObject<{
431
432
  folder: string;
432
433
  }[];
433
434
  }[];
434
- version: string;
435
435
  untested: boolean;
436
436
  features: {
437
437
  assets: {
package/lib/registry.d.ts CHANGED
@@ -1673,87 +1673,6 @@ export declare const HintGraphSchema: z.ZodObject<{
1673
1673
  }[];
1674
1674
  }>;
1675
1675
  export type HintGraph = z.infer<typeof HintGraphSchema>;
1676
- export declare const RegistryIndexSchema: z.ZodObject<{
1677
- schemaVersion: z.ZodLiteral<1>;
1678
- games: z.ZodRecord<z.ZodString, z.ZodObject<{
1679
- title: z.ZodString;
1680
- subtitle: z.ZodOptional<z.ZodString>;
1681
- manifest: z.ZodString;
1682
- hints: z.ZodString;
1683
- nativeBuilds: z.ZodArray<z.ZodObject<{
1684
- buildId: z.ZodString;
1685
- region: z.ZodString;
1686
- platform: z.ZodString;
1687
- executableHint: z.ZodString;
1688
- }, "strip", z.ZodTypeAny, {
1689
- buildId: string;
1690
- region: string;
1691
- platform: string;
1692
- executableHint: string;
1693
- }, {
1694
- buildId: string;
1695
- region: string;
1696
- platform: string;
1697
- executableHint: string;
1698
- }>, "many">;
1699
- romIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1700
- }, "strip", z.ZodTypeAny, {
1701
- title: string;
1702
- hints: string;
1703
- manifest: string;
1704
- nativeBuilds: {
1705
- buildId: string;
1706
- region: string;
1707
- platform: string;
1708
- executableHint: string;
1709
- }[];
1710
- subtitle?: string | undefined;
1711
- romIds?: string[] | undefined;
1712
- }, {
1713
- title: string;
1714
- hints: string;
1715
- manifest: string;
1716
- nativeBuilds: {
1717
- buildId: string;
1718
- region: string;
1719
- platform: string;
1720
- executableHint: string;
1721
- }[];
1722
- subtitle?: string | undefined;
1723
- romIds?: string[] | undefined;
1724
- }>>;
1725
- }, "strip", z.ZodTypeAny, {
1726
- schemaVersion: 1;
1727
- games: Record<string, {
1728
- title: string;
1729
- hints: string;
1730
- manifest: string;
1731
- nativeBuilds: {
1732
- buildId: string;
1733
- region: string;
1734
- platform: string;
1735
- executableHint: string;
1736
- }[];
1737
- subtitle?: string | undefined;
1738
- romIds?: string[] | undefined;
1739
- }>;
1740
- }, {
1741
- schemaVersion: 1;
1742
- games: Record<string, {
1743
- title: string;
1744
- hints: string;
1745
- manifest: string;
1746
- nativeBuilds: {
1747
- buildId: string;
1748
- region: string;
1749
- platform: string;
1750
- executableHint: string;
1751
- }[];
1752
- subtitle?: string | undefined;
1753
- romIds?: string[] | undefined;
1754
- }>;
1755
- }>;
1756
- export type RegistryIndex = z.infer<typeof RegistryIndexSchema>;
1757
1676
  /**
1758
1677
  * Locations extracted on the player's PC from their own game files (`local-assets/<id>/manifest.json`),
1759
1678
  * e.g. Doom maps from the player's WAD. Never committed (data-licensing.md).
package/lib/registry.js CHANGED
@@ -119,22 +119,6 @@ export const HintGraphSchema = z.object({
119
119
  gameId: z.string(),
120
120
  hints: z.array(HintNodeSchema),
121
121
  });
122
- export const RegistryIndexSchema = z.object({
123
- schemaVersion: z.literal(1),
124
- games: z.record(z.string(), z.object({
125
- title: z.string(),
126
- subtitle: z.string().optional(),
127
- manifest: z.string(),
128
- hints: z.string(),
129
- nativeBuilds: z.array(z.object({
130
- buildId: z.string(),
131
- region: z.string(),
132
- platform: z.string(),
133
- executableHint: z.string(),
134
- })),
135
- romIds: z.array(z.string()).optional(),
136
- })),
137
- });
138
122
  /**
139
123
  * Locations extracted on the player's PC from their own game files (`local-assets/<id>/manifest.json`),
140
124
  * e.g. Doom maps from the player's WAD. Never committed (data-licensing.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gameslate/sdk",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -316,6 +316,29 @@ Every image of a game uses one format. In the sandbox:
316
316
  - **Data licensing:** ship the extractor, never its output. Textures, models and renders are
317
317
  built on the player's machine and never committed.
318
318
 
319
+ ### Registry data: what the plugin commits
320
+
321
+ A plugin carries its games' committed map data in `plugin/registry/games/<gameId>/` (sdk 0.3.17):
322
+ `manifest.json` (`GameManifestSchema`), optional `hints.json` (`HintGraphSchema`) and
323
+ `maps/*.svg`, which a layer names as `games/<gameId>/maps/<file>.svg`. The build copies the folder
324
+ into the bundle, and the core serves it at `/registry/games/<gameId>/…`. `gameslate-plugin
325
+ validate` and the core's loader refuse a plugin whose registry carries a game its manifest doesn't
326
+ list, a file outside that layout, a file failing its schema, a layer naming a missing SVG, or an
327
+ SVG with anything but `svg g path polygon polyline rect circle line text title`. Two plugins
328
+ carrying the same game stop the core.
329
+
330
+ Commit only simplified data you produced: schematic SVGs, pins, affines, location and item names,
331
+ your own hint prose. Game text (objective and dialogue strings from the game's language files) is
332
+ the publisher's: generate it on the player's PC with an asset extractor (a local
333
+ `local-assets/<id>/manifest.json` merges over the registry). When you can't tell which side a
334
+ file is on (floorplans traced from the game's collision, spawn positions read from its level
335
+ files), git-ignore `plugin/registry/` with a note saying why, and ask before committing it; tests
336
+ that need it fail loudly on a fresh clone rather than skipping.
337
+
338
+ The build also writes `THIRD_PARTY_LICENSES.txt` (the licence of every npm package the code
339
+ bundles; a package without a licence file fails the build) and copies the repo's
340
+ `THIRD_PARTY_NOTICES.md` into the plugin, so a release carries the notices of what it ships.
341
+
319
342
  ### Maps from a ROM (Mario Kart 64 in gameslate-n64 is the worked example)
320
343
 
321
344
  1. **Follow the game's own load path** in the decomp: the table that names each level's data
@@ -336,13 +359,11 @@ Every image of a game uses one format. In the sandbox:
336
359
  player back on the unmirrored map.
337
360
  6. **Look at it.** Render the SVGs (`rsvg-convert -w 500 map.svg -o map.png`) and compare with
338
361
  the game's own minimap.
339
- 7. **A game needs a registry entry** (`gameslate-registry/games/<id>/manifest.json`: title,
362
+ 7. **A game needs a registry entry** (`plugin/registry/games/<id>/manifest.json`: title,
340
363
  capabilities with `map_2d`, difficulties, item names; locations empty) before the web app shows
341
- extracted maps. Doom's is the pattern. Don't hand-edit `index.json` and `channels.json`: write a
342
- spec (id, title, subtitle, romIds, capabilities, locations) from the plugin's own data and run
343
- the gameslate repo's `yarn vite-node tools/registry-add-game.ts <spec.json>`, which writes the
344
- manifest, keeps any hints, sets the index entry and rehashes channels with the registry
345
- builders' own writers (gameslate-n64's `tools/registry-specs.ts` writes its specs).
364
+ extracted maps. Doom's (gameslate-idtech1) is the pattern; gameslate-n64's
365
+ `tools/registry-specs.ts` writes its games' entries from the plugin's own data, and a test fails
366
+ when the committed files drift from it. See "Registry data" below.
346
367
  8. **No mesh traced? Map what the game itself navigates by.** Wave Race 64's course meshes sit in
347
368
  unsplit MIO0 blobs, but its buoy and AI node lists are plain 8-byte records (x, z, type,
348
369
  angle) in a raw course file, one list per difficulty: they give the course's shape, the start
@@ -849,3 +870,17 @@ the plugin repos) in the same change as the fix. The next game should not have t
849
870
  to the cache (2026-12-05).
850
871
  - **Env-var names for ROM-gated tests are per game:** `BH_ROM` was taken by Body Harvest when
851
872
  Bomberman Hero needed one (2026-12-05).
873
+ - **A mutation never uses an empty replacement.** Reverting it matches the empty string at offset
874
+ 0 and corrupts the file. Replace with a comment, and byte-compare with a backup afterwards
875
+ (2026-12-05).
876
+ - **After an sdk publish, npm lags several minutes.** `yarn up` says "No candidates found" until
877
+ `yarn cache clean --mirror`, even once npm serves it. Write the range as `^X.Y.Z`: `yarn up
878
+ pkg@X.Y.Z` pins exactly (2026-12-05).
879
+ - **A check names the statuses it means**, not `!== 'open'`: sdk 0.3.15 refused `puzzle_panel`
880
+ maps that way (2026-12-05).
881
+ - **Keep game text out of committed tables.** A builder that copies objective labels from the
882
+ game's language files into a committed table or manifest commits the publisher's text. Commit
883
+ ids only ("Objective 1", or the bank and entry number), and join the real labels by id from a
884
+ file on the player's PC or an asset extractor. Then grep your hint prose for quoted game strings:
885
+ Perfect Dark's hints quoted an objective verbatim, and MM's objective labels carried the boss
886
+ title cards (2026-12-05).
@@ -256,9 +256,10 @@ Inventory, Missions and Ref in turn) or `{ "url": …, "tabs": ["Inventory"] }`.
256
256
  counters, the item lit in a grid, the mission list, the map's arrow against the game's minimap.
257
257
  A local daemon's token is in its config:
258
258
  `export GAMESLATE_TOKEN=$(node -p "require('$HOME/.config/gameslate/config.json').pairingToken")`
259
- (don't paste it anywhere else). To see extracted maps, run the daemon with `GAMESLATE_LOCAL_ASSETS_DIR` (and
260
- `GAMESLATE_REGISTRY_DIR` for a registry entry not deployed yet).
261
- "Couldn't load this game's map data from the registry" means the game has no registry entry yet.
259
+ (don't paste it anywhere else). To see extracted maps, run the daemon with `GAMESLATE_LOCAL_ASSETS_DIR`; a registry entry
260
+ not deployed yet comes with the plugin build (`GAMESLATE_PLUGINS_DIR` pointing at your `dist/`).
261
+ "Couldn't load this game's map data from the registry" means the plugin carries no
262
+ `registry/games/<id>/manifest.json` for the game.
262
263
 
263
264
  For values the route doesn't show, drive to them: Luigi Raceway's first row of item boxes is on
264
265
  the start straight, so holding A long enough fetches an item to check the held-item read.