typia 7.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/_miscCloneAny.js +7 -7
- package/lib/internal/_miscCloneAny.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +3 -3
- package/lib/transformers/FileTransformer.js +18 -1
- package/lib/transformers/FileTransformer.js.map +1 -1
- package/package.json +1 -1
- package/src/internal/_miscCloneAny.ts +7 -9
- package/src/programmers/ValidateProgrammer.ts +3 -3
- package/src/transformers/FileTransformer.ts +21 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._miscCloneAny = void 0;
|
|
4
|
-
const _miscCloneAny = (value) =>
|
|
4
|
+
const _miscCloneAny = (value) => cloneMain(value);
|
|
5
5
|
exports._miscCloneAny = _miscCloneAny;
|
|
6
|
-
const
|
|
6
|
+
const cloneMain = (value) => {
|
|
7
7
|
if (value === undefined)
|
|
8
8
|
return undefined;
|
|
9
9
|
else if (typeof value === "object")
|
|
10
10
|
if (value === null)
|
|
11
11
|
return null;
|
|
12
12
|
else if (Array.isArray(value))
|
|
13
|
-
return value.map(
|
|
13
|
+
return value.map(cloneMain);
|
|
14
14
|
else if (value instanceof Date)
|
|
15
15
|
return new Date(value);
|
|
16
16
|
else if (value instanceof Uint8Array)
|
|
@@ -46,16 +46,16 @@ const $cloneMain = (value) => {
|
|
|
46
46
|
else if (typeof Blob !== "undefined" && value instanceof Blob)
|
|
47
47
|
return new Blob([value], { type: value.type });
|
|
48
48
|
else if (value instanceof Set)
|
|
49
|
-
return new Set([...value].map(
|
|
49
|
+
return new Set([...value].map(cloneMain));
|
|
50
50
|
else if (value instanceof Map)
|
|
51
|
-
return new Map([...value].map(([k, v]) => [
|
|
51
|
+
return new Map([...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]));
|
|
52
52
|
else if (value instanceof WeakSet || value instanceof WeakMap)
|
|
53
53
|
throw new Error("WeakSet and WeakMap are not supported");
|
|
54
54
|
else if (value.valueOf() !== value)
|
|
55
|
-
return
|
|
55
|
+
return cloneMain(value.valueOf());
|
|
56
56
|
else
|
|
57
57
|
return Object.fromEntries(Object.entries(value)
|
|
58
|
-
.map(([k, v]) => [k,
|
|
58
|
+
.map(([k, v]) => [k, cloneMain(v)])
|
|
59
59
|
.filter(([, v]) => v !== undefined));
|
|
60
60
|
else if (typeof value === "function")
|
|
61
61
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_miscCloneAny.js","sourceRoot":"","sources":["../../src/internal/_miscCloneAny.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,CAAI,KAAQ,EAAe,EAAE,CACxD,
|
|
1
|
+
{"version":3,"file":"_miscCloneAny.js","sourceRoot":"","sources":["../../src/internal/_miscCloneAny.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,CAAI,KAAQ,EAAe,EAAE,CACxD,SAAS,CAAC,KAAK,CAAgB,CAAC;AADrB,QAAA,aAAa,iBACQ;AAElC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAO,EAAE;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;SACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAChC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;aAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;aACtD,IAAI,KAAK,YAAY,IAAI;YAAE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;aAClD,IAAI,KAAK,YAAY,UAAU;YAAE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;aAC9D,IAAI,KAAK,YAAY,iBAAiB;YACzC,OAAO,IAAI,iBAAiB,CAAC,KAA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Equality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("__is"), undefined, [typescript_1.default.factory.createIdentifier("input")])), typescript_1.default.factory.createBlock([
|
|
78
78
|
// prepare errors
|
|
79
79
|
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(typescript_1.default.factory.createIdentifier("errors"), typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), typescript_1.default.factory.createArrayLiteralExpression([]))),
|
|
80
|
-
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(typescript_1.default.factory.createIdentifier("
|
|
80
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(typescript_1.default.factory.createIdentifier("_report"), typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createAsExpression(props.context.importer.internal("validateReport"), TypeFactory_1.TypeFactory.keyword("any")), [], [typescript_1.default.factory.createIdentifier("errors")]))),
|
|
81
81
|
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, composed.parameters, undefined, undefined, composed.body), undefined, [
|
|
82
82
|
typescript_1.default.factory.createIdentifier("input"),
|
|
83
83
|
typescript_1.default.factory.createStringLiteral("$input"),
|
|
@@ -105,7 +105,7 @@ var ValidateProgrammer;
|
|
|
105
105
|
value: is.arrow,
|
|
106
106
|
}),
|
|
107
107
|
StatementFactory_1.StatementFactory.mut({ name: "errors" }),
|
|
108
|
-
StatementFactory_1.StatementFactory.mut({ name: "
|
|
108
|
+
StatementFactory_1.StatementFactory.mut({ name: "_report" }),
|
|
109
109
|
],
|
|
110
110
|
arrow,
|
|
111
111
|
};
|
|
@@ -217,7 +217,7 @@ const create_output = () => typescript_1.default.factory.createObjectLiteralExpr
|
|
|
217
217
|
], true);
|
|
218
218
|
const create_report_call = (props) => {
|
|
219
219
|
var _a;
|
|
220
|
-
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("
|
|
220
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("_report"), undefined, [
|
|
221
221
|
(_a = props.exceptionable) !== null && _a !== void 0 ? _a : typescript_1.default.factory.createIdentifier("_exceptionable"),
|
|
222
222
|
typescript_1.default.factory.createObjectLiteralExpression([
|
|
223
223
|
typescript_1.default.factory.createPropertyAssignment("path", props.path),
|
|
@@ -23,7 +23,12 @@ var FileTransformer;
|
|
|
23
23
|
context,
|
|
24
24
|
node,
|
|
25
25
|
}), transformer);
|
|
26
|
-
|
|
26
|
+
const index = find_import_injection_index(file);
|
|
27
|
+
return typescript_1.default.factory.updateSourceFile(file, [
|
|
28
|
+
...file.statements.slice(0, index),
|
|
29
|
+
...importer.toStatements(),
|
|
30
|
+
...file.statements.slice(index),
|
|
31
|
+
], false, file.referencedFiles, file.typeReferenceDirectives, file.hasNoDefaultLib, file.libReferenceDirectives);
|
|
27
32
|
};
|
|
28
33
|
const iterate_node = (props) => {
|
|
29
34
|
var _a;
|
|
@@ -51,6 +56,18 @@ var FileTransformer;
|
|
|
51
56
|
return null;
|
|
52
57
|
}
|
|
53
58
|
};
|
|
59
|
+
const find_import_injection_index = (file) => {
|
|
60
|
+
let i = 0;
|
|
61
|
+
for (; i < file.statements.length; ++i) {
|
|
62
|
+
const stmt = file.statements[i];
|
|
63
|
+
if (typescript_1.default.isExpressionStatement(stmt) &&
|
|
64
|
+
typescript_1.default.isStringLiteralLike(stmt.expression) &&
|
|
65
|
+
stmt.expression.text.startsWith("use "))
|
|
66
|
+
continue;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return i;
|
|
70
|
+
};
|
|
54
71
|
})(FileTransformer || (exports.FileTransformer = FileTransformer = {}));
|
|
55
72
|
const isTransformerError = (error) => typeof error === "object" &&
|
|
56
73
|
error !== null &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTransformer.js","sourceRoot":"","sources":["../../src/transformers/FileTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAE5B,sEAAmE;AAEnE,kDAA+C;AAG/C,uDAAoD;AAGpD,IAAiB,eAAe,
|
|
1
|
+
{"version":3,"file":"FileTransformer.js","sourceRoot":"","sources":["../../src/transformers/FileTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAE5B,sEAAmE;AAEnE,kDAA+C;AAG/C,uDAAoD;AAGpD,IAAiB,eAAe,CA4F/B;AA5FD,WAAiB,eAAe;IACjB,yBAAS,GACpB,CAAC,YAA6D,EAAE,EAAE,CAClE,CAAC,WAAqC,EAAE,EAAE,CAC1C,CAAC,IAAmB,EAAiB,EAAE;QACrC,IAAI,IAAI,CAAC,iBAAiB;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,QAAQ,GAAqB,IAAI,mCAAgB,CAAC;YACtD,cAAc,EAAE,kBAAkB;SACnC,CAAC,CAAC;QACH,MAAM,OAAO,mCACR,YAAY,KACf,WAAW;YACX,QAAQ,GACT,CAAC;QACF,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAEzC,IAAI,GAAG,oBAAE,CAAC,cAAc,CACtB,IAAI,EACJ,CAAC,IAAI,EAAE,EAAE,CACP,YAAY,CAAC;YACX,OAAO;YACP,IAAI;SACL,CAAC,EACJ,WAAW,CACZ,CAAC;QACF,MAAM,KAAK,GAAW,2BAA2B,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAChC,IAAI,EACJ;YACE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;YAClC,GAAG,QAAQ,CAAC,YAAY,EAAE;YAC1B,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;SAChC,EACD,KAAK,EACL,IAAI,CAAC,eAAe,EACpB,IA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package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Resolved } from "../Resolved";
|
|
2
2
|
|
|
3
3
|
export const _miscCloneAny = <T>(value: T): Resolved<T> =>
|
|
4
|
-
|
|
4
|
+
cloneMain(value) as Resolved<T>;
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const cloneMain = (value: any): any => {
|
|
7
7
|
if (value === undefined) return undefined;
|
|
8
8
|
else if (typeof value === "object")
|
|
9
9
|
if (value === null) return null;
|
|
10
|
-
else if (Array.isArray(value)) return value.map(
|
|
10
|
+
else if (Array.isArray(value)) return value.map(cloneMain);
|
|
11
11
|
else if (value instanceof Date) return new Date(value);
|
|
12
12
|
else if (value instanceof Uint8Array) return new Uint8Array(value);
|
|
13
13
|
else if (value instanceof Uint8ClampedArray)
|
|
@@ -29,18 +29,16 @@ const $cloneMain = (value: any): any => {
|
|
|
29
29
|
return new File([value], value.name, { type: value.type });
|
|
30
30
|
else if (typeof Blob !== "undefined" && value instanceof Blob)
|
|
31
31
|
return new Blob([value], { type: value.type });
|
|
32
|
-
else if (value instanceof Set) return new Set([...value].map(
|
|
32
|
+
else if (value instanceof Set) return new Set([...value].map(cloneMain));
|
|
33
33
|
else if (value instanceof Map)
|
|
34
|
-
return new Map(
|
|
35
|
-
[...value].map(([k, v]) => [$cloneMain(k), $cloneMain(v)]),
|
|
36
|
-
);
|
|
34
|
+
return new Map([...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]));
|
|
37
35
|
else if (value instanceof WeakSet || value instanceof WeakMap)
|
|
38
36
|
throw new Error("WeakSet and WeakMap are not supported");
|
|
39
|
-
else if (value.valueOf() !== value) return
|
|
37
|
+
else if (value.valueOf() !== value) return cloneMain(value.valueOf());
|
|
40
38
|
else
|
|
41
39
|
return Object.fromEntries(
|
|
42
40
|
Object.entries(value)
|
|
43
|
-
.map(([k, v]) => [k,
|
|
41
|
+
.map(([k, v]) => [k, cloneMain(v)])
|
|
44
42
|
.filter(([, v]) => v !== undefined),
|
|
45
43
|
);
|
|
46
44
|
else if (typeof value === "function") return undefined;
|
|
@@ -139,7 +139,7 @@ export namespace ValidateProgrammer {
|
|
|
139
139
|
),
|
|
140
140
|
ts.factory.createExpressionStatement(
|
|
141
141
|
ts.factory.createBinaryExpression(
|
|
142
|
-
ts.factory.createIdentifier("
|
|
142
|
+
ts.factory.createIdentifier("_report"),
|
|
143
143
|
ts.factory.createToken(ts.SyntaxKind.EqualsToken),
|
|
144
144
|
ts.factory.createCallExpression(
|
|
145
145
|
ts.factory.createAsExpression(
|
|
@@ -223,7 +223,7 @@ export namespace ValidateProgrammer {
|
|
|
223
223
|
value: is.arrow,
|
|
224
224
|
}),
|
|
225
225
|
StatementFactory.mut({ name: "errors" }),
|
|
226
|
-
StatementFactory.mut({ name: "
|
|
226
|
+
StatementFactory.mut({ name: "_report" }),
|
|
227
227
|
],
|
|
228
228
|
arrow,
|
|
229
229
|
};
|
|
@@ -415,7 +415,7 @@ const create_report_call = (props: {
|
|
|
415
415
|
input: ts.Expression;
|
|
416
416
|
}): ts.Expression =>
|
|
417
417
|
ts.factory.createCallExpression(
|
|
418
|
-
ts.factory.createIdentifier("
|
|
418
|
+
ts.factory.createIdentifier("_report"),
|
|
419
419
|
undefined,
|
|
420
420
|
[
|
|
421
421
|
props.exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
|
|
@@ -34,9 +34,14 @@ export namespace FileTransformer {
|
|
|
34
34
|
}),
|
|
35
35
|
transformer,
|
|
36
36
|
);
|
|
37
|
+
const index: number = find_import_injection_index(file);
|
|
37
38
|
return ts.factory.updateSourceFile(
|
|
38
39
|
file,
|
|
39
|
-
[
|
|
40
|
+
[
|
|
41
|
+
...file.statements.slice(0, index),
|
|
42
|
+
...importer.toStatements(),
|
|
43
|
+
...file.statements.slice(index),
|
|
44
|
+
],
|
|
40
45
|
false,
|
|
41
46
|
file.referencedFiles,
|
|
42
47
|
file.typeReferenceDirectives,
|
|
@@ -80,6 +85,21 @@ export namespace FileTransformer {
|
|
|
80
85
|
return null;
|
|
81
86
|
}
|
|
82
87
|
};
|
|
88
|
+
|
|
89
|
+
const find_import_injection_index = (file: ts.SourceFile): number => {
|
|
90
|
+
let i: number = 0;
|
|
91
|
+
for (; i < file.statements.length; ++i) {
|
|
92
|
+
const stmt: ts.Statement = file.statements[i]!;
|
|
93
|
+
if (
|
|
94
|
+
ts.isExpressionStatement(stmt) &&
|
|
95
|
+
ts.isStringLiteralLike(stmt.expression) &&
|
|
96
|
+
stmt.expression.text.startsWith("use ")
|
|
97
|
+
)
|
|
98
|
+
continue;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return i;
|
|
102
|
+
};
|
|
83
103
|
}
|
|
84
104
|
|
|
85
105
|
const isTransformerError = (error: any): error is TransformerError =>
|