rvis-aiui-kit 1.2.1 → 1.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # rvis-aiui-kit
2
2
 
3
- 面向 Rokid AIUI / JSUI 应用的组件库与 Glass3 扩展 SDK。包内包含 7 个 Ink UI 组件、9 组 Host RPC 能力,以及一个 Rokid OpenAPI HTTPS/SSE 客户端。
3
+ 面向 Rokid AIUI / JSUI 应用的组件库与 Glass3 扩展 SDK。包内包含 6 个 Ink UI 组件、10 组 Host RPC 能力,以及一个 Rokid OpenAPI HTTPS/SSE 客户端。
4
4
 
5
5
  ## 文档导航
6
6
 
@@ -9,6 +9,7 @@
9
9
  - [Glass3 SDK API](#glass3-sdk-api)
10
10
  - [API 总览](#api-总览)
11
11
  - [Device Context](#device-context)
12
+ - [Status Bar](#status-bar)
12
13
  - [Screen](#screen)
13
14
  - [Notification](#notification)
14
15
  - [TTS](#tts)
@@ -26,7 +27,6 @@
26
27
  - [Markdown](#markdown)
27
28
  - [Model List](#model-list)
28
29
  - [Paragraph](#paragraph)
29
- - [Status Bar](#status-bar)
30
30
  - [Table](#table)
31
31
 
32
32
  ## 安装与运行环境
@@ -64,7 +64,6 @@ npm install rvis-aiui-kit
64
64
  }
65
65
  },
66
66
  "usingComponents": {
67
- "rvis-status-bar": "rvis-aiui-kit/status-bar",
68
67
  "rvis-paragraph": "rvis-aiui-kit/paragraph",
69
68
  "rvis-table": "rvis-aiui-kit/table"
70
69
  }
@@ -83,6 +82,11 @@ export default {
83
82
  resultText: '准备就绪'
84
83
  },
85
84
 
85
+ async onLoad() {
86
+ await glass3.statusBar.setTitle({ title: '巡检' });
87
+ await glass3.statusBar.setVisible({ visible: true });
88
+ },
89
+
86
90
  onMessage(messageEvent) {
87
91
  // Host RPC 的 Promise 和流式 onEvent 都依赖这一步。
88
92
  glass3.handleMessage(messageEvent);
@@ -108,7 +112,6 @@ export default {
108
112
 
109
113
  <page>
110
114
  <view class="page">
111
- <rvis-status-bar title="巡检"></rvis-status-bar>
112
115
  <view class="content">
113
116
  <rvis-paragraph text="{{ resultText }}" width="424px"></rvis-paragraph>
114
117
  </view>
@@ -127,7 +130,7 @@ export default {
127
130
 
128
131
  .content {
129
132
  position: absolute;
130
- top: 40px;
133
+ top: 150px;
131
134
  left: 28px;
132
135
  width: 424px;
133
136
  }
@@ -169,6 +172,7 @@ import glass3, {
169
172
  | `deviceContext` | `get(options?)` | 获取设备上下文原子快照 |
170
173
  | `deviceContext` | `observe(options?, callOptions?)` | 订阅设备上下文快照和变化 |
171
174
  | `deviceContext` | `stopObserve({ requestId })` | 停止设备上下文订阅 |
175
+ | `statusBar` | `setTitle({ title })` / `setVisible({ visible })` | 设置标题并显示 / 隐藏 Native 状态栏 |
172
176
  | `screen` | `turnOff()` / `turnOn()` | 息屏 / 亮屏 |
173
177
  | `notification` | `show(options)` / `hide({ requestId })` | 显示 / 隐藏原生通知 |
174
178
  | `tts` | `speak(options, callOptions?)` / `stop({ requestId })` | TTS 播报 / 停止 |
@@ -217,6 +221,18 @@ await glass3.deviceContext.stopObserve({ requestId: observer.requestId });
217
221
 
218
222
  `get()` 等待 `snapshot` 事件后完成,返回 `{ requestId, ok, eventType: 'snapshot', snapshot }`。`observe()` 在订阅启动后返回 `{ requestId, ok, state: 'started' }`;首个业务事件为 `snapshot`,后续为 `changed` 或 `invalidated`。SDK 不自动合并 patch。
219
223
 
224
+ ### Status Bar
225
+
226
+ ```js
227
+ await glass3.statusBar.setTitle({ title: '设备巡检' });
228
+ const result = await glass3.statusBar.setVisible({ visible: true });
229
+ // { updated: true, visible: true }
230
+ ```
231
+
232
+ `title` 必须是字符串,空字符串或全空白字符串用于清理标题;`visible` 必须是 Boolean。建议先设置标题,再显示状态栏。该能力直接解析 Host RPC HTTP response body,不依赖 `onMessage`。
233
+
234
+ Native 状态栏可能占用屏幕 y=0 到 y=149。全屏页面根节点仍从 y=0 开始,只将页面内容放到 y=150 或更低位置。
235
+
220
236
  ### Screen
221
237
 
222
238
  ```js
@@ -658,20 +674,6 @@ data: {
658
674
  <rvis-paragraph text="{{ text }}" width="424px" segments="{{ segments }}"></rvis-paragraph>
659
675
  ```
660
676
 
661
- ### Status Bar
662
-
663
- 注册路径:`rvis-aiui-kit/status-bar`
664
-
665
- | 属性 | 类型 | 默认值 | 说明 |
666
- | --- | --- | --- | --- |
667
- | `title` | `String` | `''` | 左侧应用标题 |
668
-
669
- ```html
670
- <rvis-status-bar title="应用名称"></rvis-status-bar>
671
- ```
672
-
673
- 组件尺寸固定为 `480px × 20px`,显示应用标题、本地日期时间和实时电量。页面应将其放在全屏绘制区域的 `(0, 0)`。组件自动管理时钟和 `power` 订阅,但 Page 必须把 `onMessage` 转发给共享的 `glass3` 实例。
674
-
675
677
  ### Table
676
678
 
677
679
  注册路径:`rvis-aiui-kit/table`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvis-aiui-kit",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "RVIS AIUI components and Glass3 extension SDK.",
5
5
  "type": "module",
6
6
  "main": "./sdk/index.js",
@@ -18,7 +18,6 @@
18
18
  "./markdown": "./components/markdown/index",
19
19
  "./model-list": "./components/model-list/index",
20
20
  "./paragraph": "./components/paragraph/index",
21
- "./status-bar": "./components/status-bar/index",
22
21
  "./table": "./components/table/index"
23
22
  }
24
23
  },
package/sdk/README.md CHANGED
@@ -226,6 +226,9 @@ const result = await glass3.deviceContext.stopObserve({
226
226
  状态栏是 Host 管理的系统 UI,可在屏幕顶部显示标题、时间、网络和电量。该能力只在
227
227
  通过 `OPEN_AIX_INK` 外部入口打开的 AIX 页面中注册,页面创建后默认隐藏。
228
228
 
229
+ Native 状态栏可能占用屏幕 y=0 到 y=149。页面根节点仍从 y=0 开始,
230
+ 只将页面内容放到 y=150 或更低位置。
231
+
229
232
  建议先设置标题,再显示:
230
233
 
231
234
  ```js
@@ -7,6 +7,9 @@
7
7
  该能力只在通过外部 `OPEN_AIX_INK` 入口打开的 AIX 页面中注册。页面建立后默认隐藏
8
8
  状态栏,普通浏览器、普通 WebView 和普通 AI 卡片中调用会失败。
9
9
 
10
+ Native 状态栏可能占用屏幕 y=0 到 y=149。保持全屏页面根节点从 y=0
11
+ 开始,只把页面内容放到 y=150 或更低位置。
12
+
10
13
  ## API
11
14
 
12
15
  ### `glass3.statusBar.setTitle({ title })`
@@ -1,139 +0,0 @@
1
- <script def>
2
- {
3
- "component": true
4
- }
5
- </script>
6
-
7
- <script setup>
8
- import glass3 from 'rvis-aiui-kit';
9
-
10
- function logError(error) {
11
- if (error && error.code === 'CALL_DISPOSED') return;
12
- console.error('[Status Bar]', error);
13
- }
14
-
15
- export default {
16
- properties: {
17
- title: {
18
- type: String,
19
- value: ''
20
- }
21
- },
22
-
23
- data: {
24
- dateText: '',
25
- timeText: '',
26
- batteryText: '--%',
27
- active: false,
28
- clockTimer: null,
29
- powerObserveRequestId: ''
30
- },
31
-
32
- methods: {
33
- updateTime() {
34
- const now = new Date();
35
- const hours = now.getHours();
36
- const minutes = now.getMinutes();
37
- this.setData({
38
- dateText: `${now.getMonth() + 1}/${now.getDate()}`,
39
- timeText: `${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes}`
40
- });
41
- },
42
-
43
- updateBattery(event) {
44
- if (!this.data.active) return;
45
- if (event.eventType === 'invalidated') {
46
- this.data.powerObserveRequestId = '';
47
- this.setData({ batteryText: '--%' });
48
- return;
49
- }
50
-
51
- const power = event.eventType === 'snapshot'
52
- ? event.snapshot && event.snapshot.power
53
- : event.patch && event.patch.power;
54
- if (!power) return;
55
-
56
- this.setData({
57
- batteryText: power.levelPercent === undefined
58
- ? '--%'
59
- : `${power.levelPercent}%`
60
- });
61
- },
62
-
63
- observePower() {
64
- glass3.deviceContext.observe(
65
- { domains: ['power'] },
66
- { onEvent: event => this.updateBattery(event) }
67
- ).then(result => {
68
- if (this.data.active) {
69
- this.data.powerObserveRequestId = result.requestId;
70
- return;
71
- }
72
-
73
- glass3.deviceContext.stopObserve({
74
- requestId: result.requestId
75
- }).catch(logError);
76
- }).catch(logError);
77
- }
78
- },
79
-
80
- lifetimes: {
81
- attached() {
82
- this.data.active = true;
83
- this.updateTime();
84
- this.data.clockTimer = setInterval(() => this.updateTime(), 1000);
85
- this.observePower();
86
- },
87
-
88
- detached() {
89
- this.data.active = false;
90
-
91
- if (this.data.clockTimer !== null) {
92
- clearInterval(this.data.clockTimer);
93
- this.data.clockTimer = null;
94
- }
95
- if (this.data.powerObserveRequestId) {
96
- glass3.deviceContext.stopObserve({
97
- requestId: this.data.powerObserveRequestId
98
- }).catch(logError);
99
- this.data.powerObserveRequestId = '';
100
- }
101
- }
102
- }
103
- };
104
- </script>
105
-
106
- <page>
107
- <view class="status-bar">
108
- <text class="status-text">{{ title }}</text>
109
- <view class="status-right">
110
- <text class="status-text">{{ dateText }}</text>
111
- <text class="status-text">{{ timeText }}</text>
112
- <text class="status-text">{{ batteryText }}</text>
113
- </view>
114
- </view>
115
- </page>
116
-
117
- <style>
118
- .status-bar {
119
- display: flex;
120
- flex-direction: row;
121
- align-items: center;
122
- justify-content: space-between;
123
- width: 480px;
124
- height: 20px;
125
- }
126
-
127
- .status-right {
128
- display: flex;
129
- flex-direction: row;
130
- align-items: center;
131
- gap: 10px;
132
- }
133
-
134
- .status-text {
135
- color: #40ff5e;
136
- font-size: 14px;
137
- line-height: 20px;
138
- }
139
- </style>
@@ -1,45 +0,0 @@
1
- # Status Bar 组件
2
-
3
- 标准 Glass3 HUD 状态栏,左侧显示应用标题,右侧显示本地月/日、时间和实时电量。
4
-
5
- 组件会在 `attached` 时启动时钟和 `power` 订阅,在 `detached` 时清理计时器并停止订阅。
6
-
7
- ## 注册与使用
8
-
9
- ```json
10
- {
11
- "usingComponents": {
12
- "rvis-status-bar": "rvis-aiui-kit/status-bar"
13
- }
14
- }
15
- ```
16
-
17
- ```html
18
- <rvis-status-bar title="应用名称"></rvis-status-bar>
19
- ```
20
-
21
- 属性:
22
-
23
- - `title: String`,默认 `''`,显示在状态栏左侧。
24
-
25
- 组件固定为 `480px × 20px`,使用 `14px / 20px` 的绿色文本;页面负责将它放在全屏绘制区域的 `(0, 0)`。
26
-
27
- ## Host 消息转发
28
-
29
- Ink 当前只把 Host 消息交给 Page,不会直接调用自定义组件的 `onMessage`。使用该组件的页面必须把消息转发到与组件共享的 `glass3` 单例:
30
-
31
- ```js
32
- import glass3 from 'rvis-aiui-kit';
33
-
34
- export default {
35
- onMessage(messageEvent) {
36
- glass3.handleMessage(messageEvent);
37
- },
38
-
39
- onUnload() {
40
- glass3.dispose();
41
- }
42
- };
43
- ```
44
-
45
- 除这条 Page 级消息入口外,时间刷新、电量显示、订阅和清理逻辑均由组件管理。电量不可读时显示 `--%`。