@carbonenginejs/runtime-resource 0.18.0 → 0.19.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.
Files changed (81) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  4. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  5. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +36 -0
  6. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  8. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  10. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  11. package/dist/format/index.js +1 -1
  12. package/dist/formats/dds/core/helpers.js +35 -6
  13. package/dist/formats/dds/core/helpers.js.map +1 -1
  14. package/dist/formats/fbx/core/helpers.js +1 -1
  15. package/dist/formats/fbx/core/helpers.js.map +1 -1
  16. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  17. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  18. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  19. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  20. package/dist/formats/index.js +3 -0
  21. package/dist/formats/index.js.map +1 -1
  22. package/dist/formats/jpeg/core/helpers.js +1 -1
  23. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  24. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +205 -44
  25. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
  26. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  27. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  28. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  29. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundValues.js +336 -0
  31. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  32. package/dist/formats/schemabound/index.js +2 -0
  33. package/dist/formats/schemabound/index.js.map +1 -0
  34. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  35. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  36. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  37. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  39. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  41. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  42. package/dist/formats/sqlite/index.js +2 -0
  43. package/dist/formats/sqlite/index.js.map +1 -0
  44. package/dist/formats/static/CjsStaticFormat.js +222 -0
  45. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  46. package/dist/formats/static/index.js +3 -0
  47. package/dist/formats/static/index.js.map +1 -0
  48. package/dist/formats/static/staticContainers.js +157 -0
  49. package/dist/formats/static/staticContainers.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +11 -2
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  57. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  58. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  59. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  60. package/dist/formats/webgpu/core/effectBackendBodySet.js +20 -20
  61. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  62. package/dist/formats/webgpu/core/packageEffect.js +14 -1
  63. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  64. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  65. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  66. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  67. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  68. package/docs/concepts/shader-resource-model.md +34 -1
  69. package/docs/formats/README.md +21 -0
  70. package/docs/formats/carbon-effect-container.md +54 -27
  71. package/docs/formats/pickle.md +36 -0
  72. package/docs/formats/schemabound.md +123 -0
  73. package/docs/formats/static.md +166 -0
  74. package/docs/formats/webgl/README.md +5 -3
  75. package/docs/formats/webgpu/README.md +2 -2
  76. package/docs/formats/webgpu/architecture.md +2 -2
  77. package/docs/formats/webgpu/formats/carbon-webgpu.md +13 -2
  78. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  79. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  80. package/docs/reference/classes/formats.md +33 -0
  81. package/package.json +4 -1
