@celljs/ta-launcher 0.0.0-stage → 4.9.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ # Cell - Ta Launcher
2
+
3
+ A pi package that comes with Ta (on by default; Settings → Extensions turns it off): Quick open, as WeChat pulls down the mini programs used lately and kept over its chats; design record in docs/design/ta-launcher.md. It has only a web extension (`pi.web`) and uses only the public `WebExtensionAPI`.
4
+
5
+ - **Where**: on a phone, pull down from the top of the list of the first tab; on a computer or a tablet, the grid at the bottom of the rail. The board has a Quick open card too.
6
+ - **Recent**: the pages opened last first (`ui.usePages()`): extensions started on open, temporary ones opened without installing, and pages under Discover; those installed or made by an agent and never opened yet come after. What the navigation or the sidebar already shows is left out. A green dot marks an extension running in the background.
7
+ - **Mine**: the pages the user keeps, in the package's data (`mine` of `pi.storage`), the same on every device; a temporary extension kept there is never cleared for want of use (`updateTemporaryPackage(id, { kept: true })`).
8
+ - **Hold or right-click an icon**: keep in or take out of Mine, Close (stop it in the background), Install (a temporary one: its pi extensions and skills load too), Share (a link and its QR code: the source of a published one, else end to end through the relay, see docs/design/ta-launcher.md 2.4), Remove from Recent, Delete (a temporary one, asked first).
9
+ - **Search**: the field at the top lists pages, and the extensions installed, built in and of the market (docs/design/ta-launcher.md 2.5).
10
+ - **Open a link**: the link button at the top right takes a link of an extension or `npm:<name>`; the Ta app scans one too, and an address of Ta Web with `#open=<source>` does the same. Ta asks first: an extension runs in the page, and reads and writes files of this computer and runs commands.
11
+
12
+ ## Limits
13
+
14
+ - The link of an extension of this computer works while its Ta service runs, for 7 days, up to 8 MB.
15
+ - A temporary extension runs only its web part; install it to use its pi extensions and skills.
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # Cell - Ta Launcher
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):快捷打开。参照微信首页下拉出的"最近使用"和"我的小程序",设计记录见 docs/design/ta-launcher.md。只有 Web 扩展(`pi.web`),只用公开的 `WebExtensionAPI`。
4
+
5
+ - **在哪里**:手机上在第一个标签的列表顶部往下拉;电脑和平板上点导轨底部的九宫格。小组件面板里也有一张"快捷打开"卡片。
6
+ - **最近使用**:按最近一次打开排列的页面(`ui.usePages()`):打开时才启动的扩展、免安装打开的临时扩展,以及收在"发现"里的页面;刚装好或 Agent 刚做好、还没打开过的排在后面。导航栏和侧栏里已经有的不重复列出。在后台运行的扩展图标上有绿点。
7
+ - **我的**:用户收进来的页面,存在包数据里(`pi.storage` 的 `mine`),所有设备一致;收进"我的"的临时扩展不会因为长时间不用被清除(`updateTemporaryPackage(id, { kept: true })`)。
8
+ - **长按或右键图标**:收进/移出"我的"、关闭(结束后台运行)、安装(临时扩展:它的 pi 扩展、技能也加载)、分享(链接和二维码:已发布的给来源,本机的经中继端到端发送,见 docs/design/ta-launcher.md 2.4)、从最近使用中删除、删除(临时扩展,先确认)。
9
+ - **搜索**:顶部搜索框列出页面、已安装、内置和市场的扩展(见 docs/design/ta-launcher.md 2.5)。
10
+ - **打开链接**:右上角的链接按钮粘贴扩展链接或 `npm:包名`,Ta 手机应用里还能扫码;打开带 `#open=<来源>` 的 Ta Web 地址也一样。打开前先确认:扩展在页面里运行,能读写这台电脑上的文件、运行命令。
11
+
12
+ ## 限制
13
+
14
+ - 本机扩展的链接只在分享者的 Ta 服务运行时可用,7 天有效,最大 8 MB。
15
+ - 临时扩展只运行 Web 部分;要用它的 pi 扩展、技能,需要安装。
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@celljs/ta-launcher",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "4.9.1",
4
+ "description": "A pi package for Ta: what a phone pulls down over its first tab (a button of the rail elsewhere), the pages used lately and those kept in Mine, opened without installing too",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "homepage": "https://github.com/cellbang/cell",
9
+ "bugs": {
10
+ "url": "https://github.com/cellbang/cell/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/cellbang/cell.git"
15
+ },
16
+ "license": "MIT",
17
+ "files": [
18
+ "web",
19
+ "!**/*.map"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js",
23
+ "clean": "rm -rf lib web *.tsbuildinfo",
24
+ "test": "bun test ./lib",
25
+ "watch": "tsc -b -w --preserveWatchOutput"
26
+ },
27
+ "devDependencies": {
28
+ "@celljs/ta-protocol": "4.9.1",
29
+ "@celljs/ta-web": "4.9.1",
30
+ "@types/react": "^19.3.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "pi": {
36
+ "title": {
37
+ "en": "Quick open",
38
+ "zh-CN": "快捷打开"
39
+ },
40
+ "summary": {
41
+ "en": "Pull down the first tab of a phone (the grid of the rail elsewhere) for the extensions used lately and those kept in Mine; open one from a link without installing it.",
42
+ "zh-CN": "在手机首页下拉(电脑上点导轨的九宫格),打开最近使用和收进\"我的\"的扩展;也能从链接免安装打开扩展。"
43
+ },
44
+ "icon": "Grip",
45
+ "web": [
46
+ "./web/index.js"
47
+ ]
48
+ }
49
+ }
package/web/index.js ADDED
@@ -0,0 +1,553 @@
1
+ // web-src/i18n.ts
2
+ var EN = {
3
+ recent: "Recent",
4
+ mine: "Mine",
5
+ mineCard: "Quick open",
6
+ emptyTitle: "Nothing opened yet",
7
+ emptyHint: "Open an extension from the market or from a link: no need to install it",
8
+ toMarket: "Market",
9
+ mineHint: "Hold an icon to keep it here",
10
+ openLink: "Open a link",
11
+ scan: "Scan",
12
+ scanInstructions: "Scan the code of an extension",
13
+ linkTitle: "Open an extension",
14
+ linkPlaceholder: "A link of an extension, or npm:<name>",
15
+ linkHint: "It runs without installing; Ta clears it after a while unused unless you keep it in Mine.",
16
+ open: "Open",
17
+ opening: "Opening…",
18
+ keep: "Keep in Mine",
19
+ unkeep: "Remove from Mine",
20
+ stop: "Close",
21
+ install: "Install",
22
+ installTitle: "Install {name}?",
23
+ installMessage: "Its extensions, skills and prompts load in conversations too, and it stays until you remove it.",
24
+ installed: "{name} is installed",
25
+ share: "Share",
26
+ forget: "Remove from Recent",
27
+ remove: "Delete",
28
+ removeTitle: "Delete {name}?",
29
+ removeMessage: "It was opened without installing: it goes from this computer. You can open it again from where it came from.",
30
+ running: "Running",
31
+ temporary: "Not installed"
32
+ };
33
+ var ZH = {
34
+ recent: "最近使用",
35
+ mine: "我的",
36
+ mineCard: "快捷打开",
37
+ emptyTitle: "还没有打开过扩展",
38
+ emptyHint: "在市场或链接里打开扩展,不用安装就能用",
39
+ toMarket: "去市场",
40
+ mineHint: "长按图标可以收进这里",
41
+ openLink: "打开链接",
42
+ scan: "扫一扫",
43
+ scanInstructions: "扫描扩展的二维码",
44
+ linkTitle: "打开扩展",
45
+ linkPlaceholder: "扩展链接,或 npm:包名",
46
+ linkHint: "不用安装就能运行;不收进“我的”的话,一段时间不用会被清除。",
47
+ open: "打开",
48
+ opening: "正在打开…",
49
+ keep: "收进“我的”",
50
+ unkeep: "从“我的”移除",
51
+ stop: "关闭",
52
+ install: "安装",
53
+ installTitle: "安装 {name}?",
54
+ installMessage: "它的 pi 扩展、技能和提示词也会在对话里加载,并且一直保留,直到你移除。",
55
+ installed: "已安装 {name}",
56
+ share: "分享",
57
+ forget: "从最近使用中删除",
58
+ remove: "删除",
59
+ removeTitle: "删除 {name}?",
60
+ removeMessage: "它是免安装打开的,会从这台电脑上删除;之后可以从原来的地方再次打开。",
61
+ running: "运行中",
62
+ temporary: "未安装"
63
+ };
64
+ var LauncherText;
65
+ ((LauncherText) => {
66
+ function of(language) {
67
+ return language === "zh-CN" ? ZH : EN;
68
+ }
69
+ LauncherText.of = of;
70
+ function fill(text, values) {
71
+ return text.replace(/\{(\w+)\}/g, (match, key) => values[key] ?? match);
72
+ }
73
+ LauncherText.fill = fill;
74
+ })(LauncherText ||= {});
75
+
76
+ // web-src/launcher-util.ts
77
+ var LauncherUtil;
78
+ ((LauncherUtil) => {
79
+ LauncherUtil.RECENT = 12;
80
+ function recent(pages) {
81
+ const used = pages.filter((page) => page.usedAt !== undefined && (page.place === "launcher" || page.place === "discover")).sort((a, b) => (b.usedAt ?? 0) - (a.usedAt ?? 0));
82
+ const fresh = pages.filter((page) => page.usedAt === undefined && page.place === "launcher").sort((a, b) => a.title.localeCompare(b.title));
83
+ return [...used, ...fresh].slice(0, LauncherUtil.RECENT);
84
+ }
85
+ LauncherUtil.recent = recent;
86
+ function mine(pages, ids) {
87
+ return ids.flatMap((id) => pages.find((page) => page.id === id) ?? []);
88
+ }
89
+ LauncherUtil.mine = mine;
90
+ function toggle(ids, id, keep) {
91
+ const rest = ids.filter((other) => other !== id);
92
+ return keep ? [...rest, id] : rest;
93
+ }
94
+ LauncherUtil.toggle = toggle;
95
+ function message(error) {
96
+ return error instanceof Error ? error.message : String(error);
97
+ }
98
+ LauncherUtil.message = message;
99
+ function hue(name) {
100
+ let hash = 0;
101
+ for (const char of name) {
102
+ hash = hash * 31 + (char.codePointAt(0) ?? 0) >>> 0;
103
+ }
104
+ return hash % 360;
105
+ }
106
+ LauncherUtil.hue = hue;
107
+ })(LauncherUtil ||= {});
108
+
109
+ // web-src/actions.ts
110
+ class LauncherActions {
111
+ pi;
112
+ mine;
113
+ dialog;
114
+ listeners = new Set;
115
+ constructor(pi, mine) {
116
+ this.pi = pi;
117
+ this.mine = mine;
118
+ }
119
+ get words() {
120
+ return LauncherText.of(this.pi.ui.language);
121
+ }
122
+ get shownDialog() {
123
+ return this.dialog;
124
+ }
125
+ subscribe = (listener) => {
126
+ this.listeners.add(listener);
127
+ return () => this.listeners.delete(listener);
128
+ };
129
+ show(dialog) {
130
+ this.dialog = dialog;
131
+ for (const listener of this.listeners) {
132
+ listener();
133
+ }
134
+ }
135
+ open(page) {
136
+ this.pi.ui.showView(page.id);
137
+ }
138
+ menu(page, inRecent) {
139
+ const words = this.words;
140
+ const icons = this.pi.ui.icons;
141
+ const kept = this.mine.value.includes(page.id);
142
+ const running = page.onOpen && (page.state === "background" || page.state === "running");
143
+ return [
144
+ [
145
+ kept ? { key: "unkeep", label: words.unkeep, icon: icons.StarOff, run: () => void this.keep(page, false) } : { key: "keep", label: words.keep, icon: icons.Star, run: () => void this.keep(page, true) },
146
+ ...running ? [{ key: "stop", label: words.stop, icon: icons.Power, run: () => this.pi.ui.stopExtension(page.extension) }] : []
147
+ ],
148
+ [
149
+ ...page.temporary ? [{ key: "install", label: words.install, icon: icons.Download, run: () => void this.install(page) }] : [],
150
+ ...page.extensionId ? [
151
+ {
152
+ key: "share",
153
+ label: words.share,
154
+ icon: icons.QrCode ?? icons.Share2,
155
+ run: () => this.pi.ui.shareExtension({ title: page.title, source: page.source, packageId: page.extensionId })
156
+ }
157
+ ] : []
158
+ ],
159
+ [
160
+ ...inRecent ? [{ key: "forget", label: words.forget, icon: icons.X, run: () => this.pi.ui.forgetPage(page.id) }] : [],
161
+ ...page.temporary ? [{ key: "remove", label: words.remove, icon: icons.Trash2, danger: true, run: () => void this.remove(page) }] : []
162
+ ]
163
+ ];
164
+ }
165
+ async keep(page, keep) {
166
+ await this.mine.set(LauncherUtil.toggle(this.mine.value, page.id, keep));
167
+ if (page.temporary) {
168
+ await this.pi.packages.updateTemporaryPackage(page.temporary.id, { kept: keep }).catch(() => {
169
+ return;
170
+ });
171
+ }
172
+ }
173
+ async install(page) {
174
+ const words = this.words;
175
+ if (!page.temporary) {
176
+ return;
177
+ }
178
+ const yes = await this.pi.ui.confirm(LauncherText.fill(words.installTitle, { name: page.title }), words.installMessage, {
179
+ confirmLabel: words.install
180
+ });
181
+ if (!yes) {
182
+ return;
183
+ }
184
+ try {
185
+ await this.pi.packages.installTemporaryPackage(page.temporary.id);
186
+ await this.pi.reloadExtensions();
187
+ this.pi.ui.notify(LauncherText.fill(words.installed, { name: page.title }));
188
+ } catch (error) {
189
+ this.pi.ui.notify(LauncherUtil.message(error), "error");
190
+ }
191
+ }
192
+ async remove(page) {
193
+ const words = this.words;
194
+ if (!page.temporary) {
195
+ return;
196
+ }
197
+ const yes = await this.pi.ui.confirm(LauncherText.fill(words.removeTitle, { name: page.title }), words.removeMessage, {
198
+ confirmLabel: words.remove,
199
+ danger: true
200
+ });
201
+ if (!yes) {
202
+ return;
203
+ }
204
+ try {
205
+ this.pi.ui.stopExtension(page.extension);
206
+ await this.pi.packages.removeWebExtension(page.temporary.id);
207
+ this.pi.ui.forgetPage(page.id);
208
+ await this.mine.set(LauncherUtil.toggle(this.mine.value, page.id, false));
209
+ await this.pi.reloadExtensions();
210
+ } catch (error) {
211
+ this.pi.ui.notify(LauncherUtil.message(error), "error");
212
+ }
213
+ }
214
+ openSource(text) {
215
+ return this.pi.ui.openShared(text);
216
+ }
217
+ async scan() {
218
+ try {
219
+ const text = await this.pi.ui.scanCode?.(this.words.scanInstructions);
220
+ if (text !== undefined) {
221
+ await this.openSource(text);
222
+ }
223
+ } catch (error) {
224
+ this.pi.ui.notify(LauncherUtil.message(error), "error");
225
+ }
226
+ }
227
+ }
228
+
229
+ // web-src/react.ts
230
+ var React;
231
+ function bind(react) {
232
+ React = react;
233
+ }
234
+
235
+ // web-src/mine-store.ts
236
+ var KEY = "mine";
237
+
238
+ class MineStore {
239
+ pi;
240
+ ids = [];
241
+ listeners = new Set;
242
+ stopWatching;
243
+ constructor(pi) {
244
+ this.pi = pi;
245
+ }
246
+ get value() {
247
+ return this.ids;
248
+ }
249
+ start() {
250
+ this.load();
251
+ this.stopWatching = this.pi.storage.onChange((keys) => {
252
+ if (keys.includes(KEY)) {
253
+ this.load();
254
+ }
255
+ });
256
+ }
257
+ dispose() {
258
+ this.stopWatching?.();
259
+ this.listeners.clear();
260
+ }
261
+ async set(ids) {
262
+ this.publish(ids);
263
+ await this.pi.storage.set(KEY, ids);
264
+ }
265
+ subscribe = (listener) => {
266
+ this.listeners.add(listener);
267
+ return () => this.listeners.delete(listener);
268
+ };
269
+ async load() {
270
+ const kept = await this.pi.storage.get(KEY).catch(() => {
271
+ return;
272
+ });
273
+ this.publish(Array.isArray(kept) ? kept.filter((id) => typeof id === "string") : []);
274
+ }
275
+ publish(ids) {
276
+ if (ids.length === this.ids.length && ids.every((id, index) => id === this.ids[index])) {
277
+ return;
278
+ }
279
+ this.ids = ids;
280
+ for (const listener of this.listeners) {
281
+ listener();
282
+ }
283
+ }
284
+ }
285
+ function useMine(store) {
286
+ return React.useSyncExternalStore(store.subscribe, () => store.value);
287
+ }
288
+
289
+ // web-src/launcher-view.tsx
290
+ function Tile({
291
+ context,
292
+ page,
293
+ inRecent,
294
+ onMenu
295
+ }) {
296
+ const { pi, actions } = context;
297
+ const Glyph = page.icon ?? pi.ui.icons.Puzzle;
298
+ const running = page.onOpen && (page.state === "background" || page.state === "running");
299
+ const words = actions.words;
300
+ const style = { "--tla-hue": String(LauncherUtil.hue(page.extension)) };
301
+ return /* @__PURE__ */ React.createElement("button", {
302
+ type: "button",
303
+ className: "tla-tile",
304
+ style,
305
+ title: page.title,
306
+ onClick: () => actions.open(page),
307
+ onContextMenu: (event) => onMenu(event, page, inRecent)
308
+ }, /* @__PURE__ */ React.createElement("span", {
309
+ className: "tla-icon"
310
+ }, /* @__PURE__ */ React.createElement(Glyph, {
311
+ size: 24,
312
+ strokeWidth: 1.7
313
+ }), running && /* @__PURE__ */ React.createElement("span", {
314
+ className: "tla-dot",
315
+ role: "img",
316
+ "aria-label": words.running
317
+ })), /* @__PURE__ */ React.createElement("span", {
318
+ className: "tla-name"
319
+ }, page.title));
320
+ }
321
+ function LinkDialog({ context }) {
322
+ const { pi, actions } = context;
323
+ const words = actions.words;
324
+ const [text, setText] = React.useState("");
325
+ const [busy, setBusy] = React.useState(false);
326
+ const Dialog = pi.ui.Dialog;
327
+ const submit = async (event) => {
328
+ event.preventDefault();
329
+ setBusy(true);
330
+ const opened = await actions.openSource(text);
331
+ setBusy(false);
332
+ if (opened) {
333
+ actions.show(undefined);
334
+ }
335
+ };
336
+ return /* @__PURE__ */ React.createElement(Dialog, {
337
+ title: words.linkTitle,
338
+ onClose: () => actions.show(undefined)
339
+ }, /* @__PURE__ */ React.createElement("form", {
340
+ className: "tla-form",
341
+ onSubmit: submit
342
+ }, /* @__PURE__ */ React.createElement("input", {
343
+ className: "tla-input",
344
+ value: text,
345
+ placeholder: words.linkPlaceholder,
346
+ "aria-label": words.linkTitle,
347
+ autoFocus: true,
348
+ autoCapitalize: "off",
349
+ autoCorrect: "off",
350
+ spellCheck: false,
351
+ enterKeyHint: "go",
352
+ onChange: (event) => setText(event.target.value)
353
+ }), /* @__PURE__ */ React.createElement("div", {
354
+ className: "tla-note"
355
+ }, words.linkHint), /* @__PURE__ */ React.createElement("div", {
356
+ className: "tla-actions"
357
+ }, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
358
+ type: "button",
359
+ className: "tla-button",
360
+ onClick: () => void actions.scan().then(() => actions.show(undefined))
361
+ }, words.scan), /* @__PURE__ */ React.createElement("button", {
362
+ type: "submit",
363
+ className: "tla-button tla-primary",
364
+ disabled: busy || !text.trim()
365
+ }, busy ? words.opening : words.open))));
366
+ }
367
+ function Dialogs({ context }) {
368
+ const { actions } = context;
369
+ const dialog = React.useSyncExternalStore(actions.subscribe, () => actions.shownDialog);
370
+ return dialog?.kind === "link" ? /* @__PURE__ */ React.createElement(LinkDialog, {
371
+ context
372
+ }) : null;
373
+ }
374
+ function LauncherView({ context }) {
375
+ const { pi, mine: store, actions } = context;
376
+ const words = actions.words;
377
+ const pages = pi.ui.usePages();
378
+ const ids = useMine(store);
379
+ const recent = LauncherUtil.recent(pages);
380
+ const mine = LauncherUtil.mine(pages, ids);
381
+ const [menu, openMenu] = pi.ui.useContextMenu();
382
+ const onMenu = (event, page, inRecent) => openMenu(event, actions.menu(page, inRecent));
383
+ const { Link, ScanLine } = pi.ui.icons;
384
+ const tools = /* @__PURE__ */ React.createElement("div", {
385
+ className: "tla-tools"
386
+ }, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
387
+ type: "button",
388
+ className: "tla-tool",
389
+ "aria-label": words.scan,
390
+ title: words.scan,
391
+ onClick: () => void actions.scan()
392
+ }, /* @__PURE__ */ React.createElement(ScanLine, {
393
+ size: 17,
394
+ strokeWidth: 1.7
395
+ })), /* @__PURE__ */ React.createElement("button", {
396
+ type: "button",
397
+ className: "tla-tool",
398
+ "aria-label": words.openLink,
399
+ title: words.openLink,
400
+ onClick: () => actions.show({ kind: "link" })
401
+ }, /* @__PURE__ */ React.createElement(Link, {
402
+ size: 17,
403
+ strokeWidth: 1.7
404
+ })));
405
+ return /* @__PURE__ */ React.createElement("div", {
406
+ className: "tla"
407
+ }, /* @__PURE__ */ React.createElement("header", {
408
+ className: "tla-head"
409
+ }, /* @__PURE__ */ React.createElement("span", {
410
+ className: "tla-label"
411
+ }, words.recent), tools), recent.length === 0 && mine.length === 0 ? /* @__PURE__ */ React.createElement("div", {
412
+ className: "tla-empty"
413
+ }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
414
+ title: words.emptyTitle,
415
+ hint: words.emptyHint,
416
+ compact: true
417
+ }, /* @__PURE__ */ React.createElement("button", {
418
+ type: "button",
419
+ className: "tla-button",
420
+ onClick: () => pi.ui.showView("@celljs/ta-extensions/extensions")
421
+ }, words.toMarket))) : /* @__PURE__ */ React.createElement(React.Fragment, null, recent.length > 0 && /* @__PURE__ */ React.createElement("div", {
422
+ className: "tla-row"
423
+ }, recent.map((page) => /* @__PURE__ */ React.createElement(Tile, {
424
+ key: page.id,
425
+ context,
426
+ page,
427
+ inRecent: true,
428
+ onMenu
429
+ }))), /* @__PURE__ */ React.createElement("header", {
430
+ className: "tla-head tla-head-mine"
431
+ }, /* @__PURE__ */ React.createElement("span", {
432
+ className: "tla-label"
433
+ }, words.mine)), mine.length > 0 ? /* @__PURE__ */ React.createElement("div", {
434
+ className: "tla-grid"
435
+ }, mine.map((page) => /* @__PURE__ */ React.createElement(Tile, {
436
+ key: page.id,
437
+ context,
438
+ page,
439
+ inRecent: false,
440
+ onMenu
441
+ }))) : /* @__PURE__ */ React.createElement("div", {
442
+ className: "tla-note tla-pad"
443
+ }, words.mineHint)), menu, /* @__PURE__ */ React.createElement(Dialogs, {
444
+ context
445
+ }));
446
+ }
447
+ function MineCard({ context }) {
448
+ const { pi, mine: store, actions } = context;
449
+ const pages = pi.ui.usePages();
450
+ const ids = useMine(store);
451
+ const mine = LauncherUtil.mine(pages, ids);
452
+ const shown = (mine.length > 0 ? mine : LauncherUtil.recent(pages)).slice(0, 8);
453
+ const [menu, openMenu] = pi.ui.useContextMenu();
454
+ if (shown.length === 0) {
455
+ return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
456
+ title: actions.words.emptyTitle,
457
+ compact: true
458
+ });
459
+ }
460
+ return /* @__PURE__ */ React.createElement("div", {
461
+ className: "tla-grid tla-card"
462
+ }, shown.map((page) => /* @__PURE__ */ React.createElement(Tile, {
463
+ key: page.id,
464
+ context,
465
+ page,
466
+ inRecent: mine.length === 0,
467
+ onMenu: (event, target, inRecent) => openMenu(event, actions.menu(target, inRecent))
468
+ })), menu);
469
+ }
470
+
471
+ // web-src/style.ts
472
+ var STYLE = `
473
+ .tla { display: flex; flex-direction: column; }
474
+ .tla-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 2px 10px; }
475
+ .tla-head-mine { margin-top: 18px; }
476
+ .tla-label { flex: 1; min-width: 0; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); line-height: calc(18px * var(--ta-font-scale)); font-weight: 500; }
477
+ .tla-tools { display: flex; gap: 2px; margin-right: -6px; }
478
+ .tla-tool { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--ta-muted); cursor: pointer; transition: background 140ms, color 140ms; }
479
+ .tla-tool:hover { background: var(--ta-hover); color: var(--ta-text); }
480
+ .tla-row { display: grid; grid-auto-flow: column; grid-auto-columns: 25%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; margin: 0 -2px; }
481
+ .tla-row::-webkit-scrollbar { display: none; }
482
+ .tla-row > .tla-tile { scroll-snap-align: start; }
483
+ .tla-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; margin: 0 -2px; }
484
+ .tla-tile { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; padding: 4px 2px; border: 0; border-radius: 14px; background: none; color: var(--ta-text); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }
485
+ .tla-icon { position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: hsl(var(--tla-hue) 70% 94%); color: hsl(var(--tla-hue) 52% 36%); box-shadow: inset 0 0 0 1px hsl(var(--tla-hue) 40% 50% / 0.08); transition: transform 160ms var(--ta-ease), filter 160ms; }
486
+ :root[data-theme='dark'] .tla-icon { background: hsl(var(--tla-hue) 26% 21%); color: hsl(var(--tla-hue) 72% 76%); box-shadow: inset 0 0 0 1px hsl(var(--tla-hue) 40% 70% / 0.1); }
487
+ .tla-tile:hover .tla-icon { filter: brightness(0.97); }
488
+ .tla-tile:active .tla-icon { transform: scale(0.92); }
489
+ .tla-dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--ta-green); box-shadow: 0 0 0 2px var(--ta-main); }
490
+ .tla-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-body); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(16px * var(--ta-font-scale)); }
491
+ .tla-empty { display: flex; flex-direction: column; padding: 18px 0 6px; }
492
+ .tla-note { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); line-height: calc(18px * var(--ta-font-scale)); }
493
+ .tla-pad { padding: 2px 2px 4px; }
494
+ .tla-card { row-gap: 10px; }
495
+ .tla-card .tla-icon { width: 44px; height: 44px; border-radius: 13px; }
496
+ .tla-form { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
497
+ .tla-input { height: 40px; padding: 0 12px; border: 1px solid var(--ta-border-field); border-radius: 10px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: calc(14px * var(--ta-font-scale)); outline: none; }
498
+ .tla-input:focus { border-color: var(--ta-border-focus); }
499
+ :root[data-touch] .tla-input { font-size: max(16px, calc(14px * var(--ta-font-scale))); }
500
+ .tla-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
501
+ .tla-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--ta-border); border-radius: 10px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; cursor: pointer; transition: background 120ms, opacity 120ms; }
502
+ .tla-button:hover:not(:disabled) { background: var(--ta-hover); }
503
+ .tla-button:disabled { opacity: 0.45; cursor: default; }
504
+ .tla-primary { border-color: var(--ta-brand); background: var(--ta-brand); color: var(--ta-brand-text); }
505
+ .tla-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: 0.88; }
506
+ `;
507
+ function injectStyle() {
508
+ const element = document.createElement("style");
509
+ element.dataset.taLauncher = "";
510
+ element.textContent = STYLE;
511
+ document.head.append(element);
512
+ return () => element.remove();
513
+ }
514
+
515
+ // web-src/index.tsx
516
+ function activate(pi) {
517
+ bind(pi.React);
518
+ const removeStyle = injectStyle();
519
+ const mine = new MineStore(pi);
520
+ mine.start();
521
+ const context = { pi, mine, actions: new LauncherActions(pi, mine) };
522
+ const icons = pi.ui.icons;
523
+ pi.registerView("launcher", {
524
+ title: () => LauncherText.of(pi.ui.language).recent,
525
+ icon: icons.Grip,
526
+ location: "launcher",
527
+ order: 0,
528
+ render: () => /* @__PURE__ */ React.createElement(LauncherView, {
529
+ context
530
+ })
531
+ });
532
+ pi.registerView("mine", {
533
+ title: () => LauncherText.of(pi.ui.language).mineCard,
534
+ icon: icons.Star,
535
+ location: "board",
536
+ order: 10,
537
+ render: () => /* @__PURE__ */ React.createElement(MineCard, {
538
+ context
539
+ })
540
+ });
541
+ if (location.hash.startsWith("#open=")) {
542
+ const link = location.hash;
543
+ history.replaceState(history.state, "", location.pathname + location.search);
544
+ context.actions.openSource(link);
545
+ }
546
+ return () => {
547
+ mine.dispose();
548
+ removeStyle();
549
+ };
550
+ }
551
+ export {
552
+ activate as default
553
+ };