typia 12.0.0-dev.20260307-2 → 12.0.0-dev.20260310
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/lib/executable/setup/PluginConfigurator.js +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
- package/lib/executable/typia.js +15 -15
- package/lib/executable/typia.mjs +15 -15
- package/lib/internal/_coerceLlmArguments.d.ts +2 -0
- package/lib/internal/_coerceLlmArguments.js +7 -0
- package/lib/internal/_coerceLlmArguments.js.map +1 -0
- package/lib/internal/_coerceLlmArguments.mjs +6 -0
- package/lib/internal/_coerceLlmArguments.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -0
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_parseLlmArguments.d.ts +2 -0
- package/lib/internal/_parseLlmArguments.js +7 -0
- package/lib/internal/_parseLlmArguments.js.map +1 -0
- package/lib/internal/_parseLlmArguments.mjs +6 -0
- package/lib/internal/_parseLlmArguments.mjs.map +1 -0
- package/lib/llm.d.ts +154 -1
- package/lib/llm.js +20 -0
- package/lib/llm.js.map +1 -1
- package/lib/llm.mjs +17 -1
- package/lib/llm.mjs.map +1 -1
- package/lib/re-exports.d.ts +1 -1
- package/lib/re-exports.js.map +1 -1
- package/package.json +5 -5
- package/src/TypeGuardError.ts +145 -145
- package/src/executable/TypiaGenerateWizard.ts +82 -82
- package/src/executable/TypiaPatchWizard.ts +45 -45
- package/src/executable/TypiaSetupWizard.ts +171 -171
- package/src/executable/setup/ArgumentParser.ts +42 -42
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +19 -19
- package/src/executable/setup/PackageManager.ts +87 -87
- package/src/executable/setup/PluginConfigurator.ts +74 -74
- package/src/executable/typia.ts +55 -55
- package/src/functional.ts +600 -600
- package/src/http.ts +843 -843
- package/src/index.ts +4 -4
- package/src/internal/_IProtobufWriter.ts +18 -18
- package/src/internal/_ProtobufReader.ts +187 -187
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_accessExpressionAsString.ts +46 -46
- package/src/internal/_assertGuard.ts +13 -13
- package/src/internal/_coerceLlmArguments.ts +7 -0
- package/src/internal/_createStandardSchema.ts +133 -133
- package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
- package/src/internal/_httpFormDataReadArray.ts +4 -4
- package/src/internal/_httpFormDataReadBigint.ts +18 -18
- package/src/internal/_httpFormDataReadBlob.ts +10 -10
- package/src/internal/_httpFormDataReadBoolean.ts +16 -16
- package/src/internal/_httpFormDataReadFile.ts +10 -10
- package/src/internal/_httpFormDataReadNumber.ts +15 -15
- package/src/internal/_httpFormDataReadString.ts +10 -10
- package/src/internal/_httpHeaderReadBigint.ts +10 -10
- package/src/internal/_httpHeaderReadBoolean.ts +8 -8
- package/src/internal/_httpHeaderReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadBigint.ts +10 -10
- package/src/internal/_httpParameterReadBoolean.ts +8 -8
- package/src/internal/_httpParameterReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadString.ts +2 -2
- package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
- package/src/internal/_httpQueryReadArray.ts +4 -4
- package/src/internal/_httpQueryReadBigint.ts +12 -12
- package/src/internal/_httpQueryReadBoolean.ts +14 -14
- package/src/internal/_httpQueryReadNumber.ts +9 -9
- package/src/internal/_httpQueryReadString.ts +4 -4
- package/src/internal/_isBetween.ts +2 -2
- package/src/internal/_isBigintString.ts +8 -8
- package/src/internal/_isFormatByte.ts +7 -7
- package/src/internal/_isFormatDate.ts +3 -3
- package/src/internal/_isFormatDateTime.ts +4 -4
- package/src/internal/_isFormatDuration.ts +4 -4
- package/src/internal/_isFormatEmail.ts +4 -4
- package/src/internal/_isFormatHostname.ts +4 -4
- package/src/internal/_isFormatIdnEmail.ts +4 -4
- package/src/internal/_isFormatIdnHostname.ts +4 -4
- package/src/internal/_isFormatIpv4.ts +4 -4
- package/src/internal/_isFormatIpv6.ts +4 -4
- package/src/internal/_isFormatIri.ts +3 -3
- package/src/internal/_isFormatIriReference.ts +4 -4
- package/src/internal/_isFormatJsonPointer.ts +3 -3
- package/src/internal/_isFormatPassword.ts +1 -1
- package/src/internal/_isFormatRegex.ts +8 -8
- package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
- package/src/internal/_isFormatTime.ts +4 -4
- package/src/internal/_isFormatUri.ts +6 -6
- package/src/internal/_isFormatUriReference.ts +5 -5
- package/src/internal/_isFormatUriTemplate.ts +4 -4
- package/src/internal/_isFormatUrl.ts +4 -4
- package/src/internal/_isFormatUuid.ts +3 -3
- package/src/internal/_isTypeFloat.ts +5 -5
- package/src/internal/_isTypeInt32.ts +5 -5
- package/src/internal/_isTypeInt64.ts +5 -5
- package/src/internal/_isTypeUint32.ts +5 -5
- package/src/internal/_isTypeUint64.ts +5 -5
- package/src/internal/_isUniqueItems.ts +159 -159
- package/src/internal/_jsonStringifyNumber.ts +12 -12
- package/src/internal/_jsonStringifyRest.ts +3 -3
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/internal/_jsonStringifyTail.ts +2 -2
- package/src/internal/_llmApplicationFinalize.ts +24 -23
- package/src/internal/_miscCloneAny.ts +46 -46
- package/src/internal/_notationAny.ts +37 -37
- package/src/internal/_notationCamel.ts +13 -13
- package/src/internal/_notationPascal.ts +8 -8
- package/src/internal/_notationSnake.ts +43 -43
- package/src/internal/_parseLlmArguments.ts +7 -0
- package/src/internal/_randomArray.ts +21 -21
- package/src/internal/_randomBigint.ts +6 -6
- package/src/internal/_randomBoolean.ts +1 -1
- package/src/internal/_randomFormatByte.ts +3 -3
- package/src/internal/_randomFormatDate.ts +18 -18
- package/src/internal/_randomFormatDatetime.ts +16 -16
- package/src/internal/_randomFormatDuration.ts +27 -27
- package/src/internal/_randomFormatEmail.ts +11 -11
- package/src/internal/_randomFormatHostname.ts +6 -6
- package/src/internal/_randomFormatIdnEmail.ts +3 -3
- package/src/internal/_randomFormatIdnHostname.ts +3 -3
- package/src/internal/_randomFormatIpv4.ts +11 -11
- package/src/internal/_randomFormatIpv6.ts +11 -11
- package/src/internal/_randomFormatIri.ts +3 -3
- package/src/internal/_randomFormatIriReference.ts +3 -3
- package/src/internal/_randomFormatJsonPointer.ts +7 -7
- package/src/internal/_randomFormatPassword.ts +8 -8
- package/src/internal/_randomFormatRegex.ts +4 -4
- package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
- package/src/internal/_randomFormatTime.ts +14 -14
- package/src/internal/_randomFormatUri.ts +3 -3
- package/src/internal/_randomFormatUriReference.ts +3 -3
- package/src/internal/_randomFormatUriTemplate.ts +3 -3
- package/src/internal/_randomFormatUrl.ts +11 -11
- package/src/internal/_randomFormatUuid.ts +6 -6
- package/src/internal/_randomInteger.ts +53 -53
- package/src/internal/_randomNumber.ts +80 -80
- package/src/internal/_randomPattern.ts +10 -10
- package/src/internal/_randomPick.ts +9 -9
- package/src/internal/_randomString.ts +24 -24
- package/src/internal/_throwTypeGuardError.ts +5 -5
- package/src/internal/_validateReport.ts +21 -21
- package/src/internal/private/__notationCapitalize.ts +2 -2
- package/src/internal/private/__notationUnsnake.ts +24 -24
- package/src/json.ts +553 -553
- package/src/llm.ts +408 -211
- package/src/misc.ts +448 -448
- package/src/module.ts +811 -811
- package/src/notations.ts +624 -624
- package/src/programmers/TypiaProgrammer.ts +8 -8
- package/src/protobuf.ts +499 -499
- package/src/re-exports.ts +33 -32
- package/src/reflect.ts +75 -75
- package/src/transform.ts +5 -5
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as typia from "./module";
|
|
2
|
-
|
|
3
|
-
export default typia;
|
|
4
|
-
export * from "./module";
|
|
1
|
+
import * as typia from "./module";
|
|
2
|
+
|
|
3
|
+
export default typia;
|
|
4
|
+
export * from "./module";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export interface _IProtobufWriter {
|
|
2
|
-
bool(value: boolean): void;
|
|
3
|
-
int32(value: number): void;
|
|
4
|
-
sint32(value: number): void;
|
|
5
|
-
uint32(value: number): void;
|
|
6
|
-
|
|
7
|
-
int64(value: bigint | number): void;
|
|
8
|
-
sint64(value: bigint | number): void;
|
|
9
|
-
uint64(value: bigint | number): void;
|
|
10
|
-
|
|
11
|
-
float(value: number): void;
|
|
12
|
-
double(value: number): void;
|
|
13
|
-
bytes(value: Uint8Array): void;
|
|
14
|
-
string(value: string): void;
|
|
15
|
-
|
|
16
|
-
fork(): void;
|
|
17
|
-
ldelim(): void;
|
|
18
|
-
}
|
|
1
|
+
export interface _IProtobufWriter {
|
|
2
|
+
bool(value: boolean): void;
|
|
3
|
+
int32(value: number): void;
|
|
4
|
+
sint32(value: number): void;
|
|
5
|
+
uint32(value: number): void;
|
|
6
|
+
|
|
7
|
+
int64(value: bigint | number): void;
|
|
8
|
+
sint64(value: bigint | number): void;
|
|
9
|
+
uint64(value: bigint | number): void;
|
|
10
|
+
|
|
11
|
+
float(value: number): void;
|
|
12
|
+
double(value: number): void;
|
|
13
|
+
bytes(value: Uint8Array): void;
|
|
14
|
+
string(value: string): void;
|
|
15
|
+
|
|
16
|
+
fork(): void;
|
|
17
|
+
ldelim(): void;
|
|
18
|
+
}
|
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
import { ProtobufWire } from "@typia/interface";
|
|
2
|
-
import { Singleton } from "@typia/utils";
|
|
3
|
-
|
|
4
|
-
/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts
|
|
5
|
-
export class _ProtobufReader {
|
|
6
|
-
/** Read buffer */
|
|
7
|
-
private buf: Uint8Array;
|
|
8
|
-
|
|
9
|
-
/** Read buffer pointer. */
|
|
10
|
-
private ptr: number;
|
|
11
|
-
|
|
12
|
-
/** DataView for buffer. */
|
|
13
|
-
private view: DataView;
|
|
14
|
-
|
|
15
|
-
public constructor(buf: Uint8Array) {
|
|
16
|
-
this.buf = buf;
|
|
17
|
-
this.ptr = 0;
|
|
18
|
-
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public index(): number {
|
|
22
|
-
return this.ptr;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public size(): number {
|
|
26
|
-
return this.buf.length;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public uint32(): number {
|
|
30
|
-
return this.varint32();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public int32(): number {
|
|
34
|
-
return this.varint32();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public sint32(): number {
|
|
38
|
-
const value: number = this.varint32();
|
|
39
|
-
return (value >>> 1) ^ -(value & 1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public uint64(): bigint {
|
|
43
|
-
return this.varint64();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public int64(): bigint {
|
|
47
|
-
return this.varint64();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public sint64(): bigint {
|
|
51
|
-
const value = this.varint64();
|
|
52
|
-
return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public bool(): boolean {
|
|
56
|
-
return this.varint32() !== 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public float(): number {
|
|
60
|
-
const value: number = this.view.getFloat32(this.ptr, true);
|
|
61
|
-
this.ptr += 4;
|
|
62
|
-
return value;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public double(): number {
|
|
66
|
-
const value: number = this.view.getFloat64(this.ptr, true);
|
|
67
|
-
this.ptr += 8;
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public bytes(): Uint8Array {
|
|
72
|
-
const length: number = this.uint32();
|
|
73
|
-
const from: number = this.ptr;
|
|
74
|
-
this.ptr += length;
|
|
75
|
-
return this.buf.subarray(from, from + length);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public string(): string {
|
|
79
|
-
return utf8.get().decode(this.bytes());
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public skip(length: number): void {
|
|
83
|
-
if (length === 0) while (this.u8() & 0x80);
|
|
84
|
-
else {
|
|
85
|
-
if (this.index() + length > this.size())
|
|
86
|
-
throw new Error("Error on typia.protobuf.decode(): buffer overflow.");
|
|
87
|
-
this.ptr += length;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public skipType(wireType: ProtobufWire): void {
|
|
92
|
-
switch (wireType) {
|
|
93
|
-
case ProtobufWire.VARIANT:
|
|
94
|
-
this.skip(0);
|
|
95
|
-
break;
|
|
96
|
-
case ProtobufWire.I64:
|
|
97
|
-
this.skip(8);
|
|
98
|
-
break;
|
|
99
|
-
case ProtobufWire.LEN:
|
|
100
|
-
this.skip(this.uint32());
|
|
101
|
-
break;
|
|
102
|
-
case ProtobufWire.START_GROUP:
|
|
103
|
-
while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)
|
|
104
|
-
this.skipType(wireType);
|
|
105
|
-
break;
|
|
106
|
-
case ProtobufWire.I32:
|
|
107
|
-
this.skip(4);
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
throw new Error(`Invalid wire type ${wireType} at offset ${this.ptr}.`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private varint32(): number {
|
|
115
|
-
let loaded: number;
|
|
116
|
-
let value: number;
|
|
117
|
-
|
|
118
|
-
value = (loaded = this.u8()) & 0x7f;
|
|
119
|
-
if (loaded < 0x80) return value;
|
|
120
|
-
|
|
121
|
-
value |= ((loaded = this.u8()) & 0x7f) << 7;
|
|
122
|
-
if (loaded < 0x80) return value;
|
|
123
|
-
|
|
124
|
-
value |= ((loaded = this.u8()) & 0x7f) << 14;
|
|
125
|
-
if (loaded < 0x80) return value;
|
|
126
|
-
|
|
127
|
-
value |= ((loaded = this.u8()) & 0x7f) << 21;
|
|
128
|
-
if (loaded < 0x80) return value;
|
|
129
|
-
|
|
130
|
-
value |= ((loaded = this.u8()) & 0xf) << 28;
|
|
131
|
-
if (loaded < 0x80) return value;
|
|
132
|
-
|
|
133
|
-
// increment position until there is no continuation bit or until we read 10 bytes
|
|
134
|
-
if (this.u8() < 0x80) return value;
|
|
135
|
-
if (this.u8() < 0x80) return value;
|
|
136
|
-
if (this.u8() < 0x80) return value;
|
|
137
|
-
if (this.u8() < 0x80) return value;
|
|
138
|
-
if (this.u8() < 0x80) return value;
|
|
139
|
-
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private varint64(): bigint {
|
|
144
|
-
let loaded: bigint;
|
|
145
|
-
let value: bigint;
|
|
146
|
-
|
|
147
|
-
value = (loaded = this.u8n()) & BigInt(0x7f);
|
|
148
|
-
if (loaded < BigInt(0x80)) return value;
|
|
149
|
-
|
|
150
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);
|
|
151
|
-
if (loaded < BigInt(0x80)) return value;
|
|
152
|
-
|
|
153
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);
|
|
154
|
-
if (loaded < BigInt(0x80)) return value;
|
|
155
|
-
|
|
156
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);
|
|
157
|
-
if (loaded < BigInt(0x80)) return value;
|
|
158
|
-
|
|
159
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);
|
|
160
|
-
if (loaded < BigInt(0x80)) return value;
|
|
161
|
-
|
|
162
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);
|
|
163
|
-
if (loaded < BigInt(0x80)) return value;
|
|
164
|
-
|
|
165
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);
|
|
166
|
-
if (loaded < BigInt(0x80)) return value;
|
|
167
|
-
|
|
168
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);
|
|
169
|
-
if (loaded < BigInt(0x80)) return value;
|
|
170
|
-
|
|
171
|
-
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);
|
|
172
|
-
if (loaded < BigInt(0x80)) return value;
|
|
173
|
-
|
|
174
|
-
value |= (this.u8n() & BigInt(0x01)) << BigInt(63);
|
|
175
|
-
return BigInt.asIntN(64, value);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private u8(): number {
|
|
179
|
-
return this.view.getUint8(this.ptr++);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private u8n(): bigint {
|
|
183
|
-
return BigInt(this.u8());
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const utf8 = new Singleton(() => new TextDecoder("utf-8"));
|
|
1
|
+
import { ProtobufWire } from "@typia/interface";
|
|
2
|
+
import { Singleton } from "@typia/utils";
|
|
3
|
+
|
|
4
|
+
/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts
|
|
5
|
+
export class _ProtobufReader {
|
|
6
|
+
/** Read buffer */
|
|
7
|
+
private buf: Uint8Array;
|
|
8
|
+
|
|
9
|
+
/** Read buffer pointer. */
|
|
10
|
+
private ptr: number;
|
|
11
|
+
|
|
12
|
+
/** DataView for buffer. */
|
|
13
|
+
private view: DataView;
|
|
14
|
+
|
|
15
|
+
public constructor(buf: Uint8Array) {
|
|
16
|
+
this.buf = buf;
|
|
17
|
+
this.ptr = 0;
|
|
18
|
+
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public index(): number {
|
|
22
|
+
return this.ptr;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public size(): number {
|
|
26
|
+
return this.buf.length;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public uint32(): number {
|
|
30
|
+
return this.varint32();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public int32(): number {
|
|
34
|
+
return this.varint32();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public sint32(): number {
|
|
38
|
+
const value: number = this.varint32();
|
|
39
|
+
return (value >>> 1) ^ -(value & 1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public uint64(): bigint {
|
|
43
|
+
return this.varint64();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public int64(): bigint {
|
|
47
|
+
return this.varint64();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public sint64(): bigint {
|
|
51
|
+
const value = this.varint64();
|
|
52
|
+
return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public bool(): boolean {
|
|
56
|
+
return this.varint32() !== 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public float(): number {
|
|
60
|
+
const value: number = this.view.getFloat32(this.ptr, true);
|
|
61
|
+
this.ptr += 4;
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public double(): number {
|
|
66
|
+
const value: number = this.view.getFloat64(this.ptr, true);
|
|
67
|
+
this.ptr += 8;
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public bytes(): Uint8Array {
|
|
72
|
+
const length: number = this.uint32();
|
|
73
|
+
const from: number = this.ptr;
|
|
74
|
+
this.ptr += length;
|
|
75
|
+
return this.buf.subarray(from, from + length);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public string(): string {
|
|
79
|
+
return utf8.get().decode(this.bytes());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public skip(length: number): void {
|
|
83
|
+
if (length === 0) while (this.u8() & 0x80);
|
|
84
|
+
else {
|
|
85
|
+
if (this.index() + length > this.size())
|
|
86
|
+
throw new Error("Error on typia.protobuf.decode(): buffer overflow.");
|
|
87
|
+
this.ptr += length;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public skipType(wireType: ProtobufWire): void {
|
|
92
|
+
switch (wireType) {
|
|
93
|
+
case ProtobufWire.VARIANT:
|
|
94
|
+
this.skip(0);
|
|
95
|
+
break;
|
|
96
|
+
case ProtobufWire.I64:
|
|
97
|
+
this.skip(8);
|
|
98
|
+
break;
|
|
99
|
+
case ProtobufWire.LEN:
|
|
100
|
+
this.skip(this.uint32());
|
|
101
|
+
break;
|
|
102
|
+
case ProtobufWire.START_GROUP:
|
|
103
|
+
while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)
|
|
104
|
+
this.skipType(wireType);
|
|
105
|
+
break;
|
|
106
|
+
case ProtobufWire.I32:
|
|
107
|
+
this.skip(4);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Invalid wire type ${wireType} at offset ${this.ptr}.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private varint32(): number {
|
|
115
|
+
let loaded: number;
|
|
116
|
+
let value: number;
|
|
117
|
+
|
|
118
|
+
value = (loaded = this.u8()) & 0x7f;
|
|
119
|
+
if (loaded < 0x80) return value;
|
|
120
|
+
|
|
121
|
+
value |= ((loaded = this.u8()) & 0x7f) << 7;
|
|
122
|
+
if (loaded < 0x80) return value;
|
|
123
|
+
|
|
124
|
+
value |= ((loaded = this.u8()) & 0x7f) << 14;
|
|
125
|
+
if (loaded < 0x80) return value;
|
|
126
|
+
|
|
127
|
+
value |= ((loaded = this.u8()) & 0x7f) << 21;
|
|
128
|
+
if (loaded < 0x80) return value;
|
|
129
|
+
|
|
130
|
+
value |= ((loaded = this.u8()) & 0xf) << 28;
|
|
131
|
+
if (loaded < 0x80) return value;
|
|
132
|
+
|
|
133
|
+
// increment position until there is no continuation bit or until we read 10 bytes
|
|
134
|
+
if (this.u8() < 0x80) return value;
|
|
135
|
+
if (this.u8() < 0x80) return value;
|
|
136
|
+
if (this.u8() < 0x80) return value;
|
|
137
|
+
if (this.u8() < 0x80) return value;
|
|
138
|
+
if (this.u8() < 0x80) return value;
|
|
139
|
+
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private varint64(): bigint {
|
|
144
|
+
let loaded: bigint;
|
|
145
|
+
let value: bigint;
|
|
146
|
+
|
|
147
|
+
value = (loaded = this.u8n()) & BigInt(0x7f);
|
|
148
|
+
if (loaded < BigInt(0x80)) return value;
|
|
149
|
+
|
|
150
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);
|
|
151
|
+
if (loaded < BigInt(0x80)) return value;
|
|
152
|
+
|
|
153
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);
|
|
154
|
+
if (loaded < BigInt(0x80)) return value;
|
|
155
|
+
|
|
156
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);
|
|
157
|
+
if (loaded < BigInt(0x80)) return value;
|
|
158
|
+
|
|
159
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);
|
|
160
|
+
if (loaded < BigInt(0x80)) return value;
|
|
161
|
+
|
|
162
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);
|
|
163
|
+
if (loaded < BigInt(0x80)) return value;
|
|
164
|
+
|
|
165
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);
|
|
166
|
+
if (loaded < BigInt(0x80)) return value;
|
|
167
|
+
|
|
168
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);
|
|
169
|
+
if (loaded < BigInt(0x80)) return value;
|
|
170
|
+
|
|
171
|
+
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);
|
|
172
|
+
if (loaded < BigInt(0x80)) return value;
|
|
173
|
+
|
|
174
|
+
value |= (this.u8n() & BigInt(0x01)) << BigInt(63);
|
|
175
|
+
return BigInt.asIntN(64, value);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private u8(): number {
|
|
179
|
+
return this.view.getUint8(this.ptr++);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private u8n(): bigint {
|
|
183
|
+
return BigInt(this.u8());
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const utf8 = new Singleton(() => new TextDecoder("utf-8"));
|