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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Mustache
|
|
3
|
+
description: 对mustache.js的轻量包装,统一模板渲染与语法解析入口。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Mustache`是对mustache.js的轻量包装,提供统一的模板渲染与语法解析功能。
|
|
7
|
+
|
|
8
|
+
## 类成员(Class members)
|
|
9
|
+
|
|
10
|
+
### 属性
|
|
11
|
+
|
|
12
|
+
无。
|
|
13
|
+
|
|
14
|
+
### 方法
|
|
15
|
+
|
|
16
|
+
#### `render`
|
|
17
|
+
|
|
18
|
+
#### 类型
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
static render(template: string,config: object): string
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 说明
|
|
25
|
+
|
|
26
|
+
- 当你有一段Mustache模板字符串,并且已经准备好渲染数据时,直接调用`render`生成最终文本。
|
|
27
|
+
- 与`parse`不同,`render`会产出可展示字符串,适合生成Markdown、HTML片段或提示文本。
|
|
28
|
+
#### 参数
|
|
29
|
+
|
|
30
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
31
|
+
|:-----------|:-------------------------|:-----|:---------------------|
|
|
32
|
+
| `template` | `string` | 是 | Mustache模板文本。 |
|
|
33
|
+
| `config` | `object` | 是 | 模板渲染上下文对象。 |
|
|
34
|
+
|
|
35
|
+
#### 返回值
|
|
36
|
+
|
|
37
|
+
- 类型:`string`
|
|
38
|
+
- 语义:渲染后的完整字符串。
|
|
39
|
+
|
|
40
|
+
#### `parse`
|
|
41
|
+
|
|
42
|
+
#### 类型
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
static parse(template: string): Array<{type:string,value:string,start:number,end:number}>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### 说明
|
|
49
|
+
|
|
50
|
+
- 当你要在渲染前先检查模板语法,或需要缓存模板token时,使用`parse`。
|
|
51
|
+
- 与`render`相比,`parse`不输出最终文本,而是输出词法结果,便于调试复杂模板。
|
|
52
|
+
#### 参数
|
|
53
|
+
|
|
54
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
55
|
+
|:-----------|:---------|:-----|:-----------------------|
|
|
56
|
+
| `template` | `string` | 是 | 待解析的Mustache模板。 |
|
|
57
|
+
|
|
58
|
+
#### 返回值
|
|
59
|
+
|
|
60
|
+
- 类型:`Array<{type:string,value:string,start:number,end:number}>`
|
|
61
|
+
- 语义:模板解析后的token数组。
|
|
62
|
+
|
|
63
|
+
## 实例成员(Instance members)
|
|
64
|
+
|
|
65
|
+
无实例成员。
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Response
|
|
3
|
+
description: LibMN中的Response对象API文档。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Response`用于封装`MNConnection.fetchDev`系列方法的响应结果,提供状态字段、头管理和正文解析方法。
|
|
7
|
+
|
|
8
|
+
## 构造函数
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
new Response(data?: NSData|null,init?: {
|
|
12
|
+
status?: number
|
|
13
|
+
statusText?: string
|
|
14
|
+
headers?: Headers|Array<[string,string]>|Record<string,string>
|
|
15
|
+
type?: string
|
|
16
|
+
url?: string
|
|
17
|
+
redirected?: boolean
|
|
18
|
+
error?: string
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
构造一个新的Response实例。
|
|
23
|
+
|
|
24
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
25
|
+
|:---|:---|:---|:---|
|
|
26
|
+
| `data` | `NSData\|null` | 否 | 响应体数据。传`null`表示空响应体。 |
|
|
27
|
+
| `init` | `object` | 否 | 响应元信息配置。 |
|
|
28
|
+
|
|
29
|
+
## 类成员(Class members)
|
|
30
|
+
|
|
31
|
+
### 属性
|
|
32
|
+
|
|
33
|
+
无。
|
|
34
|
+
|
|
35
|
+
### 方法
|
|
36
|
+
|
|
37
|
+
#### `redirect`
|
|
38
|
+
|
|
39
|
+
##### 类型
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
static redirect(url: string,status?: number): Response
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
##### 说明
|
|
46
|
+
|
|
47
|
+
创建一个重定向响应对象,仅允许301、302、303、307、308状态码。
|
|
48
|
+
|
|
49
|
+
##### 参数
|
|
50
|
+
|
|
51
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
52
|
+
|:---|:---|:---|:---|
|
|
53
|
+
| `url` | `string` | 是 | 重定向目标地址。 |
|
|
54
|
+
| `status` | `number` | 否 | 重定向状态码,默认302。 |
|
|
55
|
+
|
|
56
|
+
##### 返回值
|
|
57
|
+
|
|
58
|
+
- 类型:`Response`
|
|
59
|
+
- 语义:返回新的重定向响应对象。
|
|
60
|
+
|
|
61
|
+
#### `error`
|
|
62
|
+
|
|
63
|
+
##### 类型
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
static error(): Response
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
##### 说明
|
|
70
|
+
|
|
71
|
+
创建一个错误响应对象,状态码固定为0,`type`固定为`error`。
|
|
72
|
+
|
|
73
|
+
##### 参数
|
|
74
|
+
|
|
75
|
+
无。
|
|
76
|
+
|
|
77
|
+
##### 返回值
|
|
78
|
+
|
|
79
|
+
- 类型:`Response`
|
|
80
|
+
- 语义:返回错误响应对象。
|
|
81
|
+
|
|
82
|
+
#### `new`
|
|
83
|
+
|
|
84
|
+
##### 类型
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
static new(res: NSHTTPURLResponse,data: NSData,err: NSError,url?: string): Response
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### 说明
|
|
91
|
+
|
|
92
|
+
把原生网络回调参数封装为`Response`对象。
|
|
93
|
+
|
|
94
|
+
##### 参数
|
|
95
|
+
|
|
96
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
97
|
+
|:---|:---|:---|:---|
|
|
98
|
+
| `res` | `NSHTTPURLResponse` | 是 | 原生响应对象。 |
|
|
99
|
+
| `data` | `NSData` | 是 | 原始响应体。 |
|
|
100
|
+
| `err` | `NSError` | 是 | 原生错误对象。 |
|
|
101
|
+
| `url` | `string` | 否 | 请求URL。 |
|
|
102
|
+
|
|
103
|
+
##### 返回值
|
|
104
|
+
|
|
105
|
+
- 类型:`Response`
|
|
106
|
+
- 语义:返回封装后的响应对象。
|
|
107
|
+
|
|
108
|
+
## 实例成员(Instance members)
|
|
109
|
+
|
|
110
|
+
### 属性
|
|
111
|
+
|
|
112
|
+
#### `hasJSONResult`
|
|
113
|
+
|
|
114
|
+
##### 类型
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
get hasJSONResult(): boolean
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
##### 说明
|
|
121
|
+
|
|
122
|
+
判断当前响应体是否可解析为非空JSON对象。
|
|
123
|
+
|
|
124
|
+
##### 返回值
|
|
125
|
+
|
|
126
|
+
- 类型:`boolean`
|
|
127
|
+
- 语义:可解析且非空时返回`true`。
|
|
128
|
+
|
|
129
|
+
### 方法
|
|
130
|
+
|
|
131
|
+
#### `copy`
|
|
132
|
+
|
|
133
|
+
##### 类型
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
copy(): void
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
##### 说明
|
|
140
|
+
|
|
141
|
+
把`asJSONObject()`结果复制到剪贴板,便于调试查看。
|
|
142
|
+
|
|
143
|
+
##### 参数
|
|
144
|
+
|
|
145
|
+
无。
|
|
146
|
+
|
|
147
|
+
##### 返回值
|
|
148
|
+
|
|
149
|
+
- 类型:`void`
|
|
150
|
+
- 语义:无返回值。
|
|
151
|
+
|
|
152
|
+
#### `asJSONObject`
|
|
153
|
+
|
|
154
|
+
##### 类型
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
asJSONObject(): {
|
|
158
|
+
status: number
|
|
159
|
+
statusText: string
|
|
160
|
+
statusCodeDescription: string
|
|
161
|
+
headers: Headers
|
|
162
|
+
type: string
|
|
163
|
+
url: string
|
|
164
|
+
error?: string
|
|
165
|
+
text?: string|Promise<string>
|
|
166
|
+
json?: any
|
|
167
|
+
bodySize?: number
|
|
168
|
+
}|undefined
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
##### 说明
|
|
172
|
+
|
|
173
|
+
将当前响应转为便于展示和记录的结构化对象。
|
|
174
|
+
|
|
175
|
+
##### 参数
|
|
176
|
+
|
|
177
|
+
无。
|
|
178
|
+
|
|
179
|
+
##### 返回值
|
|
180
|
+
|
|
181
|
+
- 类型:`object|undefined`
|
|
182
|
+
- 语义:成功时返回结构化对象,异常时返回`undefined`。
|
|
183
|
+
|
|
184
|
+
#### `_parseBody`
|
|
185
|
+
|
|
186
|
+
##### 类型
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
_parseBody(body: Uint8Array|string|FormData|null): Uint8Array|null
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
##### 说明
|
|
193
|
+
|
|
194
|
+
将不同输入体归一化为`Uint8Array`。
|
|
195
|
+
|
|
196
|
+
##### 参数
|
|
197
|
+
|
|
198
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
199
|
+
|:---|:---|:---|:---|
|
|
200
|
+
| `body` | `Uint8Array\|string\|FormData\|null` | 是 | 待转换的输入体。 |
|
|
201
|
+
|
|
202
|
+
##### 返回值
|
|
203
|
+
|
|
204
|
+
- 类型:`Uint8Array|null`
|
|
205
|
+
- 语义:可解析时返回字节数组,否则返回`null`。
|
|
206
|
+
|
|
207
|
+
#### `_setBodyUsed`
|
|
208
|
+
|
|
209
|
+
##### 类型
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
_setBodyUsed(): void
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
##### 说明
|
|
216
|
+
|
|
217
|
+
内部标记方法。当前实现中该方法提前返回,不会真正改变`_bodyUsed`。
|
|
218
|
+
|
|
219
|
+
##### 参数
|
|
220
|
+
|
|
221
|
+
无。
|
|
222
|
+
|
|
223
|
+
##### 返回值
|
|
224
|
+
|
|
225
|
+
- 类型:`void`
|
|
226
|
+
- 语义:无返回值。
|
|
227
|
+
|
|
228
|
+
#### `arrayBuffer`
|
|
229
|
+
|
|
230
|
+
##### 类型
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
arrayBuffer(): Promise<ArrayBuffer>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
##### 说明
|
|
237
|
+
|
|
238
|
+
将响应体转换为`ArrayBuffer`。
|
|
239
|
+
|
|
240
|
+
##### 参数
|
|
241
|
+
|
|
242
|
+
无。
|
|
243
|
+
|
|
244
|
+
##### 返回值
|
|
245
|
+
|
|
246
|
+
- 类型:`Promise<ArrayBuffer>`
|
|
247
|
+
- 语义:返回异步数组缓冲区结果。
|
|
248
|
+
|
|
249
|
+
#### `blob`
|
|
250
|
+
|
|
251
|
+
##### 类型
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
blob(): Promise<Blob>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
##### 说明
|
|
258
|
+
|
|
259
|
+
将响应体转换为`Blob`,并携带`content-type`头中的MIME类型。
|
|
260
|
+
|
|
261
|
+
##### 参数
|
|
262
|
+
|
|
263
|
+
无。
|
|
264
|
+
|
|
265
|
+
##### 返回值
|
|
266
|
+
|
|
267
|
+
- 类型:`Promise<Blob>`
|
|
268
|
+
- 语义:返回异步Blob结果。
|
|
269
|
+
|
|
270
|
+
#### `json`
|
|
271
|
+
|
|
272
|
+
##### 类型
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
json(): any
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
##### 说明
|
|
279
|
+
|
|
280
|
+
将响应体解析为JSON对象。解析失败时返回`SyntaxError`对象。
|
|
281
|
+
|
|
282
|
+
##### 参数
|
|
283
|
+
|
|
284
|
+
无。
|
|
285
|
+
|
|
286
|
+
##### 返回值
|
|
287
|
+
|
|
288
|
+
- 类型:`any`
|
|
289
|
+
- 语义:通常为JSON对象,失败时为错误对象。
|
|
290
|
+
|
|
291
|
+
#### `text`
|
|
292
|
+
|
|
293
|
+
##### 类型
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
text(): string|Promise<string>
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
##### 说明
|
|
300
|
+
|
|
301
|
+
将响应体转换为字符串。无响应体时返回空字符串Promise。
|
|
302
|
+
|
|
303
|
+
##### 参数
|
|
304
|
+
|
|
305
|
+
无。
|
|
306
|
+
|
|
307
|
+
##### 返回值
|
|
308
|
+
|
|
309
|
+
- 类型:`string|Promise<string>`
|
|
310
|
+
- 语义:返回文本结果或其Promise。
|
|
311
|
+
|
|
312
|
+
#### `formData`
|
|
313
|
+
|
|
314
|
+
##### 类型
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
formData(): Promise<FormData>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
##### 说明
|
|
321
|
+
|
|
322
|
+
把`application/x-www-form-urlencoded`形式文本解析为`FormData`。
|
|
323
|
+
|
|
324
|
+
##### 参数
|
|
325
|
+
|
|
326
|
+
无。
|
|
327
|
+
|
|
328
|
+
##### 返回值
|
|
329
|
+
|
|
330
|
+
- 类型:`Promise<FormData>`
|
|
331
|
+
- 语义:返回异步FormData结果。
|
|
332
|
+
|
|
333
|
+
#### `clone`
|
|
334
|
+
|
|
335
|
+
##### 类型
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
clone(): Response
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
##### 说明
|
|
342
|
+
|
|
343
|
+
克隆当前响应对象。若响应体已被消费会抛出`TypeError`。
|
|
344
|
+
|
|
345
|
+
##### 参数
|
|
346
|
+
|
|
347
|
+
无。
|
|
348
|
+
|
|
349
|
+
##### 返回值
|
|
350
|
+
|
|
351
|
+
- 类型:`Response`
|
|
352
|
+
- 语义:返回克隆后的新响应对象。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RuntimeAssets
|
|
3
|
+
description: Runtime的资源路径解析器,用于把相对路径转换为插件目录绝对路径。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`RuntimeAssets`负责把插件内部资源路径解析为可访问路径,通常通过`Runtime.assets`调用。
|
|
7
|
+
|
|
8
|
+
## 类成员(Class members)
|
|
9
|
+
|
|
10
|
+
### 属性
|
|
11
|
+
|
|
12
|
+
无。
|
|
13
|
+
|
|
14
|
+
### 方法
|
|
15
|
+
|
|
16
|
+
#### `init`
|
|
17
|
+
|
|
18
|
+
##### 类型
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
static init(extensionPath: string): void
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
##### 说明
|
|
25
|
+
|
|
26
|
+
初始化资源根目录。`Runtime.init`内部会调用该方法。
|
|
27
|
+
|
|
28
|
+
##### 参数
|
|
29
|
+
|
|
30
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
31
|
+
|:---|:---|:---|:---|
|
|
32
|
+
| `extensionPath` | `string` | 是 | 插件根目录绝对路径。 |
|
|
33
|
+
|
|
34
|
+
##### 返回值
|
|
35
|
+
|
|
36
|
+
- 类型:`void`
|
|
37
|
+
- 语义:无返回值。
|
|
38
|
+
|
|
39
|
+
#### `resolve`
|
|
40
|
+
|
|
41
|
+
##### 类型
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
static resolve(path?: string): string
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
##### 说明
|
|
48
|
+
|
|
49
|
+
将相对路径拼接到插件根目录。未传`path`时返回插件根目录本身。
|
|
50
|
+
|
|
51
|
+
##### 参数
|
|
52
|
+
|
|
53
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
54
|
+
|:---|:---|:---|:---|
|
|
55
|
+
| `path` | `string` | 否 | 相对资源路径。 |
|
|
56
|
+
|
|
57
|
+
##### 返回值
|
|
58
|
+
|
|
59
|
+
- 类型:`string`
|
|
60
|
+
- 语义:返回可访问的绝对路径字符串。
|
|
61
|
+
|
|
62
|
+
## 实例成员(Instance members)
|
|
63
|
+
|
|
64
|
+
无实例成员。
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RuntimeWebViewHost
|
|
3
|
+
description: 面向WebView的轻量封装,处理本地文件加载与脚本执行。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`RuntimeWebViewHost`是面向WebView的轻量封装对象,处理本地文件加载与脚本执行,简化WebView操作的重复代码。
|
|
7
|
+
|
|
8
|
+
## 构造函数
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
new RuntimeWebViewHost(options?: { view?: UIView; webview?: UIWebView })
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
构造一个新的RuntimeWebViewHost实例。
|
|
15
|
+
|
|
16
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
17
|
+
|:---|:---|:---|:---|
|
|
18
|
+
| `options` | `{ view?: UIView; webview?: UIWebView }` | 否 | 宿主视图与WebView引用。最关键的是`webview`。 |
|
|
19
|
+
|
|
20
|
+
## 类成员(Class members)
|
|
21
|
+
|
|
22
|
+
无类成员。
|
|
23
|
+
|
|
24
|
+
## 实例成员(Instance members)
|
|
25
|
+
|
|
26
|
+
### 属性
|
|
27
|
+
|
|
28
|
+
无。
|
|
29
|
+
|
|
30
|
+
### 方法
|
|
31
|
+
|
|
32
|
+
#### `loadFile`
|
|
33
|
+
|
|
34
|
+
##### 类型
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
loadFile(path: string): void
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
##### 说明
|
|
41
|
+
|
|
42
|
+
- 当你要让WebView加载插件目录里的本地文件,例如`index.html`,使用这个方法。
|
|
43
|
+
- 与直接调用原生`loadFileURL...`相比,这里会先通过`Runtime.assets.resolve`解析相对路径,并统一可读目录权限。
|
|
44
|
+
##### 参数
|
|
45
|
+
|
|
46
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
47
|
+
|:-------|:---------|:-----|:-----------------------------------------------------|
|
|
48
|
+
| `path` | `string` | 是 | 相对插件资源根目录的文件路径,如`pages/index.html`。 |
|
|
49
|
+
|
|
50
|
+
##### 返回值
|
|
51
|
+
|
|
52
|
+
- 类型:`void`
|
|
53
|
+
- 语义:无返回值。
|
|
54
|
+
|
|
55
|
+
#### `runJavaScript`
|
|
56
|
+
|
|
57
|
+
##### 类型
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
runJavaScript(script: string): void
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
##### 说明
|
|
64
|
+
|
|
65
|
+
- 当你需要从宿主层主动驱动WebView执行一段JS代码时,使用这个方法。
|
|
66
|
+
- 与`loadFile`不同,它不负责页面切换,只负责在当前页面上下文里执行脚本。
|
|
67
|
+
##### 参数
|
|
68
|
+
|
|
69
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
70
|
+
|:---------|:---------|:-----|:-------------------------------|
|
|
71
|
+
| `script` | `string` | 是 | 要执行的JavaScript源码字符串。 |
|
|
72
|
+
|
|
73
|
+
##### 返回值
|
|
74
|
+
|
|
75
|
+
- 类型:`void`
|
|
76
|
+
- 语义:方法本身不返回脚本结果。
|
|
77
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Runtime
|
|
3
|
+
description: LibMN运行时总入口,负责生命周期注册、路由分发与资源路径能力挂载。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Runtime`是运行时总入口,负责生命周期注册、路由分发与资源路径能力挂载。
|
|
7
|
+
|
|
8
|
+
## 类成员(Class members)
|
|
9
|
+
|
|
10
|
+
### 属性
|
|
11
|
+
|
|
12
|
+
| 字段名 | 类型 | 说明 |
|
|
13
|
+
|:-------|:-----|:-----|
|
|
14
|
+
| `lifecycleHandlers` | `Array<Record<string, (...args: any[]) => any>>` | 保存所有已注册的生命周期处理器对象。 |
|
|
15
|
+
| `routeHandlers` | `Record<string, (...args: any[]) => any>` | 保存路由名到处理函数的映射。 |
|
|
16
|
+
| `initialized` | `boolean` | 标记Runtime是否已完成初始化。 |
|
|
17
|
+
| `assets` | `typeof RuntimeAssets` | 暴露路径解析工具`RuntimeAssets`。 |
|
|
18
|
+
|
|
19
|
+
### 方法
|
|
20
|
+
|
|
21
|
+
#### `init`
|
|
22
|
+
|
|
23
|
+
##### 类型
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
static init(context: string): typeof Runtime
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
##### 说明
|
|
30
|
+
|
|
31
|
+
- 作用:在插件启动时写入扩展目录,并同步初始化`Runtime.assets`。
|
|
32
|
+
##### 参数
|
|
33
|
+
|
|
34
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
35
|
+
|:----------|:---------|:-----|:-----------------------------------------------|
|
|
36
|
+
| `context` | `string` | 是 | 插件主目录路径,`addon.js`里由`mainPath`传入。 |
|
|
37
|
+
|
|
38
|
+
##### 返回值
|
|
39
|
+
|
|
40
|
+
- 类型:`typeof Runtime`
|
|
41
|
+
- 语义:返回`Runtime`自身,便于链式调用。
|
|
42
|
+
|
|
43
|
+
#### `ensureInitialized`
|
|
44
|
+
|
|
45
|
+
##### 类型
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
static ensureInitialized(): void
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
##### 说明
|
|
52
|
+
|
|
53
|
+
- 作用:在关键流程开始前显式检查Runtime初始化状态。
|
|
54
|
+
##### 参数
|
|
55
|
+
|
|
56
|
+
无。
|
|
57
|
+
|
|
58
|
+
##### 返回值
|
|
59
|
+
|
|
60
|
+
- 类型:`void`
|
|
61
|
+
- 语义:通过检查时无返回值,未通过直接抛出`Error`。
|
|
62
|
+
|
|
63
|
+
#### `registerLifecycle`
|
|
64
|
+
|
|
65
|
+
##### 类型
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
static registerLifecycle(handler: Record<string, (...args: any[]) => any>): Record<string, (...args: any[]) => any>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
##### 说明
|
|
72
|
+
|
|
73
|
+
- 作用:注册一个生命周期处理器对象。
|
|
74
|
+
##### 参数
|
|
75
|
+
|
|
76
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
77
|
+
|:---|:---|:---|:---|
|
|
78
|
+
| `handler` | `Record<string, (...args: any[]) => any>` | 是 | 处理器对象,键名对应生命周期名,如`sceneWillConnect`。 |
|
|
79
|
+
|
|
80
|
+
##### 返回值
|
|
81
|
+
|
|
82
|
+
- 类型:`T`
|
|
83
|
+
- 语义:返回原始`handler`,可用于保存引用或测试断言。
|
|
84
|
+
|
|
85
|
+
#### `emitLifecycle`
|
|
86
|
+
|
|
87
|
+
##### 类型
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
static emitLifecycle(name: string, ...args: any[]): any[]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
##### 说明
|
|
94
|
+
|
|
95
|
+
- 作用:按生命周期名批量触发所有已注册处理器。
|
|
96
|
+
##### 参数
|
|
97
|
+
|
|
98
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
99
|
+
|:-------|:------------|:-----|:-------------------------|
|
|
100
|
+
| `name` | `string` | 是 | 生命周期名。 |
|
|
101
|
+
| `args` | `any[]` | 否 | 透传给处理器方法的参数。 |
|
|
102
|
+
|
|
103
|
+
##### 返回值
|
|
104
|
+
|
|
105
|
+
- 类型:`any[]`
|
|
106
|
+
- 语义:返回每个处理器的返回值数组。未实现该生命周期的处理器会对应`undefined`。
|
|
107
|
+
|
|
108
|
+
#### `registerRoute`
|
|
109
|
+
|
|
110
|
+
##### 类型
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
static registerRoute(name: string, handler: (...args: any[]) => any): (...args: any[]) => any
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
##### 说明
|
|
117
|
+
|
|
118
|
+
- 作用:注册路由处理函数。
|
|
119
|
+
##### 参数
|
|
120
|
+
|
|
121
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
122
|
+
|:---|:---|:---|:---|
|
|
123
|
+
| `name` | `string` | 是 | 路由名,会成为`routeHandlers[name]`的键。 |
|
|
124
|
+
| `handler` | `(...args: any[]) => any` | 是 | 对应路由执行函数。 |
|
|
125
|
+
|
|
126
|
+
##### 返回值
|
|
127
|
+
|
|
128
|
+
- 类型:`T`
|
|
129
|
+
- 语义:返回注册进去的处理函数本身。
|
|
130
|
+
|
|
131
|
+
#### `handleRoute`
|
|
132
|
+
|
|
133
|
+
##### 类型
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
static handleRoute(name: string, ...args: any[]): any
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
##### 说明
|
|
140
|
+
|
|
141
|
+
- 作用:执行已注册路由。
|
|
142
|
+
##### 参数
|
|
143
|
+
|
|
144
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
145
|
+
|:-------|:------------|:-----|:---------------------------|
|
|
146
|
+
| `name` | `string` | 是 | 要执行的路由名。 |
|
|
147
|
+
| `args` | `any[]` | 否 | 透传给路由处理函数的参数。 |
|
|
148
|
+
|
|
149
|
+
##### 返回值
|
|
150
|
+
|
|
151
|
+
- 类型:`any`
|
|
152
|
+
- 语义:返回对应路由处理函数的返回值。
|
|
153
|
+
|
|
154
|
+
#### `createWebViewHost`
|
|
155
|
+
|
|
156
|
+
##### 类型
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
static createWebViewHost(options?: { view?: UIView; webview?: UIWebView }): RuntimeWebViewHost
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
##### 说明
|
|
163
|
+
|
|
164
|
+
- 作用:创建`RuntimeWebViewHost`实例,统一管理WebView文件加载与脚本执行。
|
|
165
|
+
##### 参数
|
|
166
|
+
|
|
167
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
168
|
+
|:---|:---|:---|:---|
|
|
169
|
+
| `options` | `{ view?: UIView; webview?: UIWebView }` | 否 | 视图与WebView容器,默认空对象。 |
|
|
170
|
+
|
|
171
|
+
##### 返回值
|
|
172
|
+
|
|
173
|
+
- 类型:`RuntimeWebViewHost`
|
|
174
|
+
- 语义:返回可调用`loadFile`和`runJavaScript`的Host实例。
|
|
175
|
+
|
|
176
|
+
## 实例成员(Instance members)
|
|
177
|
+
|
|
178
|
+
无实例成员。
|