runtypex 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -69
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +7 -7
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -3
- package/package.json +67 -51
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
# 🛡️ runtypex
|
|
2
|
-
|
|
3
|
-
Runtime type guards compiled from your TypeScript types.
|
|
4
|
-
No schemas. No decorators. Just types → blazing-fast runtime checks.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Use
|
|
8
|
-
```ts
|
|
9
|
-
import { makeValidate, makeAssert } from "runtypex";
|
|
10
|
-
|
|
11
|
-
interface User { id: number; name: string; active: boolean; }
|
|
12
|
-
|
|
13
|
-
const isUser = makeValidate<User>();
|
|
14
|
-
const assertUser: ReturnType<typeof makeAssert<User>> = makeAssert<User>();
|
|
15
|
-
|
|
16
|
-
isUser({ id: 1, name: "Lux", active: true }); // true
|
|
17
|
-
assertUser({ id: "bad" }); // throws
|
|
18
|
-
toUser({ nope: true }); // → fallback
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Vite
|
|
22
|
-
```ts
|
|
23
|
-
// vite.config.ts
|
|
24
|
-
import { defineConfig } from "vite";
|
|
25
|
-
import { vitePlugin as runtypex } from "runtypex";
|
|
26
|
-
|
|
27
|
-
export default defineConfig({
|
|
28
|
-
plugins: [runtypex()],
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
To disable runtime checks in production builds, pass the option `{ removeInProd: true }` when initializing the Vite plugin.
|
|
33
|
-
```ts
|
|
34
|
-
// vite.config.ts
|
|
35
|
-
import { defineConfig } from "vite";
|
|
36
|
-
import { vitePlugin as runtypex } from "runtypex";
|
|
37
|
-
|
|
38
|
-
export default defineConfig({
|
|
39
|
-
plugins: [runtypex({ removeInProd: true })],
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Webpack (ts-loader)
|
|
44
|
-
```js
|
|
45
|
-
// webpack.config.js
|
|
46
|
-
const { tsTransformer } = require("runtypex/dist/ts-transformer.js");
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
49
|
-
module: {
|
|
50
|
-
rules: [
|
|
51
|
-
{
|
|
52
|
-
test: /\.tsx?$/,
|
|
53
|
-
loader: "ts-loader",
|
|
54
|
-
options: {
|
|
55
|
-
getCustomTransformers: (program) => ({
|
|
56
|
-
before: [ tsTransformer({ program }) ]
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Why runtypex?
|
|
66
|
-
- ⚡ **Fast**: compiled checks, no runtime schema walk
|
|
67
|
-
- 🧩 **Simple**: types only, no schema duplication
|
|
68
|
-
- 🧱 **Flexible**: Vite or Webpack
|
|
69
|
-
- 🛠️ **APIs**: `makeValidate`, `makeAssert`
|
|
1
|
+
# 🛡️ runtypex
|
|
2
|
+
|
|
3
|
+
Runtime type guards compiled from your TypeScript types.
|
|
4
|
+
No schemas. No decorators. Just types → blazing-fast runtime checks.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Use
|
|
8
|
+
```ts
|
|
9
|
+
import { makeValidate, makeAssert } from "runtypex";
|
|
10
|
+
|
|
11
|
+
interface User { id: number; name: string; active: boolean; }
|
|
12
|
+
|
|
13
|
+
const isUser = makeValidate<User>();
|
|
14
|
+
const assertUser: ReturnType<typeof makeAssert<User>> = makeAssert<User>();
|
|
15
|
+
|
|
16
|
+
isUser({ id: 1, name: "Lux", active: true }); // true
|
|
17
|
+
assertUser({ id: "bad" }); // throws
|
|
18
|
+
toUser({ nope: true }); // → fallback
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Vite
|
|
22
|
+
```ts
|
|
23
|
+
// vite.config.ts
|
|
24
|
+
import { defineConfig } from "vite";
|
|
25
|
+
import { vitePlugin as runtypex } from "runtypex";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [runtypex()],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To disable runtime checks in production builds, pass the option `{ removeInProd: true }` when initializing the Vite plugin.
|
|
33
|
+
```ts
|
|
34
|
+
// vite.config.ts
|
|
35
|
+
import { defineConfig } from "vite";
|
|
36
|
+
import { vitePlugin as runtypex } from "runtypex";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
plugins: [runtypex({ removeInProd: true })],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Webpack (ts-loader)
|
|
44
|
+
```js
|
|
45
|
+
// webpack.config.js
|
|
46
|
+
const { tsTransformer } = require("runtypex/dist/ts-transformer.js");
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
module: {
|
|
50
|
+
rules: [
|
|
51
|
+
{
|
|
52
|
+
test: /\.tsx?$/,
|
|
53
|
+
loader: "ts-loader",
|
|
54
|
+
options: {
|
|
55
|
+
getCustomTransformers: (program) => ({
|
|
56
|
+
before: [ tsTransformer({ program }) ]
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Why runtypex?
|
|
66
|
+
- ⚡ **Fast**: compiled checks, no runtime schema walk
|
|
67
|
+
- 🧩 **Simple**: types only, no schema duplication
|
|
68
|
+
- 🧱 **Flexible**: Vite or Webpack
|
|
69
|
+
- 🛠️ **APIs**: `makeValidate`, `makeAssert`
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { makeValidate, makeAssert, type ValidateFn } from "./runtime/validate
|
|
2
|
-
export { default as vitePlugin } from "./transformer/vite-plugin
|
|
3
|
-
export { default as tsTransformer } from "./transformer/ts-transformer
|
|
1
|
+
export { makeValidate, makeAssert, type ValidateFn } from "./runtime/validate";
|
|
2
|
+
export { default as vitePlugin } from "./transformer/vite-plugin";
|
|
3
|
+
export { default as tsTransformer } from "./transformer/ts-transformer";
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.tsTransformer = exports.vitePlugin = exports.makeAssert = exports.makeValidate = void 0;
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "makeValidate", { enumerable: true, get: function () { return
|
|
9
|
-
Object.defineProperty(exports, "makeAssert", { enumerable: true, get: function () { return
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "vitePlugin", { enumerable: true, get: function () { return __importDefault(
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "tsTransformer", { enumerable: true, get: function () { return __importDefault(
|
|
7
|
+
var validate_1 = require("./runtime/validate");
|
|
8
|
+
Object.defineProperty(exports, "makeValidate", { enumerable: true, get: function () { return validate_1.makeValidate; } });
|
|
9
|
+
Object.defineProperty(exports, "makeAssert", { enumerable: true, get: function () { return validate_1.makeAssert; } });
|
|
10
|
+
var vite_plugin_1 = require("./transformer/vite-plugin");
|
|
11
|
+
Object.defineProperty(exports, "vitePlugin", { enumerable: true, get: function () { return __importDefault(vite_plugin_1).default; } });
|
|
12
|
+
var ts_transformer_1 = require("./transformer/ts-transformer");
|
|
13
|
+
Object.defineProperty(exports, "tsTransformer", { enumerable: true, get: function () { return __importDefault(ts_transformer_1).default; } });
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { makeValidate, makeAssert, type ValidateFn } from "./runtime/validate
|
|
2
|
-
export { default as vitePlugin } from "./transformer/vite-plugin
|
|
3
|
-
export { default as tsTransformer } from "./transformer/ts-transformer
|
|
1
|
+
export { makeValidate, makeAssert, type ValidateFn } from "./runtime/validate";
|
|
2
|
+
export { default as vitePlugin } from "./transformer/vite-plugin";
|
|
3
|
+
export { default as tsTransformer } from "./transformer/ts-transformer";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { makeValidate, makeAssert } from "./runtime/validate
|
|
2
|
-
export { default as vitePlugin } from "./transformer/vite-plugin
|
|
3
|
-
export { default as tsTransformer } from "./transformer/ts-transformer
|
|
1
|
+
export { makeValidate, makeAssert } from "./runtime/validate";
|
|
2
|
+
export { default as vitePlugin } from "./transformer/vite-plugin";
|
|
3
|
+
export { default as tsTransformer } from "./transformer/ts-transformer";
|
package/package.json
CHANGED
|
@@ -1,51 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "runtypex",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Runtime type guards compiled from TypeScript types. Fast, zero-schema, transformer-based.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "
|
|
7
|
-
"type": "module",
|
|
8
|
-
"sideEffects": false,
|
|
9
|
-
"main": "./dist/cjs/index.js",
|
|
10
|
-
"module": "./dist/esm/index.js",
|
|
11
|
-
"types": "./dist/esm/index.d.ts",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://example.com/runtypex.git"
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
}
|
|
51
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "runtypex",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Runtime type guards compiled from TypeScript types. Fast, zero-schema, transformer-based.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "KumJunMin",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/cjs/index.js",
|
|
10
|
+
"module": "./dist/esm/index.js",
|
|
11
|
+
"types": "./dist/esm/index.d.ts",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://example.com/runtypex.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/KumJungMin/runtypex/issues"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/esm/index.js",
|
|
22
|
+
"require": "./dist/cjs/index.js",
|
|
23
|
+
"types": "./dist/esm/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./runtime": {
|
|
26
|
+
"import": "./dist/esm/runtime/index.js",
|
|
27
|
+
"require": "./dist/cjs/runtime/index.js",
|
|
28
|
+
"types": "./dist/esm/runtime/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./transformer": {
|
|
31
|
+
"import": "./dist/esm/transformer/index.js",
|
|
32
|
+
"require": "./dist/cjs/transformer/index.js",
|
|
33
|
+
"types": "./dist/esm/transformer/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"typescript",
|
|
38
|
+
"runtime",
|
|
39
|
+
"type-check",
|
|
40
|
+
"validation",
|
|
41
|
+
"vite-plugin",
|
|
42
|
+
"transformer",
|
|
43
|
+
"typia"
|
|
44
|
+
],
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"clean": "rm -rf dist",
|
|
53
|
+
"build": "tsc && tsc -p tsconfig.cjs.json",
|
|
54
|
+
"test": "jest --passWithNoTests"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"typescript": ">=5.3",
|
|
58
|
+
"vite": ">=4.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/jest": "^29.5.14",
|
|
62
|
+
"@types/node": "^22.8.0",
|
|
63
|
+
"jest": "^29.7.0",
|
|
64
|
+
"ts-jest": "^29.2.5",
|
|
65
|
+
"typescript": "^5.6.3"
|
|
66
|
+
}
|
|
67
|
+
}
|