@elliots/unplugin-typical 0.2.0 → 0.2.3
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/dist/esbuild.d.mts +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/farm.d.mts +1 -1
- package/dist/farm.mjs +1 -1
- package/dist/{index-DrHjl95P.d.mts → index-B05z7_Xb.d.mts} +15 -7
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/rolldown.d.mts +1 -1
- package/dist/rolldown.mjs +1 -1
- package/dist/rollup.d.mts +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{src-DKwWaQcb.mjs → src-DjSuKGi4.mjs} +23 -3
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
package/dist/esbuild.d.mts
CHANGED
package/dist/esbuild.mjs
CHANGED
package/dist/farm.d.mts
CHANGED
package/dist/farm.mjs
CHANGED
|
@@ -24,7 +24,13 @@ interface TypicalSourceMapConfig {
|
|
|
24
24
|
interface TypicalConfig {
|
|
25
25
|
include?: string[];
|
|
26
26
|
exclude?: string[];
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Controls whether validators are hoisted to module scope for reuse.
|
|
29
|
+
* - 'auto' (default): Hoist only validators used more than once
|
|
30
|
+
* - 'never': Never hoist, always generate inline validators
|
|
31
|
+
* - 'always': Always hoist validators, even if only used once
|
|
32
|
+
*/
|
|
33
|
+
reusableValidators?: 'auto' | 'never' | 'always';
|
|
28
34
|
validateCasts?: boolean;
|
|
29
35
|
hoistRegex?: boolean;
|
|
30
36
|
debug?: TypicalDebugConfig;
|
|
@@ -34,12 +40,6 @@ interface TypicalConfig {
|
|
|
34
40
|
* Example: ["React.*", "Express.Request", "*.Event"]
|
|
35
41
|
*/
|
|
36
42
|
ignoreTypes?: string[];
|
|
37
|
-
/**
|
|
38
|
-
* Skip validation for DOM types (Document, Element, Node, etc.) and their subclasses.
|
|
39
|
-
* These types have complex Window intersections that typia cannot process.
|
|
40
|
-
* Default: true
|
|
41
|
-
*/
|
|
42
|
-
ignoreDOMTypes?: boolean;
|
|
43
43
|
/**
|
|
44
44
|
* Validate function parameters and return types at runtime.
|
|
45
45
|
* When enabled, typed function parameters get runtime validation calls injected.
|
|
@@ -63,6 +63,14 @@ interface TypicalConfig {
|
|
|
63
63
|
* Controls whether and how source maps are generated for transformed code.
|
|
64
64
|
*/
|
|
65
65
|
sourceMap?: TypicalSourceMapConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Maximum number of helper functions (_io0, _io1, etc.) that can be generated
|
|
68
|
+
* for a single type before erroring. Complex DOM types or library types can
|
|
69
|
+
* generate hundreds of functions which indicates a type that should be excluded.
|
|
70
|
+
* Set to 0 to disable the limit.
|
|
71
|
+
* Default: 50
|
|
72
|
+
*/
|
|
73
|
+
maxGeneratedFunctions?: number;
|
|
66
74
|
}
|
|
67
75
|
//#endregion
|
|
68
76
|
//#region src/core/options.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as Options, t as Typical } from "./index-
|
|
1
|
+
import { n as Options, t as Typical } from "./index-B05z7_Xb.mjs";
|
|
2
2
|
export { Options, Typical };
|
package/dist/index.mjs
CHANGED
package/dist/rolldown.d.mts
CHANGED
package/dist/rolldown.mjs
CHANGED
package/dist/rollup.d.mts
CHANGED
package/dist/rollup.mjs
CHANGED
package/dist/rspack.d.mts
CHANGED
package/dist/rspack.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const TRANSFORM_EXTENSIONS = new Set([
|
|
|
20
20
|
".mts",
|
|
21
21
|
".cts"
|
|
22
22
|
]);
|
|
23
|
+
const SKIP_ERROR_PATTERNS = ["source file not found"];
|
|
23
24
|
let transformer = null;
|
|
24
25
|
/**
|
|
25
26
|
* Transform a TypeScript file with Typical.
|
|
@@ -41,7 +42,19 @@ async function transformTypia(id, _source, config) {
|
|
|
41
42
|
buildTimer.end("init-transformer");
|
|
42
43
|
}
|
|
43
44
|
buildTimer.start("transform");
|
|
44
|
-
|
|
45
|
+
let result;
|
|
46
|
+
try {
|
|
47
|
+
result = await transformer.transform(resolvedId, "ts");
|
|
48
|
+
} catch (error) {
|
|
49
|
+
buildTimer.end("transform");
|
|
50
|
+
buildTimer.end("total-transform");
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
+
if (SKIP_ERROR_PATTERNS.some((pattern) => errorMessage.includes(pattern))) {
|
|
53
|
+
if (process.env.DEBUG) console.log(`[unplugin-typical] Skipping file (not in project): ${resolvedId}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
45
58
|
buildTimer.end("transform");
|
|
46
59
|
buildTimer.end("total-transform");
|
|
47
60
|
if (process.env.DEBUG) console.log("[unplugin-typical] Transform output (first 1000 chars):", result.code.substring(0, 1e3));
|
|
@@ -84,8 +97,15 @@ const Typical = createUnplugin((rawOptions = {}) => {
|
|
|
84
97
|
include: options.include,
|
|
85
98
|
exclude: options.exclude
|
|
86
99
|
} },
|
|
87
|
-
handler(code, id) {
|
|
88
|
-
|
|
100
|
+
async handler(code, id) {
|
|
101
|
+
const result = await transformTypia(id, code, typicalConfig);
|
|
102
|
+
if (process.env.DEBUG && result) {
|
|
103
|
+
console.log(`[unplugin-typical] Transformed ${id}:`);
|
|
104
|
+
console.log(` - Input length: ${code.length}`);
|
|
105
|
+
console.log(` - Output length: ${result.code.length}`);
|
|
106
|
+
console.log(` - Changed: ${code !== result.code}`);
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
89
109
|
}
|
|
90
110
|
}
|
|
91
111
|
};
|
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliots/unplugin-typical",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Unplugin for typical - runtime safe TypeScript transformer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"esbuild",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@elliots/typical": "0.2.
|
|
60
|
+
"@elliots/typical": "0.2.3",
|
|
61
61
|
"unplugin": "^2.3.11"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|