@celljs/ta-share 4.11.0 → 4.13.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 +1 -1
- package/README.md +1 -1
- package/extension/index.mjs +51 -0
- package/package.json +13 -5
- package/web/index.js +56 -31
package/README.en.md
CHANGED
|
@@ -15,7 +15,7 @@ A pi package that comes with Ta (on by default; Settings → Extensions turns it
|
|
|
15
15
|
| --- | --- |
|
|
16
16
|
| Anyone with the link | Anyone who has the link |
|
|
17
17
|
| With a password | Who has the link and the password; the password is not in the link, and the key of the content is derived from both |
|
|
18
|
-
|
|
|
18
|
+
| Friends | The friends chosen, in their own Ta only: the link holds no key, the key of the content is agreed between the two identities (ECDH), and neither the relay nor anyone else learns who opens it; while this computer runs Ta |
|
|
19
19
|
| Only me | Only the Ta of the one who shared it (this computer and its paired devices) |
|
|
20
20
|
|
|
21
21
|
It works for 1, 7 or 30 days, or until stopped; "opens while this computer is off" keeps a sealed copy on the relay, 30 days at most.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):把对
|
|
|
15
15
|
| --- | --- |
|
|
16
16
|
| 拿到链接的人 | 任何拿到链接的人 |
|
|
17
17
|
| 凭口令 | 拿到链接并且知道口令的人;口令不在链接里,内容密钥由链接密钥和口令共同派生 |
|
|
18
|
-
| 指定的好友 |
|
|
18
|
+
| 指定的好友 | 选定的几位好友,只能在他们自己的 Ta 里打开:链接里没有密钥,内容密钥由双方身份密钥协商(ECDH)得出,中继和别人都不知道是谁在看;只在这台电脑运行 Ta 时可打开 |
|
|
19
19
|
| 仅自己 | 只在分享者自己的 Ta(这台电脑和配对过的设备)里打开 |
|
|
20
20
|
|
|
21
21
|
有效期 1 / 7 / 30 天或不过期;"电脑关机也能打开"会把加密副本放到中继上,最长 30 天。
|
package/extension/index.mjs
CHANGED
|
@@ -5,19 +5,70 @@ var TaHostUtil;
|
|
|
5
5
|
TaHostUtil2.WAIT_MS = 1000;
|
|
6
6
|
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
7
7
|
return new Promise((resolve) => {
|
|
8
|
+
let heard = false;
|
|
9
|
+
let answered = false;
|
|
8
10
|
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
9
11
|
const request = {
|
|
10
12
|
name,
|
|
13
|
+
heard: () => {
|
|
14
|
+
heard = true;
|
|
15
|
+
},
|
|
11
16
|
resolve: (answer) => {
|
|
17
|
+
answered = true;
|
|
12
18
|
clearTimeout(timer);
|
|
13
19
|
resolve(answer);
|
|
14
20
|
}
|
|
15
21
|
};
|
|
16
22
|
events.emit(TA_HOST_EVENT, request);
|
|
23
|
+
if (!heard && !answered) {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
resolve(undefined);
|
|
26
|
+
}
|
|
17
27
|
});
|
|
18
28
|
}
|
|
19
29
|
TaHostUtil2.reach = reach;
|
|
20
30
|
})(TaHostUtil || (TaHostUtil = {}));
|
|
31
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
32
|
+
var TaAskUtil;
|
|
33
|
+
(function(TaAskUtil2) {
|
|
34
|
+
const LENGTH = 120;
|
|
35
|
+
function entry(question) {
|
|
36
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
37
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
38
|
+
}
|
|
39
|
+
TaAskUtil2.entry = entry;
|
|
40
|
+
function asking(entries) {
|
|
41
|
+
var _a;
|
|
42
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
43
|
+
const entry2 = entries[i];
|
|
44
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
48
|
+
return read(entry2);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
TaAskUtil2.asking = asking;
|
|
54
|
+
function next(asked, entry2) {
|
|
55
|
+
var _a;
|
|
56
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
60
|
+
}
|
|
61
|
+
TaAskUtil2.next = next;
|
|
62
|
+
function read(found) {
|
|
63
|
+
var _a;
|
|
64
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
65
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
69
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
70
|
+
}
|
|
71
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
21
72
|
|
|
22
73
|
// web-src/server-texts.ts
|
|
23
74
|
var ShareServerTexts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-share",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "A pi package for Ta: share a conversation, a page or a file by a link, public, with a password or for yourself, end to end through the relay; open and import what others share",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-relay": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.13.0",
|
|
31
|
+
"@celljs/ta-relay": "4.13.0",
|
|
32
|
+
"@celljs/ta-web": "4.13.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -51,6 +51,14 @@
|
|
|
51
51
|
"host": "./host/index.mjs",
|
|
52
52
|
"extensions": [
|
|
53
53
|
"./extension/index.mjs"
|
|
54
|
-
]
|
|
54
|
+
],
|
|
55
|
+
"permissions": {
|
|
56
|
+
"host": {
|
|
57
|
+
"*": "settings.manage"
|
|
58
|
+
},
|
|
59
|
+
"tools": {
|
|
60
|
+
"share_link": "chat.share"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
}
|
package/web/index.js
CHANGED
|
@@ -8,12 +8,12 @@ var EN = {
|
|
|
8
8
|
accessLink: "Anyone with the link",
|
|
9
9
|
accessPassword: "With a password",
|
|
10
10
|
accessSelf: "Only me",
|
|
11
|
-
accessPeople: "
|
|
12
|
-
accessPeopleShort: "
|
|
11
|
+
accessPeople: "Friends",
|
|
12
|
+
accessPeopleShort: "Friends",
|
|
13
13
|
accessPeopleHint: "Opens only in their own Ta, which proves who it is: the link alone opens nothing. While this computer runs Ta.",
|
|
14
|
-
peopleNone: "No
|
|
14
|
+
peopleNone: "No friends yet: add one under Discover → Friends.",
|
|
15
15
|
peopleChoose: "Choose at least one.",
|
|
16
|
-
peopleOnly: "Only the
|
|
16
|
+
peopleOnly: "Only the friends it was shared with open it, in their own Ta.",
|
|
17
17
|
peopleLine: "for {names}",
|
|
18
18
|
accessLinkShort: "Public",
|
|
19
19
|
accessPasswordShort: "Password",
|
|
@@ -110,9 +110,9 @@ var ZH = {
|
|
|
110
110
|
accessPeople: "指定的好友",
|
|
111
111
|
accessPeopleShort: "指定的好友",
|
|
112
112
|
accessPeopleHint: "只能在对方自己的 Ta 里打开,由 Ta 证明身份:光有链接打不开。这台电脑运行 Ta 时可以打开。",
|
|
113
|
-
peopleNone: "
|
|
113
|
+
peopleNone: "还没有好友:在“发现 → 好友”里添加。",
|
|
114
114
|
peopleChoose: "至少选一位。",
|
|
115
|
-
peopleOnly: "
|
|
115
|
+
peopleOnly: "这条链接只给指定的好友,请在他们自己的 Ta 里打开。",
|
|
116
116
|
peopleLine: "给{names}",
|
|
117
117
|
accessLinkShort: "公开",
|
|
118
118
|
accessPasswordShort: "口令",
|
|
@@ -300,14 +300,14 @@ function Choice({
|
|
|
300
300
|
label
|
|
301
301
|
}) {
|
|
302
302
|
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
303
|
-
className: "tsh-choice",
|
|
303
|
+
className: "ta-segmented tsh-choice",
|
|
304
304
|
"aria-label": label
|
|
305
305
|
}, options.map((option) => /* @__PURE__ */ React.createElement("button", {
|
|
306
306
|
key: String(option.value),
|
|
307
307
|
type: "button",
|
|
308
308
|
"aria-pressed": option.value === value,
|
|
309
309
|
disabled: option.disabled,
|
|
310
|
-
className: option.value === value ? "
|
|
310
|
+
className: option.value === value ? "ta-on" : "",
|
|
311
311
|
onClick: () => onChange(option.value)
|
|
312
312
|
}, option.label)));
|
|
313
313
|
}
|
|
@@ -959,10 +959,19 @@ function kindIcon(share) {
|
|
|
959
959
|
function ShareRow({ share }) {
|
|
960
960
|
const [copied, setCopied] = React.useState(false);
|
|
961
961
|
const [stopping, setStopping] = React.useState(false);
|
|
962
|
+
const touch = pi.ui.useDevice().touch;
|
|
963
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
962
964
|
const Kind = icon(kindIcon(share));
|
|
963
965
|
const Copy = icon("Copy");
|
|
964
966
|
const Qr = icon("QrCode");
|
|
965
967
|
const Stop = icon("Trash2");
|
|
968
|
+
const show = () => openShareDialog({ kind: "made", share });
|
|
969
|
+
const copy = () => void navigator.clipboard?.writeText(share.link).then(() => {
|
|
970
|
+
setCopied(true);
|
|
971
|
+
if (touch) {
|
|
972
|
+
pi.ui.notify(t("copied"));
|
|
973
|
+
}
|
|
974
|
+
}).catch((error) => pi.ui.notify(message(error), "error"));
|
|
966
975
|
const stop = async () => {
|
|
967
976
|
if (await pi.ui.confirm(t("stopTitle", { title: share.title }), t("stopHint"), { confirmLabel: t("stop"), danger: true })) {
|
|
968
977
|
setStopping(true);
|
|
@@ -972,37 +981,43 @@ function ShareRow({ share }) {
|
|
|
972
981
|
});
|
|
973
982
|
}
|
|
974
983
|
};
|
|
975
|
-
|
|
976
|
-
|
|
984
|
+
const items = [
|
|
985
|
+
[
|
|
986
|
+
{ key: "qr", label: t("qr"), icon: Qr, run: show },
|
|
987
|
+
{ key: "copy", label: t("copy"), icon: Copy, run: copy }
|
|
988
|
+
],
|
|
989
|
+
[{ key: "stop", label: t("stop"), icon: Stop, danger: true, disabled: stopping, run: () => void stop() }]
|
|
990
|
+
];
|
|
991
|
+
const content = /* @__PURE__ */ React.createElement("div", {
|
|
992
|
+
className: `tsh-row${stopping ? " ta-pending" : ""}`,
|
|
993
|
+
"aria-busy": stopping || undefined,
|
|
994
|
+
onContextMenu: (event) => openMenu(event, items)
|
|
995
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
996
|
+
type: "button",
|
|
997
|
+
className: "tsh-row-main",
|
|
998
|
+
title: t("qr"),
|
|
999
|
+
onClick: show
|
|
977
1000
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
978
1001
|
className: `tsh-tile tsh-tile-${share.access}`,
|
|
979
1002
|
"aria-hidden": "true"
|
|
980
1003
|
}, /* @__PURE__ */ React.createElement(Kind, {
|
|
981
1004
|
size: 18
|
|
982
|
-
})), /* @__PURE__ */ React.createElement("
|
|
1005
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
983
1006
|
className: "tsh-row-text"
|
|
984
1007
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
985
1008
|
className: "tsh-row-title"
|
|
986
1009
|
}, share.title), /* @__PURE__ */ React.createElement("span", {
|
|
987
1010
|
className: "tsh-row-line"
|
|
988
|
-
}, shareLine(share))), /* @__PURE__ */ React.createElement("div", {
|
|
1011
|
+
}, shareLine(share)))), !touch && /* @__PURE__ */ React.createElement("div", {
|
|
989
1012
|
className: "tsh-row-actions"
|
|
990
1013
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
991
1014
|
type: "button",
|
|
992
1015
|
className: "tsh-icon",
|
|
993
1016
|
title: copied ? t("copied") : t("copy"),
|
|
994
1017
|
"aria-label": t("copy"),
|
|
995
|
-
onClick:
|
|
1018
|
+
onClick: copy
|
|
996
1019
|
}, /* @__PURE__ */ React.createElement(Copy, {
|
|
997
1020
|
size: 15
|
|
998
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
999
|
-
type: "button",
|
|
1000
|
-
className: "tsh-icon",
|
|
1001
|
-
title: t("qr"),
|
|
1002
|
-
"aria-label": t("qr"),
|
|
1003
|
-
onClick: () => openShareDialog({ kind: "made", share })
|
|
1004
|
-
}, /* @__PURE__ */ React.createElement(Qr, {
|
|
1005
|
-
size: 15
|
|
1006
1021
|
})), /* @__PURE__ */ React.createElement("button", {
|
|
1007
1022
|
type: "button",
|
|
1008
1023
|
className: "tsh-icon tsh-danger",
|
|
@@ -1013,6 +1028,12 @@ function ShareRow({ share }) {
|
|
|
1013
1028
|
}, /* @__PURE__ */ React.createElement(Stop, {
|
|
1014
1029
|
size: 15
|
|
1015
1030
|
}))));
|
|
1031
|
+
const SwipeRow = pi.ui.SwipeRow;
|
|
1032
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1033
|
+
className: "tsh-item"
|
|
1034
|
+
}, SwipeRow ? /* @__PURE__ */ React.createElement(SwipeRow, {
|
|
1035
|
+
actions: [{ key: "stop", label: t("stop"), danger: true, run: () => void stop() }]
|
|
1036
|
+
}, content) : content, menu);
|
|
1016
1037
|
}
|
|
1017
1038
|
function SharesPage() {
|
|
1018
1039
|
const list = useShares();
|
|
@@ -1053,10 +1074,8 @@ var STYLE = `
|
|
|
1053
1074
|
.tsh-notes { margin: 8px 0 0; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1054
1075
|
.tsh-field { display: flex; flex-direction: column; gap: 6px; }
|
|
1055
1076
|
.tsh-label { font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; color: var(--ta-secondary); }
|
|
1056
|
-
|
|
1057
|
-
.tsh-choice button {
|
|
1058
|
-
.tsh-choice button:hover:not(:disabled) { color: var(--ta-text); }
|
|
1059
|
-
.tsh-choice button.tsh-on { background: var(--ta-card); color: var(--ta-text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
|
|
1077
|
+
/* The page's segmented control (.ta-segmented); only what it lacks: long labels and a disabled segment */
|
|
1078
|
+
.tsh-choice button { min-width: 0; padding: 0 6px; font-family: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1060
1079
|
.tsh-choice button:disabled { opacity: .4; cursor: default; }
|
|
1061
1080
|
.tsh-password { display: flex; gap: 8px; }
|
|
1062
1081
|
.tsh-friends { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
@@ -1080,11 +1099,13 @@ var STYLE = `
|
|
|
1080
1099
|
.tsh-stop { align-self: center; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
|
|
1081
1100
|
.tsh-stop:hover { color: var(--ta-red); background: var(--ta-hover); }
|
|
1082
1101
|
|
|
1083
|
-
/* My shares. */
|
|
1084
|
-
.tsh-page {
|
|
1085
|
-
.tsh-rows { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
|
|
1086
|
-
.tsh-
|
|
1102
|
+
/* My shares: the page fills its place and scrolls, its rows never wider than it. */
|
|
1103
|
+
.tsh-page { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow-y: auto; box-sizing: border-box; padding: 12px 16px 32px; }
|
|
1104
|
+
.tsh-rows { max-width: 720px; margin: 0 auto; padding: 0; list-style: none; display: flex; flex-direction: column; }
|
|
1105
|
+
.tsh-item { --ta-swipe-bg: var(--ta-main); min-width: 0; border-radius: 10px; overflow: hidden; }
|
|
1106
|
+
.tsh-row { display: flex; align-items: center; gap: 4px; min-width: 0; padding-right: 6px; border-radius: 10px; transition: background 120ms, opacity 200ms; }
|
|
1087
1107
|
.tsh-row:hover { background: var(--ta-hover); }
|
|
1108
|
+
.tsh-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
1088
1109
|
.tsh-tile { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; background: var(--ta-green); }
|
|
1089
1110
|
.tsh-tile-password { background: var(--ta-yellow); }
|
|
1090
1111
|
.tsh-tile-self { background: var(--ta-blue); }
|
|
@@ -1092,7 +1113,11 @@ var STYLE = `
|
|
|
1092
1113
|
.tsh-row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1093
1114
|
.tsh-row-line { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1094
1115
|
.tsh-row-actions { flex: none; display: flex; gap: 2px; opacity: .75; }
|
|
1095
|
-
.tsh-row:hover .tsh-row-actions { opacity: 1; }
|
|
1116
|
+
.tsh-row:hover .tsh-row-actions, .tsh-row:focus-within .tsh-row-actions { opacity: 1; }
|
|
1117
|
+
:root[data-touch] .tsh-row:hover { background: none; }
|
|
1118
|
+
:root[data-handheld] .tsh-item { border-radius: 0; }
|
|
1119
|
+
:root[data-touch] .tsh-row-main { padding: 12px 8px; }
|
|
1120
|
+
:root[data-touch] .tsh-row-main:active { background: var(--ta-hover); }
|
|
1096
1121
|
.tsh-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--ta-secondary); cursor: pointer; }
|
|
1097
1122
|
.tsh-icon:hover:not(:disabled) { background: var(--ta-hover-strong); color: var(--ta-text); }
|
|
1098
1123
|
.tsh-icon.tsh-danger:hover:not(:disabled) { color: var(--ta-red); }
|
|
@@ -1128,7 +1153,7 @@ var STYLE = `
|
|
|
1128
1153
|
.tsh-image { display: block; max-width: 100%; margin: 0 auto; border-radius: 10px; }
|
|
1129
1154
|
.tsh-plain { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--ta-code); font-family: var(--ta-mono); font-size: calc(12px * var(--ta-font-scale)); white-space: pre-wrap; word-break: break-word; }
|
|
1130
1155
|
.tsh-download { margin: 20vh auto 0; display: flex; width: fit-content; text-decoration: none; }
|
|
1131
|
-
@media (prefers-reduced-motion: reduce) { .tsh-row
|
|
1156
|
+
@media (prefers-reduced-motion: reduce) { .tsh-row { transition: none; } }
|
|
1132
1157
|
`;
|
|
1133
1158
|
function injectStyle() {
|
|
1134
1159
|
const element = document.createElement("style");
|