@tik-choco/mistvault 0.0.0-stage → 0.3.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/LICENSE +373 -0
- package/README.ja.md +164 -0
- package/README.md +221 -2
- package/README.zh.md +164 -0
- package/dist/appState.d.ts +24 -0
- package/dist/appState.js +20 -0
- package/dist/code.d.ts +7 -0
- package/dist/code.js +49 -0
- package/dist/controller.d.ts +55 -0
- package/dist/controller.js +74 -0
- package/dist/core/client.d.ts +112 -0
- package/dist/core/client.js +536 -0
- package/dist/core/crypto.d.ts +24 -0
- package/dist/core/crypto.js +185 -0
- package/dist/core/head.d.ts +54 -0
- package/dist/core/head.js +123 -0
- package/dist/core/parse.d.ts +1 -0
- package/dist/core/parse.js +1 -0
- package/dist/core/protocol.d.ts +74 -0
- package/dist/core/protocol.js +93 -0
- package/dist/elements/PanelElement.d.ts +30 -0
- package/dist/elements/PanelElement.js +56 -0
- package/dist/elements/RoomControls.d.ts +21 -0
- package/dist/elements/RoomControls.js +27 -0
- package/dist/elements/ScopeVaultPanelElement.d.ts +10 -0
- package/dist/elements/ScopeVaultPanelElement.js +27 -0
- package/dist/elements/VaultPanelElement.d.ts +39 -0
- package/dist/elements/VaultPanelElement.js +191 -0
- package/dist/elements/dom.d.ts +14 -0
- package/dist/elements/dom.js +58 -0
- package/dist/elements/index.d.ts +15 -0
- package/dist/elements/index.js +12 -0
- package/dist/i18n.d.ts +132 -0
- package/dist/i18n.js +96 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/parts.d.ts +42 -0
- package/dist/parts.js +267 -0
- package/dist/preact/ScopeVaultPanel.d.ts +10 -0
- package/dist/preact/ScopeVaultPanel.js +8 -0
- package/dist/preact/VaultPanel.d.ts +16 -0
- package/dist/preact/VaultPanel.js +14 -0
- package/dist/preact/index.d.ts +5 -0
- package/dist/preact/index.js +3 -0
- package/dist/preact/ui.css +132 -0
- package/dist/preact/useVault.d.ts +6 -0
- package/dist/preact/useVault.js +13 -0
- package/dist/scopeKey.d.ts +1 -0
- package/dist/scopeKey.js +49 -0
- package/dist/scopeManager.d.ts +14 -0
- package/dist/scopeManager.js +110 -0
- package/dist/scopeVault.d.ts +39 -0
- package/dist/scopeVault.js +212 -0
- package/dist/session.d.ts +44 -0
- package/dist/session.js +736 -0
- package/dist/settings.d.ts +21 -0
- package/dist/settings.js +59 -0
- package/dist/stored.d.ts +4 -0
- package/dist/stored.js +27 -0
- package/dist/transport.d.ts +20 -0
- package/dist/transport.js +117 -0
- package/package.json +57 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScopeVault, ScopeVaultView } from '../scopeVault.js';
|
|
2
|
+
import { PanelElement } from './PanelElement.js';
|
|
3
|
+
export declare class ScopeVaultPanelElement extends PanelElement<ScopeVaultView, ScopeVault> {
|
|
4
|
+
private notice;
|
|
5
|
+
private rooms;
|
|
6
|
+
get vault(): ScopeVault | undefined;
|
|
7
|
+
set vault(value: ScopeVault | undefined);
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
protected renderPanel(view: ScopeVaultView, vault: ScopeVault): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { vaultMessage } from '../i18n.js';
|
|
2
|
+
import { PanelElement } from './PanelElement.js';
|
|
3
|
+
import { RoomControls } from './RoomControls.js';
|
|
4
|
+
import { selectInput } from './dom.js';
|
|
5
|
+
export class ScopeVaultPanelElement extends PanelElement {
|
|
6
|
+
notice = '';
|
|
7
|
+
rooms = new RoomControls(() => this.render());
|
|
8
|
+
get vault() { return this.source; }
|
|
9
|
+
set vault(value) { this.source = value; }
|
|
10
|
+
connectedCallback() { this.upgradeProperties(['vault', 'locale']); super.connectedCallback(); }
|
|
11
|
+
renderPanel(view, vault) {
|
|
12
|
+
const t = (key) => vaultMessage(this.locale, key);
|
|
13
|
+
const n = this.dom.node, busy = view.mode === 'off' || view.status === 'saving' || view.status === 'restoring';
|
|
14
|
+
const copyRoom = async () => {
|
|
15
|
+
try {
|
|
16
|
+
await navigator.clipboard.writeText(view.room);
|
|
17
|
+
this.notice = t('copied');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
this.notice = t('copyError');
|
|
21
|
+
}
|
|
22
|
+
this.render();
|
|
23
|
+
};
|
|
24
|
+
this.dom.finish(n('panel', 'section', { className: 'mv-panel mv-stack', attrs: { 'aria-label': t('title') } }, n('title', 'h2', {}, t('title')), n('status-card', 'div', { className: 'mv-status-card' }, n('status', 'div', { className: 'mv-status-text', attrs: { role: 'status', 'data-state': view.status } }, n('status-title', 'strong', {}, t(`status_${view.status}`)), !!view.error && n('status-error', 'span', { className: 'mv-error' }, view.error)), n('status-actions', 'div', { className: 'mv-actions' }, n('save', 'button', { type: 'button', disabled: busy, onclick: () => { void vault.saveNow(); } }, t('save')), n('restore', 'button', { type: 'button', disabled: busy, onclick: () => { void vault.restoreNow(); } }, t('restore')))), n('settings', 'div', { className: 'mv-stack' }, this.rooms.render(this.dom, { locale: this.locale, mode: view.mode, room: view.config.room,
|
|
25
|
+
controller: vault, disableUnchanged: !!view.config.by, onInvalid: () => { this.notice = t('invalidRoom'); this.render(); } })), view.mode !== 'off' && n('room', 'div', { className: 'mv-room' }, n('room-row', 'div', { className: 'mv-room-row' }, n('room-label', 'label', {}, t('room'), n('room-input', 'input', { readOnly: true, value: view.room, placeholder: t('roomPending'), onfocus: selectInput })), n('room-copy', 'button', { type: 'button', disabled: !view.room, onclick: () => { void copyRoom(); } }, t('copy'))), n('room-hint', 'p', { className: 'mv-muted mv-hint' }, t('scopeRoomHint'))), !!this.notice && n('notice', 'p', { className: 'mv-notice', attrs: { role: 'status' } }, this.notice)));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { VaultController, VaultView } from '../controller.js';
|
|
2
|
+
import { PanelElement } from './PanelElement.js';
|
|
3
|
+
export type PendingHandledResult = 'imported' | 'cancelled';
|
|
4
|
+
export declare class VaultPanelElement extends PanelElement<VaultView, VaultController> {
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
private rooms;
|
|
7
|
+
private visible;
|
|
8
|
+
private importing;
|
|
9
|
+
private input;
|
|
10
|
+
private inputError;
|
|
11
|
+
private suppliedCode?;
|
|
12
|
+
private propPending;
|
|
13
|
+
private localPending;
|
|
14
|
+
private linkConsumed;
|
|
15
|
+
private confirmError;
|
|
16
|
+
private notice;
|
|
17
|
+
private additionalRooms?;
|
|
18
|
+
private time;
|
|
19
|
+
private timer?;
|
|
20
|
+
private previous?;
|
|
21
|
+
get controller(): VaultController | undefined;
|
|
22
|
+
set controller(value: VaultController | undefined);
|
|
23
|
+
get appName(): string | undefined;
|
|
24
|
+
set appName(value: string | undefined);
|
|
25
|
+
get pendingCode(): string | null | undefined;
|
|
26
|
+
set pendingCode(value: string | null | undefined);
|
|
27
|
+
get extraRooms(): string[] | undefined;
|
|
28
|
+
set extraRooms(value: string[] | undefined);
|
|
29
|
+
connectedCallback(): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
31
|
+
private t;
|
|
32
|
+
private copy;
|
|
33
|
+
private resetImport;
|
|
34
|
+
private closeImport;
|
|
35
|
+
private importButton;
|
|
36
|
+
private prepareImport;
|
|
37
|
+
private finishPending;
|
|
38
|
+
protected renderPanel(view: VaultView, controller: VaultController): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { consumeVaultLink, parseVaultCode, vaultLink } from '../code.js';
|
|
2
|
+
import { vaultMessage } from '../i18n.js';
|
|
3
|
+
import { PanelElement } from './PanelElement.js';
|
|
4
|
+
import { RoomControls } from './RoomControls.js';
|
|
5
|
+
import { selectInput } from './dom.js';
|
|
6
|
+
export class VaultPanelElement extends PanelElement {
|
|
7
|
+
static observedAttributes = ['locale', 'app-name'];
|
|
8
|
+
rooms = new RoomControls(() => this.render());
|
|
9
|
+
visible = false;
|
|
10
|
+
importing = false;
|
|
11
|
+
input = '';
|
|
12
|
+
inputError = '';
|
|
13
|
+
suppliedCode;
|
|
14
|
+
propPending = null;
|
|
15
|
+
localPending = null;
|
|
16
|
+
linkConsumed = false;
|
|
17
|
+
confirmError = '';
|
|
18
|
+
notice = '';
|
|
19
|
+
additionalRooms;
|
|
20
|
+
time = Date.now();
|
|
21
|
+
timer;
|
|
22
|
+
previous;
|
|
23
|
+
get controller() { return this.source; }
|
|
24
|
+
set controller(value) { this.source = value; }
|
|
25
|
+
get appName() { return this.getAttribute('app-name') ?? undefined; }
|
|
26
|
+
set appName(value) { this.setStringAttribute('app-name', value); }
|
|
27
|
+
get pendingCode() { return this.suppliedCode; }
|
|
28
|
+
set pendingCode(value) {
|
|
29
|
+
if (value === this.suppliedCode)
|
|
30
|
+
return;
|
|
31
|
+
this.suppliedCode = value;
|
|
32
|
+
this.propPending = value || null;
|
|
33
|
+
this.render();
|
|
34
|
+
}
|
|
35
|
+
get extraRooms() { return this.additionalRooms; }
|
|
36
|
+
set extraRooms(value) { this.additionalRooms = value; this.render(); }
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
this.upgradeProperties(['controller', 'locale', 'appName', 'pendingCode', 'extraRooms']);
|
|
39
|
+
super.connectedCallback();
|
|
40
|
+
this.timer = setInterval(() => { this.time = Date.now(); this.render(); }, 60000);
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
clearInterval(this.timer);
|
|
44
|
+
this.timer = undefined;
|
|
45
|
+
this.visible = false;
|
|
46
|
+
this.render();
|
|
47
|
+
super.disconnectedCallback();
|
|
48
|
+
}
|
|
49
|
+
t = (key, values) => vaultMessage(this.locale, key, values);
|
|
50
|
+
async copy(value) {
|
|
51
|
+
try {
|
|
52
|
+
await navigator.clipboard.writeText(value);
|
|
53
|
+
this.notice = this.t('copied');
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
this.notice = this.t('copyError');
|
|
57
|
+
}
|
|
58
|
+
this.render();
|
|
59
|
+
}
|
|
60
|
+
resetImport() { this.importing = false; this.input = ''; this.inputError = ''; }
|
|
61
|
+
closeImport() {
|
|
62
|
+
this.resetImport();
|
|
63
|
+
this.render();
|
|
64
|
+
this.importButton()?.focus();
|
|
65
|
+
}
|
|
66
|
+
importButton() { return this.querySelector('button[aria-expanded]'); }
|
|
67
|
+
prepareImport() {
|
|
68
|
+
const code = parseVaultCode(this.input);
|
|
69
|
+
if (!code)
|
|
70
|
+
this.inputError = this.t('invalidCode');
|
|
71
|
+
else {
|
|
72
|
+
this.inputError = '';
|
|
73
|
+
this.notice = '';
|
|
74
|
+
this.localPending = code;
|
|
75
|
+
}
|
|
76
|
+
this.render();
|
|
77
|
+
}
|
|
78
|
+
finishPending(result) {
|
|
79
|
+
const supplied = this.propPending !== null;
|
|
80
|
+
if (supplied)
|
|
81
|
+
this.propPending = null;
|
|
82
|
+
else
|
|
83
|
+
this.localPending = null;
|
|
84
|
+
this.resetImport();
|
|
85
|
+
this.visible = false;
|
|
86
|
+
this.confirmError = '';
|
|
87
|
+
this.render();
|
|
88
|
+
if (supplied)
|
|
89
|
+
this.dispatchEvent(new CustomEvent('mistvault-pending-handled', { detail: result, bubbles: true }));
|
|
90
|
+
requestAnimationFrame(() => {
|
|
91
|
+
if (!this.isConnected || this.querySelector('.mv-confirm'))
|
|
92
|
+
return;
|
|
93
|
+
const button = this.importButton();
|
|
94
|
+
if (button?.isConnected && !button.closest('details:not([open])'))
|
|
95
|
+
button.focus();
|
|
96
|
+
else
|
|
97
|
+
this.querySelector('h2')?.focus();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
renderPanel(view, controller) {
|
|
101
|
+
if (!this.linkConsumed) {
|
|
102
|
+
this.linkConsumed = true;
|
|
103
|
+
try {
|
|
104
|
+
this.localPending = consumeVaultLink();
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
this.localPending = null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const prev = this.previous, changed = prev?.controller !== controller || prev.mode !== view.mode;
|
|
111
|
+
if (changed || prev.room !== view.room)
|
|
112
|
+
this.visible = false;
|
|
113
|
+
if (changed) {
|
|
114
|
+
this.resetImport();
|
|
115
|
+
this.notice = '';
|
|
116
|
+
}
|
|
117
|
+
if (view.mode === 'off' && prev?.mode !== 'off')
|
|
118
|
+
this.rooms = new RoomControls(() => this.render());
|
|
119
|
+
const pending = this.propPending ?? this.localPending, parsedPending = pending === null ? null : parseVaultCode(pending);
|
|
120
|
+
if (prev?.pending !== pending)
|
|
121
|
+
this.confirmError = '';
|
|
122
|
+
this.previous = { controller, mode: view.mode, room: view.room, pending, importing: this.importing };
|
|
123
|
+
const t = this.t, n = this.dom.node;
|
|
124
|
+
const button = (key, label, onclick, props = {}) => n(key, 'button', { type: 'button', onclick, ...props }, t(label));
|
|
125
|
+
const actions = (key, ...content) => n(key, 'div', { className: 'mv-actions' }, content);
|
|
126
|
+
const stack = (key, ...content) => n(key, 'div', { className: 'mv-stack' }, content);
|
|
127
|
+
const error = (key, message) => !!message && n(key, 'p', { className: 'mv-error', attrs: { role: 'alert' } }, message);
|
|
128
|
+
const confirm = pending !== null && n('confirm', 'div', { className: 'mv-confirm',
|
|
129
|
+
attrs: { role: 'group', tabindex: '-1', 'aria-label': t('pendingTitle') + ' ' + t(parsedPending ? 'confirmation' : 'invalidCode') } }, n('confirm-title', 'h3', {}, t('pendingTitle')), n('confirm-text', 'p', {}, t(parsedPending ? 'confirmation' : 'invalidCode')), error('confirm-error', this.confirmError), actions('confirm-actions', !!parsedPending && button('confirm-ok', 'confirm', () => {
|
|
130
|
+
if (!controller.importCode(parsedPending)) {
|
|
131
|
+
this.confirmError = t('importError');
|
|
132
|
+
this.render();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (view.mode === 'off')
|
|
136
|
+
controller.enable();
|
|
137
|
+
this.finishPending('imported');
|
|
138
|
+
}, { className: 'mv-primary' }), button('confirm-cancel', 'cancel', () => this.finishPending('cancelled'))));
|
|
139
|
+
const importButton = (label) => button('import-button', label, () => {
|
|
140
|
+
if (this.importing)
|
|
141
|
+
this.closeImport();
|
|
142
|
+
else {
|
|
143
|
+
this.importing = true;
|
|
144
|
+
this.render();
|
|
145
|
+
}
|
|
146
|
+
}, { attrs: { 'aria-expanded': String(this.importing) } });
|
|
147
|
+
const importForm = this.importing && n('import', 'div', { className: 'mv-import' }, n('import-label', 'label', {}, t('importLabel'), n('import-input', 'input', { type: 'password', value: this.input, autocomplete: 'off',
|
|
148
|
+
attrs: { 'aria-invalid': String(!!this.inputError) }, oninput: e => {
|
|
149
|
+
this.input = e.currentTarget.value;
|
|
150
|
+
this.inputError = '';
|
|
151
|
+
this.render();
|
|
152
|
+
}, onkeydown: e => {
|
|
153
|
+
if (e.key === 'Enter') {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
this.prepareImport();
|
|
156
|
+
}
|
|
157
|
+
else if (e.key === 'Escape')
|
|
158
|
+
this.closeImport();
|
|
159
|
+
} })), error('input-error', this.inputError), actions('import-actions', button('import-prepare', 'import', () => this.prepareImport(), { className: 'mv-primary' }), button('import-cancel', 'cancel', () => this.closeImport())));
|
|
160
|
+
const busy = view.status === 'saving' || view.status === 'restoring', enabled = view.appEnabled && view.hasCode;
|
|
161
|
+
const minutes = Math.max(0, Math.floor((Math.max(this.time, Date.now()) - view.savedAt) / 60000));
|
|
162
|
+
const savedTime = minutes < 1 ? t('savedNow') : minutes < 60 ? t('savedAgo', { minutes }) :
|
|
163
|
+
minutes < 1440 ? t('savedHoursAgo', { hours: Math.floor(minutes / 60) }) :
|
|
164
|
+
minutes < 2880 ? t('savedDayAgo') : t('savedDaysAgo', { days: Math.floor(minutes / 1440) });
|
|
165
|
+
const content = view.mode === 'off' ? n('welcome', 'div', { className: 'mv-welcome' }, n('explanation', 'p', { className: 'mv-muted' }, t('explanation')), stack('welcome-buttons', button('enable', 'turnOn', () => controller.enable(), { className: 'mv-primary' }), importButton('useCode')), importForm) : [
|
|
166
|
+
n('status-card', 'div', { className: 'mv-status-card' }, n('status', 'div', { className: 'mv-status-text', attrs: { role: 'status', 'aria-live': 'polite', 'data-state': !view.appEnabled ? 'off' : view.status } }, n('status-title', 'strong', {}, !view.appEnabled && view.status === 'off' ? t('status_appOff') : t(`status_${view.status}`)), view.savedAt > 0 && n('saved-time', 'span', { className: 'mv-muted' }, ' ', savedTime), !!view.error && n('status-error', 'span', { className: 'mv-error' }, ' ', view.error)), actions('status-actions', button('save', 'save', () => { void controller.saveNow(); }, { disabled: !enabled || busy }), button('restore', 'restore', () => { void controller.restoreNow(); }, { disabled: !enabled || busy }))),
|
|
167
|
+
n('switch', 'label', { className: 'mv-switch' }, n('switch-text', 'span', {}, t('app', { app: this.appName || t('appFallback') })), n('switch-input', 'input', { type: 'checkbox', attrs: { role: 'switch' }, checked: view.appEnabled,
|
|
168
|
+
onchange: e => controller.setAppEnabled(e.currentTarget.checked) })),
|
|
169
|
+
n('room', 'div', { className: 'mv-room' }, n('room-row', 'div', { className: 'mv-room-row' }, n('room-label', 'label', {}, t('room'), n('room-input', 'input', { readOnly: true, value: view.room,
|
|
170
|
+
placeholder: t(view.appEnabled ? 'roomPending' : 'roomUnavailable'), onfocus: selectInput })), button('room-copy', 'copy', () => { void this.copy(view.room); }, { disabled: !view.room })), n('room-hint', 'p', { className: 'mv-muted mv-hint' }, t('hint'))),
|
|
171
|
+
n('code-details', 'details', { className: 'mv-disclosure', ontoggle: e => {
|
|
172
|
+
if (!e.currentTarget.open && this.visible) {
|
|
173
|
+
this.visible = false;
|
|
174
|
+
this.render();
|
|
175
|
+
}
|
|
176
|
+
} }, n('code-summary', 'summary', {}, t('code')), n('code-body', 'div', { className: 'mv-disclosure-body' }, n('code-hint', 'p', { className: 'mv-muted' }, t('codeHint')), n('code-input', 'input', { className: 'mv-code', attrs: { 'aria-label': t('code') }, readOnly: true, type: this.visible ? 'text' : 'password',
|
|
177
|
+
value: this.visible ? controller.revealCode() ?? '' : view.hasCode ? '0000000000000000' : '', autocomplete: 'off', onfocus: selectInput }), actions('code-actions', button('reveal', this.visible ? 'hide' : 'reveal', () => { this.visible = !this.visible; this.render(); }, { disabled: !view.hasCode }), button('code-copy', 'copy', () => { const code = controller.revealCode(); if (code)
|
|
178
|
+
void this.copy(code); }, { disabled: !view.hasCode })), stack('code-stack', button('link', 'link', () => { const code = controller.revealCode(); if (code)
|
|
179
|
+
void this.copy(vaultLink(window.location.href, code)); }, { disabled: !view.hasCode }), importButton('importAnother')), importForm)),
|
|
180
|
+
n('advanced-details', 'details', { className: 'mv-disclosure' }, n('advanced-summary', 'summary', {}, t('advanced')), n('advanced-body', 'div', { className: 'mv-disclosure-body' }, this.rooms.render(this.dom, { locale: this.locale, mode: view.mode, room: view.room, controller,
|
|
181
|
+
onInvalid: () => { this.notice = t('invalid'); this.render(); } }))),
|
|
182
|
+
!!view.hasParts && n('parts', 'p', { className: 'mv-parts mv-muted' }, t('parts', view.parts)),
|
|
183
|
+
];
|
|
184
|
+
const additional = [...new Set(this.extraRooms)].filter(room => room && room !== view.room);
|
|
185
|
+
this.dom.finish(n('panel', 'section', { className: 'mv-panel', attrs: { 'aria-label': t('title') } }, confirm, n('title', 'h2', { attrs: { tabindex: '-1' } }, t('title')), content, additional.length > 0 && stack('extra-rooms', n('extra-title', 'h3', {}, t('extraRooms')), n('extra-list', 'ul', {}, additional.map(room => n('extra:' + room, 'li', {}, room))), button('copy-all', 'copyAll', () => { void this.copy(additional.join('\n')); })), !!this.notice && n('notice', 'p', { className: 'mv-notice', attrs: { role: 'status' } }, this.notice)));
|
|
186
|
+
if (this.importing && !prev?.importing)
|
|
187
|
+
this.querySelector('.mv-import input')?.focus();
|
|
188
|
+
if (pending !== null && prev?.pending !== pending)
|
|
189
|
+
this.querySelector('.mv-confirm')?.focus();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Child = Node | string | false | null | undefined | Child[];
|
|
2
|
+
type Props<K extends keyof HTMLElementTagNameMap> = Partial<HTMLElementTagNameMap[K]> & {
|
|
3
|
+
attrs?: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
export declare class Dom {
|
|
6
|
+
private host;
|
|
7
|
+
private nodes;
|
|
8
|
+
private used;
|
|
9
|
+
constructor(host: HTMLElement);
|
|
10
|
+
node: <K extends keyof HTMLElementTagNameMap>(key: string, tag: K, props: Props<K>, ...content: Child[]) => HTMLElementTagNameMap[K];
|
|
11
|
+
finish(...content: Child[]): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const selectInput: (e: FocusEvent) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function flatten(values) {
|
|
2
|
+
return values.flatMap(value => Array.isArray(value) ? flatten(value) : value === false || value == null ? [] : [value]);
|
|
3
|
+
}
|
|
4
|
+
function children(parent, values) {
|
|
5
|
+
const next = flatten(values).map((value, i) => {
|
|
6
|
+
if (typeof value !== 'string')
|
|
7
|
+
return value;
|
|
8
|
+
const old = parent.childNodes[i];
|
|
9
|
+
if (old?.nodeType === 3) {
|
|
10
|
+
if (old.nodeValue !== value)
|
|
11
|
+
old.nodeValue = value;
|
|
12
|
+
return old;
|
|
13
|
+
}
|
|
14
|
+
return parent.ownerDocument.createTextNode(value);
|
|
15
|
+
});
|
|
16
|
+
const wanted = new Set(next);
|
|
17
|
+
for (const child of Array.from(parent.childNodes))
|
|
18
|
+
if (!wanted.has(child))
|
|
19
|
+
parent.removeChild(child);
|
|
20
|
+
let cursor = parent.firstChild;
|
|
21
|
+
for (const child of next) {
|
|
22
|
+
if (child !== cursor)
|
|
23
|
+
parent.insertBefore(child, cursor);
|
|
24
|
+
cursor = child.nextSibling;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class Dom {
|
|
28
|
+
host;
|
|
29
|
+
nodes = new Map();
|
|
30
|
+
used = new Set();
|
|
31
|
+
constructor(host) {
|
|
32
|
+
this.host = host;
|
|
33
|
+
}
|
|
34
|
+
node = (key, tag, props, ...content) => {
|
|
35
|
+
let node = this.nodes.get(key);
|
|
36
|
+
if (!node) {
|
|
37
|
+
node = this.host.ownerDocument.createElement(tag);
|
|
38
|
+
this.nodes.set(key, node);
|
|
39
|
+
}
|
|
40
|
+
this.used.add(key);
|
|
41
|
+
children(node, content);
|
|
42
|
+
for (const [name, value] of Object.entries(props.attrs ?? {}))
|
|
43
|
+
if (node.getAttribute(name) !== value)
|
|
44
|
+
node.setAttribute(name, value);
|
|
45
|
+
for (const [name, value] of Object.entries(props))
|
|
46
|
+
if (name !== 'attrs' && Reflect.get(node, name) !== value)
|
|
47
|
+
Reflect.set(node, name, value);
|
|
48
|
+
return node;
|
|
49
|
+
};
|
|
50
|
+
finish(...content) {
|
|
51
|
+
children(this.host, content);
|
|
52
|
+
for (const key of this.nodes.keys())
|
|
53
|
+
if (!this.used.has(key))
|
|
54
|
+
this.nodes.delete(key);
|
|
55
|
+
this.used.clear();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export const selectInput = (e) => e.currentTarget.select();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VaultPanelElement } from './VaultPanelElement.js';
|
|
2
|
+
import { ScopeVaultPanelElement } from './ScopeVaultPanelElement.js';
|
|
3
|
+
import type { PendingHandledResult } from './VaultPanelElement.js';
|
|
4
|
+
export { VaultPanelElement, ScopeVaultPanelElement };
|
|
5
|
+
export type { PendingHandledResult };
|
|
6
|
+
declare global {
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
'mistvault-panel': VaultPanelElement;
|
|
9
|
+
'mistvault-scope-panel': ScopeVaultPanelElement;
|
|
10
|
+
}
|
|
11
|
+
interface HTMLElementEventMap {
|
|
12
|
+
'mistvault-pending-handled': CustomEvent<PendingHandledResult>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare function defineMistvaultElements(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VaultPanelElement } from './VaultPanelElement.js';
|
|
2
|
+
import { ScopeVaultPanelElement } from './ScopeVaultPanelElement.js';
|
|
3
|
+
export { VaultPanelElement, ScopeVaultPanelElement };
|
|
4
|
+
export function defineMistvaultElements() {
|
|
5
|
+
if (typeof customElements === 'undefined' || typeof HTMLElement === 'undefined')
|
|
6
|
+
return;
|
|
7
|
+
if (!customElements.get('mistvault-panel'))
|
|
8
|
+
customElements.define('mistvault-panel', VaultPanelElement);
|
|
9
|
+
if (!customElements.get('mistvault-scope-panel'))
|
|
10
|
+
customElements.define('mistvault-scope-panel', ScopeVaultPanelElement);
|
|
11
|
+
}
|
|
12
|
+
defineMistvaultElements();
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
readonly title: "Distributed vault";
|
|
3
|
+
readonly scopeRoomHint: "Add this room to mistl (Storage → Escrow).";
|
|
4
|
+
readonly extraRooms: "Additional mistl rooms";
|
|
5
|
+
readonly copyAll: "Copy all rooms";
|
|
6
|
+
readonly invalidRoom: "Invalid mistl room.";
|
|
7
|
+
readonly explanation: "Your data is encrypted in this browser and stored on your mistl node. mistl cannot read it. Keep your vault code secret: anyone with it can read and write your vault.";
|
|
8
|
+
readonly master: "Enable personal vault";
|
|
9
|
+
readonly app: "Back up {app} data";
|
|
10
|
+
readonly appFallback: "this app";
|
|
11
|
+
readonly turnOn: "Turn on the distributed vault";
|
|
12
|
+
readonly useCode: "Use a code from another device";
|
|
13
|
+
readonly save: "Save now";
|
|
14
|
+
readonly restore: "Restore now";
|
|
15
|
+
readonly room: "mistl room";
|
|
16
|
+
readonly hint: "Add in mistl: Storage → Distributed vault";
|
|
17
|
+
readonly roomPending: "Preparing room…";
|
|
18
|
+
readonly roomUnavailable: "Available when backup is on";
|
|
19
|
+
readonly advanced: "Advanced";
|
|
20
|
+
readonly mode: "Mode";
|
|
21
|
+
readonly auto: "Automatic";
|
|
22
|
+
readonly custom: "Custom";
|
|
23
|
+
readonly off: "Off";
|
|
24
|
+
readonly apply: "Apply";
|
|
25
|
+
readonly code: "Vault code";
|
|
26
|
+
readonly codeHint: "Keep this code private. Anyone with it can read and write your vault.";
|
|
27
|
+
readonly reveal: "Reveal";
|
|
28
|
+
readonly hide: "Hide";
|
|
29
|
+
readonly copy: "Copy";
|
|
30
|
+
readonly copied: "Copied";
|
|
31
|
+
readonly link: "Copy link for another device";
|
|
32
|
+
readonly import: "Import code";
|
|
33
|
+
readonly importAnother: "Import another code";
|
|
34
|
+
readonly importLabel: "Code from another device";
|
|
35
|
+
readonly pendingTitle: "Use a code from another device?";
|
|
36
|
+
readonly confirmation: "Your local data stays on this device. If you already use a vault, this switches it to the new code.";
|
|
37
|
+
readonly confirm: "Confirm import";
|
|
38
|
+
readonly cancel: "Cancel";
|
|
39
|
+
readonly invalid: "Invalid vault code or room.";
|
|
40
|
+
readonly copyError: "Copy failed. Select and copy the value manually.";
|
|
41
|
+
readonly invalidCode: "Invalid vault code.";
|
|
42
|
+
readonly importError: "Could not import this vault code.";
|
|
43
|
+
readonly savedNow: "Saved just now";
|
|
44
|
+
readonly savedAgo: "Saved {minutes} min ago";
|
|
45
|
+
readonly savedHoursAgo: "Saved {hours} hr ago";
|
|
46
|
+
readonly savedDayAgo: "Saved 1 day ago";
|
|
47
|
+
readonly savedDaysAgo: "Saved {days} days ago";
|
|
48
|
+
readonly parts: "Attachments: {stored} stored, {pending} pending, {omitted} omitted";
|
|
49
|
+
readonly status_off: "Vault is off";
|
|
50
|
+
readonly status_appOff: "Backup is off for this app";
|
|
51
|
+
readonly status_searching: "Searching for mistl…";
|
|
52
|
+
readonly status_noProvider: "No provider found; still listening";
|
|
53
|
+
readonly status_restoring: "Restoring…";
|
|
54
|
+
readonly status_saving: "Saving…";
|
|
55
|
+
readonly status_saved: "Saved";
|
|
56
|
+
readonly status_restored: "Restored";
|
|
57
|
+
readonly status_upToDate: "Up to date";
|
|
58
|
+
readonly status_error: "Vault operation failed";
|
|
59
|
+
};
|
|
60
|
+
type ScopeMessage = 'scopeRoomHint' | 'extraRooms' | 'copyAll' | 'invalidRoom';
|
|
61
|
+
export type VaultMessages = Record<Exclude<keyof typeof en, ScopeMessage>, string> & Partial<Record<ScopeMessage, string>>;
|
|
62
|
+
export declare const ja: VaultMessages;
|
|
63
|
+
export declare const zhCN: VaultMessages;
|
|
64
|
+
export declare const zhTW: VaultMessages;
|
|
65
|
+
export declare const messages: {
|
|
66
|
+
en: {
|
|
67
|
+
readonly title: "Distributed vault";
|
|
68
|
+
readonly scopeRoomHint: "Add this room to mistl (Storage → Escrow).";
|
|
69
|
+
readonly extraRooms: "Additional mistl rooms";
|
|
70
|
+
readonly copyAll: "Copy all rooms";
|
|
71
|
+
readonly invalidRoom: "Invalid mistl room.";
|
|
72
|
+
readonly explanation: "Your data is encrypted in this browser and stored on your mistl node. mistl cannot read it. Keep your vault code secret: anyone with it can read and write your vault.";
|
|
73
|
+
readonly master: "Enable personal vault";
|
|
74
|
+
readonly app: "Back up {app} data";
|
|
75
|
+
readonly appFallback: "this app";
|
|
76
|
+
readonly turnOn: "Turn on the distributed vault";
|
|
77
|
+
readonly useCode: "Use a code from another device";
|
|
78
|
+
readonly save: "Save now";
|
|
79
|
+
readonly restore: "Restore now";
|
|
80
|
+
readonly room: "mistl room";
|
|
81
|
+
readonly hint: "Add in mistl: Storage → Distributed vault";
|
|
82
|
+
readonly roomPending: "Preparing room…";
|
|
83
|
+
readonly roomUnavailable: "Available when backup is on";
|
|
84
|
+
readonly advanced: "Advanced";
|
|
85
|
+
readonly mode: "Mode";
|
|
86
|
+
readonly auto: "Automatic";
|
|
87
|
+
readonly custom: "Custom";
|
|
88
|
+
readonly off: "Off";
|
|
89
|
+
readonly apply: "Apply";
|
|
90
|
+
readonly code: "Vault code";
|
|
91
|
+
readonly codeHint: "Keep this code private. Anyone with it can read and write your vault.";
|
|
92
|
+
readonly reveal: "Reveal";
|
|
93
|
+
readonly hide: "Hide";
|
|
94
|
+
readonly copy: "Copy";
|
|
95
|
+
readonly copied: "Copied";
|
|
96
|
+
readonly link: "Copy link for another device";
|
|
97
|
+
readonly import: "Import code";
|
|
98
|
+
readonly importAnother: "Import another code";
|
|
99
|
+
readonly importLabel: "Code from another device";
|
|
100
|
+
readonly pendingTitle: "Use a code from another device?";
|
|
101
|
+
readonly confirmation: "Your local data stays on this device. If you already use a vault, this switches it to the new code.";
|
|
102
|
+
readonly confirm: "Confirm import";
|
|
103
|
+
readonly cancel: "Cancel";
|
|
104
|
+
readonly invalid: "Invalid vault code or room.";
|
|
105
|
+
readonly copyError: "Copy failed. Select and copy the value manually.";
|
|
106
|
+
readonly invalidCode: "Invalid vault code.";
|
|
107
|
+
readonly importError: "Could not import this vault code.";
|
|
108
|
+
readonly savedNow: "Saved just now";
|
|
109
|
+
readonly savedAgo: "Saved {minutes} min ago";
|
|
110
|
+
readonly savedHoursAgo: "Saved {hours} hr ago";
|
|
111
|
+
readonly savedDayAgo: "Saved 1 day ago";
|
|
112
|
+
readonly savedDaysAgo: "Saved {days} days ago";
|
|
113
|
+
readonly parts: "Attachments: {stored} stored, {pending} pending, {omitted} omitted";
|
|
114
|
+
readonly status_off: "Vault is off";
|
|
115
|
+
readonly status_appOff: "Backup is off for this app";
|
|
116
|
+
readonly status_searching: "Searching for mistl…";
|
|
117
|
+
readonly status_noProvider: "No provider found; still listening";
|
|
118
|
+
readonly status_restoring: "Restoring…";
|
|
119
|
+
readonly status_saving: "Saving…";
|
|
120
|
+
readonly status_saved: "Saved";
|
|
121
|
+
readonly status_restored: "Restored";
|
|
122
|
+
readonly status_upToDate: "Up to date";
|
|
123
|
+
readonly status_error: "Vault operation failed";
|
|
124
|
+
};
|
|
125
|
+
ja: VaultMessages;
|
|
126
|
+
'zh-CN': VaultMessages;
|
|
127
|
+
'zh-TW': VaultMessages;
|
|
128
|
+
};
|
|
129
|
+
export type VaultLocale = keyof typeof messages;
|
|
130
|
+
export declare function resolveLocale(locale?: string): VaultLocale;
|
|
131
|
+
export declare function vaultMessage(locale: string | undefined, key: keyof VaultMessages, values?: Record<string, string | number>): string;
|
|
132
|
+
export {};
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
title: 'Distributed vault',
|
|
3
|
+
scopeRoomHint: 'Add this room to mistl (Storage → Escrow).', extraRooms: 'Additional mistl rooms', copyAll: 'Copy all rooms', invalidRoom: 'Invalid mistl room.',
|
|
4
|
+
explanation: 'Your data is encrypted in this browser and stored on your mistl node. mistl cannot read it. Keep your vault code secret: anyone with it can read and write your vault.',
|
|
5
|
+
master: 'Enable personal vault', app: 'Back up {app} data', appFallback: 'this app',
|
|
6
|
+
turnOn: 'Turn on the distributed vault', useCode: 'Use a code from another device',
|
|
7
|
+
save: 'Save now', restore: 'Restore now', room: 'mistl room',
|
|
8
|
+
hint: 'Add in mistl: Storage → Distributed vault', roomPending: 'Preparing room…', roomUnavailable: 'Available when backup is on', advanced: 'Advanced',
|
|
9
|
+
mode: 'Mode', auto: 'Automatic', custom: 'Custom', off: 'Off', apply: 'Apply',
|
|
10
|
+
code: 'Vault code', codeHint: 'Keep this code private. Anyone with it can read and write your vault.', reveal: 'Reveal', hide: 'Hide', copy: 'Copy', copied: 'Copied',
|
|
11
|
+
link: 'Copy link for another device', import: 'Import code', importAnother: 'Import another code', importLabel: 'Code from another device',
|
|
12
|
+
pendingTitle: 'Use a code from another device?',
|
|
13
|
+
confirmation: 'Your local data stays on this device. If you already use a vault, this switches it to the new code.',
|
|
14
|
+
confirm: 'Confirm import', cancel: 'Cancel', invalid: 'Invalid vault code or room.', copyError: 'Copy failed. Select and copy the value manually.',
|
|
15
|
+
invalidCode: 'Invalid vault code.', importError: 'Could not import this vault code.',
|
|
16
|
+
savedNow: 'Saved just now', savedAgo: 'Saved {minutes} min ago', savedHoursAgo: 'Saved {hours} hr ago', savedDayAgo: 'Saved 1 day ago', savedDaysAgo: 'Saved {days} days ago',
|
|
17
|
+
parts: 'Attachments: {stored} stored, {pending} pending, {omitted} omitted',
|
|
18
|
+
status_off: 'Vault is off', status_appOff: 'Backup is off for this app', status_searching: 'Searching for mistl…', status_noProvider: 'No provider found; still listening',
|
|
19
|
+
status_restoring: 'Restoring…', status_saving: 'Saving…', status_saved: 'Saved', status_restored: 'Restored',
|
|
20
|
+
status_upToDate: 'Up to date', status_error: 'Vault operation failed',
|
|
21
|
+
};
|
|
22
|
+
export const ja = {
|
|
23
|
+
title: '分散保管庫',
|
|
24
|
+
scopeRoomHint: 'このルームを mistl の「ストレージ → エスクロー」に追加してください。', extraRooms: '追加の mistl ルーム', copyAll: 'すべてのルームをコピー', invalidRoom: 'mistl ルームが無効です。',
|
|
25
|
+
explanation: 'データはこのブラウザーで暗号化され、あなたの mistl ノードに保存されます。mistl は内容を読めません。保管庫コードを知る人は読み書きできるため、秘密にしてください。',
|
|
26
|
+
master: '個人保管庫を有効にする', app: '{app} のデータをバックアップ', appFallback: 'このアプリ',
|
|
27
|
+
turnOn: '分散保管庫を有効にする', useCode: '別の端末のコードを使う',
|
|
28
|
+
save: '今すぐ保存', restore: '今すぐ復元', room: 'mistl ルーム',
|
|
29
|
+
hint: 'mistl の「ストレージ → 分散保管庫」に追加', roomPending: 'ルームを準備中…', roomUnavailable: 'バックアップを有効にすると表示', advanced: '詳細設定',
|
|
30
|
+
mode: 'モード', auto: '自動', custom: 'カスタム', off: '無効', apply: '適用',
|
|
31
|
+
code: '保管庫コード', codeHint: 'このコードは秘密にしてください。知っている人は保管庫を読み書きできます。', reveal: '表示', hide: '隠す', copy: 'コピー', copied: 'コピーしました',
|
|
32
|
+
link: '別の端末用リンクをコピー', import: 'コードを読み込む', importAnother: '別のコードを読み込む', importLabel: '別の端末のコード',
|
|
33
|
+
pendingTitle: '別の端末のコードを使いますか?',
|
|
34
|
+
confirmation: 'ローカルデータはこの端末に残ります。すでに保管庫を使用している場合は、新しいコードに切り替わります。',
|
|
35
|
+
confirm: '読み込みを確認', cancel: 'キャンセル', invalid: '保管庫コードまたはルームが無効です。', copyError: 'コピーできませんでした。値を選択して手動でコピーしてください。',
|
|
36
|
+
invalidCode: '保管庫コードが無効です。', importError: '保管庫コードを読み込めませんでした。',
|
|
37
|
+
savedNow: 'たった今保存', savedAgo: '{minutes} 分前に保存', savedHoursAgo: '{hours} 時間前に保存', savedDayAgo: '1 日前に保存', savedDaysAgo: '{days} 日前に保存',
|
|
38
|
+
parts: '添付ファイル:保存済み {stored}、待機中 {pending}、省略 {omitted}',
|
|
39
|
+
status_off: '保管庫は無効です', status_appOff: 'このアプリのバックアップは無効です', status_searching: 'mistl を検索中…', status_noProvider: 'プロバイダーが見つかりません。引き続き待機中',
|
|
40
|
+
status_restoring: '復元中…', status_saving: '保存中…', status_saved: '保存しました', status_restored: '復元しました',
|
|
41
|
+
status_upToDate: '最新です', status_error: '保管庫の操作に失敗しました',
|
|
42
|
+
};
|
|
43
|
+
export const zhCN = {
|
|
44
|
+
title: '分布式保管库',
|
|
45
|
+
scopeRoomHint: '请将此房间添加到 mistl 的“存储 → 托管”中。', extraRooms: '其他 mistl 房间', copyAll: '复制所有房间', invalidRoom: 'mistl 房间无效。',
|
|
46
|
+
explanation: '数据在此浏览器中加密,并存储在您的 mistl 节点上。mistl 无法读取内容。持有保管库代码的人可以读写数据,请妥善保密。',
|
|
47
|
+
master: '启用个人保管库', app: '备份{app}的数据', appFallback: '此应用',
|
|
48
|
+
turnOn: '启用分布式保管库', useCode: '使用其他设备的代码',
|
|
49
|
+
save: '立即保存', restore: '立即恢复', room: 'mistl 房间',
|
|
50
|
+
hint: '在 mistl 的“存储 → 分布式保管库”中添加', roomPending: '正在准备房间…', roomUnavailable: '启用备份后显示', advanced: '高级设置',
|
|
51
|
+
mode: '模式', auto: '自动', custom: '自定义', off: '关闭', apply: '应用',
|
|
52
|
+
code: '保管库代码', codeHint: '请妥善保密此代码。持有者可以读写您的保管库。', reveal: '显示', hide: '隐藏', copy: '复制', copied: '已复制',
|
|
53
|
+
link: '复制其他设备的链接', import: '导入代码', importAnother: '导入其他代码', importLabel: '其他设备的代码',
|
|
54
|
+
pendingTitle: '使用其他设备的代码?',
|
|
55
|
+
confirmation: '本地数据会保留在此设备上。如果您已使用保管库,此操作会切换到新代码。',
|
|
56
|
+
confirm: '确认导入', cancel: '取消', invalid: '保管库代码或房间无效。', copyError: '复制失败。请选中该值并手动复制。',
|
|
57
|
+
invalidCode: '保管库代码无效。', importError: '无法导入此保管库代码。',
|
|
58
|
+
savedNow: '刚刚保存', savedAgo: '{minutes} 分钟前保存', savedHoursAgo: '{hours} 小时前保存', savedDayAgo: '1 天前保存', savedDaysAgo: '{days} 天前保存',
|
|
59
|
+
parts: '附件:已存储 {stored},待处理 {pending},已省略 {omitted}',
|
|
60
|
+
status_off: '保管库已关闭', status_appOff: '此应用的备份已关闭', status_searching: '正在查找 mistl…', status_noProvider: '未找到提供者,继续等待',
|
|
61
|
+
status_restoring: '正在恢复…', status_saving: '正在保存…', status_saved: '已保存', status_restored: '已恢复',
|
|
62
|
+
status_upToDate: '已是最新', status_error: '保管库操作失败',
|
|
63
|
+
};
|
|
64
|
+
export const zhTW = {
|
|
65
|
+
title: '分散式保管庫',
|
|
66
|
+
scopeRoomHint: '請將此房間新增至 mistl 的「儲存空間 → 託管」。', extraRooms: '其他 mistl 房間', copyAll: '複製所有房間', invalidRoom: 'mistl 房間無效。',
|
|
67
|
+
explanation: '資料在此瀏覽器中加密,並儲存在您的 mistl 節點上。mistl 無法讀取內容。持有保管庫代碼的人可以讀寫資料,請妥善保密。',
|
|
68
|
+
master: '啟用個人保管庫', app: '備份{app}的資料', appFallback: '此應用程式',
|
|
69
|
+
turnOn: '啟用分散式保管庫', useCode: '使用其他裝置的代碼',
|
|
70
|
+
save: '立即儲存', restore: '立即還原', room: 'mistl 房間',
|
|
71
|
+
hint: '在 mistl 的「儲存空間 → 分散式保管庫」中新增', roomPending: '正在準備房間…', roomUnavailable: '啟用備份後顯示', advanced: '進階設定',
|
|
72
|
+
mode: '模式', auto: '自動', custom: '自訂', off: '關閉', apply: '套用',
|
|
73
|
+
code: '保管庫代碼', codeHint: '請妥善保密此代碼。持有者可以讀寫您的保管庫。', reveal: '顯示', hide: '隱藏', copy: '複製', copied: '已複製',
|
|
74
|
+
link: '複製其他裝置的連結', import: '匯入代碼', importAnother: '匯入其他代碼', importLabel: '其他裝置的代碼',
|
|
75
|
+
pendingTitle: '使用其他裝置的代碼?',
|
|
76
|
+
confirmation: '本機資料會保留在此裝置上。如果您已使用保管庫,此操作會切換到新代碼。',
|
|
77
|
+
confirm: '確認匯入', cancel: '取消', invalid: '保管庫代碼或房間無效。', copyError: '複製失敗。請選取該值並手動複製。',
|
|
78
|
+
invalidCode: '保管庫代碼無效。', importError: '無法匯入此保管庫代碼。',
|
|
79
|
+
savedNow: '剛剛儲存', savedAgo: '{minutes} 分鐘前儲存', savedHoursAgo: '{hours} 小時前儲存', savedDayAgo: '1 天前儲存', savedDaysAgo: '{days} 天前儲存',
|
|
80
|
+
parts: '附件:已儲存 {stored},待處理 {pending},已省略 {omitted}',
|
|
81
|
+
status_off: '保管庫已關閉', status_appOff: '此應用程式的備份已關閉', status_searching: '正在尋找 mistl…', status_noProvider: '未找到提供者,繼續等待',
|
|
82
|
+
status_restoring: '正在還原…', status_saving: '正在儲存…', status_saved: '已儲存', status_restored: '已還原',
|
|
83
|
+
status_upToDate: '已是最新', status_error: '保管庫操作失敗',
|
|
84
|
+
};
|
|
85
|
+
export const messages = { en, ja, 'zh-CN': zhCN, 'zh-TW': zhTW };
|
|
86
|
+
export function resolveLocale(locale = globalThis.navigator?.language ?? 'en') {
|
|
87
|
+
const language = locale.toLowerCase();
|
|
88
|
+
if (language.startsWith('ja'))
|
|
89
|
+
return 'ja';
|
|
90
|
+
if (language.startsWith('zh'))
|
|
91
|
+
return /(?:tw|hk|mo|hant)/.test(language) ? 'zh-TW' : 'zh-CN';
|
|
92
|
+
return 'en';
|
|
93
|
+
}
|
|
94
|
+
export function vaultMessage(locale, key, values = {}) {
|
|
95
|
+
return (messages[resolveLocale(locale)][key] ?? en[key]).replace(/\{(\w+)\}/g, (match, name) => String(values[name] ?? match));
|
|
96
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './core/crypto.js';
|
|
2
|
+
export * from './core/head.js';
|
|
3
|
+
export * from './core/protocol.js';
|
|
4
|
+
export * from './core/client.js';
|
|
5
|
+
export * from './code.js';
|
|
6
|
+
export * from './settings.js';
|
|
7
|
+
export * from './transport.js';
|
|
8
|
+
export * from './controller.js';
|
|
9
|
+
export { createScopeVault, defaultScopeConfig, scopeInviteParam, parseScopeInviteParam } from './scopeVault.js';
|
|
10
|
+
export type { ScopeConfig, ScopeVaultOptions, ScopeVaultView, ScopeVault } from './scopeVault.js';
|
|
11
|
+
export * from './scopeManager.js';
|
|
12
|
+
export * from './parts.js';
|
|
13
|
+
export * from './i18n.js';
|