litestar-vite 0.1.22__tar.gz → 0.2.0__tar.gz

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.
Files changed (123) hide show
  1. litestar_vite-0.2.0/.github/dependabot.yaml +6 -0
  2. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/ci.yaml +10 -10
  3. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/docs-preview.yaml +2 -2
  4. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/docs.yaml +2 -2
  5. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/publish.yaml +2 -2
  6. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.pre-commit-config.yaml +5 -5
  7. litestar_vite-0.2.0/.python-version +1 -0
  8. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/PKG-INFO +2 -12
  9. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/README.md +1 -11
  10. litestar_vite-0.2.0/examples/basic/tsconfig.json +30 -0
  11. litestar_vite-0.2.0/examples/flash/app.py +52 -0
  12. litestar_vite-0.2.0/examples/flash/package-lock.json +398 -0
  13. litestar_vite-0.2.0/examples/flash/public/manifest.json +14 -0
  14. litestar_vite-0.2.0/examples/flash/resources/main.ts +1 -0
  15. litestar_vite-0.2.0/examples/flash/vite.config.ts +38 -0
  16. litestar_vite-0.2.0/examples/inertia/app.py +57 -0
  17. litestar_vite-0.2.0/examples/inertia/package-lock.json +3154 -0
  18. litestar_vite-0.2.0/examples/inertia/package.json +26 -0
  19. litestar_vite-0.2.0/examples/inertia/postcss.config.cjs +6 -0
  20. litestar_vite-0.2.0/examples/inertia/public/assets/main-BIhkjqcE.js +112 -0
  21. litestar_vite-0.2.0/examples/inertia/public/assets/styles-B8hX6ha2.css +1 -0
  22. litestar_vite-0.2.0/examples/inertia/public/manifest.json +13 -0
  23. litestar_vite-0.2.0/examples/inertia/resources/Layout.vue +15 -0
  24. litestar_vite-0.2.0/examples/inertia/resources/main.js +18 -0
  25. litestar_vite-0.2.0/examples/inertia/resources/pages/Dashboard.vue +15 -0
  26. litestar_vite-0.2.0/examples/inertia/resources/pages/Home.vue +14 -0
  27. litestar_vite-0.2.0/examples/inertia/resources/styles.css +3 -0
  28. litestar_vite-0.2.0/examples/inertia/resources/templates/index.html +19 -0
  29. litestar_vite-0.2.0/examples/inertia/resources/vite-env.d.ts +1 -0
  30. litestar_vite-0.2.0/examples/inertia/tailwind.config.cjs +8 -0
  31. litestar_vite-0.2.0/examples/inertia/tsconfig.json +29 -0
  32. litestar_vite-0.2.0/examples/inertia/vite.config.ts +41 -0
  33. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/__init__.py +2 -1
  34. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/cli.py +44 -1
  35. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/commands.py +11 -8
  36. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/config.py +17 -14
  37. litestar_vite-0.2.0/litestar_vite/inertia/__init__.py +31 -0
  38. litestar_vite-0.2.0/litestar_vite/inertia/_utils.py +62 -0
  39. litestar_vite-0.2.0/litestar_vite/inertia/config.py +25 -0
  40. litestar_vite-0.2.0/litestar_vite/inertia/exception_handler.py +91 -0
  41. litestar_vite-0.2.0/litestar_vite/inertia/middleware.py +56 -0
  42. litestar_vite-0.2.0/litestar_vite/inertia/plugin.py +64 -0
  43. litestar_vite-0.2.0/litestar_vite/inertia/request.py +111 -0
  44. litestar_vite-0.2.0/litestar_vite/inertia/response.py +345 -0
  45. litestar_vite-0.2.0/litestar_vite/inertia/routes.py +54 -0
  46. litestar_vite-0.2.0/litestar_vite/inertia/types.py +39 -0
  47. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/loader.py +47 -35
  48. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/plugin.py +20 -11
  49. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/template_engine.py +24 -5
  50. litestar_vite-0.2.0/litestar_vite/templates/__init__.py +0 -0
  51. litestar_vite-0.2.0/litestar_vite/templates/index.html.j2 +16 -0
  52. litestar_vite-0.2.0/litestar_vite/templates/styles.css.j2 +0 -0
  53. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/pdm.lock +758 -339
  54. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/pyproject.toml +60 -63
  55. litestar_vite-0.2.0/tests/__init__.py +0 -0
  56. litestar_vite-0.2.0/tests/conftest.py +27 -0
  57. litestar_vite-0.2.0/tests/templates/__init__.py +0 -0
  58. litestar_vite-0.2.0/tests/test_app/__init__.py +0 -0
  59. litestar_vite-0.2.0/tests/test_app/app.py +19 -0
  60. litestar_vite-0.2.0/tests/test_app/web/__init__.py +0 -0
  61. litestar_vite-0.2.0/tests/test_app/web/public/.gitkeep +0 -0
  62. litestar_vite-0.2.0/tests/test_app/web/public/assets/main-l0sNRNKZ.js +0 -0
  63. litestar_vite-0.2.0/tests/test_app/web/public/assets/styles-l0sNRNKZ.js +0 -0
  64. litestar_vite-0.2.0/tests/test_app/web/public/manifest.json +14 -0
  65. litestar_vite-0.2.0/tests/test_app/web/resources/.gitkeep +0 -0
  66. litestar_vite-0.2.0/tests/test_app/web/resources/main.ts +1 -0
  67. litestar_vite-0.2.0/tests/test_app/web/resources/styles.css +0 -0
  68. litestar_vite-0.2.0/tests/test_app/web/templates/.gitkeep +0 -0
  69. litestar_vite-0.2.0/tests/test_app/web/templates/index.html +18 -0
  70. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/tests/test_cli/conftest.py +2 -2
  71. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/tests/test_cli/test_init.py +10 -9
  72. litestar_vite-0.1.22/tests/conftest.py → litestar_vite-0.2.0/tests/test_commands.py +10 -5
  73. litestar_vite-0.2.0/tests/test_inertia/__init__.py +0 -0
  74. litestar_vite-0.2.0/tests/test_inertia/conftest.py +30 -0
  75. litestar_vite-0.2.0/tests/test_inertia/templates/index.html.j2 +15 -0
  76. litestar_vite-0.2.0/tests/test_inertia/test_inertia_request.py +122 -0
  77. litestar_vite-0.2.0/tests/test_inertia/test_inertia_response.py +139 -0
  78. litestar_vite-0.2.0/tests/test_inertia/test_routes.py +18 -0
  79. litestar_vite-0.2.0/tests/test_template_engine.py +148 -0
  80. litestar_vite-0.1.22/package-lock.json +0 -920
  81. litestar_vite-0.1.22/tests/test_commands.py +0 -13
  82. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/CODEOWNERS +0 -0
  83. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/cd.yaml +0 -0
  84. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.github/workflows/pr-title.yaml +0 -0
  85. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/.gitignore +0 -0
  86. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/CONTRIBUTING.rst +0 -0
  87. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/LICENSE +0 -0
  88. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/Makefile +0 -0
  89. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/Makefile +0 -0
  90. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/conf.py +0 -0
  91. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/contribution-guide.rst +0 -0
  92. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/fix_missing_references.py +0 -0
  93. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/index.rst +0 -0
  94. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/reference/config.rst +0 -0
  95. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/reference/plugin.rst +0 -0
  96. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/usage/index.rst +0 -0
  97. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/docs/usage/placeholder.rst +0 -0
  98. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/__init__.py +0 -0
  99. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/app.py +0 -0
  100. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/package-lock.json +0 -0
  101. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/package.json +0 -0
  102. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/public/assets/main-l0sNRNKZ.js +0 -0
  103. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/public/assets/styles-l0sNRNKZ.js +0 -0
  104. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/public/manifest.json +0 -0
  105. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/resources/main.ts +0 -0
  106. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/resources/styles.css +0 -0
  107. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/templates/index.html.j2 +0 -0
  108. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/examples/basic/vite.config.ts +0 -0
  109. {litestar_vite-0.1.22 → litestar_vite-0.2.0/examples/flash}/package.json +0 -0
  110. /litestar_vite-0.1.22/litestar_vite/py.typed → /litestar_vite-0.2.0/examples/flash/public/assets/main-l0sNRNKZ.js +0 -0
  111. /litestar_vite-0.1.22/litestar_vite/templates/__init__.py → /litestar_vite-0.2.0/examples/flash/public/assets/styles-l0sNRNKZ.js +0 -0
  112. /litestar_vite-0.1.22/litestar_vite/templates/styles.css.j2 → /litestar_vite-0.2.0/examples/flash/resources/styles.css +0 -0
  113. {litestar_vite-0.1.22/litestar_vite → litestar_vite-0.2.0/examples/flash}/templates/index.html.j2 +0 -0
  114. {litestar_vite-0.1.22/examples/basic → litestar_vite-0.2.0/examples/flash}/tsconfig.json +0 -0
  115. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/__metadata__.py +0 -0
  116. /litestar_vite-0.1.22/tests/__init__.py → /litestar_vite-0.2.0/litestar_vite/py.typed +0 -0
  117. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/templates/main.ts.j2 +0 -0
  118. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/templates/package.json.j2 +0 -0
  119. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/templates/tsconfig.json.j2 +0 -0
  120. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/litestar_vite/templates/vite.config.ts.j2 +0 -0
  121. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/tests/templates/index.html.j2 +0 -0
  122. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/tests/test_cli/__init__.py +0 -0
  123. {litestar_vite-0.1.22 → litestar_vite-0.2.0}/tests/test_config.py +0 -0
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -12,7 +12,7 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@v4
14
14
 
