@carbonenginejs/runtime-resource 0.12.0 → 0.12.1

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.
Files changed (170) hide show
  1. package/dist/CjsResMan.js +4 -4
  2. package/dist/CjsResMan.js.map +1 -1
  3. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
  4. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  5. package/dist/format/CjsByteReader.js +310 -0
  6. package/dist/format/CjsByteReader.js.map +1 -0
  7. package/dist/format/CjsByteWriter.js +242 -0
  8. package/dist/format/CjsByteWriter.js.map +1 -0
  9. package/dist/format/CjsFormatError.js +41 -0
  10. package/dist/format/CjsFormatError.js.map +1 -0
  11. package/dist/format/CjsStringTable.js +268 -0
  12. package/dist/format/CjsStringTable.js.map +1 -0
  13. package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
  14. package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
  15. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
  16. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
  17. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
  18. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
  19. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
  20. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
  21. package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
  22. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
  23. package/dist/format/compareUtf8.js +36 -0
  24. package/dist/format/compareUtf8.js.map +1 -0
  25. package/dist/format/index.js +11 -0
  26. package/dist/format/index.js.map +1 -0
  27. package/dist/formats/bnk/CjsBnkFormat.js +10 -4
  28. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  29. package/dist/formats/bnk/core/eventAction.js +305 -0
  30. package/dist/formats/bnk/core/eventAction.js.map +1 -0
  31. package/dist/formats/bnk/core/helpers.js +11 -2
  32. package/dist/formats/bnk/core/helpers.js.map +1 -1
  33. package/dist/formats/bnk/core/nodeBase.js +532 -0
  34. package/dist/formats/bnk/core/nodeBase.js.map +1 -0
  35. package/dist/formats/bnk/core/sfxNodes.js +252 -152
  36. package/dist/formats/bnk/core/sfxNodes.js.map +1 -1
  37. package/dist/formats/hlsl/core/HlslReader.js +7 -257
  38. package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
  39. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
  40. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
  41. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
  42. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
  43. package/dist/formats/index.js +1 -1
  44. package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
  45. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
  46. package/dist/formats/webgl/core/cewg/binary.js +11 -93
  47. package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
  48. package/dist/formats/webgl/core/effectPackage.js +1 -1
  49. package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
  50. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  51. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
  52. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
  53. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
  54. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
  55. package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
  56. package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
  57. package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
  58. package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
  59. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
  60. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  61. package/dist/formats/webgpu/core/helpers.js +87 -92
  62. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  63. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
  64. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
  65. package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
  66. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
  67. package/dist/formats/webgpu/core/packageEffect.js +94 -9
  68. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  69. package/dist/formats/webgpu/core/packageMetadata.js +10 -1
  70. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
  71. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
  72. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  73. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
  74. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
  75. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
  76. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  77. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
  78. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
  79. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
  80. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
  81. package/dist/resource/CjsResource.js +700 -684
  82. package/dist/resource/CjsResource.js.map +1 -1
  83. package/dist/resource/Tr2LightProfileRes.js +18 -27
  84. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  85. package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
  86. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
  87. package/dist/resource/audio/CjsAudioRes.js +2 -2
  88. package/dist/resource/audio/CjsAudioRes.js.map +1 -1
  89. package/dist/resource/geometry/TriGeometryRes.js +605 -586
  90. package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
  91. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
  92. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
  93. package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
  94. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
  95. package/dist/resource/shader/Tr2EffectRes.js +9 -7
  96. package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
  97. package/dist/resource/shader/Tr2MaterialArea.js +5 -3
  98. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
  99. package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
  100. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
  101. package/dist/resource/shader/Tr2MaterialRes.js +5 -3
  102. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
  103. package/dist/resource/shader/Tr2Shader.js +26 -21
  104. package/dist/resource/shader/Tr2Shader.js.map +1 -1
  105. package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
  106. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
  107. package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
  108. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
  109. package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
  110. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
  111. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
  112. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
  113. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
  114. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
  115. package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
  116. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  117. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
  118. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  119. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
  120. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
  121. package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
  122. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  123. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
  124. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
  125. package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
  126. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
  127. package/dist/resource/texture/Tr2ImageRes.js +99 -95
  128. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  129. package/dist/resource/texture/TriTextureRes.js +312 -273
  130. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  131. package/docs/README.md +13 -1
  132. package/docs/architecture.md +3 -3
  133. package/docs/concepts/resource-lifecycle.md +9 -2
  134. package/docs/concepts/shader-resource-model.md +114 -0
  135. package/docs/concepts/writing-an-engine-adapter.md +115 -0
  136. package/docs/formats/README.md +24 -1
  137. package/docs/formats/carbon-effect-container.md +452 -0
  138. package/docs/formats/dxbc/reference/classes/README.md +5 -72
  139. package/docs/formats/hlsl/reference/api.md +5 -4
  140. package/docs/formats/hlsl/reference/classes/README.md +6 -11
  141. package/docs/formats/provenance.md +23 -13
  142. package/docs/formats/webgl/reference/classes/README.md +5 -92
  143. package/docs/formats/webgpu/README.md +19 -16
  144. package/docs/formats/webgpu/architecture.md +15 -12
  145. package/docs/formats/webgpu/formats/cewgpu.md +175 -438
  146. package/docs/formats/webgpu/guides/effect-packaging.md +132 -140
  147. package/docs/formats/webgpu/reference/api.md +131 -131
  148. package/docs/formats/webgpu/reference/classes/README.md +5 -62
  149. package/docs/formats/webgpu/reference/wgsl-compatibility.md +146 -45
  150. package/docs/formats/wwise.md +34 -8
  151. package/docs/reference/classes/core.md +80 -0
  152. package/docs/reference/classes/formats.md +18 -28
  153. package/docs/reference/events.md +25 -0
  154. package/docs/reference/motherlode-cache.md +22 -8
  155. package/docs/reference/workers.md +5 -5
  156. package/docs/roadmap.md +61 -41
  157. package/package.json +2 -1
  158. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
  159. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
  160. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
  161. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
  162. package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
  163. package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
  164. package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
  165. package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
  166. package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
  167. package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
  168. package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +0 -66
  169. package/docs/formats/hlsl/reference/classes/public-api.md +0 -26
  170. package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +0 -150
