@zmdb/protobuf 1.0.0-beta.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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @zmdb/protobuf
2
+
3
+ `@zmdb/protobuf` provides the source calls, typed gRPC service artifacts, and zero-dependency wire runtime used by zmdb's ahead-of-time protobuf compiler.
4
+
5
+ Reflection, descriptor emission, and codec generation are build-time responsibilities of `@zmdb/compiler`; this package contains no schema parser or TypeScript compiler.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ yarn add @zmdb/protobuf@1.0.0-beta.1
11
+ yarn add --dev @zmdb/compiler@1.0.0-beta.1 typescript@^7
12
+ ```
13
+
14
+ > **Prerelease** (`1.0.0-beta.1`). Requires **Node.js 26+** and is **ESM-only**. Ships built ESM `.js` + `.d.ts` under `./dist`.
15
+
16
+ `@zmdb/protobuf` has no runtime dependency or peer dependency and is not installed by `yarn add zmdb@1.0.0-beta.1`. Its development dependency is `@zmdb/compiler`, the build-time reflector/emitter;
17
+ generated code imports the wire runtime from this package.
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { protoDescriptor, protoEncode } from '@zmdb/protobuf';
23
+ import { type Proto, type ProtoField } from '@zmdb/schema/tags';
24
+
25
+ interface OrderMessage {
26
+ readonly id: string & ProtoField<1>;
27
+ readonly total: number & Proto<'int32'> & ProtoField<2>;
28
+ }
29
+
30
+ const descriptor = protoDescriptor<OrderMessage>();
31
+ const bytes = protoEncode<OrderMessage>({ id: 'o1', total: 42 });
32
+
33
+ void [descriptor, bytes];
34
+ ```
35
+
36
+ The source calls above must pass through the `@zmdb/compiler` build transform or project compiler. The package owns no compiler process, file watcher, connection, or shutdown hook.
37
+
38
+ ## Entry points
39
+
40
+ - `@zmdb/protobuf` — `protoEncode`, `protoDecode`, `protoDescriptor`, `grpcDescriptor`, `loadGrpcService`, and the typed service-artifact contracts.
41
+ - `@zmdb/protobuf/wire` — `ProtoReader` and `ProtoWriter`, the generated-code ABI.
42
+
43
+ ## Documentation
44
+
45
+ Full docs: **https://ambasta.github.io/zmdb/**
46
+
47
+ ## License
48
+
49
+ GNU General Public License v3.0 or later (GPL-3.0-or-later) — see [LICENSE](./LICENSE).
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Encode `value` as protobuf at build time.
3
+ *
4
+ * The type argument and its field tags do not exist at runtime, so the build plugin
5
+ * replaces this call with a generated encoder. An unreplaced call cannot guess a wire
6
+ * contract and fails by name.
7
+ */
8
+ export declare function protoEncode<T>(_value: T): Uint8Array;
9
+ /**
10
+ * Decode protobuf `bytes` as `T` at build time.
11
+ *
12
+ * The type argument and its field tags do not exist at runtime, so the build plugin
13
+ * replaces this call with a generated decoder. An unreplaced call cannot guess a wire
14
+ * contract and fails by name.
15
+ */
16
+ export declare function protoDecode<T>(_bytes: Uint8Array): T;
17
+ /**
18
+ * Emit the proto3 descriptor for `T` at build time.
19
+ *
20
+ * A type argument does not exist at runtime, so an untransformed call cannot provide
21
+ * a partial fallback. The build plugin replaces this call with a string literal.
22
+ */
23
+ export declare function protoDescriptor<_T>(): string;
24
+ /**
25
+ * One gRPC method declaration. Request and response types are reflected by the
26
+ * AOT transformer; the stream flags are present-or-absent so there is one
27
+ * spelling for each call shape.
28
+ */
29
+ export interface GrpcMethodDef {
30
+ readonly request: unknown;
31
+ readonly response: unknown;
32
+ readonly requestStream?: true;
33
+ readonly responseStream?: true;
34
+ }
35
+ /** A closed service declaration. Concrete services must be type aliases. */
36
+ export type GrpcServiceDef = {
37
+ readonly [method: string]: GrpcMethodDef;
38
+ };
39
+ /** Generated codecs and validators for one method. */
40
+ export interface GrpcLoadedMethod<D extends GrpcMethodDef> {
41
+ readonly path: string;
42
+ readonly requestStream: boolean;
43
+ readonly responseStream: boolean;
44
+ validateRequest(value: unknown): D['request'];
45
+ serializeRequest(value: D['request']): Uint8Array;
46
+ deserializeRequest(bytes: Uint8Array): D['request'];
47
+ validateResponse(value: unknown): D['response'];
48
+ serializeResponse(value: D['response']): Uint8Array;
49
+ deserializeResponse(bytes: Uint8Array): D['response'];
50
+ }
51
+ /**
52
+ * A build-time service artifact. No descriptor is parsed at runtime: the AOT
53
+ * transformer emits this object and its straight-line protobuf codecs.
54
+ */
55
+ export interface GrpcLoadedService<S extends GrpcServiceDef> {
56
+ readonly name: string;
57
+ readonly descriptor: string;
58
+ readonly methods: {
59
+ readonly [M in keyof S]: GrpcLoadedMethod<S[M]>;
60
+ };
61
+ }
62
+ /**
63
+ * Emit a complete proto3 file for `S` at build time.
64
+ *
65
+ * An untransformed call cannot recover `S`, so it fails by name.
66
+ */
67
+ export declare function grpcDescriptor<_S extends GrpcServiceDef>(_service: string, _package: string): string;
68
+ /**
69
+ * Load a typed gRPC service from `S` at build time.
70
+ *
71
+ * "Load" means emit the descriptor, codecs and validators from TypeScript. It
72
+ * never reads or parses a `.proto` file.
73
+ */
74
+ export declare function loadGrpcService<S extends GrpcServiceDef>(_service: string, _package: string): GrpcLoadedService<S>;
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,CAMpD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAAE,KAAK,MAAM,CAM5C;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;CAChC;AAED,4EA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EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAMlH"}
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Encode `value` as protobuf at build time.
3
+ *
4
+ * The type argument and its field tags do not exist at runtime, so the build plugin
5
+ * replaces this call with a generated encoder. An unreplaced call cannot guess a wire
6
+ * contract and fails by name.
7
+ */
8
+ export function protoEncode(_value) {
9
+ throw new Error('protoEncode<T>(value) was not replaced at build time. It is compiled away by @zmdb/compiler ' +
10
+ '(the unplugin, Metro adapter, or project compiler), which did not run over this file — a type argument cannot ' +
11
+ 'be read at runtime, so there is no protobuf wire contract to fall back to.');
12
+ }
13
+ /**
14
+ * Decode protobuf `bytes` as `T` at build time.
15
+ *
16
+ * The type argument and its field tags do not exist at runtime, so the build plugin
17
+ * replaces this call with a generated decoder. An unreplaced call cannot guess a wire
18
+ * contract and fails by name.
19
+ */
20
+ export function protoDecode(_bytes) {
21
+ throw new Error('protoDecode<T>(bytes) was not replaced at build time. It is compiled away by @zmdb/compiler ' +
22
+ '(the unplugin, Metro adapter, or project compiler), which did not run over this file — a type argument cannot ' +
23
+ 'be read at runtime, so there is no protobuf wire contract to fall back to.');
24
+ }
25
+ /**
26
+ * Emit the proto3 descriptor for `T` at build time.
27
+ *
28
+ * A type argument does not exist at runtime, so an untransformed call cannot provide
29
+ * a partial fallback. The build plugin replaces this call with a string literal.
30
+ */
31
+ export function protoDescriptor() {
32
+ throw new Error('protoDescriptor<T>() was not replaced at build time. It is compiled away by @zmdb/compiler ' +
33
+ '(the unplugin, Metro adapter, or project compiler), which did not run over this file — a type argument cannot ' +
34
+ 'be read at runtime, so there is no descriptor to fall back to.');
35
+ }
36
+ /**
37
+ * Emit a complete proto3 file for `S` at build time.
38
+ *
39
+ * An untransformed call cannot recover `S`, so it fails by name.
40
+ */
41
+ export function grpcDescriptor(_service, _package) {
42
+ throw new Error('grpcDescriptor<S>(service, package) was not replaced at build time. It is compiled away by ' +
43
+ '@zmdb/compiler (the unplugin, Metro adapter, or project compiler), which did not run over this file — a type argument ' +
44
+ 'cannot be read at runtime, so there is no gRPC descriptor to fall back to.');
45
+ }
46
+ /**
47
+ * Load a typed gRPC service from `S` at build time.
48
+ *
49
+ * "Load" means emit the descriptor, codecs and validators from TypeScript. It
50
+ * never reads or parses a `.proto` file.
51
+ */
52
+ export function loadGrpcService(_service, _package) {
53
+ throw new Error('loadGrpcService<S>(service, package) was not replaced at build time. It is compiled away by ' +
54
+ '@zmdb/compiler (the unplugin, Metro adapter, or project compiler), which did not run over this file — a type argument ' +
55
+ 'cannot be read at runtime, so there is no gRPC service definition to fall back to.');
56
+ }
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,MAAS;IACtC,MAAM,IAAI,KAAK,CACb,8FAA8F;QAC5F,gHAAgH;QAChH,4EAA4E,CAC/E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,MAAkB;IAC/C,MAAM,IAAI,KAAK,CACb,8FAA8F;QAC5F,gHAAgH;QAChH,4EAA4E,CAC/E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,KAAK,CACb,6FAA6F;QAC3F,gHAAgH;QAChH,gEAAgE,CACnE,CAAC;AACJ,CAAC;AAwCD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAA4B,QAAgB,EAAE,QAAgB;IAC1F,MAAM,IAAI,KAAK,CACb,6FAA6F;QAC3F,wHAAwH;QACxH,4EAA4E,CAC/E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAA2B,QAAgB,EAAE,QAAgB;IAC1F,MAAM,IAAI,KAAK,CACb,8FAA8F;QAC5F,wHAAwH;QACxH,oFAAoF,CACvF,CAAC;AACJ,CAAC"}
package/dist/wire.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ /** A growable protobuf output buffer. `finish()` returns an exact-sized copy. */
2
+ export declare class ProtoWriter {
3
+ #private;
4
+ /** A field key: `(field number << 3) | wire type`, without 32-bit bitwise truncation. */
5
+ tag(fieldNumber: number, wireType: 0 | 1 | 2 | 5): void;
6
+ uint32(value: number): void;
7
+ int32(value: number): void;
8
+ sint32(value: number): void;
9
+ uint64(value: bigint): void;
10
+ int64(value: bigint): void;
11
+ sint64(value: bigint): void;
12
+ fixed32(value: number): void;
13
+ sfixed32(value: number): void;
14
+ fixed64(value: bigint): void;
15
+ sfixed64(value: bigint): void;
16
+ float(value: number): void;
17
+ double(value: number): void;
18
+ bool(value: boolean): void;
19
+ string(value: string): void;
20
+ bytes(value: Uint8Array): void;
21
+ /** Detach the written prefix from spare capacity. */
22
+ finish(): Uint8Array;
23
+ }
24
+ /** A bounded protobuf input cursor. Every length is checked before a view is made. */
25
+ export declare class ProtoReader {
26
+ #private;
27
+ constructor(bytes?: Uint8Array);
28
+ get done(): boolean;
29
+ get offset(): number;
30
+ /** Read and validate a field key, returning `(field number << 3) | wire type`. */
31
+ key(): number;
32
+ uint32(): number;
33
+ int32(): number;
34
+ sint32(): number;
35
+ uint64(): bigint;
36
+ int64(): bigint;
37
+ sint64(): bigint;
38
+ fixed32(): number;
39
+ sfixed32(): number;
40
+ fixed64(): bigint;
41
+ sfixed64(): bigint;
42
+ float(): number;
43
+ double(): number;
44
+ bool(): boolean;
45
+ string(): string;
46
+ /** A cursor bounded to one length-delimited payload. */
47
+ message(): ProtoReader;
48
+ /** Discard one unknown occurrence without trusting its length. Groups are refused. */
49
+ skip(wireType: number): void;
50
+ }
51
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAYA,iFAA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AM,CAEf;IAED,KAAK,IAAI,MAAM,CAEd;IAED,MAAM,IAAI,MAAM,CAGf;IAED,MAAM,IAAI,MAAM,CAEf;IAED,KAAK,IAAI,MAAM,CAEd;IAED,MAAM,IAAI,MAAM,CAGf;IAED,OAAO,IAAI,MAAM,CAKhB;IAED,QAAQ,IAAI,MAAM,CAKjB;IAED,OAAO,IAAI,MAAM,CAKhB;IAED,QAAQ,IAAI,MAAM,CAKjB;IAED,KAAK,IAAI,MAAM,CAKd;IAED,MAAM,IAAI,MAAM,CAKf;IAED,IAAI,IAAI,OAAO,CAEd;IAED,MAAM,IAAI,MAAM,CASf;IAED,wDAAwD;IACxD,OAAO,IAAI,WAAW,CAErB;IAED,sFAAsF;IACtF,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAqB3B;CAmDF"}
package/dist/wire.js ADDED
@@ -0,0 +1,286 @@
1
+ // The small runtime the AOT protobuf codecs target.
2
+ //
3
+ // Message shape, field numbers and scalar choices have already been compiled into
4
+ // straight-line JavaScript. These classes own only byte-level wire primitives; neither
5
+ // receives a descriptor or performs a field lookup.
6
+ const INITIAL_CAPACITY = 64;
7
+ const UTF8 = new TextEncoder();
8
+ const UTF8_DECODER = new TextDecoder('utf-8', { fatal: true });
9
+ const EMPTY_BYTES = new Uint8Array();
10
+ const MAX_FIELD_NUMBER = 536_870_911;
11
+ /** A growable protobuf output buffer. `finish()` returns an exact-sized copy. */
12
+ export class ProtoWriter {
13
+ #buffer = new Uint8Array(INITIAL_CAPACITY);
14
+ #view = new DataView(this.#buffer.buffer);
15
+ #length = 0;
16
+ /** A field key: `(field number << 3) | wire type`, without 32-bit bitwise truncation. */
17
+ tag(fieldNumber, wireType) {
18
+ this.uint32(fieldNumber * 8 + wireType);
19
+ }
20
+ uint32(value) {
21
+ this.#varint(BigInt.asUintN(32, BigInt(value)));
22
+ }
23
+ int32(value) {
24
+ this.#varint(BigInt.asUintN(64, BigInt(value)));
25
+ }
26
+ sint32(value) {
27
+ const signed = BigInt.asIntN(32, BigInt(value));
28
+ this.#varint(BigInt.asUintN(32, (signed << 1n) ^ (signed >> 31n)));
29
+ }
30
+ uint64(value) {
31
+ this.#varint(BigInt.asUintN(64, value));
32
+ }
33
+ int64(value) {
34
+ this.#varint(BigInt.asUintN(64, value));
35
+ }
36
+ sint64(value) {
37
+ const signed = BigInt.asIntN(64, value);
38
+ this.#varint(BigInt.asUintN(64, (signed << 1n) ^ (signed >> 63n)));
39
+ }
40
+ fixed32(value) {
41
+ this.#reserve(4);
42
+ this.#view.setUint32(this.#length, value, true);
43
+ this.#length += 4;
44
+ }
45
+ sfixed32(value) {
46
+ this.#reserve(4);
47
+ this.#view.setInt32(this.#length, value, true);
48
+ this.#length += 4;
49
+ }
50
+ fixed64(value) {
51
+ this.#reserve(8);
52
+ this.#view.setBigUint64(this.#length, BigInt.asUintN(64, value), true);
53
+ this.#length += 8;
54
+ }
55
+ sfixed64(value) {
56
+ this.#reserve(8);
57
+ this.#view.setBigInt64(this.#length, BigInt.asIntN(64, value), true);
58
+ this.#length += 8;
59
+ }
60
+ float(value) {
61
+ this.#reserve(4);
62
+ this.#view.setFloat32(this.#length, value, true);
63
+ this.#length += 4;
64
+ }
65
+ double(value) {
66
+ this.#reserve(8);
67
+ this.#view.setFloat64(this.#length, value, true);
68
+ this.#length += 8;
69
+ }
70
+ bool(value) {
71
+ this.uint32(value ? 1 : 0);
72
+ }
73
+ string(value) {
74
+ this.bytes(UTF8.encode(value));
75
+ }
76
+ bytes(value) {
77
+ this.uint32(value.byteLength);
78
+ this.#reserve(value.byteLength);
79
+ this.#buffer.set(value, this.#length);
80
+ this.#length += value.byteLength;
81
+ }
82
+ /** Detach the written prefix from spare capacity. */
83
+ finish() {
84
+ return this.#buffer.slice(0, this.#length);
85
+ }
86
+ #varint(value) {
87
+ let remaining = value;
88
+ while (remaining >= 0x80n) {
89
+ this.#byte(Number((remaining & 0x7fn) | 0x80n));
90
+ remaining >>= 7n;
91
+ }
92
+ this.#byte(Number(remaining));
93
+ }
94
+ #byte(value) {
95
+ this.#reserve(1);
96
+ this.#buffer[this.#length] = value;
97
+ this.#length += 1;
98
+ }
99
+ #reserve(extra) {
100
+ const needed = this.#length + extra;
101
+ if (needed <= this.#buffer.byteLength)
102
+ return;
103
+ let capacity = this.#buffer.byteLength;
104
+ while (capacity < needed)
105
+ capacity *= 2;
106
+ const grown = new Uint8Array(capacity);
107
+ grown.set(this.#buffer);
108
+ this.#buffer = grown;
109
+ this.#view = new DataView(grown.buffer);
110
+ }
111
+ }
112
+ /** A bounded protobuf input cursor. Every length is checked before a view is made. */
113
+ export class ProtoReader {
114
+ #bytes;
115
+ #view;
116
+ #offset = 0;
117
+ constructor(bytes = EMPTY_BYTES) {
118
+ this.#bytes = bytes;
119
+ this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
120
+ }
121
+ get done() {
122
+ return this.#offset === this.#bytes.byteLength;
123
+ }
124
+ get offset() {
125
+ return this.#offset;
126
+ }
127
+ /** Read and validate a field key, returning `(field number << 3) | wire type`. */
128
+ key() {
129
+ const at = this.#offset;
130
+ const value = this.#varint();
131
+ if (value > 0xffffffffn) {
132
+ throw new RangeError(`protobuf field key at offset ${at} exceeds 32 bits`);
133
+ }
134
+ const key = Number(value);
135
+ const fieldNumber = Math.floor(key / 8);
136
+ const wireType = key % 8;
137
+ if (fieldNumber < 1 || fieldNumber > MAX_FIELD_NUMBER) {
138
+ throw new RangeError(`invalid protobuf field number ${fieldNumber} at offset ${at}`);
139
+ }
140
+ if (wireType === 6 || wireType === 7) {
141
+ throw new RangeError(`invalid protobuf wire type ${wireType} at offset ${at}`);
142
+ }
143
+ return key;
144
+ }
145
+ uint32() {
146
+ return Number(BigInt.asUintN(32, this.#varint()));
147
+ }
148
+ int32() {
149
+ return Number(BigInt.asIntN(32, this.#varint()));
150
+ }
151
+ sint32() {
152
+ const value = BigInt.asUintN(32, this.#varint());
153
+ return Number(BigInt.asIntN(32, (value >> 1n) ^ -(value & 1n)));
154
+ }
155
+ uint64() {
156
+ return BigInt.asUintN(64, this.#varint());
157
+ }
158
+ int64() {
159
+ return BigInt.asIntN(64, this.#varint());
160
+ }
161
+ sint64() {
162
+ const value = BigInt.asUintN(64, this.#varint());
163
+ return BigInt.asIntN(64, (value >> 1n) ^ -(value & 1n));
164
+ }
165
+ fixed32() {
166
+ this.#require(4, 'fixed32');
167
+ const value = this.#view.getUint32(this.#offset, true);
168
+ this.#offset += 4;
169
+ return value;
170
+ }
171
+ sfixed32() {
172
+ this.#require(4, 'sfixed32');
173
+ const value = this.#view.getInt32(this.#offset, true);
174
+ this.#offset += 4;
175
+ return value;
176
+ }
177
+ fixed64() {
178
+ this.#require(8, 'fixed64');
179
+ const value = this.#view.getBigUint64(this.#offset, true);
180
+ this.#offset += 8;
181
+ return value;
182
+ }
183
+ sfixed64() {
184
+ this.#require(8, 'sfixed64');
185
+ const value = this.#view.getBigInt64(this.#offset, true);
186
+ this.#offset += 8;
187
+ return value;
188
+ }
189
+ float() {
190
+ this.#require(4, 'float');
191
+ const value = this.#view.getFloat32(this.#offset, true);
192
+ this.#offset += 4;
193
+ return value;
194
+ }
195
+ double() {
196
+ this.#require(8, 'double');
197
+ const value = this.#view.getFloat64(this.#offset, true);
198
+ this.#offset += 8;
199
+ return value;
200
+ }
201
+ bool() {
202
+ return this.#varint() !== 0n;
203
+ }
204
+ string() {
205
+ const at = this.#offset;
206
+ const bytes = this.#lengthDelimited();
207
+ try {
208
+ return UTF8_DECODER.decode(bytes);
209
+ }
210
+ catch (error) {
211
+ const detail = error instanceof Error ? error.message : String(error);
212
+ throw new TypeError(`invalid protobuf UTF-8 string at offset ${at}: ${detail}`, { cause: error });
213
+ }
214
+ }
215
+ /** A cursor bounded to one length-delimited payload. */
216
+ message() {
217
+ return new ProtoReader(this.#lengthDelimited());
218
+ }
219
+ /** Discard one unknown occurrence without trusting its length. Groups are refused. */
220
+ skip(wireType) {
221
+ const at = this.#offset;
222
+ switch (wireType) {
223
+ case 0:
224
+ this.#varint();
225
+ return;
226
+ case 1:
227
+ this.#advance(8, 'fixed64 unknown field');
228
+ return;
229
+ case 2:
230
+ this.#lengthDelimited();
231
+ return;
232
+ case 3:
233
+ case 4:
234
+ throw new RangeError(`deprecated protobuf group wire type ${wireType} at offset ${at} is not supported`);
235
+ case 5:
236
+ this.#advance(4, 'fixed32 unknown field');
237
+ return;
238
+ default:
239
+ throw new RangeError(`invalid protobuf wire type ${wireType} at offset ${at}`);
240
+ }
241
+ }
242
+ #varint() {
243
+ const start = this.#offset;
244
+ let value = 0n;
245
+ for (let index = 0; index < 10; index += 1) {
246
+ if (this.#offset >= this.#bytes.byteLength) {
247
+ throw new RangeError(`truncated protobuf varint at offset ${start}; input ended at offset ${this.#offset}`);
248
+ }
249
+ const byte = this.#bytes[this.#offset];
250
+ if (byte === undefined) {
251
+ throw new RangeError(`truncated protobuf varint at offset ${start}; input ended at offset ${this.#offset}`);
252
+ }
253
+ this.#offset += 1;
254
+ if (index === 9 && byte > 1) {
255
+ throw new RangeError(`protobuf varint at offset ${start} exceeds 64 bits`);
256
+ }
257
+ value |= BigInt(byte & 0x7f) << BigInt(index * 7);
258
+ if ((byte & 0x80) === 0)
259
+ return value;
260
+ }
261
+ throw new RangeError(`protobuf varint at offset ${start} exceeds 10 bytes`);
262
+ }
263
+ #lengthDelimited() {
264
+ const prefix = this.#offset;
265
+ const encoded = this.#varint();
266
+ const remaining = BigInt(this.#bytes.byteLength - this.#offset);
267
+ if (encoded > remaining) {
268
+ throw new RangeError(`protobuf length ${encoded} at offset ${prefix} exceeds ${remaining} remaining byte(s) at offset ${this.#offset}`);
269
+ }
270
+ const length = Number(encoded);
271
+ const start = this.#offset;
272
+ this.#offset += length;
273
+ return this.#bytes.subarray(start, this.#offset);
274
+ }
275
+ #advance(length, what) {
276
+ this.#require(length, what);
277
+ this.#offset += length;
278
+ }
279
+ #require(length, what) {
280
+ const remaining = this.#bytes.byteLength - this.#offset;
281
+ if (length > remaining) {
282
+ throw new RangeError(`truncated protobuf ${what} at offset ${this.#offset}: needs ${length} byte(s), ${remaining} remaining`);
283
+ }
284
+ }
285
+ }
286
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,kFAAkF;AAClF,uFAAuF;AACvF,oDAAoD;AAEpD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;AAC/B,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,IAAI,UAAU,EAAE,CAAC;AACrC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC,iFAAiF;AACjF,MAAM,OAAO,WAAW;IACtB,OAAO,GAAG,IAAI,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC3C,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC,CAAC;IAEZ,yFAAyF;IACzF,GAAG,CAAC,WAAmB,EAAE,QAAuB;QAC9C,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,KAAa;QACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,MAAM,MAAM,GAAG,MAAM,CAAC,MAA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AY,CACxG,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@zmdb/protobuf",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Zero-dependency protobuf calls, typed gRPC service artifacts, and the wire runtime targeted by zmdb's ahead-of-time compiler.",
5
+ "keywords": [
6
+ "aot",
7
+ "grpc",
8
+ "protobuf",
9
+ "serialization",
10
+ "typescript",
11
+ "zmdb"
12
+ ],
13
+ "homepage": "https://github.com/ambasta/zmdb#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/ambasta/zmdb/issues"
16
+ },
17
+ "license": "GPL-3.0-or-later",
18
+ "author": "zmdb contributors",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/ambasta/zmdb.git",
22
+ "directory": "packages/protobuf"
23
+ },
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./wire": {
32
+ "types": "./dist/wire.d.ts",
33
+ "import": "./dist/wire.js"
34
+ }
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "tag": "beta"
39
+ },
40
+ "scripts": {
41
+ "build": "node ../../scripts/build-package.mjs",
42
+ "test": "vitest run"
43
+ },
44
+ "engines": {
45
+ "node": ">=26"
46
+ },
47
+ "main": "./dist/index.js",
48
+ "types": "./dist/index.d.ts"
49
+ }