@inkandswitch/patchwork-bootloader 0.1.0 → 0.2.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @inkandswitch/patchwork-bootloader
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 76db23e: Wire the new `@inkandswitch/patchwork-providers` element stack into
8
+ `bootPatchworkSite`:
9
+ - Register and mount `<repo-provider>` (backed by the booted repo) and a
10
+ top-level `<fallback-provider>` around the configured root element so
11
+ descendant `<patchwork-view>` / `<patchwork-view-legacy>` elements can
12
+ resolve their repo via the request/respond protocol.
13
+ - The single `registerPatchworkViewElement()` call now also registers
14
+ `<patchwork-view-legacy>` (the wrapper's delegation target), so no
15
+ separate registration is needed.
16
+ - Drop the `{ repo }` argument from `registerPatchworkViewLegacyElement`
17
+ (the repo now comes from the provider).
18
+ - Add `@inkandswitch/patchwork-providers` as a workspace dependency.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [76db23e]
23
+ - Updated dependencies [76db23e]
24
+ - @inkandswitch/patchwork-elements@1.0.0
25
+ - @inkandswitch/patchwork-providers@0.1.0
26
+
3
27
  ## 0.1.0
4
28
 
5
29
  ### Minor Changes
package/dist/site.d.ts CHANGED
@@ -63,8 +63,8 @@ export interface SiteConfig {
63
63
  */
64
64
  titleSuffix: string;
65
65
  /**
66
- * DOM id of the `<patchwork-view>` element that will host the root tool.
67
- * Defaults to `"root"`.
66
+ * DOM id of the `<patchwork-view>` element that will host the root
67
+ * tool. Defaults to `"root"`.
68
68
  */
69
69
  rootElementId?: string;
70
70
  /**
package/dist/site.js CHANGED
@@ -19,6 +19,7 @@ import * as AutomergeRepo from "@automerge/automerge-repo/slim";
19
19
  import { initSync as initSubductionSync } from "@automerge/automerge-subduction/slim";
20
20
  import { ModuleWatcher } from "@inkandswitch/patchwork-filesystem";
21
21
  import { openDocument, registerPatchworkViewElement, } from "@inkandswitch/patchwork-elements";
22
+ import { registerFallbackProviderElement, registerRepoProviderElement, } from "@inkandswitch/patchwork-providers";
22
23
  import { getRegistry, registerPlugins, resolveAccountHandle, unregisterPlugins, } from "@inkandswitch/patchwork-plugins";
23
24
  import * as plugins from "@inkandswitch/patchwork-plugins";
24
25
  import setupServiceWorker from "./setup.js";
@@ -70,7 +71,18 @@ export async function bootPatchworkSite(config) {
70
71
  };
71
72
  await sw.subscribeToRepoChannel(connectServiceWorkerPort);
72
73
  installDevConsoleGlobals(repo);
73
- registerPatchworkViewElement({ repo });
74
+ registerRepoProviderElement(repo);
75
+ registerFallbackProviderElement();
76
+ const rootElement = document.getElementById(config.rootElementId ?? "root");
77
+ if (!rootElement) {
78
+ throw new Error(`bootPatchworkSite: no element with id="${config.rootElementId ?? "root"}"`);
79
+ }
80
+ const repoProvider = document.createElement("repo-provider");
81
+ const fallbackProvider = document.createElement("fallback-provider");
82
+ rootElement.parentElement.insertBefore(fallbackProvider, rootElement);
83
+ fallbackProvider.appendChild(repoProvider);
84
+ repoProvider.appendChild(rootElement);
85
+ registerPatchworkViewElement();
74
86
  // The watcher is started with the site's default-tools bundle alone so that
75
87
  // `resolveAccountHandle` below has something to await on (the `account`
76
88
  // datatype lives in that bundle today). The user's own module-settings URL
@@ -81,10 +93,6 @@ export async function bootPatchworkSite(config) {
81
93
  });
82
94
  window.accountDocHandle = accountDocHandle;
83
95
  wireModuleSettingsWhenReady(accountDocHandle, moduleWatcher);
84
- const rootElement = document.getElementById(config.rootElementId ?? "root");
85
- if (!rootElement) {
86
- throw new Error(`bootPatchworkSite: no element with id="${config.rootElementId ?? "root"}"`);
87
- }
88
96
  primeRootElement(rootElement, accountDocHandle);
89
97
  logToolRegistryWhenLoaded(moduleWatcher);
90
98
  window.patchwork = {
@@ -154,9 +162,10 @@ function wireModuleSettingsWhenReady(accountDocHandle, moduleWatcher) {
154
162
  }
155
163
  }
156
164
  /**
157
- * Set initial `tool-id` / `doc-url` attributes on the root `<patchwork-view>`
158
- * based on the URL hash (if it specifies a frame override) or the account
159
- * doc's configured frame tool + the account doc itself.
165
+ * Set initial `tool-id` / `doc-url` attributes on the root
166
+ * `<patchwork-view-legacy>` based on the URL hash (if it specifies a frame
167
+ * override) or the account doc's configured frame tool + the account doc
168
+ * itself.
160
169
  */
161
170
  function primeRootElement(rootElement, accountDocHandle) {
162
171
  rootElement.style.visibility = "hidden";
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork-bootloader",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "author": "chee",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "devDependencies": {
8
- "@automerge/automerge-repo-keyhive": "0.2.0-alpha.1d",
8
+ "@automerge/automerge-repo-keyhive": "catalog:",
9
9
  "esbuild": "^0.23.1",
10
10
  "rollup": "^4.53.3"
11
11
  },
@@ -40,30 +40,31 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@automerge/automerge": "3.2.6",
44
- "@automerge/automerge-repo": "2.6.0-subduction.19",
45
- "@automerge/automerge-subduction": "0.12.0",
46
- "@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.19",
47
- "@automerge/automerge-repo-network-websocket": "2.6.0-subduction.19",
48
- "@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.19",
49
- "@automerge/vanillajs": "2.6.0-subduction.19",
43
+ "@automerge/automerge": "catalog:",
44
+ "@automerge/automerge-repo": "catalog:",
45
+ "@automerge/automerge-subduction": "catalog:",
46
+ "@automerge/automerge-repo-network-messagechannel": "catalog:",
47
+ "@automerge/automerge-repo-network-websocket": "catalog:",
48
+ "@automerge/automerge-repo-storage-indexeddb": "catalog:",
49
+ "@automerge/vanillajs": "catalog:",
50
+ "@inkandswitch/patchwork-elements": "workspace:^",
51
+ "@inkandswitch/patchwork-filesystem": "workspace:^",
52
+ "@inkandswitch/patchwork-plugins": "workspace:^",
53
+ "@inkandswitch/patchwork-providers": "workspace:^",
50
54
  "@types/debug": "^4.1.12",
51
55
  "debug": "^4.4.3",
52
56
  "resolve.exports": "^2.0.3",
53
57
  "service-worker-types": "npm:@types/serviceworker@^0.0.153",
54
- "tinyargs": "^0.1.4",
55
- "@inkandswitch/patchwork-elements": "^0.0.8",
56
- "@inkandswitch/patchwork-plugins": "^0.0.8",
57
- "@inkandswitch/patchwork-filesystem": "^0.0.6"
58
+ "tinyargs": "^0.1.4"
58
59
  },
59
60
  "peerDependencies": {
60
- "@automerge/automerge": "3.2.6",
61
- "@automerge/automerge-repo": "2.6.0-subduction.19",
62
- "@automerge/automerge-repo-keyhive": "0.2.0-alpha.1d",
63
- "@automerge/vanillajs": "2.6.0-subduction.19"
61
+ "@automerge/automerge": "catalog:",
62
+ "@automerge/automerge-repo": "catalog:",
63
+ "@automerge/automerge-repo-keyhive": "catalog:",
64
+ "@automerge/vanillajs": "catalog:"
64
65
  },
65
66
  "scripts": {
66
67
  "build": "tsc",
67
68
  "dev": "tsc -w --preserveWatchOutput"
68
69
  }
69
- }
70
+ }
@@ -124,7 +124,7 @@ function getRepo() {
124
124
  },