15
- - uses: actions/setup-python@v4
15
+ - uses: actions/setup-python@v5
16
16
  with:
17
17
  python-version: "3.11"
18
18
 
@@ -21,7 +21,7 @@ jobs:
21
21
 
22
22
  - name: Load cached Pre-Commit Dependencies
23
23
  id: cached-pre-commit-dependencies
24
- uses: actions/cache@v3
24
+ uses: actions/cache@v4
25
25
  with:
26
26
  path: ~/.cache/pre-commit/
27
27
  key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
@@ -34,7 +34,7 @@ jobs:
34
34
  strategy:
35
35
  fail-fast: true
36
36
  matrix:
37
- python-version: ["3.8", "3.9", "3.10", "3.11"]
37
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
38
38
  timeout-minutes: 30
39
39
  defaults:
40
40
  run:
@@ -43,16 +43,16 @@ jobs:
43
43
  - name: Check out repository
44
44
  uses: actions/checkout@v4
45
45
 
46
- - uses: pdm-project/setup-pdm@v3
46
+ - uses: pdm-project/setup-pdm@v4
47
47
  name: Set up PDM
48
48
  with:
49
49
  python-version: ${{ matrix.python-version }}
50
50
 
51
51
  - name: Install dependencies
52
- run: pdm install
52
+ run: pdm install -d -G:all
53
53
 
