litestar-vite-plugin 0.24.1 → 0.26.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/README.md +6 -6
- package/dist/js/astro.d.ts +6 -0
- package/dist/js/astro.js +14 -77
- package/dist/js/dev-server-index.html +2 -2
- package/dist/js/helpers/csrf.d.ts +2 -0
- package/dist/js/helpers/csrf.js +28 -1
- package/dist/js/helpers/htmx.js +105 -2
- package/dist/js/index.d.ts +6 -0
- package/dist/js/index.js +75 -128
- package/dist/js/inertia-helpers/index.d.ts +27 -9
- package/dist/js/install-hint.d.ts +17 -0
- package/dist/js/install-hint.js +35 -1
- package/dist/js/nuxt.d.ts +6 -0
- package/dist/js/nuxt.js +12 -72
- package/dist/js/shared/bridge-schema.d.ts +1 -0
- package/dist/js/shared/bridge-schema.js +41 -9
- package/dist/js/shared/constants.d.ts +4 -18
- package/dist/js/shared/constants.js +2 -6
- package/dist/js/shared/emit-page-props-types.d.ts +1 -1
- package/dist/js/shared/emit-page-props-types.js +51 -5
- package/dist/js/shared/emit-schemas-types.d.ts +1 -1
- package/dist/js/shared/emit-schemas-types.js +86 -15
- package/dist/js/shared/emit-static-props-types.d.ts +1 -1
- package/dist/js/shared/emit-static-props-types.js +2 -2
- package/dist/js/shared/typegen-cache.d.ts +10 -11
- package/dist/js/shared/typegen-cache.js +10 -1
- package/dist/js/shared/typegen-core.d.ts +24 -0
- package/dist/js/shared/typegen-core.js +101 -45
- package/dist/js/shared/typegen-plugin.d.ts +26 -0
- package/dist/js/shared/typegen-plugin.js +191 -129
- package/dist/js/shared/vite-compat.d.ts +23 -15
- package/dist/js/shared/vite-compat.js +12 -6
- package/dist/js/sveltekit.d.ts +6 -0
- package/dist/js/sveltekit.js +14 -77
- package/package.json +14 -8
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parsed major version of the running Vite instance.
|
|
3
|
-
*/
|
|
1
|
+
/** Parsed major version of the running Vite instance. */
|
|
4
2
|
export declare const viteMajor: number;
|
|
3
|
+
/** Parsed minor version of the running Vite instance. */
|
|
4
|
+
export declare const viteMinor: number;
|
|
5
5
|
/**
|
|
6
|
-
* Whether the running Vite version is 8+, which uses Rolldown
|
|
7
|
-
*
|
|
8
|
-
* in place of the deprecated `rollupOptions` / `esbuildOptions`.
|
|
6
|
+
* Whether the running Vite version is 8+, which uses Rolldown and exposes
|
|
7
|
+
* `build.rolldownOptions` in place of Vite 7's `build.rollupOptions`.
|
|
9
8
|
*/
|
|
10
9
|
export declare const isVite8Plus: boolean;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
* Whether the running Vite version is 8.1+, which moved the HMR network options
|
|
12
|
+
* (`host`/`protocol`/`port`/`clientPort`/`path`/`timeout`) from `server.hmr.*`
|
|
13
|
+
* to `server.ws.*`. On 8.1+ `server.hmr` only carries the enable/disable toggle.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isVite81Plus: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a `build` config fragment with the input placed under the bundler key
|
|
18
|
+
* for the running Vite version (`rolldownOptions` on 8+, `rollupOptions` on 7).
|
|
17
19
|
*/
|
|
18
20
|
export declare function buildInputOptions(input: string | string[] | undefined): Record<string, unknown>;
|
|
19
21
|
/**
|
|
20
|
-
* Reads the user-provided
|
|
21
|
-
*
|
|
22
|
+
* Reads the user-provided build input, preferring the version-appropriate key
|
|
23
|
+
* and falling back to the other so configs migrated across a Vite major still work.
|
|
22
24
|
*/
|
|
23
25
|
export declare function resolveUserBuildInput(userBuild: Record<string, any> | undefined): string | string[] | undefined;
|
|
24
26
|
/**
|
|
25
|
-
* Returns a `build` config fragment with arbitrary options placed under
|
|
26
|
-
*
|
|
27
|
+
* Returns a `build` config fragment with arbitrary options placed under the
|
|
28
|
+
* bundler key for the running Vite version.
|
|
27
29
|
*/
|
|
28
30
|
export declare function buildBundlerOptions(options: Record<string, unknown>): Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Wraps HMR network options under the correct server key for the running Vite
|
|
33
|
+
* version: `server.ws` on 8.1+, `server.hmr` on 8.0 / 7. Lets the plugin and
|
|
34
|
+
* integrations emit one shape that is deprecation-free on every supported Vite.
|
|
35
|
+
*/
|
|
36
|
+
export declare function hmrServerConfig(network: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { version } from "vite";
|
|
2
|
-
const
|
|
2
|
+
const [viteMajorRaw, viteMinorRaw] = version.split(".");
|
|
3
|
+
const viteMajor = Number(viteMajorRaw);
|
|
4
|
+
const viteMinor = Number(viteMinorRaw);
|
|
3
5
|
const isVite8Plus = viteMajor >= 8;
|
|
6
|
+
const isVite81Plus = viteMajor > 8 || viteMajor === 8 && viteMinor >= 1;
|
|
4
7
|
function buildInputOptions(input) {
|
|
5
8
|
if (input === void 0) return {};
|
|
6
9
|
const key = isVite8Plus ? "rolldownOptions" : "rollupOptions";
|
|
@@ -8,19 +11,22 @@ function buildInputOptions(input) {
|
|
|
8
11
|
}
|
|
9
12
|
function resolveUserBuildInput(userBuild) {
|
|
10
13
|
if (!userBuild) return void 0;
|
|
11
|
-
|
|
12
|
-
return userBuild.rolldownOptions?.input ?? userBuild.rollupOptions?.input;
|
|
13
|
-
}
|
|
14
|
-
return userBuild.rollupOptions?.input ?? userBuild.rolldownOptions?.input;
|
|
14
|
+
return isVite8Plus ? userBuild.rolldownOptions?.input ?? userBuild.rollupOptions?.input : userBuild.rollupOptions?.input ?? userBuild.rolldownOptions?.input;
|
|
15
15
|
}
|
|
16
16
|
function buildBundlerOptions(options) {
|
|
17
17
|
const key = isVite8Plus ? "rolldownOptions" : "rollupOptions";
|
|
18
18
|
return { [key]: options };
|
|
19
19
|
}
|
|
20
|
+
function hmrServerConfig(network) {
|
|
21
|
+
return isVite81Plus ? { ws: network } : { hmr: network };
|
|
22
|
+
}
|
|
20
23
|
export {
|
|
21
24
|
buildBundlerOptions,
|
|
22
25
|
buildInputOptions,
|
|
26
|
+
hmrServerConfig,
|
|
27
|
+
isVite81Plus,
|
|
23
28
|
isVite8Plus,
|
|
24
29
|
resolveUserBuildInput,
|
|
25
|
-
viteMajor
|
|
30
|
+
viteMajor,
|
|
31
|
+
viteMinor
|
|
26
32
|
};
|
package/dist/js/sveltekit.d.ts
CHANGED
|
@@ -104,6 +104,12 @@ export interface SvelteKitTypesConfig {
|
|
|
104
104
|
* @default false
|
|
105
105
|
*/
|
|
106
106
|
globalRoute?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Fail Vite when type generation fails.
|
|
109
|
+
*
|
|
110
|
+
* Defaults to true during build and false during dev.
|
|
111
|
+
*/
|
|
112
|
+
failOnError?: boolean;
|
|
107
113
|
/**
|
|
108
114
|
* Debounce time in milliseconds for type regeneration.
|
|
109
115
|
*
|
package/dist/js/sveltekit.js
CHANGED
|
@@ -2,9 +2,9 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import colors from "picocolors";
|
|
4
4
|
import { readBridgeConfig } from "./shared/bridge-schema.js";
|
|
5
|
-
import { DEBOUNCE_MS } from "./shared/constants.js";
|
|
6
5
|
import { normalizeHost, resolveHotFilePath, resolveLitestarPort } from "./shared/network.js";
|
|
7
|
-
import { createLitestarTypeGenPlugin } from "./shared/typegen-plugin.js";
|
|
6
|
+
import { createLitestarTypeGenPlugin, resolveTypesConfig } from "./shared/typegen-plugin.js";
|
|
7
|
+
import { hmrServerConfig } from "./shared/vite-compat.js";
|
|
8
8
|
function resolveConfig(config = {}) {
|
|
9
9
|
let hotFile;
|
|
10
10
|
let proxyMode = "vite";
|
|
@@ -38,74 +38,13 @@ function resolveConfig(config = {}) {
|
|
|
38
38
|
if (resolvedLitestarPort !== null) {
|
|
39
39
|
litestarPort = resolvedLitestarPort;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
schemasTsPath: path.join(output, "schemas.ts")
|
|
41
|
+
const typesConfig = resolveTypesConfig({
|
|
42
|
+
requested: config.types,
|
|
43
|
+
pythonConfig: pythonTypesConfig ?? void 0,
|
|
44
|
+
defaultOutput: "src/lib/generated",
|
|
45
|
+
mergePythonWhenTrue: true,
|
|
46
|
+
mergePythonForObject: true
|
|
48
47
|
});
|
|
49
|
-
if (config.types === true) {
|
|
50
|
-
const output = pythonTypesConfig?.output ?? defaultTypesOutput;
|
|
51
|
-
const defaults = buildTypeDefaults(output);
|
|
52
|
-
typesConfig = {
|
|
53
|
-
enabled: true,
|
|
54
|
-
output,
|
|
55
|
-
openapiPath: pythonTypesConfig?.openapiPath ?? defaults.openapiPath,
|
|
56
|
-
routesPath: pythonTypesConfig?.routesPath ?? defaults.routesPath,
|
|
57
|
-
pagePropsPath: pythonTypesConfig?.pagePropsPath ?? defaults.pagePropsPath,
|
|
58
|
-
schemasTsPath: pythonTypesConfig?.schemasTsPath ?? defaults.schemasTsPath,
|
|
59
|
-
generateZod: pythonTypesConfig?.generateZod ?? false,
|
|
60
|
-
generateSdk: pythonTypesConfig?.generateSdk ?? true,
|
|
61
|
-
generateRoutes: pythonTypesConfig?.generateRoutes ?? true,
|
|
62
|
-
generatePageProps: pythonTypesConfig?.generatePageProps ?? true,
|
|
63
|
-
generateSchemas: pythonTypesConfig?.generateSchemas ?? true,
|
|
64
|
-
globalRoute: pythonTypesConfig?.globalRoute ?? false,
|
|
65
|
-
debounce: DEBOUNCE_MS
|
|
66
|
-
};
|
|
67
|
-
} else if (typeof config.types === "object" && config.types !== null) {
|
|
68
|
-
const userProvidedOutput = Object.hasOwn(config.types, "output");
|
|
69
|
-
const output = config.types.output ?? pythonTypesConfig?.output ?? defaultTypesOutput;
|
|
70
|
-
const defaults = buildTypeDefaults(output);
|
|
71
|
-
const openapiFallback = userProvidedOutput ? defaults.openapiPath : pythonTypesConfig?.openapiPath ?? defaults.openapiPath;
|
|
72
|
-
const routesFallback = userProvidedOutput ? defaults.routesPath : pythonTypesConfig?.routesPath ?? defaults.routesPath;
|
|
73
|
-
const pagePropsFallback = userProvidedOutput ? defaults.pagePropsPath : pythonTypesConfig?.pagePropsPath ?? defaults.pagePropsPath;
|
|
74
|
-
const schemasFallback = userProvidedOutput ? defaults.schemasTsPath : pythonTypesConfig?.schemasTsPath ?? defaults.schemasTsPath;
|
|
75
|
-
typesConfig = {
|
|
76
|
-
enabled: config.types.enabled ?? true,
|
|
77
|
-
output,
|
|
78
|
-
openapiPath: config.types.openapiPath ?? openapiFallback,
|
|
79
|
-
routesPath: config.types.routesPath ?? routesFallback,
|
|
80
|
-
pagePropsPath: config.types.pagePropsPath ?? pagePropsFallback,
|
|
81
|
-
schemasTsPath: config.types.schemasTsPath ?? schemasFallback,
|
|
82
|
-
generateZod: config.types.generateZod ?? pythonTypesConfig?.generateZod ?? false,
|
|
83
|
-
generateSdk: config.types.generateSdk ?? pythonTypesConfig?.generateSdk ?? true,
|
|
84
|
-
generateRoutes: config.types.generateRoutes ?? pythonTypesConfig?.generateRoutes ?? true,
|
|
85
|
-
generatePageProps: config.types.generatePageProps ?? pythonTypesConfig?.generatePageProps ?? true,
|
|
86
|
-
generateSchemas: config.types.generateSchemas ?? pythonTypesConfig?.generateSchemas ?? true,
|
|
87
|
-
globalRoute: config.types.globalRoute ?? pythonTypesConfig?.globalRoute ?? false,
|
|
88
|
-
debounce: config.types.debounce ?? DEBOUNCE_MS
|
|
89
|
-
};
|
|
90
|
-
} else if (config.types !== false && pythonTypesConfig?.enabled) {
|
|
91
|
-
const output = pythonTypesConfig.output ?? defaultTypesOutput;
|
|
92
|
-
const defaults = buildTypeDefaults(output);
|
|
93
|
-
typesConfig = {
|
|
94
|
-
enabled: true,
|
|
95
|
-
output,
|
|
96
|
-
openapiPath: pythonTypesConfig.openapiPath ?? defaults.openapiPath,
|
|
97
|
-
routesPath: pythonTypesConfig.routesPath ?? defaults.routesPath,
|
|
98
|
-
pagePropsPath: pythonTypesConfig.pagePropsPath ?? defaults.pagePropsPath,
|
|
99
|
-
schemasTsPath: pythonTypesConfig.schemasTsPath ?? defaults.schemasTsPath,
|
|
100
|
-
generateZod: pythonTypesConfig.generateZod ?? false,
|
|
101
|
-
generateSdk: pythonTypesConfig.generateSdk ?? true,
|
|
102
|
-
generateRoutes: pythonTypesConfig.generateRoutes ?? true,
|
|
103
|
-
generatePageProps: pythonTypesConfig.generatePageProps ?? true,
|
|
104
|
-
generateSchemas: pythonTypesConfig.generateSchemas ?? true,
|
|
105
|
-
globalRoute: pythonTypesConfig.globalRoute ?? false,
|
|
106
|
-
debounce: DEBOUNCE_MS
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
48
|
return {
|
|
110
49
|
apiProxy: config.apiProxy ?? "http://localhost:8000",
|
|
111
50
|
apiPrefix: config.apiPrefix ?? "/api",
|
|
@@ -140,14 +79,12 @@ function litestarSvelteKit(userConfig = {}) {
|
|
|
140
79
|
strictPort: true
|
|
141
80
|
} : {},
|
|
142
81
|
// Route HMR through the Litestar port so DevTools never sees the framework port.
|
|
143
|
-
...config.litestarPort !== void 0 ? {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
} : {},
|
|
82
|
+
...config.litestarPort !== void 0 ? hmrServerConfig({
|
|
83
|
+
protocol: "ws",
|
|
84
|
+
host: "127.0.0.1",
|
|
85
|
+
clientPort: config.litestarPort,
|
|
86
|
+
path: hmrPath
|
|
87
|
+
}) : {},
|
|
151
88
|
proxy: {
|
|
152
89
|
[config.apiPrefix]: {
|
|
153
90
|
target: config.apiProxy,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litestar-vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Litestar plugin for Vite.",
|
|
6
6
|
"keywords": [
|
|
@@ -103,22 +103,28 @@
|
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@tailwindcss/vite": "^4.0.0",
|
|
106
|
-
"@types/node": "^
|
|
107
|
-
"@vitest/coverage-v8": "^
|
|
108
|
-
"esbuild": "0.
|
|
106
|
+
"@types/node": "^26.0.1",
|
|
107
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
108
|
+
"esbuild": "0.28.1",
|
|
109
109
|
"happy-dom": "^20.0.2",
|
|
110
|
-
"oxfmt": "^0.
|
|
110
|
+
"oxfmt": "^0.56.0",
|
|
111
111
|
"oxlint": "^1.66.0",
|
|
112
112
|
"svelte": "^5.56.0",
|
|
113
113
|
"tailwindcss": "^4.0.0",
|
|
114
|
-
"typescript": "^
|
|
115
|
-
"vite": "^8.
|
|
114
|
+
"typescript": "^6.0.3",
|
|
115
|
+
"vite": "^8.1.0",
|
|
116
116
|
"vite-plugin-singlefile": "^2.3.0",
|
|
117
|
-
"vitest": "^
|
|
117
|
+
"vitest": "^4.1.8"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
|
+
"@hey-api/openapi-ts": "^0.98.0",
|
|
120
121
|
"vite": "^7.0.0 || ^8.0.0"
|
|
121
122
|
},
|
|
123
|
+
"peerDependenciesMeta": {
|
|
124
|
+
"@hey-api/openapi-ts": {
|
|
125
|
+
"optional": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
122
128
|
"engines": {
|
|
123
129
|
"node": ">=22.12.0"
|
|
124
130
|
},
|