@inkandswitch/patchwork-bootloader 0.3.1 → 0.4.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/CHANGELOG.md +16 -0
- package/dist/automerge-worker.js +434 -15
- package/dist/externals.js +5 -0
- package/dist/service-worker.js +76 -29
- package/dist/setup.d.ts +4 -1
- package/dist/setup.js +109 -11
- package/dist/site.d.ts +6 -1
- package/dist/site.js +86 -40
- package/dist/types.d.ts +64 -0
- package/package.json +13 -13
- package/src/automerge-worker.ts +480 -15
- package/src/externals.ts +5 -0
- package/src/service-worker.ts +92 -32
- package/src/setup.ts +123 -10
- package/src/site.ts +104 -44
- package/src/types.ts +88 -0
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,62 @@ export declare const HANDOFF_CHANNEL = "@patchwork/handoff";
|
|
|
11
11
|
* informed of sync progress without repo-to-repo gossiping.
|
|
12
12
|
*/
|
|
13
13
|
export declare const SYNCSTATE_CHANNEL = "@patchwork/syncstate";
|
|
14
|
+
/**
|
|
15
|
+
* Worker → tabs: the worker's Subduction link to the sync server flipped.
|
|
16
|
+
* `serverPeerIds` are the directly-connected sync-server peer ids (their
|
|
17
|
+
* verifying keys), so a tab can tell which peer rows are *the server* and
|
|
18
|
+
* judge "synced" against them specifically.
|
|
19
|
+
*/
|
|
20
|
+
export interface SyncStateConnectionMessage {
|
|
21
|
+
type: "connection";
|
|
22
|
+
connected: boolean;
|
|
23
|
+
serverPeerIds: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Worker → tabs: the shared worker's own Subduction identity, so a tab can
|
|
27
|
+
* tell which peer rows are "us". `peerId` is `signer.peerId().toString()` (the
|
|
28
|
+
* value that shows up as a peer id); `verifyingKey` is its hex Ed25519 key.
|
|
29
|
+
*/
|
|
30
|
+
export interface SyncStateWhoAmIMessage {
|
|
31
|
+
type: "whoami";
|
|
32
|
+
peerId: string;
|
|
33
|
+
verifyingKey: string;
|
|
34
|
+
}
|
|
35
|
+
export type SyncStateBroadcast = SyncStateConnectionMessage | SyncStateWhoAmIMessage;
|
|
36
|
+
/**
|
|
37
|
+
* Tab → worker: please replay the current global sync signals (whoami +
|
|
38
|
+
* connection) so a freshly-opened tab can orient immediately. Per-document
|
|
39
|
+
* heads are no longer replayed here — a tab subscribes to the specific docs it
|
|
40
|
+
* cares about over its control port instead (see {@link SyncSubscribeMessage}).
|
|
41
|
+
*/
|
|
42
|
+
export interface SyncStateRequestMessage {
|
|
43
|
+
type: "request";
|
|
44
|
+
/** @deprecated ignored — per-doc state is delivered via sync-sub now. */
|
|
45
|
+
documentId?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Tab → worker: start pushing me this document's heads (replays current state). */
|
|
48
|
+
export interface SyncSubscribeMessage {
|
|
49
|
+
type: "sync-sub";
|
|
50
|
+
documentId: string;
|
|
51
|
+
}
|
|
52
|
+
/** Tab → worker: stop pushing me this document's heads. */
|
|
53
|
+
export interface SyncUnsubscribeMessage {
|
|
54
|
+
type: "sync-unsub";
|
|
55
|
+
documentId: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Worker → tab (control port): a peer's heads for a subscribed document — the
|
|
59
|
+
* worker's own (keyed by its peerId) or a Subduction peer's (keyed by its
|
|
60
|
+
* verifying-key storageId). Same payload as the old broadcast remote-heads
|
|
61
|
+
* message, but delivered only to the tabs that asked for this document.
|
|
62
|
+
*/
|
|
63
|
+
export interface SyncStateDocMessage {
|
|
64
|
+
type: "sync-state";
|
|
65
|
+
documentId: string;
|
|
66
|
+
storageId: string;
|
|
67
|
+
heads: string[];
|
|
68
|
+
timestamp: number;
|
|
69
|
+
}
|
|
14
70
|
/**
|
|
15
71
|
* The special URL to resolve, plus enough of the {@link Request} the service
|
|
16
72
|
* worker is holding that the automerge worker can construct one that
|
|
@@ -106,4 +162,12 @@ export type SetupServiceWorkerResult = {
|
|
|
106
162
|
subscribeToRepoChannel: (listener: ServiceWorkerRepoChannelListener) => Promise<() => void>;
|
|
107
163
|
/** Open a fresh repo sync port to the automerge worker (dev console). */
|
|
108
164
|
getRepoChannel: () => MessagePort;
|
|
165
|
+
/**
|
|
166
|
+
* Watch one document's sync heads (this tab's own and each Subduction peer's,
|
|
167
|
+
* as the worker learns them). Calls `listener` on every update for that doc,
|
|
168
|
+
* replaying the current state on subscribe. Returns an unsubscribe function;
|
|
169
|
+
* the worker stops pushing the doc once the last local watcher drops it (and
|
|
170
|
+
* automatically if this tab goes away).
|
|
171
|
+
*/
|
|
172
|
+
subscribeSyncState: (documentId: string, listener: (update: SyncStateDocMessage) => void) => () => void;
|
|
109
173
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkandswitch/patchwork-bootloader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "chee",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,29 +44,29 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@automerge/automerge": "3.3.0-fragments.
|
|
48
|
-
"@automerge/automerge-repo": "2.6.0-subduction.
|
|
49
|
-
"@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.
|
|
50
|
-
"@automerge/automerge-repo-network-websocket": "2.6.0-subduction.
|
|
51
|
-
"@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.
|
|
47
|
+
"@automerge/automerge": "3.3.0-fragments.2",
|
|
48
|
+
"@automerge/automerge-repo": "2.6.0-subduction.44",
|
|
49
|
+
"@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.44",
|
|
50
|
+
"@automerge/automerge-repo-network-websocket": "2.6.0-subduction.44",
|
|
51
|
+
"@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.44",
|
|
52
52
|
"@automerge/automerge-subduction": "0.16.0",
|
|
53
|
-
"@automerge/vanillajs": "2.6.0-subduction.
|
|
53
|
+
"@automerge/vanillajs": "2.6.0-subduction.44",
|
|
54
54
|
"@keyhive/keyhive": "0.1.0-alpha.5",
|
|
55
55
|
"@types/debug": "^4.1.13",
|
|
56
56
|
"debug": "^4.4.3",
|
|
57
57
|
"resolve.exports": "^2.0.3",
|
|
58
58
|
"service-worker-types": "npm:@types/serviceworker@^0.0.153",
|
|
59
59
|
"tinyargs": "^0.1.4",
|
|
60
|
-
"@inkandswitch/patchwork-filesystem": "^0.1.1",
|
|
61
60
|
"@inkandswitch/patchwork-elements": "^2.0.0",
|
|
62
|
-
"@inkandswitch/patchwork-
|
|
63
|
-
"@inkandswitch/patchwork-plugins": "^0.0.11"
|
|
61
|
+
"@inkandswitch/patchwork-filesystem": "^0.1.3",
|
|
62
|
+
"@inkandswitch/patchwork-plugins": "^0.0.11",
|
|
63
|
+
"@inkandswitch/patchwork-providers": "^0.3.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@automerge/automerge": "3.3.0-fragments.
|
|
67
|
-
"@automerge/automerge-repo": "2.6.0-subduction.
|
|
66
|
+
"@automerge/automerge": "3.3.0-fragments.2",
|
|
67
|
+
"@automerge/automerge-repo": "2.6.0-subduction.44",
|
|
68
68
|
"@automerge/automerge-repo-keyhive": "0.3.0-alpha.sub.8b",
|
|
69
|
-
"@automerge/vanillajs": "2.6.0-subduction.
|
|
69
|
+
"@automerge/vanillajs": "2.6.0-subduction.44"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsc",
|