minecodex 2.0.47 → 2.0.48
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.
|
@@ -39,14 +39,23 @@ export function createContextUsageAdapter(signal, codex, onChange, loadFamily =
|
|
|
39
39
|
async function discover() {
|
|
40
40
|
if (loadFamily) return loadFamily();
|
|
41
41
|
const urls=[...document.querySelectorAll('link[rel=modulepreload],script[src]')].map(node=>node.href || node.src);
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const matching = pattern => urls.filter(url=>pattern.test(url));
|
|
43
|
+
const queue=[...matching(/\/app-initial-[^/]+\.js(?:$|\?)/),
|
|
44
|
+
...matching(/\/app-shared-[^/]+\.js(?:$|\?)/),
|
|
45
|
+
...matching(/\/(?:app-main|index)-[^/]+\.js(?:$|\?)/)];
|
|
46
|
+
if (!queue.length) throw new Error("context-bundle-unavailable");
|
|
47
|
+
const visited=new Set();
|
|
48
|
+
while (queue.length) {
|
|
49
|
+
const url=queue.shift();
|
|
50
|
+
if (visited.has(url)) continue;
|
|
51
|
+
visited.add(url);
|
|
47
52
|
const source=await (await fetch(url,{signal})).text();
|
|
48
53
|
const exported=contextUsageExport(source);
|
|
49
54
|
if (exported) return (await import(url))[exported];
|
|
55
|
+
// modulepreload 只是优化提示;沿真实入口引用发现不再预加载的原生状态模块。
|
|
56
|
+
const references=[...source.matchAll(/["'`](\.\/app-(?:initial|main|shared)-[^/"'`]+\.js)["'`]/g)]
|
|
57
|
+
.map(match=>new URL(match[1],url).href);
|
|
58
|
+
queue.push(...references);
|
|
50
59
|
}
|
|
51
60
|
throw new Error("context-export-unavailable");
|
|
52
61
|
}
|