@omnibuf/web 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +361 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kevin McDonald
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { nextContainerField, type SchemaMeta, type StringCodec } from '@omnibuf/core';
|
|
2
|
+
export * from '@omnibuf/core';
|
|
3
|
+
/**
|
|
4
|
+
* Browser-optimized `StringCodec` using `TextEncoder.encodeInto` and `TextDecoder`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BrowserStringCodec: StringCodec;
|
|
7
|
+
/**
|
|
8
|
+
* Return the human-readable name for a 4-bit OmniBuf wire type (`0..15`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function wireTypeName(wireType: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Convert an OmniBuf `Uint8Array` packet into a browser `Blob` (`application/x-omnibuf`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function toBlob(packet: Uint8Array, mimeType?: string): Blob;
|
|
15
|
+
/**
|
|
16
|
+
* Read an OmniBuf `Uint8Array` packet from a browser `Blob` or `File`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fromBlob(blob: Blob): Promise<Uint8Array>;
|
|
19
|
+
/**
|
|
20
|
+
* Read an OmniBuf `Uint8Array` packet from a Fetch API `Response`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fromResponse(response: Response): Promise<Uint8Array>;
|
|
23
|
+
/**
|
|
24
|
+
* Return a standalone `ArrayBuffer` containing a copy of the OmniBuf packet bytes
|
|
25
|
+
* (suitable for `WebSocket.send`, `RTCDataChannel.send`, or `postMessage` transferables).
|
|
26
|
+
*/
|
|
27
|
+
export declare function toArrayBuffer(packet: Uint8Array): ArrayBuffer;
|
|
28
|
+
/**
|
|
29
|
+
* Wrap an `ArrayBuffer` or `ArrayBufferView` as a `Uint8Array`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fromArrayBuffer(source: ArrayBuffer | ArrayBufferView): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Encode an OmniBuf packet to lowercase hexadecimal string.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toHex(packet: Uint8Array): string;
|
|
36
|
+
/**
|
|
37
|
+
* Decode a hexadecimal string (ignoring whitespace) into an OmniBuf `Uint8Array` packet.
|
|
38
|
+
*/
|
|
39
|
+
export declare function fromHex(hex: string): Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* Encode an OmniBuf packet to a Base64 string.
|
|
42
|
+
*/
|
|
43
|
+
export declare function toBase64(packet: Uint8Array): string;
|
|
44
|
+
/**
|
|
45
|
+
* Decode a Base64 string into an OmniBuf `Uint8Array` packet.
|
|
46
|
+
*/
|
|
47
|
+
export declare function fromBase64(b64: string): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Encode an OmniBuf packet into a `data:application/x-omnibuf;base64,...` Data URL.
|
|
50
|
+
*/
|
|
51
|
+
export declare function toDataURL(packet: Uint8Array, mimeType?: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Decode a `data:...;base64,...` Data URL into an OmniBuf `Uint8Array` packet.
|
|
54
|
+
*/
|
|
55
|
+
export declare function fromDataURL(dataUrl: string): Uint8Array;
|
|
56
|
+
/**
|
|
57
|
+
* Create a Web Streams `TransformStream<Uint8Array, Uint8Array>` that frames each
|
|
58
|
+
* incoming OmniBuf packet with a 4-byte little-endian `uint32` length prefix.
|
|
59
|
+
* Suitable for streaming over `fetch`, `WebTransport`, or `RTCDataChannel`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createOmniBufEncodeStream(): TransformStream<Uint8Array, Uint8Array>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a Web Streams `TransformStream<Uint8Array, Uint8Array>` that deframes
|
|
64
|
+
* 4-byte little-endian length-prefixed chunks into complete OmniBuf `Uint8Array` packets.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createOmniBufDecodeStream(options?: {
|
|
67
|
+
maxFrameBytes?: number;
|
|
68
|
+
}): TransformStream<Uint8Array, Uint8Array>;
|
|
69
|
+
/**
|
|
70
|
+
* Detailed byte-level field breakdown entry returned by `inspectPacket`.
|
|
71
|
+
*/
|
|
72
|
+
export interface InspectedField {
|
|
73
|
+
/** Byte offset where the field tag begins in the packet */
|
|
74
|
+
offset: number;
|
|
75
|
+
/** Total byte length of this field (tag + length header + payload) */
|
|
76
|
+
byteLength: number;
|
|
77
|
+
/** Field number (`0` for inline `SchemaMeta`, `1..N` for user fields) */
|
|
78
|
+
fieldNumber: number;
|
|
79
|
+
/** Resolved field name from `Field #0` `SchemaMeta` if available, else `"field_<N>"` */
|
|
80
|
+
fieldName: string;
|
|
81
|
+
/** 4-bit wire type number (`0..15`) */
|
|
82
|
+
wireType: number;
|
|
83
|
+
/** Human-readable wire type name (e.g. `"uint"`, `"string"`, `"submsg"`) */
|
|
84
|
+
wireTypeName: string;
|
|
85
|
+
/** Hex representation of the tag bytes */
|
|
86
|
+
tagHex: string;
|
|
87
|
+
/** Hex representation of the entire field slice */
|
|
88
|
+
rawHex: string;
|
|
89
|
+
/** Decoded value for this field */
|
|
90
|
+
value: unknown;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Full packet inspection result for frontend devtools, wire explorers, and debugging UIs.
|
|
94
|
+
*/
|
|
95
|
+
export interface PacketInspection {
|
|
96
|
+
/** Total packet size in bytes */
|
|
97
|
+
byteLength: number;
|
|
98
|
+
/** Full packet as lowercase hex */
|
|
99
|
+
hex: string;
|
|
100
|
+
/** Merged `Field #0` `SchemaMeta` if the packet is self-describing, otherwise `null` */
|
|
101
|
+
schemaMeta: SchemaMeta | null;
|
|
102
|
+
/** Ordered list of all fields in wire order */
|
|
103
|
+
fields: InspectedField[];
|
|
104
|
+
/** Schema-less `decodeBlind` output object */
|
|
105
|
+
blind: Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Inspect an OmniBuf packet and return a structured byte-level breakdown of every field,
|
|
109
|
+
* along with its `Field #0` `SchemaMeta` (if present) and `decodeBlind` representation.
|
|
110
|
+
*/
|
|
111
|
+
export declare function inspectPacket(packet: Uint8Array): PacketInspection;
|
|
112
|
+
export { nextContainerField };
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @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ed64, WireFixedArr, WireMap, WireSint, WireSintArr, WireString, WireStringArr, WireSubMsg, WireSubMsgArr, WireUint, WireUintArr, base64ToUint8Array, decodeBlind, decodeVarintAuto, decodeVarintBigInt, decodeZigZagAuto, float32FromBits, float64FromBits, nextContainerField, readField0SchemaMeta, roundFloat32Shortest, setStringCodec, uint8ArrayToBase64, } from '@omnibuf/core';
|
|
2
|
+
export * from '@omnibuf/core';
|
|
3
|
+
const browserEncoder = new TextEncoder();
|
|
4
|
+
const browserDecoder = new TextDecoder('utf-8', { fatal: false });
|
|
5
|
+
/**
|
|
6
|
+
* Browser-optimized `StringCodec` using `TextEncoder.encodeInto` and `TextDecoder`.
|
|
7
|
+
*/
|
|
8
|
+
export const BrowserStringCodec = {
|
|
9
|
+
encode(str) {
|
|
10
|
+
if (str.length === 0)
|
|
11
|
+
return new Uint8Array(0);
|
|
12
|
+
return browserEncoder.encode(str);
|
|
13
|
+
},
|
|
14
|
+
decode(bytes, start = 0, end = bytes.length) {
|
|
15
|
+
if (end <= start)
|
|
16
|
+
return '';
|
|
17
|
+
return browserDecoder.decode(bytes.subarray(start, end));
|
|
18
|
+
},
|
|
19
|
+
byteLength(str) {
|
|
20
|
+
let len = 0;
|
|
21
|
+
for (let i = 0; i < str.length; i++) {
|
|
22
|
+
const code = str.charCodeAt(i);
|
|
23
|
+
if (code < 0x80) {
|
|
24
|
+
len += 1;
|
|
25
|
+
}
|
|
26
|
+
else if (code < 0x800) {
|
|
27
|
+
len += 2;
|
|
28
|
+
}
|
|
29
|
+
else if (code >= 0xd800 &&
|
|
30
|
+
code <= 0xdbff &&
|
|
31
|
+
i + 1 < str.length &&
|
|
32
|
+
str.charCodeAt(i + 1) >= 0xdc00 &&
|
|
33
|
+
str.charCodeAt(i + 1) <= 0xdfff) {
|
|
34
|
+
len += 4;
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
len += 3;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return len;
|
|
42
|
+
},
|
|
43
|
+
encodeInto(str, dst, offset) {
|
|
44
|
+
const res = browserEncoder.encodeInto(str, dst.subarray(offset));
|
|
45
|
+
return res.written ?? 0;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
// Automatically install BrowserStringCodec when @omnibuf/web is imported in browser environments
|
|
49
|
+
setStringCodec(BrowserStringCodec);
|
|
50
|
+
/**
|
|
51
|
+
* Return the human-readable name for a 4-bit OmniBuf wire type (`0..15`).
|
|
52
|
+
*/
|
|
53
|
+
export function wireTypeName(wireType) {
|
|
54
|
+
switch (wireType) {
|
|
55
|
+
case WireUint:
|
|
56
|
+
return 'uint';
|
|
57
|
+
case WireBoolFalse:
|
|
58
|
+
return 'bool_false';
|
|
59
|
+
case WireBoolTrue:
|
|
60
|
+
return 'bool_true';
|
|
61
|
+
case WireString:
|
|
62
|
+
return 'string';
|
|
63
|
+
case WireBytes:
|
|
64
|
+
return 'bytes';
|
|
65
|
+
case WireSubMsg:
|
|
66
|
+
return 'submsg';
|
|
67
|
+
case WireStringArr:
|
|
68
|
+
return 'string_arr';
|
|
69
|
+
case WireUintArr:
|
|
70
|
+
return 'uint_arr';
|
|
71
|
+
case WireSubMsgArr:
|
|
72
|
+
return 'submsg_arr';
|
|
73
|
+
case WireMap:
|
|
74
|
+
return 'map';
|
|
75
|
+
case WireFixed32:
|
|
76
|
+
return 'fixed32';
|
|
77
|
+
case WireFixed64:
|
|
78
|
+
return 'fixed64';
|
|
79
|
+
case WireSint:
|
|
80
|
+
return 'sint';
|
|
81
|
+
case WireSintArr:
|
|
82
|
+
return 'sint_arr';
|
|
83
|
+
case WireFixedArr:
|
|
84
|
+
return 'fixed_arr';
|
|
85
|
+
case WireExtended:
|
|
86
|
+
return 'extended';
|
|
87
|
+
default:
|
|
88
|
+
return `unknown(${wireType})`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Convert an OmniBuf `Uint8Array` packet into a browser `Blob` (`application/x-omnibuf`).
|
|
93
|
+
*/
|
|
94
|
+
export function toBlob(packet, mimeType = 'application/x-omnibuf') {
|
|
95
|
+
const copy = new Uint8Array(packet.byteLength);
|
|
96
|
+
copy.set(packet);
|
|
97
|
+
return new Blob([copy.buffer], { type: mimeType });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read an OmniBuf `Uint8Array` packet from a browser `Blob` or `File`.
|
|
101
|
+
*/
|
|
102
|
+
export async function fromBlob(blob) {
|
|
103
|
+
const ab = await blob.arrayBuffer();
|
|
104
|
+
return new Uint8Array(ab);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Read an OmniBuf `Uint8Array` packet from a Fetch API `Response`.
|
|
108
|
+
*/
|
|
109
|
+
export async function fromResponse(response) {
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
throw new Error(`omnibuf/web: HTTP ${response.status} ${response.statusText}`);
|
|
112
|
+
}
|
|
113
|
+
const ab = await response.arrayBuffer();
|
|
114
|
+
return new Uint8Array(ab);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Return a standalone `ArrayBuffer` containing a copy of the OmniBuf packet bytes
|
|
118
|
+
* (suitable for `WebSocket.send`, `RTCDataChannel.send`, or `postMessage` transferables).
|
|
119
|
+
*/
|
|
120
|
+
export function toArrayBuffer(packet) {
|
|
121
|
+
const copy = new Uint8Array(packet.byteLength);
|
|
122
|
+
copy.set(packet);
|
|
123
|
+
return copy.buffer;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Wrap an `ArrayBuffer` or `ArrayBufferView` as a `Uint8Array`.
|
|
127
|
+
*/
|
|
128
|
+
export function fromArrayBuffer(source) {
|
|
129
|
+
if (source instanceof Uint8Array)
|
|
130
|
+
return source;
|
|
131
|
+
if (ArrayBuffer.isView(source)) {
|
|
132
|
+
return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
133
|
+
}
|
|
134
|
+
return new Uint8Array(source);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Encode an OmniBuf packet to lowercase hexadecimal string.
|
|
138
|
+
*/
|
|
139
|
+
export function toHex(packet) {
|
|
140
|
+
let out = '';
|
|
141
|
+
for (let i = 0; i < packet.length; i++) {
|
|
142
|
+
out += packet[i].toString(16).padStart(2, '0');
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Decode a hexadecimal string (ignoring whitespace) into an OmniBuf `Uint8Array` packet.
|
|
148
|
+
*/
|
|
149
|
+
export function fromHex(hex) {
|
|
150
|
+
const clean = hex.replace(/\s+/g, '');
|
|
151
|
+
if (clean.length % 2 !== 0) {
|
|
152
|
+
throw new Error('omnibuf/web: invalid hex string length');
|
|
153
|
+
}
|
|
154
|
+
const out = new Uint8Array(clean.length / 2);
|
|
155
|
+
for (let i = 0; i < out.length; i++) {
|
|
156
|
+
const byte = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
157
|
+
if (Number.isNaN(byte)) {
|
|
158
|
+
throw new Error(`omnibuf/web: invalid hex byte at index ${i * 2}`);
|
|
159
|
+
}
|
|
160
|
+
out[i] = byte;
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Encode an OmniBuf packet to a Base64 string.
|
|
166
|
+
*/
|
|
167
|
+
export function toBase64(packet) {
|
|
168
|
+
return uint8ArrayToBase64(packet);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Decode a Base64 string into an OmniBuf `Uint8Array` packet.
|
|
172
|
+
*/
|
|
173
|
+
export function fromBase64(b64) {
|
|
174
|
+
return base64ToUint8Array(b64);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Encode an OmniBuf packet into a `data:application/x-omnibuf;base64,...` Data URL.
|
|
178
|
+
*/
|
|
179
|
+
export function toDataURL(packet, mimeType = 'application/x-omnibuf') {
|
|
180
|
+
return `data:${mimeType};base64,${uint8ArrayToBase64(packet)}`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Decode a `data:...;base64,...` Data URL into an OmniBuf `Uint8Array` packet.
|
|
184
|
+
*/
|
|
185
|
+
export function fromDataURL(dataUrl) {
|
|
186
|
+
const commaIdx = dataUrl.indexOf(',');
|
|
187
|
+
if (commaIdx === -1) {
|
|
188
|
+
throw new Error('omnibuf/web: invalid Data URL');
|
|
189
|
+
}
|
|
190
|
+
return base64ToUint8Array(dataUrl.slice(commaIdx + 1));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a Web Streams `TransformStream<Uint8Array, Uint8Array>` that frames each
|
|
194
|
+
* incoming OmniBuf packet with a 4-byte little-endian `uint32` length prefix.
|
|
195
|
+
* Suitable for streaming over `fetch`, `WebTransport`, or `RTCDataChannel`.
|
|
196
|
+
*/
|
|
197
|
+
export function createOmniBufEncodeStream() {
|
|
198
|
+
return new TransformStream({
|
|
199
|
+
transform(packet, controller) {
|
|
200
|
+
const frame = new Uint8Array(4 + packet.byteLength);
|
|
201
|
+
const len = packet.byteLength >>> 0;
|
|
202
|
+
frame[0] = len & 0xff;
|
|
203
|
+
frame[1] = (len >>> 8) & 0xff;
|
|
204
|
+
frame[2] = (len >>> 16) & 0xff;
|
|
205
|
+
frame[3] = (len >>> 24) & 0xff;
|
|
206
|
+
frame.set(packet, 4);
|
|
207
|
+
controller.enqueue(frame);
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Create a Web Streams `TransformStream<Uint8Array, Uint8Array>` that deframes
|
|
213
|
+
* 4-byte little-endian length-prefixed chunks into complete OmniBuf `Uint8Array` packets.
|
|
214
|
+
*/
|
|
215
|
+
export function createOmniBufDecodeStream(options) {
|
|
216
|
+
const maxFrameBytes = options?.maxFrameBytes ?? 16 * 1024 * 1024;
|
|
217
|
+
let buffer = new Uint8Array(0);
|
|
218
|
+
return new TransformStream({
|
|
219
|
+
transform(chunk, controller) {
|
|
220
|
+
if (chunk.byteLength === 0)
|
|
221
|
+
return;
|
|
222
|
+
if (buffer.byteLength === 0) {
|
|
223
|
+
buffer = new Uint8Array(chunk.byteLength);
|
|
224
|
+
buffer.set(chunk);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const merged = new Uint8Array(buffer.byteLength + chunk.byteLength);
|
|
228
|
+
merged.set(buffer, 0);
|
|
229
|
+
merged.set(chunk, buffer.byteLength);
|
|
230
|
+
buffer = merged;
|
|
231
|
+
}
|
|
232
|
+
let offset = 0;
|
|
233
|
+
while (buffer.byteLength - offset >= 4) {
|
|
234
|
+
const frameLen = (buffer[offset] |
|
|
235
|
+
(buffer[offset + 1] << 8) |
|
|
236
|
+
(buffer[offset + 2] << 16) |
|
|
237
|
+
(buffer[offset + 3] << 24)) >>>
|
|
238
|
+
0;
|
|
239
|
+
if (frameLen > maxFrameBytes) {
|
|
240
|
+
controller.error(new Error(`omnibuf/web: frame length ${frameLen} exceeds maxFrameBytes ${maxFrameBytes}`));
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (buffer.byteLength - offset - 4 < frameLen) {
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
const packet = buffer.slice(offset + 4, offset + 4 + frameLen);
|
|
247
|
+
controller.enqueue(packet);
|
|
248
|
+
offset += 4 + frameLen;
|
|
249
|
+
}
|
|
250
|
+
if (offset > 0) {
|
|
251
|
+
buffer = buffer.slice(offset);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
flush(controller) {
|
|
255
|
+
if (buffer.byteLength > 0) {
|
|
256
|
+
controller.error(new Error(`omnibuf/web: truncated frame at end of stream (${buffer.byteLength} trailing bytes)`));
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Inspect an OmniBuf packet and return a structured byte-level breakdown of every field,
|
|
263
|
+
* along with its `Field #0` `SchemaMeta` (if present) and `decodeBlind` representation.
|
|
264
|
+
*/
|
|
265
|
+
export function inspectPacket(packet) {
|
|
266
|
+
const blind = decodeBlind(packet);
|
|
267
|
+
const [schemaMeta] = readField0SchemaMeta(packet);
|
|
268
|
+
const fields = [];
|
|
269
|
+
let pos = 0;
|
|
270
|
+
while (pos < packet.length) {
|
|
271
|
+
const startOffset = pos;
|
|
272
|
+
const [rawTag, tn] = decodeVarintBigInt(packet, pos);
|
|
273
|
+
if (tn === 0) {
|
|
274
|
+
throw new Error(`omnibuf/web: truncated tag at ${pos}`);
|
|
275
|
+
}
|
|
276
|
+
const fieldNumber = Number(rawTag >> 4n);
|
|
277
|
+
const wireType = Number(rawTag & 0x0fn);
|
|
278
|
+
const tagEnd = pos + tn;
|
|
279
|
+
let valEnd = tagEnd;
|
|
280
|
+
let previewValue = null;
|
|
281
|
+
switch (wireType) {
|
|
282
|
+
case WireBoolFalse:
|
|
283
|
+
valEnd = tagEnd;
|
|
284
|
+
previewValue = false;
|
|
285
|
+
break;
|
|
286
|
+
case WireBoolTrue:
|
|
287
|
+
valEnd = tagEnd;
|
|
288
|
+
previewValue = true;
|
|
289
|
+
break;
|
|
290
|
+
case WireUint: {
|
|
291
|
+
const [v, vn] = decodeVarintAuto(packet, tagEnd);
|
|
292
|
+
valEnd = tagEnd + vn;
|
|
293
|
+
previewValue = v;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case WireSint: {
|
|
297
|
+
const [raw, vn] = decodeVarintBigInt(packet, tagEnd);
|
|
298
|
+
valEnd = tagEnd + vn;
|
|
299
|
+
previewValue = decodeZigZagAuto(raw);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
case WireFixed32: {
|
|
303
|
+
valEnd = tagEnd + 4;
|
|
304
|
+
const u32 = (packet[tagEnd] |
|
|
305
|
+
(packet[tagEnd + 1] << 8) |
|
|
306
|
+
(packet[tagEnd + 2] << 16) |
|
|
307
|
+
(packet[tagEnd + 3] << 24)) >>>
|
|
308
|
+
0;
|
|
309
|
+
previewValue = roundFloat32Shortest(float32FromBits(u32));
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case WireFixed64: {
|
|
313
|
+
valEnd = tagEnd + 8;
|
|
314
|
+
let u64 = 0n;
|
|
315
|
+
for (let b = 7; b >= 0; b--) {
|
|
316
|
+
u64 = (u64 << 8n) | BigInt(packet[tagEnd + b]);
|
|
317
|
+
}
|
|
318
|
+
previewValue = float64FromBits(u64);
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
default: {
|
|
322
|
+
const [lenBig, ln] = decodeVarintBigInt(packet, tagEnd);
|
|
323
|
+
const payloadStart = tagEnd + ln;
|
|
324
|
+
const len = Number(lenBig);
|
|
325
|
+
valEnd = payloadStart + len;
|
|
326
|
+
if (wireType === WireString) {
|
|
327
|
+
previewValue = BrowserStringCodec.decode(packet, payloadStart, valEnd);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
const fname = fieldNumber === 0
|
|
331
|
+
? '_schema'
|
|
332
|
+
: (schemaMeta?.fields?.[fieldNumber] ?? `field_${fieldNumber}`);
|
|
333
|
+
previewValue = fname === '_schema' ? schemaMeta : blind[fname];
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const fieldName = fieldNumber === 0 ? '_schema' : (schemaMeta?.fields?.[fieldNumber] ?? `field_${fieldNumber}`);
|
|
339
|
+
fields.push({
|
|
340
|
+
offset: startOffset,
|
|
341
|
+
byteLength: valEnd - startOffset,
|
|
342
|
+
fieldNumber,
|
|
343
|
+
fieldName,
|
|
344
|
+
wireType,
|
|
345
|
+
wireTypeName: wireTypeName(wireType),
|
|
346
|
+
tagHex: toHex(packet.subarray(startOffset, tagEnd)),
|
|
347
|
+
rawHex: toHex(packet.subarray(startOffset, valEnd)),
|
|
348
|
+
value: previewValue,
|
|
349
|
+
});
|
|
350
|
+
pos = valEnd;
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
byteLength: packet.byteLength,
|
|
354
|
+
hex: toHex(packet),
|
|
355
|
+
schemaMeta,
|
|
356
|
+
fields,
|
|
357
|
+
blind,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
export { nextContainerField };
|
|
361
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AAEvB,cAAc,eAAe,CAAC;AAE9B,MAAM,cAAc,GAAG,IAAI,WAAW,EAAE,CAAC;AACzC,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,MAAM,CAAC,GAAW;QAChB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/C,OAAO,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,CAAC,KAAiB,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM;QACrD,IAAI,GAAG,IAAI,KAAK;YAAE,OAAO,EAAE,CAAC;QA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C,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjE,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GACb,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,IAAI,SAAS,WAAW,EAAE,CAAC,CAAC;QAEhG,MAAM,CAAC,IAAI,CAAC;YACV,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,MAAM,GAAG,WAAW;YAChC,WAAW;YACX,SAAS;YACT,QAAQ;YACR,YAAY,EAAE,YAAY,CAAC,QAAQ,CAAC;YACpC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACnD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACnD,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QAEH,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IAED,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;QAClB,UAAU;QACV,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnibuf/web",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "OmniBuf for browsers and frontend runtimes - Web Streams, Blob/Response helpers, and interactive wire inspection",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/sudorandom/omnibuf-es.git",
|
|
24
|
+
"directory": "packages/omnibuf-web"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@omnibuf/core": "0.0.1"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@bufbuild/protobuf": ">=1.0.0 || >=2.0.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@bufbuild/protobuf": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.json",
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"test": "node --import tsx --test test/*.test.ts",
|
|
44
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
45
|
+
}
|
|
6
46
|
}
|
package/README.md
DELETED