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 initial=urls.find(url=>/\/app-initial-[^/]+\.js(?:$|\?)/.test(url));
43
- const shared=urls.find(url=>/\/app-shared-[^/]+\.js(?:$|\?)/.test(url));
44
- if (!initial && !shared) throw new Error("context-bundle-unavailable");
45
- // 当前 Codex 将上下文接口放在 app-initial,按实际导出识别。
46
- for (const url of [initial,shared].filter(Boolean)) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecodex",
3
- "version": "2.0.47",
3
+ "version": "2.0.48",
4
4
  "description": "Lightweight, local-first plugins for the Codex desktop app.",
5
5
  "license": "MIT",
6
6
  "type": "module",