From 04f8a3674521d8a36f70d9a04da25a73cf752fbd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:09:23 +0000 Subject: [PATCH 1/4] Initial plan From 0b4ce6e9fa5977d916d57d4d0e872df0ffd3137a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:11:53 +0000 Subject: [PATCH 2/4] Fix HTTP package import warning Co-authored-by: chee <178266+chee@users.noreply.github.com> --- packages/src/discover-plugins.test.ts | 30 +++++++++++++++++++++++++++ packages/src/discover-plugins.ts | 14 +++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 packages/src/discover-plugins.test.ts diff --git a/packages/src/discover-plugins.test.ts b/packages/src/discover-plugins.test.ts new file mode 100644 index 00000000..64633b67 --- /dev/null +++ b/packages/src/discover-plugins.test.ts @@ -0,0 +1,30 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const { importModuleFromHttpUrl } = vi.hoisted(() => ({ + importModuleFromHttpUrl: vi.fn(), +})); + +vi.mock("@inkandswitch/patchwork-filesystem", () => ({ + importModuleFromHttpUrl, +})); + +import { discoverHttpPlugins } from "./discover-plugins.ts"; + +describe("discoverHttpPlugins", () => { + beforeEach(() => { + importModuleFromHttpUrl.mockReset(); + }); + + it("imports HTTP packages through the host filesystem", async () => { + importModuleFromHttpUrl.mockResolvedValue({ + plugins: [{ id: "example", load: () => {} }], + }); + + await expect( + discoverHttpPlugins("https://example.com/package/") + ).resolves.toEqual([{ id: "example" }]); + expect(importModuleFromHttpUrl).toHaveBeenCalledWith( + "https://example.com/package/" + ); + }); +}); diff --git a/packages/src/discover-plugins.ts b/packages/src/discover-plugins.ts index eb694dfc..b8880906 100644 --- a/packages/src/discover-plugins.ts +++ b/packages/src/discover-plugins.ts @@ -138,15 +138,11 @@ export async function discoverHttpPlugins( url: string, timeoutMs = 15000 ): Promise { - // Reached via the host importmap at runtime; guard so an older filesystem - // bundle degrades to "couldn't preview" instead of a hard module-load error. - const importHttp = filesystem.importModuleFromHttpUrl; - if (typeof importHttp !== "function") { - throw new Error( - "This host build can't import http(s) packages — update @inkandswitch/patchwork-filesystem to 0.1.3+." - ); - } - const mod = await withTimeout(importHttp(url), timeoutMs, "importing the package"); + const mod = await withTimeout( + filesystem.importModuleFromHttpUrl(url), + timeoutMs, + "importing the package" + ); const plugins: any[] = Array.isArray((mod as any)?.plugins) ? (mod as any).plugins : []; From ab315734c53c24d9df2fd8cfe6c2f7de9c889809 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 9 Sep 2026 16:40:20 +0000 Subject: [PATCH 3/4] Import HTTP packages directly Co-authored-by: chee <178266+chee@users.noreply.github.com> --- packages/src/discover-plugins.test.ts | 28 ++++----------------------- packages/src/discover-plugins.ts | 5 ++--- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/packages/src/discover-plugins.test.ts b/packages/src/discover-plugins.test.ts index 64633b67..f2bc02a5 100644 --- a/packages/src/discover-plugins.test.ts +++ b/packages/src/discover-plugins.test.ts @@ -1,30 +1,10 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - -const { importModuleFromHttpUrl } = vi.hoisted(() => ({ - importModuleFromHttpUrl: vi.fn(), -})); - -vi.mock("@inkandswitch/patchwork-filesystem", () => ({ - importModuleFromHttpUrl, -})); - +import { describe, expect, it } from "vitest"; import { discoverHttpPlugins } from "./discover-plugins.ts"; describe("discoverHttpPlugins", () => { - beforeEach(() => { - importModuleFromHttpUrl.mockReset(); - }); - - it("imports HTTP packages through the host filesystem", async () => { - importModuleFromHttpUrl.mockResolvedValue({ - plugins: [{ id: "example", load: () => {} }], - }); + it("imports package plugin descriptors directly", async () => { + const url = "data:text/javascript,export const plugins = [{ id: 'example' }]"; - await expect( - discoverHttpPlugins("https://example.com/package/") - ).resolves.toEqual([{ id: "example" }]); - expect(importModuleFromHttpUrl).toHaveBeenCalledWith( - "https://example.com/package/" - ); + await expect(discoverHttpPlugins(url)).resolves.toEqual([{ id: "example" }]); }); }); diff --git a/packages/src/discover-plugins.ts b/packages/src/discover-plugins.ts index b8880906..20e5212f 100644 --- a/packages/src/discover-plugins.ts +++ b/packages/src/discover-plugins.ts @@ -6,7 +6,6 @@ // manager's client — we don't rebuild each descriptor's load(); there are no // external deps here. -import * as filesystem from "@inkandswitch/patchwork-filesystem"; import { isAutomergeUrl } from "./origin.ts"; export interface PluginDescriptor { @@ -127,7 +126,7 @@ function withTimeout(p: Promise, ms: number, what: string): Promise { * Discover the plugins an http(s) package exports by importing its entry module * and reading its `plugins` export — the http counterpart to the worker-based * automerge discovery, and the same thing the host does for suggested/http - * modules (`importModuleFromHttpUrl` → `mod.plugins`). + * modules. * * It runs on the MAIN thread deliberately: there is no host worker that imports * http URLs, and a plain Worker has no importmap to resolve the module's bare @@ -139,7 +138,7 @@ export async function discoverHttpPlugins( timeoutMs = 15000 ): Promise { const mod = await withTimeout( - filesystem.importModuleFromHttpUrl(url), + import(/* @vite-ignore */ url), timeoutMs, "importing the package" ); From 95b944671c7d3cfb8f2465fc545762380f1a1d5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:01:30 +0000 Subject: [PATCH 4/4] Use supported HTTP package importer Co-authored-by: chee <178266+chee@users.noreply.github.com> --- packages/package.json | 2 +- packages/pnpm-lock.yaml | 12 +++++------- packages/src/discover-plugins.test.ts | 28 +++++++++++++++++++++++---- packages/src/discover-plugins.ts | 5 +++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/packages/package.json b/packages/package.json index 6f4607ec..06aa28f2 100644 --- a/packages/package.json +++ b/packages/package.json @@ -19,7 +19,7 @@ "keywords": [], "author": "Ink & Switch", "dependencies": { - "@inkandswitch/patchwork-filesystem": "^0.1.3", + "@inkandswitch/patchwork-filesystem": "^0.2.7", "@inkandswitch/patchwork-plugins": "^0.0.5", "solid-js": "^1.9.3" }, diff --git a/packages/pnpm-lock.yaml b/packages/pnpm-lock.yaml index 3ffec2fc..72222f69 100644 --- a/packages/pnpm-lock.yaml +++ b/packages/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@inkandswitch/patchwork-filesystem': - specifier: ^0.1.3 - version: 0.1.3(@automerge/automerge-repo@2.5.0)(@automerge/automerge@3.2.1) + specifier: ^0.2.7 + version: 0.2.7(@automerge/automerge-repo@2.5.0)(@automerge/automerge@3.2.1) '@inkandswitch/patchwork-plugins': specifier: ^0.0.5 version: 0.0.5 @@ -351,8 +351,8 @@ packages: '@inkandswitch/patchwork-filesystem@0.0.3': resolution: {integrity: sha512-x6yqX1Xyr05ug4YfRyfKJ7jSm/zjhMxU7g/e70nz4QbxfLmcG98LHB9qAkFI2zd+VvKLnTvSpPGu2UvJzXGciw==} - '@inkandswitch/patchwork-filesystem@0.1.3': - resolution: {integrity: sha512-hanR/YQUAE8aRg9GoYdG8H9muvuYiGYYXzb4ssa9WXDkirqWwShdzM2xVs7t0txja2b1yPbmMUf9uHzSLyyPYQ==} + '@inkandswitch/patchwork-filesystem@0.2.7': + resolution: {integrity: sha512-8tyhW6Y2c5pJurfUfBioPTLwxC8j1Ye4cVQeQyhzeh8iqriklBCQRd5kacWU8tzDw5ZXcd0e/mbRjI4WxkGB2g==} peerDependencies: '@automerge/automerge': '*' '@automerge/automerge-repo': '*' @@ -1352,12 +1352,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@inkandswitch/patchwork-filesystem@0.1.3(@automerge/automerge-repo@2.5.0)(@automerge/automerge@3.2.1)': + '@inkandswitch/patchwork-filesystem@0.2.7(@automerge/automerge-repo@2.5.0)(@automerge/automerge@3.2.1)': dependencies: '@automerge/automerge': 3.2.1 '@automerge/automerge-repo': 2.5.0 - '@types/debug': 4.1.13 - '@types/node': 20.19.43 debug: 4.4.3 resolve.exports: 2.0.3 transitivePeerDependencies: diff --git a/packages/src/discover-plugins.test.ts b/packages/src/discover-plugins.test.ts index f2bc02a5..05b867e1 100644 --- a/packages/src/discover-plugins.test.ts +++ b/packages/src/discover-plugins.test.ts @@ -1,10 +1,30 @@ -import { describe, expect, it } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const { importPackageFromHttpUrl } = vi.hoisted(() => ({ + importPackageFromHttpUrl: vi.fn(), +})); + +vi.mock("@inkandswitch/patchwork-filesystem", () => ({ + importPackageFromHttpUrl, +})); + import { discoverHttpPlugins } from "./discover-plugins.ts"; describe("discoverHttpPlugins", () => { - it("imports package plugin descriptors directly", async () => { - const url = "data:text/javascript,export const plugins = [{ id: 'example' }]"; + beforeEach(() => { + importPackageFromHttpUrl.mockReset(); + }); + + it("imports HTTP packages through the host package importer", async () => { + importPackageFromHttpUrl.mockResolvedValue({ + plugins: [{ id: "example", load: () => {} }], + }); - await expect(discoverHttpPlugins(url)).resolves.toEqual([{ id: "example" }]); + await expect( + discoverHttpPlugins("https://example.com/package/") + ).resolves.toEqual([{ id: "example" }]); + expect(importPackageFromHttpUrl).toHaveBeenCalledWith( + "https://example.com/package/" + ); }); }); diff --git a/packages/src/discover-plugins.ts b/packages/src/discover-plugins.ts index 20e5212f..5d6e8b8d 100644 --- a/packages/src/discover-plugins.ts +++ b/packages/src/discover-plugins.ts @@ -6,6 +6,7 @@ // manager's client — we don't rebuild each descriptor's load(); there are no // external deps here. +import * as filesystem from "@inkandswitch/patchwork-filesystem"; import { isAutomergeUrl } from "./origin.ts"; export interface PluginDescriptor { @@ -126,7 +127,7 @@ function withTimeout(p: Promise, ms: number, what: string): Promise { * Discover the plugins an http(s) package exports by importing its entry module * and reading its `plugins` export — the http counterpart to the worker-based * automerge discovery, and the same thing the host does for suggested/http - * modules. + * modules (`importPackageFromHttpUrl` → `mod.plugins`). * * It runs on the MAIN thread deliberately: there is no host worker that imports * http URLs, and a plain Worker has no importmap to resolve the module's bare @@ -138,7 +139,7 @@ export async function discoverHttpPlugins( timeoutMs = 15000 ): Promise { const mod = await withTimeout( - import(/* @vite-ignore */ url), + filesystem.importPackageFromHttpUrl(url), timeoutMs, "importing the package" );