@loydjs/vite 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,76 @@
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 __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ hasLoydImports: () => hasLoydImports,
24
+ loydPlugin: () => loydPlugin,
25
+ transformLoydImports: () => transformLoydImports
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/transform.ts
30
+ function hasLoydImports(source) {
31
+ return source.includes("@loydjs/schema") || source.includes("@loydjs/core") || source.includes("@loydjs/compiler");
32
+ }
33
+ function transformLoydImports(source, _filename, _options = {}) {
34
+ if (!hasLoydImports(source)) return null;
35
+ return { code: `/* @loydjs/vite: AOT-ready */
36
+ ${source}`, generatedFiles: [] };
37
+ }
38
+
39
+ // src/plugin.ts
40
+ function loydPlugin(options = {}) {
41
+ const { enabled = true, verbose = false, ...transformOptions } = options;
42
+ let transformedCount = 0;
43
+ return {
44
+ name: "loyd-vite-plugin",
45
+ enforce: "pre",
46
+ configResolved(config) {
47
+ if (verbose)
48
+ console.log(
49
+ `[@loydjs/vite] ${enabled ? "enabled" : "disabled"} \u2014 ${config.command === "build" ? "production (AOT)" : "development (JIT)"}`
50
+ );
51
+ },
52
+ transform(code, id) {
53
+ if (!enabled || !/\.[jt]sx?$/.test(id) || id.includes("node_modules") || !hasLoydImports(code))
54
+ return null;
55
+ const r = transformLoydImports(code, id, { ...transformOptions, verbose });
56
+ if (!r) return null;
57
+ transformedCount++;
58
+ if (verbose) console.log(`[@loydjs/vite] Transformed: ${id}`);
59
+ return { code: r.code, map: r.map };
60
+ },
61
+ buildEnd() {
62
+ if (enabled && verbose && transformedCount > 0)
63
+ console.log(`[@loydjs/vite] Transformed ${transformedCount} files`);
64
+ },
65
+ handleHotUpdate({ file }) {
66
+ if (enabled && verbose && hasLoydImports(file)) console.log(`[@loydjs/vite] HMR: ${file}`);
67
+ }
68
+ };
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ hasLoydImports,
73
+ loydPlugin,
74
+ transformLoydImports
75
+ });
76
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/transform.ts","../src/plugin.ts"],"sourcesContent":["export { loydPlugin } from \"./plugin.js\";\nexport type { LoydVitePluginOptions } from \"./plugin.js\";\nexport { hasLoydImports, transformLoydImports } from \"./transform.js\";\nexport type { AotTransformOptions, AotTransformResult } from \"./transform.js\";\n","export interface AotTransformOptions {\n outDir?: string;\n sourcemap?: boolean;\n include?: string[];\n exclude?: string[];\n verbose?: boolean;\n}\nexport interface AotTransformResult {\n code: string;\n map?: string;\n generatedFiles: string[];\n}\nexport type AotTransformFn = (\n source: string,\n filename: string,\n options?: AotTransformOptions,\n) => AotTransformResult | null;\nexport function hasLoydImports(source: string): boolean {\n return (\n source.includes(\"@loydjs/schema\") ||\n source.includes(\"@loydjs/core\") ||\n source.includes(\"@loydjs/compiler\")\n );\n}\nexport function transformLoydImports(\n source: string,\n _filename: string,\n _options: AotTransformOptions = {},\n): AotTransformResult | null {\n if (!hasLoydImports(source)) return null;\n return { code: `/* @loydjs/vite: AOT-ready */\\n${source}`, generatedFiles: [] };\n}\n","import { type AotTransformOptions, hasLoydImports, transformLoydImports } from \"./transform.js\";\nexport interface LoydVitePluginOptions extends AotTransformOptions {\n enabled?: boolean;\n verbose?: boolean;\n cacheDir?: string;\n}\nexport function loydPlugin(options: LoydVitePluginOptions = {}): unknown {\n const { enabled = true, verbose = false, ...transformOptions } = options;\n let transformedCount = 0;\n return {\n name: \"loyd-vite-plugin\",\n enforce: \"pre\" as const,\n configResolved(config: { command: string; mode: string }) {\n if (verbose)\n console.log(\n `[@loydjs/vite] ${enabled ? \"enabled\" : \"disabled\"} — ${config.command === \"build\" ? \"production (AOT)\" : \"development (JIT)\"}`,\n );\n },\n transform(code: string, id: string): { code: string; map?: string } | null {\n if (\n !enabled ||\n !/\\.[jt]sx?$/.test(id) ||\n id.includes(\"node_modules\") ||\n !hasLoydImports(code)\n )\n return null;\n const r = transformLoydImports(code, id, { ...transformOptions, verbose });\n if (!r) return null;\n transformedCount++;\n if (verbose) console.log(`[@loydjs/vite] Transformed: ${id}`);\n return { code: r.code, map: r.map };\n },\n buildEnd() {\n if (enabled && verbose && transformedCount > 0)\n console.log(`[@loydjs/vite] Transformed ${transformedCount} files`);\n },\n handleHotUpdate({ file }: { file: string }) {\n if (enabled && verbose && hasLoydImports(file)) console.log(`[@loydjs/vite] HMR: ${file}`);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,SAAS,eAAe,QAAyB;AACtD,SACE,OAAO,SAAS,gBAAgB,KAChC,OAAO,SAAS,cAAc,KAC9B,OAAO,SAAS,kBAAkB;AAEtC;AACO,SAAS,qBACd,QACA,WACA,WAAgC,CAAC,GACN;AAC3B,MAAI,CAAC,eAAe,MAAM,EAAG,QAAO;AACpC,SAAO,EAAE,MAAM;AAAA,EAAkC,MAAM,IAAI,gBAAgB,CAAC,EAAE;AAChF;;;ACzBO,SAAS,WAAW,UAAiC,CAAC,GAAY;AACvE,QAAM,EAAE,UAAU,MAAM,UAAU,OAAO,GAAG,iBAAiB,IAAI;AACjE,MAAI,mBAAmB;AACvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,eAAe,QAA2C;AACxD,UAAI;AACF,gBAAQ;AAAA,UACN,kBAAkB,UAAU,YAAY,UAAU,WAAM,OAAO,YAAY,UAAU,qBAAqB,mBAAmB;AAAA,QAC/H;AAAA,IACJ;AAAA,IACA,UAAU,MAAc,IAAmD;AACzE,UACE,CAAC,WACD,CAAC,aAAa,KAAK,EAAE,KACrB,GAAG,SAAS,cAAc,KAC1B,CAAC,eAAe,IAAI;AAEpB,eAAO;AACT,YAAM,IAAI,qBAAqB,MAAM,IAAI,EAAE,GAAG,kBAAkB,QAAQ,CAAC;AACzE,UAAI,CAAC,EAAG,QAAO;AACf;AACA,UAAI,QAAS,SAAQ,IAAI,+BAA+B,EAAE,EAAE;AAC5D,aAAO,EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,IAAI;AAAA,IACpC;AAAA,IACA,WAAW;AACT,UAAI,WAAW,WAAW,mBAAmB;AAC3C,gBAAQ,IAAI,8BAA8B,gBAAgB,QAAQ;AAAA,IACtE;AAAA,IACA,gBAAgB,EAAE,KAAK,GAAqB;AAC1C,UAAI,WAAW,WAAW,eAAe,IAAI,EAAG,SAAQ,IAAI,uBAAuB,IAAI,EAAE;AAAA,IAC3F;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,23 @@
1
+ interface AotTransformOptions {
2
+ outDir?: string;
3
+ sourcemap?: boolean;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ verbose?: boolean;
7
+ }
8
+ interface AotTransformResult {
9
+ code: string;
10
+ map?: string;
11
+ generatedFiles: string[];
12
+ }
13
+ declare function hasLoydImports(source: string): boolean;
14
+ declare function transformLoydImports(source: string, _filename: string, _options?: AotTransformOptions): AotTransformResult | null;
15
+
16
+ interface LoydVitePluginOptions extends AotTransformOptions {
17
+ enabled?: boolean;
18
+ verbose?: boolean;
19
+ cacheDir?: string;
20
+ }
21
+ declare function loydPlugin(options?: LoydVitePluginOptions): unknown;
22
+
23
+ export { type AotTransformOptions, type AotTransformResult, type LoydVitePluginOptions, hasLoydImports, loydPlugin, transformLoydImports };
@@ -0,0 +1,23 @@
1
+ interface AotTransformOptions {
2
+ outDir?: string;
3
+ sourcemap?: boolean;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ verbose?: boolean;
7
+ }
8
+ interface AotTransformResult {
9
+ code: string;
10
+ map?: string;
11
+ generatedFiles: string[];
12
+ }
13
+ declare function hasLoydImports(source: string): boolean;
14
+ declare function transformLoydImports(source: string, _filename: string, _options?: AotTransformOptions): AotTransformResult | null;
15
+
16
+ interface LoydVitePluginOptions extends AotTransformOptions {
17
+ enabled?: boolean;
18
+ verbose?: boolean;
19
+ cacheDir?: string;
20
+ }
21
+ declare function loydPlugin(options?: LoydVitePluginOptions): unknown;
22
+
23
+ export { type AotTransformOptions, type AotTransformResult, type LoydVitePluginOptions, hasLoydImports, loydPlugin, transformLoydImports };
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ // src/transform.ts
2
+ function hasLoydImports(source) {
3
+ return source.includes("@loydjs/schema") || source.includes("@loydjs/core") || source.includes("@loydjs/compiler");
4
+ }
5
+ function transformLoydImports(source, _filename, _options = {}) {
6
+ if (!hasLoydImports(source)) return null;
7
+ return { code: `/* @loydjs/vite: AOT-ready */
8
+ ${source}`, generatedFiles: [] };
9
+ }
10
+
11
+ // src/plugin.ts
12
+ function loydPlugin(options = {}) {
13
+ const { enabled = true, verbose = false, ...transformOptions } = options;
14
+ let transformedCount = 0;
15
+ return {
16
+ name: "loyd-vite-plugin",
17
+ enforce: "pre",
18
+ configResolved(config) {
19
+ if (verbose)
20
+ console.log(
21
+ `[@loydjs/vite] ${enabled ? "enabled" : "disabled"} \u2014 ${config.command === "build" ? "production (AOT)" : "development (JIT)"}`
22
+ );
23
+ },
24
+ transform(code, id) {
25
+ if (!enabled || !/\.[jt]sx?$/.test(id) || id.includes("node_modules") || !hasLoydImports(code))
26
+ return null;
27
+ const r = transformLoydImports(code, id, { ...transformOptions, verbose });
28
+ if (!r) return null;
29
+ transformedCount++;
30
+ if (verbose) console.log(`[@loydjs/vite] Transformed: ${id}`);
31
+ return { code: r.code, map: r.map };
32
+ },
33
+ buildEnd() {
34
+ if (enabled && verbose && transformedCount > 0)
35
+ console.log(`[@loydjs/vite] Transformed ${transformedCount} files`);
36
+ },
37
+ handleHotUpdate({ file }) {
38
+ if (enabled && verbose && hasLoydImports(file)) console.log(`[@loydjs/vite] HMR: ${file}`);
39
+ }
40
+ };
41
+ }
42
+ export {
43
+ hasLoydImports,
44
+ loydPlugin,
45
+ transformLoydImports
46
+ };
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transform.ts","../src/plugin.ts"],"sourcesContent":["export interface AotTransformOptions {\n outDir?: string;\n sourcemap?: boolean;\n include?: string[];\n exclude?: string[];\n verbose?: boolean;\n}\nexport interface AotTransformResult {\n code: string;\n map?: string;\n generatedFiles: string[];\n}\nexport type AotTransformFn = (\n source: string,\n filename: string,\n options?: AotTransformOptions,\n) => AotTransformResult | null;\nexport function hasLoydImports(source: string): boolean {\n return (\n source.includes(\"@loydjs/schema\") ||\n source.includes(\"@loydjs/core\") ||\n source.includes(\"@loydjs/compiler\")\n );\n}\nexport function transformLoydImports(\n source: string,\n _filename: string,\n _options: AotTransformOptions = {},\n): AotTransformResult | null {\n if (!hasLoydImports(source)) return null;\n return { code: `/* @loydjs/vite: AOT-ready */\\n${source}`, generatedFiles: [] };\n}\n","import { type AotTransformOptions, hasLoydImports, transformLoydImports } from \"./transform.js\";\nexport interface LoydVitePluginOptions extends AotTransformOptions {\n enabled?: boolean;\n verbose?: boolean;\n cacheDir?: string;\n}\nexport function loydPlugin(options: LoydVitePluginOptions = {}): unknown {\n const { enabled = true, verbose = false, ...transformOptions } = options;\n let transformedCount = 0;\n return {\n name: \"loyd-vite-plugin\",\n enforce: \"pre\" as const,\n configResolved(config: { command: string; mode: string }) {\n if (verbose)\n console.log(\n `[@loydjs/vite] ${enabled ? \"enabled\" : \"disabled\"} — ${config.command === \"build\" ? \"production (AOT)\" : \"development (JIT)\"}`,\n );\n },\n transform(code: string, id: string): { code: string; map?: string } | null {\n if (\n !enabled ||\n !/\\.[jt]sx?$/.test(id) ||\n id.includes(\"node_modules\") ||\n !hasLoydImports(code)\n )\n return null;\n const r = transformLoydImports(code, id, { ...transformOptions, verbose });\n if (!r) return null;\n transformedCount++;\n if (verbose) console.log(`[@loydjs/vite] Transformed: ${id}`);\n return { code: r.code, map: r.map };\n },\n buildEnd() {\n if (enabled && verbose && transformedCount > 0)\n console.log(`[@loydjs/vite] Transformed ${transformedCount} files`);\n },\n handleHotUpdate({ file }: { file: string }) {\n if (enabled && verbose && hasLoydImports(file)) console.log(`[@loydjs/vite] HMR: ${file}`);\n },\n };\n}\n"],"mappings":";AAiBO,SAAS,eAAe,QAAyB;AACtD,SACE,OAAO,SAAS,gBAAgB,KAChC,OAAO,SAAS,cAAc,KAC9B,OAAO,SAAS,kBAAkB;AAEtC;AACO,SAAS,qBACd,QACA,WACA,WAAgC,CAAC,GACN;AAC3B,MAAI,CAAC,eAAe,MAAM,EAAG,QAAO;AACpC,SAAO,EAAE,MAAM;AAAA,EAAkC,MAAM,IAAI,gBAAgB,CAAC,EAAE;AAChF;;;ACzBO,SAAS,WAAW,UAAiC,CAAC,GAAY;AACvE,QAAM,EAAE,UAAU,MAAM,UAAU,OAAO,GAAG,iBAAiB,IAAI;AACjE,MAAI,mBAAmB;AACvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,eAAe,QAA2C;AACxD,UAAI;AACF,gBAAQ;AAAA,UACN,kBAAkB,UAAU,YAAY,UAAU,WAAM,OAAO,YAAY,UAAU,qBAAqB,mBAAmB;AAAA,QAC/H;AAAA,IACJ;AAAA,IACA,UAAU,MAAc,IAAmD;AACzE,UACE,CAAC,WACD,CAAC,aAAa,KAAK,EAAE,KACrB,GAAG,SAAS,cAAc,KAC1B,CAAC,eAAe,IAAI;AAEpB,eAAO;AACT,YAAM,IAAI,qBAAqB,MAAM,IAAI,EAAE,GAAG,kBAAkB,QAAQ,CAAC;AACzE,UAAI,CAAC,EAAG,QAAO;AACf;AACA,UAAI,QAAS,SAAQ,IAAI,+BAA+B,EAAE,EAAE;AAC5D,aAAO,EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,IAAI;AAAA,IACpC;AAAA,IACA,WAAW;AACT,UAAI,WAAW,WAAW,mBAAmB;AAC3C,gBAAQ,IAAI,8BAA8B,gBAAgB,QAAQ;AAAA,IACtE;AAAA,IACA,gBAAgB,EAAE,KAAK,GAAqB;AAC1C,UAAI,WAAW,WAAW,eAAe,IAAI,EAAG,SAAQ,IAAI,uBAAuB,IAAI,EAAE;AAAA,IAC3F;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@loydjs/vite",
3
+ "version": "0.0.0",
4
+ "description": "Loyd vite — Vite/Rollup AOT plugin",
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
+ "peerDependencies": {
38
+ "vite": ">=5.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "vite": "^5.4.11",
42
+ "typescript": "^5.7.2",
43
+ "tsup": "^8.3.5",
44
+ "vitest": "^2.1.8"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup",
51
+ "dev": "tsup --watch",
52
+ "typecheck": "tsc --noEmit",
53
+ "test": "vitest run",
54
+ "test:watch": "vitest",
55
+ "bench": "echo no benchmarks",
56
+ "clean": "rm -rf dist *.tsbuildinfo"
57
+ }
58
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { loydPlugin } from "./plugin.js";
2
+ export type { LoydVitePluginOptions } from "./plugin.js";
3
+ export { hasLoydImports, transformLoydImports } from "./transform.js";
4
+ export type { AotTransformOptions, AotTransformResult } from "./transform.js";
package/src/plugin.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { type AotTransformOptions, hasLoydImports, transformLoydImports } from "./transform.js";
2
+ export interface LoydVitePluginOptions extends AotTransformOptions {
3
+ enabled?: boolean;
4
+ verbose?: boolean;
5
+ cacheDir?: string;
6
+ }
7
+ export function loydPlugin(options: LoydVitePluginOptions = {}): unknown {
8
+ const { enabled = true, verbose = false, ...transformOptions } = options;
9
+ let transformedCount = 0;
10
+ return {
11
+ name: "loyd-vite-plugin",
12
+ enforce: "pre" as const,
13
+ configResolved(config: { command: string; mode: string }) {
14
+ if (verbose)
15
+ console.log(
16
+ `[@loydjs/vite] ${enabled ? "enabled" : "disabled"} — ${config.command === "build" ? "production (AOT)" : "development (JIT)"}`,
17
+ );
18
+ },
19
+ transform(code: string, id: string): { code: string; map?: string } | null {
20
+ if (
21
+ !enabled ||
22
+ !/\.[jt]sx?$/.test(id) ||
23
+ id.includes("node_modules") ||
24
+ !hasLoydImports(code)
25
+ )
26
+ return null;
27
+ const r = transformLoydImports(code, id, { ...transformOptions, verbose });
28
+ if (!r) return null;
29
+ transformedCount++;
30
+ if (verbose) console.log(`[@loydjs/vite] Transformed: ${id}`);
31
+ return { code: r.code, map: r.map };
32
+ },
33
+ buildEnd() {
34
+ if (enabled && verbose && transformedCount > 0)
35
+ console.log(`[@loydjs/vite] Transformed ${transformedCount} files`);
36
+ },
37
+ handleHotUpdate({ file }: { file: string }) {
38
+ if (enabled && verbose && hasLoydImports(file)) console.log(`[@loydjs/vite] HMR: ${file}`);
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,32 @@
1
+ export interface AotTransformOptions {
2
+ outDir?: string;
3
+ sourcemap?: boolean;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ verbose?: boolean;
7
+ }
8
+ export interface AotTransformResult {
9
+ code: string;
10
+ map?: string;
11
+ generatedFiles: string[];
12
+ }
13
+ export type AotTransformFn = (
14
+ source: string,
15
+ filename: string,
16
+ options?: AotTransformOptions,
17
+ ) => AotTransformResult | null;
18
+ export function hasLoydImports(source: string): boolean {
19
+ return (
20
+ source.includes("@loydjs/schema") ||
21
+ source.includes("@loydjs/core") ||
22
+ source.includes("@loydjs/compiler")
23
+ );
24
+ }
25
+ export function transformLoydImports(
26
+ source: string,
27
+ _filename: string,
28
+ _options: AotTransformOptions = {},
29
+ ): AotTransformResult | null {
30
+ if (!hasLoydImports(source)) return null;
31
+ return { code: `/* @loydjs/vite: AOT-ready */\n${source}`, generatedFiles: [] };
32
+ }