minecodex 2.0.42 → 2.0.43

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.
@@ -8,11 +8,24 @@ export async function loadNativeMarkdownRichText(native) {
8
8
  const sharedSource = await (await fetch(sharedUrl)).text(),
9
9
  shared = await import(sharedUrl);
10
10
  const codeAt = sharedSource.indexOf('id:`codeSnippet.wrap.disable`');
11
- const codeSection = sharedSource.slice(
11
+ let codeSection = sharedSource.slice(
12
12
  sharedSource.lastIndexOf('function ', codeAt),
13
13
  sharedSource.indexOf('function ', codeAt),
14
14
  );
15
- const codeName = codeSection.match(/^function ([\w$]+)/)?.[1];
15
+ let codeName = codeSection.match(/^function ([\w$]+)/)?.[1];
16
+ // 新版将高亮内容放在上层组件,底层只负责外壳,不能直接用作代码渲染器。
17
+ const wrapper = [...sharedSource.matchAll(/function ([\w$]+)\(/g)]
18
+ .map((match) => sharedSource.slice(match.index, sharedSource.indexOf('function ', match.index + 9)))
19
+ .find((section) =>
20
+ section.includes('renderSvgAsImage:') &&
21
+ section.includes('codeContainerClassName:') &&
22
+ section.includes(`jsx)(${codeName},{`) &&
23
+ section.includes('source:'),
24
+ );
25
+ if (wrapper) {
26
+ codeSection = wrapper;
27
+ codeName = wrapper.match(/^function ([\w$]+)/)?.[1];
28
+ }
16
29
  const sharedExports = sharedSource.slice(sharedSource.lastIndexOf('export{'));
17
30
  const sharedBinding = (name) =>
18
31
  shared[sharedExports.match(new RegExp(`${name.replace(/\$/g, '\\$')} as ([\\w$]+)`))?.[1]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecodex",
3
- "version": "2.0.42",
3
+ "version": "2.0.43",
4
4
  "description": "Lightweight, local-first plugins for the Codex desktop app.",
5
5
  "license": "MIT",
6
6
  "type": "module",