@inkandswitch/patchwork 0.1.0 → 0.2.1

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,42 @@
1
1
  # @inkandswitch/patchwork
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f00dcb8: Add `repository` metadata pointing at inkandswitch/patchwork-system, so npm links each package to its source directory and can attest provenance when published from CI.
8
+ - Updated dependencies [f00dcb8]
9
+ - @inkandswitch/patchwork-bootloader@0.5.2
10
+ - @inkandswitch/patchwork-filesystem@0.2.5
11
+ - @inkandswitch/patchwork-elements@4.0.4
12
+ - @inkandswitch/patchwork-plugins@1.0.3
13
+
14
+ ## 0.2.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 2fffabe: `setup()` now uses `packageListURL` as given instead of letting `localStorage.systemPackageListURL` silently replace it. A site that wants a dev override resolves it itself and passes the result in:
19
+
20
+ ```ts
21
+ const packageListURL =
22
+ new URLSearchParams(location.search).get("system-package-list") ||
23
+ localStorage.getItem("systemPackageListURL") ||
24
+ DEFAULT_PACKAGE_LIST;
25
+ ```
26
+
27
+ This keeps the precedence in one place — the site — so a site can add its own override sources without fighting the library for priority.
28
+
29
+ ### Patch Changes
30
+
31
+ - 6be3922: Wait for configured modules to load before routing the root view so registered frame tools are available for the initial route.
32
+ - 77bd37c: Expose the account document handle as `window.accountDocHandle` alongside `window.patchwork.account`.
33
+ - 5f70c14: Add `repository` metadata pointing at inkandswitch/patchwork-next, so npm links each package to its source directory and can attest provenance when published from CI.
34
+ - Updated dependencies [5f70c14]
35
+ - @inkandswitch/patchwork-bootloader@0.5.1
36
+ - @inkandswitch/patchwork-filesystem@0.2.4
37
+ - @inkandswitch/patchwork-elements@4.0.3
38
+ - @inkandswitch/patchwork-plugins@1.0.2
39
+
3
40
  ## 0.1.0
4
41
 
5
42
  ### Minor Changes
