@floegence/floe-webapp-core 0.86.16 → 0.86.18

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.
@@ -1153,7 +1153,7 @@ ${T}`;
1153
1153
  w(`Module.instantiateWasm callback failed with error: ${f}`), u(f);
1154
1154
  }
1155
1155
  });
1156
- Fe ??= o.locateFile ? o.locateFile ? o.locateFile("libavoid.wasm", N) : N + "libavoid.wasm" : new URL("" + new URL("../libavoid.wasm", import.meta.url).href, import.meta.url).href;
1156
+ Fe ??= o.locateFile ? o.locateFile ? o.locateFile("libavoid.wasm", N) : N + "libavoid.wasm" : new URL("" + new URL("../libavoid.wasm?no-inline", import.meta.url).href, import.meta.url).href;
1157
1157
  try {
1158
1158
  var a = await cr(n);
1159
1159
  return t(a);
@@ -1186,7 +1186,7 @@ ${T}`;
1186
1186
  } });
1187
1187
  return C;
1188
1188
  };
1189
- })(), Zr = Xr, Xt = Kr(Zr), Qr = "" + new URL("../libavoid.wasm", import.meta.url).href;
1189
+ })(), Zr = Xr, Xt = Kr(Zr), Qr = "" + new URL("../libavoid.wasm?no-inline", import.meta.url).href;
1190
1190
  let Zt;
1191
1191
  const Qt = { NORTH: 1, SOUTH: 2, WEST: 4, EAST: 8 }, Ee = ["NORTH", "EAST", "SOUTH", "WEST"], de = (s) => s.delete();
