@forgeax/engine-pack 0.1.3 → 0.1.6
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 +52 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/__tests__/owner-chain.integration.test.d.ts +2 -0
- package/dist/__tests__/owner-chain.integration.test.d.ts.map +1 -0
- package/dist/__tests__/package-finalizer.contract.test.d.ts +2 -0
- package/dist/__tests__/package-finalizer.contract.test.d.ts.map +1 -0
- package/dist/__tests__/runtime.browser.test.d.ts +2 -0
- package/dist/__tests__/runtime.browser.test.d.ts.map +1 -0
- package/dist/__tests__/scanner-inventory.contract.test.d.ts +2 -0
- package/dist/__tests__/scanner-inventory.contract.test.d.ts.map +1 -0
- package/dist/artifact-path.mjs +53 -0
- package/dist/artifact-path.mjs.map +1 -0
- package/dist/atlas/shelf-pack.d.ts.map +1 -1
- package/dist/build.d.ts +19 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.mjs +10168 -0
- package/dist/build.mjs.map +1 -0
- package/dist/builtin.d.ts +20 -0
- package/dist/builtin.d.ts.map +1 -1
- package/dist/builtin.mjs +141 -0
- package/dist/builtin.mjs.map +1 -0
- package/dist/catalog-builder.d.ts +43 -0
- package/dist/catalog-builder.d.ts.map +1 -0
- package/dist/catalog-delta.d.ts +11 -0
- package/dist/catalog-delta.d.ts.map +1 -0
- package/dist/catalog-projection.d.ts +91 -0
- package/dist/catalog-projection.d.ts.map +1 -0
- package/dist/cli-asset.mjs +231 -484
- package/dist/cli-asset.mjs.map +1 -1
- package/dist/index.mjs +83 -1
- package/dist/index.mjs.map +1 -1
- package/dist/material-cook.d.ts +2 -0
- package/dist/material-cook.d.ts.map +1 -0
- package/dist/material-cook.mjs +193 -0
- package/dist/material-cook.mjs.map +1 -0
- package/dist/mesh-bin-contract.mjs +96 -0
- package/dist/mesh-bin-contract.mjs.map +1 -0
- package/dist/native-cooker-registry.d.ts +19 -0
- package/dist/native-cooker-registry.d.ts.map +1 -1
- package/dist/native-cooker.mjs +37 -0
- package/dist/native-cooker.mjs.map +1 -1
- package/dist/package-finalizer.d.ts +121 -0
- package/dist/package-finalizer.d.ts.map +1 -0
- package/dist/resolve-asset-source.d.ts.map +1 -1
- package/dist/resolve-asset-source.mjs +16 -6
- package/dist/resolve-asset-source.mjs.map +1 -1
- package/dist/runtime-publication.d.ts +44 -0
- package/dist/runtime-publication.d.ts.map +1 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.mjs +7261 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/scanner.d.ts +87 -54
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.mjs +258 -454
- package/dist/scanner.mjs.map +1 -1
- package/dist/scriptable-pack-node.d.ts +3 -8
- package/dist/scriptable-pack-node.d.ts.map +1 -1
- package/dist/scriptable-pack-node.mjs +93 -9
- package/dist/scriptable-pack-node.mjs.map +1 -1
- package/dist/scriptable-pack-worker.mjs +1 -0
- package/dist/scriptable-pack-worker.mjs.map +1 -1
- package/dist/scriptable-pack.d.ts +33 -0
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/scriptable-pack.mjs +91 -2
- package/dist/scriptable-pack.mjs.map +1 -1
- package/dist/topology.d.ts +1 -1
- package/dist/topology.d.ts.map +1 -1
- package/package.json +27 -2
- package/src/__tests__/mesh-bin-consumer-surface.unit.test.ts +2 -1
- package/src/__tests__/owner-chain.integration.test.ts +78 -0
- package/src/__tests__/package-finalizer.contract.test.ts +105 -0
- package/src/__tests__/runtime.browser.test.ts +15 -0
- package/src/__tests__/scanner-inventory.contract.test.ts +167 -0
- package/src/__tests__/scanner-inventory.test.ts +16 -12
- package/src/__tests__/scriptable-pack.unit.test.ts +42 -0
- package/src/atlas/shelf-pack.ts +20 -24
- package/src/build.ts +139 -0
- package/src/builtin.ts +38 -0
- package/src/catalog-builder.ts +313 -0
- package/src/catalog-delta.ts +189 -0
- package/src/catalog-projection.ts +344 -0
- package/src/cli-asset.ts +1 -5
- package/src/index.ts +2 -2
- package/src/material-cook.ts +13 -0
- package/src/native-cooker-registry.ts +72 -0
- package/src/package-finalizer.ts +394 -0
- package/src/resolve-asset-source.ts +2 -7
- package/src/runtime-publication.ts +190 -0
- package/src/runtime.ts +23 -0
- package/src/scanner.ts +289 -290
- package/src/scriptable-pack-node.ts +27 -23
- package/src/scriptable-pack-worker.ts +2 -0
- package/src/scriptable-pack.ts +123 -1
- package/src/topology.ts +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Result } from '@forgeax/engine-types';
|
|
2
2
|
import { type ProducerSemanticIdentityInput } from './evidence/source-inventory.js';
|
|
3
|
-
import { type ScriptablePackAssetKind, type ScriptablePackAuthoringPort, type ScriptablePackDefinition, type ScriptablePackError } from './scriptable-pack.js';
|
|
3
|
+
import { type ScriptablePackAssetKind, type ScriptablePackAuthoringPort, type ScriptablePackDefinition, type ScriptablePackError, type ScriptablePackSourceClosureEntry } from './scriptable-pack.js';
|
|
4
4
|
export interface ScriptablePackModuleExecutor {
|
|
5
5
|
load(sourcePath: string): Promise<unknown>;
|
|
6
6
|
dispose?(reason: 'complete' | 'timeout' | 'failure'): void | Promise<void>;
|
|
@@ -23,13 +23,6 @@ export declare function readOptionalBuildCache<T>(cache: OptionalBuildCache<T>):
|
|
|
23
23
|
readonly value: T;
|
|
24
24
|
readonly fromCache: boolean;
|
|
25
25
|
}>;
|
|
26
|
-
/** Serializable source-closure evidence shared by scanner and producer paths. */
|
|
27
|
-
export interface ScriptablePackSourceClosureEntry {
|
|
28
|
-
readonly path: string;
|
|
29
|
-
readonly digest: string;
|
|
30
|
-
}
|
|
31
|
-
/** Inventory a ScriptablePack module without importing or executing it. */
|
|
32
|
-
export declare function inventoryScriptablePackSource(sourcePath: string): Promise<readonly ScriptablePackSourceClosureEntry[]>;
|
|
33
26
|
export interface LoadScriptablePackOptions {
|
|
34
27
|
/** Maximum time allowed for module initialization in the isolated worker. */
|
|
35
28
|
readonly timeoutMs?: number;
|
|
@@ -39,6 +32,8 @@ export interface LoadScriptablePackOptions {
|
|
|
39
32
|
/** Release the isolated loader after identity projection when build will not be called. */
|
|
40
33
|
readonly metadataOnly?: boolean;
|
|
41
34
|
}
|
|
35
|
+
/** Capture one immutable ScriptablePack module closure for inventory and production. */
|
|
36
|
+
export declare function inventoryScriptablePackSource(sourcePath: string, initialSourceText?: string): Promise<readonly ScriptablePackSourceClosureEntry[]>;
|
|
42
37
|
export declare function createScriptablePackModuleExecutorPool(options?: ScriptablePackModuleExecutorPoolOptions): ScriptablePackModuleExecutorPool;
|
|
43
38
|
export declare function loadScriptablePack(sourcePath: string, options?: LoadScriptablePackOptions): Promise<Result<Readonly<ScriptablePackDefinition>, ScriptablePackError>>;
|
|
44
39
|
interface CanonicalOutput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scriptable-pack-node.d.ts","sourceRoot":"","sources":["../src/scriptable-pack-node.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"scriptable-pack-node.d.ts","sourceRoot":"","sources":["../src/scriptable-pack-node.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAExB,KAAK,gCAAgC,EAEtC,MAAM,sBAAsB,CAAC;AAe9B,MAAM,WAAW,4BAA4B;IAC3C,IA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I,EAAE,mBAAmB,CAAC,CAAC,CAAC;CACjD;AAwID,wFAAwF;AACxF,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CA8DjF;AA+ED,+EAA+E;AAC/E,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,wCAAwC,GAChD,2BAA2B,CAgV7B"}
|
|
@@ -116,6 +116,22 @@ var SCRIPTABLE_PACK_ASSET_KINDS = [
|
|
|
116
116
|
function isScriptablePackAssetKind(value) {
|
|
117
117
|
return SCRIPTABLE_PACK_ASSET_KINDS.includes(value);
|
|
118
118
|
}
|
|
119
|
+
function sceneComponentFieldType(value) {
|
|
120
|
+
if (typeof value === "string") return value;
|
|
121
|
+
if (isRecord(value) && typeof value.type === "string") return value.type;
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
function projectScriptablePackSceneComponents(components) {
|
|
125
|
+
return (components ?? []).map((component) => ({
|
|
126
|
+
name: component.name,
|
|
127
|
+
fields: Object.fromEntries(
|
|
128
|
+
Object.entries(component.fields).map(([fieldName, field]) => [
|
|
129
|
+
fieldName,
|
|
130
|
+
sceneComponentFieldType(field)
|
|
131
|
+
])
|
|
132
|
+
)
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
119
135
|
var SCRIPTABLE_PACK_REQUEST_ID_SCHEMA = {
|
|
120
136
|
type: "string",
|
|
121
137
|
minLength: 1,
|
|
@@ -341,11 +357,20 @@ function freezeDefinition(definition) {
|
|
|
341
357
|
guid.slice()
|
|
342
358
|
])
|
|
343
359
|
);
|
|
360
|
+
const sceneComponents = definition.sceneComponents === void 0 ? void 0 : Object.freeze(
|
|
361
|
+
projectScriptablePackSceneComponents(definition.sceneComponents).map(
|
|
362
|
+
(component) => Object.freeze({
|
|
363
|
+
...component,
|
|
364
|
+
fields: Object.freeze({ ...component.fields })
|
|
365
|
+
})
|
|
366
|
+
)
|
|
367
|
+
);
|
|
344
368
|
return Object.freeze({
|
|
345
369
|
...definition,
|
|
346
370
|
packageId: definition.packageId.slice(),
|
|
347
371
|
assets: Object.freeze(assets),
|
|
348
|
-
externalAssets: Object.freeze(externalAssets)
|
|
372
|
+
externalAssets: Object.freeze(externalAssets),
|
|
373
|
+
...sceneComponents === void 0 ? {} : { sceneComponents }
|
|
349
374
|
});
|
|
350
375
|
}
|
|
351
376
|
function validateScriptablePackDefinition(value, sourcePath) {
|
|
@@ -376,6 +401,63 @@ function validateScriptablePackDefinition(value, sourcePath) {
|
|
|
376
401
|
sourcePath
|
|
377
402
|
);
|
|
378
403
|
}
|
|
404
|
+
if (value.sceneComponents !== void 0) {
|
|
405
|
+
if (!Array.isArray(value.sceneComponents)) {
|
|
406
|
+
return invalid(
|
|
407
|
+
"$.sceneComponents",
|
|
408
|
+
"an array of component tokens or neutral schema rows when present",
|
|
409
|
+
value.sceneComponents,
|
|
410
|
+
sourcePath
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
const componentNames = /* @__PURE__ */ new Set();
|
|
414
|
+
for (const [componentIndex, component] of value.sceneComponents.entries()) {
|
|
415
|
+
if (!isRecord(component)) {
|
|
416
|
+
return invalid(
|
|
417
|
+
`$.sceneComponents[${componentIndex}]`,
|
|
418
|
+
"a component token or neutral schema row",
|
|
419
|
+
component,
|
|
420
|
+
sourcePath
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
if (typeof component.name !== "string" || component.name.trim().length === 0) {
|
|
424
|
+
return invalid(
|
|
425
|
+
`$.sceneComponents[${componentIndex}].name`,
|
|
426
|
+
"a non-empty component name",
|
|
427
|
+
component.name,
|
|
428
|
+
sourcePath
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
if (componentNames.has(component.name)) {
|
|
432
|
+
return invalid(
|
|
433
|
+
`$.sceneComponents[${componentIndex}].name`,
|
|
434
|
+
"component names to be unique within one ScriptablePack",
|
|
435
|
+
component.name,
|
|
436
|
+
sourcePath
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
componentNames.add(component.name);
|
|
440
|
+
if (!isRecord(component.fields)) {
|
|
441
|
+
return invalid(
|
|
442
|
+
`$.sceneComponents[${componentIndex}].fields`,
|
|
443
|
+
"a field-name to schema-type object",
|
|
444
|
+
component.fields,
|
|
445
|
+
sourcePath
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
for (const [fieldName, field] of Object.entries(component.fields)) {
|
|
449
|
+
const type = sceneComponentFieldType(field);
|
|
450
|
+
if (fieldName.trim().length === 0 || type === void 0 || type.trim().length === 0) {
|
|
451
|
+
return invalid(
|
|
452
|
+
`$.sceneComponents[${componentIndex}].fields`,
|
|
453
|
+
"field names with non-empty string schema types",
|
|
454
|
+
field,
|
|
455
|
+
sourcePath
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
379
461
|
if (typeof value.build !== "function") {
|
|
380
462
|
return invalid("$.build", "a build(assetReader) function", value.build, sourcePath);
|
|
381
463
|
}
|
|
@@ -527,7 +609,7 @@ async function readOptionalBuildCache(cache) {
|
|
|
527
609
|
}
|
|
528
610
|
return { value: await cache.coldCook(), fromCache: false };
|
|
529
611
|
}
|
|
530
|
-
async function
|
|
612
|
+
async function resolveRelativeImport(sourcePath, specifier) {
|
|
531
613
|
if (!specifier.startsWith(".")) return void 0;
|
|
532
614
|
const raw = resolve(dirname(sourcePath), specifier);
|
|
533
615
|
const candidates = extname(raw).length > 0 ? [raw] : [
|
|
@@ -548,19 +630,20 @@ async function resolveRelativeSourceImport(sourcePath, specifier) {
|
|
|
548
630
|
}
|
|
549
631
|
return void 0;
|
|
550
632
|
}
|
|
551
|
-
async function inventoryScriptablePackSource(sourcePath) {
|
|
552
|
-
const
|
|
633
|
+
async function inventoryScriptablePackSource(sourcePath, initialSourceText) {
|
|
634
|
+
const root = await realpath(sourcePath);
|
|
635
|
+
const pending = [root];
|
|
553
636
|
const seen = /* @__PURE__ */ new Set();
|
|
554
637
|
const entries = [];
|
|
555
638
|
while (pending.length > 0) {
|
|
556
639
|
const path = pending.pop();
|
|
557
640
|
if (path === void 0 || seen.has(path)) continue;
|
|
558
641
|
seen.add(path);
|
|
559
|
-
const bytes = await readFile(path);
|
|
642
|
+
const bytes = path === root && initialSourceText !== void 0 ? new TextEncoder().encode(initialSourceText) : await readFile(path);
|
|
560
643
|
entries.push({ path, digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}` });
|
|
561
|
-
const
|
|
562
|
-
for (const imported of
|
|
563
|
-
const resolved = await
|
|
644
|
+
const source = new TextDecoder().decode(bytes);
|
|
645
|
+
for (const imported of ts.preProcessFile(source, true, true).importedFiles) {
|
|
646
|
+
const resolved = await resolveRelativeImport(path, imported.fileName);
|
|
564
647
|
if (resolved !== void 0) pending.push(await realpath(resolved));
|
|
565
648
|
}
|
|
566
649
|
}
|
|
@@ -634,6 +717,7 @@ var WorkerScriptablePackExecutor = class {
|
|
|
634
717
|
if (message === null || typeof message !== "object") return;
|
|
635
718
|
const value = message;
|
|
636
719
|
if (value.kind === "loaded") {
|
|
720
|
+
worker.unref();
|
|
637
721
|
worker.off("message", onMessage);
|
|
638
722
|
resolveLoad({
|
|
639
723
|
default: value.definition === void 0 ? void 0 : {
|
|
@@ -1207,7 +1291,7 @@ export default {
|
|
|
1207
1291
|
${manifest.name === void 0 ? "" : `name: ${JSON.stringify(manifest.name)},
|
|
1208
1292
|
`}assets,
|
|
1209
1293
|
externalAssets,
|
|
1210
|
-
build: () => ok(Object.fromEntries(Object.entries(assets).map(([sourceKey, asset]) => [sourceKey, createOutput(asset.kind)])) as
|
|
1294
|
+
build: () => ok(Object.fromEntries(Object.entries(assets).map(([sourceKey, asset]) => [sourceKey, createOutput(asset.kind)])) as Record<string, Asset>),
|
|
1211
1295
|
} satisfies ScriptablePackDefinition;
|
|
1212
1296
|
`;
|
|
1213
1297
|
}
|