vibedgames 0.8.1 → 0.10.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 +17 -8
- package/assets/align-framing.py +242 -0
- package/assets/render-model.py +406 -0
- package/assets/tilemap-editor.html +630 -0
- package/dist/THIRD_PARTY_NOTICES.txt +59 -7
- package/dist/chunk-2KVQJKIZ.js +6495 -0
- package/dist/chunk-2SBBKY5C.js +16993 -0
- package/dist/chunk-2ZKS7V72.js +170 -0
- package/dist/{chunk-RAUJA3OY.js → chunk-3HGBIUM5.js} +21 -18
- package/dist/chunk-3UGGMFJJ.js +22 -0
- package/dist/{chunk-I6O4HIDY.js → chunk-42K3BJJH.js} +163 -131
- package/dist/chunk-43P4U7CB.js +104 -0
- package/dist/chunk-4FJXCS3K.js +741 -0
- package/dist/{chunk-NC5XCGYU.js → chunk-4UU622RK.js} +6 -5
- package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
- package/dist/chunk-5YPLKGY3.js +87 -0
- package/dist/chunk-6KXXZXSO.js +475 -0
- package/dist/chunk-7RPLQWR2.js +91 -0
- package/dist/{chunk-C2IRIRAA.js → chunk-A556KALN.js} +15 -14
- package/dist/{chunk-N3XAUFKH.js → chunk-ABTUEIRC.js} +576 -301
- package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
- package/dist/{chunk-QGEITHUP.js → chunk-BN3Q7UEC.js} +22 -19
- package/dist/chunk-BZOMEG3X.js +412 -0
- package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
- package/dist/{chunk-PQDBCZRT.js → chunk-CTY2WZQK.js} +204 -158
- package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
- package/dist/chunk-DB7WVFS7.js +80 -0
- package/dist/chunk-DOOQUFPG.js +73 -0
- package/dist/chunk-E3FJUPLT.js +177 -0
- package/dist/chunk-E7NDOZ27.js +428 -0
- package/dist/chunk-F42QKWBB.js +39 -0
- package/dist/chunk-FXXVXDTW.js +168 -0
- package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
- package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
- package/dist/chunk-GLEW7VJQ.js +45 -0
- package/dist/{chunk-MGIASPED.js → chunk-H2C4QUTG.js} +9 -8
- package/dist/{chunk-HCMTSR7E.js → chunk-HRKVAXNN.js} +21 -17
- package/dist/{chunk-TLRL6FHW.js → chunk-HSMG6U7J.js} +10 -9
- package/dist/chunk-HX5Q63UA.js +48 -0
- package/dist/chunk-HYOXGNWS.js +53 -0
- package/dist/chunk-I5LELJSK.js +22 -0
- package/dist/{chunk-6FZPPUQH.js → chunk-JN4WZCR7.js} +5 -4
- package/dist/{chunk-QJZ72MSY.js → chunk-K36EOII3.js} +7 -6
- package/dist/chunk-KAGVI3CE.js +62 -0
- package/dist/chunk-KJK5CB6E.js +58 -0
- package/dist/chunk-KLFBAFXD.js +25 -0
- package/dist/{chunk-7MKUR7Y3.js → chunk-LONQWRTR.js} +112 -81
- package/dist/chunk-LORGE2NB.js +2484 -0
- package/dist/{chunk-HKA5LBYW.js → chunk-MEAO33XW.js} +22 -19
- package/dist/{chunk-PM5UOIKR.js → chunk-MR5KIFI7.js} +22 -21
- package/dist/{chunk-GCX5KQ6A.js → chunk-N2UHAQXC.js} +18 -11
- package/dist/chunk-NCX6LYNJ.js +117 -0
- package/dist/chunk-OGX4DKIS.js +215 -0
- package/dist/chunk-OPUCUUID.js +41 -0
- package/dist/chunk-Q2QC6KAZ.js +132 -0
- package/dist/{chunk-2GL2WJZX.js → chunk-Q3XQPNF6.js} +14 -14
- package/dist/{chunk-RYFO3ZPO.js → chunk-Q5NZNXJE.js} +15 -12
- package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
- package/dist/chunk-QLCVLCPM.js +126 -0
- package/dist/chunk-R2WVORGD.js +91 -0
- package/dist/chunk-RKS7SI5L.js +64 -0
- package/dist/{chunk-4BGCA3W7.js → chunk-RPJR3S5S.js} +32 -18
- package/dist/chunk-RPSUFZAG.js +3307 -0
- package/dist/chunk-RRI23NK2.js +40 -0
- package/dist/chunk-S7HYWITX.js +57 -0
- package/dist/chunk-SBXCK2I2.js +48 -0
- package/dist/chunk-SUSX3QIA.js +62 -0
- package/dist/{chunk-PHEDW6C7.js → chunk-SXYQL4GK.js} +16 -7
- package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
- package/dist/chunk-TXOE5UY5.js +72 -0
- package/dist/chunk-U6DTE5IX.js +124 -0
- package/dist/chunk-UPHB5HWO.js +115 -0
- package/dist/chunk-UQ7VO6B3.js +91 -0
- package/dist/chunk-VB4WLJR2.js +47 -0
- package/dist/{chunk-FNYBZNW2.js → chunk-VIEKOGKG.js} +21 -3
- package/dist/{chunk-QIVCBUYD.js → chunk-VZEJ2ZHE.js} +18 -18
- package/dist/chunk-X75Y7LUW.js +126 -0
- package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
- package/dist/chunk-ZHLPE6LI.js +71 -0
- package/dist/index.js +48 -34
- package/package.json +32 -16
- package/templates/none/src/main.ts +4 -0
- package/templates/none/vite.config.ts +0 -2
- package/templates/phaser/src/main.ts +0 -1
- package/templates/phaser/src/scenes/game-scene.ts +10 -8
- package/templates/phaser/vite.config.ts +0 -2
- package/templates/react-r3f/src/app.tsx +3 -1
- package/templates/react-r3f/src/main.tsx +1 -0
- package/templates/react-r3f/vite.config.ts +0 -2
- package/templates/threejs/src/main.ts +10 -1
- package/templates/threejs/vite.config.ts +0 -2
- package/LICENSE +0 -21
- package/dist/chunk-AYJQVZXY.js +0 -39
- package/dist/chunk-J6PKNPI2.js +0 -26
- package/dist/chunk-MJQSHP3Y.js +0 -415
- package/dist/chunk-MYFLYNPO.js +0 -68
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_cross_spawn
|
|
9
|
+
} from "./chunk-5535KDYI.js";
|
|
10
|
+
import {
|
|
11
|
+
consola
|
|
12
|
+
} from "./chunk-D2RF35HJ.js";
|
|
13
|
+
import {
|
|
14
|
+
ASSETS_DIR
|
|
15
|
+
} from "./chunk-YNCYMWER.js";
|
|
16
|
+
import {
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-GKDUYJ7R.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/asset/python.ts
|
|
21
|
+
import path from "node:path";
|
|
22
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
23
|
+
var pythonScript = (file) => (argv) => {
|
|
24
|
+
const result = import_cross_spawn.default.sync(
|
|
25
|
+
"uv",
|
|
26
|
+
["run", "--python", "3.12", "--no-project", path.join(ASSETS_DIR, file), ...argv],
|
|
27
|
+
{ stdio: "inherit" }
|
|
28
|
+
);
|
|
29
|
+
if (result.error !== void 0 && result.error !== null) {
|
|
30
|
+
consola.error(
|
|
31
|
+
`Couldn't start uv (${result.error.message}). Install it: https://docs.astral.sh/uv/getting-started/installation/`
|
|
32
|
+
);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
process.exit(result.status ?? 1);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
pythonScript
|
|
40
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
Bitmap,
|
|
9
|
+
DEFAULT_SNAP_CONFIG,
|
|
10
|
+
fail,
|
|
11
|
+
failUsage,
|
|
12
|
+
getInt,
|
|
13
|
+
main,
|
|
14
|
+
parseArgs,
|
|
15
|
+
snapSheet
|
|
16
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
17
|
+
import "./chunk-2SBBKY5C.js";
|
|
18
|
+
import "./chunk-GKDUYJ7R.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/asset/pixel-snapper-sheet.ts
|
|
21
|
+
var run = (argv) => {
|
|
22
|
+
main(() => {
|
|
23
|
+
const args = parseArgs([...argv], {
|
|
24
|
+
values: ["cols", "k-colors", "rows", "seed"]
|
|
25
|
+
});
|
|
26
|
+
const [input = "", output = ""] = args.positionals;
|
|
27
|
+
if (input === "" || output === "") {
|
|
28
|
+
failUsage("Usage: vg asset pixel-snapper-sheet input.png output.png --cols N --rows N");
|
|
29
|
+
}
|
|
30
|
+
const cols = getInt(args, "cols", 0);
|
|
31
|
+
const rows = getInt(args, "rows", 0);
|
|
32
|
+
if (cols <= 0 || rows <= 0) {
|
|
33
|
+
fail("--cols and --rows must be positive integers");
|
|
34
|
+
}
|
|
35
|
+
const kColors = getInt(args, "k-colors", 256);
|
|
36
|
+
if (kColors <= 0) {
|
|
37
|
+
fail("--k-colors must be a positive integer");
|
|
38
|
+
}
|
|
39
|
+
const { image, info } = snapSheet(Bitmap.fromFile(input), cols, rows, {
|
|
40
|
+
...DEFAULT_SNAP_CONFIG,
|
|
41
|
+
kColors,
|
|
42
|
+
kSeed: getInt(args, "seed", 42)
|
|
43
|
+
});
|
|
44
|
+
image.toFile(output);
|
|
45
|
+
const [fw, fh] = info.targetFrameDims;
|
|
46
|
+
const [ow, oh] = info.outputDims;
|
|
47
|
+
console.log(`Snapped sheet ${input} -> ${output}`);
|
|
48
|
+
console.log(
|
|
49
|
+
` input: ${info.inputDims[0]}x${info.inputDims[1]} (${cols}x${rows} of ${info.inputFrameDims[0]}x${info.inputFrameDims[1]})`
|
|
50
|
+
);
|
|
51
|
+
console.log(` target frame: ${fw}x${fh} (shared pitch across all frames)`);
|
|
52
|
+
console.log(` output: ${ow}x${oh}`);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
run
|
|
57
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
rawTool,
|
|
9
|
+
runRawTool
|
|
10
|
+
} from "./chunk-OPUCUUID.js";
|
|
11
|
+
import {
|
|
12
|
+
defineCommand
|
|
13
|
+
} from "./chunk-MBXCVCC4.js";
|
|
14
|
+
import "./chunk-D2RF35HJ.js";
|
|
15
|
+
import "./chunk-GKDUYJ7R.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/check.ts
|
|
18
|
+
var CHECK_TOOLS = {
|
|
19
|
+
canvas: {
|
|
20
|
+
description: "Fail on a blank canvas or uncaught page error (needs playwright in the project).",
|
|
21
|
+
load: rawTool(async () => await import("./chunk-6KXXZXSO.js"))
|
|
22
|
+
},
|
|
23
|
+
net: {
|
|
24
|
+
description: "Measure multiplayer smoothness across simulated clients (needs playwright in the project).",
|
|
25
|
+
load: rawTool(async () => await import("./chunk-BZOMEG3X.js"))
|
|
26
|
+
},
|
|
27
|
+
"scripted-playtest": {
|
|
28
|
+
description: "Drive a fixed input sweep through vg playtest and report progression.",
|
|
29
|
+
load: rawTool(async () => await import("./chunk-4FJXCS3K.js"))
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var runCheck = async (argv) => {
|
|
33
|
+
await runRawTool("check", CHECK_TOOLS, argv);
|
|
34
|
+
};
|
|
35
|
+
var checkCommand = defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
description: "Headless checks for a build: canvas, net, scripted-playtest (`vg check --help` lists them). All arguments pass through to the check.",
|
|
38
|
+
name: "check"
|
|
39
|
+
},
|
|
40
|
+
run: async ({ rawArgs }) => {
|
|
41
|
+
await runCheck(rawArgs);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
CHECK_TOOLS,
|
|
46
|
+
checkCommand,
|
|
47
|
+
runCheck
|
|
48
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
failUsage,
|
|
9
|
+
getFlag,
|
|
10
|
+
getInt,
|
|
11
|
+
getString,
|
|
12
|
+
main,
|
|
13
|
+
parseArgs,
|
|
14
|
+
runQc,
|
|
15
|
+
toPythonJson
|
|
16
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
17
|
+
import "./chunk-2SBBKY5C.js";
|
|
18
|
+
import "./chunk-GKDUYJ7R.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/asset/sheet-qc.ts
|
|
21
|
+
var run = (argv) => {
|
|
22
|
+
main(() => {
|
|
23
|
+
const args = parseArgs([...argv], {
|
|
24
|
+
booleans: ["fail-on-hints", "json", "strict"],
|
|
25
|
+
values: ["frame-height", "frame-width"]
|
|
26
|
+
});
|
|
27
|
+
const [sheet = ""] = args.positionals;
|
|
28
|
+
if (sheet === "") {
|
|
29
|
+
failUsage("a spritesheet path is required");
|
|
30
|
+
}
|
|
31
|
+
const frameWidth = getString(args, "frame-width") === void 0 ? null : getInt(args, "frame-width", 0);
|
|
32
|
+
const frameHeight = getString(args, "frame-height") === void 0 ? null : getInt(args, "frame-height", 0);
|
|
33
|
+
const report = runQc(sheet, frameWidth, frameHeight);
|
|
34
|
+
if (getFlag(args, "json")) {
|
|
35
|
+
console.log(toPythonJson(report));
|
|
36
|
+
} else {
|
|
37
|
+
console.log(
|
|
38
|
+
`[${report.verdict.toUpperCase()}] ${report.sheet} (${report.frameCount} frames ${report.frameWidth}x${report.frameHeight})`
|
|
39
|
+
);
|
|
40
|
+
for (const check of report.checks) {
|
|
41
|
+
const marker = check.severity === "warn" ? "!" : "?";
|
|
42
|
+
console.log(
|
|
43
|
+
` ${marker} ${check.check}: frames [${check.frames.join(", ")}] \u2014 ${check.detail}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (report.checks.length === 0) {
|
|
47
|
+
console.log(
|
|
48
|
+
" no issues: sizes consistent, facing consistent, no clipping or empty cells."
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (getFlag(args, "fail-on-hints") && report.verdict !== "clean") {
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
if (getFlag(args, "strict") && report.verdict === "warn") {
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
run
|
|
62
|
+
};
|
|
@@ -5,16 +5,21 @@ const require = __createRequire(import.meta.url);
|
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
revokeLogin
|
|
9
|
+
} from "./chunk-E3FJUPLT.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
clearConfig,
|
|
12
|
+
getConfig
|
|
13
|
+
} from "./chunk-Q5NZNXJE.js";
|
|
14
14
|
import {
|
|
15
15
|
defineCommand
|
|
16
16
|
} from "./chunk-MBXCVCC4.js";
|
|
17
|
-
import
|
|
17
|
+
import {
|
|
18
|
+
consola
|
|
19
|
+
} from "./chunk-D2RF35HJ.js";
|
|
20
|
+
import "./chunk-RPSUFZAG.js";
|
|
21
|
+
import "./chunk-2SBBKY5C.js";
|
|
22
|
+
import "./chunk-GKDUYJ7R.js";
|
|
18
23
|
|
|
19
24
|
// src/commands/logout.ts
|
|
20
25
|
var logoutCommand = defineCommand({
|
|
@@ -22,7 +27,11 @@ var logoutCommand = defineCommand({
|
|
|
22
27
|
description: "Log out of vibedgames",
|
|
23
28
|
name: "logout"
|
|
24
29
|
},
|
|
25
|
-
run: () => {
|
|
30
|
+
run: async () => {
|
|
31
|
+
const config = getConfig();
|
|
32
|
+
if (config) {
|
|
33
|
+
await revokeLogin(config);
|
|
34
|
+
}
|
|
26
35
|
clearConfig();
|
|
27
36
|
consola.success("Logged out");
|
|
28
37
|
}
|
|
@@ -6,8 +6,9 @@ var __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
isJsonObject,
|
|
9
|
-
isJsonString
|
|
10
|
-
|
|
9
|
+
isJsonString,
|
|
10
|
+
parseJson
|
|
11
|
+
} from "./chunk-RPSUFZAG.js";
|
|
11
12
|
|
|
12
13
|
// src/lib/config-file.ts
|
|
13
14
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -30,15 +31,15 @@ var findConfigPath = (dir) => {
|
|
|
30
31
|
};
|
|
31
32
|
var findProjectRoot = (dir) => {
|
|
32
33
|
const found = findConfigPath(dir);
|
|
33
|
-
return found ? path.dirname(found) : null;
|
|
34
|
+
return found !== null && found !== "" ? path.dirname(found) : null;
|
|
34
35
|
};
|
|
35
36
|
var readProjectConfig = (dir) => {
|
|
36
37
|
const file = findConfigPath(dir);
|
|
37
|
-
if (
|
|
38
|
+
if (file === null || file === "") {
|
|
38
39
|
return null;
|
|
39
40
|
}
|
|
40
41
|
const raw = readFileSync(file, "utf-8");
|
|
41
|
-
const parsed =
|
|
42
|
+
const parsed = parseJson(raw);
|
|
42
43
|
if (!isJsonObject(parsed) || !isJsonString(parsed.slug)) {
|
|
43
44
|
throw new Error(`${FILENAME} is malformed \u2014 missing "slug".`);
|
|
44
45
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
fail,
|
|
9
|
+
failUsage,
|
|
10
|
+
getFlag,
|
|
11
|
+
getInt,
|
|
12
|
+
getNumber,
|
|
13
|
+
getString,
|
|
14
|
+
main,
|
|
15
|
+
normalizeCanvas,
|
|
16
|
+
parseArgs
|
|
17
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
18
|
+
import "./chunk-2SBBKY5C.js";
|
|
19
|
+
import "./chunk-GKDUYJ7R.js";
|
|
20
|
+
|
|
21
|
+
// src/commands/asset/normalize-canvas.ts
|
|
22
|
+
var parseSize = (text = "256x256") => {
|
|
23
|
+
const match = /^(?<w>\d+)\s*x\s*(?<h>\d+)$/iu.exec(text.trim());
|
|
24
|
+
if (!match) {
|
|
25
|
+
fail(`--canvas must be WxH, e.g. 256x256 (got "${text}")`);
|
|
26
|
+
}
|
|
27
|
+
const width = Number(match?.groups?.w);
|
|
28
|
+
const height = Number(match?.groups?.h);
|
|
29
|
+
if (width <= 0 || height <= 0) {
|
|
30
|
+
fail(`--canvas dimensions must be positive, got: "${text}"`);
|
|
31
|
+
}
|
|
32
|
+
return { height, width };
|
|
33
|
+
};
|
|
34
|
+
var run = (argv) => {
|
|
35
|
+
main(() => {
|
|
36
|
+
const args = parseArgs([...argv], {
|
|
37
|
+
booleans: ["no-upscale"],
|
|
38
|
+
values: ["canvas", "char-fill", "glob", "input-dir", "out-dir", "pad", "target-height"]
|
|
39
|
+
});
|
|
40
|
+
const inputDir = getString(args, "input-dir") ?? "";
|
|
41
|
+
const outDir = getString(args, "out-dir") ?? "";
|
|
42
|
+
if (inputDir === "" || outDir === "") {
|
|
43
|
+
failUsage("--input-dir and --out-dir are required");
|
|
44
|
+
}
|
|
45
|
+
const pad = getInt(args, "pad", 6);
|
|
46
|
+
if (pad < 0) {
|
|
47
|
+
fail("--pad must be >= 0");
|
|
48
|
+
}
|
|
49
|
+
const charFill = getNumber(args, "char-fill", 0.5);
|
|
50
|
+
if (!(charFill > 0 && charFill <= 1)) {
|
|
51
|
+
fail("--char-fill must be in (0, 1]");
|
|
52
|
+
}
|
|
53
|
+
const targetHeightSpec = getString(args, "target-height");
|
|
54
|
+
const targetHeight = targetHeightSpec === void 0 ? null : getInt(args, "target-height", 0);
|
|
55
|
+
if (targetHeight !== null && targetHeight <= 0) {
|
|
56
|
+
fail("--target-height must be a positive integer");
|
|
57
|
+
}
|
|
58
|
+
const written = normalizeCanvas(inputDir, outDir, {
|
|
59
|
+
allowUpscale: !getFlag(args, "no-upscale"),
|
|
60
|
+
canvas: parseSize(getString(args, "canvas")),
|
|
61
|
+
charFill,
|
|
62
|
+
glob: getString(args, "glob") ?? "frame-*.png",
|
|
63
|
+
pad,
|
|
64
|
+
targetHeight
|
|
65
|
+
});
|
|
66
|
+
console.log(outDir);
|
|
67
|
+
console.log(`${written.length} frames`);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
run
|
|
72
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
fail,
|
|
9
|
+
failUsage,
|
|
10
|
+
getFlag,
|
|
11
|
+
getInt,
|
|
12
|
+
getNumber,
|
|
13
|
+
getString,
|
|
14
|
+
main,
|
|
15
|
+
parseArgs,
|
|
16
|
+
parseColor,
|
|
17
|
+
processSheet,
|
|
18
|
+
toPythonJson
|
|
19
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
20
|
+
import "./chunk-2SBBKY5C.js";
|
|
21
|
+
import "./chunk-GKDUYJ7R.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/asset/process-sheet.ts
|
|
24
|
+
import { existsSync } from "node:fs";
|
|
25
|
+
var run = (argv) => {
|
|
26
|
+
main(() => {
|
|
27
|
+
const args = parseArgs([...argv], {
|
|
28
|
+
booleans: ["json", "no-pixel-snap", "no-qc", "recover"],
|
|
29
|
+
values: [
|
|
30
|
+
"action",
|
|
31
|
+
"char-fill",
|
|
32
|
+
"chroma",
|
|
33
|
+
"cols",
|
|
34
|
+
"frames",
|
|
35
|
+
"out-dir",
|
|
36
|
+
"rows",
|
|
37
|
+
"snap-k-colors"
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
const readOptions = () => {
|
|
41
|
+
const [board = ""] = args.positionals;
|
|
42
|
+
if (board === "") {
|
|
43
|
+
failUsage("a pose board PNG is required");
|
|
44
|
+
}
|
|
45
|
+
if (!existsSync(board)) {
|
|
46
|
+
fail(`board not found: ${board}`);
|
|
47
|
+
}
|
|
48
|
+
const action2 = getString(args, "action") ?? "";
|
|
49
|
+
if (action2 === "") {
|
|
50
|
+
failUsage("--action is required");
|
|
51
|
+
}
|
|
52
|
+
const outDir = getString(args, "out-dir") ?? "";
|
|
53
|
+
if (outDir === "") {
|
|
54
|
+
failUsage("--out-dir is required");
|
|
55
|
+
}
|
|
56
|
+
const rows = getInt(args, "rows", 0);
|
|
57
|
+
const cols = getInt(args, "cols", 0);
|
|
58
|
+
if (rows <= 0 || cols <= 0) {
|
|
59
|
+
fail("--rows and --cols must be positive integers");
|
|
60
|
+
}
|
|
61
|
+
const charFill = getNumber(args, "char-fill", 0.5);
|
|
62
|
+
if (!(charFill > 0 && charFill <= 1)) {
|
|
63
|
+
fail("--char-fill must be in (0, 1]");
|
|
64
|
+
}
|
|
65
|
+
const snapKColors = getInt(args, "snap-k-colors", 16);
|
|
66
|
+
if (snapKColors <= 0) {
|
|
67
|
+
fail("--snap-k-colors must be a positive integer");
|
|
68
|
+
}
|
|
69
|
+
const requested = getString(args, "frames");
|
|
70
|
+
if (requested !== void 0 && getInt(args, "frames", 0) <= 0) {
|
|
71
|
+
fail("--frames must be a positive integer");
|
|
72
|
+
}
|
|
73
|
+
const frames2 = requested === void 0 ? void 0 : getInt(args, "frames", 0);
|
|
74
|
+
return { action: action2, board, charFill, cols, frames: frames2, outDir, rows, snapKColors };
|
|
75
|
+
};
|
|
76
|
+
const [chromaR, chromaG, chromaB] = parseColor(getString(args, "chroma") ?? "#00FF00");
|
|
77
|
+
const result = processSheet({
|
|
78
|
+
...readOptions(),
|
|
79
|
+
chroma: [chromaR, chromaG, chromaB],
|
|
80
|
+
pixelSnap: !getFlag(args, "no-pixel-snap"),
|
|
81
|
+
qc: !getFlag(args, "no-qc"),
|
|
82
|
+
recover: getFlag(args, "recover"),
|
|
83
|
+
warn: (message) => {
|
|
84
|
+
process.stderr.write(`[process_sheet] warning: ${message}
|
|
85
|
+
`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const { action, fps, frames, gif, qc, spritesheet } = result;
|
|
89
|
+
if (getFlag(args, "json")) {
|
|
90
|
+
const summary = {
|
|
91
|
+
action,
|
|
92
|
+
fps,
|
|
93
|
+
frames,
|
|
94
|
+
gif,
|
|
95
|
+
path: "image",
|
|
96
|
+
pixelSnap: result.pixelSnap,
|
|
97
|
+
qc: qc ? qc.verdict : "skipped",
|
|
98
|
+
runtimeFrames: result.runtimeFrames,
|
|
99
|
+
slicing: result.slicing,
|
|
100
|
+
spritesheet
|
|
101
|
+
};
|
|
102
|
+
console.log(toPythonJson(qc ? { ...summary, qcChecks: qc.checks } : summary));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const lines = [
|
|
106
|
+
`
|
|
107
|
+
=== ${action} (image): ${frames} frames @ ${fps}fps ===`,
|
|
108
|
+
` sheet: ${spritesheet}`,
|
|
109
|
+
` gif: ${gif}`
|
|
110
|
+
];
|
|
111
|
+
if (qc) {
|
|
112
|
+
lines.push(` qc: [${qc.verdict.toUpperCase()}]`);
|
|
113
|
+
for (const check of qc.checks) {
|
|
114
|
+
lines.push(
|
|
115
|
+
` ${check.severity === "warn" ? "!" : "?"} ${check.check}: frames [${check.frames.join(", ")}] \u2014 ${check.detail}`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
console.log(lines.join("\n"));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
run
|
|
124
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
assertKnownFlags
|
|
9
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
10
|
+
import {
|
|
11
|
+
getBaseUrl
|
|
12
|
+
} from "./chunk-Q5NZNXJE.js";
|
|
13
|
+
import {
|
|
14
|
+
isJsonOutput,
|
|
15
|
+
outputArgs,
|
|
16
|
+
writeStructured
|
|
17
|
+
} from "./chunk-COSLGSVO.js";
|
|
18
|
+
import {
|
|
19
|
+
defineCommand
|
|
20
|
+
} from "./chunk-MBXCVCC4.js";
|
|
21
|
+
import {
|
|
22
|
+
consola
|
|
23
|
+
} from "./chunk-D2RF35HJ.js";
|
|
24
|
+
import {
|
|
25
|
+
isJsonObject,
|
|
26
|
+
isJsonString,
|
|
27
|
+
parseJson
|
|
28
|
+
} from "./chunk-RPSUFZAG.js";
|
|
29
|
+
import "./chunk-2SBBKY5C.js";
|
|
30
|
+
import "./chunk-GKDUYJ7R.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/skills.ts
|
|
33
|
+
var skillsArgs = {
|
|
34
|
+
name: {
|
|
35
|
+
description: "A skill's name; omit to list every skill and what it is for.",
|
|
36
|
+
required: false,
|
|
37
|
+
type: "positional"
|
|
38
|
+
},
|
|
39
|
+
...outputArgs
|
|
40
|
+
};
|
|
41
|
+
var discoveryUrl = (path) => new URL(`/.well-known/agent-skills/${path}`, getBaseUrl());
|
|
42
|
+
var fetchOrExit = async (url, doing) => {
|
|
43
|
+
try {
|
|
44
|
+
return await fetch(url);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
consola.error(`${doing}: ${error instanceof Error ? error.message : String(error)}`);
|
|
47
|
+
return process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var summaries = (index) => {
|
|
51
|
+
const skills = isJsonObject(index) ? index.skills : void 0;
|
|
52
|
+
if (!Array.isArray(skills)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return skills.flatMap((entry) => {
|
|
56
|
+
if (!isJsonObject(entry) || !isJsonString(entry.name) || !isJsonString(entry.description)) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return [{ description: entry.description, name: entry.name }];
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var listSkills = async () => {
|
|
63
|
+
const res = await fetchOrExit(discoveryUrl("index.json"), "Could not list the skills");
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
consola.error(`Could not list the skills: ${res.status} ${res.statusText}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
const index = parseJson(await res.text());
|
|
69
|
+
return summaries(index);
|
|
70
|
+
};
|
|
71
|
+
var skillsCommand = defineCommand({
|
|
72
|
+
args: skillsArgs,
|
|
73
|
+
meta: {
|
|
74
|
+
description: "The game-studio skills: list them, or print one's SKILL.md (how to build, art-direct, add multiplayer to, balance and ship a browser game).",
|
|
75
|
+
name: "skills"
|
|
76
|
+
},
|
|
77
|
+
run: async ({ args, rawArgs }) => {
|
|
78
|
+
assertKnownFlags(rawArgs, skillsArgs);
|
|
79
|
+
if (args.name === void 0 || args.name === "") {
|
|
80
|
+
const skills = await listSkills();
|
|
81
|
+
if (writeStructured({ skills }, args)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (const skill of skills) {
|
|
85
|
+
consola.log(`${skill.name} ${skill.description}`);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const name = args.name.trim();
|
|
90
|
+
const res = await fetchOrExit(
|
|
91
|
+
discoveryUrl(`${encodeURIComponent(name)}/SKILL.md`),
|
|
92
|
+
`Could not fetch ${name}`
|
|
93
|
+
);
|
|
94
|
+
if (res.status === 404) {
|
|
95
|
+
consola.error(`No skill "${name}". Run \`vg skills\` to list them.`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
consola.error(`Could not fetch ${name}: ${res.status} ${res.statusText}`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const content = await res.text();
|
|
103
|
+
if (isJsonOutput(args) || args.field !== void 0 && args.field !== "") {
|
|
104
|
+
const listed = await listSkills();
|
|
105
|
+
const summary = listed.find((skill) => skill.name === name);
|
|
106
|
+
writeStructured({ content, description: summary?.description ?? "", name }, args);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
process.stdout.write(content.endsWith("\n") ? content : `${content}
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
export {
|
|
114
|
+
skillsCommand
|
|
115
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
Bitmap,
|
|
9
|
+
fail,
|
|
10
|
+
failUsage,
|
|
11
|
+
getInt,
|
|
12
|
+
getString,
|
|
13
|
+
main,
|
|
14
|
+
parseArgs,
|
|
15
|
+
parseColor
|
|
16
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
17
|
+
import "./chunk-2SBBKY5C.js";
|
|
18
|
+
import "./chunk-GKDUYJ7R.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/asset/ref-sxs.ts
|
|
21
|
+
import { existsSync } from "node:fs";
|
|
22
|
+
var GAP = 8;
|
|
23
|
+
var STRIP = 6;
|
|
24
|
+
var BACKGROUND = parseColor("#101010");
|
|
25
|
+
var REF_INK = parseColor("#dc3c3c");
|
|
26
|
+
var GAME_INK = parseColor("#3cc85a");
|
|
27
|
+
var run = (argv) => {
|
|
28
|
+
main(() => {
|
|
29
|
+
const args = parseArgs([...argv], {
|
|
30
|
+
values: ["blur", "game", "height", "out", "ref"]
|
|
31
|
+
});
|
|
32
|
+
const out = getString(args, "out") ?? "";
|
|
33
|
+
if (!out.endsWith(".png")) {
|
|
34
|
+
failUsage("--out is required and must end in .png");
|
|
35
|
+
}
|
|
36
|
+
const height = getInt(args, "height", 720);
|
|
37
|
+
const blur = getInt(args, "blur", 24);
|
|
38
|
+
if (height < 64 || blur < 2) {
|
|
39
|
+
failUsage("--height must be \u2265 64 and --blur \u2265 2");
|
|
40
|
+
}
|
|
41
|
+
const sides = [
|
|
42
|
+
{ ink: REF_INK, role: "ref" },
|
|
43
|
+
{ ink: GAME_INK, role: "game" }
|
|
44
|
+
].map(({ ink, role }) => {
|
|
45
|
+
const file = getString(args, role) ?? "";
|
|
46
|
+
if (file === "") {
|
|
47
|
+
failUsage(`--${role} is required (a PNG path)`);
|
|
48
|
+
}
|
|
49
|
+
if (!existsSync(file)) {
|
|
50
|
+
fail(`${role} not found: ${file}`);
|
|
51
|
+
}
|
|
52
|
+
const image = Bitmap.fromFile(file).flatten([0, 0, 0]);
|
|
53
|
+
const sharp = image.resize(
|
|
54
|
+
Math.max(1, Math.round(image.width * height / image.height)),
|
|
55
|
+
height,
|
|
56
|
+
"bilinear"
|
|
57
|
+
);
|
|
58
|
+
const soft = sharp.resize(
|
|
59
|
+
Math.max(1, Math.round(sharp.width / blur)),
|
|
60
|
+
Math.max(1, Math.round(sharp.height / blur)),
|
|
61
|
+
"bilinear"
|
|
62
|
+
).resize(sharp.width, sharp.height, "bilinear");
|
|
63
|
+
return { ink, sharp, soft };
|
|
64
|
+
});
|
|
65
|
+
const compose = (images = sides.map((side) => side.sharp)) => {
|
|
66
|
+
const composed = Bitmap.create(
|
|
67
|
+
images.reduce((width, image) => width + image.width, 0) + GAP * (images.length - 1),
|
|
68
|
+
STRIP + Math.max(...images.map((image) => image.height)),
|
|
69
|
+
BACKGROUND
|
|
70
|
+
);
|
|
71
|
+
let x = 0;
|
|
72
|
+
for (const [i, image] of images.entries()) {
|
|
73
|
+
composed.paste(Bitmap.create(image.width, STRIP, sides[i]?.ink ?? BACKGROUND), x, 0);
|
|
74
|
+
composed.paste(image, x, STRIP);
|
|
75
|
+
x += image.width + GAP;
|
|
76
|
+
}
|
|
77
|
+
return composed;
|
|
78
|
+
};
|
|
79
|
+
const [ref, game] = sides.map((side) => side.sharp);
|
|
80
|
+
compose().toFile(out);
|
|
81
|
+
const blurred = compose(sides.map((side) => side.soft));
|
|
82
|
+
const blurOut = out.replace(/\.png$/u, "-blur.png");
|
|
83
|
+
blurred.resize(Math.round(blurred.width / 2), Math.round(blurred.height / 2), "bilinear").toFile(blurOut);
|
|
84
|
+
console.log(
|
|
85
|
+
JSON.stringify({ blur: blurOut, game: game?.width, height, ref: ref?.width, sxs: out })
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
run
|
|
91
|
+
};
|