@reticlehq/next 2.4.0 → 2.6.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/index.cjs +63 -2
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -13,7 +13,6 @@ const path = require('node:path');
|
|
|
13
13
|
const PAIRING_TOKEN_DIR_ENV = 'RETICLE_PAIRING_TOKEN_DIR';
|
|
14
14
|
const PAIRING_TOKEN_FILE = 'pairing-token';
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* Read the daemon's auto-provisioned pairing token (~/.reticle/pairing-token, or the
|
|
19
18
|
* RETICLE_PAIRING_TOKEN_DIR override). Node-side only. Returns undefined if the daemon hasn't started
|
|
@@ -49,7 +48,9 @@ const LOADER_MODULE = '@reticlehq/next/loader';
|
|
|
49
48
|
function supportsTurbopackKey() {
|
|
50
49
|
try {
|
|
51
50
|
const { version } = require('next/package.json');
|
|
52
|
-
const [major, minor] = String(version)
|
|
51
|
+
const [major, minor] = String(version)
|
|
52
|
+
.split('.')
|
|
53
|
+
.map((n) => parseInt(n, 10));
|
|
53
54
|
if (!Number.isFinite(major)) return true; // unreadable version: assume modern, matching npm's default
|
|
54
55
|
if (major > 15) return true;
|
|
55
56
|
return major === 15 && Number.isFinite(minor) && minor >= 3;
|
|
@@ -83,6 +84,64 @@ function turbopackConfig(existing) {
|
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The React kit the host app imports the SDK from. Deliberately NOT a dependency of this package —
|
|
89
|
+
* it is the user's own install, probed for its version and nothing else. Declaring it here would
|
|
90
|
+
* force the React adapter onto every Next user, including the ones who never import it.
|
|
91
|
+
*/
|
|
92
|
+
const RETICLE_SDK_PACKAGE = '@reticlehq/react';
|
|
93
|
+
|
|
94
|
+
/** How far up from the resolved entry to look for the manifest beside it. */
|
|
95
|
+
const MANIFEST_SEARCH_DEPTH = 5;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resolve from the APP, not from this file. `next.config.js` is loaded with cwd at the project root,
|
|
99
|
+
* where the user's `@reticlehq/react` always is. A bare `require` resolves relative to THIS package
|
|
100
|
+
* instead, and since the SDK is deliberately not a dependency here, that lookup fails outright under
|
|
101
|
+
* pnpm's strict node_modules layout — silently, into a `catch` that returns ''. Every pnpm Next user
|
|
102
|
+
* therefore reported no `sdkVersion`, which is the one value that turns a skewed pair into a named
|
|
103
|
+
* mismatch rather than a bare -32000.
|
|
104
|
+
* @param {string} specifier
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
function resolveFromApp(specifier) {
|
|
108
|
+
return require.resolve(specifier, { paths: [process.cwd()] });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The installed SDK's package version, for the HELLO's `sdkVersion`. Mirrors
|
|
113
|
+
* `@reticlehq/vite-plugin`'s `sdkPackageVersion` — this package is plain CJS tooling with no
|
|
114
|
+
* dependency on the TS packages, so the logic is duplicated rather than imported.
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
function sdkPackageVersion() {
|
|
118
|
+
// Preferred: the package exports its own manifest. Newer SDKs do.
|
|
119
|
+
try {
|
|
120
|
+
const { version } = require(resolveFromApp(`${RETICLE_SDK_PACKAGE}/package.json`));
|
|
121
|
+
if (typeof version === 'string') return version;
|
|
122
|
+
} catch {
|
|
123
|
+
// Falls through — see below.
|
|
124
|
+
}
|
|
125
|
+
// Fallback, and it is load-bearing rather than defensive: an OLDER SDK has no `./package.json` in
|
|
126
|
+
// its exports map, and an older SDK is precisely the skew this value exists to name.
|
|
127
|
+
try {
|
|
128
|
+
let dir = path.dirname(resolveFromApp(RETICLE_SDK_PACKAGE));
|
|
129
|
+
for (let up = 0; up < MANIFEST_SEARCH_DEPTH; up++) {
|
|
130
|
+
const candidate = path.join(dir, 'package.json');
|
|
131
|
+
if (fs.existsSync(candidate)) {
|
|
132
|
+
const { version } = JSON.parse(fs.readFileSync(candidate, 'utf8'));
|
|
133
|
+
if (typeof version === 'string') return version;
|
|
134
|
+
}
|
|
135
|
+
const parent = path.dirname(dir);
|
|
136
|
+
if (parent === dir) break;
|
|
137
|
+
dir = parent;
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
// Unresolvable (not installed, exotic layout) — report nothing rather than guessing.
|
|
141
|
+
}
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
|
|
86
145
|
/**
|
|
87
146
|
* @param {import('next').NextConfig} [nextConfig]
|
|
88
147
|
* @returns {import('next').NextConfig}
|
|
@@ -107,6 +166,8 @@ function withReticle(nextConfig = {}) {
|
|
|
107
166
|
// Next 16 default — never runs the webpack branch, and a source pointer that only works on one
|
|
108
167
|
// of the two bundlers is worse than one that works on neither.
|
|
109
168
|
NEXT_PUBLIC_RETICLE_ROOT: process.cwd(),
|
|
169
|
+
// So a version-skewed pair can name itself instead of surfacing as a bare -32000.
|
|
170
|
+
NEXT_PUBLIC_RETICLE_SDK_VERSION: sdkPackageVersion(),
|
|
110
171
|
},
|
|
111
172
|
webpack(config, ctx) {
|
|
112
173
|
config.module = config.module || { rules: [] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/next",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/core": "^7.26.0",
|
|
41
|
-
"@reticlehq/babel-plugin": "2.
|
|
41
|
+
"@reticlehq/babel-plugin": "2.6.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"next": ">=13"
|