@showlotus/open-scriptable 0.1.25 → 0.1.26-alpha.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/README.md +41 -4
- package/dist/count-down.js +39 -20
- package/dist/hello-world.js +8 -1
- package/package.json +9 -2
- package/scriptable.d.ts +306 -43
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
参考文档:
|
|
4
4
|
|
|
5
5
|
- [Scriptable API 文档](https://docs.scriptable.app/)
|
|
6
|
+
<!-- - [图片合并网站](https://fulicat.com/lab/pintu/) -->
|
|
6
7
|
|
|
7
8
|
## 使用示例
|
|
8
9
|
|
|
@@ -19,6 +20,11 @@ const render = new Function(code)();
|
|
|
19
20
|
await render(config);
|
|
20
21
|
```
|
|
21
22
|
|
|
23
|
+
组件配置有两条通道,按字段逐项覆盖:**小组件参数 > config > 内置默认值**。
|
|
24
|
+
|
|
25
|
+
- `config`:脚本级配置,写在加载脚本里,修改会影响所有指向该脚本的小组件
|
|
26
|
+
- **小组件参数**:iOS 小组件配置界面中每个组件实例各自填写,同一份脚本可展示不同内容;段含 `=` 按 `key=value` 解析(key 与 config 字段同名),其余落到组件约定的参数格式
|
|
27
|
+
|
|
22
28
|
<div>
|
|
23
29
|
<img src="./res/hello-world/light.png" alt="light" width="300">
|
|
24
30
|
<img src="./res/hello-world/dark.jpeg" alt="dark" width="300">
|
|
@@ -35,13 +41,13 @@ const render = new Function(code)();
|
|
|
35
41
|
await render();
|
|
36
42
|
```
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
小组件参数格式(中英文逗号分段,顺序无关):
|
|
39
45
|
|
|
40
46
|
- **日历类型**:只显示指定类型的日历事件,多个类型用 `/` 分隔(如 `节假日/生日`),留空显示全部
|
|
41
|
-
- **布局**:`double`/`双列` 为两列布局(中号 2 列 × 3 行、大号 2 列 × 7 行),默认 `single`/`单列`
|
|
42
|
-
-
|
|
47
|
+
- **布局**:`double`/`双列` 为两列布局(中号 2 列 × 3 行、大号 2 列 × 7 行),默认 `single`/`单列` 单列;布局关键词免 key,直接识别为布局
|
|
48
|
+
- **key=value**:按字段指定,key 为 `calendarTypes`、`layout`、`theme`(与 config 字段同名),如 `calendarTypes=节假日,layout=double`
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
示例:`节假日,double`、`节假日,双列`、`双列`、`calendarTypes=节假日` 效果等价;旧格式 `日历类型,布局` 保持兼容
|
|
45
51
|
|
|
46
52
|
使用指南:[【iOS】倒计时小组件可以自动关联日历啦✨ - showlotus](https://www.xiaohongshu.com/discovery/item/693ad4e1000000001b0213f9?source=webshare&xhsshare=pc_web&xsec_token=AB7rXUtVvD9i-FRNDkZ48ctiVz2JxS_fcZY2waWv-enoA=&xsec_source=pc_share)
|
|
47
53
|
|
|
@@ -77,3 +83,34 @@ const code = await new Request(url).loadString();
|
|
|
77
83
|
const render = new Function(code);
|
|
78
84
|
await render();
|
|
79
85
|
```
|
|
86
|
+
|
|
87
|
+
## 类型提示(可选)
|
|
88
|
+
|
|
89
|
+
仓库中的 `scriptable.d.ts` 包含 Scriptable 全部 API 的中文 JSDoc 类型定义,随 npm 包发布。在自己电脑上编写脚本时,通过以下方式即可在 VSCode 中获得完整的代码补全、参数签名和悬停文档(`ListWidget`、`Font`、`Request` 等):
|
|
90
|
+
|
|
91
|
+
1. 安装本包:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm add -D @showlotus/open-scriptable
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. 在脚本文件开头添加引用(文件需以 `.js` 结尾并开启 `// @ts-check`):
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
// @ts-check
|
|
101
|
+
/// <reference types="@showlotus/open-scriptable/scriptable" />
|
|
102
|
+
|
|
103
|
+
const widget = new ListWidget();
|
|
104
|
+
widget.backgroundColor = Color.dynamic(new Color('#FFFFFF'), new Color('#1c1c1e'));
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
3. 在项目根目录添加 `jsconfig.json`,排除 DOM lib(Scriptable API 与浏览器 DOM 存在同名全局,如 `Image`、`Request`,不排除会产生重复声明报错):
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"compilerOptions": {
|
|
112
|
+
"checkJs": true,
|
|
113
|
+
"lib": ["ES2022"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
package/dist/count-down.js
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
|
-
return
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
return var B = Object.defineProperty, N = Object.defineProperties;
|
|
2
|
+
var J = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var A = Object.getOwnPropertySymbols;
|
|
4
|
+
var Q = Object.prototype.hasOwnProperty, X = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var K = (s, a, l) => a in s ? B(s, a, { enumerable: !0, configurable: !0, writable: !0, value: l }) : s[a] = l, p = (s, a) => { for (var l in a || (a = {}))
|
|
6
|
+
Q.call(a, l) && K(s, l, a[l]); if (A)
|
|
7
|
+
for (var l of A(a))
|
|
8
|
+
X.call(a, l) && K(s, l, a[l]); return s; }, P = (s, a) => N(s, J(a));
|
|
9
|
+
async function tt(s = {}) { var U, I; let a; config.runsInWidget ? a = config.widgetFamily || "small" : a = "large"; const l = { single: "single", double: "double", 单列: "single", 双列: "double" }, w = { 透明: "transparent", transparent: "transparent" }; function C(t) { const e = t == null ? void 0 : t.trim().toLowerCase(); return e ? l[e] : void 0; } const W = ((U = args.widgetParameter) == null ? void 0 : U.trim().split(/,|,/).map(t => t.trim()).filter(Boolean)) || [], v = ["calendarTypes", "theme", "layout"], g = {}, L = []; for (const t of W) {
|
|
10
|
+
const e = t.indexOf("=");
|
|
11
|
+
if (e > 0) {
|
|
12
|
+
const o = t.slice(0, e).trim().toLowerCase(), r = v.find(n => n.toLowerCase() === o), c = t.slice(e + 1).trim();
|
|
13
|
+
if (r) {
|
|
14
|
+
const n = r === "layout" ? C(c) : w[c.trim().toLowerCase()];
|
|
15
|
+
g[r] = n || c;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else
|
|
19
|
+
C(t) !== void 0 ? g.layout = C(t) : w[t.trim().toLowerCase()] ? g.theme = w[t.trim().toLowerCase()] : L.push(t);
|
|
20
|
+
} const S = p(p({}, s), g); function V(t, e) { return S[t] || e; } const b = g.calendarTypes || L.join("/") || S.calendarTypes || "", T = ((I = C(S.layout)) != null ? I : "single") === "double" && a !== "small", F = (T ? { small: 3, medium: 6, large: 14 } : { small: 3, medium: 3, large: 7 })[a], z = { backgroundColor: Color.dynamic(new Color("#FFFFFF"), new Color("#1c1c1c")), dateTitleTextColor: Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), dateDescriptionTextColor: Color.dynamic(new Color("#979797"), new Color("#8e8e8e")), daysTextColor: Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), daysUnitTextColor: Color.dynamic(new Color("#979797"), new Color("#8e8e8e")), lineColor: new Color("#8C8C8C", .2), emptyLineColor: new Color("#ffffff", 0) }, H = { default: z, transparent: P(p({}, z), { backgroundColor: new Color("#000000", 0) }) }, M = V("theme", "default"), y = H[M] || H.default; function $(t, e) { const o = new DateFormatter; return o.dateFormat = e, o.string(t); } function G(t) { const e = new Date; e.setHours(0, 0, 0, 0); const o = t.getTime() - e.getTime(); return Math.floor(o / (1e3 * 60 * 60 * 24)); } function O(t) { return `calshow:${Math.floor(t.getTime() / 1e3) - 978307200}`; } async function j() { const t = await Calendar.forEvents(), e = new Date, o = new Date; return o.setMonth(o.getMonth() + 12), (await CalendarEvent.between(e, o, t)).map(n => { const d = a === "small" ? "yyyy/MM/dd" : T ? "yyyy/MM/dd EEEE" : `yyyy/MM/dd EEEE${n.isAllDay ? "" : " HH:mm"}`, m = $(n.startDate, d); return { name: n.title, date: n.startDate, dateStr: m, isEmpty: !1, type: n.calendar.title, color: "#" + n.calendar.color.hex, eventUrl: `x-apple-calevent://${n.identifier.replace(/:/g, "/")}`, calshowUrl: O(n.startDate) }; }).filter(n => !(n.type === "中国大陆节假日" && /(|)/.test(n.name))).filter(n => b.trim().length > 0 ? b.split("/").includes(n.type) : !0); } const q = await j(), i = new ListWidget; i.backgroundColor = y.backgroundColor, M === "transparent" && (i.backgroundStyle = "transparent"), i.spacing = 8; function x(t) { return q[t] || { name: "", date: "", isEmpty: !0, eventUrl: "", calshowUrl: "" }; } function h(t, e) { const o = t.addStack(); o.layoutVertically(), o.spacing = 1, e.eventUrl && (o.url = e.eventUrl); const r = o.addStack(); r.layoutHorizontally(), r.spacing = 2; const c = r.addText(e.name); c.font = Font.mediumRoundedSystemFont(14), c.textColor = e.color ? new Color(e.color) : y.dateTitleTextColor; const n = o.addStack(); n.layoutHorizontally(), n.spacing = 2; const d = n.addText(e.isEmpty ? " " : e.dateStr); d.font = Font.mediumRoundedSystemFont(10), d.textColor = y.dateDescriptionTextColor, t.addSpacer(); const m = t.addStack(); m.layoutHorizontally(), m.bottomAlignContent(), m.spacing = 2; const u = e.isEmpty ? " " : G(e.date), f = m.addStack(); f.spacing = 2, f.topAlignContent(); const D = f.addText(u.toString()); D.font = Font.mediumRoundedSystemFont(24), D.textColor = e.color ? new Color(e.color) : y.daysTextColor, D.rightAlignText(); const R = m.addStack(); if (R.setPadding(0, 0, 4, 0), !e.isEmpty) {
|
|
21
|
+
const E = R.addText("天");
|
|
22
|
+
E.font = Font.mediumRoundedSystemFont(10), E.textColor = y.daysUnitTextColor, E.rightAlignText();
|
|
23
|
+
} } function k(t, e) { const o = t.addStack(); o.layoutHorizontally(), o.addSpacer(), o.backgroundColor = e.isEmpty ? y.emptyLineColor : y.lineColor, o.setPadding(.5, 0, .5, 0); } if (T) {
|
|
24
|
+
const e = F / 2;
|
|
25
|
+
for (let o = 0; o < e; o++) {
|
|
26
|
+
const r = i.addStack();
|
|
27
|
+
r.layoutHorizontally();
|
|
28
|
+
const c = x(o * 2), n = x(o * 2 + 1), d = r.addStack();
|
|
29
|
+
d.layoutVertically(), d.spacing = 8;
|
|
30
|
+
const m = d.addStack();
|
|
31
|
+
m.layoutHorizontally(), h(m, c), o < e - 1 && k(d, c), r.addSpacer(12);
|
|
32
|
+
const u = r.addStack();
|
|
33
|
+
u.layoutVertically(), u.spacing = 8;
|
|
34
|
+
const f = u.addStack();
|
|
35
|
+
f.layoutHorizontally(), h(f, n), o < e - 1 && k(u, n);
|
|
17
36
|
}
|
|
18
37
|
}
|
|
19
38
|
else
|
|
20
|
-
for (let
|
|
21
|
-
const
|
|
22
|
-
o.layoutHorizontally(),
|
|
23
|
-
} config.runsInWidget ? Script.setWidget(i) : config.runsInApp && (
|
|
39
|
+
for (let t = 0; t < F; t++) {
|
|
40
|
+
const e = x(t), o = i.addStack();
|
|
41
|
+
o.layoutHorizontally(), h(o, e), t < F - 1 && k(i, e);
|
|
42
|
+
} config.runsInWidget ? Script.setWidget(i) : config.runsInApp && (a === "small" ? i.presentSmall() : a === "medium" ? i.presentMedium() : a === "large" && i.presentLarge()), Script.complete(); }
|
package/dist/hello-world.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
return
|
|
1
|
+
return var C = Object.defineProperty;
|
|
2
|
+
var f = Object.getOwnPropertySymbols;
|
|
3
|
+
var y = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var F = (t, e, n) => e in t ? C(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, r = (t, e) => { for (var n in e || (e = {}))
|
|
5
|
+
y.call(e, n) && F(t, n, e[n]); if (f)
|
|
6
|
+
for (var n of f(e))
|
|
7
|
+
S.call(e, n) && F(t, n, e[n]); return t; };
|
|
8
|
+
async function p(t) { var g, d, a; let e; config.runsInWidget ? e = config.widgetFamily || "small" : e = "small"; const n = (g = args.widgetParameter) == null ? void 0 : g.trim(), s = (a = (d = n == null ? void 0 : n.match(/(?:^|[,,])name=([^,,]+)/i)) == null ? void 0 : d[1]) == null ? void 0 : a.trim(), u = r(r({}, t), s || n ? { name: s || n } : {}); function w(m, i) { return u[m] || i; } function c(m) { const i = new ListWidget; i.backgroundColor = Color.dynamic(new Color("#FFFFFF"), new Color("#1c1c1c")); const l = i.addText(`Hello, ${w("name", "World")}`); return l.textColor = Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), l.font = Font.boldSystemFont(16), l.centerAlignText(), console.log("config:"), console.log(JSON.stringify(config, null, 2)), i; } let o; config.runsInWidget ? (o = c(), Script.setWidget(o)) : (o = c(), e === "small" ? o.presentSmall() : e === "medium" ? o.presentMedium() : e === "large" && o.presentLarge()); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@showlotus/open-scriptable",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26-alpha.0",
|
|
4
4
|
"description": "Open-source Scriptable scripts for iOS Widgets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@8.10.0",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"dist",
|
|
13
13
|
"*.d.ts"
|
|
14
14
|
],
|
|
15
|
+
"exports": {
|
|
16
|
+
"./scriptable": {
|
|
17
|
+
"types": "./scriptable.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
15
20
|
"keywords": [
|
|
16
21
|
"scriptable",
|
|
17
22
|
"open-source",
|
|
@@ -46,7 +51,9 @@
|
|
|
46
51
|
"scripts": {
|
|
47
52
|
"dev": "vite",
|
|
48
53
|
"build": "vite build",
|
|
54
|
+
"check:dts": "node scripts/check-dts-coverage.js",
|
|
49
55
|
"lint-staged": "lint-staged",
|
|
50
|
-
"release": "node scripts/release.js"
|
|
56
|
+
"release": "node scripts/release.js",
|
|
57
|
+
"release:alpha": "node scripts/release-alpha.js"
|
|
51
58
|
}
|
|
52
59
|
}
|
package/scriptable.d.ts
CHANGED
|
@@ -369,6 +369,20 @@ declare global {
|
|
|
369
369
|
layoutHorizontally(): void;
|
|
370
370
|
/** 垂直布局 */
|
|
371
371
|
layoutVertically(): void;
|
|
372
|
+
|
|
373
|
+
/** 添加进度指示器(iOS 17+) */
|
|
374
|
+
addProgress(
|
|
375
|
+
value: number,
|
|
376
|
+
options?: { style?: 'circular' | 'linear'; progressColor?: Color; trackColor?: Color; thickness?: number },
|
|
377
|
+
): WidgetStack;
|
|
378
|
+
/** 添加运行小组件动作的按钮(iOS 17+) */
|
|
379
|
+
addButton(title: string, options: { id: string }): void;
|
|
380
|
+
/** 添加刷新小组件的按钮(iOS 17+) */
|
|
381
|
+
addRefreshButton(title: string): void;
|
|
382
|
+
/** 添加运行小组件动作的开关(iOS 17+) */
|
|
383
|
+
addToggle(title: string, isOn: boolean, options: { id: string }): void;
|
|
384
|
+
/** 点击堆栈时运行小组件动作(iOS 17+) */
|
|
385
|
+
setAction(title?: string | null, options?: { id: string }): void;
|
|
372
386
|
}
|
|
373
387
|
|
|
374
388
|
/**
|
|
@@ -454,6 +468,8 @@ declare global {
|
|
|
454
468
|
backgroundColor: Color;
|
|
455
469
|
/** 背景图像 */
|
|
456
470
|
backgroundImage: Image;
|
|
471
|
+
/** 背景样式,设为 "transparent" 可在主屏幕透出壁纸(iOS 27.2+) */
|
|
472
|
+
backgroundStyle: string;
|
|
457
473
|
/** 背景渐变 */
|
|
458
474
|
backgroundGradient: LinearGradient;
|
|
459
475
|
/** 间距 */
|
|
@@ -475,6 +491,17 @@ declare global {
|
|
|
475
491
|
addSpacer(length?: number | null): WidgetSpacer;
|
|
476
492
|
/** 添加堆栈 */
|
|
477
493
|
addStack(): WidgetStack;
|
|
494
|
+
/** 添加进度指示器(iOS 17+) */
|
|
495
|
+
addProgress(
|
|
496
|
+
value: number,
|
|
497
|
+
options?: { style?: 'circular' | 'linear'; progressColor?: Color; trackColor?: Color; thickness?: number },
|
|
498
|
+
): WidgetStack;
|
|
499
|
+
/** 添加运行小组件动作的按钮(iOS 17+) */
|
|
500
|
+
addButton(title: string, options: { id: string }): void;
|
|
501
|
+
/** 添加刷新小组件的按钮(iOS 17+) */
|
|
502
|
+
addRefreshButton(title: string): void;
|
|
503
|
+
/** 添加运行小组件动作的开关(iOS 17+) */
|
|
504
|
+
addToggle(title: string, isOn: boolean, options: { id: string }): void;
|
|
478
505
|
/** 设置内边距 */
|
|
479
506
|
setPadding(top: number, leading: number, bottom: number, trailing: number): void;
|
|
480
507
|
/** 使用默认内边距 */
|
|
@@ -487,6 +514,8 @@ declare global {
|
|
|
487
514
|
presentLarge(): Promise<void>;
|
|
488
515
|
/** 以超大尺寸展示小组件 */
|
|
489
516
|
presentExtraLarge(): Promise<void>;
|
|
517
|
+
/** 以竖屏超大尺寸展示小组件预览(iOS 27+) */
|
|
518
|
+
presentExtraLargePortrait(): Promise<void>;
|
|
490
519
|
/** 展示辅助内联小组件 */
|
|
491
520
|
presentAccessoryInline(): Promise<void>;
|
|
492
521
|
/** 展示辅助圆形小组件 */
|
|
@@ -615,6 +644,8 @@ declare global {
|
|
|
615
644
|
height: number;
|
|
616
645
|
/** 背景颜色 */
|
|
617
646
|
backgroundColor: Color;
|
|
647
|
+
/** 单元格之间的水平间距 */
|
|
648
|
+
cellSpacing: number;
|
|
618
649
|
/** 点击回调 */
|
|
619
650
|
onSelect: () => void;
|
|
620
651
|
|
|
@@ -636,10 +667,6 @@ declare global {
|
|
|
636
667
|
* UI 表格单元格类
|
|
637
668
|
*/
|
|
638
669
|
class UITableCell {
|
|
639
|
-
/** 标题文本 */
|
|
640
|
-
title: string;
|
|
641
|
-
/** 副标题文本 */
|
|
642
|
-
subtitle: string;
|
|
643
670
|
/** 标题颜色 */
|
|
644
671
|
titleColor: Color;
|
|
645
672
|
/** 副标题颜色 */
|
|
@@ -648,12 +675,28 @@ declare global {
|
|
|
648
675
|
titleFont: Font;
|
|
649
676
|
/** 副标题字体 */
|
|
650
677
|
subtitleFont: Font;
|
|
678
|
+
/** 点击按钮时是否关闭表格 */
|
|
679
|
+
dismissOnTap: boolean;
|
|
680
|
+
/** 按钮点击回调,在 Siri 中展示时不可点击 */
|
|
681
|
+
onTap: () => void;
|
|
682
|
+
/** 单元格相对宽度权重 */
|
|
683
|
+
widthWeight: number;
|
|
684
|
+
|
|
651
685
|
/** 左对齐 */
|
|
652
686
|
leftAligned(): void;
|
|
653
687
|
/** 居中对齐 */
|
|
654
688
|
centerAligned(): void;
|
|
655
689
|
/** 右对齐 */
|
|
656
690
|
rightAligned(): void;
|
|
691
|
+
|
|
692
|
+
/** 构造按钮单元格 */
|
|
693
|
+
static button(title: string): UITableCell;
|
|
694
|
+
/** 构造图像单元格 */
|
|
695
|
+
static image(image: Image): UITableCell;
|
|
696
|
+
/** 构造加载指定 URL 图像的单元格 */
|
|
697
|
+
static imageAtURL(url: string): UITableCell;
|
|
698
|
+
/** 构造文本单元格 */
|
|
699
|
+
static text(title?: string, subtitle?: string): UITableCell;
|
|
657
700
|
}
|
|
658
701
|
|
|
659
702
|
/**
|
|
@@ -662,6 +705,9 @@ declare global {
|
|
|
662
705
|
class WebView {
|
|
663
706
|
constructor();
|
|
664
707
|
|
|
708
|
+
/** 请求加载回调,返回 false 可阻止请求以加快加载 */
|
|
709
|
+
shouldAllowRequest: (request: Request) => boolean;
|
|
710
|
+
|
|
665
711
|
/** 加载 HTML */
|
|
666
712
|
loadHTML(html: string, baseURL?: string): Promise<void>;
|
|
667
713
|
/** 加载 URL */
|
|
@@ -676,6 +722,9 @@ declare global {
|
|
|
676
722
|
present(fullscreen?: boolean): Promise<void>;
|
|
677
723
|
/** 等待加载完成 */
|
|
678
724
|
waitForLoad(): Promise<void>;
|
|
725
|
+
|
|
726
|
+
/** 加载文件并展示预览 */
|
|
727
|
+
static loadFile(fileURL: string, preferredSize?: Size, fullscreen?: boolean): Promise<void>;
|
|
679
728
|
}
|
|
680
729
|
|
|
681
730
|
/**
|
|
@@ -783,6 +832,8 @@ declare global {
|
|
|
783
832
|
bookmarkedPath(name: string): string;
|
|
784
833
|
/** 添加书签 */
|
|
785
834
|
bookmarkPath(path: string, name: string): void;
|
|
835
|
+
/** 检查指定名称的文件书签是否存在 */
|
|
836
|
+
bookmarkExists(name: string): boolean;
|
|
786
837
|
}
|
|
787
838
|
|
|
788
839
|
/**
|
|
@@ -819,6 +870,12 @@ declare global {
|
|
|
819
870
|
static latestScreenshot(): Promise<Image>;
|
|
820
871
|
/** 获取最近的屏幕截图列表 */
|
|
821
872
|
static latestScreenshots(count: number): Promise<Image[]>;
|
|
873
|
+
/** 移除最近的一张照片,移除前会弹窗确认 */
|
|
874
|
+
static removeLatestPhoto(): Promise<void>;
|
|
875
|
+
/** 移除最近的指定数量照片,移除前会弹窗确认 */
|
|
876
|
+
static removeLatestPhotos(count: number): Promise<void>;
|
|
877
|
+
/** 移除最近的一张屏幕截图,移除前会弹窗确认 */
|
|
878
|
+
static removeLatestScreenshot(): Promise<void>;
|
|
822
879
|
/** 保存到相册 */
|
|
823
880
|
static save(image: Image): Promise<void>;
|
|
824
881
|
}
|
|
@@ -841,6 +898,8 @@ declare global {
|
|
|
841
898
|
static exportImage(image: Image, name?: string): Promise<string[]>;
|
|
842
899
|
/** 导出数据 */
|
|
843
900
|
static exportData(data: Data, name?: string): Promise<string[]>;
|
|
901
|
+
/** 打开文件夹,返回所选文件夹路径 */
|
|
902
|
+
static openFolder(): Promise<string[]>;
|
|
844
903
|
}
|
|
845
904
|
|
|
846
905
|
/**
|
|
@@ -849,10 +908,14 @@ declare global {
|
|
|
849
908
|
class Pasteboard {
|
|
850
909
|
/** 复制文本 */
|
|
851
910
|
static copy(text: string): void;
|
|
911
|
+
/** 复制字符串到剪贴板 */
|
|
912
|
+
static copyString(string: string): void;
|
|
852
913
|
/** 复制图像 */
|
|
853
914
|
static copyImage(image: Image): void;
|
|
854
915
|
/** 粘贴文本 */
|
|
855
916
|
static paste(): string;
|
|
917
|
+
/** 粘贴剪贴板中的字符串,无字符串时返回 null */
|
|
918
|
+
static pasteString(): string | null;
|
|
856
919
|
/** 粘贴图像 */
|
|
857
920
|
static pasteImage(): Image;
|
|
858
921
|
}
|
|
@@ -896,6 +959,8 @@ declare global {
|
|
|
896
959
|
setStrokeColor(color: Color): void;
|
|
897
960
|
/** 设置线宽 */
|
|
898
961
|
setLineWidth(width: number): void;
|
|
962
|
+
/** 设置绘制文本时的字体大小 */
|
|
963
|
+
setFontSize(size: number): void;
|
|
899
964
|
/** 填充矩形 */
|
|
900
965
|
fill(rect: Rect): void;
|
|
901
966
|
/** 填充矩形 */
|
|
@@ -904,6 +969,8 @@ declare global {
|
|
|
904
969
|
fillEllipse(rect: Rect): void;
|
|
905
970
|
/** 描边矩形 */
|
|
906
971
|
stroke(rect: Rect): void;
|
|
972
|
+
/** 沿矩形边框绘制线条 */
|
|
973
|
+
strokeRect(rect: Rect): void;
|
|
907
974
|
/** 描边椭圆 */
|
|
908
975
|
strokeEllipse(rect: Rect): void;
|
|
909
976
|
/** 添加路径 */
|
|
@@ -1016,8 +1083,12 @@ declare global {
|
|
|
1016
1083
|
static allParameters(): Record<string, string>;
|
|
1017
1084
|
/** 获取参数 */
|
|
1018
1085
|
static parameter(name: string): string;
|
|
1019
|
-
/**
|
|
1020
|
-
static
|
|
1086
|
+
/** 获取运行当前脚本的 URL */
|
|
1087
|
+
static forRunningScript(): string;
|
|
1088
|
+
/** 获取打开当前脚本的 URL */
|
|
1089
|
+
static forOpeningScript(): string;
|
|
1090
|
+
/** 获取打开当前脚本设置的 URL */
|
|
1091
|
+
static forOpeningScriptSettings(): string;
|
|
1021
1092
|
}
|
|
1022
1093
|
|
|
1023
1094
|
// ==================== 日历和提醒类 ====================
|
|
@@ -1034,18 +1105,16 @@ declare global {
|
|
|
1034
1105
|
static forEvents(): Promise<Calendar[]>;
|
|
1035
1106
|
/** 获取所有提醒日历 */
|
|
1036
1107
|
static forReminders(): Promise<Calendar[]>;
|
|
1037
|
-
/**
|
|
1038
|
-
static
|
|
1039
|
-
/**
|
|
1040
|
-
static
|
|
1041
|
-
/**
|
|
1042
|
-
static
|
|
1108
|
+
/** 通过标题获取事件日历 */
|
|
1109
|
+
static forEventsByTitle(title: string): Promise<Calendar>;
|
|
1110
|
+
/** 通过标题获取提醒日历 */
|
|
1111
|
+
static forRemindersByTitle(title: string): Promise<Calendar>;
|
|
1112
|
+
/** 查找或创建提醒日历,找到多个时返回第一个 */
|
|
1113
|
+
static findOrCreateForReminders(title: string): Promise<Calendar>;
|
|
1043
1114
|
/** 创建提醒日历 */
|
|
1044
1115
|
static createForReminders(title: string): Calendar;
|
|
1045
|
-
/**
|
|
1046
|
-
static
|
|
1047
|
-
/** 通过标识符查找提醒日历 */
|
|
1048
|
-
static forReminderByIdentifier(identifier: string): Promise<Calendar>;
|
|
1116
|
+
/** 检查日历是否支持指定的可用性(busy/free/tentative/unavailable) */
|
|
1117
|
+
static supportsAvailability(availability: string): boolean;
|
|
1049
1118
|
|
|
1050
1119
|
/** 日历标识符 */
|
|
1051
1120
|
identifier: string;
|
|
@@ -1062,8 +1131,8 @@ declare global {
|
|
|
1062
1131
|
save(): void;
|
|
1063
1132
|
/** 删除日历 */
|
|
1064
1133
|
remove(): void;
|
|
1065
|
-
/**
|
|
1066
|
-
presentPicker(): Promise<Calendar>;
|
|
1134
|
+
/** 展示日历选择器,allowMultiple 为 true 时返回日历数组 */
|
|
1135
|
+
presentPicker(allowMultiple?: boolean): Promise<Calendar | Calendar[]>;
|
|
1067
1136
|
}
|
|
1068
1137
|
|
|
1069
1138
|
/**
|
|
@@ -1130,37 +1199,63 @@ declare global {
|
|
|
1130
1199
|
* 提醒类
|
|
1131
1200
|
*/
|
|
1132
1201
|
class Reminder {
|
|
1133
|
-
/**
|
|
1202
|
+
/** 获取所有提醒 */
|
|
1134
1203
|
static all(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1135
1204
|
/** 获取所有已完成的提醒 */
|
|
1136
1205
|
static allCompleted(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1206
|
+
/** 获取所有未完成的提醒 */
|
|
1207
|
+
static allIncomplete(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1137
1208
|
/** 获取所有未完成的提醒(今天到期) */
|
|
1138
1209
|
static allDueToday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1139
|
-
/** 获取所有已完成的提醒(今天完成) */
|
|
1140
|
-
static completedToday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1141
1210
|
/** 获取所有未完成的提醒(明天到期) */
|
|
1142
1211
|
static allDueTomorrow(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1143
|
-
/** 获取所有已完成的提醒(明天完成) */
|
|
1144
|
-
static completedTomorrow(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1145
1212
|
/** 获取所有未完成的提醒(昨天到期) */
|
|
1146
1213
|
static allDueYesterday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1147
|
-
/** 获取所有已完成的提醒(昨天完成) */
|
|
1148
|
-
static completedYesterday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1149
1214
|
/** 获取所有未完成的提醒(本周到期) */
|
|
1150
1215
|
static allDueThisWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1151
|
-
/** 获取所有已完成的提醒(本周完成) */
|
|
1152
|
-
static completedThisWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1153
1216
|
/** 获取所有未完成的提醒(下周到期) */
|
|
1154
1217
|
static allDueNextWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1155
1218
|
/** 获取所有未完成的提醒(上周到期) */
|
|
1156
1219
|
static allDueLastWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1157
|
-
/** 获取所有已完成的提醒(上周完成) */
|
|
1158
|
-
static completedLastWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1159
1220
|
/** 获取所有未完成的提醒(指定日期范围) */
|
|
1160
1221
|
static allDueBetween(startDate: Date, endDate: Date, calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1161
|
-
/**
|
|
1222
|
+
/** 获取已完成的提醒(今天完成) */
|
|
1223
|
+
static completedToday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1224
|
+
/** 获取已完成的提醒(本周完成) */
|
|
1225
|
+
static completedThisWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1226
|
+
/** 获取已完成的提醒(上周完成) */
|
|
1227
|
+
static completedLastWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1228
|
+
/** 获取已完成的提醒(指定完成日期范围) */
|
|
1162
1229
|
static completedBetween(startDate: Date, endDate: Date, calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1163
|
-
/**
|
|
1230
|
+
/** 获取已完成的提醒(今天到期) */
|
|
1231
|
+
static completedDueToday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1232
|
+
/** 获取已完成的提醒(明天到期) */
|
|
1233
|
+
static completedDueTomorrow(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1234
|
+
/** 获取已完成的提醒(昨天到期) */
|
|
1235
|
+
static completedDueYesterday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1236
|
+
/** 获取已完成的提醒(本周到期) */
|
|
1237
|
+
static completedDueThisWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1238
|
+
/** 获取已完成的提醒(下周到期) */
|
|
1239
|
+
static completedDueNextWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1240
|
+
/** 获取已完成的提醒(上周到期) */
|
|
1241
|
+
static completedDueLastWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1242
|
+
/** 获取已完成的提醒(指定到期日期范围) */
|
|
1243
|
+
static completedDueBetween(startDate: Date, endDate: Date, calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1244
|
+
/** 获取未完成的提醒(今天到期) */
|
|
1245
|
+
static incompleteDueToday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1246
|
+
/** 获取未完成的提醒(明天到期) */
|
|
1247
|
+
static incompleteDueTomorrow(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1248
|
+
/** 获取未完成的提醒(昨天到期) */
|
|
1249
|
+
static incompleteDueYesterday(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1250
|
+
/** 获取未完成的提醒(本周到期) */
|
|
1251
|
+
static incompleteDueThisWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1252
|
+
/** 获取未完成的提醒(下周到期) */
|
|
1253
|
+
static incompleteDueNextWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1254
|
+
/** 获取未完成的提醒(上周到期) */
|
|
1255
|
+
static incompleteDueLastWeek(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1256
|
+
/** 获取未完成的提醒(指定到期日期范围) */
|
|
1257
|
+
static incompleteDueBetween(startDate: Date, endDate: Date, calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1258
|
+
/** 获取所有已计划的提醒 */
|
|
1164
1259
|
static scheduled(calendars?: Calendar[]): Promise<Reminder[]>;
|
|
1165
1260
|
|
|
1166
1261
|
/** 提醒标识符 */
|
|
@@ -1181,6 +1276,8 @@ declare global {
|
|
|
1181
1276
|
dueDateIncludesTime: boolean;
|
|
1182
1277
|
/** 优先级 */
|
|
1183
1278
|
priority: number;
|
|
1279
|
+
/** 是否已过期 */
|
|
1280
|
+
isOverdue: boolean;
|
|
1184
1281
|
/** 所属日历 */
|
|
1185
1282
|
calendar: Calendar;
|
|
1186
1283
|
|
|
@@ -1200,16 +1297,46 @@ declare global {
|
|
|
1200
1297
|
class RecurrenceRule {
|
|
1201
1298
|
/** 创建每日重复规则 */
|
|
1202
1299
|
static daily(interval?: number): RecurrenceRule;
|
|
1300
|
+
/** 创建每日重复规则并指定结束日期 */
|
|
1301
|
+
static dailyEndDate(interval: number, endDate: Date): RecurrenceRule;
|
|
1302
|
+
/** 创建每日重复规则并指定重复次数 */
|
|
1303
|
+
static dailyOccurrenceCount(interval: number, occurrenceCount: number): RecurrenceRule;
|
|
1203
1304
|
/** 创建每周重复规则 */
|
|
1204
1305
|
static weekly(interval?: number): RecurrenceRule;
|
|
1306
|
+
/** 创建每周重复规则并指定结束日期 */
|
|
1307
|
+
static weeklyEndDate(interval: number, endDate: Date): RecurrenceRule;
|
|
1308
|
+
/** 创建每周重复规则并指定重复次数 */
|
|
1309
|
+
static weeklyOccurrenceCount(interval: number, occurrenceCount: number): RecurrenceRule;
|
|
1205
1310
|
/** 创建每月重复规则 */
|
|
1206
1311
|
static monthly(interval?: number): RecurrenceRule;
|
|
1312
|
+
/** 创建每月重复规则并指定结束日期 */
|
|
1313
|
+
static monthlyEndDate(interval: number, endDate: Date): RecurrenceRule;
|
|
1314
|
+
/** 创建每月重复规则并指定重复次数 */
|
|
1315
|
+
static monthlyOccurrenceCount(interval: number, occurrenceCount: number): RecurrenceRule;
|
|
1207
1316
|
/** 创建每年重复规则 */
|
|
1208
1317
|
static yearly(interval?: number): RecurrenceRule;
|
|
1318
|
+
/** 创建每年重复规则并指定结束日期 */
|
|
1319
|
+
static yearlyEndDate(interval: number, endDate: Date): RecurrenceRule;
|
|
1320
|
+
/** 创建每年重复规则并指定重复次数 */
|
|
1321
|
+
static yearlyOccurrenceCount(interval: number, occurrenceCount: number): RecurrenceRule;
|
|
1209
1322
|
/** 创建每周的特定天重复规则 */
|
|
1210
1323
|
static weeklyOnDays(daysOfTheWeek: number[], interval?: number): RecurrenceRule;
|
|
1211
1324
|
/** 创建复杂重复规则 */
|
|
1212
1325
|
static complexWeekly(interval: number, daysOfTheWeek: number[], setPositions: number[]): RecurrenceRule;
|
|
1326
|
+
/** 创建复杂每周重复规则并指定结束日期 */
|
|
1327
|
+
static complexWeeklyEndDate(
|
|
1328
|
+
interval: number,
|
|
1329
|
+
daysOfTheWeek: number[],
|
|
1330
|
+
setPositions: number[],
|
|
1331
|
+
endDate: Date,
|
|
1332
|
+
): RecurrenceRule;
|
|
1333
|
+
/** 创建复杂每周重复规则并指定重复次数 */
|
|
1334
|
+
static complexWeeklyOccurrenceCount(
|
|
1335
|
+
interval: number,
|
|
1336
|
+
daysOfTheWeek: number[],
|
|
1337
|
+
setPositions: number[],
|
|
1338
|
+
occurrenceCount: number,
|
|
1339
|
+
): RecurrenceRule;
|
|
1213
1340
|
/** 创建复杂每月重复规则 */
|
|
1214
1341
|
static complexMonthly(
|
|
1215
1342
|
interval: number,
|
|
@@ -1217,6 +1344,22 @@ declare global {
|
|
|
1217
1344
|
daysOfTheMonth: number[],
|
|
1218
1345
|
setPositions: number[],
|
|
1219
1346
|
): RecurrenceRule;
|
|
1347
|
+
/** 创建复杂每月重复规则并指定结束日期 */
|
|
1348
|
+
static complexMonthlyEndDate(
|
|
1349
|
+
interval: number,
|
|
1350
|
+
daysOfTheWeek: number[],
|
|
1351
|
+
daysOfTheMonth: number[],
|
|
1352
|
+
setPositions: number[],
|
|
1353
|
+
endDate: Date,
|
|
1354
|
+
): RecurrenceRule;
|
|
1355
|
+
/** 创建复杂每月重复规则并指定重复次数 */
|
|
1356
|
+
static complexMonthlyOccurrenceCount(
|
|
1357
|
+
interval: number,
|
|
1358
|
+
daysOfTheWeek: number[],
|
|
1359
|
+
daysOfTheMonth: number[],
|
|
1360
|
+
setPositions: number[],
|
|
1361
|
+
occurrenceCount: number,
|
|
1362
|
+
): RecurrenceRule;
|
|
1220
1363
|
/** 创建复杂每年重复规则 */
|
|
1221
1364
|
static complexYearly(
|
|
1222
1365
|
interval: number,
|
|
@@ -1227,6 +1370,26 @@ declare global {
|
|
|
1227
1370
|
daysOfTheYear: number[],
|
|
1228
1371
|
setPositions: number[],
|
|
1229
1372
|
): RecurrenceRule;
|
|
1373
|
+
/** 创建复杂每年重复规则并指定结束日期 */
|
|
1374
|
+
static complexYearlyEndDate(
|
|
1375
|
+
interval: number,
|
|
1376
|
+
daysOfTheWeek: number[],
|
|
1377
|
+
monthsOfTheYear: number[],
|
|
1378
|
+
weeksOfTheYear: number[],
|
|
1379
|
+
daysOfTheYear: number[],
|
|
1380
|
+
setPositions: number[],
|
|
1381
|
+
endDate: Date,
|
|
1382
|
+
): RecurrenceRule;
|
|
1383
|
+
/** 创建复杂每年重复规则并指定重复次数 */
|
|
1384
|
+
static complexYearlyOccurrenceCount(
|
|
1385
|
+
interval: number,
|
|
1386
|
+
daysOfTheWeek: number[],
|
|
1387
|
+
monthsOfTheYear: number[],
|
|
1388
|
+
weeksOfTheYear: number[],
|
|
1389
|
+
daysOfTheYear: number[],
|
|
1390
|
+
setPositions: number[],
|
|
1391
|
+
occurrenceCount: number,
|
|
1392
|
+
): RecurrenceRule;
|
|
1230
1393
|
}
|
|
1231
1394
|
|
|
1232
1395
|
// ==================== 系统和设备类 ====================
|
|
@@ -1309,6 +1472,8 @@ declare global {
|
|
|
1309
1472
|
static removeDelivered(identifiers: string[]): Promise<void>;
|
|
1310
1473
|
/** 重置应用图标角标数字 */
|
|
1311
1474
|
static resetCurrent(): void;
|
|
1475
|
+
/** 获取脚本正在运行的通知 */
|
|
1476
|
+
static current(): Notification;
|
|
1312
1477
|
|
|
1313
1478
|
/** 通知标识符 */
|
|
1314
1479
|
identifier: string;
|
|
@@ -1322,10 +1487,14 @@ declare global {
|
|
|
1322
1487
|
badge: number;
|
|
1323
1488
|
/** 声音 */
|
|
1324
1489
|
sound: string;
|
|
1490
|
+
/** 点击通知时打开的 URL */
|
|
1491
|
+
openURL: string;
|
|
1325
1492
|
/** 启动 URL */
|
|
1326
1493
|
launchURL: string;
|
|
1327
1494
|
/** 用户信息 */
|
|
1328
1495
|
userInfo: Record<string, any>;
|
|
1496
|
+
/** 通知动作列表,通过 addAction 添加 */
|
|
1497
|
+
actions: Array<{ title: string; url: string }>;
|
|
1329
1498
|
/** 附件 */
|
|
1330
1499
|
attachments: Array<{ identifier: string; url: string; type: string }>;
|
|
1331
1500
|
/** 首选内容高度 */
|
|
@@ -1367,6 +1536,8 @@ declare global {
|
|
|
1367
1536
|
warn(message: any): void;
|
|
1368
1537
|
/** 输出错误 */
|
|
1369
1538
|
error(message: any): void;
|
|
1539
|
+
/** 输出错误日志,具有醒目的外观 */
|
|
1540
|
+
logError(message: any): void;
|
|
1370
1541
|
};
|
|
1371
1542
|
|
|
1372
1543
|
/**
|
|
@@ -1392,9 +1563,17 @@ declare global {
|
|
|
1392
1563
|
*/
|
|
1393
1564
|
class Contact {
|
|
1394
1565
|
/** 获取所有联系人 */
|
|
1395
|
-
static all(): Promise<Contact[]>;
|
|
1566
|
+
static all(containers?: ContactsContainer[]): Promise<Contact[]>;
|
|
1396
1567
|
/** 在所有容器中查找联系人 */
|
|
1397
1568
|
static inGroups(groups: ContactsGroup[]): Promise<Contact[]>;
|
|
1569
|
+
/** 将联系人加入添加队列 */
|
|
1570
|
+
static add(contact: Contact, containerIdentifier?: string): void;
|
|
1571
|
+
/** 将联系人更新加入队列 */
|
|
1572
|
+
static update(contact: Contact): void;
|
|
1573
|
+
/** 将联系人删除加入队列 */
|
|
1574
|
+
static delete(contact: Contact): void;
|
|
1575
|
+
/** 持久化所有已入队的联系人变更 */
|
|
1576
|
+
static persistChanges(): Promise<void>;
|
|
1398
1577
|
|
|
1399
1578
|
/** 联系人标识符 */
|
|
1400
1579
|
identifier: string;
|
|
@@ -1408,8 +1587,6 @@ declare global {
|
|
|
1408
1587
|
familyName: string;
|
|
1409
1588
|
/** 昵称 */
|
|
1410
1589
|
nickname: string;
|
|
1411
|
-
/** 姓名后缀 */
|
|
1412
|
-
nameSuffix: string;
|
|
1413
1590
|
/** 组织名称 */
|
|
1414
1591
|
organizationName: string;
|
|
1415
1592
|
/** 部门名称 */
|
|
@@ -1418,10 +1595,46 @@ declare global {
|
|
|
1418
1595
|
jobTitle: string;
|
|
1419
1596
|
/** 生日 */
|
|
1420
1597
|
birthday: Date;
|
|
1598
|
+
/** 重要日期列表,更新时需设置完整数组 */
|
|
1599
|
+
dates: Array<{ label?: string; date?: Date; identifier?: string }>;
|
|
1421
1600
|
/** 备注 */
|
|
1422
1601
|
note: string;
|
|
1423
1602
|
/** 头像 */
|
|
1424
1603
|
image: Image;
|
|
1604
|
+
/** 生日属性是否可用 */
|
|
1605
|
+
isBirthdayAvailable: boolean;
|
|
1606
|
+
/** 重要日期属性是否可用 */
|
|
1607
|
+
isDatesAvailable: boolean;
|
|
1608
|
+
/** 部门名称属性是否可用 */
|
|
1609
|
+
isDepartmentNameAvailable: boolean;
|
|
1610
|
+
/** 邮箱地址属性是否可用 */
|
|
1611
|
+
isEmailAddressesAvailable: boolean;
|
|
1612
|
+
/** 姓氏属性是否可用 */
|
|
1613
|
+
isFamilyNameAvailable: boolean;
|
|
1614
|
+
/** 名字属性是否可用 */
|
|
1615
|
+
isGiveNameAvailable: boolean;
|
|
1616
|
+
/** 头像属性是否可用 */
|
|
1617
|
+
isImageAvailable: boolean;
|
|
1618
|
+
/** 职位属性是否可用 */
|
|
1619
|
+
isJobTitleAvailable: boolean;
|
|
1620
|
+
/** 中间名属性是否可用 */
|
|
1621
|
+
isMiddleNameAvailable: boolean;
|
|
1622
|
+
/** 姓名前缀属性是否可用 */
|
|
1623
|
+
isNamePrefixAvailable: boolean;
|
|
1624
|
+
/** 昵称属性是否可用 */
|
|
1625
|
+
isNicknameAvailable: boolean;
|
|
1626
|
+
/** 备注属性是否可用 */
|
|
1627
|
+
isNoteAvailable: boolean;
|
|
1628
|
+
/** 组织名称属性是否可用 */
|
|
1629
|
+
isOrganizationNameAvailable: boolean;
|
|
1630
|
+
/** 电话号码属性是否可用 */
|
|
1631
|
+
isPhoneNumbersAvailable: boolean;
|
|
1632
|
+
/** 邮政地址属性是否可用 */
|
|
1633
|
+
isPostalAddressesAvailable: boolean;
|
|
1634
|
+
/** 社交资料属性是否可用 */
|
|
1635
|
+
isSocialProfilesAvailable: boolean;
|
|
1636
|
+
/** URL 地址属性是否可用 */
|
|
1637
|
+
isURLAddressesAvailable: boolean;
|
|
1425
1638
|
/** 电话号码 */
|
|
1426
1639
|
phoneNumbers: Array<{ label: string; value: string; identifier: string; localizedLabel: string }>;
|
|
1427
1640
|
/** 邮箱地址 */
|
|
@@ -1447,8 +1660,6 @@ declare global {
|
|
|
1447
1660
|
}>;
|
|
1448
1661
|
/** URL 地址 */
|
|
1449
1662
|
urlAddresses: Array<{ label: string; value: string; identifier: string }>;
|
|
1450
|
-
/** 是否可用 */
|
|
1451
|
-
isAvailable: boolean;
|
|
1452
1663
|
}
|
|
1453
1664
|
|
|
1454
1665
|
/**
|
|
@@ -1474,11 +1685,22 @@ declare global {
|
|
|
1474
1685
|
class ContactsGroup {
|
|
1475
1686
|
/** 获取所有分组 */
|
|
1476
1687
|
static all(containers?: ContactsContainer[]): Promise<ContactsGroup[]>;
|
|
1688
|
+
/** 将分组加入添加队列 */
|
|
1689
|
+
static add(group: ContactsGroup, containerIdentifier?: string): void;
|
|
1690
|
+
/** 将分组更新加入队列 */
|
|
1691
|
+
static update(group: ContactsGroup): void;
|
|
1692
|
+
/** 将分组删除加入队列 */
|
|
1693
|
+
static delete(group: ContactsGroup): void;
|
|
1477
1694
|
|
|
1478
1695
|
/** 分组标识符 */
|
|
1479
1696
|
identifier: string;
|
|
1480
1697
|
/** 分组名称 */
|
|
1481
1698
|
name: string;
|
|
1699
|
+
|
|
1700
|
+
/** 添加联系人到分组,需调用 Contact.persistChanges() 持久化 */
|
|
1701
|
+
addMember(contact: Contact): void;
|
|
1702
|
+
/** 从分组移除联系人,需调用 Contact.persistChanges() 持久化 */
|
|
1703
|
+
removeMember(contact: Contact): void;
|
|
1482
1704
|
}
|
|
1483
1705
|
|
|
1484
1706
|
/**
|
|
@@ -1592,6 +1814,27 @@ declare global {
|
|
|
1592
1814
|
string(date: Date): string;
|
|
1593
1815
|
/** 将字符串转换为日期 */
|
|
1594
1816
|
date(string: string): Date;
|
|
1817
|
+
|
|
1818
|
+
/** 日期使用完整样式,如 "Friday, August 23, 2019 AD" */
|
|
1819
|
+
useFullDateStyle(): void;
|
|
1820
|
+
/** 时间使用完整样式,如 "7:16:42 PM Pacific Standard Time" */
|
|
1821
|
+
useFullTimeStyle(): void;
|
|
1822
|
+
/** 日期使用长样式,如 "August 23, 2019" */
|
|
1823
|
+
useLongDateStyle(): void;
|
|
1824
|
+
/** 时间使用长样式,如 "7:16:42 PM PST" */
|
|
1825
|
+
useLongTimeStyle(): void;
|
|
1826
|
+
/** 日期使用中等样式,如 "Aug 23, 2019" */
|
|
1827
|
+
useMediumDateStyle(): void;
|
|
1828
|
+
/** 时间使用中等样式,如 "7:16:42 PM" */
|
|
1829
|
+
useMediumTimeStyle(): void;
|
|
1830
|
+
/** 日期使用短样式,如 "08/23/19" */
|
|
1831
|
+
useShortDateStyle(): void;
|
|
1832
|
+
/** 时间使用短样式,如 "7:17 PM" */
|
|
1833
|
+
useShortTimeStyle(): void;
|
|
1834
|
+
/** 移除格式化结果中的日期部分 */
|
|
1835
|
+
useNoDateStyle(): void;
|
|
1836
|
+
/** 移除格式化结果中的时间部分 */
|
|
1837
|
+
useNoTimeStyle(): void;
|
|
1595
1838
|
}
|
|
1596
1839
|
|
|
1597
1840
|
/**
|
|
@@ -1625,6 +1868,8 @@ declare global {
|
|
|
1625
1868
|
* 相对日期时间格式化类
|
|
1626
1869
|
*/
|
|
1627
1870
|
class RelativeDateTimeFormatter {
|
|
1871
|
+
/** 格式化使用的区域设置,如 "en"、"it"、"da",未设置时使用设备当前区域 */
|
|
1872
|
+
locale: string;
|
|
1628
1873
|
/** 使用命名日期时间样式 */
|
|
1629
1874
|
useNamedDateTimeStyle(): void;
|
|
1630
1875
|
/** 使用数字日期时间样式 */
|
|
@@ -1706,6 +1951,10 @@ declare global {
|
|
|
1706
1951
|
class XMLParser {
|
|
1707
1952
|
/** XML 字符串 */
|
|
1708
1953
|
string: string;
|
|
1954
|
+
/** 文档开始解析回调 */
|
|
1955
|
+
didStartDocument: () => void;
|
|
1956
|
+
/** 文档解析完成回调 */
|
|
1957
|
+
didEndDocument: () => void;
|
|
1709
1958
|
/** 解析完成回调 */
|
|
1710
1959
|
didStartElement: (elementName: string, attributes: Record<string, string>) => void;
|
|
1711
1960
|
/** 元素结束回调 */
|
|
@@ -1735,6 +1984,16 @@ declare global {
|
|
|
1735
1984
|
}>;
|
|
1736
1985
|
/** 设置允许后台位置更新 */
|
|
1737
1986
|
static setAllowsBackgroundLocationUpdates(allows: boolean): void;
|
|
1987
|
+
/** 使用最佳精度获取位置(默认行为) */
|
|
1988
|
+
static setAccuracyToBest(): void;
|
|
1989
|
+
/** 将精度设置为百米以内 */
|
|
1990
|
+
static setAccuracyToHundredMeters(): void;
|
|
1991
|
+
/** 将精度设置为一公里以内 */
|
|
1992
|
+
static setAccuracyToKilometer(): void;
|
|
1993
|
+
/** 将精度设置为十米以内 */
|
|
1994
|
+
static setAccuracyToTenMeters(): void;
|
|
1995
|
+
/** 将精度设置为三公里以内 */
|
|
1996
|
+
static setAccuracyToThreeKilometers(): void;
|
|
1738
1997
|
/** 反向地理编码 */
|
|
1739
1998
|
static reverseGeocode(
|
|
1740
1999
|
latitude: number,
|
|
@@ -1762,20 +2021,16 @@ declare global {
|
|
|
1762
2021
|
runsInApp: boolean;
|
|
1763
2022
|
/** 是否在小组件中运行 */
|
|
1764
2023
|
runsInWidget: boolean;
|
|
2024
|
+
/** 是否在辅助小组件中运行(锁屏小组件,iOS 16+) */
|
|
2025
|
+
runsInAccessoryWidget: boolean;
|
|
1765
2026
|
/** 是否在通知中运行 */
|
|
1766
2027
|
runsInNotification: boolean;
|
|
1767
|
-
/**
|
|
2028
|
+
/** 是否通过 Siri 运行 */
|
|
1768
2029
|
runsWithSiri: boolean;
|
|
1769
|
-
/** 是否在 Siri 中运行 */
|
|
1770
|
-
runsInSiri: boolean;
|
|
1771
|
-
/** 是否在快捷指令中运行 */
|
|
1772
|
-
runsInShortcuts: boolean;
|
|
1773
2030
|
/** 是否在操作扩展中运行 */
|
|
1774
2031
|
runsInActionExtension: boolean;
|
|
1775
2032
|
/** 是否从主屏幕运行 */
|
|
1776
2033
|
runsFromHomeScreen: boolean;
|
|
1777
|
-
/** 是否在 App Clip 中运行 */
|
|
1778
|
-
runsInAppClip: boolean;
|
|
1779
2034
|
/** 小组件类型(small, medium, large, extraLarge) */
|
|
1780
2035
|
widgetFamily: string | null;
|
|
1781
2036
|
};
|
|
@@ -1785,8 +2040,14 @@ declare global {
|
|
|
1785
2040
|
* 提供传递给脚本的参数
|
|
1786
2041
|
*/
|
|
1787
2042
|
const args: {
|
|
2043
|
+
/** 分享面板传入的全部参数 */
|
|
2044
|
+
all: any[];
|
|
2045
|
+
/** 参数数量 */
|
|
2046
|
+
length: number;
|
|
1788
2047
|
/** 小组件参数 */
|
|
1789
2048
|
widgetParameter: string | null;
|
|
2049
|
+
/** 小组件动作,交互式控件触发时包含 id 和 isOn */
|
|
2050
|
+
widgetAction: { id?: string; isOn?: boolean } | null;
|
|
1790
2051
|
/** 查询参数 */
|
|
1791
2052
|
queryParameters: Record<string, string>;
|
|
1792
2053
|
/** URL 列表 */
|
|
@@ -1799,6 +2060,8 @@ declare global {
|
|
|
1799
2060
|
fileURLs: string[];
|
|
1800
2061
|
/** 快捷指令参数 */
|
|
1801
2062
|
shortcutParameter: any;
|
|
2063
|
+
/** Siri 快捷指令参数 */
|
|
2064
|
+
siriShortcutArguments: any;
|
|
1802
2065
|
/** 通知 */
|
|
1803
2066
|
notification: Notification | null;
|
|
1804
2067
|
};
|