54
54
  - name: Test
55
- run: pdm run pytest -m ""
55
+ run: pdm run pytest -m "" tests
56
56
 
57
57
  build-docs:
58
58
  needs:
@@ -64,17 +64,17 @@ jobs:
64
64
  uses: actions/checkout@v4
65
65
 
66
66
  - name: Set up Python
67
- uses: actions/setup-python@v4
67
+ uses: actions/setup-python@v5
68
68
  with:
69
69
  python-version: "3.11"
70
70
 
71
- - uses: pdm-project/setup-pdm@v3
71
+ - uses: pdm-project/setup-pdm@v4
72
72
  name: Set up PDM
73
73
  with:
74
74
  python-version: "3.11"
75
75
 
76
76
  - name: Install dependencies
77
- run: pdm install -G:all
77
+ run: pdm install -d -G:all
78
78
 
79
79
  - name: Build docs
80
80
  run: pdm run make docs
@@ -85,7 +85,7 @@ jobs:
85
85
  run: echo $PR_NUMBER > .pr_number
86
86
 
87
87
  - name: Upload artifact
88
- uses: actions/upload-artifact@v3
88
+ uses: actions/upload-artifact@v4
89
89
  with:
90
90
  name: docs-preview
91
91
  path: |
@@ -18,7 +18,7 @@ jobs:
18
18
  uses: actions/checkout@v4
