@inkandswitch/patchwork-bootloader 0.6.0 → 0.6.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,22 @@
1
1
  # @inkandswitch/patchwork-bootloader
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 846cfac: Update the pinned `@automerge/*` versions to `2.6.0-subduction.47`. These are exact pins in `dependencies` and `peerDependencies`, so both packages need to ship the new version together — installing a `.46` and a `.47` package side by side loads two copies of automerge-repo, and document handles from one are not recognised by the other.
8
+ - 61a152a: Make `vite dev` work without a site hand-rolling the dev server.
9
+
10
+ The build emits the service worker, the automerge shared worker, the module-loader worker, and three wasm binaries. None of them existed in serve mode, so every one 404'd and dev only worked if a site served a previous production build's `dist/` behind vite. The plugin now serves all of them itself:
11
+
12
+ - The three worker entries are bundled on demand with esbuild and rebuilt per request, so they always reflect the source on disk. Their heavy imports resolve to the dev server's optimized-dep URLs, mirroring how the build rewrites them to `/packages/...` — import maps don't apply to `type: "module"` workers, so the URLs have to be real either way.
13
+ - `automerge.wasm`, `keyhive_wasm.wasm`, and `subduction.wasm` are served from the bootloader's own node_modules. `@inkandswitch/patchwork-bootloader/externals` gains `wasmAssets()`, which `emitWasmAssets` now uses too.
14
+ - `global.css` 404'd in dev: the generated `index.html` links it by bare specifier, which only the build resolves. Both patchwork's and the bootloader's stylesheets are now served under root-absolute paths, and the link points at them.
15
+ - `@patchwork/service-worker` called `emitFile` from `buildStart` unconditionally, which throws in serve mode — it logged "This plugin is likely not vite-compatible" three times on every dev-server start. It now skips emission when serving.
16
+ - Dep pre-bundling runs esbuild outside the plugin pipeline that applies `define`, so in dev the page fell back to the default storage prefix while the workers used the configured one — the two would have opened different IndexedDB databases. The defines are now passed to the optimizer as well.
17
+
18
+ Sites no longer need to filter `@patchwork/service-worker` out of the plugin list, serve stylesheets themselves, or keep a built `dist/` around for `vite dev`.
19
+
3
20
  ## 0.6.0
4
21
 
5
22
  ### Minor Changes
@@ -12,5 +12,14 @@ export { default } from "./externals-list.js";
12
12
  * up at bundle time. rollup applies the browser conditions vite configured.
13
13
  */
14
14
  export declare function resolveExternal(this: import("rollup").PluginContext, name: string): Promise<string>;
15
+ /**
16
+ * automerge/keyhive/subduction's wasm binaries, by the file name the service
17
+ * worker fetches them under. Resolved from this package's node_modules for the
18
+ * same reason as {@link resolveExternal}.
19
+ */
20
+ export declare function wasmAssets(): {
21
+ fileName: string;
22
+ path: string;
23
+ }[];
15
24
  /** Emits automerge/keyhive/subduction's wasm binaries as build assets, so the service worker can fetch them. */
16
25
  export declare function emitWasmAssets(this: import("rollup").PluginContext): void;
package/dist/externals.js CHANGED
@@ -29,24 +29,34 @@ export async function resolveExternal(name) {
29
29
  }
30
30
  return resolved.id;
31
31
  }
32
+ /**
33
+ * automerge/keyhive/subduction's wasm binaries, by the file name the service
34
+ * worker fetches them under. Resolved from this package's node_modules for the
35
+ * same reason as {@link resolveExternal}.
36
+ */
37
+ export function wasmAssets() {
38
+ return [
39
+ {
40
+ fileName: "automerge.wasm",
41
+ path: require.resolve("@automerge/automerge/automerge.wasm"),
42
+ },
43
+ {
44
+ fileName: "keyhive_wasm.wasm",
45
+ path: require.resolve("@keyhive/keyhive/keyhive_wasm.wasm"),
46
+ },
47
+ {
48
+ fileName: "subduction.wasm",
49
+ path: require.resolve("@automerge/automerge-subduction/wasm"),
50
+ },
51
+ ];
52
+ }
32
53
  /** Emits automerge/keyhive/subduction's wasm binaries as build assets, so the service worker can fetch them. */
33
54
  export function emitWasmAssets() {
34
- const automergeWasmPath = require.resolve("@automerge/automerge/automerge.wasm");
35
- this.emitFile({
36
- type: "asset",
37
- fileName: "automerge.wasm",
38
- source: readFileSync(automergeWasmPath),
39
- });
40
- const keyhiveWasmPath = require.resolve("@keyhive/keyhive/keyhive_wasm.wasm");
41
- this.emitFile({
42
- type: "asset",
43
- fileName: "keyhive_wasm.wasm",
44
- source: readFileSync(keyhiveWasmPath),
45
- });
46
- const subdWasmPath = require.resolve("@automerge/automerge-subduction/wasm");
47
- this.emitFile({
48
- type: "asset",
49
- fileName: "subduction.wasm",
50
- source: readFileSync(subdWasmPath),
51
- });
55
+ for (const { fileName, path } of wasmAssets()) {
56
+ this.emitFile({
57
+ type: "asset",
58
+ fileName,
59
+ source: readFileSync(path),
60
+ });
61
+ }
52
62
  }
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.6.0",
8
+ "version": "0.6.1",
9
9
  "author": "chee",
