@debuffjp/cli 0.0.0-stage → 0.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/README.md +86 -2
- package/aseprite/new-font.lua +31 -0
- package/bin/debuff.js +3 -0
- package/client.d.ts +3 -0
- package/dist/agent-link.d.ts +28 -0
- package/dist/agent-link.d.ts.map +1 -0
- package/dist/agent-link.js +122 -0
- package/dist/agent-link.js.map +1 -0
- package/dist/assets/aseprite.d.ts +29 -0
- package/dist/assets/aseprite.d.ts.map +1 -0
- package/dist/assets/aseprite.js +107 -0
- package/dist/assets/aseprite.js.map +1 -0
- package/dist/assets/atlas.d.ts +58 -0
- package/dist/assets/atlas.d.ts.map +1 -0
- package/dist/assets/atlas.js +164 -0
- package/dist/assets/atlas.js.map +1 -0
- package/dist/assets/builtin.d.ts +5 -0
- package/dist/assets/builtin.d.ts.map +1 -0
- package/dist/assets/builtin.js +47 -0
- package/dist/assets/builtin.js.map +1 -0
- package/dist/assets/command.d.ts +4 -0
- package/dist/assets/command.d.ts.map +1 -0
- package/dist/assets/command.js +35 -0
- package/dist/assets/command.js.map +1 -0
- package/dist/assets/compile.d.ts +29 -0
- package/dist/assets/compile.d.ts.map +1 -0
- package/dist/assets/compile.js +209 -0
- package/dist/assets/compile.js.map +1 -0
- package/dist/assets/index.d.ts +6 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/index.js +6 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +257 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +53 -0
- package/dist/config.js.map +1 -0
- package/dist/fuzz.d.ts +43 -0
- package/dist/fuzz.d.ts.map +1 -0
- package/dist/fuzz.js +229 -0
- package/dist/fuzz.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +35 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +37 -0
- package/dist/inspect.js.map +1 -0
- package/dist/plugin.d.ts +146 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/report.d.ts +26 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +80 -0
- package/dist/report.js.map +1 -0
- package/dist/scenario/browser.d.ts +12 -0
- package/dist/scenario/browser.d.ts.map +1 -0
- package/dist/scenario/browser.js +59 -0
- package/dist/scenario/browser.js.map +1 -0
- package/dist/scenario/index.d.ts +5 -0
- package/dist/scenario/index.d.ts.map +1 -0
- package/dist/scenario/index.js +4 -0
- package/dist/scenario/index.js.map +1 -0
- package/dist/scenario/run.d.ts +14 -0
- package/dist/scenario/run.d.ts.map +1 -0
- package/dist/scenario/run.js +255 -0
- package/dist/scenario/run.js.map +1 -0
- package/dist/scenario/schema.d.ts +8 -0
- package/dist/scenario/schema.d.ts.map +1 -0
- package/dist/scenario/schema.js +23 -0
- package/dist/scenario/schema.js.map +1 -0
- package/dist/scenario/types.d.ts +103 -0
- package/dist/scenario/types.d.ts.map +1 -0
- package/dist/scenario/types.js +2 -0
- package/dist/scenario/types.js.map +1 -0
- package/dist/vite-plugin.d.ts +18 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +122 -0
- package/dist/vite-plugin.js.map +1 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +25 -0
- package/dist/vite.js.map +1 -0
- package/package.json +71 -4
- package/schema/scenario.schema.json +120 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { extname, join, resolve, sep } from "node:path";
|
|
3
|
+
import { attachAgentLink } from "./agent-link.js";
|
|
4
|
+
import { compileAssets } from "./assets/compile.js";
|
|
5
|
+
export const ASSETS_DIR = "assets";
|
|
6
|
+
const URL_PREFIX = `/${ASSETS_DIR}/`;
|
|
7
|
+
const MIME = {
|
|
8
|
+
".png": "image/png",
|
|
9
|
+
".jpg": "image/jpeg",
|
|
10
|
+
".jpeg": "image/jpeg",
|
|
11
|
+
".webp": "image/webp",
|
|
12
|
+
".avif": "image/avif",
|
|
13
|
+
".gif": "image/gif",
|
|
14
|
+
".json": "application/json",
|
|
15
|
+
".ogg": "audio/ogg",
|
|
16
|
+
".opus": "audio/ogg",
|
|
17
|
+
".mp3": "audio/mpeg",
|
|
18
|
+
".wav": "audio/wav",
|
|
19
|
+
".m4a": "audio/mp4",
|
|
20
|
+
".txt": "text/plain; charset=utf-8",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Serves `<root>/assets/` through the asset pipeline: `/assets/manifest.json` and every file the
|
|
24
|
+
* manifest references, in dev from memory and in builds as emitted files. Files the manifest doesn't
|
|
25
|
+
* reference are not served or shipped.
|
|
26
|
+
*/
|
|
27
|
+
export function debuff(options = {}) {
|
|
28
|
+
let root = process.cwd();
|
|
29
|
+
let current;
|
|
30
|
+
const compile = () => {
|
|
31
|
+
current = compileAssets(root, {
|
|
32
|
+
plugins: options.plugins ?? [],
|
|
33
|
+
...(options.atlas === undefined ? {} : { atlas: options.atlas }),
|
|
34
|
+
}).then((r) => {
|
|
35
|
+
for (const w of r.warnings)
|
|
36
|
+
console.warn(`[debuff] ${w}`);
|
|
37
|
+
return r;
|
|
38
|
+
});
|
|
39
|
+
return current;
|
|
40
|
+
};
|
|
41
|
+
const latest = () => current ?? compile();
|
|
42
|
+
/** Bytes for a URL path under /assets/, or undefined if the manifest doesn't reference it. */
|
|
43
|
+
const read = (r, rel) => {
|
|
44
|
+
if (rel === "manifest.json")
|
|
45
|
+
return Buffer.from(`${JSON.stringify(r.manifest, null, 2)}\n`);
|
|
46
|
+
const generated = r.outputs.get(rel);
|
|
47
|
+
if (generated)
|
|
48
|
+
return generated;
|
|
49
|
+
const referenced = Object.values(r.manifest.assets).some((a) => a.src === `${ASSETS_DIR}/${rel}`);
|
|
50
|
+
const file = resolve(root, ASSETS_DIR, rel);
|
|
51
|
+
const inside = file.startsWith(resolve(root, ASSETS_DIR) + sep);
|
|
52
|
+
return referenced && inside && existsSync(file) ? readFileSync(file) : undefined;
|
|
53
|
+
};
|
|
54
|
+
const core = {
|
|
55
|
+
name: "debuff",
|
|
56
|
+
configResolved(config) {
|
|
57
|
+
root = config.root;
|
|
58
|
+
},
|
|
59
|
+
buildStart() {
|
|
60
|
+
compile();
|
|
61
|
+
},
|
|
62
|
+
configureServer(server) {
|
|
63
|
+
const dir = join(root, ASSETS_DIR);
|
|
64
|
+
server.watcher.add(dir);
|
|
65
|
+
const onChange = (file) => {
|
|
66
|
+
if (!file.startsWith(dir))
|
|
67
|
+
return;
|
|
68
|
+
compile().then(() => server.ws.send({ type: "full-reload" }));
|
|
69
|
+
};
|
|
70
|
+
server.watcher.on("add", onChange);
|
|
71
|
+
server.watcher.on("unlink", onChange);
|
|
72
|
+
server.watcher.on("change", onChange);
|
|
73
|
+
if (options.agentLink)
|
|
74
|
+
attachAgentLink(server, root);
|
|
75
|
+
server.middlewares.use(async (req, res, next) => {
|
|
76
|
+
const url = req.url?.split("?")[0];
|
|
77
|
+
if (!url?.startsWith(URL_PREFIX))
|
|
78
|
+
return next();
|
|
79
|
+
const rel = decodeURIComponent(url.slice(URL_PREFIX.length));
|
|
80
|
+
const body = read(await latest(), rel);
|
|
81
|
+
if (!body) {
|
|
82
|
+
res.statusCode = 404;
|
|
83
|
+
res.end(`[debuff] ${rel} is not in the asset manifest. Run \`debuff assets\` to see what was imported.`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
res.setHeader("Content-Type", MIME[extname(rel).toLowerCase()] ?? "application/octet-stream");
|
|
87
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
88
|
+
res.end(body);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
// Preload the manifest and the default group's images so they download alongside the code,
|
|
92
|
+
// instead of only after the game script has run and asked for them.
|
|
93
|
+
async transformIndexHtml() {
|
|
94
|
+
const r = await latest();
|
|
95
|
+
const images = new Set();
|
|
96
|
+
for (const a of Object.values(r.manifest.assets))
|
|
97
|
+
if (a.type === "image" && !a.group)
|
|
98
|
+
images.add(a.src);
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
tag: "link",
|
|
102
|
+
attrs: { rel: "preload", href: `${ASSETS_DIR}/manifest.json`, as: "fetch", crossorigin: "anonymous" },
|
|
103
|
+
injectTo: "head",
|
|
104
|
+
},
|
|
105
|
+
...[...images].map((href) => ({ tag: "link", attrs: { rel: "preload", href, as: "image" }, injectTo: "head" })),
|
|
106
|
+
];
|
|
107
|
+
},
|
|
108
|
+
async generateBundle() {
|
|
109
|
+
const r = await latest();
|
|
110
|
+
const files = new Set(["manifest.json", ...r.outputs.keys()]);
|
|
111
|
+
for (const a of Object.values(r.manifest.assets))
|
|
112
|
+
files.add(a.src.slice(ASSETS_DIR.length + 1));
|
|
113
|
+
for (const rel of files) {
|
|
114
|
+
const source = read(r, rel);
|
|
115
|
+
if (source)
|
|
116
|
+
this.emitFile({ type: "asset", fileName: `${ASSETS_DIR}/${rel}`, source });
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
return [core, ...(options.plugins ?? []).map((p) => p.vite ?? null)];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=vite-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,e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G,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC9D,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAChG,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;gBACxB,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;gBAC5B,IAAI,MAAM;oBAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YACzF,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InlineConfig, ViteDevServer } from "vite";
|
|
2
|
+
import { type ResolvedConfig } from "./config.js";
|
|
3
|
+
/** Vite config for a debuff project: loads `debuff.config.ts` and respects a project's own vite.config. */
|
|
4
|
+
export declare function viteConfig(root: string, extra?: InlineConfig, config?: ResolvedConfig, link?: {
|
|
5
|
+
agentLink?: boolean;
|
|
6
|
+
}): Promise<InlineConfig>;
|
|
7
|
+
export declare function createDevServer(root: string, options?: {
|
|
8
|
+
port?: number;
|
|
9
|
+
host?: boolean;
|
|
10
|
+
logLevel?: InlineConfig["logLevel"];
|
|
11
|
+
agentLink?: boolean;
|
|
12
|
+
}): Promise<ViteDevServer>;
|
|
13
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAK9D,2GAA2G;AAC3G,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,YAAiB,EACxB,MAAM,CAAC,EAAE,cAAc,EACvB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,YAAY,CAAC,CAUvB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACxG,OAAO,CAAC,aAAa,CAAC,CAaxB"}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
4
|
+
import { debuff } from "./vite-plugin.js";
|
|
5
|
+
const VITE_CONFIG_FILES = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
|
|
6
|
+
/** Vite config for a debuff project: loads `debuff.config.ts` and respects a project's own vite.config. */
|
|
7
|
+
export async function viteConfig(root, extra = {}, config, link = {}) {
|
|
8
|
+
const resolved = config ?? (await loadConfig(root));
|
|
9
|
+
const hasViteConfig = VITE_CONFIG_FILES.some((f) => existsSync(join(root, f)));
|
|
10
|
+
return {
|
|
11
|
+
root,
|
|
12
|
+
// Relative asset URLs, so a build works from any folder (itch.io, GitHub Pages, a /play/ subpath).
|
|
13
|
+
...(hasViteConfig ? {} : { configFile: false, base: "./" }),
|
|
14
|
+
plugins: debuff({ plugins: resolved.plugins, atlas: resolved.atlas, agentLink: link.agentLink ?? false }),
|
|
15
|
+
...extra,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export async function createDevServer(root, options = {}) {
|
|
19
|
+
const { createServer } = await import("vite");
|
|
20
|
+
return createServer(await viteConfig(root, {
|
|
21
|
+
...(options.logLevel ? { logLevel: options.logLevel } : {}),
|
|
22
|
+
server: { port: options.port ?? 5173, strictPort: false, host: options.host ?? false },
|
|
23
|
+
}, undefined, { agentLink: options.agentLink ?? false }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAErG,2GAA2G;AAC3G,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,KAAK,GAAiB,EAAE,EACxB,MAAuB,EACvB,IAAI,GAA4B,EAAE;IAElC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAA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builds with size reports, assets, scenarios",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"game",
|
|
7
|
+
"gamedev",
|
|
8
|
+
"game-engine",
|
|
9
|
+
"2d",
|
|
10
|
+
"html5-game",
|
|
11
|
+
"browser-game",
|
|
12
|
+
"debuff",
|
|
13
|
+
"cli",
|
|
14
|
+
"vite",
|
|
15
|
+
"build",
|
|
16
|
+
"testing",
|
|
17
|
+
"fuzzing"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"homepage": "https://debuff.jp",
|
|
21
|
+
"bugs": "https://github.com/debuffjp/debuff/issues",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/debuffjp/debuff.git",
|
|
25
|
+
"directory": "tooling/cli"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"bin": {
|
|
29
|
+
"debuff": "bin/debuff.js"
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./schema/scenario.schema.json": "./schema/scenario.schema.json",
|
|
39
|
+
"./client": {
|
|
40
|
+
"types": "./client.d.ts"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"bin",
|
|
45
|
+
"aseprite",
|
|
46
|
+
"dist",
|
|
47
|
+
"schema",
|
|
48
|
+
"README.md",
|
|
49
|
+
"client.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -b"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@clack/prompts": "^1.8.1",
|
|
56
|
+
"cac": "^7.1.0",
|
|
57
|
+
"create-debuff": "0.2.0",
|
|
58
|
+
"fast-png": "^8.0.0",
|
|
59
|
+
"picocolors": "^1.1.1",
|
|
60
|
+
"playwright-core": "^1.64.1",
|
|
61
|
+
"vite": "^8.3.4"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^26.6.5"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=22"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public",
|
|
71
|
+
"provenance": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/debuffjp/debuff/main/tooling/cli/schema/scenario.schema.json",
|
|
4
|
+
"title": "debuff scenario",
|
|
5
|
+
"description": "Deterministic gameplay scenario run by `debuff scenario`. Time only advances through `wait` steps.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["steps"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": { "type": "string" },
|
|
11
|
+
"name": { "type": "string", "description": "Defaults to the file name." },
|
|
12
|
+
"page": { "type": "string", "description": "Path to open on the dev server.", "default": "/" },
|
|
13
|
+
"steps": { "type": "array", "items": { "$ref": "#/$defs/step" } }
|
|
14
|
+
},
|
|
15
|
+
"$defs": {
|
|
16
|
+
"point": { "type": "array", "prefixItems": [{ "type": "number" }, { "type": "number" }], "minItems": 2, "maxItems": 2 },
|
|
17
|
+
"comparison": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"description": "All given conditions must hold.",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"eq": { "description": "Deep equality." },
|
|
23
|
+
"gt": { "type": "number" },
|
|
24
|
+
"gte": { "type": "number" },
|
|
25
|
+
"lt": { "type": "number" },
|
|
26
|
+
"lte": { "type": "number" },
|
|
27
|
+
"approx": { "$ref": "#/$defs/point", "description": "[target, tolerance]" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"step": {
|
|
31
|
+
"oneOf": [
|
|
32
|
+
{
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": ["wait"],
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": { "wait": { "type": "integer", "minimum": 0, "description": "Advance N fixed simulation steps." } }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "object",
|
|
40
|
+
"required": ["press"],
|
|
41
|
+
"additionalProperties": false,
|
|
42
|
+
"properties": { "press": { "type": "string", "description": "KeyboardEvent.code to hold, e.g. \"Space\"." } }
|
|
43
|
+
},
|
|
44
|
+
{ "type": "object", "required": ["release"], "additionalProperties": false, "properties": { "release": { "type": "string" } } },
|
|
45
|
+
{
|
|
46
|
+
"type": "object",
|
|
47
|
+
"required": ["tap"],
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"properties": { "tap": { "$ref": "#/$defs/point", "description": "Logical [x, y]." } }
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "object",
|
|
53
|
+
"required": ["pointerDown"],
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"properties": { "pointerDown": { "$ref": "#/$defs/point" } }
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["pointerMove"],
|
|
60
|
+
"additionalProperties": false,
|
|
61
|
+
"properties": { "pointerMove": { "$ref": "#/$defs/point" } }
|
|
62
|
+
},
|
|
63
|
+
{ "type": "object", "required": ["pointerUp"], "additionalProperties": false, "properties": { "pointerUp": { "const": true } } },
|
|
64
|
+
{
|
|
65
|
+
"type": "object",
|
|
66
|
+
"required": ["set"],
|
|
67
|
+
"additionalProperties": false,
|
|
68
|
+
"properties": {
|
|
69
|
+
"set": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"description": "Params to set, keyed \"group.key\".",
|
|
72
|
+
"propertyNames": { "pattern": "^[^.]+\\..+$" },
|
|
73
|
+
"additionalProperties": { "type": ["number", "boolean"] }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "object",
|
|
79
|
+
"required": ["command"],
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"properties": {
|
|
82
|
+
"command": { "type": "string", "description": "A command the game registered with devTools({ commands })." },
|
|
83
|
+
"args": { "type": "array", "description": "Arguments passed to the command." }
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "object",
|
|
88
|
+
"required": ["expect"],
|
|
89
|
+
"additionalProperties": false,
|
|
90
|
+
"properties": {
|
|
91
|
+
"expect": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"description": "Dotted paths into dev state (scene, tick, time, frozen, stats.*, state.*).",
|
|
94
|
+
"additionalProperties": { "$ref": "#/$defs/comparison" }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"type": "object",
|
|
100
|
+
"required": ["capture"],
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"properties": {
|
|
103
|
+
"capture": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"pattern": "^[\\w-]+$",
|
|
106
|
+
"description": "Screenshot name, compared to the per-platform baseline."
|
|
107
|
+
},
|
|
108
|
+
"tolerance": {
|
|
109
|
+
"type": "number",
|
|
110
|
+
"minimum": 0,
|
|
111
|
+
"maximum": 1,
|
|
112
|
+
"default": 0.002,
|
|
113
|
+
"description": "Max fraction of differing pixels."
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|