vibedgames 0.9.0 → 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.
Files changed (88) hide show
  1. package/README.md +3 -2
  2. package/assets/align-framing.py +242 -0
  3. package/assets/render-model.py +406 -0
  4. package/assets/tilemap-editor.html +630 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +2 -2
  6. package/dist/chunk-2KVQJKIZ.js +6495 -0
  7. package/dist/{chunk-56OY4TEP.js → chunk-2SBBKY5C.js} +1361 -4493
  8. package/dist/{chunk-FC233UKH.js → chunk-2ZKS7V72.js} +16 -16
  9. package/dist/{chunk-BMTHAVMS.js → chunk-3HGBIUM5.js} +22 -19
  10. package/dist/chunk-3UGGMFJJ.js +22 -0
  11. package/dist/{chunk-3HUWAJQH.js → chunk-42K3BJJH.js} +93 -76
  12. package/dist/{chunk-ST5FC2W3.js → chunk-43P4U7CB.js} +20 -11
  13. package/dist/chunk-4FJXCS3K.js +741 -0
  14. package/dist/{chunk-WSRIF6K4.js → chunk-4UU622RK.js} +5 -4
  15. package/dist/chunk-5YPLKGY3.js +87 -0
  16. package/dist/chunk-6KXXZXSO.js +475 -0
  17. package/dist/chunk-7RPLQWR2.js +91 -0
  18. package/dist/{chunk-ZCYWDKYP.js → chunk-A556KALN.js} +14 -13
  19. package/dist/{chunk-UFR6G6BL.js → chunk-ABTUEIRC.js} +554 -254
  20. package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
  21. package/dist/{chunk-HNRVSBRK.js → chunk-BN3Q7UEC.js} +20 -17
  22. package/dist/chunk-BZOMEG3X.js +412 -0
  23. package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
  24. package/dist/{chunk-KZBZNTM4.js → chunk-CTY2WZQK.js} +9 -13
  25. package/dist/chunk-DB7WVFS7.js +80 -0
  26. package/dist/chunk-DOOQUFPG.js +73 -0
  27. package/dist/{chunk-K2U7L4RU.js → chunk-E3FJUPLT.js} +15 -21
  28. package/dist/chunk-E7NDOZ27.js +428 -0
  29. package/dist/{chunk-TBQ5BU3Q.js → chunk-F42QKWBB.js} +18 -18
  30. package/dist/chunk-FXXVXDTW.js +168 -0
  31. package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
  32. package/dist/chunk-GLEW7VJQ.js +45 -0
  33. package/dist/{chunk-AXTLPJ2F.js → chunk-H2C4QUTG.js} +8 -7
  34. package/dist/{chunk-H3IPLBXQ.js → chunk-HRKVAXNN.js} +17 -14
  35. package/dist/{chunk-UXCWSWWX.js → chunk-HSMG6U7J.js} +8 -7
  36. package/dist/chunk-HX5Q63UA.js +48 -0
  37. package/dist/chunk-HYOXGNWS.js +53 -0
  38. package/dist/chunk-I5LELJSK.js +22 -0
  39. package/dist/{chunk-7CXMMC5S.js → chunk-JN4WZCR7.js} +5 -4
  40. package/dist/{chunk-7QZSDU52.js → chunk-K36EOII3.js} +5 -4
  41. package/dist/chunk-KAGVI3CE.js +62 -0
  42. package/dist/chunk-KJK5CB6E.js +58 -0
  43. package/dist/chunk-KLFBAFXD.js +25 -0
  44. package/dist/{chunk-355VG7EO.js → chunk-LONQWRTR.js} +107 -77
  45. package/dist/{chunk-Z5TFZQ5U.js → chunk-LORGE2NB.js} +68 -62
  46. package/dist/{chunk-LY2GQ32S.js → chunk-MEAO33XW.js} +22 -20
  47. package/dist/{chunk-OD2MNYXD.js → chunk-MR5KIFI7.js} +23 -22
  48. package/dist/{chunk-2VUUMXAQ.js → chunk-N2UHAQXC.js} +18 -11
  49. package/dist/chunk-NCX6LYNJ.js +117 -0
  50. package/dist/chunk-OGX4DKIS.js +215 -0
  51. package/dist/chunk-OPUCUUID.js +41 -0
  52. package/dist/chunk-Q2QC6KAZ.js +132 -0
  53. package/dist/{chunk-NDHXM4PL.js → chunk-Q3XQPNF6.js} +12 -12
  54. package/dist/{chunk-RXHTGX7C.js → chunk-Q5NZNXJE.js} +6 -10
  55. package/dist/chunk-QLCVLCPM.js +126 -0
  56. package/dist/chunk-R2WVORGD.js +91 -0
  57. package/dist/chunk-RKS7SI5L.js +64 -0
  58. package/dist/{chunk-US6QZICZ.js → chunk-RPJR3S5S.js} +32 -18
  59. package/dist/chunk-RPSUFZAG.js +3307 -0
  60. package/dist/chunk-RRI23NK2.js +40 -0
  61. package/dist/chunk-S7HYWITX.js +57 -0
  62. package/dist/chunk-SBXCK2I2.js +48 -0
  63. package/dist/chunk-SUSX3QIA.js +62 -0
  64. package/dist/{chunk-6EWHKL7Z.js → chunk-SXYQL4GK.js} +7 -6
  65. package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
  66. package/dist/chunk-TXOE5UY5.js +72 -0
  67. package/dist/chunk-U6DTE5IX.js +124 -0
  68. package/dist/{chunk-UZM6OSW5.js → chunk-UPHB5HWO.js} +15 -13
  69. package/dist/chunk-UQ7VO6B3.js +91 -0
  70. package/dist/chunk-VB4WLJR2.js +47 -0
  71. package/dist/{chunk-25BAMW5X.js → chunk-VIEKOGKG.js} +18 -2
  72. package/dist/{chunk-LXS3NJYD.js → chunk-VZEJ2ZHE.js} +14 -15
  73. package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
  74. package/dist/chunk-ZHLPE6LI.js +71 -0
  75. package/dist/index.js +39 -36
  76. package/package.json +31 -16
  77. package/templates/none/src/main.ts +4 -0
  78. package/templates/none/vite.config.ts +0 -2
  79. package/templates/phaser/src/main.ts +0 -1
  80. package/templates/phaser/src/scenes/game-scene.ts +10 -8
  81. package/templates/phaser/vite.config.ts +0 -2
  82. package/templates/react-r3f/src/app.tsx +3 -1
  83. package/templates/react-r3f/src/main.tsx +1 -0
  84. package/templates/react-r3f/vite.config.ts +0 -2
  85. package/templates/threejs/src/main.ts +10 -1
  86. package/templates/threejs/vite.config.ts +0 -2
  87. package/LICENSE +0 -21
  88. package/dist/chunk-J6PKNPI2.js +0 -26
