typia 13.1.19 → 13.3.0
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/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/http.d.ts +3 -3
- package/lib/http.js.map +1 -1
- package/lib/http.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_assertGuard.js +13 -3
- package/lib/internal/_assertGuard.js.map +1 -1
- package/lib/internal/_assertGuard.mjs +4 -2
- package/lib/internal/_assertGuard.mjs.map +1 -1
- package/lib/internal/_isFormatIdnHostname.js +5 -1
- package/lib/internal/_isFormatIdnHostname.js.map +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_isFormatTime.js +19 -2
- package/lib/internal/_isFormatTime.js.map +1 -1
- package/lib/internal/_isFormatTime.mjs +9 -2
- package/lib/internal/_isFormatTime.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.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 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomArray.js +37 -4
- package/lib/internal/_randomArray.js.map +1 -1
- package/lib/internal/_randomArray.mjs +16 -3
- package/lib/internal/_randomArray.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +28 -2
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +22 -3
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatHostname.d.ts +2 -2
- package/lib/internal/_randomFormatHostname.js +2 -2
- package/lib/internal/_randomFormatHostname.mjs +2 -2
- package/lib/internal/_randomFormatHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.js +9 -10
- package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.mjs +3 -4
- package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +15 -2
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -3
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +38 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +40 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +31 -0
- package/lib/internal/private/__randomComposition.js +68 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +71 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/lib/json.d.ts +2 -2
- package/lib/json.js.map +1 -1
- package/lib/json.mjs.map +1 -1
- package/lib/module.d.ts +28 -13
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/notations.d.ts +4 -4
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs.map +1 -1
- package/lib/plain.d.ts +3 -3
- package/lib/plain.js.map +1 -1
- package/lib/plain.mjs.map +1 -1
- package/lib/protobuf.d.ts +2 -2
- package/lib/protobuf.js.map +1 -1
- package/lib/protobuf.mjs.map +1 -1
- package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +17 -4
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +309 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/local_function_named_like_typia_operation_transform_test.go +185 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/recursive_conditional_alias_name_transform_test.go +307 -0
- package/native/cmd/ttsc-typia/shadowed_typia_module_declaration_diagnostic_test.go +152 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +1 -3
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +166 -25
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/FormatCheatSheet.go +2 -2
- package/native/core/factories/MetadataCommentTagFactory.go +26 -11
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/factory_utility_coverage_test.go +896 -907
- package/native/core/factories/internal/metadata/MetadataHelper.go +190 -58
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/factories/metadata_comment_tag_factory_coverage_test.go +2 -2
- package/native/core/programmers/RandomProgrammer.go +5 -2
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +47 -14
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/CallExpressionTransformer.go +167 -0
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/http.ts +18 -4
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_assertGuard.ts +13 -2
- package/src/internal/_isFormatIdnHostname.ts +5 -1
- package/src/internal/_isFormatTime.ts +19 -2
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomArray.ts +42 -6
- package/src/internal/_randomFormatByte.ts +36 -4
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatHostname.ts +2 -2
- package/src/internal/_randomFormatIdnHostname.ts +8 -9
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +22 -6
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +50 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +74 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/src/json.ts +16 -4
- package/src/module.ts +56 -22
- package/src/notations.ts +16 -4
- package/src/plain.ts +12 -3
- package/src/protobuf.ts +16 -4
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -80,14 +80,18 @@ var _ProtobufReader = class {
|
|
|
80
80
|
* Advance by exactly one varint, which carries no length prefix.
|
|
81
81
|
*
|
|
82
82
|
* A varint terminates at its first byte without the continuation bit, and may
|
|
83
|
-
* occupy no more than {@link VARINT_MAX_BYTES}.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
83
|
+
* occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded
|
|
84
|
+
* twice over, by {@link lastVarintByte}: it may neither continue into an
|
|
85
|
+
* eleventh byte nor carry payload above bit 63. Skipping is where that is
|
|
86
|
+
* easiest to get wrong, because this path discards the bytes it reads and so
|
|
87
|
+
* never notices a value it could not have represented. Relaxing either bound
|
|
88
|
+
* here would accept a varint that `varint32` and `varint64` reject, making
|
|
89
|
+
* the limit depend on which method happens to consume the value.
|
|
86
90
|
*/
|
|
87
91
|
skipVarint() {
|
|
88
92
|
this.atomic(() => {
|
|
89
|
-
for (let i =
|
|
90
|
-
|
|
93
|
+
for (let i = 1; i < VARINT_MAX_BYTES; ++i) if ((this.u8() & 128) === 0) return;
|
|
94
|
+
this.lastVarintByte();
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
skipType(wireType) {
|
|
@@ -129,7 +133,7 @@ var _ProtobufReader = class {
|
|
|
129
133
|
if (this.u8() < 128) return value;
|
|
130
134
|
if (this.u8() < 128) return value;
|
|
131
135
|
if (this.u8() < 128) return value;
|
|
132
|
-
|
|
136
|
+
this.lastVarintByte();
|
|
133
137
|
return value;
|
|
134
138
|
}
|
|
135
139
|
varint64() {
|
|
@@ -153,9 +157,25 @@ var _ProtobufReader = class {
|
|
|
153
157
|
if (loaded < BigInt(128)) return value;
|
|
154
158
|
value |= ((loaded = this.u8n()) & BigInt(127)) << BigInt(56);
|
|
155
159
|
if (loaded < BigInt(128)) return value;
|
|
156
|
-
value |= (this.
|
|
160
|
+
value |= BigInt(this.lastVarintByte()) << BigInt(63);
|
|
157
161
|
return BigInt.asUintN(64, value);
|
|
158
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Read the only byte whose varint payload is limited to bit 63.
|
|
165
|
+
*
|
|
166
|
+
* Two distinct faults meet on this byte, and each is named for what it is. A
|
|
167
|
+
* continuation bit means the varint would occupy an eleventh byte, which no
|
|
168
|
+
* 64-bit value can reach. Any other payload bit means the varint terminates
|
|
169
|
+
* within its ten bytes but carries a value bit above 63. Reporting the second
|
|
170
|
+
* as a length fault would tell the caller something untrue about a payload
|
|
171
|
+
* that is exactly ten bytes long.
|
|
172
|
+
*/
|
|
173
|
+
lastVarintByte() {
|
|
174
|
+
const loaded = this.u8();
|
|
175
|
+
if ((loaded & 128) !== 0) throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);
|
|
176
|
+
if (loaded > 1) throw error(`varint exceeds ${VARINT_MAX_BITS} bits.`);
|
|
177
|
+
return loaded;
|
|
178
|
+
}
|
|
159
179
|
u8() {
|
|
160
180
|
return this.view.getUint8(this.take(1));
|
|
161
181
|
}
|
|
@@ -194,11 +214,18 @@ const error = (message) => /* @__PURE__ */ new Error(`Error on typia.protobuf.de
|
|
|
194
214
|
/**
|
|
195
215
|
* The most bytes a varint may occupy: a 64-bit value in seven-bit groups.
|
|
196
216
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* holds it by.
|
|
217
|
+
* Every path reads no further than its tenth byte and accepts only bit 63 from
|
|
218
|
+
* that byte. This constant keeps the loop-driven skip path on the same limit.
|
|
200
219
|
*/
|
|
201
220
|
const VARINT_MAX_BYTES = 10;
|
|
221
|
+
/**
|
|
222
|
+
* The widest value a varint may carry: the 64-bit Protocol Buffer wire domain.
|
|
223
|
+
*
|
|
224
|
+
* The tenth byte reaches only bit 63, so a payload bit above it belongs to no
|
|
225
|
+
* representable value. This names the overflow fault apart from the length
|
|
226
|
+
* one.
|
|
227
|
+
*/
|
|
228
|
+
const VARINT_MAX_BITS = 64;
|
|
202
229
|
const utf8 = new Singleton(() => new TextDecoder("utf-8", {
|
|
203
230
|
fatal: true,
|
|
204
231
|
ignoreBOM: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_ProtobufReader.mjs","names":[],"sources":["../../src/internal/_ProtobufReader.ts"],"sourcesContent":["import { ProtobufWire } from \"@typia/interface\";\nimport { Singleton } from \"@typia/utils\";\n\n/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts\nexport class _ProtobufReader {\n /** Read buffer */\n private buf: Uint8Array;\n\n /** Read buffer pointer. */\n private ptr: number;\n\n /** DataView for buffer. */\n private view: DataView;\n\n /** Current length-delimited boundary. */\n private end: number;\n\n public constructor(buf: Uint8Array) {\n this.buf = buf;\n this.ptr = 0;\n this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n this.end = buf.length;\n }\n\n public index(): number {\n return this.ptr;\n }\n\n public size(): number {\n return this.end;\n }\n\n public uint32(): number {\n return this.varint32() >>> 0;\n }\n\n public int32(): number {\n return this.varint32();\n }\n\n public sint32(): number {\n const value: number = this.varint32();\n return (value >>> 1) ^ -(value & 1);\n }\n\n public uint64(): bigint {\n return this.varint64();\n }\n\n public int64(): bigint {\n return BigInt.asIntN(64, this.varint64());\n }\n\n public sint64(): bigint {\n const value = this.varint64();\n return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));\n }\n\n public bool(): boolean {\n return this.varint32() !== 0;\n }\n\n public float(): number {\n return this.view.getFloat32(this.take(4), true);\n }\n\n public double(): number {\n return this.view.getFloat64(this.take(8), true);\n }\n\n public bytes(): Uint8Array {\n return this.atomic(() => {\n const length: number = this.uint32();\n const from: number = this.take(length);\n return this.buf.subarray(from, from + length);\n });\n }\n\n public string(): string {\n const bytes: Uint8Array = this.bytes();\n const decoder: TextDecoder = utf8.get();\n try {\n return decoder.decode(bytes);\n } catch {\n throw error(\"invalid UTF-8 string.\");\n }\n }\n\n public fork(): number {\n return this.atomic(() => {\n const previous: number = this.end;\n const length: number = this.uint32();\n this.validate(length);\n this.end = this.ptr + length;\n return previous;\n });\n }\n\n public close(previous: number): void {\n if (this.ptr !== this.end) throw error(\"buffer overflow.\");\n this.end = previous;\n }\n\n /** Advance by exactly `length` bytes, for every length including zero. */\n public skip(length: number): void {\n this.take(length);\n }\n\n /**\n * Advance by exactly one varint, which carries no length prefix.\n *\n * A varint terminates at its first byte without the continuation bit, and may\n * occupy no more than {@link VARINT_MAX_BYTES}. Reading past that limit would\n * accept a varint that `varint32` and `varint64` could not, making the limit\n * depend on which method happens to consume the value.\n */\n public skipVarint(): void {\n this.atomic(() => {\n for (let i: number = 0; i < VARINT_MAX_BYTES; ++i)\n if ((this.u8() & 0x80) === 0) return;\n throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);\n });\n }\n\n public skipType(wireType: ProtobufWire): void {\n this.atomic(() => {\n switch (wireType) {\n case ProtobufWire.VARIANT:\n this.skipVarint();\n break;\n case ProtobufWire.I64:\n this.skip(8);\n break;\n case ProtobufWire.LEN:\n this.skip(this.uint32());\n break;\n case ProtobufWire.START_GROUP:\n while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)\n this.skipType(wireType);\n break;\n case ProtobufWire.I32:\n this.skip(4);\n break;\n default:\n throw error(`invalid wire type ${wireType} at offset ${this.ptr}.`);\n }\n });\n }\n\n private varint32(): number {\n let loaded: number;\n let value: number;\n\n value = (loaded = this.u8()) & 0x7f;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 7;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 14;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 21;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0xf) << 28;\n if (loaded < 0x80) return value;\n\n // increment position until there is no continuation bit, or until this read\n // reaches VARINT_MAX_BYTES and the value can hold no further bits\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n\n return value;\n }\n\n private varint64(): bigint {\n let loaded: bigint;\n let value: bigint;\n\n value = (loaded = this.u8n()) & BigInt(0x7f);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);\n if (loaded < BigInt(0x80)) return value;\n\n value |= (this.u8n() & BigInt(0x01)) << BigInt(63);\n return BigInt.asUintN(64, value);\n }\n\n private u8(): number {\n return this.view.getUint8(this.take(1));\n }\n\n private u8n(): bigint {\n return BigInt(this.u8());\n }\n\n private take(length: number): number {\n this.validate(length);\n const from: number = this.ptr;\n this.ptr += length;\n return from;\n }\n\n private atomic<T>(closure: () => T): T {\n const index: number = this.ptr;\n const end: number = this.end;\n try {\n return closure();\n } catch (thrown) {\n this.ptr = index;\n this.end = end;\n throw thrown;\n }\n }\n\n private validate(length: number): void {\n if (\n Number.isSafeInteger(length) === false ||\n length < 0 ||\n length > this.size() - this.ptr\n )\n throw error(\"buffer overflow.\");\n }\n}\n\n/**\n * Builds every fault this reader raises, so each one names typia as its source.\n *\n * Every decode error a caller can see must be attributable, and the prefix is\n * what attributes it. Composing it here rather than at each throw keeps a new\n * fault from silently shipping without it.\n */\nconst error = (message: string): Error =>\n new Error(`Error on typia.protobuf.decode(): ${message}`);\n\n/**\n * The most bytes a varint may occupy: a 64-bit value in seven-bit groups.\n *\n * `varint32` and `varint64` hold this same limit structurally, by reading no\n * further than their tenth byte. This constant is what a loop-driven consumer\n * holds it by.\n */\nconst VARINT_MAX_BYTES = 10;\n\nconst utf8 = new Singleton(\n () => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }),\n);\n"],"mappings":";;;AAIA,IAAa,kBAAb,MAA6B;CAa3B,YAAmB,KAAiB;EAClC,KAAK,MAAM;EACX,KAAK,MAAM;EACX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AO,GAAI,GAAG,OAAO;EAElC,UAAU,KAAK,IAAI,IAAI,OAAO,CAAI,MAAM,OAAO,EAAE;EACjD,OAAO,OAAO,QAAQ,IAAI,KAAK;CACjC;CAEA,KAAqB;EACnB,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC;CACxC;CAEA,MAAsB;EACpB,OAAO,OAAO,KAAK,GAAG,CAAC;CACzB;CAEA,KAAa,QAAwB;EACnC,KAAK,SAAS,MAAM;EACpB,MAAM,OAAe,KAAK;EAC1B,KAAK,OAAO;EACZ,OAAO;CACT;CAEA,OAAkB,SAAqB;EACrC,MAAM,QAAgB,KAAK;EAC3B,MAAM,MAAc,KAAK;EACzB,IAAI;GACF,OAAO,QAAQ;EACjB,SAAS,QAAQ;GACf,KAAK,MAAM;GACX,KAAK,MAAM;GACX,MAAM;EACR;CACF;CAEA,SAAiB,QAAsB;EACrC,IACE,OAAO,cAAc,MAAM,MAAM,SACjC,SAAS,KACT,SAAS,KAAK,KAAK,IAAI,KAAK,KAE5B,MAAM,MAAM,kBAAkB;CAClC;AACF;;;;;;;;AASA,MAAM,SAAS,4BACb,IAAI,MAAM,qCAAqC,SAAS;;;;;;;;AAS1D,MAAM,mBAAmB;AAEzB,MAAM,OAAO,IAAI,gBACT,IAAI,YAAY,SAAS;CAAE,OAAO;CAAM,WAAW;AAAK,CAAC,CACjE"}
|
|
1
|
+
{"version":3,"file":"_ProtobufReader.mjs","names":[],"sources":["../../src/internal/_ProtobufReader.ts"],"sourcesContent":["import { ProtobufWire } from \"@typia/interface\";\nimport { Singleton } from \"@typia/utils\";\n\n/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts\nexport class _ProtobufReader {\n /** Read buffer */\n private buf: Uint8Array;\n\n /** Read buffer pointer. */\n private ptr: number;\n\n /** DataView for buffer. */\n private view: DataView;\n\n /** Current length-delimited boundary. */\n private end: number;\n\n public constructor(buf: Uint8Array) {\n this.buf = buf;\n this.ptr = 0;\n this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n this.end = buf.length;\n }\n\n public index(): number {\n return this.ptr;\n }\n\n public size(): number {\n return this.end;\n }\n\n public uint32(): number {\n return this.varint32() >>> 0;\n }\n\n public int32(): number {\n return this.varint32();\n }\n\n public sint32(): number {\n const value: number = this.varint32();\n return (value >>> 1) ^ -(value & 1);\n }\n\n public uint64(): bigint {\n return this.varint64();\n }\n\n public int64(): bigint {\n return BigInt.asIntN(64, this.varint64());\n }\n\n public sint64(): bigint {\n const value = this.varint64();\n return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));\n }\n\n public bool(): boolean {\n return this.varint32() !== 0;\n }\n\n public float(): number {\n return this.view.getFloat32(this.take(4), true);\n }\n\n public double(): number {\n return this.view.getFloat64(this.take(8), true);\n }\n\n public bytes(): Uint8Array {\n return this.atomic(() => {\n const length: number = this.uint32();\n const from: number = this.take(length);\n return this.buf.subarray(from, from + length);\n });\n }\n\n public string(): string {\n const bytes: Uint8Array = this.bytes();\n const decoder: TextDecoder = utf8.get();\n try {\n return decoder.decode(bytes);\n } catch {\n throw error(\"invalid UTF-8 string.\");\n }\n }\n\n public fork(): number {\n return this.atomic(() => {\n const previous: number = this.end;\n const length: number = this.uint32();\n this.validate(length);\n this.end = this.ptr + length;\n return previous;\n });\n }\n\n public close(previous: number): void {\n if (this.ptr !== this.end) throw error(\"buffer overflow.\");\n this.end = previous;\n }\n\n /** Advance by exactly `length` bytes, for every length including zero. */\n public skip(length: number): void {\n this.take(length);\n }\n\n /**\n * Advance by exactly one varint, which carries no length prefix.\n *\n * A varint terminates at its first byte without the continuation bit, and may\n * occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded\n * twice over, by {@link lastVarintByte}: it may neither continue into an\n * eleventh byte nor carry payload above bit 63. Skipping is where that is\n * easiest to get wrong, because this path discards the bytes it reads and so\n * never notices a value it could not have represented. Relaxing either bound\n * here would accept a varint that `varint32` and `varint64` reject, making\n * the limit depend on which method happens to consume the value.\n */\n public skipVarint(): void {\n this.atomic(() => {\n for (let i: number = 1; i < VARINT_MAX_BYTES; ++i)\n if ((this.u8() & 0x80) === 0) return;\n this.lastVarintByte();\n });\n }\n\n public skipType(wireType: ProtobufWire): void {\n this.atomic(() => {\n switch (wireType) {\n case ProtobufWire.VARIANT:\n this.skipVarint();\n break;\n case ProtobufWire.I64:\n this.skip(8);\n break;\n case ProtobufWire.LEN:\n this.skip(this.uint32());\n break;\n case ProtobufWire.START_GROUP:\n while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)\n this.skipType(wireType);\n break;\n case ProtobufWire.I32:\n this.skip(4);\n break;\n default:\n throw error(`invalid wire type ${wireType} at offset ${this.ptr}.`);\n }\n });\n }\n\n private varint32(): number {\n let loaded: number;\n let value: number;\n\n value = (loaded = this.u8()) & 0x7f;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 7;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 14;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 21;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0xf) << 28;\n if (loaded < 0x80) return value;\n\n // increment position until there is no continuation bit, or until this read\n // reaches VARINT_MAX_BYTES and the value can hold no further bits\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n this.lastVarintByte();\n return value;\n }\n\n private varint64(): bigint {\n let loaded: bigint;\n let value: bigint;\n\n value = (loaded = this.u8n()) & BigInt(0x7f);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);\n if (loaded < BigInt(0x80)) return value;\n\n value |= BigInt(this.lastVarintByte()) << BigInt(63);\n return BigInt.asUintN(64, value);\n }\n\n /**\n * Read the only byte whose varint payload is limited to bit 63.\n *\n * Two distinct faults meet on this byte, and each is named for what it is. A\n * continuation bit means the varint would occupy an eleventh byte, which no\n * 64-bit value can reach. Any other payload bit means the varint terminates\n * within its ten bytes but carries a value bit above 63. Reporting the second\n * as a length fault would tell the caller something untrue about a payload\n * that is exactly ten bytes long.\n */\n private lastVarintByte(): number {\n const loaded: number = this.u8();\n if ((loaded & 0x80) !== 0)\n throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);\n if (loaded > 0x01) throw error(`varint exceeds ${VARINT_MAX_BITS} bits.`);\n return loaded;\n }\n\n private u8(): number {\n return this.view.getUint8(this.take(1));\n }\n\n private u8n(): bigint {\n return BigInt(this.u8());\n }\n\n private take(length: number): number {\n this.validate(length);\n const from: number = this.ptr;\n this.ptr += length;\n return from;\n }\n\n private atomic<T>(closure: () => T): T {\n const index: number = this.ptr;\n const end: number = this.end;\n try {\n return closure();\n } catch (thrown) {\n this.ptr = index;\n this.end = end;\n throw thrown;\n }\n }\n\n private validate(length: number): void {\n if (\n Number.isSafeInteger(length) === false ||\n length < 0 ||\n length > this.size() - this.ptr\n )\n throw error(\"buffer overflow.\");\n }\n}\n\n/**\n * Builds every fault this reader raises, so each one names typia as its source.\n *\n * Every decode error a caller can see must be attributable, and the prefix is\n * what attributes it. Composing it here rather than at each throw keeps a new\n * fault from silently shipping without it.\n */\nconst error = (message: string): Error =>\n new Error(`Error on typia.protobuf.decode(): ${message}`);\n\n/**\n * The most bytes a varint may occupy: a 64-bit value in seven-bit groups.\n *\n * Every path reads no further than its tenth byte and accepts only bit 63 from\n * that byte. This constant keeps the loop-driven skip path on the same limit.\n */\nconst VARINT_MAX_BYTES = 10;\n\n/**\n * The widest value a varint may carry: the 64-bit Protocol Buffer wire domain.\n *\n * The tenth byte reaches only bit 63, so a payload bit above it belongs to no\n * representable value. This names the overflow fault apart from the length\n * one.\n */\nconst VARINT_MAX_BITS = 64;\n\nconst utf8 = new Singleton(\n () => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }),\n);\n"],"mappings":";;;AAIA,IAAa,kBAAb,MAA6B;CAa3B,YAAmB,KAAiB;EAClC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,OAAO,IAAI,SAAS,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU;EACnE,KAAK,MAAM,IAAI;CACjB;CAEA,QAAuB;EACrB,OAAO,KAAK;CACd;CAEA,OAAsB;EACpB,OAAO,KAAK;CACd;CAEA,SAAwB;EACtB,OAAO,KAAK,SAAS,MAAM;CAC7B;CAEA,QAAuB;EACrB,OAAO,KAAK,SAAS;CACvB;CAEA,SAAwB;EACtB,MAAM,QAAgB,KAAK,SAAS;EACpC,OAAQ,UAAU,IAAK,EAAE,QAAQ;CACnC;CAEA,SAAwB;EACtB,OAAO,KAAK,SAAS;CACvB;CAEA,QAAuB;EACrB,OAAO,OAAO,OAAO,IAAI,KAAK,SAAS,CAAC;CAC1C;CAEA,SAAwB;EACtB,MAAM,QAAQ,KAAK,SAAS;EAC5B,OAAQ,SAAS,OAAO,CAAI,IAAK,EAAE,QAAQ,OAAO,CAAI;CACxD;CAEA,OAAuB;EACrB,OAAO,KAAK,SAAS,MAAM;CAC7B;CAE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;GACf,KAAK,MAAM;GACX,KAAK,MAAM;GACX,MAAM;EACR;CACF;CAEA,SAAiB,QAAsB;EACrC,IACE,OAAO,cAAc,MAAM,MAAM,SACjC,SAAS,KACT,SAAS,KAAK,KAAK,IAAI,KAAK,KAE5B,MAAM,MAAM,kBAAkB;CAClC;AACF;;;;;;;;AASA,MAAM,SAAS,4BACb,IAAI,MAAM,qCAAqC,SAAS;;;;;;;AAQ1D,MAAM,mBAAmB;;;;;;;;AASzB,MAAM,kBAAkB;AAExB,MAAM,OAAO,IAAI,gBACT,IAAI,YAAY,SAAS;CAAE,OAAO;CAAM,WAAW;AAAK,CAAC,CACjE"}
|
|
@@ -4,10 +4,20 @@ exports._assertGuard = void 0;
|
|
|
4
4
|
const TypeGuardError_1 = require("../TypeGuardError");
|
|
5
5
|
const _assertGuard = (exceptionable, props, factory) => {
|
|
6
6
|
if (exceptionable === true) {
|
|
7
|
-
|
|
7
|
+
// `factory` arrives from the generated function's second parameter, which
|
|
8
|
+
// a pointwise hand-off fills with something that is not a factory at all:
|
|
9
|
+
// `rows.map(assertUser)` passes the element index. A truthiness test then
|
|
10
|
+
// called a number and reported `factory is not a function`, hiding the
|
|
11
|
+
// real assertion failure — and only for indices other than 0. Require a
|
|
12
|
+
// callable, and fall back to TypeGuardError for everything else.
|
|
13
|
+
//
|
|
14
|
+
// A create-time factory is the default of that same parameter, so a
|
|
15
|
+
// non-callable argument has already overridden it by the time this runs
|
|
16
|
+
// and cannot be recovered here. TypeGuardError still names the property
|
|
17
|
+
// that failed, which `factory is not a function` never did.
|
|
18
|
+
if (typeof factory === "function")
|
|
8
19
|
throw factory(props);
|
|
9
|
-
|
|
10
|
-
throw new TypeGuardError_1.TypeGuardError(props);
|
|
20
|
+
throw new TypeGuardError_1.TypeGuardError(props);
|
|
11
21
|
}
|
|
12
22
|
return false;
|
|
13
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_assertGuard.js","sourceRoot":"","sources":["../../src/internal/_assertGuard.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAE5C,MAAM,YAAY,GAAG,CAC1B,aAAsB,EACtB,KAA4B,EAC5B,OAAiD,EAC1C,EAAE;IACT,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,OAAO;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"_assertGuard.js","sourceRoot":"","sources":["../../src/internal/_assertGuard.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAE5C,MAAM,YAAY,GAAG,CAC1B,aAAsB,EACtB,KAA4B,EAC5B,OAAiD,EAC1C,EAAE;IACT,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,0EAA0E;QAC1E,0EAA0E;QAC1E,0EAA0E;QAC1E,uEAAuE;QACvE,wEAAwE;QACxE,iEAAiE;QACjE,EAAE;QACF,oEAAoE;QACpE,wEAAwE;QACxE,wEAAwE;QACxE,4DAA4D;QAC5D,IAAI,OAAO,OAAO,KAAK,UAAU;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,IAAI,+BAAc,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AArBW,QAAA,YAAY,GAAZ,YAAY,CAqBvB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { TypeGuardError } from "../TypeGuardError.mjs";
|
|
2
2
|
//#region src/internal/_assertGuard.ts
|
|
3
3
|
const _assertGuard = (exceptionable, props, factory) => {
|
|
4
|
-
if (exceptionable === true)
|
|
5
|
-
|
|
4
|
+
if (exceptionable === true) {
|
|
5
|
+
if (typeof factory === "function") throw factory(props);
|
|
6
|
+
throw new TypeGuardError(props);
|
|
7
|
+
}
|
|
6
8
|
return false;
|
|
7
9
|
};
|
|
8
10
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_assertGuard.mjs","names":[],"sources":["../../src/internal/_assertGuard.ts"],"sourcesContent":["import { TypeGuardError } from \"../TypeGuardError\";\n\nexport const _assertGuard = (\n exceptionable: boolean,\n props: TypeGuardError.IProps,\n factory?: (props: TypeGuardError.IProps) => Error,\n): false => {\n if (exceptionable === true) {\n if (factory) throw factory(props);\n
|
|
1
|
+
{"version":3,"file":"_assertGuard.mjs","names":[],"sources":["../../src/internal/_assertGuard.ts"],"sourcesContent":["import { TypeGuardError } from \"../TypeGuardError\";\n\nexport const _assertGuard = (\n exceptionable: boolean,\n props: TypeGuardError.IProps,\n factory?: (props: TypeGuardError.IProps) => Error,\n): false => {\n if (exceptionable === true) {\n // `factory` arrives from the generated function's second parameter, which\n // a pointwise hand-off fills with something that is not a factory at all:\n // `rows.map(assertUser)` passes the element index. A truthiness test then\n // called a number and reported `factory is not a function`, hiding the\n // real assertion failure — and only for indices other than 0. Require a\n // callable, and fall back to TypeGuardError for everything else.\n //\n // A create-time factory is the default of that same parameter, so a\n // non-callable argument has already overridden it by the time this runs\n // and cannot be recovered here. TypeGuardError still names the property\n // that failed, which `factory is not a function` never did.\n if (typeof factory === \"function\") throw factory(props);\n throw new TypeGuardError(props);\n }\n return false;\n};\n"],"mappings":";;AAEA,MAAa,gBACX,eACA,OACA,YACU;CACV,IAAI,kBAAkB,MAAM;EAY1B,IAAI,OAAO,YAAY,YAAY,MAAM,QAAQ,KAAK;EACtD,MAAM,IAAI,eAAe,KAAK;CAChC;CACA,OAAO;AACT"}
|
|
@@ -3,5 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._isFormatIdnHostname = void 0;
|
|
4
4
|
const _isFormatIdnHostname = (str) => PATTERN.test(str);
|
|
5
5
|
exports._isFormatIdnHostname = _isFormatIdnHostname;
|
|
6
|
-
|
|
6
|
+
// The ASCII `hostname` structure with the label character class extended by the
|
|
7
|
+
// non-ASCII range: every valid host name is a valid IDN host name, so this must
|
|
8
|
+
// accept a single label, a one-to-63-character label in any position, and a
|
|
9
|
+
// name up to 253 characters, exactly as `_isFormatHostname` does (issue #2317).
|
|
10
|
+
const PATTERN = /^(?=.{1,253}\.?$)[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?(?:\.[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?)*\.?$/i;
|
|
7
11
|
//# sourceMappingURL=_isFormatIdnHostname.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_isFormatIdnHostname.js","sourceRoot":"","sources":["../../src/internal/_isFormatIdnHostname.ts"],"names":[],"mappings":";;;AAAO,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAAnE,QAAA,oBAAoB,GAApB,oBAAoB,CAA+C;AAEhF,MAAM,OAAO,GACX,
|
|
1
|
+
{"version":3,"file":"_isFormatIdnHostname.js","sourceRoot":"","sources":["../../src/internal/_isFormatIdnHostname.ts"],"names":[],"mappings":";;;AAAO,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAAnE,QAAA,oBAAoB,GAApB,oBAAoB,CAA+C;AAEhF,gFAAgF;AAChF,gFAAgF;AAChF,4EAA4E;AAC5E,gFAAgF;AAChF,MAAM,OAAO,GACX,qLAAqL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/internal/_isFormatIdnHostname.ts
|
|
2
2
|
const _isFormatIdnHostname = (str) => PATTERN.test(str);
|
|
3
|
-
const PATTERN = /^([a-z0-9\u00a1-\
|
|
3
|
+
const PATTERN = /^(?=.{1,253}\.?$)[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?(?:\.[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?)*\.?$/i;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { _isFormatIdnHostname };
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_isFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_isFormatIdnHostname.ts"],"sourcesContent":["export const _isFormatIdnHostname = (str: string): boolean => PATTERN.test(str);\n\nconst PATTERN =\n /^([a-z0-9\\u00a1-\\
|
|
1
|
+
{"version":3,"file":"_isFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_isFormatIdnHostname.ts"],"sourcesContent":["export const _isFormatIdnHostname = (str: string): boolean => PATTERN.test(str);\n\n// The ASCII `hostname` structure with the label character class extended by the\n// non-ASCII range: every valid host name is a valid IDN host name, so this must\n// accept a single label, a one-to-63-character label in any position, and a\n// name up to 253 characters, exactly as `_isFormatHostname` does (issue #2317).\nconst PATTERN =\n /^(?=.{1,253}\\.?$)[a-z0-9\\u00a1-\\uffff](?:[a-z0-9\\u00a1-\\uffff-]{0,61}[a-z0-9\\u00a1-\\uffff])?(?:\\.[a-z0-9\\u00a1-\\uffff](?:[a-z0-9\\u00a1-\\uffff-]{0,61}[a-z0-9\\u00a1-\\uffff])?)*\\.?$/i;\n"],"mappings":";AAAA,MAAa,wBAAwB,QAAyB,QAAQ,KAAK,GAAG;AAM9E,MAAM,UACJ"}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._isFormatTime = void 0;
|
|
4
|
-
const _isFormatTime = (str) =>
|
|
4
|
+
const _isFormatTime = (str) => {
|
|
5
|
+
const match = PATTERN.exec(str);
|
|
6
|
+
if (match === null)
|
|
7
|
+
return false;
|
|
8
|
+
if (match[3] !== "60")
|
|
9
|
+
return true;
|
|
10
|
+
// RFC 3339 admits `:60` only where a leap second is inserted, which is
|
|
11
|
+
// always 23:59:60 UTC. `date-time` decides that from the instant it can
|
|
12
|
+
// build; a clock carries no date, so it shifts itself by its own offset and
|
|
13
|
+
// asks the same question, wrapping the result back into the day.
|
|
14
|
+
const offset = match[4] === undefined
|
|
15
|
+
? 0
|
|
16
|
+
: (match[4] === "+" ? 1 : -1) *
|
|
17
|
+
(Number(match[5]) * 60 + Number(match[6]));
|
|
18
|
+
const minutes = Number(match[1]) * 60 + Number(match[2]) - offset;
|
|
19
|
+
return ((minutes % DAY) + DAY) % DAY === DAY - 1;
|
|
20
|
+
};
|
|
5
21
|
exports._isFormatTime = _isFormatTime;
|
|
6
|
-
const PATTERN = /^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]
|
|
22
|
+
const PATTERN = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(?:\.[0-9]+)?(?:[Zz]|([+-])((?:[01][0-9]|2[0-3])):([0-5][0-9]))$/;
|
|
23
|
+
const DAY = 24 * 60;
|
|
7
24
|
//# sourceMappingURL=_isFormatTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_isFormatTime.js","sourceRoot":"","sources":["../../src/internal/_isFormatTime.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"_isFormatTime.js","sourceRoot":"","sources":["../../src/internal/_isFormatTime.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;IACpD,MAAM,KAAK,GAA2B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEnC,uEAAuE;IACvE,wEAAwE;IACxE,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM,MAAM,GACV,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS;QACpB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,OAAO,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1E,OAAO,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC;AAhBW,QAAA,aAAa,GAAb,aAAa,CAgBxB;AAEF,MAAM,OAAO,GACX,kHAAkH,CAAC;AACrH,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
//#region src/internal/_isFormatTime.ts
|
|
2
|
-
const _isFormatTime = (str) =>
|
|
3
|
-
const
|
|
2
|
+
const _isFormatTime = (str) => {
|
|
3
|
+
const match = PATTERN.exec(str);
|
|
4
|
+
if (match === null) return false;
|
|
5
|
+
if (match[3] !== "60") return true;
|
|
6
|
+
const offset = match[4] === void 0 ? 0 : (match[4] === "+" ? 1 : -1) * (Number(match[5]) * 60 + Number(match[6]));
|
|
7
|
+
return ((Number(match[1]) * 60 + Number(match[2]) - offset) % DAY + DAY) % DAY === DAY - 1;
|
|
8
|
+
};
|
|
9
|
+
const PATTERN = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(?:\.[0-9]+)?(?:[Zz]|([+-])((?:[01][0-9]|2[0-3])):([0-5][0-9]))$/;
|
|
10
|
+
const DAY = 1440;
|
|
4
11
|
//#endregion
|
|
5
12
|
export { _isFormatTime };
|
|
6
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_isFormatTime.mjs","names":[],"sources":["../../src/internal/_isFormatTime.ts"],"sourcesContent":["export const _isFormatTime = (str: string): boolean => PATTERN.
|
|
1
|
+
{"version":3,"file":"_isFormatTime.mjs","names":[],"sources":["../../src/internal/_isFormatTime.ts"],"sourcesContent":["export const _isFormatTime = (str: string): boolean => {\n const match: RegExpExecArray | null = PATTERN.exec(str);\n if (match === null) return false;\n if (match[3] !== \"60\") return true;\n\n // RFC 3339 admits `:60` only where a leap second is inserted, which is\n // always 23:59:60 UTC. `date-time` decides that from the instant it can\n // build; a clock carries no date, so it shifts itself by its own offset and\n // asks the same question, wrapping the result back into the day.\n const offset: number =\n match[4] === undefined\n ? 0\n : (match[4] === \"+\" ? 1 : -1) *\n (Number(match[5]) * 60 + Number(match[6]));\n const minutes: number = Number(match[1]) * 60 + Number(match[2]) - offset;\n return ((minutes % DAY) + DAY) % DAY === DAY - 1;\n};\n\nconst PATTERN =\n /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(?:\\.[0-9]+)?(?:[Zz]|([+-])((?:[01][0-9]|2[0-3])):([0-5][0-9]))$/;\nconst DAY = 24 * 60;\n"],"mappings":";AAAA,MAAa,iBAAiB,QAAyB;CACrD,MAAM,QAAgC,QAAQ,KAAK,GAAG;CACtD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,MAAM,OAAO,MAAM,OAAO;CAM9B,MAAM,SACJ,MAAM,OAAO,KAAA,IACT,KACC,MAAM,OAAO,MAAM,IAAI,OACvB,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE;CAE9C,SADwB,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE,IAAI,UAChD,MAAO,OAAO,QAAQ,MAAM;AACjD;AAEA,MAAM,UACJ;AACF,MAAM,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._jsonStringifyArray = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Serializes the elements of an array the way ECMAScript `JSON.stringify` does.
|
|
6
|
+
*
|
|
7
|
+
* `SerializeJSONArray` walks index `0` to `LengthOfArrayLike(value) - 1` and
|
|
8
|
+
* writes `null` wherever the element serializes to `undefined`. Neither
|
|
9
|
+
* `Array.prototype.map` nor `Array.prototype.join` reproduces that:
|
|
10
|
+
*
|
|
11
|
+
* - `map` never visits a hole and leaves one behind, and `join` renders a hole as
|
|
12
|
+
* empty text, so a sparse array joined into malformed text such as `[,1]`. A
|
|
13
|
+
* hole exists at runtime whatever the element type declares, so this is not
|
|
14
|
+
* an `any` concern.
|
|
15
|
+
* - `join` renders a mapped `undefined` as empty text too, which is what an `any`
|
|
16
|
+
* or `unknown` element holding a function, a symbol, or a `toJSON` that
|
|
17
|
+
* returns nothing serializes to.
|
|
18
|
+
*
|
|
19
|
+
* The length is converted with `ToLength` and read once, which is both what
|
|
20
|
+
* `JSON.stringify` does and what `Array.prototype.every` - the traversal
|
|
21
|
+
* typia's own array checkers emit - does, so the checker and the serializer
|
|
22
|
+
* walk one index range rather than two that merely usually coincide.
|
|
23
|
+
*
|
|
24
|
+
* @param elements Array being serialized.
|
|
25
|
+
* @param mapper Serializer of one element, emitted by the transform.
|
|
26
|
+
* @returns Comma separated element text, without the enclosing brackets.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
const _jsonStringifyArray = (elements, mapper) => {
|
|
30
|
+
const length = Math.min(Math.max(Math.trunc(elements.length) || 0, 0), Number.MAX_SAFE_INTEGER);
|
|
31
|
+
let output = "";
|
|
32
|
+
for (let i = 0; i < length; ++i) {
|
|
33
|
+
const elem = elements[i];
|
|
34
|
+
// A hole and an explicit `undefined` are answered without calling the
|
|
35
|
+
// mapper, because the mapper is the element type's own serializer and a
|
|
36
|
+
// typed one has no answer for a missing value. Everything else is answered
|
|
37
|
+
// from the mapper's *result*: an element that is present but serializes to
|
|
38
|
+
// nothing — a function, a symbol, or a `toJSON` returning nothing in an
|
|
39
|
+
// `any` slot — is `null` in an array position, exactly as
|
|
40
|
+
// SerializeJSONArray specifies, and testing the input instead would let its
|
|
41
|
+
// text become the literal `undefined`.
|
|
42
|
+
const text = elem === undefined ? undefined : mapper(elem, i);
|
|
43
|
+
output += (i === 0 ? "" : ",") + (text === undefined ? "null" : text);
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
exports._jsonStringifyArray = _jsonStringifyArray;
|
|
48
|
+
//# sourceMappingURL=_jsonStringifyArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyArray.js","sourceRoot":"","sources":["../../src/internal/_jsonStringifyArray.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,mBAAmB,GAAG,CACjC,QAAsB,EACtB,MAA0C,EAClC,EAAE;IACV,MAAM,MAAM,GAAW,IAAI,CAAC,GAAG,CAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAC7C,MAAM,CAAC,gBAAgB,CACxB,CAAC;IACF,IAAI,MAAM,GAAW,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,GAAkB,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,sEAAsE;QACtE,wEAAwE;QACxE,2EAA2E;QAC3E,2EAA2E;QAC3E,wEAAwE;QACxE,0DAA0D;QAC1D,4EAA4E;QAC5E,uCAAuC;QACvC,MAAM,IAAI,GACR,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAxBW,QAAA,mBAAmB,GAAnB,mBAAmB,CAwB9B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/internal/_jsonStringifyArray.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serializes the elements of an array the way ECMAScript `JSON.stringify` does.
|
|
4
|
+
*
|
|
5
|
+
* `SerializeJSONArray` walks index `0` to `LengthOfArrayLike(value) - 1` and
|
|
6
|
+
* writes `null` wherever the element serializes to `undefined`. Neither
|
|
7
|
+
* `Array.prototype.map` nor `Array.prototype.join` reproduces that:
|
|
8
|
+
*
|
|
9
|
+
* - `map` never visits a hole and leaves one behind, and `join` renders a hole as
|
|
10
|
+
* empty text, so a sparse array joined into malformed text such as `[,1]`. A
|
|
11
|
+
* hole exists at runtime whatever the element type declares, so this is not
|
|
12
|
+
* an `any` concern.
|
|
13
|
+
* - `join` renders a mapped `undefined` as empty text too, which is what an `any`
|
|
14
|
+
* or `unknown` element holding a function, a symbol, or a `toJSON` that
|
|
15
|
+
* returns nothing serializes to.
|
|
16
|
+
*
|
|
17
|
+
* The length is converted with `ToLength` and read once, which is both what
|
|
18
|
+
* `JSON.stringify` does and what `Array.prototype.every` - the traversal
|
|
19
|
+
* typia's own array checkers emit - does, so the checker and the serializer
|
|
20
|
+
* walk one index range rather than two that merely usually coincide.
|
|
21
|
+
*
|
|
22
|
+
* @param elements Array being serialized.
|
|
23
|
+
* @param mapper Serializer of one element, emitted by the transform.
|
|
24
|
+
* @returns Comma separated element text, without the enclosing brackets.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
const _jsonStringifyArray = (elements, mapper) => {
|
|
28
|
+
const length = Math.min(Math.max(Math.trunc(elements.length) || 0, 0), Number.MAX_SAFE_INTEGER);
|
|
29
|
+
let output = "";
|
|
30
|
+
for (let i = 0; i < length; ++i) {
|
|
31
|
+
const elem = elements[i];
|
|
32
|
+
const text = elem === void 0 ? void 0 : mapper(elem, i);
|
|
33
|
+
output += (i === 0 ? "" : ",") + (text === void 0 ? "null" : text);
|
|
34
|
+
}
|
|
35
|
+
return output;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { _jsonStringifyArray };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=_jsonStringifyArray.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyArray.mjs","names":[],"sources":["../../src/internal/_jsonStringifyArray.ts"],"sourcesContent":["/**\n * Serializes the elements of an array the way ECMAScript `JSON.stringify` does.\n *\n * `SerializeJSONArray` walks index `0` to `LengthOfArrayLike(value) - 1` and\n * writes `null` wherever the element serializes to `undefined`. Neither\n * `Array.prototype.map` nor `Array.prototype.join` reproduces that:\n *\n * - `map` never visits a hole and leaves one behind, and `join` renders a hole as\n * empty text, so a sparse array joined into malformed text such as `[,1]`. A\n * hole exists at runtime whatever the element type declares, so this is not\n * an `any` concern.\n * - `join` renders a mapped `undefined` as empty text too, which is what an `any`\n * or `unknown` element holding a function, a symbol, or a `toJSON` that\n * returns nothing serializes to.\n *\n * The length is converted with `ToLength` and read once, which is both what\n * `JSON.stringify` does and what `Array.prototype.every` - the traversal\n * typia's own array checkers emit - does, so the checker and the serializer\n * walk one index range rather than two that merely usually coincide.\n *\n * @param elements Array being serialized.\n * @param mapper Serializer of one element, emitted by the transform.\n * @returns Comma separated element text, without the enclosing brackets.\n * @internal\n */\nexport const _jsonStringifyArray = <T>(\n elements: ArrayLike<T>,\n mapper: (elem: T, index: number) => string,\n): string => {\n const length: number = Math.min(\n Math.max(Math.trunc(elements.length) || 0, 0),\n Number.MAX_SAFE_INTEGER,\n );\n let output: string = \"\";\n for (let i: number = 0; i < length; ++i) {\n const elem: T | undefined = elements[i];\n // A hole and an explicit `undefined` are answered without calling the\n // mapper, because the mapper is the element type's own serializer and a\n // typed one has no answer for a missing value. Everything else is answered\n // from the mapper's *result*: an element that is present but serializes to\n // nothing — a function, a symbol, or a `toJSON` returning nothing in an\n // `any` slot — is `null` in an array position, exactly as\n // SerializeJSONArray specifies, and testing the input instead would let its\n // text become the literal `undefined`.\n const text: string | undefined =\n elem === undefined ? undefined : mapper(elem, i);\n output += (i === 0 ? \"\" : \",\") + (text === undefined ? \"null\" : text);\n }\n return output;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,uBACX,UACA,WACW;CACX,MAAM,SAAiB,KAAK,IAC1B,KAAK,IAAI,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG,CAAC,GAC5C,OAAO,gBACT;CACA,IAAI,SAAiB;CACrB,KAAK,IAAI,IAAY,GAAG,IAAI,QAAQ,EAAE,GAAG;EACvC,MAAM,OAAsB,SAAS;EASrC,MAAM,OACJ,SAAS,KAAA,IAAY,KAAA,IAAY,OAAO,MAAM,CAAC;EACjD,WAAW,MAAM,IAAI,KAAK,QAAQ,SAAS,KAAA,IAAY,SAAS;CAClE;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._jsonStringifyElement = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Writes one array or tuple element the way ECMAScript `JSON.stringify` writes
|
|
6
|
+
* it.
|
|
7
|
+
*
|
|
8
|
+
* `SerializeJSONArray` writes `null` wherever an element serializes to
|
|
9
|
+
* `undefined`, because an array position cannot be omitted without shifting
|
|
10
|
+
* every element after it. A present value with no serialization — a function, a
|
|
11
|
+
* symbol, or a `toJSON` returning nothing — is therefore `null`, not the
|
|
12
|
+
* literal text `undefined` and not an empty slot.
|
|
13
|
+
*
|
|
14
|
+
* This is the fixed-position counterpart of `_jsonStringifyArray`, which
|
|
15
|
+
* answers the same question while walking an array's own index range.
|
|
16
|
+
*
|
|
17
|
+
* @param text Serialized element value, or `undefined` when it has none.
|
|
18
|
+
* @returns Element text, or `null` when the element has no serialization.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
const _jsonStringifyElement = (text) => text === undefined ? "null" : text;
|
|
22
|
+
exports._jsonStringifyElement = _jsonStringifyElement;
|
|
23
|
+
//# sourceMappingURL=_jsonStringifyElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyElement.js","sourceRoot":"","sources":["../../src/internal/_jsonStringifyElement.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,qBAAqB,GAAG,CAAC,IAAwB,EAAU,EAAE,CACxE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AADxB,QAAA,qBAAqB,GAArB,qBAAqB,CACG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/internal/_jsonStringifyElement.ts
|
|
2
|
+
/**
|
|
3
|
+
* Writes one array or tuple element the way ECMAScript `JSON.stringify` writes
|
|
4
|
+
* it.
|
|
5
|
+
*
|
|
6
|
+
* `SerializeJSONArray` writes `null` wherever an element serializes to
|
|
7
|
+
* `undefined`, because an array position cannot be omitted without shifting
|
|
8
|
+
* every element after it. A present value with no serialization — a function, a
|
|
9
|
+
* symbol, or a `toJSON` returning nothing — is therefore `null`, not the
|
|
10
|
+
* literal text `undefined` and not an empty slot.
|
|
11
|
+
*
|
|
12
|
+
* This is the fixed-position counterpart of `_jsonStringifyArray`, which
|
|
13
|
+
* answers the same question while walking an array's own index range.
|
|
14
|
+
*
|
|
15
|
+
* @param text Serialized element value, or `undefined` when it has none.
|
|
16
|
+
* @returns Element text, or `null` when the element has no serialization.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
const _jsonStringifyElement = (text) => text === void 0 ? "null" : text;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { _jsonStringifyElement };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=_jsonStringifyElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyElement.mjs","names":[],"sources":["../../src/internal/_jsonStringifyElement.ts"],"sourcesContent":["/**\n * Writes one array or tuple element the way ECMAScript `JSON.stringify` writes\n * it.\n *\n * `SerializeJSONArray` writes `null` wherever an element serializes to\n * `undefined`, because an array position cannot be omitted without shifting\n * every element after it. A present value with no serialization — a function, a\n * symbol, or a `toJSON` returning nothing — is therefore `null`, not the\n * literal text `undefined` and not an empty slot.\n *\n * This is the fixed-position counterpart of `_jsonStringifyArray`, which\n * answers the same question while walking an array's own index range.\n *\n * @param text Serialized element value, or `undefined` when it has none.\n * @returns Element text, or `null` when the element has no serialization.\n * @internal\n */\nexport const _jsonStringifyElement = (text: string | undefined): string =>\n text === undefined ? \"null\" : text;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,yBAAyB,SACpC,SAAS,KAAA,IAAY,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._jsonStringifyProperty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Writes one object member the way ECMAScript `JSON.stringify` writes it.
|
|
6
|
+
*
|
|
7
|
+
* `SerializeJSONObject` serializes each member first and drops the member
|
|
8
|
+
* entirely when that result is `undefined`. Deciding omission from the _input_
|
|
9
|
+
* instead cannot reach the same answer: a symbol and a `toJSON` returning
|
|
10
|
+
* nothing are both present, non-`undefined`, non-function values whose
|
|
11
|
+
* serialization is `undefined`, so the member's text became the literal
|
|
12
|
+
* `"k":undefined` — output that is not JSON at all.
|
|
13
|
+
*
|
|
14
|
+
* The serialized text is passed in already evaluated, so the member's value is
|
|
15
|
+
* serialized exactly once. Testing the input and then serializing would
|
|
16
|
+
* evaluate a `toJSON` twice, and a `toJSON` is free to answer differently each
|
|
17
|
+
* call.
|
|
18
|
+
*
|
|
19
|
+
* The trailing separator belongs to the member because a dropped member must
|
|
20
|
+
* take its comma with it; `_jsonStringifyTail` removes the one that is left
|
|
21
|
+
* behind when the last written member is the one that dropped.
|
|
22
|
+
*
|
|
23
|
+
* @param head Quoted key and colon, emitted by the transform.
|
|
24
|
+
* @param text Serialized member value, or `undefined` when it has none.
|
|
25
|
+
* @param tail Separator following this member, empty for the last one.
|
|
26
|
+
* @returns Member text, or an empty string when the member is omitted.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
const _jsonStringifyProperty = (head, text, tail) => (text === undefined ? "" : head + text + tail);
|
|
30
|
+
exports._jsonStringifyProperty = _jsonStringifyProperty;
|
|
31
|
+
//# sourceMappingURL=_jsonStringifyProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyProperty.js","sourceRoot":"","sources":["../../src/internal/_jsonStringifyProperty.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,sBAAsB,GAAG,CACpC,IAAY,EACZ,IAAwB,EACxB,IAAY,EACJ,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAJ/C,QAAA,sBAAsB,GAAtB,sBAAsB,CAIyB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/internal/_jsonStringifyProperty.ts
|
|
2
|
+
/**
|
|
3
|
+
* Writes one object member the way ECMAScript `JSON.stringify` writes it.
|
|
4
|
+
*
|
|
5
|
+
* `SerializeJSONObject` serializes each member first and drops the member
|
|
6
|
+
* entirely when that result is `undefined`. Deciding omission from the _input_
|
|
7
|
+
* instead cannot reach the same answer: a symbol and a `toJSON` returning
|
|
8
|
+
* nothing are both present, non-`undefined`, non-function values whose
|
|
9
|
+
* serialization is `undefined`, so the member's text became the literal
|
|
10
|
+
* `"k":undefined` — output that is not JSON at all.
|
|
11
|
+
*
|
|
12
|
+
* The serialized text is passed in already evaluated, so the member's value is
|
|
13
|
+
* serialized exactly once. Testing the input and then serializing would
|
|
14
|
+
* evaluate a `toJSON` twice, and a `toJSON` is free to answer differently each
|
|
15
|
+
* call.
|
|
16
|
+
*
|
|
17
|
+
* The trailing separator belongs to the member because a dropped member must
|
|
18
|
+
* take its comma with it; `_jsonStringifyTail` removes the one that is left
|
|
19
|
+
* behind when the last written member is the one that dropped.
|
|
20
|
+
*
|
|
21
|
+
* @param head Quoted key and colon, emitted by the transform.
|
|
22
|
+
* @param text Serialized member value, or `undefined` when it has none.
|
|
23
|
+
* @param tail Separator following this member, empty for the last one.
|
|
24
|
+
* @returns Member text, or an empty string when the member is omitted.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
const _jsonStringifyProperty = (head, text, tail) => text === void 0 ? "" : head + text + tail;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { _jsonStringifyProperty };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=_jsonStringifyProperty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_jsonStringifyProperty.mjs","names":[],"sources":["../../src/internal/_jsonStringifyProperty.ts"],"sourcesContent":["/**\n * Writes one object member the way ECMAScript `JSON.stringify` writes it.\n *\n * `SerializeJSONObject` serializes each member first and drops the member\n * entirely when that result is `undefined`. Deciding omission from the _input_\n * instead cannot reach the same answer: a symbol and a `toJSON` returning\n * nothing are both present, non-`undefined`, non-function values whose\n * serialization is `undefined`, so the member's text became the literal\n * `\"k\":undefined` — output that is not JSON at all.\n *\n * The serialized text is passed in already evaluated, so the member's value is\n * serialized exactly once. Testing the input and then serializing would\n * evaluate a `toJSON` twice, and a `toJSON` is free to answer differently each\n * call.\n *\n * The trailing separator belongs to the member because a dropped member must\n * take its comma with it; `_jsonStringifyTail` removes the one that is left\n * behind when the last written member is the one that dropped.\n *\n * @param head Quoted key and colon, emitted by the transform.\n * @param text Serialized member value, or `undefined` when it has none.\n * @param tail Separator following this member, empty for the last one.\n * @returns Member text, or an empty string when the member is omitted.\n * @internal\n */\nexport const _jsonStringifyProperty = (\n head: string,\n text: string | undefined,\n tail: string,\n): string => (text === undefined ? \"\" : head + text + tail);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,0BACX,MACA,MACA,SACY,SAAS,KAAA,IAAY,KAAK,OAAO,OAAO"}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._llmApplicationFinalize = void 0;
|
|
4
4
|
const utils_1 = require("@typia/utils");
|
|
5
|
-
const _llmApplicationFinalize = (app, config) => { var _a; return (Object.assign(Object.assign({}, app), { config: Object.assign(Object.assign({}, utils_1.LlmSchemaConverter.getConfig()), { validate: (_a = config === null || config === void 0 ? void 0 : config.validate) !== null && _a !== void 0 ? _a : null }), functions: app.functions.map((func) => { var _a; var _b; return (Object.assign(Object.assign({}, func), { parse: (input) => utils_1.LlmJson.parse(input, func.parameters), coerce: (input) => utils_1.LlmJson.coerce(input, func.parameters), validate: (_b = (_a = config === null || config === void 0 ? void 0 : config.validate) === null || _a === void 0 ? void 0 : _a[func.name]) !== null && _b !== void 0 ? _b : func.validate })); }) })); };
|
|
5
|
+
const _llmApplicationFinalize = (app, config) => { var _a; return (Object.assign(Object.assign({}, app), { config: Object.assign(Object.assign({}, utils_1.LlmSchemaConverter.getConfig(app.config)), { validate: (_a = config === null || config === void 0 ? void 0 : config.validate) !== null && _a !== void 0 ? _a : null }), functions: app.functions.map((func) => { var _a; var _b; return (Object.assign(Object.assign({}, func), { parse: (input) => utils_1.LlmJson.parse(input, func.parameters), coerce: (input) => utils_1.LlmJson.coerce(input, func.parameters), validate: (_b = (_a = config === null || config === void 0 ? void 0 : config.validate) === null || _a === void 0 ? void 0 : _a[func.name]) !== null && _b !== void 0 ? _b : func.validate })); }) })); };
|
|
6
6
|
exports._llmApplicationFinalize = _llmApplicationFinalize;
|
|
7
7
|
//# sourceMappingURL=_llmApplicationFinalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_llmApplicationFinalize.js","sourceRoot":"","sources":["../../src/internal/_llmApplicationFinalize.ts"],"names":[],"mappings":";;;AACA,wCAA2D;AAEpD,MAAM,uBAAuB,GAAG,CACrC,GAAwC,EACxC,MAA2D,EACnC,EAAE,kBAAC,iCACxB,GAAG,KACN,MAAM,
|
|
1
|
+
{"version":3,"file":"_llmApplicationFinalize.js","sourceRoot":"","sources":["../../src/internal/_llmApplicationFinalize.ts"],"names":[],"mappings":";;;AACA,wCAA2D;AAEpD,MAAM,uBAAuB,GAAG,CACrC,GAAwC,EACxC,MAA2D,EACnC,EAAE,kBAAC,iCACxB,GAAG,KACN,MAAM,kCAMD,0BAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,KAC3C,QAAQ,QAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,IAAI,KAEpC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,0BAAC,iCAClC,IAAI,KACP,KAAK,EAAE,CAAC,KAAa,EAA6B,EAAE,CAClD,eAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EACvC,MAAM,EAAE,CAAC,KAAc,EAAW,EAAE,CAAC,eAAO,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EAC3E,QAAQ,QAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAG,IAAI,CAAC,IAAI,CAAC,mCAAI,IAAI,CAAC,QAAQ,IACxD,GAAA,CAAC,IACH,GAAA,CAAC;AArBU,QAAA,uBAAuB,GAAvB,uBAAuB,CAqBjC"}
|
|
@@ -3,7 +3,7 @@ import { LlmJson, LlmSchemaConverter } from "@typia/utils";
|
|
|
3
3
|
const _llmApplicationFinalize = (app, config) => ({
|
|
4
4
|
...app,
|
|
5
5
|
config: {
|
|
6
|
-
...LlmSchemaConverter.getConfig(),
|
|
6
|
+
...LlmSchemaConverter.getConfig(app.config),
|
|
7
7
|
validate: config?.validate ?? null
|
|
8
8
|
},
|
|
9
9
|
functions: app.functions.map((func) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_llmApplicationFinalize.mjs","names":[],"sources":["../../src/internal/_llmApplicationFinalize.ts"],"sourcesContent":["import { IJsonParseResult, ILlmApplication } from \"@typia/interface\";\nimport { LlmJson, LlmSchemaConverter } from \"@typia/utils\";\n\nexport const _llmApplicationFinalize = <Class extends object = any>(\n app: ILlmApplication.__IPrimitive<Class>,\n config?: Partial<Pick<ILlmApplication.IConfig, \"validate\">>,\n): ILlmApplication<Class> => ({\n ...app,\n config: {\n ...LlmSchemaConverter.getConfig(),\n validate: config?.validate ?? null,\n },\n functions: app.functions.map((func) => ({\n ...func,\n parse: (input: string): IJsonParseResult<unknown> =>\n LlmJson.parse(input, func.parameters),\n coerce: (input: unknown): unknown => LlmJson.coerce(input, func.parameters),\n validate: config?.validate?.[func.name] ?? func.validate,\n })),\n});\n"],"mappings":";;AAGA,MAAa,2BACX,KACA,YAC4B;CAC5B,GAAG;CACH,QAAQ;
|
|
1
|
+
{"version":3,"file":"_llmApplicationFinalize.mjs","names":[],"sources":["../../src/internal/_llmApplicationFinalize.ts"],"sourcesContent":["import { IJsonParseResult, ILlmApplication } from \"@typia/interface\";\nimport { LlmJson, LlmSchemaConverter } from \"@typia/utils\";\n\nexport const _llmApplicationFinalize = <Class extends object = any>(\n app: ILlmApplication.__IPrimitive<Class>,\n config?: Partial<Pick<ILlmApplication.IConfig, \"validate\">>,\n): ILlmApplication<Class> => ({\n ...app,\n config: {\n // The schema configuration comes from the emitted application, which is\n // where the `Config` generic was resolved. Rebuilding it from the\n // converter's defaults reported `strict: false` for a strict build, and\n // `@typia/mcp` then inverted a strict output schema without strict, which\n // drops every constraint it carries as a description tag (issue #2293).\n ...LlmSchemaConverter.getConfig(app.config),\n validate: config?.validate ?? null,\n },\n functions: app.functions.map((func) => ({\n ...func,\n parse: (input: string): IJsonParseResult<unknown> =>\n LlmJson.parse(input, func.parameters),\n coerce: (input: unknown): unknown => LlmJson.coerce(input, func.parameters),\n validate: config?.validate?.[func.name] ?? func.validate,\n })),\n});\n"],"mappings":";;AAGA,MAAa,2BACX,KACA,YAC4B;CAC5B,GAAG;CACH,QAAQ;EAMN,GAAG,mBAAmB,UAAU,IAAI,MAAM;EAC1C,UAAU,QAAQ,YAAY;CAChC;CACA,WAAW,IAAI,UAAU,KAAK,UAAU;EACtC,GAAG;EACH,QAAQ,UACN,QAAQ,MAAM,OAAO,KAAK,UAAU;EACtC,SAAS,UAA4B,QAAQ,OAAO,OAAO,KAAK,UAAU;EAC1E,UAAU,QAAQ,WAAW,KAAK,SAAS,KAAK;CAClD,EAAE;AACJ"}
|