@vivari/react 1.3.11 → 1.5.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.
- package/CHANGELOG.md +10 -4
- package/README.md +40 -133
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# @vivari/react
|
|
2
2
|
|
|
3
|
-
From 1.1.0 on, entries are generated from [changesets](https://github.com/changesets/changesets).
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
From 1.1.0 on, entries are generated from [changesets](https://github.com/changesets/changesets). `@vivari/core` and `@vivari/react` are released together under the same version, so a release that says "No changes in this release" changed only `@vivari/core`.
|
|
4
|
+
|
|
5
|
+
## 1.5.0
|
|
6
|
+
|
|
7
|
+
No changes in this release.
|
|
8
|
+
|
|
9
|
+
## 1.4.0
|
|
10
|
+
|
|
11
|
+
No changes in this release.
|
|
6
12
|
|
|
7
13
|
## 1.3.11
|
|
8
14
|
|
|
@@ -110,4 +116,4 @@ No changes in this release.
|
|
|
110
116
|
|
|
111
117
|
## 1.0.0
|
|
112
118
|
|
|
113
|
-
First release: the `<Vivari>` component and the `useVivari()` hook.
|
|
119
|
+
First release: the `<Vivari>` component and the `useVivari()` hook.
|
package/README.md
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
# @vivari/react
|
|
2
2
|
|
|
3
|
-
React bindings for [Vivari](../core). Run Node, Bun and Python projects fully
|
|
4
|
-
client-side in the browser, embedded in your React app.
|
|
3
|
+
React bindings for [Vivari](../core). Run Node, Bun and Python projects fully client-side in the browser, embedded in your React app.
|
|
5
4
|
|
|
6
5
|
```bash
|
|
7
6
|
npm install @vivari/react @vivari/core react
|
|
8
7
|
```
|
|
9
8
|
|
|
10
|
-
`@vivari/core` and `react` are **peer dependencies**: you install them, and you
|
|
11
|
-
get exactly one copy of each. (Two copies of core would mean two kernel worker
|
|
12
|
-
bundles and two Wasm asset sets in your build.) The package is ESM-only.
|
|
9
|
+
`@vivari/core` and `react` are **peer dependencies**: you install them, and you get exactly one copy of each. (Two copies of core would mean two kernel worker bundles and two Wasm asset sets in your build.) The package is ESM-only.
|
|
13
10
|
|
|
14
|
-
> Like all of Vivari, this needs a **cross-origin isolated** page. See
|
|
15
|
-
> [Cross-origin isolation](#cross-origin-isolation) below — it is the wall most
|
|
16
|
-
> people hit first.
|
|
11
|
+
> Like all of Vivari, this needs a **cross-origin isolated** page. See [Cross-origin isolation](#cross-origin-isolation) below — it is the wall most people hit first.
|
|
17
12
|
|
|
18
13
|
## Quick start
|
|
19
14
|
|
|
@@ -41,15 +36,11 @@ export function Playground() {
|
|
|
41
36
|
}
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
`fallback` is the **pending** slot only. Failures — a page that isn't
|
|
45
|
-
cross-origin isolated, a failed `npm install`, a spawn that throws — render a
|
|
46
|
-
built-in notice instead, and call `onError`. Nothing is swallowed. Use
|
|
47
|
-
`renderError` to replace that notice.
|
|
39
|
+
`fallback` is the **pending** slot only. Failures — a page that isn't cross-origin isolated, a failed `npm install`, a spawn that throws — render a built-in notice instead, and call `onError`. Nothing is swallowed. Use `renderError` to replace that notice.
|
|
48
40
|
|
|
49
41
|
## Composing the pieces
|
|
50
42
|
|
|
51
|
-
`<Vivari>` is a thin composition of a boot hook and a preview component. When you
|
|
52
|
-
need your own layout, use them directly — one kernel is shared across the tree:
|
|
43
|
+
`<Vivari>` is a thin composition of a boot hook and a preview component. When you need your own layout, use them directly — one kernel is shared across the tree:
|
|
53
44
|
|
|
54
45
|
```tsx
|
|
55
46
|
import {
|
|
@@ -91,8 +82,7 @@ export function App() {
|
|
|
91
82
|
}
|
|
92
83
|
```
|
|
93
84
|
|
|
94
|
-
You can also pass `children` to `<Vivari>` to keep its install/run orchestration
|
|
95
|
-
while taking over rendering. A function child receives the live boot state:
|
|
85
|
+
You can also pass `children` to `<Vivari>` to keep its install/run orchestration while taking over rendering. A function child receives the live boot state:
|
|
96
86
|
|
|
97
87
|
```tsx
|
|
98
88
|
<Vivari files={files} run="npm run dev">
|
|
@@ -103,14 +93,11 @@ while taking over rendering. A function child receives the live boot state:
|
|
|
103
93
|
</Vivari>
|
|
104
94
|
```
|
|
105
95
|
|
|
106
|
-
`<Vivari>` publishes nothing to the tree below it, so a nested `<VivariPreview>`
|
|
107
|
-
takes the instance from `state` rather than from context. Under a
|
|
108
|
-
`<VivariProvider>` you can leave `vivari` off and let it resolve on its own.
|
|
96
|
+
`<Vivari>` publishes nothing to the tree below it, so a nested `<VivariPreview>` takes the instance from `state` rather than from context. Under a `<VivariProvider>` you can leave `vivari` off and let it resolve on its own.
|
|
109
97
|
|
|
110
98
|
## Cross-origin isolation
|
|
111
99
|
|
|
112
|
-
Vivari needs `SharedArrayBuffer`, which browsers only expose on a cross-origin
|
|
113
|
-
isolated page. Serve your HTML documents (and `sw.js`) with:
|
|
100
|
+
Vivari needs `SharedArrayBuffer`, which browsers only expose on a cross-origin isolated page. Serve your HTML documents (and `sw.js`) with:
|
|
114
101
|
|
|
115
102
|
```
|
|
116
103
|
Cross-Origin-Opener-Policy: same-origin
|
|
@@ -147,16 +134,8 @@ module.exports = {
|
|
|
147
134
|
|
|
148
135
|
Two Next-specific gotchas:
|
|
149
136
|
|
|
150
|
-
1. **`require-corp` breaks cross-origin subresources.** Under it, every
|
|
151
|
-
|
|
152
|
-
CORS). That means remote-loader `next/image` sources, third-party analytics,
|
|
153
|
-
embedded fonts and most `<script src>` tags from other origins will fail on an
|
|
154
|
-
isolated page. Scope the headers to the route that hosts Vivari rather than
|
|
155
|
-
applying them site-wide.
|
|
156
|
-
2. **Next does not serve the Service Worker with the header Vivari needs.** Put
|
|
157
|
-
`sw.js` in `public/` and add a header rule giving it
|
|
158
|
-
`Service-Worker-Allowed: /`, or pass `boot={{ serviceWorkerUrl: false }}` if
|
|
159
|
-
you don't need in-browser server previews. The default is `"/sw.js"`.
|
|
137
|
+
1. **`require-corp` breaks cross-origin subresources.** Under it, every cross-origin resource must opt in with `Cross-Origin-Resource-Policy` (or CORS). That means remote-loader `next/image` sources, third-party analytics, embedded fonts and most `<script src>` tags from other origins will fail on an isolated page. Scope the headers to the route that hosts Vivari rather than applying them site-wide.
|
|
138
|
+
2. **Next does not serve the Service Worker with the header Vivari needs.** Put `sw.js` in `public/` and add a header rule giving it `Service-Worker-Allowed: /`, or pass `boot={{ serviceWorkerUrl: false }}` if you don't need in-browser server previews. The default is `"/sw.js"`.
|
|
160
139
|
|
|
161
140
|
### Vite
|
|
162
141
|
|
|
@@ -168,21 +147,17 @@ const isolation = {
|
|
|
168
147
|
export default defineConfig({ server: { headers: isolation }, preview: { headers: isolation } });
|
|
169
148
|
```
|
|
170
149
|
|
|
171
|
-
More recipes (Cloudflare, Netlify, Nginx, Express) are in the
|
|
172
|
-
[core docs](../core/README.md).
|
|
150
|
+
More recipes (Cloudflare, Netlify, Nginx, Express) are in the [core docs](../core/README.md).
|
|
173
151
|
|
|
174
152
|
## Server rendering
|
|
175
153
|
|
|
176
|
-
Every entry point carries `"use client"`, so importing this package from a
|
|
177
|
-
Next.js Server Component works. During SSR/prerender the hooks report
|
|
178
|
-
`status: "idle"` and boot nothing; the kernel starts in an effect on the client.
|
|
154
|
+
Every entry point carries `"use client"`, so importing this package from a Next.js Server Component works. During SSR/prerender the hooks report `status: "idle"` and boot nothing; the kernel starts in an effect on the client.
|
|
179
155
|
|
|
180
156
|
## API
|
|
181
157
|
|
|
182
158
|
### `<Vivari>`
|
|
183
159
|
|
|
184
|
-
Extends the standard `<iframe>` props (`className`, `style`, `id`, `allow`,
|
|
185
|
-
`sandbox`, `loading`, …), which reach the preview frame. `ref` forwards to it.
|
|
160
|
+
Extends the standard `<iframe>` props (`className`, `style`, `id`, `allow`, `sandbox`, `loading`, …), which reach the preview frame. `ref` forwards to it.
|
|
186
161
|
|
|
187
162
|
| prop | type | default |
|
|
188
163
|
| --- | --- | --- |
|
|
@@ -203,20 +178,13 @@ Extends the standard `<iframe>` props (`className`, `style`, `id`, `allow`,
|
|
|
203
178
|
| `renderError` | `(failure: VivariFailure) => ReactNode` | built-in notice |
|
|
204
179
|
| `children` | `ReactNode \| (state) => ReactNode` | – |
|
|
205
180
|
|
|
206
|
-
`VivariFailure` is `{ phase, error }` where `phase` is `"unsupported"`,
|
|
207
|
-
`"boot"`, `"mount"`, `"install"` or `"run"`. The `"unsupported"` variant also
|
|
208
|
-
carries a `reason`.
|
|
181
|
+
`VivariFailure` is `{ phase, error }` where `phase` is `"unsupported"`, `"boot"`, `"mount"`, `"install"` or `"run"`. The `"unsupported"` variant also carries a `reason`.
|
|
209
182
|
|
|
210
|
-
Commands given as a string are split on whitespace; use the array form for
|
|
211
|
-
anything containing quotes.
|
|
183
|
+
Commands given as a string are split on whitespace; use the array form for anything containing quotes.
|
|
212
184
|
|
|
213
185
|
### `<VivariPreview>`
|
|
214
186
|
|
|
215
|
-
The preview `<iframe>` on its own. It renders `fallback` until the in-VM server
|
|
216
|
-
is genuinely serving, then points the frame at it and calls
|
|
217
|
-
`vivari.attachPreview(frame)` to run the inbound half of the HMR/SSE tunnel that
|
|
218
|
-
Vite's client needs — without that, Vite HMR never gets past
|
|
219
|
-
`[vite] connecting…`.
|
|
187
|
+
The preview `<iframe>` on its own. It renders `fallback` until the in-VM server is genuinely serving, then points the frame at it and calls `vivari.attachPreview(frame)` to run the inbound half of the HMR/SSE tunnel that Vite's client needs — without that, Vite HMR never gets past `[vite] connecting…`.
|
|
220
188
|
|
|
221
189
|
| prop | type | default |
|
|
222
190
|
| --- | --- | --- |
|
|
@@ -227,18 +195,11 @@ Vite's client needs — without that, Vite HMR never gets past
|
|
|
227
195
|
| `onServerReady` | `(port, url) => void` | – |
|
|
228
196
|
| `fallback` | `ReactNode` | – |
|
|
229
197
|
|
|
230
|
-
Any other prop (`className`, `style`, `title`, `allow`, `sandbox`, …) goes
|
|
231
|
-
straight to the `<iframe>`, and `ref` forwards to the element.
|
|
198
|
+
Any other prop (`className`, `style`, `title`, `allow`, `sandbox`, …) goes straight to the `<iframe>`, and `ref` forwards to the element.
|
|
232
199
|
|
|
233
|
-
It follows core's `server-ready` event, which fires when the kernel has
|
|
234
|
-
confirmed the port is answering — not on the raw `listen`, which a dev server
|
|
235
|
-
emits several times while it rebinds. Each `server-ready` re-points the frame,
|
|
236
|
-
so a dev server that dies and restarts reconnects rather than being ignored.
|
|
237
|
-
The flip side is that a `<VivariPreview>` mounted *after* a server started
|
|
238
|
-
missed the event: keep it mounted, or bump `reloadKey`.
|
|
200
|
+
It follows core's `server-ready` event, which fires when the kernel has confirmed the port is answering — not on the raw `listen`, which a dev server emits several times while it rebinds. Each `server-ready` re-points the frame, so a dev server that dies and restarts reconnects rather than being ignored. The flip side is that a `<VivariPreview>` mounted *after* a server started missed the event: keep it mounted, or bump `reloadKey`.
|
|
239
201
|
|
|
240
|
-
Change `reloadKey` to reload the frame without remounting it — remounting would
|
|
241
|
-
tear down the HMR socket.
|
|
202
|
+
Change `reloadKey` to reload the frame without remounting it — remounting would tear down the HMR socket.
|
|
242
203
|
|
|
243
204
|
### `useVivari(options?)`
|
|
244
205
|
|
|
@@ -246,9 +207,7 @@ tear down the HMR socket.
|
|
|
246
207
|
const { status, vivari, error, boot, restart } = useVivari();
|
|
247
208
|
```
|
|
248
209
|
|
|
249
|
-
`status` is a discriminated union — `"idle" | "booting" | "ready" | "error" |
|
|
250
|
-
"unsupported"` — so `status === "ready"` narrows `vivari` to a non-null instance
|
|
251
|
-
and no defensive null check is needed:
|
|
210
|
+
`status` is a discriminated union — `"idle" | "booting" | "ready" | "error" | "unsupported"` — so `status === "ready"` narrows `vivari` to a non-null instance and no defensive null check is needed:
|
|
252
211
|
|
|
253
212
|
```tsx
|
|
254
213
|
const state = useVivari();
|
|
@@ -264,14 +223,9 @@ Options are `BootOptions` plus:
|
|
|
264
223
|
| `instanceKey` | `string` | `"default"` |
|
|
265
224
|
| `autoBoot` | `boolean` | `true` |
|
|
266
225
|
|
|
267
|
-
Instances are **shared and ref-counted per `instanceKey`**. Two components with
|
|
268
|
-
the same key share one kernel, and React StrictMode's double-mount boots exactly
|
|
269
|
-
once. Boot options are read when the boot starts; later changes apply on the
|
|
270
|
-
next `restart()`.
|
|
226
|
+
Instances are **shared and ref-counted per `instanceKey`**. Two components with the same key share one kernel, and React StrictMode's double-mount boots exactly once. Boot options are read when the boot starts; later changes apply on the next `restart()`.
|
|
271
227
|
|
|
272
|
-
Pass `autoBoot: false` to defer the boot until a user gesture — worth doing for a
|
|
273
|
-
playground below the fold, so a visitor who never scrolls never pays for a
|
|
274
|
-
kernel:
|
|
228
|
+
Pass `autoBoot: false` to defer the boot until a user gesture — worth doing for a playground below the fold, so a visitor who never scrolls never pays for a kernel:
|
|
275
229
|
|
|
276
230
|
```tsx
|
|
277
231
|
const { status, boot } = useVivari({ autoBoot: false });
|
|
@@ -280,11 +234,7 @@ return status === "idle" ? <button onClick={boot}>Run this example</button> :
|
|
|
280
234
|
|
|
281
235
|
### `<VivariProvider>` / `useVivariContext()` / `useVivariInstance()`
|
|
282
236
|
|
|
283
|
-
`<VivariProvider>` takes the same options as `useVivari` and publishes the result
|
|
284
|
-
to the subtree. `useVivariContext()` reads it and throws outside a provider;
|
|
285
|
-
`useVivariContext({ optional: true })` returns `null` instead.
|
|
286
|
-
`useVivariInstance(explicit?)` resolves the instance a hook should act on and is
|
|
287
|
-
what `useSpawn` / `useVivariFile` / `<VivariPreview>` use internally.
|
|
237
|
+
`<VivariProvider>` takes the same options as `useVivari` and publishes the result to the subtree. `useVivariContext()` reads it and throws outside a provider; `useVivariContext({ optional: true })` returns `null` instead. `useVivariInstance(explicit?)` resolves the instance a hook should act on and is what `useSpawn` / `useVivariFile` / `<VivariPreview>` use internally.
|
|
288
238
|
|
|
289
239
|
### `useSpawn(command, args?, options?)`
|
|
290
240
|
|
|
@@ -292,9 +242,7 @@ what `useSpawn` / `useVivariFile` / `<VivariPreview>` use internally.
|
|
|
292
242
|
const { run, kill, write, status, output, exitCode, process } = useSpawn("node", ["index.js"]);
|
|
293
243
|
```
|
|
294
244
|
|
|
295
|
-
`command` and `args` are read when a run starts, so an inline array is fine and
|
|
296
|
-
changing them does not restart anything — call `run()` for that. Any running
|
|
297
|
-
process is killed on unmount.
|
|
245
|
+
`command` and `args` are read when a run starts, so an inline array is fine and changing them does not restart anything — call `run()` for that. Any running process is killed on unmount.
|
|
298
246
|
|
|
299
247
|
| option | type | default |
|
|
300
248
|
| --- | --- | --- |
|
|
@@ -306,21 +254,13 @@ process is killed on unmount.
|
|
|
306
254
|
| `vivari` | `VivariInstance \| null` | nearest provider's |
|
|
307
255
|
| `cwd`, `env` | from `SpawnOptions` | – |
|
|
308
256
|
|
|
309
|
-
`collect` is off by default on purpose: `npm install` emits thousands of chunks
|
|
310
|
-
and a re-render per chunk is a perf disaster. Use `onOutput` (zero re-renders) to
|
|
311
|
-
drive a terminal, and turn `collect` on only when you want to render the log into
|
|
312
|
-
a `<pre>`.
|
|
257
|
+
`collect` is off by default on purpose: `npm install` emits thousands of chunks and a re-render per chunk is a perf disaster. Use `onOutput` (zero re-renders) to drive a terminal, and turn `collect` on only when you want to render the log into a `<pre>`.
|
|
313
258
|
|
|
314
|
-
`output` is the interleaved stdout+stderr stream, which is what a terminal
|
|
315
|
-
wants. To style them differently, read the separate `process.stdout` and
|
|
316
|
-
`process.stderr` streams off the returned `process` handle — reading either one
|
|
317
|
-
does not consume `output`.
|
|
259
|
+
`output` is the interleaved stdout+stderr stream, which is what a terminal wants. To style them differently, read the separate `process.stdout` and `process.stderr` streams off the returned `process` handle — reading either one does not consume `output`.
|
|
318
260
|
|
|
319
261
|
#### xterm.js recipe
|
|
320
262
|
|
|
321
|
-
There is no `<VivariTerminal>` component, deliberately — xterm.js is a heavy,
|
|
322
|
-
opinionated dependency and every embedder wants different theming, addons and
|
|
323
|
-
fit behaviour. `useSpawn` reduces the glue to this:
|
|
263
|
+
There is no `<VivariTerminal>` component, deliberately — xterm.js is a heavy, opinionated dependency and every embedder wants different theming, addons and fit behaviour. `useSpawn` reduces the glue to this:
|
|
324
264
|
|
|
325
265
|
```tsx
|
|
326
266
|
import { useEffect, useRef } from "react";
|
|
@@ -366,16 +306,9 @@ function NodeTerminal({ file }: { file: string }) {
|
|
|
366
306
|
}
|
|
367
307
|
```
|
|
368
308
|
|
|
369
|
-
There is no `<VivariProvider>` here, so this component boots its own kernel and
|
|
370
|
-
hands the instance to `useSpawn` through the `vivari` option. Without it the
|
|
371
|
-
hook has nothing to act on and every `run()` fails. Inside a provider, drop both
|
|
372
|
-
the `useVivari` call and the option and the hook resolves the instance itself.
|
|
373
|
-
Either way `vivari` is null until the boot lands, which is what `bootStatus`
|
|
374
|
-
gates the button on: `useSpawn` reads the instance when a run starts, not when
|
|
375
|
-
the hook is called.
|
|
309
|
+
There is no `<VivariProvider>` here, so this component boots its own kernel and hands the instance to `useSpawn` through the `vivari` option. Without it the hook has nothing to act on and every `run()` fails. Inside a provider, drop both the `useVivari` call and the option and the hook resolves the instance itself. Either way `vivari` is null until the boot lands, which is what `bootStatus` gates the button on: `useSpawn` reads the instance when a run starts, not when the hook is called.
|
|
376
310
|
|
|
377
|
-
`run`, `kill` and `write` keep a stable identity, so they are safe in dependency
|
|
378
|
-
arrays.
|
|
311
|
+
`run`, `kill` and `write` keep a stable identity, so they are safe in dependency arrays.
|
|
379
312
|
|
|
380
313
|
### `useVivariFile(path, options?)`
|
|
381
314
|
|
|
@@ -385,10 +318,7 @@ const [source, setSource, { status, error, save, reload }] = useVivariFile("/src
|
|
|
385
318
|
});
|
|
386
319
|
```
|
|
387
320
|
|
|
388
|
-
Reads the file into React state and writes edits back with a debounce. `save()`
|
|
389
|
-
cancels the pending debounce and writes immediately (the Cmd+S path), and a
|
|
390
|
-
pending write is **flushed on unmount and before switching paths** — so the last
|
|
391
|
-
edit before navigating away isn't lost.
|
|
321
|
+
Reads the file into React state and writes edits back with a debounce. `save()` cancels the pending debounce and writes immediately (the Cmd+S path), and a pending write is **flushed on unmount and before switching paths** — so the last edit before navigating away isn't lost.
|
|
392
322
|
|
|
393
323
|
| option | type | default |
|
|
394
324
|
| --- | --- | --- |
|
|
@@ -413,8 +343,7 @@ return (
|
|
|
413
343
|
);
|
|
414
344
|
```
|
|
415
345
|
|
|
416
|
-
A directory listing that stays current as the VFS changes underneath it — the
|
|
417
|
-
file-tree half of an IDE, without hand-rolling a watcher.
|
|
346
|
+
A directory listing that stays current as the VFS changes underneath it — the file-tree half of an IDE, without hand-rolling a watcher.
|
|
418
347
|
|
|
419
348
|
| option | type | default |
|
|
420
349
|
| --- | --- | --- |
|
|
@@ -422,43 +351,21 @@ file-tree half of an IDE, without hand-rolling a watcher.
|
|
|
422
351
|
| `vivari` | `VivariInstance \| null` | nearest provider's |
|
|
423
352
|
| `onError` | `(error: Error) => void` | – |
|
|
424
353
|
|
|
425
|
-
`entries` are `DirEnt`s (`name`, `isFile()`, `isDirectory()`). The watch is
|
|
426
|
-
non-recursive, since only changes directly inside `path` can alter its listing,
|
|
427
|
-
and re-reads are debounced because core reports every change with no coalescing
|
|
428
|
-
— one `npm install` fires thousands of events. A slow read can never overwrite a
|
|
429
|
-
newer one. Render one hook per expanded directory rather than one recursive
|
|
430
|
-
watch over the root.
|
|
354
|
+
`entries` are `DirEnt`s (`name`, `isFile()`, `isDirectory()`). The watch is non-recursive, since only changes directly inside `path` can alter its listing, and re-reads are debounced because core reports every change with no coalescing — one `npm install` fires thousands of events. A slow read can never overwrite a newer one. Render one hook per expanded directory rather than one recursive watch over the root.
|
|
431
355
|
|
|
432
356
|
### Re-exports
|
|
433
357
|
|
|
434
|
-
Every type on the wrapped surface is re-exported, so you never need a second
|
|
435
|
-
|
|
436
|
-
`
|
|
437
|
-
|
|
438
|
-
`
|
|
439
|
-
`FSWatcher`, `KernelMessage`, `ListenerOptions`, `MountOptions`, `OutputStream`,
|
|
440
|
-
`PortKind`, `PortListener`, `ServerReadyListener`, `SpawnOptions`, `Stats`,
|
|
441
|
-
`Unsubscribe`, `VivariEventMap`, `VivariErrorCode`, `VivariFsErrorCode`,
|
|
442
|
-
`VivariListener`, `VivariProcess`, `VivariRuntimeErrorCode`, `WatchOptions`,
|
|
443
|
-
`VivariInstance`.
|
|
444
|
-
|
|
445
|
-
Plus four values: `isCrossOriginIsolated`, `resetVfs`, and the `VivariError` /
|
|
446
|
-
`VivariFsError` classes (so `instanceof` and `error.code` work without a second
|
|
447
|
-
import).
|
|
448
|
-
|
|
449
|
-
`KernelBridge` is deliberately not re-exported — it is core's escape hatch
|
|
450
|
-
(`vivari.internal`), and reaching for it should be an explicit `@vivari/core`
|
|
451
|
-
import rather than something these bindings normalise.
|
|
358
|
+
Every type on the wrapped surface is re-exported, so you never need a second import from `@vivari/core` just to annotate a variable: `BootOptions`, `DirEnt`, `DirectoryNode`, `Encoding`, `ErrorListener`, `ExportedFile`, `ExportOptions`, `ExportResult`, `FileNode`, `FileSystemAPI`, `FileSystemTree`, `FsChangeEvent`, `FsChangeKind`, `FsChangeListener`, `FsOperationOptions`, `FSWatcher`, `KernelMessage`, `ListenerOptions`, `MountOptions`, `OutputStream`, `PortKind`, `PortListener`, `ServerReadyListener`, `SpawnOptions`, `Stats`, `Unsubscribe`, `VivariEventMap`, `VivariErrorCode`, `VivariFsErrorCode`, `VivariListener`, `VivariProcess`, `VivariRuntimeErrorCode`, `WatchOptions`, `VivariInstance`.
|
|
359
|
+
|
|
360
|
+
Plus four values: `isCrossOriginIsolated`, `resetVfs`, and the `VivariError` / `VivariFsError` classes (so `instanceof` and `error.code` work without a second import).
|
|
361
|
+
|
|
362
|
+
`KernelBridge` is deliberately not re-exported — it is core's escape hatch (`vivari.internal`), and reaching for it should be an explicit `@vivari/core` import rather than something these bindings normalise.
|
|
452
363
|
|
|
453
364
|
## A note on the name `Vivari`
|
|
454
365
|
|
|
455
|
-
`Vivari` in this package is the React **component**. The core **class** — what
|
|
456
|
-
`Vivari.boot()` returns and what every hook hands you — is re-exported as the
|
|
457
|
-
type `VivariInstance`, because in React you only ever see it in type position:
|
|
458
|
-
the hooks construct it for you.
|
|
366
|
+
`Vivari` in this package is the React **component**. The core **class** — what `Vivari.boot()` returns and what every hook hands you — is re-exported as the type `VivariInstance`, because in React you only ever see it in type position: the hooks construct it for you.
|
|
459
367
|
|
|
460
|
-
To call `Vivari.boot()` yourself, import the class from `@vivari/core` directly.
|
|
461
|
-
It's a peer dependency, so you already have exactly one copy of it.
|
|
368
|
+
To call `Vivari.boot()` yourself, import the class from `@vivari/core` directly. It's a peer dependency, so you already have exactly one copy of it.
|
|
462
369
|
|
|
463
370
|
```tsx
|
|
464
371
|
import { Vivari } from "@vivari/react"; // the <Vivari> component
|
|
@@ -468,4 +375,4 @@ import { Vivari as VivariClass } from "@vivari/core"; // the class, if you need
|
|
|
468
375
|
|
|
469
376
|
## License
|
|
470
377
|
|
|
471
|
-
MIT © Duc Trung Mai
|
|
378
|
+
MIT © Duc Trung Mai
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivari/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "React bindings for Vivari. Run Node, Bun and Python projects fully client-side in the browser, embedded in your React app.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webcontainer",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@vivari/core": "^1.
|
|
48
|
+
"@vivari/core": "^1.5.0",
|
|
49
49
|
"react": "^18.0.0 || ^19.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/react": "^19.2.18",
|
|
53
|
-
"@vivari/core": "^1.
|
|
53
|
+
"@vivari/core": "^1.5.0",
|
|
54
54
|
"react": "^19.2.8",
|
|
55
55
|
"typescript": "~6.0.2",
|
|
56
56
|
"vite": "^8.2.0"
|