@celljs/ta-relay 4.14.0 → 4.15.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/page-language.d.ts +14 -0
- package/esm/common/page-language.js +27 -0
- package/esm/common/relay-team.d.ts +33 -8
- package/esm/common/relay-team.js +55 -7
- package/esm/guest/guest-i18n.d.ts +6 -1
- package/esm/guest/guest-i18n.js +98 -5
- package/esm/guest/guest.js +1 -1
- package/esm/join/join-i18n.d.ts +13 -1
- package/esm/join/join-i18n.js +133 -3
- package/esm/join/join.js +79 -10
- package/esm/viewer/viewer-i18n.d.ts +6 -1
- package/esm/viewer/viewer-i18n.js +107 -3
- package/lib/common/page-language.d.ts +15 -0
- package/lib/common/page-language.js +31 -0
- package/lib/common/relay-team.d.ts +33 -8
- package/lib/common/relay-team.js +55 -7
- package/lib/guest/guest-i18n.d.ts +6 -1
- package/lib/guest/guest-i18n.js +99 -6
- package/lib/guest/guest.js +1 -1
- package/lib/join/join-i18n.d.ts +13 -1
- package/lib/join/join-i18n.js +134 -4
- package/lib/join/join.js +79 -10
- package/lib/viewer/viewer-i18n.d.ts +6 -1
- package/lib/viewer/viewer-i18n.js +108 -4
- package/package.json +2 -2
- package/viewer/join.html +4 -3
- package/viewer/page.html +9 -9
- package/viewer/room.html +10 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A language of the pages of the relay, the languages of Ta. */
|
|
2
|
+
export type PageLanguage = 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP';
|
|
3
|
+
/**
|
|
4
|
+
* The language of a page, from the browser's (`navigator.language`): Traditional Chinese for Taiwan, Hong Kong, Macau
|
|
5
|
+
* and `Hant`, Simplified for other Chinese, Japanese, else English; as TaLanguageUtil.of of ta-protocol, which the
|
|
6
|
+
* relay does without.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pageLanguage(tag?: string | undefined): PageLanguage;
|
|
9
|
+
/**
|
|
10
|
+
* The language of a page a link opens: the first of the browser's languages that is Chinese or Japanese, else the
|
|
11
|
+
* language the link was made in (`linked`, the inviter's), else English. A browser in English alone, as many are
|
|
12
|
+
* whatever their users read, gets the page in the words of who sent the link.
|
|
13
|
+
*/
|
|
14
|
+
export declare function linkLanguage(languages: readonly string[], linked?: string): PageLanguage;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The language of a page, from the browser's (`navigator.language`): Traditional Chinese for Taiwan, Hong Kong, Macau
|
|
3
|
+
* and `Hant`, Simplified for other Chinese, Japanese, else English; as TaLanguageUtil.of of ta-protocol, which the
|
|
4
|
+
* relay does without.
|
|
5
|
+
*/
|
|
6
|
+
export function pageLanguage(tag = typeof navigator === 'undefined' ? undefined : navigator.language) {
|
|
7
|
+
const said = (tag !== null && tag !== void 0 ? tag : '').toLowerCase().replace(/_/g, '-');
|
|
8
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
9
|
+
return /-hant\b/.test(said) || (!/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said)) ? 'zh-TW' : 'zh-CN';
|
|
10
|
+
}
|
|
11
|
+
return /^ja(\b|-)/.test(said) ? 'ja-JP' : 'en-US';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The language of a page a link opens: the first of the browser's languages that is Chinese or Japanese, else the
|
|
15
|
+
* language the link was made in (`linked`, the inviter's), else English. A browser in English alone, as many are
|
|
16
|
+
* whatever their users read, gets the page in the words of who sent the link.
|
|
17
|
+
*/
|
|
18
|
+
export function linkLanguage(languages, linked) {
|
|
19
|
+
for (const tag of languages) {
|
|
20
|
+
const language = pageLanguage(tag);
|
|
21
|
+
if (language !== 'en-US') {
|
|
22
|
+
return language;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return linked && /^(zh|ja|en)\b/i.test(linked) ? pageLanguage(linked) : 'en-US';
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=page-language.js.map
|
|
@@ -16,6 +16,8 @@ export interface RelayTeamLink {
|
|
|
16
16
|
role: string;
|
|
17
17
|
/** It shares something on its own: the name shown (`设计师`). */
|
|
18
18
|
what?: string;
|
|
19
|
+
/** The language of who made it (`zh-CN`): the page of the link speaks it, unless the browser asks Chinese or Japanese. */
|
|
20
|
+
language?: string;
|
|
19
21
|
}
|
|
20
22
|
/** Where one asking from a browser comes from: the page of the relay (RELAY_JOIN_PATH), not the Ta app. */
|
|
21
23
|
export type RelayTeamVia = 'web';
|
|
@@ -35,19 +37,34 @@ export interface RelayTeamAnswer {
|
|
|
35
37
|
}
|
|
36
38
|
/** How one asking by a link may say who they are (docs/design/ta-team.md 17). */
|
|
37
39
|
export interface RelayTeamWays {
|
|
38
|
-
/** The providers the Ta signs in with: GitHub, Google, WeChat, the operator's. */
|
|
40
|
+
/** The providers the Ta signs in with: GitHub, Google, WeChat, the operator's; `device`, by a code typed at it. */
|
|
39
41
|
providers: {
|
|
40
42
|
id: string;
|
|
41
43
|
name: string;
|
|
44
|
+
device?: true;
|
|
42
45
|
}[];
|
|
43
46
|
/** They sign in first: the role manages members and they ask from a browser; otherwise signing in is theirs to choose. */
|
|
44
47
|
required: boolean;
|
|
45
48
|
/** The role manages members. */
|
|
46
49
|
manages?: boolean;
|
|
47
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A sign-in started: `url`, where the browser goes, to come back to the page of the link; `device`, a code to type at
|
|
53
|
+
* the provider's `uri` (GitHub's device flow), the Ta asking it whether it was ({@link RelayTeamJoining.typed}).
|
|
54
|
+
*/
|
|
55
|
+
export interface RelayTeamSignInStart {
|
|
56
|
+
state: string;
|
|
57
|
+
url?: string;
|
|
58
|
+
device?: {
|
|
59
|
+
code: string;
|
|
60
|
+
uri: string;
|
|
61
|
+
expiresAt: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
48
64
|
/**
|
|
49
65
|
* Signed in with a provider: as it came back to the page of the link (the code goes to the Ta, which alone can use it),
|
|
50
|
-
* or in a browser for the Ta app, by the handoff id the app gave it (RelayTeamLinkUtil.signInFor)
|
|
66
|
+
* or in a browser for the Ta app, by the handoff id the app gave it (RelayTeamLinkUtil.signInFor), or by a code typed,
|
|
67
|
+
* by the state of its sign-in as the handoff.
|
|
51
68
|
*/
|
|
52
69
|
export type RelayTeamSignIn = {
|
|
53
70
|
state: string;
|
|
@@ -108,15 +125,14 @@ export declare class RelayTeamJoining {
|
|
|
108
125
|
/** The keys of the request asked. */
|
|
109
126
|
get keys(): RelayIdentity | undefined;
|
|
110
127
|
/**
|
|
111
|
-
* How to say who one is. A Ta of before has no accounts for those asking (its link may not call `ways`): none needed
|
|
112
|
-
*
|
|
128
|
+
* How to say who one is. A Ta of before has no accounts for those asking (its link may not call `ways`): none needed.
|
|
129
|
+
* A Ta that cannot be reached throws, so that the page says so rather than hide the ways to sign in.
|
|
113
130
|
*/
|
|
114
131
|
ways(via?: RelayTeamVia): Promise<RelayTeamWays>;
|
|
132
|
+
/** A call the relay or the Ta did not answer: the Ta is off, or the connection was lost. */
|
|
133
|
+
static unreachable(failure: unknown): boolean;
|
|
115
134
|
/** Where the browser goes to sign in with a provider, and the state it comes back with to the page of the link; for the app, its handoff. */
|
|
116
|
-
signIn(provider: string, handoff?: string): Promise<
|
|
117
|
-
url: string;
|
|
118
|
-
state: string;
|
|
119
|
-
}>;
|
|
135
|
+
signIn(provider: string, handoff?: string): Promise<RelayTeamSignInStart>;
|
|
120
136
|
/** The browser came back signed in for the Ta app: the Ta verifies the account and keeps it for the app. */
|
|
121
137
|
signedIn(state: string, code: string): Promise<{
|
|
122
138
|
account: {
|
|
@@ -124,6 +140,15 @@ export declare class RelayTeamJoining {
|
|
|
124
140
|
name?: string;
|
|
125
141
|
};
|
|
126
142
|
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Waits for the code of a sign-in (`device` of {@link signIn}) to be typed at the provider, asking again till it was
|
|
145
|
+
* (the account, kept by the Ta under the handoff of the sign-in, or its state), this stops or `until` passes. A call
|
|
146
|
+
* the relay or the Ta did not answer (a phone away while the code was typed) is asked again; one refused throws.
|
|
147
|
+
*/
|
|
148
|
+
typed(state: string, until?: number): Promise<{
|
|
149
|
+
id: string;
|
|
150
|
+
name?: string;
|
|
151
|
+
} | undefined>;
|
|
127
152
|
/**
|
|
128
153
|
* Waits for the browser to sign in for the app, asking again till it did (the account), this stops or `until`
|
|
129
154
|
* passes; a call that fails (the app was away while the browser was in front) is asked again.
|
package/esm/common/relay-team.js
CHANGED
|
@@ -47,18 +47,21 @@ export var RelayTeamLinkUtil;
|
|
|
47
47
|
if (link.what) {
|
|
48
48
|
fragment.set('w', link.what);
|
|
49
49
|
}
|
|
50
|
+
if (link.language) {
|
|
51
|
+
fragment.set('l', link.language);
|
|
52
|
+
}
|
|
50
53
|
return `${link.relay.replace(/\/+$/, '')}${RELAY_JOIN_PATH}#${fragment}`;
|
|
51
54
|
}
|
|
52
55
|
RelayTeamLinkUtil.format = format;
|
|
53
56
|
/** Undefined for text that is not such a link. */
|
|
54
57
|
function parse(text) {
|
|
55
58
|
var _a;
|
|
56
|
-
var _b, _c;
|
|
59
|
+
var _b, _c, _d;
|
|
57
60
|
let url;
|
|
58
61
|
try {
|
|
59
62
|
url = new URL(text.trim());
|
|
60
63
|
}
|
|
61
|
-
catch (
|
|
64
|
+
catch (_e) {
|
|
62
65
|
return undefined;
|
|
63
66
|
}
|
|
64
67
|
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
@@ -72,7 +75,17 @@ export var RelayTeamLinkUtil;
|
|
|
72
75
|
return undefined;
|
|
73
76
|
}
|
|
74
77
|
const what = (_a = fragment.get('w')) === null || _a === void 0 ? void 0 : _a.slice(0, 80);
|
|
75
|
-
|
|
78
|
+
const language = (_b = fragment.get('l')) !== null && _b !== void 0 ? _b : '';
|
|
79
|
+
return {
|
|
80
|
+
relay: url.origin,
|
|
81
|
+
host,
|
|
82
|
+
device,
|
|
83
|
+
key,
|
|
84
|
+
owner: (_c = fragment.get('o')) !== null && _c !== void 0 ? _c : '',
|
|
85
|
+
role: (_d = fragment.get('r')) !== null && _d !== void 0 ? _d : '',
|
|
86
|
+
...(what ? { what } : {}),
|
|
87
|
+
...(/^[a-z]{2}(-[A-Za-z]{2,4})?$/.test(language) ? { language } : {}),
|
|
88
|
+
};
|
|
76
89
|
}
|
|
77
90
|
RelayTeamLinkUtil.parse = parse;
|
|
78
91
|
/**
|
|
@@ -121,24 +134,59 @@ export class RelayTeamJoining {
|
|
|
121
134
|
return this.own;
|
|
122
135
|
}
|
|
123
136
|
/**
|
|
124
|
-
* How to say who one is. A Ta of before has no accounts for those asking (its link may not call `ways`): none needed
|
|
125
|
-
*
|
|
137
|
+
* How to say who one is. A Ta of before has no accounts for those asking (its link may not call `ways`): none needed.
|
|
138
|
+
* A Ta that cannot be reached throws, so that the page says so rather than hide the ways to sign in.
|
|
126
139
|
*/
|
|
127
140
|
async ways(via) {
|
|
128
141
|
try {
|
|
129
142
|
return (await this.calls.callHost('ways', via ? { via } : {}));
|
|
130
143
|
}
|
|
131
|
-
catch (
|
|
144
|
+
catch (failure) {
|
|
145
|
+
if (RelayTeamJoining.unreachable(failure)) {
|
|
146
|
+
throw failure;
|
|
147
|
+
}
|
|
132
148
|
return { providers: [], required: false };
|
|
133
149
|
}
|
|
134
150
|
}
|
|
151
|
+
/** A call the relay or the Ta did not answer: the Ta is off, or the connection was lost. */
|
|
152
|
+
static unreachable(failure) {
|
|
153
|
+
return /did not answer|was lost/i.test(failure instanceof Error ? failure.message : String(failure));
|
|
154
|
+
}
|
|
135
155
|
/** Where the browser goes to sign in with a provider, and the state it comes back with to the page of the link; for the app, its handoff. */
|
|
136
156
|
async signIn(provider, handoff) {
|
|
137
157
|
return (await this.calls.callHost('signIn', { provider, ...(handoff ? { handoff } : {}) }));
|
|
138
158
|
}
|
|
139
159
|
/** The browser came back signed in for the Ta app: the Ta verifies the account and keeps it for the app. */
|
|
140
160
|
async signedIn(state, code) {
|
|
141
|
-
|
|
161
|
+
const answer = (await this.calls.callHost('signedIn', { state, code }));
|
|
162
|
+
return { account: answer.account };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Waits for the code of a sign-in (`device` of {@link signIn}) to be typed at the provider, asking again till it was
|
|
166
|
+
* (the account, kept by the Ta under the handoff of the sign-in, or its state), this stops or `until` passes. A call
|
|
167
|
+
* the relay or the Ta did not answer (a phone away while the code was typed) is asked again; one refused throws.
|
|
168
|
+
*/
|
|
169
|
+
async typed(state, until = Date.now() + 15 * 60000) {
|
|
170
|
+
while (!this.closed && Date.now() < until) {
|
|
171
|
+
let answer;
|
|
172
|
+
try {
|
|
173
|
+
answer = (await this.calls.callHost('signedIn', { state }));
|
|
174
|
+
}
|
|
175
|
+
catch (failure) {
|
|
176
|
+
if (this.closed) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
if (!RelayTeamJoining.unreachable(failure)) {
|
|
180
|
+
throw failure;
|
|
181
|
+
}
|
|
182
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (answer.status === 'done' && answer.account) {
|
|
186
|
+
return answer.account;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
142
190
|
}
|
|
143
191
|
/**
|
|
144
192
|
* Waits for the browser to sign in for the app, asking again till it did (the account), this stops or `until`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PageLanguage } from '../common/page-language.js';
|
|
1
2
|
declare const zh: {
|
|
2
3
|
title: string;
|
|
3
4
|
invalid: string;
|
|
@@ -43,8 +44,12 @@ declare const zh: {
|
|
|
43
44
|
close: string;
|
|
44
45
|
};
|
|
45
46
|
export type GuestText = keyof typeof zh;
|
|
47
|
+
/** The words of each language of Ta, checked by scripts/check-i18n.ts. */
|
|
48
|
+
export declare const GUEST_WORDS: Readonly<Record<PageLanguage, typeof zh>>;
|
|
46
49
|
export declare namespace GuestI18n {
|
|
47
|
-
const
|
|
50
|
+
const language: PageLanguage;
|
|
51
|
+
/** Chinese or Japanese: Latin among the words has a space on each side. */
|
|
52
|
+
const cjk: boolean;
|
|
48
53
|
function t(id: GuestText, values?: Record<string, string | number>): string;
|
|
49
54
|
/** The time of a line: when today, else the day too. */
|
|
50
55
|
function time(at: number): string;
|
package/esm/guest/guest-i18n.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pageLanguage } from '../common/page-language.js';
|
|
1
2
|
const zh = {
|
|
2
3
|
title: 'Ta 房间',
|
|
3
4
|
invalid: '这不是一个完整的 Ta 房间邀请链接,请检查是否复制完整。',
|
|
@@ -42,6 +43,50 @@ const zh = {
|
|
|
42
43
|
secure: '端到端加密,中继看不到内容',
|
|
43
44
|
close: '关闭',
|
|
44
45
|
};
|
|
46
|
+
const zhTw = {
|
|
47
|
+
title: 'Ta 房間',
|
|
48
|
+
invalid: '這不是一個完整的 Ta 房間邀請連結,請檢查是否複製完整。',
|
|
49
|
+
inTa: '這是{by}在 Ta 裡的加好友連結,要在 Ta 裡開啟:用 Ta 掃碼,或把連結貼上到 Ta 的快捷開啟。',
|
|
50
|
+
invited: '{by}邀請你加入',
|
|
51
|
+
joinHint: '房主同意後,就能在這裡和大家聊天。',
|
|
52
|
+
name: '你的名字',
|
|
53
|
+
namePlaceholder: '大家看到的名字',
|
|
54
|
+
join: '申請加入',
|
|
55
|
+
joining: '正在申請…',
|
|
56
|
+
keep: '你的名字和一把只屬於這個瀏覽器的鑰匙儲存在本機;清除瀏覽器資料後要重新申請。',
|
|
57
|
+
haveTa: '裝了 Ta?在 Ta 應用裡掃碼或貼上這個連結,還能一起玩小鎮等遊戲。',
|
|
58
|
+
waiting: '已向{by}申請',
|
|
59
|
+
waitingHint: '等對方同意。可以先關掉頁面,之後再開啟這個連結。',
|
|
60
|
+
cancel: '取消申請',
|
|
61
|
+
refused: '{by}沒有同意你加入',
|
|
62
|
+
again: '再申請一次',
|
|
63
|
+
removed: '你已被移出這個房間',
|
|
64
|
+
closed: '這個房間已被房主解散',
|
|
65
|
+
inviteGone: '邀請已失效,請向房主要一個新連結',
|
|
66
|
+
own: '這是你自己的房間,請在 Ta 裡開啟。',
|
|
67
|
+
connecting: '連線中…',
|
|
68
|
+
online: '另有 {n} 人線上',
|
|
69
|
+
nobody: '其他人都不線上',
|
|
70
|
+
onlineNow: '線上',
|
|
71
|
+
members: '成員',
|
|
72
|
+
owner: '房主',
|
|
73
|
+
you: '我',
|
|
74
|
+
guest: '網頁訪客',
|
|
75
|
+
doubleOf: '{name}的分身',
|
|
76
|
+
double: '分身',
|
|
77
|
+
task: '任務',
|
|
78
|
+
agentOf: '{name}的智慧體',
|
|
79
|
+
rename: '修改我的名字',
|
|
80
|
+
leave: '退出房間',
|
|
81
|
+
leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
|
|
82
|
+
game: '這個房間裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
|
|
83
|
+
empty: '還沒有人說話。只有房間裡的人能看到,中繼儲存的是密文。',
|
|
84
|
+
placeholder: '發訊息',
|
|
85
|
+
send: '傳送',
|
|
86
|
+
failed: '沒發出去:{reason}',
|
|
87
|
+
secure: '端到端加密,中繼看不到內容',
|
|
88
|
+
close: '關閉',
|
|
89
|
+
};
|
|
45
90
|
const en = {
|
|
46
91
|
title: 'A room of Ta',
|
|
47
92
|
invalid: 'This is not a whole link that invites into a room of Ta: check it was copied in full.',
|
|
@@ -86,21 +131,69 @@ const en = {
|
|
|
86
131
|
secure: 'End to end: the relay reads none of it',
|
|
87
132
|
close: 'Close',
|
|
88
133
|
};
|
|
134
|
+
const ja = {
|
|
135
|
+
title: 'Ta のルーム',
|
|
136
|
+
invalid: 'これは Ta ルームへの完全な招待リンクではありません。全体がコピーされているか確認してください。',
|
|
137
|
+
inTa: 'これは {by} さんが Ta で友だちを追加するリンクで、Ta で開きます。Ta でスキャンするか、Ta のクイックオープンにペーストしてください。',
|
|
138
|
+
invited: '{by}さんがあなたを招待しています',
|
|
139
|
+
joinHint: 'ルーム管理者が承認すると、ここでみんなとチャットできます。',
|
|
140
|
+
name: 'あなたの名前',
|
|
141
|
+
namePlaceholder: 'みんなに見える名前',
|
|
142
|
+
join: '参加をリクエスト',
|
|
143
|
+
joining: 'リクエスト中…',
|
|
144
|
+
keep: 'あなたの名前とこのブラウザ専用のキーはこのデバイスに保存されます。ブラウザデータをクリアすると再度リクエストが必要です。',
|
|
145
|
+
haveTa: 'Ta をインストール済みですか?Ta アプリでこのリンクをスキャンするかペーストして、タウンなどのゲームも一緒にプレイできます。',
|
|
146
|
+
waiting: '{by}さんにリクエスト済み',
|
|
147
|
+
waitingHint: '相手が承認するのを待っています。ページを閉じて、後でもう一度開くことができます。',
|
|
148
|
+
cancel: 'キャンセル',
|
|
149
|
+
refused: '{by}さんはあなたの参加を承認しませんでした',
|
|
150
|
+
again: 'もう一度リクエスト',
|
|
151
|
+
removed: 'このルームから削除されました',
|
|
152
|
+
closed: 'このルームはルーム管理者に閉じられました',
|
|
153
|
+
inviteGone: '招待が無効です。ルーム管理者に新しいリンクをリクエストしてください',
|
|
154
|
+
own: 'これはあなた自身のルームです。Ta で開いてください。',
|
|
155
|
+
connecting: '接続中…',
|
|
156
|
+
online: '他に {n} 人がオンライン',
|
|
157
|
+
nobody: '他に誰もオンラインではありません',
|
|
158
|
+
onlineNow: 'オンライン',
|
|
159
|
+
members: 'メンバー',
|
|
160
|
+
owner: 'ルーム管理者',
|
|
161
|
+
you: '私',
|
|
162
|
+
guest: 'ウェブゲスト',
|
|
163
|
+
doubleOf: '{name}の分身',
|
|
164
|
+
double: '分身',
|
|
165
|
+
task: 'タスク',
|
|
166
|
+
agentOf: '{name}のエージェント',
|
|
167
|
+
rename: '名前を変更',
|
|
168
|
+
leave: 'ルームを退出',
|
|
169
|
+
leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
|
|
170
|
+
game: 'このルームには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
|
|
171
|
+
empty: 'まだ誰も話していません。ルーム内の人だけが見ることができ、リレーは暗号化されて保存されます。',
|
|
172
|
+
placeholder: 'メッセージ',
|
|
173
|
+
send: '送信',
|
|
174
|
+
failed: '送信されませんでした:{reason}',
|
|
175
|
+
secure: 'エンドツーエンド暗号化。リレーは内容を読むことができません',
|
|
176
|
+
close: '閉じる',
|
|
177
|
+
};
|
|
178
|
+
/** The words of each language of Ta, checked by scripts/check-i18n.ts. */
|
|
179
|
+
export const GUEST_WORDS = { 'zh-CN': zh, 'zh-TW': zhTw, 'en-US': en, 'ja-JP': ja };
|
|
89
180
|
export var GuestI18n;
|
|
90
181
|
(function (GuestI18n) {
|
|
91
|
-
GuestI18n.
|
|
182
|
+
GuestI18n.language = pageLanguage();
|
|
183
|
+
/** Chinese or Japanese: Latin among the words has a space on each side. */
|
|
184
|
+
GuestI18n.cjk = GuestI18n.language !== 'en-US';
|
|
185
|
+
const words = GUEST_WORDS[GuestI18n.language];
|
|
92
186
|
function t(id, values = {}) {
|
|
93
|
-
return
|
|
187
|
+
return words[id].replace(/\{(\w+)\}/g, (_, name) => { var _a; return String((_a = values[name]) !== null && _a !== void 0 ? _a : ''); });
|
|
94
188
|
}
|
|
95
189
|
GuestI18n.t = t;
|
|
96
190
|
/** The time of a line: when today, else the day too. */
|
|
97
191
|
function time(at) {
|
|
98
192
|
const date = new Date(at);
|
|
99
|
-
const
|
|
100
|
-
const clock = date.toLocaleTimeString(language, { hour: '2-digit', minute: '2-digit' });
|
|
193
|
+
const clock = date.toLocaleTimeString(GuestI18n.language, { hour: '2-digit', minute: '2-digit' });
|
|
101
194
|
return date.toDateString() === new Date().toDateString()
|
|
102
195
|
? clock
|
|
103
|
-
: `${date.toLocaleDateString(language, { month: 'numeric', day: 'numeric' })} ${clock}`;
|
|
196
|
+
: `${date.toLocaleDateString(GuestI18n.language, { month: 'numeric', day: 'numeric' })} ${clock}`;
|
|
104
197
|
}
|
|
105
198
|
GuestI18n.time = time;
|
|
106
199
|
})(GuestI18n || (GuestI18n = {}));
|
package/esm/guest/guest.js
CHANGED
|
@@ -83,7 +83,7 @@ class GuestPage {
|
|
|
83
83
|
store: new BrowserStore(),
|
|
84
84
|
relay: () => location.origin,
|
|
85
85
|
guest: true,
|
|
86
|
-
name: () => (
|
|
86
|
+
name: () => ({ 'zh-CN': '访客', 'zh-TW': '訪客', 'en-US': 'Guest', 'ja-JP': 'ゲスト' })[GuestI18n.language],
|
|
87
87
|
});
|
|
88
88
|
this.screen = '';
|
|
89
89
|
this.stuck = true;
|
package/esm/join/join-i18n.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PageLanguage } from '../common/page-language.js';
|
|
1
2
|
declare const zh: {
|
|
2
3
|
title: string;
|
|
3
4
|
invalid: string;
|
|
@@ -33,12 +34,21 @@ declare const zh: {
|
|
|
33
34
|
'provider.wechat': string;
|
|
34
35
|
handedOff: string;
|
|
35
36
|
backToApp: string;
|
|
37
|
+
typeCode: string;
|
|
38
|
+
copyOpen: string;
|
|
39
|
+
copied: string;
|
|
40
|
+
typeCodeHint: string;
|
|
41
|
+
codeGone: string;
|
|
42
|
+
back: string;
|
|
43
|
+
retry: string;
|
|
36
44
|
'role.admin': string;
|
|
37
45
|
'role.collaborator': string;
|
|
38
46
|
'role.viewer': string;
|
|
39
47
|
'role.guest': string;
|
|
40
48
|
};
|
|
41
49
|
export type JoinText = keyof typeof zh;
|
|
50
|
+
/** The words of each language of Ta, checked by scripts/check-i18n.ts. */
|
|
51
|
+
export declare const JOIN_WORDS: Readonly<Record<PageLanguage, typeof zh>>;
|
|
42
52
|
export declare namespace JoinI18n {
|
|
43
53
|
/** A provider in the words of the page: WeChat is 微信 in Chinese. */
|
|
44
54
|
function provider(one: {
|
|
@@ -47,7 +57,9 @@ export declare namespace JoinI18n {
|
|
|
47
57
|
}): string;
|
|
48
58
|
/** A role of those that come with Ta in the words of the page; one of the owner's own as they named it. */
|
|
49
59
|
function role(name: string): string;
|
|
50
|
-
const
|
|
60
|
+
const language: PageLanguage;
|
|
61
|
+
/** Chinese or Japanese: Latin among the words has a space on each side. */
|
|
62
|
+
const cjk: boolean;
|
|
51
63
|
function t(id: JoinText, values?: Record<string, string | number>): string;
|
|
52
64
|
}
|
|
53
65
|
export {};
|
package/esm/join/join-i18n.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { linkLanguage } from '../common/page-language.js';
|
|
1
2
|
const zh = {
|
|
2
3
|
title: '加入 Ta',
|
|
3
4
|
invalid: '这不是一个完整的 Ta 邀请链接,请检查是否复制完整。',
|
|
@@ -33,11 +34,65 @@ const zh = {
|
|
|
33
34
|
'provider.wechat': '微信',
|
|
34
35
|
handedOff: '已用 {who} 登录',
|
|
35
36
|
backToApp: '回到 Ta 应用继续申请加入{owner}的 Ta,这个页面可以关掉了。',
|
|
37
|
+
typeCode: '在{provider}输入这个码,确认是你:',
|
|
38
|
+
copyOpen: '复制并打开{provider}',
|
|
39
|
+
copied: '已复制,在打开的页面里粘贴',
|
|
40
|
+
typeCodeHint: '在{provider}授权后回到这个页面,会自动继续。',
|
|
41
|
+
codeGone: '这个码过期了,请重新登录。',
|
|
42
|
+
back: '返回',
|
|
43
|
+
retry: '重试',
|
|
36
44
|
'role.admin': '管理员',
|
|
37
45
|
'role.collaborator': '协作者',
|
|
38
46
|
'role.viewer': '只读',
|
|
39
47
|
'role.guest': '访客',
|
|
40
48
|
};
|
|
49
|
+
const zhTw = {
|
|
50
|
+
title: '加入 Ta',
|
|
51
|
+
invalid: '這不是一個完整的 Ta 邀請連結,請檢查是否複製完整。',
|
|
52
|
+
invited: '{owner}邀請你一起用 Ta',
|
|
53
|
+
role: '角色:{role}',
|
|
54
|
+
what: '對方分享給你:{what}',
|
|
55
|
+
hint: '加入後你在這個瀏覽器裡使用{owner}的 Ta,能看什麼、做什麼由對方給你的角色決定。',
|
|
56
|
+
name: '你的名字',
|
|
57
|
+
namePlaceholder: '對方看到的名字',
|
|
58
|
+
join: '申請加入',
|
|
59
|
+
joining: '正在申請…',
|
|
60
|
+
keep: '進入用的鑰匙只儲存在這個瀏覽器裡;清除瀏覽器資料後要重新申請。',
|
|
61
|
+
haveTa: '裝了 Ta?在 Ta 裡開啟這個連結,用起來更順手。',
|
|
62
|
+
waiting: '已向{owner}申請',
|
|
63
|
+
waitingHint: '等對方同意。可以先關掉頁面,之後在這個瀏覽器裡再開啟這個連結。',
|
|
64
|
+
cancel: '取消申請',
|
|
65
|
+
connecting: '對方同意了,正在進入…',
|
|
66
|
+
refused: '{owner}沒有同意你加入',
|
|
67
|
+
again: '再申請一次',
|
|
68
|
+
gone: '這個邀請已失效,請向對方要一個新連結',
|
|
69
|
+
app: '這個邀請給的是管理員角色,要在 Ta 應用裡開啟:從瀏覽器加入的人不能當管理員。',
|
|
70
|
+
joined: '你已經加入了{owner}的 Ta',
|
|
71
|
+
open: '開啟',
|
|
72
|
+
failed: '沒能申請:{reason}',
|
|
73
|
+
unreachable: '{owner}的 Ta 現在連不上,等對方的電腦開著時再試。',
|
|
74
|
+
or: '不登入就是匿名加入,對方看到的是你填的名字。也可以:',
|
|
75
|
+
signInWith: '用{provider}登入',
|
|
76
|
+
signingIn: '正在開啟登入…',
|
|
77
|
+
checking: '正在確認你的身份…',
|
|
78
|
+
signInFailed: '沒有登入成功:{reason}',
|
|
79
|
+
needAccount: '這個邀請給的是管理員角色,從瀏覽器加入要先用帳號登入,對方會看到你是誰。',
|
|
80
|
+
keepAccount: '用帳號登入後,換個瀏覽器再開啟這個連結也是同一個人。進入用的鑰匙只儲存在這個瀏覽器裡。',
|
|
81
|
+
'provider.wechat': '微信',
|
|
82
|
+
handedOff: '已用 {who} 登入',
|
|
83
|
+
backToApp: '回到 Ta 應用繼續申請加入{owner}的 Ta,這個頁面可以關掉了。',
|
|
84
|
+
typeCode: '在{provider}輸入這組碼,確認是你:',
|
|
85
|
+
copyOpen: '複製並開啟{provider}',
|
|
86
|
+
copied: '已複製,在開啟的頁面裡貼上',
|
|
87
|
+
typeCodeHint: '在{provider}授權後回到這個頁面,會自動繼續。',
|
|
88
|
+
codeGone: '這組碼過期了,請重新登入。',
|
|
89
|
+
back: '返回',
|
|
90
|
+
retry: '重試',
|
|
91
|
+
'role.admin': '管理員',
|
|
92
|
+
'role.collaborator': '協作者',
|
|
93
|
+
'role.viewer': '只讀',
|
|
94
|
+
'role.guest': '訪客',
|
|
95
|
+
};
|
|
41
96
|
const en = {
|
|
42
97
|
title: 'Join a Ta',
|
|
43
98
|
invalid: 'This is not a whole link that invites into a Ta: check that it was copied in full.',
|
|
@@ -73,19 +128,76 @@ const en = {
|
|
|
73
128
|
'provider.wechat': 'WeChat',
|
|
74
129
|
handedOff: 'Signed in as {who}',
|
|
75
130
|
backToApp: "Go back to the Ta app to ask to join {owner}'s Ta; you may close this page.",
|
|
131
|
+
typeCode: 'Enter this code at {provider} to show it is you:',
|
|
132
|
+
copyOpen: 'Copy and open {provider}',
|
|
133
|
+
copied: 'Copied: paste it in the page that opened',
|
|
134
|
+
typeCodeHint: 'Once you authorize it at {provider}, come back here: it goes on by itself.',
|
|
135
|
+
codeGone: 'The code ran out: sign in again.',
|
|
136
|
+
back: 'Back',
|
|
137
|
+
retry: 'Try again',
|
|
76
138
|
'role.admin': 'Admin',
|
|
77
139
|
'role.collaborator': 'Collaborator',
|
|
78
140
|
'role.viewer': 'Viewer',
|
|
79
141
|
'role.guest': 'Guest',
|
|
80
142
|
};
|
|
143
|
+
const ja = {
|
|
144
|
+
title: 'Ta に参加',
|
|
145
|
+
invalid: 'これは Ta への完全な招待リンクではありません。全体がコピーされているか確認してください。',
|
|
146
|
+
invited: '{owner}さんが Ta での作業にあなたを招待しています',
|
|
147
|
+
role: 'ロール:{role}',
|
|
148
|
+
what: 'あなたと共有:{what}',
|
|
149
|
+
hint: '参加すると、このブラウザで {owner} さんの Ta を使用します。見ることができることと実行できることはロールによって決まります。',
|
|
150
|
+
name: 'あなたの名前',
|
|
151
|
+
namePlaceholder: '相手が見る名前',
|
|
152
|
+
join: '参加をリクエスト',
|
|
153
|
+
joining: 'リクエスト中…',
|
|
154
|
+
keep: '参加用のキーはこのブラウザのみに保存されます。ブラウザデータをクリアすると再度リクエストが必要です。',
|
|
155
|
+
haveTa: 'Ta をインストール済みですか?Ta でこのリンクを開いてください。',
|
|
156
|
+
waiting: '{owner}さんにリクエスト済み',
|
|
157
|
+
waitingHint: '相手が承認するか拒否するかを待っています。このページを閉じて、後でこのブラウザでリンクを開き直すことができます。',
|
|
158
|
+
cancel: 'キャンセル',
|
|
159
|
+
connecting: '相手が承認しました。参加中…',
|
|
160
|
+
refused: '{owner}さんはあなたの参加を承認しませんでした',
|
|
161
|
+
again: 'もう一度リクエスト',
|
|
162
|
+
gone: 'この招待はもう有効ではありません。新しいリンクをリクエストしてください',
|
|
163
|
+
app: 'この招待はメンバーを管理するロールを提供していますが、Ta アプリで開く必要があります。',
|
|
164
|
+
joined: 'すでに {owner} さんの Ta に参加しています',
|
|
165
|
+
open: '開く',
|
|
166
|
+
failed: 'リクエストできませんでした:{reason}',
|
|
167
|
+
unreachable: '{owner}さんの Ta は現在到達できません。相手のコンピュータがオンの間にもう一度試してください。',
|
|
168
|
+
or: 'サインインしないと、入力した名前で匿名となります。または:',
|
|
169
|
+
signInWith: '{provider} でサインイン',
|
|
170
|
+
signingIn: 'サインイン画面を開いています…',
|
|
171
|
+
checking: 'あなたの身元を確認中…',
|
|
172
|
+
signInFailed: 'サインインできませんでした:{reason}',
|
|
173
|
+
needAccount: 'この招待はメンバーを管理するロールを提供しています。ブラウザからの参加には、まずアカウントでサインインする必要があり、相手があなたが誰かを確認できます。',
|
|
174
|
+
keepAccount: 'サインイン後、このリンクを開くどのブラウザからでも同じ人物です。参加用のキーはこのブラウザのみに保存されます。',
|
|
175
|
+
'provider.wechat': 'WeChat',
|
|
176
|
+
handedOff: '{who} としてサインイン済み',
|
|
177
|
+
backToApp: 'Ta アプリに戻って {owner}さんの Ta への参加をリクエストしてください。このページは閉じられます。',
|
|
178
|
+
typeCode: '{provider}でこのコードを入力して本人確認してください:',
|
|
179
|
+
copyOpen: 'コピーして{provider}を開く',
|
|
180
|
+
copied: 'コピーしました。開いたページに貼り付けてください',
|
|
181
|
+
typeCodeHint: '{provider}で承認したらこのページに戻ってください。自動で続行します。',
|
|
182
|
+
codeGone: 'コードの有効期限が切れました。もう一度サインインしてください。',
|
|
183
|
+
back: '戻る',
|
|
184
|
+
retry: '再試行',
|
|
185
|
+
'role.admin': '管理者',
|
|
186
|
+
'role.collaborator': '共同作業者',
|
|
187
|
+
'role.viewer': '閲覧者',
|
|
188
|
+
'role.guest': 'ゲスト',
|
|
189
|
+
};
|
|
190
|
+
/** The words of each language of Ta, checked by scripts/check-i18n.ts. */
|
|
191
|
+
export const JOIN_WORDS = { 'zh-CN': zh, 'zh-TW': zhTw, 'en-US': en, 'ja-JP': ja };
|
|
81
192
|
export var JoinI18n;
|
|
82
193
|
(function (JoinI18n) {
|
|
194
|
+
var _a;
|
|
83
195
|
/** A provider in the words of the page: WeChat is 微信 in Chinese. */
|
|
84
196
|
function provider(one) {
|
|
85
197
|
const key = `provider.${one.id}`;
|
|
86
198
|
const name = key in zh ? t(key) : one.name;
|
|
87
199
|
// Latin among Chinese has a space on each side: 用 GitHub 登录, 用企业账号登录.
|
|
88
|
-
return JoinI18n.
|
|
200
|
+
return JoinI18n.cjk && /^[\x20-\x7e]+$/.test(name) ? ` ${name} ` : name;
|
|
89
201
|
}
|
|
90
202
|
JoinI18n.provider = provider;
|
|
91
203
|
/** A role of those that come with Ta in the words of the page; one of the owner's own as they named it. */
|
|
@@ -94,9 +206,27 @@ export var JoinI18n;
|
|
|
94
206
|
return key in zh ? t(key) : name;
|
|
95
207
|
}
|
|
96
208
|
JoinI18n.role = role;
|
|
97
|
-
|
|
209
|
+
/** The language the link was made in: `l` of the fragment, or of the link kept while signing in elsewhere. */
|
|
210
|
+
function linked() {
|
|
211
|
+
var _a, _b, _c;
|
|
212
|
+
if (typeof location === 'undefined') {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
let hash = location.hash;
|
|
216
|
+
try {
|
|
217
|
+
hash || (hash = new URL((_b = JSON.parse((_a = localStorage.getItem('ta-join:sign-in')) !== null && _a !== void 0 ? _a : '{}').href) !== null && _b !== void 0 ? _b : '').hash);
|
|
218
|
+
}
|
|
219
|
+
catch (_d) {
|
|
220
|
+
// No sign-in kept.
|
|
221
|
+
}
|
|
222
|
+
return (_c = new URLSearchParams(hash.slice(1)).get('l')) !== null && _c !== void 0 ? _c : undefined;
|
|
223
|
+
}
|
|
224
|
+
JoinI18n.language = typeof navigator === 'undefined' ? 'en-US' : linkLanguage(((_a = navigator.languages) === null || _a === void 0 ? void 0 : _a.length) ? navigator.languages : [navigator.language], linked());
|
|
225
|
+
/** Chinese or Japanese: Latin among the words has a space on each side. */
|
|
226
|
+
JoinI18n.cjk = JoinI18n.language !== 'en-US';
|
|
227
|
+
const words = JOIN_WORDS[JoinI18n.language];
|
|
98
228
|
function t(id, values = {}) {
|
|
99
|
-
return
|
|
229
|
+
return words[id].replace(/\{(\w+)\}/g, (_, name) => { var _a; return String((_a = values[name]) !== null && _a !== void 0 ? _a : ''); });
|
|
100
230
|
}
|
|
101
231
|
JoinI18n.t = t;
|
|
102
232
|
})(JoinI18n || (JoinI18n = {}));
|