@reticlehq/vite-plugin 2.7.0 → 2.9.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/README.md CHANGED
@@ -2,39 +2,60 @@
2
2
 
3
3
  One-line Vite integration for [Reticle](https://github.com/reticlehq/reticle). The plugin does the whole dev-time wiring for you:
4
4
 
5
- - **Source mapping** stamps `data-reticle-source="file:line:col"` on JSX host elements (via [`@reticlehq/babel-plugin`](https://www.npmjs.com/package/@reticlehq/babel-plugin)) so `reticle_inspect` can report the component's source file needed on React 19.
6
- - **Auto-connect** injects a dev-only `install(); reticle.connect()` so you don't touch your entry file.
7
- - **Production-safe by construction** `apply: 'serve'` means Vite drops the plugin entirely from `vite build`. There is no env gate to forget; instrumentation cannot reach a production bundle.
5
+ - **Source mapping**: stamps `data-reticle-source="file:line:col"` on JSX host elements (via [`@reticlehq/babel-plugin`](https://www.npmjs.com/package/@reticlehq/babel-plugin)) so `reticle_inspect` can report the component's source file. Needed on React 19.
6
+ - **Auto-connect**: injects a dev-only `install(); reticle.connect()` into your entry module, so you never touch the entry file yourself.
7
+ - **Svelte source mapping**: the same stamp on Svelte markup, applied before `@sveltejs/vite-plugin-svelte` compiles it.
8
+ - **Dependency pre-bundling**: declares the SDK's CJS runtime deps in `optimizeDeps` so the SDK loads on linked and monorepo setups.
9
+ - **Production-safe by construction**: `apply: 'serve'` means Vite drops the plugin entirely from `vite build`. There is no env gate to forget; instrumentation cannot reach a production web bundle.
8
10
 
9
- Usually installed via the umbrella package and imported from its `/vite` subpath:
11
+ ## Install
10
12
 
11
13
  ```bash
12
- npm i -D @reticlehq/core
14
+ npm i -D @reticlehq/react @reticlehq/vite-plugin
13
15
  ```
14
16
 
17
+ `@reticlehq/react` is the runtime kit the injected `connect()` imports (it re-exports the browser SDK). `vite >= 4` is a peer dependency.
18
+
19
+ ## Use
20
+
15
21
  ```ts
16
22
  // vite.config.ts
17
23
  import { defineConfig } from 'vite';
18
24
  import react from '@vitejs/plugin-react';
19
- import { reticle } from '@reticlehq/core/vite';
25
+ import { reticle } from '@reticlehq/vite-plugin';
20
26
 
21
27
  export default defineConfig({
22
- plugins: [react(), reticle()],
28
+ plugins: [reticle(), react()],
23
29
  });
24
30
  ```
25
31
 
26
- That is the entire integration no entry-file edit, no Babel-plugin wiring, no env gating. `npx @reticlehq/core init` adds this line for you automatically in a Vite project.
32
+ That is the entire integration: no entry-file edit, no Babel-plugin wiring, no env gating. `npx @reticlehq/server init` writes this line for you in a Vite project, inserting `reticle()` right after the opening `[`, which is why that is the order shown here.
33
+
34
+ Array order does not actually matter: the plugin declares `enforce: 'pre'`, so Vite runs it before `@vitejs/plugin-react` wherever you put it.
27
35
 
28
36
  ## Options
29
37
 
30
38
  ```ts
31
39
  reticle({
32
40
  port, // bridge WebSocket port; baked into connect() only when non-default
33
- session, // stable session label (defaults to the SDK's auto id)
41
+ session, // stable session label; defaults to a fresh per-tab id
42
+ projectId, // stable project identity; defaults to one derived from package.json name + root
34
43
  token, // auth token forwarded to connect() when the bridge requires one
35
- sourceMapping, // default true stamp data-reticle-source (harmless on React <=18)
36
- inject, // default true auto-inject reticle.connect()
44
+ root, // project root, so reported source paths are repo-relative
45
+ sdkVersion, // installed SDK version, so a skewed pair can name itself
46
+ sourceMapping, // default true; stamp data-reticle-source (harmless on React <=18)
47
+ inject, // default true; auto-inject reticle.connect()
48
+ captureNetworkBodies, // default false; record request/response bodies on reticle_network
49
+ allowNonLocalhost, // default false; allow a page/bridge that is not on localhost (needs a token)
50
+ desktop, // default false; also apply to `vite build`, for an Electron/Tauri renderer
51
+ onWarn, // where a diagnostic goes; defaults to the console
37
52
  });
38
53
  ```
39
54
 
40
- MIT.
55
+ `captureNetworkBodies` is off by default because a body is the one part of a request that routinely carries a card number, a token, or a customer's address. It is also settable as `VITE_RETICLE_CAPTURE_BODIES=1` for a single debugging session.
56
+
57
+ `allowNonLocalhost` is for a dev server that cannot be served on localhost — a host-based multi-tenant frontend, or an app with cookie-scoped auth on a custom dev hostname. It is **not sufficient on its own**: the SDK also requires a pairing token outside localhost, and refuses with "a pairing token is required outside localhost" when it is missing. The plugin supplies one automatically from the daemon's `~/.reticle/pairing-token`, so a running daemon is normally all it takes — pass `token` yourself only when that file is unreachable. A bridge that is itself non-local must also use `wss://`. Settable as `VITE_RETICLE_ALLOW_NON_LOCALHOST=1` for a single session.
58
+
59
+ `desktop: true` makes the plugin apply to `vite build` as well and calls `connect()` with `allowInProduction`, because a packaged desktop renderer is a production build with no dev server. That means an instrumented production bundle, which a web app must never ship. Keep it behind your own dev-only build target.
60
+
61
+ Apache-2.0.