Skip to content

Commit df5e962

Browse files
🔄 Sync from private repository - 2026-02-04 14:20:32
1 parent 1b46599 commit df5e962

6 files changed

Lines changed: 417 additions & 2 deletions

File tree

API.en.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,122 @@ Get the data container path for an app (TrollStore privilege)
14911491

14921492
---
14931493

1494+
### `app.cpuUsage`
1495+
1496+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1497+
1498+
**Signature:** `cpuUsage()`
1499+
1500+
Get CPU usage (process-level + system-level)
1501+
1502+
**Returns:** `CPUUsage`
1503+
1504+
*Object containing process (process CPU %) and system (system CPU object with total/user/system/idle/nice/cores)*
1505+
1506+
---
1507+
1508+
### `app.memoryUsage`
1509+
1510+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1511+
1512+
**Signature:** `memoryUsage()`
1513+
1514+
Get memory usage information
1515+
1516+
**Returns:** `MemoryUsage`
1517+
1518+
*Object containing usage (current MB), peak (peak MB), unit (unit string)*
1519+
1520+
---
1521+
1522+
### `app.fps`
1523+
1524+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1525+
1526+
**Signature:** `fps()`
1527+
1528+
Get current frame rate
1529+
1530+
**Returns:** `FPSInfo`
1531+
1532+
*Object containing fps (frame rate), isWarning (warning state), isCritical (critical state)*
1533+
1534+
---
1535+
1536+
### `app.performanceSnapshot`
1537+
1538+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1539+
1540+
**Signature:** `performanceSnapshot()`
1541+
1542+
Get complete performance metrics snapshot
1543+
1544+
**Returns:** `PerformanceSnapshot`
1545+
1546+
*Complete performance snapshot containing cpu, memory, fps, isMonitoring, timestamp*
1547+
1548+
---
1549+
1550+
### `app.startMonitoring`
1551+
1552+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1553+
1554+
**Signature:** `startMonitoring()`
1555+
1556+
Start performance monitoring (FPS sampling, metrics recording)
1557+
1558+
**Returns:** `boolean`
1559+
1560+
*Whether monitoring started successfully*
1561+
1562+
---
1563+
1564+
### `app.stopMonitoring`
1565+
1566+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1567+
1568+
**Signature:** `stopMonitoring()`
1569+
1570+
Stop performance monitoring
1571+
1572+
**Returns:** `boolean`
1573+
1574+
*Whether monitoring stopped successfully*
1575+
1576+
---
1577+
1578+
### `app.performanceRecords`
1579+
1580+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1581+
1582+
**Signature:** `performanceRecords(limit?)`
1583+
1584+
Get historical performance records
1585+
1586+
**Parameters:**
1587+
1588+
| Name | Type | Description | Optional |
1589+
|------|------|-------------|----------|
1590+
| `limit` | `number` | Number of records to return, defaults to 50 | Yes |
1591+
1592+
**Returns:** `[PerformanceRecord]`
1593+
1594+
*Array of performance records containing id, scriptName, executionTime, peakMemory, averageCPU, timestamp, success*
1595+
1596+
---
1597+
1598+
### `app.clearPerformanceRecords`
1599+
1600+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1601+
1602+
**Signature:** `clearPerformanceRecords()`
1603+
1604+
Clear all performance records
1605+
1606+
**Returns:** `void`
1607+
1608+
---
1609+
14941610
## haptic
14951611

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

API.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,122 @@ Ping 主机
14901490

14911491
---
14921492