125
125
  enableRemoteHeadsGossiping: true,
126
126
  subductionWebsocketEndpoints: SUBDUCTION_ENDPOINTS,
127
- //network: [new WebSocketClientAdapter("wss://sync3.automerge.org")],
127
+ network: [new WebSocketClientAdapter("wss://sync3.automerge.org")],
128
128
  });
129
129
 
130
130
  (self as any).repo = repo;
package/src/site.ts CHANGED
@@ -37,6 +37,10 @@ import {
37
37
  openDocument,
38
38
  registerPatchworkViewElement,
39
39
  } from "@inkandswitch/patchwork-elements";
40
+ import {
41
+ registerFallbackProviderElement,
42
+ registerRepoProviderElement,
43
+ } from "@inkandswitch/patchwork-providers";
40
44
  import {
41
45
  type AccountDoc,
42
46
  type DatatypeDescription,
@@ -182,7 +186,25 @@ export async function bootPatchworkSite(
182
186
  await sw.subscribeToRepoChannel(connectServiceWorkerPort);
183
187
 
184
188
  installDevConsoleGlobals(repo);
185
- registerPatchworkViewElement({ repo });
189
+
190
+ registerRepoProviderElement(repo);
191
+ registerFallbackProviderElement();
192
+
193
+ const rootElement = document.getElementById(config.rootElementId ?? "root");
194
+ if (!rootElement) {
195
+ throw new Error(
196
+ `bootPatchworkSite: no element with id="${config.rootElementId ?? "root"}"`
197
+ );
198
+ }
199
+ const repoProvider = document.createElement("repo-provider");
200
+ const fallbackProvider = document.createElement("fallback-provider");
201
+ rootElement.parentElement!.insertBefore(fallbackProvider, rootElement);
202
+ fallbackProvider.appendChild(repoProvider);
203
+ repoProvider.appendChild(rootElement);
204
+
205
+ // Registers `<patchwork-view>` and the `<patchwork-view-legacy>` it
206
+ // delegates to in one go.
207
+ registerPatchworkViewElement();
186
208
 
187
209
  // The watcher is started with the site's default-tools bundle alone so that
188
210
  // `resolveAccountHandle` below has something to await on (the `account`
@@ -203,13 +225,6 @@ export async function bootPatchworkSite(
203
225
 
204
226
  wireModuleSettingsWhenReady(accountDocHandle, moduleWatcher);
205
227
 
206
- const rootElement = document.getElementById(config.rootElementId ?? "root");
207
- if (!rootElement) {
208
- throw new Error(
209
- `bootPatchworkSite: no element with id="${config.rootElementId ?? "root"}"`
210
- );
211
- }
212
-
213
228
  primeRootElement(rootElement, accountDocHandle);
214
229
  logToolRegistryWhenLoaded(moduleWatcher);
215
230
 
@@ -298,9 +313,10 @@ function wireModuleSettingsWhenReady(
298
313
  }
299
314
 
300
315
  /**
301
- * Set initial `tool-id` / `doc-url` attributes on the root `<patchwork-view>`
302
- * based on the URL hash (if it specifies a frame override) or the account
303
- * doc's configured frame tool + the account doc itself.
316
+ * Set initial `tool-id` / `doc-url` attributes on the root
317
+ * `<patchwork-view>` based on the URL hash (if it specifies a frame
318
+ * override) or the account doc's configured frame tool + the account doc
319
+ * itself.
304
320
  */
305
321
  function primeRootElement(
306
322
  rootElement: HTMLElement,