@omnibuf/core 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 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.
@@ -0,0 +1,62 @@
1
+ import { Encoder } from './encoder.js';
2
+ /**
3
+ * SchemaMeta is the optional inline schema header encoded as Field #0
4
+ * (`Tag = 0x0B`, `WireSubMsg = 5`) at byte 0 of an OmniBuf message (`omnibuf.v1.SchemaMeta`).
5
+ */
6
+ export interface SchemaMeta {
7
+ typeName?: string;
8
+ fields?: Record<number, string>;
9
+ children?: Record<number, SchemaMeta>;
10
+ }
11
+ export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
12
+ export declare function base64ToUint8Array(b64: string): Uint8Array;
13
+ /**
14
+ * Writes Field #0 (`Tag = 0x0B`, `WireSubMsg = 5`) containing `meta` into `enc`.
15
+ */
16
+ export declare function writeField0SchemaMeta(enc: Encoder, meta: SchemaMeta | null | undefined, deterministic?: boolean): void;
17
+ /**
18
+ * Encodes Field #0 (`Tag = 0x0B`, `WireSubMsg = 5`) containing `meta` as a Uint8Array.
19
+ */
20
+ export declare function encodeField0SchemaMeta(meta: SchemaMeta | null | undefined, deterministic?: boolean): Uint8Array;
21
+ /**
22
+ * Merges two `SchemaMeta` definitions (later fields and children override/extend earlier ones).
23
+ */
24
+ export declare function mergeSchemaMeta(base: SchemaMeta | null | undefined, next: SchemaMeta | null | undefined): SchemaMeta | null;
25
+ export declare function decodeSchemaMeta(data: Uint8Array, depth?: number, limit?: number): SchemaMeta;
26
+ /**
27
+ * Decodes and merges all Field #0 (`Tag = 0x0B`, `WireSubMsg = 5`) SchemaMeta blocks in `packet`.
28
+ */
29
+ export declare function readField0SchemaMeta(packet: Uint8Array): [meta: SchemaMeta | null, ok: boolean];
30
+ export interface DecodeBlindOptions {
31
+ /**
32
+ * When true, `WireBytes` fields are returned as standard Base64 strings (matching Go's `encoding/json` output).
33
+ * When false (default), `WireBytes` fields are returned as `Uint8Array`.
34
+ */
35
+ bytesAsBase64?: boolean;
36
+ /**
37
+ * When true (default), `WireFixed32` values are rounded to their shortest 32-bit IEEE-754 decimal representation.
38
+ */
39
+ roundFloat32?: boolean;
40
+ }
41
+ /**
42
+ * Decodes any OmniBuf packet without a compile-time schema.
43
+ * If Field #0 (`Tag = 0x0B`, `WireSubMsg = 5`, `omnibuf.v1.SchemaMeta`) is present, its field names
44
+ * (and any nested children schemas) are used to decode human-readable keys.
45
+ * Otherwise, synthetic field names (`"field_1"`, `"field_2"`, ...) are used.
46
+ */
47
+ export declare function decodeBlind(packet: Uint8Array, options?: DecodeBlindOptions): Record<string, unknown>;
48
+ /**
49
+ * Serializes a blind-decoded object to JSON with deterministic lexicographically sorted object keys,
50
+ * exact 64-bit `bigint` numeric emission, and base64-encoded `Uint8Array` values.
51
+ * If the object contains `NaN` or `Infinity` (which cannot be represented in standard JSON),
52
+ * returns `"{}"` when `fallbackOnNonFinite` is true.
53
+ */
54
+ export declare function stringifyBlindJSON(value: unknown, indent?: number, fallbackOnNonFinite?: boolean): string;
55
+ /**
56
+ * Decodes an OmniBuf packet without a schema and returns the formatted JSON string.
57
+ */
58
+ export declare function decodeBlindJSON(packet: Uint8Array, options?: {
59
+ indent?: number;
60
+ fallbackOnNonFinite?: boolean;
61
+ }): string;
62
+ //# sourceMappingURL=blind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blind.d.ts","sourceRoot":"","sources":["../src/blind.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AAoCtD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACvC;AAOD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CA0B5D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAkB1D;AAuDD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACnC,aAAa,UAAQ,GACpB,IAAI,CAMN;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACnC,aAAa,UAAO,GACnB,UAAU,CAKZ;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACnC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAClC,UAAU,GAA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