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.
Files changed (96) hide show
  1. package/README.md +17 -8
  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 +59 -7
  6. package/dist/chunk-2KVQJKIZ.js +6495 -0
  7. package/dist/chunk-2SBBKY5C.js +16993 -0
  8. package/dist/chunk-2ZKS7V72.js +170 -0
  9. package/dist/{chunk-RAUJA3OY.js → chunk-3HGBIUM5.js} +21 -18
  10. package/dist/chunk-3UGGMFJJ.js +22 -0
  11. package/dist/{chunk-I6O4HIDY.js → chunk-42K3BJJH.js} +163 -131
  12. package/dist/chunk-43P4U7CB.js +104 -0
  13. package/dist/chunk-4FJXCS3K.js +741 -0
  14. package/dist/{chunk-NC5XCGYU.js → chunk-4UU622RK.js} +6 -5
  15. package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
  16. package/dist/chunk-5YPLKGY3.js +87 -0
  17. package/dist/chunk-6KXXZXSO.js +475 -0
  18. package/dist/chunk-7RPLQWR2.js +91 -0
  19. package/dist/{chunk-C2IRIRAA.js → chunk-A556KALN.js} +15 -14
  20. package/dist/{chunk-N3XAUFKH.js → chunk-ABTUEIRC.js} +576 -301
  21. package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
  22. package/dist/{chunk-QGEITHUP.js → chunk-BN3Q7UEC.js} +22 -19
  23. package/dist/chunk-BZOMEG3X.js +412 -0
  24. package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
  25. package/dist/{chunk-PQDBCZRT.js → chunk-CTY2WZQK.js} +204 -158
  26. package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
  27. package/dist/chunk-DB7WVFS7.js +80 -0
  28. package/dist/chunk-DOOQUFPG.js +73 -0
  29. package/dist/chunk-E3FJUPLT.js +177 -0
  30. package/dist/chunk-E7NDOZ27.js +428 -0
  31. package/dist/chunk-F42QKWBB.js +39 -0
  32. package/dist/chunk-FXXVXDTW.js +168 -0
  33. package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
  34. package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
  35. package/dist/chunk-GLEW7VJQ.js +45 -0
  36. package/dist/{chunk-MGIASPED.js → chunk-H2C4QUTG.js} +9 -8
  37. package/dist/{chunk-HCMTSR7E.js → chunk-HRKVAXNN.js} +21 -17
  38. package/dist/{chunk-TLRL6FHW.js → chunk-HSMG6U7J.js} +10 -9
  39. package/dist/chunk-HX5Q63UA.js +48 -0
  40. package/dist/chunk-HYOXGNWS.js +53 -0
  41. package/dist/chunk-I5LELJSK.js +22 -0
  42. package/dist/{chunk-6FZPPUQH.js → chunk-JN4WZCR7.js} +5 -4
  43. package/dist/{chunk-QJZ72MSY.js → chunk-K36EOII3.js} +7 -6
  44. package/dist/chunk-KAGVI3CE.js +62 -0
  45. package/dist/chunk-KJK5CB6E.js +58 -0
  46. package/dist/chunk-KLFBAFXD.js +25 -0
  47. package/dist/{chunk-7MKUR7Y3.js → chunk-LONQWRTR.js} +112 -81
  48. package/dist/chunk-LORGE2NB.js +2484 -0
  49. package/dist/{chunk-HKA5LBYW.js → chunk-MEAO33XW.js} +22 -19
  50. package/dist/{chunk-PM5UOIKR.js → chunk-MR5KIFI7.js} +22 -21
  51. package/dist/{chunk-GCX5KQ6A.js → chunk-N2UHAQXC.js} +18 -11
  52. package/dist/chunk-NCX6LYNJ.js +117 -0
  53. package/dist/chunk-OGX4DKIS.js +215 -0
  54. package/dist/chunk-OPUCUUID.js +41 -0
  55. package/dist/chunk-Q2QC6KAZ.js +132 -0
  56. package/dist/{chunk-2GL2WJZX.js → chunk-Q3XQPNF6.js} +14 -14
  57. package/dist/{chunk-RYFO3ZPO.js → chunk-Q5NZNXJE.js} +15 -12
  58. package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
  59. package/dist/chunk-QLCVLCPM.js +126 -0
  60. package/dist/chunk-R2WVORGD.js +91 -0
  61. package/dist/chunk-RKS7SI5L.js +64 -0
  62. package/dist/{chunk-4BGCA3W7.js → chunk-RPJR3S5S.js} +32 -18
  63. package/dist/chunk-RPSUFZAG.js +3307 -0
  64. package/dist/chunk-RRI23NK2.js +40 -0
  65. package/dist/chunk-S7HYWITX.js +57 -0
  66. package/dist/chunk-SBXCK2I2.js +48 -0
  67. package/dist/chunk-SUSX3QIA.js +62 -0
  68. package/dist/{chunk-PHEDW6C7.js → chunk-SXYQL4GK.js} +16 -7
  69. package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
  70. package/dist/chunk-TXOE5UY5.js +72 -0
  71. package/dist/chunk-U6DTE5IX.js +124 -0
  72. package/dist/chunk-UPHB5HWO.js +115 -0
  73. package/dist/chunk-UQ7VO6B3.js +91 -0
  74. package/dist/chunk-VB4WLJR2.js +47 -0
  75. package/dist/{chunk-FNYBZNW2.js → chunk-VIEKOGKG.js} +21 -3
  76. package/dist/{chunk-QIVCBUYD.js → chunk-VZEJ2ZHE.js} +18 -18
  77. package/dist/chunk-X75Y7LUW.js +126 -0
  78. package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
  79. package/dist/chunk-ZHLPE6LI.js +71 -0
  80. package/dist/index.js +48 -34
  81. package/package.json +32 -16
  82. package/templates/none/src/main.ts +4 -0
  83. package/templates/none/vite.config.ts +0 -2
  84. package/templates/phaser/src/main.ts +0 -1
  85. package/templates/phaser/src/scenes/game-scene.ts +10 -8
  86. package/templates/phaser/vite.config.ts +0 -2
  87. package/templates/react-r3f/src/app.tsx +3 -1
  88. package/templates/react-r3f/src/main.tsx +1 -0
  89. package/templates/react-r3f/vite.config.ts +0 -2
  90. package/templates/threejs/src/main.ts +10 -1
  91. package/templates/threejs/vite.config.ts +0 -2
  92. package/LICENSE +0 -21
  93. package/dist/chunk-AYJQVZXY.js +0 -39
  94. package/dist/chunk-J6PKNPI2.js +0 -26
  95. package/dist/chunk-MJQSHP3Y.js +0 -415
  96. package/dist/chunk-MYFLYNPO.js +0 -68
