@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
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1607 @@
|
|
|
1
|
+
import { ok, validateSourceOverrideMap, ImportError, IMPORT_ERROR_HINTS, canonicalizeSourceOverrides, err, AssetError, MATERIAL_TEXTURE_SLOTS } from '@forgeax/engine-types';
|
|
2
|
+
export { IMPORT_ERROR_HINTS, ImportError } from '@forgeax/engine-types';
|
|
3
|
+
import { deriveVertexLayoutProjection } from '@forgeax/engine-geometry';
|
|
4
|
+
import { MESH_BIN_HEADER_V4_BYTES, writeMeshBinHeader, isScriptablePackAssetKind } from '@forgeax/engine-pack';
|
|
5
|
+
import { AssetGuid } from '@forgeax/engine-pack/guid';
|
|
6
|
+
import { projectScriptablePackMeta } from '@forgeax/engine-pack/source';
|
|
7
|
+
import { componentSchema } from '@forgeax/engine-ecs/internal';
|
|
8
|
+
import { externalizeSceneAsset } from '@forgeax/engine-scene';
|
|
9
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
10
|
+
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
11
|
+
|
|
12
|
+
// src/index.ts
|
|
13
|
+
function invalid(field) {
|
|
14
|
+
return err({
|
|
15
|
+
code: "material-import-product-invalid",
|
|
16
|
+
expected: "an authored MaterialAsset with complete dependency references",
|
|
17
|
+
hint: "declare every material dependency before the product enters the cook pipeline",
|
|
18
|
+
detail: { field }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function distinct(values) {
|
|
22
|
+
return [...new Set(values)];
|
|
23
|
+
}
|
|
24
|
+
function createMaterialImportProduct(input) {
|
|
25
|
+
if (!input.guid || !input.sourcePath) return invalid("guid/sourcePath");
|
|
26
|
+
if (input.material.kind !== "material") return invalid("material.kind");
|
|
27
|
+
if (!input.sourceEvidence.inputFingerprint || !input.sourceEvidence.importerVersion) {
|
|
28
|
+
return invalid("sourceEvidence");
|
|
29
|
+
}
|
|
30
|
+
const refs = distinct([
|
|
31
|
+
...input.refs.parent,
|
|
32
|
+
...input.refs.textures,
|
|
33
|
+
...input.refs.samplers,
|
|
34
|
+
...input.refs.modules
|
|
35
|
+
]);
|
|
36
|
+
return ok({
|
|
37
|
+
sourcePath: input.sourcePath,
|
|
38
|
+
sourceEvidence: input.sourceEvidence,
|
|
39
|
+
asset: {
|
|
40
|
+
guid: input.guid,
|
|
41
|
+
kind: "material",
|
|
42
|
+
payload: input.material,
|
|
43
|
+
refs: refs.map((guid) => ({ guid })),
|
|
44
|
+
artifacts: {}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function materialImportProductReady(product, availableRefs) {
|
|
49
|
+
return product.asset.refs.every((reference) => availableRefs.has(reference.guid));
|
|
50
|
+
}
|
|
51
|
+
async function sha256Hex(bytes2) {
|
|
52
|
+
const subtle = globalThis.crypto?.subtle;
|
|
53
|
+
if (subtle === void 0) throw new Error("Web Crypto API is required for importer digests");
|
|
54
|
+
const owned = new Uint8Array(bytes2.byteLength);
|
|
55
|
+
owned.set(bytes2);
|
|
56
|
+
const digest = await subtle.digest("SHA-256", owned.buffer);
|
|
57
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
58
|
+
}
|
|
59
|
+
async function artifactDigest(bytes2) {
|
|
60
|
+
return `sha256:${await sha256Hex(bytes2)}`;
|
|
61
|
+
}
|
|
62
|
+
function concatBytes(chunks) {
|
|
63
|
+
const encoder = new TextEncoder();
|
|
64
|
+
const encoded = chunks.map(
|
|
65
|
+
(chunk) => typeof chunk === "string" ? encoder.encode(chunk) : chunk
|
|
66
|
+
);
|
|
67
|
+
const totalLength = encoded.reduce((total, chunk) => total + chunk.byteLength, 0);
|
|
68
|
+
const bytes2 = new Uint8Array(totalLength);
|
|
69
|
+
let offset = 0;
|
|
70
|
+
for (const chunk of encoded) {
|
|
71
|
+
bytes2.set(chunk, offset);
|
|
72
|
+
offset += chunk.byteLength;
|
|
73
|
+
}
|
|
74
|
+
return bytes2;
|
|
75
|
+
}
|
|
76
|
+
async function productDigest(asset, artifacts) {
|
|
77
|
+
const chunks = [
|
|
78
|
+
JSON.stringify(digestPayload(asset)),
|
|
79
|
+
JSON.stringify(asset.refs.map((ref2) => ref2.guid)),
|
|
80
|
+
JSON.stringify(artifacts)
|
|
81
|
+
];
|
|
82
|
+
for (const [key, artifact] of Object.entries(asset.artifacts).sort(
|
|
83
|
+
([left], [right]) => left.localeCompare(right)
|
|
84
|
+
)) {
|
|
85
|
+
chunks.push(key, artifact.bytes);
|
|
86
|
+
}
|
|
87
|
+
return `sha256:${await sha256Hex(concatBytes(chunks))}`;
|
|
88
|
+
}
|
|
89
|
+
async function artifactDescriptors(artifacts) {
|
|
90
|
+
const entries = [];
|
|
91
|
+
for (const [path, artifact] of Object.entries(artifacts)) {
|
|
92
|
+
entries.push([
|
|
93
|
+
path,
|
|
94
|
+
{
|
|
95
|
+
path,
|
|
96
|
+
mediaType: artifact.mediaType,
|
|
97
|
+
byteLength: artifact.bytes.byteLength,
|
|
98
|
+
integrity: { algorithm: "sha256", digest: await artifactDigest(artifact.bytes) },
|
|
99
|
+
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec }
|
|
100
|
+
}
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
return Object.fromEntries(entries);
|
|
104
|
+
}
|
|
105
|
+
function digestPayload(asset) {
|
|
106
|
+
if (Object.keys(asset.artifacts).length === 0) return asset.payload;
|
|
107
|
+
if (asset.kind === "mesh") return { kind: "mesh" };
|
|
108
|
+
if (asset.kind === "texture" || asset.kind === "equirect") {
|
|
109
|
+
const payload = asset.payload;
|
|
110
|
+
const { data: _runtimeBytes, ...metadata } = payload;
|
|
111
|
+
return metadata;
|
|
112
|
+
}
|
|
113
|
+
return asset.payload;
|
|
114
|
+
}
|
|
115
|
+
function finalizeImportProducts(product, inputFingerprint) {
|
|
116
|
+
return (async () => {
|
|
117
|
+
const products = [];
|
|
118
|
+
for (const asset of product.assets) {
|
|
119
|
+
const artifacts = await artifactDescriptors(asset.artifacts);
|
|
120
|
+
const digest = await productDigest(asset, artifacts);
|
|
121
|
+
products.push({
|
|
122
|
+
guid: asset.guid,
|
|
123
|
+
payload: asset.payload,
|
|
124
|
+
refs: asset.refs.map((ref2) => ref2.guid),
|
|
125
|
+
artifacts,
|
|
126
|
+
digest,
|
|
127
|
+
receipt: {
|
|
128
|
+
guid: asset.guid,
|
|
129
|
+
origin: "sourceMeta",
|
|
130
|
+
status: "succeeded",
|
|
131
|
+
inputFingerprint,
|
|
132
|
+
outputDigest: digest
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return products;
|
|
137
|
+
})();
|
|
138
|
+
}
|
|
139
|
+
var SHADER_RESERVED_IMPORTER_KEY = "shader";
|
|
140
|
+
function isModuleLoadFailure(e) {
|
|
141
|
+
if (!(e instanceof Error)) return false;
|
|
142
|
+
const code = e.code;
|
|
143
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_DLOPEN_FAILED") {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const msg = e.message;
|
|
147
|
+
return msg.includes("Cannot find module") || msg.includes("native addon") || msg.includes(".node");
|
|
148
|
+
}
|
|
149
|
+
function normaliseForPack(value) {
|
|
150
|
+
if (value === null || value === void 0) return value;
|
|
151
|
+
if (value instanceof Float32Array || value instanceof Float64Array || value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array) {
|
|
152
|
+
return Array.from(value);
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(value)) {
|
|
155
|
+
return value.map(normaliseForPack);
|
|
156
|
+
}
|
|
157
|
+
if (typeof value === "object") {
|
|
158
|
+
const out = {};
|
|
159
|
+
for (const [k, v] of Object.entries(value)) {
|
|
160
|
+
out[k] = normaliseForPack(v);
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
function declarationFields(declaration) {
|
|
167
|
+
if (declaration === void 0) return {};
|
|
168
|
+
return {
|
|
169
|
+
sourceIndex: declaration.sourceIndex,
|
|
170
|
+
...declaration.sourceKey !== void 0 ? { sourceKey: declaration.sourceKey } : {},
|
|
171
|
+
...declaration.relations !== void 0 ? { relations: declaration.relations } : {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function joinSiblingPath(sourcePath, uri) {
|
|
175
|
+
const slash = Math.max(sourcePath.lastIndexOf("/"), sourcePath.lastIndexOf("\\"));
|
|
176
|
+
const dir = slash >= 0 ? sourcePath.slice(0, slash + 1) : "";
|
|
177
|
+
return `${dir}${uri}`;
|
|
178
|
+
}
|
|
179
|
+
function normalizeDependencyPath(path) {
|
|
180
|
+
const slash = path.replaceAll("\\", "/");
|
|
181
|
+
const parts = [];
|
|
182
|
+
for (const part of slash.split("/")) {
|
|
183
|
+
if (part === "" || part === ".") continue;
|
|
184
|
+
if (part === "..") {
|
|
185
|
+
parts.pop();
|
|
186
|
+
} else {
|
|
187
|
+
parts.push(part);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return parts.join("/");
|
|
191
|
+
}
|
|
192
|
+
function errResult(error) {
|
|
193
|
+
return { ok: false, error };
|
|
194
|
+
}
|
|
195
|
+
function sourceKeyActual(value) {
|
|
196
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
197
|
+
if (value === void 0) return "missing";
|
|
198
|
+
return typeof value;
|
|
199
|
+
}
|
|
200
|
+
function sourceReadFailureReason(error) {
|
|
201
|
+
if (typeof error !== "object" || error === null) {
|
|
202
|
+
return typeof error === "string" ? error : "unknown";
|
|
203
|
+
}
|
|
204
|
+
const metadata = error;
|
|
205
|
+
const token = typeof metadata.code === "string" ? metadata.code : typeof metadata.name === "string" ? metadata.name : void 0;
|
|
206
|
+
switch (token) {
|
|
207
|
+
case "ENOENT":
|
|
208
|
+
case "NotFoundError":
|
|
209
|
+
return "not-found";
|
|
210
|
+
case "EACCES":
|
|
211
|
+
case "EPERM":
|
|
212
|
+
case "PermissionDeniedError":
|
|
213
|
+
case "NotAllowedError":
|
|
214
|
+
case "SecurityError":
|
|
215
|
+
return "permission-denied";
|
|
216
|
+
case "EAGAIN":
|
|
217
|
+
case "EBUSY":
|
|
218
|
+
case "EINTR":
|
|
219
|
+
case "ECONNABORTED":
|
|
220
|
+
case "ECONNREFUSED":
|
|
221
|
+
case "ECONNRESET":
|
|
222
|
+
case "EHOSTUNREACH":
|
|
223
|
+
case "ENETDOWN":
|
|
224
|
+
case "ENETUNREACH":
|
|
225
|
+
case "ETIMEDOUT":
|
|
226
|
+
case "EPIPE":
|
|
227
|
+
case "ABORT_ERR":
|
|
228
|
+
case "AbortError":
|
|
229
|
+
case "TimeoutError":
|
|
230
|
+
return "transient";
|
|
231
|
+
default:
|
|
232
|
+
if (typeof metadata.detail === "object" && metadata.detail !== null) {
|
|
233
|
+
const reason = metadata.detail.reason;
|
|
234
|
+
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
235
|
+
}
|
|
236
|
+
if (typeof metadata.message === "string" && metadata.message.length > 0) {
|
|
237
|
+
return metadata.message;
|
|
238
|
+
}
|
|
239
|
+
return "unknown";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function validateOutputSourceKeys(meta) {
|
|
243
|
+
if (meta.subAssets.length <= 1) return void 0;
|
|
244
|
+
const diagnostics = [];
|
|
245
|
+
const seen = /* @__PURE__ */ new Map();
|
|
246
|
+
for (const [index, declaration] of meta.subAssets.entries()) {
|
|
247
|
+
const sourcePath = `${meta.source}#subAssets[${index}]`;
|
|
248
|
+
const sourceRange = { start: 0, end: 0, line: 1, column: 1 };
|
|
249
|
+
const sourceKey = declaration.sourceKey;
|
|
250
|
+
if (typeof sourceKey !== "string" || sourceKey.trim().length === 0) {
|
|
251
|
+
diagnostics.push({
|
|
252
|
+
code: "source-key-required",
|
|
253
|
+
severity: "error",
|
|
254
|
+
sourcePath,
|
|
255
|
+
sourceRange,
|
|
256
|
+
rule: "import-output-source-key",
|
|
257
|
+
expected: "a non-empty producer-owned sourceKey",
|
|
258
|
+
actual: sourceKeyActual(sourceKey),
|
|
259
|
+
hint: "publish a stable semantic sourceKey; sourceIndex is only a locator"
|
|
260
|
+
});
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const prior = seen.get(sourceKey);
|
|
264
|
+
if (prior !== void 0) {
|
|
265
|
+
diagnostics.push({
|
|
266
|
+
code: "duplicate-source-key",
|
|
267
|
+
severity: "error",
|
|
268
|
+
sourcePath,
|
|
269
|
+
sourceRange,
|
|
270
|
+
rule: "import-output-source-key-unique",
|
|
271
|
+
expected: "sourceKey to be unique within one imported package",
|
|
272
|
+
actual: `${JSON.stringify(sourceKey)} duplicates subAssets[${prior}]`,
|
|
273
|
+
hint: "rename the duplicate semantic output before writing Meta"
|
|
274
|
+
});
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
seen.set(sourceKey, index);
|
|
278
|
+
}
|
|
279
|
+
if (diagnostics.length === 0) return void 0;
|
|
280
|
+
return new ImportError({
|
|
281
|
+
code: "source-validation-failed",
|
|
282
|
+
expected: "every writable imported output to declare a unique non-empty sourceKey",
|
|
283
|
+
hint: IMPORT_ERROR_HINTS["source-validation-failed"],
|
|
284
|
+
detail: { diagnostics }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
async function runImport(meta, registry, fs) {
|
|
288
|
+
if (meta.importer === SHADER_RESERVED_IMPORTER_KEY) {
|
|
289
|
+
return { ok: true, value: { skipped: "shader" } };
|
|
290
|
+
}
|
|
291
|
+
const sourceKeyError = validateOutputSourceKeys(meta);
|
|
292
|
+
if (sourceKeyError !== void 0) return errResult(sourceKeyError);
|
|
293
|
+
const declaredSourceKeys = meta.subAssets.flatMap(
|
|
294
|
+
(subAsset) => subAsset.sourceKey === void 0 ? [] : [subAsset.sourceKey]
|
|
295
|
+
);
|
|
296
|
+
const sourceOverridesResult = validateSourceOverrideMap(meta.sourceOverrides, declaredSourceKeys);
|
|
297
|
+
if (!sourceOverridesResult.ok) {
|
|
298
|
+
const error = new ImportError({
|
|
299
|
+
code: sourceOverridesResult.error.code,
|
|
300
|
+
expected: sourceOverridesResult.error.expected,
|
|
301
|
+
hint: IMPORT_ERROR_HINTS[sourceOverridesResult.error.code],
|
|
302
|
+
detail: {
|
|
303
|
+
sourceKey: sourceOverridesResult.error.actual,
|
|
304
|
+
declaredSourceKeys,
|
|
305
|
+
reason: sourceOverridesResult.error.hint
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
if (sourceOverridesResult.error.actual !== void 0) {
|
|
309
|
+
Object.assign(error, { actual: sourceOverridesResult.error.actual });
|
|
310
|
+
}
|
|
311
|
+
return errResult(error);
|
|
312
|
+
}
|
|
313
|
+
const importer = registry.get(meta.importer);
|
|
314
|
+
if (importer === void 0) {
|
|
315
|
+
return errResult(
|
|
316
|
+
new ImportError({
|
|
317
|
+
code: "importer-not-registered",
|
|
318
|
+
expected: `an importer registered for meta.importer "${meta.importer}"`,
|
|
319
|
+
hint: IMPORT_ERROR_HINTS["importer-not-registered"],
|
|
320
|
+
detail: {
|
|
321
|
+
importer: meta.importer,
|
|
322
|
+
registeredImporters: registry.registeredImporters()
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
328
|
+
const readSource = async (sourcePath) => {
|
|
329
|
+
dependencies.add(normalizeDependencyPath(sourcePath));
|
|
330
|
+
try {
|
|
331
|
+
return await fs.readSource(sourcePath);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
return { ok: false, error };
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
const readSibling = async (uri) => {
|
|
337
|
+
let inner;
|
|
338
|
+
try {
|
|
339
|
+
if (fs.readSibling) {
|
|
340
|
+
dependencies.add(normalizeDependencyPath(joinSiblingPath(meta.source, uri)));
|
|
341
|
+
inner = await fs.readSibling(meta.source, uri);
|
|
342
|
+
} else {
|
|
343
|
+
inner = await readSource(joinSiblingPath(meta.source, uri));
|
|
344
|
+
}
|
|
345
|
+
} catch (error) {
|
|
346
|
+
inner = { ok: false, error };
|
|
347
|
+
}
|
|
348
|
+
if (inner.ok) {
|
|
349
|
+
return { ok: true, value: inner.value };
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
ok: false,
|
|
353
|
+
error: new ImportError({
|
|
354
|
+
code: "source-read-failed",
|
|
355
|
+
expected: `readable sibling file "${uri}" co-located with meta.source "${meta.source}"`,
|
|
356
|
+
hint: IMPORT_ERROR_HINTS["source-read-failed"],
|
|
357
|
+
detail: {
|
|
358
|
+
source: uri,
|
|
359
|
+
reason: sourceReadFailureReason(inner.error)
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
const decodeImage = fs.decodeImage ?? (async () => {
|
|
365
|
+
throw new Error(
|
|
366
|
+
"ImportRunnerFs.decodeImage was not provided; gltfImporter texture extraction requires the host (vite-plugin-pack / cli-gltf / test) to bind decodeImage when constructing the ImportRunnerFs"
|
|
367
|
+
);
|
|
368
|
+
});
|
|
369
|
+
const canonicalSourceOverrides = canonicalizeSourceOverrides(sourceOverridesResult.value);
|
|
370
|
+
const ctx = {
|
|
371
|
+
source: meta.source,
|
|
372
|
+
readSource: () => readSource(meta.source),
|
|
373
|
+
readSibling,
|
|
374
|
+
decodeImage,
|
|
375
|
+
subAssets: meta.subAssets.map(({ guid, sourceIndex, sourceKey, kind }) => ({
|
|
376
|
+
guid,
|
|
377
|
+
sourceIndex,
|
|
378
|
+
...sourceKey === void 0 ? {} : { sourceKey },
|
|
379
|
+
kind
|
|
380
|
+
})),
|
|
381
|
+
importSettings: meta.importSettings ?? {},
|
|
382
|
+
...canonicalSourceOverrides === void 0 ? {} : { sourceOverrides: canonicalSourceOverrides }
|
|
383
|
+
};
|
|
384
|
+
const sourceProbe = await readSource(meta.source);
|
|
385
|
+
if (!sourceProbe.ok) {
|
|
386
|
+
return errResult(
|
|
387
|
+
new ImportError({
|
|
388
|
+
code: "source-read-failed",
|
|
389
|
+
expected: `readable source file at meta.source "${meta.source}"`,
|
|
390
|
+
hint: IMPORT_ERROR_HINTS["source-read-failed"],
|
|
391
|
+
detail: {
|
|
392
|
+
source: meta.source,
|
|
393
|
+
reason: sourceReadFailureReason(sourceProbe.error)
|
|
394
|
+
}
|
|
395
|
+
})
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
let product;
|
|
399
|
+
try {
|
|
400
|
+
const imported = await importer.import(ctx);
|
|
401
|
+
if (imported === void 0 || imported === null || typeof imported !== "object" || !("ok" in imported)) {
|
|
402
|
+
throw new Error(
|
|
403
|
+
"importer returned a legacy or malformed result; expected ImportResult<ImportProduct>"
|
|
404
|
+
);
|
|
405
|
+
} else {
|
|
406
|
+
if (!imported.ok) {
|
|
407
|
+
if (imported.error === void 0)
|
|
408
|
+
throw new Error("importer returned an invalid failure result");
|
|
409
|
+
if (imported.error instanceof ImportError) return errResult(imported.error);
|
|
410
|
+
return errResult(
|
|
411
|
+
new ImportError({
|
|
412
|
+
code: "import-internal-error",
|
|
413
|
+
expected: `importer "${meta.importer}" to return a structured ImportError`,
|
|
414
|
+
hint: IMPORT_ERROR_HINTS["import-internal-error"],
|
|
415
|
+
detail: { reason: String(imported.error) }
|
|
416
|
+
})
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if (imported.value === void 0)
|
|
420
|
+
throw new Error("importer returned an invalid success result");
|
|
421
|
+
const value = imported.value;
|
|
422
|
+
if (value === void 0 || !Array.isArray(value.assets) || !Array.isArray(value.sourceDependencies) || "artifacts" in value) {
|
|
423
|
+
throw new Error("importer returned an invalid ImportProduct");
|
|
424
|
+
}
|
|
425
|
+
for (const asset of value.assets) {
|
|
426
|
+
if (asset === null || typeof asset !== "object" || !("artifacts" in asset) || asset.artifacts === null || typeof asset.artifacts !== "object" || Array.isArray(asset.artifacts)) {
|
|
427
|
+
throw new Error("importer returned an asset without local artifacts");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
product = value;
|
|
431
|
+
}
|
|
432
|
+
} catch (e) {
|
|
433
|
+
if (e instanceof ImportError) return errResult(e);
|
|
434
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
435
|
+
if (isModuleLoadFailure(e)) {
|
|
436
|
+
return errResult(
|
|
437
|
+
new ImportError({
|
|
438
|
+
code: "import-internal-error",
|
|
439
|
+
expected: `importer module "${meta.importer}" to load (module + native addon present)`,
|
|
440
|
+
hint: IMPORT_ERROR_HINTS["import-internal-error"],
|
|
441
|
+
detail: { loadError: message }
|
|
442
|
+
})
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return errResult(
|
|
446
|
+
new ImportError({
|
|
447
|
+
code: "import-internal-error",
|
|
448
|
+
expected: `importer "${meta.importer}" to convert the source without throwing`,
|
|
449
|
+
hint: IMPORT_ERROR_HINTS["import-internal-error"],
|
|
450
|
+
detail: { reason: message }
|
|
451
|
+
})
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
const produced = product.assets;
|
|
455
|
+
const declared = new Set(meta.subAssets.map((s) => s.guid));
|
|
456
|
+
const producedGuids = new Set(produced.map((a) => a.guid));
|
|
457
|
+
const unexpectedGuids = [...producedGuids].filter((g) => !declared.has(g));
|
|
458
|
+
if (unexpectedGuids.length > 0) {
|
|
459
|
+
return errResult(
|
|
460
|
+
new ImportError({
|
|
461
|
+
code: "guid-mismatch",
|
|
462
|
+
expected: "every produced GUID to be declared in meta.subAssets[]",
|
|
463
|
+
hint: IMPORT_ERROR_HINTS["guid-mismatch"],
|
|
464
|
+
detail: { unexpectedGuids }
|
|
465
|
+
})
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
const missingGuids = [...declared].filter((g) => !producedGuids.has(g));
|
|
469
|
+
if (produced.length === 0 || missingGuids.length > 0) {
|
|
470
|
+
return errResult(
|
|
471
|
+
new ImportError({
|
|
472
|
+
code: "import-produced-no-assets",
|
|
473
|
+
expected: produced.length === 0 ? "the importer to produce at least one ImportedAsset" : "the produced GUID set to be a superset of meta.subAssets[]",
|
|
474
|
+
hint: IMPORT_ERROR_HINTS["import-produced-no-assets"],
|
|
475
|
+
detail: { missingGuids }
|
|
476
|
+
})
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
const declarations = new Map(
|
|
480
|
+
meta.subAssets.map((declaration) => [declaration.guid, declaration])
|
|
481
|
+
);
|
|
482
|
+
const productWithDependencies = {
|
|
483
|
+
...product,
|
|
484
|
+
sourceDependencies: [...dependencies]
|
|
485
|
+
};
|
|
486
|
+
const inputFingerprint = `source:${[...dependencies].sort().join("|")}`;
|
|
487
|
+
let cookProducts;
|
|
488
|
+
try {
|
|
489
|
+
cookProducts = await finalizeImportProducts(productWithDependencies, inputFingerprint);
|
|
490
|
+
} catch (e) {
|
|
491
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
492
|
+
return errResult(
|
|
493
|
+
new ImportError({
|
|
494
|
+
code: "import-internal-error",
|
|
495
|
+
expected: `importer "${meta.importer}" finalization to produce complete CookProduct digests`,
|
|
496
|
+
hint: IMPORT_ERROR_HINTS["import-internal-error"],
|
|
497
|
+
detail: { reason: `finalization/digest: ${reason}` }
|
|
498
|
+
})
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
if (meta.buildPack === false) {
|
|
502
|
+
return {
|
|
503
|
+
ok: true,
|
|
504
|
+
value: { product: productWithDependencies, cookProducts }
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
const assets = produced.map((a) => {
|
|
508
|
+
const outputFields = declarationFields(declarations.get(a.guid));
|
|
509
|
+
return {
|
|
510
|
+
guid: a.guid,
|
|
511
|
+
kind: a.kind,
|
|
512
|
+
...outputFields,
|
|
513
|
+
...a.name !== void 0 ? { name: a.name } : {},
|
|
514
|
+
// bug-20260610: mesh / scene / animation-clip payloads carry Float32Array
|
|
515
|
+
// / Uint16Array / Uint32Array fields. JSON.stringify on a typed array
|
|
516
|
+
// serialises to `{ "0": v0, "1": v1, ... }` (a plain object), which the
|
|
517
|
+
// runtime mesh / animation loaders reject (`vertexData instanceof
|
|
518
|
+
// Float32Array` and `Array.isArray(vertexData)` both fail). Convert
|
|
519
|
+
// every typed-array field to a plain Array here so the pack is JSON-
|
|
520
|
+
// roundtrip safe end-to-end. This matches the convention every
|
|
521
|
+
// existing pack-fixture test uses (`vertices: Array.from(...)`).
|
|
522
|
+
payload: normaliseForPack(a.payload),
|
|
523
|
+
refs: a.refs.map((r) => r.guid),
|
|
524
|
+
artifacts: a.artifacts
|
|
525
|
+
};
|
|
526
|
+
});
|
|
527
|
+
const pack = {
|
|
528
|
+
schemaVersion: "2.0.0",
|
|
529
|
+
kind: "internal-text-package",
|
|
530
|
+
...meta.packageId !== void 0 ? { packageId: meta.packageId } : {},
|
|
531
|
+
...meta.provenance !== void 0 ? { provenance: meta.provenance } : {},
|
|
532
|
+
...meta.revision !== void 0 ? { revision: meta.revision } : {},
|
|
533
|
+
...meta.diagnostics !== void 0 ? { diagnostics: meta.diagnostics } : {},
|
|
534
|
+
assets
|
|
535
|
+
};
|
|
536
|
+
return {
|
|
537
|
+
ok: true,
|
|
538
|
+
value: {
|
|
539
|
+
product: {
|
|
540
|
+
...productWithDependencies
|
|
541
|
+
},
|
|
542
|
+
cookProducts,
|
|
543
|
+
pack
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// src/importer-registry.ts
|
|
549
|
+
var ImporterRegistry = class {
|
|
550
|
+
importers = /* @__PURE__ */ new Map();
|
|
551
|
+
/**
|
|
552
|
+
* Register an importer for its `importer.key`. Fail-fast on a malformed
|
|
553
|
+
* importer (charter P3); idempotent on a repeated key (last write wins).
|
|
554
|
+
*
|
|
555
|
+
* @param importer the `{ key, import }` object to register.
|
|
556
|
+
* @throws TypeError when `importer.key` is empty or `importer.import` is not
|
|
557
|
+
* a function - a wire-time misconfiguration the host must fix.
|
|
558
|
+
*/
|
|
559
|
+
register(importer) {
|
|
560
|
+
if (typeof importer.key !== "string" || importer.key.length === 0) {
|
|
561
|
+
throw new TypeError(
|
|
562
|
+
`ImporterRegistry.register: importer.key must be a non-empty string (got ${JSON.stringify(importer.key)})`
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
if (typeof importer.import !== "function") {
|
|
566
|
+
throw new TypeError(
|
|
567
|
+
`ImporterRegistry.register: importer.import must be a function for key "${importer.key}"`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
this.importers.set(importer.key, importer);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Look up the importer registered for `key`. Returns `undefined` when no
|
|
574
|
+
* importer is wired - the import runner maps that to a structured
|
|
575
|
+
* `ImportError(code='importer-not-registered')` with the registered keys in
|
|
576
|
+
* `.detail.registeredImporters` (charter P3).
|
|
577
|
+
*/
|
|
578
|
+
get(key) {
|
|
579
|
+
return this.importers.get(key);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* The importer keys currently wired, in insertion order. Fed into the
|
|
583
|
+
* `importer-not-registered` error `.detail.registeredImporters` so AI users
|
|
584
|
+
* see exactly what is injectable.
|
|
585
|
+
*/
|
|
586
|
+
registeredImporters() {
|
|
587
|
+
return [...this.importers.keys()];
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
function failure(sourceKey, expected, actual) {
|
|
591
|
+
return {
|
|
592
|
+
code: "mesh-bin-payload-invalid",
|
|
593
|
+
subject: "mesh-bin",
|
|
594
|
+
sourceKey,
|
|
595
|
+
expected,
|
|
596
|
+
actual,
|
|
597
|
+
recovery: "re-cook the source with its Meta sidecar through the build-time importer"
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function asAttributeMap(value) {
|
|
601
|
+
return value ?? {};
|
|
602
|
+
}
|
|
603
|
+
function jsonValue(value) {
|
|
604
|
+
if (value instanceof Float32Array || value instanceof Uint16Array) return Array.from(value);
|
|
605
|
+
if (Array.isArray(value)) return value.map(jsonValue);
|
|
606
|
+
if (value !== null && typeof value === "object") {
|
|
607
|
+
return Object.fromEntries(
|
|
608
|
+
Object.entries(value).map(([key, nested]) => [key, jsonValue(nested)])
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
return value;
|
|
612
|
+
}
|
|
613
|
+
function refsMeta(payload, refs) {
|
|
614
|
+
const materialSlots = (payload.materialSlots ?? [{ slotName: "Default" }]).map(
|
|
615
|
+
(slot, slotIndex) => {
|
|
616
|
+
const defaultMaterial = slot.defaultMaterial;
|
|
617
|
+
let defaultMaterialRef;
|
|
618
|
+
if (defaultMaterial !== void 0) {
|
|
619
|
+
const guid = AssetGuid.format(defaultMaterial);
|
|
620
|
+
defaultMaterialRef = refs.findIndex((candidate) => candidate.toLowerCase() === guid);
|
|
621
|
+
if (defaultMaterialRef < 0) {
|
|
622
|
+
throw new Error(
|
|
623
|
+
`material slot ${slotIndex} default material ${guid} is absent from refs`
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
slotName: slot.slotName,
|
|
629
|
+
...slot.sourceKey === void 0 ? {} : { sourceKey: slot.sourceKey },
|
|
630
|
+
...defaultMaterialRef === void 0 ? {} : { defaultMaterialRef }
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
return {
|
|
635
|
+
submeshes: payload.submeshes === void 0 || payload.submeshes.length === 0 ? [{ indexOffset: 0, indexCount: payload.indices?.length ?? 0, materialSlot: 0 }] : payload.submeshes,
|
|
636
|
+
materialSlots,
|
|
637
|
+
...payload.aabb === void 0 ? {} : { aabb: jsonValue(payload.aabb) },
|
|
638
|
+
...payload.morphTargets === void 0 ? {} : { morphTargets: jsonValue(payload.morphTargets) },
|
|
639
|
+
...payload.morphWeights === void 0 ? {} : { morphWeights: jsonValue(payload.morphWeights) }
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function packMeshBinV4(payload, sourceKey, refs = []) {
|
|
643
|
+
try {
|
|
644
|
+
const vertices = payload.vertices;
|
|
645
|
+
const indices = payload.indices;
|
|
646
|
+
if (!(vertices instanceof Float32Array)) {
|
|
647
|
+
return err(
|
|
648
|
+
failure(sourceKey, "Float32Array interleaved vertices", "vertices is not Float32Array")
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
if (indices !== void 0 && !(indices instanceof Uint16Array || indices instanceof Uint32Array)) {
|
|
652
|
+
return err(
|
|
653
|
+
failure(sourceKey, "Uint16Array or Uint32Array indices", "indices has an unsupported type")
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
const attributes = asAttributeMap(payload.attributes);
|
|
657
|
+
const projection = deriveVertexLayoutProjection(attributes);
|
|
658
|
+
if (projection.attributes.length === 0 || projection.arrayStride === 0) {
|
|
659
|
+
return err(
|
|
660
|
+
failure(
|
|
661
|
+
sourceKey,
|
|
662
|
+
"a non-empty canonical geometry projection",
|
|
663
|
+
"projection has no attributes"
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
const vertexCount = payload.vertexCount ?? vertices.byteLength / projection.arrayStride;
|
|
668
|
+
if (!Number.isSafeInteger(vertexCount) || vertexCount < 0) {
|
|
669
|
+
return err(
|
|
670
|
+
failure(sourceKey, "a non-negative safe vertex cardinality", `vertexCount=${vertexCount}`)
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
if (vertices.byteLength !== vertexCount * projection.arrayStride) {
|
|
674
|
+
return err(
|
|
675
|
+
failure(
|
|
676
|
+
sourceKey,
|
|
677
|
+
`vertices.byteLength=${vertexCount * projection.arrayStride}`,
|
|
678
|
+
`vertices.byteLength=${vertices.byteLength}; stride=${projection.arrayStride}`
|
|
679
|
+
)
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
for (const attribute of projection.attributes) {
|
|
683
|
+
const value = attributes[attribute.key];
|
|
684
|
+
const components = attribute.byteLength / (attribute.format === "uint16x4" ? 2 : 4);
|
|
685
|
+
if (value === void 0 || !(value instanceof Float32Array) && !(value instanceof Uint16Array) || value.length !== vertexCount * components) {
|
|
686
|
+
return err(
|
|
687
|
+
failure(
|
|
688
|
+
sourceKey,
|
|
689
|
+
`${attribute.key} cardinality=${vertexCount * components}`,
|
|
690
|
+
`${attribute.key} cardinality=${value?.byteLength ?? "missing"}`
|
|
691
|
+
)
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const interleaved = new Uint8Array(vertexCount * projection.arrayStride);
|
|
696
|
+
const interleavedView = new DataView(interleaved.buffer);
|
|
697
|
+
for (const attribute of projection.attributes) {
|
|
698
|
+
const value = attributes[attribute.key];
|
|
699
|
+
if (value === void 0) continue;
|
|
700
|
+
const components = attribute.byteLength / (attribute.format === "uint16x4" ? 2 : 4);
|
|
701
|
+
for (let vertex = 0; vertex < vertexCount; vertex++) {
|
|
702
|
+
for (let component = 0; component < components; component++) {
|
|
703
|
+
const sourceIndex = vertex * components + component;
|
|
704
|
+
const targetOffset = vertex * projection.arrayStride + attribute.offset + component * (attribute.format === "uint16x4" ? 2 : 4);
|
|
705
|
+
if (attribute.format === "uint16x4") {
|
|
706
|
+
interleavedView.setUint16(targetOffset, value[sourceIndex] ?? 0, true);
|
|
707
|
+
} else {
|
|
708
|
+
interleavedView.setFloat32(
|
|
709
|
+
targetOffset,
|
|
710
|
+
value[sourceIndex] ?? 0,
|
|
711
|
+
true
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
const indexCount = indices?.length ?? 0;
|
|
718
|
+
const indexWidth = indices === void 0 || indexCount === 0 ? 0 : indices.BYTES_PER_ELEMENT;
|
|
719
|
+
const indexBytes = indexCount * indexWidth;
|
|
720
|
+
if (!Number.isSafeInteger(indexBytes) || indexBytes > 4294967295) {
|
|
721
|
+
return err(failure(sourceKey, "safe index payload byte length", `indexBytes=${indexBytes}`));
|
|
722
|
+
}
|
|
723
|
+
const meta = new TextEncoder().encode(JSON.stringify(refsMeta(payload, refs)));
|
|
724
|
+
const header = {
|
|
725
|
+
version: 4,
|
|
726
|
+
projectionVersion: projection.schemaVersion,
|
|
727
|
+
mask: projection.mask,
|
|
728
|
+
digest: projection.digest,
|
|
729
|
+
stride: projection.arrayStride,
|
|
730
|
+
vertexCount,
|
|
731
|
+
vertexBytes: interleaved.byteLength,
|
|
732
|
+
indexCount,
|
|
733
|
+
indexWidth,
|
|
734
|
+
indexBytes,
|
|
735
|
+
jsonBytes: meta.byteLength
|
|
736
|
+
};
|
|
737
|
+
const total = MESH_BIN_HEADER_V4_BYTES + interleaved.byteLength + indexBytes + meta.byteLength;
|
|
738
|
+
if (!Number.isSafeInteger(total) || total > 4294967295) {
|
|
739
|
+
return err(failure(sourceKey, "safe mesh binary byte length", `total=${total}`));
|
|
740
|
+
}
|
|
741
|
+
const out = new Uint8Array(total);
|
|
742
|
+
writeMeshBinHeader(header, out);
|
|
743
|
+
let offset = MESH_BIN_HEADER_V4_BYTES;
|
|
744
|
+
out.set(interleaved, offset);
|
|
745
|
+
offset += interleaved.byteLength;
|
|
746
|
+
if (indices !== void 0 && indexBytes > 0) {
|
|
747
|
+
out.set(new Uint8Array(indices.buffer, indices.byteOffset, indices.byteLength), offset);
|
|
748
|
+
offset += indexBytes;
|
|
749
|
+
}
|
|
750
|
+
out.set(meta, offset);
|
|
751
|
+
return ok(out);
|
|
752
|
+
} catch (error) {
|
|
753
|
+
return err(
|
|
754
|
+
failure(
|
|
755
|
+
sourceKey,
|
|
756
|
+
"valid canonical mesh payload",
|
|
757
|
+
error instanceof Error ? error.message : String(error)
|
|
758
|
+
)
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function commonPathPrefix(paths) {
|
|
763
|
+
const first = paths[0];
|
|
764
|
+
if (first === void 0) return "";
|
|
765
|
+
const firstNormalized = first.replaceAll("\\", "/");
|
|
766
|
+
const firstDirectory = firstNormalized.slice(0, firstNormalized.lastIndexOf("/"));
|
|
767
|
+
const parts = firstDirectory.split("/");
|
|
768
|
+
let length = parts.length;
|
|
769
|
+
for (const path of paths.slice(1)) {
|
|
770
|
+
const normalized = path.replaceAll("\\", "/");
|
|
771
|
+
const candidate = normalized.slice(0, normalized.lastIndexOf("/")).split("/");
|
|
772
|
+
length = Math.min(length, candidate.length);
|
|
773
|
+
for (let index = 0; index < length; index += 1) {
|
|
774
|
+
if (parts[index] !== candidate[index]) {
|
|
775
|
+
length = index;
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return parts.slice(0, length).join("/");
|
|
781
|
+
}
|
|
782
|
+
function stableSourceClosure(closure) {
|
|
783
|
+
const root = commonPathPrefix(closure.map((entry) => entry.path));
|
|
784
|
+
return closure.map((entry) => ({
|
|
785
|
+
path: entry.path.replaceAll("\\", "/").slice(root.length).replace(/^\/+/, ""),
|
|
786
|
+
digest: entry.digest
|
|
787
|
+
})).sort((left, right) => left.path.localeCompare(right.path));
|
|
788
|
+
}
|
|
789
|
+
var AssetOutputProducerRegistry = class {
|
|
790
|
+
producers = /* @__PURE__ */ new Map();
|
|
791
|
+
register(producer) {
|
|
792
|
+
if (producer.kind.trim().length === 0 || producer.version.trim().length === 0) {
|
|
793
|
+
throw new TypeError("ScriptablePack output producer kind and version must be non-empty");
|
|
794
|
+
}
|
|
795
|
+
if (typeof producer.produce !== "function") {
|
|
796
|
+
throw new TypeError(`ScriptablePack output producer ${producer.kind} must expose produce`);
|
|
797
|
+
}
|
|
798
|
+
this.producers.set(producer.kind, producer);
|
|
799
|
+
}
|
|
800
|
+
get(kind) {
|
|
801
|
+
return this.producers.get(kind);
|
|
802
|
+
}
|
|
803
|
+
versions() {
|
|
804
|
+
return Object.fromEntries(
|
|
805
|
+
[...this.producers.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([kind, producer]) => [kind, producer.version])
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
function privateClone(value) {
|
|
810
|
+
return structuredClone(value);
|
|
811
|
+
}
|
|
812
|
+
function record(value) {
|
|
813
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
814
|
+
}
|
|
815
|
+
function isAsset(value) {
|
|
816
|
+
return record(value) && typeof value.kind === "string" && isScriptablePackAssetKind(value.kind);
|
|
817
|
+
}
|
|
818
|
+
function isStructuredDomainError(value) {
|
|
819
|
+
return value !== null && typeof value === "object" && typeof value.code === "string" && typeof value.expected === "string" && typeof value.hint === "string";
|
|
820
|
+
}
|
|
821
|
+
function remapBuildFailureSource(value, sourcePath) {
|
|
822
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
823
|
+
const error = value;
|
|
824
|
+
if (error.code !== "pack-source-load-failed") return void 0;
|
|
825
|
+
if (error.detail === null || typeof error.detail !== "object") return void 0;
|
|
826
|
+
const detail = error.detail;
|
|
827
|
+
if (detail.phase !== "build") return void 0;
|
|
828
|
+
return {
|
|
829
|
+
...value,
|
|
830
|
+
detail: { ...detail, sourcePath }
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
function observedAssetReader(source) {
|
|
834
|
+
const reads = /* @__PURE__ */ new Map();
|
|
835
|
+
const reader = {
|
|
836
|
+
async readByGuid(guid) {
|
|
837
|
+
const key = AssetGuid.format(guid);
|
|
838
|
+
const cached = reads.get(key);
|
|
839
|
+
if (cached !== void 0) return ok(privateClone(cached.asset));
|
|
840
|
+
if (source === void 0) {
|
|
841
|
+
return err(
|
|
842
|
+
new AssetError({
|
|
843
|
+
code: "asset-not-found",
|
|
844
|
+
expected: `a host Asset snapshot source for ScriptablePack content read ${key}`,
|
|
845
|
+
hint: "configure pluginPack({ scriptablePack: { assetSource, ... } }) or remove the content read"
|
|
846
|
+
})
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
const result = await source.readByGuid(guid);
|
|
850
|
+
if (!result.ok) return result;
|
|
851
|
+
const fixed = privateClone(result.value.asset);
|
|
852
|
+
reads.set(key, {
|
|
853
|
+
guid: key,
|
|
854
|
+
asset: fixed,
|
|
855
|
+
generation: result.value.generation,
|
|
856
|
+
digest: result.value.digest
|
|
857
|
+
});
|
|
858
|
+
return ok(privateClone(fixed));
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
return { reader, reads };
|
|
862
|
+
}
|
|
863
|
+
function stable(value) {
|
|
864
|
+
if (value instanceof Uint8Array) return JSON.stringify(Array.from(value));
|
|
865
|
+
if (Array.isArray(value)) return `[${value.map(stable).join(",")}]`;
|
|
866
|
+
if (value !== null && typeof value === "object") {
|
|
867
|
+
const record2 = value;
|
|
868
|
+
return `{${Object.keys(record2).sort().map((key) => `${JSON.stringify(key)}:${stable(record2[key])}`).join(",")}}`;
|
|
869
|
+
}
|
|
870
|
+
return JSON.stringify(value) ?? "null";
|
|
871
|
+
}
|
|
872
|
+
async function fingerprint(value) {
|
|
873
|
+
const subtle = globalThis.crypto?.subtle;
|
|
874
|
+
if (subtle === void 0)
|
|
875
|
+
throw new Error("Web Crypto API is required for ScriptablePack fingerprints");
|
|
876
|
+
const digest = await subtle.digest("SHA-256", new TextEncoder().encode(stable(value)));
|
|
877
|
+
const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
878
|
+
""
|
|
879
|
+
);
|
|
880
|
+
return `sha256:${hex}`;
|
|
881
|
+
}
|
|
882
|
+
function outputError(definition, output) {
|
|
883
|
+
const declaredKeys = Object.keys(definition.assets);
|
|
884
|
+
const outputKeys = Object.keys(output);
|
|
885
|
+
const outputKeySet = new Set(outputKeys);
|
|
886
|
+
const declaredKeySet = new Set(declaredKeys);
|
|
887
|
+
const missingKeys = declaredKeys.filter((key) => !outputKeySet.has(key));
|
|
888
|
+
const unexpectedSourceKeys = outputKeys.filter((key) => !declaredKeySet.has(key));
|
|
889
|
+
const kindMismatches = declaredKeys.flatMap((sourceKey) => {
|
|
890
|
+
const descriptor = definition.assets[sourceKey];
|
|
891
|
+
const value = output[sourceKey];
|
|
892
|
+
if (descriptor === void 0 || value === void 0) return [];
|
|
893
|
+
const actualKind = value !== null && typeof value === "object" && "kind" in value ? String(value.kind) : typeof value;
|
|
894
|
+
return actualKind === descriptor.kind ? [] : [{ sourceKey, expected: descriptor.kind, actual: actualKind }];
|
|
895
|
+
});
|
|
896
|
+
if (missingKeys.length === 0 && unexpectedSourceKeys.length === 0 && kindMismatches.length === 0) {
|
|
897
|
+
return void 0;
|
|
898
|
+
}
|
|
899
|
+
return {
|
|
900
|
+
code: "pack-source-output-invalid",
|
|
901
|
+
expected: "build output keys and kinds to exactly match definition.assets",
|
|
902
|
+
hint: "inspect sourceKey and GUID topology, then rebuild or cold-cook the ScriptablePack",
|
|
903
|
+
detail: {
|
|
904
|
+
missingGuids: missingKeys.map(
|
|
905
|
+
(key) => AssetGuid.format(definition.assets[key]?.guid)
|
|
906
|
+
),
|
|
907
|
+
unexpectedSourceKeys,
|
|
908
|
+
kindMismatches
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function externalClosureError(declared, referenced, read) {
|
|
913
|
+
const used = /* @__PURE__ */ new Set([...referenced, ...read]);
|
|
914
|
+
const undeclaredReferencedGuids = [...referenced].filter((guid) => !declared.has(guid));
|
|
915
|
+
const undeclaredReadGuids = [...read].filter((guid) => !declared.has(guid));
|
|
916
|
+
const unusedDeclaredGuids = [...declared].filter((guid) => !used.has(guid));
|
|
917
|
+
if (undeclaredReferencedGuids.length === 0 && undeclaredReadGuids.length === 0 && unusedDeclaredGuids.length === 0) {
|
|
918
|
+
return void 0;
|
|
919
|
+
}
|
|
920
|
+
return {
|
|
921
|
+
code: "pack-source-external-closure-mismatch",
|
|
922
|
+
expected: "externalAssets GUIDs to equal output external refs union AssetReader reads",
|
|
923
|
+
hint: "inspect refs and AssetReader reads, repair GUID declarations, then rebuild or cold-cook",
|
|
924
|
+
detail: {
|
|
925
|
+
undeclaredReferencedGuids: undeclaredReferencedGuids.sort(),
|
|
926
|
+
undeclaredReadGuids: undeclaredReadGuids.sort(),
|
|
927
|
+
unusedDeclaredGuids: unusedDeclaredGuids.sort()
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
function productContractError(sourceKey, kind, product) {
|
|
932
|
+
const mismatches = [];
|
|
933
|
+
if (product.payload.kind !== kind) {
|
|
934
|
+
mismatches.push({ sourceKey, expected: kind, actual: product.payload.kind });
|
|
935
|
+
}
|
|
936
|
+
for (const reference of product.refs) {
|
|
937
|
+
if (!AssetGuid.parse(reference.guid).ok) {
|
|
938
|
+
mismatches.push({
|
|
939
|
+
sourceKey,
|
|
940
|
+
expected: "every producer ref to contain a valid Asset GUID",
|
|
941
|
+
actual: reference.guid
|
|
942
|
+
});
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
for (const [artifactKey, artifact] of Object.entries(product.artifacts)) {
|
|
947
|
+
if (artifactKey.length === 0 || artifactKey.startsWith("/") || artifactKey.includes("..") || artifactKey.includes("\\") || artifact.mediaType.trim().length === 0 || !(artifact.bytes instanceof Uint8Array)) {
|
|
948
|
+
mismatches.push({
|
|
949
|
+
sourceKey,
|
|
950
|
+
expected: "asset-local artifacts with safe keys, mediaType, and Uint8Array bytes",
|
|
951
|
+
actual: artifactKey
|
|
952
|
+
});
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (mismatches.length === 0) return void 0;
|
|
957
|
+
return {
|
|
958
|
+
code: "pack-source-output-invalid",
|
|
959
|
+
expected: "producer output refs and asset-local artifacts to satisfy the Pack v2 contract",
|
|
960
|
+
hint: "inspect sourceKey and artifact provenance, repair refs or bytes, then rebuild or cold-cook",
|
|
961
|
+
detail: { missingGuids: [], unexpectedSourceKeys: [], kindMismatches: mismatches }
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
async function buildScriptablePack(options) {
|
|
965
|
+
const observed = observedAssetReader(options.assetSource);
|
|
966
|
+
let built;
|
|
967
|
+
try {
|
|
968
|
+
const build = options.definition.build;
|
|
969
|
+
built = await build(observed.reader);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
return err(
|
|
972
|
+
new ImportError({
|
|
973
|
+
code: "import-internal-error",
|
|
974
|
+
expected: "ScriptablePack build to return a structured Result without throwing",
|
|
975
|
+
hint: "fix the build implementation and return a structured failure for expected authoring errors",
|
|
976
|
+
detail: { reason: error instanceof Error ? error.message : String(error) }
|
|
977
|
+
})
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
if (!built.ok) {
|
|
981
|
+
const remappedBuildFailure = remapBuildFailureSource(built.error, options.sourcePath);
|
|
982
|
+
if (remappedBuildFailure !== void 0) return err(remappedBuildFailure);
|
|
983
|
+
if (built.error instanceof ImportError || built.error instanceof AssetError || isStructuredDomainError(built.error)) {
|
|
984
|
+
return err(built.error);
|
|
985
|
+
}
|
|
986
|
+
return err(
|
|
987
|
+
new ImportError({
|
|
988
|
+
code: "import-internal-error",
|
|
989
|
+
expected: "ScriptablePack build failure to use a structured domain error",
|
|
990
|
+
hint: "return an error with code, expected, hint, and optional detail fields",
|
|
991
|
+
detail: { reason: String(built.error) }
|
|
992
|
+
})
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
if (!record(built.value)) {
|
|
996
|
+
return err(
|
|
997
|
+
new ImportError({
|
|
998
|
+
code: "import-internal-error",
|
|
999
|
+
expected: "ScriptablePack build output to be an object keyed by declared sourceKey",
|
|
1000
|
+
hint: "return one concrete Asset payload for each declared sourceKey",
|
|
1001
|
+
detail: { reason: "build output is not an object" }
|
|
1002
|
+
})
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
const output = built.value;
|
|
1006
|
+
const invalidOutput = outputError(options.definition, output);
|
|
1007
|
+
if (invalidOutput !== void 0) return err(invalidOutput);
|
|
1008
|
+
const assets = [];
|
|
1009
|
+
for (const sourceKey of Object.keys(options.definition.assets).sort()) {
|
|
1010
|
+
const descriptor = options.definition.assets[sourceKey];
|
|
1011
|
+
const asset = output[sourceKey];
|
|
1012
|
+
if (descriptor === void 0) continue;
|
|
1013
|
+
if (!isAsset(asset)) {
|
|
1014
|
+
return err(
|
|
1015
|
+
new ImportError({
|
|
1016
|
+
code: "import-internal-error",
|
|
1017
|
+
expected: `a concrete Asset payload for sourceKey ${sourceKey}`,
|
|
1018
|
+
hint: "return a durable Asset with a kind from SCRIPTABLE_PACK_ASSET_KINDS",
|
|
1019
|
+
detail: { reason: "build output payload is missing or has an unknown kind" }
|
|
1020
|
+
})
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
const producer = options.outputs.get(descriptor.kind);
|
|
1024
|
+
if (producer === void 0) {
|
|
1025
|
+
return err({
|
|
1026
|
+
code: "pack-source-output-invalid",
|
|
1027
|
+
expected: `a domain output producer registered for kind ${descriptor.kind}`,
|
|
1028
|
+
hint: "attach the owning producer capability, inspect registration, then rebuild or cold-cook",
|
|
1029
|
+
detail: {
|
|
1030
|
+
missingGuids: [AssetGuid.format(descriptor.guid)],
|
|
1031
|
+
unexpectedSourceKeys: [],
|
|
1032
|
+
kindMismatches: []
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
const product2 = await producer.produce({
|
|
1037
|
+
guid: AssetGuid.format(descriptor.guid),
|
|
1038
|
+
sourceKey,
|
|
1039
|
+
asset,
|
|
1040
|
+
...options.components === void 0 ? {} : { components: options.components }
|
|
1041
|
+
});
|
|
1042
|
+
if (!product2.ok) return err(product2.error);
|
|
1043
|
+
const productError = productContractError(sourceKey, descriptor.kind, product2.value);
|
|
1044
|
+
if (productError !== void 0) return err(productError);
|
|
1045
|
+
assets.push({
|
|
1046
|
+
guid: AssetGuid.format(descriptor.guid),
|
|
1047
|
+
kind: descriptor.kind,
|
|
1048
|
+
...descriptor.name === void 0 ? {} : { name: descriptor.name },
|
|
1049
|
+
payload: product2.value.payload,
|
|
1050
|
+
refs: product2.value.refs,
|
|
1051
|
+
artifacts: product2.value.artifacts
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
const local = new Set(assets.map((asset) => asset.guid.toLowerCase()));
|
|
1055
|
+
const referenced = new Set(
|
|
1056
|
+
assets.flatMap((asset) => asset.refs.map((reference) => reference.guid.toLowerCase())).filter((guid) => !local.has(guid))
|
|
1057
|
+
);
|
|
1058
|
+
const read = new Set([...observed.reads.keys()].map((guid) => guid.toLowerCase()));
|
|
1059
|
+
const declared = new Set(
|
|
1060
|
+
Object.values(options.definition.externalAssets).map(
|
|
1061
|
+
(guid) => AssetGuid.format(guid).toLowerCase()
|
|
1062
|
+
)
|
|
1063
|
+
);
|
|
1064
|
+
const closureError = externalClosureError(declared, referenced, read);
|
|
1065
|
+
if (closureError !== void 0) return err(closureError);
|
|
1066
|
+
const externalEvidence = [...declared].sort().map((guid) => {
|
|
1067
|
+
const observedRead = observed.reads.get(guid);
|
|
1068
|
+
const isReference = referenced.has(guid);
|
|
1069
|
+
return {
|
|
1070
|
+
guid,
|
|
1071
|
+
usage: observedRead === void 0 ? "reference" : isReference ? "both" : "content",
|
|
1072
|
+
...observedRead === void 0 ? {} : { generation: observedRead.generation, digest: observedRead.digest }
|
|
1073
|
+
};
|
|
1074
|
+
});
|
|
1075
|
+
const fingerprintEvidence = externalEvidence.map(({ guid, usage, digest }) => ({
|
|
1076
|
+
guid,
|
|
1077
|
+
usage,
|
|
1078
|
+
...digest === void 0 ? {} : { digest }
|
|
1079
|
+
}));
|
|
1080
|
+
const product = {
|
|
1081
|
+
assets,
|
|
1082
|
+
sourceDependencies: options.sourceClosure.map((entry) => entry.path)
|
|
1083
|
+
};
|
|
1084
|
+
const inputFingerprint = await fingerprint({
|
|
1085
|
+
meta: projectScriptablePackMeta(options.definition, options.sourcePath),
|
|
1086
|
+
sourceClosure: stableSourceClosure(options.sourceClosure),
|
|
1087
|
+
externalEvidence: fingerprintEvidence,
|
|
1088
|
+
authoringContractVersion: options.authoringContractVersion,
|
|
1089
|
+
producerVersions: options.outputs.versions()
|
|
1090
|
+
});
|
|
1091
|
+
return ok({
|
|
1092
|
+
product,
|
|
1093
|
+
stagedOutputs: await Promise.all(
|
|
1094
|
+
Object.keys(options.definition.assets).sort().map(async (sourceKey) => {
|
|
1095
|
+
const descriptor = options.definition.assets[sourceKey];
|
|
1096
|
+
const asset = output[sourceKey];
|
|
1097
|
+
if (descriptor === void 0 || !isAsset(asset)) {
|
|
1098
|
+
throw new Error(`validated ScriptablePack output ${sourceKey} is not an Asset`);
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
guid: descriptor.guid,
|
|
1102
|
+
sourceKey,
|
|
1103
|
+
asset: privateClone(asset),
|
|
1104
|
+
digest: await fingerprint(asset)
|
|
1105
|
+
};
|
|
1106
|
+
})
|
|
1107
|
+
),
|
|
1108
|
+
externalEvidence,
|
|
1109
|
+
inputFingerprint
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
function producerError(input, reason) {
|
|
1113
|
+
return new ImportError({
|
|
1114
|
+
code: "import-internal-error",
|
|
1115
|
+
expected: `ScriptablePack ${input.asset.kind} output ${input.sourceKey} to satisfy its domain producer contract`,
|
|
1116
|
+
hint: "fix the generated Asset payload and rebuild the ScriptablePack",
|
|
1117
|
+
detail: { reason: reason instanceof Error ? reason.message : String(reason) }
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
function formatGuid(value) {
|
|
1121
|
+
if (typeof value === "string") {
|
|
1122
|
+
const parsed = AssetGuid.parse(value);
|
|
1123
|
+
if (!parsed.ok) throw parsed.error;
|
|
1124
|
+
return AssetGuid.format(parsed.value);
|
|
1125
|
+
}
|
|
1126
|
+
return AssetGuid.format(value);
|
|
1127
|
+
}
|
|
1128
|
+
function canonical(value) {
|
|
1129
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
1130
|
+
if (value !== null && typeof value === "object") {
|
|
1131
|
+
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonical(child)}`).join(",")}}`;
|
|
1132
|
+
}
|
|
1133
|
+
return JSON.stringify(value) ?? "null";
|
|
1134
|
+
}
|
|
1135
|
+
function particleProgramArtifact(effect) {
|
|
1136
|
+
const artifactProgram = { format: effect.program.format, emitters: effect.program.emitters };
|
|
1137
|
+
const bytes2 = new TextEncoder().encode(canonical(artifactProgram));
|
|
1138
|
+
const fingerprint2 = `sha256:${bytesToHex(sha256(bytes2))}`;
|
|
1139
|
+
return {
|
|
1140
|
+
program: { ...effect.program, fingerprint: fingerprint2 },
|
|
1141
|
+
bytes: bytes2,
|
|
1142
|
+
fingerprint: fingerprint2
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
function materialProduct(input) {
|
|
1146
|
+
if (input.asset.kind !== "material") throw new TypeError("expected MaterialAsset");
|
|
1147
|
+
const material = input.asset;
|
|
1148
|
+
const refs = [];
|
|
1149
|
+
const addRef = (guid, sourceField) => {
|
|
1150
|
+
refs.push({ guid: formatGuid(guid), sourceField });
|
|
1151
|
+
return refs.length - 1;
|
|
1152
|
+
};
|
|
1153
|
+
const addMaterialRef = (value, sourceField) => {
|
|
1154
|
+
if (typeof value === "number") {
|
|
1155
|
+
throw new TypeError("material texture references must be GUIDs, not runtime handles");
|
|
1156
|
+
}
|
|
1157
|
+
return addRef(value, sourceField);
|
|
1158
|
+
};
|
|
1159
|
+
const textureFields = material.parameters === void 0 ? new Set(MATERIAL_TEXTURE_SLOTS) : new Set(
|
|
1160
|
+
material.parameters.filter((parameter) => parameter.type === "texture").map((parameter) => parameter.name)
|
|
1161
|
+
);
|
|
1162
|
+
const parent = material.parent === void 0 ? void 0 : addRef(material.parent, { fieldName: "parent" });
|
|
1163
|
+
const values = {};
|
|
1164
|
+
for (const fieldName of Object.keys(material.values ?? {}).sort()) {
|
|
1165
|
+
const value = material.values?.[fieldName];
|
|
1166
|
+
if (typeof value === "string" && textureFields.has(fieldName)) {
|
|
1167
|
+
values[fieldName] = addMaterialRef(value, { componentName: "<material>", fieldName });
|
|
1168
|
+
} else if (value !== null && typeof value === "object" && !Array.isArray(value) && "texture" in value) {
|
|
1169
|
+
const texture = value;
|
|
1170
|
+
values[fieldName] = {
|
|
1171
|
+
...texture,
|
|
1172
|
+
texture: addMaterialRef(texture.texture, { componentName: "<material>", fieldName }),
|
|
1173
|
+
...texture.sampler === void 0 ? {} : {
|
|
1174
|
+
sampler: addMaterialRef(texture.sampler, {
|
|
1175
|
+
componentName: "<material>",
|
|
1176
|
+
fieldName: `${fieldName}.sampler`
|
|
1177
|
+
})
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
} else {
|
|
1181
|
+
values[fieldName] = value;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
const { parent: _parent, values: _values, ...materialShape } = material;
|
|
1185
|
+
return {
|
|
1186
|
+
payload: {
|
|
1187
|
+
...materialShape,
|
|
1188
|
+
...parent === void 0 ? {} : { parent },
|
|
1189
|
+
...material.values === void 0 ? {} : { values }
|
|
1190
|
+
},
|
|
1191
|
+
refs,
|
|
1192
|
+
artifacts: {}
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
var materialAssetOutputProducer = {
|
|
1196
|
+
kind: "material",
|
|
1197
|
+
version: "material-pack/1",
|
|
1198
|
+
produce(input) {
|
|
1199
|
+
try {
|
|
1200
|
+
return ok(materialProduct(input));
|
|
1201
|
+
} catch (error) {
|
|
1202
|
+
return err(producerError(input, error));
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
function meshProduct(input) {
|
|
1207
|
+
if (input.asset.kind !== "mesh") throw new TypeError("expected MeshAsset");
|
|
1208
|
+
const mesh = input.asset;
|
|
1209
|
+
const refs = [];
|
|
1210
|
+
for (let slotIndex = 0; slotIndex < mesh.materialSlots.length; slotIndex++) {
|
|
1211
|
+
const defaultMaterial = mesh.materialSlots[slotIndex]?.defaultMaterial;
|
|
1212
|
+
if (defaultMaterial === void 0) continue;
|
|
1213
|
+
refs.push({
|
|
1214
|
+
guid: formatGuid(defaultMaterial),
|
|
1215
|
+
sourceField: { fieldName: "materialSlots", arrayIndex: slotIndex }
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
return {
|
|
1219
|
+
payload: mesh,
|
|
1220
|
+
refs,
|
|
1221
|
+
artifacts: {
|
|
1222
|
+
body: {
|
|
1223
|
+
mediaType: "application/x-forgeax-mesh",
|
|
1224
|
+
assetCodec: { name: "mesh-binary", version: "4" },
|
|
1225
|
+
bytes: (() => {
|
|
1226
|
+
const packed = packMeshBinV4(
|
|
1227
|
+
mesh,
|
|
1228
|
+
input.sourceKey,
|
|
1229
|
+
refs.map((reference) => reference.guid)
|
|
1230
|
+
);
|
|
1231
|
+
if (!packed.ok) {
|
|
1232
|
+
throw packed.error;
|
|
1233
|
+
}
|
|
1234
|
+
return packed.value;
|
|
1235
|
+
})()
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
var meshAssetOutputProducer = {
|
|
1241
|
+
kind: "mesh",
|
|
1242
|
+
version: "mesh-binary/4",
|
|
1243
|
+
produce(input) {
|
|
1244
|
+
try {
|
|
1245
|
+
return ok(meshProduct(input));
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
return err(producerError(input, error));
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
function sceneProduct(input) {
|
|
1252
|
+
if (input.asset.kind !== "scene") throw new TypeError("expected SceneAsset");
|
|
1253
|
+
const externalized = externalizeSceneAsset(input.asset, (componentName) => {
|
|
1254
|
+
const component = input.components?.get(componentName);
|
|
1255
|
+
return component === void 0 ? void 0 : componentSchema(component);
|
|
1256
|
+
});
|
|
1257
|
+
if (!externalized.ok) throw new TypeError(`scene field ${externalized.error.field} is invalid`);
|
|
1258
|
+
return {
|
|
1259
|
+
payload: { kind: "scene", ...externalized.value.payload },
|
|
1260
|
+
refs: externalized.value.refs,
|
|
1261
|
+
artifacts: {}
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function jsonArtifact(value) {
|
|
1265
|
+
return {
|
|
1266
|
+
mediaType: "application/json",
|
|
1267
|
+
assetCodec: { name: "forgeax-json", version: "1" },
|
|
1268
|
+
bytes: new TextEncoder().encode(JSON.stringify(value))
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
function ref(guid, fieldName, arrayIndex) {
|
|
1272
|
+
return {
|
|
1273
|
+
guid: formatGuid(guid),
|
|
1274
|
+
sourceField: { fieldName, ...arrayIndex === void 0 ? {} : { arrayIndex } }
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
function bytes(value) {
|
|
1278
|
+
return Uint8Array.from(value);
|
|
1279
|
+
}
|
|
1280
|
+
function ordinaryPodProduct(input) {
|
|
1281
|
+
const asset = input.asset;
|
|
1282
|
+
switch (asset.kind) {
|
|
1283
|
+
case "texture": {
|
|
1284
|
+
const texture = asset;
|
|
1285
|
+
return {
|
|
1286
|
+
payload: texture,
|
|
1287
|
+
refs: [],
|
|
1288
|
+
artifacts: {
|
|
1289
|
+
body: {
|
|
1290
|
+
mediaType: "image/raw",
|
|
1291
|
+
assetCodec: { name: "raw-image", version: "1" },
|
|
1292
|
+
bytes: bytes(texture.data)
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
case "equirect": {
|
|
1298
|
+
const equirect = asset;
|
|
1299
|
+
return {
|
|
1300
|
+
payload: equirect,
|
|
1301
|
+
refs: [],
|
|
1302
|
+
artifacts: {
|
|
1303
|
+
body: {
|
|
1304
|
+
mediaType: "image/raw",
|
|
1305
|
+
assetCodec: { name: "raw-image", version: "1" },
|
|
1306
|
+
bytes: bytes(equirect.data)
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
case "sampler": {
|
|
1312
|
+
const sampler = asset;
|
|
1313
|
+
return { payload: sampler, refs: [], artifacts: { body: jsonArtifact(sampler) } };
|
|
1314
|
+
}
|
|
1315
|
+
case "font": {
|
|
1316
|
+
const font = asset;
|
|
1317
|
+
const atlas = ref(font.atlas, "atlas");
|
|
1318
|
+
const sampler = ref(font.sampler, "sampler");
|
|
1319
|
+
return {
|
|
1320
|
+
payload: {
|
|
1321
|
+
kind: font.kind,
|
|
1322
|
+
glyphs: font.glyphs,
|
|
1323
|
+
common: font.common,
|
|
1324
|
+
atlasGuid: atlas.guid,
|
|
1325
|
+
samplerGuid: sampler.guid
|
|
1326
|
+
},
|
|
1327
|
+
refs: [atlas, sampler],
|
|
1328
|
+
artifacts: { body: jsonArtifact(font) }
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
case "render-pipeline": {
|
|
1332
|
+
const pipeline = asset;
|
|
1333
|
+
return {
|
|
1334
|
+
payload: pipeline,
|
|
1335
|
+
refs: [],
|
|
1336
|
+
artifacts: { body: jsonArtifact(pipeline) }
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
case "tileset": {
|
|
1340
|
+
const tileset = asset;
|
|
1341
|
+
const refs = tileset.atlases.map((atlas, index) => {
|
|
1342
|
+
const parsed = AssetGuid.parse(atlas);
|
|
1343
|
+
if (!parsed.ok) throw parsed.error;
|
|
1344
|
+
return ref(parsed.value, "atlases", index);
|
|
1345
|
+
});
|
|
1346
|
+
return {
|
|
1347
|
+
payload: { ...tileset, atlases: refs.map((_entry, index) => index) },
|
|
1348
|
+
refs,
|
|
1349
|
+
artifacts: { body: jsonArtifact(tileset) }
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
case "video": {
|
|
1353
|
+
const video = asset;
|
|
1354
|
+
try {
|
|
1355
|
+
const url = new URL(video.url);
|
|
1356
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
1357
|
+
throw new Error("unsupported URL scheme");
|
|
1358
|
+
} catch (error) {
|
|
1359
|
+
throw new TypeError(
|
|
1360
|
+
`video URL is invalid: ${error instanceof Error ? error.message : String(error)}`
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
return { payload: video, refs: [], artifacts: {} };
|
|
1364
|
+
}
|
|
1365
|
+
case "skeleton": {
|
|
1366
|
+
const skeleton = asset;
|
|
1367
|
+
return {
|
|
1368
|
+
payload: skeleton,
|
|
1369
|
+
refs: [],
|
|
1370
|
+
artifacts: { body: jsonArtifact(skeleton) }
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
case "skin": {
|
|
1374
|
+
const skin = asset;
|
|
1375
|
+
const skeletonGuid = AssetGuid.parse(skin.skeletonGuid);
|
|
1376
|
+
if (!skeletonGuid.ok) throw skeletonGuid.error;
|
|
1377
|
+
return {
|
|
1378
|
+
payload: skin,
|
|
1379
|
+
refs: [ref(skeletonGuid.value, "skeletonGuid")],
|
|
1380
|
+
artifacts: { body: jsonArtifact(skin) }
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
case "animation-clip":
|
|
1384
|
+
return {
|
|
1385
|
+
payload: asset,
|
|
1386
|
+
refs: [],
|
|
1387
|
+
artifacts: { body: jsonArtifact(asset) }
|
|
1388
|
+
};
|
|
1389
|
+
case "animation-graph": {
|
|
1390
|
+
const graph = asset;
|
|
1391
|
+
const refs = [];
|
|
1392
|
+
const nodes = graph.nodes.map((node, index) => {
|
|
1393
|
+
if (node.type !== "clip") return node;
|
|
1394
|
+
const parsed = AssetGuid.parse(node.clip);
|
|
1395
|
+
if (!parsed.ok) throw parsed.error;
|
|
1396
|
+
const referenceIndex = refs.push(ref(parsed.value, "nodes", index)) - 1;
|
|
1397
|
+
return { ...node, clip: referenceIndex };
|
|
1398
|
+
});
|
|
1399
|
+
return {
|
|
1400
|
+
payload: { kind: graph.kind, root: graph.root, nodes },
|
|
1401
|
+
refs,
|
|
1402
|
+
artifacts: { body: jsonArtifact(graph) }
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
case "audio": {
|
|
1406
|
+
const audio = asset;
|
|
1407
|
+
return {
|
|
1408
|
+
payload: {
|
|
1409
|
+
kind: audio.kind,
|
|
1410
|
+
sourceKey: audio.sourceKey,
|
|
1411
|
+
mediaType: audio.mediaType,
|
|
1412
|
+
bytes: audio.bytes.slice()
|
|
1413
|
+
},
|
|
1414
|
+
refs: [],
|
|
1415
|
+
artifacts: {
|
|
1416
|
+
source: {
|
|
1417
|
+
mediaType: audio.mediaType,
|
|
1418
|
+
assetCodec: { name: "browser-audio", version: "1" },
|
|
1419
|
+
bytes: audio.bytes.slice()
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
case "particle-effect": {
|
|
1425
|
+
const effect = asset;
|
|
1426
|
+
const cooked = particleProgramArtifact(effect);
|
|
1427
|
+
return {
|
|
1428
|
+
payload: { ...effect, programFingerprint: cooked.fingerprint, program: cooked.program },
|
|
1429
|
+
refs: [],
|
|
1430
|
+
artifacts: {
|
|
1431
|
+
"particle-effect/program.json": {
|
|
1432
|
+
mediaType: "application/json",
|
|
1433
|
+
assetCodec: { name: "forgeax-vfx-program", version: effect.program.format },
|
|
1434
|
+
bytes: cooked.bytes
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
case "material":
|
|
1440
|
+
case "mesh":
|
|
1441
|
+
case "scene":
|
|
1442
|
+
throw new TypeError(`ordinary producer received already-owned ${asset.kind} asset`);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
var ordinaryAssetOutputProducer = {
|
|
1446
|
+
kind: "texture",
|
|
1447
|
+
version: "ordinary-pod/1",
|
|
1448
|
+
produce(input) {
|
|
1449
|
+
try {
|
|
1450
|
+
return ok(ordinaryPodProduct(input));
|
|
1451
|
+
} catch (error) {
|
|
1452
|
+
return err(producerError(input, error));
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
function createOrdinaryAssetOutputProducer(kind) {
|
|
1457
|
+
return { ...ordinaryAssetOutputProducer, kind };
|
|
1458
|
+
}
|
|
1459
|
+
var sceneAssetOutputProducer = {
|
|
1460
|
+
kind: "scene",
|
|
1461
|
+
version: "scene-pack/2",
|
|
1462
|
+
produce(input) {
|
|
1463
|
+
try {
|
|
1464
|
+
return ok(sceneProduct(input));
|
|
1465
|
+
} catch (error) {
|
|
1466
|
+
return err(producerError(input, error));
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1470
|
+
function createStandardAssetOutputProducerRegistry() {
|
|
1471
|
+
const registry = new AssetOutputProducerRegistry();
|
|
1472
|
+
registry.register(materialAssetOutputProducer);
|
|
1473
|
+
registry.register(meshAssetOutputProducer);
|
|
1474
|
+
registry.register(sceneAssetOutputProducer);
|
|
1475
|
+
for (const kind of [
|
|
1476
|
+
"texture",
|
|
1477
|
+
"equirect",
|
|
1478
|
+
"sampler",
|
|
1479
|
+
"font",
|
|
1480
|
+
"render-pipeline",
|
|
1481
|
+
"tileset",
|
|
1482
|
+
"video",
|
|
1483
|
+
"skeleton",
|
|
1484
|
+
"skin",
|
|
1485
|
+
"animation-clip",
|
|
1486
|
+
"animation-graph",
|
|
1487
|
+
"audio",
|
|
1488
|
+
"particle-effect"
|
|
1489
|
+
]) {
|
|
1490
|
+
registry.register(createOrdinaryAssetOutputProducer(kind));
|
|
1491
|
+
}
|
|
1492
|
+
return registry;
|
|
1493
|
+
}
|
|
1494
|
+
function stable2(value) {
|
|
1495
|
+
if (ArrayBuffer.isView(value)) {
|
|
1496
|
+
return `${value.constructor.name}:${JSON.stringify(Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)))}`;
|
|
1497
|
+
}
|
|
1498
|
+
if (Array.isArray(value)) return `[${value.map(stable2).join(",")}]`;
|
|
1499
|
+
if (value !== null && typeof value === "object") {
|
|
1500
|
+
const record2 = value;
|
|
1501
|
+
return `{${Object.keys(record2).sort().map((key) => `${JSON.stringify(key)}:${stable2(record2[key])}`).join(",")}}`;
|
|
1502
|
+
}
|
|
1503
|
+
return JSON.stringify(value) ?? "null";
|
|
1504
|
+
}
|
|
1505
|
+
async function assetDigest(asset) {
|
|
1506
|
+
const bytes2 = new TextEncoder().encode(stable2(asset));
|
|
1507
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes2);
|
|
1508
|
+
return `sha256:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
1509
|
+
}
|
|
1510
|
+
function cycleError(stack, owner, guid) {
|
|
1511
|
+
const cycleStart = stack.indexOf(owner);
|
|
1512
|
+
const cycle = [...stack.slice(cycleStart), owner];
|
|
1513
|
+
return {
|
|
1514
|
+
code: "pack-source-build-cycle",
|
|
1515
|
+
expected: "an acyclic graph of ScriptablePack content dependencies",
|
|
1516
|
+
actual: cycle.join(" -> "),
|
|
1517
|
+
hint: "break one content read edge or convert it to a reference-only dependency",
|
|
1518
|
+
retryable: false,
|
|
1519
|
+
recoveryActions: ["inspect-content-dependency-graph", "edit-source"],
|
|
1520
|
+
detail: { sourcePath: owner, sourceKey: guid, incomingRefs: cycle }
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
function missingOutputError(owner, guid) {
|
|
1524
|
+
return {
|
|
1525
|
+
code: "pack-source-output-invalid",
|
|
1526
|
+
expected: `owner ${owner} to stage every declared output including ${guid}`,
|
|
1527
|
+
hint: "return one output for every GUID declared by the staged owner",
|
|
1528
|
+
detail: { missingGuids: [guid], unexpectedSourceKeys: [], kindMismatches: [] }
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
function createScriptablePackStagedAssetSnapshotSource(options) {
|
|
1532
|
+
const ownerByGuid = /* @__PURE__ */ new Map();
|
|
1533
|
+
for (const owner of options.owners) {
|
|
1534
|
+
if (owner.id.trim().length === 0) throw new TypeError("staged owner id must be non-empty");
|
|
1535
|
+
for (const guid of owner.guids) {
|
|
1536
|
+
const key = AssetGuid.format(guid).toLowerCase();
|
|
1537
|
+
const existing = ownerByGuid.get(key);
|
|
1538
|
+
if (existing !== void 0) {
|
|
1539
|
+
throw new TypeError(`staged GUID ${key} is owned by both ${existing.id} and ${owner.id}`);
|
|
1540
|
+
}
|
|
1541
|
+
ownerByGuid.set(key, owner);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
1545
|
+
const builds = /* @__PURE__ */ new Map();
|
|
1546
|
+
const sourceFor = (stack) => ({
|
|
1547
|
+
async readByGuid(guid) {
|
|
1548
|
+
const key = AssetGuid.format(guid).toLowerCase();
|
|
1549
|
+
const cached = snapshots.get(key);
|
|
1550
|
+
if (cached !== void 0) return ok(structuredClone(cached));
|
|
1551
|
+
const owner = ownerByGuid.get(key);
|
|
1552
|
+
if (owner === void 0) {
|
|
1553
|
+
if (options.fallback !== void 0) return options.fallback.readByGuid(guid);
|
|
1554
|
+
return err(
|
|
1555
|
+
new AssetError({
|
|
1556
|
+
code: "asset-not-imported",
|
|
1557
|
+
expected: "a staged local owner or explicit prebuilt fallback for the requested GUID",
|
|
1558
|
+
hint: "declare the local ScriptablePack output or configure a prebuilt asset authority"
|
|
1559
|
+
})
|
|
1560
|
+
);
|
|
1561
|
+
}
|
|
1562
|
+
if (stack.includes(owner.id)) return err(cycleError(stack, owner.id, key));
|
|
1563
|
+
let building = builds.get(owner.id);
|
|
1564
|
+
if (building === void 0) {
|
|
1565
|
+
building = (async () => {
|
|
1566
|
+
const built2 = await owner.build(sourceFor([...stack, owner.id]));
|
|
1567
|
+
if (!built2.ok) {
|
|
1568
|
+
builds.delete(owner.id);
|
|
1569
|
+
return built2;
|
|
1570
|
+
}
|
|
1571
|
+
const next = /* @__PURE__ */ new Map();
|
|
1572
|
+
for (const output of built2.value) {
|
|
1573
|
+
const outputGuid = AssetGuid.format(output.guid).toLowerCase();
|
|
1574
|
+
if (ownerByGuid.get(outputGuid) !== owner) {
|
|
1575
|
+
builds.delete(owner.id);
|
|
1576
|
+
return err(missingOutputError(owner.id, outputGuid));
|
|
1577
|
+
}
|
|
1578
|
+
next.set(outputGuid, {
|
|
1579
|
+
asset: structuredClone(output.asset),
|
|
1580
|
+
generation: options.generation,
|
|
1581
|
+
digest: output.digest ?? await assetDigest(output.asset)
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
for (const declared of owner.guids) {
|
|
1585
|
+
const declaredGuid = AssetGuid.format(declared).toLowerCase();
|
|
1586
|
+
if (!next.has(declaredGuid)) {
|
|
1587
|
+
builds.delete(owner.id);
|
|
1588
|
+
return err(missingOutputError(owner.id, declaredGuid));
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
for (const [outputGuid, snapshot] of next) snapshots.set(outputGuid, snapshot);
|
|
1592
|
+
return ok(void 0);
|
|
1593
|
+
})();
|
|
1594
|
+
builds.set(owner.id, building);
|
|
1595
|
+
}
|
|
1596
|
+
const built = await building;
|
|
1597
|
+
if (!built.ok) return built;
|
|
1598
|
+
const staged = snapshots.get(key);
|
|
1599
|
+
return staged === void 0 ? err(missingOutputError(owner.id, key)) : ok(structuredClone(staged));
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
return sourceFor([]);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
export { AssetOutputProducerRegistry, ImporterRegistry, SHADER_RESERVED_IMPORTER_KEY, buildScriptablePack, createMaterialImportProduct, createScriptablePackStagedAssetSnapshotSource, createStandardAssetOutputProducerRegistry, finalizeImportProducts, materialAssetOutputProducer, materialImportProductReady, meshAssetOutputProducer, normaliseForPack, packMeshBinV4, runImport, sceneAssetOutputProducer };
|
|
1606
|
+
//# sourceMappingURL=index.mjs.map
|
|
1607
|
+
//# sourceMappingURL=index.mjs.map
|