@octane-xplat/patches 0.9.0 → 0.11.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.
@@ -1,3 +1,36 @@
1
+ diff --git a/helpers/project.js b/helpers/project.js
2
+ index ef8a029f7e6e66cdeaa344a6af18af28145b8b05..b06cce4f6909d61b538295124ebb1d80a1eb31bf 100644
3
+ --- a/helpers/project.js
4
+ +++ b/helpers/project.js
5
+ @@ -73,7 +73,11 @@ function denoConfigHasWorkspace(dir) {
6
+ * - `lerna.json`
7
+ * - `nx.json` (Nx)
8
+ * - `rush.json` (Rush)
9
+ - * - `turbo.json` (Turborepo)
10
+ + * - `turbo.json` (Turborepo) — NOT self-declaring: Turborepo scatters
11
+ + * per-package `turbo.json` task configs (`"extends": ["//"]`) into every
12
+ + * workspace package, so the file alone marks a package dir, not a root.
13
+ + * Real turbo roots still resolve through their workspace declaration
14
+ + * (`pnpm-workspace.yaml`, `lerna.json`, or `package.json#workspaces`)
15
+ * - `deno.json` / `deno.jsonc` containing a `workspace` field
16
+ * - `package.json` containing a `workspaces` field (npm/yarn workspaces)
17
+ *
18
+ @@ -106,6 +110,15 @@ export function findMonorepoWorkspaceRoot(start = getProjectRootPath()) {
19
+ return current;
20
+ continue;
21
+ }
22
+ + if (marker === 'turbo.json') {
23
+ + // turbo.json is not self-declaring: Turborepo writes
24
+ + // per-package task configs (`"extends": ["//"]`) into
25
+ + // workspace packages, so a lone turbo.json marks a package
26
+ + // dir, not a root. Every real turbo root still resolves —
27
+ + // its workspace is declared by pnpm-workspace.yaml,
28
+ + // lerna.json, or package.json#workspaces.
29
+ + continue;
30
+ + }
31
+ if (existsSync(join(current, marker)))
32
+ return current;
33
+ }
1
34
  diff --git a/helpers/ts-config-paths.js b/helpers/ts-config-paths.js
2
35
  index 27013b5c8f78a72b6e6df903ac36f72fc0d75c1a..53a2e7d489ab91593cbec47ee6fb640fc56c786f 100644
3
36
  --- a/helpers/ts-config-paths.js
@@ -172,8 +205,127 @@ index 4a6575cb00a6aeecbbb7ac5ccac3268cb10d7f54..dc70055007e26117b76fbb9d2f4f17fa
172
205
  }
173
206
  // Vite 8 oxc runtime helpers (decorators etc.) — emitted as
174
207
  // `/@id/__x00__@oxc-project+runtime@<ver>/helpers/<name>.js`. These are