1493+
### `app.cpuUsage`
1494+
1495+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1496+
1497+
**Signature:** `cpuUsage()`
1498+
1499+
获取 CPU 使用率(进程级 + 系统级)
1500+
1501+
**Returns:** `CPUUsage`
1502+
1503+
*包含 process (进程 CPU %) 和 system (系统 CPU 对象,含 total/user/system/idle/nice/cores) 的对象*
1504+
1505+
---
1506+
1507+
### `app.memoryUsage`
1508+
1509+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1510+
1511+
**Signature:** `memoryUsage()`
1512+
1513+
获取内存使用情况
1514+
1515+
**Returns:** `MemoryUsage`
1516+
1517+
*包含 usage (当前使用 MB), peak (峰值 MB), unit (单位) 的对象*
1518+
1519+
---
1520+
1521+
### `app.fps`
1522+
1523+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1524+
1525+
**Signature:** `fps()`
1526+
1527+
获取当前帧率
1528+
1529+
**Returns:** `FPSInfo`
1530+
1531+
*包含 fps (帧率), isWarning (警告状态), isCritical (危险状态) 的对象*
1532+
1533+
---
1534+
1535+
### `app.performanceSnapshot`
1536+
1537+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1538+
1539+
**Signature:** `performanceSnapshot()`
1540+
1541+
获取完整性能指标快照
1542+
1543+
**Returns:** `PerformanceSnapshot`
1544+
1545+
*包含 cpu, memory, fps, isMonitoring, timestamp 的完整性能快照*
1546+
1547+
---
1548+
1549+
### `app.startMonitoring`
1550+
1551+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1552+
1553+
**Signature:** `startMonitoring()`
1554+
1555+
开启性能监控(FPS 采样、指标记录)
1556+
1557+
**Returns:** `boolean`
1558+
1559+
*是否成功开启*
1560+
1561+
---
1562+
1563+
### `app.stopMonitoring`
1564+
1565+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1566+
1567+
**Signature:** `stopMonitoring()`
1568+
1569+
停止性能监控
1570+
1571+
**Returns:** `boolean`
1572+
1573+
*是否成功停止*
1574+
1575+
---
1576+
1577+
### `app.performanceRecords`
1578+
1579+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1580+
1581+
**Signature:** `performanceRecords(limit?)`
1582+
1583+
获取历史性能记录
1584+
1585+
**Parameters:**
1586+
1587+
| Name | Type | Description | Optional |
1588+
|------|------|-------------|----------|
1589+
| `limit` | `number` | 返回的记录数量,默认 50 | Yes |
1590+
1591+
**Returns:** `[PerformanceRecord]`
1592+
1593+
*性能记录数组,包含 id, scriptName, executionTime, peakMemory, averageCPU, timestamp, success*
1594+
1595+
---
1596+
1597+
### `app.clearPerformanceRecords`
1598+
1599+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
1600+
1601+
**Signature:** `clearPerformanceRecords()`
1602+
1603+
清除所有性能记录
1604+
1605+
**Returns:** `void`
1606+
1607+
---
1608+
14931609
## haptic
14941610

14951611
![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 29672407719922111be9edcdd11764bc9d4eae36
1+
Subproject commit afbfa06de792cbe625301d228f79a50a35ba0c74

npm/index.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,54 @@ interface App {
625625
*/
626626
getDataContainer(bundleId: string): any;
627627

628+
/**
629+
* 获取 CPU 使用率(进程级 + 系统级)
630+
* @returns 包含 process (进程 CPU %) 和 system (系统 CPU 对象,含 total/user/system/idle/nice/cores) 的对象
631+
*/
632+
cpuUsage(): any;
633+
634+
/**
635+
* 获取内存使用情况
636+
* @returns 包含 usage (当前使用 MB), peak (峰值 MB), unit (单位) 的对象
637+
*/
638+
memoryUsage(): any;
639+
640+
/**
641+
* 获取当前帧率
642+
* @returns 包含 fps (帧率), isWarning (警告状态), isCritical (危险状态) 的对象
643+
*/
644+
fps(): any;
645+
646+
/**
647+
* 获取完整性能指标快照
648+
* @returns 包含 cpu, memory, fps, isMonitoring, timestamp 的完整性能快照
649+
*/
650+
performanceSnapshot(): any;
651+
652+
/**
653+
* 开启性能监控(FPS 采样、指标记录)
654+
* @returns 是否成功开启
655+
*/
656+
startMonitoring(): boolean;
657+
658+
/**
659+
* 停止性能监控
660+
* @returns 是否成功停止
661+
*/
662+
stopMonitoring(): boolean;
663+
664+
/**
665+
* 获取历史性能记录
666+
* @param limit 返回的记录数量,默认 50
667+
* @returns 性能记录数组,包含 id, scriptName, executionTime, peakMemory, averageCPU, timestamp, success
668+
*/
669+
performanceRecords(limit?: number): any;
670+
671+
/**
672+
* 清除所有性能记录
673+
*/
674+
clearPerformanceRecords(): void;
675+
628676
}
629677

630678
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.48",
3+
"version": "1.0.49",
44
"description": "TypeScript definitions for TrollScript",
55
"main": "",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)