@manta-eu/horns-client 0.1.4 → 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.
@@ -1,3 +1,8 @@
1
1
  export { hornsShapeCatalog, shapeCatalogModuleId } from "./shape-catalog.ts";
2
2
  export { hornsComponentApi, componentApiModuleId } from "./component-api.ts";
3
3
  export { hornsTypecheckFs, typecheckFsModuleId } from "./typecheck-fs.ts";
4
+ export { hornsWorkerSafe } from "./worker-safe.ts";
5
+ import type { Plugin } from "vite";
6
+ import type { Realm } from "@manta-eu/horns";
7
+ /** Every build-time input the worker needs, in one line. One realm per build: the SDK resolves its own at load. */
8
+ export declare function hornsPlugins(realm: Realm): Plugin[];
@@ -1,3 +1,12 @@
1
1
  export { hornsShapeCatalog, shapeCatalogModuleId } from "./shape-catalog.js";
2
2
  export { hornsComponentApi, componentApiModuleId } from "./component-api.js";
3
3
  export { hornsTypecheckFs, typecheckFsModuleId } from "./typecheck-fs.js";
4
+ export { hornsWorkerSafe } from "./worker-safe.js";
5
+ import { hornsShapeCatalog } from "./shape-catalog.js";
6
+ import { hornsComponentApi } from "./component-api.js";
7
+ import { hornsTypecheckFs } from "./typecheck-fs.js";
8
+ import { hornsWorkerSafe } from "./worker-safe.js";
9
+ /** Every build-time input the worker needs, in one line. One realm per build: the SDK resolves its own at load. */
10
+ export function hornsPlugins(realm) {
11
+ return [hornsShapeCatalog(realm), hornsComponentApi(), hornsTypecheckFs(), hornsWorkerSafe()];
12
+ }
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Keeps the worker bootable.
4
+ *
5
+ * None of `pnpm verify`, `vite build` or `wrangler deploy --dry-run` evaluates the worker's modules, so a
6
+ * dependency that throws at load passes all three and then dies on the first request. `boot:check` is what
7
+ * proves the worker starts; this is what keeps the known offenders from stopping it.
8
+ */
9
+ export declare function hornsWorkerSafe(also?: Readonly<Record<string, string>>): Plugin;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Modules that cannot be loaded in a worker, and why.
3
+ *
4
+ * Each one runs something at module load that workerd has not got, so importing it kills the worker before
5
+ * it serves anything. They are stubbed rather than removed: a host whose own code really wants one gets a
6
+ * sentence saying so, instead of a dependency failing somewhere far away.
7
+ *
8
+ * `turndown` is the one Horns drags in — `agents` depends on `just-bash`, which depends on it. At load it
9
+ * asks whether the platform parses HTML natively, and falls back to `require("@mixmark-io/domino")`.
10
+ */
11
+ const unloadable = {
12
+ turndown: "it needs a DOM parser, and falls back to `require` without one",
13
+ };
14
+ const prefix = "\0horns:worker-safe:";
15
+ function stubFor(name, why) {
16
+ const said = `${name} does not load in a worker: ${why}.`;
17
+ return [
18
+ `const why = ${JSON.stringify(said)};`,
19
+ "function refuse() { throw new Error(why); }",
20
+ "export default class { constructor() { refuse(); } }",
21
+ "export { refuse };",
22
+ ].join("\n");
23
+ }
24
+ /**
25
+ * Keeps the worker bootable.
26
+ *
27
+ * None of `pnpm verify`, `vite build` or `wrangler deploy --dry-run` evaluates the worker's modules, so a
28
+ * dependency that throws at load passes all three and then dies on the first request. `boot:check` is what
29
+ * proves the worker starts; this is what keeps the known offenders from stopping it.
30
+ */
31
+ export function hornsWorkerSafe(also = {}) {
32
+ const stubbed = { ...unloadable, ...also };
33
+ return {
34
+ name: "horns-worker-safe",
35
+ enforce: "pre",
36
+ resolveId: (source) => (source in stubbed ? `${prefix}${source}` : undefined),
37
+ load: (id) => {
38
+ if (!id.startsWith(prefix))
39
+ return undefined;
40
+ const name = id.slice(prefix.length);
41
+ const why = stubbed[name];
42
+ return why === undefined ? undefined : stubFor(name, why);
43
+ },
44
+ };
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manta-eu/horns-client",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "The Manta Horns app as a library: routes, providers and the written-view runtime for a React host.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,14 +60,15 @@
60
60
  "@manta-eu/lib": "0.1.5",
61
61
  "@ulb-darmstadt/shacl-form": "^2.1.1-rc1",
62
62
  "@xyflow/react": "^12.4.4",
63
+ "agents": "^0.24.0",
63
64
  "html-to-image": "1.11.13",
64
65
  "ldkit": "2.9.0",
65
66
  "lucide-react": "^0.525.0",
66
67
  "ts-pattern": "^5.9.0",
67
68
  "zod": "^4.5.4",
68
- "@manta-eu/horns": "0.1.4",
69
- "@manta-eu/horns-kit": "0.1.4",
70
- "@manta-eu/horns-server": "0.1.4"
69
+ "@manta-eu/horns": "0.2.1",
70
+ "@manta-eu/horns-kit": "0.2.1",
71
+ "@manta-eu/horns-server": "0.2.1"
71
72
  },
72
73
  "devDependencies": {
73
74
  "@manta-eu/ldo": "0.1.5",