litestar-vite-plugin 0.27.0 → 0.28.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.
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Vue bindings for generic and Litestar Queues event streams.
3
+ *
4
+ * @module
5
+ */
6
+ import { createEventStream, createQueueEventStream } from "litestar-vite-plugin/helpers";
7
+ import { onMounted, onScopeDispose, ref, shallowRef, toValue, watch } from "vue";
8
+ function useStream(factory, options) {
9
+ const healthy = ref(false);
10
+ const lastEvent = shallowRef(null);
11
+ const lastGap = shallowRef(null);
12
+ const events = shallowRef([]);
13
+ let stream = null;
14
+ const stop = () => {
15
+ stream?.dispose();
16
+ stream = null;
17
+ };
18
+ const start = () => {
19
+ stop();
20
+ healthy.value = false;
21
+ const { bufferSize: _bufferSize, key: _key, ...streamOptions } = options;
22
+ stream = factory({
23
+ ...streamOptions,
24
+ onEvent: (frame) => {
25
+ options.onEvent(frame);
26
+ lastEvent.value = frame;
27
+ const bufferSize = Math.max(0, options.bufferSize ?? 100);
28
+ events.value = bufferSize === 0 ? [] : [...events.value, frame].slice(-bufferSize);
29
+ },
30
+ onGap: (gap) => {
31
+ options.onGap?.(gap);
32
+ lastGap.value = gap;
33
+ },
34
+ onHealthChange: (value) => {
35
+ options.onHealthChange?.(value);
36
+ healthy.value = value;
37
+ },
38
+ });
39
+ stream.connect();
40
+ };
41
+ onMounted(start);
42
+ watch(() => [toValue(options.key), options.transport ?? "websocket"], () => start());
43
+ onScopeDispose(stop);
44
+ return { events, healthy, lastEvent, lastGap };
45
+ }
46
+ /**
47
+ * Subscribe a Vue scope to a generic event stream.
48
+ */
49
+ export function useEventStream(options) {
50
+ return useStream(createEventStream, options);
51
+ }
52
+ /**
53
+ * Subscribe a Vue scope to a Litestar Queues event stream.
54
+ */
55
+ export function useQueueEventStream(options) {
56
+ return useStream(createQueueEventStream, options);
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litestar-vite-plugin",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "type": "module",
5
5
  "description": "Litestar plugin for Vite.",
6
6
  "keywords": [
@@ -30,6 +30,18 @@
30
30
  "types": "./dist/js/inertia-helpers/index.d.ts",
31
31
  "import": "./dist/js/inertia-helpers/index.js"
32
32
  },
33
+ "./react": {
34
+ "types": "./dist/js/react/index.d.ts",
35
+ "import": "./dist/js/react/index.js"
36
+ },
37
+ "./vue": {
38
+ "types": "./dist/js/vue/index.d.ts",
39
+ "import": "./dist/js/vue/index.js"
40
+ },
41
+ "./svelte": {
42
+ "types": "./dist/js/svelte/index.d.ts",
43
+ "import": "./dist/js/svelte/index.js"
44
+ },
33
45
  "./astro": {
34
46
  "types": "./dist/js/astro.d.ts",
35
47
  "import": "./dist/js/astro.js"
@@ -59,6 +71,15 @@
59
71
  "inertia-helpers": [
60
72
  "./dist/js/inertia-helpers/index.d.ts"
61
73
  ],
74
+ "react": [
75
+ "./dist/js/react/index.d.ts"
76
+ ],
77
+ "vue": [
78
+ "./dist/js/vue/index.d.ts"
79
+ ],
80
+ "svelte": [
81
+ "./dist/js/svelte/index.d.ts"
82
+ ],
62
83
  "astro": [
63
84
  "./dist/js/astro.d.ts"
64
85
  ],
@@ -85,14 +106,15 @@
85
106
  "litestar-vite-typegen": "dist/js/typegen-cli.js"
86
107
  },
87
108
  "scripts": {
88
- "build": "npm run build-plugin && npm run build-helpers && npm run build-inertia-helpers && npm run build-integrations && npm run build-static-pages",
109
+ "build": "npm run build-plugin && npm run build-helpers && npm run build-inertia-helpers && npm run build-adapters && npm run build-integrations && npm run build-static-pages",
89
110
  "build-static-pages": "vite build --config src/js/src/server-starting/vite.config.ts && mv src/py/litestar_vite/static/index.html src/py/litestar_vite/static/server-starting.html",
90
111
  "build-plugin": "rm -rf dist/js && npm run build-plugin-types && npm run build-plugin-esm && npm run build-dev-server",
91
112
  "build-dev-server": "vite build --config src/js/src/dev-server/vite.config.ts && mv dist/js/index.html dist/js/dev-server-index.html",
92
113
  "build-plugin-types": "tsc --project src/js/tsconfig.json --emitDeclarationOnly",
93
- "build-plugin-esm": "esbuild src/js/src/index.ts --platform=node --format=esm --outfile=dist/js/index.js && esbuild src/js/src/install-hint.ts --platform=node --format=esm --outfile=dist/js/install-hint.js && esbuild src/js/src/litestar-meta.ts --platform=node --format=esm --outfile=dist/js/litestar-meta.js && esbuild src/js/src/typegen-cli.ts --platform=node --format=esm --outfile=dist/js/typegen-cli.js --banner:js='#!/usr/bin/env node' && chmod +x dist/js/typegen-cli.js && mkdir -p dist/js/shared && esbuild src/js/src/shared/bridge-schema.ts src/js/src/shared/constants.ts src/js/src/shared/debounce.ts src/js/src/shared/format-path.ts src/js/src/shared/logger.ts src/js/src/shared/emit-page-props-types.ts src/js/src/shared/emit-schemas-types.ts src/js/src/shared/emit-static-props-types.ts src/js/src/shared/typegen-plugin.ts src/js/src/shared/typegen-core.ts src/js/src/shared/write-if-changed.ts src/js/src/shared/typegen-cache.ts src/js/src/shared/network.ts src/js/src/shared/vite-compat.ts --platform=node --format=esm --outdir=dist/js/shared",
114
+ "build-plugin-esm": "esbuild src/js/src/index.ts --platform=node --format=esm --outfile=dist/js/index.js && esbuild src/js/src/install-hint.ts --platform=node --format=esm --outfile=dist/js/install-hint.js && esbuild src/js/src/litestar-meta.ts --platform=node --format=esm --outfile=dist/js/litestar-meta.js && esbuild src/js/src/typegen-cli.ts --platform=node --format=esm --outfile=dist/js/typegen-cli.js --banner:js='#!/usr/bin/env node' && chmod +x dist/js/typegen-cli.js && mkdir -p dist/js/shared && esbuild src/js/src/shared/bridge-schema.ts src/js/src/shared/constants.ts src/js/src/shared/debounce.ts src/js/src/shared/format-path.ts src/js/src/shared/logger.ts src/js/src/shared/managed-shutdown.ts src/js/src/shared/emit-page-props-types.ts src/js/src/shared/emit-schemas-types.ts src/js/src/shared/emit-static-props-types.ts src/js/src/shared/typegen-plugin.ts src/js/src/shared/typegen-core.ts src/js/src/shared/write-if-changed.ts src/js/src/shared/typegen-cache.ts src/js/src/shared/network.ts src/js/src/shared/vite-compat.ts --platform=node --format=esm --outdir=dist/js/shared",
94
115
  "build-helpers": "rm -rf dist/js/helpers && tsc --project src/js/tsconfig.helpers.json",
95
116
  "build-inertia-helpers": "rm -rf dist/js/inertia-helpers && tsc --project src/js/tsconfig.inertia-helpers.json",
117
+ "build-adapters": "rm -rf dist/js/react dist/js/vue dist/js/svelte && tsc --project src/js/tsconfig.react.json && tsc --project src/js/tsconfig.vue.json && tsc --project src/js/tsconfig.svelte.json",
96
118
  "build-integrations": "esbuild src/js/src/astro.ts src/js/src/sveltekit.ts src/js/src/nuxt.ts src/js/src/inertia-types.ts --platform=node --format=esm --outdir=dist/js",
97
119
  "lint": "oxlint src/js/src src/js/tests",
98
120
  "lint:examples": "oxlint examples",
@@ -104,25 +126,46 @@
104
126
  "devDependencies": {
105
127
  "@tailwindcss/vite": "^4.0.0",
106
128
  "@types/node": "^26.0.1",
129
+ "@types/react": "^19.2.17",
130
+ "@types/react-dom": "^19.2.3",
107
131
  "@vitest/coverage-v8": "^4.1.8",
108
132
  "esbuild": "0.28.1",
109
133
  "happy-dom": "^20.0.2",
110
134
  "oxfmt": "^0.56.0",
111
135
  "oxlint": "^1.66.0",
136
+ "react": "^19.2.8",
137
+ "react-dom": "^19.2.8",
112
138
  "svelte": "^5.56.0",
113
139
  "tailwindcss": "^4.0.0",
114
140
  "typescript": "^6.0.3",
115
141
  "vite": "^8.1.0",
116
142
  "vite-plugin-singlefile": "^2.3.0",
117
- "vitest": "^4.1.8"
143
+ "vitest": "^4.1.8",
144
+ "vue": "^3.5.40"
118
145
  },
119
146
  "peerDependencies": {
120
147
  "@hey-api/openapi-ts": "^0.98.0",
148
+ "react": "^19.0.0",
149
+ "react-dom": "^19.0.0",
150
+ "svelte": "^5.0.0",
151
+ "vue": "^3.5.0",
121
152
  "vite": "^7.0.0 || ^8.0.0"
122
153
  },
123
154
  "peerDependenciesMeta": {
124
155
  "@hey-api/openapi-ts": {
125
156
  "optional": true
157
+ },
158
+ "react": {
159
+ "optional": true
160
+ },
161
+ "react-dom": {
162
+ "optional": true
163
+ },
164
+ "svelte": {
165
+ "optional": true
166
+ },
167
+ "vue": {
168
+ "optional": true
126
169
  }
127
170
  },
128
171
  "engines": {