@@ -0,0 +1,336 @@
1
+ import { SchemaBoundError } from './schemaBoundErrors.js';
2
+
3
+ const TEXT = new TextDecoder("utf-8");
4
+
5
+ /**
6
+ * Decodes one value of any schema type, and reports how many bytes it spanned.
7
+ *
8
+ * Every type answers both questions through this one function because the
9
+ * container mixes them: a list's items may be fixed, in which case the schema
10
+ * states the stride, or variable, in which case the only way to find item `n+1`
11
+ * is to have finished reading item `n`.
12
+ *
13
+ * @param {object} context Reader context: `view`, `bytes` and `options`.
14
+ * @param {number} offset Absolute byte offset of the value.
15
+ * @param {object} node The schema node describing the value.
16
+ * @returns {{value: *, size: number}} Decoded value and the bytes it occupied.
17
+ */
18
+ function ReadValue(context, offset, node) {
19
+ switch (node.type) {
20
+ case "int":
21
+ return ReadInt(context, offset, node);
22
+ // Identifier types. Each is a four-byte unsigned integer that names a row in
23
+ // another table, and the schema states the meaning rather than the width -
24
+ // `factionID` and one or two others declare no size at all. Keeping them
25
+ // named here rather than folding them into `int` is what lets a consumer see
26
+ // that a number is a key.
27
+ case "localizationID":
28
+ case "typeID":
29
+ case "factionID":
30
+ case "groupID":
31
+ case "categoryID":
32
+ case "graphicID":
33
+ case "iconID":
34
+ case "fsdReference":
35
+ return ReadInt(context, offset, {
36
+ size: node.size ?? 4,
37
+ min: 0
38
+ });
39
+ case "float":
40
+ return ReadFloat(context, offset, node);
41
+ case "bool":
42
+ return {
43
+ value: context.view.getUint8(offset) !== 0,
44
+ size: node.size ?? 1
45
+ };
46
+ case "enum":
47
+ return ReadEnum(context, offset, node);
48
+ case "vector2":
49
+ return ReadVector(context, offset, node, 2);
50
+ case "vector3":
51
+ return ReadVector(context, offset, node, 3);
52
+ // `unicode` is the same framing as `string`; the distinction is Python's,
53
+ // and both arrive as a byte length followed by UTF-8.
54
+ case "string":
55
+ case "resPath":
56
+ case "unicode":
57
+ return ReadString(context, offset);
58
+ case "list":
59
+ return ReadList(context, offset, node);
60
+ case "dict":
61
+ return ReadDict(context, offset, node);
62
+ case "object":
63
+ return ReadObject(context, offset, node);
64
+ default:
65
+ throw SchemaBoundError(`The schema declares a type this reader does not know: ${node.type}.`, {
66
+ schemaType: node.type
67
+ });
68
+ }
69
+ }
70
+
71
+ /** Reads a 1, 2, 4 or 8 byte integer, signed only when the schema allows it. */
72
+ function ReadInt(context, offset, node) {
73
+ const size = node.size ?? 4;
74
+ // `min: 0` is the schema's own statement that the field cannot go negative,
75
+ // and it is the only signedness information there is.
76
+ const unsigned = typeof node.min === "number" && node.min >= 0;
77
+ const view = context.view;
78
+ switch (size) {
79
+ case 1:
80
+ return {
81
+ value: unsigned ? view.getUint8(offset) : view.getInt8(offset),
82
+ size
83
+ };
84
+ case 2:
85
+ return {
86
+ value: unsigned ? view.getUint16(offset, true) : view.getInt16(offset, true),
87
+ size
88
+ };
89
+ case 4:
90
+ return {
91
+ value: unsigned ? view.getUint32(offset, true) : view.getInt32(offset, true),
92
+ size
93
+ };
94
+ case 8:
95
+ return {
96
+ value: Narrow(unsigned ? view.getBigUint64(offset, true) : view.getBigInt64(offset, true)),
97
+ size
98
+ };
99
+ default:
100
+ throw SchemaBoundError(`An integer of ${size} bytes is not a width this container uses.`);
101
+ }
102
+ }
103
+
104
+ /** Returns a wide integer as a Number when that is lossless, else a BigInt. */
105
+ function Narrow(value) {
106
+ return value >= -9007199254740991n && value <= 9007199254740991n ? Number(value) : value;
107
+ }
108
+
109
+ /** Reads a single or double precision float. */
110
+ function ReadFloat(context, offset, node) {
111
+ const size = node.size ?? 4;
112
+ if (size === 8) return {
113
+ value: context.view.getFloat64(offset, true),
114
+ size
115
+ };
116
+ if (size === 4) return {
117
+ value: context.view.getFloat32(offset, true),
118
+ size
119
+ };
120
+ throw SchemaBoundError(`A float of ${size} bytes is not a width this container uses.`);
121
+ }
122
+
123
+ /**
124
+ * Reads an enumeration, as its number or its name.
125
+ *
126
+ * `readEnumValue` is the schema saying the stored number is the meaning; without
127
+ * it the name is. A number with no name is returned as the number rather than
128
+ * dropped, because an unnamed member is data the client still stored.
129
+ */
130
+ function ReadEnum(context, offset, node) {
131
+ const {
132
+ value,
133
+ size
134
+ } = ReadInt(context, offset, {
135
+ size: node.size ?? 1,
136
+ min: 0
137
+ });
138
+ if (node.readEnumValue === true || !node.values) return {
139
+ value,
140
+ size
141
+ };
142
+ for (const [name, member] of Object.entries(node.values)) {
143
+ if (member === value) return {
144
+ value: name,
145
+ size
146
+ };
147
+ }
148
+ return {
149
+ value,
150
+ size
151
+ };
152
+ }
153
+
154
+ /** Reads a fixed-length vector into the component names the schema aliases. */
155
+ function ReadVector(context, offset, node, components) {
156
+ const wide = (node.precision ?? "double") === "double";
157
+ const width = wide ? 8 : 4;
158
+ const read = index => wide ? context.view.getFloat64(offset + index * width, true) : context.view.getFloat32(offset + index * width, true);
159
+ const aliases = node.aliases ?? DEFAULT_COMPONENTS[components];
160
+ const value = {};
161
+ for (const [name, index] of Object.entries(aliases)) value[name] = read(index);
162
+ return {
163
+ value,
164
+ size: node.size ?? width * components
165
+ };
166
+ }
167
+ const DEFAULT_COMPONENTS = {
168
+ 2: {
169
+ x: 0,
170
+ y: 1
171
+ },
172
+ 3: {
173
+ x: 0,
174
+ y: 1,
175
+ z: 2
176
+ }
177
+ };
178
+
179
+ /** Reads a length-prefixed UTF-8 string; `resPath` is the same shape. */
180
+ function ReadString(context, offset) {
181
+ const length = context.view.getUint32(offset, true);
182
+ const start = offset + 4;
183
+ return {
184
+ value: TEXT.decode(context.bytes.subarray(start, start + length)),
185
+ size: 4 + length
186
+ };
187
+ }
188
+
189
+ /**
190
+ * Reads a count-prefixed list.
191
+ *
192
+ * A list has two framings and the schema says which: `fixedItemSize` means the
193
+ * items are packed one after another at that stride, and its absence means they
194
+ * are variable, so the count is followed by one `uint32` per item. Those offsets
195
+ * are relative to the start of the list.
196
+ */
197
+ function ReadList(context, offset, node) {
198
+ const view = context.view;
199
+ const count = view.getUint32(offset, true);
200
+ const items = [];
201
+ if (node.fixedItemSize === undefined) {
202
+ let end = offset + 4 + count * 4;
203
+ for (let index = 0; index < count; index += 1) {
204
+ const at = offset + view.getUint32(offset + 4 + index * 4, true);
205
+ const item = ReadValue(context, at, node.itemTypes);
206
+ items.push(item.value);
207
+ end = Math.max(end, at + item.size);
208
+ }
209
+ return {
210
+ value: items,
211
+ size: end - offset
212
+ };
213
+ }
214
+ let cursor = offset + 4;
215
+ for (let index = 0; index < count; index += 1) {
216
+ items.push(ReadValue(context, cursor, node.itemTypes).value);
217
+ cursor += node.fixedItemSize;
218
+ }
219
+ return {
220
+ value: items,
221
+ size: cursor - offset
222
+ };
223
+ }
224
+
225
+ /**
226
+ * Reads a keyed map.
227
+ *
228
+ * The framing is the same at the root of a container and nested inside one
229
+ * record: a `uint32` of everything that follows, the values, then the key
230
+ * footer, then a `uint32` of the footer's own size. **The footer is found from
231
+ * the end, never from the front** — nothing at the front points at it.
232
+ *
233
+ * Each footer entry carries a key and an offset, and that offset is relative to
234
+ * the end of the leading `uint32`, not to the file and not to the value region.
235
+ */
236
+ function ReadDict(context, offset, node) {
237
+ const view = context.view;
238
+ const total = view.getUint32(offset, true);
239
+ const base = offset + 4;
240
+ const end = base + total;
241
+ const footerSize = view.getUint32(end - 4, true);
242
+ const footerStart = end - 4 - footerSize;
243
+ if (footerStart < base) {
244
+ throw SchemaBoundError("The key footer does not fit inside the container.", {
245
+ footerStart,
246
+ base
247
+ });
248
+ }
249
+ const value = {};
250
+
251
+ // The footer is an ordinary list, and it uses both of the list framings: a
252
+ // list of integer keys is fixed-stride, a list of string keys is not.
253
+ for (const entry of ReadList(context, footerStart, node.keyFooter).value) {
254
+ value[entry.key] = ReadValue(context, base + entry.offset, node.valueTypes).value;
255
+ }
256
+ return {
257
+ value,
258
+ size: 4 + total
259
+ };
260
+ }
261
+
262
+ /**
263
+ * Reads a record.
264
+ *
265
+ * Fixed attributes sit at the offsets the schema names. Everything in
266
+ * `attributesWithVariableOffsets` is reached through a table that follows the
267
+ * fixed part, and **that table's length changes from record to record**: an
268
+ * optional attribute whose presence bit is clear takes no slot in it. A reader
269
+ * that assumes a constant stride decodes the first record correctly and then
270
+ * drifts, which is the single most misleading property of this format.
271
+ */
272
+ function ReadObject(context, offset, node) {
273
+ const attributes = node.attributes ?? {};
274
+ const variable = node.attributesWithVariableOffsets ?? [];
275
+ const decoded = new Map();
276
+ let size = node.size ?? node.endOfFixedSizeData ?? 0;
277
+ for (const [name, at] of Object.entries(node.constantAttributeOffsets ?? {})) {
278
+ decoded.set(name, ReadValue(context, offset + at, Attribute(attributes, name)).value);
279
+ }
280
+ if (variable.length) {
281
+ const lookups = node.optionalValueLookups ?? {};
282
+ const view = context.view;
283
+ // The presence bitfield is written whenever a record has a variable section
284
+ // at all, including where nothing in it is optional and the field is
285
+ // therefore always zero. It is the offset table that shrinks, never this.
286
+ const bits = view.getBigUint64(offset + node.endOfFixedSizeData, true);
287
+ const table = offset + node.endOfFixedSizeData + 8;
288
+ const present = variable.filter(name => {
289
+ const attribute = Attribute(attributes, name);
290
+ return !attribute.isOptional || (bits & BigInt(lookups[name] ?? 0)) !== 0n;
291
+ });
292
+ const data = table + present.length * 4;
293
+ let end = data;
294
+ present.forEach((name, index) => {
295
+ const at = data + view.getUint32(table + index * 4, true);
296
+ const read = ReadValue(context, at, Attribute(attributes, name));
297
+ decoded.set(name, read.value);
298
+ end = Math.max(end, at + read.size);
299
+ });
300
+ for (const name of variable) {
301
+ const attribute = Attribute(attributes, name);
302
+
303
+ // An absent optional takes the value the schema declares for it. Where no
304
+ // default is declared the attribute is simply not part of this record -
305
+ // which is what the published exports show for these same rows.
306
+ if (!decoded.has(name) && Object.hasOwn(attribute, "default")) {
307
+ decoded.set(name, attribute.default);
308
+ }
309
+ }
310
+ size = end - offset;
311
+ }
312
+
313
+ // Declaration order, not the order the two passes above happened to fill.
314
+ const value = {};
315
+ for (const name of Object.keys(attributes)) {
316
+ if (decoded.has(name)) value[name] = decoded.get(name);
317
+ }
318
+ return {
319
+ value,
320
+ size
321
+ };
322
+ }
323
+
324
+ /** Looks up an attribute, naming the schema rather than failing on undefined. */
325
+ function Attribute(attributes, name) {
326
+ const attribute = attributes[name];
327
+ if (!attribute) {
328
+ throw SchemaBoundError(`The schema offsets an attribute it never declares: ${name}.`, {
329
+ attribute: name
330
+ });
331
+ }
332
+ return attribute;
333
+ }
334
+
335
+ export { ReadValue };
336
+ //# sourceMappingURL=schemaBoundValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaBoundValues.js","sources":["../../../../../src/formats/schemabound/core/schemaBoundValues.js"],"sourcesContent":["import { SchemaBoundError } from \"./schemaBoundErrors.js\";\n\nconst TEXT = new TextDecoder(\"utf-8\");\n\n/**\n * Decodes one value of any schema type, and reports how many bytes it spanned.\n *\n * Every type answers both questions through this one function because the\n * container mixes them: a list's items may be fixed, in which case the schema\n * states the stride, or variable, in which case the only way to find item `n+1`\n * is to have finished reading item `n`.\n *\n * @param {object} context Reader context: `view`, `bytes` and `options`.\n * @param {number} offset Absolute byte offset of the value.\n * @param {object} node The schema node describing the value.\n * @returns {{value: *, size: number}} Decoded value and the bytes it occupied.\n */\nexport function ReadValue(context, offset, node) {\n switch (node.type) {\n case \"int\": return ReadInt(context, offset, node);\n // Identifier types. Each is a four-byte unsigned integer that names a row in\n // another table, and the schema states the meaning rather than the width -\n // `factionID` and one or two others declare no size at all. Keeping them\n // named here rather than folding them into `int` is what lets a consumer see\n // that a number is a key.\n case \"localizationID\": case \"typeID\": case \"factionID\": case \"groupID\":\n case \"categoryID\": case \"graphicID\": case \"iconID\": case \"fsdReference\":\n return ReadInt(context, offset, { size: node.size ?? 4, min: 0 });\n case \"float\": return ReadFloat(context, offset, node);\n case \"bool\": return { value: context.view.getUint8(offset) !== 0, size: node.size ?? 1 };\n case \"enum\": return ReadEnum(context, offset, node);\n case \"vector2\": return ReadVector(context, offset, node, 2);\n case \"vector3\": return ReadVector(context, offset, node, 3);\n // `unicode` is the same framing as `string`; the distinction is Python's,\n // and both arrive as a byte length followed by UTF-8.\n case \"string\": case \"resPath\": case \"unicode\": return ReadString(context, offset);\n case \"list\": return ReadList(context, offset, node);\n case \"dict\": return ReadDict(context, offset, node);\n case \"object\": return ReadObject(context, offset, node);\n default:\n throw SchemaBoundError(`The schema declares a type this reader does not know: ${node.type}.`, {\n schemaType: node.type\n });\n }\n}\n\n/** Reads a 1, 2, 4 or 8 byte integer, signed only when the schema allows it. */\nfunction ReadInt(context, offset, node) {\n const size = node.size ?? 4;\n // `min: 0` is the schema's own statement that the field cannot go negative,\n // and it is the only signedness information there is.\n const unsigned = typeof node.min === \"number\" && node.min >= 0;\n const view = context.view;\n\n switch (size) {\n case 1: return { value: unsigned ? view.getUint8(offset) : view.getInt8(offset), size };\n case 2: return { value: unsigned ? view.getUint16(offset, true) : view.getInt16(offset, true), size };\n case 4: return { value: unsigned ? view.getUint32(offset, true) : view.getInt32(offset, true), size };\n case 8: return { value: Narrow(unsigned ? view.getBigUint64(offset, true) : view.getBigInt64(offset, true)), size };\n default:\n throw SchemaBoundError(`An integer of ${size} bytes is not a width this container uses.`);\n }\n}\n\n/** Returns a wide integer as a Number when that is lossless, else a BigInt. */\nfunction Narrow(value) {\n return value >= -9007199254740991n && value <= 9007199254740991n ? Number(value) : value;\n}\n\n/** Reads a single or double precision float. */\nfunction ReadFloat(context, offset, node) {\n const size = node.size ?? 4;\n\n if (size === 8) return { value: context.view.getFloat64(offset, true), size };\n if (size === 4) return { value: context.view.getFloat32(offset, true), size };\n\n throw SchemaBoundError(`A float of ${size} bytes is not a width this container uses.`);\n}\n\n/**\n * Reads an enumeration, as its number or its name.\n *\n * `readEnumValue` is the schema saying the stored number is the meaning; without\n * it the name is. A number with no name is returned as the number rather than\n * dropped, because an unnamed member is data the client still stored.\n */\nfunction ReadEnum(context, offset, node) {\n const { value, size } = ReadInt(context, offset, { size: node.size ?? 1, min: 0 });\n\n if (node.readEnumValue === true || !node.values) return { value, size };\n\n for (const [ name, member ] of Object.entries(node.values)) {\n if (member === value) return { value: name, size };\n }\n\n return { value, size };\n}\n\n/** Reads a fixed-length vector into the component names the schema aliases. */\nfunction ReadVector(context, offset, node, components) {\n const wide = (node.precision ?? \"double\") === \"double\";\n const width = wide ? 8 : 4;\n const read = index => wide\n ? context.view.getFloat64(offset + index * width, true)\n : context.view.getFloat32(offset + index * width, true);\n const aliases = node.aliases ?? DEFAULT_COMPONENTS[components];\n const value = {};\n\n for (const [ name, index ] of Object.entries(aliases)) value[name] = read(index);\n\n return { value, size: node.size ?? width * components };\n}\n\nconst DEFAULT_COMPONENTS = { 2: { x: 0, y: 1 }, 3: { x: 0, y: 1, z: 2 } };\n\n/** Reads a length-prefixed UTF-8 string; `resPath` is the same shape. */\nfunction ReadString(context, offset) {\n const length = context.view.getUint32(offset, true);\n const start = offset + 4;\n\n return {\n value: TEXT.decode(context.bytes.subarray(start, start + length)),\n size: 4 + length\n };\n}\n\n/**\n * Reads a count-prefixed list.\n *\n * A list has two framings and the schema says which: `fixedItemSize` means the\n * items are packed one after another at that stride, and its absence means they\n * are variable, so the count is followed by one `uint32` per item. Those offsets\n * are relative to the start of the list.\n */\nfunction ReadList(context, offset, node) {\n const view = context.view;\n const count = view.getUint32(offset, true);\n const items = [];\n\n if (node.fixedItemSize === undefined) {\n let end = offset + 4 + count * 4;\n\n for (let index = 0; index < count; index += 1) {\n const at = offset + view.getUint32(offset + 4 + index * 4, true);\n const item = ReadValue(context, at, node.itemTypes);\n\n items.push(item.value);\n end = Math.max(end, at + item.size);\n }\n\n return { value: items, size: end - offset };\n }\n\n let cursor = offset + 4;\n\n for (let index = 0; index < count; index += 1) {\n items.push(ReadValue(context, cursor, node.itemTypes).value);\n cursor += node.fixedItemSize;\n }\n\n return { value: items, size: cursor - offset };\n}\n\n/**\n * Reads a keyed map.\n *\n * The framing is the same at the root of a container and nested inside one\n * record: a `uint32` of everything that follows, the values, then the key\n * footer, then a `uint32` of the footer's own size. **The footer is found from\n * the end, never from the front** — nothing at the front points at it.\n *\n * Each footer entry carries a key and an offset, and that offset is relative to\n * the end of the leading `uint32`, not to the file and not to the value region.\n */\nfunction ReadDict(context, offset, node) {\n const view = context.view;\n const total = view.getUint32(offset, true);\n const base = offset + 4;\n const end = base + total;\n const footerSize = view.getUint32(end - 4, true);\n const footerStart = end - 4 - footerSize;\n\n if (footerStart < base) {\n throw SchemaBoundError(\"The key footer does not fit inside the container.\", { footerStart, base });\n }\n\n const value = {};\n\n // The footer is an ordinary list, and it uses both of the list framings: a\n // list of integer keys is fixed-stride, a list of string keys is not.\n for (const entry of ReadList(context, footerStart, node.keyFooter).value) {\n value[entry.key] = ReadValue(context, base + entry.offset, node.valueTypes).value;\n }\n\n return { value, size: 4 + total };\n}\n\n/**\n * Reads a record.\n *\n * Fixed attributes sit at the offsets the schema names. Everything in\n * `attributesWithVariableOffsets` is reached through a table that follows the\n * fixed part, and **that table's length changes from record to record**: an\n * optional attribute whose presence bit is clear takes no slot in it. A reader\n * that assumes a constant stride decodes the first record correctly and then\n * drifts, which is the single most misleading property of this format.\n */\nfunction ReadObject(context, offset, node) {\n const attributes = node.attributes ?? {};\n const variable = node.attributesWithVariableOffsets ?? [];\n const decoded = new Map();\n let size = node.size ?? node.endOfFixedSizeData ?? 0;\n\n for (const [ name, at ] of Object.entries(node.constantAttributeOffsets ?? {})) {\n decoded.set(name, ReadValue(context, offset + at, Attribute(attributes, name)).value);\n }\n\n if (variable.length) {\n const lookups = node.optionalValueLookups ?? {};\n const view = context.view;\n // The presence bitfield is written whenever a record has a variable section\n // at all, including where nothing in it is optional and the field is\n // therefore always zero. It is the offset table that shrinks, never this.\n const bits = view.getBigUint64(offset + node.endOfFixedSizeData, true);\n const table = offset + node.endOfFixedSizeData + 8;\n const present = variable.filter(name => {\n const attribute = Attribute(attributes, name);\n\n return !attribute.isOptional || (bits & BigInt(lookups[name] ?? 0)) !== 0n;\n });\n const data = table + present.length * 4;\n let end = data;\n\n present.forEach((name, index) => {\n const at = data + view.getUint32(table + index * 4, true);\n const read = ReadValue(context, at, Attribute(attributes, name));\n\n decoded.set(name, read.value);\n end = Math.max(end, at + read.size);\n });\n\n for (const name of variable) {\n const attribute = Attribute(attributes, name);\n\n // An absent optional takes the value the schema declares for it. Where no\n // default is declared the attribute is simply not part of this record -\n // which is what the published exports show for these same rows.\n if (!decoded.has(name) && Object.hasOwn(attribute, \"default\")) {\n decoded.set(name, attribute.default);\n }\n }\n\n size = end - offset;\n }\n\n // Declaration order, not the order the two passes above happened to fill.\n const value = {};\n\n for (const name of Object.keys(attributes)) {\n if (decoded.has(name)) value[name] = decoded.get(name);\n }\n\n return { value, size };\n}\n\n/** Looks up an attribute, naming the schema rather than failing on undefined. */\nfunction Attribute(attributes, name) {\n const attribute = attributes[name];\n\n if (!attribute) {\n throw SchemaBoundError(`The schema offsets an attribute it never declares: ${name}.`, {\n attribute: name\n });\n }\n\n return attribute;\n}\n\nexport default ReadValue;\n"],"names":["TEXT","TextDecoder","ReadValue","context","offset","node","type","ReadInt","size","min","ReadFloat","value","view","getUint8","ReadEnum","ReadVector","ReadString","ReadList","ReadDict","ReadObject","SchemaBoundError","schemaType","unsigned","getInt8","getUint16","getInt16","getUint32","getInt32","Narrow","getBigUint64","getBigInt64","Number","getFloat64","getFloat32","readEnumValue","values","name","member","Object","entries","components","wide","precision","width","read","index","aliases","DEFAULT_COMPONENTS","x","y","z","length","start","decode","bytes","subarray","count","items","fixedItemSize","undefined","end","at","item","itemTypes","push","Math","max","cursor","total","base","footerSize","footerStart","entry","keyFooter","key","valueTypes","attributes","variable","attributesWithVariableOffsets","decoded","Map","endOfFixedSizeData","constantAttributeOffsets","set","Attribute","lookups","optionalValueLookups","bits","table","present","filter","attribute","isOptional","BigInt","data","forEach","has","hasOwn","default","keys","get"],"mappings":";;AAEA,MAAMA,IAAI,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE;EAC/C,QAAQA,IAAI,CAACC,IAAI;AACf,IAAA,KAAK,KAAK;AAAE,MAAA,OAAOC,OAAO,CAACJ,OAAO,EAAEC,MAAM,EAAEC,IAAI,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA,IAAA,KAAK,gBAAgB;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,SAAS;AACtE,IAAA,KAAK,YAAY;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,cAAc;AACrE,MAAA,OAAOE,OAAO,CAACJ,OAAO,EA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CjsSchemaBoundFormat as default } from './CjsSchemaBoundFormat.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,244 @@
1
+ import { ReadColumns } from './core/sqliteSchema.js';
2
+ import { ReadHeader, TableRows } from './core/sqlitePages.js';
3
+ import { SqliteError, ReadRecord } from './core/sqliteRecords.js';
4
+
5
+ const OUTPUT_JSON = "json";
6
+ const OUTPUT_PAYLOAD = "payload";
7
+ const OUTPUT_RAW = "raw";
8
+ const MASTER_ROOT_PAGE = 1;
9
+
10
+ /**
11
+ * Reads a SQLite 3 container as data.
12
+ *
13
+ * **This is a reader, not a database.** It accepts no SQL and runs no queries.
14
+ * It returns the tables a container holds and every row of them, because that
15
+ * is the whole of what this organization does with a SQLite file: the client's
16
+ * `.static` containers and the prepared static data export are both opened,
17
+ * scanned once, and closed.
18
+ *
19
+ * That scope is what makes it small. A query planner, an index walker, writing,
20
+ * journalling and transactions are most of SQLite and none of this, so none of
21
+ * them are here. Index b-tree pages are never visited: an index holds no data a
22
+ * table scan does not already produce.
23
+ *
24
+ * It exists because `runtime-resource` is browser-safe and ships no SQLite
25
+ * engine, so `.static` containers of the SQLite family previously needed a
26
+ * driver injected by the caller — which meant Node, and in practice the
27
+ * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.
28
+ *
29
+ * Values map as the format defines them: NULL, integers, doubles, text decoded
30
+ * with the database's own encoding, and blobs as `Uint8Array`. An integer wider
31
+ * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently
32
+ * rounded.
33
+ */
34
+ class CjsSqliteFormat {
35
+ /**
36
+ * Reports whether bytes are a SQLite container, by signature.
37
+ *
38
+ * @param {Uint8Array|ArrayBuffer} input Candidate bytes.
39
+ * @returns {boolean} True when the header signature matches.
40
+ */
41
+ static is(input) {
42
+ try {
43
+ ReadHeader(Normalize(input));
44
+ return true;
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Reports whether these bytes are a SQLite container, on the signature.
52
+ *
53
+ * The signature is the whole claim: the header either says
54
+ * `SQLite format 3` or it does not, so this is verified by content rather
55
+ * than inferred from a name — which matters because `.static` carries three
56
+ * unrelated families and the extension proves nothing.
57
+ *
58
+ * @param {ArrayBuffer|ArrayBufferView} input Container bytes.
59
+ * @param {object} [options] Probe options.
60
+ * @returns {object} Resource probe.
61
+ */
62
+ static isSupported(input, options = null) {
63
+ return Probe(this.is(input), options);
64
+ }
65
+
66
+ // INTERIM, 2026-08-16. No `inspect` alias onto `isSupported`, while nineteen
67
+ // sibling formats have one. The capability-surface decision page names that
68
+ // alias as the confusion it wants removed, but its own "What is not proposed"
69
+ // says not to change things on its strength alone - so this is a divergence
70
+ // awaiting a decision, not a settled position.
71
+ //
72
+ // See maintenance/INTERIM-sqlite-and-static-2026-08-16.md before resolving it,
73
+ // and search for callers of `inspect` on any format first.
74
+
75
+ /**
76
+ * Reads every table and row.
77
+ *
78
+ * @param {Uint8Array|ArrayBuffer} input Container bytes.
79
+ * @param {object} [options] Read options.
80
+ * @param {string} [options.output] `json`, `payload` or `raw`.
81
+ * @param {string[]} [options.tables] Read only these tables.
82
+ * @returns {object} Tables keyed by name, each an array of row objects.
83
+ */
84
+ static read(input, options = {}) {
85
+ const output = options.output ?? OUTPUT_JSON;
86
+ const bytes = Normalize(input);
87
+ const header = ReadHeader(bytes);
88
+ const schema = ReadMaster(bytes, header);
89
+ if (output === OUTPUT_RAW) {
90
+ return {
91
+ header,
92
+ schema
93
+ };
94
+ }
95
+ const wanted = options.tables ? new Set(options.tables) : null;
96
+ const tables = {};
97
+ for (const entry of schema) {
98
+ if (entry.type !== "table" || wanted && !wanted.has(entry.name)) {
99
+ continue;
100
+ }
101
+
102
+ // A table with no root page holds nothing: a view, or WITHOUT ROWID.
103
+ tables[entry.name] = entry.rootPage ? ReadTable(bytes, header, entry, output === OUTPUT_JSON) : [];
104
+ }
105
+ return tables;
106
+ }
107
+
108
+ /** Reads to plain JSON-compatible values, converting blobs to arrays. */
109
+ static readJSON(input, options = {}) {
110
+ return this.read(input, {
111
+ ...options,
112
+ output: OUTPUT_JSON
113
+ });
114
+ }
115
+
116
+ /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */
117
+ static readPayload(input, options = {}) {
118
+ return this.read(input, {
119
+ ...options,
120
+ output: OUTPUT_PAYLOAD
121
+ });
122
+ }
123
+
124
+ /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */
125
+ static readRaw(input, options = {}) {
126
+ return this.read(input, {
127
+ ...options,
128
+ output: OUTPUT_RAW
129
+ });
130
+ }
131
+
132
+ /**
133
+ * Lists the tables a container holds, without reading their rows.
134
+ *
135
+ * @param {Uint8Array|ArrayBuffer} input Container bytes.
136
+ * @returns {Array<object>} One entry per table.
137
+ */
138
+ static tables(input) {
139
+ const bytes = Normalize(input);
140
+ return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === "table");
141
+ }
142
+ static Output = Object.freeze({
143
+ JSON: OUTPUT_JSON,
144
+ PAYLOAD: OUTPUT_PAYLOAD,
145
+ RAW: OUTPUT_RAW
146
+ });
147
+ static id = "sqlite";
148
+ static extensions = Object.freeze([".sqlite", ".db", ".sqlite3"]);
149
+ static type = Object.freeze(["data"]);
150
+ static mediaTypes = Object.freeze(["data"]);
151
+ static inputTypes = Object.freeze(["sqlite"]);
152
+ static outputTypes = Object.freeze([OUTPUT_JSON, OUTPUT_PAYLOAD]);
153
+ static debugOutputTypes = Object.freeze([OUTPUT_RAW]);
154
+ }
155
+
156
+ /** Builds the probe shape the resource manager routes on. */
157
+ function Probe(recognized, options) {
158
+ return {
159
+ format: "sqlite",
160
+ source: "buffer",
161
+ supported: recognized ? "full" : "none",
162
+ confidence: 1,
163
+ preferred: "sqlite",
164
+ // The header signature is content, not a declaration, so a match is
165
+ // evidence rather than a claim to be checked later.
166
+ verified: true,
167
+ reason: recognized ? "Recognized a SQLite 3 container." : "The header signature is not SQLite 3.",
168
+ variants: [{
169
+ kind: "container",
170
+ codec: "sqlite",
171
+ supported: recognized
172
+ }],
173
+ metadata: {
174
+ family: "sqlite",
175
+ decodable: recognized
176
+ },
177
+ ...(options || {})
178
+ };
179
+ }
180
+
181
+ /** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */
182
+ function ReadMaster(bytes, header) {
183
+ const entries = [];
184
+ for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {
185
+ const [type, name, tableName, rootPage, sql] = ReadRecord(row.payload, header.encoding);
186
+ entries.push({
187
+ type: String(type ?? ""),
188
+ name: String(name ?? ""),
189
+ tableName: String(tableName ?? ""),
190
+ rootPage: Number(rootPage ?? 0),
191
+ sql: sql === null || sql === undefined ? "" : String(sql)
192
+ });
193
+ }
194
+ return entries;
195
+ }
196
+
197
+ /** Reads one table's rows as objects, named from its `CREATE TABLE` text. */
198
+ function ReadTable(bytes, header, entry, json) {
199
+ const {
200
+ names,
201
+ rowidAlias
202
+ } = ReadColumns(entry.sql);
203
+ const rows = [];
204
+ for (const row of TableRows(bytes, header, entry.rootPage)) {
205
+ const values = ReadRecord(row.payload, header.encoding);
206
+ const record = {};
207
+ for (let index = 0; index < values.length; index += 1) {
208
+ // Positional names keep a row readable when the statement could not be
209
+ // parsed, rather than dropping columns that certainly hold data.
210
+ const name = names[index] ?? `column${index}`;
211
+ const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];
212
+ record[name] = json ? ToJSON(value) : value;
213
+ }
214
+ rows.push(record);
215
+ }
216
+ return rows;
217
+ }
218
+
219
+ /** Converts a decoded value to something `JSON.stringify` keeps losslessly. */
220
+ function ToJSON(value) {
221
+ if (value instanceof Uint8Array) {
222
+ return Array.from(value);
223
+ }
224
+
225
+ // A BigInt has no JSON form; a decimal string keeps every digit.
226
+ return typeof value === "bigint" ? value.toString(10) : value;
227
+ }
228
+
229
+ /** Accepts the byte forms every other format here accepts. */
230
+ function Normalize(input) {
231
+ if (input instanceof Uint8Array) {
232
+ return input;
233
+ }
234
+ if (input instanceof ArrayBuffer) {
235
+ return new Uint8Array(input);
236
+ }
237
+ if (ArrayBuffer.isView(input)) {
238
+ return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
239
+ }
240
+ throw SqliteError("A SQLite container must be supplied as bytes.");
241
+ }
242
+
243
+ export { CjsSqliteFormat };
244
+ //# sourceMappingURL=CjsSqliteFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsSqliteFormat.js","sources":["../../../../src/formats/sqlite/CjsSqliteFormat.js"],"sourcesContent":["import { ReadColumns } from \"./core/sqliteSchema.js\";\nimport { ReadHeader, TableRows } from \"./core/sqlitePages.js\";\nimport { ReadRecord, SqliteError } from \"./core/sqliteRecords.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst OUTPUT_RAW = \"raw\";\nconst MASTER_ROOT_PAGE = 1;\n\n/**\n * Reads a SQLite 3 container as data.\n *\n * **This is a reader, not a database.** It accepts no SQL and runs no queries.\n * It returns the tables a container holds and every row of them, because that\n * is the whole of what this organization does with a SQLite file: the client's\n * `.static` containers and the prepared static data export are both opened,\n * scanned once, and closed.\n *\n * That scope is what makes it small. A query planner, an index walker, writing,\n * journalling and transactions are most of SQLite and none of this, so none of\n * them are here. Index b-tree pages are never visited: an index holds no data a\n * table scan does not already produce.\n *\n * It exists because `runtime-resource` is browser-safe and ships no SQLite\n * engine, so `.static` containers of the SQLite family previously needed a\n * driver injected by the caller — which meant Node, and in practice the\n * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.\n *\n * Values map as the format defines them: NULL, integers, doubles, text decoded\n * with the database's own encoding, and blobs as `Uint8Array`. An integer wider\n * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently\n * rounded.\n */\nexport class CjsSqliteFormat {\n\n /**\n * Reports whether bytes are a SQLite container, by signature.\n *\n * @param {Uint8Array|ArrayBuffer} input Candidate bytes.\n * @returns {boolean} True when the header signature matches.\n */\n static is(input) {\n try {\n ReadHeader(Normalize(input));\n\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether these bytes are a SQLite container, on the signature.\n *\n * The signature is the whole claim: the header either says\n * `SQLite format 3` or it does not, so this is verified by content rather\n * than inferred from a name — which matters because `.static` carries three\n * unrelated families and the extension proves nothing.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static isSupported(input, options = null) {\n return Probe(this.is(input), options);\n }\n\n // INTERIM, 2026-08-16. No `inspect` alias onto `isSupported`, while nineteen\n // sibling formats have one. The capability-surface decision page names that\n // alias as the confusion it wants removed, but its own \"What is not proposed\"\n // says not to change things on its strength alone - so this is a divergence\n // awaiting a decision, not a settled position.\n //\n // See maintenance/INTERIM-sqlite-and-static-2026-08-16.md before resolving it,\n // and search for callers of `inspect` on any format first.\n\n /**\n * Reads every table and row.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.output] `json`, `payload` or `raw`.\n * @param {string[]} [options.tables] Read only these tables.\n * @returns {object} Tables keyed by name, each an array of row objects.\n */\n static read(input, options = {}) {\n const output = options.output ?? OUTPUT_JSON;\n const bytes = Normalize(input);\n const header = ReadHeader(bytes);\n const schema = ReadMaster(bytes, header);\n\n if (output === OUTPUT_RAW) {\n return { header, schema };\n }\n\n const wanted = options.tables ? new Set(options.tables) : null;\n const tables = {};\n\n for (const entry of schema) {\n if (entry.type !== \"table\" || (wanted && !wanted.has(entry.name))) {\n continue;\n }\n\n // A table with no root page holds nothing: a view, or WITHOUT ROWID.\n tables[entry.name] = entry.rootPage\n ? ReadTable(bytes, header, entry, output === OUTPUT_JSON)\n : [];\n }\n\n return tables;\n }\n\n /** Reads to plain JSON-compatible values, converting blobs to arrays. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */\n static readRaw(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_RAW });\n }\n\n /**\n * Lists the tables a container holds, without reading their rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @returns {Array<object>} One entry per table.\n */\n static tables(input) {\n const bytes = Normalize(input);\n\n return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === \"table\");\n }\n\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n PAYLOAD: OUTPUT_PAYLOAD,\n RAW: OUTPUT_RAW\n });\n\n static id = \"sqlite\";\n static extensions = Object.freeze([ \".sqlite\", \".db\", \".sqlite3\" ]);\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"sqlite\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n}\n\n/** Builds the probe shape the resource manager routes on. */\nfunction Probe(recognized, options) {\n return {\n format: \"sqlite\",\n source: \"buffer\",\n supported: recognized ? \"full\" : \"none\",\n confidence: 1,\n preferred: \"sqlite\",\n // The header signature is content, not a declaration, so a match is\n // evidence rather than a claim to be checked later.\n verified: true,\n reason: recognized\n ? \"Recognized a SQLite 3 container.\"\n : \"The header signature is not SQLite 3.\",\n variants: [ { kind: \"container\", codec: \"sqlite\", supported: recognized } ],\n metadata: { family: \"sqlite\", decodable: recognized },\n ...(options || {})\n };\n}\n\n/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */\nfunction ReadMaster(bytes, header) {\n const entries = [];\n\n for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {\n const [ type, name, tableName, rootPage, sql ] = ReadRecord(row.payload, header.encoding);\n\n entries.push({\n type: String(type ?? \"\"),\n name: String(name ?? \"\"),\n tableName: String(tableName ?? \"\"),\n rootPage: Number(rootPage ?? 0),\n sql: sql === null || sql === undefined ? \"\" : String(sql)\n });\n }\n\n return entries;\n}\n\n/** Reads one table's rows as objects, named from its `CREATE TABLE` text. */\nfunction ReadTable(bytes, header, entry, json) {\n const { names, rowidAlias } = ReadColumns(entry.sql);\n const rows = [];\n\n for (const row of TableRows(bytes, header, entry.rootPage)) {\n const values = ReadRecord(row.payload, header.encoding);\n const record = {};\n\n for (let index = 0; index < values.length; index += 1) {\n // Positional names keep a row readable when the statement could not be\n // parsed, rather than dropping columns that certainly hold data.\n const name = names[index] ?? `column${index}`;\n const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];\n\n record[name] = json ? ToJSON(value) : value;\n }\n\n rows.push(record);\n }\n\n return rows;\n}\n\n/** Converts a decoded value to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n\n // A BigInt has no JSON form; a decimal string keeps every digit.\n return typeof value === \"bigint\" ? value.toString(10) : value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) {\n return input;\n }\n\n if (input instanceof ArrayBuffer) {\n return new Uint8Array(input);\n }\n\n if (ArrayBuffer.isView(input)) {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n throw SqliteError(\"A SQLite container must be supplied as bytes.\");\n}\n\nexport default CjsSqliteFormat;\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RAW","MASTER_ROOT_PAGE","CjsSqliteFormat","is","input","ReadHeader","Normalize","isSupported","options","Probe","read","output","bytes","header","schema","ReadMaster","wanted","tables","Set","entry","type","has","name","rootPage","ReadTable","readJSON","readPayload","readRaw","filter","Output","Object","freeze","JSON","PAYLOAD","RAW","id","extensions","mediaTypes","inputTypes","outputTypes","debugOutputTypes","recognized","format","source","supported","confidence","preferred","verified","reason","variants","kind","codec","metadata","family","decodable","entries","row","TableRows","tableName","sql","ReadRecord","payload","encoding","push","String","Number","undefined","json","names","rowidAlias","ReadColumns","rows","values","record","index","length","value","rowid","ToJSON","Uint8Array","Array","from","toString","ArrayBuffer","isView","buffer","byteOffset","byteLength","SqliteError"],"mappings":";;;;AAIA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,KAAK;AACxB,MAAMC,gBAAgB,GAAG,CAAC;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,CAAC;AAE3B;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,EAAEA,CAACC,KAAK,EAAE;IACf,IAAI;AACFC,MAAAA,UAAU,CAACC,SAAS,CAACF,KAAK,CAAC,CAAC;AAE5B,MAAA,OAAO,IAAI;AACb,IAAA,CAAC,CAAC,MAAM;AACN,MAAA,OAAO,KAAK;AACd,IAAA;AACF,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOG,WAAWA,CAACH,KAAK,EAAEI,OAAO,GAAG,IAAI,EAAE;IACxC,OAAOC,KAAK,CAAC,IAAI,CAACN,EAAE,CAACC,KAAK,CAAC,EAAEI,OAAO,CAAC;AACvC,EAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOE,IAAIA,CAACN,KAAK,EAAEI,OAAO,GAAG,EAAE,EAAE;AAC/B,IAAA,MAAMG,MAAM,GAAGH,OAAO,CAACG,MAAM,IAAIb,WAAW;AAC5C,IAAA,MAAMc,KAAK,GAAGN,SAAS,CAACF,KAAK,CAAC;AAC9B,IAAA,MAAMS,MAAM,GAAGR,UA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