@celljs/ta-relay 4.16.0 → 4.18.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/esm/common/index.d.ts +2 -0
- package/esm/common/index.js +2 -0
- package/esm/common/relay-content.d.ts +13 -0
- package/esm/common/relay-content.js +42 -0
- package/esm/common/relay-conversation.d.ts +14 -0
- package/esm/common/relay-faces.d.ts +1 -1
- package/esm/common/relay-faces.js +56 -1
- package/esm/common/relay-files.d.ts +14 -3
- package/esm/common/relay-files.js +41 -16
- package/esm/common/relay-friend-sends.d.ts +64 -0
- package/esm/common/relay-friend-sends.js +126 -0
- package/esm/common/relay-group-invites.d.ts +76 -0
- package/esm/common/relay-group-invites.js +163 -0
- package/esm/common/relay-hub.js +2 -2
- package/esm/common/relay-hubs-identity.d.ts +36 -0
- package/esm/common/relay-hubs-identity.js +156 -0
- package/esm/common/relay-hubs-protocol.d.ts +7 -1
- package/esm/common/relay-hubs-util.d.ts +11 -0
- package/esm/common/relay-hubs-util.js +74 -0
- package/esm/common/relay-hubs.d.ts +36 -44
- package/esm/common/relay-hubs.js +95 -235
- package/esm/common/relay-open-in-ta.d.ts +11 -0
- package/esm/common/relay-open-in-ta.js +34 -0
- package/esm/common/relay-protocol.d.ts +11 -2
- package/esm/common/relay-protocol.js +18 -2
- package/esm/common/relay-spot.d.ts +15 -3
- package/esm/common/relay-spot.js +17 -5
- package/esm/guest/guest-i18n.d.ts +1 -0
- package/esm/guest/guest-i18n.js +45 -41
- package/esm/guest/guest-style.d.ts +1 -1
- package/esm/guest/guest-style.js +2 -0
- package/esm/guest/guest.js +7 -2
- package/esm/join/join-i18n.d.ts +1 -0
- package/esm/join/join-i18n.js +4 -0
- package/esm/join/join.js +4 -1
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/relay-files-host.d.ts +2 -0
- package/esm/node/relay-files-host.js +24 -5
- package/esm/node/relay-memory-storage.d.ts +26 -0
- package/esm/node/relay-memory-storage.js +60 -0
- package/esm/node/relay-server.d.ts +14 -26
- package/esm/node/relay-server.js +33 -60
- package/esm/node/relay-store.js +4 -4
- package/esm/node/relays-file.d.ts +27 -0
- package/esm/node/relays-file.js +59 -4
- package/esm/viewer/viewer-i18n.d.ts +1 -0
- package/esm/viewer/viewer-i18n.js +4 -0
- package/esm/viewer/viewer-style.d.ts +1 -1
- package/esm/viewer/viewer-style.js +2 -0
- package/esm/viewer/viewer.js +36 -2
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/relay-content.d.ts +13 -0
- package/lib/common/relay-content.js +43 -1
- package/lib/common/relay-conversation.d.ts +14 -0
- package/lib/common/relay-faces.d.ts +1 -1
- package/lib/common/relay-faces.js +56 -1
- package/lib/common/relay-files.d.ts +14 -3
- package/lib/common/relay-files.js +42 -17
- package/lib/common/relay-friend-sends.d.ts +65 -0
- package/lib/common/relay-friend-sends.js +130 -0
- package/lib/common/relay-group-invites.d.ts +77 -0
- package/lib/common/relay-group-invites.js +167 -0
- package/lib/common/relay-hub.js +1 -1
- package/lib/common/relay-hubs-identity.d.ts +37 -0
- package/lib/common/relay-hubs-identity.js +160 -0
- package/lib/common/relay-hubs-protocol.d.ts +7 -1
- package/lib/common/relay-hubs-util.d.ts +12 -0
- package/lib/common/relay-hubs-util.js +77 -0
- package/lib/common/relay-hubs.d.ts +36 -44
- package/lib/common/relay-hubs.js +94 -234
- package/lib/common/relay-open-in-ta.d.ts +12 -0
- package/lib/common/relay-open-in-ta.js +37 -0
- package/lib/common/relay-protocol.d.ts +11 -2
- package/lib/common/relay-protocol.js +20 -3
- package/lib/common/relay-spot.d.ts +15 -3
- package/lib/common/relay-spot.js +17 -5
- package/lib/guest/guest-i18n.d.ts +1 -0
- package/lib/guest/guest-i18n.js +45 -41
- package/lib/guest/guest-style.d.ts +1 -1
- package/lib/guest/guest-style.js +2 -0
- package/lib/guest/guest.js +7 -2
- package/lib/join/join-i18n.d.ts +1 -0
- package/lib/join/join-i18n.js +4 -0
- package/lib/join/join.js +4 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/relay-files-host.d.ts +2 -0
- package/lib/node/relay-files-host.js +23 -4
- package/lib/node/relay-memory-storage.d.ts +27 -0
- package/lib/node/relay-memory-storage.js +65 -0
- package/lib/node/relay-server.d.ts +14 -26
- package/lib/node/relay-server.js +34 -61
- package/lib/node/relay-store.js +3 -3
- package/lib/node/relays-file.d.ts +27 -0
- package/lib/node/relays-file.js +58 -3
- package/lib/viewer/viewer-i18n.d.ts +1 -0
- package/lib/viewer/viewer-i18n.js +4 -0
- package/lib/viewer/viewer-style.d.ts +1 -1
- package/lib/viewer/viewer-style.js +2 -0
- package/lib/viewer/viewer.js +35 -1
- package/package.json +3 -2
- package/viewer/join.html +12 -3
- package/viewer/page.html +18 -9
- package/viewer/room.html +21 -10
package/lib/common/relay-spot.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RelaySpot = exports.RelaySpotTries = exports.RelaySpotCloseCode = exports.RELAY_SPOT_TRIES_MS = exports.RELAY_SPOT_TRIES = exports.RELAY_SPOT_MESSAGE = exports.RELAY_SPOT_MAX = exports.RELAY_SPOT_JOIN_MS = exports.RELAY_SPOT_PATH = void 0;
|
|
4
|
+
const relay_bytes_1 = require("./relay-bytes");
|
|
4
5
|
const relay_protocol_1 = require("./relay-protocol");
|
|
5
6
|
/**
|
|
6
7
|
* A spot (docs/design/ta-nearby.md 2.2): the Ta that typed the same code of six digits, on networks that keep them
|
|
@@ -28,6 +29,8 @@ var RelaySpotCloseCode;
|
|
|
28
29
|
RelaySpotCloseCode[RelaySpotCloseCode["FULL"] = 4429] = "FULL";
|
|
29
30
|
/** This address tried too many codes nobody opened: it waits (RelaySpotTries). */
|
|
30
31
|
RelaySpotCloseCode[RelaySpotCloseCode["TRIES"] = 4428] = "TRIES";
|
|
32
|
+
/** Opened already, by one whose key this one does not hold: a new code is needed. Counted as a failure. */
|
|
33
|
+
RelaySpotCloseCode[RelaySpotCloseCode["TAKEN"] = 4409] = "TAKEN";
|
|
31
34
|
})(RelaySpotCloseCode || (exports.RelaySpotCloseCode = RelaySpotCloseCode = {}));
|
|
32
35
|
/**
|
|
33
36
|
* The codes nobody opened that one address tried lately (docs/design/ta-nearby.md 2.2): six digits are a million
|
|
@@ -126,7 +129,7 @@ class RelaySpot {
|
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
enter(socket, message) {
|
|
129
|
-
var _a;
|
|
132
|
+
var _a, _b, _c, _d;
|
|
130
133
|
if (message.t !== 'open' && message.t !== 'join') {
|
|
131
134
|
socket.close(RelaySpotCloseCode.BAD, 'Open or join first.');
|
|
132
135
|
return;
|
|
@@ -134,19 +137,27 @@ class RelaySpot {
|
|
|
134
137
|
const others = this.others(socket);
|
|
135
138
|
const now = this.now();
|
|
136
139
|
const opened = others.length ? Math.min(...others.map(other => { var _a; var _b; return (_b = (_a = other.who) === null || _a === void 0 ? void 0 : _a.opened) !== null && _b !== void 0 ? _b : now; })) : now;
|
|
140
|
+
const key = (_b = (_a = others.find(other => { var _a; return (_a = other.who) === null || _a === void 0 ? void 0 : _a.k; })) === null || _a === void 0 ? void 0 : _a.who) === null || _b === void 0 ? void 0 : _b.k;
|
|
141
|
+
const back = message.t === 'open' && !!key && !!message.k && message.k === key;
|
|
137
142
|
if (!others.length && message.t === 'join') {
|
|
138
|
-
(
|
|
143
|
+
(_c = this.missed) === null || _c === void 0 ? void 0 : _c.call(this, socket);
|
|
139
144
|
socket.close(RelaySpotCloseCode.NONE, 'No such spot.');
|
|
140
145
|
}
|
|
141
|
-
else if (
|
|
146
|
+
else if (others.length && message.t === 'open' && !back) {
|
|
147
|
+
(_d = this.missed) === null || _d === void 0 ? void 0 : _d.call(this, socket);
|
|
148
|
+
socket.close(RelaySpotCloseCode.TAKEN, 'Opened already.');
|
|
149
|
+
}
|
|
150
|
+
else if (!back && now - opened > exports.RELAY_SPOT_JOIN_MS) {
|
|
142
151
|
socket.close(RelaySpotCloseCode.LATE, 'Too late to come in.');
|
|
143
152
|
}
|
|
144
153
|
else if (others.length >= exports.RELAY_SPOT_MAX) {
|
|
145
154
|
socket.close(RelaySpotCloseCode.FULL, 'Full.');
|
|
146
155
|
}
|
|
147
156
|
else {
|
|
148
|
-
|
|
149
|
-
socket.
|
|
157
|
+
const k = key !== null && key !== void 0 ? key : relay_bytes_1.RelayBytes.toBase64(relay_bytes_1.RelayBytes.random(18));
|
|
158
|
+
socket.who = { opened, k };
|
|
159
|
+
const mine = message.t === 'open';
|
|
160
|
+
socket.send(JSON.stringify({ t: 'ready', opened, ...(mine ? { k } : {}) }));
|
|
150
161
|
}
|
|
151
162
|
}
|
|
152
163
|
/** The others in the spot. */
|
|
@@ -159,6 +170,7 @@ class RelaySpot {
|
|
|
159
170
|
const id = (value) => typeof value === 'string' && value.length > 0 && value.length <= 64;
|
|
160
171
|
switch (data.t) {
|
|
161
172
|
case 'open':
|
|
173
|
+
return id(data.k) ? { t: 'open', k: data.k } : { t: 'open' };
|
|
162
174
|
case 'join':
|
|
163
175
|
case 'bye':
|
|
164
176
|
return { t: data.t };
|
package/lib/guest/guest-i18n.js
CHANGED
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GuestI18n = exports.GUEST_WORDS = void 0;
|
|
4
4
|
const page_language_1 = require("../common/page-language");
|
|
5
5
|
const zh = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
openInTa: '在 Ta 中打开',
|
|
7
|
+
title: 'Ta 群聊',
|
|
8
|
+
invalid: '这不是一个完整的 Ta 群聊邀请链接,请检查是否复制完整。',
|
|
8
9
|
inTa: '这是{by}在 Ta 里的加好友链接,要在 Ta 里打开:用 Ta 扫码,或把链接粘贴到 Ta 的快捷打开。',
|
|
9
10
|
invited: '{by}邀请你加入',
|
|
10
|
-
joinHint: '
|
|
11
|
+
joinHint: '群主同意后,就能在这里和大家聊天。',
|
|
11
12
|
name: '你的名字',
|
|
12
13
|
namePlaceholder: '大家看到的名字',
|
|
13
14
|
join: '申请加入',
|
|
@@ -19,16 +20,16 @@ const zh = {
|
|
|
19
20
|
cancel: '取消申请',
|
|
20
21
|
refused: '{by}没有同意你加入',
|
|
21
22
|
again: '再申请一次',
|
|
22
|
-
removed: '
|
|
23
|
-
closed: '
|
|
24
|
-
inviteGone: '
|
|
25
|
-
own: '
|
|
23
|
+
removed: '你已被移出这个群聊',
|
|
24
|
+
closed: '这个群聊已被群主解散',
|
|
25
|
+
inviteGone: '邀请已失效,请向群主要一个新链接',
|
|
26
|
+
own: '这是你自己的群聊,请在 Ta 里打开。',
|
|
26
27
|
connecting: '连接中…',
|
|
27
28
|
online: '另有 {n} 人在线',
|
|
28
29
|
nobody: '其他人都不在线',
|
|
29
30
|
onlineNow: '在线',
|
|
30
31
|
members: '成员',
|
|
31
|
-
owner: '
|
|
32
|
+
owner: '群主',
|
|
32
33
|
you: '我',
|
|
33
34
|
guest: '网页访客',
|
|
34
35
|
doubleOf: '{name}的分身',
|
|
@@ -36,10 +37,10 @@ const zh = {
|
|
|
36
37
|
task: '任务',
|
|
37
38
|
agentOf: '{name}的智能体',
|
|
38
39
|
rename: '修改我的名字',
|
|
39
|
-
leave: '
|
|
40
|
+
leave: '退出群聊',
|
|
40
41
|
leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
|
|
41
|
-
game: '
|
|
42
|
-
empty: '
|
|
42
|
+
game: '这个群里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
|
|
43
|
+
empty: '还没有人说话。只有群里的人能看到,中继保存的是密文。',
|
|
43
44
|
placeholder: '发消息',
|
|
44
45
|
send: '发送',
|
|
45
46
|
failed: '没发出去:{reason}',
|
|
@@ -47,11 +48,12 @@ const zh = {
|
|
|
47
48
|
close: '关闭',
|
|
48
49
|
};
|
|
49
50
|
const zhTw = {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
openInTa: '在 Ta 中開啟',
|
|
52
|
+
title: 'Ta 群聊',
|
|
53
|
+
invalid: '這不是一個完整的 Ta 群聊邀請連結,請檢查是否複製完整。',
|
|
52
54
|
inTa: '這是{by}在 Ta 裡的加好友連結,要在 Ta 裡開啟:用 Ta 掃碼,或把連結貼上到 Ta 的快捷開啟。',
|
|
53
55
|
invited: '{by}邀請你加入',
|
|
54
|
-
joinHint: '
|
|
56
|
+
joinHint: '群主同意後,就能在這裡和大家聊天。',
|
|
55
57
|
name: '你的名字',
|
|
56
58
|
namePlaceholder: '大家看到的名字',
|
|
57
59
|
join: '申請加入',
|
|
@@ -63,16 +65,16 @@ const zhTw = {
|
|
|
63
65
|
cancel: '取消申請',
|
|
64
66
|
refused: '{by}沒有同意你加入',
|
|
65
67
|
again: '再申請一次',
|
|
66
|
-
removed: '
|
|
67
|
-
closed: '
|
|
68
|
-
inviteGone: '
|
|
69
|
-
own: '
|
|
68
|
+
removed: '你已被移出這個群聊',
|
|
69
|
+
closed: '這個群聊已被群主解散',
|
|
70
|
+
inviteGone: '邀請已失效,請向群主要一個新連結',
|
|
71
|
+
own: '這是你自己的群聊,請在 Ta 裡開啟。',
|
|
70
72
|
connecting: '連線中…',
|
|
71
73
|
online: '另有 {n} 人線上',
|
|
72
74
|
nobody: '其他人都不線上',
|
|
73
75
|
onlineNow: '線上',
|
|
74
76
|
members: '成員',
|
|
75
|
-
owner: '
|
|
77
|
+
owner: '群主',
|
|
76
78
|
you: '我',
|
|
77
79
|
guest: '網頁訪客',
|
|
78
80
|
doubleOf: '{name}的分身',
|
|
@@ -80,10 +82,10 @@ const zhTw = {
|
|
|
80
82
|
task: '任務',
|
|
81
83
|
agentOf: '{name}的智慧體',
|
|
82
84
|
rename: '修改我的名字',
|
|
83
|
-
leave: '
|
|
85
|
+
leave: '退出群聊',
|
|
84
86
|
leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
|
|
85
|
-
game: '
|
|
86
|
-
empty: '
|
|
87
|
+
game: '這個群裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
|
|
88
|
+
empty: '還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。',
|
|
87
89
|
placeholder: '發訊息',
|
|
88
90
|
send: '傳送',
|
|
89
91
|
failed: '沒發出去:{reason}',
|
|
@@ -91,8 +93,9 @@ const zhTw = {
|
|
|
91
93
|
close: '關閉',
|
|
92
94
|
};
|
|
93
95
|
const en = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
openInTa: 'Open in Ta',
|
|
97
|
+
title: 'A group chat of Ta',
|
|
98
|
+
invalid: 'This is not a whole link that invites into a group chat of Ta: check it was copied in full.',
|
|
96
99
|
inTa: 'This link of {by} adds them as a friend in Ta, and opens in Ta: scan it with Ta, or paste it in Quick open of Ta.',
|
|
97
100
|
invited: '{by} invites you to join',
|
|
98
101
|
joinHint: 'Once the owner lets you in, you chat with everyone here.',
|
|
@@ -107,10 +110,10 @@ const en = {
|
|
|
107
110
|
cancel: 'Cancel',
|
|
108
111
|
refused: '{by} did not let you in',
|
|
109
112
|
again: 'Ask again',
|
|
110
|
-
removed: 'You were taken out of this
|
|
111
|
-
closed: 'This
|
|
113
|
+
removed: 'You were taken out of this group chat',
|
|
114
|
+
closed: 'This group chat was closed by its owner',
|
|
112
115
|
inviteGone: 'The invitation no longer works: ask the owner for a new link',
|
|
113
|
-
own: 'This is a
|
|
116
|
+
own: 'This is a group chat of your own: open it in Ta.',
|
|
114
117
|
connecting: 'Connecting…',
|
|
115
118
|
online: '{n} more online',
|
|
116
119
|
nobody: 'Nobody else online',
|
|
@@ -124,10 +127,10 @@ const en = {
|
|
|
124
127
|
task: 'Task',
|
|
125
128
|
agentOf: "{name}'s agent",
|
|
126
129
|
rename: 'Change my name',
|
|
127
|
-
leave: 'Leave the
|
|
130
|
+
leave: 'Leave the group chat',
|
|
128
131
|
leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
|
|
129
|
-
game: 'This
|
|
130
|
-
empty: 'Nothing said yet. Only those in the
|
|
132
|
+
game: 'This group chat plays a game of Ta, which takes Ta to play; here you chat.',
|
|
133
|
+
empty: 'Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.',
|
|
131
134
|
placeholder: 'Message',
|
|
132
135
|
send: 'Send',
|
|
133
136
|
failed: 'Not sent: {reason}',
|
|
@@ -135,11 +138,12 @@ const en = {
|
|
|
135
138
|
close: 'Close',
|
|
136
139
|
};
|
|
137
140
|
const ja = {
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
openInTa: 'Ta で開く',
|
|
142
|
+
title: 'Ta のグループチャット',
|
|
143
|
+
invalid: 'これは Ta グループチャットへの完全な招待リンクではありません。全体がコピーされているか確認してください。',
|
|
140
144
|
inTa: 'これは {by} さんが Ta で友だちを追加するリンクで、Ta で開きます。Ta でスキャンするか、Ta のクイックオープンにペーストしてください。',
|
|
141
145
|
invited: '{by}さんがあなたを招待しています',
|
|
142
|
-
joinHint: '
|
|
146
|
+
joinHint: 'グループチャット管理者が承認すると、ここでみんなとチャットできます。',
|
|
143
147
|
name: 'あなたの名前',
|
|
144
148
|
namePlaceholder: 'みんなに見える名前',
|
|
145
149
|
join: '参加をリクエスト',
|
|
@@ -151,16 +155,16 @@ const ja = {
|
|
|
151
155
|
cancel: 'キャンセル',
|
|
152
156
|
refused: '{by}さんはあなたの参加を承認しませんでした',
|
|
153
157
|
again: 'もう一度リクエスト',
|
|
154
|
-
removed: '
|
|
155
|
-
closed: '
|
|
156
|
-
inviteGone: '
|
|
157
|
-
own: '
|
|
158
|
+
removed: 'このグループチャットから削除されました',
|
|
159
|
+
closed: 'このグループチャットはグループチャット管理者に閉じられました',
|
|
160
|
+
inviteGone: '招待が無効です。グループチャット管理者に新しいリンクをリクエストしてください',
|
|
161
|
+
own: 'これはあなた自身のグループチャットです。Ta で開いてください。',
|
|
158
162
|
connecting: '接続中…',
|
|
159
163
|
online: '他に {n} 人がオンライン',
|
|
160
164
|
nobody: '他に誰もオンラインではありません',
|
|
161
165
|
onlineNow: 'オンライン',
|
|
162
166
|
members: 'メンバー',
|
|
163
|
-
owner: '
|
|
167
|
+
owner: 'グループチャット管理者',
|
|
164
168
|
you: '私',
|
|
165
169
|
guest: 'ウェブゲスト',
|
|
166
170
|
doubleOf: '{name}の分身',
|
|
@@ -168,10 +172,10 @@ const ja = {
|
|
|
168
172
|
task: 'タスク',
|
|
169
173
|
agentOf: '{name}のエージェント',
|
|
170
174
|
rename: '名前を変更',
|
|
171
|
-
leave: '
|
|
175
|
+
leave: 'グループチャットを退出',
|
|
172
176
|
leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
|
|
173
|
-
game: '
|
|
174
|
-
empty: '
|
|
177
|
+
game: 'このグループチャットには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
|
|
178
|
+
empty: 'まだ誰も話していません。グループ内の人だけが見ることができ、リレーは暗号化されて保存されます。',
|
|
175
179
|
placeholder: 'メッセージ',
|
|
176
180
|
send: '送信',
|
|
177
181
|
failed: '送信されませんでした:{reason}',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const GUEST_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--mine:#e7f6ec;--mine-fg:#14532d;--code:#f6f6f6;--accent:#16a34a;--red:#dc2626;--radius:16px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#262626;--mine:#1f3a2a;--mine-fg:#d1fae5;--code:#232323;--accent:#4ade80;--red:#f87171}}\n*{box-sizing:border-box}\nhtml,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased;overscroll-behavior:none}\nbutton{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}\n.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}\n.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}\n.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}\n.heading{flex:1;min-width:0;display:flex;flex-direction:column}\n.heading b{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.heading b span{color:var(--muted);font-weight:500;margin-left:4px}\n.heading small{font-size:11.5px;line-height:15px;color:var(--accent)}\n.heading small.quiet{color:var(--muted)}\n.icon{flex:none;width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:10px;background:none;font-size:20px;line-height:1;color:var(--muted)}\n.icon:hover{background:var(--soft);color:var(--fg)}\n.center{flex:1;display:flex;flex-direction:column;justify-content:center;padding:24px 22px calc(32px + env(safe-area-inset-bottom));max-width:440px;width:100%;margin:0 auto;gap:14px}\n.card-face{align-self:center}\n.lead{margin:0;text-align:center;color:var(--muted);font-size:14px}\n.room-name{margin:0;text-align:center;font-size:21px;font-weight:600;line-height:1.35;word-break:break-word}\n.hint{margin:0;text-align:center;color:var(--muted);font-size:13px}\n.small{margin:0;color:var(--faint);font-size:12px;line-height:1.55;text-align:center}\nlabel.field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted);margin-top:6px}\ninput.text{font:inherit;font-size:16px;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:11px 13px;outline:none}\ninput.text:focus{border-color:var(--accent)}\n.primary{border:0;border-radius:12px;padding:12px 16px;background:#16a34a;color:#fff;font-weight:600;font-size:15px}\n.primary:disabled{opacity:.55;cursor:default}\n.plain{border:0;background:none;color:var(--muted);font-size:13.5px;padding:8px}\n.plain:hover{color:var(--fg)}\n.danger{color:var(--red)}\n.error{margin:0;text-align:center;color:var(--red);font-size:13px}\n.spin{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);animation:spin .9s linear infinite;align-self:center}\n@keyframes spin{to{transform:rotate(360deg)}}\n.face{flex:none;display:inline-flex;position:relative;user-select:none}\n.face svg{display:block;overflow:visible}\n.ta-face-eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}\n.face[data-face=\"1\"] .ta-face-eyes,.face[data-face=\"5\"] .ta-face-eyes,.face[data-face=\"9\"] .ta-face-eyes,.face[data-face=\"13\"] .ta-face-eyes{animation-delay:-1.7s}\n.face[data-face=\"2\"] .ta-face-eyes,.face[data-face=\"6\"] .ta-face-eyes,.face[data-face=\"10\"] .ta-face-eyes,.face[data-face=\"14\"] .ta-face-eyes{animation-delay:-3.1s}\n.face[data-face=\"3\"] .ta-face-eyes,.face[data-face=\"7\"] .ta-face-eyes,.face[data-face=\"11\"] .ta-face-eyes,.face[data-face=\"15\"] .ta-face-eyes{animation-delay:-4.4s}\n@keyframes blink{0%,94%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}\n@media (prefers-reduced-motion:reduce){.face *{animation:none!important}}\n@media (prefers-color-scheme:dark){.face[data-face=\"11\"] .ta-face-body>g>circle{fill:#4a4a52}}\n.face i{position:absolute;right:-1px;bottom:-1px;width:28%;height:28%;min-width:7px;min-height:7px;border-radius:50%;border:2px solid var(--bg);background:var(--faint)}\n.face i.on{background:var(--accent)}\n.banner{flex:none;margin:10px 14px 0;padding:8px 12px;border-radius:12px;background:var(--soft);color:var(--muted);font-size:12.5px;line-height:1.5}\n.list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:none;padding:10px 14px 12px;display:flex;flex-direction:column;gap:4px}\n.empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}\n.when{align-self:center;margin:14px 0 6px;color:var(--faint);font-size:11.5px;font-variant-numeric:tabular-nums}\n.msg{display:flex;align-items:flex-start;gap:10px}\n.msg.first{margin-top:10px}\n.msg .slot{width:32px;flex:none;display:flex;justify-content:center}\n.msg .col{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 84px)}\n.msg .who{display:flex;align-items:center;gap:6px;margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}\n.msg.double .bubble{border:1px dashed var(--soft);background:none}\n.bubble{min-width:0;max-width:100%;padding:8px 13px;border-radius:5px var(--radius) var(--radius) var(--radius);background:var(--bubble);word-break:break-word}\n.mine{display:flex;justify-content:flex-end;margin:6px 0 2px}\n.mine .bubble{max-width:78%;border-radius:var(--radius) 5px var(--radius) var(--radius);background:var(--mine);color:var(--mine-fg)}\n.bubble>:first-child{margin-top:0}.bubble>:last-child{margin-bottom:0}\n.bubble p{margin:0 0 .6em}\n.bubble ul,.bubble ol{margin:0 0 .6em;padding-left:1.3em}\n.bubble a{color:inherit;text-decoration:underline;text-underline-offset:2px}\n.bubble code{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--code);padding:1px 4px;border-radius:5px}\n.bubble pre{margin:0 0 .6em;padding:8px 10px;background:var(--code);border-radius:10px;overflow-x:auto}\n.bubble pre code{background:none;padding:0}\n.bubble blockquote{margin:0 0 .6em;padding-left:10px;border-left:3px solid var(--line);color:var(--muted)}\n.failed{align-self:flex-end;color:var(--red);font-size:12px;margin:2px 4px 0}\n.box{flex:none;display:flex;align-items:flex-end;gap:8px;padding:8px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}\n.box textarea{flex:1;min-width:0;resize:none;max-height:160px;font:inherit;font-size:16px;line-height:1.45;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:18px;padding:8px 14px;outline:none}\n.box textarea:focus{border-color:var(--accent)}\n.box .primary{flex:none;border-radius:18px;padding:8px 16px;min-height:40px}\n.foot{flex:none;text-align:center;color:var(--faint);font-size:11px;padding:0 0 6px}\n.sheet{position:fixed;inset:0;z-index:5;display:flex;align-items:flex-end;justify-content:center;background:rgba(0,0,0,.32)}\n.sheet .panel{width:100%;max-width:520px;max-height:80dvh;overflow-y:auto;background:var(--bg);border-radius:18px 18px 0 0;padding:14px 8px calc(14px + env(safe-area-inset-bottom))}\n@media (min-width:700px){.sheet{align-items:center}.sheet .panel{border-radius:18px}}\n.panel h3{margin:4px 14px 8px;font-size:13px;font-weight:500;color:var(--muted)}\n.member{display:flex;align-items:center;gap:10px;padding:8px 12px}\n.member .nm{flex:1;min-width:0;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.tag{flex:none;padding:0 6px;border-radius:6px;background:var(--soft);color:var(--muted);font-size:11px;line-height:18px}\n.member .st{font-size:12px;color:var(--muted)}\n.member .st.on{color:var(--accent)}\n.row{display:block;width:100%;text-align:left;border:0;background:none;padding:12px 14px;border-radius:12px;font-size:14.5px}\n.row:hover{background:var(--soft)}\n.sep{height:1px;margin:6px 12px;background:var(--line)}\n";
|
|
1
|
+
export declare const GUEST_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--mine:#e7f6ec;--mine-fg:#14532d;--code:#f6f6f6;--accent:#16a34a;--red:#dc2626;--radius:16px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#262626;--mine:#1f3a2a;--mine-fg:#d1fae5;--code:#232323;--accent:#4ade80;--red:#f87171}}\n*{box-sizing:border-box}\nhtml,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased;overscroll-behavior:none}\nbutton{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}\n.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}\n.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}\n.open-in-ta{flex:none;display:inline-flex;align-items:center;height:32px;padding:0 14px;border-radius:16px;background:var(--fg);color:var(--bg);font-size:13.5px;font-weight:600;text-decoration:none;white-space:nowrap;-webkit-tap-highlight-color:transparent}\n.open-in-ta:active{opacity:.8}\n.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}\n.heading{flex:1;min-width:0;display:flex;flex-direction:column}\n.heading b{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.heading b span{color:var(--muted);font-weight:500;margin-left:4px}\n.heading small{font-size:11.5px;line-height:15px;color:var(--accent)}\n.heading small.quiet{color:var(--muted)}\n.icon{flex:none;width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:10px;background:none;font-size:20px;line-height:1;color:var(--muted)}\n.icon:hover{background:var(--soft);color:var(--fg)}\n.center{flex:1;display:flex;flex-direction:column;justify-content:center;padding:24px 22px calc(32px + env(safe-area-inset-bottom));max-width:440px;width:100%;margin:0 auto;gap:14px}\n.card-face{align-self:center}\n.lead{margin:0;text-align:center;color:var(--muted);font-size:14px}\n.room-name{margin:0;text-align:center;font-size:21px;font-weight:600;line-height:1.35;word-break:break-word}\n.hint{margin:0;text-align:center;color:var(--muted);font-size:13px}\n.small{margin:0;color:var(--faint);font-size:12px;line-height:1.55;text-align:center}\nlabel.field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted);margin-top:6px}\ninput.text{font:inherit;font-size:16px;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:11px 13px;outline:none}\ninput.text:focus{border-color:var(--accent)}\n.primary{border:0;border-radius:12px;padding:12px 16px;background:#16a34a;color:#fff;font-weight:600;font-size:15px}\n.primary:disabled{opacity:.55;cursor:default}\n.plain{border:0;background:none;color:var(--muted);font-size:13.5px;padding:8px}\n.plain:hover{color:var(--fg)}\n.danger{color:var(--red)}\n.error{margin:0;text-align:center;color:var(--red);font-size:13px}\n.spin{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);animation:spin .9s linear infinite;align-self:center}\n@keyframes spin{to{transform:rotate(360deg)}}\n.face{flex:none;display:inline-flex;position:relative;user-select:none}\n.face svg{display:block;overflow:visible}\n.ta-face-eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}\n.face[data-face=\"1\"] .ta-face-eyes,.face[data-face=\"5\"] .ta-face-eyes,.face[data-face=\"9\"] .ta-face-eyes,.face[data-face=\"13\"] .ta-face-eyes{animation-delay:-1.7s}\n.face[data-face=\"2\"] .ta-face-eyes,.face[data-face=\"6\"] .ta-face-eyes,.face[data-face=\"10\"] .ta-face-eyes,.face[data-face=\"14\"] .ta-face-eyes{animation-delay:-3.1s}\n.face[data-face=\"3\"] .ta-face-eyes,.face[data-face=\"7\"] .ta-face-eyes,.face[data-face=\"11\"] .ta-face-eyes,.face[data-face=\"15\"] .ta-face-eyes{animation-delay:-4.4s}\n@keyframes blink{0%,94%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}\n@media (prefers-reduced-motion:reduce){.face *{animation:none!important}}\n@media (prefers-color-scheme:dark){.face[data-face=\"11\"] .ta-face-body>g>circle{fill:#4a4a52}}\n.face i{position:absolute;right:-1px;bottom:-1px;width:28%;height:28%;min-width:7px;min-height:7px;border-radius:50%;border:2px solid var(--bg);background:var(--faint)}\n.face i.on{background:var(--accent)}\n.banner{flex:none;margin:10px 14px 0;padding:8px 12px;border-radius:12px;background:var(--soft);color:var(--muted);font-size:12.5px;line-height:1.5}\n.list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:none;padding:10px 14px 12px;display:flex;flex-direction:column;gap:4px}\n.empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}\n.when{align-self:center;margin:14px 0 6px;color:var(--faint);font-size:11.5px;font-variant-numeric:tabular-nums}\n.msg{display:flex;align-items:flex-start;gap:10px}\n.msg.first{margin-top:10px}\n.msg .slot{width:32px;flex:none;display:flex;justify-content:center}\n.msg .col{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 84px)}\n.msg .who{display:flex;align-items:center;gap:6px;margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}\n.msg.double .bubble{border:1px dashed var(--soft);background:none}\n.bubble{min-width:0;max-width:100%;padding:8px 13px;border-radius:5px var(--radius) var(--radius) var(--radius);background:var(--bubble);word-break:break-word}\n.mine{display:flex;justify-content:flex-end;margin:6px 0 2px}\n.mine .bubble{max-width:78%;border-radius:var(--radius) 5px var(--radius) var(--radius);background:var(--mine);color:var(--mine-fg)}\n.bubble>:first-child{margin-top:0}.bubble>:last-child{margin-bottom:0}\n.bubble p{margin:0 0 .6em}\n.bubble ul,.bubble ol{margin:0 0 .6em;padding-left:1.3em}\n.bubble a{color:inherit;text-decoration:underline;text-underline-offset:2px}\n.bubble code{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--code);padding:1px 4px;border-radius:5px}\n.bubble pre{margin:0 0 .6em;padding:8px 10px;background:var(--code);border-radius:10px;overflow-x:auto}\n.bubble pre code{background:none;padding:0}\n.bubble blockquote{margin:0 0 .6em;padding-left:10px;border-left:3px solid var(--line);color:var(--muted)}\n.failed{align-self:flex-end;color:var(--red);font-size:12px;margin:2px 4px 0}\n.box{flex:none;display:flex;align-items:flex-end;gap:8px;padding:8px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}\n.box textarea{flex:1;min-width:0;resize:none;max-height:160px;font:inherit;font-size:16px;line-height:1.45;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:18px;padding:8px 14px;outline:none}\n.box textarea:focus{border-color:var(--accent)}\n.box .primary{flex:none;border-radius:18px;padding:8px 16px;min-height:40px}\n.foot{flex:none;text-align:center;color:var(--faint);font-size:11px;padding:0 0 6px}\n.sheet{position:fixed;inset:0;z-index:5;display:flex;align-items:flex-end;justify-content:center;background:rgba(0,0,0,.32)}\n.sheet .panel{width:100%;max-width:520px;max-height:80dvh;overflow-y:auto;background:var(--bg);border-radius:18px 18px 0 0;padding:14px 8px calc(14px + env(safe-area-inset-bottom))}\n@media (min-width:700px){.sheet{align-items:center}.sheet .panel{border-radius:18px}}\n.panel h3{margin:4px 14px 8px;font-size:13px;font-weight:500;color:var(--muted)}\n.member{display:flex;align-items:center;gap:10px;padding:8px 12px}\n.member .nm{flex:1;min-width:0;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.tag{flex:none;padding:0 6px;border-radius:6px;background:var(--soft);color:var(--muted);font-size:11px;line-height:18px}\n.member .st{font-size:12px;color:var(--muted)}\n.member .st.on{color:var(--accent)}\n.row{display:block;width:100%;text-align:left;border:0;background:none;padding:12px 14px;border-radius:12px;font-size:14.5px}\n.row:hover{background:var(--soft)}\n.sep{height:1px;margin:6px 12px;background:var(--line)}\n";
|
|
2
2
|
//# sourceMappingURL=guest-style.d.ts.map
|
package/lib/guest/guest-style.js
CHANGED
|
@@ -9,6 +9,8 @@ html,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.
|
|
|
9
9
|
button{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
|
|
10
10
|
.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}
|
|
11
11
|
.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}
|
|
12
|
+
.open-in-ta{flex:none;display:inline-flex;align-items:center;height:32px;padding:0 14px;border-radius:16px;background:var(--fg);color:var(--bg);font-size:13.5px;font-weight:600;text-decoration:none;white-space:nowrap;-webkit-tap-highlight-color:transparent}
|
|
13
|
+
.open-in-ta:active{opacity:.8}
|
|
12
14
|
.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}
|
|
13
15
|
.heading{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
14
16
|
.heading b{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
package/lib/guest/guest.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const relay_faces_1 = require("../common/relay-faces");
|
|
4
4
|
const relay_hub_util_1 = require("../common/relay-hub-util");
|
|
5
5
|
const relay_hubs_1 = require("../common/relay-hubs");
|
|
6
|
+
const relay_open_in_ta_1 = require("../common/relay-open-in-ta");
|
|
6
7
|
const relay_room_chat_1 = require("../common/relay-room-chat");
|
|
7
8
|
const viewer_markdown_1 = require("../viewer/viewer-markdown");
|
|
8
9
|
const guest_i18n_1 = require("./guest-i18n");
|
|
@@ -38,6 +39,10 @@ class BrowserStore {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
/** Open in Ta: the link of this page, handed to the Ta app by the system (`ta://open?link=`). */
|
|
43
|
+
function openInTa() {
|
|
44
|
+
return Object.assign(el('a', t('openInTa')), { className: 'open-in-ta', href: relay_open_in_ta_1.RelayOpenInTa.link(location.href) });
|
|
45
|
+
}
|
|
41
46
|
function div(className, ...children) {
|
|
42
47
|
const node = el('div');
|
|
43
48
|
node.className = className;
|
|
@@ -144,7 +149,7 @@ class GuestPage {
|
|
|
144
149
|
const logo = el('span', 'Ta');
|
|
145
150
|
logo.className = 'logo';
|
|
146
151
|
const heading = div('heading', Object.assign(el('b'), { textContent: t('title') }));
|
|
147
|
-
return div('top', logo, heading);
|
|
152
|
+
return div('top', logo, heading, openInTa());
|
|
148
153
|
}
|
|
149
154
|
join(error) {
|
|
150
155
|
document.title = t('title');
|
|
@@ -384,7 +389,7 @@ function main() {
|
|
|
384
389
|
if (link.kind) {
|
|
385
390
|
// A room a package keeps for itself (friends of Moments): only a Ta joins it.
|
|
386
391
|
const logo = Object.assign(el('span', 'Ta'), { className: 'logo' });
|
|
387
|
-
document.body.replaceChildren(div('app', div('top', logo), div('center', Object.assign(el('p', t('inTa', { by: link.by })), { className: 'hint' }))));
|
|
392
|
+
document.body.replaceChildren(div('app', div('top', logo, openInTa()), div('center', Object.assign(el('p', t('inTa', { by: link.by })), { className: 'hint' }))));
|
|
388
393
|
return;
|
|
389
394
|
}
|
|
390
395
|
new GuestPage(link).start();
|
package/lib/join/join-i18n.d.ts
CHANGED
package/lib/join/join-i18n.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JoinI18n = exports.JOIN_WORDS = void 0;
|
|
4
4
|
const page_language_1 = require("../common/page-language");
|
|
5
5
|
const zh = {
|
|
6
|
+
openInTa: '在 Ta 中打开',
|
|
6
7
|
title: '加入 Ta',
|
|
7
8
|
invalid: '这不是一个完整的 Ta 邀请链接,请检查是否复制完整。',
|
|
8
9
|
invited: '{owner}邀请你一起用 Ta',
|
|
@@ -50,6 +51,7 @@ const zh = {
|
|
|
50
51
|
'role.guest': '访客',
|
|
51
52
|
};
|
|
52
53
|
const zhTw = {
|
|
54
|
+
openInTa: '在 Ta 中開啟',
|
|
53
55
|
title: '加入 Ta',
|
|
54
56
|
invalid: '這不是一個完整的 Ta 邀請連結,請檢查是否複製完整。',
|
|
55
57
|
invited: '{owner}邀請你一起用 Ta',
|
|
@@ -97,6 +99,7 @@ const zhTw = {
|
|
|
97
99
|
'role.guest': '訪客',
|
|
98
100
|
};
|
|
99
101
|
const en = {
|
|
102
|
+
openInTa: 'Open in Ta',
|
|
100
103
|
title: 'Join a Ta',
|
|
101
104
|
invalid: 'This is not a whole link that invites into a Ta: check that it was copied in full.',
|
|
102
105
|
invited: '{owner} invites you to work in their Ta',
|
|
@@ -144,6 +147,7 @@ const en = {
|
|
|
144
147
|
'role.guest': 'Guest',
|
|
145
148
|
};
|
|
146
149
|
const ja = {
|
|
150
|
+
openInTa: 'Ta で開く',
|
|
147
151
|
title: 'Ta に参加',
|
|
148
152
|
invalid: 'これは Ta への完全な招待リンクではありません。全体がコピーされているか確認してください。',
|
|
149
153
|
invited: '{owner}さんが Ta での作業にあなたを招待しています',
|
package/lib/join/join.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const relay_open_in_ta_1 = require("../common/relay-open-in-ta");
|
|
4
5
|
const relay_team_1 = require("../common/relay-team");
|
|
5
6
|
const guest_style_1 = require("../guest/guest-style");
|
|
6
7
|
const join_i18n_1 = require("./join-i18n");
|
|
@@ -226,7 +227,9 @@ class JoinPage {
|
|
|
226
227
|
const heading = el('div', 'heading');
|
|
227
228
|
heading.append(el('b', undefined, t('title')));
|
|
228
229
|
const top = el('div', 'top');
|
|
229
|
-
|
|
230
|
+
const open = el('a', 'open-in-ta', t('openInTa'));
|
|
231
|
+
open.href = relay_open_in_ta_1.RelayOpenInTa.link(location.href);
|
|
232
|
+
top.append(logo, heading, open);
|
|
230
233
|
const center = el('div', 'center');
|
|
231
234
|
center.append(...children);
|
|
232
235
|
const app = el('div', 'app');
|
package/lib/node/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './relay-file-storage';
|
|
|
3
3
|
export * from './relay-files-host';
|
|
4
4
|
export * from './relay-host';
|
|
5
5
|
export * from './relay-hub-files';
|
|
6
|
+
export * from './relay-memory-storage';
|
|
6
7
|
export * from './relay-server';
|
|
7
8
|
export * from './relay-store';
|
|
8
9
|
export * from './relay-viewer';
|
package/lib/node/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./relay-file-storage"), exports);
|
|
|
19
19
|
__exportStar(require("./relay-files-host"), exports);
|
|
20
20
|
__exportStar(require("./relay-host"), exports);
|
|
21
21
|
__exportStar(require("./relay-hub-files"), exports);
|
|
22
|
+
__exportStar(require("./relay-memory-storage"), exports);
|
|
22
23
|
__exportStar(require("./relay-server"), exports);
|
|
23
24
|
__exportStar(require("./relay-store"), exports);
|
|
24
25
|
__exportStar(require("./relay-viewer"), exports);
|
|
@@ -16,6 +16,8 @@ export declare class RelayFilesHost {
|
|
|
16
16
|
protected readonly base: string;
|
|
17
17
|
protected reading: number;
|
|
18
18
|
protected readonly running: Set<AbortController>;
|
|
19
|
+
/** Asked for past {@link RELAY_FILES_MAX_PARALLEL}: read in turn, not turned away (a page of an older Ta asks for all at once). */
|
|
20
|
+
protected readonly waiting: ((go: boolean) => void)[];
|
|
19
21
|
constructor(options: RelayFilesHostOptions);
|
|
20
22
|
/** A frame of the device: a file to read, or something of a version it does not know. */
|
|
21
23
|
receive(text: string): Promise<void>;
|
|
@@ -14,6 +14,8 @@ class RelayFilesHost {
|
|
|
14
14
|
this.options = options;
|
|
15
15
|
this.reading = 0;
|
|
16
16
|
this.running = new Set();
|
|
17
|
+
/** Asked for past {@link RELAY_FILES_MAX_PARALLEL}: read in turn, not turned away (a page of an older Ta asks for all at once). */
|
|
18
|
+
this.waiting = [];
|
|
17
19
|
// Only ever loopback, whatever the address of the socket says: what this reaches is one server.
|
|
18
20
|
this.base = `http://127.0.0.1:${new URL(options.localUrl).port}`;
|
|
19
21
|
}
|
|
@@ -33,6 +35,9 @@ class RelayFilesHost {
|
|
|
33
35
|
}
|
|
34
36
|
/** The device went: what it asked for is not read to the end. */
|
|
35
37
|
close() {
|
|
38
|
+
for (const go of this.waiting.splice(0)) {
|
|
39
|
+
go(false);
|
|
40
|
+
}
|
|
36
41
|
for (const controller of this.running) {
|
|
37
42
|
controller.abort();
|
|
38
43
|
}
|
|
@@ -61,12 +66,20 @@ class RelayFilesHost {
|
|
|
61
66
|
return;
|
|
62
67
|
}
|
|
63
68
|
if (this.reading >= relay_files_1.RELAY_FILES_MAX_PARALLEL) {
|
|
64
|
-
this.
|
|
65
|
-
|
|
69
|
+
if (this.waiting.length >= relay_files_1.RELAY_FILES_MAX_WAITING) {
|
|
70
|
+
this.options.send({ t: 'error', id, message: 'Too many files are loading at once.' });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// A read that ends hands its place to this one: no more than the most are read at once.
|
|
74
|
+
if (!(await new Promise(go => this.waiting.push(go)))) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.reading++;
|
|
66
80
|
}
|
|
67
81
|
const controller = new AbortController();
|
|
68
82
|
this.running.add(controller);
|
|
69
|
-
this.reading++;
|
|
70
83
|
const timer = setTimeout(() => controller.abort(), relay_files_1.RELAY_FILES_TIMEOUT_MS);
|
|
71
84
|
try {
|
|
72
85
|
const response = await fetch(target, { signal: controller.signal, redirect: 'error', headers: { accept: '*/*' } });
|
|
@@ -126,7 +139,13 @@ class RelayFilesHost {
|
|
|
126
139
|
finally {
|
|
127
140
|
clearTimeout(timer);
|
|
128
141
|
this.running.delete(controller);
|
|
129
|
-
this.
|
|
142
|
+
const next = this.waiting.shift();
|
|
143
|
+
if (next) {
|
|
144
|
+
next(true);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.reading--;
|
|
148
|
+
}
|
|
130
149
|
}
|
|
131
150
|
}
|
|
132
151
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RelayBlobStorage } from '../common/relay-blobs';
|
|
2
|
+
import type { RelayHubStorage } from '../common/relay-hub';
|
|
3
|
+
/** A copy of content in memory, deleted when it runs out. */
|
|
4
|
+
export declare class MemoryBlobStorage implements RelayBlobStorage {
|
|
5
|
+
protected readonly values: Map<string, unknown>;
|
|
6
|
+
protected timer?: ReturnType<typeof setTimeout>;
|
|
7
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
8
|
+
put(key: string, value: unknown): Promise<void>;
|
|
9
|
+
deleteAll(): Promise<void>;
|
|
10
|
+
/** No copy is kept: nothing of it need stay in the relay's memory. */
|
|
11
|
+
get empty(): boolean;
|
|
12
|
+
setAlarm(at: number): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** A room in memory, as a Durable Object keeps it. */
|
|
15
|
+
export declare class MemoryHubStorage implements RelayHubStorage {
|
|
16
|
+
protected readonly values: Map<string, unknown>;
|
|
17
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
18
|
+
put(key: string, value: unknown): Promise<void>;
|
|
19
|
+
delete(key: string): Promise<boolean>;
|
|
20
|
+
list<T>(options: {
|
|
21
|
+
prefix: string;
|
|
22
|
+
}): Promise<Map<string, T>>;
|
|
23
|
+
deleteAll(): Promise<void>;
|
|
24
|
+
/** No room was made, or it was closed. */
|
|
25
|
+
get empty(): boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=relay-memory-storage.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryHubStorage = exports.MemoryBlobStorage = void 0;
|
|
4
|
+
/** A copy of content in memory, deleted when it runs out. */
|
|
5
|
+
class MemoryBlobStorage {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.values = new Map();
|
|
8
|
+
}
|
|
9
|
+
async get(key) {
|
|
10
|
+
return this.values.get(key);
|
|
11
|
+
}
|
|
12
|
+
async put(key, value) {
|
|
13
|
+
this.values.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
async deleteAll() {
|
|
16
|
+
this.values.clear();
|
|
17
|
+
clearTimeout(this.timer);
|
|
18
|
+
}
|
|
19
|
+
/** No copy is kept: nothing of it need stay in the relay's memory. */
|
|
20
|
+
get empty() {
|
|
21
|
+
return this.values.size === 0;
|
|
22
|
+
}
|
|
23
|
+
async setAlarm(at) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
clearTimeout(this.timer);
|
|
26
|
+
// Past the 24 days of a timer, it is found run out on the next read.
|
|
27
|
+
this.timer = setTimeout(() => this.values.clear(), Math.min(Math.max(at - Date.now(), 0), 2 ** 31 - 1));
|
|
28
|
+
(_b = (_a = this.timer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.MemoryBlobStorage = MemoryBlobStorage;
|
|
32
|
+
/** A room in memory, as a Durable Object keeps it. */
|
|
33
|
+
class MemoryHubStorage {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.values = new Map();
|
|
36
|
+
}
|
|
37
|
+
async get(key) {
|
|
38
|
+
const value = this.values.get(key);
|
|
39
|
+
return value === undefined ? undefined : structuredClone(value);
|
|
40
|
+
}
|
|
41
|
+
async put(key, value) {
|
|
42
|
+
this.values.set(key, structuredClone(value));
|
|
43
|
+
}
|
|
44
|
+
async delete(key) {
|
|
45
|
+
return this.values.delete(key);
|
|
46
|
+
}
|
|
47
|
+
async list(options) {
|
|
48
|
+
const found = new Map();
|
|
49
|
+
for (const [key, value] of [...this.values].sort(([a], [b]) => a.localeCompare(b))) {
|
|
50
|
+
if (key.startsWith(options.prefix)) {
|
|
51
|
+
found.set(key, structuredClone(value));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
async deleteAll() {
|
|
57
|
+
this.values.clear();
|
|
58
|
+
}
|
|
59
|
+
/** No room was made, or it was closed. */
|
|
60
|
+
get empty() {
|
|
61
|
+
return this.values.size === 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.MemoryHubStorage = MemoryHubStorage;
|
|
65
|
+
//# sourceMappingURL=relay-memory-storage.js.map
|