@carbonenginejs/runtime-resource 0.12.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/CjsResMan.js +393 -29
- package/dist/CjsResMan.js.map +1 -1
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +165 -118
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js +182 -0
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +7 -113
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectRecords.js +258 -66
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js +197 -0
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -0
- package/dist/format/effect/effectBodyInventory.js +146 -0
- package/dist/format/effect/effectBodyInventory.js.map +1 -0
- package/dist/format/effect/effectPermutationGraph.js +13 -13
- package/dist/format/effect/effectPermutationGraph.js.map +1 -1
- package/dist/format/index.js +4 -4
- package/dist/formats/black/CjsBlackFormat.js +19 -1
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/bnk/CjsBnkFormat.js +28 -9
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/busNodes.js +252 -0
- package/dist/formats/bnk/core/busNodes.js.map +1 -0
- package/dist/formats/bnk/core/effectNodes.js +147 -0
- package/dist/formats/bnk/core/effectNodes.js.map +1 -0
- package/dist/formats/bnk/core/eventAction.js +135 -24
- package/dist/formats/bnk/core/eventAction.js.map +1 -1
- package/dist/formats/bnk/core/globalSettings.js +215 -0
- package/dist/formats/bnk/core/globalSettings.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +37 -5
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +43 -19
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +28 -7
- package/dist/formats/bnk/core/nodeBase.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +40 -1
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dxbc/CjsDxbcFormat.js +45 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -1
- package/dist/formats/dxbc/core/disassemble.js +240 -0
- package/dist/formats/dxbc/core/disassemble.js.map +1 -0
- package/dist/formats/gltf/CjsGltfFormat.js +1 -39
- package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
- package/dist/formats/gltf/core/helpers.js +1 -21
- package/dist/formats/gltf/core/helpers.js.map +1 -1
- package/dist/formats/hlsl/CjsHlslFormat.js +0 -21
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +118 -49
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js +128 -0
- package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -0
- package/dist/formats/hlsl/core/localLightFamily.js +133 -0
- package/dist/formats/hlsl/core/localLightFamily.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +79 -73
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +8 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +11 -691
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -1
- package/dist/formats/index.js +4 -2
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/obj/CjsObjFormat.js +1 -22
- package/dist/formats/obj/CjsObjFormat.js.map +1 -1
- package/dist/formats/obj/core/helpers.js +1 -21
- package/dist/formats/obj/core/helpers.js.map +1 -1
- package/dist/formats/pickle/CjsPickleFormat.js +214 -0
- package/dist/formats/pickle/CjsPickleFormat.js.map +1 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +551 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -0
- package/dist/formats/pickle/index.js +2 -0
- package/dist/formats/pickle/index.js.map +1 -0
- package/dist/formats/red/core/redGraph.js +11 -8
- package/dist/formats/red/core/redGraph.js.map +1 -1
- package/dist/formats/stl/CjsStlFormat.js +1 -46
- package/dist/formats/stl/CjsStlFormat.js.map +1 -1
- package/dist/formats/stl/core/helpers.js +1 -21
- package/dist/formats/stl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +33 -55
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -1
- package/dist/formats/webgl/core/buildGlslEffectContainer.js +70 -0
- package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +216 -108
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +1 -1
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +166 -24
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +63 -5
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/packedLightFixups.js +98 -0
- package/dist/formats/webgl/core/glsl/packedLightFixups.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBlock.js +552 -0
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js +243 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -0
- package/dist/formats/webgl/core/{cewgCompleteness.js → glslEffectCompleteness.js} +12 -8
- package/dist/formats/webgl/core/glslEffectCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +33 -172
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js +122 -0
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js +249 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js +15 -15
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +37 -145
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/core/{cewgpu/CewgpuContainer.js → carbonWebgpu/CarbonWebgpuContainer.js} +13 -27
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/containerViews.js +1 -1
- package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/validateContainer.js +4 -4
- package/dist/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +18 -18
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/errors.js +1 -1
- package/dist/formats/webgpu/core/errors.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +22 -22
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +11 -15
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffectSelection.js +1 -1
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +23 -23
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +6 -6
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/yaml/CjsYamlFormat.js +3 -3
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +4 -6
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +27 -1
- package/dist/formats/yaml/core/helpers.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/resource/CjsLoadingObject.js +19 -0
- package/dist/resource/CjsLoadingObject.js.map +1 -0
- package/dist/resource/CjsResource.js +4 -0
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/ResourceHandlerMode.js +14 -0
- package/dist/resource/ResourceHandlerMode.js.map +1 -0
- package/dist/resource/index.js +2 -0
- package/dist/resource/index.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +118 -213
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +37 -15
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +37 -29
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +39 -34
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +51 -30
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +45 -25
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +51 -17
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +219 -88
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +28 -18
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +96 -39
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/reflection/carbonRecordFields.js +159 -0
- package/dist/resource/shader/reflection/carbonRecordFields.js.map +1 -0
- package/dist/resource/shader/reflection/shaderStage.js +22 -0
- package/dist/resource/shader/reflection/shaderStage.js.map +1 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +68 -10
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/worker/CjsResManMainThreadLoader.js +9 -7
- package/dist/worker/CjsResManMainThreadLoader.js.map +1 -1
- package/dist/worker/CjsResManWorker.js +5 -4
- package/dist/worker/CjsResManWorker.js.map +1 -1
- package/dist/worker/CjsResManWorkerLoader.js +9 -6
- package/dist/worker/CjsResManWorkerLoader.js.map +1 -1
- package/docs/README.md +2 -2
- package/docs/architecture.md +12 -3
- package/docs/concepts/resource-lifecycle.md +9 -8
- package/docs/concepts/shader-resource-model.md +14 -17
- package/docs/concepts/writing-an-engine-adapter.md +1 -1
- package/docs/formats/README.md +4 -2
- package/docs/formats/carbon-effect-container.md +127 -26
- package/docs/formats/dxbc/architecture.md +1 -1
- package/docs/formats/dxbc/reference/api.md +28 -0
- package/docs/formats/hlsl/README.md +3 -3
- package/docs/formats/hlsl/architecture.md +8 -9
- package/docs/formats/hlsl/guides/hydrating-json-output.md +3 -5
- package/docs/formats/hlsl/guides/reading-effects.md +5 -1
- package/docs/formats/hlsl/reference/advanced-analysis.md +20 -25
- package/docs/formats/hlsl/reference/api.md +0 -7
- package/docs/formats/hlsl/reference/json-graph.md +1 -4
- package/docs/formats/pickle.md +82 -0
- package/docs/formats/webgl/README.md +71 -13
- package/docs/formats/webgl/architecture.md +16 -17
- package/docs/formats/webgl/carbon-constant-layouts.md +3 -3
- package/docs/formats/webgl/decl-io.md +3 -3
- package/docs/formats/webgl/memory-structured.md +27 -8
- package/docs/formats/webgl/texture-sample.md +1 -1
- package/docs/formats/webgpu/README.md +3 -3
- package/docs/formats/webgpu/architecture.md +5 -6
- package/docs/formats/webgpu/formats/{cewgpu.md → carbon-webgpu.md} +10 -11
- package/docs/formats/webgpu/guides/effect-packaging.md +6 -8
- package/docs/formats/webgpu/reference/api.md +11 -12
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +11 -8
- package/docs/formats/wwise.md +63 -2
- package/docs/reference/classes/core.md +10 -0
- package/docs/reference/classes/formats.md +40 -48
- package/docs/reference/classes/resources.md +2 -2
- package/docs/reference/queues.md +88 -4
- package/docs/reference/workers.md +7 -0
- package/package.json +61 -61
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +0 -372
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +0 -1
- package/dist/format/effect/effectReflectionPackage.js +0 -636
- package/dist/format/effect/effectReflectionPackage.js.map +0 -1
- package/dist/formats/hlsl/core/HlslReader.js +0 -16
- package/dist/formats/hlsl/core/HlslReader.js.map +0 -1
- package/dist/formats/hlsl/core/portableReflection.js +0 -848
- package/dist/formats/hlsl/core/portableReflection.js.map +0 -1
- package/dist/formats/hlsl/portable.js +0 -2
- package/dist/formats/hlsl/portable.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +0 -340
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +0 -104
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +0 -1
- package/dist/formats/webgl/core/cewg/binary.js +0 -19
- package/dist/formats/webgl/core/cewg/binary.js.map +0 -1
- package/dist/formats/webgl/core/cewgCompleteness.js.map +0 -1
- package/dist/formats/webgl/core/effectPackageValidation.js +0 -331
- package/dist/formats/webgl/core/effectPackageValidation.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +0 -1
- package/dist/resource/shader/portable.js +0 -33
- package/dist/resource/shader/portable.js.map +0 -1
- package/docs/formats/hlsl/reference/portable-reflection.md +0 -141
- package/docs/formats/webgl/effect-reflection.md +0 -127
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Groups a Carbon effect's permutation rows onto the distinct bodies they
|
|
3
|
+
* address.
|
|
4
|
+
*
|
|
5
|
+
* A container's offset table is dense and positionally indexed, and rows alias:
|
|
6
|
+
* several permutations routinely point at one compiled body. Anything that walks
|
|
7
|
+
* bodies rather than permutations needs that grouping first, or it does the same
|
|
8
|
+
* work once per row — a 4,096-row file with 128 distinct bodies would translate
|
|
9
|
+
* each of them thirty-two times.
|
|
10
|
+
*
|
|
11
|
+
* This is pure container geometry: offsets, byte ranges, and byte equality. It
|
|
12
|
+
* carried no reflection when it lived beside the effect-reflection document, and
|
|
13
|
+
* it outlived that document for exactly that reason.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const EFFECT_VERSION = 15;
|
|
17
|
+
const EFFECT_BODY_COUNT_MAX = 0x10000;
|
|
18
|
+
const UINT32_MAX = 0xffffffff;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validates one offset-table row against the file it indexes.
|
|
22
|
+
*
|
|
23
|
+
* @param {object} record Offset-table row.
|
|
24
|
+
* @param {number} permutationIndex Position of the row in the table.
|
|
25
|
+
* @param {number} sourceByteLength Size of the source file.
|
|
26
|
+
* @returns {{offset:number, byteLength:number}} Normalized source record.
|
|
27
|
+
*/
|
|
28
|
+
function normalizeBodySourceRecord(record, permutationIndex, sourceByteLength) {
|
|
29
|
+
const end = record?.offset + record?.size;
|
|
30
|
+
if (!record || record.index !== permutationIndex || !Number.isSafeInteger(record.offset) || record.offset < 0 || record.offset > UINT32_MAX || !Number.isSafeInteger(record.size) || record.size < 1 || record.size > UINT32_MAX || !Number.isSafeInteger(end) || record.end !== end || !Number.isSafeInteger(sourceByteLength) || end > sourceByteLength) {
|
|
31
|
+
throw new Error(`Effect body index ${permutationIndex} disagrees with its source record`);
|
|
32
|
+
}
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
offset: record.offset,
|
|
35
|
+
byteLength: record.size
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Rejects source records that partially overlap.
|
|
41
|
+
*
|
|
42
|
+
* Rows may alias exactly — that is how a container shares one body between
|
|
43
|
+
* permutations — but a partial overlap means two bodies claim the same bytes
|
|
44
|
+
* with different extents, which no reading of the file can satisfy.
|
|
45
|
+
*
|
|
46
|
+
* @param {Array<{offset:number, byteLength:number}>} sourceRecords Records.
|
|
47
|
+
*/
|
|
48
|
+
function validateDisjointBodySourceRecords(sourceRecords) {
|
|
49
|
+
const unique = new Map();
|
|
50
|
+
for (const record of sourceRecords) {
|
|
51
|
+
const key = `${record.offset}:${record.byteLength}`;
|
|
52
|
+
if (!unique.has(key)) unique.set(key, record);
|
|
53
|
+
}
|
|
54
|
+
const ordered = Array.from(unique.values()).sort((left, right) => left.offset - right.offset || left.byteLength - right.byteLength);
|
|
55
|
+
for (let index = 1; index < ordered.length; index += 1) {
|
|
56
|
+
const previous = ordered[index - 1];
|
|
57
|
+
const current = ordered[index];
|
|
58
|
+
if (current.offset < previous.offset + previous.byteLength) {
|
|
59
|
+
throw new Error("Effect body source records partially overlap");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A cheap content key, used only to shrink the set of byte-equality comparisons.
|
|
66
|
+
*
|
|
67
|
+
* @param {Uint8Array} bytes Body bytes.
|
|
68
|
+
* @returns {string} Length-qualified FNV-1a fingerprint.
|
|
69
|
+
*/
|
|
70
|
+
function fingerprintBytes(bytes) {
|
|
71
|
+
let hash = 0x811c9dc5;
|
|
72
|
+
for (const value of bytes) {
|
|
73
|
+
hash = Math.imul(hash ^ value, 0x01000193) >>> 0;
|
|
74
|
+
}
|
|
75
|
+
return `${bytes.byteLength}:${hash.toString(16).padStart(8, "0")}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Byte equality. The fingerprint narrows candidates; this decides.
|
|
80
|
+
*
|
|
81
|
+
* @param {Uint8Array} left Left bytes.
|
|
82
|
+
* @param {Uint8Array} right Right bytes.
|
|
83
|
+
* @returns {boolean} Whether the two are byte-identical.
|
|
84
|
+
*/
|
|
85
|
+
function bytesEqual(left, right) {
|
|
86
|
+
return left.byteLength === right.byteLength && left.every((value, index) => value === right[index]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Groups permutation rows onto the distinct bodies they address.
|
|
91
|
+
*
|
|
92
|
+
* Rows are grouped by byte range first, then by content: two ranges holding
|
|
93
|
+
* identical bytes are one body, which is what makes the count "unique bodies"
|
|
94
|
+
* rather than "distinct offsets".
|
|
95
|
+
*
|
|
96
|
+
* @param {object} effectRes Loaded version-15 effect resource.
|
|
97
|
+
* @returns {ReadonlyArray<object>} Frozen groups, each with its representative
|
|
98
|
+
* permutation index, source record, and every variant that shares it.
|
|
99
|
+
*/
|
|
100
|
+
function enumerateUniqueEffectBodies(effectRes) {
|
|
101
|
+
if (!effectRes || typeof effectRes !== "object" || effectRes.m_version !== EFFECT_VERSION || !(effectRes.m_data instanceof Uint8Array) || !Array.isArray(effectRes.m_offsets) || effectRes.m_offsetCount !== effectRes.m_offsets.length || !effectRes.m_offsets.length) {
|
|
102
|
+
throw new TypeError("Effect body inventory requires a loaded version-15 effect resource");
|
|
103
|
+
}
|
|
104
|
+
if (effectRes.m_offsets.length > EFFECT_BODY_COUNT_MAX) {
|
|
105
|
+
throw new RangeError(`Effect body inventory exceeds ${EFFECT_BODY_COUNT_MAX} records`);
|
|
106
|
+
}
|
|
107
|
+
const sourceRecords = effectRes.m_offsets.map((record, permutationIndex) => normalizeBodySourceRecord(record, permutationIndex, effectRes.m_data.byteLength));
|
|
108
|
+
validateDisjointBodySourceRecords(sourceRecords);
|
|
109
|
+
const groups = [];
|
|
110
|
+
const groupByRange = new Map();
|
|
111
|
+
const groupsByFingerprint = new Map();
|
|
112
|
+
for (const [permutationIndex, sourceRecord] of sourceRecords.entries()) {
|
|
113
|
+
const rangeKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;
|
|
114
|
+
let group = groupByRange.get(rangeKey);
|
|
115
|
+
if (!group) {
|
|
116
|
+
const bytes = effectRes.m_data.subarray(sourceRecord.offset, sourceRecord.offset + sourceRecord.byteLength);
|
|
117
|
+
const fingerprint = fingerprintBytes(bytes);
|
|
118
|
+
const candidates = groupsByFingerprint.get(fingerprint) ?? [];
|
|
119
|
+
group = candidates.find(candidate => bytesEqual(candidate.bytes, bytes));
|
|
120
|
+
if (!group) {
|
|
121
|
+
group = {
|
|
122
|
+
bytes,
|
|
123
|
+
permutationIndex,
|
|
124
|
+
sourceRecord,
|
|
125
|
+
variants: []
|
|
126
|
+
};
|
|
127
|
+
candidates.push(group);
|
|
128
|
+
groupsByFingerprint.set(fingerprint, candidates);
|
|
129
|
+
groups.push(group);
|
|
130
|
+
}
|
|
131
|
+
groupByRange.set(rangeKey, group);
|
|
132
|
+
}
|
|
133
|
+
group.variants.push({
|
|
134
|
+
permutationIndex,
|
|
135
|
+
sourceRecord
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return Object.freeze(groups.map(group => Object.freeze({
|
|
139
|
+
permutationIndex: group.permutationIndex,
|
|
140
|
+
sourceRecord: group.sourceRecord,
|
|
141
|
+
variants: Object.freeze(group.variants.map(variant => Object.freeze(variant)))
|
|
142
|
+
})));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { enumerateUniqueEffectBodies };
|
|
146
|
+
//# sourceMappingURL=effectBodyInventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectBodyInventory.js","sources":["../../../../src/format/effect/effectBodyInventory.js"],"sourcesContent":["/**\n * Groups a Carbon effect's permutation rows onto the distinct bodies they\n * address.\n *\n * A container's offset table is dense and positionally indexed, and rows alias:\n * several permutations routinely point at one compiled body. Anything that walks\n * bodies rather than permutations needs that grouping first, or it does the same\n * work once per row — a 4,096-row file with 128 distinct bodies would translate\n * each of them thirty-two times.\n *\n * This is pure container geometry: offsets, byte ranges, and byte equality. It\n * carried no reflection when it lived beside the effect-reflection document, and\n * it outlived that document for exactly that reason.\n */\n\nconst EFFECT_VERSION = 15;\nconst EFFECT_BODY_COUNT_MAX = 0x10000;\nconst UINT32_MAX = 0xffffffff;\n\n/**\n * Validates one offset-table row against the file it indexes.\n *\n * @param {object} record Offset-table row.\n * @param {number} permutationIndex Position of the row in the table.\n * @param {number} sourceByteLength Size of the source file.\n * @returns {{offset:number, byteLength:number}} Normalized source record.\n */\nfunction normalizeBodySourceRecord(record, permutationIndex, sourceByteLength)\n{\n const end = record?.offset + record?.size;\n if (!record || record.index !== permutationIndex\n || !Number.isSafeInteger(record.offset) || record.offset < 0\n || record.offset > UINT32_MAX\n || !Number.isSafeInteger(record.size) || record.size < 1\n || record.size > UINT32_MAX\n || !Number.isSafeInteger(end)\n || record.end !== end\n || !Number.isSafeInteger(sourceByteLength)\n || end > sourceByteLength)\n {\n throw new Error(\n `Effect body index ${permutationIndex} disagrees with its source record`\n );\n }\n return Object.freeze({\n offset: record.offset,\n byteLength: record.size\n });\n}\n\n/**\n * Rejects source records that partially overlap.\n *\n * Rows may alias exactly — that is how a container shares one body between\n * permutations — but a partial overlap means two bodies claim the same bytes\n * with different extents, which no reading of the file can satisfy.\n *\n * @param {Array<{offset:number, byteLength:number}>} sourceRecords Records.\n */\nfunction validateDisjointBodySourceRecords(sourceRecords)\n{\n const unique = new Map();\n for (const record of sourceRecords)\n {\n const key = `${record.offset}:${record.byteLength}`;\n if (!unique.has(key)) unique.set(key, record);\n }\n const ordered = Array.from(unique.values()).sort((left, right) =>\n left.offset - right.offset || left.byteLength - right.byteLength);\n for (let index = 1; index < ordered.length; index += 1)\n {\n const previous = ordered[index - 1];\n const current = ordered[index];\n if (current.offset < previous.offset + previous.byteLength)\n {\n throw new Error(\n \"Effect body source records partially overlap\"\n );\n }\n }\n}\n\n/**\n * A cheap content key, used only to shrink the set of byte-equality comparisons.\n *\n * @param {Uint8Array} bytes Body bytes.\n * @returns {string} Length-qualified FNV-1a fingerprint.\n */\nfunction fingerprintBytes(bytes)\n{\n let hash = 0x811c9dc5;\n for (const value of bytes)\n {\n hash = Math.imul(hash ^ value, 0x01000193) >>> 0;\n }\n return `${bytes.byteLength}:${hash.toString(16).padStart(8, \"0\")}`;\n}\n\n/**\n * Byte equality. The fingerprint narrows candidates; this decides.\n *\n * @param {Uint8Array} left Left bytes.\n * @param {Uint8Array} right Right bytes.\n * @returns {boolean} Whether the two are byte-identical.\n */\nfunction bytesEqual(left, right)\n{\n return left.byteLength === right.byteLength\n && left.every((value, index) => value === right[index]);\n}\n\n/**\n * Groups permutation rows onto the distinct bodies they address.\n *\n * Rows are grouped by byte range first, then by content: two ranges holding\n * identical bytes are one body, which is what makes the count \"unique bodies\"\n * rather than \"distinct offsets\".\n *\n * @param {object} effectRes Loaded version-15 effect resource.\n * @returns {ReadonlyArray<object>} Frozen groups, each with its representative\n * permutation index, source record, and every variant that shares it.\n */\nexport function enumerateUniqueEffectBodies(effectRes)\n{\n if (!effectRes || typeof effectRes !== \"object\"\n || effectRes.m_version !== EFFECT_VERSION\n || !(effectRes.m_data instanceof Uint8Array)\n || !Array.isArray(effectRes.m_offsets)\n || effectRes.m_offsetCount !== effectRes.m_offsets.length\n || !effectRes.m_offsets.length)\n {\n throw new TypeError(\n \"Effect body inventory requires a loaded version-15 effect resource\"\n );\n }\n if (effectRes.m_offsets.length > EFFECT_BODY_COUNT_MAX)\n {\n throw new RangeError(\n `Effect body inventory exceeds ${EFFECT_BODY_COUNT_MAX} records`\n );\n }\n\n const sourceRecords = effectRes.m_offsets.map((record, permutationIndex) =>\n normalizeBodySourceRecord(\n record,\n permutationIndex,\n effectRes.m_data.byteLength\n ));\n validateDisjointBodySourceRecords(sourceRecords);\n\n const groups = [];\n const groupByRange = new Map();\n const groupsByFingerprint = new Map();\n for (const [ permutationIndex, sourceRecord ] of sourceRecords.entries())\n {\n const rangeKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n let group = groupByRange.get(rangeKey);\n if (!group)\n {\n const bytes = effectRes.m_data.subarray(\n sourceRecord.offset,\n sourceRecord.offset + sourceRecord.byteLength\n );\n const fingerprint = fingerprintBytes(bytes);\n const candidates = groupsByFingerprint.get(fingerprint) ?? [];\n group = candidates.find((candidate) =>\n bytesEqual(candidate.bytes, bytes));\n if (!group)\n {\n group = {\n bytes,\n permutationIndex,\n sourceRecord,\n variants: []\n };\n candidates.push(group);\n groupsByFingerprint.set(fingerprint, candidates);\n groups.push(group);\n }\n groupByRange.set(rangeKey, group);\n }\n group.variants.push({\n permutationIndex,\n sourceRecord\n });\n }\n\n return Object.freeze(groups.map((group) => Object.freeze({\n permutationIndex: group.permutationIndex,\n sourceRecord: group.sourceRecord,\n variants: Object.freeze(group.variants.map((variant) =>\n Object.freeze(variant)))\n })));\n}\n\nexport default enumerateUniqueEffectBodies;\n"],"names":["EFFECT_VERSION","EFFECT_BODY_COUNT_MAX","UINT32_MAX","normalizeBodySourceRecord","record","permutationIndex","sourceByteLength","end","offset","size","index","Number","isSafeInteger","Error","Object","freeze","byteLength","validateDisjointBodySourceRecords","sourceRecords","unique","Map","key","has","set","ordered","Array","from","values","sort","left","right","length","previous","current","fingerprintBytes","bytes","hash","value","Math","imul","toString","padStart","bytesEqual","every","enumerateUniqueEffectBodies","effectRes","m_version","m_data","Uint8Array","isArray","m_offsets","m_offsetCount","TypeError","RangeError","map","groups","groupByRange","groupsByFingerprint","sourceRecord","entries","rangeKey","group","get","subarray","fingerprint","candidates","find","candidate","variants","push","variant"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,cAAc,GAAG,EAAE;AACzB,MAAMC,qBAAqB,GAAG,OAAO;AACrC,MAAMC,UAAU,GAAG,UAAU;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAACC,MAAM,EAAEC,gBAAgB,EAAEC,gBAAgB,EAC7E;EACI,MAAMC,GAAG,GAAGH,MAAM,EAAEI,MAAM,GAAGJ,MAAM,EAAEK,IAAI;AACzC,EAAA,IAAI,CAACL,MAAM,IAAIA,MAAM,CAACM,KAAK,KAAKL,gBAAgB,IACzC,CAACM,MAAM,CAACC,aAAa,CAACR,MAAM,CAACI,MAAM,CAAC,IAAIJ,MAAM,CAACI,MAAM,GAAG,CAAC,IACzDJ,MAAM,CAACI,MAAM,GAAGN,UAAU,IAC1B,CAACS,MAAM,CAACC,aAAa,CAACR,MAAM,CAACK,IAAI,CAAC,IAAIL,MAAM,CAACK,IAAI,GAAG,CAAC,IACrDL,MAAM,CAACK,IAAI,GAAGP,UAAU,IACxB,CAACS,MAAM,CAACC,aAAa,CAACL,GAAG,CAAC,IAC1BH,MAAM,CAACG,GAAG,KAAKA,GAAG,IAClB,CAACI,MAAM,CAACC,aAAa,CAACN,gBAAgB,CAAC,IACvCC,GAAG,GAAGD,gBAAgB,EAC7B;AACI,IAAA,MAAM,IAAIO,KAAK,CACX,CAAA,kBAAA,EAAqBR,gBAAgB,mCACzC,CAAC;AACL,EAAA;EACA,OAAOS,MAAM,CAACC,MAAM,CAAC;IACjBP,MAAM,EAAEJ,MAAM,CAACI,MAAM;IACrBQ,UAAU,EAAEZ,MAAM,CAACK;AACvB,GAAC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,iCAAiCA,CAACC,aAAa,E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MAAM,CAACc,IAAI,CAACR,KAAK,CAAC;AACtB,MAAA;AACAL,MAAAA,YAAY,CAACjC,GAAG,CAACqC,QAAQ,EAAEC,KAAK,CAAC;AACrC,IAAA;AACAA,IAAAA,KAAK,CAACO,QAAQ,CAACC,IAAI,CAAC;MAChBhE,gBAAgB;AAChBqD,MAAAA;AACJ,KAAC,CAAC;AACN,EAAA;AAEA,EAAA,OAAO5C,MAAM,CAACC,MAAM,CAACwC,MAAM,CAACD,GAAG,CAAEO,KAAK,IAAK/C,MAAM,CAACC,MAAM,CAAC;IACrDV,gBAAgB,EAAEwD,KAAK,CAACxD,gBAAgB;IACxCqD,YAAY,EAAEG,KAAK,CAACH,YAAY;AAChCU,IAAAA,QAAQ,EAAEtD,MAAM,CAACC,MAAM,CAAC8C,KAAK,CAACO,QAAQ,CAACd,GAAG,CAAEgB,OAAO,IAC/CxD,MAAM,CAACC,MAAM,CAACuD,OAAO,CAAC,CAAC;GAC9B,CAAC,CAAC,CAAC;AACR;;;;"}
|
|
@@ -94,21 +94,21 @@ function buildEffectPermutationGraph(effectRes) {
|
|
|
94
94
|
*/
|
|
95
95
|
function validateEffectPermutationGraph(graph, options = {}) {
|
|
96
96
|
if (!graph || typeof graph !== "object" || Array.isArray(graph) || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION || !graph.coverage || typeof graph.coverage !== "object" || Array.isArray(graph.coverage) || graph.coverage.permutations !== "complete" || graph.coverage.bodies !== "identity-only" || graph.coverage.reflection !== "absent") {
|
|
97
|
-
throw new Error("
|
|
97
|
+
throw new Error("PGRF schema or coverage is unsupported");
|
|
98
98
|
}
|
|
99
99
|
const axes = validateGraphAxes(graph.axes);
|
|
100
100
|
const permutationCount = permutationProduct(axes);
|
|
101
101
|
if (!Array.isArray(graph.variants) || graph.variants.length !== permutationCount) {
|
|
102
|
-
throw new Error("
|
|
102
|
+
throw new Error("PGRF must contain one variant per Cartesian permutation");
|
|
103
103
|
}
|
|
104
104
|
if (!Array.isArray(graph.bodies) || !graph.bodies.length || graph.bodies.length > graph.variants.length) {
|
|
105
|
-
throw new Error("
|
|
105
|
+
throw new Error("PGRF bodies are malformed");
|
|
106
106
|
}
|
|
107
107
|
const bodies = new Map();
|
|
108
108
|
const bodyDigests = new Set();
|
|
109
109
|
for (const [bodyIndex, body] of graph.bodies.entries()) {
|
|
110
110
|
if (!body || typeof body !== "object" || Array.isArray(body) || typeof body.key !== "string" || !body.key || body.key !== body.key.trim() || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1 || body.byteLength > UINT32_MAX || typeof body.sha256 !== "string" || !SHA256.test(body.sha256) || bodies.has(body.key) || bodyDigests.has(body.sha256)) {
|
|
111
|
-
throw new Error(`
|
|
111
|
+
throw new Error(`PGRF body ${bodyIndex} is malformed or duplicated`);
|
|
112
112
|
}
|
|
113
113
|
bodyDigests.add(body.sha256);
|
|
114
114
|
bodies.set(body.key, {
|
|
@@ -121,26 +121,26 @@ function validateEffectPermutationGraph(graph, options = {}) {
|
|
|
121
121
|
for (const [permutationIndex, variant] of graph.variants.entries()) {
|
|
122
122
|
const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);
|
|
123
123
|
if (!variant || typeof variant !== "object" || Array.isArray(variant) || variant.permutationIndex !== permutationIndex || !Array.isArray(variant.optionIndices) || variant.optionIndices.length !== expectedOptionIndices.length || variant.optionIndices.some((value, index) => value !== expectedOptionIndices[index]) || typeof variant.bodyKey !== "string" || !bodies.has(variant.bodyKey)) {
|
|
124
|
-
throw new Error(`
|
|
124
|
+
throw new Error(`PGRF variant ${permutationIndex} is malformed`);
|
|
125
125
|
}
|
|
126
126
|
const sourceRecord = validateGraphSourceRecord(variant.sourceRecord, permutationIndex, options.sourceByteLength);
|
|
127
127
|
const body = bodies.get(variant.bodyKey);
|
|
128
128
|
if (sourceRecord.byteLength !== body.byteLength) {
|
|
129
|
-
throw new Error(`
|
|
129
|
+
throw new Error(`PGRF variant ${permutationIndex} body length disagrees`);
|
|
130
130
|
}
|
|
131
131
|
const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;
|
|
132
132
|
const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);
|
|
133
133
|
if (existingBodyKey && existingBodyKey !== variant.bodyKey) {
|
|
134
|
-
throw new Error(`
|
|
134
|
+
throw new Error(`PGRF source record ${recordKey} maps to multiple bodies`);
|
|
135
135
|
}
|
|
136
136
|
bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);
|
|
137
137
|
sourceRecords.push(sourceRecord);
|
|
138
138
|
body.references += 1;
|
|
139
139
|
}
|
|
140
|
-
validateDisjointSourceRecords(sourceRecords, "
|
|
140
|
+
validateDisjointSourceRecords(sourceRecords, "PGRF source body records partially overlap");
|
|
141
141
|
for (const [bodyKey, body] of bodies) {
|
|
142
142
|
if (!body.references) {
|
|
143
|
-
throw new Error(`
|
|
143
|
+
throw new Error(`PGRF body ${bodyKey} is unreferenced`);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
return Object.freeze({
|
|
@@ -177,18 +177,18 @@ function normalizeAxes(value) {
|
|
|
177
177
|
}
|
|
178
178
|
function validateGraphAxes(value) {
|
|
179
179
|
if (!Array.isArray(value) || value.length > UINT8_MAX) {
|
|
180
|
-
throw new Error("
|
|
180
|
+
throw new Error("PGRF axes must be an array");
|
|
181
181
|
}
|
|
182
182
|
const names = new Set();
|
|
183
183
|
return value.map((axis, index) => {
|
|
184
184
|
if (!axis || typeof axis !== "object" || Array.isArray(axis) || axis.index !== index || typeof axis.name !== "string" || !axis.name || axis.name !== axis.name.trim() || names.has(axis.name) || !Array.isArray(axis.options) || !axis.options.length || axis.options.length > UINT8_MAX || !Number.isSafeInteger(axis.defaultOption) || axis.defaultOption < 0 || axis.defaultOption >= axis.options.length || typeof axis.description !== "string" || !Number.isSafeInteger(axis.type) || axis.type < 0 || axis.type > UINT8_MAX) {
|
|
185
|
-
throw new Error(`
|
|
185
|
+
throw new Error(`PGRF axis ${index} is malformed or duplicated`);
|
|
186
186
|
}
|
|
187
187
|
names.add(axis.name);
|
|
188
188
|
const options = new Set();
|
|
189
189
|
for (const option of axis.options) {
|
|
190
190
|
if (typeof option !== "string" || !option || option !== option.trim() || options.has(option)) {
|
|
191
|
-
throw new Error(`
|
|
191
|
+
throw new Error(`PGRF axis ${index} options are malformed`);
|
|
192
192
|
}
|
|
193
193
|
options.add(option);
|
|
194
194
|
}
|
|
@@ -227,7 +227,7 @@ function validateGraphSourceRecord(record, permutationIndex, sourceByteLength) {
|
|
|
227
227
|
const byteLength = record?.byteLength;
|
|
228
228
|
const end = offset + byteLength;
|
|
229
229
|
if (!record || typeof record !== "object" || Array.isArray(record) || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX || !Number.isSafeInteger(byteLength) || byteLength < 1 || byteLength > UINT32_MAX || !Number.isSafeInteger(end) || sourceByteLength !== undefined && (!Number.isSafeInteger(sourceByteLength) || sourceByteLength < 1 || end > sourceByteLength)) {
|
|
230
|
-
throw new Error(`
|
|
230
|
+
throw new Error(`PGRF variant ${permutationIndex} source record is malformed`);
|
|
231
231
|
}
|
|
232
232
|
return record;
|
|
233
233
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectPermutationGraph.js","sources":["../../../../src/format/effect/effectPermutationGraph.js"],"sourcesContent":["import { sha256Bytes } from \"./sha256.js\";\n\nexport const EFFECT_PERMUTATION_GRAPH_FORMAT = \"CJS_EFFECT_PERMUTATION_GRAPH\";\nexport const EFFECT_PERMUTATION_GRAPH_VERSION = 1;\nexport const EFFECT_PERMUTATION_GRAPH_CHUNK = \"PGRF\";\n\nconst SHA256 = /^[0-9a-f]{64}$/u;\nconst UINT8_MAX = 0xff;\nconst UINT32_MAX = 0xffffffff;\nconst MAX_EFFECT_PERMUTATIONS = 0x10000;\n\n/**\n * Build a complete source permutation topology without claiming that every\n * body has portable reflection or backend programs.\n *\n * @param {object} effectRes Raw format-hlsl effect resource.\n * @returns {object} JSON-safe permutation graph.\n */\nexport function buildEffectPermutationGraph(effectRes)\n{\n if (!effectRes || typeof effectRes !== \"object\")\n {\n throw new TypeError(\"Effect permutation graph requires a decoded effect resource\");\n }\n\n const sourceBytes = effectRes.m_data;\n if (!(sourceBytes instanceof Uint8Array))\n {\n throw new TypeError(\"Effect permutation graph requires exact source bytes\");\n }\n\n const axes = normalizeAxes(effectRes.m_permutations);\n const permutationCount = permutationProduct(axes);\n const offsets = effectRes.m_offsets;\n if (!Array.isArray(offsets) || offsets.length !== permutationCount\n || effectRes.m_offsetCount !== offsets.length)\n {\n throw new Error(\n \"Effect permutation graph requires one source body record per permutation\"\n );\n }\n\n const sourceRecords = offsets.map((record, permutationIndex) =>\n normalizeSourceRecord(\n record,\n permutationIndex,\n sourceBytes.byteLength\n ));\n validateDisjointSourceRecords(\n sourceRecords,\n \"Effect permutation source body records partially overlap\"\n );\n\n const bodies = [];\n const bodyCandidatesByDigest = new Map();\n const bodyBySourceRecord = new Map();\n const variants = sourceRecords.map((sourceRecord, permutationIndex) =>\n {\n const sourceRecordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n let body = bodyBySourceRecord.get(sourceRecordKey);\n if (!body)\n {\n const bodyBytes = sourceBytes.subarray(\n sourceRecord.offset,\n sourceRecord.offset + sourceRecord.byteLength\n );\n const digest = sha256Bytes(bodyBytes);\n body = (bodyCandidatesByDigest.get(digest) || [])\n .find((candidate) => bytesEqual(candidate.bytes, bodyBytes));\n if (!body && bodyCandidatesByDigest.has(digest))\n {\n throw new Error(\n \"Effect permutation graph body SHA-256 collision detected\"\n );\n }\n if (!body)\n {\n body = {\n bytes: bodyBytes,\n record: Object.freeze({\n key: `body${bodies.length}`,\n byteLength: bodyBytes.byteLength,\n sha256: digest\n })\n };\n bodyCandidatesByDigest.set(digest, [ body ]);\n bodies.push(body.record);\n }\n bodyBySourceRecord.set(sourceRecordKey, body);\n }\n\n return Object.freeze({\n permutationIndex,\n optionIndices: Object.freeze(decodeOptionIndices(\n permutationIndex,\n axes\n )),\n bodyKey: body.record.key,\n sourceRecord\n });\n });\n\n const graph = Object.freeze({\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\n coverage: Object.freeze({\n permutations: \"complete\",\n bodies: \"identity-only\",\n reflection: \"absent\"\n }),\n axes: Object.freeze(axes),\n variants: Object.freeze(variants),\n bodies: Object.freeze(bodies)\n });\n\n validateEffectPermutationGraph(graph, {\n sourceByteLength: sourceBytes.byteLength\n });\n return graph;\n}\n\n/**\n * Validate a source permutation graph independently of the original effect\n * bytes.\n *\n * @param {object} graph Candidate graph.\n * @param {object} [options] Optional source-envelope limits.\n * @param {number} [options.sourceByteLength] Exact enclosing source byte length.\n * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.\n */\nexport function validateEffectPermutationGraph(graph, options = {})\n{\n if (!graph || typeof graph !== \"object\" || Array.isArray(graph)\n || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT\n || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION\n || !graph.coverage || typeof graph.coverage !== \"object\"\n || Array.isArray(graph.coverage)\n || graph.coverage.permutations !== \"complete\"\n || graph.coverage.bodies !== \"identity-only\"\n || graph.coverage.reflection !== \"absent\")\n {\n throw new Error(\"CEWGPU PGRF schema or coverage is unsupported\");\n }\n\n const axes = validateGraphAxes(graph.axes);\n const permutationCount = permutationProduct(axes);\n if (!Array.isArray(graph.variants)\n || graph.variants.length !== permutationCount)\n {\n throw new Error(\n \"CEWGPU PGRF must contain one variant per Cartesian permutation\"\n );\n }\n if (!Array.isArray(graph.bodies)\n || !graph.bodies.length\n || graph.bodies.length > graph.variants.length)\n {\n throw new Error(\"CEWGPU PGRF bodies are malformed\");\n }\n\n const bodies = new Map();\n const bodyDigests = new Set();\n for (const [ bodyIndex, body ] of graph.bodies.entries())\n {\n if (!body || typeof body !== \"object\" || Array.isArray(body)\n || typeof body.key !== \"string\" || !body.key\n || body.key !== body.key.trim()\n || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1\n || body.byteLength > UINT32_MAX\n || typeof body.sha256 !== \"string\" || !SHA256.test(body.sha256)\n || bodies.has(body.key)\n || bodyDigests.has(body.sha256))\n {\n throw new Error(`CEWGPU PGRF body ${bodyIndex} is malformed or duplicated`);\n }\n bodyDigests.add(body.sha256);\n bodies.set(body.key, {\n byteLength: body.byteLength,\n references: 0\n });\n }\n\n const bodyKeyBySourceRecord = new Map();\n const sourceRecords = [];\n for (const [ permutationIndex, variant ] of graph.variants.entries())\n {\n const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);\n if (!variant || typeof variant !== \"object\" || Array.isArray(variant)\n || variant.permutationIndex !== permutationIndex\n || !Array.isArray(variant.optionIndices)\n || variant.optionIndices.length !== expectedOptionIndices.length\n || variant.optionIndices.some((value, index) =>\n value !== expectedOptionIndices[index])\n || typeof variant.bodyKey !== \"string\"\n || !bodies.has(variant.bodyKey))\n {\n throw new Error(`CEWGPU PGRF variant ${permutationIndex} is malformed`);\n }\n\n const sourceRecord = validateGraphSourceRecord(\n variant.sourceRecord,\n permutationIndex,\n options.sourceByteLength\n );\n const body = bodies.get(variant.bodyKey);\n if (sourceRecord.byteLength !== body.byteLength)\n {\n throw new Error(\n `CEWGPU PGRF variant ${permutationIndex} body length disagrees`\n );\n }\n\n const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);\n if (existingBodyKey && existingBodyKey !== variant.bodyKey)\n {\n throw new Error(\n `CEWGPU PGRF source record ${recordKey} maps to multiple bodies`\n );\n }\n bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);\n sourceRecords.push(sourceRecord);\n body.references += 1;\n }\n\n validateDisjointSourceRecords(\n sourceRecords,\n \"CEWGPU PGRF source body records partially overlap\"\n );\n\n for (const [ bodyKey, body ] of bodies)\n {\n if (!body.references)\n {\n throw new Error(`CEWGPU PGRF body ${bodyKey} is unreferenced`);\n }\n }\n\n return Object.freeze({\n permutationCount,\n uniqueBodyCount: bodies.size\n });\n}\n\nfunction normalizeAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new TypeError(\"Effect permutation axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\"\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim()\n || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`Effect permutation axis ${index} is malformed`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(\n `Effect permutation axis ${axis.name} has malformed options`\n );\n }\n options.add(option);\n }\n\n return Object.freeze({\n index,\n name: axis.name,\n options: Object.freeze(axis.options.slice()),\n defaultOption: axis.defaultOption,\n description: axis.description,\n type: axis.type\n });\n });\n}\n\nfunction validateGraphAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new Error(\"CEWGPU PGRF axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\" || Array.isArray(axis)\n || axis.index !== index\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim() || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`CEWGPU PGRF axis ${index} is malformed or duplicated`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(`CEWGPU PGRF axis ${index} options are malformed`);\n }\n options.add(option);\n }\n return axis;\n });\n}\n\nfunction permutationProduct(axes)\n{\n let product = 1;\n for (const axis of axes)\n {\n product *= axis.options.length;\n if (!Number.isSafeInteger(product) || product < 1\n || product > MAX_EFFECT_PERMUTATIONS)\n {\n throw new Error(\n `Effect permutation count above the implementation limit `\n + `${MAX_EFFECT_PERMUTATIONS} is not supported`\n );\n }\n }\n return product;\n}\n\nfunction decodeOptionIndices(permutationIndex, axes)\n{\n let value = permutationIndex;\n return axes.map((axis) =>\n {\n const optionIndex = value % axis.options.length;\n value = Math.floor(value / axis.options.length);\n return optionIndex;\n });\n}\n\nfunction normalizeSourceRecord(record, permutationIndex, sourceByteLength)\n{\n if (!record || typeof record !== \"object\"\n || record.index !== permutationIndex\n || !Number.isSafeInteger(record.offset) || record.offset < 0\n || record.offset > UINT32_MAX\n || !Number.isSafeInteger(record.size) || record.size < 1\n || record.size > UINT32_MAX\n || !Number.isSafeInteger(record.end)\n || record.end !== record.offset + record.size\n || record.end > sourceByteLength)\n {\n throw new Error(\n `Effect permutation ${permutationIndex} has an invalid source body record`\n );\n }\n\n return Object.freeze({\n offset: record.offset,\n byteLength: record.size\n });\n}\n\nfunction validateGraphSourceRecord(record, permutationIndex, sourceByteLength)\n{\n const offset = record?.offset;\n const byteLength = record?.byteLength;\n const end = offset + byteLength;\n if (!record || typeof record !== \"object\" || Array.isArray(record)\n || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX\n || !Number.isSafeInteger(byteLength) || byteLength < 1\n || byteLength > UINT32_MAX\n || !Number.isSafeInteger(end)\n || (sourceByteLength !== undefined\n && (!Number.isSafeInteger(sourceByteLength)\n || sourceByteLength < 1\n || end > sourceByteLength)))\n {\n throw new Error(\n `CEWGPU PGRF variant ${permutationIndex} source record is malformed`\n );\n }\n return record;\n}\n\nfunction validateDisjointSourceRecords(records, message)\n{\n const uniqueRanges = new Map();\n for (const record of records)\n {\n const key = `${record.offset}:${record.byteLength}`;\n if (!uniqueRanges.has(key))\n {\n uniqueRanges.set(key, {\n offset: record.offset,\n end: record.offset + record.byteLength\n });\n }\n }\n\n const orderedRanges = Array.from(uniqueRanges.values())\n .sort((left, right) => left.offset - right.offset || left.end - right.end);\n for (let index = 1; index < orderedRanges.length; index += 1)\n {\n if (orderedRanges[index].offset < orderedRanges[index - 1].end)\n {\n throw new Error(message);\n }\n }\n}\n\nfunction bytesEqual(left, right)\n{\n return left.byteLength === right.byteLength\n && left.every((value, index) => value === right[index]);\n}\n"],"names":["EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","EFFECT_PERMUTATION_GRAPH_CHUNK","SHA256","UINT8_MAX","UINT32_MAX","MAX_EFFECT_PERMUTATIONS","buildEffectPermutationGraph","effectRes","TypeError","sourceBytes","m_data","Uint8Array","axes","normalizeAxes","m_permutations","permutationCount","permutationProduct","offsets","m_offsets","Array","isArray","length","m_offsetCount","Error","sourceRecords","map","record","permutationIndex","normalizeSourceRecord","byteLength","validateDisjointSourceRecords","bodies","bodyCandidatesByDigest","Map","bodyBySourceRecord","variants","sourceRecord","sourceRecordKey","offset","body","get","bodyBytes","subarray","digest","sha256Bytes","find","candidate","bytesEqual","bytes","has","Object","freeze","key","sha256","set","push","optionIndices","decodeOptionIndices","bodyKey","graph","format","formatVersion","coverage","permutations","reflection","validateEffectPermutationGraph","sourceByteLength","options","validateGraphAxes","bodyDigests","Set","bodyIndex","entries","trim","Number","isSafeInteger","test","add","references","bodyKeyBySourceRecord","variant","expectedOptionIndices","some","value","index","validateGraphSourceRecord","recordKey","existingBodyKey","uniqueBodyCount","size","names","axis","name","defaultOption","description","type","option","slice","product","optionIndex","Math","floor","end","undefined","records","message","uniqueRanges","orderedRanges","from","values","sort","left","right","every"],"mappings":";;AAEO,MAAMA,+BAA+B,GAAG;AACxC,MAAMC,gCAAgC,GAAG;AACzC,MAAMC,8BAA8B,GAAG;AAE9C,MAAMC,MAAM,GAAG,iBAAiB;AAChC,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,uBAAuB,GAAG,OAAO;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,2BAA2BA,CAACC,SAAS,EACrD;AACI,EAAA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAC/C;AACI,IAAA,MAAM,IAAIC,SAAS,CAAC,6DAA6D,CAAC;AACtF,EAAA;AAEA,EAAA,MAAMC,WAAW,GAAGF,SAAS,CAACG,MAAM;AACpC,EAAA,IAAI,EAAED,WAAW,YAAYE,UAAU,CAAC,EACxC;AACI,IAAA,MAAM,IAAIH,SAAS,CAAC,sDAAsD,CAAC;AAC/E,EAAA;AAEA,EAAA,MAAMI,IAAI,GAAGC,aAAa,CAACN,SAAS,CAACO,cAAc,CAAC;AACpD,EAAA,MAAMC,gBAAgB,GAAGC,kBAAkB,CAACJ,IAAI,CAAC;AACjD,EAAA,MAAMK,OAAO,GAAGV,SAAS,CAACW,SAAS;EACnC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,IAAIA,OAAO,CAACI,MAAM,KAAKN,gBAAgB,IAC3DR,SAAS,CAACe,aAAa,KAAKL,OAAO,CAACI,MAAM,EACjD;AACI,IAAA,MAAM,IAAIE,KAAK,CACX,0EACJ,CAAC;AACL,EAAA;EAEA,MAAMC,aAAa,GAAGP,OAAO,CAACQ,GAAG,CAAC,CAACC,MAAM,EAAEC,gBAAgB,KACvDC,qBAAqB,CACjBF,MAAM,EACNC,gBAAgB,EAChBlB,WAAW,CAACoB,UAChB,CAAC,CAAC;AACNC,EAAAA,6BAA6B,CACzBN,aAAa,EACb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KAAK,CAACnF,UAAU,IACpCkF,IAAI,CAACE,KAAK,CAAC,CAAC9B,KAAK,EAAEC,KAAK,KAAKD,KAAK,KAAK6B,KAAK,CAAC5B,KAAK,CAAC,CAAC;AAC/D;;;;"}
|
|
1
|
+
{"version":3,"file":"effectPermutationGraph.js","sources":["../../../../src/format/effect/effectPermutationGraph.js"],"sourcesContent":["import { sha256Bytes } from \"./sha256.js\";\n\nexport const EFFECT_PERMUTATION_GRAPH_FORMAT = \"CJS_EFFECT_PERMUTATION_GRAPH\";\nexport const EFFECT_PERMUTATION_GRAPH_VERSION = 1;\nexport const EFFECT_PERMUTATION_GRAPH_CHUNK = \"PGRF\";\n\nconst SHA256 = /^[0-9a-f]{64}$/u;\nconst UINT8_MAX = 0xff;\nconst UINT32_MAX = 0xffffffff;\nconst MAX_EFFECT_PERMUTATIONS = 0x10000;\n\n/**\n * Build a complete source permutation topology without claiming that every\n * body has portable reflection or backend programs.\n *\n * @param {object} effectRes Raw format-hlsl effect resource.\n * @returns {object} JSON-safe permutation graph.\n */\nexport function buildEffectPermutationGraph(effectRes)\n{\n if (!effectRes || typeof effectRes !== \"object\")\n {\n throw new TypeError(\"Effect permutation graph requires a decoded effect resource\");\n }\n\n const sourceBytes = effectRes.m_data;\n if (!(sourceBytes instanceof Uint8Array))\n {\n throw new TypeError(\"Effect permutation graph requires exact source bytes\");\n }\n\n const axes = normalizeAxes(effectRes.m_permutations);\n const permutationCount = permutationProduct(axes);\n const offsets = effectRes.m_offsets;\n if (!Array.isArray(offsets) || offsets.length !== permutationCount\n || effectRes.m_offsetCount !== offsets.length)\n {\n throw new Error(\n \"Effect permutation graph requires one source body record per permutation\"\n );\n }\n\n const sourceRecords = offsets.map((record, permutationIndex) =>\n normalizeSourceRecord(\n record,\n permutationIndex,\n sourceBytes.byteLength\n ));\n validateDisjointSourceRecords(\n sourceRecords,\n \"Effect permutation source body records partially overlap\"\n );\n\n const bodies = [];\n const bodyCandidatesByDigest = new Map();\n const bodyBySourceRecord = new Map();\n const variants = sourceRecords.map((sourceRecord, permutationIndex) =>\n {\n const sourceRecordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n let body = bodyBySourceRecord.get(sourceRecordKey);\n if (!body)\n {\n const bodyBytes = sourceBytes.subarray(\n sourceRecord.offset,\n sourceRecord.offset + sourceRecord.byteLength\n );\n const digest = sha256Bytes(bodyBytes);\n body = (bodyCandidatesByDigest.get(digest) || [])\n .find((candidate) => bytesEqual(candidate.bytes, bodyBytes));\n if (!body && bodyCandidatesByDigest.has(digest))\n {\n throw new Error(\n \"Effect permutation graph body SHA-256 collision detected\"\n );\n }\n if (!body)\n {\n body = {\n bytes: bodyBytes,\n record: Object.freeze({\n key: `body${bodies.length}`,\n byteLength: bodyBytes.byteLength,\n sha256: digest\n })\n };\n bodyCandidatesByDigest.set(digest, [ body ]);\n bodies.push(body.record);\n }\n bodyBySourceRecord.set(sourceRecordKey, body);\n }\n\n return Object.freeze({\n permutationIndex,\n optionIndices: Object.freeze(decodeOptionIndices(\n permutationIndex,\n axes\n )),\n bodyKey: body.record.key,\n sourceRecord\n });\n });\n\n const graph = Object.freeze({\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\n coverage: Object.freeze({\n permutations: \"complete\",\n bodies: \"identity-only\",\n reflection: \"absent\"\n }),\n axes: Object.freeze(axes),\n variants: Object.freeze(variants),\n bodies: Object.freeze(bodies)\n });\n\n validateEffectPermutationGraph(graph, {\n sourceByteLength: sourceBytes.byteLength\n });\n return graph;\n}\n\n/**\n * Validate a source permutation graph independently of the original effect\n * bytes.\n *\n * @param {object} graph Candidate graph.\n * @param {object} [options] Optional source-envelope limits.\n * @param {number} [options.sourceByteLength] Exact enclosing source byte length.\n * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.\n */\nexport function validateEffectPermutationGraph(graph, options = {})\n{\n if (!graph || typeof graph !== \"object\" || Array.isArray(graph)\n || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT\n || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION\n || !graph.coverage || typeof graph.coverage !== \"object\"\n || Array.isArray(graph.coverage)\n || graph.coverage.permutations !== \"complete\"\n || graph.coverage.bodies !== \"identity-only\"\n || graph.coverage.reflection !== \"absent\")\n {\n throw new Error(\"PGRF schema or coverage is unsupported\");\n }\n\n const axes = validateGraphAxes(graph.axes);\n const permutationCount = permutationProduct(axes);\n if (!Array.isArray(graph.variants)\n || graph.variants.length !== permutationCount)\n {\n throw new Error(\n \"PGRF must contain one variant per Cartesian permutation\"\n );\n }\n if (!Array.isArray(graph.bodies)\n || !graph.bodies.length\n || graph.bodies.length > graph.variants.length)\n {\n throw new Error(\"PGRF bodies are malformed\");\n }\n\n const bodies = new Map();\n const bodyDigests = new Set();\n for (const [ bodyIndex, body ] of graph.bodies.entries())\n {\n if (!body || typeof body !== \"object\" || Array.isArray(body)\n || typeof body.key !== \"string\" || !body.key\n || body.key !== body.key.trim()\n || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1\n || body.byteLength > UINT32_MAX\n || typeof body.sha256 !== \"string\" || !SHA256.test(body.sha256)\n || bodies.has(body.key)\n || bodyDigests.has(body.sha256))\n {\n throw new Error(`PGRF body ${bodyIndex} is malformed or duplicated`);\n }\n bodyDigests.add(body.sha256);\n bodies.set(body.key, {\n byteLength: body.byteLength,\n references: 0\n });\n }\n\n const bodyKeyBySourceRecord = new Map();\n const sourceRecords = [];\n for (const [ permutationIndex, variant ] of graph.variants.entries())\n {\n const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);\n if (!variant || typeof variant !== \"object\" || Array.isArray(variant)\n || variant.permutationIndex !== permutationIndex\n || !Array.isArray(variant.optionIndices)\n || variant.optionIndices.length !== expectedOptionIndices.length\n || variant.optionIndices.some((value, index) =>\n value !== expectedOptionIndices[index])\n || typeof variant.bodyKey !== \"string\"\n || !bodies.has(variant.bodyKey))\n {\n throw new Error(`PGRF variant ${permutationIndex} is malformed`);\n }\n\n const sourceRecord = validateGraphSourceRecord(\n variant.sourceRecord,\n permutationIndex,\n options.sourceByteLength\n );\n const body = bodies.get(variant.bodyKey);\n if (sourceRecord.byteLength !== body.byteLength)\n {\n throw new Error(\n `PGRF variant ${permutationIndex} body length disagrees`\n );\n }\n\n const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);\n if (existingBodyKey && existingBodyKey !== variant.bodyKey)\n {\n throw new Error(\n `PGRF source record ${recordKey} maps to multiple bodies`\n );\n }\n bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);\n sourceRecords.push(sourceRecord);\n body.references += 1;\n }\n\n validateDisjointSourceRecords(\n sourceRecords,\n \"PGRF source body records partially overlap\"\n );\n\n for (const [ bodyKey, body ] of bodies)\n {\n if (!body.references)\n {\n throw new Error(`PGRF body ${bodyKey} is unreferenced`);\n }\n }\n\n return Object.freeze({\n permutationCount,\n uniqueBodyCount: bodies.size\n });\n}\n\nfunction normalizeAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new TypeError(\"Effect permutation axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\"\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim()\n || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`Effect permutation axis ${index} is malformed`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(\n `Effect permutation axis ${axis.name} has malformed options`\n );\n }\n options.add(option);\n }\n\n return Object.freeze({\n index,\n name: axis.name,\n options: Object.freeze(axis.options.slice()),\n defaultOption: axis.defaultOption,\n description: axis.description,\n type: axis.type\n });\n });\n}\n\nfunction validateGraphAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new Error(\"PGRF axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\" || Array.isArray(axis)\n || axis.index !== index\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim() || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`PGRF axis ${index} is malformed or duplicated`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(`PGRF axis ${index} options are malformed`);\n }\n options.add(option);\n }\n return axis;\n });\n}\n\nfunction permutationProduct(axes)\n{\n let product = 1;\n for (const axis of axes)\n {\n product *= axis.options.length;\n if (!Number.isSafeInteger(product) || product < 1\n || product > MAX_EFFECT_PERMUTATIONS)\n {\n throw new Error(\n `Effect permutation count above the implementation limit `\n + `${MAX_EFFECT_PERMUTATIONS} is not supported`\n );\n }\n }\n return product;\n}\n\nfunction decodeOptionIndices(permutationIndex, axes)\n{\n let value = permutationIndex;\n return axes.map((axis) =>\n {\n const optionIndex = value % axis.options.length;\n value = Math.floor(value / axis.options.length);\n return optionIndex;\n });\n}\n\nfunction normalizeSourceRecord(record, permutationIndex, sourceByteLength)\n{\n if (!record || typeof record !== \"object\"\n || record.index !== permutationIndex\n || !Number.isSafeInteger(record.offset) || record.offset < 0\n || record.offset > UINT32_MAX\n || !Number.isSafeInteger(record.size) || record.size < 1\n || record.size > UINT32_MAX\n || !Number.isSafeInteger(record.end)\n || record.end !== record.offset + record.size\n || record.end > sourceByteLength)\n {\n throw new Error(\n `Effect permutation ${permutationIndex} has an invalid source body record`\n );\n }\n\n return Object.freeze({\n offset: record.offset,\n byteLength: record.size\n });\n}\n\nfunction validateGraphSourceRecord(record, permutationIndex, sourceByteLength)\n{\n const offset = record?.offset;\n const byteLength = record?.byteLength;\n const end = offset + byteLength;\n if (!record || typeof record !== \"object\" || Array.isArray(record)\n || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX\n || !Number.isSafeInteger(byteLength) || byteLength < 1\n || byteLength > UINT32_MAX\n || !Number.isSafeInteger(end)\n || (sourceByteLength !== undefined\n && (!Number.isSafeInteger(sourceByteLength)\n || sourceByteLength < 1\n || end > sourceByteLength)))\n {\n throw new Error(\n `PGRF variant ${permutationIndex} source record is malformed`\n );\n }\n return record;\n}\n\nfunction validateDisjointSourceRecords(records, message)\n{\n const uniqueRanges = new Map();\n for (const record of records)\n {\n const key = `${record.offset}:${record.byteLength}`;\n if (!uniqueRanges.has(key))\n {\n uniqueRanges.set(key, {\n offset: record.offset,\n end: record.offset + record.byteLength\n });\n }\n }\n\n const orderedRanges = Array.from(uniqueRanges.values())\n .sort((left, right) => left.offset - right.offset || left.end - right.end);\n for (let index = 1; index < orderedRanges.length; index += 1)\n {\n if (orderedRanges[index].offset < orderedRanges[index - 1].end)\n {\n throw new Error(message);\n }\n }\n}\n\nfunction bytesEqual(left, right)\n{\n return left.byteLength === right.byteLength\n && left.every((value, index) => value === right[index]);\n}\n"],"names":["EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","EFFECT_PERMUTATION_GRAPH_CHUNK","SHA256","UINT8_MAX","UINT32_MAX","MAX_EFFECT_PERMUTATIONS","buildEffectPermutationGraph","effectRes","TypeError","sourceBytes","m_data","Uint8Array","axes","normalizeAxes","m_permutations","permutationCount","permutationProduct","offsets","m_offsets","Array","isArray","length","m_offsetCount","Error","sourceRecords","map","record","permutationIndex","normalizeSourceRecord","byteLength","validateDisjointSourceRecords","bodies","bodyCandidatesByDigest","Map","bodyBySourceRecord","variants","sourceRecord","sourceRecordKey","offset","body","get","bodyBytes","subarray","digest","sha256Bytes","find","candidate","bytesEqual","bytes","has","Object","freeze","key","sha256","set","push","optionIndices","decodeOptionIndices","bodyKey","graph","format","formatVersion","coverage","permutations","reflection","validateEffectPermutationGraph","sourceByteLength","options","validateGraphAxes","bodyDigests","Set","bodyIndex","entries","trim","Number","isSafeInteger","test","add","references","bodyKeyBySourceRecord","variant","expectedOptionIndices","some","value","index","validateGraphSourceRecord","recordKey","existingBodyKey","uniqueBodyCount","size","names","axis","name","defaultOption","description","type","option","slice","product","optionIndex","Math","floor","end","undefined","records","message","uniqueRanges","orderedRanges","from","values","sort","left","right","every"],"mappings":";;AAEO,MAAMA,+BAA+B,GAAG;AACxC,MAAMC,gCAAgC,GAAG;AACzC,MAAMC,8BAA8B,GAAG;AAE9C,MAAMC,MAAM,GAAG,iBAAiB;AAChC,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,uBAAuB,GAAG,OAAO;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,2BAA2BA,CAACC,SAAS,EACrD;AACI,EAAA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAC/C;AACI,IAAA,MAAM,IAAIC,SAAS,CAAC,6DAA6D,CAAC;AACtF,EAAA;AAEA,EAAA,MAAMC,WAAW,GAAGF,SAAS,CAACG,MAAM;AACpC,EAAA,IAAI,EAAED,WAAW,YAAYE,UAAU,CAAC,EACxC;AACI,IAAA,MAAM,IAAIH,SAAS,CAAC,sDAAsD,CAAC;AAC/E,EAAA;AAEA,EAAA,MAAMI,IAAI,GAAGC,aAAa,CAACN,SAAS,CAACO,cAAc,CAAC;AACpD,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KAAK,CAAC1E,MAAM,IAAIyE,IAAI,CAACT,GAAG,GAAGU,KAAK,CAACV,GAAG,CAAC;AAC9E,EAAA,KAAK,IAAIlB,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGuB,aAAa,CAACtF,MAAM,EAAE+D,KAAK,IAAI,CAAC,EAC5D;AACI,IAAA,IAAIuB,aAAa,CAACvB,KAAK,CAAC,CAAC9C,MAAM,GAAGqE,aAAa,CAACvB,KAAK,GAAG,CAAC,CAAC,CAACkB,GAAG,EAC9D;AACI,MAAA,MAAM,IAAI/E,KAAK,CAACkF,OAAO,CAAC;AAC5B,IAAA;AACJ,EAAA;AACJ;AAEA,SAAS1D,UAAUA,CAACgE,IAAI,EAAEC,KAAK,EAC/B;EACI,OAAOD,IAAI,CAAClF,UAAU,KAAKmF,KAAK,CAACnF,UAAU,IACpCkF,IAAI,CAACE,KAAK,CAAC,CAAC9B,KAAK,EAAEC,KAAK,KAAKD,KAAK,KAAK6B,KAAK,CAAC5B,KAAK,CAAC,CAAC;AAC/D;;;;"}
|
package/dist/format/index.js
CHANGED
|
@@ -3,9 +3,9 @@ export { CjsFormatReadError, CjsFormatWriteError } from './CjsFormatError.js';
|
|
|
3
3
|
export { CjsByteReader } from './CjsByteReader.js';
|
|
4
4
|
export { CjsByteWriter } from './CjsByteWriter.js';
|
|
5
5
|
export { CJS_STRING_TABLE_NULL_REFERENCE, CjsStringTable, compareTableBlobs } from './CjsStringTable.js';
|
|
6
|
-
export { CARBON_ANNOTATION_TYPE, CARBON_EFFECT_COUNT_CAPS, CARBON_EFFECT_DATA_VERSION, CARBON_SHADER_CONSTANTS_MAX, collectArena, compareAnnotationNames, internArena, passthroughArena, readEffectDescription, writeEffectDescription } from './carbonEffect/carbonEffectRecords.js';
|
|
7
|
-
export { CARBON_BACKEND_RESOURCE_KIND,
|
|
8
|
-
export {
|
|
9
|
-
export { CARBON_EFFECT_RECORD_BYTES, CARBON_EFFECT_SOURCE_HASH_BYTES, CjsCarbonEffectBodyReader, CjsCarbonEffectReader } from './carbonEffect/CjsCarbonEffectReader.js';
|
|
6
|
+
export { CARBON_ANNOTATION_TYPE, CARBON_EFFECT_COUNT_CAPS, CARBON_EFFECT_DATA_VERSION, CARBON_EFFECT_MIN_DATA_VERSION, CARBON_SHADER_CONSTANTS_MAX, collectArena, compareAnnotationNames, internArena, passthroughArena, readEffectDescription, writeEffectDescription } from './carbonEffect/carbonEffectRecords.js';
|
|
7
|
+
export { CARBON_BACKEND_RESOURCE_KIND, CARBON_BACKEND_VISIBILITY, CARBON_EFFECT_BACKEND_BLOCK_VERSION, readBackendBlock, writeBackendBlock } from './carbonEffect/carbonEffectBackendBlock.js';
|
|
8
|
+
export { CARBON_EFFECT_RECORD_BYTES, CARBON_EFFECT_SOURCE_HASH_BYTES, CjsCarbonEffectBodyReader, CjsCarbonEffectReader, looksLikeCarbonEffectContainer } from './carbonEffect/CjsCarbonEffectReader.js';
|
|
10
9
|
export { CjsCarbonEffectWriter, writeCarbonEffectFile } from './carbonEffect/CjsCarbonEffectWriter.js';
|
|
10
|
+
export { CARBON_BACKEND_TRANSFORM_FAMILY, DETAIL_MAP_ARRAY_DEFAULTS } from './carbonEffect/carbonEffectResourceTransform.js';
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLASS_KEYS } from './core/schema.js';
|
|
2
2
|
import { DEFAULT_VALUES, OUTPUT_JSON, OUTPUT_PAYLOAD, normalizeValues, validateClassKey, validateClass, toJsonValue, OUTPUT_DOCUMENT, OUTPUT_RAW, OUTPUT_RUNTIME } from './core/helpers.js';
|
|
3
|
-
import { CJS_BLACK_FORMAT_ID, CJS_BLACK_EXTENSION,
|
|
3
|
+
import { CJS_BLACK_FOURCC, CJS_BLACK_FORMAT_ID, CJS_BLACK_EXTENSION, CJS_BLACK_VERSION } from './core/blackConstants.js';
|
|
4
4
|
import { CjsBlackReader } from './core/CjsBlackReader.js';
|
|
5
5
|
|
|
6
6
|
const FORMAT_NAME = "CjsBlackFormat";
|
|
@@ -255,6 +255,19 @@ class CjsBlackFormat {
|
|
|
255
255
|
return toJsonValue(value);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Performs the bounded Black content discriminator used by ordered object
|
|
260
|
+
* routes. Magic selects the Black reader; version and body failures remain
|
|
261
|
+
* that reader's errors and are never reinterpreted as Red/YAML.
|
|
262
|
+
*
|
|
263
|
+
* @param {ArrayBuffer|ArrayBufferView} input Candidate source bytes.
|
|
264
|
+
* @returns {boolean} True when the little-endian Black magic is present.
|
|
265
|
+
*/
|
|
266
|
+
static isSupported(input) {
|
|
267
|
+
const view = getBlackProbeView(input);
|
|
268
|
+
return Boolean(view && view.byteLength >= 4 && view.getUint32(0, true) === CJS_BLACK_FOURCC);
|
|
269
|
+
}
|
|
270
|
+
|
|
258
271
|
/**
|
|
259
272
|
* Emit targets for this format (canonical frozen enum).
|
|
260
273
|
*/
|
|
@@ -287,6 +300,11 @@ class CjsBlackFormat {
|
|
|
287
300
|
return readerOptions;
|
|
288
301
|
}
|
|
289
302
|
}
|
|
303
|
+
function getBlackProbeView(input) {
|
|
304
|
+
if (input instanceof ArrayBuffer) return new DataView(input);
|
|
305
|
+
if (!ArrayBuffer.isView(input)) return null;
|
|
306
|
+
return new DataView(input.buffer, input.byteOffset, input.byteLength);
|
|
307
|
+
}
|
|
290
308
|
|
|
291
309
|
export { CjsBlackFormat, CjsBlackFormat as default };
|
|
292
310
|
//# sourceMappingURL=CjsBlackFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsBlackFormat.js","sources":["../../../../src/formats/black/CjsBlackFormat.js"],"sourcesContent":["import { CLASS_KEYS } from \"./core/schema.js\";\nimport {\n DEFAULT_VALUES,\n OUTPUT_DOCUMENT,\n OUTPUT_JSON,\n OUTPUT_PAYLOAD,\n OUTPUT_RAW,\n OUTPUT_RUNTIME,\n normalizeValues,\n toJsonValue,\n validateClass,\n validateClassKey\n} from \"./core/helpers.js\";\nimport {\n CJS_BLACK_EXTENSION,\n CJS_BLACK_FORMAT_ID,\n CJS_BLACK_FOURCC,\n CJS_BLACK_VERSION\n} from \"./core/blackConstants.js\";\nimport { CjsBlackReader } from \"./core/CjsBlackReader.js\";\n\nconst FORMAT_NAME = \"CjsBlackFormat\";\n\n/**\n * CarbonEngineJS-facing Black format profile.\n *\n * This package reads public-facing `.black` payload data using CarbonEngineJS\n * canonical schemas or source-shape registries.\n */\nexport class CjsBlackFormat\n{\n\n #emit = DEFAULT_VALUES.emit;\n #schema = DEFAULT_VALUES.schema;\n #readerOptions = {};\n #classes = {};\n\n /**\n * Plain payload outputs can be decoded in a browser worker. Document and\n * runtime outputs retain class identity and therefore stay on the caller\n * thread.\n */\n static worker = Object.freeze({\n module: import.meta.url,\n exportName: \"CjsBlackFormat\",\n outputTypes: Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]),\n defaultOutput: OUTPUT_JSON\n });\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\n this.#emit = values.emit;\n this.#schema = values.schema;\n this.#classes = values.classes;\n this.#readerOptions = CjsBlackFormat.copyReaderOptions(values);\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n schema: this.#schema,\n ...this.#readerOptions,\n classes: this.#classes\n }, options, CLASS_KEYS, FORMAT_NAME);\n }\n\n /**\n * Set multiple runtime class constructors for this profile.\n *\n * @param {object} [classes] Map of Black class names to constructors.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set one node-class constructor for this profile.\n *\n * @param {string} type Black class name.\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetClass(type, Class)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n if (Class === null || Class === undefined)\n {\n delete this.#classes[type];\n return this;\n }\n\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\n this.#classes = { ...this.#classes, [type]: Class };\n return this;\n }\n\n /**\n * Get a configured runtime class constructor.\n *\n * @param {string} type Black class name.\n * @returns {Function|undefined} The registered constructor, if any.\n */\n GetClass(type)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n return this.#classes[type];\n }\n\n /**\n * Whether this format profile has a constructor registered for a node key.\n *\n * @param {string} type Node class key.\n * @returns {boolean} True when a constructor is registered.\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Read Black data with this profile's values.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Public payload output by default.\n */\n Read(input, options = {})\n {\n return CjsBlackFormat.read(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as a neutral document graph for diagnostics.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} CarbonEngineJS document graph.\n */\n ReadDocument(input, options = {})\n {\n return CjsBlackFormat.readDocument(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as runtime objects or plain source-shaped objects.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Runtime read result.\n */\n ReadRuntime(input, options = {})\n {\n return CjsBlackFormat.readRuntime(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as compact public payload JSON.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Public payload output.\n */\n ReadPayload(input, options = {})\n {\n return CjsBlackFormat.readPayload(input, this.GetValues(options));\n }\n\n /**\n * Inspect Black data with this profile's values.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return CjsBlackFormat.inspect(input, this.GetValues(options));\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static one-shot read. Static methods use camelCase by convention.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Format output.\n */\n static read(input, options = {})\n {\n const values = normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME);\n if (values.emit === OUTPUT_DOCUMENT || values.emit === OUTPUT_RAW) return CjsBlackFormat.readDocument(input, values);\n if (values.emit === OUTPUT_RUNTIME) return CjsBlackFormat.readRuntime(input, values);\n return CjsBlackFormat.readPayload(input, values);\n }\n\n /**\n * Static one-shot document read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} CarbonEngineJS document graph.\n */\n static readDocument(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadDocument();\n }\n\n /**\n * Static one-shot runtime read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Runtime read result.\n */\n static readRuntime(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRuntime();\n }\n\n /**\n * Static one-shot public payload read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Public payload output.\n */\n static readPayload(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadPayload();\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).Inspect();\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n RAW: OUTPUT_RAW,\n DOCUMENT: OUTPUT_DOCUMENT,\n PAYLOAD: OUTPUT_PAYLOAD,\n RUNTIME: OUTPUT_RUNTIME\n });\n static CLASS_KEYS = CLASS_KEYS;\n static id = CJS_BLACK_FORMAT_ID;\n static extensions = Object.freeze([CJS_BLACK_EXTENSION]);\n static fourCC = CJS_BLACK_FOURCC;\n static version = CJS_BLACK_VERSION;\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"black\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_DOCUMENT, OUTPUT_PAYLOAD, OUTPUT_RUNTIME ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n\n /** Provides the one-shot Black copy reader options helper entry point. */\n static copyReaderOptions(values)\n {\n const {\n emit: _emit,\n schema: _schema,\n classes: _classes,\n ...readerOptions\n } = values;\n return readerOptions;\n }\n\n}\n\nexport default CjsBlackFormat;\n"],"names":["FORMAT_NAME","CjsBlackFormat","DEFAULT_VALUES","emit","schema","worker","Object","freeze","module","import","meta","url","exportName","outputTypes","OUTPUT_JSON","OUTPUT_PAYLOAD","defaultOutput","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","copyReaderOptions","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","read","ReadDocument","readDocument","ReadRuntime","readRuntime","ReadPayload","readPayload","Inspect","inspect","ToJSON","value","toJsonValue","OUTPUT_DOCUMENT","OUTPUT_RAW","OUTPUT_RUNTIME","CjsBlackReader","toJSON","Output","JSON","RAW","DOCUMENT","PAYLOAD","RUNTIME","id","CJS_BLACK_FORMAT_ID","extensions","CJS_BLACK_EXTENSION","fourCC","CJS_BLACK_FOURCC","version","CJS_BLACK_VERSION","mediaTypes","inputTypes","debugOutputTypes","_emit","_schema","_classes","readerOptions"],"mappings":";;;;;AAqBA,MAAMA,WAAW,GAAG,gBAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,CAC3B;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;EAC/B,cAAc,GAAG,EAAE;EACnB,QAAQ,GAAG,EAAE;;AAEb;AACJ;AACA;AACA;AACA;AACI,EAAA,OAAOC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC1BC,IAAAA,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,GAAG;AACvBC,IAAAA,UAAU,EAAE,gBAAgB;IAC5BC,WAAW,EAAEP,MAAM,CAACC,MAAM,CAAC,CAAEO,WAAW,EAAEC,cAAc,CAAE,CAAC;AAC3DC,IAAAA,aAAa,EAAEF;AACnB,GAAC,CAAC;;AAEF;AACJ;AACA;AACA;AACA;AACIG,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,MAAME,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACC,SAAS,EAAE,EAAEJ,OAAO,EAAEK,UAAU,EAAEvB,WAAW,CAAC;AAClF,IAAA,IAAI,CAAC,KAAK,GAAGoB,MAAM,CAACjB,IAA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,gBAAgB;EAChC,OAAOC,OAAO,GAAGC,iBAAiB;EAClC,OAAOvC,IAAI,GAAGtB,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;EACvC,OAAO6D,UAAU,GAAG9D,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;EAC7C,OAAO8D,UAAU,GAAG/D,MAAM,CAACC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC;AAC9C,EAAA,OAAOM,WAAW,GAAGP,MAAM,CAACC,MAAM,CAAC,CAAEO,WAAW,EAAEmC,eAAe,EAAElC,cAAc,EAAEoC,cAAc,CAAE,CAAC;EACpG,OAAOmB,gBAAgB,GAAGhE,MAAM,CAACC,MAAM,CAAC,CAAE2C,UAAU,CAAE,CAAC;;AAEvD;EACA,OAAOzB,iBAAiBA,CAACL,MAAM,EAC/B;IACI,MAAM;AACFjB,MAAAA,IAAI,EAAEoE,KAAK;AACXnE,MAAAA,MAAM,EAAEoE,OAAO;AACfhD,MAAAA,OAAO,EAAEiD,QAAQ;MACjB,GAAGC;AACP,KAAC,GAAGtD,MAAM;AACV,IAAA,OAAOsD,aAAa;AACxB,EAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsBlackFormat.js","sources":["../../../../src/formats/black/CjsBlackFormat.js"],"sourcesContent":["import { CLASS_KEYS } from \"./core/schema.js\";\nimport {\n DEFAULT_VALUES,\n OUTPUT_DOCUMENT,\n OUTPUT_JSON,\n OUTPUT_PAYLOAD,\n OUTPUT_RAW,\n OUTPUT_RUNTIME,\n normalizeValues,\n toJsonValue,\n validateClass,\n validateClassKey\n} from \"./core/helpers.js\";\nimport {\n CJS_BLACK_EXTENSION,\n CJS_BLACK_FORMAT_ID,\n CJS_BLACK_FOURCC,\n CJS_BLACK_VERSION\n} from \"./core/blackConstants.js\";\nimport { CjsBlackReader } from \"./core/CjsBlackReader.js\";\n\nconst FORMAT_NAME = \"CjsBlackFormat\";\n\n/**\n * CarbonEngineJS-facing Black format profile.\n *\n * This package reads public-facing `.black` payload data using CarbonEngineJS\n * canonical schemas or source-shape registries.\n */\nexport class CjsBlackFormat\n{\n\n #emit = DEFAULT_VALUES.emit;\n #schema = DEFAULT_VALUES.schema;\n #readerOptions = {};\n #classes = {};\n\n /**\n * Plain payload outputs can be decoded in a browser worker. Document and\n * runtime outputs retain class identity and therefore stay on the caller\n * thread.\n */\n static worker = Object.freeze({\n module: import.meta.url,\n exportName: \"CjsBlackFormat\",\n outputTypes: Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]),\n defaultOutput: OUTPUT_JSON\n });\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\n this.#emit = values.emit;\n this.#schema = values.schema;\n this.#classes = values.classes;\n this.#readerOptions = CjsBlackFormat.copyReaderOptions(values);\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n schema: this.#schema,\n ...this.#readerOptions,\n classes: this.#classes\n }, options, CLASS_KEYS, FORMAT_NAME);\n }\n\n /**\n * Set multiple runtime class constructors for this profile.\n *\n * @param {object} [classes] Map of Black class names to constructors.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set one node-class constructor for this profile.\n *\n * @param {string} type Black class name.\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\n * @returns {CjsBlackFormat} This format profile.\n */\n SetClass(type, Class)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n if (Class === null || Class === undefined)\n {\n delete this.#classes[type];\n return this;\n }\n\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\n this.#classes = { ...this.#classes, [type]: Class };\n return this;\n }\n\n /**\n * Get a configured runtime class constructor.\n *\n * @param {string} type Black class name.\n * @returns {Function|undefined} The registered constructor, if any.\n */\n GetClass(type)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n return this.#classes[type];\n }\n\n /**\n * Whether this format profile has a constructor registered for a node key.\n *\n * @param {string} type Node class key.\n * @returns {boolean} True when a constructor is registered.\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Read Black data with this profile's values.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Public payload output by default.\n */\n Read(input, options = {})\n {\n return CjsBlackFormat.read(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as a neutral document graph for diagnostics.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} CarbonEngineJS document graph.\n */\n ReadDocument(input, options = {})\n {\n return CjsBlackFormat.readDocument(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as runtime objects or plain source-shaped objects.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Runtime read result.\n */\n ReadRuntime(input, options = {})\n {\n return CjsBlackFormat.readRuntime(input, this.GetValues(options));\n }\n\n /**\n * Read Black data as compact public payload JSON.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Public payload output.\n */\n ReadPayload(input, options = {})\n {\n return CjsBlackFormat.readPayload(input, this.GetValues(options));\n }\n\n /**\n * Inspect Black data with this profile's values.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return CjsBlackFormat.inspect(input, this.GetValues(options));\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static one-shot read. Static methods use camelCase by convention.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Format output.\n */\n static read(input, options = {})\n {\n const values = normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME);\n if (values.emit === OUTPUT_DOCUMENT || values.emit === OUTPUT_RAW) return CjsBlackFormat.readDocument(input, values);\n if (values.emit === OUTPUT_RUNTIME) return CjsBlackFormat.readRuntime(input, values);\n return CjsBlackFormat.readPayload(input, values);\n }\n\n /**\n * Static one-shot document read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} CarbonEngineJS document graph.\n */\n static readDocument(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadDocument();\n }\n\n /**\n * Static one-shot runtime read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Runtime read result.\n */\n static readRuntime(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRuntime();\n }\n\n /**\n * Static one-shot public payload read.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Public payload output.\n */\n static readPayload(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadPayload();\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {unknown} input Black format input.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return new CjsBlackReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).Inspect();\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Performs the bounded Black content discriminator used by ordered object\n * routes. Magic selects the Black reader; version and body failures remain\n * that reader's errors and are never reinterpreted as Red/YAML.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Candidate source bytes.\n * @returns {boolean} True when the little-endian Black magic is present.\n */\n static isSupported(input)\n {\n const view = getBlackProbeView(input);\n return Boolean(\n view\n && view.byteLength >= 4\n && view.getUint32(0, true) === CJS_BLACK_FOURCC\n );\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n RAW: OUTPUT_RAW,\n DOCUMENT: OUTPUT_DOCUMENT,\n PAYLOAD: OUTPUT_PAYLOAD,\n RUNTIME: OUTPUT_RUNTIME\n });\n static CLASS_KEYS = CLASS_KEYS;\n static id = CJS_BLACK_FORMAT_ID;\n static extensions = Object.freeze([CJS_BLACK_EXTENSION]);\n static fourCC = CJS_BLACK_FOURCC;\n static version = CJS_BLACK_VERSION;\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"black\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_DOCUMENT, OUTPUT_PAYLOAD, OUTPUT_RUNTIME ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n\n /** Provides the one-shot Black copy reader options helper entry point. */\n static copyReaderOptions(values)\n {\n const {\n emit: _emit,\n schema: _schema,\n classes: _classes,\n ...readerOptions\n } = values;\n return readerOptions;\n }\n\n}\n\nfunction getBlackProbeView(input)\n{\n if (input instanceof ArrayBuffer) return new DataView(input);\n if (!ArrayBuffer.isView(input)) return null;\n return new DataView(input.buffer, input.byteOffset, input.byteLength);\n}\n\nexport default CjsBlackFormat;\n"],"names":["FORMAT_NAME","CjsBlackFormat","DEFAULT_VALUES","emit","schema","worker","Object","freeze","module","import","meta","url","exportName","outputTypes","OUTPUT_JSON","OUTPUT_PAYLOAD","defaultOutput","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","copyReaderOptions","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","read","ReadDocument","readDocument","ReadRuntime","readRuntime","ReadPayload","readPayload","Inspect","inspect","ToJSON","value","toJsonValue","OUTPUT_DOCUMENT","OUTPUT_RAW","OUTPUT_RUNTIME","CjsBlackReader","toJSON","isSupported","view","getBlackProbeView","Boolean","byteLength","getUint32","CJS_BLACK_FOURCC","Output","JSON","RAW","DOCUMENT","PAYLOAD","RUNTIME","id","CJS_BLACK_FORMAT_ID","extensions","CJS_BLACK_EXTENSION","fourCC","version","CJS_BLACK_VERSION","mediaTypes","inputTypes","debugOutputTypes","_emit","_schema","_classes","readerOptions","ArrayBuffer","DataView","isView","buffer","byteOffset"],"mappings":";;;;;AAqBA,MAAMA,WAAW,GAAG,gBAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,CAC3B;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;EAC/B,cAAc,GAAG,EAAE;EACnB,QAAQ,GAAG,EAAE;;AAEb;AACJ;AACA;AACA;AACA;AACI,EAAA,OAAOC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC1BC,IAAAA,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,GAAG;AACvBC,IAAAA,UAAU,EAAE,gBAAgB;IAC5BC,WAAW,EAAEP,MAAM,CAACC,MAAM,CAAC,CAAEO,WAAW,EAAEC,cAAc,CAAE,CAAC;AAC3DC,IAAAA,aAAa,EAAEF;AACnB,GAAC,CAAC;;AAEF;AACJ;AACA;AACA;AACA;AACIG,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;A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