@vrowzer/vite-plugin 0.1.1 → 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.
Files changed (27) hide show
  1. package/README.md +77 -7
  2. package/dist/ide/assets/{css.worker-CTXDGAqi.js → css.worker-B3bjHA4E.js} +12 -12
  3. package/dist/ide/assets/{html.worker-DoEWTywB.js → html.worker-CdKyo4PJ.js} +15 -15
  4. package/dist/ide/assets/json.worker-Dv30RK47.js +58 -0
  5. package/dist/ide/assets/{ts.worker-CEDDf2SQ.js → ts.worker-BMQFrgtp.js} +43 -43
  6. package/dist/ide/{cssMode-Bx4pwP7t.js → cssMode-BjT8Ilz9.js} +6 -6
  7. package/dist/ide/{handlebars-niagtI6v.js → handlebars-D8oWedcX.js} +1 -1
  8. package/dist/ide/{html-vu3rIOlL.js → html-BtI1mgAb.js} +1 -1
  9. package/dist/ide/{htmlMode-DJyFRqKm.js → htmlMode-nJv21bwP.js} +6 -6
  10. package/dist/ide/ide.js +1018 -1013
  11. package/dist/ide/{javascript-BaiNOEh_.js → javascript-CsLyoDyq.js} +1 -1
  12. package/dist/ide/{jsonMode-DLQ0j1a3.js → jsonMode-Gp85lTwz.js} +26 -25
  13. package/dist/ide/{lspLanguageFeatures-CY50NMcK.js → lspLanguageFeatures-Bh3u5Duz.js} +4 -4
  14. package/dist/ide/{mdx-DhZSVASO.js → mdx-BXUwpKml.js} +1 -1
  15. package/dist/ide/{monaco.contribution-4V6BrQ5P.js → monaco.contribution-Df9Y1epv.js} +2 -2
  16. package/dist/ide/{toggleHighContrast-DzGcs4Kw.js → toggleHighContrast-BAyJBPWB.js} +11852 -11696
  17. package/dist/ide/{tsMode-D6r_-_rM.js → tsMode-DW5hjWiU.js} +4 -4
  18. package/dist/ide/{typescript-DM2pFj0X.js → typescript-DdUYzFye.js} +1 -1
  19. package/dist/ide/{workers-DRkYqOHL.js → workers-_EnUbIXZ.js} +1 -1
  20. package/dist/ide/{xml-DrNRTdma.js → xml-YkclMbCx.js} +1 -1
  21. package/dist/ide/{yaml-ck2FlP6B.js → yaml-nzDq4-PC.js} +1 -1
  22. package/dist/index.d.mts +7 -2
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +69 -27
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +12 -12
  27. package/dist/ide/assets/json.worker-C4xqSSAJ.js +0 -58
package/README.md CHANGED
@@ -39,12 +39,81 @@ The auto-generated manifest is available via the `virtual:vrowzer-manifest` virt
39
39
  ```ts
40
40
  import manifest from 'virtual:vrowzer-manifest'
41
41
 
42
- const vrowzer = Vrowzer({ basePath: '/__preview__/' })
42
+ const vrowzer = Vrowzer()
43
43
  await vrowzer.ready({
44
44
  files: { ...manifest.files, ...manifest.nodeModules }
45
45
  })
46
46
  ```
47
47
 
48
+ ### Preview base path
49
+
50
+ The plugin's `basePath` is the source of truth for the application, Web Worker, and Service Worker bundles. Configure it once in `vite.config.ts`; application code can call `Vrowzer()` without repeating the value.
51
+
52
+ For a host application served from a nested Vite base:
53
+
54
+ ```ts
55
+ // vite.config.ts
56
+ export default defineConfig({
57
+ base: '/app/',
58
+ plugins: [Vrowzer({ basePath: '/app/__preview__/' })]
59
+ })
60
+ ```
61
+
62
+ ```ts
63
+ // application code
64
+ import { Vrowzer } from 'vrowzer'
65
+
66
+ const vrowzer = Vrowzer()
67
+ ```
68
+
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
+
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
+
48
117
  When the host page and preview content are in different directories, use `manifest.sourceDir`:
49
118
 
50
119
  ```ts
@@ -140,12 +209,12 @@ Vrowzer({
140
209
  // Default: '/__preview__/'
141
210
  basePath: '/__preview__/',
142
211
 
143
- // Service Worker scope
212
+ // Service Worker registration scope and allowed response header
144
213
  // Default: '/'
145
214
  serviceWorkerScope: '/',
146
215
 
147
216
  // Service Worker version for cache management
148
- // Default: 'SERVICE_WORKER_VERSION'
217
+ // Default: 'vrowzer-v1'
149
218
  serviceWorkerVersion: 'my-app-v1',
150
219
 
151
220
  // Explicit Service Worker entry file path
@@ -165,9 +234,9 @@ Vrowzer({
165
234
  | `auto` | `boolean` | `true` | Enable auto manifest generation. Set `false` to use `VrowzerManifest()` manually. |
166
235
  | `manifest` | `VrowzerManifestOptions` | `undefined` | Auto manifest options (sourceDir, pkgDir, targets). Used when `auto: true`. |
167
236
  | `experimental` | `VrowzerExperimentalOptions` | `undefined` | Experimental features. Currently supports `ide`. |
168
- | `basePath` | `string` | `'/__preview__/'` | Base path for the preview system. The Service Worker intercepts requests under this path. |
169
- | `serviceWorkerScope` | `string` | `'/'` | The scope for the Service Worker registration. |
170
- | `serviceWorkerVersion` | `string` | `'SERVICE_WORKER_VERSION'` | Version string for Service Worker cache management. |
237
+ | `basePath` | `string` | `'/__preview__/'` | Preview URL pathname shared with the application and Service Worker bundles. |
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. |
171
240
  | `serviceWorkerEntry` | `string` | Resolved path to `vrowzer/service-worker` | Explicit Service Worker entry file path. |
172
241
  | `resolve` | `{ alias?: Alias[] }` | `undefined` | Worker-specific resolve settings passed to the internal Vite dev server. |
173
242
 
@@ -214,6 +283,7 @@ Auto-extracts user plugins from `vite.config.ts` using OXC parser, then pre-bund
214
283
  - Resolves `@vrowzer/*` imports from the plugin's own dependency graph
215
284
  - Inlines `readFileSync()` and `createRequire()` calls for Worker compatibility
216
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
217
287
 
218
288
  #### 3. Preview Guard Middleware (`vrowzer:server-middleware`)
219
289
 
@@ -232,7 +302,7 @@ Sets up Vite configuration for the browser-based Vite dev server:
232
302
 
233
303
  - **`resolve.alias`** — Maps Node.js built-in modules (`node:fs`, `node:path`, `node:events`, etc.) to browser-compatible polyfills
234
304
  - **`worker.format`** — Set to `'es'` for ES Module workers
235
- - **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 `/`)
236
306
 
237
307
  #### 6. Rolldown WASM Copy (`vrowzer:rolldown`)
238
308