pi-pocket 0.28.0-beta.9 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/contrib/systemd/pi-pocket@.service +1 -1
- package/docs/architecture.md +1 -1
- package/docs/extensions/reference/api-versions.md +4 -0
- package/docs/extensions/reference/theme-surface.md +1 -1
- package/docs/extensions/reference/web.md +1 -1
- package/docs/extensions/themes.md +1 -0
- package/docs/features.md +1 -1
- package/docs/map.md +47 -42
- package/docs/systemd.md +2 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/server/design/system.ts +7 -0
- package/src/server/main.ts +15 -0
- package/types/pocket.d.ts +1 -1
- package/web/browser-panel.js +13 -25
- package/web/extension-ui.js +15 -1
- package/web/files-panel.js +13 -24
- package/web/history.js +1 -4
- package/web/person-storage.js +60 -2
- package/web/running-board.js +3 -2
- package/web/session-cache.js +26 -2
- package/web/sessions.js +501 -207
- package/web/store.js +3 -0
- package/web/style.css +111 -32
- package/web/transcript.js +158 -15
- package/web/ui.js +100 -24
- package/web/window-controls.js +7 -4
package/web/history.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
// What this person sent from this browser in one session, oldest first: ↑ recalls it and Ctrl+R searches it.
|
|
2
|
-
import { personStorage } from "./person-storage.js";
|
|
3
|
-
|
|
4
|
-
const KEY = "history";
|
|
5
|
-
const MAX = 200;
|
|
2
|
+
import { HISTORY as KEY, HISTORY_MAX as MAX, personStorage } from "./person-storage.js";
|
|
6
3
|
|
|
7
4
|
/** All of this person's scoped records, bounded together across sessions. */
|
|
8
5
|
function readHistory(person) {
|
package/web/person-storage.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// Browser-local content belongs to a person, never to the next account that uses this browser.
|
|
2
2
|
const PREFIX = "pocket.person.";
|
|
3
|
+
|
|
4
|
+
/** What `history.js` keeps for a person, and how many records. */
|
|
5
|
+
export const HISTORY = "history";
|
|
6
|
+
export const HISTORY_MAX = 200;
|
|
7
|
+
/** The records of every person that 0.27 kept together: each one names its person. */
|
|
8
|
+
const OLD_HISTORY = "pocket.history.v2";
|
|
3
9
|
// Old versions did not know whose drafts these were. Do not assign them to whoever signs in next.
|
|
4
10
|
const legacy = (key) =>
|
|
5
11
|
/^(pocket\.(draft\.|pastes\.|attached\.|viewed\.|history(?:$|\.)|pip\.draft$))/.test(key);
|
|
@@ -35,7 +41,52 @@ export function createPersonStorage(storage = () => localStorage) {
|
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Move the sent text that 0.27 kept for `account` to its own key, before the old ones, and leave other people's to
|
|
46
|
+
* them: it is theirs when they sign in. Nothing moves if the new key cannot be written.
|
|
47
|
+
*/
|
|
48
|
+
const moveOldHistory = (account) => {
|
|
49
|
+
try {
|
|
50
|
+
const disk = storage();
|
|
51
|
+
let old;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
old = JSON.parse(disk.getItem(OLD_HISTORY) ?? "[]");
|
|
55
|
+
} catch {
|
|
56
|
+
old = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// No records at all: nothing in it is anybody's.
|
|
60
|
+
if (!Array.isArray(old) || old.length === 0) {
|
|
61
|
+
disk.removeItem(OLD_HISTORY);
|
|
62
|
+
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const mine = old.filter((each) => each?.person === account);
|
|
67
|
+
|
|
68
|
+
if (mine.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const now = JSON.parse(self.get(HISTORY, account) ?? "[]");
|
|
73
|
+
const kept = [...mine, ...(Array.isArray(now) ? now : [])].slice(-HISTORY_MAX);
|
|
74
|
+
|
|
75
|
+
if (self.set(HISTORY, JSON.stringify(kept), account)) {
|
|
76
|
+
const others = old.filter((each) => each?.person !== account);
|
|
77
|
+
|
|
78
|
+
if (others.length === 0) {
|
|
79
|
+
disk.removeItem(OLD_HISTORY);
|
|
80
|
+
} else {
|
|
81
|
+
disk.setItem(OLD_HISTORY, JSON.stringify(others));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// Storage can be denied or hold something else: the old records stay where they are.
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const self = {
|
|
39
90
|
identify(account) {
|
|
40
91
|
if (account === person && locked === (account === null)) {
|
|
41
92
|
return;
|
|
@@ -44,7 +95,12 @@ export function createPersonStorage(storage = () => localStorage) {
|
|
|
44
95
|
person = account;
|
|
45
96
|
locked = account === null;
|
|
46
97
|
pending.clear();
|
|
47
|
-
|
|
98
|
+
|
|
99
|
+
if (account !== null) {
|
|
100
|
+
moveOldHistory(account);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
removeMatching((key) => legacy(key) && key !== OLD_HISTORY);
|
|
48
104
|
},
|
|
49
105
|
get(key, account = person) {
|
|
50
106
|
const name = scoped(key, account);
|
|
@@ -118,6 +174,8 @@ export function createPersonStorage(storage = () => localStorage) {
|
|
|
118
174
|
removeMatching((key) => key.startsWith(PREFIX) || legacy(key));
|
|
119
175
|
},
|
|
120
176
|
};
|
|
177
|
+
|
|
178
|
+
return self;
|
|
121
179
|
}
|
|
122
180
|
|
|
123
181
|
export const personStorage = createPersonStorage();
|
package/web/running-board.js
CHANGED
|
@@ -883,7 +883,7 @@ function Timeline({
|
|
|
883
883
|
class="rb-pin-label"
|
|
884
884
|
style=${`left:${left}px`}
|
|
885
885
|
>
|
|
886
|
-
${clock(t,
|
|
886
|
+
${clock(t, HERE, now)}
|
|
887
887
|
</span>`);
|
|
888
888
|
labelled = true;
|
|
889
889
|
}
|
|
@@ -1243,6 +1243,7 @@ function Needs({ needs, colorOf, onOpen, onPick }) {
|
|
|
1243
1243
|
</div>`;
|
|
1244
1244
|
}
|
|
1245
1245
|
|
|
1246
|
+
/** The next runs of all schedules, by moment: their times are this browser's, so the list reads in order. */
|
|
1246
1247
|
function NextUp({ schedules, now, colorOf, onPick }) {
|
|
1247
1248
|
const times = schedules
|
|
1248
1249
|
.filter((each) => !each.held)
|
|
@@ -1262,7 +1263,7 @@ function NextUp({ schedules, now, colorOf, onPick }) {
|
|
|
1262
1263
|
class="rb-next"
|
|
1263
1264
|
onClick=${() => onPick(schedule)}
|
|
1264
1265
|
>
|
|
1265
|
-
<span class="rb-next-time">${clock(at,
|
|
1266
|
+
<span class="rb-next-time">${clock(at, HERE, now)}</span>
|
|
1266
1267
|
<span class="folder-mark" style=${`--folder:${colorOf(schedule.session)}`}></span>
|
|
1267
1268
|
<span class="rb-ellipsis grow">${schedule.text}</span>
|
|
1268
1269
|
<span class="rb-next-rel">${relative(at, now)}</span>
|
package/web/session-cache.js
CHANGED
|
@@ -11,11 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
const NAME = "pocket-sessions";
|
|
13
13
|
|
|
14
|
+
/** How long an open may take before the cache counts as nothing kept: some browsers never answer. */
|
|
15
|
+
const OPEN_MS = 1000;
|
|
16
|
+
|
|
14
17
|
let opening;
|
|
15
18
|
|
|
16
19
|
function database() {
|
|
17
20
|
opening ??= new Promise((resolve, reject) => {
|
|
18
21
|
const request = indexedDB.open(NAME, 1);
|
|
22
|
+
let late = false;
|
|
23
|
+
const timer = setTimeout(() => {
|
|
24
|
+
late = true;
|
|
25
|
+
reject(new Error("The session cache did not open"));
|
|
26
|
+
}, OPEN_MS);
|
|
19
27
|
|
|
20
28
|
request.onupgradeneeded = () => {
|
|
21
29
|
request.result.createObjectStore("views");
|
|
@@ -25,6 +33,15 @@ function database() {
|
|
|
25
33
|
request.onsuccess = () => {
|
|
26
34
|
const db = request.result;
|
|
27
35
|
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
|
|
38
|
+
// It answered after the wait: nothing uses it, and a later call opens it again.
|
|
39
|
+
if (late) {
|
|
40
|
+
db.close();
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
// Another tab deletes or upgrades it: let go, and open it again when next needed.
|
|
29
46
|
db.onversionchange = () => {
|
|
30
47
|
db.close();
|
|
@@ -34,8 +51,15 @@ function database() {
|
|
|
34
51
|
resolve(db);
|
|
35
52
|
};
|
|
36
53
|
|
|
37
|
-
request.onerror = () =>
|
|
38
|
-
|
|
54
|
+
request.onerror = () => {
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
reject(request.error);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
request.onblocked = () => {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
reject(new Error("The session cache is open in an older tab"));
|
|
62
|
+
};
|
|
39
63
|
}).catch((error) => {
|
|
40
64
|
opening = undefined;
|
|
41
65
|
|