@bitmagic/cli 0.1.36 → 0.1.37
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/dist/commands/forge.js +39 -26
- package/dist/commands/forge.js.map +1 -1
- package/dist/editor/shell-page.js +123 -7
- package/dist/editor/shell-page.js.map +1 -1
- package/dist/forge/browser-host.d.ts +0 -10
- package/dist/forge/browser-host.js +0 -12
- package/dist/forge/browser-host.js.map +1 -1
- package/dist/forge/progress.d.ts +80 -0
- package/dist/forge/progress.js +158 -0
- package/dist/forge/progress.js.map +1 -0
- package/dist/forge/run-pipeline.d.ts +11 -2
- package/dist/forge/run-pipeline.js +9 -7
- package/dist/forge/run-pipeline.js.map +1 -1
- package/dist/forge/stream.d.ts +14 -3
- package/dist/forge/stream.js +62 -9
- package/dist/forge/stream.js.map +1 -1
- package/dist/forge/transport.js +14 -3
- package/dist/forge/transport.js.map +1 -1
- package/dist/project/jobs.d.ts +22 -1
- package/dist/project/jobs.js +60 -3
- package/dist/project/jobs.js.map +1 -1
- package/package.json +3 -3
- package/dist/forge/bake-progress.d.ts +0 -44
- package/dist/forge/bake-progress.js +0 -77
- package/dist/forge/bake-progress.js.map +0 -1
package/dist/project/jobs.js
CHANGED
|
@@ -83,6 +83,40 @@ function writeRecord(root, record) {
|
|
|
83
83
|
function isRecord(value) {
|
|
84
84
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Read a progress snapshot off a record, or `undefined` when there is not a well-formed one.
|
|
88
|
+
*
|
|
89
|
+
* These files cross a process boundary and a VERSION boundary — the writer is whichever
|
|
90
|
+
* `bitmagic` binary started the generation, the reader is whichever `bitmagic dev` happens to be
|
|
91
|
+
* running — so the field is treated as untrusted input rather than as something this build wrote.
|
|
92
|
+
* Dropping it is the right degradation and matches the rest of this file: the record still carries
|
|
93
|
+
* its `message`, so a reader that cannot make sense of the steps falls back to the sentence.
|
|
94
|
+
*
|
|
95
|
+
* `summary` is passed through unshaped on purpose. It is display-only, every field is optional,
|
|
96
|
+
* and its contents are the pipeline's schema, not this file's — re-deriving that shape here would
|
|
97
|
+
* be a second copy to keep in step for no invariant worth protecting.
|
|
98
|
+
*/
|
|
99
|
+
function parseProgress(value) {
|
|
100
|
+
if (!isRecord(value) || !Array.isArray(value.steps))
|
|
101
|
+
return undefined;
|
|
102
|
+
const steps = value.steps.filter((step) => isRecord(step) && typeof step.key === 'string' && typeof step.label === 'string'
|
|
103
|
+
&& (step.status === 'pending' || step.status === 'running' || step.status === 'done'));
|
|
104
|
+
if (steps.length === 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
return {
|
|
107
|
+
steps: steps.map((step) => ({
|
|
108
|
+
key: step.key,
|
|
109
|
+
label: step.label,
|
|
110
|
+
status: step.status,
|
|
111
|
+
...(typeof step.durationMs === 'number' ? { durationMs: step.durationMs } : {}),
|
|
112
|
+
...(typeof step.completed === 'number' ? { completed: step.completed } : {}),
|
|
113
|
+
...(typeof step.total === 'number' ? { total: step.total } : {}),
|
|
114
|
+
...(typeof step.detail === 'string' ? { detail: step.detail } : {}),
|
|
115
|
+
...(step.resumed === true ? { resumed: true } : {}),
|
|
116
|
+
})),
|
|
117
|
+
...(isRecord(value.summary) ? { summary: value.summary } : {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
86
120
|
function parseRecord(raw) {
|
|
87
121
|
let parsed;
|
|
88
122
|
try {
|
|
@@ -96,6 +130,7 @@ function parseRecord(raw) {
|
|
|
96
130
|
const { jobId, kind, label, status, message, pid, startedAt, updatedAt } = parsed;
|
|
97
131
|
if (typeof jobId !== 'string' || typeof kind !== 'string' || typeof pid !== 'number')
|
|
98
132
|
return null;
|
|
133
|
+
const progress = parseProgress(parsed.progress);
|
|
99
134
|
return {
|
|
100
135
|
jobId,
|
|
101
136
|
kind: kind,
|
|
@@ -103,6 +138,7 @@ function parseRecord(raw) {
|
|
|
103
138
|
...(typeof parsed.assetId === 'string' ? { assetId: parsed.assetId } : {}),
|
|
104
139
|
status: status === 'failed' ? 'failed' : 'running',
|
|
105
140
|
message: typeof message === 'string' ? message : '',
|
|
141
|
+
...(progress ? { progress } : {}),
|
|
106
142
|
pid,
|
|
107
143
|
startedAt: typeof startedAt === 'string' ? startedAt : '',
|
|
108
144
|
updatedAt: typeof updatedAt === 'string' ? updatedAt : '',
|
|
@@ -248,12 +284,19 @@ export function startJob(options) {
|
|
|
248
284
|
updatedAt: now,
|
|
249
285
|
};
|
|
250
286
|
writeRecord(options.root, record);
|
|
287
|
+
const touch = () => {
|
|
288
|
+
record.updatedAt = new Date().toISOString();
|
|
289
|
+
writeRecord(options.root, record);
|
|
290
|
+
};
|
|
251
291
|
return {
|
|
252
292
|
jobId: record.jobId,
|
|
253
293
|
update: (message) => {
|
|
254
294
|
record.message = message;
|
|
255
|
-
|
|
256
|
-
|
|
295
|
+
touch();
|
|
296
|
+
},
|
|
297
|
+
setProgress: (progress) => {
|
|
298
|
+
record.progress = progress;
|
|
299
|
+
touch();
|
|
257
300
|
},
|
|
258
301
|
};
|
|
259
302
|
}
|
|
@@ -266,6 +309,12 @@ export function startJob(options) {
|
|
|
266
309
|
* way since it shipped, and it means a command gains live progress in the dev view without a single
|
|
267
310
|
* new call site inside it.
|
|
268
311
|
*
|
|
312
|
+
* The SECOND argument is for the one command that has more than a sentence to say. A forge runs
|
|
313
|
+
* for half an hour across five steps on two machines, and a line-at-a-time record can only ever
|
|
314
|
+
* show the most recent one — so `forge` also reports a snapshot of all five (see
|
|
315
|
+
* `forge/progress.ts`). Every other caller ignores this parameter, which is the point: the log tap
|
|
316
|
+
* above stays the default, and structured progress is opt-in for the kind that needs it.
|
|
317
|
+
*
|
|
269
318
|
* **Never fails the generation it is watching.** Bookkeeping that breaks a paid, minutes-long
|
|
270
319
|
* generation would be a far worse bug than the missing progress line it is trying to provide, so
|
|
271
320
|
* every filesystem error here is swallowed. The body's own errors propagate untouched, after being
|
|
@@ -289,8 +338,16 @@ export async function withJobRecord(options, body) {
|
|
|
289
338
|
// Same.
|
|
290
339
|
}
|
|
291
340
|
};
|
|
341
|
+
const report = (progress) => {
|
|
342
|
+
try {
|
|
343
|
+
handle?.setProgress(progress);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// Same.
|
|
347
|
+
}
|
|
348
|
+
};
|
|
292
349
|
try {
|
|
293
|
-
const result = await body(log);
|
|
350
|
+
const result = await body(log, report);
|
|
294
351
|
if (handle)
|
|
295
352
|
removeJob(options.root, handle.jobId);
|
|
296
353
|
return result;
|
package/dist/project/jobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/project/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/project/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAmChE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAEvD,4EAA4E;AAC5E,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjD,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,IAAI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EAAmE;AACnE,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,IAAI,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,6FAA6F;IAC/F,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,KAAa;IAChE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7E,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO;QAC9B,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACnG,CAAC;IAAC,MAAM,CAAC;QACP,8EAA8E;IAChF,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitmagic/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Build Bitmagic games from your own agent tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"citty": "^0.2.2",
|
|
20
20
|
"playwright-core": "^1.59.1",
|
|
21
21
|
"tar": "^7.4.3",
|
|
22
|
-
"@bitmagic/
|
|
23
|
-
"@bitmagic/
|
|
22
|
+
"@bitmagic/asset-core": "0.1.2",
|
|
23
|
+
"@bitmagic/world-forger": "0.1.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@eslint/js": "^9.38.0",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal progress for the level bake.
|
|
3
|
-
*
|
|
4
|
-
* The bake is the one step that can legitimately run for many minutes, and its transport wait is
|
|
5
|
-
* an IDLE timeout of 20 minutes (`VOXELIZE_TIMEOUT_MS`) — per-chunk progress re-arms the timer but
|
|
6
|
-
* is otherwise consumed silently inside the transport. Without a printed line a creator watching a
|
|
7
|
-
* still terminal concludes the command has hung and kills it mid-bake, losing the whole step. So
|
|
8
|
-
* the command subscribes to the page's own `VOXELIZE_GLB_AS_LEVEL_PROGRESS` messages
|
|
9
|
-
* (`game/src/engine/template/VoxelMessageHandlers.ts`) and prints them.
|
|
10
|
-
*
|
|
11
|
-
* Throttled, because the engine emits one message per chunk and a large level has thousands: an
|
|
12
|
-
* unthrottled relay would bury every other line of output. The formatter and the throttle are pure
|
|
13
|
-
* and separate from the subscription so both are testable without a browser.
|
|
14
|
-
*/
|
|
15
|
-
/** The engine's per-chunk progress payload. `chunkIndex: -1` marks the post-bake upload phase. */
|
|
16
|
-
export interface BakeProgress {
|
|
17
|
-
chunkIndex: number;
|
|
18
|
-
totalChunks: number;
|
|
19
|
-
nonEmptyChunks?: number;
|
|
20
|
-
label?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare const BAKE_PROGRESS_TYPE = "VOXELIZE_GLB_AS_LEVEL_PROGRESS";
|
|
23
|
-
/** Minimum gap between printed bake lines. Long enough not to flood, short enough that the
|
|
24
|
-
* terminal never looks frozen. */
|
|
25
|
-
export declare const BAKE_PROGRESS_MIN_INTERVAL_MS = 3000;
|
|
26
|
-
/** Read a bake-progress payload off a page message, or null if it is not one. */
|
|
27
|
-
export declare function asBakeProgress(message: unknown): BakeProgress | null;
|
|
28
|
-
/**
|
|
29
|
-
* The line to print for one progress message.
|
|
30
|
-
*
|
|
31
|
-
* `chunkIndex: -1` / `totalChunks: -1` is the engine's sentinel for the upload phase that follows
|
|
32
|
-
* the chunk loop; it carries a label instead of a count, so it is rendered as that label rather
|
|
33
|
-
* than as a nonsensical "chunk -1 of -1".
|
|
34
|
-
*/
|
|
35
|
-
export declare function formatBakeProgress(progress: BakeProgress): string;
|
|
36
|
-
/**
|
|
37
|
-
* A printer that emits at most one line per `minIntervalMs` — except for the final chunk and the
|
|
38
|
-
* label-only phases, which always print. The last chunk is what tells a creator the loop finished
|
|
39
|
-
* rather than stalled, so dropping it to a throttle would remove the single most informative line.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createBakeProgressPrinter(log: (message: string) => void, options?: {
|
|
42
|
-
minIntervalMs?: number;
|
|
43
|
-
now?: () => number;
|
|
44
|
-
}): (message: unknown) => void;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal progress for the level bake.
|
|
3
|
-
*
|
|
4
|
-
* The bake is the one step that can legitimately run for many minutes, and its transport wait is
|
|
5
|
-
* an IDLE timeout of 20 minutes (`VOXELIZE_TIMEOUT_MS`) — per-chunk progress re-arms the timer but
|
|
6
|
-
* is otherwise consumed silently inside the transport. Without a printed line a creator watching a
|
|
7
|
-
* still terminal concludes the command has hung and kills it mid-bake, losing the whole step. So
|
|
8
|
-
* the command subscribes to the page's own `VOXELIZE_GLB_AS_LEVEL_PROGRESS` messages
|
|
9
|
-
* (`game/src/engine/template/VoxelMessageHandlers.ts`) and prints them.
|
|
10
|
-
*
|
|
11
|
-
* Throttled, because the engine emits one message per chunk and a large level has thousands: an
|
|
12
|
-
* unthrottled relay would bury every other line of output. The formatter and the throttle are pure
|
|
13
|
-
* and separate from the subscription so both are testable without a browser.
|
|
14
|
-
*/
|
|
15
|
-
export const BAKE_PROGRESS_TYPE = 'VOXELIZE_GLB_AS_LEVEL_PROGRESS';
|
|
16
|
-
/** Minimum gap between printed bake lines. Long enough not to flood, short enough that the
|
|
17
|
-
* terminal never looks frozen. */
|
|
18
|
-
export const BAKE_PROGRESS_MIN_INTERVAL_MS = 3000;
|
|
19
|
-
function isRecord(value) {
|
|
20
|
-
return typeof value === 'object' && value !== null;
|
|
21
|
-
}
|
|
22
|
-
/** Read a bake-progress payload off a page message, or null if it is not one. */
|
|
23
|
-
export function asBakeProgress(message) {
|
|
24
|
-
if (!isRecord(message) || message.type !== BAKE_PROGRESS_TYPE)
|
|
25
|
-
return null;
|
|
26
|
-
const { chunkIndex, totalChunks } = message;
|
|
27
|
-
if (typeof chunkIndex !== 'number' || typeof totalChunks !== 'number')
|
|
28
|
-
return null;
|
|
29
|
-
return {
|
|
30
|
-
chunkIndex,
|
|
31
|
-
totalChunks,
|
|
32
|
-
...(typeof message.nonEmptyChunks === 'number' ? { nonEmptyChunks: message.nonEmptyChunks } : {}),
|
|
33
|
-
...(typeof message.label === 'string' ? { label: message.label } : {}),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* The line to print for one progress message.
|
|
38
|
-
*
|
|
39
|
-
* `chunkIndex: -1` / `totalChunks: -1` is the engine's sentinel for the upload phase that follows
|
|
40
|
-
* the chunk loop; it carries a label instead of a count, so it is rendered as that label rather
|
|
41
|
-
* than as a nonsensical "chunk -1 of -1".
|
|
42
|
-
*/
|
|
43
|
-
export function formatBakeProgress(progress) {
|
|
44
|
-
if (progress.totalChunks <= 0) {
|
|
45
|
-
return ` bake: ${progress.label ?? 'working…'}`;
|
|
46
|
-
}
|
|
47
|
-
const percent = Math.floor(((progress.chunkIndex + 1) / progress.totalChunks) * 100);
|
|
48
|
-
const filled = progress.nonEmptyChunks !== undefined ? `, ${progress.nonEmptyChunks} non-empty` : '';
|
|
49
|
-
const label = progress.label ? ` — ${progress.label}` : '';
|
|
50
|
-
return ` bake: chunk ${progress.chunkIndex + 1}/${progress.totalChunks} (${percent}%${filled})${label}`;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* A printer that emits at most one line per `minIntervalMs` — except for the final chunk and the
|
|
54
|
-
* label-only phases, which always print. The last chunk is what tells a creator the loop finished
|
|
55
|
-
* rather than stalled, so dropping it to a throttle would remove the single most informative line.
|
|
56
|
-
*/
|
|
57
|
-
export function createBakeProgressPrinter(log, options = {}) {
|
|
58
|
-
const minIntervalMs = options.minIntervalMs ?? BAKE_PROGRESS_MIN_INTERVAL_MS;
|
|
59
|
-
const now = options.now ?? (() => Date.now());
|
|
60
|
-
// -Infinity, not 0: the FIRST message must always print. A zero start throttles it whenever
|
|
61
|
-
// `now()` begins near zero — which a monotonic clock does, and which is exactly the moment the
|
|
62
|
-
// creator most needs to see that the bake has begun.
|
|
63
|
-
let lastAt = -Infinity;
|
|
64
|
-
return (message) => {
|
|
65
|
-
const progress = asBakeProgress(message);
|
|
66
|
-
if (progress === null)
|
|
67
|
-
return;
|
|
68
|
-
const isFinalChunk = progress.totalChunks > 0 && progress.chunkIndex + 1 >= progress.totalChunks;
|
|
69
|
-
const isPhaseLabel = progress.totalChunks <= 0;
|
|
70
|
-
const at = now();
|
|
71
|
-
if (!isFinalChunk && !isPhaseLabel && at - lastAt < minIntervalMs)
|
|
72
|
-
return;
|
|
73
|
-
lastAt = at;
|
|
74
|
-
log(formatBakeProgress(progress));
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=bake-progress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bake-progress.js","sourceRoot":"","sources":["../../src/forge/bake-progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAEnE;mCACmC;AACnC,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAElD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC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