@celljs/ta-launcher 4.10.0 → 4.11.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/package.json +3 -3
- package/web/index.js +34 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-launcher",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
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
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@celljs/ta-protocol": "4.
|
|
29
|
-
"@celljs/ta-web": "4.
|
|
28
|
+
"@celljs/ta-protocol": "4.11.0",
|
|
29
|
+
"@celljs/ta-web": "4.11.0",
|
|
30
30
|
"@types/react": "^19.3.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -74,11 +74,12 @@ var LauncherText;
|
|
|
74
74
|
})(LauncherText ||= {});
|
|
75
75
|
|
|
76
76
|
// web-src/launcher-util.ts
|
|
77
|
+
var TINTS = 9;
|
|
77
78
|
var LauncherUtil;
|
|
78
79
|
((LauncherUtil) => {
|
|
79
80
|
LauncherUtil.RECENT = 12;
|
|
80
81
|
function recent(pages) {
|
|
81
|
-
const used = pages.filter((page) => page.usedAt !== undefined && (page.
|
|
82
|
+
const used = pages.filter((page) => page.usedAt !== undefined && (page.onOpen || page.place === "discover")).sort((a, b) => (b.usedAt ?? 0) - (a.usedAt ?? 0));
|
|
82
83
|
const fresh = pages.filter((page) => page.usedAt === undefined && page.place === "launcher").sort((a, b) => a.title.localeCompare(b.title));
|
|
83
84
|
return [...used, ...fresh].slice(0, LauncherUtil.RECENT);
|
|
84
85
|
}
|
|
@@ -96,14 +97,14 @@ var LauncherUtil;
|
|
|
96
97
|
return error instanceof Error ? error.message : String(error);
|
|
97
98
|
}
|
|
98
99
|
LauncherUtil.message = message;
|
|
99
|
-
function
|
|
100
|
+
function tint(name) {
|
|
100
101
|
let hash = 0;
|
|
101
102
|
for (const char of name) {
|
|
102
103
|
hash = hash * 31 + (char.codePointAt(0) ?? 0) >>> 0;
|
|
103
104
|
}
|
|
104
|
-
return hash %
|
|
105
|
+
return hash % TINTS;
|
|
105
106
|
}
|
|
106
|
-
LauncherUtil.
|
|
107
|
+
LauncherUtil.tint = tint;
|
|
107
108
|
})(LauncherUtil ||= {});
|
|
108
109
|
|
|
109
110
|
// web-src/actions.ts
|
|
@@ -133,7 +134,7 @@ class LauncherActions {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
open(page) {
|
|
136
|
-
this.pi.ui.showView(page.id);
|
|
137
|
+
return this.pi.ui.showView(page.id);
|
|
137
138
|
}
|
|
138
139
|
menu(page, inRecent) {
|
|
139
140
|
const words = this.words;
|
|
@@ -203,7 +204,7 @@ class LauncherActions {
|
|
|
203
204
|
}
|
|
204
205
|
try {
|
|
205
206
|
this.pi.ui.stopExtension(page.extension);
|
|
206
|
-
await this.pi.packages.
|
|
207
|
+
await this.pi.packages.removePackage(page.temporary.id);
|
|
207
208
|
this.pi.ui.forgetPage(page.id);
|
|
208
209
|
await this.mine.set(LauncherUtil.toggle(this.mine.value, page.id, false));
|
|
209
210
|
await this.pi.reloadExtensions();
|
|
@@ -215,6 +216,9 @@ class LauncherActions {
|
|
|
215
216
|
return this.pi.ui.openShared(text);
|
|
216
217
|
}
|
|
217
218
|
async scan() {
|
|
219
|
+
if (this.pi.ui.scan) {
|
|
220
|
+
return this.pi.ui.scan();
|
|
221
|
+
}
|
|
218
222
|
try {
|
|
219
223
|
const text = await this.pi.ui.scanCode?.(this.words.scanInstructions);
|
|
220
224
|
if (text !== undefined) {
|
|
@@ -231,6 +235,10 @@ var React;
|
|
|
231
235
|
function bind(react) {
|
|
232
236
|
React = react;
|
|
233
237
|
}
|
|
238
|
+
var idle = () => [false, async (action) => await action()];
|
|
239
|
+
function useBusy(ui) {
|
|
240
|
+
return (ui.useBusy ?? idle)();
|
|
241
|
+
}
|
|
234
242
|
|
|
235
243
|
// web-src/mine-store.ts
|
|
236
244
|
var KEY = "mine";
|
|
@@ -297,16 +305,19 @@ function Tile({
|
|
|
297
305
|
const Glyph = page.icon ?? pi.ui.icons.Puzzle;
|
|
298
306
|
const running = page.onOpen && (page.state === "background" || page.state === "running");
|
|
299
307
|
const words = actions.words;
|
|
300
|
-
const
|
|
308
|
+
const tint = LauncherUtil.tint(page.extension);
|
|
309
|
+
const style = { "--tla-tint": `var(--ta-tint-${tint})`, "--tla-ink": `var(--ta-tint-ink-${tint})` };
|
|
310
|
+
const [opening, run] = useBusy(pi.ui);
|
|
301
311
|
return /* @__PURE__ */ React.createElement("button", {
|
|
302
312
|
type: "button",
|
|
303
313
|
className: "tla-tile",
|
|
304
314
|
style,
|
|
305
315
|
title: page.title,
|
|
306
|
-
|
|
316
|
+
"aria-busy": opening || undefined,
|
|
317
|
+
onClick: () => void run(() => actions.open(page)),
|
|
307
318
|
onContextMenu: (event) => onMenu(event, page, inRecent)
|
|
308
319
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
309
|
-
className: "tla-icon"
|
|
320
|
+
className: opening ? "tla-icon ta-busy" : "tla-icon"
|
|
310
321
|
}, /* @__PURE__ */ React.createElement(Glyph, {
|
|
311
322
|
size: 24,
|
|
312
323
|
strokeWidth: 1.7
|
|
@@ -314,6 +325,8 @@ function Tile({
|
|
|
314
325
|
className: "tla-dot",
|
|
315
326
|
role: "img",
|
|
316
327
|
"aria-label": words.running
|
|
328
|
+
}), opening && /* @__PURE__ */ React.createElement("span", {
|
|
329
|
+
className: "ta-spinner ta-busy-mark"
|
|
317
330
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
318
331
|
className: "tla-name"
|
|
319
332
|
}, page.title));
|
|
@@ -354,15 +367,17 @@ function LinkDialog({ context }) {
|
|
|
354
367
|
className: "tla-note"
|
|
355
368
|
}, words.linkHint), /* @__PURE__ */ React.createElement("div", {
|
|
356
369
|
className: "tla-actions"
|
|
357
|
-
}, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
|
|
370
|
+
}, (pi.ui.scan || pi.ui.scanCode) && /* @__PURE__ */ React.createElement("button", {
|
|
358
371
|
type: "button",
|
|
359
372
|
className: "tla-button",
|
|
360
373
|
onClick: () => void actions.scan().then(() => actions.show(undefined))
|
|
361
374
|
}, words.scan), /* @__PURE__ */ React.createElement("button", {
|
|
362
375
|
type: "submit",
|
|
363
|
-
className: "tla-button tla-primary",
|
|
376
|
+
className: busy ? "tla-button tla-primary ta-busy" : "tla-button tla-primary",
|
|
364
377
|
disabled: busy || !text.trim()
|
|
365
|
-
}, busy ? words.opening : words.open
|
|
378
|
+
}, busy ? words.opening : words.open, busy && /* @__PURE__ */ React.createElement("span", {
|
|
379
|
+
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
380
|
+
})))));
|
|
366
381
|
}
|
|
367
382
|
function Dialogs({ context }) {
|
|
368
383
|
const { actions } = context;
|
|
@@ -383,7 +398,7 @@ function LauncherView({ context }) {
|
|
|
383
398
|
const { Link, ScanLine } = pi.ui.icons;
|
|
384
399
|
const tools = /* @__PURE__ */ React.createElement("div", {
|
|
385
400
|
className: "tla-tools"
|
|
386
|
-
}, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
|
|
401
|
+
}, (pi.ui.scan || pi.ui.scanCode) && /* @__PURE__ */ React.createElement("button", {
|
|
387
402
|
type: "button",
|
|
388
403
|
className: "tla-tool",
|
|
389
404
|
"aria-label": words.scan,
|
|
@@ -482,10 +497,10 @@ var STYLE = `
|
|
|
482
497
|
.tla-row > .tla-tile { scroll-snap-align: start; }
|
|
483
498
|
.tla-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; margin: 0 -2px; }
|
|
484
499
|
.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:
|
|
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); }
|
|
500
|
+
.tla-icon { position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--tla-tint); color: var(--tla-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tla-ink) 10%, transparent); transition: transform 160ms var(--ta-ease), filter 160ms; }
|
|
487
501
|
.tla-tile:hover .tla-icon { filter: brightness(0.97); }
|
|
488
502
|
.tla-tile:active .tla-icon { transform: scale(0.92); }
|
|
503
|
+
.tla-icon > .ta-busy-mark { width: 20px; height: 20px; border-width: 2px; border-color: color-mix(in srgb, var(--tla-ink) 25%, transparent); border-top-color: var(--tla-ink); }
|
|
489
504
|
.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
505
|
.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
506
|
.tla-empty { display: flex; flex-direction: column; padding: 18px 0 6px; }
|
|
@@ -498,9 +513,11 @@ var STYLE = `
|
|
|
498
513
|
.tla-input:focus { border-color: var(--ta-border-focus); }
|
|
499
514
|
:root[data-touch] .tla-input { font-size: max(16px, calc(14px * var(--ta-font-scale))); }
|
|
500
515
|
.tla-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
|
|
501
|
-
|
|
516
|
+
/* As the buttons of the page (.ta-button). */
|
|
517
|
+
.tla-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--ta-border); border-radius: 8px; 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
518
|
.tla-button:hover:not(:disabled) { background: var(--ta-hover); }
|
|
503
|
-
.tla-button:disabled { opacity: 0.45; cursor: default; }
|
|
519
|
+
.tla-button:disabled:not(.ta-busy) { opacity: 0.45; cursor: default; }
|
|
520
|
+
.tla-button.ta-busy { position: relative; }
|
|
504
521
|
.tla-primary { border-color: var(--ta-brand); background: var(--ta-brand); color: var(--ta-brand-text); }
|
|
505
522
|
.tla-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: 0.88; }
|
|
506
523
|
`;
|