rig-parts 2.70.0 → 2.72.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/cli.ts +12 -5
- package/docs/AUTHORING.md +11 -7
- package/docs/STABILITY.md +89 -21
- package/package.json +6 -5
- package/src/assemble.ts +2 -2
- package/src/build.ts +53 -29
- package/src/clipstretch.ts +0 -1
- package/src/configwrite.ts +1 -2
- package/src/depthsheets.ts +9 -2
- package/src/diagnostics.ts +1 -2
- package/src/edgesplit.ts +1 -2
- package/src/layers.ts +34 -6
- package/src/meshdraft.ts +3 -4
- package/src/paintingextension.ts +1 -2
- package/src/propose.ts +1 -2
- package/src/requirements.ts +1 -2
- package/src/rig.ts +9 -12
- package/src/runstamp.ts +96 -10
- package/src/scene.ts +1 -1
- package/src/structure.ts +1 -2
- package/src/turn.ts +1 -3
- package/src/visibility.ts +16 -11
- package/tools/build-process.ts +59 -8
package/tools/build-process.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
-
import { assembleStage, checkStage, rigStage, type AssembleOutputs, type AssembleStageInput, type CheckStageInput, type RigStageInput } from '../src/build.ts';
|
|
5
|
+
import { assembleStage, checkStage, rigStage, type AssembleOutputs, type AssembleStageInput, type BuildWrapperRole, type CheckStageInput, type RigStageInput } from '../src/build.ts';
|
|
6
6
|
import { rigcRunnerAt, type CheckReport, type RigcRunner } from '../src/check.ts';
|
|
7
7
|
import type { Mask } from '../src/raster/types.ts';
|
|
8
8
|
import { PartsError, type Problem } from '../src/errors.ts';
|
|
9
|
+
import { bindBuildWrapperInputs, type RunStampInputEntry } from '../src/runstamp.ts';
|
|
9
10
|
|
|
10
11
|
/** Preserve native/custom executables; adapt only a proven package-manager script shim. */
|
|
11
12
|
export function selectedRigcCommand(bin: string, platform: NodeJS.Platform = process.platform): { command: string; prefix: string[] } {
|
|
@@ -73,7 +74,7 @@ export type BuildProcessJob =
|
|
|
73
74
|
function record(value: unknown): value is Record<string, unknown> {
|
|
74
75
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
75
76
|
}
|
|
76
|
-
type AssemblyReading = { supportFigure?: Mask };
|
|
77
|
+
type AssemblyReading = { supportFigure?: Mask; wrapperPngs?: RunStampInputEntry<BuildWrapperRole>[] };
|
|
77
78
|
type StageReading = CheckReport | AssemblyReading | void;
|
|
78
79
|
|
|
79
80
|
/** Private inter-process source observation, never written to build outputs. */
|
|
@@ -87,6 +88,26 @@ function decodeSupportFigure(value: unknown): Mask {
|
|
|
87
88
|
if (data.length !== value.width * value.height || data.toString('base64') !== value.alpha_base64 || data.some(p => p !== 0 && p !== 1)) throw new Error('BUILD_STAGE_SUPPORT_FIGURE: canonical binary alpha must fill the native grid');
|
|
88
89
|
return { width: value.width, height: value.height, data };
|
|
89
90
|
}
|
|
91
|
+
function isBuildWrapperRole(value: unknown): value is BuildWrapperRole {
|
|
92
|
+
return value === 'full' || value === 'head' || (typeof value === 'string' && /^alt\[(?:0|[1-9][0-9]*)\]\.(?:full|head)$/.test(value));
|
|
93
|
+
}
|
|
94
|
+
function decodeWrapperPngs(value: unknown): RunStampInputEntry<BuildWrapperRole>[] {
|
|
95
|
+
if (!Array.isArray(value) || value.length === 0) return resultError('assemble', 'wrapperPngs must be a non-empty array when present');
|
|
96
|
+
return value.map((entry) => {
|
|
97
|
+
if (
|
|
98
|
+
!record(entry) ||
|
|
99
|
+
Object.keys(entry).join(',') !== 'role,path,sha256' ||
|
|
100
|
+
!isBuildWrapperRole(entry.role) ||
|
|
101
|
+
typeof entry.path !== 'string' ||
|
|
102
|
+
entry.path === '' ||
|
|
103
|
+
typeof entry.sha256 !== 'string' ||
|
|
104
|
+
!/^[0-9a-f]{64}$/.test(entry.sha256)
|
|
105
|
+
) {
|
|
106
|
+
return resultError('assemble', 'wrapperPngs rows must carry valid role, path and sha256');
|
|
107
|
+
}
|
|
108
|
+
return { role: entry.role, path: entry.path, sha256: entry.sha256 };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
90
111
|
function problems(value: unknown): value is Problem[] {
|
|
91
112
|
return Array.isArray(value) && value.length > 0 && value.every((p) => record(p) && typeof p.code === 'string' && typeof p.object === 'string' && typeof p.detail === 'string');
|
|
92
113
|
}
|
|
@@ -126,9 +147,18 @@ export function readBuildReceipt(stage: Stage, status: number | null, signal: st
|
|
|
126
147
|
if (status !== 0) throw new Error('BUILD_STAGE_CHILD: ' + stage + ' child — exit ' + status + ' with a completion receipt; no later stage ran');
|
|
127
148
|
if (stage !== 'check') {
|
|
128
149
|
if (Object.hasOwn(row, 'report') || Object.hasOwn(row, 'sweepSteps')) return resultError(stage, 'a void stage returned an invented check report');
|
|
129
|
-
if (stage
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
if (stage !== 'assemble') {
|
|
151
|
+
if (row.supportFigure !== undefined) return resultError(stage, 'only assembly returns a source observation');
|
|
152
|
+
if (row.wrapperPngs !== undefined) return resultError(stage, 'only assembly returns wrapper PNG readings');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const supportFigure = row.supportFigure === undefined ? undefined : decodeSupportFigure(row.supportFigure);
|
|
156
|
+
const wrapperPngs = row.wrapperPngs === undefined ? undefined : decodeWrapperPngs(row.wrapperPngs);
|
|
157
|
+
if (supportFigure === undefined && wrapperPngs === undefined) return;
|
|
158
|
+
return {
|
|
159
|
+
...(supportFigure === undefined ? {} : { supportFigure }),
|
|
160
|
+
...(wrapperPngs === undefined ? {} : { wrapperPngs }),
|
|
161
|
+
};
|
|
132
162
|
}
|
|
133
163
|
if (!checkReport(row.report)) return resultError(stage, 'check report is incomplete');
|
|
134
164
|
if (row.sweepSteps !== null && (!Array.isArray(row.sweepSteps) || !row.sweepSteps.every((p) =>
|
|
@@ -207,10 +237,31 @@ function worker(args: string[]): number {
|
|
|
207
237
|
try {
|
|
208
238
|
let report: CheckReport | undefined;
|
|
209
239
|
let supportFigure: Mask | undefined;
|
|
210
|
-
|
|
211
|
-
|
|
240
|
+
let wrapperPngs: RunStampInputEntry<BuildWrapperRole>[] | undefined;
|
|
241
|
+
if (job.stage === 'assemble') {
|
|
242
|
+
supportFigure = assembleStage(
|
|
243
|
+
job.input,
|
|
244
|
+
job.outputs,
|
|
245
|
+
log,
|
|
246
|
+
(readings) => {
|
|
247
|
+
const bound = bindBuildWrapperInputs(readings);
|
|
248
|
+
wrapperPngs = bound !== undefined && bound.pngs.length > 0 ? bound.pngs : undefined;
|
|
249
|
+
},
|
|
250
|
+
).supportFigure;
|
|
251
|
+
} else if (job.stage === 'rig') rigStage(job.input, runner, job.scratch, log);
|
|
212
252
|
else report = checkStage(job.input, runner, job.bin, log);
|
|
213
|
-
writeFileSync(
|
|
253
|
+
writeFileSync(
|
|
254
|
+
args[1],
|
|
255
|
+
report === undefined
|
|
256
|
+
? JSON.stringify({
|
|
257
|
+
version: 1,
|
|
258
|
+
stage: job.stage,
|
|
259
|
+
kind: 'done',
|
|
260
|
+
...(supportFigure === undefined ? {} : { supportFigure: encodeSupportFigure(supportFigure) }),
|
|
261
|
+
...(wrapperPngs === undefined ? {} : { wrapperPngs }),
|
|
262
|
+
})
|
|
263
|
+
: encodeCheckReceipt(report),
|
|
264
|
+
);
|
|
214
265
|
return 0;
|
|
215
266
|
} catch (err) {
|
|
216
267
|
if (!(err instanceof PartsError)) throw err;
|