package/docs/roadmap.md CHANGED
@@ -3,9 +3,10 @@
3
3
  Status: Evolving
4
4
  Scope: `@carbonenginejs/runtime-resource`
5
5
  Audience: Integrators and maintainers
6
- Summary: Records approved future direction and open design questions; nothing on this page is implemented.
6
+ Summary: Records approved future direction, open design questions, and the current shader-format boundary needed to interpret that direction.
7
7
 
8
- Everything below is future work. Current behavior is documented in the
8
+ Unless a section is explicitly marked **Current**, everything below is future
9
+ work. Current behavior is documented in the
9
10
  [reference pages](reference/motherlode-cache.md); where this page and a
10
11
  reference page disagree, the reference page describes the shipped package.
11
12
 
@@ -23,16 +24,18 @@ resource preparation abstraction:
23
24
  - automatic resource/payload byte estimation and separate CPU/adapter
24
25
  budgets;
25
26
  - additional browser-source response types and configurable worker-pool
26
- concurrency;
27
- - purged-resource/device-loss recovery policy (backend device-loss recovery
28
- belongs to the engine's realization operation).
27
+ concurrency.
29
28
 
30
29
  ## Browser shader formats
31
30
 
32
- The HLSL, DXBC, WebGL, and WebGPU format packages are expected to migrate into
33
- runtime-resource as independently exported format entry points. HLSL and DXBC
34
- remain directly usable; WebGL and WebGPU may compose them to read DX11/DX12
35
- effect inputs and translate them in the browser.
31
+ **Current:** HLSL, DXBC, WebGL, and WebGPU are consolidated into
32
+ runtime-resource and exposed as independently importable
33
+ `@carbonenginejs/runtime-resource/formats/<name>` entry points. HLSL and DXBC
34
+ remain directly usable; WebGL and WebGPU compose them to read DX11/DX12 effect
35
+ inputs and translate them.
36
+
37
+ **Planned:** Browser delivery and fallback policy still needs a stable
38
+ application-facing contract.
36
39
 
37
40
  Browser-targeted production modules must not import or require Node-only
38
41
  shader libraries. A format package may use local Node libraries as development
@@ -41,7 +44,7 @@ those libraries must not ship and must not be runtime dependencies.
41
44
 
42
45
  ccpwgl currently preserves an authored `.fx` path while `Tw2Device` maps it to
43
46
  a backend-specific remote namespace such as `effect.gles2` or `effect.webgl2`
44
- and appends the selected shader-model extension. The migrated resource/format
47
+ and appends the selected shader-model extension. The resource/format
45
48
  contract must retain both use cases:
46
49
 
47
50
  - resolve and load a pretranslated backend artifact from a remote resource
@@ -52,32 +55,52 @@ The authored effect path should remain the stable identity. Backend profile,
52
55
  shader model, translated cache path, and translation capabilities are
53
56
  resolution facts rather than changes a caller must make to its source path.
54
57
 
55
- ## Pre-adoption lifecycle API cleanup (approved, not implemented)
56
-
57
- No released consumer currently depends on the ccpwgl-compatible liveness
58
- names; the known ccpwgl format integrations are migration targets rather than
59
- a reason to preserve them. Before runtime-core or another public consumer
60
- adopts this contract, remove `KeepAlive()` and `KeepPayloadAlive()` instead
61
- of retaining or deprecating compatibility aliases.
62
-
63
- The public lifecycle should express caller intent directly:
64
-
65
- - `Ready()` obtains or reconstructs the CPU payload;
66
- - `AcquireLock()` returns a scoped hard-retention token;
67
- - `ReleasePayload()` explicitly drops the CPU payload; and
68
- - state queries remain pure.
69
-
70
- ResMan should update identity activity when a canonical resource is acquired
71
- and payload activity when it publishes or returns a ready payload. Those
72
- timestamps are cache-policy implementation details, not calls consumers
73
- should have to make. Cache admission and promotion must also be explicit
74
- manager operations: merely accessing a resource must not permanently move it
75
- from the byte-budget candidate set into an unbudgeted live set.
76
-
77
- Do not add `TouchIdentity()` or `TouchPayload()` to the initial public API
78
- unless a concrete soft-retention consumer appears. A consumer that needs a
79
- residency guarantee should acquire a lock; one that merely uses a resource
80
- should call `Ready()` and allow the configured cache policy to operate.
58
+ ## Format buffer ownership and destination reuse
59
+
60
+ **Current:** The CMF, DDS, FBX, GIF, glTF, JPEG, MP3, MP4, Ogg, PNG, STL,
61
+ TGA, WAV, WebM, and WebP byte normalizers preserve an existing `Uint8Array`.
62
+ `ArrayBuffer` and other byte-addressable views are exposed through a
63
+ `Uint8Array` view over the same backing storage rather than copied merely for
64
+ input normalization. Decode operations that produce new pixel, sample,
65
+ geometry, or decompression payloads currently allocate those result arrays
66
+ internally. Resource payload references are shared read-only by default;
67
+ [MotherLode retention](reference/motherlode-cache.md) defines the cases where
68
+ a consumer must make an explicit copy.
69
+
70
+ **Planned:** Known-size decode and transform operations should gain
71
+ format-specific optional destination-array seams. Omitting the destination
72
+ must preserve the convenient allocating call. Supplying a valid destination
73
+ must fill and return that exact object. Each seam must:
74
+
75
+ - require the correct typed-array kind and sufficient capacity before writing;
76
+ - support non-zero-offset input and destination views;
77
+ - leave input unchanged unless the operation explicitly documents an
78
+ in-place transform;
79
+ - produce the same bytes and typed-array kind as the allocating form; and
80
+ - behave deterministically when one destination is reused across sequential
81
+ calls.
82
+
83
+ The first candidates are CMF decompression, FBX inflate and packed-array
84
+ helpers, DDS block and uncompressed decoders, PNG row/RGBA decode, JPEG
85
+ component and final RGBA output, TGA RGBA decode, GIF compositing canvas, WAV
86
+ PCM decode, and glTF data-URI decode. Decoder workspaces such as JPEG
87
+ coefficient blocks, cached lookup tables, CRC tables, and small fixed scratch
88
+ arrays remain implementation-owned rather than becoming public output
89
+ arguments.
90
+
91
+ Some copies remain necessary: mutation of otherwise shared data,
92
+ `ArrayBuffer` transfer/detachment, compacting a small retained range out of a
93
+ large backing buffer, immutable frame history, and platform APIs that expose
94
+ no destination seam. Those copies should stay explicit at the owning call
95
+ site. This direction does not introduce a generic deep-copy operation for
96
+ payload objects or typed-array bundles.
97
+
98
+ ## Scoped lock token
99
+
100
+ **Planned:** add `AcquireLock()` as an async-safe wrapper around the current
101
+ `Lock()`/`Unlock()` contract. Existing `KeepAlive()` and
102
+ `KeepPayloadAlive()` behavior remains current package API; this roadmap does
103
+ not propose removing it.
81
104
 
82
105
  Raw `Lock()` / `Unlock()` is easy to mis-pair across asynchronous success,
83
106
  failure, cancellation, and disposal. Prefer a JS-only acquired-lock API:
@@ -118,11 +141,8 @@ built from explicit tokens, not an implicit default on every loaded resource.
118
141
  buffers?
119
142
  - Should manually attached/dynamic resources default to locked, like ccpwgl's
120
143
  manual shader resources use `doNotPurge`?
121
- - What explicit `Reload()`/reconstruction API should restore purged resources
122
- without introducing surprising browser or network work?
123
- - A resource-level `Purge()`/`Reload()` vocabulary remains future policy
124
- work, as does whether `Unload()` should release engine adapter resources
125
- and optionally CPU payloads.
144
+ - Should a resource-level `Purge()` complement the existing automatic and
145
+ MotherLode-level eviction operations?
126
146
 
127
147
  ## Related documentation
128
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonenginejs/runtime-resource",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "CarbonEngineJS resource lifecycle, cache, source, and object loading contracts.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,6 +12,7 @@
12
12
  "./resource/shader": "./dist/resource/shader/index.js",
13
13
  "./resource/texture": "./dist/resource/texture/index.js",
14
14
  "./worker": "./dist/worker/CjsResManWorker.js",
15
+ "./format": "./dist/format/index.js",
15
16
  "./formats": "./dist/formats/index.js",
16
17
  "./formats/black": "./dist/formats/black/index.js",
17
18
  "./formats/black/schema": "./dist/formats/black/core/blackSchema.js",
@@ -1,415 +0,0 @@
1
- import { asUint8Array, WebgpuReader } from './binary.js';
2
- import { validateCewgpuChunkTag } from './tags.js';
3
- import { sha256Bytes } from '../../../../format/effect/sha256.js';
4
- import { hydrateEffectReflectionForPermutation } from '../../../../format/effect/effectReflectionPackage.js';
5
-
6
- const validatedEffectPackages = new WeakSet();
7
- const CEWGPU_MAGIC = "CWGP";
8
- const CEWGPU_FORMAT = "CEWGPU";
9
- const CEWGPU_VERSION = 1;
10
- const textDecoder = new TextDecoder("utf-8", {
11
- fatal: false
12
- });
13
- const jsonTextDecoder = new TextDecoder("utf-8", {
14
- fatal: true
15
- });
16
-
17
- /**
18
- * Reader for CarbonEngineJS CEWGPU shader packages.
19
- */
20
- class CewgpuPackage {
21
- /**
22
- * Creates an empty package reader.
23
- */
24
- constructor() {
25
- this.version = 0;
26
- this.chunks = [];
27
- this.chunkMap = new Map();
28
- this.jsonCache = new Map();
29
- this.reflectionBlobIndex = null;
30
- this.readError = null;
31
- this.sourcePath = "";
32
- }
33
-
34
- /**
35
- * Reads a CEWGPU package from bytes.
36
- *
37
- * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source CEWGPU bytes.
38
- * @param {object} [options] Read options.
39
- * @param {string} [options.sourcePath] Source path for diagnostics.
40
- * @returns {boolean} True when the package was decoded.
41
- */
42
- Read(source, options = {}) {
43
- this.version = 0;
44
- this.chunks = [];
45
- this.chunkMap = new Map();
46
- this.jsonCache = new Map();
47
- this.reflectionBlobIndex = null;
48
- this.readError = null;
49
- this.sourcePath = options.sourcePath || "";
50
- try {
51
- const bytes = asUint8Array(source);
52
- const stream = new WebgpuReader(bytes, {
53
- source: this.sourcePath || "CEWGPU"
54
- });
55
- const magic = decodeAscii(stream.readRaw(CEWGPU_MAGIC.length));
56
- if (magic !== CEWGPU_MAGIC) {
57
- throw new Error(`Invalid CEWGPU magic "${magic}"`);
58
- }
59
- this.version = stream.readUint32();
60
- if (this.version !== CEWGPU_VERSION) {
61
- throw new Error(`Unsupported CEWGPU version ${this.version}`);
62
- }
63
- const chunkCount = stream.readUint32();
64
- for (let index = 0; index < chunkCount; index += 1) {
65
- const tag = decodeAscii(stream.readRaw(4));
66
- validateCewgpuChunkTag(tag);
67
- if (this.chunkMap.has(tag)) {
68
- throw new Error(`CEWGPU package contains duplicate chunk tag ${tag}`);
69
- }
70
- const size = stream.readUint32();
71
- const offset = stream.offset;
72
- const chunkBytes = stream.readRaw(size);
73
- const chunk = {
74
- tag,
75
- size,
76
- offset,
77
- bytes: chunkBytes
78
- };
79
- this.chunks.push(chunk);
80
- this.chunkMap.set(tag, chunk);
81
- }
82
- if (stream.remaining !== 0) {
83
- throw new Error(`CEWGPU package has ${stream.remaining} trailing bytes`);
84
- }
85
- return true;
86
- } catch (error) {
87
- this.readError = error;
88
- this.chunks = [];
89
- this.chunkMap = new Map();
90
- this.jsonCache = new Map();
91
- this.reflectionBlobIndex = null;
92
- return false;
93
- }
94
- }
95
-
96
- /**
97
- * Reports whether the package decoded successfully.
98
- *
99
- * @returns {boolean} True when no read error is present.
100
- */
101
- IsGood() {
102
- return !this.readError && this.version === CEWGPU_VERSION;
103
- }
104
-
105
- /**
106
- * Gets a chunk by four-character tag.
107
- *
108
- * @param {string} tag Chunk tag.
109
- * @returns {{tag:string,size:number,offset:number,bytes:Uint8Array}|null} Chunk record.
110
- */
111
- GetChunk(tag) {
112
- return this.chunkMap.get(tag) || null;
113
- }
114
-
115
- /**
116
- * Decodes a text chunk.
117
- *
118
- * @param {string} tag Chunk tag.
119
- * @returns {string|null} Decoded text, or null when absent.
120
- */
121
- GetText(tag) {
122
- const chunk = this.GetChunk(tag);
123
- return chunk ? textDecoder.decode(chunk.bytes) : null;
124
- }
125
-
126
- /**
127
- * Decodes a JSON chunk.
128
- *
129
- * @param {string} tag Chunk tag.
130
- * @returns {object|null} Parsed JSON, or null when absent.
131
- */
132
- GetJson(tag) {
133
- return cloneJson(getCachedJson(this, tag));
134
- }
135
-
136
- /**
137
- * Gets translator summary metadata from the `INFO` chunk.
138
- *
139
- * @returns {object|null} Info JSON.
140
- */
141
- get info() {
142
- return this.GetJson("INFO");
143
- }
144
-
145
- /**
146
- * Gets caller-provided metadata from the `META` chunk.
147
- *
148
- * @returns {object|null} Metadata JSON.
149
- */
150
- get metadata() {
151
- return this.GetJson("META");
152
- }
153
-
154
- /**
155
- * Gets the complete source permutation graph when present.
156
- *
157
- * @returns {object|null} Parsed permutation graph.
158
- */
159
- get permutationGraph() {
160
- return this.GetJson("PGRF");
161
- }
162
-
163
- /**
164
- * Gets complete source effect reflection when present.
165
- *
166
- * @returns {object|null} Parsed reflection document.
167
- */
168
- get reflection() {
169
- return this.GetJson("RFLX");
170
- }
171
-
172
- /**
173
- * Gets the raw reflection blob store when present.
174
- *
175
- * @returns {Uint8Array|null} RBLB bytes.
176
- */
177
- get reflectionBlobBytes() {
178
- return this.GetChunk("RBLB")?.bytes ?? null;
179
- }
180
-
181
- /**
182
- * Copies one reflected byte payload by blob key or exact reference.
183
- *
184
- * A string performs an inventory-key lookup. An object must exactly match
185
- * the stored blob key, offset, byte length, and digest.
186
- *
187
- * @param {string|object} value Blob key or exact RFLX byte-reference object.
188
- * @returns {Uint8Array|null} Owned payload bytes, or null when unavailable.
189
- */
190
- GetReflectionBlob(value) {
191
- const key = typeof value === "string" ? value : value?.blobKey;
192
- if (!this.reflectionBlobIndex) {
193
- this.reflectionBlobIndex = new Map((getCachedJson(this, "RFLX")?.blobStore?.blobs ?? []).map(entry => [entry.blobKey, entry]));
194
- }
195
- const entry = this.reflectionBlobIndex.get(key);
196
- const bytes = this.reflectionBlobBytes;
197
- if (!entry || !bytes) return null;
198
- if (typeof value !== "string" && (!value || value.offset !== entry.offset || value.byteLength !== entry.byteLength || value.sha256 !== entry.sha256)) {
199
- return null;
200
- }
201
- const end = entry.offset + entry.byteLength;
202
- if (!Number.isSafeInteger(entry.offset) || entry.offset < 0 || !Number.isSafeInteger(entry.byteLength) || entry.byteLength < 0 || end > bytes.byteLength || sha256Bytes(bytes.subarray(entry.offset, end)) !== entry.sha256) {
203
- return null;
204
- }
205
- return Uint8Array.from(bytes.subarray(entry.offset, end));
206
- }
207
-
208
- /**
209
- * Gets fully hydrated portable source reflection for one permutation.
210
- *
211
- * The optional index defaults to `META.bodyIndex`. Every reflected byte
212
- * field is returned as a fresh owned `Uint8Array`.
213
- *
214
- * @param {number} [permutationIndex] Exact PGRF permutation index.
215
- * @returns {object|null} Validated portable reflection, or null when absent.
216
- */
217
- GetPortableEffectReflection(permutationIndex) {
218
- if (!validatedEffectPackages.has(this)) return null;
219
- const reflection = getCachedJson(this, "RFLX");
220
- const permutationGraph = getCachedJson(this, "PGRF");
221
- if (!reflection || !permutationGraph) return null;
222
- const selectedIndex = permutationIndex ?? getCachedJson(this, "META")?.bodyIndex ?? 0;
223
- return hydrateEffectReflectionForPermutation(reflection, permutationGraph, selectedIndex, reference => this.GetReflectionBlob(reference));
224
- }
225
-
226
- /**
227
- * Gets the all-body backend translation graph when present.
228
- *
229
- * Selected-mode packages do not carry this chunk.
230
- *
231
- * @returns {object|null} Parsed `CJS_WGSL_BODY_SET` document.
232
- */
233
- get backendBodySet() {
234
- return this.GetJson("WGSB");
235
- }
236
-
237
- /**
238
- * Resolves the translated backend passes for one permutation index.
239
- *
240
- * Joins `PGRF` variant identity to the `WGSB` body record and expands every
241
- * pass reference into its shared translation unit. Returns null when the
242
- * package carries no all-body graph, and an explicitly unsupported record
243
- * when that body could not be lowered.
244
- *
245
- * @param {number} [permutationIndex] Exact PGRF permutation index.
246
- * @returns {object|null} Resolved backend body, or null when unavailable.
247
- */
248
- GetBackendBodyPrograms(permutationIndex) {
249
- if (!validatedEffectPackages.has(this)) return null;
250
- const bodySet = getCachedJson(this, "WGSB");
251
- const permutationGraph = getCachedJson(this, "PGRF");
252
- if (!bodySet || !permutationGraph) return null;
253
- const index = permutationIndex ?? getCachedJson(this, "META")?.bodyIndex ?? 0;
254
- const variant = permutationGraph.variants?.[index];
255
- if (!variant) return null;
256
- const body = bodySet.bodies?.find(entry => entry.bodyKey === variant.bodyKey);
257
- if (!body) return null;
258
- if (body.status !== "translated") {
259
- return {
260
- permutationIndex: index,
261
- bodyKey: body.bodyKey,
262
- status: body.status,
263
- error: body.error,
264
- passes: []
265
- };
266
- }
267
- const units = new Map((bodySet.passUnits ?? []).map(unit => [unit.key, unit]));
268
- return {
269
- permutationIndex: index,
270
- bodyKey: body.bodyKey,
271
- status: body.status,
272
- error: null,
273
- passes: body.passes.map(pass => {
274
- const unit = units.get(pass.unitKey);
275
- if (!unit) {
276
- throw new Error(`CEWGPU backend body ${body.bodyKey} references missing translation unit ${pass.unitKey}`);
277
- }
278
- return {
279
- passKey: pass.passKey,
280
- unitKey: pass.unitKey,
281
- wgslSetVersion: unit.wgslSetVersion,
282
- shaders: unit.shaders,
283
- layouts: unit.layouts,
284
- ...(unit.resourceTransforms ? {
285
- resourceTransforms: unit.resourceTransforms
286
- } : {})
287
- };
288
- })
289
- };
290
- }
291
-
292
- /**
293
- * Gets normalized shader analysis from the `ANLS` chunk.
294
- *
295
- * @returns {string|null} Analysis text.
296
- */
297
- get analysis() {
298
- return this.GetText("ANLS");
299
- }
300
-
301
- /**
302
- * Gets normalized shader analysis metadata when the `ANLS` chunk contains
303
- * JSON.
304
- *
305
- * @returns {object|null} Parsed analysis, or null for raw text.
306
- */
307
- get analysisJson() {
308
- try {
309
- return this.GetJson("ANLS");
310
- } catch {
311
- return null;
312
- }
313
- }
314
-
315
- /**
316
- * Gets emitted WGSL when present.
317
- *
318
- * @returns {string|null} WGSL text.
319
- */
320
- get wgsl() {
321
- return this.GetText("WGSL");
322
- }
323
-
324
- /**
325
- * Gets emitted WGSL metadata when the `WGSL` chunk contains JSON.
326
- *
327
- * @returns {object|null} Parsed WGSL metadata, or null for raw source.
328
- */
329
- get wgslJson() {
330
- try {
331
- return this.GetJson("WGSL");
332
- } catch {
333
- return null;
334
- }
335
- }
336
-
337
- /**
338
- * Returns a JSON-safe package summary.
339
- *
340
- * @returns {object} Serializable summary.
341
- */
342
- toJSON() {
343
- return {
344
- format: CEWGPU_FORMAT,
345
- version: this.version,
346
- sourcePath: this.sourcePath,
347
- chunks: this.chunks.map(chunk => ({
348
- tag: chunk.tag,
349
- size: chunk.size,
350
- offset: chunk.offset
351
- })),
352
- readError: this.readError ? {
353
- name: this.readError.name,
354
- message: this.readError.message
355
- } : null
356
- };
357
- }
358
- }
359
-
360
- /**
361
- * Decode and cache one private JSON document.
362
- *
363
- * @param {CewgpuPackage} pkg Package reader.
364
- * @param {string} tag Chunk tag.
365
- * @returns {object|null} Private parsed JSON, or null when absent.
366
- */
367
- function getCachedJson(pkg, tag) {
368
- if (!pkg.jsonCache.has(tag)) {
369
- const chunk = pkg.GetChunk(tag);
370
- pkg.jsonCache.set(tag, chunk ? JSON.parse(jsonTextDecoder.decode(chunk.bytes)) : null);
371
- }
372
- return pkg.jsonCache.get(tag);
373
- }
374
-
375
- /**
376
- * Copy JSON-compatible data without reparsing its source chunk.
377
- *
378
- * @param {any} value Cached JSON value.
379
- * @returns {any} Structurally independent JSON value.
380
- */
381
- function cloneJson(value) {
382
- if (Array.isArray(value)) return value.map(cloneJson);
383
- if (value && typeof value === "object") {
384
- return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneJson(entry)]));
385
- }
386
- return value;
387
- }
388
-
389
- /**
390
- * Decodes an ASCII four-character code.
391
- *
392
- * @param {Uint8Array} bytes Four-byte tag payload.
393
- * @returns {string} ASCII string.
394
- */
395
- function decodeAscii(bytes) {
396
- return String.fromCharCode(...bytes);
397
- }
398
-
399
- /**
400
- * Marks one package as having passed the canonical effect envelope.
401
- *
402
- * Reflection and backend accessors return null until this runs, so a
403
- * hand-assembled or tampered container cannot be hydrated as if it had been
404
- * validated. This is intentionally an internal deep import rather than
405
- * package-root API.
406
- *
407
- * @param {CewgpuPackage} pkg Validated package reader.
408
- * @returns {void}
409
- */
410
- function markEffectPackageValidated(pkg) {
411
- validatedEffectPackages.add(pkg);
412
- }
413
-
414
- export { CewgpuPackage, markEffectPackageValidated };
415
- //# sourceMappingURL=CewgpuPackage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CewgpuPackage.js","sources":["../../../../../../src/formats/webgpu/core/cewgpu/CewgpuPackage.js"],"sourcesContent":["import { WebgpuReader, asUint8Array } from \"./binary.js\";\nimport { validateCewgpuChunkTag } from \"./tags.js\";\nimport { sha256Bytes } from \"../../../../format/effect/sha256.js\";\nimport {\n hydrateEffectReflectionForPermutation\n} from \"../../../../format/effect/effectReflectionPackage.js\";\n\nconst validatedEffectPackages = new WeakSet();\nconst CEWGPU_MAGIC = \"CWGP\";\nconst CEWGPU_FORMAT = \"CEWGPU\";\nconst CEWGPU_VERSION = 1;\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: false });\nconst jsonTextDecoder = new TextDecoder(\"utf-8\", { fatal: true });\n\n/**\n * Reader for CarbonEngineJS CEWGPU shader packages.\n */\nexport class CewgpuPackage\n{\n /**\n * Creates an empty package reader.\n */\n constructor()\n {\n this.version = 0;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n this.readError = null;\n this.sourcePath = \"\";\n }\n\n /**\n * Reads a CEWGPU package from bytes.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source CEWGPU bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.sourcePath] Source path for diagnostics.\n * @returns {boolean} True when the package was decoded.\n */\n Read(source, options = {})\n {\n this.version = 0;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n this.readError = null;\n this.sourcePath = options.sourcePath || \"\";\n\n try\n {\n const bytes = asUint8Array(source);\n const stream = new WebgpuReader(bytes, { source: this.sourcePath || \"CEWGPU\" });\n const magic = decodeAscii(stream.readRaw(CEWGPU_MAGIC.length));\n if (magic !== CEWGPU_MAGIC)\n {\n throw new Error(`Invalid CEWGPU magic \"${magic}\"`);\n }\n\n this.version = stream.readUint32();\n if (this.version !== CEWGPU_VERSION)\n {\n throw new Error(`Unsupported CEWGPU version ${this.version}`);\n }\n\n const chunkCount = stream.readUint32();\n for (let index = 0; index < chunkCount; index += 1)\n {\n const tag = decodeAscii(stream.readRaw(4));\n validateCewgpuChunkTag(tag);\n if (this.chunkMap.has(tag))\n {\n throw new Error(`CEWGPU package contains duplicate chunk tag ${tag}`);\n }\n const size = stream.readUint32();\n const offset = stream.offset;\n const chunkBytes = stream.readRaw(size);\n const chunk = {\n tag,\n size,\n offset,\n bytes: chunkBytes\n };\n this.chunks.push(chunk);\n this.chunkMap.set(tag, chunk);\n }\n\n if (stream.remaining !== 0)\n {\n throw new Error(`CEWGPU package has ${stream.remaining} trailing bytes`);\n }\n\n return true;\n }\n catch (error)\n {\n this.readError = error;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n return false;\n }\n }\n\n /**\n * Reports whether the package decoded successfully.\n *\n * @returns {boolean} True when no read error is present.\n */\n IsGood()\n {\n return !this.readError && this.version === CEWGPU_VERSION;\n }\n\n /**\n * Gets a chunk by four-character tag.\n *\n * @param {string} tag Chunk tag.\n * @returns {{tag:string,size:number,offset:number,bytes:Uint8Array}|null} Chunk record.\n */\n GetChunk(tag)\n {\n return this.chunkMap.get(tag) || null;\n }\n\n /**\n * Decodes a text chunk.\n *\n * @param {string} tag Chunk tag.\n * @returns {string|null} Decoded text, or null when absent.\n */\n GetText(tag)\n {\n const chunk = this.GetChunk(tag);\n return chunk ? textDecoder.decode(chunk.bytes) : null;\n }\n\n /**\n * Decodes a JSON chunk.\n *\n * @param {string} tag Chunk tag.\n * @returns {object|null} Parsed JSON, or null when absent.\n */\n GetJson(tag)\n {\n return cloneJson(getCachedJson(this, tag));\n }\n\n /**\n * Gets translator summary metadata from the `INFO` chunk.\n *\n * @returns {object|null} Info JSON.\n */\n get info()\n {\n return this.GetJson(\"INFO\");\n }\n\n /**\n * Gets caller-provided metadata from the `META` chunk.\n *\n * @returns {object|null} Metadata JSON.\n */\n get metadata()\n {\n return this.GetJson(\"META\");\n }\n\n /**\n * Gets the complete source permutation graph when present.\n *\n * @returns {object|null} Parsed permutation graph.\n */\n get permutationGraph()\n {\n return this.GetJson(\"PGRF\");\n }\n\n /**\n * Gets complete source effect reflection when present.\n *\n * @returns {object|null} Parsed reflection document.\n */\n get reflection()\n {\n return this.GetJson(\"RFLX\");\n }\n\n /**\n * Gets the raw reflection blob store when present.\n *\n * @returns {Uint8Array|null} RBLB bytes.\n */\n get reflectionBlobBytes()\n {\n return this.GetChunk(\"RBLB\")?.bytes ?? null;\n }\n\n /**\n * Copies one reflected byte payload by blob key or exact reference.\n *\n * A string performs an inventory-key lookup. An object must exactly match\n * the stored blob key, offset, byte length, and digest.\n *\n * @param {string|object} value Blob key or exact RFLX byte-reference object.\n * @returns {Uint8Array|null} Owned payload bytes, or null when unavailable.\n */\n GetReflectionBlob(value)\n {\n const key = typeof value === \"string\" ? value : value?.blobKey;\n if (!this.reflectionBlobIndex)\n {\n this.reflectionBlobIndex = new Map(\n (getCachedJson(this, \"RFLX\")?.blobStore?.blobs ?? []).map((entry) => [\n entry.blobKey,\n entry\n ])\n );\n }\n const entry = this.reflectionBlobIndex.get(key);\n const bytes = this.reflectionBlobBytes;\n if (!entry || !bytes) return null;\n if (typeof value !== \"string\"\n && (!value\n || value.offset !== entry.offset\n || value.byteLength !== entry.byteLength\n || value.sha256 !== entry.sha256))\n {\n return null;\n }\n const end = entry.offset + entry.byteLength;\n if (!Number.isSafeInteger(entry.offset) || entry.offset < 0\n || !Number.isSafeInteger(entry.byteLength) || entry.byteLength < 0\n || end > bytes.byteLength\n || sha256Bytes(bytes.subarray(entry.offset, end)) !== entry.sha256)\n {\n return null;\n }\n return Uint8Array.from(bytes.subarray(entry.offset, end));\n }\n\n /**\n * Gets fully hydrated portable source reflection for one permutation.\n *\n * The optional index defaults to `META.bodyIndex`. Every reflected byte\n * field is returned as a fresh owned `Uint8Array`.\n *\n * @param {number} [permutationIndex] Exact PGRF permutation index.\n * @returns {object|null} Validated portable reflection, or null when absent.\n */\n GetPortableEffectReflection(\n permutationIndex\n )\n {\n if (!validatedEffectPackages.has(this)) return null;\n const reflection = getCachedJson(this, \"RFLX\");\n const permutationGraph = getCachedJson(this, \"PGRF\");\n if (!reflection || !permutationGraph) return null;\n const selectedIndex = permutationIndex\n ?? getCachedJson(this, \"META\")?.bodyIndex\n ?? 0;\n return hydrateEffectReflectionForPermutation(\n reflection,\n permutationGraph,\n selectedIndex,\n (reference) => this.GetReflectionBlob(reference)\n );\n }\n\n /**\n * Gets the all-body backend translation graph when present.\n *\n * Selected-mode packages do not carry this chunk.\n *\n * @returns {object|null} Parsed `CJS_WGSL_BODY_SET` document.\n */\n get backendBodySet()\n {\n return this.GetJson(\"WGSB\");\n }\n\n /**\n * Resolves the translated backend passes for one permutation index.\n *\n * Joins `PGRF` variant identity to the `WGSB` body record and expands every\n * pass reference into its shared translation unit. Returns null when the\n * package carries no all-body graph, and an explicitly unsupported record\n * when that body could not be lowered.\n *\n * @param {number} [permutationIndex] Exact PGRF permutation index.\n * @returns {object|null} Resolved backend body, or null when unavailable.\n */\n GetBackendBodyPrograms(permutationIndex)\n {\n if (!validatedEffectPackages.has(this)) return null;\n const bodySet = getCachedJson(this, \"WGSB\");\n const permutationGraph = getCachedJson(this, \"PGRF\");\n if (!bodySet || !permutationGraph) return null;\n\n const index = permutationIndex\n ?? getCachedJson(this, \"META\")?.bodyIndex\n ?? 0;\n const variant = permutationGraph.variants?.[index];\n if (!variant) return null;\n\n const body = bodySet.bodies?.find((entry) => entry.bodyKey === variant.bodyKey);\n if (!body) return null;\n if (body.status !== \"translated\")\n {\n return {\n permutationIndex: index,\n bodyKey: body.bodyKey,\n status: body.status,\n error: body.error,\n passes: []\n };\n }\n\n const units = new Map((bodySet.passUnits ?? []).map((unit) => [ unit.key, unit ]));\n\n return {\n permutationIndex: index,\n bodyKey: body.bodyKey,\n status: body.status,\n error: null,\n passes: body.passes.map((pass) =>\n {\n const unit = units.get(pass.unitKey);\n if (!unit)\n {\n throw new Error(\n `CEWGPU backend body ${body.bodyKey} references missing translation unit ${pass.unitKey}`\n );\n }\n return {\n passKey: pass.passKey,\n unitKey: pass.unitKey,\n wgslSetVersion: unit.wgslSetVersion,\n shaders: unit.shaders,\n layouts: unit.layouts,\n ...(unit.resourceTransforms\n ? { resourceTransforms: unit.resourceTransforms }\n : {})\n };\n })\n };\n }\n\n /**\n * Gets normalized shader analysis from the `ANLS` chunk.\n *\n * @returns {string|null} Analysis text.\n */\n get analysis()\n {\n return this.GetText(\"ANLS\");\n }\n\n /**\n * Gets normalized shader analysis metadata when the `ANLS` chunk contains\n * JSON.\n *\n * @returns {object|null} Parsed analysis, or null for raw text.\n */\n get analysisJson()\n {\n try\n {\n return this.GetJson(\"ANLS\");\n }\n catch\n {\n return null;\n }\n }\n\n /**\n * Gets emitted WGSL when present.\n *\n * @returns {string|null} WGSL text.\n */\n get wgsl()\n {\n return this.GetText(\"WGSL\");\n }\n\n /**\n * Gets emitted WGSL metadata when the `WGSL` chunk contains JSON.\n *\n * @returns {object|null} Parsed WGSL metadata, or null for raw source.\n */\n get wgslJson()\n {\n try\n {\n return this.GetJson(\"WGSL\");\n }\n catch\n {\n return null;\n }\n }\n\n /**\n * Returns a JSON-safe package summary.\n *\n * @returns {object} Serializable summary.\n */\n toJSON()\n {\n return {\n format: CEWGPU_FORMAT,\n version: this.version,\n sourcePath: this.sourcePath,\n chunks: this.chunks.map((chunk) => ({\n tag: chunk.tag,\n size: chunk.size,\n offset: chunk.offset\n })),\n readError: this.readError ? {\n name: this.readError.name,\n message: this.readError.message\n } : null\n };\n }\n}\n\n/**\n * Decode and cache one private JSON document.\n *\n * @param {CewgpuPackage} pkg Package reader.\n * @param {string} tag Chunk tag.\n * @returns {object|null} Private parsed JSON, or null when absent.\n */\nfunction getCachedJson(pkg, tag)\n{\n if (!pkg.jsonCache.has(tag))\n {\n const chunk = pkg.GetChunk(tag);\n pkg.jsonCache.set(\n tag,\n chunk ? JSON.parse(jsonTextDecoder.decode(chunk.bytes)) : null\n );\n }\n return pkg.jsonCache.get(tag);\n}\n\n/**\n * Copy JSON-compatible data without reparsing its source chunk.\n *\n * @param {any} value Cached JSON value.\n * @returns {any} Structurally independent JSON value.\n */\nfunction cloneJson(value)\n{\n if (Array.isArray(value)) return value.map(cloneJson);\n if (value && typeof value === \"object\")\n {\n return Object.fromEntries(Object.entries(value).map(([ key, entry ]) => [\n key,\n cloneJson(entry)\n ]));\n }\n return value;\n}\n\n/**\n * Decodes an ASCII four-character code.\n *\n * @param {Uint8Array} bytes Four-byte tag payload.\n * @returns {string} ASCII string.\n */\nfunction decodeAscii(bytes)\n{\n return String.fromCharCode(...bytes);\n}\n\n/**\n * Marks one package as having passed the canonical effect envelope.\n *\n * Reflection and backend accessors return null until this runs, so a\n * hand-assembled or tampered container cannot be hydrated as if it had been\n * validated. This is intentionally an internal deep import rather than\n * package-root API.\n *\n * @param {CewgpuPackage} pkg Validated package reader.\n * @returns {void}\n */\nexport function markEffectPackageValidated(pkg)\n{\n validatedEffectPackages.add(pkg);\n}\n"],"names":["validatedEffectPackages","WeakSet","CEWGPU_MAGIC","CEWGPU_FORMAT","CEWGPU_VERSION","textDecoder","TextDecoder","fatal","jsonTextDecoder","CewgpuPackage","constructor","version","chunks","chunkMap","Map","jsonCache","reflectionBlobIndex","readError","sourcePath","Read","source","options","bytes","asUint8Array","stream","WebgpuReader","magic","decodeAscii","readRaw","length","Error","readUint32","chunkCount","index","tag","validateCewgpuChunkTag","has","size","offset","chunkBytes","chunk","push","set","remaining","error","IsGood","GetChunk","get","GetText","decode","GetJson","cloneJson","getCachedJson","info","metadata","permutationGraph","reflection","reflectionBlobBytes","GetReflectionBlob","value","key","blobKey","blobStore","blobs","map","entry","byteLength","sha256","end","Number","isSafeInteger","sha256Bytes","subarray","Uint8Array","from","GetPortableEffectReflection","permutationIndex","selectedIndex","bodyIndex","hydrateEffectReflectionForPermutation","reference","backendBodySet","GetBackendBodyPrograms","bodySet","variant","variants","body","bodies","find","bodyKey","status","passes","units","passUnits","unit","pass","unitKey","passKey","wgslSetVersion","shaders","layouts","resourceTransforms","analysis","analysisJson","wgsl","wgslJson","toJSON","format","name","message","pkg","JSON","parse","Array","isArray","Object","fromEntries","entries","String","fromCharCode","markEffectPackageValidated","add"],"mappings":";;;;;AAOA,MAAMA,uBAAuB,GAAG,IAAIC,OAAO,EAAE;AAC7C,MAAMC,YAAY,GAAG,MAAM;AAC3B,MAAMC,aAAa,GAAG,QAAQ;AAC9B,MAAMC,cAAc,GAAG,CAAC;AACxB,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,OAAO,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAM,CAAC,CAAC;AAC9D,MAAMC,eAAe,GAAG,IAAIF,WAAW,CAAC,OAAO,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAK,CAAC,CAAC;;AAEjE;AACA;AACA;AACO,MAAME,aAAa,CAC1B;AACI;AACJ;AACA;AACIC,EAAAA,WAAWA,GACX;IACI,IAAI,CAACC,OAAO,GAAG,CAAC;IAChB,IAAI,CAACC,MAAM,GAAG,EAAE;AAChB,IAAA,IAAI,CAACC,QAAQ,GAAG,IAAIC,GAAG,EAAE;AACzB,IAAA,IAAI,CAACC,SAAS,GAAG,IAAID,GAAG,EAAE;IAC1B,IAAI,CAACE,mBAAmB,GAAG,IAAI;IAC/B,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,UAAU,GAAG,EAAE;AACxB,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACIC,EAAAA,IAAIA,CAACC,MAAM,EAAEC,OAAO,GAAG,EAAE,EACzB;IACI,IAAI,CAACV,OAAO,GAAG,CAAC;IAChB,IAAI,CAACC,MAAM,GAAG,EA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