@@ -4,39 +4,41 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import {
8
- run
9
- } from "./chunk-TBQ5BU3Q.js";
10
- import "./chunk-5535KDYI.js";
11
7
  import {
12
8
  buildManifest,
13
9
  contentTypeForPath,
14
10
  resolveBuildDir
15
11
  } from "./chunk-X75Y7LUW.js";
12
+ import {
13
+ run
14
+ } from "./chunk-F42QKWBB.js";
16
15
  import {
17
16
  SLUG_RE,
18
17
  findProjectRoot,
19
18
  projectConfigPath
20
- } from "./chunk-ZI6PKVXG.js";
19
+ } from "./chunk-TMPBGXT4.js";
20
+ import {
21
+ assertKnownFlags
22
+ } from "./chunk-RZ4DIJQW.js";
21
23
  import {
22
24
  isJsonOutput,
23
25
  outputArgs,
24
26
  writeStructured
25
- } from "./chunk-ZYCSYJWX.js";
27
+ } from "./chunk-COSLGSVO.js";
26
28
  import {
27
- assertKnownFlags
28
- } from "./chunk-RZ4DIJQW.js";
29
+ defineCommand
30
+ } from "./chunk-MBXCVCC4.js";
31
+ import "./chunk-5535KDYI.js";
29
32
  import {
30
33
  consola
31
34
  } from "./chunk-D2RF35HJ.js";
