@reticlehq/vite-plugin 2.0.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/LICENSE +202 -0
- package/README.md +40 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/project-id.d.ts +27 -0
- package/dist/project-id.d.ts.map +1 -0
- package/dist/project-id.js +71 -0
- package/dist/project-id.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Reticle Labs
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @reticlehq/vite-plugin
|
|
2
|
+
|
|
3
|
+
One-line Vite integration for [Reticle](https://github.com/reticlehq/reticle). The plugin does the whole dev-time wiring for you:
|
|
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.
|
|
8
|
+
|
|
9
|
+
Usually installed via the umbrella package and imported from its `/vite` subpath:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i -D @reticlehq/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// vite.config.ts
|
|
17
|
+
import { defineConfig } from 'vite';
|
|
18
|
+
import react from '@vitejs/plugin-react';
|
|
19
|
+
import { reticle } from '@reticlehq/core/vite';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
plugins: [react(), reticle()],
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
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.
|
|
27
|
+
|
|
28
|
+
## Options
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
reticle({
|
|
32
|
+
port, // bridge WebSocket port; baked into connect() only when non-default
|
|
33
|
+
session, // stable session label (defaults to the SDK's auto id)
|
|
34
|
+
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()
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
MIT.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const RETICLE_VITE_PLUGIN_NAME = "reticle";
|
|
2
|
+
/**
|
|
3
|
+
* The connect code is served as a real module (not an inline <script>) so that Vite's import
|
|
4
|
+
* pipeline resolves the bare `@reticlehq/react` specifier. An inline injected script is NOT run through
|
|
5
|
+
* import resolution, so its bare import would fail in the browser. This path-like id is requested
|
|
6
|
+
* by the injected <script src> and served by the load() hook below.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RETICLE_CONNECT_MODULE = "/@reticle-connect";
|
|
9
|
+
export interface ReticleVitePluginOptions {
|
|
10
|
+
/** Bridge WebSocket port. Defaults to the SDK default; only baked into connect() when non-default. */
|
|
11
|
+
port?: number;
|
|
12
|
+
/** Stable session label for the bridge. Defaults to the SDK's auto-generated id. */
|
|
13
|
+
session?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Stable project identity. Defaults to one derived from the app's package.json name + root path,
|
|
16
|
+
* so multi-project session scoping works with zero config. Override only for special setups.
|
|
17
|
+
*/
|
|
18
|
+
projectId?: string;
|
|
19
|
+
/** Auth token forwarded to connect() when the bridge requires one. */
|
|
20
|
+
token?: string;
|
|
21
|
+
/** Stamp data-reticle-source for React 19 source mapping. Default true (harmless on React <=18). */
|
|
22
|
+
sourceMapping?: boolean;
|
|
23
|
+
/** Auto-inject the dev-gated reticle.connect() call. Default true. */
|
|
24
|
+
inject?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Structural Vite plugin shape — avoids a hard dependency on `vite` while staying assignable to its `Plugin`. */
|
|
27
|
+
export interface ReticleVitePlugin {
|
|
28
|
+
name: string;
|
|
29
|
+
apply: 'serve';
|
|
30
|
+
enforce: 'pre';
|
|
31
|
+
transform: (code: string, id: string) => {
|
|
32
|
+
code: string;
|
|
33
|
+
map: string | null;
|
|
34
|
+
} | null;
|
|
35
|
+
resolveId: (id: string) => string | null;
|
|
36
|
+
load: (id: string) => string | null;
|
|
37
|
+
transformIndexHtml: (html: string) => HtmlTag[];
|
|
38
|
+
}
|
|
39
|
+
interface HtmlTag {
|
|
40
|
+
tag: string;
|
|
41
|
+
attrs: Record<string, string>;
|
|
42
|
+
injectTo: 'body';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read the daemon's auto-provisioned pairing token (~/.reticle/pairing-token, or the
|
|
46
|
+
* RETICLE_PAIRING_TOKEN_DIR override) so the served app can present it. Node-side only — a browser
|
|
47
|
+
* sandbox can't read the file, which is exactly why a rogue localhost app can't forge it. Best-effort:
|
|
48
|
+
* undefined if the daemon hasn't started yet (the page reloads once it has). Exported for testing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readPairingToken(): string | undefined;
|
|
51
|
+
/** The body of the connect module — real imports, resolved by Vite when the module is served. */
|
|
52
|
+
export declare function connectModuleSource(options: ReticleVitePluginOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Reticle Vite plugin. Add to your `plugins` array and the entire integration is done:
|
|
55
|
+
*
|
|
56
|
+
* import { reticle } from '@reticlehq/vite-plugin';
|
|
57
|
+
* export default defineConfig({ plugins: [react(), reticle()] });
|
|
58
|
+
*
|
|
59
|
+
* `apply: 'serve'` means Vite drops the plugin entirely from `vite build` — production bundles
|
|
60
|
+
* are never instrumented. Gating is the tool's job, not a user-managed env check.
|
|
61
|
+
*/
|
|
62
|
+
export declare function reticle(options?: ReticleVitePluginOptions): ReticleVitePlugin;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAYlD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D,MAAM,WAAW,wBAAwB;IACvC,sGAAsG;IACtG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,kHAAkH;AAClH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACrF,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACzC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACpC,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;CACjD;AAED,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AA0BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAUrD;AAcD,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAG7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,wBAA6B,GAAG,iBAAiB,CAoCjF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { transformSync } from '@babel/core';
|
|
5
|
+
import reticleSource from '@reticlehq/babel-plugin';
|
|
6
|
+
import { RETICLE_DEFAULT_PORT, RETICLE_WS_PATH, ReticleDir, ReticleEnv } from '@reticlehq/core';
|
|
7
|
+
import { resolveProjectId } from './project-id.js';
|
|
8
|
+
export const RETICLE_VITE_PLUGIN_NAME = 'reticle';
|
|
9
|
+
// The React kit the host app imports the SDK from. It re-exports the browser sensor, so a single
|
|
10
|
+
// specifier yields both `reticle` (connect) and `install` (the React adapter). NOT `@reticlehq/core`
|
|
11
|
+
// — that is the isomorphic foundation and exports neither.
|
|
12
|
+
const RETICLE_PACKAGE = '@reticlehq/react';
|
|
13
|
+
/** Files we stamp with source info — JSX/TSX only. */
|
|
14
|
+
const JSX_FILE = /\.[jt]sx$/;
|
|
15
|
+
/** Rollup virtual-module ids start with a NUL byte; never transform those. */
|
|
16
|
+
const VIRTUAL_PREFIX = '\0';
|
|
17
|
+
const NODE_MODULES = 'node_modules';
|
|
18
|
+
/**
|
|
19
|
+
* The connect code is served as a real module (not an inline <script>) so that Vite's import
|
|
20
|
+
* pipeline resolves the bare `@reticlehq/react` specifier. An inline injected script is NOT run through
|
|
21
|
+
* import resolution, so its bare import would fail in the browser. This path-like id is requested
|
|
22
|
+
* by the injected <script src> and served by the load() hook below.
|
|
23
|
+
*/
|
|
24
|
+
export const RETICLE_CONNECT_MODULE = '/@reticle-connect';
|
|
25
|
+
function shouldStamp(id) {
|
|
26
|
+
if (id.startsWith(VIRTUAL_PREFIX))
|
|
27
|
+
return false;
|
|
28
|
+
if (id.includes(NODE_MODULES))
|
|
29
|
+
return false;
|
|
30
|
+
// Strip any query suffix (?worker, ?raw, ...) before matching the extension.
|
|
31
|
+
const clean = id.split('?')[0] ?? id;
|
|
32
|
+
return JSX_FILE.test(clean);
|
|
33
|
+
}
|
|
34
|
+
function stamp(code, id) {
|
|
35
|
+
const out = transformSync(code, {
|
|
36
|
+
filename: id,
|
|
37
|
+
plugins: [reticleSource],
|
|
38
|
+
parserOpts: { plugins: ['jsx', 'typescript'] },
|
|
39
|
+
sourceMaps: true,
|
|
40
|
+
configFile: false,
|
|
41
|
+
babelrc: false,
|
|
42
|
+
});
|
|
43
|
+
if (out?.code === undefined || out.code === null)
|
|
44
|
+
return null;
|
|
45
|
+
return {
|
|
46
|
+
code: out.code,
|
|
47
|
+
map: out.map === undefined || out.map === null ? null : JSON.stringify(out.map),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read the daemon's auto-provisioned pairing token (~/.reticle/pairing-token, or the
|
|
52
|
+
* RETICLE_PAIRING_TOKEN_DIR override) so the served app can present it. Node-side only — a browser
|
|
53
|
+
* sandbox can't read the file, which is exactly why a rogue localhost app can't forge it. Best-effort:
|
|
54
|
+
* undefined if the daemon hasn't started yet (the page reloads once it has). Exported for testing.
|
|
55
|
+
*/
|
|
56
|
+
export function readPairingToken() {
|
|
57
|
+
const override = process.env[ReticleEnv.PAIRING_TOKEN_DIR];
|
|
58
|
+
const dir = override !== undefined && override.length > 0 ? override : join(homedir(), ReticleDir.ROOT);
|
|
59
|
+
try {
|
|
60
|
+
const token = readFileSync(join(dir, ReticleDir.PAIRING_TOKEN_FILE), 'utf8').trim();
|
|
61
|
+
return token.length > 0 ? token : undefined;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Build the `reticle.connect()` argument literal — only includes keys the user set. */
|
|
68
|
+
function connectArgs(options) {
|
|
69
|
+
const args = {};
|
|
70
|
+
const port = options.port ?? RETICLE_DEFAULT_PORT;
|
|
71
|
+
if (port !== RETICLE_DEFAULT_PORT)
|
|
72
|
+
args['url'] = `ws://localhost:${String(port)}${RETICLE_WS_PATH}`;
|
|
73
|
+
if (options.session !== undefined)
|
|
74
|
+
args['session'] = options.session;
|
|
75
|
+
if (options.projectId !== undefined)
|
|
76
|
+
args['projectId'] = options.projectId;
|
|
77
|
+
if (options.token !== undefined)
|
|
78
|
+
args['token'] = options.token;
|
|
79
|
+
return Object.keys(args).length > 0 ? JSON.stringify(args) : '';
|
|
80
|
+
}
|
|
81
|
+
/** The body of the connect module — real imports, resolved by Vite when the module is served. */
|
|
82
|
+
export function connectModuleSource(options) {
|
|
83
|
+
const args = connectArgs(options);
|
|
84
|
+
return `import { reticle, install } from '${RETICLE_PACKAGE}';\ninstall();\nreticle.connect(${args});\n`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reticle Vite plugin. Add to your `plugins` array and the entire integration is done:
|
|
88
|
+
*
|
|
89
|
+
* import { reticle } from '@reticlehq/vite-plugin';
|
|
90
|
+
* export default defineConfig({ plugins: [react(), reticle()] });
|
|
91
|
+
*
|
|
92
|
+
* `apply: 'serve'` means Vite drops the plugin entirely from `vite build` — production bundles
|
|
93
|
+
* are never instrumented. Gating is the tool's job, not a user-managed env check.
|
|
94
|
+
*/
|
|
95
|
+
export function reticle(options = {}) {
|
|
96
|
+
const sourceMapping = options.sourceMapping !== false;
|
|
97
|
+
const inject = options.inject !== false;
|
|
98
|
+
// Resolve the stable projectId once (explicit option, else derived from package.json + cwd) so the
|
|
99
|
+
// app is identifiable across port changes with zero config.
|
|
100
|
+
const resolved = {
|
|
101
|
+
...options,
|
|
102
|
+
projectId: resolveProjectId(options.projectId, process.cwd()),
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
name: RETICLE_VITE_PLUGIN_NAME,
|
|
106
|
+
apply: 'serve',
|
|
107
|
+
enforce: 'pre',
|
|
108
|
+
transform(code, id) {
|
|
109
|
+
if (!sourceMapping || !shouldStamp(id))
|
|
110
|
+
return null;
|
|
111
|
+
return stamp(code, id);
|
|
112
|
+
},
|
|
113
|
+
resolveId(id) {
|
|
114
|
+
// Return the id verbatim so Vite serves it back to load() (the bare imports inside it then
|
|
115
|
+
// go through normal resolution). No NUL prefix: the browser requests it as a URL.
|
|
116
|
+
return inject && id === RETICLE_CONNECT_MODULE ? RETICLE_CONNECT_MODULE : null;
|
|
117
|
+
},
|
|
118
|
+
load(id) {
|
|
119
|
+
if (!inject || id !== RETICLE_CONNECT_MODULE)
|
|
120
|
+
return null;
|
|
121
|
+
// Read the token lazily per request: by the time the browser loads the app the daemon is up and
|
|
122
|
+
// has written it. An explicit token option still wins. Undefined ⇒ omitted (page reloads once up).
|
|
123
|
+
const token = resolved.token ?? readPairingToken();
|
|
124
|
+
return connectModuleSource(token !== undefined ? { ...resolved, token } : resolved);
|
|
125
|
+
},
|
|
126
|
+
transformIndexHtml() {
|
|
127
|
+
if (!inject)
|
|
128
|
+
return [];
|
|
129
|
+
return [
|
|
130
|
+
{ tag: 'script', attrs: { type: 'module', src: RETICLE_CONNECT_MODULE }, injectTo: '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
2
|
+
* Zero-config project identity for the build plugin.
|
|
3
|
+
*
|
|
4
|
+
* The whole multi-project model hinges on each app carrying a STABLE id that survives the dev server
|
|
5
|
+
* booting on a different port than usual. We derive it once, at config time, from the app's
|
|
6
|
+
* package.json name plus a short hash of its absolute root — human-readable AND unique per checkout,
|
|
7
|
+
* and unchanged when the port shifts. An explicit `projectId` option always overrides.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Turn a package name into an id-safe slug: scoped names lose the `@scope/` punctuation
|
|
11
|
+
* (`@acme/web` → `acme-web`), everything non-alphanumeric collapses to single dashes, edges trimmed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function slugifyPackageName(name: string): string;
|
|
14
|
+
/** A short, stable hex fingerprint of the absolute project root (disambiguates same-named checkouts). */
|
|
15
|
+
export declare function shortHash(input: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Derive the stable projectId from the package name (may be undefined) and the absolute root path.
|
|
18
|
+
* Pure — both inputs are passed in. Falls back to the root's folder name, then to "app".
|
|
19
|
+
*/
|
|
20
|
+
export declare function deriveProjectId(pkgName: string | undefined, rootPath: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the projectId for a plugin instance: an explicit option wins; otherwise derive from the
|
|
23
|
+
* app's package.json name + root. `cwd` and `readPkgName` are injectable so the resolution is
|
|
24
|
+
* unit-tested without touching the real filesystem.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveProjectId(explicit: string | undefined, cwd: string, readPkgName?: (dir: string) => string | undefined): string;
|
|
27
|
+
//# sourceMappingURL=project-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-id.d.ts","sourceRoot":"","sources":["../src/project-id.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,yGAAyG;AACzG,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrF;AAyBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,GAAG,EAAE,MAAM,EACX,WAAW,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAkC,GACxE,MAAM,CAGR"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-config project identity for the build plugin.
|
|
3
|
+
*
|
|
4
|
+
* The whole multi-project model hinges on each app carrying a STABLE id that survives the dev server
|
|
5
|
+
* booting on a different port than usual. We derive it once, at config time, from the app's
|
|
6
|
+
* package.json name plus a short hash of its absolute root — human-readable AND unique per checkout,
|
|
7
|
+
* and unchanged when the port shifts. An explicit `projectId` option always overrides.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { basename, dirname, join } from 'node:path';
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
/**
|
|
13
|
+
* Turn a package name into an id-safe slug: scoped names lose the `@scope/` punctuation
|
|
14
|
+
* (`@acme/web` → `acme-web`), everything non-alphanumeric collapses to single dashes, edges trimmed.
|
|
15
|
+
*/
|
|
16
|
+
export function slugifyPackageName(name) {
|
|
17
|
+
return name
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
.replace(/^@/, '')
|
|
20
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
21
|
+
.replace(/^-+|-+$/g, '');
|
|
22
|
+
}
|
|
23
|
+
/** A short, stable hex fingerprint of the absolute project root (disambiguates same-named checkouts). */
|
|
24
|
+
export function shortHash(input) {
|
|
25
|
+
return createHash('sha1').update(input).digest('hex').slice(0, 8);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derive the stable projectId from the package name (may be undefined) and the absolute root path.
|
|
29
|
+
* Pure — both inputs are passed in. Falls back to the root's folder name, then to "app".
|
|
30
|
+
*/
|
|
31
|
+
export function deriveProjectId(pkgName, rootPath) {
|
|
32
|
+
const fromName = pkgName !== undefined ? slugifyPackageName(pkgName) : '';
|
|
33
|
+
const base = fromName.length > 0 ? fromName : slugifyPackageName(basename(rootPath)) || 'app';
|
|
34
|
+
return `${base}-${shortHash(rootPath)}`;
|
|
35
|
+
}
|
|
36
|
+
/** Read the `name` from the nearest package.json at or above `startDir`, or undefined if none. */
|
|
37
|
+
function readNearestPackageName(startDir) {
|
|
38
|
+
let dir = startDir;
|
|
39
|
+
for (let depth = 0; depth < 50; depth++) {
|
|
40
|
+
const pkgPath = join(dir, 'package.json');
|
|
41
|
+
if (existsSync(pkgPath)) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
44
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
45
|
+
const name = parsed['name'];
|
|
46
|
+
if (typeof name === 'string' && name.length > 0)
|
|
47
|
+
return name;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// unreadable package.json → keep walking up
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const parent = dirname(dir);
|
|
55
|
+
if (parent === dir)
|
|
56
|
+
break; // reached filesystem root
|
|
57
|
+
dir = parent;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the projectId for a plugin instance: an explicit option wins; otherwise derive from the
|
|
63
|
+
* app's package.json name + root. `cwd` and `readPkgName` are injectable so the resolution is
|
|
64
|
+
* unit-tested without touching the real filesystem.
|
|
65
|
+
*/
|
|
66
|
+
export function resolveProjectId(explicit, cwd, readPkgName = readNearestPackageName) {
|
|
67
|
+
if (explicit !== undefined && explicit.length > 0)
|
|
68
|
+
return explicit;
|
|
69
|
+
return deriveProjectId(readPkgName(cwd), cwd);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=project-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-id.js","sourceRoot":"","sources":["../src/project-id.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAA2B,EAAE,QAAgB;IAC3E,MAAM,QAAQ,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,CAAC;IAC9F,OAAO,GAAG,IAAI,IAAI,SAAS,CAAC,QAAQ,CAAC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60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reticlehq/vite-plugin",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Vite plugin for Reticle: dev-only source-map stamping plus auto-injected reticle.connect(). apply:'serve' guarantees it never ships to production.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Reticle contributors",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/reticlehq/reticle.git",
|
|
11
|
+
"directory": "packages/vite-plugin"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/reticlehq/reticle#readme",
|
|
14
|
+
"bugs": "https://github.com/reticlehq/reticle/issues",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vite-plugin",
|
|
17
|
+
"reticle",
|
|
18
|
+
"react",
|
|
19
|
+
"devtools"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@babel/core": "^7.26.0",
|
|
36
|
+
"@reticlehq/babel-plugin": "2.0.0",
|
|
37
|
+
"@reticlehq/core": "2.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/babel__core": "^7.20.5",
|
|
41
|
+
"vite": "^7"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"vite": ">=4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"vite": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc -b",
|
|
56
|
+
"typecheck": "tsc -b",
|
|
57
|
+
"lint": "eslint src",
|
|
58
|
+
"test:unit": "vitest run src --passWithNoTests"
|
|
59
|
+
}
|
|
60
|
+
}
|