Skip to content

Commit 78757ee

Browse files
🔄 Sync from private repository - 2026-02-05 08:12:53
1 parent 0028656 commit 78757ee

7 files changed

Lines changed: 197 additions & 2 deletions

File tree

API.en.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,66 @@ Clear all performance records
16071607

16081608
---
16091609

1610+
### `app.notifyPost`
1611+
1612+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1613+
1614+
**Signature:** `notifyPost(name)`
1615+
1616+
Send a Darwin Notification
1617+
1618+
**Parameters:**
1619+
1620+
| Name | Type | Description | Optional |
1621+
|------|------|-------------|----------|
1622+
| `name` | `string` | Notification name | No |
1623+
1624+
**Returns:** `boolean`
1625+
1626+
*Whether the notification was sent successfully*
1627+
1628+
---
1629+
1630+
### `app.notifyRegister`
1631+
1632+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1633+
1634+
**Signature:** `notifyRegister(name)`
1635+
1636+
Register to listen for a Darwin Notification
1637+
1638+
**Parameters:**
1639+
1640+
| Name | Type | Description | Optional |
1641+
|------|------|-------------|----------|
1642+
| `name` | `string` | Notification name | No |
1643+
1644+
**Returns:** `number`
1645+
1646+
*Listener token*
1647+
1648+
---
1649+
1650+
### `app.notifyCancel`
1651+
1652+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1653+
1654+
**Signature:** `notifyCancel(token)`
1655+
1656+
Cancel listening for a Darwin Notification
1657+
1658+
**Parameters:**
1659+
1660+
| Name | Type | Description | Optional |
1661+
|------|------|-------------|----------|
1662+
| `token` | `number` | Listener token | No |
1663+
1664+
**Returns:** `boolean`
1665+
1666+
*Whether the listener was cancelled successfully*
1667+
1668+
---
1669+
16101670
## haptic
16111671

16121672
![Limited Support](https://img.shields.io/badge/Trigger-Limited-orange)

API.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,66 @@ Ping 主机
16061606

16071607
---
16081608

1609+
### `app.notifyPost`
1610+
1611+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1612+
1613+
**Signature:** `notifyPost(name)`
1614+
1615+
发送 Darwin Notification
1616+
1617+
**Parameters:**
1618+
1619+
| Name | Type | Description | Optional |
1620+
|------|------|-------------|----------|
1621+
| `name` | `string` | notification 名称 | No |
1622+
1623+
**Returns:** `boolean`
1624+
1625+
*是否发送成功*
1626+
1627+
---
1628+
1629+
### `app.notifyRegister`
1630+
1631+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1632+
1633+
**Signature:** `notifyRegister(name)`
1634+
1635+
注册监听 Darwin Notification
1636+
1637+
**Parameters:**
1638+
1639+
| Name | Type | Description | Optional |
1640+
|------|------|-------------|----------|
1641+
| `name` | `string` | notification 名称 | No |
1642+
1643+
**Returns:** `number`
1644+
1645+
*监听 token*
1646+
1647+
---
1648+
1649+
### `app.notifyCancel`
1650+
1651+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1652+
1653+
**Signature:** `notifyCancel(token)`
1654+
1655+
取消监听 Darwin Notification
1656+
1657+
**Parameters:**
1658+
1659+
| Name | Type | Description | Optional |
1660+
|------|------|-------------|----------|
1661+
| `token` | `number` | token 数字 | No |
1662+
1663+
**Returns:** `boolean`
1664+
1665+
*是否取消成功*
1666+
1667+
---
1668+
16091669
## haptic
16101670

16111671
![Limited Support](https://img.shields.io/badge/Trigger-Limited-orange)

TrollScript-Private

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 6b31b7a03f68ad494dbe21ebcbff077f9f475e00
1+
Subproject commit 6395cdd06f881d29d393339dda1de82955fb941c

npm/index.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,27 @@ interface App {
673673
*/
674674
clearPerformanceRecords(): void;
675675

676+
/**
677+
* 发送 Darwin Notification
678+
* @param name notification 名称
679+
* @returns 是否发送成功
680+
*/
681+
notifyPost(name: string): boolean;
682+
683+
/**
684+
* 注册监听 Darwin Notification
685+
* @param name notification 名称
686+
* @returns 监听 token
687+
*/
688+
notifyRegister(name: string): number;
689+
690+
/**
691+
* 取消监听 Darwin Notification
692+
* @param token token 数字
693+
* @returns 是否取消成功
694+
*/
695+
notifyCancel(token: number): boolean;
696+
676697
}
677698

678699
declare const app: App;

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dompling/trollscript-types",
3-
"version": "1.0.52",
3+
"version": "1.0.50",
44
"description": "TypeScript definitions for TrollScript",
55
"main": "",
66
"types": "index.d.ts",

templates/API/App.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,59 @@ app.launch('com.apple.mobilesafari');
313313

314314
---
315315

316+
### Darwin Notification
317+
318+
Darwin Notification 是 iOS 系统级的通知机制,可用于进程间通信。
319+
320+
#### `app.notifyPost(name)`
321+
发送 Darwin Notification。**参数:** `name` (string) - notification 名称 **返回:** `boolean` - 是否发送成功
322+
323+
```javascript
324+
// 发送通知 唤起 Copylog
325+
const success = app.notifyPost('me.tomt000.copylog.showView');
326+
if (success) {
327+
console.log('通知发送成功');
328+
}
329+
```
330+
331+
#### `app.notifyRegister(name)`
332+
注册监听 Darwin Notification。**参数:** `name` (string) - notification 名称 **返回:** `number` - 监听 token
333+
334+
```javascript
335+
// 注册监听
336+
const token = app.notifyRegister('com.example.mynotification');
337+
console.log('注册成功,token:', token);
338+
```
339+
340+
#### `app.notifyCancel(token)`
341+
取消监听 Darwin Notification。**参数:** `token` (number) - 监听 token **返回:** `boolean` - 是否取消成功
342+
343+
```javascript
344+
// 取消监听
345+
const success = app.notifyCancel(token);
346+
if (success) {
347+
console.log('取消监听成功');
348+
}
349+
```
350+
351+
**完整示例:进程间通信**
352+
353+
```javascript
354+
// 进程 A:注册监听
355+
const token = app.notifyRegister('com.example.data.updated');
356+
console.log('开始监听数据更新通知');
357+
358+
// 进程 B:发送通知
359+
app.notifyPost('com.example.data.updated');
360+
361+
// 进程 A:取消监听
362+
app.notifyCancel(token);
363+
```
364+
365+
> **注意**: Darwin Notification 是系统级通知,适用于跨进程通信。通知名称建议使用反向域名格式(如 `com.example.notification`)以避免冲突。
366+
367+
---
368+
316369
## 完整示例
317370

318371
### 示例 1: 应用信息显示
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app.notifyPost("me.tomt000.copylog.showView");

0 commit comments

Comments
 (0)