1192
1192
  async function pt(s, l = {}) {
@@ -1849,11 +1849,7 @@ function sn(s, l) {
1849
1849
  }
1850
1850
  const cn = new qr({
1851
1851
  workerFactory: () => {
1852
- const s = new Worker(new URL(
1853
- /* @vite-ignore */
1854
- "" + new URL("elk-worker-CrDP6jPz.js", import.meta.url).href,
1855
- import.meta.url
1856
- ), { type: "module" });
1852
+ const s = new Worker(new URL("elk-worker-CrDP6jPz.js", import.meta.url), { type: "module" });
1857
1853
  return s.addEventListener("error", (l) => {
1858
1854
  throw new Error(l.message || "Graph ELK worker failed");
1859
1855
  }), s.addEventListener("messageerror", () => {
@@ -1,9 +1,5 @@
1
1
  function w() {
2
- const t = new Worker(new URL(
3
- /* @vite-ignore */
4
- "" + new URL("../../assets/layout-worker-BK6m515B.js", import.meta.url).href,
5
- import.meta.url
6
- ), { type: "module" });
2
+ const t = new Worker(new URL("../../assets/layout-worker-BK6m515B.js", import.meta.url), { type: "module" });
7
3
  let s, u = 0;
8
4
  const o = /* @__PURE__ */ new Map(), n = (e) => {
9
5
  s = e, t.terminate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.86.16",
3
+ "version": "0.86.18",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -139,17 +139,23 @@
139
139
  "types": "./dist/graph.d.ts",
140
140
  "import": "./dist/graph.js"
141
141
  },
142
- "./graph.css": "./dist/graph.css"
142
+ "./graph.css": "./dist/graph.css",
143
+ "./graph-assets": {
144
+ "types": "./scripts/graph-assets.d.mts",
145
+ "import": "./scripts/graph-assets.mjs"
146
+ }
143
147
  },
144
148
  "files": [
145
149
  "dist",
146
150
  "scripts/pdf-assets.mjs",
147
- "scripts/pdf-assets.d.mts"
151
+ "scripts/pdf-assets.d.mts",
152
+ "scripts/graph-assets.mjs",
153
+ "scripts/graph-assets.d.mts"
148
154
  ],
149
155
  "scripts": {
150
156
  "dev": "node ./scripts/dev.mjs",
151
157
  "build": "pnpm clean && pnpm build:shell-theme-css && vite build && tsc -p tsconfig.build.json && pnpm build:styles && pnpm build:assets",
152
- "build:assets": "node ./scripts/copy-style-assets.mjs && node ./scripts/build-pdf-styles.mjs",
158
+ "build:assets": "node ./scripts/normalize-graph-worker-urls.mjs && node ./scripts/copy-style-assets.mjs && node ./scripts/build-pdf-styles.mjs",
153
159
  "build:shell-theme-css": "node ./scripts/generate-shell-theme-css.mjs",
154
160
  "build:styles": "vite build -c vite.styles.config.ts",
155
161
  "typecheck": "tsc --noEmit",
@@ -0,0 +1,7 @@
1
+ /** Vite build plugin for offline file-origin hosts. Requires local file read
2
+ * access and CSP blob: permissions for scripts, workers, and connections. */
3
+ export declare function graphBlobWorkersPlugin(): {
4
+ name: string;
5
+ apply: 'build';
6
+ transform(this: { emitFile(asset: {type: 'asset'; fileName: string; source: Uint8Array}): string }, code: string, id: string): string | undefined;
7
+ };
@@ -0,0 +1,64 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { URL } from 'node:url';
3
+
4
+ /** Vite build adapter for offline file-origin hosts. Layout and ELK remain
5
+ * unchanged published modules; the raw LGPL WASM stays independently replaceable.
6
+ * The host must grant local read access and allow blob workers/scripts/connects.
7
+ */
8
+ export function graphBlobWorkersPlugin() {
9
+ const root = new URL('../dist/', import.meta.url);
10
+ const engine = readFileSync(new URL('components/graph/engine.js', root), 'utf8');
11
+ const entry = /new URL\("(\.\.\/\.\.\/assets\/[^"\n]+)", import\.meta\.url\)/.exec(engine)?.[1];
12
+ if (!entry) throw new Error('Unsupported graph layout worker entry');
13
+ const layoutURL = new URL(entry, new URL('components/graph/', root));
14
+ let layout = readFileSync(layoutURL, 'utf8');
15
+ const child = /new URL\("([^"\n]*elk-worker[^"\n]+)", import\.meta\.url\)/.exec(layout)?.[1];
16
+ if (!child) throw new Error('Unsupported graph ELK worker entry');
17
+ const elk = readFileSync(new URL(child, layoutURL), 'utf8');
18
+ // Every package-owned resource URL is substituted by a local blob URL.
19
+ layout = layout.replaceAll(`new URL("${child}", import.meta.url)`, 'new URL(__floeElkURL)');
20
+ layout = layout.replaceAll(/new URL\("[^"\n]*libavoid\.wasm(?:\?no-inline)?", import\.meta\.url\)/g, 'new URL(__floeWasmURL)');
21
+ const bootstrap = `
22
+ const queue = [];
23
+ self.onmessage = async ({data}) => {
24
+ if (!data.__floeGraphWasm) { queue.push(data); return; }
25
+ const __floeWasmURL = URL.createObjectURL(new Blob([data.__floeGraphWasm], {type:'application/wasm'}));
26
+ const __floeElkURL = URL.createObjectURL(new Blob([${JSON.stringify(elk)}], {type:'text/javascript'}));
27
+ const source = 'const __floeElkURL=' + JSON.stringify(__floeElkURL) + ',__floeWasmURL=' + JSON.stringify(__floeWasmURL) + ';\\n' + ${JSON.stringify(layout)};
28
+ try { await import(URL.createObjectURL(new Blob([source], {type:'text/javascript'}))); }
29
+ catch (error) { setTimeout(() => { throw error; }); return; }
30
+ for (const data of queue) self.onmessage({data});
31
+ queue.length = 0;
32
+ };
33
+ `;
34
+ return {
35
+ name: 'floe-graph-blob-workers',
36
+ apply: 'build',
37
+ transform(code, id) {
38
+ if (!id.endsWith('/components/graph/engine.js')) return;
39
+ const expression = /new Worker\(new URL\([\s\S]*?\), \{ type: "module" \}\)/;
40
+ if (!expression.test(code)) throw new Error('Unsupported graph layout worker factory');
41
+ const asset = this.emitFile({ type: 'asset', fileName: 'assets/libavoid.wasm', source: readFileSync(new URL('libavoid.wasm', root)) });
42
+ const factory = `(() => {
43
+ const url = URL.createObjectURL(new Blob([${JSON.stringify(bootstrap)}], {type:'text/javascript'}));
44
+ const worker = new Worker(url, {type:'module'});
45
+ URL.revokeObjectURL(url);
46
+ const request = new XMLHttpRequest();
47
+ request.open('GET', import.meta.ROLLUP_FILE_URL_${asset});
48
+ request.responseType = 'arraybuffer';
49
+ const fail = () => worker.dispatchEvent(new ErrorEvent('error', {message:'Unable to read graph routing WASM'}));
50
+ request.onload = () => {
51
+ if ((request.status === 0 || request.status === 200) && request.response?.byteLength) {
52
+ worker.postMessage({__floeGraphWasm:request.response}, [request.response]);
53
+ } else fail();
54
+ };
55
+ request.onerror = fail;
56
+ request.send();
57
+ const terminate = worker.terminate.bind(worker);
58
+ worker.terminate = () => { request.abort(); terminate(); };
59
+ return worker;
60
+ })()`;
61
+ return code.replace(expression, () => factory);
62
+ },
63
+ };
64
+ }