litestar-vite 0.1.1__py3-none-any.whl → 0.15.0rc2__py3-none-any.whl
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.
- litestar_vite/__init__.py +54 -4
- litestar_vite/__metadata__.py +12 -7
- litestar_vite/_codegen/__init__.py +26 -0
- litestar_vite/_codegen/inertia.py +407 -0
- litestar_vite/_codegen/openapi.py +233 -0
- litestar_vite/_codegen/routes.py +653 -0
- litestar_vite/_codegen/ts.py +235 -0
- litestar_vite/_handler/__init__.py +8 -0
- litestar_vite/_handler/app.py +524 -0
- litestar_vite/_handler/routing.py +130 -0
- litestar_vite/cli.py +1147 -10
- litestar_vite/codegen.py +39 -0
- litestar_vite/commands.py +79 -0
- litestar_vite/config.py +1594 -70
- litestar_vite/deploy.py +355 -0
- litestar_vite/doctor.py +1179 -0
- litestar_vite/exceptions.py +78 -0
- litestar_vite/executor.py +316 -0
- litestar_vite/handler.py +9 -0
- litestar_vite/html_transform.py +426 -0
- litestar_vite/inertia/__init__.py +53 -0
- litestar_vite/inertia/_utils.py +114 -0
- litestar_vite/inertia/exception_handler.py +172 -0
- litestar_vite/inertia/helpers.py +1043 -0
- litestar_vite/inertia/middleware.py +54 -0
- litestar_vite/inertia/plugin.py +133 -0
- litestar_vite/inertia/request.py +286 -0
- litestar_vite/inertia/response.py +706 -0
- litestar_vite/inertia/types.py +316 -0
- litestar_vite/loader.py +462 -121
- litestar_vite/plugin.py +2160 -21
- litestar_vite/py.typed +0 -0
- litestar_vite/scaffolding/__init__.py +20 -0
- litestar_vite/scaffolding/generator.py +270 -0
- litestar_vite/scaffolding/templates.py +437 -0
- litestar_vite/templates/__init__.py +0 -0
- litestar_vite/templates/addons/tailwindcss/tailwind.css.j2 +1 -0
- litestar_vite/templates/angular/index.html.j2 +12 -0
- litestar_vite/templates/angular/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/angular/package.json.j2 +35 -0
- litestar_vite/templates/angular/src/app/app.component.css.j2 +3 -0
- litestar_vite/templates/angular/src/app/app.component.html.j2 +1 -0
- litestar_vite/templates/angular/src/app/app.component.ts.j2 +9 -0
- litestar_vite/templates/angular/src/app/app.config.ts.j2 +5 -0
- litestar_vite/templates/angular/src/main.ts.j2 +9 -0
- litestar_vite/templates/angular/src/styles.css.j2 +9 -0
- litestar_vite/templates/angular/tsconfig.app.json.j2 +34 -0
- litestar_vite/templates/angular/tsconfig.json.j2 +20 -0
- litestar_vite/templates/angular/vite.config.ts.j2 +21 -0
- litestar_vite/templates/angular-cli/.postcssrc.json.j2 +5 -0
- litestar_vite/templates/angular-cli/angular.json.j2 +36 -0
- litestar_vite/templates/angular-cli/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/angular-cli/package.json.j2 +27 -0
- litestar_vite/templates/angular-cli/proxy.conf.json.j2 +18 -0
- litestar_vite/templates/angular-cli/src/app/app.component.css.j2 +3 -0
- litestar_vite/templates/angular-cli/src/app/app.component.html.j2 +1 -0
- litestar_vite/templates/angular-cli/src/app/app.component.ts.j2 +9 -0
- litestar_vite/templates/angular-cli/src/app/app.config.ts.j2 +5 -0
- litestar_vite/templates/angular-cli/src/index.html.j2 +13 -0
- litestar_vite/templates/angular-cli/src/main.ts.j2 +6 -0
- litestar_vite/templates/angular-cli/src/styles.css.j2 +10 -0
- litestar_vite/templates/angular-cli/tailwind.config.js.j2 +4 -0
- litestar_vite/templates/angular-cli/tsconfig.app.json.j2 +16 -0
- litestar_vite/templates/angular-cli/tsconfig.json.j2 +26 -0
- litestar_vite/templates/angular-cli/tsconfig.spec.json.j2 +9 -0
- litestar_vite/templates/astro/astro.config.mjs.j2 +28 -0
- litestar_vite/templates/astro/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/astro/src/layouts/Layout.astro.j2 +63 -0
- litestar_vite/templates/astro/src/pages/index.astro.j2 +36 -0
- litestar_vite/templates/astro/src/styles/global.css.j2 +1 -0
- litestar_vite/templates/base/.gitignore.j2 +42 -0
- litestar_vite/templates/base/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/base/package.json.j2 +38 -0
- litestar_vite/templates/base/resources/vite-env.d.ts.j2 +1 -0
- litestar_vite/templates/base/tsconfig.json.j2 +37 -0
- litestar_vite/templates/htmx/src/main.js.j2 +8 -0
- litestar_vite/templates/htmx/templates/base.html.j2.j2 +56 -0
- litestar_vite/templates/htmx/templates/index.html.j2.j2 +13 -0
- litestar_vite/templates/htmx/vite.config.ts.j2 +40 -0
- litestar_vite/templates/nuxt/app.vue.j2 +29 -0
- litestar_vite/templates/nuxt/composables/useApi.ts.j2 +33 -0
- litestar_vite/templates/nuxt/nuxt.config.ts.j2 +31 -0
- litestar_vite/templates/nuxt/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/nuxt/pages/index.vue.j2 +54 -0
- litestar_vite/templates/react/index.html.j2 +13 -0
- litestar_vite/templates/react/src/App.css.j2 +56 -0
- litestar_vite/templates/react/src/App.tsx.j2 +19 -0
- litestar_vite/templates/react/src/main.tsx.j2 +10 -0
- litestar_vite/templates/react/vite.config.ts.j2 +39 -0
- litestar_vite/templates/react-inertia/index.html.j2 +14 -0
- litestar_vite/templates/react-inertia/package.json.j2 +46 -0
- litestar_vite/templates/react-inertia/resources/App.css.j2 +68 -0
- litestar_vite/templates/react-inertia/resources/main.tsx.j2 +17 -0
- litestar_vite/templates/react-inertia/resources/pages/Home.tsx.j2 +18 -0
- litestar_vite/templates/react-inertia/resources/ssr.tsx.j2 +19 -0
- litestar_vite/templates/react-inertia/vite.config.ts.j2 +59 -0
- litestar_vite/templates/react-router/index.html.j2 +12 -0
- litestar_vite/templates/react-router/src/App.css.j2 +17 -0
- litestar_vite/templates/react-router/src/App.tsx.j2 +7 -0
- litestar_vite/templates/react-router/src/main.tsx.j2 +10 -0
- litestar_vite/templates/react-router/vite.config.ts.j2 +39 -0
- litestar_vite/templates/react-tanstack/index.html.j2 +12 -0
- litestar_vite/templates/react-tanstack/openapi-ts.config.ts.j2 +18 -0
- litestar_vite/templates/react-tanstack/src/App.css.j2 +17 -0
- litestar_vite/templates/react-tanstack/src/main.tsx.j2 +21 -0
- litestar_vite/templates/react-tanstack/src/routeTree.gen.ts.j2 +7 -0
- litestar_vite/templates/react-tanstack/src/routes/__root.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/src/routes/books.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/src/routes/index.tsx.j2 +9 -0
- litestar_vite/templates/react-tanstack/vite.config.ts.j2 +39 -0
- litestar_vite/templates/svelte/index.html.j2 +13 -0
- litestar_vite/templates/svelte/src/App.svelte.j2 +30 -0
- litestar_vite/templates/svelte/src/app.css.j2 +45 -0
- litestar_vite/templates/svelte/src/main.ts.j2 +8 -0
- litestar_vite/templates/svelte/src/vite-env.d.ts.j2 +2 -0
- litestar_vite/templates/svelte/svelte.config.js.j2 +5 -0
- litestar_vite/templates/svelte/vite.config.ts.j2 +39 -0
- litestar_vite/templates/svelte-inertia/index.html.j2 +14 -0
- litestar_vite/templates/svelte-inertia/resources/app.css.j2 +21 -0
- litestar_vite/templates/svelte-inertia/resources/main.ts.j2 +11 -0
- litestar_vite/templates/svelte-inertia/resources/pages/Home.svelte.j2 +43 -0
- litestar_vite/templates/svelte-inertia/resources/vite-env.d.ts.j2 +2 -0
- litestar_vite/templates/svelte-inertia/svelte.config.js.j2 +5 -0
- litestar_vite/templates/svelte-inertia/vite.config.ts.j2 +37 -0
- litestar_vite/templates/sveltekit/openapi-ts.config.ts.j2 +15 -0
- litestar_vite/templates/sveltekit/src/app.css.j2 +40 -0
- litestar_vite/templates/sveltekit/src/app.html.j2 +12 -0
- litestar_vite/templates/sveltekit/src/hooks.server.ts.j2 +55 -0
- litestar_vite/templates/sveltekit/src/routes/+layout.svelte.j2 +12 -0
- litestar_vite/templates/sveltekit/src/routes/+page.svelte.j2 +34 -0
- litestar_vite/templates/sveltekit/svelte.config.js.j2 +12 -0
- litestar_vite/templates/sveltekit/tsconfig.json.j2 +14 -0
- litestar_vite/templates/sveltekit/vite.config.ts.j2 +31 -0
- litestar_vite/templates/vue/env.d.ts.j2 +7 -0
- litestar_vite/templates/vue/index.html.j2 +13 -0
- litestar_vite/templates/vue/src/App.vue.j2 +28 -0
- litestar_vite/templates/vue/src/main.ts.j2 +5 -0
- litestar_vite/templates/vue/src/style.css.j2 +45 -0
- litestar_vite/templates/vue/vite.config.ts.j2 +39 -0
- litestar_vite/templates/vue-inertia/env.d.ts.j2 +7 -0
- litestar_vite/templates/vue-inertia/index.html.j2 +14 -0
- litestar_vite/templates/vue-inertia/package.json.j2 +49 -0
- litestar_vite/templates/vue-inertia/resources/main.ts.j2 +18 -0
- litestar_vite/templates/vue-inertia/resources/pages/Home.vue.j2 +22 -0
- litestar_vite/templates/vue-inertia/resources/ssr.ts.j2 +21 -0
- litestar_vite/templates/vue-inertia/resources/style.css.j2 +21 -0
- litestar_vite/templates/vue-inertia/vite.config.ts.j2 +59 -0
- litestar_vite-0.15.0rc2.dist-info/METADATA +230 -0
- litestar_vite-0.15.0rc2.dist-info/RECORD +151 -0
- {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0rc2.dist-info}/WHEEL +1 -1
- litestar_vite/template_engine.py +0 -103
- litestar_vite-0.1.1.dist-info/METADATA +0 -68
- litestar_vite-0.1.1.dist-info/RECORD +0 -11
- {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0rc2.dist-info}/licenses/LICENSE +0 -0
litestar_vite/codegen.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Public code generation API.
|
|
2
|
+
|
|
3
|
+
The internal implementation lives in ``litestar_vite._codegen``.
|
|
4
|
+
|
|
5
|
+
This module provides a stable import surface for:
|
|
6
|
+
|
|
7
|
+
- Route metadata export (``routes.json`` + Ziggy-compatible TS)
|
|
8
|
+
- Inertia page props metadata export
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from litestar_vite._codegen.inertia import ( # noqa: F401
|
|
12
|
+
InertiaPageMetadata,
|
|
13
|
+
_get_openapi_schema_ref, # pyright: ignore[reportPrivateUsage,reportUnusedImport]
|
|
14
|
+
_get_return_type_name, # pyright: ignore[reportPrivateUsage,reportUnusedImport]
|
|
15
|
+
extract_inertia_pages,
|
|
16
|
+
generate_inertia_pages_json,
|
|
17
|
+
)
|
|
18
|
+
from litestar_vite._codegen.routes import ( # noqa: F401
|
|
19
|
+
RouteMetadata,
|
|
20
|
+
_escape_ts_string, # pyright: ignore[reportPrivateUsage,reportUnusedImport]
|
|
21
|
+
_is_type_required, # pyright: ignore[reportPrivateUsage,reportUnusedImport]
|
|
22
|
+
_ts_type_for_param, # pyright: ignore[reportPrivateUsage,reportUnusedImport]
|
|
23
|
+
extract_route_metadata,
|
|
24
|
+
generate_routes_json,
|
|
25
|
+
generate_routes_ts,
|
|
26
|
+
)
|
|
27
|
+
from litestar_vite._codegen.ts import (
|
|
28
|
+
ts_type_from_openapi as _ts_type_from_openapi, # noqa: F401 # pyright: ignore[reportUnusedImport]
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = (
|
|
32
|
+
"InertiaPageMetadata",
|
|
33
|
+
"RouteMetadata",
|
|
34
|
+
"extract_inertia_pages",
|
|
35
|
+
"extract_route_metadata",
|
|
36
|
+
"generate_inertia_pages_json",
|
|
37
|
+
"generate_routes_json",
|
|
38
|
+
"generate_routes_ts",
|
|
39
|
+
)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Vite commands module.
|
|
2
|
+
|
|
3
|
+
This module provides utility functions for Vite project initialization.
|
|
4
|
+
The main scaffolding functionality has moved to litestar_vite.scaffolding.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
from litestar_vite.config import JINJA_INSTALLED
|
|
10
|
+
from litestar_vite.exceptions import MissingDependencyError
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from litestar import Litestar
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def init_vite(
|
|
19
|
+
app: "Litestar",
|
|
20
|
+
root_path: "Path",
|
|
21
|
+
resource_path: "Path",
|
|
22
|
+
asset_url: "str",
|
|
23
|
+
static_path: "Path",
|
|
24
|
+
bundle_path: "Path",
|
|
25
|
+
enable_ssr: "bool",
|
|
26
|
+
vite_port: int,
|
|
27
|
+
hot_file: "Path",
|
|
28
|
+
litestar_port: int,
|
|
29
|
+
framework: str = "react",
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Initialize a new Vite project using the scaffolding system.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
app: The Litestar application instance.
|
|
35
|
+
root_path: Root directory for the Vite project.
|
|
36
|
+
resource_path: Directory containing source files.
|
|
37
|
+
asset_url: Base URL for serving assets.
|
|
38
|
+
static_path: Directory for static (unprocessed) frontend assets.
|
|
39
|
+
bundle_path: Output directory for built files.
|
|
40
|
+
enable_ssr: Enable server-side rendering.
|
|
41
|
+
vite_port: Port for Vite dev server.
|
|
42
|
+
hot_file: Path to hot reload manifest.
|
|
43
|
+
litestar_port: Port for Litestar server.
|
|
44
|
+
framework: Framework template to use (default: react).
|
|
45
|
+
|
|
46
|
+
Raises:
|
|
47
|
+
MissingDependencyError: If Jinja2 is not installed.
|
|
48
|
+
ValueError: If the specified framework template is not found.
|
|
49
|
+
"""
|
|
50
|
+
if not JINJA_INSTALLED:
|
|
51
|
+
raise MissingDependencyError(package="jinja2", install_package="jinja")
|
|
52
|
+
|
|
53
|
+
from litestar_vite.scaffolding import TemplateContext, generate_project
|
|
54
|
+
from litestar_vite.scaffolding.templates import FrameworkType, get_template
|
|
55
|
+
|
|
56
|
+
template = get_template(framework)
|
|
57
|
+
if template is None:
|
|
58
|
+
template = get_template(FrameworkType.REACT)
|
|
59
|
+
if template is None: # pragma: no cover
|
|
60
|
+
msg = f"Could not find template for framework: {framework}"
|
|
61
|
+
raise ValueError(msg)
|
|
62
|
+
|
|
63
|
+
context = TemplateContext(
|
|
64
|
+
project_name=root_path.name or "my-project",
|
|
65
|
+
framework=template,
|
|
66
|
+
use_typescript=template.uses_typescript,
|
|
67
|
+
use_tailwind=False,
|
|
68
|
+
vite_port=vite_port,
|
|
69
|
+
litestar_port=litestar_port,
|
|
70
|
+
asset_url=asset_url,
|
|
71
|
+
resource_dir=str(resource_path),
|
|
72
|
+
bundle_dir=str(bundle_path),
|
|
73
|
+
static_dir=str(static_path),
|
|
74
|
+
enable_ssr=enable_ssr,
|
|
75
|
+
enable_inertia=template.inertia_compatible and "inertia" in framework,
|
|
76
|
+
enable_types=True,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
generate_project(root_path, context, overwrite=True)
|