@elaraai/east 1.0.68 → 1.0.70

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 (132) hide show
  1. package/dist/src/ast.d.ts +2 -0
  2. package/dist/src/ast.d.ts.map +1 -1
  3. package/dist/src/ast_to_ir.d.ts +7 -3
  4. package/dist/src/ast_to_ir.d.ts.map +1 -1
  5. package/dist/src/ast_to_ir.js +62 -15
  6. package/dist/src/ast_to_ir.js.map +1 -1
  7. package/dist/src/builtins.d.ts +1 -1
  8. package/dist/src/builtins.d.ts.map +1 -1
  9. package/dist/src/builtins.js +7 -0
  10. package/dist/src/builtins.js.map +1 -1
  11. package/dist/src/codegen/codegen.spec.d.ts +6 -0
  12. package/dist/src/codegen/codegen.spec.d.ts.map +1 -0
  13. package/dist/src/codegen/codegen.spec.js +763 -0
  14. package/dist/src/codegen/codegen.spec.js.map +1 -0
  15. package/dist/src/codegen/doc.d.ts +111 -0
  16. package/dist/src/codegen/doc.d.ts.map +1 -0
  17. package/dist/src/codegen/doc.js +350 -0
  18. package/dist/src/codegen/doc.js.map +1 -0
  19. package/dist/src/codegen/doc.spec.d.ts +6 -0
  20. package/dist/src/codegen/doc.spec.d.ts.map +1 -0
  21. package/dist/src/codegen/doc.spec.js +86 -0
  22. package/dist/src/codegen/doc.spec.js.map +1 -0
  23. package/dist/src/codegen/index.d.ts +15 -0
  24. package/dist/src/codegen/index.d.ts.map +1 -0
  25. package/dist/src/codegen/index.js +15 -0
  26. package/dist/src/codegen/index.js.map +1 -0
  27. package/dist/src/codegen/printer.d.ts +63 -0
  28. package/dist/src/codegen/printer.d.ts.map +1 -0
  29. package/dist/src/codegen/printer.js +1529 -0
  30. package/dist/src/codegen/printer.js.map +1 -0
  31. package/dist/src/codegen/spellings.d.ts +73 -0
  32. package/dist/src/codegen/spellings.d.ts.map +1 -0
  33. package/dist/src/codegen/spellings.js +299 -0
  34. package/dist/src/codegen/spellings.js.map +1 -0
  35. package/dist/src/codegen/spellings.spec.d.ts +6 -0
  36. package/dist/src/codegen/spellings.spec.d.ts.map +1 -0
  37. package/dist/src/codegen/spellings.spec.js +191 -0
  38. package/dist/src/codegen/spellings.spec.js.map +1 -0
  39. package/dist/src/codegen/types.d.ts +67 -0
  40. package/dist/src/codegen/types.d.ts.map +1 -0
  41. package/dist/src/codegen/types.js +173 -0
  42. package/dist/src/codegen/types.js.map +1 -0
  43. package/dist/src/compile.d.ts.map +1 -1
  44. package/dist/src/compile.js +50 -2
  45. package/dist/src/compile.js.map +1 -1
  46. package/dist/src/compile.open_beast.spec.d.ts +6 -0
  47. package/dist/src/compile.open_beast.spec.d.ts.map +1 -0
  48. package/dist/src/compile.open_beast.spec.js +99 -0
  49. package/dist/src/compile.open_beast.spec.js.map +1 -0
  50. package/dist/src/expr/blob.d.ts +41 -1
  51. package/dist/src/expr/blob.d.ts.map +1 -1
  52. package/dist/src/expr/blob.js +52 -0
  53. package/dist/src/expr/blob.js.map +1 -1
  54. package/dist/src/expr/block.d.ts +148 -0
  55. package/dist/src/expr/block.d.ts.map +1 -1
  56. package/dist/src/expr/block.js +168 -4
  57. package/dist/src/expr/block.js.map +1 -1
  58. package/dist/src/expr/index.d.ts +155 -2
  59. package/dist/src/expr/index.d.ts.map +1 -1
  60. package/dist/src/expr/index.js +155 -2
  61. package/dist/src/expr/index.js.map +1 -1
  62. package/dist/src/expr/libs/datetime.d.ts +11 -0
  63. package/dist/src/expr/libs/datetime.d.ts.map +1 -1
  64. package/dist/src/expr/libs/datetime.js +11 -0
  65. package/dist/src/expr/libs/datetime.js.map +1 -1
  66. package/dist/src/functions.crossimport.spec.d.ts +6 -0
  67. package/dist/src/functions.crossimport.spec.d.ts.map +1 -0
  68. package/dist/src/functions.crossimport.spec.js +45 -0
  69. package/dist/src/functions.crossimport.spec.js.map +1 -0
  70. package/dist/src/functions.d.ts +4103 -0
  71. package/dist/src/functions.d.ts.map +1 -0
  72. package/dist/src/functions.js +443 -0
  73. package/dist/src/functions.js.map +1 -0
  74. package/dist/src/functions.spec.d.ts +6 -0
  75. package/dist/src/functions.spec.d.ts.map +1 -0
  76. package/dist/src/functions.spec.js +123 -0
  77. package/dist/src/functions.spec.js.map +1 -0
  78. package/dist/src/index.d.ts +2 -0
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +2 -0
  81. package/dist/src/index.js.map +1 -1
  82. package/dist/src/naming.d.ts +50 -0
  83. package/dist/src/naming.d.ts.map +1 -0
  84. package/dist/src/naming.js +194 -0
  85. package/dist/src/naming.js.map +1 -0
  86. package/dist/src/naming.spec.d.ts +6 -0
  87. package/dist/src/naming.spec.d.ts.map +1 -0
  88. package/dist/src/naming.spec.js +154 -0
  89. package/dist/src/naming.spec.js.map +1 -0
  90. package/dist/src/serialization/beast2/index.d.ts +16 -1
  91. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  92. package/dist/src/serialization/beast2/index.js +24 -3
  93. package/dist/src/serialization/beast2/index.js.map +1 -1
  94. package/dist/src/serialization/beast2/index.spec.js +25 -0
  95. package/dist/src/serialization/beast2/index.spec.js.map +1 -1
  96. package/dist/src/serialization/beast2/shared.d.ts +1 -1
  97. package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
  98. package/dist/src/serialization/beast2/shared.js +9 -1
  99. package/dist/src/serialization/beast2/shared.js.map +1 -1
  100. package/dist/src/serialization/beast2/v4/container.d.ts +10 -0
  101. package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
  102. package/dist/src/serialization/beast2/v4/container.js +13 -0
  103. package/dist/src/serialization/beast2/v4/container.js.map +1 -1
  104. package/dist/src/serialization/beast2/v5/frames.d.ts +17 -0
  105. package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
  106. package/dist/src/serialization/beast2/v5/frames.js +40 -0
  107. package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
  108. package/dist/src/serialization/beast2/v5/geometry.d.ts +10 -113
  109. package/dist/src/serialization/beast2/v5/geometry.d.ts.map +1 -1
  110. package/dist/src/serialization/beast2/v5/geometry.js +7 -151
  111. package/dist/src/serialization/beast2/v5/geometry.js.map +1 -1
  112. package/dist/src/serialization/beast2/v5/lazy.d.ts +8 -2
  113. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  114. package/dist/src/serialization/beast2/v5/lazy.js +9 -3
  115. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  116. package/dist/src/serialization/beast2/v5/range.d.ts +201 -0
  117. package/dist/src/serialization/beast2/v5/range.d.ts.map +1 -0
  118. package/dist/src/serialization/beast2/v5/range.js +252 -0
  119. package/dist/src/serialization/beast2/v5/range.js.map +1 -0
  120. package/dist/src/serialization/beast2/v5/stream.d.ts +29 -5
  121. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  122. package/dist/src/serialization/beast2/v5/stream.js +86 -19
  123. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  124. package/dist/src/serialization/beast2/v5/sync-reader.spec.d.ts +6 -0
  125. package/dist/src/serialization/beast2/v5/sync-reader.spec.d.ts.map +1 -0
  126. package/dist/src/serialization/beast2/v5/sync-reader.spec.js +228 -0
  127. package/dist/src/serialization/beast2/v5/sync-reader.spec.js.map +1 -0
  128. package/dist/src/serialization/index.d.ts +1 -1
  129. package/dist/src/serialization/index.d.ts.map +1 -1
  130. package/dist/src/serialization/index.js +1 -1
  131. package/dist/src/serialization/index.js.map +1 -1
  132. package/package.json +11 -2
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Beast2 v5 ranged access — reading a segmented, indexed blob's geometry
7
+ * through positioned byte reads instead of a whole buffer.
8
+ *
9
+ * A v5 collection blob is `header · tag frame · segment frames · terminator
10
+ * frame · index · footer`, so its whole geometry is recoverable from two
11
+ * ranged reads: the tail (footer + index) and the head (header sections +
12
+ * tag frame). Every segment frame's byte range is then known up front, and a
13
+ * paging reader fetches only the frames it decodes: an Array index read or
14
+ * a Set/Dict keyed read touches one frame, iteration touches each frame
15
+ * once. The exception is a Set/Dict root's FIRST keyed read, which verifies
16
+ * the segment fences by probing every frame once (as east-c does) — a
17
+ * bounded prefix of each frame, read and inflated as far as it goes, never
18
+ * the frame unless its first key is wider than the probe. I/O is O(header +
19
+ * index + touched frames) in every case; peak memory is O(segment).
20
+ *
21
+ * Two reader shapes serve two consumers: {@link Beast2RangeReader} (async —
22
+ * an HTTP range request, an S3 ranged GET, e3's dataset paging) and
23
+ * {@link Beast2SyncRangeReader} (sync — a file descriptor with positioned
24
+ * reads, a memory mapping, a plain `Uint8Array`), which is what a compiled
25
+ * East body drives through `Beast2Pages` and `openBeast2LazyFor`. Core stays
26
+ * free of any file system: the reader is injected.
27
+ */
28
+ import { type EastTypeValue } from "../../../type_of_type.js";
29
+ /** The exact bytes of the root NEW tag frame and of the terminator frame:
30
+ * codec `none`, one logical byte, payload `0x00`. */
31
+ export declare const TAG_OR_TERMINATOR_FRAME: Uint8Array<ArrayBuffer>;
32
+ /**
33
+ * The byte geometry of a segmented, indexed v5 blob.
34
+ *
35
+ * All offsets are absolute wire offsets into the blob the extents were read
36
+ * from. The value stream occupies `[0, indexOffset)`: header sections and the
37
+ * root tag frame in `[0, prefixEnd)`, segment frames in
38
+ * `[prefixEnd, segmentsEnd)`, and the terminator frame in
39
+ * `[segmentsEnd, indexOffset)`.
40
+ */
41
+ export interface Beast2Extents {
42
+ /** End of the header sections + root tag frame — the first segment frame
43
+ * starts here. */
44
+ readonly prefixEnd: number;
45
+ /** End of the last segment frame — the terminator frame starts here. */
46
+ readonly segmentsEnd: number;
47
+ /** Wire offset of the index section. */
48
+ readonly indexOffset: number;
49
+ /** Absolute wire offset of each segment's frame. */
50
+ readonly offsets: readonly number[];
51
+ /** Element count of each segment (pairs for Dict roots). */
52
+ readonly counts: readonly number[];
53
+ /** Sum of all segment counts. */
54
+ readonly elementCount: number;
55
+ /** Whether segments are independently decodable (no cross-segment
56
+ * aliasing) — required by both carve and splice. */
57
+ readonly selfContained: boolean;
58
+ /** Whether the header source-map section carries no stacks. */
59
+ readonly sourceMapEmpty: boolean;
60
+ /** The blob's wire root type. */
61
+ readonly typeValue: EastTypeValue;
62
+ }
63
+ /**
64
+ * Ranged access to an immutable blob: its total byte size plus positional
65
+ * reads.
66
+ *
67
+ * The blob is content-addressed and its size known up front, so callers only
68
+ * ever request ranges inside `[0, size)` and `read` must return exactly the
69
+ * requested bytes. Backed by anything that can serve byte ranges — a file
70
+ * descriptor, an HTTP range request, an S3 ranged GET.
71
+ */
72
+ export interface Beast2RangeReader {
73
+ /** Total blob size in bytes. */
74
+ readonly size: number;
75
+ /**
76
+ * Reads `length` bytes at absolute wire offset `offset`.
77
+ *
78
+ * @param offset - absolute byte offset into the blob
79
+ * @param length - number of bytes to read
80
+ * @returns exactly the requested bytes
81
+ */
82
+ read(offset: number, length: number): Promise<Uint8Array>;
83
+ }
84
+ /**
85
+ * Synchronous ranged access to an immutable blob — the sync twin of
86
+ * {@link Beast2RangeReader}, for the paging readers a compiled East body
87
+ * drives without awaiting (`Beast2Pages`, `openBeast2LazyFor`).
88
+ *
89
+ * Backed by anything that serves byte ranges synchronously: a file
90
+ * descriptor with positioned reads (so the blob's residency is the page
91
+ * cache, not the heap), a memory mapping, or a plain `Uint8Array`. As for
92
+ * the async reader, `read` must return exactly the requested bytes, and the
93
+ * returned buffer is the reader's to reuse only after the caller is done
94
+ * with it — a paging reader decodes a frame as soon as it reads it.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const fd = openSync("rows.beast2", "r");
99
+ * const reader: Beast2SyncRangeReader = {
100
+ * size: fstatSync(fd).size,
101
+ * read(offset, length) {
102
+ * const out = new Uint8Array(length);
103
+ * let done = 0;
104
+ * while (done < length) done += readSync(fd, out, done, length - done, offset + done);
105
+ * return out;
106
+ * },
107
+ * };
108
+ * const rows = openBeast2LazyFor(ArrayType(RowType), { frozen: true })(reader);
109
+ * ```
110
+ */
111
+ export interface Beast2SyncRangeReader {
112
+ /** Total blob size in bytes. */
113
+ readonly size: number;
114
+ /**
115
+ * Reads `length` bytes at absolute wire offset `offset`.
116
+ *
117
+ * @param offset - absolute byte offset into the blob
118
+ * @param length - number of bytes to read
119
+ * @returns exactly the requested bytes
120
+ */
121
+ read(offset: number, length: number): Uint8Array;
122
+ }
123
+ /** Options accepted by {@link readBeast2ExtentsRanged} and
124
+ * {@link readBeast2ExtentsSync}. */
125
+ export type ReadBeast2ExtentsRangedOptions = {
126
+ /** Initial tail-probe size in bytes (default 64 KiB). When the index
127
+ * section is larger than the probe, one further tail read fetches the
128
+ * rest — the probe only tunes how often that second read happens. */
129
+ tailProbeBytes?: number;
130
+ };
131
+ /**
132
+ * A blob's {@link Beast2Extents} read via ranged access, plus the header
133
+ * bytes `carveBeast2Ranged` reuses.
134
+ *
135
+ * Everything a paged reader needs to serve any window of the blob without
136
+ * ever buffering it whole: the segment geometry addresses the frame byte
137
+ * ranges, and `head` carries the header sections a window blob is assembled
138
+ * under.
139
+ */
140
+ export interface Beast2RangedExtents extends Beast2Extents {
141
+ /** Total blob size in bytes. */
142
+ readonly size: number;
143
+ /** Bytes `[0, prefixEnd)` — the header sections and the root tag frame. */
144
+ readonly head: Uint8Array;
145
+ }
146
+ /** Whether `source` is a {@link Beast2SyncRangeReader} rather than a blob —
147
+ * judged by shape, since a typed array from another realm fails
148
+ * `instanceof Uint8Array`. */
149
+ export declare function isBeast2SyncRangeReader(source: unknown): source is Beast2SyncRangeReader;
150
+ /**
151
+ * Reads exactly `length` bytes at `offset` through a sync reader, refusing a
152
+ * short result up front: a reader that returns fewer bytes (a bare
153
+ * `readSync` without the retry loop) would otherwise be reported as a
154
+ * malformed blob.
155
+ *
156
+ * @param reader - the reader
157
+ * @param offset - absolute byte offset
158
+ * @param length - number of bytes
159
+ * @returns exactly the requested bytes
160
+ * @throws {Error} When the reader returns a different number of bytes.
161
+ */
162
+ export declare function readExact(reader: Beast2SyncRangeReader, offset: number, length: number): Uint8Array;
163
+ /** Whether the 4 bytes at `offset` are a tag/terminator frame. */
164
+ export declare function isTagOrTerminatorFrame(data: Uint8Array, offset: number): boolean;
165
+ /** Parses the u64 little-endian index offset from 8 bytes at `at`. */
166
+ export declare function readU64LE(data: Uint8Array, at: number): number;
167
+ /**
168
+ * Reads the byte geometry of a segmented, indexed v5 collection blob through
169
+ * ranged access — the footer and index from a tail read, the header sections
170
+ * from a head read — without ever buffering the blob whole.
171
+ *
172
+ * The result carries everything `carveBeast2Ranged` needs to assemble a
173
+ * standalone blob for any segment span whose frame bytes are then the only
174
+ * further reads: total I/O for a window is O(header + index + window), not
175
+ * O(blob).
176
+ *
177
+ * @param reader - ranged access to the blob
178
+ * @param options - tail-probe tuning
179
+ * @returns the blob's {@link Beast2RangedExtents}
180
+ * @throws {Error} When the blob is not a v5 container, its root is not a
181
+ * collection, it carries no index, or the frame geometry is malformed —
182
+ * the same conditions `readBeast2Extents` rejects.
183
+ */
184
+ export declare function readBeast2ExtentsRanged(reader: Beast2RangeReader, options?: ReadBeast2ExtentsRangedOptions): Promise<Beast2RangedExtents>;
185
+ /**
186
+ * The synchronous twin of {@link readBeast2ExtentsRanged}: the same two
187
+ * ranged reads (tail, then head) through a {@link Beast2SyncRangeReader},
188
+ * for the paging readers a compiled body drives without awaiting.
189
+ *
190
+ * @param reader - synchronous ranged access to the blob
191
+ * @param options - tail-probe tuning
192
+ * @returns the blob's {@link Beast2RangedExtents}
193
+ * @throws {Error} When the blob is not a v5 container, its root is not a
194
+ * collection, it carries no index, or the frame geometry is malformed.
195
+ */
196
+ export declare function readBeast2ExtentsSync(reader: Beast2SyncRangeReader, options?: ReadBeast2ExtentsRangedOptions): Beast2RangedExtents;
197
+ /** A {@link Beast2SyncRangeReader} over a whole in-memory blob: reads are
198
+ * zero-copy views. What the `Uint8Array` entry points wrap, so every paging
199
+ * reader has one source shape. */
200
+ export declare function bytesReader(data: Uint8Array): Beast2SyncRangeReader;
201
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/range.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAW9D;sDACsD;AACtD,eAAO,MAAM,uBAAuB,yBAA2C,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B;uBACmB;IACnB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,wCAAwC;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,iCAAiC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;yDACqD;IACrD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EA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 /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Beast2 v5 ranged access — reading a segmented, indexed blob's geometry
7
+ * through positioned byte reads instead of a whole buffer.
8
+ *
9
+ * A v5 collection blob is `header · tag frame · segment frames · terminator
10
+ * frame · index · footer`, so its whole geometry is recoverable from two
11
+ * ranged reads: the tail (footer + index) and the head (header sections +
12
+ * tag frame). Every segment frame's byte range is then known up front, and a
13
+ * paging reader fetches only the frames it decodes: an Array index read or
14
+ * a Set/Dict keyed read touches one frame, iteration touches each frame
15
+ * once. The exception is a Set/Dict root's FIRST keyed read, which verifies
16
+ * the segment fences by probing every frame once (as east-c does) — a
17
+ * bounded prefix of each frame, read and inflated as far as it goes, never
18
+ * the frame unless its first key is wider than the probe. I/O is O(header +
19
+ * index + touched frames) in every case; peak memory is O(segment).
20
+ *
21
+ * Two reader shapes serve two consumers: {@link Beast2RangeReader} (async —
22
+ * an HTTP range request, an S3 ranged GET, e3's dataset paging) and
23
+ * {@link Beast2SyncRangeReader} (sync — a file descriptor with positioned
24
+ * reads, a memory mapping, a plain `Uint8Array`), which is what a compiled
25
+ * East body drives through `Beast2Pages` and `openBeast2LazyFor`. Core stays
26
+ * free of any file system: the reader is injected.
27
+ */
28
+ import {} from "../../../type_of_type.js";
29
+ import { BufferReader } from "../../binary-utils.js";
30
+ import { readTypeSection } from "./type-section.js";
31
+ import { MAGIC_BYTES_V5, FOOTER_MAGIC_V5, INDEX_FLAG_SELF_CONTAINED, readSourceMapSectionV5, isSegmentedRoot, } from "./codec.js";
32
+ /** The exact bytes of the root NEW tag frame and of the terminator frame:
33
+ * codec `none`, one logical byte, payload `0x00`. */
34
+ export const TAG_OR_TERMINATOR_FRAME = new Uint8Array([0x00, 0x01, 0x01, 0x00]);
35
+ /** Whether `source` is a {@link Beast2SyncRangeReader} rather than a blob —
36
+ * judged by shape, since a typed array from another realm fails
37
+ * `instanceof Uint8Array`. */
38
+ export function isBeast2SyncRangeReader(source) {
39
+ const r = source;
40
+ return r !== null && typeof r === "object" && typeof r.read === "function" && typeof r.size === "number";
41
+ }
42
+ /**
43
+ * Reads exactly `length` bytes at `offset` through a sync reader, refusing a
44
+ * short result up front: a reader that returns fewer bytes (a bare
45
+ * `readSync` without the retry loop) would otherwise be reported as a
46
+ * malformed blob.
47
+ *
48
+ * @param reader - the reader
49
+ * @param offset - absolute byte offset
50
+ * @param length - number of bytes
51
+ * @returns exactly the requested bytes
52
+ * @throws {Error} When the reader returns a different number of bytes.
53
+ */
54
+ export function readExact(reader, offset, length) {
55
+ const bytes = reader.read(offset, length);
56
+ if (bytes.length !== length) {
57
+ throw new Error(`beast2 v5: reader returned ${bytes.length} bytes for a ${length}-byte range at offset ${offset}`);
58
+ }
59
+ return bytes;
60
+ }
61
+ /** Whether the 4 bytes at `offset` are a tag/terminator frame. */
62
+ export function isTagOrTerminatorFrame(data, offset) {
63
+ if (offset + 4 > data.length)
64
+ return false;
65
+ for (let i = 0; i < 4; i++) {
66
+ if (data[offset + i] !== TAG_OR_TERMINATOR_FRAME[i])
67
+ return false;
68
+ }
69
+ return true;
70
+ }
71
+ /** Parses the u64 little-endian index offset from 8 bytes at `at`. */
72
+ export function readU64LE(data, at) {
73
+ let value = 0n;
74
+ for (let i = 7; i >= 0; i--) {
75
+ value = (value << 8n) | BigInt(data[at + i]);
76
+ }
77
+ return Number(value);
78
+ }
79
+ /** The size of the initial tail read: the footer plus a probe of the index. */
80
+ function tailProbeSize(size, options) {
81
+ return Math.min(size, Math.max(options?.tailProbeBytes ?? 64 * 1024, 16));
82
+ }
83
+ /** Reads the footer from a tail read holding `[tailStart, size)`: the index
84
+ * offset, validated against the blob size. */
85
+ function footerIndexOffset(tail, tailStart, size) {
86
+ const footerStart = size - 16;
87
+ for (let i = 0; i < 8; i++) {
88
+ if (tail[footerStart + 8 + i - tailStart] !== FOOTER_MAGIC_V5[i]) {
89
+ throw new Error(`beast2 v5: blob carries no index — ranged reads need one (write with the index enabled, the default)`);
90
+ }
91
+ }
92
+ const indexOffset = readU64LE(tail, footerStart - tailStart);
93
+ if (indexOffset < MAGIC_BYTES_V5.length || indexOffset >= footerStart) {
94
+ throw new Error(`beast2 v5: footer index offset ${indexOffset} out of range`);
95
+ }
96
+ return indexOffset;
97
+ }
98
+ /** Parses the index section and checks the terminator frame from a tail
99
+ * read holding `[tailStart, size)` that reaches back to the terminator. */
100
+ function parseIndexTail(tail, tailStart, size, indexOffset) {
101
+ const footerStart = size - 16;
102
+ const segmentsEnd = indexOffset - TAG_OR_TERMINATOR_FRAME.length;
103
+ const indexReader = new BufferReader(tail, indexOffset - tailStart);
104
+ const flags = indexReader.readVarint();
105
+ if ((flags & ~INDEX_FLAG_SELF_CONTAINED) !== 0) {
106
+ throw new Error(`beast2 v5: unknown index flags 0x${flags.toString(16)}`);
107
+ }
108
+ const segmentCount = indexReader.readVarint();
109
+ const offsets = new Array(segmentCount);
110
+ const counts = new Array(segmentCount);
111
+ let prev = 0;
112
+ let elementCount = 0;
113
+ for (let i = 0; i < segmentCount; i++) {
114
+ prev += indexReader.readVarint();
115
+ offsets[i] = prev;
116
+ counts[i] = indexReader.readVarint();
117
+ elementCount += counts[i];
118
+ if (prev >= indexOffset) {
119
+ throw new Error(`beast2 v5: index segment offset ${prev} overlaps the index section`);
120
+ }
121
+ }
122
+ if (indexReader.offset !== footerStart - tailStart) {
123
+ throw new Error(`beast2 v5: index section size mismatch (ends at ${indexReader.offset + tailStart}, footer at ${footerStart})`);
124
+ }
125
+ if (!isTagOrTerminatorFrame(tail, segmentsEnd - tailStart)) {
126
+ throw new Error(`beast2 v5: terminator frame not found where expected (offset ${segmentsEnd})`);
127
+ }
128
+ return { segmentsEnd, offsets, counts, elementCount, selfContained: (flags & INDEX_FLAG_SELF_CONTAINED) !== 0 };
129
+ }
130
+ /** Parses the header sections + root tag frame from a head read holding
131
+ * `[0, prefixEnd)`: the v5 magic, a collection root type, the source-map
132
+ * section, and the tag frame ending exactly at `prefixEnd`. */
133
+ function parseHead(head, prefixEnd) {
134
+ for (let i = 0; i < 8; i++) {
135
+ if (head[i] !== MAGIC_BYTES_V5[i]) {
136
+ if (i === 7 && head[i] === 0x04) {
137
+ throw new Error(`beast2 v5: ranged reads need v5 blobs; this is a v4 container (re-encode with version 5)`);
138
+ }
139
+ throw new Error(`beast2 v5: not a beast2 v5 container`);
140
+ }
141
+ }
142
+ const headReader = new BufferReader(head, MAGIC_BYTES_V5.length);
143
+ const { rootType } = readTypeSection(headReader);
144
+ if (!isSegmentedRoot(rootType)) {
145
+ throw new Error(`beast2 v5: ranged reads address Array, Set or Dict roots, not ${rootType.type}`);
146
+ }
147
+ const sourceMap = readSourceMapSectionV5(headReader);
148
+ const frameOffset = headReader.offset;
149
+ if (frameOffset + 4 !== prefixEnd || !isTagOrTerminatorFrame(head, frameOffset)) {
150
+ throw new Error(`beast2 v5: root tag frame not found where expected (offset ${frameOffset})`);
151
+ }
152
+ return { rootType, sourceMapEmpty: sourceMap.size <= 1n };
153
+ }
154
+ /** Assembles the extents from the parsed tail and head. */
155
+ function assembleExtents(size, indexOffset, index, prefixEnd, head) {
156
+ const { rootType, sourceMapEmpty } = parseHead(head, prefixEnd);
157
+ return {
158
+ prefixEnd,
159
+ segmentsEnd: index.segmentsEnd,
160
+ indexOffset,
161
+ offsets: index.offsets,
162
+ counts: index.counts,
163
+ elementCount: index.elementCount,
164
+ selfContained: index.selfContained,
165
+ sourceMapEmpty,
166
+ typeValue: rootType,
167
+ size,
168
+ head,
169
+ };
170
+ }
171
+ /**
172
+ * Reads the byte geometry of a segmented, indexed v5 collection blob through
173
+ * ranged access — the footer and index from a tail read, the header sections
174
+ * from a head read — without ever buffering the blob whole.
175
+ *
176
+ * The result carries everything `carveBeast2Ranged` needs to assemble a
177
+ * standalone blob for any segment span whose frame bytes are then the only
178
+ * further reads: total I/O for a window is O(header + index + window), not
179
+ * O(blob).
180
+ *
181
+ * @param reader - ranged access to the blob
182
+ * @param options - tail-probe tuning
183
+ * @returns the blob's {@link Beast2RangedExtents}
184
+ * @throws {Error} When the blob is not a v5 container, its root is not a
185
+ * collection, it carries no index, or the frame geometry is malformed —
186
+ * the same conditions `readBeast2Extents` rejects.
187
+ */
188
+ export async function readBeast2ExtentsRanged(reader, options) {
189
+ const size = reader.size;
190
+ if (size < MAGIC_BYTES_V5.length + 16) {
191
+ throw new Error(`Data too short for Beast2 format: ${size} bytes`);
192
+ }
193
+ // Tail: footer first, then the index section (one further read when the
194
+ // probe missed its start).
195
+ let tailStart = size - tailProbeSize(size, options);
196
+ let tail = checkedLength(await reader.read(tailStart, size - tailStart), tailStart, size - tailStart);
197
+ const indexOffset = footerIndexOffset(tail, tailStart, size);
198
+ const segmentsEnd = indexOffset - TAG_OR_TERMINATOR_FRAME.length;
199
+ if (segmentsEnd < tailStart) {
200
+ tailStart = segmentsEnd;
201
+ tail = checkedLength(await reader.read(tailStart, size - tailStart), tailStart, size - tailStart);
202
+ }
203
+ const index = parseIndexTail(tail, tailStart, size, indexOffset);
204
+ // Head: header sections + root tag frame, ending exactly where the first
205
+ // segment starts (or at the terminator, for an empty blob).
206
+ const prefixEnd = index.offsets.length > 0 ? index.offsets[0] : segmentsEnd;
207
+ const head = checkedLength(await reader.read(0, prefixEnd), 0, prefixEnd);
208
+ return assembleExtents(size, indexOffset, index, prefixEnd, head);
209
+ }
210
+ /** The exact-length check {@link readExact} applies, for an awaited read. */
211
+ function checkedLength(bytes, offset, length) {
212
+ if (bytes.length !== length) {
213
+ throw new Error(`beast2 v5: reader returned ${bytes.length} bytes for a ${length}-byte range at offset ${offset}`);
214
+ }
215
+ return bytes;
216
+ }
217
+ /**
218
+ * The synchronous twin of {@link readBeast2ExtentsRanged}: the same two
219
+ * ranged reads (tail, then head) through a {@link Beast2SyncRangeReader},
220
+ * for the paging readers a compiled body drives without awaiting.
221
+ *
222
+ * @param reader - synchronous ranged access to the blob
223
+ * @param options - tail-probe tuning
224
+ * @returns the blob's {@link Beast2RangedExtents}
225
+ * @throws {Error} When the blob is not a v5 container, its root is not a
226
+ * collection, it carries no index, or the frame geometry is malformed.
227
+ */
228
+ export function readBeast2ExtentsSync(reader, options) {
229
+ const size = reader.size;
230
+ if (size < MAGIC_BYTES_V5.length + 16) {
231
+ throw new Error(`Data too short for Beast2 format: ${size} bytes`);
232
+ }
233
+ let tailStart = size - tailProbeSize(size, options);
234
+ let tail = readExact(reader, tailStart, size - tailStart);
235
+ const indexOffset = footerIndexOffset(tail, tailStart, size);
236
+ const segmentsEnd = indexOffset - TAG_OR_TERMINATOR_FRAME.length;
237
+ if (segmentsEnd < tailStart) {
238
+ tailStart = segmentsEnd;
239
+ tail = readExact(reader, tailStart, size - tailStart);
240
+ }
241
+ const index = parseIndexTail(tail, tailStart, size, indexOffset);
242
+ const prefixEnd = index.offsets.length > 0 ? index.offsets[0] : segmentsEnd;
243
+ const head = readExact(reader, 0, prefixEnd);
244
+ return assembleExtents(size, indexOffset, index, prefixEnd, head);
245
+ }
246
+ /** A {@link Beast2SyncRangeReader} over a whole in-memory blob: reads are
247
+ * zero-copy views. What the `Uint8Array` entry points wrap, so every paging
248
+ * reader has one source shape. */
249
+ export function bytesReader(data) {
250
+ return { size: data.length, read: (offset, length) => data.subarray(offset, offset + length) };
251
+ }
252
+ //# sourceMappingURL=range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/range.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB;sDACsD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AAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AACjG,CAAC"}
@@ -24,6 +24,7 @@ import type { EastType, ValueTypeOf } from "../../../types.js";
24
24
  import { SourceMap } from "../../../location.js";
25
25
  import { type Beast2DecodeOptions } from "../shared.js";
26
26
  import { type Beast2Codec } from "./frames.js";
27
+ import { type Beast2SyncRangeReader } from "./range.js";
27
28
  /** Options accepted by {@link Beast2Writer} and {@link encodeBeast2SegmentsFor}. */
28
29
  export type Beast2WriterOptions = {
29
30
  /** Per-frame codec. Defaults to `"deflate"`. */
@@ -191,6 +192,15 @@ export declare function iterBeast2SegmentsFor<T extends EastType>(type: T | East
191
192
  * small LRU, so a read loop over neighbouring rows decodes each segment once
192
193
  * rather than once per element; {@link segment} itself always decodes fresh.
193
194
  *
195
+ * The blob is either a whole `Uint8Array` or a {@link Beast2SyncRangeReader}:
196
+ * through a reader the open reads only the tail (footer + index) and the
197
+ * head (header sections), and every segment read fetches exactly that
198
+ * segment's frame — a file-backed reader keeps the wire bytes in the page
199
+ * cache rather than on the heap. A Set/Dict root's first keyed read verifies
200
+ * the fences, probing a bounded prefix of every frame once (never the frame,
201
+ * unless its first key is wider than the probe); later keyed reads fetch one
202
+ * frame.
203
+ *
194
204
  * Set/Dict blobs page like Arrays: the wire holds the canonical value split
195
205
  * at segment boundaries (strictly ascending, disjoint segments), so row
196
206
  * windows ({@link slice}) and key lookups ({@link get}) address the sorted
@@ -209,7 +219,9 @@ export declare class Beast2Pages<T extends EastType = EastType> {
209
219
  readonly elementCount: number;
210
220
  /** Whether segments are independently decodable. */
211
221
  readonly selfContained: boolean;
212
- private readonly data;
222
+ private readonly source;
223
+ /** Wire offset of the terminator frame — where the last segment's frame ends. */
224
+ private readonly segmentsEnd;
213
225
  private readonly indexData;
214
226
  private readonly kind;
215
227
  private readonly typeValue;
@@ -230,9 +242,14 @@ export declare class Beast2Pages<T extends EastType = EastType> {
230
242
  * container walk. */
231
243
  private readonly segmentCache;
232
244
  /** @internal Use {@link openBeast2PagesFor}. */
233
- constructor(data: Uint8Array, typeValue: EastTypeValue, options?: Beast2DecodeOptions);
245
+ constructor(source: Uint8Array | Beast2SyncRangeReader, typeValue: EastTypeValue, options?: Beast2DecodeOptions);
234
246
  /** Number of segments in the blob. */
235
247
  get segmentCount(): number;
248
+ /** Reads segment `i`'s frame — exactly its wire bytes, from its index
249
+ * offset to the next segment's (or the terminator) — and opens its
250
+ * logical chunk. The only place segment bytes are fetched, so a ranged
251
+ * source touches one frame per decode. */
252
+ private frameReader;
236
253
  /**
237
254
  * Decodes one segment by index.
238
255
  *
@@ -256,7 +273,10 @@ export declare class Beast2Pages<T extends EastType = EastType> {
256
273
  * only — see {@link segmentCache}. */
257
274
  private segmentCached;
258
275
  /** Decodes just the first key/element of segment `i` — a bounded probe
259
- * (one frame inflate, one element decode), not a whole-segment decode. */
276
+ * (a prefix of the frame read and inflated, one element decode), not a
277
+ * whole-segment decode. A first key wider than the probe grows it; the
278
+ * final attempt reads the frame whole, so corruption is still reported
279
+ * with the frame's own error. */
260
280
  private firstKey;
261
281
  /**
262
282
  * Probes segment `i`'s fence: its first Dict key, Set element, or Array
@@ -326,13 +346,17 @@ export declare class Beast2Pages<T extends EastType = EastType> {
326
346
  get(key: ValueTypeOf<T> extends Map<infer K, any> ? K : ValueTypeOf<T> extends Set<infer E> ? E : never): (ValueTypeOf<T> extends Map<any, infer V> ? V : ValueTypeOf<T> extends Set<infer E> ? E : never) | undefined;
327
347
  }
328
348
  /**
329
- * Builds a curried pages opener: `open(data)` parses the header, footer and
349
+ * Builds a curried pages opener: `open(source)` parses the header, footer and
330
350
  * index once and returns a {@link Beast2Pages} for random access.
331
351
  *
352
+ * `source` is the whole blob, or a {@link Beast2SyncRangeReader} over it —
353
+ * then only the tail, the head and the segments actually read are ever
354
+ * fetched.
355
+ *
332
356
  * @param type - the collection type (Array/Set/Dict)
333
357
  * @param options - decode options (platform functions for decoded functions)
334
358
  * @returns a function opening a blob for paged reads
335
359
  * @throws {TypeError} When `type` is not an Array, Set or Dict type.
336
360
  */
337
- export declare function openBeast2PagesFor<T extends EastType>(type: T | EastTypeValue, options?: Beast2DecodeOptions): (data: Uint8Array) => Beast2Pages<T>;
361
+ export declare function openBeast2PagesFor<T extends EastType>(type: T | EastTypeValue, options?: Beast2DecodeOptions): (source: Uint8Array | Beast2SyncRangeReader) => Beast2Pages<T>;
338
362
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAuC,MAAM,0BAA0B,CAAC;AACnG,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,KAAK,mBAAmB,EAAwB,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,aAAa,CAAC;AAsCxE,oFAAoF;AACpF,MAAM,MAAM,mBAAmB,GAAG;IAChC,gDAAgD;IAChD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;6CACyC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;8BAC0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B;;;;6EAIyE;IACzE,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,QAAQ,GAA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