@forgeax/engine-pack 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 +12 -6
- package/dist/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts +2 -0
- package/dist/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts.map +1 -0
- package/dist/build.d.ts +3 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/build.mjs +331 -290
- package/dist/build.mjs.map +1 -1
- package/dist/cli-asset.mjs +33 -35
- package/dist/cli-asset.mjs.map +1 -1
- package/dist/evidence/material-cook.d.ts +11 -0
- package/dist/evidence/material-cook.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +69 -26
- package/dist/index.mjs.map +1 -1
- package/dist/material-cook.d.ts +1 -1
- package/dist/material-cook.d.ts.map +1 -1
- package/dist/material-cook.mjs +50 -3
- package/dist/material-cook.mjs.map +1 -1
- package/dist/{parameterized-pack-node.d.ts → pack-authoring-node.d.ts} +7 -7
- package/dist/pack-authoring-node.d.ts.map +1 -0
- package/dist/{parameterized-pack-node.mjs → pack-authoring-node.mjs} +59 -63
- package/dist/pack-authoring-node.mjs.map +1 -0
- package/dist/{parameterized-pack.d.ts → pack-authoring.d.ts} +28 -31
- package/dist/pack-authoring.d.ts.map +1 -0
- package/dist/pack-authoring.mjs +1137 -0
- package/dist/pack-authoring.mjs.map +1 -0
- package/dist/runtime.mjs +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/scanner.d.ts +8 -8
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.mjs +29 -31
- package/dist/scanner.mjs.map +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/schema.mjs.map +1 -1
- package/dist/scriptable-pack-node.d.ts +4 -4
- package/dist/scriptable-pack-node.d.ts.map +1 -1
- package/dist/scriptable-pack-node.mjs +18 -20
- package/dist/scriptable-pack-node.mjs.map +1 -1
- package/dist/scriptable-pack.d.ts +3 -2
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/scriptable-pack.mjs +19 -23
- package/dist/scriptable-pack.mjs.map +1 -1
- package/package.json +2 -7
- package/schema/pack.schema.json +1 -1
- package/src/__tests__/material-cook-receipt-layer-plan.unit.test.ts +16 -0
- package/src/__tests__/material-cook-schema.unit.test.ts +62 -0
- package/src/__tests__/{parameterized-pack-authoring-gateway.unit.test.ts → pack-authoring-gateway.unit.test.ts} +9 -9
- package/src/__tests__/{parameterized-pack.unit.test.ts → pack-authoring.unit.test.ts} +10 -10
- package/src/__tests__/{parameterized-pack-scanner.unit.test.ts → pack-scanner.unit.test.ts} +6 -6
- package/src/__tests__/scanner-inventory.contract.test.ts +2 -4
- package/src/__tests__/scanner-inventory.test.ts +7 -6
- package/src/__tests__/scriptable-pack-cli.integration.test.ts +1 -1
- package/src/build.ts +8 -8
- package/src/catalog-builder.ts +3 -3
- package/src/cli-asset.ts +5 -5
- package/src/evidence/material-cook.ts +79 -3
- package/src/evidence/source-inventory.ts +3 -3
- package/src/index.ts +4 -1
- package/src/material-cook.ts +1 -0
- package/src/{parameterized-pack-node.ts → pack-authoring-node.ts} +71 -73
- package/src/{parameterized-pack.ts → pack-authoring.ts} +59 -74
- package/src/scanner.ts +26 -28
- package/src/schema/material-cook.schema.json +4 -1
- package/src/scriptable-pack-node.ts +25 -25
- package/src/scriptable-pack.ts +3 -2
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack.unit.test.d.ts.map +0 -1
- package/dist/parameterized-pack-node.d.ts.map +0 -1
- package/dist/parameterized-pack-node.mjs.map +0 -1
- package/dist/parameterized-pack.d.ts.map +0 -1
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
producerRelativeDdcKey,
|
|
14
14
|
} from './evidence/source-inventory.js';
|
|
15
15
|
import {
|
|
16
|
-
type
|
|
16
|
+
type AnyScriptablePackDefinition,
|
|
17
17
|
type PackAuthoringError,
|
|
18
18
|
type PackBuildContextWithoutParameters,
|
|
19
19
|
type PackBuildResult,
|
|
20
20
|
validatePackDefinition,
|
|
21
|
-
} from './
|
|
21
|
+
} from './pack-authoring.js';
|
|
22
22
|
import type { AssetReader, ScriptablePackSourceClosureEntry } from './scriptable-pack.js';
|
|
23
23
|
|
|
24
24
|
const IMPORT_META_RESOLVE_FLAG = '--experimental-import-meta-resolve';
|
|
@@ -39,13 +39,13 @@ export interface ScriptablePackModuleExecutor {
|
|
|
39
39
|
dispose?(reason: 'complete' | 'timeout' | 'failure'): void | Promise<void>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
interface
|
|
42
|
+
interface SerializedScriptablePackBuildContext {
|
|
43
43
|
readonly packageId: readonly number[];
|
|
44
44
|
readonly values?: Readonly<Record<string, unknown>>;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
interface WorkerBackedScriptablePackExecutor {
|
|
48
|
-
readonly
|
|
48
|
+
readonly supportsPackParameters: true;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface ScriptablePackModuleExecutorPool {
|
|
@@ -212,7 +212,7 @@ function hydrateFailure(value: unknown): unknown {
|
|
|
212
212
|
class WorkerScriptablePackExecutor
|
|
213
213
|
implements ScriptablePackModuleExecutor, WorkerBackedScriptablePackExecutor
|
|
214
214
|
{
|
|
215
|
-
readonly
|
|
215
|
+
readonly supportsPackParameters = true as const;
|
|
216
216
|
private worker: Worker | undefined;
|
|
217
217
|
private compileRoot: string | undefined;
|
|
218
218
|
private nextBuildId = 0;
|
|
@@ -256,7 +256,7 @@ class WorkerScriptablePackExecutor
|
|
|
256
256
|
...(value.definition as Record<string, unknown>),
|
|
257
257
|
build: (
|
|
258
258
|
readByGuid: AssetReader['readByGuid'],
|
|
259
|
-
context?:
|
|
259
|
+
context?: SerializedScriptablePackBuildContext,
|
|
260
260
|
) => this.runBuild({ readByGuid }, context),
|
|
261
261
|
},
|
|
262
262
|
});
|
|
@@ -293,7 +293,7 @@ class WorkerScriptablePackExecutor
|
|
|
293
293
|
|
|
294
294
|
private runBuild(
|
|
295
295
|
reader: AssetReader,
|
|
296
|
-
context?:
|
|
296
|
+
context?: SerializedScriptablePackBuildContext,
|
|
297
297
|
): Promise<unknown> {
|
|
298
298
|
const worker = this.worker;
|
|
299
299
|
if (worker === undefined) return Promise.reject(new Error('ScriptablePack worker is closed'));
|
|
@@ -347,7 +347,7 @@ function scriptablePackWorkerUrl(): URL {
|
|
|
347
347
|
class ReusableWorkerScriptablePackExecutor
|
|
348
348
|
implements ScriptablePackModuleExecutor, WorkerBackedScriptablePackExecutor
|
|
349
349
|
{
|
|
350
|
-
readonly
|
|
350
|
+
readonly supportsPackParameters = true as const;
|
|
351
351
|
private readonly worker: Worker;
|
|
352
352
|
private readonly compileRootReady = mkdtemp(resolve(tmpdir(), 'forgeax-scriptable-pack-pool-'));
|
|
353
353
|
private compileRoot: string | undefined;
|
|
@@ -484,7 +484,7 @@ class ReusableWorkerScriptablePackExecutor
|
|
|
484
484
|
|
|
485
485
|
private runBuild(
|
|
486
486
|
reader: AssetReader,
|
|
487
|
-
context?:
|
|
487
|
+
context?: SerializedScriptablePackBuildContext,
|
|
488
488
|
): Promise<unknown> {
|
|
489
489
|
if (this.released || this.disposal !== undefined) {
|
|
490
490
|
return Promise.reject(new Error('ScriptablePack executor is not leased'));
|
|
@@ -519,7 +519,7 @@ class ReusableWorkerScriptablePackExecutor
|
|
|
519
519
|
...(value.definition as Record<string, unknown>),
|
|
520
520
|
build: (
|
|
521
521
|
readByGuid: AssetReader['readByGuid'],
|
|
522
|
-
context?:
|
|
522
|
+
context?: SerializedScriptablePackBuildContext,
|
|
523
523
|
) => this.runBuild({ readByGuid }, context),
|
|
524
524
|
},
|
|
525
525
|
});
|
|
@@ -642,14 +642,14 @@ export function createScriptablePackModuleExecutorPool(
|
|
|
642
642
|
return new DefaultScriptablePackModuleExecutorPool(options);
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
-
export interface
|
|
645
|
+
export interface LoadScriptablePackOptions {
|
|
646
646
|
readonly timeoutMs?: number;
|
|
647
647
|
readonly buildTimeoutMs?: number;
|
|
648
648
|
readonly executor?: ScriptablePackModuleExecutor;
|
|
649
649
|
readonly metadataOnly?: boolean;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
function
|
|
652
|
+
function scriptablePackLoadFailure(
|
|
653
653
|
sourcePath: string,
|
|
654
654
|
reason: 'module-load' | 'timeout',
|
|
655
655
|
phase: 'module-load' | 'build',
|
|
@@ -670,18 +670,18 @@ function parameterizedLoadFailure(
|
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
/** Load
|
|
674
|
-
export async function
|
|
673
|
+
/** Load a ScriptablePack source contract in an isolated module executor. */
|
|
674
|
+
export async function loadScriptablePack(
|
|
675
675
|
sourcePath: string,
|
|
676
|
-
options:
|
|
677
|
-
): Promise<Result<Readonly<
|
|
676
|
+
options: LoadScriptablePackOptions = {},
|
|
677
|
+
): Promise<Result<Readonly<AnyScriptablePackDefinition>, PackAuthoringError>> {
|
|
678
678
|
const timeoutMs = options.timeoutMs ?? 15_000;
|
|
679
679
|
const buildTimeoutMs = options.buildTimeoutMs ?? 5_000;
|
|
680
680
|
const executor = options.executor ?? new WorkerScriptablePackExecutor();
|
|
681
681
|
let disposeReason: 'complete' | 'timeout' | 'failure' | undefined;
|
|
682
682
|
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
683
683
|
try {
|
|
684
|
-
const timeoutSignal = Symbol('
|
|
684
|
+
const timeoutSignal = Symbol('scriptable-pack-module-timeout');
|
|
685
685
|
const loaded = await Promise.race([
|
|
686
686
|
executor.load(sourcePath),
|
|
687
687
|
new Promise<typeof timeoutSignal>((resolve) => {
|
|
@@ -691,7 +691,7 @@ export async function loadParameterizedScriptablePack(
|
|
|
691
691
|
if (loaded === timeoutSignal) {
|
|
692
692
|
disposeReason = 'timeout';
|
|
693
693
|
return err(
|
|
694
|
-
|
|
694
|
+
scriptablePackLoadFailure(
|
|
695
695
|
sourcePath,
|
|
696
696
|
'timeout',
|
|
697
697
|
'module-load',
|
|
@@ -716,7 +716,7 @@ export async function loadParameterizedScriptablePack(
|
|
|
716
716
|
const definition = validated.value;
|
|
717
717
|
const build = definition.build as unknown as (
|
|
718
718
|
first: unknown,
|
|
719
|
-
context?:
|
|
719
|
+
context?: SerializedScriptablePackBuildContext,
|
|
720
720
|
) => PackBuildResult;
|
|
721
721
|
return ok({
|
|
722
722
|
...definition,
|
|
@@ -726,7 +726,7 @@ export async function loadParameterizedScriptablePack(
|
|
|
726
726
|
let buildTimedOut = false;
|
|
727
727
|
let buildTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
728
728
|
const timeoutResult = err(
|
|
729
|
-
|
|
729
|
+
scriptablePackLoadFailure(
|
|
730
730
|
sourcePath,
|
|
731
731
|
'timeout',
|
|
732
732
|
'build',
|
|
@@ -736,9 +736,9 @@ export async function loadParameterizedScriptablePack(
|
|
|
736
736
|
);
|
|
737
737
|
try {
|
|
738
738
|
const invocation =
|
|
739
|
-
'
|
|
740
|
-
(executor as Partial<WorkerBackedScriptablePackExecutor>)
|
|
741
|
-
|
|
739
|
+
'supportsPackParameters' in executor &&
|
|
740
|
+
(executor as Partial<WorkerBackedScriptablePackExecutor>).supportsPackParameters ===
|
|
741
|
+
true
|
|
742
742
|
? build(context.readByGuid, {
|
|
743
743
|
packageId: [...context.packageId],
|
|
744
744
|
...('values' in context && context.values !== undefined
|
|
@@ -768,11 +768,11 @@ export async function loadParameterizedScriptablePack(
|
|
|
768
768
|
if (buildTimeout !== undefined) clearTimeout(buildTimeout);
|
|
769
769
|
}
|
|
770
770
|
},
|
|
771
|
-
} as
|
|
771
|
+
} as AnyScriptablePackDefinition);
|
|
772
772
|
} catch (error) {
|
|
773
773
|
disposeReason = 'failure';
|
|
774
774
|
return err(
|
|
775
|
-
|
|
775
|
+
scriptablePackLoadFailure(
|
|
776
776
|
sourcePath,
|
|
777
777
|
'module-load',
|
|
778
778
|
'module-load',
|
package/src/scriptable-pack.ts
CHANGED
|
@@ -2,10 +2,11 @@ import type { Asset, AssetGuid, Result } from '@forgeax/engine-types';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Build-time Pack vocabulary shared by the source loader and output
|
|
5
|
-
* producers.
|
|
5
|
+
* producers. ScriptablePack and Pack authoring definitions live in the shared
|
|
6
|
+
* Pack authoring implementation; this facade is the browser-safe source entry.
|
|
6
7
|
*/
|
|
7
8
|
export * from './guid.js';
|
|
8
|
-
export * from './
|
|
9
|
+
export * from './pack-authoring.js';
|
|
9
10
|
|
|
10
11
|
/** Closed ordinary kind vocabulary shared by Pack discovery and producers. */
|
|
11
12
|
export type ScriptablePackAssetKind = Asset['kind'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameterized-pack-authoring-gateway.unit.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/parameterized-pack-authoring-gateway.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameterized-pack-scanner.unit.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/parameterized-pack-scanner.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameterized-pack.unit.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/parameterized-pack.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameterized-pack-node.d.ts","sourceRoot":"","sources":["../src/parameterized-pack-node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgC,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGlF,OAAO,EAIL,KAAK,kBAAkB,EAIvB,KAAK,4BAA4B,EAEjC,KAAK,gCAAgC,EAOtC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,cAAc,CAAC;AAEjE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,2CAA2C;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,CAAC,EAAE,MACpB,SAAS,kCAAkC,EAAE,GAC7C,OAAO,CAAC,SAAS,kCAAkC,EAAE,CAAC,CAAC;IAC3D,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,GAAG,WAAW,KAC1B,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAClD,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;CACpE;AAg3DD,wBAAgB,8CAA8C,CAC5D,OAAO,EAAE,2CAA2C,GACnD,4BAA4B,CAAC,gCAAgC,CAAC,CAEhE;AAED,wBAAgB,iDAAiD,CAC/D,OAAO,EAAE,2CAA2C,GACnD,4BAA4B,CAAC,gCAAgC,CAAC,CAIhE"}
|