19
19
 
20
20
  - name: Download artifact
21
- uses: dawidd6/action-download-artifact@v2
21
+ uses: dawidd6/action-download-artifact@v6
22
22
  with:
23
23
  workflow_conclusion: success
24
24
  run_id: ${{ github.event.workflow_run.id }}
@@ -38,7 +38,7 @@ jobs:
38
38
  target-folder: ${{ env.PR_NUMBER }}
39
39
  branch: gh-pages
40
40
 
41
- - uses: actions/github-script@v6
41
+ - uses: actions/github-script@v7
42
42
  env:
43
43
  PR_NUMBER: ${{ env.PR_NUMBER }}
44
44
  with:
@@ -15,11 +15,11 @@ jobs:
15
15
  steps:
16
16
  - uses: actions/checkout@v4
17
17
 
18
- - uses: actions/setup-python@v4
18
+ - uses: actions/setup-python@v5
19
19
  with:
20
20
  python-version: "3.11"
21
21
 
22
- - uses: pdm-project/setup-pdm@v3
22
+ - uses: pdm-project/setup-pdm@v4
23
23
  name: Set up PDM
24
24
  with:
25
25
  python-version: "3.11"
@@ -15,11 +15,11 @@ jobs:
15
15
  - name: Check out repository
16
16
  uses: actions/checkout@v4
17
17
 
18
- - uses: actions/setup-python@v4
18
+ - uses: actions/setup-python@v5
19
19
  with:
20
20
  python-version: "3.11"
21
21
 
22
- - uses: pdm-project/setup-pdm@v3
22
+ - uses: pdm-project/setup-pdm@v4
23
23
  name: Set up PDM
24
24
  with:
25
25
  python-version: "3.11"
@@ -2,12 +2,12 @@ default_language_version:
2
2
  python: "3.11"
3
3
  repos:
4
4
  - repo: https://github.com/compilerla/conventional-pre-commit
5
- rev: v3.1.0
5
+ rev: v3.3.0
6
6
  hooks:
7
7
  - id: conventional-pre-commit
8
8
  stages: [commit-msg]
9
9
  - repo: https://github.com/pre-commit/pre-commit-hooks
10
- rev: v4.5.0
10
+ rev: v4.6.0
11
11
  hooks:
12
12
  - id: check-ast
13
13
  - id: check-case-conflict
@@ -17,17 +17,17 @@ repos:
17
17
  - id: mixed-line-ending
18
18
  - id: trailing-whitespace
19
19
  - repo: https://github.com/charliermarsh/ruff-pre-commit
20
- rev: "v0.3.3"
20
+ rev: "v0.5.4"
21
21
  hooks:
22
22
  - id: ruff
23
23
  args: ["--fix"]
24
24
  exclude: "docs"
25
25
  - repo: https://github.com/codespell-project/codespell
26
- rev: v2.2.6
26
+ rev: v2.3.0
27
27
  hooks:
28
28
  - id: codespell
29
29
  - repo: https://github.com/pre-commit/mirrors-mypy
30
- rev: "v1.9.0"
30
+ rev: "v1.11.0"
31
31
  hooks:
32
32
  - id: mypy
33
33
  exclude: "docs"
@@ -0,0 +1 @@
1
+ 3.8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litestar-vite
3
- Version: 0.1.22
3
+ Version: 0.2.0
4
4
  Summary: Vite plugin for Litestar
5
5
  Project-URL: Changelog, https://cofin.github.io/litestar-vite/latest/changelog
6
6
  Project-URL: Discord, https://discord.gg/X3FJqy8d2j
@@ -70,19 +70,9 @@ class WebController(Controller):
70
70
  return Template(template_name="index.html.j2")
71
71
 
72
72
 
