mn-docs-mcp 0.6.2 → 1.1.0
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/.trae/documents/libmn_cleanup_plan.md +51 -0
- package/.trae/documents/libmn_doc_restructure_plan.md +140 -0
- package/.trae/documents/libmn_indentation_plan.md +116 -0
- package/.trae/documents/libmn_title_hierarchy_plan.md +91 -0
- package/README.md +9 -7
- package/next-env.d.ts +6 -0
- package/next.config.mjs +14 -0
- package/package.json +25 -10
- package/postcss.config.mjs +7 -0
- package/scripts/sync-definitions.mjs +33 -0
- package/source.config.ts +5 -0
- package/src/app/[[...slug]]/page.tsx +259 -0
- package/src/app/api/search/route.ts +6 -0
- package/src/app/global.css +81 -0
- package/src/app/layout.tsx +33 -0
- package/src/components/JsbApiFooter.tsx +251 -0
- package/src/content/docs/{guides/contributing.md → contributing.md} +31 -6
- package/src/content/docs/{guides/cookbook → cookbook}/addon-settings.md +2 -2
- package/src/content/docs/{guides/cookbook → cookbook}/embed-webview-panel.md +2 -2
- package/src/content/docs/cookbook/meta.json +13 -0
- package/src/content/docs/{guides/cookbook → cookbook}/network-api-call.md +2 -2
- package/src/content/docs/{guides/cookbook → cookbook}/webview-bidirectional-js.md +1 -1
- package/src/content/docs/guides/getting-started.md +2 -2
- package/src/content/docs/guides/lifecycle-and-window.md +4 -4
- package/src/content/docs/guides/meta.json +14 -0
- package/src/content/docs/guides/mindmap-and-selection.md +2 -2
- package/src/content/docs/guides/native-ui.md +4 -4
- package/src/content/docs/guides/network-requests.md +8 -9
- package/src/content/docs/guides/notes-and-database.md +2 -2
- package/src/content/docs/guides/shortcut-keys.md +9 -9
- package/src/content/docs/guides/storage-and-files.md +4 -4
- package/src/content/docs/guides/toolbar-and-commands.md +1 -1
- package/src/content/docs/index.mdx +13 -38
- package/src/content/docs/libmn/data-converter.md +1572 -0
- package/src/content/docs/libmn/frame.md +279 -0
- package/src/content/docs/libmn/headers.md +234 -0
- package/src/content/docs/libmn/index.md +60 -0
- package/src/content/docs/libmn/internal-exposed.md +46 -0
- package/src/content/docs/libmn/locale.md +307 -0
- package/src/content/docs/libmn/menu.md +77 -0
- package/src/content/docs/libmn/meta.json +27 -0
- package/src/content/docs/libmn/mnbutton.md +966 -0
- package/src/content/docs/libmn/mncomment.md +533 -0
- package/src/content/docs/libmn/mnconnection.md +717 -0
- package/src/content/docs/libmn/mndocument.md +309 -0
- package/src/content/docs/libmn/mnextension-panel.md +340 -0
- package/src/content/docs/libmn/mnnote.md +533 -0
- package/src/content/docs/libmn/mnnotebook.md +725 -0
- package/src/content/docs/libmn/mnutil.md +2936 -0
- package/src/content/docs/libmn/mnwebview.md +693 -0
- package/src/content/docs/libmn/mustache.md +65 -0
- package/src/content/docs/libmn/response.md +352 -0
- package/src/content/docs/libmn/runtime-assets.md +64 -0
- package/src/content/docs/libmn/runtime-web-view-host.md +77 -0
- package/src/content/docs/libmn/runtime.md +178 -0
- package/src/content/docs/libmn/vendor-globals.md +34 -0
- package/src/content/docs/meta.json +11 -0
- package/src/content/docs/reference/black-box.md +2 -2
- package/src/content/docs/reference/foundation/meta.json +4 -0
- package/src/content/docs/reference/foundation/ns-attributed-string.md +1 -1
- package/src/content/docs/reference/foundation/ns-counted-set.md +1 -1
- package/src/content/docs/reference/foundation/ns-date-components.md +2 -2
- package/src/content/docs/reference/foundation/ns-date-formatter.md +1 -3
- package/src/content/docs/reference/foundation/ns-decimal-number.md +1 -1
- package/src/content/docs/reference/foundation/ns-enumerator.md +1 -1
- package/src/content/docs/reference/foundation/ns-error.md +2 -2
- package/src/content/docs/reference/foundation/ns-file-manager.md +1 -1
- package/src/content/docs/reference/foundation/ns-formatter.md +2 -2
- package/src/content/docs/reference/foundation/ns-json-serialization.md +10 -2
- package/src/content/docs/reference/foundation/ns-mutable-attributed-string.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-character-set.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-dictionary.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-index-set.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-set.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-string.md +1 -1
- package/src/content/docs/reference/foundation/ns-mutable-url-request.md +2 -3
- package/src/content/docs/reference/foundation/ns-null.md +1 -1
- package/src/content/docs/reference/foundation/ns-number-formatter.md +1 -1
- package/src/content/docs/reference/foundation/ns-operation.md +2 -2
- package/src/content/docs/reference/foundation/ns-pointer-array.md +1 -1
- package/src/content/docs/reference/foundation/ns-proxy.md +5 -3
- package/src/content/docs/reference/foundation/ns-scanner.md +7 -1
- package/src/content/docs/reference/foundation/ns-set.md +1 -1
- package/src/content/docs/reference/foundation/ns-simple-c-string.md +3 -4
- package/src/content/docs/reference/foundation/ns-time-zone.md +1 -1
- package/src/content/docs/reference/foundation/ns-ubiquitous-key-value-store.md +61 -0
- package/src/content/docs/reference/foundation/ns-url-connection.md +2 -2
- package/src/content/docs/reference/foundation/ns-url-request.md +2 -2
- package/src/content/docs/reference/foundation/ns-url-response.md +5 -5
- package/src/content/docs/reference/foundation/ns-url.md +1 -1
- package/src/content/docs/reference/foundation/ns-user-defaults.md +5 -5
- package/src/content/docs/reference/foundation/ns-value.md +15 -15
- package/src/content/docs/reference/global/agent-tools.md +91 -0
- package/src/content/docs/reference/global/application.md +4 -4
- package/src/content/docs/reference/global/builtin-commands.md +2 -2
- package/src/content/docs/reference/global/database.md +4 -4
- package/src/content/docs/reference/global/document.md +21 -0
- package/src/content/docs/reference/global/global-variables.md +22 -5
- package/src/content/docs/reference/global/jsb.md +6 -4
- package/src/content/docs/reference/global/meta.json +18 -0
- package/src/content/docs/reference/global/note.md +2 -2
- package/src/content/docs/reference/global/notebook.md +21 -0
- package/src/content/docs/reference/global/popup-menu-item.md +2 -2
- package/src/content/docs/reference/global/popup-menu.md +5 -6
- package/src/content/docs/reference/global/search-manager.md +12 -6
- package/src/content/docs/reference/global/self.md +1 -13
- package/src/content/docs/reference/js-runtime.md +5 -4
- package/src/content/docs/reference/marginnote/document-controller.md +37 -5
- package/src/content/docs/reference/marginnote/jsextension.md +7 -7
- package/src/content/docs/reference/marginnote/mb-book-note.md +162 -72
- package/src/content/docs/reference/marginnote/mb-book.md +3 -3
- package/src/content/docs/reference/marginnote/mb-model-tool.md +2 -2
- package/src/content/docs/reference/marginnote/mb-topic.md +13 -2
- package/src/content/docs/reference/marginnote/meta.json +18 -0
- package/src/content/docs/reference/marginnote/mindmap-node.md +2 -2
- package/src/content/docs/reference/marginnote/mindmap-view.md +2 -2
- package/src/content/docs/reference/marginnote/notebook-controller.md +1 -1
- package/src/content/docs/reference/marginnote/outline-view.md +2 -2
- package/src/content/docs/reference/marginnote/reader-controller.md +1 -1
- package/src/content/docs/reference/marginnote/study-controller.md +19 -19
- package/src/content/docs/reference/meta.json +14 -0
- package/src/content/docs/reference/quartzcore/caanimation-group.md +3 -3
- package/src/content/docs/reference/quartzcore/cabasic-animation.md +3 -3
- package/src/content/docs/reference/quartzcore/caemitter-layer.md +44 -0
- package/src/content/docs/reference/quartzcore/cagradient-layer.md +1 -1
- package/src/content/docs/reference/quartzcore/cakeyframe-animation.md +3 -3
- package/src/content/docs/reference/quartzcore/calayer.md +1 -1
- package/src/content/docs/reference/quartzcore/camedia-timing-function.md +1 -1
- package/src/content/docs/reference/quartzcore/caproperty-animation.md +1 -1
- package/src/content/docs/reference/quartzcore/careplicator-layer.md +2 -2
- package/src/content/docs/reference/quartzcore/cascroll-layer.md +1 -1
- package/src/content/docs/reference/quartzcore/cashape-layer.md +2 -2
- package/src/content/docs/reference/quartzcore/catext-layer.md +4 -4
- package/src/content/docs/reference/quartzcore/catransaction.md +5 -3
- package/src/content/docs/reference/quartzcore/catransform-layer.md +3 -3
- package/src/content/docs/reference/quartzcore/catransition.md +10 -6
- package/src/content/docs/reference/quartzcore/cavalue-function.md +1 -1
- package/src/content/docs/reference/quartzcore/meta.json +4 -0
- package/src/content/docs/reference/uikit/meta.json +4 -0
- package/src/content/docs/reference/uikit/ns-mutable-paragraph-style.md +3 -3
- package/src/content/docs/reference/uikit/ns-paragraph-style.md +3 -4
- package/src/content/docs/reference/uikit/ns-text-storage.md +4 -5
- package/src/content/docs/reference/uikit/uiactivity-indicator-view.md +2 -2
- package/src/content/docs/reference/uikit/uiapplication.md +1 -1
- package/src/content/docs/reference/uikit/uibar-button-item.md +3 -4
- package/src/content/docs/reference/uikit/uibar-item.md +2 -3
- package/src/content/docs/reference/uikit/uibezier-path.md +2 -2
- package/src/content/docs/reference/uikit/uibutton.md +1 -1
- package/src/content/docs/reference/uikit/uicollection-view-cell.md +5 -5
- package/src/content/docs/reference/uikit/uicollection-view-controller.md +22 -2
- package/src/content/docs/reference/uikit/uicollection-view-flow-layout.md +54 -0
- package/src/content/docs/reference/uikit/uicollection-view-layout.md +9 -2
- package/src/content/docs/reference/uikit/uicollection-view.md +13 -4
- package/src/content/docs/reference/uikit/uicolor.md +1 -1
- package/src/content/docs/reference/uikit/uicontrol.md +3 -5
- package/src/content/docs/reference/uikit/uidate-picker.md +1 -1
- package/src/content/docs/reference/uikit/uievent.md +2 -2
- package/src/content/docs/reference/uikit/uifont.md +1 -1
- package/src/content/docs/reference/uikit/uigesture-recognizer.md +1 -1
- package/src/content/docs/reference/uikit/uiimage-picker-controller.md +1 -1
- package/src/content/docs/reference/uikit/uiimage-view.md +2 -2
- package/src/content/docs/reference/uikit/uiimage.md +2 -2
- package/src/content/docs/reference/uikit/uikey-command.md +2 -2
- package/src/content/docs/reference/uikit/uilabel.md +3 -3
- package/src/content/docs/reference/uikit/uilocal-notification.md +2 -2
- package/src/content/docs/reference/uikit/uilong-press-gesture-recognizer.md +2 -2
- package/src/content/docs/reference/uikit/uinavigation-bar.md +2 -2
- package/src/content/docs/reference/uikit/uinavigation-controller.md +1 -1
- package/src/content/docs/reference/uikit/uinavigation-item.md +1 -1
- package/src/content/docs/reference/uikit/uipage-control.md +1 -1
- package/src/content/docs/reference/uikit/uipage-view-controller.md +1 -1
- package/src/content/docs/reference/uikit/uipan-gesture-recognizer.md +1 -1
- package/src/content/docs/reference/uikit/uipasteboard.md +1 -1
- package/src/content/docs/reference/uikit/uipicker-view.md +3 -3
- package/src/content/docs/reference/uikit/uipinch-gesture-recognizer.md +1 -1
- package/src/content/docs/reference/uikit/uipopover-controller.md +1 -1
- package/src/content/docs/reference/uikit/uiresponder.md +3 -4
- package/src/content/docs/reference/uikit/uirotation-gesture-recognizer.md +1 -1
- package/src/content/docs/reference/uikit/uiscreen-mode.md +2 -2
- package/src/content/docs/reference/uikit/uiscrollview.md +1 -1
- package/src/content/docs/reference/uikit/uisearch-bar.md +25 -2
- package/src/content/docs/reference/uikit/uisegmented-control.md +1 -1
- package/src/content/docs/reference/uikit/uislider.md +1 -1
- package/src/content/docs/reference/uikit/uiswipe-gesture-recognizer.md +1 -1
- package/src/content/docs/reference/uikit/uiswitch.md +2 -2
- package/src/content/docs/reference/uikit/uitab-bar-controller.md +2 -2
- package/src/content/docs/reference/uikit/uitab-bar-item.md +1 -1
- package/src/content/docs/reference/uikit/uitab-bar.md +1 -1
- package/src/content/docs/reference/uikit/uitable-view-cell.md +6 -6
- package/src/content/docs/reference/uikit/uitable-view-controller.md +1 -1
- package/src/content/docs/reference/uikit/uitable-view.md +3 -3
- package/src/content/docs/reference/uikit/uitap-gesture-recognizer.md +2 -2
- package/src/content/docs/reference/uikit/uitext-input-mode.md +7 -3
- package/src/content/docs/reference/uikit/uitext-position.md +5 -5
- package/src/content/docs/reference/uikit/uitext-range.md +4 -4
- package/src/content/docs/reference/uikit/uitext-view.md +2 -2
- package/src/content/docs/reference/uikit/uitextfield.md +3 -3
- package/src/content/docs/reference/uikit/uitoolbar.md +1 -1
- package/src/content/docs/reference/uikit/uitouch.md +3 -3
- package/src/content/docs/reference/uikit/uiview-controller.md +2 -2
- package/src/content/docs/reference/uikit/uiview.md +5 -5
- package/src/content/docs/reference/uikit/uiwebview.md +5 -5
- package/src/content/docs/reference/uikit/uiwindow.md +2 -2
- package/src/content/docs/reference/utility/menu-controller.md +1 -1
- package/src/content/docs/reference/utility/meta.json +4 -0
- package/src/content/docs/reference/utility/sqlite-result-set.md +1 -1
- package/src/content/docs/reference/utility/sqlite-statement.md +2 -2
- package/src/content/docs/reference/utility/zip-archive.md +13 -14
- package/src/content/docs/reference/value-sturct.md +105 -0
- package/src/lib/layout.tsx +31 -0
- package/src/lib/source.ts +7 -0
- package/tsconfig.json +42 -3
- package/astro.config.mjs +0 -126
- package/src/client/jsb-api-footer.ts +0 -242
- package/src/components/Footer.astro +0 -57
- package/src/components/Search.astro +0 -330
- package/src/content.config.ts +0 -7
- package/src/styles/starlight-overrides.css +0 -23
- /package/src/content/docs/{guides/cookbook → cookbook}/append-selection-as-comment.md +0 -0
- /package/src/content/docs/{guides/cookbook → cookbook}/batch-rename-notes.md +0 -0
- /package/src/content/docs/{guides/cookbook → cookbook}/export-notebook.md +0 -0
- /package/src/content/docs/{guides/cookbook → cookbook}/focus-note-in-mindmap.md +0 -0
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"es2022"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"plugins": [
|
|
21
|
+
{
|
|
22
|
+
"name": "next"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": [
|
|
27
|
+
"./*"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"include": [
|
|
32
|
+
"next-env.d.ts",
|
|
33
|
+
"**/*.ts",
|
|
34
|
+
"**/*.tsx",
|
|
35
|
+
".next/types/**/*.ts",
|
|
36
|
+
".source/**/*",
|
|
37
|
+
".next/dev/types/**/*.ts"
|
|
38
|
+
],
|
|
39
|
+
"exclude": [
|
|
40
|
+
"node_modules",
|
|
41
|
+
"out",
|
|
42
|
+
"dist"
|
|
43
|
+
]
|
|
5
44
|
}
|
package/astro.config.mjs
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { defineConfig } from 'astro/config';
|
|
3
|
-
import starlight from '@astrojs/starlight';
|
|
4
|
-
|
|
5
|
-
// https://astro.build/config
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
site: 'https://mn-docs.museday.top',
|
|
8
|
-
integrations: [
|
|
9
|
-
starlight({
|
|
10
|
-
title: 'MarginNote 插件开发文档',
|
|
11
|
-
customCss: ['/src/styles/starlight-overrides.css'],
|
|
12
|
-
components: {
|
|
13
|
-
Search: './src/components/Search.astro',
|
|
14
|
-
Footer: './src/components/Footer.astro',
|
|
15
|
-
},
|
|
16
|
-
social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/Temsys-Shen/marginnote-addon-docs' }],
|
|
17
|
-
sidebar: [
|
|
18
|
-
{
|
|
19
|
-
label: '入门',
|
|
20
|
-
items: [
|
|
21
|
-
{ label: '快速开始', slug: 'guides/getting-started' },
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: '教程与 Cookbook',
|
|
26
|
-
items: [
|
|
27
|
-
{ label: '生命周期与窗口', slug: 'guides/lifecycle-and-window' },
|
|
28
|
-
{ label: '笔记与数据库', slug: 'guides/notes-and-database' },
|
|
29
|
-
{ label: '脑图与选区', slug: 'guides/mindmap-and-selection' },
|
|
30
|
-
{ label: '工具栏与命令', slug: 'guides/toolbar-and-commands' },
|
|
31
|
-
{ label: '快捷键', slug: 'guides/shortcut-keys' },
|
|
32
|
-
{ label: '原生 UI', slug: 'guides/native-ui' },
|
|
33
|
-
{ label: '存储与文件', slug: 'guides/storage-and-files' },
|
|
34
|
-
{ label: '网络请求', slug: 'guides/network-requests' },
|
|
35
|
-
{
|
|
36
|
-
label: 'Cookbook 配方',
|
|
37
|
-
items: [
|
|
38
|
-
{ label: '批量修改笔记标题', slug: 'guides/cookbook/batch-rename-notes' },
|
|
39
|
-
{ label: '调用远程 API', slug: 'guides/cookbook/network-api-call' },
|
|
40
|
-
{ label: '导出当前笔记本', slug: 'guides/cookbook/export-notebook' },
|
|
41
|
-
{ label: '在脑图中高亮指定笔记', slug: 'guides/cookbook/focus-note-in-mindmap' },
|
|
42
|
-
{ label: '将选区追加为评论', slug: 'guides/cookbook/append-selection-as-comment' },
|
|
43
|
-
{ label: '插件设置页', slug: 'guides/cookbook/addon-settings' },
|
|
44
|
-
{ label: '在插件中嵌入 WebView 面板', slug: 'guides/cookbook/embed-webview-panel' },
|
|
45
|
-
{ label: 'WebView 内 JS 与插件 JS 双向通信', slug: 'guides/cookbook/webview-bidirectional-js' },
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: 'API 参考',
|
|
52
|
-
items: [
|
|
53
|
-
{
|
|
54
|
-
label: '全局与入口',
|
|
55
|
-
items: [
|
|
56
|
-
{ label: '全局入口对象', slug: 'reference/global/global-variables' },
|
|
57
|
-
{ label: 'JSB', slug: 'reference/global/jsb' },
|
|
58
|
-
{ label: 'Application', slug: 'reference/global/application' },
|
|
59
|
-
{ label: 'SearchManager', slug: 'reference/global/search-manager' },
|
|
60
|
-
{ label: 'Database', slug: 'reference/global/database' },
|
|
61
|
-
{ label: 'Note', slug: 'reference/global/note' },
|
|
62
|
-
{ label: 'PopupMenu', slug: 'reference/global/popup-menu' },
|
|
63
|
-
{ label: 'PopupMenuItem', slug: 'reference/global/popup-menu-item' },
|
|
64
|
-
{ label: 'self', slug: 'reference/global/self' },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
label: 'MarginNote 核心',
|
|
69
|
-
items: [
|
|
70
|
-
{ label: 'JSExtension', slug: 'reference/marginnote/jsextension' },
|
|
71
|
-
{ label: 'StudyController', slug: 'reference/marginnote/study-controller' },
|
|
72
|
-
{ label: 'NotebookController', slug: 'reference/marginnote/notebook-controller' },
|
|
73
|
-
{ label: 'ReaderController', slug: 'reference/marginnote/reader-controller' },
|
|
74
|
-
{ label: 'DocumentController', slug: 'reference/marginnote/document-controller' },
|
|
75
|
-
{ label: 'MindMapView', slug: 'reference/marginnote/mindmap-view' },
|
|
76
|
-
{ label: 'OutlineView', slug: 'reference/marginnote/outline-view' },
|
|
77
|
-
{ label: 'MindMapNode', slug: 'reference/marginnote/mindmap-node' },
|
|
78
|
-
{ label: 'MbBookNote', slug: 'reference/marginnote/mb-book-note' },
|
|
79
|
-
{ label: 'NoteComment', slug: 'reference/marginnote/note-comment' },
|
|
80
|
-
{ label: 'MbTopic', slug: 'reference/marginnote/mb-topic' },
|
|
81
|
-
{ label: 'MbBook', slug: 'reference/marginnote/mb-book' },
|
|
82
|
-
{ label: 'MbModelTool', slug: 'reference/marginnote/mb-model-tool' },
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: 'Foundation',
|
|
87
|
-
autogenerate: { directory: 'reference/foundation' },
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
label: 'UIKit',
|
|
91
|
-
autogenerate: { directory: 'reference/uikit' },
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
label: 'QuartzCore',
|
|
95
|
-
autogenerate: { directory: 'reference/quartzcore' },
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: 'Utility',
|
|
99
|
-
autogenerate: { directory: 'reference/utility' },
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: '运行时边界',
|
|
103
|
-
items: [
|
|
104
|
-
{ label: 'JavaScript 原生环境', slug: 'reference/js-runtime' },
|
|
105
|
-
{ label: '隐藏的边界(The Black Box)', slug: 'reference/black-box' },
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: '附录',
|
|
110
|
-
items: [
|
|
111
|
-
{ label: '内建command清单', slug: 'reference/global/builtin-commands' },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: '关于',
|
|
118
|
-
items: [
|
|
119
|
-
{ label: '贡献指南', slug: 'guides/contributing' },
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
}),
|
|
125
|
-
],
|
|
126
|
-
});
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
type JsbApi = {
|
|
2
|
-
protocol: string;
|
|
3
|
-
properties: string[];
|
|
4
|
-
instance_methods: string[];
|
|
5
|
-
class_methods: string[];
|
|
6
|
-
export_aliases: Record<string, string>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const headerUrlLoaders = import.meta.glob('../definitions/**/*.h', {
|
|
10
|
-
query: '?url',
|
|
11
|
-
import: 'default',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
type PageConfig = {
|
|
15
|
-
protocol: string;
|
|
16
|
-
only?: Array<'properties' | 'class' | 'instance' | 'aliases'>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const GLOBAL_PAGE_PROTOCOL_MAP: Record<string, PageConfig> = {
|
|
20
|
-
'reference/global/application': { protocol: 'JSBApplication' },
|
|
21
|
-
'reference/global/database': { protocol: 'JSBMbModelTool' },
|
|
22
|
-
'reference/global/note': { protocol: 'JSBMbBookNote', only: ['class'] },
|
|
23
|
-
'reference/global/self': { protocol: 'JSBJSExtension' },
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function getPageTitle(): string | null {
|
|
27
|
-
const h1 = document.querySelector('main h1');
|
|
28
|
-
const t = (h1 && h1.textContent ? h1.textContent : '').trim();
|
|
29
|
-
return t || null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function protocolFromTitle(title: string): string {
|
|
33
|
-
return `JSB${title.replace(/\s+/g, '')}`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function selectorGuessFromDecl(decl: string): string {
|
|
37
|
-
const stripped = decl.split('//', 1)[0].trim().replace(/;$/, '').trim();
|
|
38
|
-
const noPrefix = stripped.replace(/^[-+]\s*\([^)]*\)\s*/, '').trim();
|
|
39
|
-
if (!noPrefix.includes(':')) return noPrefix.split(/\s|\(/, 1)[0].trim();
|
|
40
|
-
const parts = noPrefix.split(':');
|
|
41
|
-
const labels = parts.slice(0, -1).map((p) => {
|
|
42
|
-
const tokens = p.match(/[A-Za-z_][A-Za-z0-9_]*/g);
|
|
43
|
-
return tokens && tokens.length ? tokens[tokens.length - 1] : '';
|
|
44
|
-
});
|
|
45
|
-
return `${labels.join(':')}:`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function jsNameFromObjcDecl(decl: string): string {
|
|
49
|
-
const stripped = decl.split('//', 1)[0].trim().replace(/;$/, '').trim();
|
|
50
|
-
const noPrefix = stripped.replace(/^[-+]\s*\([^)]*\)\s*/, '').trim();
|
|
51
|
-
if (!noPrefix.includes(':')) return noPrefix.split(/\s|\(/, 1)[0].trim();
|
|
52
|
-
const parts = noPrefix.split(':');
|
|
53
|
-
const labels = parts.slice(0, -1).map((p) => {
|
|
54
|
-
const tokens = p.match(/[A-Za-z_][A-Za-z0-9_]*/g);
|
|
55
|
-
return tokens && tokens.length ? tokens[tokens.length - 1] : '';
|
|
56
|
-
});
|
|
57
|
-
if (!labels.length) return '';
|
|
58
|
-
let js = labels[0];
|
|
59
|
-
for (const lab of labels.slice(1)) {
|
|
60
|
-
if (!lab) continue;
|
|
61
|
-
js += lab[0].toUpperCase() + lab.slice(1);
|
|
62
|
-
}
|
|
63
|
-
return js;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function parseProtocolFromHeader(headerText: string, protocolName: string): JsbApi {
|
|
67
|
-
const lines = headerText.split(/\r?\n/);
|
|
68
|
-
let inProtocol = false;
|
|
69
|
-
const properties: string[] = [];
|
|
70
|
-
const instanceMethods: string[] = [];
|
|
71
|
-
const classMethods: string[] = [];
|
|
72
|
-
const exportAliases: Record<string, string> = {};
|
|
73
|
-
let pendingExportAs: string | null = null;
|
|
74
|
-
|
|
75
|
-
for (const raw of lines) {
|
|
76
|
-
const line = raw.trim();
|
|
77
|
-
if (!line || line.startsWith('#') || line.startsWith('//')) continue;
|
|
78
|
-
const start = line.match(/^@protocol\s+(\w+)\b/);
|
|
79
|
-
if (start) {
|
|
80
|
-
inProtocol = start[1] === protocolName;
|
|
81
|
-
pendingExportAs = null;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (!inProtocol) continue;
|
|
85
|
-
if (line === '@end') break;
|
|
86
|
-
|
|
87
|
-
if (line.startsWith('JSExportAs(')) {
|
|
88
|
-
const m = line.match(/^JSExportAs\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*,/);
|
|
89
|
-
if (m) pendingExportAs = m[1];
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (line.startsWith('@property')) {
|
|
93
|
-
const m = line.match(/([A-Za-z_][A-Za-z0-9_]*)\s*;\s*(?:(?:\/\/).*)?$/);
|
|
94
|
-
if (m) properties.push(m[1]);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (line.startsWith('- (') || line.startsWith('+ (')) {
|
|
98
|
-
const jsName = pendingExportAs || jsNameFromObjcDecl(line);
|
|
99
|
-
const selector = selectorGuessFromDecl(line);
|
|
100
|
-
if (pendingExportAs) exportAliases[jsName] = selector;
|
|
101
|
-
pendingExportAs = null;
|
|
102
|
-
if (line.startsWith('+ (')) classMethods.push(jsName);
|
|
103
|
-
else instanceMethods.push(jsName);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const uniq = (arr: string[]) => Array.from(new Set(arr.filter(Boolean))).sort();
|
|
109
|
-
const sortedAliases = Object.fromEntries(
|
|
110
|
-
Object.entries(exportAliases).sort(([a], [b]) => a.localeCompare(b))
|
|
111
|
-
) as Record<string, string>;
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
protocol: protocolName,
|
|
115
|
-
properties: uniq(properties),
|
|
116
|
-
instance_methods: uniq(instanceMethods),
|
|
117
|
-
class_methods: uniq(classMethods),
|
|
118
|
-
export_aliases: sortedAliases,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function el<K extends keyof HTMLElementTagNameMap>(
|
|
123
|
-
name: K,
|
|
124
|
-
attrs: Record<string, string> = {},
|
|
125
|
-
children: Node[] = []
|
|
126
|
-
): HTMLElementTagNameMap[K] {
|
|
127
|
-
const node = document.createElement(name);
|
|
128
|
-
for (const [k, v] of Object.entries(attrs)) {
|
|
129
|
-
if (k === 'text') node.textContent = v;
|
|
130
|
-
else node.setAttribute(k, v);
|
|
131
|
-
}
|
|
132
|
-
for (const c of children) node.appendChild(c);
|
|
133
|
-
return node;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function code(text: string): HTMLElement {
|
|
137
|
-
return el('code', { text });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function renderApi(container: HTMLElement, api: JsbApi, only?: PageConfig['only']) {
|
|
141
|
-
const allowed = new Set(only ?? ['properties', 'class', 'instance', 'aliases']);
|
|
142
|
-
container.textContent = '';
|
|
143
|
-
if (allowed.has('properties') && api.properties.length) {
|
|
144
|
-
container.appendChild(el('h3', { text: '属性' }));
|
|
145
|
-
const ul = el('ul');
|
|
146
|
-
for (const p of api.properties) ul.appendChild(el('li', {}, [code(p)]));
|
|
147
|
-
container.appendChild(ul);
|
|
148
|
-
}
|
|
149
|
-
if (allowed.has('class') && api.class_methods.length) {
|
|
150
|
-
container.appendChild(el('h3', { text: '类方法' }));
|
|
151
|
-
const ul = el('ul');
|
|
152
|
-
for (const m of api.class_methods) ul.appendChild(el('li', {}, [code(`${m}()`)]));
|
|
153
|
-
container.appendChild(ul);
|
|
154
|
-
}
|
|
155
|
-
if (allowed.has('instance') && api.instance_methods.length) {
|
|
156
|
-
container.appendChild(el('h3', { text: '实例方法' }));
|
|
157
|
-
const ul = el('ul');
|
|
158
|
-
for (const m of api.instance_methods) ul.appendChild(el('li', {}, [code(`${m}()`)]));
|
|
159
|
-
container.appendChild(ul);
|
|
160
|
-
}
|
|
161
|
-
const aliasKeys = Object.keys(api.export_aliases || {});
|
|
162
|
-
if (allowed.has('aliases') && aliasKeys.length) {
|
|
163
|
-
container.appendChild(el('h3', { text: 'JSExportAs 别名' }));
|
|
164
|
-
const table = el('table');
|
|
165
|
-
const thead = el('thead');
|
|
166
|
-
const trh = el('tr');
|
|
167
|
-
trh.appendChild(el('th', { text: 'JS 名' }));
|
|
168
|
-
trh.appendChild(el('th', { text: 'ObjC selector(推断)' }));
|
|
169
|
-
thead.appendChild(trh);
|
|
170
|
-
table.appendChild(thead);
|
|
171
|
-
const tbody = el('tbody');
|
|
172
|
-
for (const jsName of aliasKeys) {
|
|
173
|
-
const tr = el('tr');
|
|
174
|
-
tr.appendChild(el('td', {}, [code(jsName)]));
|
|
175
|
-
tr.appendChild(el('td', {}, [code(api.export_aliases[jsName])]));
|
|
176
|
-
tbody.appendChild(tr);
|
|
177
|
-
}
|
|
178
|
-
table.appendChild(tbody);
|
|
179
|
-
container.appendChild(table);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async function loadHeaderText(protocol: string): Promise<{ source: string; text: string } | null> {
|
|
184
|
-
const entries = Object.keys(headerUrlLoaders);
|
|
185
|
-
const targetKey = entries.find((k) => k.endsWith(`/${protocol}.h`));
|
|
186
|
-
if (!targetKey) return null;
|
|
187
|
-
const url = (await (headerUrlLoaders as any)[targetKey]()) as string;
|
|
188
|
-
const resp = await fetch(url);
|
|
189
|
-
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
|
190
|
-
return { source: targetKey.replace('../definitions/', ''), text: await resp.text() };
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function getSlug(): string {
|
|
194
|
-
return location.pathname.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function initJsbApiFooter() {
|
|
198
|
-
const root = document.querySelector<HTMLElement>('[data-jsb-api]');
|
|
199
|
-
if (!root) return;
|
|
200
|
-
|
|
201
|
-
if (!location.pathname.startsWith('/reference/')) {
|
|
202
|
-
root.style.display = 'none';
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const statusEl = root.querySelector<HTMLElement>('[data-jsb-api-status]')!;
|
|
207
|
-
const protocolEl = root.querySelector<HTMLElement>('[data-jsb-api-protocol]')!;
|
|
208
|
-
const sourceEl = root.querySelector<HTMLElement>('[data-jsb-api-source]')!;
|
|
209
|
-
const bodyEl = root.querySelector<HTMLElement>('[data-jsb-api-body]')!;
|
|
210
|
-
|
|
211
|
-
const slug = getSlug();
|
|
212
|
-
const cfg = GLOBAL_PAGE_PROTOCOL_MAP[slug];
|
|
213
|
-
|
|
214
|
-
let protocol: string | null = cfg?.protocol ?? null;
|
|
215
|
-
if (!protocol) {
|
|
216
|
-
const title = getPageTitle();
|
|
217
|
-
if (!title) {
|
|
218
|
-
root.style.display = 'none';
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
protocol = protocolFromTitle(title);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
protocolEl.textContent = protocol;
|
|
225
|
-
|
|
226
|
-
(async () => {
|
|
227
|
-
try {
|
|
228
|
-
const loaded = await loadHeaderText(protocol);
|
|
229
|
-
if (!loaded) {
|
|
230
|
-
root.style.display = 'none';
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const api = parseProtocolFromHeader(loaded.text, protocol);
|
|
234
|
-
sourceEl.textContent = loaded.source;
|
|
235
|
-
renderApi(bodyEl, api, cfg?.only);
|
|
236
|
-
statusEl.textContent = '';
|
|
237
|
-
} catch (e: any) {
|
|
238
|
-
// Keep user-facing UI clean: hide the block on errors.
|
|
239
|
-
root.style.display = 'none';
|
|
240
|
-
}
|
|
241
|
-
})().catch(() => {});
|
|
242
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import DefaultFooter from '@astrojs/starlight/components/Footer.astro';
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<section class="jsb-api sl-markdown-content" data-jsb-api>
|
|
6
|
-
<details class="jsb-api__details">
|
|
7
|
-
<summary class="jsb-api__summary">头文件 API 清单</summary>
|
|
8
|
-
<p class="jsb-api__meta">
|
|
9
|
-
<span data-jsb-api-status>正在加载…</span>
|
|
10
|
-
</p>
|
|
11
|
-
<p class="jsb-api__meta">
|
|
12
|
-
协议:<code data-jsb-api-protocol>—</code>,来源:<code data-jsb-api-source>—</code>
|
|
13
|
-
</p>
|
|
14
|
-
<div data-jsb-api-body></div>
|
|
15
|
-
</details>
|
|
16
|
-
</section>
|
|
17
|
-
|
|
18
|
-
<DefaultFooter />
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import { initJsbApiFooter } from '../client/jsb-api-footer';
|
|
22
|
-
|
|
23
|
-
initJsbApiFooter();
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<style>
|
|
27
|
-
@layer starlight.components {
|
|
28
|
-
.jsb-api {
|
|
29
|
-
margin-top: 2rem;
|
|
30
|
-
}
|
|
31
|
-
.jsb-api__details {
|
|
32
|
-
border: 1px solid var(--sl-color-gray-6);
|
|
33
|
-
border-radius: 0.75rem;
|
|
34
|
-
padding: 0.75rem 1rem;
|
|
35
|
-
background: color-mix(in srgb, var(--sl-color-gray-7), transparent 70%);
|
|
36
|
-
}
|
|
37
|
-
.jsb-api__summary {
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
font-weight: 600;
|
|
40
|
-
}
|
|
41
|
-
.jsb-api__meta {
|
|
42
|
-
margin-top: 0.75rem;
|
|
43
|
-
color: var(--sl-color-gray-3);
|
|
44
|
-
font-size: var(--sl-text-sm);
|
|
45
|
-
}
|
|
46
|
-
.jsb-api__meta code {
|
|
47
|
-
word-break: break-all;
|
|
48
|
-
}
|
|
49
|
-
.jsb-api :global(ul) {
|
|
50
|
-
margin-top: 0.5rem;
|
|
51
|
-
}
|
|
52
|
-
.jsb-api :global(table) {
|
|
53
|
-
margin-top: 0.75rem;
|
|
54
|
-
width: 100%;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
</style>
|