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
|
@@ -6,35 +6,38 @@ var __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
extractSource
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-42K3BJJH.js";
|
|
10
|
+
import "./chunk-G66HRVDW.js";
|
|
11
11
|
import {
|
|
12
12
|
SLUG_RE
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TMPBGXT4.js";
|
|
14
|
+
import {
|
|
15
|
+
assertKnownFlags
|
|
16
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
14
17
|
import {
|
|
15
18
|
createClient
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-CTY2WZQK.js";
|
|
20
|
+
import "./chunk-E3FJUPLT.js";
|
|
21
|
+
import "./chunk-Q5NZNXJE.js";
|
|
19
22
|
import {
|
|
20
23
|
isJsonOutput,
|
|
21
24
|
outputArgs,
|
|
22
25
|
writeStructured
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-COSLGSVO.js";
|
|
24
27
|
import {
|
|
25
|
-
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import "./chunk-RYFO3ZPO.js";
|
|
28
|
+
defineCommand
|
|
29
|
+
} from "./chunk-MBXCVCC4.js";
|
|
28
30
|
import {
|
|
29
31
|
consola
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import
|
|
32
|
-
|
|
33
|
-
} from "./chunk-J6PKNPI2.js";
|
|
32
|
+
} from "./chunk-D2RF35HJ.js";
|
|
33
|
+
import "./chunk-YNCYMWER.js";
|
|
34
|
+
import "./chunk-AWJNAGPE.js";
|
|
34
35
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
isJsonObject,
|
|
37
|
+
parseJson
|
|
38
|
+
} from "./chunk-RPSUFZAG.js";
|
|
39
|
+
import "./chunk-2SBBKY5C.js";
|
|
40
|
+
import "./chunk-GKDUYJ7R.js";
|
|
38
41
|
|
|
39
42
|
// src/commands/fork.ts
|
|
40
43
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -68,7 +71,7 @@ var rewritePackageName = (dir, slug) => {
|
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
73
|
try {
|
|
71
|
-
const pkg =
|
|
74
|
+
const pkg = parseJson(readFileSync(pkgPath, "utf-8"));
|
|
72
75
|
if (!isJsonObject(pkg)) {
|
|
73
76
|
throw new Error("package.json is not a JSON object");
|
|
74
77
|
}
|
|
@@ -109,7 +112,7 @@ var forkCommand = defineCommand({
|
|
|
109
112
|
rmSync(dir, { force: true, recursive: true });
|
|
110
113
|
}
|
|
111
114
|
const client = createClient();
|
|
112
|
-
if (!isJsonOutput(args) &&
|
|
115
|
+
if (!isJsonOutput(args) && (args.field === void 0 || args.field === "")) {
|
|
113
116
|
consola.start(`Forking ${source}`);
|
|
114
117
|
}
|
|
115
118
|
let src;
|
|
@@ -9,43 +9,44 @@ import {
|
|
|
9
9
|
reportSkills,
|
|
10
10
|
settleSync,
|
|
11
11
|
syncSkills
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3HGBIUM5.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchLatestVersion,
|
|
15
15
|
isNewerVersion
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-6FZPPUQH.js";
|
|
16
|
+
} from "./chunk-N2UHAQXC.js";
|
|
18
17
|
import {
|
|
19
18
|
FACTORY_PACKAGE,
|
|
20
19
|
installedFactoryVersion,
|
|
21
20
|
updateFactory
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-A556KALN.js";
|
|
23
22
|
import {
|
|
24
23
|
isMissingCommand,
|
|
25
24
|
run
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-VFFOT7KD.js";
|
|
29
|
-
import {
|
|
30
|
-
PACKAGE_VERSION
|
|
31
|
-
} from "./chunk-Z4Z24FWO.js";
|
|
32
|
-
import {
|
|
33
|
-
detectPackageManager,
|
|
34
|
-
globalInstallArgs,
|
|
35
|
-
globalInstallCommand
|
|
36
|
-
} from "./chunk-PEUP4MZR.js";
|
|
25
|
+
} from "./chunk-F42QKWBB.js";
|
|
26
|
+
import "./chunk-G66HRVDW.js";
|
|
37
27
|
import {
|
|
38
28
|
assertKnownFlags
|
|
39
29
|
} from "./chunk-RZ4DIJQW.js";
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import
|
|
42
|
-
consola
|
|
43
|
-
} from "./chunk-CU7UY5YJ.js";
|
|
44
|
-
import "./chunk-J6PKNPI2.js";
|
|
30
|
+
import "./chunk-JN4WZCR7.js";
|
|
31
|
+
import "./chunk-Q5NZNXJE.js";
|
|
45
32
|
import {
|
|
46
33
|
defineCommand
|
|
47
34
|
} from "./chunk-MBXCVCC4.js";
|
|
48
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-5535KDYI.js";
|
|
36
|
+
import {
|
|
37
|
+
consola
|
|
38
|
+
} from "./chunk-D2RF35HJ.js";
|
|
39
|
+
import {
|
|
40
|
+
PACKAGE_VERSION
|
|
41
|
+
} from "./chunk-YNCYMWER.js";
|
|
42
|
+
import {
|
|
43
|
+
detectPackageManager,
|
|
44
|
+
globalInstallArgs,
|
|
45
|
+
globalInstallCommand
|
|
46
|
+
} from "./chunk-AWJNAGPE.js";
|
|
47
|
+
import "./chunk-RPSUFZAG.js";
|
|
48
|
+
import "./chunk-2SBBKY5C.js";
|
|
49
|
+
import "./chunk-GKDUYJ7R.js";
|
|
49
50
|
|
|
50
51
|
// src/commands/update.ts
|
|
51
52
|
var updateInstalledSkills = async (global) => {
|
|
@@ -6,15 +6,16 @@ var __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
resolveSetting
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JN4WZCR7.js";
|
|
10
10
|
import {
|
|
11
11
|
getConfigDir
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q5NZNXJE.js";
|
|
13
13
|
import {
|
|
14
14
|
isJsonNumber,
|
|
15
15
|
isJsonObject,
|
|
16
|
-
isJsonString
|
|
17
|
-
|
|
16
|
+
isJsonString,
|
|
17
|
+
parseJson
|
|
18
|
+
} from "./chunk-RPSUFZAG.js";
|
|
18
19
|
|
|
19
20
|
// src/lib/update.ts
|
|
20
21
|
import { spawn } from "node:child_process";
|
|
@@ -29,7 +30,7 @@ var getLastCheckedAt = () => {
|
|
|
29
30
|
return 0;
|
|
30
31
|
}
|
|
31
32
|
try {
|
|
32
|
-
const data =
|
|
33
|
+
const data = parseJson(readFileSync(cache, "utf-8"));
|
|
33
34
|
if (isJsonObject(data)) {
|
|
34
35
|
const ts = data.lastCheckedAt;
|
|
35
36
|
if (isJsonNumber(ts)) {
|
|
@@ -37,6 +38,7 @@ var getLastCheckedAt = () => {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
} catch {
|
|
41
|
+
return 0;
|
|
40
42
|
}
|
|
41
43
|
return 0;
|
|
42
44
|
};
|
|
@@ -47,7 +49,9 @@ var markUpdateChecked = () => {
|
|
|
47
49
|
mkdirSync(dir, { mode: 448, recursive: true });
|
|
48
50
|
}
|
|
49
51
|
writeFileSync(getCachePath(), JSON.stringify({ lastCheckedAt: Date.now() }, null, 2));
|
|
52
|
+
return true;
|
|
50
53
|
} catch {
|
|
54
|
+
return false;
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
57
|
var isNewerVersion = (latest, current) => {
|
|
@@ -77,7 +81,7 @@ var fetchLatestVersion = async (packageName) => {
|
|
|
77
81
|
if (!res.ok) {
|
|
78
82
|
return null;
|
|
79
83
|
}
|
|
80
|
-
const data = await res.
|
|
84
|
+
const data = parseJson(await res.text());
|
|
81
85
|
if (isJsonObject(data)) {
|
|
82
86
|
const { version } = data;
|
|
83
87
|
if (isJsonString(version)) {
|
|
@@ -85,19 +89,20 @@ var fetchLatestVersion = async (packageName) => {
|
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
} catch {
|
|
92
|
+
return null;
|
|
88
93
|
}
|
|
89
94
|
return null;
|
|
90
95
|
};
|
|
91
96
|
var maybeScheduleAutoUpdate = () => {
|
|
92
|
-
if (process.env.CI || resolveSetting("update.auto").value === "false") {
|
|
93
|
-
return;
|
|
97
|
+
if (process.env.CI !== void 0 && process.env.CI !== "" || resolveSetting("update.auto").value === "false") {
|
|
98
|
+
return false;
|
|
94
99
|
}
|
|
95
100
|
const [, script] = process.argv;
|
|
96
|
-
if (
|
|
97
|
-
return;
|
|
101
|
+
if (script === void 0 || script === "") {
|
|
102
|
+
return false;
|
|
98
103
|
}
|
|
99
104
|
if (Date.now() - getLastCheckedAt() < CHECK_INTERVAL_MS) {
|
|
100
|
-
return;
|
|
105
|
+
return false;
|
|
101
106
|
}
|
|
102
107
|
markUpdateChecked();
|
|
103
108
|
try {
|
|
@@ -106,7 +111,9 @@ var maybeScheduleAutoUpdate = () => {
|
|
|
106
111
|
stdio: "ignore"
|
|
107
112
|
});
|
|
108
113
|
child.unref();
|
|
114
|
+
return true;
|
|
109
115
|
} catch {
|
|
116
|
+
return false;
|
|
110
117
|
}
|
|
111
118
|
};
|
|
112
119
|
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
getDirection,
|
|
11
|
+
getFlag,
|
|
12
|
+
getInt,
|
|
13
|
+
getString,
|
|
14
|
+
main,
|
|
15
|
+
parseArgs,
|
|
16
|
+
renderAnchorPrompt,
|
|
17
|
+
renderPoseBoardPrompt,
|
|
18
|
+
resolvePoseBoardPreset,
|
|
19
|
+
totalCells,
|
|
20
|
+
withStyle
|
|
21
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
22
|
+
import "./chunk-2SBBKY5C.js";
|
|
23
|
+
import "./chunk-GKDUYJ7R.js";
|
|
24
|
+
|
|
25
|
+
// src/commands/asset/sprite-prompt.ts
|
|
26
|
+
var STYLE_CHOICES = ["lobit-v1", "high-fidelity-v1", "preserve-reference-v1"];
|
|
27
|
+
var run = (argv) => {
|
|
28
|
+
main(() => {
|
|
29
|
+
const args = parseArgs([...argv], {
|
|
30
|
+
booleans: ["guide-image"],
|
|
31
|
+
values: [
|
|
32
|
+
"action",
|
|
33
|
+
"anchor-context",
|
|
34
|
+
"chroma",
|
|
35
|
+
"direction",
|
|
36
|
+
"frame-prompt-style",
|
|
37
|
+
"frames",
|
|
38
|
+
"game-view",
|
|
39
|
+
"pose-board",
|
|
40
|
+
"role",
|
|
41
|
+
"style"
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
const styleOf = () => {
|
|
45
|
+
const style = getString(args, "style");
|
|
46
|
+
if (style !== void 0 && !STYLE_CHOICES.includes(style)) {
|
|
47
|
+
failUsage(
|
|
48
|
+
`argument --style: invalid choice: '${style}' (choose from ${STYLE_CHOICES.map((c) => `'${c}'`).join(", ")})`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return style ?? null;
|
|
52
|
+
};
|
|
53
|
+
const anchor = () => {
|
|
54
|
+
const direction = getString(args, "direction") ?? "";
|
|
55
|
+
if (direction === "") {
|
|
56
|
+
failUsage("--direction is required (n,s,e,w,ne,nw,se,sw)");
|
|
57
|
+
}
|
|
58
|
+
const prompt = renderAnchorPrompt(getDirection(direction), {
|
|
59
|
+
anchorContext: getString(args, "anchor-context") ?? null,
|
|
60
|
+
anchorRole: getString(args, "role") ?? "character",
|
|
61
|
+
chroma: getString(args, "chroma") ?? "#00FF00",
|
|
62
|
+
gameView: getString(args, "game-view") ?? "platformer",
|
|
63
|
+
guideImage: getFlag(args, "guide-image")
|
|
64
|
+
});
|
|
65
|
+
console.log(withStyle(prompt, styleOf()));
|
|
66
|
+
};
|
|
67
|
+
const poseBoard = () => {
|
|
68
|
+
const action = getString(args, "action") ?? "";
|
|
69
|
+
const direction = getString(args, "direction") ?? "";
|
|
70
|
+
if (action === "") {
|
|
71
|
+
failUsage("--action is required (e.g. attack, idle, walk)");
|
|
72
|
+
}
|
|
73
|
+
if (direction === "") {
|
|
74
|
+
failUsage("--direction is required (n,s,e,w,ne,nw,se,sw)");
|
|
75
|
+
}
|
|
76
|
+
const framePromptStyle = getString(args, "frame-prompt-style") ?? "specific";
|
|
77
|
+
if (framePromptStyle !== "specific" && framePromptStyle !== "loose") {
|
|
78
|
+
failUsage(
|
|
79
|
+
`argument --frame-prompt-style: invalid choice: '${framePromptStyle}' (choose from 'specific', 'loose')`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const board = resolvePoseBoardPreset(getString(args, "pose-board") ?? "standard");
|
|
83
|
+
const frames = getInt(args, "frames", 0);
|
|
84
|
+
if (frames <= 0) {
|
|
85
|
+
fail("--frames must be a positive integer");
|
|
86
|
+
}
|
|
87
|
+
if (frames > totalCells(board)) {
|
|
88
|
+
fail(
|
|
89
|
+
`--frames ${frames} exceeds the ${board.id} board's ${totalCells(board)} cells; use fewer frames or a larger --pose-board`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
const prompt = renderPoseBoardPrompt(
|
|
93
|
+
action.trim().toLowerCase(),
|
|
94
|
+
getDirection(direction),
|
|
95
|
+
frames,
|
|
96
|
+
{
|
|
97
|
+
chroma: getString(args, "chroma") ?? "#00FF00",
|
|
98
|
+
framePromptStyle,
|
|
99
|
+
guideImage: getFlag(args, "guide-image"),
|
|
100
|
+
poseBoard: board
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
console.log(withStyle(prompt, styleOf()));
|
|
104
|
+
};
|
|
105
|
+
const mode = (/* @__PURE__ */ new Map([
|
|
106
|
+
["anchor", anchor],
|
|
107
|
+
["pose-board", poseBoard]
|
|
108
|
+
])).get(args.positionals[0] ?? "");
|
|
109
|
+
if (mode === void 0) {
|
|
110
|
+
failUsage("Usage: vg asset sprite-prompt <anchor|pose-board> ...");
|
|
111
|
+
}
|
|
112
|
+
mode?.();
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
export {
|
|
116
|
+
run
|
|
117
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
HIGH_FRINGE_REMOVAL_RATIO,
|
|
10
|
+
cleanChroma,
|
|
11
|
+
despillChroma,
|
|
12
|
+
fail,
|
|
13
|
+
failUsage,
|
|
14
|
+
getFlag,
|
|
15
|
+
getInt,
|
|
16
|
+
getNumber,
|
|
17
|
+
getString,
|
|
18
|
+
globFrames,
|
|
19
|
+
keyMatte,
|
|
20
|
+
main,
|
|
21
|
+
parseArgs,
|
|
22
|
+
parseColor,
|
|
23
|
+
removeChromaFringe,
|
|
24
|
+
writeJsonFile
|
|
25
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
26
|
+
import "./chunk-2SBBKY5C.js";
|
|
27
|
+
import "./chunk-GKDUYJ7R.js";
|
|
28
|
+
|
|
29
|
+
// src/commands/asset/chroma-clean.ts
|
|
30
|
+
import { existsSync, statSync } from "node:fs";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
var inputsFor = (input = "", glob = "*.png") => {
|
|
33
|
+
if (!existsSync(input)) {
|
|
34
|
+
fail(`input not found: ${input}`);
|
|
35
|
+
}
|
|
36
|
+
if (!statSync(input).isDirectory()) {
|
|
37
|
+
return [input];
|
|
38
|
+
}
|
|
39
|
+
const frames = globFrames(input, glob);
|
|
40
|
+
if (frames.length === 0) {
|
|
41
|
+
fail(`no files matched ${glob} in ${input}`);
|
|
42
|
+
}
|
|
43
|
+
return frames;
|
|
44
|
+
};
|
|
45
|
+
var siblingOutput = (src = "", suffix = "") => {
|
|
46
|
+
const name = path.basename(src).replace(/\.[^.]+$/u, "");
|
|
47
|
+
return path.join(path.dirname(src), `${name}-${suffix}.png`);
|
|
48
|
+
};
|
|
49
|
+
var run = (argv) => {
|
|
50
|
+
main(() => {
|
|
51
|
+
const args = parseArgs([...argv], {
|
|
52
|
+
booleans: ["keep-largest", "no-decontam", "whole-image"],
|
|
53
|
+
values: [
|
|
54
|
+
"chroma",
|
|
55
|
+
"despill-radius",
|
|
56
|
+
"edge-radius",
|
|
57
|
+
"fringe-radius",
|
|
58
|
+
"glob",
|
|
59
|
+
"input",
|
|
60
|
+
"out",
|
|
61
|
+
"out-dir",
|
|
62
|
+
"tolerance"
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
const chromaOf = () => {
|
|
66
|
+
const [r, g, b] = parseColor(getString(args, "chroma") ?? "#00FF00");
|
|
67
|
+
const rgb = [r, g, b];
|
|
68
|
+
return rgb;
|
|
69
|
+
};
|
|
70
|
+
const requiredInput = () => {
|
|
71
|
+
const input = getString(args, "input") ?? "";
|
|
72
|
+
if (input === "") {
|
|
73
|
+
failUsage("--input is required");
|
|
74
|
+
}
|
|
75
|
+
return input;
|
|
76
|
+
};
|
|
77
|
+
const clean = () => {
|
|
78
|
+
const input = requiredInput();
|
|
79
|
+
const chroma = chromaOf();
|
|
80
|
+
const settings = {
|
|
81
|
+
chroma,
|
|
82
|
+
decontam: !getFlag(args, "no-decontam"),
|
|
83
|
+
despillRadius: getInt(args, "despill-radius", 2),
|
|
84
|
+
fringeRadius: getInt(args, "fringe-radius", 1),
|
|
85
|
+
tolerance: getNumber(args, "tolerance", 90)
|
|
86
|
+
};
|
|
87
|
+
const cleanOne = (src = "", out2 = "") => {
|
|
88
|
+
const result = cleanChroma(Bitmap.fromFile(src), settings);
|
|
89
|
+
result.image.toFile(out2);
|
|
90
|
+
return {
|
|
91
|
+
chromaRgb: chroma,
|
|
92
|
+
decontam: result.decontam,
|
|
93
|
+
despill: result.despill,
|
|
94
|
+
fringe: result.fringe,
|
|
95
|
+
input: src,
|
|
96
|
+
key: result.key,
|
|
97
|
+
output: out2
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
if (statSync(input).isDirectory()) {
|
|
101
|
+
const outDir = getString(args, "out-dir") ?? input;
|
|
102
|
+
const frames = inputsFor(input, getString(args, "glob")).map(
|
|
103
|
+
(frame) => cleanOne(frame, path.join(outDir, path.basename(frame)))
|
|
104
|
+
);
|
|
105
|
+
writeJsonFile(path.join(outDir, "clean-metadata.json"), {
|
|
106
|
+
frames,
|
|
107
|
+
inputDir: input,
|
|
108
|
+
outDir
|
|
109
|
+
});
|
|
110
|
+
console.log(outDir);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const out = getString(args, "out") ?? siblingOutput(input, "clean");
|
|
114
|
+
const meta = cleanOne(input, out);
|
|
115
|
+
writeJsonFile(path.join(path.dirname(out), "clean-metadata.json"), meta);
|
|
116
|
+
console.log(out);
|
|
117
|
+
};
|
|
118
|
+
const outDirFor = (input = "") => getString(args, "out-dir") ?? (statSync(input).isDirectory() ? input : path.dirname(input));
|
|
119
|
+
const despill = () => {
|
|
120
|
+
const input = requiredInput();
|
|
121
|
+
const chroma = chromaOf();
|
|
122
|
+
const edgeRadius = getInt(args, "edge-radius", 2);
|
|
123
|
+
const bandOnly = !getFlag(args, "whole-image");
|
|
124
|
+
const frames = inputsFor(input, getString(args, "glob"));
|
|
125
|
+
const outDir = outDirFor(input);
|
|
126
|
+
const metadata = frames.map((frame) => {
|
|
127
|
+
const { image, record } = despillChroma(Bitmap.fromFile(frame), {
|
|
128
|
+
bandOnly,
|
|
129
|
+
chroma,
|
|
130
|
+
edgeRadius
|
|
131
|
+
});
|
|
132
|
+
const out = path.join(outDir, path.basename(frame));
|
|
133
|
+
image.toFile(out);
|
|
134
|
+
return { input: frame, output: out, ...record };
|
|
135
|
+
});
|
|
136
|
+
writeJsonFile(path.join(outDir, "despill-metadata.json"), {
|
|
137
|
+
bandOnly,
|
|
138
|
+
chromaRgb: chroma,
|
|
139
|
+
edgeRadius,
|
|
140
|
+
frames: metadata
|
|
141
|
+
});
|
|
142
|
+
console.log(outDir);
|
|
143
|
+
};
|
|
144
|
+
const fringe = () => {
|
|
145
|
+
const input = requiredInput();
|
|
146
|
+
const chroma = chromaOf();
|
|
147
|
+
const edgeRadius = getInt(args, "edge-radius", 1);
|
|
148
|
+
const frames = inputsFor(input, getString(args, "glob"));
|
|
149
|
+
const outDir = outDirFor(input);
|
|
150
|
+
const results = frames.map((frame) => {
|
|
151
|
+
const { image, record } = removeChromaFringe(Bitmap.fromFile(frame), {
|
|
152
|
+
chroma,
|
|
153
|
+
edgeRadius
|
|
154
|
+
});
|
|
155
|
+
const out = path.join(outDir, path.basename(frame));
|
|
156
|
+
image.toFile(out);
|
|
157
|
+
return { frame, out, record };
|
|
158
|
+
});
|
|
159
|
+
const warnings = results.filter(({ record }) => record.warning !== null && record.warning !== "").map(({ frame, record }) => ({
|
|
160
|
+
frame: path.basename(frame),
|
|
161
|
+
keptPixels: record.keptPixels,
|
|
162
|
+
removedFringePixels: record.removedFringePixels,
|
|
163
|
+
removedToKeptRatio: record.removedToKeptRatio,
|
|
164
|
+
warning: record.warning
|
|
165
|
+
}));
|
|
166
|
+
writeJsonFile(path.join(outDir, "fringe-metadata.json"), {
|
|
167
|
+
chromaRgb: chroma,
|
|
168
|
+
edgeRadius,
|
|
169
|
+
frames: results.map(({ frame, out, record }) => ({ input: frame, output: out, ...record })),
|
|
170
|
+
highRemovalRatioThreshold: HIGH_FRINGE_REMOVAL_RATIO,
|
|
171
|
+
warnings
|
|
172
|
+
});
|
|
173
|
+
console.log(outDir);
|
|
174
|
+
};
|
|
175
|
+
const key = () => {
|
|
176
|
+
const [, src = ""] = args.positionals;
|
|
177
|
+
const option = getString(args, "input");
|
|
178
|
+
if (src === "" && (option === void 0 || option === "")) {
|
|
179
|
+
failUsage("--input is required");
|
|
180
|
+
}
|
|
181
|
+
const input = option ?? src;
|
|
182
|
+
if (statSync(input).isDirectory()) {
|
|
183
|
+
fail("key expects a single PNG; use fringe/despill for directories");
|
|
184
|
+
}
|
|
185
|
+
const { image, record } = keyMatte(Bitmap.fromFile(input), {
|
|
186
|
+
chroma: chromaOf(),
|
|
187
|
+
keepLargest: getFlag(args, "keep-largest"),
|
|
188
|
+
tolerance: getNumber(args, "tolerance", 90)
|
|
189
|
+
});
|
|
190
|
+
const out = getString(args, "out") ?? siblingOutput(input, "keyed");
|
|
191
|
+
image.toFile(out);
|
|
192
|
+
writeJsonFile(path.join(path.dirname(out), "key-metadata.json"), {
|
|
193
|
+
input,
|
|
194
|
+
output: out,
|
|
195
|
+
...record
|
|
196
|
+
});
|
|
197
|
+
console.log(out);
|
|
198
|
+
};
|
|
199
|
+
const mode = (/* @__PURE__ */ new Map([
|
|
200
|
+
["clean", clean],
|
|
201
|
+
["despill", despill],
|
|
202
|
+
["fringe", fringe],
|
|
203
|
+
["key", key]
|
|
204
|
+
])).get(args.positionals[0] ?? "");
|
|
205
|
+
if (mode === void 0) {
|
|
206
|
+
fail(
|
|
207
|
+
`Usage: vg asset chroma-clean <clean|key|fringe|despill> --input <path> [--chroma '#00FF00']`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
mode?.();
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
run
|
|
215
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
consola
|
|
9
|
+
} from "./chunk-D2RF35HJ.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/raw-tools.ts
|
|
12
|
+
var rawTool = (load) => async () => {
|
|
13
|
+
const module = await load();
|
|
14
|
+
return module.run;
|
|
15
|
+
};
|
|
16
|
+
var usage = (group, tools) => [
|
|
17
|
+
`Usage: vg ${group} <tool> [args]`,
|
|
18
|
+
"",
|
|
19
|
+
...Object.entries(tools).map(([name, entry]) => ` ${name.padEnd(26)}${entry.description}`)
|
|
20
|
+
].join("\n");
|
|
21
|
+
var runRawTool = async (group, tools, argv) => {
|
|
22
|
+
const [name = "", ...rest] = argv;
|
|
23
|
+
if (name === "" || name === "--help" || name === "-h") {
|
|
24
|
+
console.log(usage(group, tools));
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
const entry = Object.hasOwn(tools, name) ? tools[name] : void 0;
|
|
28
|
+
if (entry === void 0) {
|
|
29
|
+
consola.error(`Unknown ${group} tool: ${name}
|
|
30
|
+
|
|
31
|
+
${usage(group, tools)}`);
|
|
32
|
+
process.exit(2);
|
|
33
|
+
}
|
|
34
|
+
const run = await entry.load();
|
|
35
|
+
await run(rest);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
rawTool,
|
|
40
|
+
runRawTool
|
|
41
|
+
};
|