@forgeax/engine-import 0.1.23 → 0.1.24
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 +5 -5
- package/dist/__tests__/scriptable-pack-build.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-build.unit.test.d.ts.map +1 -0
- package/dist/build-production.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +230 -56
- package/dist/index.mjs.map +1 -1
- package/dist/{parameterized-scriptable-pack.d.ts → scriptable-pack-build.d.ts} +15 -15
- package/dist/scriptable-pack-build.d.ts.map +1 -0
- package/dist/scriptable-pack-host.d.ts +13 -13
- package/dist/scriptable-pack-host.d.ts.map +1 -1
- package/dist/scriptable-pack.d.ts +2 -1
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/source-package-publication.d.ts +7 -0
- package/dist/source-package-publication.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/{parameterized-scriptable-pack.unit.test.ts → scriptable-pack-build.unit.test.ts} +11 -14
- package/src/__tests__/scriptable-pack-host.unit.test.ts +5 -5
- package/src/__tests__/source-package-publication.integration.test.ts +141 -0
- package/src/build-production.ts +44 -50
- package/src/index.ts +17 -16
- package/src/{parameterized-scriptable-pack.ts → scriptable-pack-build.ts} +24 -24
- package/src/scriptable-pack-host.ts +38 -40
- package/src/scriptable-pack.ts +2 -1
- package/src/source-package-publication.ts +242 -10
- package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts.map +0 -1
- package/dist/parameterized-scriptable-pack.d.ts.map +0 -1
package/src/build-production.ts
CHANGED
|
@@ -11,11 +11,11 @@ import type { NativeCooker } from '@forgeax/engine-pack/native-cooker';
|
|
|
11
11
|
import type { LegacyPackInventoryDocument } from '@forgeax/engine-pack/scanner';
|
|
12
12
|
import {
|
|
13
13
|
PackageId,
|
|
14
|
-
|
|
14
|
+
parsePackSourceJson,
|
|
15
15
|
projectDirectPackJson,
|
|
16
16
|
resolvePackParameterInheritance,
|
|
17
17
|
} from '@forgeax/engine-pack/source';
|
|
18
|
-
import {
|
|
18
|
+
import { loadScriptablePack } from '@forgeax/engine-pack/source-node';
|
|
19
19
|
import type {
|
|
20
20
|
AssetPublicationEnvelope,
|
|
21
21
|
AssetPublicationOutput,
|
|
@@ -30,11 +30,11 @@ import { projectImportProductForBuild } from './pack-projection.js';
|
|
|
30
30
|
import {
|
|
31
31
|
canonicalScriptableSourcePath,
|
|
32
32
|
declaredPackExternalOutputs,
|
|
33
|
-
type
|
|
34
|
-
type PreparedParameterizedScriptablePack,
|
|
33
|
+
type PreparedScriptablePack,
|
|
35
34
|
prepareDirectPackTransport,
|
|
36
35
|
prepareLegacyPackTransport,
|
|
37
|
-
|
|
36
|
+
produceScriptablePackProducts,
|
|
37
|
+
type ScriptablePackInput,
|
|
38
38
|
} from './scriptable-pack-host.js';
|
|
39
39
|
import {
|
|
40
40
|
finalizeSourcePackage,
|
|
@@ -133,21 +133,21 @@ function sourceKeysFor(
|
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
interface
|
|
137
|
-
readonly input:
|
|
138
|
-
readonly prepared:
|
|
136
|
+
interface PackBuildBundle {
|
|
137
|
+
readonly input: ScriptablePackInput;
|
|
138
|
+
readonly prepared: PreparedScriptablePack;
|
|
139
139
|
readonly entries: readonly PackIndexEntry[];
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
type
|
|
142
|
+
type PackSourceSubject = {
|
|
143
143
|
readonly kind: 'source';
|
|
144
144
|
readonly packageId: PackageId;
|
|
145
145
|
readonly sourcePath: string;
|
|
146
|
-
readonly definition: import('@forgeax/engine-pack/source').
|
|
146
|
+
readonly definition: import('@forgeax/engine-pack/source').AnyScriptablePackDefinition;
|
|
147
147
|
readonly sourceClosure: readonly import('@forgeax/engine-pack/source').ScriptablePackSourceClosureEntry[];
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
type
|
|
150
|
+
type PackInstanceSubject = {
|
|
151
151
|
readonly kind: 'instance';
|
|
152
152
|
readonly packageId: PackageId;
|
|
153
153
|
readonly parent: PackageId;
|
|
@@ -155,16 +155,13 @@ type ParameterizedInstanceSubject = {
|
|
|
155
155
|
readonly sourcePath: string;
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
type
|
|
158
|
+
type PackDirectSubject = {
|
|
159
159
|
readonly kind: 'direct';
|
|
160
160
|
readonly packageId: PackageId;
|
|
161
161
|
readonly sourcePath: string;
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
type
|
|
165
|
-
| ParameterizedSourceSubject
|
|
166
|
-
| ParameterizedInstanceSubject
|
|
167
|
-
| ParameterizedDirectSubject;
|
|
164
|
+
type PackSourceIndexSubject = PackSourceSubject | PackInstanceSubject | PackDirectSubject;
|
|
168
165
|
|
|
169
166
|
function dynamicFailure(context: BuildProductionOptions, value: unknown): never {
|
|
170
167
|
const candidate = value !== null && typeof value === 'object' ? value : {};
|
|
@@ -175,23 +172,20 @@ function dynamicFailure(context: BuildProductionOptions, value: unknown): never
|
|
|
175
172
|
readonly detail?: unknown;
|
|
176
173
|
};
|
|
177
174
|
throw context.fail({
|
|
178
|
-
code: typeof error.code === 'string' ? error.code : '
|
|
175
|
+
code: typeof error.code === 'string' ? error.code : 'pack-build-failed',
|
|
179
176
|
expected:
|
|
180
177
|
typeof error.expected === 'string'
|
|
181
178
|
? error.expected
|
|
182
|
-
: 'the
|
|
179
|
+
: 'the Pack source generation to produce a valid terminal result',
|
|
183
180
|
hint:
|
|
184
181
|
typeof error.hint === 'string'
|
|
185
182
|
? error.hint
|
|
186
|
-
: 'inspect the
|
|
183
|
+
: 'inspect the Pack source subject and rebuild the current generation',
|
|
187
184
|
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
188
185
|
});
|
|
189
186
|
}
|
|
190
187
|
|
|
191
|
-
function
|
|
192
|
-
context: BuildProductionOptions,
|
|
193
|
-
sourcePath: string,
|
|
194
|
-
): string {
|
|
188
|
+
function packCatalogSourcePath(context: BuildProductionOptions, sourcePath: string): string {
|
|
195
189
|
const projected = context.fsForImport.sourceIdentityFor?.(sourcePath);
|
|
196
190
|
const logical =
|
|
197
191
|
projected === undefined || isAbsolute(projected)
|
|
@@ -200,13 +194,13 @@ function parameterizedCatalogSourcePath(
|
|
|
200
194
|
return canonicalScriptableSourcePath(logical).replaceAll('\\', '/');
|
|
201
195
|
}
|
|
202
196
|
|
|
203
|
-
/** Build
|
|
204
|
-
async function
|
|
197
|
+
/** Build ScriptablePack roots and Pack JSON instances before normal emission. */
|
|
198
|
+
async function buildPackSources(
|
|
205
199
|
context: BuildProductionOptions,
|
|
206
|
-
): Promise<readonly
|
|
207
|
-
const subjects = new Map<string,
|
|
200
|
+
): Promise<readonly PackBuildBundle[]> {
|
|
201
|
+
const subjects = new Map<string, PackSourceIndexSubject>();
|
|
208
202
|
for (const [sourcePath, declaration] of context.inventory.sourceDeclarations) {
|
|
209
|
-
if (declaration.format === 'pack.ts
|
|
203
|
+
if (declaration.format === 'pack.ts') {
|
|
210
204
|
const key = PackageId.format(declaration.definition.packageId).toLowerCase();
|
|
211
205
|
subjects.set(key, {
|
|
212
206
|
kind: 'source',
|
|
@@ -220,7 +214,7 @@ async function buildParameterizedPackages(
|
|
|
220
214
|
if (declaration.format !== 'pack.json' || declaration.value.schemaVersion !== '3.0.0') {
|
|
221
215
|
continue;
|
|
222
216
|
}
|
|
223
|
-
const parsed =
|
|
217
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
224
218
|
if (!parsed.ok) dynamicFailure(context, parsed.error);
|
|
225
219
|
if (parsed.value.format === 'direct') {
|
|
226
220
|
subjects.set(PackageId.format(parsed.value.packageId).toLowerCase(), {
|
|
@@ -238,7 +232,7 @@ async function buildParameterizedPackages(
|
|
|
238
232
|
});
|
|
239
233
|
}
|
|
240
234
|
}
|
|
241
|
-
const sourceSubject = (packageId: PackageId):
|
|
235
|
+
const sourceSubject = (packageId: PackageId): PackSourceSubject | undefined => {
|
|
242
236
|
const subject = subjects.get(PackageId.format(packageId).toLowerCase());
|
|
243
237
|
return subject?.kind === 'source' ? subject : undefined;
|
|
244
238
|
};
|
|
@@ -269,16 +263,16 @@ async function buildParameterizedPackages(
|
|
|
269
263
|
const orderedSubjects = [...subjects.values()].sort((left, right) =>
|
|
270
264
|
left.sourcePath.localeCompare(right.sourcePath),
|
|
271
265
|
);
|
|
272
|
-
const inputs:
|
|
266
|
+
const inputs: ScriptablePackInput[] = [];
|
|
273
267
|
for (const subject of orderedSubjects) {
|
|
274
268
|
if (subject.kind === 'source') {
|
|
275
269
|
const packageId = PackageId.format(subject.packageId);
|
|
276
|
-
const loaded = await
|
|
270
|
+
const loaded = await loadScriptablePack(subject.sourcePath);
|
|
277
271
|
if (!loaded.ok) dynamicFailure(context, loaded.error);
|
|
278
272
|
if (PackageId.format(loaded.value.packageId) !== packageId) {
|
|
279
273
|
dynamicFailure(context, {
|
|
280
274
|
code: 'pack-source-revision-conflict',
|
|
281
|
-
expected: 'the
|
|
275
|
+
expected: 'the ScriptablePack source packageId to remain fixed during production',
|
|
282
276
|
hint: 'retry after source writes settle and rebuild the current generation',
|
|
283
277
|
detail: {
|
|
284
278
|
sourcePath: subject.sourcePath,
|
|
@@ -289,7 +283,7 @@ async function buildParameterizedPackages(
|
|
|
289
283
|
}
|
|
290
284
|
inputs.push({
|
|
291
285
|
sourcePath: subject.sourcePath,
|
|
292
|
-
displaySourcePath:
|
|
286
|
+
displaySourcePath: packCatalogSourcePath(context, subject.sourcePath),
|
|
293
287
|
definition: loaded.value,
|
|
294
288
|
sourceClosure: subject.sourceClosure,
|
|
295
289
|
publicationGeneration: context.generation,
|
|
@@ -316,18 +310,18 @@ async function buildParameterizedPackages(
|
|
|
316
310
|
const root = sourceSubject(resolved.value.rootPackageId);
|
|
317
311
|
if (root === undefined) {
|
|
318
312
|
dynamicFailure(context, {
|
|
319
|
-
code: 'pack-parent-
|
|
320
|
-
expected: 'the instance parent chain to terminate at a
|
|
321
|
-
hint: 'point the instance at a
|
|
313
|
+
code: 'pack-parent-has-no-parameters',
|
|
314
|
+
expected: 'the instance parent chain to terminate at a ScriptablePack source',
|
|
315
|
+
hint: 'point the instance at a ScriptablePack *.pack.ts source with parameters',
|
|
322
316
|
detail: { packageId: PackageId.format(subject.packageId) },
|
|
323
317
|
});
|
|
324
318
|
}
|
|
325
|
-
const loaded = await
|
|
319
|
+
const loaded = await loadScriptablePack(root.sourcePath);
|
|
326
320
|
if (!loaded.ok) dynamicFailure(context, loaded.error);
|
|
327
321
|
if (PackageId.format(loaded.value.packageId) !== PackageId.format(root.packageId)) {
|
|
328
322
|
dynamicFailure(context, {
|
|
329
323
|
code: 'pack-source-revision-conflict',
|
|
330
|
-
expected: 'the
|
|
324
|
+
expected: 'the ScriptablePack parent packageId to remain fixed during production',
|
|
331
325
|
hint: 'retry after source writes settle and rebuild the current generation',
|
|
332
326
|
detail: {
|
|
333
327
|
sourcePath: root.sourcePath,
|
|
@@ -339,7 +333,7 @@ async function buildParameterizedPackages(
|
|
|
339
333
|
const packageId = PackageId.format(subject.packageId);
|
|
340
334
|
inputs.push({
|
|
341
335
|
sourcePath: subject.sourcePath,
|
|
342
|
-
displaySourcePath:
|
|
336
|
+
displaySourcePath: packCatalogSourcePath(context, subject.sourcePath),
|
|
343
337
|
definition: loaded.value,
|
|
344
338
|
sourceClosure: root.sourceClosure,
|
|
345
339
|
subjectPackageId: subject.packageId,
|
|
@@ -369,21 +363,21 @@ async function buildParameterizedPackages(
|
|
|
369
363
|
},
|
|
370
364
|
);
|
|
371
365
|
const availableGuids = new Set(requiredGuids.map((guid) => AssetGuid.format(guid).toLowerCase()));
|
|
372
|
-
const built = await
|
|
366
|
+
const built = await produceScriptablePackProducts({
|
|
373
367
|
sources: inputs,
|
|
374
368
|
declaredExternalOutputs: externalOutputs,
|
|
375
369
|
availableGuids,
|
|
376
370
|
});
|
|
377
371
|
if (!built.ok) dynamicFailure(context, built.error);
|
|
378
372
|
|
|
379
|
-
const bundles:
|
|
373
|
+
const bundles: PackBuildBundle[] = [];
|
|
380
374
|
for (const input of inputs) {
|
|
381
375
|
const prepared = built.value.get(input.displaySourcePath);
|
|
382
376
|
if (prepared === undefined) {
|
|
383
377
|
dynamicFailure(context, {
|
|
384
|
-
code: '
|
|
378
|
+
code: 'pack-build-failed',
|
|
385
379
|
expected: 'the worklist to return one prepared result per source subject',
|
|
386
|
-
hint: 'rerun
|
|
380
|
+
hint: 'rerun Pack source generation from a clean inventory',
|
|
387
381
|
detail: { sourcePath: input.sourcePath },
|
|
388
382
|
});
|
|
389
383
|
}
|
|
@@ -544,13 +538,13 @@ async function emitAuthoredPack(
|
|
|
544
538
|
});
|
|
545
539
|
}
|
|
546
540
|
if (declaration.value.schemaVersion === '3.0.0') {
|
|
547
|
-
const parsed =
|
|
541
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
548
542
|
if (!parsed.ok) dynamicFailure(work.context, parsed.error);
|
|
549
543
|
if (parsed.value.format !== 'direct') {
|
|
550
544
|
dynamicFailure(work.context, {
|
|
551
545
|
code: 'catalog-declaration-missing',
|
|
552
546
|
expected: 'a direct v3 Pack declaration for an indexed authored output',
|
|
553
|
-
hint: 'instances are built from their
|
|
547
|
+
hint: 'instances are built from their ScriptablePack parent and do not have direct Catalog rows',
|
|
554
548
|
detail: { stage: 'scan', sourcePath: packPath },
|
|
555
549
|
});
|
|
556
550
|
}
|
|
@@ -659,10 +653,10 @@ async function emitAuthoredPack(
|
|
|
659
653
|
}
|
|
660
654
|
}
|
|
661
655
|
|
|
662
|
-
async function
|
|
656
|
+
async function emitScriptablePack(
|
|
663
657
|
work: BuildEmissionWork,
|
|
664
658
|
guidSeen: Set<string>,
|
|
665
|
-
bundle:
|
|
659
|
+
bundle: PackBuildBundle,
|
|
666
660
|
): Promise<void> {
|
|
667
661
|
const { input, prepared } = bundle;
|
|
668
662
|
const packageId = PackageId.format(input.subjectPackageId ?? input.definition.packageId);
|
|
@@ -854,7 +848,7 @@ async function emitBuildEntry(
|
|
|
854
848
|
export async function produceBuildAssets(
|
|
855
849
|
context: BuildProductionOptions,
|
|
856
850
|
): Promise<PackIndexEntry[]> {
|
|
857
|
-
const dynamicBundles = await
|
|
851
|
+
const dynamicBundles = await buildPackSources(context);
|
|
858
852
|
const entries = [
|
|
859
853
|
...context.inventory.entries,
|
|
860
854
|
...dynamicBundles.flatMap((bundle) => bundle.entries),
|
|
@@ -864,7 +858,7 @@ export async function produceBuildAssets(
|
|
|
864
858
|
const guidSeen = new Set<string>();
|
|
865
859
|
const work: BuildEmissionWork = { importedEntries, context };
|
|
866
860
|
for (const bundle of dynamicBundles) {
|
|
867
|
-
await
|
|
861
|
+
await emitScriptablePack(work, guidSeen, bundle);
|
|
868
862
|
}
|
|
869
863
|
for (const entry of importedEntries) {
|
|
870
864
|
if (!guidSeen.has(entry.guid.toLowerCase()))
|
package/src/index.ts
CHANGED
|
@@ -106,31 +106,31 @@ export {
|
|
|
106
106
|
validateMeshLodContract,
|
|
107
107
|
} from './mesh-lod.js';
|
|
108
108
|
export { projectImportProductForBuild } from './pack-projection.js';
|
|
109
|
-
export {
|
|
110
|
-
buildParameterizedScriptablePack,
|
|
111
|
-
buildParameterizedScriptablePackWorklist,
|
|
112
|
-
type ParameterizedScriptablePackBuildOptions,
|
|
113
|
-
type ParameterizedScriptablePackBuildProduct,
|
|
114
|
-
type ParameterizedScriptablePackBuildResult,
|
|
115
|
-
type ParameterizedScriptablePackWorkItem,
|
|
116
|
-
type ParameterizedScriptablePackWorklistOptions,
|
|
117
|
-
type ParameterizedScriptablePackWorklistProduct,
|
|
118
|
-
} from './parameterized-scriptable-pack.js';
|
|
119
109
|
export {
|
|
120
110
|
type AssetOutputInput,
|
|
121
111
|
type AssetOutputPayload,
|
|
122
112
|
type AssetOutputProducer,
|
|
123
113
|
AssetOutputProducerRegistry,
|
|
124
114
|
type AssetOutputProduct,
|
|
115
|
+
type PackBuildProduct,
|
|
125
116
|
type ScriptablePackAssetSnapshot,
|
|
126
117
|
type ScriptablePackAssetSnapshotSource,
|
|
127
|
-
type ScriptablePackBuildProduct,
|
|
128
118
|
type ScriptablePackDomainError,
|
|
129
119
|
type ScriptablePackExternalEvidence,
|
|
130
120
|
type ScriptablePackExternalUsage,
|
|
131
121
|
type ScriptablePackSourceClosureEntry,
|
|
132
122
|
type ScriptablePackStagedOutput,
|
|
133
123
|
} from './scriptable-pack.js';
|
|
124
|
+
export {
|
|
125
|
+
buildScriptablePack,
|
|
126
|
+
buildScriptablePackWorklist,
|
|
127
|
+
type ScriptablePackBuildOptions,
|
|
128
|
+
type ScriptablePackBuildProduct,
|
|
129
|
+
type ScriptablePackBuildResult,
|
|
130
|
+
type ScriptablePackBuildWorkItem,
|
|
131
|
+
type ScriptablePackBuildWorklistOptions,
|
|
132
|
+
type ScriptablePackBuildWorklistProduct,
|
|
133
|
+
} from './scriptable-pack-build.js';
|
|
134
134
|
export {
|
|
135
135
|
createScriptablePackFileAssetSnapshotSource,
|
|
136
136
|
type ScriptablePackFileAssetSnapshotError,
|
|
@@ -142,15 +142,15 @@ export {
|
|
|
142
142
|
type DirectPackTransportInput,
|
|
143
143
|
declaredPackExternalOutputs,
|
|
144
144
|
type LegacyPackTransport,
|
|
145
|
-
|
|
146
|
-
type
|
|
147
|
-
type ParameterizedScriptablePackProductionOptions,
|
|
148
|
-
type PreparedParameterizedScriptablePack,
|
|
145
|
+
materializePreparedScriptablePack,
|
|
146
|
+
type PreparedScriptablePack,
|
|
149
147
|
prepareDirectPackTransport,
|
|
150
148
|
prepareLegacyPackTransport,
|
|
151
|
-
|
|
149
|
+
produceScriptablePackProducts,
|
|
152
150
|
readCookedAuthoredPack,
|
|
153
151
|
type ScriptablePackExternalImportOptions,
|
|
152
|
+
type ScriptablePackInput,
|
|
153
|
+
type ScriptablePackProductionOptions,
|
|
154
154
|
type ScriptablePackPublicationFacts,
|
|
155
155
|
type ScriptablePackTransportPaths,
|
|
156
156
|
type ScriptablePackTransportSink,
|
|
@@ -196,6 +196,7 @@ export {
|
|
|
196
196
|
export {
|
|
197
197
|
commitImportPublication,
|
|
198
198
|
discardImportPublication,
|
|
199
|
+
type ImportPublicationArtifact,
|
|
199
200
|
type ImportPublicationError,
|
|
200
201
|
type ImportPublicationInput,
|
|
201
202
|
type ImportPublicationResult,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BUILTIN_MESH_ASSETS } from '@forgeax/engine-pack/builtin';
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type AnyScriptablePackDefinition,
|
|
4
4
|
AssetGuid,
|
|
5
5
|
isScriptablePackAssetKind,
|
|
6
6
|
isValidPackSourceKey,
|
|
@@ -28,16 +28,16 @@ import {
|
|
|
28
28
|
import type {
|
|
29
29
|
AssetOutputProducer,
|
|
30
30
|
AssetOutputProducerRegistry,
|
|
31
|
+
PackBuildProduct,
|
|
31
32
|
ScriptablePackAssetSnapshotSource,
|
|
32
|
-
ScriptablePackBuildProduct,
|
|
33
33
|
ScriptablePackDomainError,
|
|
34
34
|
ScriptablePackExternalEvidence,
|
|
35
35
|
ScriptablePackSourceClosureEntry,
|
|
36
36
|
ScriptablePackStagedOutput,
|
|
37
37
|
} from './scriptable-pack.js';
|
|
38
38
|
|
|
39
|
-
export interface
|
|
40
|
-
readonly definition:
|
|
39
|
+
export interface ScriptablePackBuildOptions {
|
|
40
|
+
readonly definition: AnyScriptablePackDefinition;
|
|
41
41
|
readonly sourcePath: string;
|
|
42
42
|
/** Instance identity. Omitted for a root source and defaults to definition.packageId. */
|
|
43
43
|
readonly subjectPackageId?: PackageId;
|
|
@@ -56,12 +56,12 @@ export interface ParameterizedScriptablePackBuildOptions {
|
|
|
56
56
|
readonly publication?: AssetPublicationEnvelope;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export interface
|
|
59
|
+
export interface ScriptablePackBuildProduct extends PackBuildProduct {
|
|
60
60
|
readonly publication?: AssetPublicationEnvelope;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export type
|
|
64
|
-
|
|
63
|
+
export type ScriptablePackBuildResult = Result<
|
|
64
|
+
ScriptablePackBuildProduct,
|
|
65
65
|
| PackAuthoringError
|
|
66
66
|
| ScriptablePackDomainError
|
|
67
67
|
| AssetError
|
|
@@ -289,9 +289,9 @@ function normalizedGuidSet(value: ReadonlySet<string> | undefined): Set<string>
|
|
|
289
289
|
* Execute a v2 Pack source and project its dynamic output map through the
|
|
290
290
|
* existing importer producers. No output GUID or output manifest is read.
|
|
291
291
|
*/
|
|
292
|
-
export async function
|
|
293
|
-
options:
|
|
294
|
-
): Promise<
|
|
292
|
+
export async function buildScriptablePack(
|
|
293
|
+
options: ScriptablePackBuildOptions,
|
|
294
|
+
): Promise<ScriptablePackBuildResult> {
|
|
295
295
|
const subjectPackageId = options.subjectPackageId ?? options.definition.packageId;
|
|
296
296
|
const availableGuids = normalizedGuidSet(options.availableGuids);
|
|
297
297
|
const observed = observedReader(options.assetSource);
|
|
@@ -319,8 +319,8 @@ export async function buildParameterizedScriptablePack(
|
|
|
319
319
|
PackageId.format(options.definition.packageId).toLowerCase()
|
|
320
320
|
) {
|
|
321
321
|
return err({
|
|
322
|
-
code: 'pack-parent-
|
|
323
|
-
expected: 'a
|
|
322
|
+
code: 'pack-parent-has-no-parameters',
|
|
323
|
+
expected: 'a ScriptablePack source with parameters for an independent instance packageId',
|
|
324
324
|
hint: 'use clone for a zero-parameter Pack instead of building it as an instance',
|
|
325
325
|
detail: {
|
|
326
326
|
sourcePath: options.sourcePath,
|
|
@@ -509,7 +509,7 @@ export async function buildParameterizedScriptablePack(
|
|
|
509
509
|
usage,
|
|
510
510
|
digest: evidenceDigest,
|
|
511
511
|
})),
|
|
512
|
-
authoringContractVersion: options.authoringContractVersion ?? '
|
|
512
|
+
authoringContractVersion: options.authoringContractVersion ?? 'scriptable-pack/1',
|
|
513
513
|
producerVersions: options.outputs.versions(),
|
|
514
514
|
});
|
|
515
515
|
const refs = imported.flatMap((asset) => asset.refs);
|
|
@@ -543,8 +543,8 @@ export async function buildParameterizedScriptablePack(
|
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
export interface
|
|
547
|
-
readonly definition:
|
|
546
|
+
export interface ScriptablePackBuildWorkItem {
|
|
547
|
+
readonly definition: AnyScriptablePackDefinition;
|
|
548
548
|
readonly sourcePath: string;
|
|
549
549
|
readonly subjectPackageId?: PackageId;
|
|
550
550
|
readonly values?: Readonly<Record<string, unknown>>;
|
|
@@ -552,8 +552,8 @@ export interface ParameterizedScriptablePackWorkItem {
|
|
|
552
552
|
readonly sourceClosure?: readonly ScriptablePackSourceClosureEntry[];
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
-
export interface
|
|
556
|
-
readonly subjects: readonly
|
|
555
|
+
export interface ScriptablePackBuildWorklistOptions {
|
|
556
|
+
readonly subjects: readonly ScriptablePackBuildWorkItem[];
|
|
557
557
|
readonly outputs: AssetOutputProducerRegistry;
|
|
558
558
|
readonly assetSource?: ScriptablePackAssetSnapshotSource;
|
|
559
559
|
readonly availableGuids?: ReadonlySet<string>;
|
|
@@ -561,9 +561,9 @@ export interface ParameterizedScriptablePackWorklistOptions {
|
|
|
561
561
|
readonly maxPasses?: number;
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
export interface
|
|
564
|
+
export interface ScriptablePackBuildWorklistProduct {
|
|
565
565
|
readonly products: readonly TerminalImportProduct<unknown>[];
|
|
566
|
-
readonly buildProducts: readonly
|
|
566
|
+
readonly buildProducts: readonly ScriptablePackBuildProduct[];
|
|
567
567
|
readonly stagedOutputs: readonly ScriptablePackStagedOutput[];
|
|
568
568
|
readonly iterations: number;
|
|
569
569
|
}
|
|
@@ -597,11 +597,11 @@ function stagedSource(
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
/** Build subjects in stable passes; content reads may wait for a later subject. */
|
|
600
|
-
export async function
|
|
601
|
-
options:
|
|
600
|
+
export async function buildScriptablePackWorklist(
|
|
601
|
+
options: ScriptablePackBuildWorklistOptions,
|
|
602
602
|
): Promise<
|
|
603
603
|
Result<
|
|
604
|
-
|
|
604
|
+
ScriptablePackBuildWorklistProduct,
|
|
605
605
|
| PackAuthoringError
|
|
606
606
|
| ScriptablePackDomainError
|
|
607
607
|
| AssetError
|
|
@@ -621,7 +621,7 @@ export async function buildParameterizedScriptablePackWorklist(
|
|
|
621
621
|
orderedSubjects.map((subject, index) => [`${index}:${subject.sourcePath}`, subject]),
|
|
622
622
|
);
|
|
623
623
|
const staged = new Map<string, ScriptablePackStagedOutput>();
|
|
624
|
-
const results = new Map<string,
|
|
624
|
+
const results = new Map<string, ScriptablePackBuildProduct>();
|
|
625
625
|
const availableGuids = new Set([
|
|
626
626
|
...(normalizedGuidSet(options.availableGuids) ?? []),
|
|
627
627
|
...BUILTIN_MESH_ASSETS.map((asset) => asset.guid.toLowerCase()),
|
|
@@ -632,7 +632,7 @@ export async function buildParameterizedScriptablePackWorklist(
|
|
|
632
632
|
let progress = false;
|
|
633
633
|
const waiting = new Set<string>();
|
|
634
634
|
for (const [key, subject] of pending) {
|
|
635
|
-
const result = await
|
|
635
|
+
const result = await buildScriptablePack({
|
|
636
636
|
definition: subject.definition,
|
|
637
637
|
sourcePath: subject.sourcePath,
|
|
638
638
|
...(subject.subjectPackageId === undefined
|