@celljs/ta-watch 0.0.0-stage → 4.49.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.en.md +15 -0
- package/README.md +14 -2
- package/fixtures/watch-v1.json +137 -0
- package/host/index.mjs +1352 -0
- package/package.json +61 -4
- package/web/index.js +354 -0
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-watch",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "4.49.0",
|
|
4
|
+
"description": "A pi package for Ta: Apple Watch, talk to Ta from the wrist, see what waits for you and answer it; the watch reaches the computer through the relay by itself, sealed end to end",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/cellbang/ta",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/cellbang/ta/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/cellbang/cell.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"files": [
|
|
18
|
+
"web",
|
|
19
|
+
"host",
|
|
20
|
+
"fixtures",
|
|
21
|
+
"!**/*.map"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js && bun build web-src/host.ts --format esm --target node --outfile host/index.mjs",
|
|
25
|
+
"clean": "rm -rf lib web host *.tsbuildinfo",
|
|
26
|
+
"fixtures": "tsc -b && TA_WATCH_FIXTURES=write bun test ./lib/watch-fixtures.spec.js",
|
|
27
|
+
"test": "bun test ./lib",
|
|
28
|
+
"watch": "tsc -b -w --preserveWatchOutput"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@celljs/ta-protocol": "4.49.0",
|
|
32
|
+
"@celljs/ta-web": "4.49.0",
|
|
33
|
+
"@types/react": "^19.3.3"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"pi": {
|
|
39
|
+
"title": {
|
|
40
|
+
"en": "Apple Watch",
|
|
41
|
+
"zh-CN": "Apple Watch",
|
|
42
|
+
"zh-TW": "Apple Watch",
|
|
43
|
+
"ja-JP": "Apple Watch"
|
|
44
|
+
},
|
|
45
|
+
"summary": {
|
|
46
|
+
"en": "Talk to Ta from your wrist: it works on your computer and answers on the watch, aloud. See what waits for you and answer it with a tap; a complication on the watch face counts it. Works over Wi-Fi or cellular without the iPhone.",
|
|
47
|
+
"zh-CN": "在手腕上和 Ta 说话:活在你的电脑上干,回复显示在手表上并读出来。待你决定的事点一下就能回答,表盘上的小组件告诉你有几件。手表连着 Wi-Fi 或蜂窝网络就能用,不需要 iPhone 在身边。",
|
|
48
|
+
"zh-TW": "在手腕上和 Ta 說話:活在你的電腦上做,回覆顯示在手錶上並唸出來。待你決定的事點一下就能回答,錶面上的小工具告訴你有幾件。手錶連著 Wi-Fi 或行動網路就能用,不需要 iPhone 在身邊。",
|
|
49
|
+
"ja-JP": "手首から Ta に話しかけます。作業はあなたのコンピューターで行い、返事はウォッチに表示して読み上げます。あなたの判断を待っていることはタップで答えられ、文字盤のコンプリケーションが件数を示します。Wi-Fi かモバイル通信があれば iPhone なしで使えます。"
|
|
50
|
+
},
|
|
51
|
+
"icon": "Smartphone",
|
|
52
|
+
"group": "devices",
|
|
53
|
+
"web": [
|
|
54
|
+
"./web/index.js"
|
|
55
|
+
],
|
|
56
|
+
"host": "./host/index.mjs",
|
|
57
|
+
"permissions": {
|
|
58
|
+
"host": {
|
|
59
|
+
"*": "settings.manage"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/web/index.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// web-src/phone-watch.ts
|
|
2
|
+
var PhoneWatch;
|
|
3
|
+
((PhoneWatch) => {
|
|
4
|
+
PhoneWatch.EVENT = "ta-watch";
|
|
5
|
+
function bridge(scope = globalThis) {
|
|
6
|
+
return scope.webkit?.messageHandlers?.taWatch;
|
|
7
|
+
}
|
|
8
|
+
PhoneWatch.bridge = bridge;
|
|
9
|
+
function parse(detail) {
|
|
10
|
+
const value = detail;
|
|
11
|
+
if (!value || typeof value.paired !== "boolean" || typeof value.installed !== "boolean") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
paired: value.paired,
|
|
16
|
+
installed: value.installed,
|
|
17
|
+
...typeof value.device === "string" ? { device: value.device } : {},
|
|
18
|
+
...typeof value.expiresAt === "number" ? { expiresAt: value.expiresAt } : {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
PhoneWatch.parse = parse;
|
|
22
|
+
let last;
|
|
23
|
+
const listeners = new Set;
|
|
24
|
+
function watch(listener) {
|
|
25
|
+
listeners.add(listener);
|
|
26
|
+
if (last) {
|
|
27
|
+
listener(last);
|
|
28
|
+
}
|
|
29
|
+
bridge()?.postMessage({ action: "state" });
|
|
30
|
+
return () => listeners.delete(listener);
|
|
31
|
+
}
|
|
32
|
+
PhoneWatch.watch = watch;
|
|
33
|
+
async function pair(pi, name) {
|
|
34
|
+
const native = bridge();
|
|
35
|
+
if (!native) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const pairing = await pi.callHost("pair", name);
|
|
39
|
+
native.postMessage({ action: "pair", pairing });
|
|
40
|
+
}
|
|
41
|
+
PhoneWatch.pair = pair;
|
|
42
|
+
async function renew(pi, state) {
|
|
43
|
+
const native = bridge();
|
|
44
|
+
if (!native || !state?.device) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const renewed = await pi.callHost("renew", state.device).catch(() => {
|
|
48
|
+
return;
|
|
49
|
+
});
|
|
50
|
+
if (renewed) {
|
|
51
|
+
native.postMessage({ action: "renew", device: renewed.id, expiresAt: renewed.expiresAt });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
PhoneWatch.renew = renew;
|
|
55
|
+
function start(pi) {
|
|
56
|
+
if (!bridge() || typeof window === "undefined") {
|
|
57
|
+
return () => {
|
|
58
|
+
return;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
let renewed = false;
|
|
62
|
+
const onState = (event) => {
|
|
63
|
+
const state = parse(event.detail);
|
|
64
|
+
if (!state) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
last = state;
|
|
68
|
+
if (!renewed && state.device) {
|
|
69
|
+
renewed = true;
|
|
70
|
+
renew(pi, state);
|
|
71
|
+
}
|
|
72
|
+
for (const listener of listeners) {
|
|
73
|
+
listener(state);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
window.addEventListener(PhoneWatch.EVENT, onState);
|
|
77
|
+
bridge()?.postMessage({ action: "state" });
|
|
78
|
+
return () => window.removeEventListener(PhoneWatch.EVENT, onState);
|
|
79
|
+
}
|
|
80
|
+
PhoneWatch.start = start;
|
|
81
|
+
})(PhoneWatch ||= {});
|
|
82
|
+
|
|
83
|
+
// web-src/react.ts
|
|
84
|
+
var React;
|
|
85
|
+
function bind(react) {
|
|
86
|
+
React = react;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ../ta-protocol/esm/common/language.js
|
|
90
|
+
var TaLanguageUtil;
|
|
91
|
+
(function(TaLanguageUtil2) {
|
|
92
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
93
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
94
|
+
function of(tag) {
|
|
95
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
96
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
97
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
98
|
+
}
|
|
99
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
100
|
+
}
|
|
101
|
+
TaLanguageUtil2.of = of;
|
|
102
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
103
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
104
|
+
}
|
|
105
|
+
TaLanguageUtil2.server = server;
|
|
106
|
+
function pick(language, words) {
|
|
107
|
+
return words[of(language)];
|
|
108
|
+
}
|
|
109
|
+
TaLanguageUtil2.pick = pick;
|
|
110
|
+
function say(words) {
|
|
111
|
+
return words[server()];
|
|
112
|
+
}
|
|
113
|
+
TaLanguageUtil2.say = say;
|
|
114
|
+
function chinese(language) {
|
|
115
|
+
return of(language).startsWith("zh");
|
|
116
|
+
}
|
|
117
|
+
TaLanguageUtil2.chinese = chinese;
|
|
118
|
+
function cjk(language) {
|
|
119
|
+
return of(language) !== "en-US";
|
|
120
|
+
}
|
|
121
|
+
TaLanguageUtil2.cjk = cjk;
|
|
122
|
+
function list(language, items) {
|
|
123
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
124
|
+
}
|
|
125
|
+
TaLanguageUtil2.list = list;
|
|
126
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
127
|
+
|
|
128
|
+
// web-src/i18n.ts
|
|
129
|
+
var EN = {
|
|
130
|
+
settingsTitle: "Apple Watch",
|
|
131
|
+
watchLabel: "This iPhone’s watch",
|
|
132
|
+
watchHint: "Talk to Ta from your wrist, see what waits for you and answer it. The watch reaches this computer by itself over Wi-Fi or cellular; opening Ta on this iPhone once a month keeps it signed in.",
|
|
133
|
+
connect: "Connect the watch",
|
|
134
|
+
connecting: "Connecting…",
|
|
135
|
+
connected: "Connected · until {date}",
|
|
136
|
+
noWatch: "No Apple Watch is paired with this iPhone.",
|
|
137
|
+
noApp: "Install Ta on the watch from the Watch app of this iPhone first.",
|
|
138
|
+
watchesLabel: "Watches connected",
|
|
139
|
+
watchesHint: "Each reaches only this computer, with a key of its own. Removing one signs it out at once.",
|
|
140
|
+
watchesNone: "None yet: connect one from Ta on your iPhone.",
|
|
141
|
+
lastUsed: "Used {date}",
|
|
142
|
+
neverUsed: "Not used yet",
|
|
143
|
+
expires: "until {date}",
|
|
144
|
+
expired: "expired",
|
|
145
|
+
remove: "Remove"
|
|
146
|
+
};
|
|
147
|
+
var WORDS = {
|
|
148
|
+
"en-US": EN,
|
|
149
|
+
"zh-CN": {
|
|
150
|
+
settingsTitle: "Apple Watch",
|
|
151
|
+
watchLabel: "这台 iPhone 的手表",
|
|
152
|
+
watchHint: "在手腕上和 Ta 说话,看看哪些事在等你决定、直接回答。手表连着 Wi-Fi 或蜂窝网络就能自己连到这台电脑;每个月在这台 iPhone 上打开一次 Ta,手表就一直保持登录。",
|
|
153
|
+
connect: "连接手表",
|
|
154
|
+
connecting: "正在连接…",
|
|
155
|
+
connected: "已连接 · 有效到 {date}",
|
|
156
|
+
noWatch: "这台 iPhone 没有配对 Apple Watch。",
|
|
157
|
+
noApp: "先在 iPhone 的「Watch」App 里把 Ta 装到手表上。",
|
|
158
|
+
watchesLabel: "已连接的手表",
|
|
159
|
+
watchesHint: "每块手表只能连这台电脑,各用自己的密钥。移除后它立刻退出登录。",
|
|
160
|
+
watchesNone: "还没有:在 iPhone 上的 Ta 里连接。",
|
|
161
|
+
lastUsed: "{date} 用过",
|
|
162
|
+
neverUsed: "还没用过",
|
|
163
|
+
expires: "有效到 {date}",
|
|
164
|
+
expired: "已过期",
|
|
165
|
+
remove: "移除"
|
|
166
|
+
},
|
|
167
|
+
"zh-TW": {
|
|
168
|
+
settingsTitle: "Apple Watch",
|
|
169
|
+
watchLabel: "這台 iPhone 的手錶",
|
|
170
|
+
watchHint: "在手腕上和 Ta 說話,看看哪些事在等你決定、直接回答。手錶連著 Wi-Fi 或行動網路就能自己連到這台電腦;每個月在這台 iPhone 上打開一次 Ta,手錶就一直保持登入。",
|
|
171
|
+
connect: "連接手錶",
|
|
172
|
+
connecting: "正在連接…",
|
|
173
|
+
connected: "已連接 · 有效到 {date}",
|
|
174
|
+
noWatch: "這台 iPhone 沒有配對 Apple Watch。",
|
|
175
|
+
noApp: "先在 iPhone 的「Watch」App 裡把 Ta 裝到手錶上。",
|
|
176
|
+
watchesLabel: "已連接的手錶",
|
|
177
|
+
watchesHint: "每支手錶只能連這台電腦,各用自己的金鑰。移除後它立刻登出。",
|
|
178
|
+
watchesNone: "還沒有:在 iPhone 上的 Ta 裡連接。",
|
|
179
|
+
lastUsed: "{date} 用過",
|
|
180
|
+
neverUsed: "還沒用過",
|
|
181
|
+
expires: "有效到 {date}",
|
|
182
|
+
expired: "已過期",
|
|
183
|
+
remove: "移除"
|
|
184
|
+
},
|
|
185
|
+
"ja-JP": {
|
|
186
|
+
settingsTitle: "Apple Watch",
|
|
187
|
+
watchLabel: "この iPhone のウォッチ",
|
|
188
|
+
watchHint: "手首から Ta に話しかけ、あなたの判断を待っていることを見てその場で答えられます。ウォッチは Wi-Fi かモバイル通信でこのコンピューターに直接つながります。月に一度この iPhone で Ta を開けば、サインインが続きます。",
|
|
189
|
+
connect: "ウォッチを接続",
|
|
190
|
+
connecting: "接続中…",
|
|
191
|
+
connected: "接続済み · {date} まで",
|
|
192
|
+
noWatch: "この iPhone には Apple Watch がペアリングされていません。",
|
|
193
|
+
noApp: "先に iPhone の「Watch」App で Ta をウォッチに入れてください。",
|
|
194
|
+
watchesLabel: "接続済みのウォッチ",
|
|
195
|
+
watchesHint: "どのウォッチもこのコンピューターにだけ、それぞれの鍵でつながります。削除するとすぐにサインアウトします。",
|
|
196
|
+
watchesNone: "まだありません。iPhone の Ta から接続してください。",
|
|
197
|
+
lastUsed: "{date} に使用",
|
|
198
|
+
neverUsed: "まだ使っていません",
|
|
199
|
+
expires: "{date} まで",
|
|
200
|
+
expired: "期限切れ",
|
|
201
|
+
remove: "削除"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var WatchWords;
|
|
205
|
+
((WatchWords) => {
|
|
206
|
+
function of(language) {
|
|
207
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
208
|
+
}
|
|
209
|
+
WatchWords.of = of;
|
|
210
|
+
function format(text, values) {
|
|
211
|
+
return text.replace(/\{(\w+)\}/g, (whole, key) => (key in values) ? String(values[key]) : whole);
|
|
212
|
+
}
|
|
213
|
+
WatchWords.format = format;
|
|
214
|
+
})(WatchWords ||= {});
|
|
215
|
+
|
|
216
|
+
// web-src/settings.tsx
|
|
217
|
+
var date = (at, language) => new Date(at).toLocaleDateString(language, { month: "short", day: "numeric" });
|
|
218
|
+
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
219
|
+
function PhoneSetting({ pi }) {
|
|
220
|
+
const words = WatchWords.of(pi.ui.language);
|
|
221
|
+
const [state, setState] = React.useState();
|
|
222
|
+
const [busy, run] = pi.ui.useBusy();
|
|
223
|
+
React.useEffect(() => PhoneWatch.watch(setState), []);
|
|
224
|
+
if (!state) {
|
|
225
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
226
|
+
className: "ta-watch-state"
|
|
227
|
+
}, "…");
|
|
228
|
+
}
|
|
229
|
+
if (!state.paired) {
|
|
230
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
231
|
+
className: "ta-watch-state"
|
|
232
|
+
}, words.noWatch);
|
|
233
|
+
}
|
|
234
|
+
if (!state.installed) {
|
|
235
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
236
|
+
className: "ta-watch-state"
|
|
237
|
+
}, words.noApp);
|
|
238
|
+
}
|
|
239
|
+
const connect = () => void run(() => PhoneWatch.pair(pi, "Apple Watch").catch((error) => pi.ui.notify(message(error), "error")));
|
|
240
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
241
|
+
className: "ta-watch-phone"
|
|
242
|
+
}, state.device && state.expiresAt && state.expiresAt > Date.now() && /* @__PURE__ */ React.createElement("span", {
|
|
243
|
+
className: "ta-watch-state"
|
|
244
|
+
}, WatchWords.format(words.connected, { date: date(state.expiresAt, pi.ui.language) })), /* @__PURE__ */ React.createElement("button", {
|
|
245
|
+
type: "button",
|
|
246
|
+
className: `ta-button${busy ? " ta-busy" : ""}`,
|
|
247
|
+
"aria-busy": busy || undefined,
|
|
248
|
+
disabled: busy,
|
|
249
|
+
onClick: connect
|
|
250
|
+
}, busy && /* @__PURE__ */ React.createElement("span", {
|
|
251
|
+
className: "ta-spinner ta-busy-mark"
|
|
252
|
+
}), /* @__PURE__ */ React.createElement("span", null, busy ? words.connecting : words.connect)));
|
|
253
|
+
}
|
|
254
|
+
function RemoveButton({ pi, device, label }) {
|
|
255
|
+
const [busy, run] = pi.ui.useBusy();
|
|
256
|
+
const remove = () => void run(() => pi.callHost("remove", device.id).catch((error) => pi.ui.notify(message(error), "error")));
|
|
257
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
258
|
+
type: "button",
|
|
259
|
+
className: `ta-button${busy ? " ta-busy" : ""}`,
|
|
260
|
+
"aria-busy": busy || undefined,
|
|
261
|
+
disabled: busy,
|
|
262
|
+
onClick: remove
|
|
263
|
+
}, busy && /* @__PURE__ */ React.createElement("span", {
|
|
264
|
+
className: "ta-spinner ta-busy-mark"
|
|
265
|
+
}), /* @__PURE__ */ React.createElement("span", null, label));
|
|
266
|
+
}
|
|
267
|
+
function DevicesSetting({ pi }) {
|
|
268
|
+
const words = WatchWords.of(pi.ui.language);
|
|
269
|
+
const devices = pi.ui.useHost("devices", [], { topics: ["devices"] });
|
|
270
|
+
const list = devices.value ?? [];
|
|
271
|
+
if (list.length === 0) {
|
|
272
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
273
|
+
className: "ta-watch-state"
|
|
274
|
+
}, devices.loading ? "…" : words.watchesNone);
|
|
275
|
+
}
|
|
276
|
+
const now = Date.now();
|
|
277
|
+
return /* @__PURE__ */ React.createElement("ul", {
|
|
278
|
+
className: "ta-watch-devices"
|
|
279
|
+
}, list.map((device) => /* @__PURE__ */ React.createElement("li", {
|
|
280
|
+
key: device.id
|
|
281
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
282
|
+
className: "ta-watch-name"
|
|
283
|
+
}, device.name), /* @__PURE__ */ React.createElement("span", {
|
|
284
|
+
className: "ta-watch-state"
|
|
285
|
+
}, device.usedAt ? WatchWords.format(words.lastUsed, { date: date(device.usedAt, pi.ui.language) }) : words.neverUsed, " · ", device.expiresAt > now ? WatchWords.format(words.expires, { date: date(device.expiresAt, pi.ui.language) }) : words.expired), /* @__PURE__ */ React.createElement(RemoveButton, {
|
|
286
|
+
pi,
|
|
287
|
+
device,
|
|
288
|
+
label: words.remove
|
|
289
|
+
}))));
|
|
290
|
+
}
|
|
291
|
+
function watchSettings(pi) {
|
|
292
|
+
const words = () => WatchWords.of(pi.ui.language);
|
|
293
|
+
return {
|
|
294
|
+
title: () => words().settingsTitle,
|
|
295
|
+
icon: pi.ui.icons.Smartphone,
|
|
296
|
+
group: "devices",
|
|
297
|
+
order: 20,
|
|
298
|
+
rows: [
|
|
299
|
+
...PhoneWatch.bridge() ? [
|
|
300
|
+
{
|
|
301
|
+
key: "phone",
|
|
302
|
+
label: () => words().watchLabel,
|
|
303
|
+
description: () => words().watchHint,
|
|
304
|
+
stacked: true,
|
|
305
|
+
render: () => /* @__PURE__ */ React.createElement(PhoneSetting, {
|
|
306
|
+
pi
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
] : [],
|
|
310
|
+
{
|
|
311
|
+
key: "devices",
|
|
312
|
+
label: () => words().watchesLabel,
|
|
313
|
+
description: () => words().watchesHint,
|
|
314
|
+
stacked: true,
|
|
315
|
+
render: () => /* @__PURE__ */ React.createElement(DevicesSetting, {
|
|
316
|
+
pi
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// web-src/style.ts
|
|
324
|
+
var STYLE = `
|
|
325
|
+
.ta-watch-phone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
326
|
+
.ta-watch-state { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
327
|
+
.ta-watch-devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
328
|
+
.ta-watch-devices > li { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
329
|
+
.ta-watch-name { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-secondary); }
|
|
330
|
+
.ta-watch-devices .ta-watch-state { flex: 1 1 auto; min-width: 0; }
|
|
331
|
+
.ta-watch-devices .ta-button { flex: none; }
|
|
332
|
+
`;
|
|
333
|
+
function injectStyle() {
|
|
334
|
+
const element = document.createElement("style");
|
|
335
|
+
element.dataset.taPackage = "ta-watch";
|
|
336
|
+
element.textContent = STYLE;
|
|
337
|
+
document.head.appendChild(element);
|
|
338
|
+
return () => element.remove();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// web-src/index.tsx
|
|
342
|
+
function activate(pi) {
|
|
343
|
+
bind(pi.React);
|
|
344
|
+
const removeStyle = injectStyle();
|
|
345
|
+
pi.registerSettings(watchSettings(pi));
|
|
346
|
+
const stop = PhoneWatch.start(pi);
|
|
347
|
+
return () => {
|
|
348
|
+
stop();
|
|
349
|
+
removeStyle();
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
export {
|
|
353
|
+
activate as default
|
|
354
|
+
};
|