@celljs/ta-rooms 4.18.0 → 4.20.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/extension/index.mjs +16 -0
- package/host/index.mjs +1608 -6
- package/package.json +4 -4
- package/web/index.js +48 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-rooms",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.20.0",
|
|
4
4
|
"description": "A pi package for Ta: rooms shared with other Ta through the relay, end to end: who asks to join and the owner's answer, your rooms and their members, your Ta friends, and links that invite",
|
|
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.20.0",
|
|
31
|
+
"@celljs/ta-relay": "4.20.0",
|
|
32
|
+
"@celljs/ta-web": "4.20.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -37,6 +37,37 @@ var RelayBytes;
|
|
|
37
37
|
RelayBytes2.concat = concat;
|
|
38
38
|
})(RelayBytes || (RelayBytes = {}));
|
|
39
39
|
|
|
40
|
+
// ../ta-relay/esm/common/relay-protocol.js
|
|
41
|
+
var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
|
|
42
|
+
var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
|
|
43
|
+
var OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
|
|
44
|
+
<script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
|
|
45
|
+
var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
46
|
+
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
47
|
+
<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
|
|
48
|
+
<p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
|
|
49
|
+
var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
50
|
+
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
51
|
+
<h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
|
|
52
|
+
<p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
|
|
53
|
+
var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
|
|
54
|
+
var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
|
|
55
|
+
var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
|
|
56
|
+
var RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
|
|
57
|
+
var RelayCloseCode;
|
|
58
|
+
(function(RelayCloseCode2) {
|
|
59
|
+
RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
|
|
60
|
+
RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
|
|
61
|
+
RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
|
|
62
|
+
RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
|
|
63
|
+
RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
|
|
64
|
+
RelayCloseCode2[RelayCloseCode2["TIMEOUT"] = 4408] = "TIMEOUT";
|
|
65
|
+
})(RelayCloseCode || (RelayCloseCode = {}));
|
|
66
|
+
var RELAY_ROOM_PATH = "/r";
|
|
67
|
+
var RELAY_HUB_MAX_VALUE = 96 * 1024;
|
|
68
|
+
var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
|
|
69
|
+
var RELAY_PICTURE_MAX_CHARS = 16 * 1024;
|
|
70
|
+
|
|
40
71
|
// ../ta-relay/esm/common/relay-identity.js
|
|
41
72
|
var encoder = new TextEncoder;
|
|
42
73
|
var decoder = new TextDecoder;
|
|
@@ -126,6 +157,10 @@ var RelayIdentityUtil;
|
|
|
126
157
|
return typeof look === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(look);
|
|
127
158
|
}
|
|
128
159
|
RelayIdentityUtil2.isLook = isLook;
|
|
160
|
+
function isPicture(picture) {
|
|
161
|
+
return typeof picture === "string" && picture.length <= RELAY_PICTURE_MAX_CHARS && /^data:image\/(png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/.test(picture);
|
|
162
|
+
}
|
|
163
|
+
RelayIdentityUtil2.isPicture = isPicture;
|
|
129
164
|
function withLook(value, look) {
|
|
130
165
|
const { look: _, ...rest } = value;
|
|
131
166
|
return isLook(look) ? { ...rest, look } : rest;
|
|
@@ -158,36 +193,6 @@ var RelayIdentityUtil;
|
|
|
158
193
|
}
|
|
159
194
|
})(RelayIdentityUtil || (RelayIdentityUtil = {}));
|
|
160
195
|
|
|
161
|
-
// ../ta-relay/esm/common/relay-protocol.js
|
|
162
|
-
var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
|
|
163
|
-
var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
|
|
164
|
-
var OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
|
|
165
|
-
<script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
|
|
166
|
-
var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
167
|
-
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
168
|
-
<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
|
|
169
|
-
<p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
|
|
170
|
-
var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
171
|
-
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
172
|
-
<h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
|
|
173
|
-
<p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
|
|
174
|
-
var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
|
|
175
|
-
var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
|
|
176
|
-
var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
|
|
177
|
-
var RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
|
|
178
|
-
var RelayCloseCode;
|
|
179
|
-
(function(RelayCloseCode2) {
|
|
180
|
-
RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
|
|
181
|
-
RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
|
|
182
|
-
RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
|
|
183
|
-
RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
|
|
184
|
-
RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
|
|
185
|
-
RelayCloseCode2[RelayCloseCode2["TIMEOUT"] = 4408] = "TIMEOUT";
|
|
186
|
-
})(RelayCloseCode || (RelayCloseCode = {}));
|
|
187
|
-
var RELAY_ROOM_PATH = "/r";
|
|
188
|
-
var RELAY_HUB_MAX_VALUE = 96 * 1024;
|
|
189
|
-
var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
|
|
190
|
-
|
|
191
196
|
// ../ta-relay/esm/common/relay-hub-util.js
|
|
192
197
|
var RelayHubUtil;
|
|
193
198
|
(function(RelayHubUtil2) {
|
|
@@ -1647,7 +1652,7 @@ function useJoining(room) {
|
|
|
1647
1652
|
}
|
|
1648
1653
|
function openRoom(id, direct = false) {
|
|
1649
1654
|
book.set({ opened: id, direct: direct || !!pi.ui.doubleInChats });
|
|
1650
|
-
pi.ui.showView(ROOMS_VIEW);
|
|
1655
|
+
return pi.ui.showView(ROOMS_VIEW);
|
|
1651
1656
|
}
|
|
1652
1657
|
function useOpened() {
|
|
1653
1658
|
const { rooms: list, opened } = useBook();
|
|
@@ -3065,6 +3070,7 @@ function registerTasks() {
|
|
|
3065
3070
|
}
|
|
3066
3071
|
|
|
3067
3072
|
// web-src/room-view.tsx
|
|
3073
|
+
var CHANNEL_MEMBERS_VIEW = "@celljs/ta-channels/members";
|
|
3068
3074
|
var RUN_MS = 5 * 60 * 1000;
|
|
3069
3075
|
var PAUSE_MS = 15 * 60 * 1000;
|
|
3070
3076
|
async function confirmThen(title, hint, label, action) {
|
|
@@ -3095,6 +3101,14 @@ function time(at) {
|
|
|
3095
3101
|
}
|
|
3096
3102
|
function RoomHead({ room }) {
|
|
3097
3103
|
const shown = !!pi.ui.useView?.(MEMBERS_VIEW)?.shown;
|
|
3104
|
+
const channelMembers = !!pi.ui.useView?.(CHANNEL_MEMBERS_VIEW)?.shown;
|
|
3105
|
+
const follow = React.useRef(channelMembers);
|
|
3106
|
+
follow.current = channelMembers;
|
|
3107
|
+
React.useEffect(() => {
|
|
3108
|
+
if (room.id && follow.current) {
|
|
3109
|
+
pi.ui.showView(MEMBERS_VIEW);
|
|
3110
|
+
}
|
|
3111
|
+
}, [room.id]);
|
|
3098
3112
|
const page = usePageOf(room);
|
|
3099
3113
|
const online = room.members.filter((member) => member.online).length;
|
|
3100
3114
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -4264,7 +4278,9 @@ function SubPage({ title, onBack, children }) {
|
|
|
4264
4278
|
}
|
|
4265
4279
|
function MembersView() {
|
|
4266
4280
|
const { identity } = useBook();
|
|
4267
|
-
const
|
|
4281
|
+
const shownPage = !!pi.ui.useView?.(ROOMS_VIEW)?.shown;
|
|
4282
|
+
const opened = useOpened();
|
|
4283
|
+
const room = shownPage ? opened : undefined;
|
|
4268
4284
|
const agents = useAgents(room ?? { status: "gone" });
|
|
4269
4285
|
const joining = useJoining(room ?? { id: "", status: "gone", members: [] });
|
|
4270
4286
|
const { apps } = useRoomApps(room);
|