@inkandswitch/patchwork-bootloader 0.4.0 → 0.4.2

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,34 @@
1
1
  # @inkandswitch/patchwork-bootloader
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 82bee46: A doc's `suggestedImportUrl` may now be an `automerge:` folder-doc URL as well
8
+ as an `http(s):` module bundle. When a view finds no built-in tool for a doc, it
9
+ loads the suggested module either way. Adds `importPackage` (which dispatches on
10
+ the URL scheme) and `isImportableSuggestedUrl` to `patchwork-filesystem`, and
11
+ `getSuggestedImportUrl` now honors automerge URLs.
12
+
13
+ The package-importing helpers are renamed from `module` to `package`, since they
14
+ resolve a `package.json` entry point: `importModuleFromFolderDocUrl` →
15
+ `importPackageFromFolderDocUrl`, `importModuleFromHttpUrl` →
16
+ `importPackageFromHttpUrl`, and the `ModuleWatcher` `importAutomergeModule` hook
17
+ (with bootloader's `importAutomergeModuleViaWorker`) → `importAutomergePackage`.
18
+
19
+ - Updated dependencies [82bee46]
20
+ - @inkandswitch/patchwork-filesystem@0.2.0
21
+ - @inkandswitch/patchwork-elements@4.0.0
22
+ - @inkandswitch/patchwork-plugins@1.0.0
23
+
24
+ ## 0.4.1
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [2d39c84]
29
+ - @inkandswitch/patchwork-providers@0.4.0
30
+ - @inkandswitch/patchwork-elements@3.0.0
31
+
3
32
  ## 0.4.0
4
33
 
5
34
  ### Minor Changes
package/dist/externals.js CHANGED
@@ -28,6 +28,7 @@ const externals = [
28
28
  "@codemirror/state",
29
29
  "@codemirror/view",
30
30
  "@codemirror/language",
31
+ "@codemirror/commands",
31
32
  // rip
32
33
  "solid-js",
33
34
  "solid-js/html",
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // Created with type:"module"; its dynamic `import()` of `/<automergeUrl>/…`
12
12
  // entry points is served by the service worker that controls this worker.
13
- import { importModuleFromFolderDocUrl } from "@inkandswitch/patchwork-filesystem";
13
+ import { importPackageFromFolderDocUrl } from "@inkandswitch/patchwork-filesystem";
14
14
  // Keep only the structured-cloneable description fields. `load` is a closure
15
15
  // and `module` is the (possibly already-loaded) implementation — neither can
16
16
  // cross the worker boundary. `import` is droppable too: the main thread
@@ -33,7 +33,7 @@ self.addEventListener("message", (event) => {
33
33
  if (!isDiscoverRequest(data))
34
34
  return;
35
35
  const { id, url } = data;
36
- importModuleFromFolderDocUrl(url)
36
+ importPackageFromFolderDocUrl(url)
37
37
  .then((mod) => {
38
38
  const plugins = Array.isArray(mod?.plugins) ? mod.plugins : [];
39
39
  const descriptors = plugins.map(toDescriptor);
@@ -3,11 +3,11 @@ type Descriptor = Record<string, unknown> & {
3
3
  type?: string;
4
4
  };
5
5
  /**
6
- * ModuleWatcher `importAutomergeModule` hook: discover descriptors in the
6
+ * ModuleWatcher `importAutomergePackage` hook: discover descriptors in the
7
7
  * worker, then return the `{ plugins }` shape with a main-thread `load()` per
8
8
  * plugin that imports the package at heads and calls its real loader.
9
9
  */
10
- export declare function importAutomergeModuleViaWorker(urlAtHeads: string): Promise<{
10
+ export declare function importAutomergePackageViaWorker(urlAtHeads: string): Promise<{
11
11
  plugins: Descriptor[];
12
12
  }>;
13
13
  export {};
@@ -1,6 +1,6 @@
1
1
  // Main-thread client for the module-loader worker (see module-loader-worker.ts).
2
2
  //
3
- // `importAutomergeModuleViaWorker` is wired into the ModuleWatcher in place of
3
+ // `importAutomergePackageViaWorker` is wired into the ModuleWatcher in place of
4
4
  // its default (direct, main-thread) package import. It asks the worker to
5
5
  // import the package entry point and report which plugins it exports, then
6
6
  // returns the same `{ plugins }` shape the watcher already feeds to
@@ -50,11 +50,11 @@ function discoverDescriptors(urlAtHeads) {
50
50
  });
51
51
  }
52
52
  /**
53
- * ModuleWatcher `importAutomergeModule` hook: discover descriptors in the
53
+ * ModuleWatcher `importAutomergePackage` hook: discover descriptors in the
54
54
  * worker, then return the `{ plugins }` shape with a main-thread `load()` per
55
55
  * plugin that imports the package at heads and calls its real loader.
56
56
  */
57
- export async function importAutomergeModuleViaWorker(urlAtHeads) {
57
+ export async function importAutomergePackageViaWorker(urlAtHeads) {
58
58
  const url = urlAtHeads;
59
59
  const descriptors = await discoverDescriptors(url);
60
60
  const plugins = descriptors.map((descriptor) => {
package/dist/site.d.ts CHANGED
@@ -61,7 +61,7 @@ export interface SiteConfig {
61
61
  * folder docs or plain HTTP(S) bundles, so deployment targets can be freely
62
62
  * mixed.
63
63
  *
64
- * Can be overridden at runtime by setting `localStorage.defaultToolsUrl` to
64
+ * Can be overridden at runtime by setting `localStorage.systemPackageListURL` to
65
65
  * another `automerge:` URL or manifest URL — useful for local development
66
66
  * against an unpublished tool set.
67
67
  */
package/dist/site.js CHANGED
@@ -23,7 +23,7 @@ import { MemorySigner } from "@automerge/automerge-subduction/slim";
23
23
  const siteName = typeof __SITE_NAME__ !== "undefined" ? __SITE_NAME__ : "tiny-patchwork";
24
24
  const useKeyhiveSyncServer = typeof __KEYHIVE_SYNC_SERVER__ !== "undefined" && __KEYHIVE_SYNC_SERVER__;
25
25
  import { ModuleWatcher } from "@inkandswitch/patchwork-filesystem";
26
- import { importAutomergeModuleViaWorker } from "./module-loader.js";
26
+ import { importAutomergePackageViaWorker } from "./module-loader.js";
27
27
  import { openDocument, registerPatchworkViewElement, } from "@inkandswitch/patchwork-elements";
28
28
  import { registerRepoProviderElement } from "@inkandswitch/patchwork-providers";
29
29
  import { getRegistry, registerPlugins, resolveAccountHandle, unregisterPlugins, } from "@inkandswitch/patchwork-plugins";
@@ -157,7 +157,7 @@ export async function bootPatchworkSite(config) {
157
157
  const moduleWatcher = new ModuleWatcher(repo, buildSystemSources(defaultModuleSources), onModuleLoaded, unregisterPlugins,
158
158
  // Discover an Automerge package's plugin descriptors off the main thread;
159
159
  // each plugin's load() re-imports the package (at heads) on this thread.
160
- importAutomergeModuleViaWorker);
160
+ importAutomergePackageViaWorker);
161
161
  const accountDocHandle = (await resolveAccountHandle(repo, {
162
162
  storageKey: config.accountStorageKey,
163
163
  hive,
@@ -204,21 +204,24 @@ function isValidModuleSource(source) {
204
204
  }
205
205
  /**
206
206
  * Resolve the site's default module-list sources, honouring the
207
- * `localStorage.defaultToolsUrl` dev override (which replaces the entire
207
+ * `localStorage.systemPackageListURL` dev override (which replaces the entire
208
208
  * built-in default bundle).
209
209
  */
210
210
  function resolveDefaultModules(config) {
211
211
  const builtin = config.defaultModules ?? config.defaultModulesUrl ?? [];
212
212
  const builtinList = (Array.isArray(builtin) ? builtin : [builtin]).filter(Boolean);
213
- const override = globalThis.localStorage?.getItem("defaultToolsUrl");
213
+ const storage = globalThis.localStorage;
214
+ // `defaultToolsUrl` is the pre-rename key, still honoured for existing browsers.
215
+ const override = storage?.getItem("systemPackageListURL") ??
216
+ storage?.getItem("defaultToolsUrl");
214
217
  if (override) {
215
218
  if (isValidModuleSource(override)) {
216
219
  if (!builtinList.includes(override)) {
217
- console.info(`using defaultToolsUrl override from localStorage: ${override}`);
220
+ console.info(`using systemPackageListURL override from localStorage: ${override}`);
218
221
  }
219
222
  return [override];
220
223
  }
221
- console.warn(`ignoring invalid defaultToolsUrl in localStorage: ${override}; using built-in default`);
224
+ console.warn(`ignoring invalid systemPackageListURL in localStorage: ${override}; using built-in default`);
222
225
  }
223
226
  if (builtinList.length === 0) {
224
227
  throw new Error("bootPatchworkSite: no default module sources configured (set `defaultModules`)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork-bootloader",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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.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",
47
+ "@automerge/automerge": "3.3.2",
48
+ "@automerge/automerge-repo": "2.6.0-subduction.46",
49
+ "@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.45",
50
+ "@automerge/automerge-repo-network-websocket": "2.6.0-subduction.45",
51
+ "@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.45",
52
52
  "@automerge/automerge-subduction": "0.16.0",
53
- "@automerge/vanillajs": "2.6.0-subduction.44",
53
+ "@automerge/vanillajs": "2.6.0-subduction.45",
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-elements": "^2.0.0",
61
- "@inkandswitch/patchwork-filesystem": "^0.1.3",
62
- "@inkandswitch/patchwork-plugins": "^0.0.11",
63
- "@inkandswitch/patchwork-providers": "^0.3.0"
60
+ "@inkandswitch/patchwork-elements": "^4.0.0",
61
+ "@inkandswitch/patchwork-filesystem": "^0.2.0",
62
+ "@inkandswitch/patchwork-plugins": "^1.0.0",
63
+ "@inkandswitch/patchwork-providers": "^0.4.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@automerge/automerge": "3.3.0-fragments.2",
67
- "@automerge/automerge-repo": "2.6.0-subduction.44",
66
+ "@automerge/automerge": "3.3.2",
67
+ "@automerge/automerge-repo": "2.6.0-subduction.46",
68
68
  "@automerge/automerge-repo-keyhive": "0.3.0-alpha.sub.8b",
69
- "@automerge/vanillajs": "2.6.0-subduction.44"
69
+ "@automerge/vanillajs": "2.6.0-subduction.45"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsc",
package/src/externals.ts CHANGED
@@ -29,6 +29,7 @@ const externals = [
29
29
  "@codemirror/state",
30
30
  "@codemirror/view",
31
31
  "@codemirror/language",
32
+ "@codemirror/commands",
32
33
 
33
34
  // rip
34
35
  "solid-js",
@@ -11,7 +11,7 @@
11
11
  // Created with type:"module"; its dynamic `import()` of `/<automergeUrl>/…`
12
12
  // entry points is served by the service worker that controls this worker.
13
13
 
14
- import { importModuleFromFolderDocUrl } from "@inkandswitch/patchwork-filesystem";
14
+ import { importPackageFromFolderDocUrl } from "@inkandswitch/patchwork-filesystem";
15
15
  import type { AutomergeUrl } from "@automerge/automerge-repo/slim";
16
16
 
17
17
  type DiscoverRequest = {
@@ -45,7 +45,7 @@ self.addEventListener("message", (event: MessageEvent) => {
45
45
  if (!isDiscoverRequest(data)) return;
46
46
  const { id, url } = data;
47
47
 
48
- importModuleFromFolderDocUrl(url)
48
+ importPackageFromFolderDocUrl(url)
49
49
  .then((mod) => {
50
50
  const plugins: any[] = Array.isArray(mod?.plugins) ? mod.plugins : [];
51
51
  const descriptors = plugins.map(toDescriptor);
@@ -1,6 +1,6 @@
1
1
  // Main-thread client for the module-loader worker (see module-loader-worker.ts).
2
2
  //
3
- // `importAutomergeModuleViaWorker` is wired into the ModuleWatcher in place of
3
+ // `importAutomergePackageViaWorker` is wired into the ModuleWatcher in place of
4
4
  // its default (direct, main-thread) package import. It asks the worker to
5
5
  // import the package entry point and report which plugins it exports, then
6
6
  // returns the same `{ plugins }` shape the watcher already feeds to
@@ -62,11 +62,11 @@ function discoverDescriptors(urlAtHeads: AutomergeUrl): Promise<Descriptor[]> {
62
62
  }
63
63
 
64
64
  /**
65
- * ModuleWatcher `importAutomergeModule` hook: discover descriptors in the
65
+ * ModuleWatcher `importAutomergePackage` hook: discover descriptors in the
66
66
  * worker, then return the `{ plugins }` shape with a main-thread `load()` per
67
67
  * plugin that imports the package at heads and calls its real loader.
68
68
  */
69
- export async function importAutomergeModuleViaWorker(
69
+ export async function importAutomergePackageViaWorker(
70
70
  urlAtHeads: string
71
71
  ): Promise<{ plugins: Descriptor[] }> {
72
72
  const url = urlAtHeads as AutomergeUrl;
package/src/site.ts CHANGED
@@ -48,7 +48,7 @@ const useKeyhiveSyncServer =
48
48
  typeof __KEYHIVE_SYNC_SERVER__ !== "undefined" && __KEYHIVE_SYNC_SERVER__;
49
49
 
50
50
  import { ModuleWatcher } from "@inkandswitch/patchwork-filesystem";
51
- import { importAutomergeModuleViaWorker } from "./module-loader.js";
51
+ import { importAutomergePackageViaWorker } from "./module-loader.js";
52
52
  import {
53
53
  openDocument,
54
54
  registerPatchworkViewElement,
@@ -126,7 +126,7 @@ export interface SiteConfig {
126
126
  * folder docs or plain HTTP(S) bundles, so deployment targets can be freely
127
127
  * mixed.
128
128
  *
129
- * Can be overridden at runtime by setting `localStorage.defaultToolsUrl` to
129
+ * Can be overridden at runtime by setting `localStorage.systemPackageListURL` to
130
130
  * another `automerge:` URL or manifest URL — useful for local development
131
131
  * against an unpublished tool set.
132
132
  */
@@ -322,7 +322,7 @@ export async function bootPatchworkSite(
322
322
  unregisterPlugins,
323
323
  // Discover an Automerge package's plugin descriptors off the main thread;
324
324
  // each plugin's load() re-imports the package (at heads) on this thread.
325
- importAutomergeModuleViaWorker
325
+ importAutomergePackageViaWorker
326
326
  );
327
327
 
328
328
  const accountDocHandle = (await resolveAccountHandle(repo, {
@@ -381,7 +381,7 @@ function isValidModuleSource(source: string): boolean {
381
381
 
382
382
  /**
383
383
  * Resolve the site's default module-list sources, honouring the
384
- * `localStorage.defaultToolsUrl` dev override (which replaces the entire
384
+ * `localStorage.systemPackageListURL` dev override (which replaces the entire
385
385
  * built-in default bundle).
386
386
  */
387
387
  function resolveDefaultModules(config: SiteConfig): string[] {
@@ -390,18 +390,22 @@ function resolveDefaultModules(config: SiteConfig): string[] {
390
390
  Boolean
391
391
  );
392
392
 
393
- const override = globalThis.localStorage?.getItem("defaultToolsUrl");
393
+ const storage = globalThis.localStorage;
394
+ // `defaultToolsUrl` is the pre-rename key, still honoured for existing browsers.
395
+ const override =
396
+ storage?.getItem("systemPackageListURL") ??
397
+ storage?.getItem("defaultToolsUrl");
394
398
  if (override) {
395
399
  if (isValidModuleSource(override)) {
396
400
  if (!builtinList.includes(override)) {
397
401
  console.info(
398
- `using defaultToolsUrl override from localStorage: ${override}`
402
+ `using systemPackageListURL override from localStorage: ${override}`
399
403
  );
400
404
  }
401
405
  return [override];
402
406
  }
403
407
  console.warn(
404
- `ignoring invalid defaultToolsUrl in localStorage: ${override}; using built-in default`
408
+ `ignoring invalid systemPackageListURL in localStorage: ${override}; using built-in default`
405
409
  );
406
410
  }
407
411