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,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: LibMN Vendor Globals
|
|
3
|
+
description: LibMN加载后可用的第三方全局对象与库内真实调用点。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
LibMN会在启动阶段加载一组第三方库并把全局对象暴露到JSContext。这里的重点不是重复上游全部API,而是告诉你“LibMN当前实际依赖了哪些能力”。
|
|
7
|
+
|
|
8
|
+
## 第三方全局对象清单
|
|
9
|
+
|
|
10
|
+
| 全局对象 | 来源模块 | LibMN已使用能力 | 官方文档 |
|
|
11
|
+
|:---|:---|:---|:---|
|
|
12
|
+
| `CryptoJS` | `vendor/CryptoJS` | `AES.encrypt/decrypt`、`MD5`、`SHA256`、`enc.Base64`、`enc.Utf8`、`lib.WordArray.create` | [CryptoJS](https://github.com/brix/crypto-js) |
|
|
13
|
+
| `marked` | `vendor/marked` | `marked.parse`、`marked.lexer` | [Marked](https://marked.js.org/) |
|
|
14
|
+
| `mustache` | `vendor/mustache` | `mustache.render`、`mustache.parse` | [mustache.js](https://github.com/janl/mustache.js) |
|
|
15
|
+
| `Segmentit` | `vendor/segmentit` | `Segmentit.useDefault`、`Segmentit.Segment` | [Segmentit](https://github.com/linonetwo/segmentit) |
|
|
16
|
+
| `jsonrepair` | `vendor/jsonrepair` | `jsonrepair(...)` | [jsonrepair](https://github.com/josdejong/jsonrepair) |
|
|
17
|
+
| `pako` | `vendor/pako` | `pako.gzip`、`pako.ungzip` | [pako](https://github.com/nodeca/pako) |
|
|
18
|
+
| `LZString` | `vendor/lz-string` | `compressToBase64`、`decompressFromBase64` | [LZString](https://pieroxy.net/blog/pages/lz-string/index.html) |
|
|
19
|
+
| `PDFTools` | `vendor/pdf-bridge-core` | `convertImageBase64ToPdfBase64`、`extractPage` | [AddonLib仓库](https://github.com/Temsys-Shen/marginnote-addon-docs) |
|
|
20
|
+
|
|
21
|
+
## 依赖策略建议
|
|
22
|
+
|
|
23
|
+
- 你的业务代码若直接调用这些全局对象,等于直接承担第三方升级风险。
|
|
24
|
+
- 若LibMN中已有对应封装,优先走`MNUtil`或相关包装类,避免把业务和vendor细节绑死。
|
|
25
|
+
- 只有在封装能力不足时再直接访问vendor全局,并在插件内注明版本假设。
|
|
26
|
+
|
|
27
|
+
## 常见误区
|
|
28
|
+
|
|
29
|
+
- 误区1:把vendor全局当成LibMN稳定API。
|
|
30
|
+
说明:它们的稳定性由上游库决定,不由LibMN承诺。
|
|
31
|
+
- 误区2:忽略二进制和编码边界。
|
|
32
|
+
说明:涉及Base64、压缩、PDF转换时,优先复用`DataConverter`和`MNUtil`现成通路。
|
|
33
|
+
- 误区3:只看单次调用成功就上线。
|
|
34
|
+
说明:应在不同文档类型、不同笔记本规模下做回归验证。
|
|
@@ -3,7 +3,7 @@ title: 隐藏的边界(The Black Box)
|
|
|
3
3
|
description: 只作为属性返回、但没有 JSExport 接口文件的对象与风险边界。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
本节记录一些在 API
|
|
6
|
+
本节记录一些在 API 中会“能拿到对象实例”,但由于**没有对应的 `JSB*.h`(JSExport)接口文件**,因此你无法在 JS 中安全地调用其独有方法的“黑盒对象”。
|
|
7
7
|
|
|
8
8
|
典型表现:某个对象作为属性被返回,但你在文档/头文件清单里找不到它的 JSB 接口定义。
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ description: 只作为属性返回、但没有 JSExport 接口文件的对象与
|
|
|
13
13
|
- `NSTextContainer`:同上。
|
|
14
14
|
- `UIFontDescriptor`:在头文件中被注释掉或未导出。
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## 规范
|
|
17
17
|
|
|
18
18
|
- **不要**依赖 KVC/KVO 等高危手段“硬调用”黑盒对象。
|
|
19
19
|
- 如果必须实现相关功能:优先寻找已导出对象提供的替代 API(例如通过 `UITextView`/`NSAttributedString` 侧可用方法绕开)。
|
|
@@ -3,7 +3,7 @@ title: NSDateComponents
|
|
|
3
3
|
description: 日期组成部分(年/月/日/时/分/秒等)。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSDateComponents`
|
|
6
|
+
`NSDateComponents` 用于表示日期的组成部分(年/月/日/时/分/秒等)。默认与 `NSCalendar`(如可用)配合用于构造/分解日期。
|
|
7
7
|
|
|
8
8
|
## 实例成员 (Instance members)
|
|
9
9
|
|
|
@@ -16,7 +16,7 @@ description: 日期组成部分(年/月/日/时/分/秒等)。
|
|
|
16
16
|
|
|
17
17
|
## 类成员 (Class members)
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
当前接口未额外暴露 `NSDateComponents` 的类成员。
|
|
20
20
|
|
|
21
21
|
## 相关
|
|
22
22
|
|
|
@@ -9,13 +9,11 @@ description: 日期格式化与解析。
|
|
|
9
9
|
|
|
10
10
|
### 创建
|
|
11
11
|
|
|
12
|
-
通过 `new
|
|
12
|
+
通过 `new NSDateFormatter()` 创建。
|
|
13
13
|
|
|
14
14
|
```javascript
|
|
15
15
|
// 示例
|
|
16
16
|
var formatter = new NSDateFormatter();
|
|
17
|
-
// 或
|
|
18
|
-
var formatter = NSDateFormatter.alloc().init();
|
|
19
17
|
```
|
|
20
18
|
|
|
21
19
|
## 实例成员 (Instance members)
|
|
@@ -3,7 +3,7 @@ title: NSError
|
|
|
3
3
|
description: 错误对象,包含 domain/code/userInfo 与本地化描述信息。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSError` 用于表示错误信息。网络请求(如 `NSURLConnection`)或文件API
|
|
6
|
+
`NSError` 用于表示错误信息。网络请求(如 `NSURLConnection`)或文件API会通过`NSError **`返回错误对象,JS侧默认作为回调参数或返回值的一部分出现。
|
|
7
7
|
|
|
8
8
|
## 类成员 (Class members)
|
|
9
9
|
|
|
@@ -44,7 +44,7 @@ static errorWithDomainCodeUserInfo(domain: string, code: number, userInfo: NSDic
|
|
|
44
44
|
|
|
45
45
|
### `initWithDomainCodeUserInfo`
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
初始化错误实例(默认由工厂方法创建,较少直接调用)。
|
|
48
48
|
|
|
49
49
|
```javascript
|
|
50
50
|
initWithDomainCodeUserInfo(domain: string, code: number, userInfo: NSDictionary): void
|
|
@@ -65,7 +65,7 @@ createDirectoryAtPathWithIntermediateDirectoriesAttributes(path: string, withInt
|
|
|
65
65
|
| :--- | :--- | :--- |
|
|
66
66
|
| `path` | `string` | 目录路径。 |
|
|
67
67
|
| `withIntermediateDirectories` | `boolean` | 是否创建中间目录。 |
|
|
68
|
-
| `attributes` | `NSDictionary \| null` |
|
|
68
|
+
| `attributes` | `NSDictionary \| null` | 目录属性(默认传 null)。 |
|
|
69
69
|
|
|
70
70
|
### `createDirectoryAtPathAttributes` (简易版)
|
|
71
71
|
|
|
@@ -5,7 +5,7 @@ description: 格式化基类(对象↔字符串转换)。
|
|
|
5
5
|
|
|
6
6
|
`NSFormatter` 是格式化器基类,用于把对象转换成字符串、或从字符串解析回对象。
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
常用的是其具体子类(例如 `NSDateFormatter`、`NSNumberFormatter`)。
|
|
9
9
|
|
|
10
10
|
## 实例成员 (Instance members)
|
|
11
11
|
|
|
@@ -128,4 +128,4 @@ isPartialStringValidProposedSelectedRangeOriginalStringOriginalSelectedRangeErro
|
|
|
128
128
|
|
|
129
129
|
## 类成员 (Class members)
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
当前接口未额外暴露 `NSFormatter` 的类成员。
|
|
@@ -7,7 +7,7 @@ description: JSON 与 Foundation 对象之间的序列化与反序列化。
|
|
|
7
7
|
|
|
8
8
|
## 实例成员 (Instance members)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
当前接口未额外暴露 `NSJSONSerialization` 的实例成员;默认直接使用其类成员完成序列化/反序列化。
|
|
11
11
|
|
|
12
12
|
## 类成员 (Class members)
|
|
13
13
|
|
|
@@ -17,7 +17,15 @@ description: JSON 与 Foundation 对象之间的序列化与反序列化。
|
|
|
17
17
|
| `dataWithJSONObjectOptions(obj, options)` | obj, options: number | NSData | 将对象/数组序列化为 NSData。 |
|
|
18
18
|
| `JSONObjectWithDataOptions(data, options)` | data: NSData, options: number | any | 将 NSData 解析为对象/数组。 |
|
|
19
19
|
|
|
20
|
-
options
|
|
20
|
+
`options`默认传`0`。最新导出接口不包含`error`参数。
|
|
21
|
+
|
|
22
|
+
### 已确认行为
|
|
23
|
+
|
|
24
|
+
- `JSONObjectWithDataOptions(data, 0)`解析非法JSON时返回`undefined`,不抛桥接层错误。
|
|
25
|
+
- `dataWithJSONObjectOptions(obj, 0)`在传入包含函数成员的对象时,插件环境仍会返回`NSData`。
|
|
26
|
+
- `isValidJSONObject(obj)`对包含函数成员的对象返回`true`。
|
|
27
|
+
|
|
28
|
+
要求:不要只依赖`isValidJSONObject`判断可序列化性,序列化后仍应检查返回值并记录日志。
|
|
21
29
|
|
|
22
30
|
## 相关
|
|
23
31
|
|
|
@@ -41,7 +41,7 @@ static dictionaryWithSharedKeySet(sharedKeySet: any): NSMutableDictionary
|
|
|
41
41
|
static sharedKeySetForKeys(keys: NSArray): any
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
> 注:`NSMutableDictionary`
|
|
44
|
+
> 注:`NSMutableDictionary` 的工厂方法在插件环境的导出范围较小;请以本页底部的「头文件 API 清单」为准。
|
|
45
45
|
|
|
46
46
|
## 实例成员 (Instance members)
|
|
47
47
|
|
|
@@ -5,7 +5,7 @@ description: 可变 URL 请求对象(NSURLRequest 子类),用于设置 met
|
|
|
5
5
|
|
|
6
6
|
完整用法见 [网络请求](/guides/network-requests/) 教程。
|
|
7
7
|
|
|
8
|
-
`NSMutableURLRequest` 继承自 `NSURLRequest`,用于构造可变的 HTTP 请求(设置 method/header/body 等)。在插件的网络请求里(例如 `NSURLConnection
|
|
8
|
+
`NSMutableURLRequest` 继承自 `NSURLRequest`,用于构造可变的 HTTP 请求(设置 method/header/body 等)。在插件的网络请求里(例如 `NSURLConnection`)默认用它来构造请求。
|
|
9
9
|
|
|
10
10
|
## 实例成员 (Instance members)
|
|
11
11
|
|
|
@@ -20,7 +20,6 @@ req.setHTTPBody(NSData.dataWithStringEncoding("{}", 4));
|
|
|
20
20
|
|
|
21
21
|
## 类成员 (Class members)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
`NSMutableURLRequest` 通过 `requestWithURL(...)` 工厂方法创建。
|
|
24
24
|
|
|
25
25
|
相关:[网络请求](/guides/network-requests/) 教程含完整请求构建示例。
|
|
26
|
-
|
|
@@ -5,7 +5,7 @@ description: 可调度的任务单元,常与 NSOperationQueue 配合使用。
|
|
|
5
5
|
|
|
6
6
|
`NSOperation` 表示一个可调度任务。常与 `NSOperationQueue` 搭配,用于异步调度(例如 `NSURLConnection.sendAsynchronousRequest...` 的 queue 参数)。
|
|
7
7
|
|
|
8
|
-
>
|
|
8
|
+
> 注意:默认直接使用 `NSOperationQueue.mainQueue()` / `currentQueue()` 即可,不会稳定需要手动构造自定义 operation。
|
|
9
9
|
|
|
10
10
|
## 实例成员 (Instance members)
|
|
11
11
|
|
|
@@ -245,4 +245,4 @@ setThreadPriority(p: number): void
|
|
|
245
245
|
|
|
246
246
|
## 类成员 (Class members)
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
当前接口未额外暴露 `NSOperation` 的类成员。
|
|
@@ -3,7 +3,7 @@ title: NSPointerArray
|
|
|
3
3
|
description: 指针数组(可配置强/弱引用语义)。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSPointerArray` 是“指针数组”容器,允许存放对象指针或空洞,并支持强/弱语义(例如 `weakObjectsPointerArray()
|
|
6
|
+
`NSPointerArray` 是“指针数组”容器,允许存放对象指针或空洞,并支持强/弱语义(例如 `weakObjectsPointerArray()`)。在插件里默认把它当成“特殊数组”来用。
|
|
7
7
|
|
|
8
8
|
## 类成员 (Class members)
|
|
9
9
|
|
|
@@ -3,10 +3,12 @@ title: NSProxy
|
|
|
3
3
|
description: 代理基类(消息转发基础设施)。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSProxy
|
|
6
|
+
`NSProxy`是系统代理基类,提供消息转发相关能力。你直接不会直接创建它,但会在调试/反射/桥接场景里遇到它的基础方法。
|
|
7
7
|
|
|
8
8
|
## 类成员 (Class members)
|
|
9
9
|
|
|
10
|
+
> 注意:插件业务代码不建议调用`alloc/allocWithZone`,推荐使用`.new()`或工厂方法。
|
|
11
|
+
|
|
10
12
|
### `alloc`
|
|
11
13
|
|
|
12
14
|
分配实例。
|
|
@@ -107,7 +109,7 @@ forwardInvocation(invocation: any): void
|
|
|
107
109
|
|
|
108
110
|
### `dealloc`
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
析构。
|
|
111
113
|
|
|
112
114
|
```javascript
|
|
113
115
|
dealloc(): void
|
|
@@ -119,7 +121,7 @@ dealloc(): void
|
|
|
119
121
|
|
|
120
122
|
### `finalize`
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
终结。
|
|
123
125
|
|
|
124
126
|
```javascript
|
|
125
127
|
finalize(): void
|
|
@@ -445,4 +445,10 @@ isAtEnd(): boolean
|
|
|
445
445
|
|
|
446
446
|
- `boolean`: 是否到末尾。
|
|
447
447
|
|
|
448
|
-
> 注:`scanUpToEndOfStringIntoString(...)
|
|
448
|
+
> 注:`scanUpToEndOfStringIntoString(...)`在最新头文件导出清单中未暴露;可结合`isAtEnd()`与`scanUpToStringIntoString(...)`/`scanUpToCharactersFromSetIntoString(...)`实现类似效果。
|
|
449
|
+
>
|
|
450
|
+
> 已确认边界行为:
|
|
451
|
+
>
|
|
452
|
+
> - 空字符串时`isAtEnd()`为`true`。
|
|
453
|
+
> - 全空白字符串在默认跳过规则下`isAtEnd()`为`true`。
|
|
454
|
+
> - `setScanLocation(pos)`传入越界值有崩溃风险,先把`pos`钳制到`[0, string.length]`。
|
|
@@ -3,7 +3,7 @@ title: NSSimpleCString
|
|
|
3
3
|
description: 内部字符串类型(可当作 NSString 使用)。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSSimpleCString`
|
|
6
|
+
`NSSimpleCString` 是一种内部字符串类型。你默认**不需要关心它本身**:它按“字符串”语义工作,可当作 `NSString`/JS 字符串的等价载体来使用。
|
|
7
7
|
|
|
8
8
|
## 实例成员 (Instance members)
|
|
9
9
|
|
|
@@ -11,10 +11,9 @@ description: 内部字符串类型(可当作 NSString 使用)。
|
|
|
11
11
|
|
|
12
12
|
## 类成员 (Class members)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
当前接口未额外暴露 `NSSimpleCString` 的类成员。
|
|
15
15
|
|
|
16
16
|
## 说明
|
|
17
17
|
|
|
18
18
|
- **没有额外可调用成员**:它不额外暴露独有方法/属性。
|
|
19
|
-
-
|
|
20
|
-
|
|
19
|
+
- **使用规范**:把它当作普通字符串传递/拼接/比较即可。
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: NSUbiquitousKeyValueStore
|
|
3
|
+
description: iCloud键值存储对象。用于跨设备同步少量配置数据。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`NSUbiquitousKeyValueStore`用于iCloud键值同步。适合存放小体积配置,不适合大数据或强一致事务。
|
|
7
|
+
|
|
8
|
+
## 类成员 (Class members)
|
|
9
|
+
|
|
10
|
+
### `defaultStore`
|
|
11
|
+
|
|
12
|
+
获取默认iCloud键值存储实例。
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
static defaultStore(): NSUbiquitousKeyValueStore
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 实例成员 (Instance members)
|
|
19
|
+
|
|
20
|
+
### 读取
|
|
21
|
+
|
|
22
|
+
| 方法 | 参数 | 返回值 | 说明 |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `objectForKey(key)` | key: string | any | 读取任意对象。 |
|
|
25
|
+
| `stringForKey(key)` | key: string | string \| null | 读取字符串。 |
|
|
26
|
+
| `arrayForKey(key)` | key: string | NSArray \| null | 读取数组。 |
|
|
27
|
+
| `dictionaryForKey(key)` | key: string | NSDictionary \| null | 读取字典。 |
|
|
28
|
+
| `dataForKey(key)` | key: string | NSData \| null | 读取二进制数据。 |
|
|
29
|
+
| `longLongForKey(key)` | key: string | number | 读取long long。 |
|
|
30
|
+
| `doubleForKey(key)` | key: string | number | 读取double。 |
|
|
31
|
+
| `boolForKey(key)` | key: string | boolean | 读取布尔值。 |
|
|
32
|
+
|
|
33
|
+
### 写入
|
|
34
|
+
|
|
35
|
+
| 方法 | 参数 | 返回值 | 说明 |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| `setObjectForKey(value, key)` | value: any, key: string | void | 写入对象。 |
|
|
38
|
+
| `setStringForKey(value, key)` | value: string, key: string | void | 写入字符串。 |
|
|
39
|
+
| `setArrayForKey(value, key)` | value: NSArray, key: string | void | 写入数组。 |
|
|
40
|
+
| `setDictionaryForKey(value, key)` | value: NSDictionary, key: string | void | 写入字典。 |
|
|
41
|
+
| `setDataForKey(value, key)` | value: NSData, key: string | void | 写入二进制数据。 |
|
|
42
|
+
| `setLongLongForKey(value, key)` | value: number, key: string | void | 写入long long。 |
|
|
43
|
+
| `setDoubleForKey(value, key)` | value: number, key: string | void | 写入double。 |
|
|
44
|
+
| `setBoolForKey(value, key)` | value: boolean, key: string | void | 写入布尔值。 |
|
|
45
|
+
|
|
46
|
+
### 其他
|
|
47
|
+
|
|
48
|
+
| 方法 | 参数 | 返回值 | 说明 |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| `removeObjectForKey(key)` | key: string | void | 删除键。 |
|
|
51
|
+
| `dictionaryRepresentation()` | — | NSDictionary | 获取当前键值快照。 |
|
|
52
|
+
| `synchronize()` | — | boolean | 触发同步。 |
|
|
53
|
+
|
|
54
|
+
## 使用规范
|
|
55
|
+
|
|
56
|
+
- 缺失key时,读取默认返回`nil/0/false`。
|
|
57
|
+
- `synchronize()`不保证强一致即时成功,受iCloud账号、网络和系统同步时机影响。
|
|
58
|
+
|
|
59
|
+
## 相关
|
|
60
|
+
|
|
61
|
+
- [NSUserDefaults](/reference/foundation/ns-user-defaults/)
|
|
@@ -5,7 +5,7 @@ description: 插件环境中唯一导出的网络请求类(deprecated,但可
|
|
|
5
5
|
|
|
6
6
|
完整用法见 [网络请求](/guides/network-requests/) 教程。
|
|
7
7
|
|
|
8
|
-
`NSURLConnection` 是插件环境中导出的网络请求类(头文件标注为 deprecated
|
|
8
|
+
`NSURLConnection` 是插件环境中导出的网络请求类(头文件标注为 deprecated,但在当前接口里仍可用)。它默认与 `NSURLRequest`/`NSMutableURLRequest`、`NSOperationQueue`、`NSData`、`NSError`、`NSHTTPURLResponse` 配合使用。
|
|
9
9
|
|
|
10
10
|
## 类成员 (Class members)
|
|
11
11
|
|
|
@@ -102,7 +102,7 @@ originalRequest(): NSURLRequest
|
|
|
102
102
|
|
|
103
103
|
### `currentRequest`
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
当前请求(会经重定向等变更)。
|
|
106
106
|
|
|
107
107
|
```javascript
|
|
108
108
|
currentRequest(): NSURLRequest
|
|
@@ -3,7 +3,7 @@ title: NSURLRequest
|
|
|
3
3
|
description: 不可变 URL 请求对象,包含 URL、缓存策略、HTTP header/body 等只读访问。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSURLRequest` 表示一个不可变的 URL
|
|
6
|
+
`NSURLRequest` 表示一个不可变的 URL 请求。默认在插件里用于读取请求信息,或作为 `NSMutableURLRequest` 的父接口使用。
|
|
7
7
|
|
|
8
8
|
## 类成员 (Class members)
|
|
9
9
|
|
|
@@ -221,4 +221,4 @@ HTTPShouldUsePipelining(): boolean
|
|
|
221
221
|
|
|
222
222
|
- `boolean`: 是否使用。
|
|
223
223
|
|
|
224
|
-
>
|
|
224
|
+
> 要求:需要设置 method/header/body 等可变字段时,直接使用 [NSMutableURLRequest](/reference/foundation/ns-mutable-url-request/)。
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: NSURLResponse
|
|
3
|
-
description: URL 响应对象,包含 MIMEType
|
|
3
|
+
description: URL 响应对象,包含 MIMEType、编码、期望文件名等元信息。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`NSURLResponse` 是 URL 请求的响应对象基类。HTTP
|
|
6
|
+
`NSURLResponse` 是 URL 请求的响应对象基类。HTTP 响应默认会是其子类 `NSHTTPURLResponse`。
|
|
7
7
|
|
|
8
8
|
## 实例成员 (Instance members)
|
|
9
9
|
|
|
@@ -78,7 +78,7 @@ textEncodingName(): string
|
|
|
78
78
|
|
|
79
79
|
### `suggestedFilename`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
保存文件名。
|
|
82
82
|
|
|
83
83
|
```javascript
|
|
84
84
|
suggestedFilename(): string
|
|
@@ -86,11 +86,11 @@ suggestedFilename(): string
|
|
|
86
86
|
|
|
87
87
|
**Return Value:**
|
|
88
88
|
|
|
89
|
-
- `string`:
|
|
89
|
+
- `string`: 期望文件名。
|
|
90
90
|
|
|
91
91
|
## 类成员 (Class members)
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
当前接口未额外暴露 `NSURLResponse` 的类成员。
|
|
94
94
|
|
|
95
95
|
## 相关
|
|
96
96
|
|
|
@@ -25,7 +25,7 @@ static standardUserDefaults(): NSUserDefaults
|
|
|
25
25
|
|
|
26
26
|
### `setObjectForKey`
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
存储任意对象(为字符串、数字、数组、字典等可序列化类型)。
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
31
|
setObjectForKey(value: any, key: string): void
|
|
@@ -203,7 +203,7 @@ integerForKey(key: string): number
|
|
|
203
203
|
|
|
204
204
|
**Return Value:**
|
|
205
205
|
|
|
206
|
-
- `number`:
|
|
206
|
+
- `number`: 整数值(若不存在默认返回 0)。
|
|
207
207
|
|
|
208
208
|
### `floatForKey`
|
|
209
209
|
|
|
@@ -239,7 +239,7 @@ boolForKey(key: string): boolean
|
|
|
239
239
|
|
|
240
240
|
**Return Value:**
|
|
241
241
|
|
|
242
|
-
- `boolean`:
|
|
242
|
+
- `boolean`: 布尔值(若不存在默认返回 false)。
|
|
243
243
|
|
|
244
244
|
### `URLForKey`
|
|
245
245
|
|
|
@@ -281,7 +281,7 @@ synchronize(): boolean
|
|
|
281
281
|
|
|
282
282
|
- `boolean`: 是否写入成功。
|
|
283
283
|
|
|
284
|
-
**Note:**
|
|
284
|
+
**Note:** 系统默认会自动保存,仅在需要立即持久化时调用。
|
|
285
285
|
|
|
286
286
|
### `registerDefaults`
|
|
287
287
|
|
|
@@ -299,4 +299,4 @@ registerDefaults(registrationDictionary: NSDictionary): void
|
|
|
299
299
|
|
|
300
300
|
## 相关
|
|
301
301
|
|
|
302
|
-
- [教程:存储与文件](/guides/storage-and-files/)、[Cookbook:插件设置页](/
|
|
302
|
+
- [教程:存储与文件](/guides/storage-and-files/)、[Cookbook:插件设置页](/cookbook/addon-settings/)
|