@redocly/openapi-core 0.0.0-snapshot.1778704883 → 0.0.0-snapshot.1778773569
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/lib/config/plugin-import-tree.d.ts +17 -0
- package/lib/config/plugin-import-tree.d.ts.map +1 -0
- package/lib/config/plugin-import-tree.js +118 -0
- package/lib/config/plugin-import-tree.js.map +1 -0
- package/lib/config/plugins-cache.d.ts.map +1 -1
- package/lib/config/plugins-cache.js +23 -6
- package/lib/config/plugins-cache.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TEMP: debug-only plugin import tree on `clearPluginsCache`. Tree is built
|
|
3
|
+
* from disk by parsing `import` / `require` statements; every node carries the
|
|
4
|
+
* same `?v=<cacheVersion>` because that's what the loader hook propagates.
|
|
5
|
+
*
|
|
6
|
+
* Removal: delete this file and the matching imports + calls in `plugins-cache.ts`.
|
|
7
|
+
*/
|
|
8
|
+
export type PluginClearLogEntry = {
|
|
9
|
+
absolutePath: string;
|
|
10
|
+
entryHref: string;
|
|
11
|
+
/** Same value as `?v=` on the entry URL. */
|
|
12
|
+
version: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function logHookStatus(): void;
|
|
15
|
+
/** TEMP: after `clearPluginsCache` — tree with current `?v=<cacheVersion>` URLs. */
|
|
16
|
+
export declare function logClearPluginImportTrees(entries: PluginClearLogEntry[], versionParam: string): void;
|
|
17
|
+
//# sourceMappingURL=plugin-import-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-import-tree.d.ts","sourceRoot":"","sources":["../../src/config/plugin-import-tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAgGF,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,MAAM,GACnB,IAAI,CAgBN"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TEMP: debug-only plugin import tree on `clearPluginsCache`. Tree is built
|
|
3
|
+
* from disk by parsing `import` / `require` statements; every node carries the
|
|
4
|
+
* same `?v=<cacheVersion>` because that's what the loader hook propagates.
|
|
5
|
+
*
|
|
6
|
+
* Removal: delete this file and the matching imports + calls in `plugins-cache.ts`.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import module from 'node:module';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import * as url from 'node:url';
|
|
12
|
+
const EXTENSIONS = ['', '.js', '.mjs', '.cjs', '.ts', '.tsx'];
|
|
13
|
+
const INDEX_EXTENSIONS = ['.js', '.mjs', '.cjs', '.ts'];
|
|
14
|
+
const ESM_IMPORT_RE = /^[ \t]*import\s+(?:.+?\s+from\s+)?['"](\.\.?\/[^'"]+)['"]/gm;
|
|
15
|
+
const CJS_REQUIRE_RE = /(?:^|[^.\w])require\s*\(\s*['"](\.\.?\/[^'"]+)['"]\s*\)/g;
|
|
16
|
+
const DYNAMIC_IMPORT_RE = /(?:^|[^.\w])import\s*\(\s*['"](\.\.?\/[^'"]+)['"]\s*\)/g;
|
|
17
|
+
function resolveRelativeImport(spec, fromDir) {
|
|
18
|
+
for (const ext of EXTENSIONS) {
|
|
19
|
+
const candidate = path.resolve(fromDir, spec + ext);
|
|
20
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile())
|
|
21
|
+
return candidate;
|
|
22
|
+
}
|
|
23
|
+
for (const ext of INDEX_EXTENSIONS) {
|
|
24
|
+
const candidate = path.resolve(fromDir, spec, `index${ext}`);
|
|
25
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile())
|
|
26
|
+
return candidate;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function parseImports(source, fromDir) {
|
|
31
|
+
const resolved = [];
|
|
32
|
+
const push = (spec) => {
|
|
33
|
+
const r = resolveRelativeImport(spec, fromDir);
|
|
34
|
+
if (r)
|
|
35
|
+
resolved.push(r);
|
|
36
|
+
};
|
|
37
|
+
let m;
|
|
38
|
+
ESM_IMPORT_RE.lastIndex = 0;
|
|
39
|
+
while ((m = ESM_IMPORT_RE.exec(source)))
|
|
40
|
+
push(m[1]);
|
|
41
|
+
CJS_REQUIRE_RE.lastIndex = 0;
|
|
42
|
+
while ((m = CJS_REQUIRE_RE.exec(source)))
|
|
43
|
+
push(m[1]);
|
|
44
|
+
DYNAMIC_IMPORT_RE.lastIndex = 0;
|
|
45
|
+
while ((m = DYNAMIC_IMPORT_RE.exec(source)))
|
|
46
|
+
push(m[1]);
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
function fileHrefWithVersion(absPath, versionParam, version) {
|
|
50
|
+
const u = url.pathToFileURL(absPath);
|
|
51
|
+
u.searchParams.set(versionParam, String(version));
|
|
52
|
+
return u.href;
|
|
53
|
+
}
|
|
54
|
+
function buildImportTree(filePath, versionParam, version, ancestors = new Set()) {
|
|
55
|
+
const label = fileHrefWithVersion(filePath, versionParam, version);
|
|
56
|
+
const node = { label, children: [] };
|
|
57
|
+
if (ancestors.has(filePath)) {
|
|
58
|
+
node.cycle = true;
|
|
59
|
+
return node;
|
|
60
|
+
}
|
|
61
|
+
let source = '';
|
|
62
|
+
try {
|
|
63
|
+
source = fs.readFileSync(filePath, 'utf8');
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
const next = new Set(ancestors);
|
|
69
|
+
next.add(filePath);
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
for (const resolved of parseImports(source, path.dirname(filePath))) {
|
|
72
|
+
if (seen.has(resolved))
|
|
73
|
+
continue;
|
|
74
|
+
seen.add(resolved);
|
|
75
|
+
node.children.push(buildImportTree(resolved, versionParam, version, next));
|
|
76
|
+
}
|
|
77
|
+
return node;
|
|
78
|
+
}
|
|
79
|
+
function renderTree(node, prefix = '', isLast = true, depth = 0) {
|
|
80
|
+
const branch = depth === 0 ? '' : isLast ? '└─ ' : '├─ ';
|
|
81
|
+
const cycle = node.cycle ? ' [CYCLE]' : '';
|
|
82
|
+
const lines = [prefix + branch + node.label + cycle];
|
|
83
|
+
if (node.cycle)
|
|
84
|
+
return lines;
|
|
85
|
+
const childPrefix = prefix + (depth === 0 ? '' : isLast ? ' ' : '│ ');
|
|
86
|
+
node.children.forEach((c, i) => lines.push(...renderTree(c, childPrefix, i === node.children.length - 1, depth + 1)));
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
let clearCounter = 0;
|
|
90
|
+
// Off by default; set `REDOCLY_DEBUG_PLUGINS_CACHE=1` (or any truthy value) to
|
|
91
|
+
// enable. Keeps stderr clean for snapshot/smoke tests.
|
|
92
|
+
const DEBUG = !!process.env.REDOCLY_DEBUG_PLUGINS_CACHE;
|
|
93
|
+
export function logHookStatus() {
|
|
94
|
+
if (!DEBUG)
|
|
95
|
+
return;
|
|
96
|
+
const ok = typeof module.registerHooks === 'function';
|
|
97
|
+
process.stderr.write(`[plugins-cache] module.registerHooks=${ok ? 'available' : 'missing'}\n`);
|
|
98
|
+
}
|
|
99
|
+
/** TEMP: after `clearPluginsCache` — tree with current `?v=<cacheVersion>` URLs. */
|
|
100
|
+
export function logClearPluginImportTrees(entries, versionParam) {
|
|
101
|
+
if (!DEBUG)
|
|
102
|
+
return;
|
|
103
|
+
clearCounter += 1;
|
|
104
|
+
const out = [];
|
|
105
|
+
out.push('─'.repeat(70));
|
|
106
|
+
out.push(`[plugins-cache] clearPluginsCache #${clearCounter} — current import tree`);
|
|
107
|
+
if (entries.length === 0) {
|
|
108
|
+
out.push(' (no plugin paths were in cache)');
|
|
109
|
+
}
|
|
110
|
+
entries.forEach((e, i) => {
|
|
111
|
+
const isLast = i === entries.length - 1;
|
|
112
|
+
const root = buildImportTree(e.absolutePath, versionParam, e.version);
|
|
113
|
+
renderTree(root, '', isLast, 1).forEach((l) => out.push(' ' + l));
|
|
114
|
+
});
|
|
115
|
+
out.push('─'.repeat(70));
|
|
116
|
+
process.stderr.write(out.join('\n') + '\n');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=plugin-import-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-import-tree.js","sourceRoot":"","sources":["../../src/config/plugin-import-tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAehC,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAExD,MAAM,aAAa,GAAG,6DAA6D,CAAC;AACpF,MAAM,cAAc,GAAG,0DAA0D,CAAC;AAClF,MAAM,iBAAiB,GAAG,yDAAyD,CAAC;AAEpF,SAAS,qBAAqB,CAAC,IAAY,EAAE,OAAe;IAC1D,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;QACpD,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,SAAS,CAA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zB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins-cache.d.ts","sourceRoot":"","sources":["../../src/config/plugins-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins-cache.d.ts","sourceRoot":"","sources":["../../src/config/plugins-cache.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAsDzC,wBAAgB,eAAe,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAEjF;AAED,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAEpF;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAuBD,eAAO,MAAM,iBAAiB,QAAO,IAmBpC,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAQlC"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import module from 'node:module';
|
|
2
2
|
import * as url from 'node:url';
|
|
3
3
|
import { logger } from '../logger.js';
|
|
4
|
+
// ─── LOGGING (TEMP, language-server) — remove this import + all `LOGGING` blocks
|
|
5
|
+
// below together with `plugin-import-tree.ts`. ───
|
|
6
|
+
import { logClearPluginImportTrees, logHookStatus } from './plugin-import-tree.js';
|
|
4
7
|
const pluginsCache = new Map();
|
|
5
|
-
// Marks plugin-scoped URLs and carries the cache-bust version.
|
|
6
8
|
const PLUGIN_VERSION_PARAM = 'v';
|
|
7
|
-
// Cleared in `clearPluginsCache()` so the next load re-walks the directory; if any
|
|
8
|
-
// file changed on disk, the new `?v=` busts Node's ESM cache.
|
|
9
9
|
let cacheVersion = 0;
|
|
10
10
|
let isEsmCacheBustHookRegistered = false;
|
|
11
|
+
// Installs a Node ESM resolve hook (requires Node >= 22.15) that propagates
|
|
12
|
+
// `?v=<cacheVersion>` from a plugin URL down to its nested `file:` imports.
|
|
13
|
+
// Together with `cacheVersion` bumping in `clearPluginsCache`, this makes one
|
|
14
|
+
// clear invalidate the whole plugin graph in Node's ESM cache, not just the entry.
|
|
11
15
|
function registerEsmCacheBustHook() {
|
|
12
16
|
module.registerHooks({
|
|
17
|
+
// `specifier` — raw import string (e.g. './utils.js', 'node:util').
|
|
18
|
+
// `context` — { parentURL, conditions, importAttributes }.
|
|
19
|
+
// `nextResolve` — delegate to the remaining hooks + Node's default resolver.
|
|
13
20
|
resolve(specifier, context, nextResolve) {
|
|
14
21
|
const result = nextResolve(specifier, context);
|
|
15
22
|
if (!result.url.startsWith('file:'))
|
|
16
23
|
return result;
|
|
24
|
+
// Top-level entry: no parent URL to inherit a version from.
|
|
17
25
|
if (!context.parentURL)
|
|
18
26
|
return result;
|
|
19
27
|
const parentVersion = new URL(context.parentURL).searchParams.get(PLUGIN_VERSION_PARAM);
|
|
@@ -24,10 +32,8 @@ function registerEsmCacheBustHook() {
|
|
|
24
32
|
return result;
|
|
25
33
|
if (childURL.searchParams.has(PLUGIN_VERSION_PARAM))
|
|
26
34
|
return result;
|
|
27
|
-
// Propagate parent's version down the whole plugin graph so every nested
|
|
28
|
-
// URL is busted together with the entry.
|
|
29
35
|
childURL.searchParams.set(PLUGIN_VERSION_PARAM, parentVersion);
|
|
30
|
-
return { ...result, url: childURL.href
|
|
36
|
+
return { ...result, url: childURL.href };
|
|
31
37
|
},
|
|
32
38
|
});
|
|
33
39
|
}
|
|
@@ -54,6 +60,8 @@ export function setCachedPlugins(absolutePluginPath, plugins) {
|
|
|
54
60
|
export function getPluginCacheVersion() {
|
|
55
61
|
return cacheVersion;
|
|
56
62
|
}
|
|
63
|
+
// Walks the plugin's CJS `require.cache` subgraph and deletes each entry,
|
|
64
|
+
// skipping anything under `node_modules` so npm singletons survive the clear.
|
|
57
65
|
function evictPluginFromCjsCache(pluginPath) {
|
|
58
66
|
const nodeRequire = module.createRequire(pluginPath);
|
|
59
67
|
const visited = new Set();
|
|
@@ -83,6 +91,13 @@ export const clearPluginsCache = () => {
|
|
|
83
91
|
pluginsCache.clear();
|
|
84
92
|
cacheVersion += 1;
|
|
85
93
|
ensureEsmCacheBustHook();
|
|
94
|
+
// LOGGING (TEMP)
|
|
95
|
+
const entries = paths.map((absolutePath) => {
|
|
96
|
+
const pluginUrl = url.pathToFileURL(absolutePath);
|
|
97
|
+
pluginUrl.searchParams.set(PLUGIN_VERSION_PARAM, String(cacheVersion));
|
|
98
|
+
return { absolutePath, entryHref: pluginUrl.href, version: cacheVersion };
|
|
99
|
+
});
|
|
100
|
+
logClearPluginImportTrees(entries, PLUGIN_VERSION_PARAM);
|
|
86
101
|
};
|
|
87
102
|
export async function loadPluginModule(absolutePluginPath) {
|
|
88
103
|
const pluginUrl = url.pathToFileURL(absolutePluginPath);
|
|
@@ -92,4 +107,6 @@ export async function loadPluginModule(absolutePluginPath) {
|
|
|
92
107
|
// rewriting it during VSCE/Reunite bundling.
|
|
93
108
|
return import(/* webpackIgnore: true */ pluginUrl.href);
|
|
94
109
|
}
|
|
110
|
+
// LOGGING (TEMP)
|
|
111
|
+
logHookStatus();
|
|
95
112
|
//# sourceMappingURL=plugins-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins-cache.js","sourceRoot":"","sources":["../../src/config/plugins-cache.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"plugins-cache.js","sourceRoot":"","sources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