73
- vite = VitePlugin(
74
- config=ViteConfig(
75
- bundle_dir=Path("./public"),
76
- resource_dir=Path("./resources"),
77
- template_dir=Path("./templates"),
78
- # Should be False when in production
79
- dev_mode=True,
80
- hot_reload=True, # Websocket HMR asset reloading is enabled when true.
81
- ),
82
- )
73
+ vite = VitePlugin(config=ViteConfig(template_dir='templates/'))
83
74
  app = Litestar(plugins=[vite], route_handlers=[WebController])
84
75
 
85
-
86
76
  ```
87
77
 
88
78
  Create a template to serve the application in `./templates/index.html.h2`:
@@ -33,19 +33,9 @@ class WebController(Controller):
33
33
  return Template(template_name="index.html.j2")
34
34
 
35
35
 
36
- vite = VitePlugin(
37
- config=ViteConfig(
38
- bundle_dir=Path("./public"),
39
- resource_dir=Path("./resources"),
40
- template_dir=Path("./templates"),
41
- # Should be False when in production
42
- dev_mode=True,
43
- hot_reload=True, # Websocket HMR asset reloading is enabled when true.
44
- ),
45
- )
36
+ vite = VitePlugin(config=ViteConfig(template_dir='templates/'))
46
37
  app = Litestar(plugins=[vite], route_handlers=[WebController])
47
38
 
48
-
49
39
  ```
50
40
 
51
41
  Create a template to serve the application in `./templates/index.html.h2`:
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ES2020",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "resolveJsonModule": true,
10
+ "isolatedModules": true,
11
+ "esModuleInterop": true,
12
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
13
+ "skipLibCheck": true,
14
+ "noEmit": true,
15
+ "composite": true,
16
+ "allowSyntheticDefaultImports": true,
17
+ "baseUrl": "resources",
18
+ "paths": {
19
+ "@/*": ["./*"]
20
+ },
21
+ "types": ["vite/client"]
22
+ },
23
+ "include": [
24
+ "**/*.d.ts",
25
+ "resources/**/*.js",
26
+ "resources/**/*.ts",
27
+
28
+ "vite.config.ts"
29
+ ]
30
+ }
@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ from typing import TYPE_CHECKING
5
+
6
+ from litestar import Controller, Litestar, Request, get
7
+ from litestar.middleware.session.server_side import ServerSideSessionConfig
8
+ from litestar.plugins.flash import FlashConfig, FlashPlugin, flash # pyright: ignore[reportUnknownVariableType]
9
+ from litestar.response import Template
10
+ from litestar.stores.memory import MemoryStore
11
+
12
+ from litestar_vite import ViteConfig, VitePlugin
13
+ from litestar_vite.inertia import InertiaConfig, InertiaPlugin
14
+
15
+ if TYPE_CHECKING:
16
+ from litestar.connection.base import AuthT, StateT, UserT
17
+
18
+ here = Path(__file__).parent
19
+
20
+
21
+ class WebController(Controller):
22
+ """Web Controller."""
23
+
24
+ opt = {"exclude_from_auth": True}
25
+ include_in_schema = False
26
+
27
+ @get("/")
28
+ async def index(self, request: Request[UserT, AuthT, StateT]) -> Template:
29
+ """Serve site root."""
30
+ flash(request, "Oh no! I've been flashed!", category="error")
31
+
32
+ return Template(template_name="index.html.j2")
33
+
34
+
35
+ vite = VitePlugin(
36
+ config=ViteConfig(
37
+ hot_reload=True,
38
+ port=3006,
39
+ use_server_lifespan=True,
40
+ dev_mode=True,
41
+ template_dir="templates/",
42
+ ),
43
+ )
44
+ inertia = InertiaPlugin(config=InertiaConfig())
45
+ flasher = FlashPlugin(config=FlashConfig(template_config=vite.template_config))
46
+
47
+ app = Litestar(
48
+ plugins=[vite, flasher],
49
+ route_handlers=[WebController],
50
+ middleware=[ServerSideSessionConfig().middleware],
51
+ stores={"sessions": MemoryStore()},
52
+ )