@loydjs/runtime 0.0.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/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { RuntimeMode, ExecutorOptions, Executor } from \"./executor.js\";\nexport { createExecutor, defaultExecutor } from \"./executor.js\";\n\nexport type { ModeConfig } from \"./mode.js\";\nexport { getModeConfig } from \"./mode.js\";\n\nexport { deepFreeze, isDeepFrozen } from \"./freeze.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,41 @@
1
+ import { LoydSchema, LoydResult } from '@loydjs/core';
2
+
3
+ type RuntimeMode = "strict" | "strip" | "passthrough";
4
+ interface ExecutorOptions {
5
+ mode?: RuntimeMode;
6
+ /**
7
+ * @default false
8
+ */
9
+ freeze?: boolean;
10
+ /**
11
+ * @default false
12
+ */
13
+ zeroCopy?: boolean;
14
+ }
15
+ /**
16
+ * Creates an optimized executor with fixed options.
17
+ * More efficient than going through the options on every call.
18
+ * @example
19
+ * const executor = createExecutor({ mode: "strict", freeze: true });
20
+ * const result = executor.run(UserSchema, rawInput);
21
+ */
22
+ interface Executor {
23
+ run<T>(schema: LoydSchema<T>, input: unknown): LoydResult<T>;
24
+ runOrThrow<T>(schema: LoydSchema<T>, input: unknown): T;
25
+ readonly options: Required<ExecutorOptions>;
26
+ }
27
+ declare function createExecutor(options?: ExecutorOptions): Executor;
28
+ /** Default executor (mode: "strip", freeze: false, zeroCopy: false) */
29
+ declare const defaultExecutor: Executor;
30
+
31
+ interface ModeConfig {
32
+ stripUnknownKeys: boolean;
33
+ errorOnUnknownKeys: boolean;
34
+ passthroughUnknownKeys: boolean;
35
+ }
36
+ declare function getModeConfig(mode: RuntimeMode): ModeConfig;
37
+
38
+ declare function deepFreeze<T>(value: T): Readonly<T>;
39
+ declare function isDeepFrozen(value: unknown): boolean;
40
+
41
+ export { type Executor, type ExecutorOptions, type ModeConfig, type RuntimeMode, createExecutor, deepFreeze, defaultExecutor, getModeConfig, isDeepFrozen };
@@ -0,0 +1,41 @@
1
+ import { LoydSchema, LoydResult } from '@loydjs/core';
2
+
3
+ type RuntimeMode = "strict" | "strip" | "passthrough";
4
+ interface ExecutorOptions {
5
+ mode?: RuntimeMode;
6
+ /**
7
+ * @default false
8
+ */
9
+ freeze?: boolean;
10
+ /**
11
+ * @default false
12
+ */
13
+ zeroCopy?: boolean;
14
+ }
15
+ /**
16
+ * Creates an optimized executor with fixed options.
17
+ * More efficient than going through the options on every call.
18
+ * @example
19
+ * const executor = createExecutor({ mode: "strict", freeze: true });
20
+ * const result = executor.run(UserSchema, rawInput);
21
+ */
22
+ interface Executor {
23
+ run<T>(schema: LoydSchema<T>, input: unknown): LoydResult<T>;
24
+ runOrThrow<T>(schema: LoydSchema<T>, input: unknown): T;
25
+ readonly options: Required<ExecutorOptions>;
26
+ }
27
+ declare function createExecutor(options?: ExecutorOptions): Executor;
28
+ /** Default executor (mode: "strip", freeze: false, zeroCopy: false) */
29
+ declare const defaultExecutor: Executor;
30
+
31
+ interface ModeConfig {
32
+ stripUnknownKeys: boolean;
33
+ errorOnUnknownKeys: boolean;
34
+ passthroughUnknownKeys: boolean;
35
+ }
36
+ declare function getModeConfig(mode: RuntimeMode): ModeConfig;
37
+
38
+ declare function deepFreeze<T>(value: T): Readonly<T>;
39
+ declare function isDeepFrozen(value: unknown): boolean;
40
+
41
+ export { type Executor, type ExecutorOptions, type ModeConfig, type RuntimeMode, createExecutor, deepFreeze, defaultExecutor, getModeConfig, isDeepFrozen };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@loydjs/runtime",
3
+ "version": "0.0.0",
4
+ "description": "Loyd runtime — zero-copy execution engine",
5
+ "keywords": [
6
+ "loyd",
7
+ "validation",
8
+ "typescript",
9
+ "schema"
10
+ ],
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "require": {
23
+ "types": "./dist/index.d.cts",
24
+ "default": "./dist/index.cjs"
25
+ }
26
+ }
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "src"
31
+ ],
32
+ "sideEffects": false,
33
+ "dependencies": {
34
+ "@loydjs/core": "0.0.0",
35
+ "@loydjs/compiler": "0.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^5.7.2",
39
+ "tsup": "^8.3.5",
40
+ "vitest": "^2.1.8"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "dev": "tsup --watch",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest",
51
+ "bench": "vitest bench",
52
+ "clean": "rm -rf dist *.tsbuildinfo"
53
+ }
54
+ }
@@ -0,0 +1,33 @@
1
+ import type { LoydResult, LoydSchema } from "@loydjs/core";
2
+
3
+ export type RuntimeMode = "strict" | "strip" | "passthrough";
4
+
5
+ export interface ExecutorOptions {
6
+ mode?: RuntimeMode;
7
+ /**
8
+ * @default false
9
+ */
10
+ freeze?: boolean;
11
+ /**
12
+ * @default false
13
+ */
14
+ zeroCopy?: boolean;
15
+ }
16
+
17
+ /**
18
+ * Creates an optimized executor with fixed options.
19
+ * More efficient than going through the options on every call.
20
+ * @example
21
+ * const executor = createExecutor({ mode: "strict", freeze: true });
22
+ * const result = executor.run(UserSchema, rawInput);
23
+ */
24
+ export interface Executor {
25
+ run<T>(schema: LoydSchema<T>, input: unknown): LoydResult<T>;
26
+ runOrThrow<T>(schema: LoydSchema<T>, input: unknown): T;
27
+ readonly options: Required<ExecutorOptions>;
28
+ }
29
+
30
+ export declare function createExecutor(options?: ExecutorOptions): Executor;
31
+
32
+ /** Default executor (mode: "strip", freeze: false, zeroCopy: false) */
33
+ export declare const defaultExecutor: Executor;
package/src/freeze.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function deepFreeze<T>(value: T): Readonly<T>;
2
+ export declare function isDeepFrozen(value: unknown): boolean;
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export type { RuntimeMode, ExecutorOptions, Executor } from "./executor.js";
2
+ export { createExecutor, defaultExecutor } from "./executor.js";
3
+
4
+ export type { ModeConfig } from "./mode.js";
5
+ export { getModeConfig } from "./mode.js";
6
+
7
+ export { deepFreeze, isDeepFrozen } from "./freeze.js";
package/src/mode.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { RuntimeMode } from "./executor.js";
2
+ export interface ModeConfig {
3
+ stripUnknownKeys: boolean;
4
+ errorOnUnknownKeys: boolean;
5
+ passthroughUnknownKeys: boolean;
6
+ }
7
+
8
+ export declare function getModeConfig(mode: RuntimeMode): ModeConfig;