@inkandswitch/patchwork-bootloader 0.5.4 → 0.6.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 +14 -0
- package/dist/automerge-worker.js +3 -5
- package/dist/storage.d.ts +8 -0
- package/dist/storage.js +10 -0
- package/package.json +8 -4
- package/src/automerge-worker.ts +4 -7
- package/src/storage.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @inkandswitch/patchwork-bootloader
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 98be594: Namespace IndexedDB and peer ids with a new build-time `storagePrefix` option.
|
|
8
|
+
|
|
9
|
+
The tab and the shared automerge worker are separate bundles that must open the same databases. Both now read the name from one place, `@inkandswitch/patchwork-bootloader/storage`, resolved from the `__STORAGE_PREFIX__` define the vite plugin emits unconditionally.
|
|
10
|
+
|
|
11
|
+
Previously each side resolved `__SITE_NAME__` itself with a different fallback — `"patchwork.inkandswitch.com"` in the worker, `"patchwork"` in the tab — so a site that never set `siteName` had its tab and worker on two different keyhive databases, and one that passed `setup({name})` split them the same way, since a runtime option never reaches the worker.
|
|
12
|
+
|
|
13
|
+
- `storagePrefix` defaults to `"patchwork"` and is settable only in the build config. Sites sharing an origin must use distinct prefixes. It is deliberately not derived from any display name: changing it points a site at empty storage, so a rebrand must not be able to change it by accident.
|
|
14
|
+
- Sites that relied on `siteName` to namespace their storage must now set `storagePrefix` explicitly to that same value to keep their existing databases.
|
|
15
|
+
- `createRepo` in `@inkandswitch/patchwork` no longer takes a site name argument.
|
|
16
|
+
|
|
3
17
|
## 0.5.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/automerge-worker.js
CHANGED
|
@@ -19,10 +19,8 @@ import { MessageChannelNetworkAdapter } from "@automerge/automerge-repo-network-
|
|
|
19
19
|
import { WebSocketWorkerClientAdapter } from "@automerge/automerge-repo-network-websocket";
|
|
20
20
|
import { initializeAutomergeRepoKeyhiveRustWithRepo, initKeyhiveWasm, } from "@automerge/automerge-repo-keyhive";
|
|
21
21
|
import { DEFAULT_CLASSIC_SYNC_SERVER } from "./sync-config.js";
|
|
22
|
+
import { keyhiveStorageName, storagePrefix } from "./storage.js";
|
|
22
23
|
import { HANDOFF_CHANNEL, SYNCSTATE_CHANNEL, } from "./types.js";
|
|
23
|
-
const siteName = typeof __SITE_NAME__ !== "undefined"
|
|
24
|
-
? __SITE_NAME__
|
|
25
|
-
: "patchwork.inkandswitch.com";
|
|
26
24
|
const syncServer = typeof __SYNC_SERVER__ !== "undefined"
|
|
27
25
|
? __SYNC_SERVER__
|
|
28
26
|
: { url: "wss://subduction.sync.inkandswitch.com" };
|
|
@@ -210,8 +208,8 @@ async function buildKeyhiveRepo(keyhiveSyncServer) {
|
|
|
210
208
|
initKeyhiveWasm();
|
|
211
209
|
const { hive, repo } = await initializeAutomergeRepoKeyhiveRustWithRepo({
|
|
212
210
|
createRepo: (config) => new Repo(config),
|
|
213
|
-
storage: new IndexedDBWorkerStorageAdapter(
|
|
214
|
-
peerIdSuffix: `${
|
|
211
|
+
storage: new IndexedDBWorkerStorageAdapter(keyhiveStorageName),
|
|
212
|
+
peerIdSuffix: `${storagePrefix}-worker` + Math.random().toString(36).slice(2),
|
|
215
213
|
automaticArchiveIngestion: true,
|
|
216
214
|
cachingMode: "periodic",
|
|
217
215
|
// ARK selects the relay via `syncServer`, which pairs the contact card with
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_STORAGE_PREFIX = "patchwork";
|
|
2
|
+
/**
|
|
3
|
+
* Namespace for this site's IndexedDB databases and peer ids. The tab and the
|
|
4
|
+
* shared automerge worker are separate bundles that must open the same
|
|
5
|
+
* databases, and this module is the single place either of them gets the name.
|
|
6
|
+
*/
|
|
7
|
+
export declare const storagePrefix: string;
|
|
8
|
+
export declare const keyhiveStorageName: string;
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const DEFAULT_STORAGE_PREFIX = "patchwork";
|
|
2
|
+
/**
|
|
3
|
+
* Namespace for this site's IndexedDB databases and peer ids. The tab and the
|
|
4
|
+
* shared automerge worker are separate bundles that must open the same
|
|
5
|
+
* databases, and this module is the single place either of them gets the name.
|
|
6
|
+
*/
|
|
7
|
+
export const storagePrefix = typeof __STORAGE_PREFIX__ !== "undefined"
|
|
8
|
+
? __STORAGE_PREFIX__
|
|
9
|
+
: DEFAULT_STORAGE_PREFIX;
|
|
10
|
+
export const keyhiveStorageName = `${storagePrefix}-keyhive`;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/inkandswitch/patchwork-system.git",
|
|
6
6
|
"directory": "core/bootloader"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.6.0",
|
|
9
9
|
"author": "chee",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"license": "MIT",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"import": "./dist/externals-list.js",
|
|
27
27
|
"types": "./dist/externals-list.d.ts"
|
|
28
28
|
},
|
|
29
|
+
"./storage": {
|
|
30
|
+
"import": "./dist/storage.js",
|
|
31
|
+
"types": "./dist/storage.d.ts"
|
|
32
|
+
},
|
|
29
33
|
"./service-worker": {
|
|
30
34
|
"import": "./dist/service-worker.js",
|
|
31
35
|
"types": "./dist/service-worker.d.ts"
|
|
@@ -68,10 +72,10 @@
|
|
|
68
72
|
"service-worker-types": "npm:@types/serviceworker@^0.0.153",
|
|
69
73
|
"solid-js": "^1.9.13",
|
|
70
74
|
"tinyargs": "^0.1.4",
|
|
71
|
-
"@inkandswitch/patchwork-elements": "^6.0.0",
|
|
72
75
|
"@inkandswitch/patchwork-filesystem": "^0.2.5",
|
|
73
|
-
"@inkandswitch/patchwork-
|
|
74
|
-
"@inkandswitch/patchwork-
|
|
76
|
+
"@inkandswitch/patchwork-providers": "^0.5.0",
|
|
77
|
+
"@inkandswitch/patchwork-plugins": "^1.2.0",
|
|
78
|
+
"@inkandswitch/patchwork-elements": "^6.0.0"
|
|
75
79
|
},
|
|
76
80
|
"peerDependencies": {
|
|
77
81
|
"@automerge/automerge": "3.3.2",
|
package/src/automerge-worker.ts
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
} from "@automerge/automerge-repo-keyhive";
|
|
39
39
|
|
|
40
40
|
import { DEFAULT_CLASSIC_SYNC_SERVER } from "./sync-config.js";
|
|
41
|
+
import { keyhiveStorageName, storagePrefix } from "./storage.js";
|
|
41
42
|
import {
|
|
42
43
|
HANDOFF_CHANNEL,
|
|
43
44
|
SYNCSTATE_CHANNEL,
|
|
@@ -52,16 +53,11 @@ import {
|
|
|
52
53
|
type SyncStateRequestMessage,
|
|
53
54
|
} from "./types.js";
|
|
54
55
|
|
|
55
|
-
declare const __SITE_NAME__: string;
|
|
56
56
|
declare const __SYNC_SERVER__: {
|
|
57
57
|
url: string;
|
|
58
58
|
keyhive?: SyncServerSelection;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const siteName =
|
|
62
|
-
typeof __SITE_NAME__ !== "undefined"
|
|
63
|
-
? __SITE_NAME__
|
|
64
|
-
: "patchwork.inkandswitch.com";
|
|
65
61
|
const syncServer =
|
|
66
62
|
typeof __SYNC_SERVER__ !== "undefined"
|
|
67
63
|
? __SYNC_SERVER__
|
|
@@ -288,8 +284,9 @@ async function buildKeyhiveRepo(
|
|
|
288
284
|
initKeyhiveWasm();
|
|
289
285
|
const { hive, repo } = await initializeAutomergeRepoKeyhiveRustWithRepo({
|
|
290
286
|
createRepo: (config) => new Repo(config),
|
|
291
|
-
storage: new IndexedDBWorkerStorageAdapter(
|
|
292
|
-
peerIdSuffix:
|
|
287
|
+
storage: new IndexedDBWorkerStorageAdapter(keyhiveStorageName),
|
|
288
|
+
peerIdSuffix:
|
|
289
|
+
`${storagePrefix}-worker` + Math.random().toString(36).slice(2),
|
|
293
290
|
automaticArchiveIngestion: true,
|
|
294
291
|
cachingMode: "periodic",
|
|
295
292
|
// ARK selects the relay via `syncServer`, which pairs the contact card with
|
package/src/storage.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __STORAGE_PREFIX__: string;
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_STORAGE_PREFIX = "patchwork";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Namespace for this site's IndexedDB databases and peer ids. The tab and the
|
|
7
|
+
* shared automerge worker are separate bundles that must open the same
|
|
8
|
+
* databases, and this module is the single place either of them gets the name.
|
|
9
|
+
*/
|
|
10
|
+
export const storagePrefix =
|
|
11
|
+
typeof __STORAGE_PREFIX__ !== "undefined"
|
|
12
|
+
? __STORAGE_PREFIX__
|
|
13
|
+
: DEFAULT_STORAGE_PREFIX;
|
|
14
|
+
|
|
15
|
+
export const keyhiveStorageName = `${storagePrefix}-keyhive`;
|