@reticlehq/next 3.4.0 → 3.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 +26 -13
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -10,8 +10,10 @@ const path = require('node:path');
|
|
|
10
10
|
const crypto = require('node:crypto');
|
|
11
11
|
|
|
12
12
|
// Kept in sync with @reticlehq/core (ReticleDir / ReticleEnv). This package is plain CJS tooling and
|
|
13
|
-
// deliberately has no ESM/TS dependency on core, so
|
|
13
|
+
// deliberately has no ESM/TS dependency on core, so these values are mirrored here.
|
|
14
14
|
const PAIRING_TOKEN_DIR_ENV = 'RETICLE_PAIRING_TOKEN_DIR';
|
|
15
|
+
const STATE_DIR_ENV = 'RETICLE_STATE_DIR';
|
|
16
|
+
const PORT_ENV = 'RETICLE_PORT';
|
|
15
17
|
/**
|
|
16
18
|
* Instrument anyway, whatever NODE_ENV says — for `NODE_ENV=production next dev`.
|
|
17
19
|
*
|
|
@@ -101,15 +103,9 @@ function readPairingToken() {
|
|
|
101
103
|
* matches no daemon, which is the exact bug this function exists to remove.
|
|
102
104
|
* @returns {string | undefined}
|
|
103
105
|
*/
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* Honours the same RETICLE_PAIRING_TOKEN_DIR override the token reader uses, because it is the same
|
|
108
|
-
* directory. One override rather than two keeps a test (or a sandbox) from pointing the two halves at
|
|
109
|
-
* different places and getting a token from one daemon with the port of another.
|
|
110
|
-
*/
|
|
111
|
-
function reticleHomeDir() {
|
|
112
|
-
const override = process.env[PAIRING_TOKEN_DIR_ENV];
|
|
106
|
+
/** Pairing token and registry locations have separate overrides, matching the daemon. */
|
|
107
|
+
function reticleHomeDir(envKey = PAIRING_TOKEN_DIR_ENV) {
|
|
108
|
+
const override = process.env[envKey];
|
|
113
109
|
return override !== undefined && override.length > 0
|
|
114
110
|
? override
|
|
115
111
|
: path.join(os.homedir(), RETICLE_HOME_DIR);
|
|
@@ -131,13 +127,23 @@ const MAX_TCP_PORT = 65535;
|
|
|
131
127
|
const bridgeUrl = (port) => `ws://${RETICLE_CLIENT_HOST}:${String(port)}${RETICLE_WS_PATH}`;
|
|
132
128
|
|
|
133
129
|
/**
|
|
134
|
-
*
|
|
130
|
+
* RETICLE_PORT overrides discovery. Otherwise, follow the Vite plugin's order: a live daemon for this
|
|
135
131
|
* project, then the `port` in `.reticle.json`, and only then the `url` literal `reticle init` wrote
|
|
136
132
|
* into the generated ReticleDev component (which this value overrides page-side). The file comes
|
|
137
133
|
* before the literal because it is what the daemon and the CLI read: a user who edited it moved the
|
|
138
134
|
* daemon, and the page kept dialling the old literal with nothing saying why.
|
|
139
135
|
*/
|
|
140
|
-
function discoverDaemonUrl(
|
|
136
|
+
function discoverDaemonUrl(
|
|
137
|
+
cwd = process.cwd(),
|
|
138
|
+
home = reticleHomeDir(STATE_DIR_ENV),
|
|
139
|
+
alive = defaultIsAlive,
|
|
140
|
+
env = process.env,
|
|
141
|
+
) {
|
|
142
|
+
const requested = env[PORT_ENV];
|
|
143
|
+
if (requested !== undefined && /^\d+$/.test(requested)) {
|
|
144
|
+
const port = Number(requested);
|
|
145
|
+
if (Number.isInteger(port) && port > 0 && port <= MAX_TCP_PORT) return bridgeUrl(port);
|
|
146
|
+
}
|
|
141
147
|
let projectId;
|
|
142
148
|
let configuredPort;
|
|
143
149
|
try {
|
|
@@ -423,7 +429,14 @@ function withReticle(nextConfig = {}, options = {}) {
|
|
|
423
429
|
return {
|
|
424
430
|
...nextConfig,
|
|
425
431
|
...(allowedDevOrigins !== undefined ? { allowedDevOrigins } : {}),
|
|
426
|
-
...(supportsTurbopackKey()
|
|
432
|
+
...(supportsTurbopackKey()
|
|
433
|
+
? {
|
|
434
|
+
turbopack:
|
|
435
|
+
options.sourceMapping !== false
|
|
436
|
+
? turbopackConfig(nextConfig.turbopack)
|
|
437
|
+
: (nextConfig.turbopack ?? {}),
|
|
438
|
+
}
|
|
439
|
+
: {}),
|
|
427
440
|
// Expose the token to the client bundle as process.env.NEXT_PUBLIC_RETICLE_TOKEN (Next's convention
|
|
428
441
|
// for client-readable env), so a dev-only client connect can present it. Minted here if the file
|
|
429
442
|
// is missing: Next evaluates this once, so an empty value is frozen and a reload cannot pick a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/next",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.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": "3.
|
|
41
|
+
"@reticlehq/babel-plugin": "3.6.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"next": ">=13"
|