208
+ diff --git a/hmr/server/websocket-module-specifiers.js b/hmr/server/websocket-module-specifiers.js
209
+ index 74f50a77f48f3873aebf375a29d06b16c29440a3..cc196fb6b92d48179bf8e124ba2a2aa9b13796f9 100644
210
+ --- a/hmr/server/websocket-module-specifiers.js
211
+ +++ b/hmr/server/websocket-module-specifiers.js
212
+ @@ -1,4 +1,4 @@
213
+ -import { existsSync, readdirSync, readFileSync, realpathSync } from 'fs';
214
+ +import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'fs';
215
+ import * as path from 'path';
216
+ import * as PAT from './constants.js';
217
+ import { getVendorManifest, resolveVendorSpecifier } from '../shared/vendor/registry.js';
218
+ @@ -328,6 +328,60 @@ export function resolveVendorFromCandidate(specifier) {
219
+ }
220
+ return null;
221
+ }
222
+ +const depFallbackDirsCache = new Map();
223
+ +/**
224
+ + * `node_modules` dirs reachable through the app's dependency specs rather than
225
+ + * its workspace layout — consulted when neither the project root nor the
226
+ + * workspace root can anchor a served `/node_modules/` tail:
227
+ + * - `link:`/`file:`/`portal:` deps keep their own `node_modules` at the real
228
+ + * target; a linked package's transitive deps never reach the app's store.
229
+ + * - pnpm's isolated virtual store keeps every non-hoisted package under
230
+ + * `node_modules/.pnpm/<name>@<ver>/node_modules/`.
231
+ + * Importer info is gone from the URL — first hit wins, same as the workspace
232
+ + * scan above. Cached per project root; the set only changes on install.
233
+ + */
234
+ +function listDepFallbackDirs(projectRoot) {
235
+ + const cached = depFallbackDirsCache.get(projectRoot);
236
+ + if (cached) {
237
+ + return cached;
238
+ + }
239
+ + const dirs = [];
240
+ + const pushIfPresent = (dir) => {
241
+ + if (existsSync(dir))
242
+ + dirs.push(dir);
243
+ + };
244
+ + const pnpmStore = path.join(projectRoot, 'node_modules', '.pnpm');
245
+ + try {
246
+ + for (const entry of readdirSync(pnpmStore, { withFileTypes: true })) {
247
+ + if (entry.isDirectory() && !entry.name.startsWith('.')) {
248
+ + pushIfPresent(path.join(pnpmStore, entry.name, 'node_modules'));
249
+ + }
250
+ + }
251
+ + }
252
+ + catch {
253
+ + }
254
+ + try {
255
+ + const pkg = JSON.parse(readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
256
+ + for (const section of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
257
+ + for (const spec of Object.values(pkg[section] ?? {})) {
258
+ + const target = /^(?:link|file|portal):(.+)$/.exec(String(spec))?.[1];
259
+ + if (!target)
260
+ + continue;
261
+ + try {
262
+ + const depDir = realpathSync(path.resolve(projectRoot, target));
263
+ + if (statSync(depDir).isDirectory())
264
+ + pushIfPresent(path.join(depDir, 'node_modules'));
265
+ + }
266
+ + catch {
267
+ + }
268
+ + }
269
+ + }
270
+ + }
271
+ + catch {
272
+ + }
273
+ + depFallbackDirsCache.set(projectRoot, dirs);
274
+ + return dirs;
275
+ +}
276
+ const workspaceNodeModulesDirsCache = new Map();
277
+ /**
278
+ * `node_modules` dirs that can hold a package the served URL no longer
279
+ @@ -428,6 +482,16 @@ export function resolveCandidateFilePath(candidate, projectRoot, workspaceRoot)
280
+ }
281
+ }
282
+ }
283
+ + // Deps reachable only through the app's dependency specs — linked-package
284
+ + // node_modules, pnpm's virtual store — still resolve to real files.
285
+ + if (cleaned.includes('/node_modules/')) {
286
+ + const tail = cleaned.slice(cleaned.lastIndexOf('/node_modules/') + '/node_modules/'.length);
287
+ + for (const nmDir of listDepFallbackDirs(projectRoot)) {
288
+ + const absPath = path.resolve(nmDir, tail);
289
+ + if (absPath.startsWith(nmDir + path.sep) && existsSync(absPath))
290
+ + return absPath;
291
+ + }
292
+ + }
293
+ return null;
294
+ }
295
+ /**
296
+ @@ -557,22 +621,17 @@ export function filterExistingNodeModulesTransformCandidates(spec, candidates, p
297
+ // through to the existing project/workspace logic.
298
+ }
299
+ if (mapped === null) {
300
+ - if (!hasDistinctWorkspaceRoot) {
301
+ + const relFromProject = path.relative(resolvedProjectRoot, resolved);
302
+ + const insideProjectRoot = relFromProject !== '' && !relFromProject.startsWith('..') && !path.isAbsolute(relFromProject);
303
+ + if (insideProjectRoot) {
304
+ mapped = candidate;
305
+ }
306
+ else {
307
+ - const relFromProject = path.relative(resolvedProjectRoot, resolved);
308
+ - const insideProjectRoot = relFromProject !== '' && !relFromProject.startsWith('..') && !path.isAbsolute(relFromProject);
309
+ - if (insideProjectRoot) {
310
+ - mapped = candidate;
311
+ - }
312
+ - else {
313
+ - // Hoisted `node_modules/<pkg>/...` file lives above projectRoot.
314
+ - // Rewrite the URL to its fs-anchored form so Vite reads it directly
315
+ - // instead of bouncing through bare-specifier resolution that the
316
+ - // hoisted package's `exports` field may refuse.
317
+ - mapped = `/@fs${resolved.replace(/\\/g, '/')}${querySuffix}`;
318
+ - }
319
+ + // File resolves outside the project root — hoisted workspace
320
+ + // node_modules, pnpm's `.pnpm` store, or a link:/file:/portal:
321
+ + // dep's own node_modules. Serve the fs-anchored URL so Vite
322
+ + // reads it directly; the root-relative URL would miss.
323
+ + mapped = `/@fs${resolved.replace(/\\/g, '/')}${querySuffix}`;
324
+ }
325
+ }
326
+ if (seen.has(mapped))
175
327
  diff --git a/hmr/server/websocket-ns-m-request.js b/hmr/server/websocket-ns-m-request.js
176
- index a11fbd5d24579cdf572a91f70cb06561bfa43cd0..75906db5f3c2cb552b947388a21d29918285849d 100644
328
+ index a11fbd5d24579cdf572a91f70cb06561bfa43cd0..c887334efce2c2f6cf85c7508276109467ff3737 100644
177
329
  --- a/hmr/server/websocket-ns-m-request.js
178
330
  +++ b/hmr/server/websocket-ns-m-request.js
179
331
  @@ -27,10 +27,15 @@ const MODULE_CANDIDATE_EXTS = ['ts', 'js', 'tsx', 'jsx', 'mjs', 'mts', 'cts', 'v
@@ -194,6 +346,21 @@ index a11fbd5d24579cdf572a91f70cb06561bfa43cd0..75906db5f3c2cb552b947388a21d2991
194
346
  }
195
347
  candidates.push(...MODULE_CANDIDATE_EXTS.map((ext) => `${base}.${ext}`));
196
348
  }
349
+ @@ -149,8 +154,12 @@ export function resolveFsAnchoredSpec(spec, serverRoot, workspaceRoot) {
350
+ for (const root of roots) {
351
+ const rootPosix = root.replace(/\\/g, '/').replace(/\/$/, '');
352
+ const fsId = `/@fs${rootPosix}${spec.startsWith('/') ? '' : '/'}${spec}`;
353
+ - if (resolveCandidateFilePath(fsId, serverRoot, workspaceRoot)) {
354
+ - return fsId;
355
+ + // The fs id is a guess composed under a root — serve the path the
356
+ + // resolver actually found (it may live in a dep's own node_modules,
357
+ + // outside both roots).
358
+ + const resolved = resolveCandidateFilePath(fsId, serverRoot, workspaceRoot);
359
+ + if (resolved) {
360
+ + return `/@fs${resolved.replace(/\\/g, '/')}`;
361
+ }
362
+ }
363
+ return null;
197
364
  diff --git a/hmr/server/websocket-served-module-helpers.js b/hmr/server/websocket-served-module-helpers.js
198
365
  index b9e3ab67eb4ae7c9b12bc4b02b9aa3660d712644..f857f4a5a5956af229e447ed04bf1a52a90c6399 100644
199
366
  --- a/hmr/server/websocket-served-module-helpers.js