32
35
  import {
33
36
  isJsonNumber,
34
37
  isJsonObject,
35
- isJsonString
36
- } from "./chunk-J6PKNPI2.js";
37
- import {
38
- defineCommand
39
- } from "./chunk-MBXCVCC4.js";
38
+ isJsonString,
39
+ parseJson
40
+ } from "./chunk-RPSUFZAG.js";
41
+ import "./chunk-2SBBKY5C.js";
40
42
  import "./chunk-GKDUYJ7R.js";
41
43
 
42
44
  // src/commands/distribute.ts
@@ -182,7 +184,11 @@ var fileNameFinding = ({ files, limits }) => {
182
184
  }
183
185
  ];
184
186
  };
185
- var sdkFinding = ({ files, readText, sdk }) => {
187
+ var sdkFinding = ({
188
+ files,
189
+ readText,
190
+ sdk
191
+ }) => {
186
192
  if (sdk === null) {
187
193
  return [];
188
194
  }
@@ -254,7 +260,7 @@ var COLOR_RE = /^#[0-9a-fA-F]{6}$/u;
254
260
  var DEFAULT_ICON = "icon.png";
255
261
  var isOrientation = (value) => ORIENTATIONS.some((orientation) => orientation === value);
256
262
  var readJson = (file) => {
257
- const parsed = JSON.parse(readFileSync(file, "utf-8"));
263
+ const parsed = parseJson(readFileSync(file, "utf-8"));
258
264
  if (!isJsonObject(parsed)) {
259
265
  throw new Error(`${file} must hold a JSON object.`);
260
266
  }
@@ -263,7 +269,7 @@ var readJson = (file) => {
263
269
  var optionalString = (source, key, pattern, expected) => {
264
270
  const value = source[key];
265
271
  if (value === void 0) {
266
- return void 0;
272
+ return value;
267
273
  }
268
274
  if (!isJsonString(value) || !pattern.test(value)) {
269
275
  throw new Error(`vibedgames.json: distribute.${key} must be ${expected}.`);
@@ -338,7 +344,7 @@ var parseNative = (root, block) => {
338
344
  };
339
345
  var readDistributeProject = (dir) => {
340
346
  const root = findProjectRoot(dir);
341
- if (!root) {
347
+ if (root === null || root === "") {
342
348
  throw new Error(
343
349
  `No vibedgames.json at or above ${dir}. Create one: {"slug": "my-game", "name": "My Game"}`
344
350
  );
@@ -504,12 +510,7 @@ var ORIENTATION_MASKS = {
504
510
  };
505
511
  var iosPlistEntries = (config) => {
506
512
  const entries = {
507
- // The shell speaks only HTTPS and WSS, which is the encryption Apple
508
- // exempts; declared here so every upload does not stop to ask.
509
513
  ITSAppUsesNonExemptEncryption: false,
510
- // A game owns the whole screen. Without this an iPad build that does not
511
- // offer all four orientations is refused at upload, since it could not
512
- // take part in Split View.
513
514
  UIRequiresFullScreen: true,
514
515
  UIStatusBarHidden: true,
515
516
  UISupportedInterfaceOrientations: ORIENTATION_MASKS[config.orientation],
@@ -580,7 +581,7 @@ var projectPackageManager = (root) => {
580
581
  }
581
582
  };
582
583
  var readJsonObject = (file) => {
583
- const parsed = JSON.parse(readFileSync2(file, "utf-8"));
584
+ const parsed = parseJson(readFileSync2(file, "utf-8"));
584
585
  if (!isJsonObject(parsed)) {
585
586
  throw new Error(`${file} must hold a JSON object.`);
586
587
  }
@@ -651,7 +652,7 @@ var writeCapacitorConfig = ({ project, native, buildDir }) => {
651
652
  writeFileSync2(file, `${JSON.stringify(config, null, 2)}
652
653
  `);
653
654
  };
654
- var cap = (root, args) => run("npx", ["--no-install", "cap", ...args], root);
655
+ var cap = async (root, args) => await run("npx", ["--no-install", "cap", ...args], root);
655
656
  var rewrite = (file, transform) => {
656
657
  if (!existsSync2(file)) {
657
658
  throw new Error(`${file} is missing: delete the platform folder and run this again.`);
@@ -905,6 +906,7 @@ var checkToolchain = async (platform, env = process.env) => {
905
906
  };
906
907
 
907
908
  // src/lib/distribute/preview.ts
909
+ import { once } from "node:events";
908
910
  import { createServer } from "node:http";
909
911
 
910
912
  // ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
@@ -2014,20 +2016,16 @@ for (const button of document.querySelectorAll("button[data-a]")) {
2014
2016
  }
2015
2017
  </script></body></html>`;
2016
2018
  };
2017
- var listen = (server, port, host) => (
2018
- // oxlint-disable-next-line promise/avoid-new -- node:http's listen is callback-based
2019
- new Promise((resolve, reject) => {
2020
- server.once("error", reject);
2021
- server.listen(port, host, () => resolve());
2022
- })
2023
- );
2024
- var closeServer = (server) => (
2025
- // oxlint-disable-next-line promise/avoid-new -- node:http's close is callback-based
2026
- new Promise((resolve) => {
2027
- server.close(() => resolve());
2028
- server.closeAllConnections();
2029
- })
2030
- );
2019
+ var listen = async (server, port, host) => {
2020
+ server.listen(port, host);
2021
+ await once(server, "listening");
2022
+ };
2023
+ var closeServer = async (server) => {
2024
+ const closed = once(server, "close");
2025
+ server.close();
2026
+ server.closeAllConnections();
2027
+ await closed;
2028
+ };
2031
2029
  var send = (res, status, type, body, headers = {}) => {
2032
2030
  res.writeHead(status, { "cache-control": "no-store", "content-type": type, ...headers });
2033
2031
  res.end(body);
@@ -2071,7 +2069,9 @@ var startPreview = async ({ zip, portal, port }) => {
2071
2069
  const gameUrl = `http://127.0.0.1:${port}${GAME_PATH}index.html`;
2072
2070
  const page = previewPage(portal, gameUrl);
2073
2071
  const game = createServer(serveGame);
2074
- const host = createServer((_req, res) => send(res, 200, "text/html; charset=utf-8", page));
2072
+ const host = createServer((_req, res) => {
2073
+ send(res, 200, "text/html; charset=utf-8", page);
2074
+ });
2075
2075
  try {
2076
2076
  await listen(game, port, "127.0.0.1");
2077
2077
  await listen(host, port + 1, "localhost");
@@ -2134,8 +2134,9 @@ var fail = (message) => {
2134
2134
  consola.error(message);
2135
2135
  process.exit(1);
2136
2136
  };
2137
- var narrator = (args) => isJsonOutput(args) || Boolean(args.field) ? () => {
2138
- } : (message) => consola.info(message);
2137
+ var narrator = (args) => isJsonOutput(args) || Boolean(args.field) ? () => null : (message) => {
2138
+ consola.info(message);
2139
+ };
2139
2140
  var formatBytes2 = (bytes) => bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
2140
2141
  var requireBuild = (dir) => {
2141
2142
  if (!existsSync4(dir)) {
@@ -2290,8 +2291,12 @@ var servePreview = async (portal, zip, port) => {
2290
2291
  await preview.close();
2291
2292
  process.exit(0);
2292
2293
  };
2293
- process.once("SIGINT", stop);
2294
- process.once("SIGTERM", stop);
2294
+ process.once("SIGINT", () => {
2295
+ void stop();
2296
+ });
2297
+ process.once("SIGTERM", () => {
2298
+ void stop();
2299
+ });
2295
2300
  return { game_url: preview.gameUrl, sdk_stub: portal.integration !== null, url: preview.url };
2296
2301
  };
2297
2302
  var portalCommand = (portal) => defineCommand({
@@ -2372,6 +2377,13 @@ var requireNative = (dir, appId) => {
2372
2377
  return fail(error instanceof Error ? error.message : String(error));
2373
2378
  }
2374
2379
  };
2380
+ var shellOrFail = async (input) => {
2381
+ try {
2382
+ return await prepareShell(input);
2383
+ } catch (error) {
2384
+ return fail(error instanceof Error ? error.message : String(error));
2385
+ }
2386
+ };
2375
2387
  var nativeCommand = (platform, store) => defineCommand({
2376
2388
  args: nativeArgs,
2377
2389
  meta: {
@@ -2384,12 +2396,7 @@ var nativeCommand = (platform, store) => defineCommand({
2384
2396
  const dir = path5.resolve(args.dir);
2385
2397
  const { project, native } = requireNative(dir, args["app-id"]);
2386
2398
  const buildDir = requireBuild(project.root);
2387
- let shell;
2388
- try {
2389
- shell = await prepareShell({ buildDir, native, platform, project, say });
2390
- } catch (error) {
2391
- return fail(error instanceof Error ? error.message : String(error));
2392
- }
2399
+ const shell = await shellOrFail({ buildDir, native, platform, project, say });
2393
2400
  const toolchain = await checkToolchain(platform);
2394
2401
  const result = {
2395
2402
  app_id: native.appId,
@@ -2401,20 +2408,19 @@ var nativeCommand = (platform, store) => defineCommand({
2401
2408
  toolchain_missing: toolchain.ready ? [] : toolchain.missing,
2402
2409
  version: native.version
2403
2410
  };
2404
- if (writeStructured(result, args)) {
2405
- return;
2406
- }
2407
- consola.success(`${result.project} \u2014 ${native.appId} ${native.version} (${native.build})`);
2408
- if (!shell.icon) {
2409
- consola.warn(
2410
- "Still the placeholder icon, which no store accepts. Add a square 1024px icon.png to the project (or set distribute.icon) and run this again."
2411
- );
2412
- }
2413
- for (const missing of result.toolchain_missing) {
2414
- consola.warn(missing);
2415
- }
2416
- consola.info(`Next:
2411
+ if (!writeStructured(result, args)) {
2412
+ consola.success(`${result.project} \u2014 ${native.appId} ${native.version} (${native.build})`);
2413
+ if (!shell.icon) {
2414
+ consola.warn(
2415
+ "Still the placeholder icon, which no store accepts. Add a square 1024px icon.png to the project (or set distribute.icon) and run this again."
2416
+ );
2417
+ }
2418
+ for (const missing of result.toolchain_missing) {
2419
+ consola.warn(missing);
2420
+ }
2421
+ consola.info(`Next:
2417
2422
  ${result.next.join("\n ")}`);
2423
+ }
2418
2424
  }
2419
2425
  });
2420
2426
  var targetsArgs = { ...outputArgs };
@@ -6,35 +6,37 @@ var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  extractSource
9
- } from "./chunk-3HUWAJQH.js";
10
- import "./chunk-VFFOT7KD.js";
11
- import {
12
- createClient
13
- } from "./chunk-KZBZNTM4.js";
14
- import "./chunk-K2U7L4RU.js";
15
- import "./chunk-Z4Z24FWO.js";
16
- import "./chunk-PEUP4MZR.js";
17
- import "./chunk-RXHTGX7C.js";
9
+ } from "./chunk-42K3BJJH.js";
10
+ import "./chunk-G66HRVDW.js";
18
11
  import {
19
12
  SLUG_RE
20
- } from "./chunk-ZI6PKVXG.js";
13
+ } from "./chunk-TMPBGXT4.js";
14
+ import {
15
+ assertKnownFlags
16
+ } from "./chunk-RZ4DIJQW.js";
17
+ import {
18
+ createClient
19
+ } from "./chunk-CTY2WZQK.js";
20
+ import "./chunk-E3FJUPLT.js";
21
+ import "./chunk-Q5NZNXJE.js";
21
22
  import {
22
23
  isJsonOutput,
23
24
  outputArgs,
24
25
  writeStructured
25
- } from "./chunk-ZYCSYJWX.js";
26
+ } from "./chunk-COSLGSVO.js";
26
27
  import {
27
- assertKnownFlags
28
- } from "./chunk-RZ4DIJQW.js";
28
+ defineCommand
29
+ } from "./chunk-MBXCVCC4.js";
29
30
  import {
30
31
  consola
31
32
  } from "./chunk-D2RF35HJ.js";
33
+ import "./chunk-YNCYMWER.js";
34
+ import "./chunk-AWJNAGPE.js";
32
35
  import {
33
- isJsonObject
34
- } from "./chunk-J6PKNPI2.js";
35
- import {
36
- defineCommand
37
- } from "./chunk-MBXCVCC4.js";
36
+ isJsonObject,
37
+ parseJson
38
+ } from "./chunk-RPSUFZAG.js";
39
+ import "./chunk-2SBBKY5C.js";
38
40
  import "./chunk-GKDUYJ7R.js";
39
41
 
40
42
  // src/commands/fork.ts
@@ -69,7 +71,7 @@ var rewritePackageName = (dir, slug) => {
69
71
  return;
70
72
  }
71
73
  try {
72
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
74
+ const pkg = parseJson(readFileSync(pkgPath, "utf-8"));
73
75
  if (!isJsonObject(pkg)) {
74
76
  throw new Error("package.json is not a JSON object");
75
77
  }
@@ -110,7 +112,7 @@ var forkCommand = defineCommand({
110
112
  rmSync(dir, { force: true, recursive: true });
111
113
  }
112
114
  const client = createClient();
113
- if (!isJsonOutput(args) && !args.field) {
115
+ if (!isJsonOutput(args) && (args.field === void 0 || args.field === "")) {
114
116
  consola.start(`Forking ${source}`);
115
117
  }
116
118
  let src;
@@ -4,47 +4,48 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import {
8
- FACTORY_PACKAGE,
9
- installedFactoryVersion,
10
- updateFactory
11
- } from "./chunk-ZCYWDKYP.js";
12
7
  import {
13
8
  findInstall,
14
9
  reportSkills,
15
10
  settleSync,
16
11
  syncSkills
17
- } from "./chunk-BMTHAVMS.js";
12
+ } from "./chunk-3HGBIUM5.js";
18
13
  import {
19
14
  fetchLatestVersion,
20
15
  isNewerVersion
21
- } from "./chunk-2VUUMXAQ.js";
22
- import "./chunk-7CXMMC5S.js";
23
- import "./chunk-VFFOT7KD.js";
24
- import {
25
- PACKAGE_VERSION
26
- } from "./chunk-Z4Z24FWO.js";
16
+ } from "./chunk-N2UHAQXC.js";
27
17
  import {
28
- detectPackageManager,
29
- globalInstallArgs,
30
- globalInstallCommand
31
- } from "./chunk-PEUP4MZR.js";
32
- import "./chunk-RXHTGX7C.js";
18
+ FACTORY_PACKAGE,
19
+ installedFactoryVersion,
20
+ updateFactory
21
+ } from "./chunk-A556KALN.js";
33
22
  import {
34
23
  isMissingCommand,
35
24
  run
36
- } from "./chunk-TBQ5BU3Q.js";
37
- import "./chunk-5535KDYI.js";
25
+ } from "./chunk-F42QKWBB.js";
26
+ import "./chunk-G66HRVDW.js";
38
27
  import {
39
28
  assertKnownFlags
40
29
  } from "./chunk-RZ4DIJQW.js";
30
+ import "./chunk-JN4WZCR7.js";
31
+ import "./chunk-Q5NZNXJE.js";
32
+ import {
33
+ defineCommand
34
+ } from "./chunk-MBXCVCC4.js";
35
+ import "./chunk-5535KDYI.js";
41
36
  import {
42
37
  consola
43
38
  } from "./chunk-D2RF35HJ.js";
44
- import "./chunk-J6PKNPI2.js";
45
39
  import {
46
- defineCommand
47
- } from "./chunk-MBXCVCC4.js";
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";
48
49
  import "./chunk-GKDUYJ7R.js";
49
50
 
50
51
  // src/commands/update.ts
@@ -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-7CXMMC5S.js";
9
+ } from "./chunk-JN4WZCR7.js";
10
10
  import {
11
11
  getConfigDir
12
- } from "./chunk-RXHTGX7C.js";
12
+ } from "./chunk-Q5NZNXJE.js";
13
13
  import {
14
14
  isJsonNumber,
15
15
  isJsonObject,
16
- isJsonString
17
- } from "./chunk-J6PKNPI2.js";
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 = JSON.parse(readFileSync(cache, "utf-8"));
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.json();
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 (!script) {
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
+ };