@vrowzer/vite-plugin 0.1.2 → 0.1.3
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 +52 -5
- package/dist/ide/assets/{css.worker-CTXDGAqi.js → css.worker-B3bjHA4E.js} +12 -12
- package/dist/ide/assets/{html.worker-DoEWTywB.js → html.worker-CdKyo4PJ.js} +15 -15
- package/dist/ide/assets/json.worker-Dv30RK47.js +58 -0
- package/dist/ide/assets/{ts.worker-CEDDf2SQ.js → ts.worker-BMQFrgtp.js} +43 -43
- package/dist/ide/{cssMode-Bx4pwP7t.js → cssMode-BjT8Ilz9.js} +6 -6
- package/dist/ide/{handlebars-niagtI6v.js → handlebars-D8oWedcX.js} +1 -1
- package/dist/ide/{html-vu3rIOlL.js → html-BtI1mgAb.js} +1 -1
- package/dist/ide/{htmlMode-DJyFRqKm.js → htmlMode-nJv21bwP.js} +6 -6
- package/dist/ide/ide.js +1018 -1013
- package/dist/ide/{javascript-BaiNOEh_.js → javascript-CsLyoDyq.js} +1 -1
- package/dist/ide/{jsonMode-DLQ0j1a3.js → jsonMode-Gp85lTwz.js} +26 -25
- package/dist/ide/{lspLanguageFeatures-CY50NMcK.js → lspLanguageFeatures-Bh3u5Duz.js} +4 -4
- package/dist/ide/{mdx-DhZSVASO.js → mdx-BXUwpKml.js} +1 -1
- package/dist/ide/{monaco.contribution-4V6BrQ5P.js → monaco.contribution-Df9Y1epv.js} +2 -2
- package/dist/ide/{toggleHighContrast-DzGcs4Kw.js → toggleHighContrast-BAyJBPWB.js} +11852 -11696
- package/dist/ide/{tsMode-D6r_-_rM.js → tsMode-DW5hjWiU.js} +4 -4
- package/dist/ide/{typescript-DM2pFj0X.js → typescript-DdUYzFye.js} +1 -1
- package/dist/ide/{workers-DRkYqOHL.js → workers-_EnUbIXZ.js} +1 -1
- package/dist/ide/{xml-DrNRTdma.js → xml-YkclMbCx.js} +1 -1
- package/dist/ide/{yaml-ck2FlP6B.js → yaml-nzDq4-PC.js} +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +46 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/ide/assets/json.worker-C4xqSSAJ.js +0 -58
package/README.md
CHANGED
|
@@ -68,6 +68,52 @@ const vrowzer = Vrowzer()
|
|
|
68
68
|
|
|
69
69
|
The runtime `Vrowzer({ basePath })` option remains compatible. When it is also specified, its canonical path must match the plugin value; a mismatch throws during `Vrowzer()` creation. The Service Worker registration `serviceWorkerScope` is independent of this preview URL path.
|
|
70
70
|
|
|
71
|
+
### Service Worker scope
|
|
72
|
+
|
|
73
|
+
The plugin's `serviceWorkerScope` is the source of truth for both Service Worker registration and the `Service-Worker-Allowed` response header. Configure it once in `vite.config.ts`; the runtime option can be omitted:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// vite.config.ts
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
base: '/app/',
|
|
79
|
+
plugins: [
|
|
80
|
+
Vrowzer({
|
|
81
|
+
basePath: '/app/__preview__/',
|
|
82
|
+
serviceWorkerScope: '/app/'
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
// application code
|
|
90
|
+
import { Vrowzer } from 'vrowzer'
|
|
91
|
+
|
|
92
|
+
const vrowzer = Vrowzer()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The runtime `Vrowzer({ serviceWorkerScope })` option remains available for compatibility and for builds without the plugin. If both values are provided, they must match or `Vrowzer()` throws before registration. Without either value, the scope and response header default to `/`.
|
|
96
|
+
|
|
97
|
+
### Service Worker version
|
|
98
|
+
|
|
99
|
+
The plugin's `serviceWorkerVersion` is the source of truth for the version expected by the application and reported by the Service Worker. Configure it once in `vite.config.ts`; application code can call `Vrowzer()` without repeating the value:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// vite.config.ts
|
|
103
|
+
export default defineConfig({
|
|
104
|
+
plugins: [Vrowzer({ serviceWorkerVersion: 'app-v2' })]
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// application code
|
|
110
|
+
import { Vrowzer } from 'vrowzer'
|
|
111
|
+
|
|
112
|
+
const vrowzer = Vrowzer()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The runtime `Vrowzer({ serviceWorkerVersion })` option remains available for compatibility and for builds without the plugin. If both values are provided, they must match or `Vrowzer()` throws before Service Worker registration. Without either value, the version defaults to `vrowzer-v1`. The resolved version is also reflected in the Service Worker script URL, so changing it may trigger a Service Worker update.
|
|
116
|
+
|
|
71
117
|
When the host page and preview content are in different directories, use `manifest.sourceDir`:
|
|
72
118
|
|
|
73
119
|
```ts
|
|
@@ -163,12 +209,12 @@ Vrowzer({
|
|
|
163
209
|
// Default: '/__preview__/'
|
|
164
210
|
basePath: '/__preview__/',
|
|
165
211
|
|
|
166
|
-
// Service Worker scope
|
|
212
|
+
// Service Worker registration scope and allowed response header
|
|
167
213
|
// Default: '/'
|
|
168
214
|
serviceWorkerScope: '/',
|
|
169
215
|
|
|
170
216
|
// Service Worker version for cache management
|
|
171
|
-
// Default: '
|
|
217
|
+
// Default: 'vrowzer-v1'
|
|
172
218
|
serviceWorkerVersion: 'my-app-v1',
|
|
173
219
|
|
|
174
220
|
// Explicit Service Worker entry file path
|
|
@@ -189,8 +235,8 @@ Vrowzer({
|
|
|
189
235
|
| `manifest` | `VrowzerManifestOptions` | `undefined` | Auto manifest options (sourceDir, pkgDir, targets). Used when `auto: true`. |
|
|
190
236
|
| `experimental` | `VrowzerExperimentalOptions` | `undefined` | Experimental features. Currently supports `ide`. |
|
|
191
237
|
| `basePath` | `string` | `'/__preview__/'` | Preview URL pathname shared with the application and Service Worker bundles. |
|
|
192
|
-
| `serviceWorkerScope` | `string` | `'/'` | Service
|
|
193
|
-
| `serviceWorkerVersion` | `string` | `'
|
|
238
|
+
| `serviceWorkerScope` | `string` | `'/'` | Registration scope and `Service-Worker-Allowed` header injected into the runtime. |
|
|
239
|
+
| `serviceWorkerVersion` | `string` | `'vrowzer-v1'` | Version shared with the application and Service Worker bundles. |
|
|
194
240
|
| `serviceWorkerEntry` | `string` | Resolved path to `vrowzer/service-worker` | Explicit Service Worker entry file path. |
|
|
195
241
|
| `resolve` | `{ alias?: Alias[] }` | `undefined` | Worker-specific resolve settings passed to the internal Vite dev server. |
|
|
196
242
|
|
|
@@ -237,6 +283,7 @@ Auto-extracts user plugins from `vite.config.ts` using OXC parser, then pre-bund
|
|
|
237
283
|
- Resolves `@vrowzer/*` imports from the plugin's own dependency graph
|
|
238
284
|
- Inlines `readFileSync()` and `createRequire()` calls for Worker compatibility
|
|
239
285
|
- Maps `vite` imports to `@vrowzer/vite-dev-server/vite`
|
|
286
|
+
- Excludes `@vrowzer/vite-dev-server` from host dependency pre-bundling while keeping `vrowzer` optimizable
|
|
240
287
|
|
|
241
288
|
#### 3. Preview Guard Middleware (`vrowzer:server-middleware`)
|
|
242
289
|
|
|
@@ -255,7 +302,7 @@ Sets up Vite configuration for the browser-based Vite dev server:
|
|
|
255
302
|
|
|
256
303
|
- **`resolve.alias`** — Maps Node.js built-in modules (`node:fs`, `node:path`, `node:events`, etc.) to browser-compatible polyfills
|
|
257
304
|
- **`worker.format`** — Set to `'es'` for ES Module workers
|
|
258
|
-
- **CORS headers** — `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: credentialless`, plus `Service-Worker-Allowed
|
|
305
|
+
- **CORS headers** — `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: credentialless`, plus `Service-Worker-Allowed` matching `serviceWorkerScope` (default `/`)
|
|
259
306
|
|
|
260
307
|
#### 6. Rolldown WASM Copy (`vrowzer:rolldown`)
|
|
261
308
|
|