@carbonenginejs/runtime-resource 0.15.0 → 0.17.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/dist/format/CjsFormat.js +84 -83
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsResourceProbe.js +87 -86
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/carbonEffect/backendEngineId.js +100 -0
- package/dist/format/carbonEffect/backendEngineId.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +23 -23
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/index.js +1 -1
- package/dist/formats/png/core/helpers.js +27 -8
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +141 -53
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +799 -456
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBlock.js +70 -27
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
- package/dist/formats/webgl/core/helpers.js +53 -53
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/readGlslEffectContainer.js +82 -67
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js +10 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +121 -121
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/resolve.js +8 -8
- package/dist/formats/wem/core/resolve.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +2 -2
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +2 -2
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +102 -60
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +2 -2
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js +2 -2
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -1
- package/docs/concepts/format-type-resolution.md +79 -0
- package/docs/formats/README.md +11 -0
- package/docs/formats/wwise.md +25 -0
- package/docs/roadmap.md +19 -0
- package/package.json +61 -61
|
@@ -3,186 +3,186 @@ import { resolveTypeWithValues } from './core/resolve.js';
|
|
|
3
3
|
|
|
4
4
|
const FORMAT_NAME = "CjsWemFormat";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Reader for Audiokinetic Wwise media (.wem) containers.
|
|
8
|
-
*
|
|
9
|
-
* Inspection identifies the codec, channel/rate layout, and Vorbis duration
|
|
10
|
-
* without decoding audio data. Read emits the container bytes untouched by
|
|
11
|
-
* default; `emit: "ogg"` repacks Wwise Vorbis into a standard Ogg stream and
|
|
12
|
-
* `emit: "pcm"` decodes PTADPCM / 16-bit PCM media to float32 samples.
|
|
6
|
+
/**
|
|
7
|
+
* Reader for Audiokinetic Wwise media (.wem) containers.
|
|
8
|
+
*
|
|
9
|
+
* Inspection identifies the codec, channel/rate layout, and Vorbis duration
|
|
10
|
+
* without decoding audio data. Read emits the container bytes untouched by
|
|
11
|
+
* default; `emit: "ogg"` repacks Wwise Vorbis into a standard Ogg stream and
|
|
12
|
+
* `emit: "pcm"` decodes PTADPCM / 16-bit PCM media to float32 samples.
|
|
13
13
|
*/
|
|
14
14
|
class CjsWemFormat {
|
|
15
15
|
#values = DEFAULT_VALUES;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Browser-worker module declaration consumed by CjsResManWorkerLoader.
|
|
17
|
+
/**
|
|
18
|
+
* Browser-worker module declaration consumed by CjsResManWorkerLoader.
|
|
19
19
|
*/
|
|
20
20
|
static worker = Object.freeze({
|
|
21
21
|
module: import.meta.url,
|
|
22
22
|
exportName: "CjsWemFormat"
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Create a reusable wem format profile.
|
|
27
|
-
*
|
|
28
|
-
* @param {object} [options] Default read/inspect options.
|
|
25
|
+
/**
|
|
26
|
+
* Create a reusable wem format profile.
|
|
27
|
+
*
|
|
28
|
+
* @param {object} [options] Default read/inspect options.
|
|
29
29
|
*/
|
|
30
30
|
constructor(options = {}) {
|
|
31
31
|
this.SetValues(options);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Merge options into this profile.
|
|
36
|
-
*
|
|
37
|
-
* @param {object} [options] Values to merge.
|
|
38
|
-
* @returns {CjsWemFormat} This format profile.
|
|
34
|
+
/**
|
|
35
|
+
* Merge options into this profile.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} [options] Values to merge.
|
|
38
|
+
* @returns {CjsWemFormat} This format profile.
|
|
39
39
|
*/
|
|
40
40
|
SetValues(options = {}) {
|
|
41
41
|
this.#values = normalizeValues(this.#values, options, FORMAT_NAME);
|
|
42
42
|
return this;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
46
|
-
* Get normalized profile values with optional per-call overrides.
|
|
47
|
-
*
|
|
48
|
-
* @param {object} [options] Per-call values.
|
|
49
|
-
* @returns {object} Normalized read values.
|
|
45
|
+
/**
|
|
46
|
+
* Get normalized profile values with optional per-call overrides.
|
|
47
|
+
*
|
|
48
|
+
* @param {object} [options] Per-call values.
|
|
49
|
+
* @returns {object} Normalized read values.
|
|
50
50
|
*/
|
|
51
51
|
GetValues(options = {}) {
|
|
52
52
|
return normalizeValues(this.#values, options, FORMAT_NAME);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Read wem bytes with this profile.
|
|
57
|
-
*
|
|
58
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
59
|
-
* @param {object} [options] Per-call values.
|
|
60
|
-
* @returns {object} GPU-free raw/debug payload for the selected emit target.
|
|
55
|
+
/**
|
|
56
|
+
* Read wem bytes with this profile.
|
|
57
|
+
*
|
|
58
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
59
|
+
* @param {object} [options] Per-call values.
|
|
60
|
+
* @returns {object} GPU-free raw/debug payload for the selected emit target.
|
|
61
61
|
*/
|
|
62
62
|
Read(input, options = {}) {
|
|
63
63
|
return readWithValues(input, this.GetValues(options));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* Read wem bytes asynchronously with this profile.
|
|
68
|
-
*
|
|
69
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
70
|
-
* @param {object} [options] Per-call values.
|
|
71
|
-
* @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.
|
|
66
|
+
/**
|
|
67
|
+
* Read wem bytes asynchronously with this profile.
|
|
68
|
+
*
|
|
69
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
70
|
+
* @param {object} [options] Per-call values.
|
|
71
|
+
* @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.
|
|
72
72
|
*/
|
|
73
73
|
async ReadAsync(input, options = {}) {
|
|
74
74
|
return this.Read(input, options);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
* Inspect wem bytes without decoding audio data.
|
|
79
|
-
*
|
|
80
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
81
|
-
* @param {object} [options] Per-call values.
|
|
82
|
-
* @returns {object} Wwise container metadata.
|
|
77
|
+
/**
|
|
78
|
+
* Inspect wem bytes without decoding audio data.
|
|
79
|
+
*
|
|
80
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
81
|
+
* @param {object} [options] Per-call values.
|
|
82
|
+
* @returns {object} Wwise container metadata.
|
|
83
83
|
*/
|
|
84
84
|
Inspect(input, options = {}) {
|
|
85
85
|
return inspectWithValues(input, this.GetValues(options));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* Report whether wem input and requested output variants are supported.
|
|
90
|
-
*
|
|
91
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
92
|
-
* @param {object} [options] Per-call values.
|
|
93
|
-
* @returns {object} Support/probe report.
|
|
88
|
+
/**
|
|
89
|
+
* Report whether wem input and requested output variants are supported.
|
|
90
|
+
*
|
|
91
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
92
|
+
* @param {object} [options] Per-call values.
|
|
93
|
+
* @returns {object} Support/probe report.
|
|
94
94
|
*/
|
|
95
95
|
IsSupported(input, options = {}) {
|
|
96
96
|
return isSupportedWithValues(input, this.GetValues(options));
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* Convert format output into JSON-compatible debug data.
|
|
101
|
-
*
|
|
102
|
-
* @param {any} value Format output.
|
|
103
|
-
* @returns {any} JSON-compatible value.
|
|
99
|
+
/**
|
|
100
|
+
* Convert format output into JSON-compatible debug data.
|
|
101
|
+
*
|
|
102
|
+
* @param {any} value Format output.
|
|
103
|
+
* @returns {any} JSON-compatible value.
|
|
104
104
|
*/
|
|
105
105
|
ToJSON(value) {
|
|
106
106
|
return toJsonValue(value);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/**
|
|
110
|
-
* One-shot wem read.
|
|
111
|
-
*
|
|
112
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
113
|
-
* @param {object} [options] Read options.
|
|
114
|
-
* @returns {object} GPU-free raw/debug payload for the selected emit target.
|
|
109
|
+
/**
|
|
110
|
+
* One-shot wem read.
|
|
111
|
+
*
|
|
112
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
113
|
+
* @param {object} [options] Read options.
|
|
114
|
+
* @returns {object} GPU-free raw/debug payload for the selected emit target.
|
|
115
115
|
*/
|
|
116
116
|
static read(input, options = {}) {
|
|
117
117
|
return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/**
|
|
121
|
-
* One-shot asynchronous wem read.
|
|
122
|
-
*
|
|
123
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
124
|
-
* @param {object} [options] Read options.
|
|
125
|
-
* @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.
|
|
120
|
+
/**
|
|
121
|
+
* One-shot asynchronous wem read.
|
|
122
|
+
*
|
|
123
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
124
|
+
* @param {object} [options] Read options.
|
|
125
|
+
* @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.
|
|
126
126
|
*/
|
|
127
127
|
static async readAsync(input, options = {}) {
|
|
128
128
|
return CjsWemFormat.read(input, options);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* One-shot wem inspection.
|
|
133
|
-
*
|
|
134
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
135
|
-
* @param {object} [options] Inspect options.
|
|
136
|
-
* @returns {object} Wwise container metadata.
|
|
131
|
+
/**
|
|
132
|
+
* One-shot wem inspection.
|
|
133
|
+
*
|
|
134
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
135
|
+
* @param {object} [options] Inspect options.
|
|
136
|
+
* @returns {object} Wwise container metadata.
|
|
137
137
|
*/
|
|
138
138
|
static inspect(input, options = {}) {
|
|
139
139
|
return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
/**
|
|
143
|
-
* One-shot wem support probe.
|
|
144
|
-
*
|
|
145
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
146
|
-
* @param {object} [options] Probe options.
|
|
147
|
-
* @returns {object} Support/probe report.
|
|
142
|
+
/**
|
|
143
|
+
* One-shot wem support probe.
|
|
144
|
+
*
|
|
145
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
146
|
+
* @param {object} [options] Probe options.
|
|
147
|
+
* @returns {object} Support/probe report.
|
|
148
148
|
*/
|
|
149
149
|
static isSupported(input, options = {}) {
|
|
150
150
|
return isSupportedWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Content-verified codec/route resolution (
|
|
155
|
-
*
|
|
156
|
-
* Where `isSupported` trusts the fmt tag, this validates the declared
|
|
157
|
-
* codec against the container's actual structure (Vorbis sidecar,
|
|
158
|
-
* PTADPCM frame layout, PCM size consistency - bounded, no audio
|
|
159
|
-
* decode) and tries the other codecs when the declaration fails.
|
|
160
|
-
* The report carries `verified: true`, `preferred` = `ogg`/`pcm`/`raw`,
|
|
161
|
-
* and declared/resolved/mismatch evidence in `metadata`.
|
|
162
|
-
*
|
|
163
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
164
|
-
* @param {object} [options] Probe options.
|
|
165
|
-
* @returns {Promise<object>} Content-verified probe report.
|
|
153
|
+
/**
|
|
154
|
+
* Content-verified codec/route resolution (resolveType seam; see docs/concepts/format-type-resolution.md).
|
|
155
|
+
*
|
|
156
|
+
* Where `isSupported` trusts the fmt tag, this validates the declared
|
|
157
|
+
* codec against the container's actual structure (Vorbis sidecar,
|
|
158
|
+
* PTADPCM frame layout, PCM size consistency - bounded, no audio
|
|
159
|
+
* decode) and tries the other codecs when the declaration fails.
|
|
160
|
+
* The report carries `verified: true`, `preferred` = `ogg`/`pcm`/`raw`,
|
|
161
|
+
* and declared/resolved/mismatch evidence in `metadata`.
|
|
162
|
+
*
|
|
163
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
164
|
+
* @param {object} [options] Probe options.
|
|
165
|
+
* @returns {Promise<object>} Content-verified probe report.
|
|
166
166
|
*/
|
|
167
167
|
static async resolveType(input, options = {}) {
|
|
168
168
|
return resolveTypeWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
/**
|
|
172
|
-
* Convert format output into JSON-compatible debug data.
|
|
173
|
-
*
|
|
174
|
-
* @param {any} value Format output.
|
|
175
|
-
* @returns {any} JSON-compatible value.
|
|
171
|
+
/**
|
|
172
|
+
* Convert format output into JSON-compatible debug data.
|
|
173
|
+
*
|
|
174
|
+
* @param {any} value Format output.
|
|
175
|
+
* @returns {any} JSON-compatible value.
|
|
176
176
|
*/
|
|
177
177
|
static toJSON(value) {
|
|
178
178
|
return toJsonValue(value);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* Test whether bytes look like a Wwise media container.
|
|
183
|
-
*
|
|
184
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Candidate wem bytes.
|
|
185
|
-
* @returns {boolean} True when RIFF/RIFX WAVE signatures are present.
|
|
181
|
+
/**
|
|
182
|
+
* Test whether bytes look like a Wwise media container.
|
|
183
|
+
*
|
|
184
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Candidate wem bytes.
|
|
185
|
+
* @returns {boolean} True when RIFF/RIFX WAVE signatures are present.
|
|
186
186
|
*/
|
|
187
187
|
static isWEM(input) {
|
|
188
188
|
try {
|
|
@@ -192,16 +192,16 @@ class CjsWemFormat {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/**
|
|
196
|
-
* Repack Wwise Vorbis wem bytes into a standard Ogg Vorbis stream.
|
|
197
|
-
*
|
|
198
|
-
* Lossless container transform (no audio decode/re-encode); output plays
|
|
199
|
-
* natively where Ogg Vorbis is supported. Equivalent to
|
|
200
|
-
* `read(input, { emit: "ogg" })`.
|
|
201
|
-
*
|
|
202
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
203
|
-
* @param {object} [options] Options, including a `codebooks` override.
|
|
204
|
-
* @returns {object} Ogg payload with bytes, timing, and loop metadata.
|
|
195
|
+
/**
|
|
196
|
+
* Repack Wwise Vorbis wem bytes into a standard Ogg Vorbis stream.
|
|
197
|
+
*
|
|
198
|
+
* Lossless container transform (no audio decode/re-encode); output plays
|
|
199
|
+
* natively where Ogg Vorbis is supported. Equivalent to
|
|
200
|
+
* `read(input, { emit: "ogg" })`.
|
|
201
|
+
*
|
|
202
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
203
|
+
* @param {object} [options] Options, including a `codebooks` override.
|
|
204
|
+
* @returns {object} Ogg payload with bytes, timing, and loop metadata.
|
|
205
205
|
*/
|
|
206
206
|
static toOgg(input, options = {}) {
|
|
207
207
|
return CjsWemFormat.read(input, {
|
|
@@ -210,16 +210,16 @@ class CjsWemFormat {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
/**
|
|
214
|
-
* Decode wem audio data to per-channel float32 PCM (AudioBuffer-ready).
|
|
215
|
-
*
|
|
216
|
-
* Covers Wwise PTADPCM (0x8311) and uncompressed 16-bit PCM. Wwise Vorbis
|
|
217
|
-
* is not decoded here - repack it with `toOgg()` instead. Equivalent to
|
|
218
|
-
* `read(input, { emit: "pcm" })`.
|
|
219
|
-
*
|
|
220
|
-
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
221
|
-
* @param {object} [options] Read options.
|
|
222
|
-
* @returns {object} PCM payload with channelData, sample rate, and timing.
|
|
213
|
+
/**
|
|
214
|
+
* Decode wem audio data to per-channel float32 PCM (AudioBuffer-ready).
|
|
215
|
+
*
|
|
216
|
+
* Covers Wwise PTADPCM (0x8311) and uncompressed 16-bit PCM. Wwise Vorbis
|
|
217
|
+
* is not decoded here - repack it with `toOgg()` instead. Equivalent to
|
|
218
|
+
* `read(input, { emit: "pcm" })`.
|
|
219
|
+
*
|
|
220
|
+
* @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.
|
|
221
|
+
* @param {object} [options] Read options.
|
|
222
|
+
* @returns {object} PCM payload with channelData, sample rate, and timing.
|
|
223
223
|
*/
|
|
224
224
|
static toPcm(input, options = {}) {
|
|
225
225
|
return CjsWemFormat.read(input, {
|
|
@@ -228,8 +228,8 @@ class CjsWemFormat {
|
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
/**
|
|
232
|
-
* Emit targets for this format (canonical frozen enum).
|
|
231
|
+
/**
|
|
232
|
+
* Emit targets for this format (canonical frozen enum).
|
|
233
233
|
*/
|
|
234
234
|
static Output = Object.freeze({
|
|
235
235
|
RAW: OUTPUT_RAW,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWemFormat.js","sources":["../../../../src/formats/wem/CjsWemFormat.js"],"sourcesContent":["import {\n DEFAULT_VALUES,\n OUTPUT_JSON,\n OUTPUT_OGG,\n OUTPUT_PCM,\n OUTPUT_RAW,\n OUTPUT_WEM_JSON,\n WEM_CODEC_NAMES,\n inspectWithValues,\n isSupportedWithValues,\n isWEM,\n normalizeValues,\n readWithValues,\n toBytes,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { resolveTypeWithValues } from \"./core/resolve.js\";\n\nconst FORMAT_NAME = \"CjsWemFormat\";\n\n/**\n * Reader for Audiokinetic Wwise media (.wem) containers.\n *\n * Inspection identifies the codec, channel/rate layout, and Vorbis duration\n * without decoding audio data. Read emits the container bytes untouched by\n * default; `emit: \"ogg\"` repacks Wwise Vorbis into a standard Ogg stream and\n * `emit: \"pcm\"` decodes PTADPCM / 16-bit PCM media to float32 samples.\n */\nexport class CjsWemFormat\n{\n #values = DEFAULT_VALUES;\n\n /**\n * Browser-worker module declaration consumed by CjsResManWorkerLoader.\n */\n static worker = Object.freeze({\n module: import.meta.url,\n exportName: \"CjsWemFormat\"\n });\n\n /**\n * Create a reusable wem format profile.\n *\n * @param {object} [options] Default read/inspect options.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Merge options into this profile.\n *\n * @param {object} [options] Values to merge.\n * @returns {CjsWemFormat} This format profile.\n */\n SetValues(options = {})\n {\n this.#values = normalizeValues(this.#values, options, FORMAT_NAME);\n return this;\n }\n\n /**\n * Get normalized profile values with optional per-call overrides.\n *\n * @param {object} [options] Per-call values.\n * @returns {object} Normalized read values.\n */\n GetValues(options = {})\n {\n return normalizeValues(this.#values, options, FORMAT_NAME);\n }\n\n /**\n * Read wem bytes with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options));\n }\n\n /**\n * Read wem bytes asynchronously with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Per-call values.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n async ReadAsync(input, options = {})\n {\n return this.Read(input, options);\n }\n\n /**\n * Inspect wem bytes without decoding audio data.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} Wwise container metadata.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Report whether wem input and requested output variants are supported.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} Support/probe report.\n */\n IsSupported(input, options = {})\n {\n return isSupportedWithValues(input, this.GetValues(options));\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * One-shot wem read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Read options.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * One-shot asynchronous wem read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Read options.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n static async readAsync(input, options = {})\n {\n return CjsWemFormat.read(input, options);\n }\n\n /**\n * One-shot wem inspection.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Inspect options.\n * @returns {object} Wwise container metadata.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * One-shot wem support probe.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Support/probe report.\n */\n static isSupported(input, options = {})\n {\n return isSupportedWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Content-verified codec/route resolution (kb §5 resolveType seam).\n *\n * Where `isSupported` trusts the fmt tag, this validates the declared\n * codec against the container's actual structure (Vorbis sidecar,\n * PTADPCM frame layout, PCM size consistency - bounded, no audio\n * decode) and tries the other codecs when the declaration fails.\n * The report carries `verified: true`, `preferred` = `ogg`/`pcm`/`raw`,\n * and declared/resolved/mismatch evidence in `metadata`.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Probe options.\n * @returns {Promise<object>} Content-verified probe report.\n */\n static async resolveType(input, options = {})\n {\n return resolveTypeWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Test whether bytes look like a Wwise media container.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate wem bytes.\n * @returns {boolean} True when RIFF/RIFX WAVE signatures are present.\n */\n static isWEM(input)\n {\n try\n {\n return isWEM(toBytes(input));\n }\n catch\n {\n return false;\n }\n }\n\n /**\n * Repack Wwise Vorbis wem bytes into a standard Ogg Vorbis stream.\n *\n * Lossless container transform (no audio decode/re-encode); output plays\n * natively where Ogg Vorbis is supported. Equivalent to\n * `read(input, { emit: \"ogg\" })`.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Options, including a `codebooks` override.\n * @returns {object} Ogg payload with bytes, timing, and loop metadata.\n */\n static toOgg(input, options = {})\n {\n return CjsWemFormat.read(input, { ...options, emit: OUTPUT_OGG });\n }\n\n /**\n * Decode wem audio data to per-channel float32 PCM (AudioBuffer-ready).\n *\n * Covers Wwise PTADPCM (0x8311) and uncompressed 16-bit PCM. Wwise Vorbis\n * is not decoded here - repack it with `toOgg()` instead. Equivalent to\n * `read(input, { emit: \"pcm\" })`.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\n * @param {object} [options] Read options.\n * @returns {object} PCM payload with channelData, sample rate, and timing.\n */\n static toPcm(input, options = {})\n {\n return CjsWemFormat.read(input, { ...options, emit: OUTPUT_PCM });\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static Output = Object.freeze({\n RAW: OUTPUT_RAW,\n JSON: OUTPUT_JSON,\n WEM_JSON: OUTPUT_WEM_JSON,\n OGG: OUTPUT_OGG,\n PCM: OUTPUT_PCM\n });\n static CODEC_NAMES = WEM_CODEC_NAMES;\n static type = Object.freeze([ \"audio\" ]);\n static mediaTypes = Object.freeze([ \"audio\" ]);\n static inputTypes = Object.freeze([ \"wem\" ]);\n static outputTypes = Object.freeze([ OUTPUT_RAW, OUTPUT_OGG, OUTPUT_PCM ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_WEM_JSON, OUTPUT_RAW ]);\n}\n\nexport default CjsWemFormat;\n"],"names":["FORMAT_NAME","CjsWemFormat","DEFAULT_VALUES","worker","Object","freeze","module","import","meta","url","exportName","constructor","options","SetValues","normalizeValues","GetValues","Read","input","readWithValues","ReadAsync","Inspect","inspectWithValues","IsSupported","isSupportedWithValues","ToJSON","value","toJsonValue","read","readAsync","inspect","isSupported","resolveType","resolveTypeWithValues","toJSON","isWEM","toBytes","toOgg","emit","OUTPUT_OGG","toPcm","OUTPUT_PCM","Output","RAW","OUTPUT_RAW","JSON","OUTPUT_JSON","WEM_JSON","OUTPUT_WEM_JSON","OGG","PCM","CODEC_NAMES","WEM_CODEC_NAMES","type","mediaTypes","inputTypes","outputTypes","debugOutputTypes"],"mappings":";;;AAkBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,CACzB;EACI,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACI,EAAA,OAAOC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC1BC,IAAAA,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,GAAG;AACvBC,IAAAA,UAAU,EAAE;AAChB,GAAC,CAAC;;AAEF;AACJ;AACA;AACA;AACA;AACIC,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,IAAI,CAAC,OAAO,GAAGE,eAAe,CAAC,IAAI,CAAC,OAAO,EAAEF,OAAO,EAAEZ,WAAW,CAAC;AAClE,IAAA,OAAO,IAAI;AACf,EAAA;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,eAAe,EAAEJ,UAAU,CAAE,CAAC;AAC5E;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWemFormat.js","sources":["../../../../src/formats/wem/CjsWemFormat.js"],"sourcesContent":["import {\r\n DEFAULT_VALUES,\r\n OUTPUT_JSON,\r\n OUTPUT_OGG,\r\n OUTPUT_PCM,\r\n OUTPUT_RAW,\r\n OUTPUT_WEM_JSON,\r\n WEM_CODEC_NAMES,\r\n inspectWithValues,\r\n isSupportedWithValues,\r\n isWEM,\r\n normalizeValues,\r\n readWithValues,\r\n toBytes,\r\n toJsonValue\r\n} from \"./core/helpers.js\";\r\nimport { resolveTypeWithValues } from \"./core/resolve.js\";\r\n\r\nconst FORMAT_NAME = \"CjsWemFormat\";\r\n\r\n/**\r\n * Reader for Audiokinetic Wwise media (.wem) containers.\r\n *\r\n * Inspection identifies the codec, channel/rate layout, and Vorbis duration\r\n * without decoding audio data. Read emits the container bytes untouched by\r\n * default; `emit: \"ogg\"` repacks Wwise Vorbis into a standard Ogg stream and\r\n * `emit: \"pcm\"` decodes PTADPCM / 16-bit PCM media to float32 samples.\r\n */\r\nexport class CjsWemFormat\r\n{\r\n #values = DEFAULT_VALUES;\r\n\r\n /**\r\n * Browser-worker module declaration consumed by CjsResManWorkerLoader.\r\n */\r\n static worker = Object.freeze({\r\n module: import.meta.url,\r\n exportName: \"CjsWemFormat\"\r\n });\r\n\r\n /**\r\n * Create a reusable wem format profile.\r\n *\r\n * @param {object} [options] Default read/inspect options.\r\n */\r\n constructor(options = {})\r\n {\r\n this.SetValues(options);\r\n }\r\n\r\n /**\r\n * Merge options into this profile.\r\n *\r\n * @param {object} [options] Values to merge.\r\n * @returns {CjsWemFormat} This format profile.\r\n */\r\n SetValues(options = {})\r\n {\r\n this.#values = normalizeValues(this.#values, options, FORMAT_NAME);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get normalized profile values with optional per-call overrides.\r\n *\r\n * @param {object} [options] Per-call values.\r\n * @returns {object} Normalized read values.\r\n */\r\n GetValues(options = {})\r\n {\r\n return normalizeValues(this.#values, options, FORMAT_NAME);\r\n }\r\n\r\n /**\r\n * Read wem bytes with this profile.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Per-call values.\r\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\r\n */\r\n Read(input, options = {})\r\n {\r\n return readWithValues(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read wem bytes asynchronously with this profile.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Per-call values.\r\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\r\n */\r\n async ReadAsync(input, options = {})\r\n {\r\n return this.Read(input, options);\r\n }\r\n\r\n /**\r\n * Inspect wem bytes without decoding audio data.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Per-call values.\r\n * @returns {object} Wwise container metadata.\r\n */\r\n Inspect(input, options = {})\r\n {\r\n return inspectWithValues(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Report whether wem input and requested output variants are supported.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Per-call values.\r\n * @returns {object} Support/probe report.\r\n */\r\n IsSupported(input, options = {})\r\n {\r\n return isSupportedWithValues(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Convert format output into JSON-compatible debug data.\r\n *\r\n * @param {any} value Format output.\r\n * @returns {any} JSON-compatible value.\r\n */\r\n ToJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /**\r\n * One-shot wem read.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Read options.\r\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\r\n */\r\n static read(input, options = {})\r\n {\r\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\r\n }\r\n\r\n /**\r\n * One-shot asynchronous wem read.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Read options.\r\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\r\n */\r\n static async readAsync(input, options = {})\r\n {\r\n return CjsWemFormat.read(input, options);\r\n }\r\n\r\n /**\r\n * One-shot wem inspection.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Inspect options.\r\n * @returns {object} Wwise container metadata.\r\n */\r\n static inspect(input, options = {})\r\n {\r\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\r\n }\r\n\r\n /**\r\n * One-shot wem support probe.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {object} Support/probe report.\r\n */\r\n static isSupported(input, options = {})\r\n {\r\n return isSupportedWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\r\n }\r\n\r\n /**\r\n * Content-verified codec/route resolution (resolveType seam; see docs/concepts/format-type-resolution.md).\r\n *\r\n * Where `isSupported` trusts the fmt tag, this validates the declared\r\n * codec against the container's actual structure (Vorbis sidecar,\r\n * PTADPCM frame layout, PCM size consistency - bounded, no audio\r\n * decode) and tries the other codecs when the declaration fails.\r\n * The report carries `verified: true`, `preferred` = `ogg`/`pcm`/`raw`,\r\n * and declared/resolved/mismatch evidence in `metadata`.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {Promise<object>} Content-verified probe report.\r\n */\r\n static async resolveType(input, options = {})\r\n {\r\n return resolveTypeWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\r\n }\r\n\r\n /**\r\n * Convert format output into JSON-compatible debug data.\r\n *\r\n * @param {any} value Format output.\r\n * @returns {any} JSON-compatible value.\r\n */\r\n static toJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /**\r\n * Test whether bytes look like a Wwise media container.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate wem bytes.\r\n * @returns {boolean} True when RIFF/RIFX WAVE signatures are present.\r\n */\r\n static isWEM(input)\r\n {\r\n try\r\n {\r\n return isWEM(toBytes(input));\r\n }\r\n catch\r\n {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Repack Wwise Vorbis wem bytes into a standard Ogg Vorbis stream.\r\n *\r\n * Lossless container transform (no audio decode/re-encode); output plays\r\n * natively where Ogg Vorbis is supported. Equivalent to\r\n * `read(input, { emit: \"ogg\" })`.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Options, including a `codebooks` override.\r\n * @returns {object} Ogg payload with bytes, timing, and loop metadata.\r\n */\r\n static toOgg(input, options = {})\r\n {\r\n return CjsWemFormat.read(input, { ...options, emit: OUTPUT_OGG });\r\n }\r\n\r\n /**\r\n * Decode wem audio data to per-channel float32 PCM (AudioBuffer-ready).\r\n *\r\n * Covers Wwise PTADPCM (0x8311) and uncompressed 16-bit PCM. Wwise Vorbis\r\n * is not decoded here - repack it with `toOgg()` instead. Equivalent to\r\n * `read(input, { emit: \"pcm\" })`.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|DataView} input Wem bytes.\r\n * @param {object} [options] Read options.\r\n * @returns {object} PCM payload with channelData, sample rate, and timing.\r\n */\r\n static toPcm(input, options = {})\r\n {\r\n return CjsWemFormat.read(input, { ...options, emit: OUTPUT_PCM });\r\n }\r\n\r\n /**\r\n * Emit targets for this format (canonical frozen enum).\r\n */\r\n static Output = Object.freeze({\r\n RAW: OUTPUT_RAW,\r\n JSON: OUTPUT_JSON,\r\n WEM_JSON: OUTPUT_WEM_JSON,\r\n OGG: OUTPUT_OGG,\r\n PCM: OUTPUT_PCM\r\n });\r\n static CODEC_NAMES = WEM_CODEC_NAMES;\r\n static type = Object.freeze([ \"audio\" ]);\r\n static mediaTypes = Object.freeze([ \"audio\" ]);\r\n static inputTypes = Object.freeze([ \"wem\" ]);\r\n static outputTypes = Object.freeze([ OUTPUT_RAW, OUTPUT_OGG, OUTPUT_PCM ]);\r\n static debugOutputTypes = Object.freeze([ OUTPUT_WEM_JSON, OUTPUT_RAW ]);\r\n}\r\n\r\nexport default CjsWemFormat;\r\n"],"names":["FORMAT_NAME","CjsWemFormat","DEFAULT_VALUES","worker","Object","freeze","module","import","meta","url","exportName","constructor","options","SetValues","normalizeValues","GetValues","Read","input","readWithValues","ReadAsync","Inspect","inspectWithValues","IsSupported","isSupportedWithValues","ToJSON","value","toJsonValue","read","readAsync","inspect","isSupported","resolveType","resolveTypeWithValues","toJSON","isWEM","toBytes","toOgg","emit","OUTPUT_OGG","toPcm","OUTPUT_PCM","Output","RAW","OUTPUT_RAW","JSON","OUTPUT_JSON","WEM_JSON","OUTPUT_WEM_JSON","OGG","PCM","CODEC_NAMES","WEM_CODEC_NAMES","type","mediaTypes","inputTypes","outputTypes","debugOutputTypes"],"mappings":";;;AAkBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,CACzB;EACI,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACI,EAAA,OAAOC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC1BC,IAAAA,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,GAAG;AACvBC,IAAAA,UAAU,EAAE;AAChB,GAAC,CAAC;;AAEF;AACJ;AACA;AACA;AACA;AACIC,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,IAAI,CAAC,OAAO,GAAGE,eAAe,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AU,EAAEE,UAAU,CAAE,CAAC;EAC1E,OAAOgB,gBAAgB,GAAGpD,MAAM,CAACC,MAAM,CAAC,CAAE0C,eAAe,EAAEJ,UAAU,CAAE,CAAC;AAC5E;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inspectWithValues } from './helpers.js';
|
|
2
2
|
|
|
3
|
-
// Content-verified codec resolution for wem media (
|
|
3
|
+
// Content-verified codec resolution for wem media (resolveType seam; see docs/concepts/format-type-resolution.md).
|
|
4
4
|
// The fmt tag is the declaration; each candidate codec gets ONE bounded
|
|
5
5
|
// structural check against the actual container facts - no audio is decoded:
|
|
6
6
|
//
|
|
@@ -49,13 +49,13 @@ function emitFor(candidate) {
|
|
|
49
49
|
return "raw";
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Resolve a wem's actual decode route from content, not just its fmt tag.
|
|
54
|
-
*
|
|
55
|
-
* @param {*} input Wem bytes.
|
|
56
|
-
* @param {object} values Normalized read values.
|
|
57
|
-
* @returns {object} Probe-shaped report: verified variant flags, `preferred`
|
|
58
|
-
* route, and declared/resolved/mismatch evidence in `metadata`.
|
|
52
|
+
/**
|
|
53
|
+
* Resolve a wem's actual decode route from content, not just its fmt tag.
|
|
54
|
+
*
|
|
55
|
+
* @param {*} input Wem bytes.
|
|
56
|
+
* @param {object} values Normalized read values.
|
|
57
|
+
* @returns {object} Probe-shaped report: verified variant flags, `preferred`
|
|
58
|
+
* route, and declared/resolved/mismatch evidence in `metadata`.
|
|
59
59
|
*/
|
|
60
60
|
function resolveTypeWithValues(input, values) {
|
|
61
61
|
const metadata = inspectWithValues(input, values);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sources":["../../../../../src/formats/wem/core/resolve.js"],"sourcesContent":["// Content-verified codec resolution for wem media (kb §5 resolveType seam).\n// The fmt tag is the declaration; each candidate codec gets ONE bounded\n// structural check against the actual container facts - no audio is decoded:\n//\n// - wwise-vorbis: the Wwise Vorbis sidecar must exist (vorb chunk or inline\n// fmt-0x42 layout) with a positive sample count and data payload;\n// - wwise-ptadpcm: the frame layout must satisfy the decoder's own guard\n// (blockAlign = frameSize * channels, frameSize >= 6) with block-aligned\n// data;\n// - pcm / pcm-extensible: 16-bit with self-consistent blockAlign/byteRate\n// and sample-aligned data.\n//\n// The declared codec is validated FIRST; when its check fails (a mislabeled\n// tag), the other candidates are tried in order. A 2026-07-19 census of all\n// 8,987 embedded wems in EVE build 3435006 found no mislabeled tags, so\n// mismatch is the exceptional path - but the check is what makes that a\n// verified fact per file rather than a corpus-wide assumption.\nimport { inspectWithValues } from \"./helpers.js\";\n\nconst CANDIDATES = [ \"wwise-vorbis\", \"wwise-ptadpcm\", \"pcm\" ];\n\nfunction validateVorbis(metadata)\n{\n if (metadata.codec === \"wwise-vorbis\")\n {\n return metadata.vorbis !== null && metadata.sampleCount > 0 && metadata.dataBytes > 0;\n }\n // Mislabeled tag: inspect() only fills `vorbis` when the tag says so, but\n // the chunk walk always records a standalone vorb sidecar chunk.\n return (metadata.chunks ?? []).some(chunk => chunk.id === \"vorb\") && metadata.dataBytes > 0;\n}\n\nfunction validatePtadpcm(metadata)\n{\n const channels = metadata.channels;\n const frameSize = channels > 0 ? Math.floor(metadata.blockAlign / channels) : 0;\n return channels >= 1\n && frameSize >= 6\n && metadata.blockAlign === frameSize * channels\n && metadata.dataBytes >= metadata.blockAlign\n && metadata.dataBytes % metadata.blockAlign === 0;\n}\n\nfunction validatePcm(metadata)\n{\n return metadata.bitsPerSample === 16\n && metadata.channels >= 1\n && metadata.blockAlign === metadata.channels * 2\n && metadata.byteRate === metadata.sampleRate * metadata.blockAlign\n && metadata.dataBytes > 0\n && metadata.dataBytes % metadata.blockAlign === 0;\n}\n\nfunction validate(candidate, metadata)\n{\n if (candidate === \"wwise-vorbis\") return validateVorbis(metadata);\n if (candidate === \"wwise-ptadpcm\") return validatePtadpcm(metadata);\n return validatePcm(metadata);\n}\n\nfunction candidateFor(codec)\n{\n if (codec === \"pcm-extensible\") return \"pcm\";\n return CANDIDATES.includes(codec) ? codec : null;\n}\n\nfunction emitFor(candidate)\n{\n if (candidate === \"wwise-vorbis\") return \"ogg\";\n if (candidate === \"wwise-ptadpcm\" || candidate === \"pcm\") return \"pcm\";\n return \"raw\";\n}\n\n/**\n * Resolve a wem's actual decode route from content, not just its fmt tag.\n *\n * @param {*} input Wem bytes.\n * @param {object} values Normalized read values.\n * @returns {object} Probe-shaped report: verified variant flags, `preferred`\n * route, and declared/resolved/mismatch evidence in `metadata`.\n */\nexport function resolveTypeWithValues(input, values)\n{\n const metadata = inspectWithValues(input, values);\n const declared = metadata.codec || null;\n let resolved = null;\n const declaredCandidate = candidateFor(declared);\n if (declaredCandidate && validate(declaredCandidate, metadata))\n {\n resolved = declaredCandidate;\n }\n else\n {\n for (const candidate of CANDIDATES)\n {\n if (candidate === declaredCandidate) continue;\n if (validate(candidate, metadata))\n {\n resolved = candidate;\n break;\n }\n }\n }\n\n const preferred = emitFor(resolved);\n const mismatch = resolved !== null && declaredCandidate !== resolved;\n return {\n format: \"wem\",\n source: values.source || \"buffer\",\n supported: metadata.codec ? \"partial\" : \"none\",\n confidence: resolved ? 1 : 0,\n verified: true,\n preferred,\n reason: resolved\n ? (mismatch\n ? `Declared codec ${declared} failed content validation; ${resolved} validated instead.`\n : `Declared codec validated by content.`)\n : `No decodable codec validated against the content (declared ${declared ?? \"none\"}).`,\n metadata: { ...metadata, declared, resolved, mismatch },\n variants: [\n {\n kind: \"raw\",\n payloadType: \"raw\",\n codec: declared || \"unknown\",\n mimeType: \"application/octet-stream\",\n supported: true,\n containerOnly: true,\n isDecoded: false,\n pcmDecodeSupported: false\n },\n {\n kind: \"ogg\",\n payloadType: \"raw\",\n codec: \"vorbis\",\n mimeType: \"audio/ogg\",\n supported: resolved === \"wwise-vorbis\",\n containerOnly: true,\n isDecoded: false\n },\n {\n kind: \"pcm\",\n payloadType: \"pcm\",\n codec: \"float32\",\n supported: resolved === \"wwise-ptadpcm\" || resolved === \"pcm\",\n isDecoded: true,\n pcmDecodeSupported: resolved === \"wwise-ptadpcm\" || resolved === \"pcm\"\n }\n ]\n };\n}\n"],"names":["CANDIDATES","validateVorbis","metadata","codec","vorbis","sampleCount","dataBytes","chunks","some","chunk","id","validatePtadpcm","channels","frameSize","Math","floor","blockAlign","validatePcm","bitsPerSample","byteRate","sampleRate","validate","candidate","candidateFor","includes","emitFor","resolveTypeWithValues","input","values","inspectWithValues","declared","resolved","declaredCandidate","preferred","mismatch","format","source","supported","confidence","verified","reason","variants","kind","payloadType","mimeType","containerOnly","isDecoded","pcmDecodeSupported"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,UAAU,GAAG,CAAE,cAAc,EAAE,eAAe,EAAE,KAAK,CAAE;AAE7D,SAASC,cAAcA,CAACC,QAAQ,EAChC;AACI,EAAA,IAAIA,QAAQ,CAACC,KAAK,KAAK,cAAc,EACrC;AACI,IAAA,OAAOD,QAAQ,CAACE,MAAM,KAAK,IAAI,IAAIF,QAAQ,CAACG,WAAW,GAAG,CAAC,IAAIH,QAAQ,CAACI,SAAS,GAAG,CAAC;AACzF,EAAA;AACA;AACA;EACA,OAAO,CAACJ,QAAQ,CAACK,MAAM,IAAI,EAAE,EAAEC,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACC,EAAE,KAAK,MAAM,CAAC,IAAIR,QAAQ,CAACI,SAAS,GAAG,CAAC;AAC/F;AAEA,SAASK,eAAeA,CAACT,QAAQ,EACjC;AACI,EAAA,MAAMU,QAAQ,GAAGV,QAAQ,CAACU,QAAQ;AAClC,EAAA,MAAMC,SAAS,GAAGD,QAAQ,GAAG,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACb,QAAQ,CAACc,UAAU,GAAGJ,QAAQ,CAAC,GAAG,CAAC;AAC/E,EAAA,OAAOA,QAAQ,IAAI,CAAC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tF,CAAA,oCAAA,CAAsC,GAC1C,8DAA8DD,QAAQ,IAAI,MAAM,CAAA,EAAA,CAAI;AAC1F5B,IAAAA,QAAQ,EAAE;AAAE,MAAA,GAAGA,QAAQ;MAAE4B,QAAQ;MAAEC,QAAQ;AAAEG,MAAAA;KAAU;AACvDO,IAAAA,QAAQ,EAAE,CACN;AACIC,MAAAA,IAAI,EAAE,KAAK;AACXC,MAAAA,WAAW,EAAE,KAAK;MAClBxC,KAAK,EAAE2B,QAAQ,IAAI,SAAS;AAC5Bc,MAAAA,QAAQ,EAAE,0BAA0B;AACpCP,MAAAA,SAAS,EAAE,IAAI;AACfQ,MAAAA,aAAa,EAAE,IAAI;AACnBC,MAAAA,SAAS,EAAE,KAAK;AAChBC,MAAAA,kBAAkB,EAAE;AACxB,KAAC,EACD;AACIL,MAAAA,IAAI,EAAE,KAAK;AACXC,MAAAA,WAAW,EAAE,KAAK;AAClBxC,MAAAA,KAAK,EAAE,QAAQ;AACfyC,MAAAA,QAAQ,EAAE,WAAW;MACrBP,SAAS,EAAEN,QAAQ,KAAK,cAAc;AACtCc,MAAAA,aAAa,EAAE,IAAI;AACnBC,MAAAA,SAAS,EAAE;AACf,KAAC,EACD;AACIJ,MAAAA,IAAI,EAAE,KAAK;AACXC,MAAAA,WAAW,EAAE,KAAK;AAClBxC,MAAAA,KAAK,EAAE,SAAS;AAChBkC,MAAAA,SAAS,EAAEN,QAAQ,KAAK,eAAe,IAAIA,QAAQ,KAAK,KAAK;AAC7De,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,kBAAkB,EAAEhB,QAAQ,KAAK,eAAe,IAAIA,QAAQ,KAAK;KACpE;GAER;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"resolve.js","sources":["../../../../../src/formats/wem/core/resolve.js"],"sourcesContent":["// Content-verified codec resolution for wem media (resolveType seam; see docs/concepts/format-type-resolution.md).\r\n// The fmt tag is the declaration; each candidate codec gets ONE bounded\r\n// structural check against the actual container facts - no audio is decoded:\r\n//\r\n// - wwise-vorbis: the Wwise Vorbis sidecar must exist (vorb chunk or inline\r\n// fmt-0x42 layout) with a positive sample count and data payload;\r\n// - wwise-ptadpcm: the frame layout must satisfy the decoder's own guard\r\n// (blockAlign = frameSize * channels, frameSize >= 6) with block-aligned\r\n// data;\r\n// - pcm / pcm-extensible: 16-bit with self-consistent blockAlign/byteRate\r\n// and sample-aligned data.\r\n//\r\n// The declared codec is validated FIRST; when its check fails (a mislabeled\r\n// tag), the other candidates are tried in order. A 2026-07-19 census of all\r\n// 8,987 embedded wems in EVE build 3435006 found no mislabeled tags, so\r\n// mismatch is the exceptional path - but the check is what makes that a\r\n// verified fact per file rather than a corpus-wide assumption.\r\nimport { inspectWithValues } from \"./helpers.js\";\r\n\r\nconst CANDIDATES = [ \"wwise-vorbis\", \"wwise-ptadpcm\", \"pcm\" ];\r\n\r\nfunction validateVorbis(metadata)\r\n{\r\n if (metadata.codec === \"wwise-vorbis\")\r\n {\r\n return metadata.vorbis !== null && metadata.sampleCount > 0 && metadata.dataBytes > 0;\r\n }\r\n // Mislabeled tag: inspect() only fills `vorbis` when the tag says so, but\r\n // the chunk walk always records a standalone vorb sidecar chunk.\r\n return (metadata.chunks ?? []).some(chunk => chunk.id === \"vorb\") && metadata.dataBytes > 0;\r\n}\r\n\r\nfunction validatePtadpcm(metadata)\r\n{\r\n const channels = metadata.channels;\r\n const frameSize = channels > 0 ? Math.floor(metadata.blockAlign / channels) : 0;\r\n return channels >= 1\r\n && frameSize >= 6\r\n && metadata.blockAlign === frameSize * channels\r\n && metadata.dataBytes >= metadata.blockAlign\r\n && metadata.dataBytes % metadata.blockAlign === 0;\r\n}\r\n\r\nfunction validatePcm(metadata)\r\n{\r\n return metadata.bitsPerSample === 16\r\n && metadata.channels >= 1\r\n && metadata.blockAlign === metadata.channels * 2\r\n && metadata.byteRate === metadata.sampleRate * metadata.blockAlign\r\n && metadata.dataBytes > 0\r\n && metadata.dataBytes % metadata.blockAlign === 0;\r\n}\r\n\r\nfunction validate(candidate, metadata)\r\n{\r\n if (candidate === \"wwise-vorbis\") return validateVorbis(metadata);\r\n if (candidate === \"wwise-ptadpcm\") return validatePtadpcm(metadata);\r\n return validatePcm(metadata);\r\n}\r\n\r\nfunction candidateFor(codec)\r\n{\r\n if (codec === \"pcm-extensible\") return \"pcm\";\r\n return CANDIDATES.includes(codec) ? codec : null;\r\n}\r\n\r\nfunction emitFor(candidate)\r\n{\r\n if (candidate === \"wwise-vorbis\") return \"ogg\";\r\n if (candidate === \"wwise-ptadpcm\" || candidate === \"pcm\") return \"pcm\";\r\n return \"raw\";\r\n}\r\n\r\n/**\r\n * Resolve a wem's actual decode route from content, not just its fmt tag.\r\n *\r\n * @param {*} input Wem bytes.\r\n * @param {object} values Normalized read values.\r\n * @returns {object} Probe-shaped report: verified variant flags, `preferred`\r\n * route, and declared/resolved/mismatch evidence in `metadata`.\r\n */\r\nexport function resolveTypeWithValues(input, values)\r\n{\r\n const metadata = inspectWithValues(input, values);\r\n const declared = metadata.codec || null;\r\n let resolved = null;\r\n const declaredCandidate = candidateFor(declared);\r\n if (declaredCandidate && validate(declaredCandidate, metadata))\r\n {\r\n resolved = declaredCandidate;\r\n }\r\n else\r\n {\r\n for (const candidate of CANDIDATES)\r\n {\r\n if (candidate === declaredCandidate) continue;\r\n if (validate(candidate, metadata))\r\n {\r\n resolved = candidate;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const preferred = emitFor(resolved);\r\n const mismatch = resolved !== null && declaredCandidate !== resolved;\r\n return {\r\n format: \"wem\",\r\n source: values.source || \"buffer\",\r\n supported: metadata.codec ? \"partial\" : \"none\",\r\n confidence: resolved ? 1 : 0,\r\n verified: true,\r\n preferred,\r\n reason: resolved\r\n ? (mismatch\r\n ? `Declared codec ${declared} failed content validation; ${resolved} validated instead.`\r\n : `Declared codec validated by content.`)\r\n : `No decodable codec validated against the content (declared ${declared ?? \"none\"}).`,\r\n metadata: { ...metadata, declared, resolved, mismatch },\r\n variants: [\r\n {\r\n kind: \"raw\",\r\n payloadType: \"raw\",\r\n codec: declared || \"unknown\",\r\n mimeType: \"application/octet-stream\",\r\n supported: true,\r\n containerOnly: true,\r\n isDecoded: false,\r\n pcmDecodeSupported: false\r\n },\r\n {\r\n kind: \"ogg\",\r\n payloadType: \"raw\",\r\n codec: \"vorbis\",\r\n mimeType: \"audio/ogg\",\r\n supported: resolved === \"wwise-vorbis\",\r\n containerOnly: true,\r\n isDecoded: false\r\n },\r\n {\r\n kind: \"pcm\",\r\n payloadType: \"pcm\",\r\n codec: \"float32\",\r\n supported: resolved === \"wwise-ptadpcm\" || resolved === \"pcm\",\r\n isDecoded: true,\r\n pcmDecodeSupported: resolved === \"wwise-ptadpcm\" || resolved === \"pcm\"\r\n }\r\n ]\r\n };\r\n}\r\n"],"names":["CANDIDATES","validateVorbis","metadata","codec","vorbis","sampleCount","dataBytes","chunks","some","chunk","id","validatePtadpcm","channels","frameSize","Math","floor","blockAlign","validatePcm","bitsPerSample","byteRate","sampleRate","validate","candidate","candidateFor","includes","emitFor","resolveTypeWithValues","input","values","inspectWithValues","declared","resolved","declaredCandidate","preferred","mismatch","format","source","supported","confidence","verified","reason","variants","kind","payloadType","mimeType","containerOnly","isDecoded","pcmDecodeSupported"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,UAAU,GAAG,CAAE,cAAc,EAAE,eAAe,EAAE,KAAK,CAAE;AAE7D,SAASC,cAAcA,CAACC,QAAQ,EAChC;AACI,EAAA,IAAIA,QAAQ,CAACC,KAAK,KAAK,cAAc,EACrC;AACI,IAAA,OAAOD,QAAQ,CAACE,MAAM,KAAK,IAAI,IAAIF,QAAQ,CAACG,WAAW,GAAG,CAAC,IAAIH,QAAQ,CAACI,SAAS,GAAG,CAAC;AACzF,EAAA;AACA;AACA;EACA,OAAO,CAACJ,QAAQ,CAACK,MAAM,IAAI,EAAE,EAAE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AAAA,SAAS,EAAEN,QAAQ,KAAK,eAAe,IAAIA,QAAQ,KAAK,KAAK;AAC7De,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,kBAAkB,EAAEhB,QAAQ,KAAK,eAAe,IAAIA,QAAQ,KAAK;KACpE;GAER;AACL;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CjsSchema, type, impl
|
|
1
|
+
import { CjsSchema, type, impl } from '@carbonenginejs/runtime-utils/schema';
|
|
2
2
|
import { CjsModel } from '@carbonenginejs/runtime-utils/model';
|
|
3
3
|
import { dwordToFloat } from '@carbonenginejs/runtime-utils/math/num';
|
|
4
4
|
import { isPlainObject } from '@carbonenginejs/runtime-utils/is';
|
|
@@ -112,7 +112,7 @@ CjsSchema.define(Tr2EffectParameterAnnotation, {
|
|
|
112
112
|
family: "shader",
|
|
113
113
|
fields: {
|
|
114
114
|
name: type.string,
|
|
115
|
-
type: [type.int32,
|
|
115
|
+
type: [type.int32, type.enum("Type")],
|
|
116
116
|
boolValue: type.boolean,
|
|
117
117
|
rawValue: [impl.adapted, impl.reason("Carbon reads numeric annotations into typed values; the portable source contract retains the exact uint32 payload so NaN, negative zero, and integer bit patterns round-trip losslessly."), type.uint32],
|
|
118
118
|
intValue: type.int32,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tr2EffectParameterAnnotation.js","sources":["../../../../../src/resource/shader/reflection/Tr2EffectParameterAnnotation.js"],"sourcesContent":["// Source: trinity/trinity/Shader/Tr2EffectDescription.h\nimport { CjsSchema, impl,
|
|
1
|
+
{"version":3,"file":"Tr2EffectParameterAnnotation.js","sources":["../../../../../src/resource/shader/reflection/Tr2EffectParameterAnnotation.js"],"sourcesContent":["// Source: trinity/trinity/Shader/Tr2EffectDescription.h\nimport { CjsSchema, impl, type } from \"@carbonenginejs/runtime-utils/schema\";\nimport { CjsModel } from \"@carbonenginejs/runtime-utils/model\";\nimport { dwordToFloat } from \"@carbonenginejs/runtime-utils/math/num\";\nimport {\n isPlainObject\n} from \"@carbonenginejs/runtime-utils/is\";\nimport { recordRawValue, recordText, toRecordRawValue, toRecordText } from \"./carbonRecordFields.js\";\n\n/** Typed annotation attached to a reflected effect parameter. */\nexport class Tr2EffectParameterAnnotation extends CjsModel\n{\n\n /** name (const char*) */\n name = \"\";\n\n /** type (Type - enum Type) */\n type = 0;\n\n /** boolValue (bool) */\n boolValue = false;\n\n /** Exact serialized BOOL, INT, or FLOAT payload bits. */\n rawValue = 0;\n\n /** intValue (int) */\n intValue = 0;\n\n /** floatValue (float) */\n floatValue = 0;\n\n /** stringValue (const char*) */\n stringValue = \"\";\n\n /**\n * Build one typed annotation from its Carbon v15 description record.\n *\n * The type byte decides which member is meaningful, and every non-string type\n * arrives as four untyped bytes rather than a number — Carbon writes the value\n * through one member of a `{float,int32_t}` union and reads it back through\n * another, so the bit pattern is the only faithful carrier. `rawValue` keeps\n * those bits and the typed accessor is derived from them, never the reverse.\n *\n * @param {object} record Carbon annotation record.\n * @returns {Tr2EffectParameterAnnotation} Reflected annotation.\n */\n static fromCarbonBinary(record)\n {\n if (!isPlainObject(record))\n {\n throw new TypeError(\"Carbon effect annotation record must be an object\");\n }\n\n const annotation = new this();\n annotation.name = recordText(record.name);\n annotation.type = record.type;\n\n switch (annotation.type)\n {\n case this.Type.BOOL:\n annotation.rawValue = recordRawValue(record.rawValue);\n annotation.boolValue = annotation.rawValue !== 0;\n break;\n\n case this.Type.INT:\n annotation.rawValue = recordRawValue(record.rawValue);\n annotation.intValue = annotation.rawValue | 0;\n break;\n\n case this.Type.FLOAT:\n annotation.rawValue = recordRawValue(record.rawValue);\n annotation.floatValue = dwordToFloat(annotation.rawValue);\n break;\n\n case this.Type.STRING:\n annotation.stringValue = recordText(record.stringValue);\n break;\n\n default:\n throw new Error(\n `Carbon effect annotation type ${annotation.type} is unsupported`\n );\n }\n\n return annotation;\n }\n\n /**\n * Emit this annotation as a Carbon v15 record.\n *\n * The type byte decides which branch the writer takes, and every non-string\n * type travels as the raw bits rather than the typed member.\n *\n * @returns {object} Carbon annotation record.\n */\n toCarbonBinary()\n {\n if (this.type === Tr2EffectParameterAnnotation.Type.STRING)\n {\n return {\n name: toRecordText(this.name),\n type: this.type,\n stringValue: toRecordText(this.stringValue),\n rawValue: null\n };\n }\n return {\n name: toRecordText(this.name),\n type: this.type,\n stringValue: null,\n rawValue: toRecordRawValue(this.rawValue)\n };\n }\n\n static Type = Object.freeze({\n BOOL: 0,\n INT: 1,\n FLOAT: 2,\n STRING: 3\n });\n\n}\n\n// Declared imperatively rather than with decorators, so this module stays\n// plain ESM that loads from source without a transform. The decorator\n// expressions are reused verbatim, so the registered metadata is identical.\n// Statics belong in `methods`: decorateMethod targets the prototype and\n// would register a static as an instance field.\nCjsSchema.define(Tr2EffectParameterAnnotation, {\n className: \"Tr2EffectParameterAnnotation\",\n family: \"shader\",\n fields: {\n name: type.string,\n type: [ type.int32, type.enum(\"Type\") ],\n boolValue: type.boolean,\n rawValue: [ impl.adapted, impl.reason(\"Carbon reads numeric annotations into typed values; the portable source contract retains the exact uint32 payload so NaN, negative zero, and integer bit patterns round-trip losslessly.\"), type.uint32 ],\n intValue: type.int32,\n floatValue: type.float32,\n stringValue: type.string\n }\n});\n"],"names":["Tr2EffectParameterAnnotation","CjsModel","name","type","boolValue","rawValue","intValue","floatValue","stringValue","fromCarbonBinary","record","isPlainObject","TypeError","annotation","recordText","Type","BOOL","recordRawValue","INT","FLOAT","dwordToFloat","STRING","Error","toCarbonBinary","toRecordText","toRecordRawValue","Object","freeze","CjsSchema","define","className","family","fields","string","int32","enum","boolean","impl","adapted","reason","uint32","float32"],"mappings":";;;;;;AAAA;;AASA;AACO,MAAMA,4BAA4B,SAASC,QAAQ,CAC1D;AAEE;AACAC,EAAAA,IAAI,GAAG,EAAE;;AAET;AACAC,EAAAA,IAAI,GAAG,CAAC;;AAER;AACAC,EAAAA,SAAS,GAAG,KAAK;;AAEjB;AACAC,EAAAA,QAAQ,GAAG,CA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AE,CAAEA,IAAI,CAAC+B,KAAK,EAAE/B,IAAI,CAACgC,IAAI,CAAC,MAAM,CAAC,CAAE;IACvC/B,SAAS,EAAED,IAAI,CAACiC,OAAO;AACvB/B,IAAAA,QAAQ,EAAE,CAAEgC,IAAI,CAACC,OAAO,EAAED,IAAI,CAACE,MAAM,CAAC,0LAA0L,CAAC,EAAEpC,IAAI,CAACqC,MAAM,CAAE;IAChPlC,QAAQ,EAAEH,IAAI,CAAC+B,KAAK;IACpB3B,UAAU,EAAEJ,IAAI,CAACsC,OAAO;IACxBjC,WAAW,EAAEL,IAAI,CAAC8B;AACpB;AACF,CAAC,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CjsSchema, type
|
|
1
|
+
import { CjsSchema, type } from '@carbonenginejs/runtime-utils/schema';
|
|
2
2
|
import { CjsModel } from '@carbonenginejs/runtime-utils/model';
|
|
3
3
|
import { isPlainObject } from '@carbonenginejs/runtime-utils/is';
|
|
4
4
|
import { recordText, toRecordText } from './carbonRecordFields.js';
|
|
@@ -111,7 +111,7 @@ CjsSchema.define(Tr2EffectResource, {
|
|
|
111
111
|
isSRGB: type.boolean,
|
|
112
112
|
isAutoregister: type.boolean,
|
|
113
113
|
name: type.string,
|
|
114
|
-
type: [type.int32,
|
|
114
|
+
type: [type.int32, type.enum("Type")],
|
|
115
115
|
arrayElements: type.uint32
|
|
116
116
|
}
|
|
117
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tr2EffectResource.js","sources":["../../../../../src/resource/shader/reflection/Tr2EffectResource.js"],"sourcesContent":["// Source: trinity/trinity/Shader/Tr2EffectDescription.h\nimport { CjsSchema, impl,
|
|
1
|
+
{"version":3,"file":"Tr2EffectResource.js","sources":["../../../../../src/resource/shader/reflection/Tr2EffectResource.js"],"sourcesContent":["// Source: trinity/trinity/Shader/Tr2EffectDescription.h\nimport { CjsSchema, impl, type } from \"@carbonenginejs/runtime-utils/schema\";\nimport { CjsModel } from \"@carbonenginejs/runtime-utils/model\";\nimport {\n isPlainObject\n} from \"@carbonenginejs/runtime-utils/is\";\nimport { recordText, toRecordText } from \"./carbonRecordFields.js\";\n\n/** Reflected SRV or UAV resource metadata. */\nexport class Tr2EffectResource extends CjsModel\n{\n\n /** isSRGB (bool) */\n isSRGB = false;\n\n /** isAutoregister (bool) */\n isAutoregister = false;\n\n /** name (const char*) */\n name = \"\";\n\n /** type (Type - enum Type) */\n type = 0;\n\n /** arrayElements (uint32_t) */\n arrayElements = 0;\n\n /**\n * Build one SRV or UAV from its Carbon v15 description record.\n *\n * Both a texture record and a UAV record land here, and they are not the same\n * shape: a UAV record carries no `isSRGB` at all. Carbon's reader hardcodes\n * `isSRGB = false` for UAVs rather than reading a byte, and `Uav::Save` omits\n * it, so the field being absent is correct rather than missing — reading\n * `undefined` through `!!` reproduces Carbon exactly. The array size is spelled\n * `count` in the record and `arrayElements` on the class.\n *\n * @param {object} record Carbon texture or UAV record.\n * @returns {Tr2EffectResource} Reflected resource.\n */\n static fromCarbonBinary(record)\n {\n if (!isPlainObject(record))\n {\n throw new TypeError(\"Carbon effect resource record must be an object\");\n }\n\n const resource = new this();\n resource.name = recordText(record.name);\n resource.type = record.type;\n resource.arrayElements = record.count;\n resource.isSRGB = !!record.isSRGB;\n resource.isAutoregister = !!record.isAutoregister;\n return resource;\n }\n\n /**\n * Emit this resource as a Carbon v15 texture or UAV record.\n *\n * A UAV record is one byte shorter: it carries no `isSRGB`, because Carbon's\n * reader hardcodes it false and `Uav::Save` omits it. Emitting the field\n * anyway would desynchronise every following field in the stage.\n *\n * @param {number} registerIndex Register this resource is bound at.\n * @param {boolean} [uav] Whether to emit the UAV shape.\n * @returns {object} Carbon texture or UAV record.\n */\n toCarbonBinary(registerIndex, uav = false)\n {\n const record = {\n registerIndex,\n name: toRecordText(this.name),\n type: this.type,\n count: this.arrayElements,\n isAutoregister: this.isAutoregister ? 1 : 0\n };\n if (uav)\n {\n return record;\n }\n return {\n registerIndex,\n name: record.name,\n type: record.type,\n count: record.count,\n isSRGB: this.isSRGB ? 1 : 0,\n isAutoregister: record.isAutoregister\n };\n }\n\n static BINDLESS_SAMPLER = 100;\n\n static Type = Object.freeze({\n TEXTURE_1D: 1,\n TEXTURE_2D: 2,\n TEXTURE_3D: 3,\n TEXTURE_CUBE: 4,\n TEXTURE_TYPELESS: 5,\n BUFFER: 6,\n STRUCTURED_BUFFER: 7,\n TBUFFER: 8,\n BYTEADDRESS_BUFFER: 9,\n UAV_RWTYPED: 10,\n UAV_RWSTRUCTURED: 11,\n UAV_RWBYTEADDRESS: 12,\n UAV_APPEND_STRUCTURED: 13,\n UAV_CONSUME_STRUCTURED: 14,\n UAV_RWSTRUCTURED_WITH_COUNTER: 15\n });\n\n}\n\n// Declared imperatively rather than with decorators, so this module stays\n// plain ESM that loads from source without a transform. The decorator\n// expressions are reused verbatim, so the registered metadata is identical.\n// Statics belong in `methods`: decorateMethod targets the prototype and\n// would register a static as an instance field.\nCjsSchema.define(Tr2EffectResource, {\n className: \"Tr2EffectResource\",\n family: \"shader\",\n fields: {\n isSRGB: type.boolean,\n isAutoregister: type.boolean,\n name: type.string,\n type: [ type.int32, type.enum(\"Type\") ],\n arrayElements: type.uint32\n }\n});\n"],"names":["Tr2EffectResource","CjsModel","isSRGB","isAutoregister","name","type","arrayElements","fromCarbonBinary","record","isPlainObject","TypeError","resource","recordText","count","toCarbonBinary","registerIndex","uav","toRecordText","BINDLESS_SAMPLER","Type","Object","freeze","TEXTURE_1D","TEXTURE_2D","TEXTURE_3D","TEXTURE_CUBE","TEXTURE_TYPELESS","BUFFER","STRUCTURED_BUFFER","TBUFFER","BYTEADDRESS_BUFFER","UAV_RWTYPED","UAV_RWSTRUCTURED","UAV_RWBYTEADDRESS","UAV_APPEND_STRUCTURED","UAV_CONSUME_STRUCTURED","UAV_RWSTRUCTURED_WITH_COUNTER","CjsSchema","define","className","family","fields","boolean","string","int32","enum","uint32"],"mappings":";;;;;AAAA;;AA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