package/dist/client.d.ts CHANGED
@@ -18,7 +18,7 @@ declare global {
18
18
  /**
19
19
  * Comma-separated list of default tool-manifest sources the shell boots
20
20
  * with. Each entry is an `automerge:` URL or a static `modules.json`
21
- * URL. Overridable at runtime via `localStorage.systemPackageListURL`.
21
+ * URL.
22
22
  */
23
23
  readonly PATCHWORK_SYSTEM_PACKAGE_LIST_URL?: string;
24
24
  /**
package/dist/index.d.ts CHANGED
@@ -17,12 +17,14 @@
17
17
  * `@inkandswitch/patchwork-bootloader` directly, which does SW registration
18
18
  * and the automerge-worker handoff and nothing else.
19
19
  */
20
- import { Repo } from "@automerge/vanillajs/slim";
20
+ import { type DocHandle, Repo } from "@automerge/vanillajs/slim";
21
21
  import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
22
+ import { type AccountDoc } from "@inkandswitch/patchwork-plugins";
22
23
  import type { Patchwork, PatchworkOptions } from "./types.js";
23
24
  declare global {
24
25
  interface Window {
25
26
  patchwork: Patchwork;
27
+ accountDocHandle: DocHandle<AccountDoc>;
26
28
  repo: Repo;
27
29
  Automerge: typeof import("@automerge/automerge");
28
30
  AutomergeRepo: typeof import("@automerge/automerge-repo");
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * `@inkandswitch/patchwork-bootloader` directly, which does SW registration
18
18
  * and the automerge-worker handoff and nothing else.
19
19
  */
20
- import { MessageChannelNetworkAdapter, isValidAutomergeUrl, } from "@automerge/vanillajs/slim";
20
+ import { MessageChannelNetworkAdapter, } from "@automerge/vanillajs/slim";
21
21
  import * as Automerge from "@automerge/automerge/slim";
22
22
  import * as AutomergeRepo from "@automerge/automerge-repo/slim";
23
23
  import { ModuleWatcher } from "@inkandswitch/patchwork-filesystem";
@@ -140,10 +140,15 @@ async function doSetup(options) {
140
140
  storageKey: options.accountKey ?? "patchworkAccountURL",
141
141
  hive,
142
142
  }));
143
+ window.accountDocHandle = accountDocHandle;
143
144
  wireModuleSettings(accountDocHandle, moduleWatcher);
145
+ const toolsLoaded = moduleWatcher.doneLoading.then(() => log("doneLoading, tools registered:", getRegistry("patchwork:tool")
146
+ .all()
147
+ .map((t) => t.id)), (err) => console.error("doneLoading rejected:", err));
144
148
  let router;
145
149
  if (routing !== false) {
146
150
  rootElement.style.visibility = "hidden";
151
+ await toolsLoaded;
147
152
  router = createRouter({
148
153
  rootElement,
149
154
  repo,
@@ -151,9 +156,6 @@ async function doSetup(options) {
151
156
  siteName,
152
157
  });
153
158
  }
154
- const toolsLoaded = moduleWatcher.doneLoading.then(() => log("doneLoading, tools registered:", getRegistry("patchwork:tool")
155
- .all()
156
- .map((t) => t.id)), (err) => console.error("doneLoading rejected:", err));
157
159
  installReveal(rootElement, router, toolsLoaded);
158
160
  return {
159
161
  repo,
@@ -215,25 +217,13 @@ function installReveal(rootElement, router, toolsLoaded) {
215
217
  setTimeout(reveal, 12_000);
216
218
  }
217
219
  // ── Module sources ───────────────────────────────────────────────────────
218
- function isValidModuleSource(source) {
219
- return isValidAutomergeUrl(source) || /^(https?:\/\/|\.?\/)/.test(source);
220
- }
221
220
  /**
222
- * The site's default module-list sources, honouring the
223
- * `localStorage.systemPackageListURL` dev override, which replaces the entire
224
- * built-in bundle.
221
+ * The site's module-list sources. The site owns any dev overrides and passes
222
+ * the result in as `packageListURL`.
225
223
  */
226
224
  function resolveDefaultModules(options) {
227
225
  const configured = options.packageListURL ?? [];
228
226
  const builtin = (Array.isArray(configured) ? configured : [configured]).filter(Boolean);
229
- const override = globalThis.localStorage?.getItem("systemPackageListURL");
230
- if (override && isValidModuleSource(override)) {
231
- console.info(`using systemPackageListURL from localStorage: ${override}`);
232
- return [override];
233
- }
234
- if (override) {
235
- console.warn(`ignoring invalid systemPackageListURL in localStorage: ${override}`);
236
- }
237
227
  if (builtin.length === 0) {
238
228
  throw new Error("patchwork.setup: no default module sources configured (set `packageListURL`)");
239
229
  }
package/dist/types.d.ts CHANGED
@@ -36,8 +36,6 @@ export interface PatchworkOptions {
36
36
  * The module URLs *inside* either kind of source may themselves be Automerge
37
37
  * folder docs or plain HTTP(S) bundles, so deployment targets can be freely
38
38
  * mixed.
39
- *
40
- * Overridable at runtime with `localStorage.systemPackageListURL`.
41
39
  */
42
40
  packageListURL?: string | string[];
43
41
  /**
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork",
3
- "version": "0.1.0",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "git+https://github.com/inkandswitch/patchwork-system.git",
6
+ "directory": "core/patchwork"
7
+ },
8
+ "version": "0.2.1",
4
9
  "author": "Ink & Switch",
5
10
  "type": "module",
6
11
  "license": "MIT",
@@ -37,11 +42,11 @@
37
42
  "debug": "^4.4.3",
38
43
  "sharp": "^0.35.3",
39
44
  "vite-plugin-wasm": "^3.6.0",
40
- "@inkandswitch/patchwork-bootloader": "^0.5.0",
41
- "@inkandswitch/patchwork-elements": "^4.0.2",
42
- "@inkandswitch/patchwork-filesystem": "^0.2.3",
43
- "@inkandswitch/patchwork-plugins": "^1.0.1",
44
- "@inkandswitch/patchwork-providers": "^0.4.2"
45
+ "@inkandswitch/patchwork-bootloader": "^0.5.2",
46
+ "@inkandswitch/patchwork-filesystem": "^0.2.5",
47
+ "@inkandswitch/patchwork-elements": "^4.0.4",
48
+ "@inkandswitch/patchwork-providers": "^0.4.2",
49
+ "@inkandswitch/patchwork-plugins": "^1.0.3"
45
50
  },
46
51
  "devDependencies": {
47
52
  "esbuild": "^0.23.1",
package/src/client.d.ts CHANGED
@@ -18,7 +18,7 @@ declare global {
18
18
  /**
19
19
  * Comma-separated list of default tool-manifest sources the shell boots
20
20
  * with. Each entry is an `automerge:` URL or a static `modules.json`
21
- * URL. Overridable at runtime via `localStorage.systemPackageListURL`.
21
+ * URL.
22
22
  */
23
23
  readonly PATCHWORK_SYSTEM_PACKAGE_LIST_URL?: string;
24
24
  /**
package/src/index.ts CHANGED
@@ -22,7 +22,6 @@ import {
22
22
  type DocHandle,
23
23
  MessageChannelNetworkAdapter,
24
24
  Repo,
25
- isValidAutomergeUrl,
26
25
  } from "@automerge/vanillajs/slim";
27
26
  import * as Automerge from "@automerge/automerge/slim";
28
27
  import * as AutomergeRepo from "@automerge/automerge-repo/slim";
@@ -69,6 +68,7 @@ declare const __SITE_NAME__: string;
69
68
  declare global {
70
69
  interface Window {
71
70
  patchwork: Patchwork;
71
+ accountDocHandle: DocHandle<AccountDoc>;
72
72
  repo: Repo;
73
73
  Automerge: typeof import("@automerge/automerge");
74
74
  AutomergeRepo: typeof import("@automerge/automerge-repo");
@@ -224,19 +224,9 @@ async function doSetup(options: PatchworkOptions): Promise<Patchwork> {
224
224
  hive,
225
225
  })) as DocHandle<AccountDoc>;
226
226
 
227
+ window.accountDocHandle = accountDocHandle;
227
228
  wireModuleSettings(accountDocHandle, moduleWatcher);
228
229
 
229
- let router: Router | undefined;
230
- if (routing !== false) {
231
- rootElement.style.visibility = "hidden";
232
- router = createRouter({
233
- rootElement,
234
- repo,
235
- accountDocHandle,
236
- siteName,
237
- });
238
- }
239
-
240
230
  const toolsLoaded = moduleWatcher.doneLoading.then(
241
231
  () =>
242
232
  log(
@@ -248,6 +238,18 @@ async function doSetup(options: PatchworkOptions): Promise<Patchwork> {
248
238
  (err: unknown) => console.error("doneLoading rejected:", err)
249
239
  );
250
240
 
241
+ let router: Router | undefined;
242
+ if (routing !== false) {
243
+ rootElement.style.visibility = "hidden";
244
+ await toolsLoaded;
245
+ router = createRouter({
246
+ rootElement,
247
+ repo,
248
+ accountDocHandle,
249
+ siteName,
250
+ });
251
+ }
252
+
251
253
  installReveal(rootElement, router, toolsLoaded);
252
254
 
253
255
  return {
@@ -330,14 +332,9 @@ function installReveal(
330
332
 
331
333
  // ── Module sources ───────────────────────────────────────────────────────
332
334
 
333
- function isValidModuleSource(source: string): boolean {
334
- return isValidAutomergeUrl(source) || /^(https?:\/\/|\.?\/)/.test(source);
335
- }
336
-
337
335
  /**
338
- * The site's default module-list sources, honouring the
339
- * `localStorage.systemPackageListURL` dev override, which replaces the entire
340
- * built-in bundle.
336
+ * The site's module-list sources. The site owns any dev overrides and passes
337
+ * the result in as `packageListURL`.
341
338
  */
342
339
  function resolveDefaultModules(options: PatchworkOptions): string[] {
343
340
  const configured = options.packageListURL ?? [];
@@ -345,18 +342,6 @@ function resolveDefaultModules(options: PatchworkOptions): string[] {
345
342
  Array.isArray(configured) ? configured : [configured]
346
343
  ).filter(Boolean);
347
344
 
348
- const override = globalThis.localStorage?.getItem("systemPackageListURL");
349
-
350
- if (override && isValidModuleSource(override)) {
351
- console.info(`using systemPackageListURL from localStorage: ${override}`);
352
- return [override];
353
- }
354
- if (override) {
355
- console.warn(
356
- `ignoring invalid systemPackageListURL in localStorage: ${override}`
357
- );
358
- }
359
-
360
345
  if (builtin.length === 0) {
361
346
  throw new Error(
362
347
  "patchwork.setup: no default module sources configured (set `packageListURL`)"
package/src/types.ts CHANGED
@@ -53,8 +53,6 @@ export interface PatchworkOptions {
53
53
  * The module URLs *inside* either kind of source may themselves be Automerge
54
54
  * folder docs or plain HTTP(S) bundles, so deployment targets can be freely
55
55
  * mixed.
56
- *
57
- * Overridable at runtime with `localStorage.systemPackageListURL`.
58
56
  */
59
57
  packageListURL?: string | string[];
60
58