10
10
  "type": "module",
11
11
  "license": "MIT",
@@ -54,13 +54,13 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@automerge/automerge": "3.3.2",
57
- "@automerge/automerge-repo": "2.6.0-subduction.46",
57
+ "@automerge/automerge-repo": "2.6.0-subduction.47",
58
58
  "@automerge/automerge-repo-keyhive": "0.3.0-alpha.sub.8b",
59
- "@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.46",
60
- "@automerge/automerge-repo-network-websocket": "2.6.0-subduction.46",
61
- "@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.46",
59
+ "@automerge/automerge-repo-network-messagechannel": "2.6.0-subduction.47",
60
+ "@automerge/automerge-repo-network-websocket": "2.6.0-subduction.47",
61
+ "@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.47",
62
62
  "@automerge/automerge-subduction": "0.16.0",
63
- "@automerge/vanillajs": "2.6.0-subduction.46",
63
+ "@automerge/vanillajs": "2.6.0-subduction.47",
64
64
  "@codemirror/commands": "^6.10.4",
65
65
  "@codemirror/language": "^6.12.4",
66
66
  "@codemirror/state": "^6.7.1",
@@ -72,16 +72,16 @@
72
72
  "service-worker-types": "npm:@types/serviceworker@^0.0.153",
73
73
  "solid-js": "^1.9.13",
74
74
  "tinyargs": "^0.1.4",
75
+ "@inkandswitch/patchwork-elements": "^6.0.0",
75
76
  "@inkandswitch/patchwork-filesystem": "^0.2.5",
76
- "@inkandswitch/patchwork-providers": "^0.5.0",
77
77
  "@inkandswitch/patchwork-plugins": "^1.2.0",
78
- "@inkandswitch/patchwork-elements": "^6.0.0"
78
+ "@inkandswitch/patchwork-providers": "^0.5.0"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@automerge/automerge": "3.3.2",
82
- "@automerge/automerge-repo": "2.6.0-subduction.46",
82
+ "@automerge/automerge-repo": "2.6.0-subduction.47",
83
83
  "@automerge/automerge-repo-keyhive": "0.3.0-alpha.sub.8b",
84
- "@automerge/vanillajs": "2.6.0-subduction.46"
84
+ "@automerge/vanillajs": "2.6.0-subduction.47"
85
85
  },
86
86
  "peerDependenciesMeta": {
87
87
  "@automerge/automerge": {
package/src/externals.ts CHANGED
@@ -39,30 +39,35 @@ export async function resolveExternal(
39
39
  return resolved.id;
40
40
  }
41
41
 
42
+ /**
43
+ * automerge/keyhive/subduction's wasm binaries, by the file name the service
44
+ * worker fetches them under. Resolved from this package's node_modules for the
45
+ * same reason as {@link resolveExternal}.
46
+ */
47
+ export function wasmAssets(): { fileName: string; path: string }[] {
48
+ return [
49
+ {
50
+ fileName: "automerge.wasm",
51
+ path: require.resolve("@automerge/automerge/automerge.wasm"),
52
+ },
53
+ {
54
+ fileName: "keyhive_wasm.wasm",
55
+ path: require.resolve("@keyhive/keyhive/keyhive_wasm.wasm"),
56
+ },
57
+ {
58
+ fileName: "subduction.wasm",
59
+ path: require.resolve("@automerge/automerge-subduction/wasm"),
60
+ },
61
+ ];
62
+ }
63
+
42
64
  /** Emits automerge/keyhive/subduction's wasm binaries as build assets, so the service worker can fetch them. */
43
65
  export function emitWasmAssets(this: import("rollup").PluginContext): void {
44
- const automergeWasmPath = require.resolve(
45
- "@automerge/automerge/automerge.wasm"
46
- );
47
- this.emitFile({
48
- type: "asset",
49
- fileName: "automerge.wasm",
50
- source: readFileSync(automergeWasmPath),
51
- });
52
-
53
- const keyhiveWasmPath = require.resolve(
54
- "@keyhive/keyhive/keyhive_wasm.wasm"
55
- );
56
- this.emitFile({
57
- type: "asset",
58
- fileName: "keyhive_wasm.wasm",
59
- source: readFileSync(keyhiveWasmPath),
60
- });
61
-
62
- const subdWasmPath = require.resolve("@automerge/automerge-subduction/wasm");
63
- this.emitFile({
64
- type: "asset",
65
- fileName: "subduction.wasm",
66
- source: readFileSync(subdWasmPath),
67
- });
66
+ for (const { fileName, path } of wasmAssets()) {
67
+ this.emitFile({
68
+ type: "asset",
69
+ fileName,
70
+ source: readFileSync(path),
71
+ });
72
+ }
68
73
  }