@forgeax/engine-import 0.1.2
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/LICENSE +202 -0
- package/README.md +226 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/decode-image-owner.test-d.d.ts +2 -0
- package/dist/__tests__/decode-image-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/import-contract-migration.test.d.ts +2 -0
- package/dist/__tests__/import-contract-migration.test.d.ts.map +1 -0
- package/dist/__tests__/import-dependencies.test.d.ts +2 -0
- package/dist/__tests__/import-dependencies.test.d.ts.map +1 -0
- package/dist/__tests__/import-finalizer-digest-retry.test.d.ts +2 -0
- package/dist/__tests__/import-finalizer-digest-retry.test.d.ts.map +1 -0
- package/dist/__tests__/import-local-artifacts.test.d.ts +2 -0
- package/dist/__tests__/import-local-artifacts.test.d.ts.map +1 -0
- package/dist/__tests__/import.unit.test.d.ts +2 -0
- package/dist/__tests__/import.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-import-product.unit.test.d.ts +2 -0
- package/dist/__tests__/material-import-product.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin-contract.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin-contract.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-output-producers.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-output-producers.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-production-producers.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-production-producers.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-staged-snapshot.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-staged-snapshot.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack.integration.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack.integration.test.d.ts.map +1 -0
- package/dist/__tests__/source-overrides-import-context.unit.test.d.ts +2 -0
- package/dist/__tests__/source-overrides-import-context.unit.test.d.ts.map +1 -0
- package/dist/import-product.d.ts +36 -0
- package/dist/import-product.d.ts.map +1 -0
- package/dist/import-runner.d.ts +133 -0
- package/dist/import-runner.d.ts.map +1 -0
- package/dist/importer-registry.d.ts +40 -0
- package/dist/importer-registry.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1607 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mesh-bin.d.ts +19 -0
- package/dist/mesh-bin.d.ts.map +1 -0
- package/dist/scriptable-pack-output-producers.d.ts +6 -0
- package/dist/scriptable-pack-output-producers.d.ts.map +1 -0
- package/dist/scriptable-pack-staged-snapshot.d.ts +22 -0
- package/dist/scriptable-pack-staged-snapshot.d.ts.map +1 -0
- package/dist/scriptable-pack.d.ts +153 -0
- package/dist/scriptable-pack.d.ts.map +1 -0
- package/package.json +63 -0
- package/src/__tests__/decode-image-owner.test-d.ts +53 -0
- package/src/__tests__/import-contract-migration.test.ts +190 -0
- package/src/__tests__/import-dependencies.test.ts +65 -0
- package/src/__tests__/import-finalizer-digest-retry.test.ts +113 -0
- package/src/__tests__/import-local-artifacts.test.ts +100 -0
- package/src/__tests__/import.unit.test.ts +429 -0
- package/src/__tests__/material-import-product.unit.test.ts +56 -0
- package/src/__tests__/mesh-bin-contract.test.ts +95 -0
- package/src/__tests__/mesh-bin-morph-v3.test.ts +44 -0
- package/src/__tests__/mesh-bin.test.ts +102 -0
- package/src/__tests__/scriptable-pack-output-producers.unit.test.ts +190 -0
- package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +429 -0
- package/src/__tests__/scriptable-pack-staged-snapshot.unit.test.ts +258 -0
- package/src/__tests__/scriptable-pack.integration.test.ts +435 -0
- package/src/__tests__/source-overrides-import-context.unit.test.ts +92 -0
- package/src/import-product.ts +195 -0
- package/src/import-runner.ts +720 -0
- package/src/importer-registry.ts +80 -0
- package/src/index.ts +103 -0
- package/src/mesh-bin.ts +229 -0
- package/src/scriptable-pack-output-producers.ts +466 -0
- package/src/scriptable-pack-staged-snapshot.ts +161 -0
- package/src/scriptable-pack.ts +615 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/import-product.ts","../src/import-runner.ts","../src/importer-registry.ts","../src/mesh-bin.ts","../src/scriptable-pack.ts","../src/scriptable-pack-output-producers.ts","../src/scriptable-pack-staged-snapshot.ts"],"names":["bytes","ref","err","ok","AssetGuid","record","ImportError","product","fingerprint","stable","AssetError","built"],"mappings":";;;;;;;;;;;;AA6CA,SAAS,QAAQ,KAAA,EAA0D;AACzE,EAAA,OAAO,GAAA,CAAI;AAAA,IACT,IAAA,EAAM,iCAAA;AAAA,IACN,QAAA,EAAU,+DAAA;AAAA,IACV,IAAA,EAAM,+EAAA;AAAA,IACN,MAAA,EAAQ,EAAE,KAAA;AAAM,GACjB,CAAA;AACH;AAEA,SAAS,SAAS,MAAA,EAA8C;AAC9D,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,MAAM,CAAC,CAAA;AAC5B;AAEO,SAAS,4BACd,KAAA,EAC2D;AAC3D,EAAA,IAAI,CAAC,MAAM,IAAA,IAAQ,CAAC,MAAM,UAAA,EAAY,OAAO,QAAQ,iBAAiB,CAAA;AACtE,EAAA,IAAI,MAAM,QAAA,CAAS,IAAA,KAAS,UAAA,EAAY,OAAO,QAAQ,eAAe,CAAA;AACtE,EAAA,IAAI,CAAC,KAAA,CAAM,cAAA,CAAe,oBAAoB,CAAC,KAAA,CAAM,eAAe,eAAA,EAAiB;AACnF,IAAA,OAAO,QAAQ,gBAAgB,CAAA;AAAA,EACjC;AACA,EAAA,MAAM,OAAO,QAAA,CAAS;AAAA,IACpB,GAAG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,EAAI,GAAG,CAAC,CAAA,GACrCC,EAAAA,CAAG,eAAA,CAAgB,MAAM,CAAC,CAAA;AAAA,IAChC;AAAA,GACF,CAAA;AAEA,EAAA,OAAO,SAAA,CAAU,EAAE,CAAA;AACrB","file":"index.mjs","sourcesContent":["import type {\n ArtifactDescriptor,\n AssetRef,\n CookProduct,\n ImportedArtifactBody,\n ImportedAsset,\n ImportProduct,\n MaterialAsset,\n Result,\n} from '@forgeax/engine-types';\nimport { err, ok } from '@forgeax/engine-types';\n\nexport interface MaterialImportRefs {\n readonly parent: readonly string[];\n readonly textures: readonly string[];\n readonly samplers: readonly string[];\n readonly modules: readonly string[];\n}\n\nexport interface MaterialSourceEvidence {\n readonly inputFingerprint: string;\n readonly importerVersion: string;\n}\n\nexport interface MaterialImportProductInput {\n readonly guid: string;\n readonly sourcePath: string;\n readonly material: MaterialAsset;\n readonly refs: MaterialImportRefs;\n readonly sourceEvidence: MaterialSourceEvidence;\n}\n\nexport interface MaterialImportProduct {\n readonly asset: ImportedAsset<MaterialAsset>;\n readonly sourcePath: string;\n readonly sourceEvidence: MaterialSourceEvidence;\n}\n\nexport interface MaterialImportProductError {\n readonly code: 'material-import-product-invalid';\n readonly expected: string;\n readonly hint: string;\n readonly detail: { readonly field: string };\n}\n\nfunction invalid(field: string): Result<never, MaterialImportProductError> {\n return err({\n code: 'material-import-product-invalid',\n expected: 'an authored MaterialAsset with complete dependency references',\n hint: 'declare every material dependency before the product enters the cook pipeline',\n detail: { field },\n });\n}\n\nfunction distinct(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n\nexport function createMaterialImportProduct(\n input: MaterialImportProductInput,\n): Result<MaterialImportProduct, MaterialImportProductError> {\n if (!input.guid || !input.sourcePath) return invalid('guid/sourcePath');\n if (input.material.kind !== 'material') return invalid('material.kind');\n if (!input.sourceEvidence.inputFingerprint || !input.sourceEvidence.importerVersion) {\n return invalid('sourceEvidence');\n }\n const refs = distinct([\n ...input.refs.parent,\n ...input.refs.textures,\n ...input.refs.samplers,\n ...input.refs.modules,\n ]);\n return ok({\n sourcePath: input.sourcePath,\n sourceEvidence: input.sourceEvidence,\n asset: {\n guid: input.guid,\n kind: 'material',\n payload: input.material,\n refs: refs.map((guid): AssetRef => ({ guid })),\n artifacts: {},\n },\n });\n}\n\nexport function materialImportProductReady(\n product: MaterialImportProduct,\n availableRefs: ReadonlySet<string>,\n): boolean {\n return product.asset.refs.every((reference) => availableRefs.has(reference.guid));\n}\n\nasync function sha256Hex(bytes: Uint8Array): Promise<string> {\n const subtle = globalThis.crypto?.subtle;\n if (subtle === undefined) throw new Error('Web Crypto API is required for importer digests');\n const owned = new Uint8Array(bytes.byteLength);\n owned.set(bytes);\n const digest = await subtle.digest('SHA-256', owned.buffer);\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\nasync function artifactDigest(bytes: Uint8Array): Promise<string> {\n return `sha256:${await sha256Hex(bytes)}`;\n}\n\nfunction concatBytes(chunks: readonly (Uint8Array | string)[]): Uint8Array {\n const encoder = new TextEncoder();\n const encoded = chunks.map((chunk) =>\n typeof chunk === 'string' ? encoder.encode(chunk) : chunk,\n );\n const totalLength = encoded.reduce((total, chunk) => total + chunk.byteLength, 0);\n const bytes = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of encoded) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n}\n\nasync function productDigest(\n asset: ImportedAsset<unknown>,\n artifacts: Readonly<Record<string, ArtifactDescriptor>>,\n): Promise<string> {\n const chunks: (Uint8Array | string)[] = [\n JSON.stringify(digestPayload(asset)),\n JSON.stringify(asset.refs.map((ref) => ref.guid)),\n JSON.stringify(artifacts),\n ];\n for (const [key, artifact] of Object.entries(asset.artifacts).sort(([left], [right]) =>\n left.localeCompare(right),\n )) {\n chunks.push(key, artifact.bytes);\n }\n return `sha256:${await sha256Hex(concatBytes(chunks))}`;\n}\n\nasync function artifactDescriptors(\n artifacts: Readonly<Record<string, ImportedArtifactBody>>,\n): Promise<Readonly<Record<string, ArtifactDescriptor>>> {\n const entries: [string, ArtifactDescriptor][] = [];\n for (const [path, artifact] of Object.entries(artifacts)) {\n entries.push([\n path,\n {\n path,\n mediaType: artifact.mediaType,\n byteLength: artifact.bytes.byteLength,\n integrity: { algorithm: 'sha256' as const, digest: await artifactDigest(artifact.bytes) },\n ...(artifact.assetCodec === undefined ? {} : { assetCodec: artifact.assetCodec }),\n },\n ]);\n }\n return Object.fromEntries(entries);\n}\n\nfunction digestPayload(asset: ImportedAsset<unknown>): unknown {\n if (Object.keys(asset.artifacts).length === 0) return asset.payload;\n if (asset.kind === 'mesh') return { kind: 'mesh' };\n if (asset.kind === 'texture' || asset.kind === 'equirect') {\n const payload = asset.payload as Record<string, unknown>;\n const { data: _runtimeBytes, ...metadata } = payload;\n return metadata;\n }\n return asset.payload;\n}\n\n/** Convert each importer asset into the shared completed producer product. */\nexport function finalizeImportProducts(\n product: ImportProduct<unknown>,\n inputFingerprint: string,\n): Promise<readonly CookProduct[]> {\n return (async () => {\n const products: CookProduct[] = [];\n for (const asset of product.assets) {\n const artifacts = await artifactDescriptors(asset.artifacts);\n const digest = await productDigest(asset, artifacts);\n products.push({\n guid: asset.guid,\n payload: asset.payload,\n refs: asset.refs.map((ref) => ref.guid),\n artifacts,\n digest,\n receipt: {\n guid: asset.guid,\n origin: 'sourceMeta' as const,\n status: 'succeeded' as const,\n inputFingerprint,\n outputDigest: digest,\n },\n });\n }\n return products;\n })();\n}\n","// @forgeax/engine-import - import runner (feat-20260603-asset-import-loader-injection M2 / w15).\n//\n// The build-time orchestration that turns one parsed `*.meta.json` sidecar\n// into the logical Pack v2 package. It is the consumer side of\n// the ImporterRegistry: it reads `meta.importer`, looks up the registered\n// Importer, calls `importer.import(ctx)`, enforces the GUID import-stable iron\n// law against the produced asset set, then folds the produced PODs into\n// logical `assets[]` rows. Artifact bytes stay with their owning asset;\n// final paths and integrity belong to M3.\n//\n// Error model (charter P3, ImportErrorCode 5 closed members):\n// - importer-not-registered : registry.get(meta.importer) === undefined\n// - source-read-failed : ctx.readSource() failed\n// - import-internal-error : importer conversion or CookProduct finalization threw (never bare-throws out)\n// - guid-mismatch : produced a GUID not declared in subAssets[]\n// - import-produced-no-assets: produced [], or omitted a declared GUID\n//\n// The reserved key `importer: 'shader'` is skipped (plan-strategy D-4 /\n// research Finding 10): shader sidecars are consumed by the orthogonal\n// `@forgeax/engine-vite-plugin-shader` transform pipeline, never by asset\n// import. `runImport` returns `{ ok: true, value: { skipped: 'shader' } }`\n// for them so the caller can account for the sidecar without writing a DDC.\n\nimport type {\n AssetRelation,\n CatalogDiagnostic,\n CookProduct,\n ImportContext,\n ImportDiagnostic,\n ImportError as ImportErrorType,\n ImportedArtifactBody,\n ImportProduct,\n ProviderProvenance,\n ResourceRevision,\n SourceOverrideMap,\n} from '@forgeax/engine-types';\nimport {\n canonicalizeSourceOverrides,\n IMPORT_ERROR_HINTS,\n ImportError,\n validateSourceOverrideMap,\n} from '@forgeax/engine-types';\nimport { finalizeImportProducts } from './import-product.js';\nimport type { ImporterRegistry } from './importer-registry.js';\n\n/** Reserved `meta.importer` key consumed by vite-plugin-shader, not the import runner. */\nexport const SHADER_RESERVED_IMPORTER_KEY = 'shader';\n\n/**\n * Classify an importer throw as a build-time module-LOAD failure (the importer\n * module / native addon could not be imported) vs a conversion THROW (the\n * loaded importer ran and threw). feat-20260629 D-5: both keep the\n * `import-internal-error` code, but a load failure surfaces `.detail.loadError`\n * so AI users distinguish \"my importer is not loadable / not built\" from \"my\n * importer ran and crashed\" without parsing `.message`.\n *\n * Node signals a module-load failure via `err.code` (`MODULE_NOT_FOUND` for\n * CJS `require`, `ERR_MODULE_NOT_FOUND` for ESM `import()`, `ERR_DLOPEN_FAILED`\n * for a broken native `.node` addon) or a recognizable message. Native FBX-style\n * bindings throw a plain Error whose message names the missing addon.\n */\nfunction isModuleLoadFailure(e: unknown): boolean {\n if (!(e instanceof Error)) return false;\n const code = (e as { code?: unknown }).code;\n if (\n code === 'MODULE_NOT_FOUND' ||\n code === 'ERR_MODULE_NOT_FOUND' ||\n code === 'ERR_DLOPEN_FAILED'\n ) {\n return true;\n }\n const msg = e.message;\n return (\n msg.includes('Cannot find module') || msg.includes('native addon') || msg.includes('.node')\n );\n}\n\n/**\n * bug-20260610-pack-typed-array-roundtrip: normalise a value tree so every\n * typed-array becomes a plain `number[]`. The DDC pack is serialised via\n * `JSON.stringify`; left as-is, a `Float32Array` round-trips to an indexed\n * object (`{ \"0\": v0, ... }`) and the runtime mesh / animation-clip loaders\n * reject it with `asset-parse-failed`. Walking the tree once at the importer\n * boundary keeps every downstream consumer (build emitFile, dev startMetaImport,\n * and any future pack-cache tool) aligned on the same on-disk shape.\n */\nexport function normaliseForPack(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n if (\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Uint8Array ||\n value instanceof Uint16Array ||\n value instanceof Uint32Array ||\n value instanceof Int8Array ||\n value instanceof Int16Array ||\n value instanceof Int32Array\n ) {\n return Array.from(value as ArrayLike<number>);\n }\n if (Array.isArray(value)) {\n return value.map(normaliseForPack);\n }\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n out[k] = normaliseForPack(v);\n }\n return out;\n }\n return value;\n}\n\n/** Result envelope returned by {@link runImport} (mirrors the engine `Result<T,E>` shape). */\nexport type RunImportResult =\n | { readonly ok: true; readonly value: RunImportOk }\n | { readonly ok: false; readonly error: ImportErrorType };\n\nexport type RunImportProductResult =\n | {\n readonly ok: true;\n readonly value:\n | { readonly skipped: 'shader' }\n | {\n readonly product: ImportProduct;\n readonly cookProducts: readonly CookProduct[];\n };\n }\n | { readonly ok: false; readonly error: ImportErrorType };\n\n/**\n * Success payload. `skipped: 'shader'` marks a reserved shader sidecar the\n * runner intentionally did not import (no DDC written); otherwise `pack` is the\n * logical Pack v2 document. Artifact bytes remain owned by each asset.\n */\nexport type RunImportOk =\n | { readonly skipped: 'shader' }\n | {\n readonly product: ImportProduct;\n readonly cookProducts: readonly CookProduct[];\n readonly pack: DdcPack;\n };\n\n/** The logical Pack v2 document consumed by the shared finalizer. */\nexport interface DdcPack {\n readonly schemaVersion: '2.0.0';\n readonly kind: 'internal-text-package';\n readonly packageId?: string;\n readonly provenance?: ProviderProvenance;\n readonly revision?: ResourceRevision;\n readonly diagnostics?: readonly CatalogDiagnostic[];\n readonly assets: ReadonlyArray<{\n readonly guid: string;\n readonly kind: string;\n readonly name?: string;\n readonly sourceKey?: string;\n readonly sourceIndex?: number;\n readonly relations?: readonly AssetRelation[];\n readonly payload: Record<string, unknown>;\n readonly refs: readonly string[];\n readonly artifacts: Readonly<Record<string, ImportedArtifactBody>>;\n }>;\n}\n\n/** Minimal parsed-meta shape the runner reads (a superset of the sidecar). */\nexport interface RunImportMeta {\n readonly importer: string;\n readonly source: string;\n readonly packageId?: string;\n readonly provenance?: ProviderProvenance;\n readonly revision?: ResourceRevision;\n readonly diagnostics?: readonly CatalogDiagnostic[];\n readonly importSettings?: Readonly<Record<string, unknown>>;\n readonly sourceOverrides?: SourceOverrideMap;\n /** Skip the normalized DDC pack when a downstream finalizer owns publication. */\n readonly buildPack?: boolean;\n readonly subAssets: ReadonlyArray<{\n readonly guid: string;\n readonly sourceIndex: number;\n readonly kind: string;\n readonly sourceKey?: string;\n readonly relations?: readonly AssetRelation[];\n }>;\n}\n\nfunction declarationFields(\n declaration: RunImportMeta['subAssets'][number] | undefined,\n): Pick<DdcPack['assets'][number], 'sourceKey' | 'sourceIndex' | 'relations'> {\n if (declaration === undefined) return {};\n return {\n sourceIndex: declaration.sourceIndex,\n ...(declaration.sourceKey !== undefined ? { sourceKey: declaration.sourceKey } : {}),\n ...(declaration.relations !== undefined ? { relations: declaration.relations } : {}),\n };\n}\n\n/** Filesystem + decode capabilities the runner needs to drive an importer.\n *\n * `readSource` reads the primary source bytes addressed by `meta.source`.\n * `readSibling` reads a co-located file (e.g. an external `.bin` / `.png`\n * referenced from a `.gltf` via relative URI). Optional today so existing\n * callers stay green; importers that depend on it (gltfImporter texture\n * external-uri path) gate on its presence and surface a structured\n * `'source-read-failed'` ImportError when the host did not wire it.\n *\n * `decodeImage` is the M3 D-1 seam: gltfImporter funnels all three image\n * sources (bufferView / data-uri / external-uri) through one callback so\n * `@forgeax/engine-gltf` carries no `from '@forgeax/engine-image'` edge\n * (the grep gate `packages/gltf/scripts/check-no-image-import.mjs` enforces\n * this). The concrete decode lives in `@forgeax/engine-image/image-importer`;\n * the build-time orchestrator binds the callback when constructing this\n * `ImportRunnerFs`.\n */\nexport interface ImportRunnerFs {\n readSource(\n sourcePath: string,\n ): Promise<\n | { readonly ok: true; readonly value: Uint8Array }\n | { readonly ok: false; readonly error: unknown }\n >;\n readSibling?(\n sourcePath: string,\n uri: string,\n ): Promise<\n | { readonly ok: true; readonly value: Uint8Array }\n | { readonly ok: false; readonly error: unknown }\n >;\n decodeImage?: ImportContext['decodeImage'];\n}\n\n/**\n * Resolve an `images[].uri` (or any sibling reference) against the directory\n * of `meta.source`. Pure path arithmetic — no I/O. Used as the default\n * `readSibling` fallback when the host did not wire one explicitly.\n */\nfunction joinSiblingPath(sourcePath: string, uri: string): string {\n const slash = Math.max(sourcePath.lastIndexOf('/'), sourcePath.lastIndexOf('\\\\'));\n const dir = slash >= 0 ? sourcePath.slice(0, slash + 1) : '';\n return `${dir}${uri}`;\n}\n\nfunction normalizeDependencyPath(path: string): string {\n const slash = path.replaceAll('\\\\', '/');\n const parts: string[] = [];\n for (const part of slash.split('/')) {\n if (part === '' || part === '.') continue;\n if (part === '..') {\n parts.pop();\n } else {\n parts.push(part);\n }\n }\n return parts.join('/');\n}\n\nfunction errResult(error: ImportErrorType): {\n readonly ok: false;\n readonly error: ImportErrorType;\n} {\n return { ok: false, error };\n}\n\nfunction sourceKeyActual(value: unknown): string {\n if (typeof value === 'string') return JSON.stringify(value);\n if (value === undefined) return 'missing';\n return typeof value;\n}\n\ntype SourceReaderErrorMetadata = {\n readonly code?: unknown;\n readonly name?: unknown;\n readonly message?: unknown;\n readonly detail?: unknown;\n};\n\nfunction sourceReadFailureReason(error: unknown): string {\n if (typeof error !== 'object' || error === null) {\n return typeof error === 'string' ? error : 'unknown';\n }\n const metadata = error as SourceReaderErrorMetadata;\n const token =\n typeof metadata.code === 'string'\n ? metadata.code\n : typeof metadata.name === 'string'\n ? metadata.name\n : undefined;\n switch (token) {\n case 'ENOENT':\n case 'NotFoundError':\n return 'not-found';\n case 'EACCES':\n case 'EPERM':\n case 'PermissionDeniedError':\n case 'NotAllowedError':\n case 'SecurityError':\n return 'permission-denied';\n case 'EAGAIN':\n case 'EBUSY':\n case 'EINTR':\n case 'ECONNABORTED':\n case 'ECONNREFUSED':\n case 'ECONNRESET':\n case 'EHOSTUNREACH':\n case 'ENETDOWN':\n case 'ENETUNREACH':\n case 'ETIMEDOUT':\n case 'EPIPE':\n case 'ABORT_ERR':\n case 'AbortError':\n case 'TimeoutError':\n return 'transient';\n default:\n if (typeof metadata.detail === 'object' && metadata.detail !== null) {\n const reason = (metadata.detail as { readonly reason?: unknown }).reason;\n if (typeof reason === 'string' && reason.length > 0) return reason;\n }\n if (typeof metadata.message === 'string' && metadata.message.length > 0) {\n return metadata.message;\n }\n return 'unknown';\n }\n}\n\n/**\n * Validate producer identity before source work or DDC product finalization.\n * Multi-output declarations cannot recover identity from sourceIndex, array\n * order, or a path, so every row must carry one unique semantic sourceKey.\n * Single-output declarations may omit the key for legacy source compatibility;\n * producers that expose a semantic output should still declare it so Catalog\n * evidence remains stable when the output later gains siblings.\n */\nfunction validateOutputSourceKeys(meta: RunImportMeta): ImportErrorType | undefined {\n if (meta.subAssets.length <= 1) return undefined;\n\n const diagnostics: ImportDiagnostic[] = [];\n const seen = new Map<string, number>();\n for (const [index, declaration] of meta.subAssets.entries()) {\n const sourcePath = `${meta.source}#subAssets[${index}]`;\n const sourceRange = { start: 0, end: 0, line: 1, column: 1 };\n const sourceKey = declaration.sourceKey;\n if (typeof sourceKey !== 'string' || sourceKey.trim().length === 0) {\n diagnostics.push({\n code: 'source-key-required',\n severity: 'error',\n sourcePath,\n sourceRange,\n rule: 'import-output-source-key',\n expected: 'a non-empty producer-owned sourceKey',\n actual: sourceKeyActual(sourceKey),\n hint: 'publish a stable semantic sourceKey; sourceIndex is only a locator',\n });\n continue;\n }\n const prior = seen.get(sourceKey);\n if (prior !== undefined) {\n diagnostics.push({\n code: 'duplicate-source-key',\n severity: 'error',\n sourcePath,\n sourceRange,\n rule: 'import-output-source-key-unique',\n expected: 'sourceKey to be unique within one imported package',\n actual: `${JSON.stringify(sourceKey)} duplicates subAssets[${prior}]`,\n hint: 'rename the duplicate semantic output before writing Meta',\n });\n continue;\n }\n seen.set(sourceKey, index);\n }\n if (diagnostics.length === 0) return undefined;\n return new ImportError({\n code: 'source-validation-failed',\n expected: 'every writable imported output to declare a unique non-empty sourceKey',\n hint: IMPORT_ERROR_HINTS['source-validation-failed'],\n detail: { diagnostics },\n });\n}\n\n/**\n * Run the importer for one parsed meta sidecar and produce its DDC.\n *\n * @param meta the parsed `*.meta.json` (importer + source + subAssets[]).\n * @param registry the wired {@link ImporterRegistry}.\n * @param fs the source-read capability (injected so the runner stays\n * testable without touching real disk).\n */\nexport function runImport(\n meta: RunImportMeta & { readonly buildPack: false },\n registry: ImporterRegistry,\n fs: ImportRunnerFs,\n): Promise<RunImportProductResult>;\nexport function runImport(\n meta: RunImportMeta,\n registry: ImporterRegistry,\n fs: ImportRunnerFs,\n): Promise<RunImportResult>;\nexport async function runImport(\n meta: RunImportMeta,\n registry: ImporterRegistry,\n fs: ImportRunnerFs,\n): Promise<RunImportResult | RunImportProductResult> {\n // Reserved shader key: orthogonal vite-plugin-shader pipeline owns these.\n if (meta.importer === SHADER_RESERVED_IMPORTER_KEY) {\n return { ok: true, value: { skipped: 'shader' } };\n }\n\n const sourceKeyError = validateOutputSourceKeys(meta);\n if (sourceKeyError !== undefined) return errResult(sourceKeyError);\n\n const declaredSourceKeys = meta.subAssets.flatMap((subAsset) =>\n subAsset.sourceKey === undefined ? [] : [subAsset.sourceKey],\n );\n const sourceOverridesResult = validateSourceOverrideMap(meta.sourceOverrides, declaredSourceKeys);\n if (!sourceOverridesResult.ok) {\n const error = new ImportError({\n code: sourceOverridesResult.error.code,\n expected: sourceOverridesResult.error.expected,\n hint: IMPORT_ERROR_HINTS[sourceOverridesResult.error.code],\n detail: {\n sourceKey: sourceOverridesResult.error.actual,\n declaredSourceKeys,\n reason: sourceOverridesResult.error.hint,\n },\n });\n if (sourceOverridesResult.error.actual !== undefined) {\n Object.assign(error, { actual: sourceOverridesResult.error.actual });\n }\n return errResult(error);\n }\n\n const importer = registry.get(meta.importer);\n if (importer === undefined) {\n return errResult(\n new ImportError({\n code: 'importer-not-registered',\n expected: `an importer registered for meta.importer \"${meta.importer}\"`,\n hint: IMPORT_ERROR_HINTS['importer-not-registered'],\n detail: {\n importer: meta.importer,\n registeredImporters: registry.registeredImporters(),\n },\n }),\n );\n }\n\n const dependencies = new Set<string>();\n const readSource = async (sourcePath: string) => {\n dependencies.add(normalizeDependencyPath(sourcePath));\n try {\n return await fs.readSource(sourcePath);\n } catch (error) {\n return { ok: false as const, error };\n }\n };\n\n const readSibling = async (\n uri: string,\n ): Promise<\n | { readonly ok: true; readonly value: Uint8Array }\n | { readonly ok: false; readonly error: ImportErrorType }\n > => {\n let inner:\n | { readonly ok: true; readonly value: Uint8Array }\n | { readonly ok: false; readonly error: unknown }\n | { readonly ok: false; readonly error: ImportErrorType };\n try {\n if (fs.readSibling) {\n dependencies.add(normalizeDependencyPath(joinSiblingPath(meta.source, uri)));\n inner = await fs.readSibling(meta.source, uri);\n } else {\n inner = await readSource(joinSiblingPath(meta.source, uri));\n }\n } catch (error) {\n inner = { ok: false, error };\n }\n if (inner.ok) {\n return { ok: true, value: inner.value };\n }\n return {\n ok: false,\n error: new ImportError({\n code: 'source-read-failed',\n expected: `readable sibling file \"${uri}\" co-located with meta.source \"${meta.source}\"`,\n hint: IMPORT_ERROR_HINTS['source-read-failed'],\n detail: {\n source: uri,\n reason: sourceReadFailureReason(inner.error),\n },\n }),\n };\n };\n\n const decodeImage: ImportContext['decodeImage'] =\n fs.decodeImage ??\n (async () => {\n throw new Error(\n 'ImportRunnerFs.decodeImage was not provided; gltfImporter texture extraction requires the host (vite-plugin-pack / cli-gltf / test) to bind decodeImage when constructing the ImportRunnerFs',\n );\n });\n\n const canonicalSourceOverrides = canonicalizeSourceOverrides(sourceOverridesResult.value);\n const ctx: ImportContext = {\n source: meta.source,\n readSource: () => readSource(meta.source),\n readSibling,\n decodeImage,\n subAssets: meta.subAssets.map(({ guid, sourceIndex, sourceKey, kind }) => ({\n guid,\n sourceIndex,\n ...(sourceKey === undefined ? {} : { sourceKey }),\n kind,\n })),\n importSettings: meta.importSettings ?? {},\n ...(canonicalSourceOverrides === undefined\n ? {}\n : { sourceOverrides: canonicalSourceOverrides }),\n };\n\n // Probe the source once up-front so a missing/unreadable source surfaces as\n // source-read-failed rather than as an opaque import-internal-error inside\n // the importer (charter P3 precise attribution).\n const sourceProbe = await readSource(meta.source);\n if (!sourceProbe.ok) {\n return errResult(\n new ImportError({\n code: 'source-read-failed',\n expected: `readable source file at meta.source \"${meta.source}\"`,\n hint: IMPORT_ERROR_HINTS['source-read-failed'],\n detail: {\n source: meta.source,\n reason: sourceReadFailureReason(sourceProbe.error),\n },\n }),\n );\n }\n\n let product: ImportProduct;\n try {\n const imported = (await importer.import(ctx)) as\n | { readonly ok: boolean; readonly value?: ImportProduct; readonly error?: ImportErrorType }\n | undefined;\n if (\n imported === undefined ||\n imported === null ||\n typeof imported !== 'object' ||\n !('ok' in imported)\n ) {\n throw new Error(\n 'importer returned a legacy or malformed result; expected ImportResult<ImportProduct>',\n );\n } else {\n if (!imported.ok) {\n if (imported.error === undefined)\n throw new Error('importer returned an invalid failure result');\n if (imported.error instanceof ImportError) return errResult(imported.error);\n return errResult(\n new ImportError({\n code: 'import-internal-error',\n expected: `importer \"${meta.importer}\" to return a structured ImportError`,\n hint: IMPORT_ERROR_HINTS['import-internal-error'],\n detail: { reason: String(imported.error) },\n }),\n );\n }\n if (imported.value === undefined)\n throw new Error('importer returned an invalid success result');\n const value = imported.value;\n if (\n value === undefined ||\n !Array.isArray(value.assets) ||\n !Array.isArray(value.sourceDependencies) ||\n 'artifacts' in value\n ) {\n throw new Error('importer returned an invalid ImportProduct');\n }\n for (const asset of value.assets) {\n if (\n asset === null ||\n typeof asset !== 'object' ||\n !('artifacts' in asset) ||\n asset.artifacts === null ||\n typeof asset.artifacts !== 'object' ||\n Array.isArray(asset.artifacts)\n ) {\n throw new Error('importer returned an asset without local artifacts');\n }\n }\n product = value;\n }\n } catch (e) {\n if (e instanceof ImportError) return errResult(e);\n const message = e instanceof Error ? e.message : String(e);\n // D-5: a module-LOAD failure rides `.detail.loadError`; a conversion THROW\n // rides `.detail.reason`. Same `import-internal-error` code (no new closed\n // union member); AI users branch on the `.detail` shape.\n if (isModuleLoadFailure(e)) {\n return errResult(\n new ImportError({\n code: 'import-internal-error',\n expected: `importer module \"${meta.importer}\" to load (module + native addon present)`,\n hint: IMPORT_ERROR_HINTS['import-internal-error'],\n detail: { loadError: message },\n }),\n );\n }\n return errResult(\n new ImportError({\n code: 'import-internal-error',\n expected: `importer \"${meta.importer}\" to convert the source without throwing`,\n hint: IMPORT_ERROR_HINTS['import-internal-error'],\n detail: { reason: message },\n }),\n );\n }\n\n const produced = product.assets;\n\n // GUID import-stable iron law: the produced GUID set must be a superset of\n // the declared set, and must not contain any GUID the meta never declared.\n const declared = new Set(meta.subAssets.map((s) => s.guid));\n const producedGuids = new Set(produced.map((a) => a.guid));\n\n const unexpectedGuids = [...producedGuids].filter((g) => !declared.has(g));\n if (unexpectedGuids.length > 0) {\n return errResult(\n new ImportError({\n code: 'guid-mismatch',\n expected: 'every produced GUID to be declared in meta.subAssets[]',\n hint: IMPORT_ERROR_HINTS['guid-mismatch'],\n detail: { unexpectedGuids },\n }),\n );\n }\n\n const missingGuids = [...declared].filter((g) => !producedGuids.has(g));\n if (produced.length === 0 || missingGuids.length > 0) {\n return errResult(\n new ImportError({\n code: 'import-produced-no-assets',\n expected:\n produced.length === 0\n ? 'the importer to produce at least one ImportedAsset'\n : 'the produced GUID set to be a superset of meta.subAssets[]',\n hint: IMPORT_ERROR_HINTS['import-produced-no-assets'],\n detail: { missingGuids },\n }),\n );\n }\n\n const declarations = new Map(\n meta.subAssets.map((declaration) => [declaration.guid, declaration]),\n );\n const productWithDependencies = {\n ...product,\n sourceDependencies: [...dependencies],\n };\n const inputFingerprint = `source:${[...dependencies].sort().join('|')}`;\n let cookProducts: readonly CookProduct[];\n try {\n cookProducts = await finalizeImportProducts(productWithDependencies, inputFingerprint);\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n return errResult(\n new ImportError({\n code: 'import-internal-error',\n expected: `importer \"${meta.importer}\" finalization to produce complete CookProduct digests`,\n hint: IMPORT_ERROR_HINTS['import-internal-error'],\n detail: { reason: `finalization/digest: ${reason}` },\n }),\n );\n }\n if (meta.buildPack === false) {\n return {\n ok: true,\n value: { product: productWithDependencies, cookProducts },\n };\n }\n\n const assets = produced.map((a) => {\n const outputFields = declarationFields(declarations.get(a.guid));\n return {\n guid: a.guid,\n kind: a.kind,\n ...outputFields,\n ...(a.name !== undefined ? { name: a.name } : {}),\n // bug-20260610: mesh / scene / animation-clip payloads carry Float32Array\n // / Uint16Array / Uint32Array fields. JSON.stringify on a typed array\n // serialises to `{ \"0\": v0, \"1\": v1, ... }` (a plain object), which the\n // runtime mesh / animation loaders reject (`vertexData instanceof\n // Float32Array` and `Array.isArray(vertexData)` both fail). Convert\n // every typed-array field to a plain Array here so the pack is JSON-\n // roundtrip safe end-to-end. This matches the convention every\n // existing pack-fixture test uses (`vertices: Array.from(...)`).\n payload: normaliseForPack(a.payload as unknown) as Record<string, unknown>,\n refs: a.refs.map((r) => r.guid),\n artifacts: a.artifacts,\n };\n });\n\n const pack: DdcPack = {\n schemaVersion: '2.0.0',\n kind: 'internal-text-package',\n ...(meta.packageId !== undefined ? { packageId: meta.packageId } : {}),\n ...(meta.provenance !== undefined ? { provenance: meta.provenance } : {}),\n ...(meta.revision !== undefined ? { revision: meta.revision } : {}),\n ...(meta.diagnostics !== undefined ? { diagnostics: meta.diagnostics } : {}),\n assets,\n };\n\n return {\n ok: true,\n value: {\n product: {\n ...productWithDependencies,\n },\n cookProducts,\n pack,\n },\n };\n}\n","// @forgeax/engine-import - ImporterRegistry (feat-20260603-asset-import-loader-injection M2 / w14).\n//\n// The build-time twin of the runtime LoaderRegistry\n// (packages/runtime/src/loader-registry.ts): an injectable table that maps a\n// `meta.importer` string key -> an `Importer` (the contract SSOT lives in\n// `@forgeax/engine-types`). The import runner holds one of these and dispatches\n// on `meta.importer` through `get(key)` instead of a hardcoded\n// `if (importer === ...)` chain (plan-strategy D-1).\n//\n// Shape mirrors the runtime LoaderRegistry + Console `Registry`\n// (packages/console/src/registry.ts) register/lookup pattern (research\n// Finding 8). The injected unit is an **object** `{ key, import }`, not a bare\n// function, so a \"one importer key -> one Importer\" dispatch table is the\n// natural shape.\n//\n// Fail-fast semantics (charter P3): `register` throws on a malformed importer\n// (empty key or non-function `import`) at wire time, so a misconfigured host\n// surfaces immediately rather than at the first import run. `register` is\n// idempotent on a repeated key (last write wins, no throw) so re-wiring a\n// registry across build invocations is safe.\n\nimport type { Importer } from '@forgeax/engine-types';\n\n/**\n * Injectable `meta.importer` -> {@link Importer} table held by the import\n * runner.\n *\n * @example Wire + dispatch (build tooling side)\n * ```ts\n * import { ImporterRegistry } from '@forgeax/engine-import';\n * import { gltfImporter } from '@forgeax/engine-gltf';\n * const importers = new ImporterRegistry();\n * importers.register(gltfImporter);\n * const gltf = importers.get('gltf'); // Importer | undefined\n * ```\n */\nexport class ImporterRegistry {\n private readonly importers = new Map<string, Importer>();\n\n /**\n * Register an importer for its `importer.key`. Fail-fast on a malformed\n * importer (charter P3); idempotent on a repeated key (last write wins).\n *\n * @param importer the `{ key, import }` object to register.\n * @throws TypeError when `importer.key` is empty or `importer.import` is not\n * a function - a wire-time misconfiguration the host must fix.\n */\n register(importer: Importer): void {\n if (typeof importer.key !== 'string' || importer.key.length === 0) {\n throw new TypeError(\n `ImporterRegistry.register: importer.key must be a non-empty string (got ${JSON.stringify(importer.key)})`,\n );\n }\n if (typeof importer.import !== 'function') {\n throw new TypeError(\n `ImporterRegistry.register: importer.import must be a function for key \"${importer.key}\"`,\n );\n }\n this.importers.set(importer.key, importer);\n }\n\n /**\n * Look up the importer registered for `key`. Returns `undefined` when no\n * importer is wired - the import runner maps that to a structured\n * `ImportError(code='importer-not-registered')` with the registered keys in\n * `.detail.registeredImporters` (charter P3).\n */\n get(key: string): Importer | undefined {\n return this.importers.get(key);\n }\n\n /**\n * The importer keys currently wired, in insertion order. Fed into the\n * `importer-not-registered` error `.detail.registeredImporters` so AI users\n * see exactly what is injectable.\n */\n registeredImporters(): readonly string[] {\n return [...this.importers.keys()];\n }\n}\n","import { deriveVertexLayoutProjection } from '@forgeax/engine-geometry';\nimport {\n MESH_BIN_HEADER_V4_BYTES,\n type MeshBinContractError,\n type MeshBinHeaderV4,\n writeMeshBinHeader,\n} from '@forgeax/engine-pack';\nimport { AssetGuid } from '@forgeax/engine-pack/guid';\nimport {\n err,\n type MeshAsset,\n ok,\n type Result,\n type VertexAttributeMap,\n} from '@forgeax/engine-types';\n\ntype MeshPayloadIn = { readonly [Key in keyof MeshAsset]?: MeshAsset[Key] | undefined } & {\n readonly vertexCount?: number;\n};\n\nexport type MeshBinEncodeError =\n | MeshBinContractError\n | {\n readonly code: 'mesh-bin-payload-invalid';\n readonly subject: 'mesh-bin';\n readonly sourceKey: string;\n readonly expected: string;\n readonly actual: string;\n readonly recovery: string;\n };\n\nfunction failure(sourceKey: string, expected: string, actual: string): MeshBinEncodeError {\n return {\n code: 'mesh-bin-payload-invalid',\n subject: 'mesh-bin',\n sourceKey,\n expected,\n actual,\n recovery: 're-cook the source with its Meta sidecar through the build-time importer',\n };\n}\n\nfunction asAttributeMap(value: unknown): VertexAttributeMap {\n return (value ?? {}) as VertexAttributeMap;\n}\n\nfunction jsonValue(value: unknown): unknown {\n if (value instanceof Float32Array || value instanceof Uint16Array) return Array.from(value);\n if (Array.isArray(value)) return value.map(jsonValue);\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, nested]) => [key, jsonValue(nested)]),\n );\n }\n return value;\n}\n\nfunction refsMeta(payload: MeshPayloadIn, refs: readonly string[]): Record<string, unknown> {\n const materialSlots = (payload.materialSlots ?? [{ slotName: 'Default' }]).map(\n (slot, slotIndex) => {\n const defaultMaterial = slot.defaultMaterial;\n let defaultMaterialRef: number | undefined;\n if (defaultMaterial !== undefined) {\n const guid = AssetGuid.format(defaultMaterial);\n defaultMaterialRef = refs.findIndex((candidate) => candidate.toLowerCase() === guid);\n if (defaultMaterialRef < 0) {\n throw new Error(\n `material slot ${slotIndex} default material ${guid} is absent from refs`,\n );\n }\n }\n return {\n slotName: slot.slotName,\n ...(slot.sourceKey === undefined ? {} : { sourceKey: slot.sourceKey }),\n ...(defaultMaterialRef === undefined ? {} : { defaultMaterialRef }),\n };\n },\n );\n return {\n submeshes:\n payload.submeshes === undefined || payload.submeshes.length === 0\n ? [{ indexOffset: 0, indexCount: payload.indices?.length ?? 0, materialSlot: 0 }]\n : payload.submeshes,\n materialSlots,\n ...(payload.aabb === undefined ? {} : { aabb: jsonValue(payload.aabb) }),\n ...(payload.morphTargets === undefined\n ? {}\n : { morphTargets: jsonValue(payload.morphTargets) }),\n ...(payload.morphWeights === undefined\n ? {}\n : { morphWeights: jsonValue(payload.morphWeights) }),\n };\n}\n\n/** Encode one canonical v4 mesh binary. No legacy version is accepted or emitted. */\nexport function packMeshBinV4(\n payload: MeshPayloadIn,\n sourceKey: string,\n refs: readonly string[] = [],\n): Result<Uint8Array, MeshBinEncodeError> {\n try {\n const vertices = payload.vertices;\n const indices = payload.indices;\n if (!(vertices instanceof Float32Array)) {\n return err(\n failure(sourceKey, 'Float32Array interleaved vertices', 'vertices is not Float32Array'),\n );\n }\n if (\n indices !== undefined &&\n !(indices instanceof Uint16Array || indices instanceof Uint32Array)\n ) {\n return err(\n failure(sourceKey, 'Uint16Array or Uint32Array indices', 'indices has an unsupported type'),\n );\n }\n const attributes = asAttributeMap(payload.attributes);\n const projection = deriveVertexLayoutProjection(attributes);\n if (projection.attributes.length === 0 || projection.arrayStride === 0) {\n return err(\n failure(\n sourceKey,\n 'a non-empty canonical geometry projection',\n 'projection has no attributes',\n ),\n );\n }\n const vertexCount = payload.vertexCount ?? vertices.byteLength / projection.arrayStride;\n if (!Number.isSafeInteger(vertexCount) || vertexCount < 0) {\n return err(\n failure(sourceKey, 'a non-negative safe vertex cardinality', `vertexCount=${vertexCount}`),\n );\n }\n if (vertices.byteLength !== vertexCount * projection.arrayStride) {\n return err(\n failure(\n sourceKey,\n `vertices.byteLength=${vertexCount * projection.arrayStride}`,\n `vertices.byteLength=${vertices.byteLength}; stride=${projection.arrayStride}`,\n ),\n );\n }\n for (const attribute of projection.attributes) {\n const value = attributes[attribute.key];\n const components = attribute.byteLength / (attribute.format === 'uint16x4' ? 2 : 4);\n if (\n value === undefined ||\n (!(value instanceof Float32Array) && !(value instanceof Uint16Array)) ||\n value.length !== vertexCount * components\n ) {\n return err(\n failure(\n sourceKey,\n `${attribute.key} cardinality=${vertexCount * components}`,\n `${attribute.key} cardinality=${value?.byteLength ?? 'missing'}`,\n ),\n );\n }\n }\n const interleaved = new Uint8Array(vertexCount * projection.arrayStride);\n const interleavedView = new DataView(interleaved.buffer);\n for (const attribute of projection.attributes) {\n const value = attributes[attribute.key];\n if (value === undefined) continue;\n const components = attribute.byteLength / (attribute.format === 'uint16x4' ? 2 : 4);\n for (let vertex = 0; vertex < vertexCount; vertex++) {\n for (let component = 0; component < components; component++) {\n const sourceIndex = vertex * components + component;\n const targetOffset =\n vertex * projection.arrayStride +\n attribute.offset +\n component * (attribute.format === 'uint16x4' ? 2 : 4);\n if (attribute.format === 'uint16x4') {\n interleavedView.setUint16(targetOffset, (value as Uint16Array)[sourceIndex] ?? 0, true);\n } else {\n interleavedView.setFloat32(\n targetOffset,\n (value as Float32Array)[sourceIndex] ?? 0,\n true,\n );\n }\n }\n }\n }\n const indexCount = indices?.length ?? 0;\n const indexWidth = indices === undefined || indexCount === 0 ? 0 : indices.BYTES_PER_ELEMENT;\n const indexBytes = indexCount * indexWidth;\n if (!Number.isSafeInteger(indexBytes) || indexBytes > 0xffffffff) {\n return err(failure(sourceKey, 'safe index payload byte length', `indexBytes=${indexBytes}`));\n }\n const meta = new TextEncoder().encode(JSON.stringify(refsMeta(payload, refs)));\n const header: MeshBinHeaderV4 = {\n version: 4,\n projectionVersion: projection.schemaVersion,\n mask: projection.mask,\n digest: projection.digest,\n stride: projection.arrayStride,\n vertexCount,\n vertexBytes: interleaved.byteLength,\n indexCount,\n indexWidth: indexWidth as 0 | 2 | 4,\n indexBytes,\n jsonBytes: meta.byteLength,\n };\n const total = MESH_BIN_HEADER_V4_BYTES + interleaved.byteLength + indexBytes + meta.byteLength;\n if (!Number.isSafeInteger(total) || total > 0xffffffff) {\n return err(failure(sourceKey, 'safe mesh binary byte length', `total=${total}`));\n }\n const out = new Uint8Array(total);\n writeMeshBinHeader(header, out);\n let offset = MESH_BIN_HEADER_V4_BYTES;\n out.set(interleaved, offset);\n offset += interleaved.byteLength;\n if (indices !== undefined && indexBytes > 0) {\n out.set(new Uint8Array(indices.buffer, indices.byteOffset, indices.byteLength), offset);\n offset += indexBytes;\n }\n out.set(meta, offset);\n return ok(out);\n } catch (error) {\n return err(\n failure(\n sourceKey,\n 'valid canonical mesh payload',\n error instanceof Error ? error.message : String(error),\n ),\n );\n }\n}\n","import type { Component } from '@forgeax/engine-ecs';\nimport { isScriptablePackAssetKind, type ScriptablePackAssetKind } from '@forgeax/engine-pack';\nimport { AssetGuid } from '@forgeax/engine-pack/guid';\nimport {\n type AssetReader,\n projectScriptablePackMeta,\n type ScriptablePackDefinition,\n type ScriptablePackError,\n type ScriptablePackReadError,\n} from '@forgeax/engine-pack/source';\nimport type {\n AnimationGraph,\n Asset,\n AssetGuid as AssetGuidType,\n AssetPublicationEnvelope,\n AssetRef,\n FontAsset,\n ImportedArtifactBody,\n ImportedAsset,\n ImportProduct,\n MaterialAsset,\n MeshAsset,\n Result,\n TilesetAsset,\n} from '@forgeax/engine-types';\nimport { AssetError, err, ImportError, ok } from '@forgeax/engine-types';\n\nfunction commonPathPrefix(paths: readonly string[]): string {\n const first = paths[0];\n if (first === undefined) return '';\n const firstNormalized = first.replaceAll('\\\\', '/');\n const firstDirectory = firstNormalized.slice(0, firstNormalized.lastIndexOf('/'));\n const parts = firstDirectory.split('/');\n let length = parts.length;\n for (const path of paths.slice(1)) {\n const normalized = path.replaceAll('\\\\', '/');\n const candidate = normalized.slice(0, normalized.lastIndexOf('/')).split('/');\n length = Math.min(length, candidate.length);\n for (let index = 0; index < length; index += 1) {\n if (parts[index] !== candidate[index]) {\n length = index;\n break;\n }\n }\n }\n return parts.slice(0, length).join('/');\n}\n\n/** Remove host-specific absolute roots from the source closure fingerprint. */\nfunction stableSourceClosure(\n closure: readonly ScriptablePackSourceClosureEntry[],\n): readonly ScriptablePackSourceClosureEntry[] {\n const root = commonPathPrefix(closure.map((entry) => entry.path));\n return closure\n .map((entry) => ({\n path: entry.path.replaceAll('\\\\', '/').slice(root.length).replace(/^\\/+/, ''),\n digest: entry.digest,\n }))\n .sort((left, right) => left.path.localeCompare(right.path));\n}\n\nexport interface ScriptablePackAssetSnapshot {\n readonly asset: Asset;\n readonly generation: number;\n readonly digest: string;\n}\n\nexport interface ScriptablePackStagedOutput {\n readonly guid: AssetGuidType;\n /** Producer-owned stable output identity from the ScriptablePack definition. */\n readonly sourceKey?: string;\n readonly asset: Asset;\n readonly digest?: string;\n}\n\nexport interface ScriptablePackAssetSnapshotSource {\n readByGuid(\n guid: AssetGuidType,\n ): Promise<Result<ScriptablePackAssetSnapshot, ScriptablePackReadError>>;\n}\n\nexport interface AssetOutputInput {\n readonly guid: string;\n readonly sourceKey: string;\n readonly asset: Asset;\n /** World-local schema projection for scene ref externalization. */\n readonly components?: ReadonlyMap<string, Component>;\n}\n\ntype MaterialPackPayload = Omit<MaterialAsset, 'parent' | 'values'> & {\n readonly parent?: number;\n readonly values?: Readonly<Record<string, unknown>>;\n};\n\ntype ScenePackPayload = { readonly kind: 'scene'; readonly [key: string]: unknown };\n\ntype FontPackPayload = Omit<FontAsset, 'atlas' | 'sampler'> & {\n readonly atlasGuid: string;\n readonly samplerGuid: string;\n};\n\ntype TilesetPackPayload = Omit<TilesetAsset, 'atlases'> & { readonly atlases: readonly number[] };\n\ntype AnimationGraphPackPayload = Omit<AnimationGraph, 'nodes'> & {\n readonly nodes: readonly (\n | Exclude<AnimationGraph['nodes'][number], { readonly type: 'clip' }>\n | (Omit<Extract<AnimationGraph['nodes'][number], { readonly type: 'clip' }>, 'clip'> & {\n readonly clip: number;\n })\n )[];\n};\n\n/** Serialized Pack projection; durable runtime Assets never carry ref indices. */\nexport type AssetOutputPayloadByKind = {\n readonly mesh: MeshAsset;\n readonly material: MaterialPackPayload;\n readonly scene: ScenePackPayload;\n readonly texture: Extract<Asset, { readonly kind: 'texture' }>;\n readonly equirect: Extract<Asset, { readonly kind: 'equirect' }>;\n readonly sampler: Extract<Asset, { readonly kind: 'sampler' }>;\n readonly font: FontPackPayload;\n readonly 'render-pipeline': Extract<Asset, { readonly kind: 'render-pipeline' }>;\n readonly tileset: TilesetPackPayload;\n readonly video: Extract<Asset, { readonly kind: 'video' }>;\n readonly skeleton: Extract<Asset, { readonly kind: 'skeleton' }>;\n readonly skin: Extract<Asset, { readonly kind: 'skin' }>;\n readonly 'animation-clip': Extract<Asset, { readonly kind: 'animation-clip' }>;\n readonly 'animation-graph': AnimationGraphPackPayload;\n readonly audio: Extract<Asset, { readonly kind: 'audio' }>;\n readonly 'particle-effect': Extract<Asset, { readonly kind: 'particle-effect' }>;\n};\n\nexport type AssetOutputPayload = AssetOutputPayloadByKind[ScriptablePackAssetKind];\n\nexport interface AssetOutputProduct {\n readonly payload: AssetOutputPayload;\n readonly refs: readonly AssetRef[];\n readonly artifacts: Readonly<Record<string, ImportedArtifactBody>>;\n}\n\nexport interface AssetOutputProducer {\n readonly kind: string;\n readonly version: string;\n produce(\n input: AssetOutputInput,\n ): Result<AssetOutputProduct, ImportError> | Promise<Result<AssetOutputProduct, ImportError>>;\n}\n\nexport class AssetOutputProducerRegistry {\n private readonly producers = new Map<string, AssetOutputProducer>();\n\n register(producer: AssetOutputProducer): void {\n if (producer.kind.trim().length === 0 || producer.version.trim().length === 0) {\n throw new TypeError('ScriptablePack output producer kind and version must be non-empty');\n }\n if (typeof producer.produce !== 'function') {\n throw new TypeError(`ScriptablePack output producer ${producer.kind} must expose produce`);\n }\n this.producers.set(producer.kind, producer);\n }\n\n get(kind: string): AssetOutputProducer | undefined {\n return this.producers.get(kind);\n }\n\n versions(): Readonly<Record<string, string>> {\n return Object.fromEntries(\n [...this.producers.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([kind, producer]) => [kind, producer.version]),\n );\n }\n}\n\nexport type ScriptablePackExternalUsage = 'reference' | 'content' | 'both';\n\nexport interface ScriptablePackExternalEvidence {\n readonly guid: string;\n readonly usage: ScriptablePackExternalUsage;\n readonly generation?: number;\n readonly digest?: string;\n}\n\nexport interface ScriptablePackSourceClosureEntry {\n readonly path: string;\n readonly digest: string;\n}\n\nexport interface ScriptablePackBuildProduct {\n readonly product: ImportProduct<unknown>;\n /** Raw private outputs for the current staged build generation, never a runtime publication path. */\n readonly stagedOutputs: readonly ScriptablePackStagedOutput[];\n readonly externalEvidence: readonly ScriptablePackExternalEvidence[];\n readonly inputFingerprint: string;\n /** Engine publication fields projected after ordinary producers run. */\n readonly publication?: AssetPublicationEnvelope;\n}\n\n/** Domain-owned structured failure transported without flattening its recovery fields. */\nexport interface ScriptablePackDomainError {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: unknown;\n}\n\nexport type ScriptablePackBuildBridgeResult = Result<\n ScriptablePackBuildProduct,\n ScriptablePackError | AssetError | ImportError | ScriptablePackDomainError\n>;\n\ninterface ObservedRead {\n readonly guid: string;\n readonly asset: Asset;\n readonly generation: number;\n readonly digest: string;\n}\n\nfunction privateClone<T>(value: T): T {\n return structuredClone(value);\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction isAsset(value: unknown): value is Asset {\n return record(value) && typeof value.kind === 'string' && isScriptablePackAssetKind(value.kind);\n}\n\nfunction isStructuredDomainError(value: unknown): value is ScriptablePackDomainError {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as { readonly code?: unknown }).code === 'string' &&\n typeof (value as { readonly expected?: unknown }).expected === 'string' &&\n typeof (value as { readonly hint?: unknown }).hint === 'string'\n );\n}\n\nfunction remapBuildFailureSource(\n value: unknown,\n sourcePath: string,\n): ScriptablePackError | undefined {\n if (value === null || typeof value !== 'object') return undefined;\n const error = value as { readonly code?: unknown; readonly detail?: unknown };\n if (error.code !== 'pack-source-load-failed') return undefined;\n if (error.detail === null || typeof error.detail !== 'object') return undefined;\n const detail = error.detail as { readonly phase?: unknown } & Record<string, unknown>;\n if (detail.phase !== 'build') return undefined;\n return {\n ...(value as ScriptablePackError),\n detail: { ...detail, sourcePath },\n } as ScriptablePackError;\n}\n\nfunction observedAssetReader(source?: ScriptablePackAssetSnapshotSource): {\n readonly reader: AssetReader;\n readonly reads: ReadonlyMap<string, ObservedRead>;\n} {\n const reads = new Map<string, ObservedRead>();\n const reader: AssetReader = {\n async readByGuid<TAsset extends Asset = Asset>(guid: AssetGuidType) {\n const key = AssetGuid.format(guid);\n const cached = reads.get(key);\n if (cached !== undefined) return ok(privateClone(cached.asset) as TAsset);\n if (source === undefined) {\n return err(\n new AssetError({\n code: 'asset-not-found',\n expected: `a host Asset snapshot source for ScriptablePack content read ${key}`,\n hint: 'configure pluginPack({ scriptablePack: { assetSource, ... } }) or remove the content read',\n }),\n );\n }\n const result = await source.readByGuid(guid);\n if (!result.ok) return result;\n const fixed = privateClone(result.value.asset);\n reads.set(key, {\n guid: key,\n asset: fixed,\n generation: result.value.generation,\n digest: result.value.digest,\n });\n return ok(privateClone(fixed) as TAsset);\n },\n };\n return { reader, reads };\n}\n\nfunction stable(value: unknown): string {\n if (value instanceof Uint8Array) return JSON.stringify(Array.from(value));\n if (Array.isArray(value)) return `[${value.map(stable).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${stable(record[key])}`)\n .join(',')}}`;\n }\n return JSON.stringify(value) ?? 'null';\n}\n\nasync function fingerprint(value: unknown): Promise<string> {\n const subtle = globalThis.crypto?.subtle;\n if (subtle === undefined)\n throw new Error('Web Crypto API is required for ScriptablePack fingerprints');\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(stable(value)));\n const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join(\n '',\n );\n return `sha256:${hex}`;\n}\n\nfunction outputError(\n definition: ScriptablePackDefinition,\n output: Readonly<Record<string, unknown>>,\n): ScriptablePackError | undefined {\n const declaredKeys = Object.keys(definition.assets);\n const outputKeys = Object.keys(output);\n const outputKeySet = new Set(outputKeys);\n const declaredKeySet = new Set(declaredKeys);\n const missingKeys = declaredKeys.filter((key) => !outputKeySet.has(key));\n const unexpectedSourceKeys = outputKeys.filter((key) => !declaredKeySet.has(key));\n const kindMismatches = declaredKeys.flatMap((sourceKey) => {\n const descriptor = definition.assets[sourceKey];\n const value = output[sourceKey];\n if (descriptor === undefined || value === undefined) return [];\n const actualKind =\n value !== null && typeof value === 'object' && 'kind' in value\n ? String((value as { readonly kind: unknown }).kind)\n : typeof value;\n return actualKind === descriptor.kind\n ? []\n : [{ sourceKey, expected: descriptor.kind, actual: actualKind }];\n });\n if (\n missingKeys.length === 0 &&\n unexpectedSourceKeys.length === 0 &&\n kindMismatches.length === 0\n ) {\n return undefined;\n }\n return {\n code: 'pack-source-output-invalid',\n expected: 'build output keys and kinds to exactly match definition.assets',\n hint: 'inspect sourceKey and GUID topology, then rebuild or cold-cook the ScriptablePack',\n detail: {\n missingGuids: missingKeys.map((key) =>\n AssetGuid.format(definition.assets[key]?.guid as AssetGuidType),\n ),\n unexpectedSourceKeys,\n kindMismatches,\n },\n };\n}\n\nfunction externalClosureError(\n declared: ReadonlySet<string>,\n referenced: ReadonlySet<string>,\n read: ReadonlySet<string>,\n): ScriptablePackError | undefined {\n const used = new Set([...referenced, ...read]);\n const undeclaredReferencedGuids = [...referenced].filter((guid) => !declared.has(guid));\n const undeclaredReadGuids = [...read].filter((guid) => !declared.has(guid));\n const unusedDeclaredGuids = [...declared].filter((guid) => !used.has(guid));\n if (\n undeclaredReferencedGuids.length === 0 &&\n undeclaredReadGuids.length === 0 &&\n unusedDeclaredGuids.length === 0\n ) {\n return undefined;\n }\n return {\n code: 'pack-source-external-closure-mismatch',\n expected: 'externalAssets GUIDs to equal output external refs union AssetReader reads',\n hint: 'inspect refs and AssetReader reads, repair GUID declarations, then rebuild or cold-cook',\n detail: {\n undeclaredReferencedGuids: undeclaredReferencedGuids.sort(),\n undeclaredReadGuids: undeclaredReadGuids.sort(),\n unusedDeclaredGuids: unusedDeclaredGuids.sort(),\n },\n };\n}\n\nfunction productContractError(\n sourceKey: string,\n kind: string,\n product: AssetOutputProduct,\n): ScriptablePackError | undefined {\n const mismatches: { sourceKey: string; expected: string; actual: string }[] = [];\n if (product.payload.kind !== kind) {\n mismatches.push({ sourceKey, expected: kind, actual: product.payload.kind });\n }\n for (const reference of product.refs) {\n if (!AssetGuid.parse(reference.guid).ok) {\n mismatches.push({\n sourceKey,\n expected: 'every producer ref to contain a valid Asset GUID',\n actual: reference.guid,\n });\n break;\n }\n }\n for (const [artifactKey, artifact] of Object.entries(product.artifacts)) {\n if (\n artifactKey.length === 0 ||\n artifactKey.startsWith('/') ||\n artifactKey.includes('..') ||\n artifactKey.includes('\\\\') ||\n artifact.mediaType.trim().length === 0 ||\n !(artifact.bytes instanceof Uint8Array)\n ) {\n mismatches.push({\n sourceKey,\n expected: 'asset-local artifacts with safe keys, mediaType, and Uint8Array bytes',\n actual: artifactKey,\n });\n break;\n }\n }\n if (mismatches.length === 0) return undefined;\n return {\n code: 'pack-source-output-invalid',\n expected: 'producer output refs and asset-local artifacts to satisfy the Pack v2 contract',\n hint: 'inspect sourceKey and artifact provenance, repair refs or bytes, then rebuild or cold-cook',\n detail: { missingGuids: [], unexpectedSourceKeys: [], kindMismatches: mismatches },\n };\n}\n\nexport interface BuildScriptablePackOptions {\n readonly definition: ScriptablePackDefinition;\n readonly sourcePath: string;\n readonly assetSource?: ScriptablePackAssetSnapshotSource;\n readonly outputs: AssetOutputProducerRegistry;\n readonly sourceClosure: readonly ScriptablePackSourceClosureEntry[];\n readonly authoringContractVersion: string;\n /** Optional owner-provided component schema projection for scene output. */\n readonly components?: ReadonlyMap<string, Component>;\n}\n\n/**\n * Build one external ScriptablePack through the producer-owned Pack bridge.\n * Success preserves payloads, GUID refs, and local artifacts; failure retains\n * `code`, `expected`, `hint`, and `detail` for recovery by the caller.\n */\nexport async function buildScriptablePack(\n options: BuildScriptablePackOptions,\n): Promise<ScriptablePackBuildBridgeResult> {\n const observed = observedAssetReader(options.assetSource);\n let built: Awaited<ReturnType<ScriptablePackDefinition['build']>>;\n try {\n const build = options.definition.build;\n built = await build(observed.reader);\n } catch (error) {\n return err(\n new ImportError({\n code: 'import-internal-error',\n expected: 'ScriptablePack build to return a structured Result without throwing',\n hint: 'fix the build implementation and return a structured failure for expected authoring errors',\n detail: { reason: error instanceof Error ? error.message : String(error) },\n }),\n );\n }\n if (!built.ok) {\n const remappedBuildFailure = remapBuildFailureSource(built.error, options.sourcePath);\n if (remappedBuildFailure !== undefined) return err(remappedBuildFailure);\n if (\n built.error instanceof ImportError ||\n built.error instanceof AssetError ||\n isStructuredDomainError(built.error)\n ) {\n return err(built.error);\n }\n return err(\n new ImportError({\n code: 'import-internal-error',\n expected: 'ScriptablePack build failure to use a structured domain error',\n hint: 'return an error with code, expected, hint, and optional detail fields',\n detail: { reason: String(built.error) },\n }),\n );\n }\n if (!record(built.value)) {\n return err(\n new ImportError({\n code: 'import-internal-error',\n expected: 'ScriptablePack build output to be an object keyed by declared sourceKey',\n hint: 'return one concrete Asset payload for each declared sourceKey',\n detail: { reason: 'build output is not an object' },\n }),\n );\n }\n const output = built.value;\n const invalidOutput = outputError(options.definition, output);\n if (invalidOutput !== undefined) return err(invalidOutput);\n\n const assets: ImportedAsset<unknown>[] = [];\n for (const sourceKey of Object.keys(options.definition.assets).sort()) {\n const descriptor = options.definition.assets[sourceKey];\n const asset = output[sourceKey];\n if (descriptor === undefined) continue;\n if (!isAsset(asset)) {\n return err(\n new ImportError({\n code: 'import-internal-error',\n expected: `a concrete Asset payload for sourceKey ${sourceKey}`,\n hint: 'return a durable Asset with a kind from SCRIPTABLE_PACK_ASSET_KINDS',\n detail: { reason: 'build output payload is missing or has an unknown kind' },\n }),\n );\n }\n const producer = options.outputs.get(descriptor.kind);\n if (producer === undefined) {\n return err({\n code: 'pack-source-output-invalid',\n expected: `a domain output producer registered for kind ${descriptor.kind}`,\n hint: 'attach the owning producer capability, inspect registration, then rebuild or cold-cook',\n detail: {\n missingGuids: [AssetGuid.format(descriptor.guid)],\n unexpectedSourceKeys: [],\n kindMismatches: [],\n },\n });\n }\n const product = await producer.produce({\n guid: AssetGuid.format(descriptor.guid),\n sourceKey,\n asset,\n ...(options.components === undefined ? {} : { components: options.components }),\n });\n if (!product.ok) return err(product.error);\n const productError = productContractError(sourceKey, descriptor.kind, product.value);\n if (productError !== undefined) return err(productError);\n assets.push({\n guid: AssetGuid.format(descriptor.guid),\n kind: descriptor.kind,\n ...(descriptor.name === undefined ? {} : { name: descriptor.name }),\n payload: product.value.payload,\n refs: product.value.refs,\n artifacts: product.value.artifacts,\n });\n }\n\n const local = new Set(assets.map((asset) => asset.guid.toLowerCase()));\n const referenced = new Set(\n assets\n .flatMap((asset) => asset.refs.map((reference) => reference.guid.toLowerCase()))\n .filter((guid) => !local.has(guid)),\n );\n const read = new Set([...observed.reads.keys()].map((guid) => guid.toLowerCase()));\n const declared = new Set(\n Object.values(options.definition.externalAssets).map((guid) =>\n AssetGuid.format(guid).toLowerCase(),\n ),\n );\n const closureError = externalClosureError(declared, referenced, read);\n if (closureError !== undefined) return err(closureError);\n\n const externalEvidence = [...declared].sort().map((guid): ScriptablePackExternalEvidence => {\n const observedRead = observed.reads.get(guid);\n const isReference = referenced.has(guid);\n return {\n guid,\n usage: observedRead === undefined ? 'reference' : isReference ? 'both' : 'content',\n ...(observedRead === undefined\n ? {}\n : { generation: observedRead.generation, digest: observedRead.digest }),\n };\n });\n // The dependency generation is runtime provenance, not a content identity.\n // It may advance when a fresh AssetRegistry is created even though the\n // referenced bytes are unchanged. Keep it in the receipt for diagnostics,\n // but exclude it from the source fingerprint so an identical source closure\n // and dependency digest produce the same publication fence across Edit and\n // fresh Play worlds.\n const fingerprintEvidence = externalEvidence.map(({ guid, usage, digest }) => ({\n guid,\n usage,\n ...(digest === undefined ? {} : { digest }),\n }));\n const product: ImportProduct<unknown> = {\n assets,\n sourceDependencies: options.sourceClosure.map((entry) => entry.path),\n };\n const inputFingerprint = await fingerprint({\n meta: projectScriptablePackMeta(options.definition, options.sourcePath),\n sourceClosure: stableSourceClosure(options.sourceClosure),\n externalEvidence: fingerprintEvidence,\n authoringContractVersion: options.authoringContractVersion,\n producerVersions: options.outputs.versions(),\n });\n return ok({\n product,\n stagedOutputs: await Promise.all(\n Object.keys(options.definition.assets)\n .sort()\n .map(async (sourceKey) => {\n const descriptor = options.definition.assets[sourceKey];\n const asset = output[sourceKey];\n if (descriptor === undefined || !isAsset(asset)) {\n throw new Error(`validated ScriptablePack output ${sourceKey} is not an Asset`);\n }\n return {\n guid: descriptor.guid,\n sourceKey,\n asset: privateClone(asset),\n digest: await fingerprint(asset),\n };\n }),\n ),\n externalEvidence,\n inputFingerprint,\n });\n}\n","import { componentSchema } from '@forgeax/engine-ecs/internal';\nimport { AssetGuid } from '@forgeax/engine-pack/guid';\nimport { externalizeSceneAsset } from '@forgeax/engine-scene';\nimport type {\n AnimationGraph,\n Asset,\n AssetGuid as AssetGuidType,\n AssetRef,\n AudioClipAsset,\n EquirectAsset,\n FontAsset,\n ImportedArtifactBody,\n MaterialAsset,\n MaterialTextureReference,\n MaterialTextureValue,\n MeshAsset,\n ParticleEffectAsset,\n RenderPipelineAsset,\n Result,\n SamplerAsset,\n SceneAsset,\n SkeletonAsset,\n SkinAsset,\n TextureAsset,\n TilesetAsset,\n VideoAsset,\n} from '@forgeax/engine-types';\nimport { err, ImportError, MATERIAL_TEXTURE_SLOTS, ok } from '@forgeax/engine-types';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\nimport { packMeshBinV4 } from './mesh-bin.js';\nimport {\n type AssetOutputInput,\n type AssetOutputProducer,\n AssetOutputProducerRegistry,\n type AssetOutputProduct,\n} from './scriptable-pack.js';\n\nfunction producerError(input: AssetOutputInput, reason: unknown): ImportError {\n return new ImportError({\n code: 'import-internal-error',\n expected: `ScriptablePack ${input.asset.kind} output ${input.sourceKey} to satisfy its domain producer contract`,\n hint: 'fix the generated Asset payload and rebuild the ScriptablePack',\n detail: { reason: reason instanceof Error ? reason.message : String(reason) },\n });\n}\n\nfunction formatGuid(value: AssetGuidType | string): string {\n if (typeof value === 'string') {\n const parsed = AssetGuid.parse(value);\n if (!parsed.ok) throw parsed.error;\n return AssetGuid.format(parsed.value);\n }\n return AssetGuid.format(value);\n}\n\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n return `{${Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => `${JSON.stringify(key)}:${canonical(child)}`)\n .join(',')}}`;\n }\n return JSON.stringify(value) ?? 'null';\n}\n\nfunction particleProgramArtifact(effect: ParticleEffectAsset): {\n readonly program: ParticleEffectAsset['program'];\n readonly bytes: Uint8Array;\n readonly fingerprint: string;\n} {\n const artifactProgram = { format: effect.program.format, emitters: effect.program.emitters };\n const bytes = new TextEncoder().encode(canonical(artifactProgram));\n const fingerprint = `sha256:${bytesToHex(sha256(bytes))}`;\n return {\n program: { ...effect.program, fingerprint },\n bytes,\n fingerprint,\n };\n}\n\nfunction materialProduct(input: AssetOutputInput): AssetOutputProduct {\n if (input.asset.kind !== 'material') throw new TypeError('expected MaterialAsset');\n const material = input.asset as MaterialAsset;\n const refs: AssetRef[] = [];\n const addRef = (\n guid: AssetGuidType | string,\n sourceField: NonNullable<AssetRef['sourceField']>,\n ): number => {\n refs.push({ guid: formatGuid(guid), sourceField });\n return refs.length - 1;\n };\n\n const addMaterialRef = (\n value: MaterialTextureReference,\n sourceField: NonNullable<AssetRef['sourceField']>,\n ): number => {\n if (typeof value === 'number') {\n throw new TypeError('material texture references must be GUIDs, not runtime handles');\n }\n return addRef(value, sourceField);\n };\n\n const textureFields =\n material.parameters === undefined\n ? new Set<string>(MATERIAL_TEXTURE_SLOTS)\n : new Set(\n material.parameters\n .filter((parameter) => parameter.type === 'texture')\n .map((parameter) => parameter.name),\n );\n\n const parent =\n material.parent === undefined ? undefined : addRef(material.parent, { fieldName: 'parent' });\n const values: Record<string, unknown> = {};\n for (const fieldName of Object.keys(material.values ?? {}).sort()) {\n const value = material.values?.[fieldName];\n if (typeof value === 'string' && textureFields.has(fieldName)) {\n values[fieldName] = addMaterialRef(value, { componentName: '<material>', fieldName });\n } else if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n 'texture' in value\n ) {\n const texture = value as MaterialTextureValue;\n values[fieldName] = {\n ...texture,\n texture: addMaterialRef(texture.texture, { componentName: '<material>', fieldName }),\n ...(texture.sampler === undefined\n ? {}\n : {\n sampler: addMaterialRef(texture.sampler, {\n componentName: '<material>',\n fieldName: `${fieldName}.sampler`,\n }),\n }),\n };\n } else {\n values[fieldName] = value;\n }\n }\n\n const { parent: _parent, values: _values, ...materialShape } = material;\n return {\n payload: {\n ...materialShape,\n ...(parent === undefined ? {} : { parent }),\n ...(material.values === undefined ? {} : { values }),\n },\n refs,\n artifacts: {},\n };\n}\n\nexport const materialAssetOutputProducer: AssetOutputProducer = {\n kind: 'material',\n version: 'material-pack/1',\n produce(input): Result<AssetOutputProduct, ImportError> {\n try {\n return ok(materialProduct(input));\n } catch (error) {\n return err(producerError(input, error));\n }\n },\n};\n\nfunction meshProduct(input: AssetOutputInput): AssetOutputProduct {\n if (input.asset.kind !== 'mesh') throw new TypeError('expected MeshAsset');\n const mesh = input.asset as MeshAsset;\n const refs: AssetRef[] = [];\n for (let slotIndex = 0; slotIndex < mesh.materialSlots.length; slotIndex++) {\n const defaultMaterial = mesh.materialSlots[slotIndex]?.defaultMaterial;\n if (defaultMaterial === undefined) continue;\n refs.push({\n guid: formatGuid(defaultMaterial),\n sourceField: { fieldName: 'materialSlots', arrayIndex: slotIndex },\n });\n }\n return {\n payload: mesh,\n refs,\n artifacts: {\n body: {\n mediaType: 'application/x-forgeax-mesh',\n assetCodec: { name: 'mesh-binary', version: '4' },\n bytes: (() => {\n const packed = packMeshBinV4(\n mesh,\n input.sourceKey,\n refs.map((reference) => reference.guid),\n );\n if (!packed.ok) {\n throw packed.error;\n }\n return packed.value;\n })(),\n },\n },\n };\n}\n\nexport const meshAssetOutputProducer: AssetOutputProducer = {\n kind: 'mesh',\n version: 'mesh-binary/4',\n produce(input): Result<AssetOutputProduct, ImportError> {\n try {\n return ok(meshProduct(input));\n } catch (error) {\n return err(producerError(input, error));\n }\n },\n};\n\nfunction sceneProduct(input: AssetOutputInput): AssetOutputProduct {\n if (input.asset.kind !== 'scene') throw new TypeError('expected SceneAsset');\n const externalized = externalizeSceneAsset(input.asset as SceneAsset, (componentName) => {\n const component = input.components?.get(componentName);\n return component === undefined ? undefined : componentSchema(component);\n });\n if (!externalized.ok) throw new TypeError(`scene field ${externalized.error.field} is invalid`);\n return {\n payload: { kind: 'scene', ...externalized.value.payload },\n refs: externalized.value.refs,\n artifacts: {},\n };\n}\n\nfunction jsonArtifact(value: unknown): ImportedArtifactBody {\n return {\n mediaType: 'application/json',\n assetCodec: { name: 'forgeax-json', version: '1' },\n bytes: new TextEncoder().encode(JSON.stringify(value)),\n };\n}\n\nfunction ref(guid: AssetGuidType, fieldName: string, arrayIndex?: number): AssetRef {\n return {\n guid: formatGuid(guid),\n sourceField: { fieldName, ...(arrayIndex === undefined ? {} : { arrayIndex }) },\n };\n}\n\nfunction bytes(value: Uint8Array | Uint8ClampedArray): Uint8Array {\n return Uint8Array.from(value);\n}\n\nfunction ordinaryPodProduct(input: AssetOutputInput): AssetOutputProduct {\n const asset = input.asset;\n switch (asset.kind) {\n case 'texture': {\n const texture = asset as TextureAsset;\n return {\n payload: texture,\n refs: [],\n artifacts: {\n body: {\n mediaType: 'image/raw',\n assetCodec: { name: 'raw-image', version: '1' },\n bytes: bytes(texture.data),\n },\n },\n };\n }\n case 'equirect': {\n const equirect = asset as EquirectAsset;\n return {\n payload: equirect,\n refs: [],\n artifacts: {\n body: {\n mediaType: 'image/raw',\n assetCodec: { name: 'raw-image', version: '1' },\n bytes: bytes(equirect.data),\n },\n },\n };\n }\n case 'sampler': {\n const sampler = asset as SamplerAsset;\n return { payload: sampler, refs: [], artifacts: { body: jsonArtifact(sampler) } };\n }\n case 'font': {\n const font = asset as FontAsset;\n const atlas = ref(font.atlas, 'atlas');\n const sampler = ref(font.sampler, 'sampler');\n return {\n payload: {\n kind: font.kind,\n glyphs: font.glyphs,\n common: font.common,\n atlasGuid: atlas.guid,\n samplerGuid: sampler.guid,\n },\n refs: [atlas, sampler],\n artifacts: { body: jsonArtifact(font) },\n };\n }\n case 'render-pipeline': {\n const pipeline = asset as RenderPipelineAsset;\n return {\n payload: pipeline,\n refs: [],\n artifacts: { body: jsonArtifact(pipeline) },\n };\n }\n case 'tileset': {\n const tileset = asset as TilesetAsset;\n const refs = tileset.atlases.map((atlas, index) => {\n const parsed = AssetGuid.parse(atlas);\n if (!parsed.ok) throw parsed.error;\n return ref(parsed.value, 'atlases', index);\n });\n return {\n payload: { ...tileset, atlases: refs.map((_entry, index) => index) },\n refs,\n artifacts: { body: jsonArtifact(tileset) },\n };\n }\n case 'video': {\n const video = asset as VideoAsset;\n try {\n const url = new URL(video.url);\n if (url.protocol !== 'http:' && url.protocol !== 'https:')\n throw new Error('unsupported URL scheme');\n } catch (error) {\n throw new TypeError(\n `video URL is invalid: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n return { payload: video, refs: [], artifacts: {} };\n }\n case 'skeleton': {\n const skeleton = asset as SkeletonAsset;\n return {\n payload: skeleton,\n refs: [],\n artifacts: { body: jsonArtifact(skeleton) },\n };\n }\n case 'skin': {\n const skin = asset as SkinAsset;\n const skeletonGuid = AssetGuid.parse(skin.skeletonGuid);\n if (!skeletonGuid.ok) throw skeletonGuid.error;\n return {\n payload: skin,\n refs: [ref(skeletonGuid.value, 'skeletonGuid')],\n artifacts: { body: jsonArtifact(skin) },\n };\n }\n case 'animation-clip':\n return {\n payload: asset,\n refs: [],\n artifacts: { body: jsonArtifact(asset) },\n };\n case 'animation-graph': {\n const graph = asset as AnimationGraph;\n const refs: AssetRef[] = [];\n const nodes = graph.nodes.map((node, index) => {\n if (node.type !== 'clip') return node;\n const parsed = AssetGuid.parse(node.clip);\n if (!parsed.ok) throw parsed.error;\n const referenceIndex = refs.push(ref(parsed.value, 'nodes', index)) - 1;\n return { ...node, clip: referenceIndex };\n });\n return {\n payload: { kind: graph.kind, root: graph.root, nodes },\n refs,\n artifacts: { body: jsonArtifact(graph) },\n };\n }\n case 'audio': {\n const audio = asset as AudioClipAsset;\n return {\n payload: {\n kind: audio.kind,\n sourceKey: audio.sourceKey,\n mediaType: audio.mediaType,\n bytes: audio.bytes.slice(),\n },\n refs: [],\n artifacts: {\n source: {\n mediaType: audio.mediaType,\n assetCodec: { name: 'browser-audio', version: '1' },\n bytes: audio.bytes.slice(),\n },\n },\n };\n }\n case 'particle-effect': {\n const effect = asset as ParticleEffectAsset;\n const cooked = particleProgramArtifact(effect);\n return {\n payload: { ...effect, programFingerprint: cooked.fingerprint, program: cooked.program },\n refs: [],\n artifacts: {\n 'particle-effect/program.json': {\n mediaType: 'application/json',\n assetCodec: { name: 'forgeax-vfx-program', version: effect.program.format },\n bytes: cooked.bytes,\n },\n },\n };\n }\n case 'material':\n case 'mesh':\n case 'scene':\n throw new TypeError(`ordinary producer received already-owned ${asset.kind} asset`);\n }\n}\n\nconst ordinaryAssetOutputProducer: AssetOutputProducer = {\n kind: 'texture',\n version: 'ordinary-pod/1',\n produce(input) {\n try {\n return ok(ordinaryPodProduct(input));\n } catch (error) {\n return err(producerError(input, error));\n }\n },\n};\n\nfunction createOrdinaryAssetOutputProducer(kind: Asset['kind']): AssetOutputProducer {\n return { ...ordinaryAssetOutputProducer, kind };\n}\n\nexport const sceneAssetOutputProducer: AssetOutputProducer = {\n kind: 'scene',\n version: 'scene-pack/2',\n produce(input): Result<AssetOutputProduct, ImportError> {\n try {\n return ok(sceneProduct(input));\n } catch (error) {\n return err(producerError(input, error));\n }\n },\n};\n\nexport function createStandardAssetOutputProducerRegistry(): AssetOutputProducerRegistry {\n const registry = new AssetOutputProducerRegistry();\n registry.register(materialAssetOutputProducer);\n registry.register(meshAssetOutputProducer);\n registry.register(sceneAssetOutputProducer);\n for (const kind of [\n 'texture',\n 'equirect',\n 'sampler',\n 'font',\n 'render-pipeline',\n 'tileset',\n 'video',\n 'skeleton',\n 'skin',\n 'animation-clip',\n 'animation-graph',\n 'audio',\n 'particle-effect',\n ] as const) {\n registry.register(createOrdinaryAssetOutputProducer(kind));\n }\n return registry;\n}\n","import { AssetGuid } from '@forgeax/engine-pack/guid';\nimport type { ScriptablePackError } from '@forgeax/engine-pack/source';\nimport type { Asset, AssetGuid as AssetGuidType, ImportError, Result } from '@forgeax/engine-types';\nimport { AssetError, err, ok } from '@forgeax/engine-types';\nimport type {\n ScriptablePackAssetSnapshot,\n ScriptablePackAssetSnapshotSource,\n ScriptablePackDomainError,\n ScriptablePackStagedOutput,\n} from './scriptable-pack.js';\n\nexport type ScriptablePackSnapshotError =\n | AssetError\n | ImportError\n | ScriptablePackError\n | ScriptablePackDomainError;\n\nexport interface ScriptablePackStagedOwner {\n readonly id: string;\n readonly guids: readonly AssetGuidType[];\n build(\n source: ScriptablePackAssetSnapshotSource,\n ): Promise<Result<readonly ScriptablePackStagedOutput[], ScriptablePackSnapshotError>>;\n}\n\nexport interface ScriptablePackStagedSnapshotOptions {\n readonly generation: number;\n readonly owners: readonly ScriptablePackStagedOwner[];\n /** A prebuilt authority only. Local source ownership always wins. */\n readonly fallback?: ScriptablePackAssetSnapshotSource;\n}\n\nfunction stable(value: unknown): string {\n if (ArrayBuffer.isView(value)) {\n return `${value.constructor.name}:${JSON.stringify(Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)))}`;\n }\n if (Array.isArray(value)) return `[${value.map(stable).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${stable(record[key])}`)\n .join(',')}}`;\n }\n return JSON.stringify(value) ?? 'null';\n}\n\nasync function assetDigest(asset: Asset): Promise<string> {\n const bytes = new TextEncoder().encode(stable(asset));\n const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);\n return `sha256:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('')}`;\n}\n\nfunction cycleError(stack: readonly string[], owner: string, guid: string): ScriptablePackError {\n const cycleStart = stack.indexOf(owner);\n const cycle = [...stack.slice(cycleStart), owner];\n return {\n code: 'pack-source-build-cycle',\n expected: 'an acyclic graph of ScriptablePack content dependencies',\n actual: cycle.join(' -> '),\n hint: 'break one content read edge or convert it to a reference-only dependency',\n retryable: false,\n recoveryActions: ['inspect-content-dependency-graph', 'edit-source'],\n detail: { sourcePath: owner, sourceKey: guid, incomingRefs: cycle },\n };\n}\n\nfunction missingOutputError(owner: string, guid: string): ScriptablePackError {\n return {\n code: 'pack-source-output-invalid',\n expected: `owner ${owner} to stage every declared output including ${guid}`,\n hint: 'return one output for every GUID declared by the staged owner',\n detail: { missingGuids: [guid], unexpectedSourceKeys: [], kindMismatches: [] },\n };\n}\n\n/**\n * One-build authority for current-generation ScriptablePack content reads.\n * Local owners are built lazily, memoized, and never resolved through an old Catalog/DDC generation.\n */\nexport function createScriptablePackStagedAssetSnapshotSource(\n options: ScriptablePackStagedSnapshotOptions,\n): ScriptablePackAssetSnapshotSource {\n const ownerByGuid = new Map<string, ScriptablePackStagedOwner>();\n for (const owner of options.owners) {\n if (owner.id.trim().length === 0) throw new TypeError('staged owner id must be non-empty');\n for (const guid of owner.guids) {\n const key = AssetGuid.format(guid).toLowerCase();\n const existing = ownerByGuid.get(key);\n if (existing !== undefined) {\n throw new TypeError(`staged GUID ${key} is owned by both ${existing.id} and ${owner.id}`);\n }\n ownerByGuid.set(key, owner);\n }\n }\n\n const snapshots = new Map<string, ScriptablePackAssetSnapshot>();\n const builds = new Map<string, Promise<Result<void, ScriptablePackSnapshotError>>>();\n\n const sourceFor = (stack: readonly string[]): ScriptablePackAssetSnapshotSource => ({\n async readByGuid(guid) {\n const key = AssetGuid.format(guid).toLowerCase();\n const cached = snapshots.get(key);\n if (cached !== undefined) return ok(structuredClone(cached));\n const owner = ownerByGuid.get(key);\n if (owner === undefined) {\n if (options.fallback !== undefined) return options.fallback.readByGuid(guid);\n return err(\n new AssetError({\n code: 'asset-not-imported',\n expected: 'a staged local owner or explicit prebuilt fallback for the requested GUID',\n hint: 'declare the local ScriptablePack output or configure a prebuilt asset authority',\n }),\n );\n }\n if (stack.includes(owner.id)) return err(cycleError(stack, owner.id, key));\n\n let building = builds.get(owner.id);\n if (building === undefined) {\n building = (async () => {\n const built = await owner.build(sourceFor([...stack, owner.id]));\n if (!built.ok) {\n builds.delete(owner.id);\n return built;\n }\n const next = new Map<string, ScriptablePackAssetSnapshot>();\n for (const output of built.value) {\n const outputGuid = AssetGuid.format(output.guid).toLowerCase();\n if (ownerByGuid.get(outputGuid) !== owner) {\n builds.delete(owner.id);\n return err(missingOutputError(owner.id, outputGuid));\n }\n next.set(outputGuid, {\n asset: structuredClone(output.asset),\n generation: options.generation,\n digest: output.digest ?? (await assetDigest(output.asset)),\n });\n }\n for (const declared of owner.guids) {\n const declaredGuid = AssetGuid.format(declared).toLowerCase();\n if (!next.has(declaredGuid)) {\n builds.delete(owner.id);\n return err(missingOutputError(owner.id, declaredGuid));\n }\n }\n for (const [outputGuid, snapshot] of next) snapshots.set(outputGuid, snapshot);\n return ok(undefined);\n })();\n builds.set(owner.id, building);\n }\n const built = await building;\n if (!built.ok) return built;\n const staged = snapshots.get(key);\n return staged === undefined\n ? err(missingOutputError(owner.id, key))\n : ok(structuredClone(staged));\n },\n });\n\n return sourceFor([]);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MeshBinContractError } from '@forgeax/engine-pack';
|
|
2
|
+
import { type MeshAsset, type Result } from '@forgeax/engine-types';
|
|
3
|
+
type MeshPayloadIn = {
|
|
4
|
+
readonly [Key in keyof MeshAsset]?: MeshAsset[Key] | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
readonly vertexCount?: number;
|
|
7
|
+
};
|
|
8
|
+
export type MeshBinEncodeError = MeshBinContractError | {
|
|
9
|
+
readonly code: 'mesh-bin-payload-invalid';
|
|
10
|
+
readonly subject: 'mesh-bin';
|
|
11
|
+
readonly sourceKey: string;
|
|
12
|
+
readonly expected: string;
|
|
13
|
+
readonly actual: string;
|
|
14
|
+
readonly recovery: string;
|
|
15
|
+
};
|
|
16
|
+
/** Encode one canonical v4 mesh binary. No legacy version is accepted or emitted. */
|
|
17
|
+
export declare function packMeshBinV4(payload: MeshPayloadIn, sourceKey: string, refs?: readonly string[]): Result<Uint8Array, MeshBinEncodeError>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=mesh-bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-bin.d.ts","sourceRoot":"","sources":["../src/mesh-bin.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,MAAM,EAEZ,MAAM,uBAAuB,CAAC;AAE/B,KAAK,aAAa,GAAG;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS;CAAE,GAAG;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,oBAAoB,GACpB;IACE,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAiEN,qFAAqF;AACrF,wBAAgB,aAAa,CAC3B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,SAAS,MAAM,EAAO,GAC3B,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAiIxC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AssetOutputProducer, AssetOutputProducerRegistry } from './scriptable-pack.js';
|
|
2
|
+
export declare const materialAssetOutputProducer: AssetOutputProducer;
|
|
3
|
+
export declare const meshAssetOutputProducer: AssetOutputProducer;
|
|
4
|
+
export declare const sceneAssetOutputProducer: AssetOutputProducer;
|
|
5
|
+
export declare function createStandardAssetOutputProducerRegistry(): AssetOutputProducerRegistry;
|
|
6
|
+
//# sourceMappingURL=scriptable-pack-output-producers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptable-pack-output-producers.d.ts","sourceRoot":"","sources":["../src/scriptable-pack-output-producers.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,KAAK,mBAAmB,EACxB,2BAA2B,EAE5B,MAAM,sBAAsB,CAAC;AAwH9B,eAAO,MAAM,2BAA2B,EAAE,mBAUzC,CAAC;AAqCF,eAAO,MAAM,uBAAuB,EAAE,mBAUrC,CAAC;AAyNF,eAAO,MAAM,wBAAwB,EAAE,mBAUtC,CAAC;AAEF,wBAAgB,yCAAyC,IAAI,2BAA2B,CAuBvF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ScriptablePackError } from '@forgeax/engine-pack/source';
|
|
2
|
+
import type { AssetGuid as AssetGuidType, ImportError, Result } from '@forgeax/engine-types';
|
|
3
|
+
import { AssetError } from '@forgeax/engine-types';
|
|
4
|
+
import type { ScriptablePackAssetSnapshotSource, ScriptablePackDomainError, ScriptablePackStagedOutput } from './scriptable-pack.js';
|
|
5
|
+
export type ScriptablePackSnapshotError = AssetError | ImportError | ScriptablePackError | ScriptablePackDomainError;
|
|
6
|
+
export interface ScriptablePackStagedOwner {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly guids: readonly AssetGuidType[];
|
|
9
|
+
build(source: ScriptablePackAssetSnapshotSource): Promise<Result<readonly ScriptablePackStagedOutput[], ScriptablePackSnapshotError>>;
|
|
10
|
+
}
|
|
11
|
+
export interface ScriptablePackStagedSnapshotOptions {
|
|
12
|
+
readonly generation: number;
|
|
13
|
+
readonly owners: readonly ScriptablePackStagedOwner[];
|
|
14
|
+
/** A prebuilt authority only. Local source ownership always wins. */
|
|
15
|
+
readonly fallback?: ScriptablePackAssetSnapshotSource;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One-build authority for current-generation ScriptablePack content reads.
|
|
19
|
+
* Local owners are built lazily, memoized, and never resolved through an old Catalog/DDC generation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createScriptablePackStagedAssetSnapshotSource(options: ScriptablePackStagedSnapshotOptions): ScriptablePackAssetSnapshotSource;
|
|
22
|
+
//# sourceMappingURL=scriptable-pack-staged-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptable-pack-staged-snapshot.d.ts","sourceRoot":"","sources":["../src/scriptable-pack-staged-snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAS,SAAS,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,UAAU,EAAW,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAEV,iCAAiC,EACjC,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,2BAA2B,GACnC,UAAU,GACV,WAAW,GACX,mBAAmB,GACnB,yBAAyB,CAAC;AAE9B,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,KAAK,CACH,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,MAAM,CAAC,SAAS,0BAA0B,EAAE,EAAE,2BAA2B,CAAC,CAAC,CAAC;CACxF;AAED,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACtD,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,iCAAiC,CAAC;CACvD;AA8CD;;;GAGG;AACH,wBAAgB,6CAA6C,CAC3D,OAAO,EAAE,mCAAmC,GAC3C,iCAAiC,CA8EnC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { Component } from '@forgeax/engine-ecs';
|
|
2
|
+
import { type ScriptablePackAssetKind } from '@forgeax/engine-pack';
|
|
3
|
+
import { type ScriptablePackDefinition, type ScriptablePackError, type ScriptablePackReadError } from '@forgeax/engine-pack/source';
|
|
4
|
+
import type { AnimationGraph, Asset, AssetGuid as AssetGuidType, AssetPublicationEnvelope, AssetRef, FontAsset, ImportedArtifactBody, ImportProduct, MaterialAsset, MeshAsset, Result, TilesetAsset } from '@forgeax/engine-types';
|
|
5
|
+
import { AssetError, ImportError } from '@forgeax/engine-types';
|
|
6
|
+
export interface ScriptablePackAssetSnapshot {
|
|
7
|
+
readonly asset: Asset;
|
|
8
|
+
readonly generation: number;
|
|
9
|
+
readonly digest: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ScriptablePackStagedOutput {
|
|
12
|
+
readonly guid: AssetGuidType;
|
|
13
|
+
/** Producer-owned stable output identity from the ScriptablePack definition. */
|
|
14
|
+
readonly sourceKey?: string;
|
|
15
|
+
readonly asset: Asset;
|
|
16
|
+
readonly digest?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ScriptablePackAssetSnapshotSource {
|
|
19
|
+
readByGuid(guid: AssetGuidType): Promise<Result<ScriptablePackAssetSnapshot, ScriptablePackReadError>>;
|
|
20
|
+
}
|
|
21
|
+
export interface AssetOutputInput {
|
|
22
|
+
readonly guid: string;
|
|
23
|
+
readonly sourceKey: string;
|
|
24
|
+
readonly asset: Asset;
|
|
25
|
+
/** World-local schema projection for scene ref externalization. */
|
|
26
|
+
readonly components?: ReadonlyMap<string, Component>;
|
|
27
|
+
}
|
|
28
|
+
type MaterialPackPayload = Omit<MaterialAsset, 'parent' | 'values'> & {
|
|
29
|
+
readonly parent?: number;
|
|
30
|
+
readonly values?: Readonly<Record<string, unknown>>;
|
|
31
|
+
};
|
|
32
|
+
type ScenePackPayload = {
|
|
33
|
+
readonly kind: 'scene';
|
|
34
|
+
readonly [key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
type FontPackPayload = Omit<FontAsset, 'atlas' | 'sampler'> & {
|
|
37
|
+
readonly atlasGuid: string;
|
|
38
|
+
readonly samplerGuid: string;
|
|
39
|
+
};
|
|
40
|
+
type TilesetPackPayload = Omit<TilesetAsset, 'atlases'> & {
|
|
41
|
+
readonly atlases: readonly number[];
|
|
42
|
+
};
|
|
43
|
+
type AnimationGraphPackPayload = Omit<AnimationGraph, 'nodes'> & {
|
|
44
|
+
readonly nodes: readonly (Exclude<AnimationGraph['nodes'][number], {
|
|
45
|
+
readonly type: 'clip';
|
|
46
|
+
}> | (Omit<Extract<AnimationGraph['nodes'][number], {
|
|
47
|
+
readonly type: 'clip';
|
|
48
|
+
}>, 'clip'> & {
|
|
49
|
+
readonly clip: number;
|
|
50
|
+
}))[];
|
|
51
|
+
};
|
|
52
|
+
/** Serialized Pack projection; durable runtime Assets never carry ref indices. */
|
|
53
|
+
export type AssetOutputPayloadByKind = {
|
|
54
|
+
readonly mesh: MeshAsset;
|
|
55
|
+
readonly material: MaterialPackPayload;
|
|
56
|
+
readonly scene: ScenePackPayload;
|
|
57
|
+
readonly texture: Extract<Asset, {
|
|
58
|
+
readonly kind: 'texture';
|
|
59
|
+
}>;
|
|
60
|
+
readonly equirect: Extract<Asset, {
|
|
61
|
+
readonly kind: 'equirect';
|
|
62
|
+
}>;
|
|
63
|
+
readonly sampler: Extract<Asset, {
|
|
64
|
+
readonly kind: 'sampler';
|
|
65
|
+
}>;
|
|
66
|
+
readonly font: FontPackPayload;
|
|
67
|
+
readonly 'render-pipeline': Extract<Asset, {
|
|
68
|
+
readonly kind: 'render-pipeline';
|
|
69
|
+
}>;
|
|
70
|
+
readonly tileset: TilesetPackPayload;
|
|
71
|
+
readonly video: Extract<Asset, {
|
|
72
|
+
readonly kind: 'video';
|
|
73
|
+
}>;
|
|
74
|
+
readonly skeleton: Extract<Asset, {
|
|
75
|
+
readonly kind: 'skeleton';
|
|
76
|
+
}>;
|
|
77
|
+
readonly skin: Extract<Asset, {
|
|
78
|
+
readonly kind: 'skin';
|
|
79
|
+
}>;
|
|
80
|
+
readonly 'animation-clip': Extract<Asset, {
|
|
81
|
+
readonly kind: 'animation-clip';
|
|
82
|
+
}>;
|
|
83
|
+
readonly 'animation-graph': AnimationGraphPackPayload;
|
|
84
|
+
readonly audio: Extract<Asset, {
|
|
85
|
+
readonly kind: 'audio';
|
|
86
|
+
}>;
|
|
87
|
+
readonly 'particle-effect': Extract<Asset, {
|
|
88
|
+
readonly kind: 'particle-effect';
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
export type AssetOutputPayload = AssetOutputPayloadByKind[ScriptablePackAssetKind];
|
|
92
|
+
export interface AssetOutputProduct {
|
|
93
|
+
readonly payload: AssetOutputPayload;
|
|
94
|
+
readonly refs: readonly AssetRef[];
|
|
95
|
+
readonly artifacts: Readonly<Record<string, ImportedArtifactBody>>;
|
|
96
|
+
}
|
|
97
|
+
export interface AssetOutputProducer {
|
|
98
|
+
readonly kind: string;
|
|
99
|
+
readonly version: string;
|
|
100
|
+
produce(input: AssetOutputInput): Result<AssetOutputProduct, ImportError> | Promise<Result<AssetOutputProduct, ImportError>>;
|
|
101
|
+
}
|
|
102
|
+
export declare class AssetOutputProducerRegistry {
|
|
103
|
+
private readonly producers;
|
|
104
|
+
register(producer: AssetOutputProducer): void;
|
|
105
|
+
get(kind: string): AssetOutputProducer | undefined;
|
|
106
|
+
versions(): Readonly<Record<string, string>>;
|
|
107
|
+
}
|
|
108
|
+
export type ScriptablePackExternalUsage = 'reference' | 'content' | 'both';
|
|
109
|
+
export interface ScriptablePackExternalEvidence {
|
|
110
|
+
readonly guid: string;
|
|
111
|
+
readonly usage: ScriptablePackExternalUsage;
|
|
112
|
+
readonly generation?: number;
|
|
113
|
+
readonly digest?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface ScriptablePackSourceClosureEntry {
|
|
116
|
+
readonly path: string;
|
|
117
|
+
readonly digest: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ScriptablePackBuildProduct {
|
|
120
|
+
readonly product: ImportProduct<unknown>;
|
|
121
|
+
/** Raw private outputs for the current staged build generation, never a runtime publication path. */
|
|
122
|
+
readonly stagedOutputs: readonly ScriptablePackStagedOutput[];
|
|
123
|
+
readonly externalEvidence: readonly ScriptablePackExternalEvidence[];
|
|
124
|
+
readonly inputFingerprint: string;
|
|
125
|
+
/** Engine publication fields projected after ordinary producers run. */
|
|
126
|
+
readonly publication?: AssetPublicationEnvelope;
|
|
127
|
+
}
|
|
128
|
+
/** Domain-owned structured failure transported without flattening its recovery fields. */
|
|
129
|
+
export interface ScriptablePackDomainError {
|
|
130
|
+
readonly code: string;
|
|
131
|
+
readonly expected: string;
|
|
132
|
+
readonly hint: string;
|
|
133
|
+
readonly detail?: unknown;
|
|
134
|
+
}
|
|
135
|
+
export type ScriptablePackBuildBridgeResult = Result<ScriptablePackBuildProduct, ScriptablePackError | AssetError | ImportError | ScriptablePackDomainError>;
|
|
136
|
+
export interface BuildScriptablePackOptions {
|
|
137
|
+
readonly definition: ScriptablePackDefinition;
|
|
138
|
+
readonly sourcePath: string;
|
|
139
|
+
readonly assetSource?: ScriptablePackAssetSnapshotSource;
|
|
140
|
+
readonly outputs: AssetOutputProducerRegistry;
|
|
141
|
+
readonly sourceClosure: readonly ScriptablePackSourceClosureEntry[];
|
|
142
|
+
readonly authoringContractVersion: string;
|
|
143
|
+
/** Optional owner-provided component schema projection for scene output. */
|
|
144
|
+
readonly components?: ReadonlyMap<string, Component>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build one external ScriptablePack through the producer-owned Pack bridge.
|
|
148
|
+
* Success preserves payloads, GUID refs, and local artifacts; failure retains
|
|
149
|
+
* `code`, `expected`, `hint`, and `detail` for recovery by the caller.
|
|
150
|
+
*/
|
|
151
|
+
export declare function buildScriptablePack(options: BuildScriptablePackOptions): Promise<ScriptablePackBuildBridgeResult>;
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=scriptable-pack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptable-pack.d.ts","sourceRoot":"","sources":["../src/scriptable-pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,IAAI,aAAa,EAC1B,wBAAwB,EACxB,QAAQ,EACR,SAAS,EACT,oBAAoB,EAEpB,aAAa,EACb,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAO,WAAW,EAAM,MAAM,uBAAuB,CAAC;AAoCzE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW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