minecodex 2.0.38 → 2.0.40
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/README.md +1 -0
- package/apps/dashboard/assets/preview-content.js +3 -0
- package/features/markdown-reading/src/adapters/codex/lists.mjs +0 -26
- package/features/markdown-reading/src/adapters/codex/reading-runtime.mjs +5 -3
- package/features/markdown-reading/src/adapters/codex/rich-text.mjs +1 -1
- package/features/markdown-reading/src/adapters/codex/table-actions.mjs +1 -108
- package/features/markdown-reading/src/adapters/codex/toc.mjs +1 -1
- package/features/markdown-reading/src/injection-source.mjs +8 -10
- package/features/markdown-reading/src/markdown-reading.mjs +5 -2
- package/features/mermaid-diagrams/assets/qv-dependencies.js +4412 -0
- package/features/mermaid-diagrams/assets/qv-export.js +2 -0
- package/features/mermaid-diagrams/assets/qv-loading.css +4 -0
- package/features/mermaid-diagrams/assets/qv-template.json +1 -0
- package/features/mermaid-diagrams/assets/workflow.svg +15 -0
- package/features/mermaid-diagrams/codex-feature.json +31 -0
- package/features/mermaid-diagrams/src/adapters/codex/mermaid-viewer.mjs +95 -0
- package/features/mermaid-diagrams/src/adapters/codex/mermaid.mjs +91 -0
- package/features/mermaid-diagrams/src/adapters/codex/native.mjs +34 -0
- package/features/mermaid-diagrams/src/adapters/codex/runtime.mjs +42 -0
- package/features/mermaid-diagrams/src/injection-source.mjs +26 -0
- package/features/mermaid-diagrams/src/mermaid/export.mjs +83 -0
- package/features/mermaid-diagrams/src/mermaid/frame.mjs +109 -0
- package/features/mermaid-diagrams/src/mermaid/loading.mjs +27 -0
- package/features/mermaid-diagrams/src/mermaid/theme.css +8 -0
- package/features/mermaid-diagrams/src/mermaid/viewport.mjs +75 -0
- package/features/mermaid-diagrams/src/mermaid-diagrams.mjs +85 -0
- package/features/mermaid-diagrams/vendor/lucide-LICENSE +43 -0
- package/features/mermaid-diagrams/vendor/qv/LICENSE +21 -0
- package/features/mermaid-diagrams/vendor/qv/THIRD_PARTY_NOTICES.txt +3009 -0
- package/features/mermaid-diagrams/vendor/qv/provenance.json +55 -0
- package/features/usage-meter/src/adapters/codex/renderer.mjs +11 -3
- package/features/usage-meter/src/usage-meter.mjs +19 -4
- package/package.json +19 -5
- package/packages/cli/src/config.mjs +2 -1
- package/packages/cli/src/control-server.mjs +1 -1
- package/packages/codex-adapter/src/markdown/block-actions.mjs +107 -0
- package/packages/codex-adapter/src/markdown/editor-api.mjs +26 -0
- package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/preview.mjs +2 -8
- package/packages/plugin/assets/app.js +2 -2
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/markdown-native.mjs +0 -0
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/providers.mjs +0 -0
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/toc-native.mjs +0 -0
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
| 额度环 | 查看五小时与每周剩余额度,点击打开用量详情。 |
|
|
16
16
|
| 会话状态 | 查看回复速度、Token 用量和上下文占用。 |
|
|
17
17
|
| Markdown 阅读增强 | 改善文档排版,支持章节目录、表格展开和代码复制。 |
|
|
18
|
+
| Mermaid 图表增强(实验性) | 独立开关,默认关闭;支持图表缩放与 PNG 下载。 |
|
|
18
19
|
| 文件级联浏览 | 点击文件路径,分列浏览目录并切换文件。 |
|
|
19
20
|
| 图片集合 | 浏览本机生成图片,查看提示词,收藏到 Library。 |
|
|
20
21
|
| 站点收藏 | 发现本地项目网页,收藏网址并快速打开。 |
|
|
@@ -15,6 +15,9 @@ const content = {
|
|
|
15
15
|
'markdown-reading': [
|
|
16
16
|
['Codex 的 Markdown 文件预览。', '长文阅读、脚注跳转和表格查看不够方便。', '在文件预览中阅读增强排版,使用目录、脚注和表格操作。'],
|
|
17
17
|
['Markdown file previews in Codex.', 'Long documents, footnotes and tables take extra effort to read.', 'Read enhanced formatting and use the outline, footnote navigation and table actions.']],
|
|
18
|
+
'mermaid-diagrams': [
|
|
19
|
+
['Markdown 文件预览中的 Mermaid 图表。', '实验性图表样式与交互仍在完善,默认关闭。', '按需开启图表增强,使用缩放和 PNG 下载;关闭后使用 Codex 原生图表。'],
|
|
20
|
+
['Mermaid diagrams in Markdown file previews.', 'Enhanced diagram styles and interactions are experimental and off by default.', 'Opt in to diagram zoom and PNG download. Turn it off to use native Codex diagrams.']],
|
|
18
21
|
'file-navigation': [
|
|
19
22
|
['Codex 文件预览上方的路径区域。', '浏览相邻目录和文件需要额外跳转。', '点击路径展开分列目录,逐级浏览并打开另一个文件。'],
|
|
20
23
|
['The path above a file preview in Codex.', 'Browsing nearby files and folders takes extra navigation.', 'Open the path to browse cascading folder columns and choose another file.']],
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
// 使用当前编辑器所属的原生 CodeMirror 实例,避免引入第二套编辑器依赖。
|
|
2
|
-
export async function loadMarkdownListAPI(view) {
|
|
3
|
-
const links = [...document.querySelectorAll('link[rel="modulepreload"]')];
|
|
4
|
-
for (const link of links) {
|
|
5
|
-
if (!/\/dist-[\w-]+\.js$/.test(link.href)) continue;
|
|
6
|
-
const exports = Object.values(await import(link.href));
|
|
7
|
-
if (!exports.includes(view.constructor)) continue;
|
|
8
|
-
const Decoration = exports.find((value) => value?.line && value?.replace && value?.mark);
|
|
9
|
-
const ViewPlugin = exports.find((value) => value?.fromClass && value?.define);
|
|
10
|
-
const StateEffect = exports.find((value) => value?.appendConfig && value?.reconfigure);
|
|
11
|
-
const Compartment = exports.find(
|
|
12
|
-
(value) => value?.prototype?.reconfigure && value?.prototype?.of && value?.prototype?.get,
|
|
13
|
-
);
|
|
14
|
-
const WidgetType = exports.find(
|
|
15
|
-
(value) => value?.prototype?.eq && value?.prototype?.ignoreEvent && value?.prototype?.updateDOM,
|
|
16
|
-
);
|
|
17
|
-
const StateField = exports.find(
|
|
18
|
-
(value) =>
|
|
19
|
-
value?.define && value?.prototype?.slot && value?.prototype?.init && value?.prototype?.create,
|
|
20
|
-
);
|
|
21
|
-
const Prec = exports.find((value) => value?.highest && value?.lowest && value?.high);
|
|
22
|
-
if (Decoration && ViewPlugin && StateEffect && Compartment && WidgetType && Prec && StateField)
|
|
23
|
-
return { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType, Prec, StateField };
|
|
24
|
-
}
|
|
25
|
-
throw new Error('native-markdown-list-api-unavailable');
|
|
26
|
-
}
|
|
27
1
|
export function installMarkdownLists(view, api) {
|
|
28
2
|
const { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType, Prec } = api;
|
|
29
3
|
class Marker extends WidgetType {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { loadMarkdownListAPI
|
|
1
|
+
import { loadMarkdownListAPI } from '../../../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
2
|
+
import { installMarkdownLists } from './lists.mjs';
|
|
2
3
|
import { loadNativeMarkdownLinks, installMarkdownLinks } from './links.mjs';
|
|
3
4
|
import { installMarkdownTables } from './tables.mjs';
|
|
4
|
-
import { loadNativeMarkdownToc } from '
|
|
5
|
+
import { loadNativeMarkdownToc } from '../../../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
5
6
|
import { installMarkdownToc } from './toc.mjs';
|
|
6
|
-
import { loadNativeMarkdownTableActions
|
|
7
|
+
import { loadNativeMarkdownTableActions } from '../../../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
8
|
+
import { installMarkdownTableActions } from './table-actions.mjs';
|
|
7
9
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './rich-text.mjs';
|
|
8
10
|
|
|
9
11
|
// 每个 Preview 共用换行状态,虚拟滚动重挂载的块也读取当前值。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectMarkdownFootnotes } from '../../domain/footnotes.mjs';
|
|
2
|
-
import { captureMarkdownProviders } from '
|
|
2
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
3
3
|
|
|
4
4
|
// 复用消息流的代码组件与 Markdown lexer;文件内容及编辑器仍由 Codex 持有。
|
|
5
5
|
export async function loadNativeMarkdownRichText(native) {
|
|
@@ -1,111 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { captureMarkdownProviders } from './providers.mjs';
|
|
3
|
-
|
|
4
|
-
export function markdownExportAlias(source, name) {
|
|
5
|
-
const start = source.lastIndexOf('export{');
|
|
6
|
-
if (start < 0) return undefined;
|
|
7
|
-
const entries = source.slice(start + 7).split('}')[0].split(',');
|
|
8
|
-
for (const entry of entries) {
|
|
9
|
-
const [local, alias = local] = entry.trim().split(/\s+as\s+/);
|
|
10
|
-
if (local === name) return alias;
|
|
11
|
-
}
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 从 Chat Markdown 的公开组件发现悬浮操作栏和控件,不绑定构建 hash。
|
|
16
|
-
export async function loadNativeMarkdownTableActions(native) {
|
|
17
|
-
const url = [...document.querySelectorAll('link[rel="modulepreload"],script[src]')]
|
|
18
|
-
.map((n) => n.href || n.src)
|
|
19
|
-
.find((url) => /\/app-initial-[^/]+\.js/.test(url));
|
|
20
|
-
const response = await fetch(url);
|
|
21
|
-
if (!response.ok) throw new Error('native-table-actions-source-unavailable');
|
|
22
|
-
const source = await response.text();
|
|
23
|
-
const section = (marker) => {
|
|
24
|
-
const at = source.indexOf(marker),
|
|
25
|
-
start = source.lastIndexOf('function ', at),
|
|
26
|
-
end = source.indexOf('function ', at);
|
|
27
|
-
if (at < 0 || start < 0 || end < 0) throw new Error('native-table-actions-contract-changed');
|
|
28
|
-
return source.slice(start, end);
|
|
29
|
-
};
|
|
30
|
-
const actions = section('"data-block-actions":!0'),
|
|
31
|
-
table = section('id:`markdown.expandTable`');
|
|
32
|
-
const exported = source.slice(source.lastIndexOf('export{'));
|
|
33
|
-
const module = await import(url);
|
|
34
|
-
const publicBinding = (name) => {
|
|
35
|
-
const alias = markdownExportAlias(exported, name);
|
|
36
|
-
if (!alias || !module[alias]) throw new Error('native-table-actions-export-unavailable');
|
|
37
|
-
return module[alias];
|
|
38
|
-
};
|
|
39
|
-
// 初始化原生 lazy module,再使用其公开 React 组件。
|
|
40
|
-
const initializer = source
|
|
41
|
-
.slice(source.indexOf(table) + table.length)
|
|
42
|
-
.match(/^function ([\w$]+)\(\)\{return\(\1=/)?.[1];
|
|
43
|
-
if (!initializer) throw new Error('native-table-actions-initializer-unavailable');
|
|
44
|
-
publicBinding(initializer)();
|
|
45
|
-
const imports = new Map();
|
|
46
|
-
for (const match of source.matchAll(/import\{([^}]+)\}from["']([^"']+)["']/g))
|
|
47
|
-
for (const entry of match[1].split(',')) {
|
|
48
|
-
const parts = entry.trim().split(/\s+as\s+/);
|
|
49
|
-
imports.set(parts.at(-1), { name: parts[0], url: new URL(match[2], url).href });
|
|
50
|
-
}
|
|
51
|
-
const binding = async (name) => {
|
|
52
|
-
const item = imports.get(name);
|
|
53
|
-
if (!item) throw new Error('native-table-actions-dependency-unavailable');
|
|
54
|
-
return (await import(item.url))[item.name];
|
|
55
|
-
};
|
|
56
|
-
const sharedUrl = [...imports.values()].find((item) => /\/app-shared-[^/]+\.js/.test(item.url))?.url;
|
|
57
|
-
if (!sharedUrl) throw new Error('native-code-wrap-module-unavailable');
|
|
58
|
-
const sharedSource = await (await fetch(sharedUrl)).text(),
|
|
59
|
-
shared = await import(sharedUrl);
|
|
60
|
-
const wrapAt = sharedSource.indexOf('id:`codeSnippet.wrap.disable`');
|
|
61
|
-
const wrapSection = sharedSource.slice(
|
|
62
|
-
sharedSource.lastIndexOf('function ', wrapAt),
|
|
63
|
-
sharedSource.indexOf('function ', wrapAt),
|
|
64
|
-
);
|
|
65
|
-
const wrapPair = wrapSection.match(
|
|
66
|
-
/children:[\w$]+\?\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\):\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\)/,
|
|
67
|
-
);
|
|
68
|
-
if (wrapAt < 0 || !wrapPair) throw new Error('native-code-wrap-icons-unavailable');
|
|
69
|
-
const sharedExports = sharedSource.slice(sharedSource.lastIndexOf('export{'));
|
|
70
|
-
const sharedBinding = (name) => shared[markdownExportAlias(sharedExports, name)];
|
|
71
|
-
const assignment = sharedSource.indexOf(`${wrapPair[1]}=`);
|
|
72
|
-
const initialize = sharedSource
|
|
73
|
-
.slice(sharedSource.lastIndexOf('function ', assignment))
|
|
74
|
-
.match(/^function ([\w$]+)\(\)/)?.[1];
|
|
75
|
-
if (initialize && typeof sharedBinding(initialize) === 'function') sharedBinding(initialize)();
|
|
76
|
-
const wrapIcons = { disable: sharedBinding(wrapPair[1]), enable: sharedBinding(wrapPair[2]) };
|
|
77
|
-
if (!wrapIcons.disable || !wrapIcons.enable) throw new Error('native-code-wrap-icon-exports-unavailable');
|
|
78
|
-
const button = table.match(/jsx\)\(([\w$]+),\{"aria-label":[\w$]+,"aria-expanded"/)?.[1];
|
|
79
|
-
const copy = table.match(/jsx\)\(([\w$]+),\{ariaLabel:[\w$]+,buttonText:/)?.[1];
|
|
80
|
-
const tooltip = table.match(/jsx\)\(([\w$]+),\{tooltipContent:[\w$]+,delayOpen:!0/)?.[1];
|
|
81
|
-
if (!button || !copy || !tooltip) throw new Error('native-table-actions-controls-unavailable');
|
|
82
|
-
const [Button, CopyButton, Tooltip] = await Promise.all([binding(button), binding(copy), binding(tooltip)]);
|
|
83
|
-
const previewName = table.match(/jsx\)\(([\w$]+),\{src:``,alt:/)?.[1];
|
|
84
|
-
const tableName = table.match(/jsx\)\(([\w$]+),\{className:[\w$]+,children:[\w$]+\}/)?.[1];
|
|
85
|
-
const classesName = table.match(/([\w$]+)\.MarkdownTablePreview/)?.[1];
|
|
86
|
-
const icon = table.match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{icon:\{16:([\w$]+),20:([\w$]+)\}\}\)/);
|
|
87
|
-
if (!previewName || !tableName || !classesName || !icon)
|
|
88
|
-
throw new Error('native-table-preview-contract-unavailable');
|
|
89
|
-
const [Icon, small, medium, renderer] = await Promise.all([
|
|
90
|
-
binding(icon[1]),
|
|
91
|
-
binding(icon[2]),
|
|
92
|
-
binding(icon[3]),
|
|
93
|
-
loadNativeMarkdownRenderer(source, url, module),
|
|
94
|
-
]);
|
|
95
|
-
return {
|
|
96
|
-
...native,
|
|
97
|
-
...renderer,
|
|
98
|
-
TablePreview: publicBinding(previewName),
|
|
99
|
-
Table: publicBinding(tableName),
|
|
100
|
-
tableClasses: publicBinding(classesName),
|
|
101
|
-
ExpandIcon: () => native.React.createElement(Icon, { icon: { 16: small, 20: medium } }),
|
|
102
|
-
Actions: publicBinding(actions.match(/^function ([\w$]+)/)[1]),
|
|
103
|
-
Button,
|
|
104
|
-
wrapIcons,
|
|
105
|
-
CopyButton,
|
|
106
|
-
Tooltip,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
1
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
109
2
|
|
|
110
3
|
export function installMarkdownTableActions(view, native, codex, controller) {
|
|
111
4
|
const {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { captureMarkdownProviders } from '
|
|
1
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
2
2
|
|
|
3
3
|
// Markdown 负责标题与导航;原生组件负责短线、动效、浮层材质与悬浮定位。
|
|
4
4
|
export function installMarkdownToc(view, api, native, codex) {
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { loadMarkdownListAPI } from '../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
2
|
+
import { markdownExportAlias, loadNativeMarkdownTableActions } from '../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
3
|
+
import { loadNativeMarkdownRenderer } from '../../../packages/codex-adapter/src/markdown/markdown-native.mjs';
|
|
2
4
|
import { collectMarkdownFootnotes } from './domain/footnotes.mjs';
|
|
3
|
-
import { captureMarkdownProviders } from '
|
|
5
|
+
import { captureMarkdownProviders } from '../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
4
6
|
import {
|
|
5
7
|
createMarkdownReadingRuntime,
|
|
6
8
|
createMarkdownWrapState,
|
|
7
9
|
installMarkdownMetadataScroll,
|
|
8
10
|
} from './adapters/codex/reading-runtime.mjs';
|
|
9
11
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './adapters/codex/rich-text.mjs';
|
|
10
|
-
import {
|
|
11
|
-
markdownExportAlias,
|
|
12
|
-
loadNativeMarkdownTableActions,
|
|
13
|
-
installMarkdownTableActions,
|
|
14
|
-
} from './adapters/codex/table-actions.mjs';
|
|
12
|
+
import { installMarkdownTableActions } from './adapters/codex/table-actions.mjs';
|
|
15
13
|
import { loadNativeMarkdownLinks, installMarkdownLinks } from './adapters/codex/links.mjs';
|
|
16
|
-
import { loadNativeMarkdownToc } from '
|
|
14
|
+
import { loadNativeMarkdownToc } from '../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
17
15
|
import { installMarkdownToc } from './adapters/codex/toc.mjs';
|
|
18
16
|
import { readFile } from 'node:fs/promises';
|
|
19
17
|
import { installMarkdownTables } from './adapters/codex/tables.mjs';
|
|
20
|
-
import {
|
|
21
|
-
import { createMarkdownPreviewAdapter } from '
|
|
18
|
+
import { installMarkdownLists } from './adapters/codex/lists.mjs';
|
|
19
|
+
import { createMarkdownPreviewAdapter } from '../../../packages/codex-adapter/src/markdown/preview.mjs';
|
|
22
20
|
export async function createPageScriptSource() {
|
|
23
21
|
const bindings = [
|
|
24
22
|
collectMarkdownFootnotes,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const marker = 'data-minecodex-markdown-reading';
|
|
2
|
-
const
|
|
2
|
+
const runtime = createMarkdownReadingRuntime(config.codex);
|
|
3
|
+
const native = createMarkdownPreviewAdapter(config.codex, item => runtime.attach(item));
|
|
3
4
|
const styled = new Map();
|
|
4
5
|
const sessions = new Map();
|
|
5
|
-
const tokenNames = ['--font-content', '--text-document', '--leading-relaxed', '--font-weight-semibold'
|
|
6
|
+
const tokenNames = ['--font-content', '--text-document', '--leading-relaxed', '--font-weight-semibold',
|
|
7
|
+
'--color-token-main-surface-primary', '--color-token-bg-secondary', '--color-text-foreground',
|
|
8
|
+
'--color-text-foreground-secondary', '--color-border'];
|
|
6
9
|
const style = document.createElement('style');
|
|
7
10
|
style.setAttribute('data-minecodex-markdown-reading-styles', '');
|
|
8
11
|
style.textContent = config.resources.styles;
|