@reticlehq/next 2.13.1 → 3.1.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.
Files changed (3) hide show
  1. package/index.cjs +22 -13
  2. package/index.d.ts +11 -1
  3. package/package.json +3 -3
package/index.cjs CHANGED
@@ -28,10 +28,9 @@ const RETICLE_WS_PATH = '/reticle';
28
28
  /**
29
29
  * Read the pairing token, or create it — whichever process gets there first.
30
30
  *
31
- * The token used to be read ONCE, when next.config was evaluated. Start `next dev` before the
32
- * daemon and that value was empty, every page was refused, and a reload could not help: there was
33
- * no token page-side to pick up. The comment that claimed "the client then connects without a token
34
- * and the page reloads once it has" was false for Next.
31
+ * Read once at `next.config` evaluation is NOT enough: start `next dev` before the daemon and the
32
+ * value is empty, every page is refused, and a reload cannot help because there is no token
33
+ * page-side to pick up.
35
34
  *
36
35
  * Same mint as the daemon (24 random bytes, 0600 file, never overwrite). An existing token is
37
36
  * reused so a plugin-injected page keeps working after the daemon bounces.
@@ -260,9 +259,17 @@ function sdkPackageVersion() {
260
259
 
261
260
  /**
262
261
  * @param {import('next').NextConfig} [nextConfig]
262
+ * @param {{ sourceMapping?: boolean }} [options] Pass `{ sourceMapping: false }` for an app that
263
+ * renders through a non-DOM React reconciler — react-three-fiber, react-pdf, ink. A lowercase JSX
264
+ * tag is a host element in every React renderer, but only React DOM's host instances are nodes
265
+ * that take attributes. R3F reads the dashed `data-reticle-source` as a pierced property path,
266
+ * walks `data` -> `reticle` on a three.js instance that has no `data`, and throws from the commit
267
+ * phase — unmounting the whole tree to a white screen. The babel plugin's allowlist keeps the
268
+ * stamp off `<mesh>`, and cannot help with the tags that COLLIDE: `<line>` is SVG's AND
269
+ * `THREE.Line`; `<audio>` is both. Turning the stamp off costs source pointers, not the app.
263
270
  * @returns {import('next').NextConfig}
264
271
  */
265
- function withReticle(nextConfig = {}) {
272
+ function withReticle(nextConfig = {}, options = {}) {
266
273
  // Production builds are untouched — this is a dev-time aid only.
267
274
  if (process.env.NODE_ENV === 'production') return nextConfig;
268
275
 
@@ -292,14 +299,16 @@ function withReticle(nextConfig = {}) {
292
299
  NEXT_PUBLIC_RETICLE_SDK_VERSION: sdkPackageVersion(),
293
300
  },
294
301
  webpack(config, ctx) {
295
- config.module = config.module || { rules: [] };
296
- config.module.rules = config.module.rules || [];
297
- config.module.rules.push({
298
- test: /\.(t|j)sx$/,
299
- exclude: /node_modules/,
300
- enforce: 'pre',
301
- use: [{ loader: require.resolve('./loader.cjs') }],
302
- });
302
+ if (options.sourceMapping !== false) {
303
+ config.module = config.module || { rules: [] };
304
+ config.module.rules = config.module.rules || [];
305
+ config.module.rules.push({
306
+ test: /\.(t|j)sx$/,
307
+ exclude: /node_modules/,
308
+ enforce: 'pre',
309
+ use: [{ loader: require.resolve('./loader.cjs') }],
310
+ });
311
+ }
303
312
  return typeof userWebpack === 'function' ? userWebpack(config, ctx) : config;
304
313
  },
305
314
  };
package/index.d.ts CHANGED
@@ -1,2 +1,12 @@
1
1
  /** Wrap a Next.js config to add dev-only source-file mapping (data-reticle-source), keeping SWC. */
2
- export function withReticle<T = unknown>(nextConfig?: T): T;
2
+ export function withReticle<T = unknown>(
3
+ nextConfig?: T,
4
+ options?: {
5
+ /**
6
+ * Stamp `data-reticle-source` on JSX host elements. Default true. Set false for an app that
7
+ * renders through a non-DOM React reconciler (react-three-fiber, react-pdf, ink), where a
8
+ * lowercase tag is not an element and the stamp crashes the app at commit time.
9
+ */
10
+ sourceMapping?: boolean;
11
+ },
12
+ ): T;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@reticlehq/next",
3
- "version": "2.13.1",
3
+ "version": "3.1.0",
4
4
  "description": "Next.js helper for Reticle: keeps SWC, adds source-file mapping via a dev-only webpack pre-loader (data-reticle-source).",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Reticle contributors",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/reticlehq/reticle.git",
10
- "directory": "packages/next"
10
+ "directory": "adapters/build/next"
11
11
  },
12
12
  "homepage": "https://github.com/reticlehq/reticle#readme",
13
13
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@babel/core": "^7.26.0",
41
- "@reticlehq/babel-plugin": "2.13.1"
41
+ "@reticlehq/babel-plugin": "3.1.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "next": ">=13"