@@ -0,0 +1,428 @@
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
+ buildManifest,
9
+ resolveBuildDir
10
+ } from "./chunk-X75Y7LUW.js";
11
+ import {
12
+ packBuild,
13
+ packSource
14
+ } from "./chunk-42K3BJJH.js";
15
+ import "./chunk-G66HRVDW.js";
16
+ import {
17
+ SLUG_RE,
18
+ findProjectRoot,
19
+ projectConfigPath,
20
+ readProjectConfig,
21
+ writeProjectConfig
22
+ } from "./chunk-TMPBGXT4.js";
23
+ import {
24
+ assertKnownFlags
25
+ } from "./chunk-RZ4DIJQW.js";
26
+ import {
27
+ createClient
28
+ } from "./chunk-CTY2WZQK.js";
29
+ import "./chunk-E3FJUPLT.js";
30
+ import "./chunk-Q5NZNXJE.js";
31
+ import {
32
+ isJsonOutput,
33
+ outputArgs,
34
+ writeStructured
35
+ } from "./chunk-COSLGSVO.js";
36
+ import {
37
+ defineCommand
38
+ } from "./chunk-MBXCVCC4.js";
39
+ import {
40
+ consola
41
+ } from "./chunk-D2RF35HJ.js";
42
+ import "./chunk-YNCYMWER.js";
43
+ import "./chunk-AWJNAGPE.js";
44
+ import {
45
+ external_exports,
46
+ isJsonString
47
+ } from "./chunk-RPSUFZAG.js";
48
+ import "./chunk-2SBBKY5C.js";
49
+ import "./chunk-GKDUYJ7R.js";
50
+
51
+ // src/commands/deploy.ts
52
+ import { existsSync, readFileSync as readFileSync2, rmSync } from "node:fs";
53
+ import { tmpdir } from "node:os";
54
+ import path from "node:path";
55
+
56
+ // ../../packages/contract/src/deploy/deploy-schema.ts
57
+ var MAX_FILE_SIZE = 10 * 1024 * 1024;
58
+ var MAX_TOTAL_SIZE = 200 * 1024 * 1024;
59
+ var MAX_FILE_COUNT = 500;
60
+ var MAX_SOURCE_SIZE = 100 * 1024 * 1024;
61
+ var MAX_UPLOAD_BODY = 100 * 1024 * 1024;
62
+ var slugSchema = external_exports.string().min(3).max(40).regex(/^[a-z0-9][a-z0-9-]*[a-z0-9]$/u, {
63
+ message: "slug must be lowercase alphanumeric with hyphens"
64
+ });
65
+ var fileSchema = external_exports.object({
66
+ contentType: external_exports.string().min(1).max(127),
67
+ path: external_exports.string().min(1).max(512).refine((p) => !p.startsWith("/"), "path must be relative").refine((p) => !p.includes(".."), "path must not contain ..").describe(
68
+ "The file's path from the game's root, e.g. `index.html` or `assets/hero.png`; no leading `/` and no `..`"
69
+ ),
70
+ sha256: external_exports.string().length(64).describe("The SHA-256 of the file's bytes as 64 hex characters, as `sha256sum` prints it"),
71
+ size: external_exports.number().int().nonnegative().max(MAX_FILE_SIZE).describe(
72
+ `The file's exact size in bytes, at most ${MAX_FILE_SIZE} (10 MB); publish checks the uploaded file has this size`
73
+ )
74
+ });
75
+ var createInput = external_exports.object({
76
+ files: external_exports.array(fileSchema).min(1).max(MAX_FILE_COUNT),
77
+ name: external_exports.string().max(120).optional(),
78
+ slug: slugSchema,
79
+ source: external_exports.object({
80
+ bytes: external_exports.number().int().positive().max(MAX_SOURCE_SIZE),
81
+ sha256: external_exports.string().length(64)
82
+ }).optional()
83
+ });
84
+ var finalizeInput = external_exports.object({
85
+ deploymentId: external_exports.string()
86
+ });
87
+ var deleteInput = external_exports.object({
88
+ gameId: external_exports.string().describe(
89
+ "The id of one of your games: a game's `id` in the deployments list, or the `gameId` deploy returned"
90
+ )
91
+ });
92
+ var getSourceInput = external_exports.object({
93
+ slug: slugSchema.describe(
94
+ "The slug of the game to fork, as in its address `{slug}.vibedgames.com`, e.g. `space-pong`; any game deployed with source can be forked"
95
+ )
96
+ });
97
+ var inlineFileSchema = external_exports.object({
98
+ content: external_exports.string().describe("The file's text, or with `encoding: url` a generated asset's URL"),
99
+ contentType: external_exports.string().min(1).max(127).optional().describe(
100
+ "The MIME type to serve the file with, e.g. `text/html; charset=utf-8`; omit to infer it from the path's extension"
101
+ ),
102
+ encoding: external_exports.enum(["utf-8", "url"]).default("utf-8").describe(
103
+ "How to read `content`: `utf-8` (the default) stores it as the file's text; `url` fetches it from a URL a generate tool returned (other hosts are refused), up to 10 MB a file and 32 MB a call"
104
+ ),
105
+ path: fileSchema.shape.path
106
+ });
107
+ var presignedFileSchema = fileSchema.extend({
108
+ contentType: fileSchema.shape.contentType.optional().describe(
109
+ "The MIME type to serve the file with, and the Content-Type to PUT it with, e.g. `image/png`; omit to infer it from the path's extension"
110
+ )
111
+ });
112
+ var uploadInput = external_exports.object({
113
+ bundle: external_exports.boolean().default(false).describe(
114
+ "true returns a `bundleUpload` URL to PUT the whole built game to as one gzipped tar, `index.html` at its root (`tar -czf game.tgz -C dist .`); a later call with `publish: true` unpacks it. The usual way in. Default false"
115
+ ),
116
+ deploymentId: external_exports.string().optional().describe(
117
+ "The `deploymentId` an earlier deploy call for this slug returned, to add files to that staged deployment or publish it; omit to stage a new one"
118
+ ),
119
+ files: external_exports.array(inlineFileSchema).max(MAX_FILE_COUNT).default([]).describe(
120
+ "Files sent in the call itself: text, or a generated asset's URL with `encoding: url`. A path already staged is replaced. Default none"
121
+ ),
122
+ name: external_exports.string().max(120).optional().describe(
123
+ "The game's display name, up to 120 characters, e.g. `Space Pong`; omit to keep the name it has"
124
+ ),
125
+ presign: external_exports.array(presignedFileSchema).max(MAX_FILE_COUNT).default([]).describe(
126
+ "Files you PUT yourself: each returns a signed URL in `uploads`, valid 15 minutes, to PUT its bytes to with the `headers` given; list a file again to renew its URL. Default none"
127
+ ),
128
+ publish: external_exports.boolean().default(false).describe(
129
+ "true makes the staged deployment live at `{slug}.vibedgames.com` once this call's files are in (it needs `index.html` and every presigned file at its declared size), then removes the previous one. Default false: the files stay staged"
130
+ ),
131
+ slug: slugSchema.describe(
132
+ "The game's slug, which makes its address `{slug}.vibedgames.com`: 3 to 40 lowercase letters, digits and hyphens, no hyphen at either end, e.g. `space-pong`. A new slug becomes your game, one another account owns is refused; pass the same one on every call of a deployment"
133
+ ),
134
+ source: external_exports.boolean().default(false).describe(
135
+ "With `publish: true`, also keep the deployment's files (up to 64 MB) as the game's forkable source, which fork downloads. Default false; not with `sourceArchive`"
136
+ ),
137
+ sourceArchive: external_exports.object({
138
+ bytes: external_exports.number().int().positive().max(MAX_SOURCE_SIZE).describe(
139
+ `The archive's exact size in bytes, at most ${MAX_SOURCE_SIZE} (100 MB); publish checks the upload has this size`
140
+ ),
141
+ sha256: external_exports.string().length(64).describe("The SHA-256 of the archive's bytes as 64 hex characters")
142
+ }).optional().describe(
143
+ "Your own forkable source archive (a .tar.gz of the project, what `vg deploy --source` packs), which you PUT to the `sourceUpload` URL this call returns; omit for none. Not with `source: true`"
144
+ )
145
+ });
146
+
147
+ // src/lib/upload.ts
148
+ import { readFileSync } from "node:fs";
149
+ var uploadAll = async ({
150
+ files,
151
+ uploads,
152
+ concurrency = 6,
153
+ onProgress
154
+ }) => {
155
+ const byPath = new Map(files.map((f) => [f.path, f]));
156
+ let done = 0;
157
+ let cursor = 0;
158
+ const worker = async () => {
159
+ const idx = cursor;
160
+ cursor += 1;
161
+ if (idx >= uploads.length) {
162
+ return;
163
+ }
164
+ const upload = uploads[idx];
165
+ if (!upload) {
166
+ return;
167
+ }
168
+ const file = byPath.get(upload.path);
169
+ if (!file) {
170
+ throw new Error(`Missing file for upload target: ${upload.path}`);
171
+ }
172
+ const body = readFileSync(file.absolutePath);
173
+ const res = await fetch(upload.url, {
174
+ body,
175
+ headers: upload.headers,
176
+ method: "PUT"
177
+ });
178
+ if (!res.ok) {
179
+ const text = await res.text().catch(() => "");
180
+ throw new Error(`Upload failed for ${upload.path}: ${res.status} ${res.statusText} ${text}`);
181
+ }
182
+ done += 1;
183
+ onProgress?.(done, uploads.length);
184
+ await worker();
185
+ };
186
+ const workers = Array.from({ length: Math.min(concurrency, uploads.length) }, async () => {
187
+ await worker();
188
+ });
189
+ await Promise.all(workers);
190
+ };
191
+
192
+ // src/commands/deploy.ts
193
+ var deployArgs = {
194
+ dir: {
195
+ default: ".",
196
+ description: "Directory to deploy",
197
+ required: false,
198
+ type: "positional"
199
+ },
200
+ slug: {
201
+ description: "Override the slug (bypasses vibedgames.json)",
202
+ required: false,
203
+ type: "string"
204
+ },
205
+ source: {
206
+ default: false,
207
+ description: "Also upload a forkable source archive, letting anyone logged in fork the project.",
208
+ type: "boolean"
209
+ },
210
+ ...outputArgs
211
+ };
212
+ var formatBytes = (n) => {
213
+ if (n < 1024) {
214
+ return `${n} B`;
215
+ }
216
+ if (n < 1024 * 1024) {
217
+ return `${(n / 1024).toFixed(1)} KB`;
218
+ }
219
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
220
+ };
221
+ var resolveDeployDir = (dir, say) => {
222
+ const build = resolveBuildDir(dir);
223
+ if (build.kind === "build") {
224
+ say(`Project root detected \u2014 deploying its build output ${build.name}/ instead.`);
225
+ } else if (build.kind === "unbuilt") {
226
+ consola.warn(
227
+ "This looks like an unbuilt project (package.json, no dist/build/out) \u2014 run the build first, or the deployed index.html will reference missing source files."
228
+ );
229
+ }
230
+ return build.dir;
231
+ };
232
+ var promptForConfig = async (dir, say) => {
233
+ if (!process.stdin.isTTY) {
234
+ consola.error(
235
+ "No slug specified and no vibedgames.json found.\n Pass --slug <name> when running without a TTY (e.g. in CI or from a coding agent).\n Example: vg deploy ./dist --slug my-game"
236
+ );
237
+ process.exit(1);
238
+ }
239
+ const slug = await consola.prompt("Slug (e.g. pong):", { type: "text" });
240
+ if (!isJsonString(slug) || !SLUG_RE.test(slug)) {
241
+ consola.error("Invalid slug. Use lowercase letters, digits, hyphens.");
242
+ process.exit(1);
243
+ }
244
+ const name = await consola.prompt("Name (optional):", { type: "text" });
245
+ const config = {
246
+ name: isJsonString(name) && name.length > 0 ? name : void 0,
247
+ slug
248
+ };
249
+ writeProjectConfig(dir, config);
250
+ say(`Wrote ${projectConfigPath(dir)}`);
251
+ return config;
252
+ };
253
+ var resolveDeployConfig = async (dir, slugOverride, say) => {
254
+ let config = null;
255
+ try {
256
+ config = readProjectConfig(dir);
257
+ } catch (error) {
258
+ consola.error(error instanceof Error ? error.message : String(error));
259
+ process.exit(1);
260
+ }
261
+ if (slugOverride !== void 0 && slugOverride !== "") {
262
+ config = { name: config?.name, slug: slugOverride };
263
+ }
264
+ config ??= await promptForConfig(dir, say);
265
+ if (!SLUG_RE.test(config.slug)) {
266
+ consola.error(`Invalid slug in vibedgames.json: ${config.slug}`);
267
+ process.exit(1);
268
+ }
269
+ return config;
270
+ };
271
+ var packForkableSource = async (dir, slug, say) => {
272
+ const root = findProjectRoot(dir);
273
+ if (root === null || root === "") {
274
+ consola.warn("No vibedgames.json found above the deploy dir \u2014 skipping source upload.");
275
+ return null;
276
+ }
277
+ try {
278
+ const archive = await packSource(root, path.join(tmpdir(), "vibedgames"));
279
+ say(
280
+ `Source: ${archive.files.length} files, ${formatBytes(archive.bytes)} \u2014 forkable via \`vg fork ${slug}\``
281
+ );
282
+ return archive;
283
+ } catch (error) {
284
+ consola.error(
285
+ `Source archive failed: ${error instanceof Error ? error.message : String(error)}`
286
+ );
287
+ return process.exit(1);
288
+ }
289
+ };
290
+ var putArchive = async (archivePath, upload, what) => {
291
+ const res = await fetch(upload.url, {
292
+ body: readFileSync2(archivePath),
293
+ headers: upload.headers,
294
+ method: "PUT"
295
+ });
296
+ if (!res.ok) {
297
+ throw new Error(`${what} upload failed: ${res.status} ${res.statusText}`);
298
+ }
299
+ };
300
+ var publishDeployment = async (client, { deploymentId, slug }) => {
301
+ try {
302
+ const published = await client.deploy.upload({ deploymentId, publish: true, slug });
303
+ if (published.url === null) {
304
+ throw new Error("The deployment did not publish.");
305
+ }
306
+ return { url: published.url };
307
+ } catch (error) {
308
+ consola.error(error instanceof Error ? error.message : String(error));
309
+ return process.exit(1);
310
+ }
311
+ };
312
+ var deployCommand = defineCommand({
313
+ args: deployArgs,
314
+ meta: {
315
+ description: "Deploy a game to vibedgames",
316
+ name: "deploy"
317
+ },
318
+ run: async ({ args, rawArgs }) => {
319
+ assertKnownFlags(rawArgs, deployArgs);
320
+ const structured = isJsonOutput(args) || Boolean(args.field);
321
+ const say = structured ? () => null : (message) => {
322
+ consola.info(message);
323
+ };
324
+ const dir = path.resolve(args.dir);
325
+ if (!existsSync(dir)) {
326
+ consola.error(`Directory does not exist: ${dir}`);
327
+ process.exit(1);
328
+ }
329
+ const deployDir = resolveDeployDir(dir, say);
330
+ const config = await resolveDeployConfig(dir, args.slug, say);
331
+ const manifest = buildManifest(deployDir);
332
+ if (manifest.length === 0) {
333
+ consola.error(`No files found in ${deployDir}`);
334
+ process.exit(1);
335
+ }
336
+ const hasIndex = manifest.some((f) => f.path === "index.html");
337
+ if (!hasIndex) {
338
+ consola.error("Deployment must contain an index.html at the root.");
339
+ process.exit(1);
340
+ }
341
+ const totalBytes = manifest.reduce((acc, f) => acc + f.size, 0);
342
+ say(`Deploying ${config.slug}: ${manifest.length} files, ${formatBytes(totalBytes)}`);
343
+ const sourceArchive = args.source ? await packForkableSource(dir, config.slug, say) : null;
344
+ const tmp = path.join(tmpdir(), "vibedgames");
345
+ const bundle = await packBuild(
346
+ deployDir,
347
+ manifest.map((f) => f.path),
348
+ tmp
349
+ );
350
+ const cleanUp = () => {
351
+ rmSync(bundle.path, { force: true });
352
+ if (sourceArchive) {
353
+ rmSync(sourceArchive.path, { force: true });
354
+ }
355
+ };
356
+ const client = createClient();
357
+ const started = Date.now();
358
+ const asBundle = bundle.bytes <= MAX_UPLOAD_BODY;
359
+ let created;
360
+ try {
361
+ created = await client.deploy.upload({
362
+ bundle: asBundle,
363
+ name: config.name,
364
+ presign: asBundle ? [] : manifest.map((f) => ({
365
+ contentType: f.contentType,
366
+ path: f.path,
367
+ sha256: f.sha256,
368
+ size: f.size
369
+ })),
370
+ slug: config.slug,
371
+ sourceArchive: sourceArchive ? { bytes: sourceArchive.bytes, sha256: sourceArchive.sha256 } : void 0
372
+ });
373
+ if (!structured) {
374
+ consola.start(
375
+ asBundle ? `Uploading ${formatBytes(bundle.bytes)}` : `Uploading ${manifest.length} files (too large for one bundle)`
376
+ );
377
+ }
378
+ if (asBundle) {
379
+ if (!created.bundleUpload) {
380
+ throw new Error("The server returned no bundle upload URL.");
381
+ }
382
+ await putArchive(bundle.path, created.bundleUpload, "bundle");
383
+ } else {
384
+ await uploadAll({
385
+ files: manifest,
386
+ onProgress: (done, total) => {
387
+ if (done === total || done % 10 === 0) {
388
+ say(`Uploaded ${done}/${total}`);
389
+ }
390
+ },
391
+ uploads: created.uploads
392
+ });
393
+ }
394
+ if (sourceArchive && created.sourceUpload) {
395
+ await putArchive(sourceArchive.path, created.sourceUpload, "source");
396
+ }
397
+ } catch (error) {
398
+ cleanUp();
399
+ consola.error(error instanceof Error ? error.message : String(error));
400
+ process.exit(1);
401
+ }
402
+ cleanUp();
403
+ const published = await publishDeployment(client, {
404
+ deploymentId: created.deploymentId,
405
+ slug: config.slug
406
+ });
407
+ const elapsedMs = Date.now() - started;
408
+ if (writeStructured(
409
+ {
410
+ bytes: totalBytes,
411
+ deployment_id: created.deploymentId,
412
+ elapsed_ms: elapsedMs,
413
+ files: manifest.length,
414
+ slug: config.slug,
415
+ source: sourceArchive ? { bytes: sourceArchive.bytes, files: sourceArchive.files.length } : null,
416
+ url: published.url
417
+ },
418
+ args
419
+ )) {
420
+ return;
421
+ }
422
+ consola.success(`Deployed ${config.slug} in ${(elapsedMs / 1e3).toFixed(1)}s`);
423
+ consola.log(` ${published.url}`);
424
+ }
425
+ });
426
+ export {
427
+ deployCommand
428
+ };
@@ -0,0 +1,39 @@
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
+ __toESM
12
+ } from "./chunk-GKDUYJ7R.js";
13
+
14
+ // src/lib/run.ts
15
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
16
+ var isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/iu.test(result.output);
17
+ var run = async (cmd, args, cwd) => {
18
+ const { promise, resolve } = Promise.withResolvers();
19
+ const chunks = [];
20
+ const child = (0, import_cross_spawn.default)(cmd, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
21
+ const collect = (c) => {
22
+ chunks.push(c);
23
+ };
24
+ child.stdout?.on("data", collect);
25
+ child.stderr?.on("data", collect);
26
+ child.on("error", (err) => {
27
+ resolve({ code: 1, output: `${err.message}
28
+ ` });
29
+ });
30
+ child.on("close", (code) => {
31
+ resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf-8") });
32
+ });
33
+ return await promise;
34
+ };
35
+
36
+ export {
37
+ isMissingCommand,
38
+ run
39
+ };
@@ -0,0 +1,168 @@
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
+ ASSETS_DIR
9
+ } from "./chunk-YNCYMWER.js";
10
+ import "./chunk-AWJNAGPE.js";
11
+ import "./chunk-RPSUFZAG.js";
12
+ import {
13
+ MANIFEST_JSON_CANDIDATES,
14
+ createTilemapEditor,
15
+ exportMapRender,
16
+ exportTilesetGrid,
17
+ fail,
18
+ getAll,
19
+ getFlag,
20
+ getInt,
21
+ getString,
22
+ isJsonObject,
23
+ isJsonString,
24
+ loadManifestJson,
25
+ main,
26
+ makeSelftestMap,
27
+ parseArgs,
28
+ parseColor,
29
+ parseJsonText,
30
+ sanitizeTilesets,
31
+ tilesetMetaFromManifest,
32
+ writeJsonFile
33
+ } from "./chunk-2KVQJKIZ.js";
34
+ import "./chunk-2SBBKY5C.js";
35
+ import "./chunk-GKDUYJ7R.js";
36
+
37
+ // src/commands/asset/tilemap-editor.ts
38
+ import { existsSync, readFileSync, statSync } from "node:fs";
39
+ import path from "node:path";
40
+ var firstTileset = (manifestPath, tilesets) => Object.keys(tilesets).toSorted()[0] ?? fail(`No tilesets in ${manifestPath}.`);
41
+ var resolveManifest = (explicit = "") => {
42
+ if (explicit === "") {
43
+ return MANIFEST_JSON_CANDIDATES.find((c) => existsSync(c)) ?? fail(
44
+ `Manifest not found. Pass --manifest or create one of: ${MANIFEST_JSON_CANDIDATES.join(", ")}`
45
+ );
46
+ }
47
+ if (existsSync(explicit) && statSync(explicit).isDirectory()) {
48
+ return ["assets_index.json", "asset_index.json"].map((n) => path.join(explicit, n)).find((c) => existsSync(c)) ?? fail(
49
+ `--manifest points at a directory (${explicit}), but no assets_index.json was found inside.`
50
+ );
51
+ }
52
+ if (!existsSync(explicit)) {
53
+ fail(`Manifest not found: ${explicit}`);
54
+ }
55
+ return explicit;
56
+ };
57
+ var run = (argv) => {
58
+ main(() => {
59
+ const args = parseArgs([...argv], {
60
+ booleans: ["edit", "label-ids", "trim"],
61
+ values: [
62
+ "bg",
63
+ "export-map-render",
64
+ "export-tileset-grid",
65
+ "fill-rect",
66
+ "host",
67
+ "make-selftest-map",
68
+ "manifest",
69
+ "map",
70
+ "port",
71
+ "scale",
72
+ "tileset",
73
+ "write-root"
74
+ ]
75
+ });
76
+ const manifestPath = resolveManifest(getString(args, "manifest"));
77
+ const manifest = loadManifestJson(manifestPath);
78
+ const tilesets = sanitizeTilesets(manifest);
79
+ const name = getString(args, "tileset") ?? firstTileset(manifestPath, tilesets);
80
+ let meta = tilesetMetaFromManifest(manifestPath, manifest, name);
81
+ const scale = getInt(args, "scale", 4);
82
+ const trim = getFlag(args, "trim");
83
+ const gridOut = getString(args, "export-tileset-grid") ?? "";
84
+ const renderOut = getString(args, "export-map-render") ?? "";
85
+ const selftestOut = getString(args, "make-selftest-map") ?? "";
86
+ const startEditor = () => {
87
+ const html = readFileSync(path.join(ASSETS_DIR, "tilemap-editor.html"), "utf-8");
88
+ const host = getString(args, "host") ?? "127.0.0.1";
89
+ const port = getInt(args, "port", 0);
90
+ const editor = createTilemapEditor({
91
+ html,
92
+ manifestPath,
93
+ mapPath: getString(args, "map") ?? null,
94
+ tileset: name,
95
+ writeRoot: getString(args, "write-root") ?? process.cwd()
96
+ });
97
+ editor.server.on("error", (error) => {
98
+ fail(
99
+ "code" in error && error.code === "EADDRINUSE" ? `Port ${port} is already in use \u2014 pass a different --port, or omit it to get a free one.` : error.message
100
+ );
101
+ });
102
+ editor.server.listen(port, host, () => {
103
+ const address = editor.server.address();
104
+ const actual = address !== null && address instanceof Object ? address.port : port;
105
+ console.log(`Tilemap editor: ${editor.url(actual, host)}`);
106
+ console.log("Open that URL (the token is part of it). Ctrl-C to stop.");
107
+ });
108
+ process.on("SIGINT", () => {
109
+ editor.server.close();
110
+ process.exit(0);
111
+ });
112
+ };
113
+ if (getFlag(args, "edit")) {
114
+ startEditor();
115
+ return;
116
+ }
117
+ if (gridOut === "" && renderOut === "" && selftestOut === "") {
118
+ fail(
119
+ "Nothing to do. Pass --edit, --export-tileset-grid, --export-map-render or --make-selftest-map."
120
+ );
121
+ }
122
+ if (gridOut !== "") {
123
+ exportTilesetGrid(meta, gridOut, { labelIds: getFlag(args, "label-ids"), scale, trim });
124
+ console.log(`Wrote ${gridOut}`);
125
+ }
126
+ if (renderOut !== "") {
127
+ const mapPath = getString(args, "map") ?? "";
128
+ if (mapPath === "") {
129
+ fail("--export-map-render requires --map PATH");
130
+ }
131
+ const parsedMap = parseJsonText(readFileSync(mapPath, "utf-8"));
132
+ const mapPayload = isJsonObject(parsedMap) ? parsedMap : fail("Map JSON must be an object at top-level.");
133
+ const mapMeta = mapPayload.meta;
134
+ if (isJsonObject(mapMeta) && isJsonString(mapMeta.tileset) && mapMeta.tileset in tilesets) {
135
+ meta = tilesetMetaFromManifest(manifestPath, manifest, mapMeta.tileset);
136
+ }
137
+ const fills = getAll(args, "fill-rect").map((spec) => {
138
+ const parts = spec.split(",").map((p) => p.trim());
139
+ if (parts.length !== 5) {
140
+ fail("--fill-rect must be x,y,w,h,#RRGGBB[AA]");
141
+ }
142
+ return {
143
+ color: parseColor(parts[4] ?? ""),
144
+ h: Number(parts[3]),
145
+ w: Number(parts[2]),
146
+ x: Number(parts[0]),
147
+ y: Number(parts[1])
148
+ };
149
+ });
150
+ const bg = getString(args, "bg") ?? "";
151
+ exportMapRender(meta, renderOut, {
152
+ background: bg === "" ? null : parseColor(bg),
153
+ fills,
154
+ mapPayload,
155
+ scale,
156
+ trim
157
+ });
158
+ console.log(`Wrote ${renderOut}`);
159
+ }
160
+ if (selftestOut !== "") {
161
+ writeJsonFile(selftestOut, makeSelftestMap(meta));
162
+ console.log(`Wrote ${selftestOut}`);
163
+ }
164
+ });
165
+ };
166
+ export {
167
+ run
168
+ };
@@ -5,7 +5,7 @@ const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
 
8
- // ../../node_modules/.pnpm/tar@7.5.22/node_modules/tar/dist/esm/index.min.js
8
+ // ../../node_modules/.pnpm/tar@7.5.23/node_modules/tar/dist/esm/index.min.js
9
9
  import Qr from "events";
10
10
  import I from "fs";
11
11
  import { EventEmitter as Di } from "node:events";
@@ -23,6 +23,10 @@ var __commonJS = (cb, mod) => function __require2() {
23
23
  throw mod = 0, e;
24
24
  }
25
25
  };
26
+ var __export = (target, all) => {
27
+ for (var name in all)
28
+ __defProp(target, name, { get: all[name], enumerable: true });
29
+ };
26
30
  var __copyProps = (to, from, except, desc) => {
27
31
  if (from && typeof from === "object" || typeof from === "function") {
28
32
  for (let key of __getOwnPropNames(from))
@@ -43,5 +47,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
47
  export {
44
48
  __require,
45
49
  __commonJS,
50
+ __export,
46
51
  __toESM
47
52
  };