@seedprotocol/vite 0.5.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.
@@ -0,0 +1,4 @@
1
+ export default ArweaveFromGlobal;
2
+ export function init(...args: any[]): any;
3
+ declare const ArweaveFromGlobal: any;
4
+ //# sourceMappingURL=arweave-default-shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arweave-default-shim.d.ts","sourceRoot":"","sources":["../src/arweave-default-shim.js"],"names":[],"mappings":";AAKO,0CAA4D;AAHnE,qCAA4C"}
@@ -0,0 +1,6 @@
1
+ import 'arweave/bundles/web.bundle.js'
2
+
3
+ const ArweaveFromGlobal = globalThis.Arweave
4
+
5
+ export default ArweaveFromGlobal
6
+ export const init = (...args) => ArweaveFromGlobal?.init?.(...args)
@@ -0,0 +1,3 @@
1
+ export default debugFn;
2
+ declare const debugFn: any;
3
+ //# sourceMappingURL=debug-default-shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-default-shim.d.ts","sourceRoot":"","sources":["../src/debug-default-shim.js"],"names":[],"mappings":";AAgBA,2BAA+C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ESM interop shim for the `debug` package browser entry.
3
+ * `debug/src/browser.js` is CJS and may not expose a default export when served
4
+ * directly by Vite; default-import consumers expect `import debug from 'debug'`.
5
+ */
6
+ import * as debugModule from 'debug/src/browser.js'
7
+
8
+ function resolveDebugExport(mod) {
9
+ if (typeof mod === 'function') return mod
10
+ if (mod && typeof mod.default === 'function') return mod.default
11
+ const candidate = mod?.default ?? mod
12
+ if (typeof candidate === 'function') return candidate
13
+ if (candidate && typeof candidate.default === 'function') return candidate.default
14
+ return candidate
15
+ }
16
+
17
+ const debugFn = resolveDebugExport(debugModule)
18
+
19
+ export default debugFn
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=easFix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easFix.d.ts","sourceRoot":"","sources":["../src/easFix.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface SeedVitePluginOptions {
3
+ /**
4
+ * Additional modules to alias to ZenFS equivalents.
5
+ * @default ['fs', 'fs/promises', 'node:fs', 'node:fs/promises']
6
+ */
7
+ fsModules?: string[];
8
+ /**
9
+ * Whether to inject automatic ZenFS initialization script into index.html.
10
+ * When true, injects a <script type="module"> that imports from '@zenfs/core'/'@zenfs/dom'.
11
+ * Browsers cannot resolve those bare specifiers, so the script fails at runtime unless you use
12
+ * an import map or load ZenFS another way. Prefer false and initialize ZenFS in your entry:
13
+ * import { configure } from '@zenfs/core'; import { IndexedDB } from '@zenfs/dom';
14
+ * await configure({ mounts: { '/': IndexedDB } });
15
+ * @default false
16
+ */
17
+ autoInit?: boolean;
18
+ /**
19
+ * Enable debug logging.
20
+ * @default false
21
+ */
22
+ debug?: boolean;
23
+ /**
24
+ * Whether to automatically include vite-plugin-node-polyfills with sensible defaults.
25
+ * The SDK depends on that package and aliases its injected shim imports to absolute
26
+ * paths, so consuming apps do not need to install vite-plugin-node-polyfills themselves.
27
+ * @default true
28
+ */
29
+ includeNodePolyfills?: boolean;
30
+ }
31
+ /**
32
+ * Minimal Vite plugin to make the SDK work in browser/Electron renderer:
33
+ * - Aliases fs → @zenfs/core (and promises variant)
34
+ * - Aliases path → path-browserify
35
+ * - Ensures CommonJS in SDK dist is transformed by Vite's CommonJS plugin
36
+ * - Allowlists linked SDK / sqlocal worker paths on server.fs.allow for Vite dev
37
+ * - Optionally injects a simple ZenFS initialization script
38
+ * - Optionally wires up vite-plugin-node-polyfills with safe defaults
39
+ *
40
+ * This plugin assumes the SDK does not bundle Node-only code in the browser entry.
41
+ * For Electron, Node-only work (e.g. better-sqlite3) should run in the
42
+ * main process; the renderer should only use browser-safe SDK usage.
43
+ *
44
+ * For the renderer build:
45
+ * - Use the SDK's ESM entry: import from '@seedprotocol/sdk' (resolves to dist/main.js).
46
+ * - When autoInit is false (default), initialize ZenFS in your entry:
47
+ * import { configure } from '@zenfs/core'; import { IndexedDB } from '@zenfs/dom';
48
+ * await configure({ mounts: { '/': IndexedDB } });
49
+ */
50
+ export declare function seedVitePlugin(options?: SeedVitePluginOptions): Plugin[];
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAS9C,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IAEpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAglBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,EAAE,CAke5E"}
package/dist/index.js ADDED
@@ -0,0 +1,540 @@
1
+ import e from "node:fs";
2
+ import { createRequire as t } from "node:module";
3
+ import n from "node:path";
4
+ import { fileURLToPath as r } from "node:url";
5
+ import { nodePolyfills as i } from "vite-plugin-node-polyfills";
6
+ //#region src/index.ts
7
+ var a = t(import.meta.url), o = {
8
+ global: /\btypeof\s+global\b/,
9
+ process: /\btypeof\s+process\b/,
10
+ Buffer: /\btypeof\s+Buffer\b/,
11
+ __dirname: /\btypeof\s+__dirname\b/,
12
+ __filename: /\btypeof\s+__filename\b/
13
+ };
14
+ function s(e) {
15
+ return e.replace(/\/\*[\s\S]*?\*\//g, (e) => " ".repeat(e.length)).replace(/\/\/[^\n]*/g, (e) => " ".repeat(e.length)).replace(/`(?:[^`\\]|\\.)*`/gs, (e) => "`" + " ".repeat(e.length - 2) + "`").replace(/"(?:[^"\\]|\\.)*"/g, (e) => "\"" + " ".repeat(e.length - 2) + "\"").replace(/'(?:[^'\\]|\\.)*'/g, (e) => "'" + " ".repeat(e.length - 2) + "'");
16
+ }
17
+ function c(e) {
18
+ let t = s(e), n = [];
19
+ for (let [r, i] of Object.entries(o)) {
20
+ let a = RegExp(`(?<![.\\w$])\\b${r}\\b(?!This)(?![\\w$])`, "g"), o;
21
+ for (; (o = a.exec(t)) !== null;) {
22
+ let a = o.index, s = t.slice(Math.max(0, a - 20), a);
23
+ if (i.test(s)) continue;
24
+ let c = e.slice(0, a).split("\n"), l = c.length, u = c.at(-1)?.length ?? 0, d = (e.split("\n")[l - 1] ?? "").slice(Math.max(0, u - 40), u + r.length + 40).trim();
25
+ n.push({
26
+ global: r,
27
+ offset: a,
28
+ line: l,
29
+ context: d
30
+ });
31
+ }
32
+ }
33
+ return n;
34
+ }
35
+ var l = [
36
+ "fs",
37
+ "fs/promises",
38
+ "node:fs",
39
+ "node:fs/promises"
40
+ ], u = n.dirname(r(import.meta.url)), d = n.join(u, "arweave-default-shim.js"), f = n.join(u, "debug-default-shim.js"), p = [
41
+ "debug",
42
+ "random",
43
+ "seedrandom",
44
+ "@georgedoescode/generative-utils",
45
+ "nanoid-dictionary"
46
+ ], m = ["@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk", "@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk > @ethereum-attestation-service/eas-contracts"];
47
+ function h(t, r, i, a) {
48
+ if (!e.existsSync(t)) return;
49
+ let o = r.startsWith("@") ? r.replace("/", "+") : r;
50
+ for (let s of e.readdirSync(t)) !s.startsWith(`${o}@`) && !s.startsWith(`${r}@`) || a.push(n.join(t, s, `node_modules/${r}`, i));
51
+ }
52
+ function g(t, r) {
53
+ let i = [], o = n.resolve(u, "..");
54
+ try {
55
+ let e = a.resolve(`${t}/package.json`);
56
+ i.push(n.join(n.dirname(e), r));
57
+ } catch {
58
+ try {
59
+ let o = a.resolve(t), s = n.dirname(o);
60
+ for (let a = 0; a < 8; a++) {
61
+ let a = n.join(s, "package.json");
62
+ if (e.existsSync(a)) try {
63
+ if (JSON.parse(e.readFileSync(a, "utf8")).name === t) {
64
+ i.push(n.join(s, r));
65
+ break;
66
+ }
67
+ } catch {}
68
+ let o = n.dirname(s);
69
+ if (o === s) break;
70
+ s = o;
71
+ }
72
+ } catch {}
73
+ }
74
+ i.push(n.join(o, "node_modules", t, r));
75
+ let s = n.join(process.cwd(), "node_modules");
76
+ i.push(n.join(s, t, r)), h(n.join(s, ".bun"), t, r, i), h(n.join(o, "node_modules", ".bun"), t, r, i);
77
+ let c = _(o);
78
+ c && h(n.join(c, "node_modules", ".bun"), t, r, i);
79
+ for (let t of i) if (e.existsSync(t)) return t;
80
+ }
81
+ function _(t) {
82
+ let r = n.resolve(t);
83
+ for (let t = 0; t < 8; t++) {
84
+ if (e.existsSync(n.join(r, "node_modules", ".bun"))) return r;
85
+ let t = n.dirname(r);
86
+ if (t === r) break;
87
+ r = t;
88
+ }
89
+ }
90
+ function v(e, t) {
91
+ let r = n.resolve(t);
92
+ return e.some((e) => {
93
+ let t = n.resolve(String(e));
94
+ return r === t || r.startsWith(t.endsWith(n.sep) ? t : t + n.sep);
95
+ });
96
+ }
97
+ function y(t) {
98
+ try {
99
+ return e.realpathSync(t);
100
+ } catch {
101
+ return n.resolve(t);
102
+ }
103
+ }
104
+ function b() {
105
+ let e = /* @__PURE__ */ new Set(), t = (t) => {
106
+ t && e.add(y(t));
107
+ }, r;
108
+ try {
109
+ r = n.dirname(a.resolve("@seedprotocol/sdk/package.json"));
110
+ } catch {
111
+ r = n.resolve(u, "..");
112
+ }
113
+ t(r);
114
+ let i = _(r);
115
+ i && t(i);
116
+ for (let e of ["sqlocal", "@sqlite.org/sqlite-wasm"]) {
117
+ let r = g(e, "package.json");
118
+ r && t(n.dirname(r));
119
+ }
120
+ return [...e];
121
+ }
122
+ function x(e) {
123
+ let t = [];
124
+ for (let n of b()) v(e, n) || (e.push(n), t.push(n));
125
+ return t;
126
+ }
127
+ function S(e) {
128
+ return e ? Array.isArray(e) ? e.filter((e) => !!e && !!e.replacement).map((e) => ({
129
+ find: e.find,
130
+ replacement: e.replacement
131
+ })) : Object.entries(e).map(([e, t]) => ({
132
+ find: e,
133
+ replacement: String(t)
134
+ })) : [];
135
+ }
136
+ function C(e, t) {
137
+ let n = [...e], r = (e) => typeof e == "string" ? `s:${e}` : `r:${e.toString()}`, i = new Set(n.map((e) => r(e.find)));
138
+ for (let e of t) {
139
+ let t = r(e.find);
140
+ i.has(t) || (i.add(t), n.push(e));
141
+ }
142
+ return n;
143
+ }
144
+ var w = [
145
+ "vite-plugin-node-polyfills/shims/buffer",
146
+ "vite-plugin-node-polyfills/shims/global",
147
+ "vite-plugin-node-polyfills/shims/process"
148
+ ];
149
+ function T(t) {
150
+ let n = a.resolve(t);
151
+ if (n.endsWith(".cjs")) {
152
+ let t = n.slice(0, -4) + ".js";
153
+ if (e.existsSync(t)) return t;
154
+ }
155
+ return n;
156
+ }
157
+ function E() {
158
+ let e = {}, t = [];
159
+ for (let n of w) try {
160
+ let t = T(n);
161
+ n.endsWith("/buffer") ? e.buffer = t : n.endsWith("/global") ? e.global = t : n.endsWith("/process") && (e.process = t);
162
+ } catch {
163
+ t.push(n);
164
+ }
165
+ return {
166
+ paths: e,
167
+ unresolved: t
168
+ };
169
+ }
170
+ function D(e, t) {
171
+ if ((e.match(/import\s+__buffer_polyfill\b/g) || []).length <= 1 || !t.buffer || !t.global || !t.process) return null;
172
+ let n = e.replace(/import\s+__buffer_polyfill\s+from\s+['"][^'"]+['"];?\s*\n\s*globalThis\.Buffer\s*=\s*globalThis\.Buffer\s*\|\|\s*__buffer_polyfill;?\s*\n\s*import\s+__global_polyfill\s+from\s+['"][^'"]+['"];?\s*\n\s*globalThis\.global\s*=\s*globalThis\.global\s*\|\|\s*__global_polyfill;?\s*\n\s*import\s+__process_polyfill\s+from\s+['"][^'"]+['"];?\s*\n\s*globalThis\.process\s*=\s*globalThis\.process\s*\|\|\s*__process_polyfill;?\s*\n?/g, "");
173
+ return n === e ? null : `import __buffer_polyfill from ${JSON.stringify(t.buffer)};\nglobalThis.Buffer = globalThis.Buffer || __buffer_polyfill;
174
+ import __global_polyfill from ${JSON.stringify(t.global)};\nglobalThis.global = globalThis.global || __global_polyfill;
175
+ import __process_polyfill from ${JSON.stringify(t.process)};\nglobalThis.process = globalThis.process || __process_polyfill;
176
+ ` + n;
177
+ }
178
+ function O(e, t) {
179
+ let n = e, r = !1, i = [];
180
+ t.buffer && i.push(["vite-plugin-node-polyfills/shims/buffer", t.buffer]), t.global && i.push(["vite-plugin-node-polyfills/shims/global", t.global]), t.process && i.push(["vite-plugin-node-polyfills/shims/process", t.process]);
181
+ for (let [e, t] of i) {
182
+ let i = JSON.stringify(t);
183
+ for (let t of ["\"", "'"]) {
184
+ let a = `${t}${e}${t}`;
185
+ n.includes(a) && (n = n.split(a).join(i), r = !0);
186
+ }
187
+ }
188
+ return r ? n : null;
189
+ }
190
+ function k(e, t) {
191
+ t.buffer && e.push({
192
+ find: "vite-plugin-node-polyfills/shims/buffer",
193
+ replacement: t.buffer
194
+ }, {
195
+ find: /^buffer$/,
196
+ replacement: t.buffer
197
+ }, {
198
+ find: /^node:buffer$/,
199
+ replacement: t.buffer
200
+ }), t.global && e.push({
201
+ find: "vite-plugin-node-polyfills/shims/global",
202
+ replacement: t.global
203
+ }, {
204
+ find: /^global$/,
205
+ replacement: t.global
206
+ }), t.process && e.push({
207
+ find: "vite-plugin-node-polyfills/shims/process",
208
+ replacement: t.process
209
+ }, {
210
+ find: /^process$/,
211
+ replacement: t.process
212
+ }, {
213
+ find: /^node:process$/,
214
+ replacement: t.process
215
+ });
216
+ }
217
+ function A(e) {
218
+ let t = {};
219
+ return e.buffer && (t["vite-plugin-node-polyfills/shims/buffer"] = e.buffer, t.buffer = e.buffer, t["node:buffer"] = e.buffer), e.global && (t["vite-plugin-node-polyfills/shims/global"] = e.global, t.global = e.global), e.process && (t["vite-plugin-node-polyfills/shims/process"] = e.process, t.process = e.process, t["node:process"] = e.process), t;
220
+ }
221
+ var j = new Set([
222
+ "vite-plugin-node-polyfills/shims/buffer",
223
+ "vite-plugin-node-polyfills/shims/global",
224
+ "vite-plugin-node-polyfills/shims/process",
225
+ "buffer",
226
+ "node:buffer",
227
+ "process",
228
+ "node:process",
229
+ "global"
230
+ ]);
231
+ function M(e, t) {
232
+ let n = [];
233
+ if (k(n, t), n.length === 0) return e;
234
+ let r = e.filter((e) => typeof e.find == "string" ? !j.has(e.find) : !0);
235
+ return [...n, ...r];
236
+ }
237
+ function N(t) {
238
+ let n = g("nanoid-dictionary", "dist/dictionary.esm.js");
239
+ n && t.push({
240
+ find: /^nanoid-dictionary$/,
241
+ replacement: n
242
+ });
243
+ let r = g("@zenfs/core", "dist/index.js"), i = g("@zenfs/core", "dist/path.js");
244
+ r && t.push({
245
+ find: /^@zenfs\/core$/,
246
+ replacement: r
247
+ }), i && t.push({
248
+ find: /^@zenfs\/core\/path$/,
249
+ replacement: i
250
+ });
251
+ let a = g("@zenfs/dom", "dist/index.js");
252
+ a && t.push({
253
+ find: /^@zenfs\/dom$/,
254
+ replacement: a
255
+ }), e.existsSync(f) && t.push({
256
+ find: /^debug$/,
257
+ replacement: f
258
+ });
259
+ let o = g("debug", "src/browser.js");
260
+ o && t.push({
261
+ find: /^debug\/src\/browser\.js$/,
262
+ replacement: o
263
+ });
264
+ }
265
+ function P() {
266
+ let e = g("debug", "src/browser.js");
267
+ return e ? { "debug/src/browser.js": e } : {};
268
+ }
269
+ function F(e) {
270
+ let t = e ?? {};
271
+ return t.rolldownOptions ?? t.rollupOptions ?? {};
272
+ }
273
+ function I(e, t) {
274
+ let n = F(e), r = n.resolve ?? {}, i = n.transform ?? {}, a = {
275
+ ...e?.esbuildOptions?.define ?? {},
276
+ ...i.define,
277
+ ...t.define
278
+ }, o = {
279
+ ...r.alias,
280
+ ...t.alias
281
+ };
282
+ return {
283
+ ...n,
284
+ ...Object.keys(a).length > 0 ? { transform: {
285
+ ...i,
286
+ define: a
287
+ } } : {},
288
+ ...Object.keys(o).length > 0 ? { resolve: {
289
+ ...r,
290
+ alias: o
291
+ } } : {}
292
+ };
293
+ }
294
+ function L(e) {
295
+ let { esbuildOptions: t, rollupOptions: n, ...r } = e ?? {};
296
+ return r;
297
+ }
298
+ function R(e = {}) {
299
+ let { fsModules: t = l, autoInit: n = !1, debug: r = !1, includeNodePolyfills: a = !0 } = e, o = (...e) => {
300
+ r && console.log("[seed-vite-plugin]", ...e);
301
+ }, { paths: s, unresolved: u } = E(), f = A(s);
302
+ a && u.length > 0 ? console.warn("[seed-vite-plugin] Could not resolve vite-plugin-node-polyfills shims from the SDK package:\n" + u.map((e) => ` - ${e}`).join("\n") + "\nNode polyfill globals may fail to resolve. Reinstall @seedprotocol/sdk, or set includeNodePolyfills: false and configure polyfills yourself.") : u.length === 0 && o("Resolved vite-plugin-node-polyfills shims to absolute paths");
303
+ let h = {
304
+ name: "seed-protocol:config",
305
+ enforce: "pre",
306
+ configResolved(e) {
307
+ let t = x(e.server.fs.allow);
308
+ t.length > 0 && o("Extended server.fs.allow for linked SDK / sqlocal worker paths:", t);
309
+ },
310
+ config(e) {
311
+ let n = [];
312
+ for (let e of t) {
313
+ let t = e.includes("promises") ? "@zenfs/core/promises" : "@zenfs/core";
314
+ n.push({
315
+ find: e,
316
+ replacement: t
317
+ });
318
+ }
319
+ let r = g("eventemitter3", "dist/eventemitter3.esm.js");
320
+ r && n.push({
321
+ find: "eventemitter3",
322
+ replacement: r
323
+ }, {
324
+ find: "eventemitter3/index.mjs",
325
+ replacement: r
326
+ }, {
327
+ find: "eventemitter3/index.js",
328
+ replacement: r
329
+ });
330
+ let i = g("arweave", "bundles/web.bundle.js");
331
+ i && n.push({
332
+ find: /^arweave$/,
333
+ replacement: d
334
+ }, {
335
+ find: /^arweave\/web\/index\.js$/,
336
+ replacement: d
337
+ }, {
338
+ find: /^arweave\/bundles\/web\.bundle\.js$/,
339
+ replacement: i
340
+ }), N(n), k(n, s);
341
+ let a = e.resolve ?? {}, o = C(S(a.alias), n), c = [
342
+ "@zenfs/core",
343
+ "@zenfs/dom",
344
+ "kerium",
345
+ "utilium",
346
+ "memium",
347
+ "readable-stream",
348
+ "viem",
349
+ "isows",
350
+ ...p
351
+ ].filter((e) => !!g(e, "package.json")), l = e.optimizeDeps, u = P(), h = {
352
+ ...L(l),
353
+ exclude: [
354
+ ...l?.exclude ?? [],
355
+ "@seedprotocol/sdk",
356
+ "drizzle-orm",
357
+ "better-sqlite3",
358
+ "sqlocal"
359
+ ],
360
+ include: [
361
+ ...l?.include ?? [],
362
+ ...c,
363
+ ...m
364
+ ],
365
+ rolldownOptions: I(l, {
366
+ define: { global: "globalThis" },
367
+ alias: {
368
+ ...u,
369
+ ...f
370
+ }
371
+ })
372
+ };
373
+ return {
374
+ define: {
375
+ ...e.define ?? {},
376
+ global: "globalThis",
377
+ "process.env.NODE_ENV": JSON.stringify("production"),
378
+ "process.browser": "true",
379
+ "process.platform": "\"browser\""
380
+ },
381
+ resolve: {
382
+ ...a,
383
+ alias: o,
384
+ dedupe: Array.from(new Set([
385
+ ...a.dedupe ?? [],
386
+ "react",
387
+ "react-dom",
388
+ "thirdweb",
389
+ "xstate",
390
+ "@xstate/react",
391
+ "@seedprotocol/sdk",
392
+ "@seedprotocol/react",
393
+ "@seedprotocol/publish",
394
+ "@seedprotocol/feed"
395
+ ]))
396
+ },
397
+ optimizeDeps: h
398
+ };
399
+ }
400
+ }, _ = {
401
+ name: "seed-protocol:polyfill-resolve",
402
+ enforce: "post",
403
+ config(e) {
404
+ if (Object.keys(f).length === 0) return;
405
+ let t = e.resolve ?? {}, n = M(S(t.alias), s), r = e.optimizeDeps;
406
+ return {
407
+ resolve: {
408
+ ...t,
409
+ alias: n
410
+ },
411
+ optimizeDeps: { rolldownOptions: I(r, { alias: f }) }
412
+ };
413
+ },
414
+ resolveId: {
415
+ order: "pre",
416
+ handler(e) {
417
+ return e === "vite-plugin-node-polyfills/shims/buffer" ? s.buffer ?? null : e === "vite-plugin-node-polyfills/shims/global" ? s.global ?? null : e === "vite-plugin-node-polyfills/shims/process" ? s.process ?? null : a ? e === "buffer" || e === "node:buffer" ? s.buffer ?? null : e === "global" ? s.global ?? null : e === "process" || e === "node:process" ? s.process ?? null : null : null;
418
+ }
419
+ },
420
+ transform: {
421
+ order: "post",
422
+ handler(e) {
423
+ let t = (e.match(/import\s+__buffer_polyfill\b/g) || []).length, n = e, r = !1;
424
+ if (t > 1) {
425
+ let e = D(n, s);
426
+ e && (n = e, r = !0);
427
+ }
428
+ let i = O(n, s);
429
+ return i && (n = i, r = !0), r ? {
430
+ code: n,
431
+ map: null
432
+ } : null;
433
+ }
434
+ }
435
+ }, v = [
436
+ h,
437
+ {
438
+ name: "seed-protocol:main",
439
+ enforce: "post",
440
+ config(e) {
441
+ let t = e.build ?? {}, n = t.commonjsOptions ?? {}, r = t.rollupOptions ?? {}, i = t.rolldownOptions, a = r.external ?? [], o = [
442
+ ...Array.isArray(n.include) ? n.include : n.include ? [n.include] : [],
443
+ /node_modules/,
444
+ /seed-protocol-sdk[\\/]+dist[\\/]/
445
+ ], s = [...Array.isArray(n.exclude) ? n.exclude : n.exclude ? [n.exclude] : [], /node_modules[\\/]+sqlocal[\\/]/], c = {
446
+ ...n,
447
+ include: o,
448
+ exclude: s,
449
+ transformMixedEsModules: !0
450
+ }, l = ["better-sqlite3"], u = (e) => l.some((t) => e === t || e.startsWith(`${t}/`) || e.includes(`/${t}/`) || e.endsWith(`/${t}`)), d = (e, t, n) => u(e) ? !0 : typeof a == "function" ? a(e, t, n ?? !1) : Array.isArray(a) ? a.some((t) => t === e || e.startsWith(`${t}/`)) : !1, f = {
451
+ ...r,
452
+ external: d
453
+ }, p = {
454
+ ...t,
455
+ commonjsOptions: c
456
+ };
457
+ i ? p.rolldownOptions = {
458
+ ...i,
459
+ external: d
460
+ } : p.rollupOptions = f;
461
+ let m = e.worker ?? {};
462
+ return {
463
+ build: p,
464
+ worker: {
465
+ ...m,
466
+ format: m.format ?? "es"
467
+ }
468
+ };
469
+ },
470
+ generateBundle(e, t) {
471
+ let n = [];
472
+ for (let [e, r] of Object.entries(t)) {
473
+ if (r.type !== "chunk") continue;
474
+ let t = c(r.code);
475
+ for (let r of t) n.push({
476
+ chunk: e,
477
+ ...r
478
+ });
479
+ }
480
+ if (n.length === 0) return;
481
+ console.warn("\n[seed-vite-plugin] ⚠️ Bare Node.js globals detected in browser bundle chunks. These will throw ReferenceError at runtime unless shimmed.\n");
482
+ let r = /* @__PURE__ */ new Map();
483
+ for (let e of n) {
484
+ let t = r.get(e.chunk) ?? [];
485
+ t.push(e), r.set(e.chunk, t);
486
+ }
487
+ for (let [e, t] of r) {
488
+ console.warn(` ${e}`);
489
+ for (let e of t) console.warn(` line ${e.line}: \`${e.global}\` — ${e.context}`);
490
+ }
491
+ console.warn("");
492
+ },
493
+ transformIndexHtml(e) {
494
+ let t = "<script>\n(function(){\n if(typeof globalThis.global==='undefined')globalThis.global=globalThis;\n if(typeof globalThis.process==='undefined')globalThis.process={env:{NODE_ENV:'production'},browser:true,version:'v18.0.0',versions:{},platform:'browser',cwd:function(){return'/'},nextTick:function(fn){setTimeout(fn,0)}};\n})();\n<\/script>", r = e;
495
+ if (r = r.includes("<head>") ? r.replace("<head>", `<head>\n${t}`) : t + r, !n) return r;
496
+ let i = "\n<script type=\"module\">\nimport { configure } from '@zenfs/core';\nimport { IndexedDB } from '@zenfs/dom';\n\nif (!window.__seedFsReady) {\n window.__seedFsReady = configure({\n mounts: { '/': IndexedDB },\n }).catch((err) => {\n console.error('[seed-vite-plugin] ZenFS initialization failed', err);\n });\n}\n<\/script>";
497
+ return r.includes("</head>") ? r.replace("</head>", `${i}\n</head>`) : r + i;
498
+ }
499
+ },
500
+ {
501
+ name: "seed-protocol:sdk-import-fix",
502
+ enforce: "post",
503
+ transform(e, t) {
504
+ if (!t.includes("@seedprotocol/sdk") || !t.includes("FileManager") || !/import\s+path\s+from\s+['"]path-browserify['"]/.test(e)) return null;
505
+ let n = e.replace(/import\s+path\s+from\s+['"]path-browserify['"];/g, "import * as path from 'path';");
506
+ return n === e ? null : {
507
+ code: n,
508
+ map: null
509
+ };
510
+ }
511
+ }
512
+ ];
513
+ if (a) {
514
+ o("Including vite-plugin-node-polyfills with default settings");
515
+ let e = i({
516
+ exclude: ["readline"],
517
+ include: [
518
+ "path",
519
+ "crypto",
520
+ "stream",
521
+ "util",
522
+ "buffer",
523
+ "events",
524
+ "string_decoder"
525
+ ],
526
+ globals: {
527
+ Buffer: !0,
528
+ global: !0,
529
+ process: !0
530
+ },
531
+ protocolImports: !0
532
+ });
533
+ Array.isArray(e) ? v.push(...e) : v.push(e);
534
+ }
535
+ return Object.keys(f).length > 0 && v.push(_), v;
536
+ }
537
+ //#endregion
538
+ export { R as seedVitePlugin };
539
+
540
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite'\nimport fs from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { nodePolyfills } from 'vite-plugin-node-polyfills'\n\nconst _req = createRequire(import.meta.url)\n\nexport interface SeedVitePluginOptions {\n /**\n * Additional modules to alias to ZenFS equivalents.\n * @default ['fs', 'fs/promises', 'node:fs', 'node:fs/promises']\n */\n fsModules?: string[]\n\n /**\n * Whether to inject automatic ZenFS initialization script into index.html.\n * When true, injects a &lt;script type=\"module\"&gt; that imports from '@zenfs/core'/'@zenfs/dom'.\n * Browsers cannot resolve those bare specifiers, so the script fails at runtime unless you use\n * an import map or load ZenFS another way. Prefer false and initialize ZenFS in your entry:\n * import { configure } from '@zenfs/core'; import { IndexedDB } from '@zenfs/dom';\n * await configure({ mounts: { '/': IndexedDB } });\n * @default false\n */\n autoInit?: boolean\n\n /**\n * Enable debug logging.\n * @default false\n */\n debug?: boolean\n\n /**\n * Whether to automatically include vite-plugin-node-polyfills with sensible defaults.\n * The SDK depends on that package and aliases its injected shim imports to absolute\n * paths, so consuming apps do not need to install vite-plugin-node-polyfills themselves.\n * @default true\n */\n includeNodePolyfills?: boolean\n}\n\n// Node.js globals that are undefined in browsers and will throw at runtime.\n// Keyed by identifier; value is the safe typeof-guard pattern so we can skip those.\nconst BROWSER_DANGEROUS_GLOBALS: Record<string, RegExp> = {\n global: /\\btypeof\\s+global\\b/,\n process: /\\btypeof\\s+process\\b/,\n Buffer: /\\btypeof\\s+Buffer\\b/,\n __dirname: /\\btypeof\\s+__dirname\\b/,\n __filename: /\\btypeof\\s+__filename\\b/,\n}\n\n/**\n * Strip JS string literals, template literals, and comments from source text\n * so that identifier searches don't false-positive on string content.\n * This is intentionally approximate — good enough for a lint-style warning pass.\n */\nfunction stripStringsAndComments(code: string): string {\n return code\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, (m) => ' '.repeat(m.length)) // /* block comments */\n .replace(/\\/\\/[^\\n]*/g, (m) => ' '.repeat(m.length)) // // line comments\n .replace(/`(?:[^`\\\\]|\\\\.)*`/gs, (m) => '`' + ' '.repeat(m.length - 2) + '`') // template literals\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, (m) => '\"' + ' '.repeat(m.length - 2) + '\"') // double-quoted strings\n .replace(/'(?:[^'\\\\]|\\\\.)*'/g, (m) => \"'\" + ' '.repeat(m.length - 2) + \"'\") // single-quoted strings\n}\n\ninterface GlobalHit {\n global: string\n /** zero-based character offset in the stripped source */\n offset: number\n /** 1-based line number */\n line: number\n /** surrounding raw source for context */\n context: string\n}\n\nfunction findDangerousGlobals(rawCode: string): GlobalHit[] {\n const stripped = stripStringsAndComments(rawCode)\n const hits: GlobalHit[] = []\n\n for (const [name, typeofGuard] of Object.entries(BROWSER_DANGEROUS_GLOBALS)) {\n // Skip globalThis when checking 'global'\n const re = new RegExp(`(?<![.\\\\w$])\\\\b${name}\\\\b(?!This)(?![\\\\w$])`, 'g')\n let m: RegExpExecArray | null\n while ((m = re.exec(stripped)) !== null) {\n const offset = m.index\n // Check for typeof guard in the ~20 chars before the match\n const before = stripped.slice(Math.max(0, offset - 20), offset)\n if (typeofGuard.test(before)) continue\n\n // Compute 1-based line number from raw source (positions are preserved because\n // we replace with equal-length spaces, so offsets are stable)\n const linesBefore = rawCode.slice(0, offset).split('\\n')\n const line = linesBefore.length\n const colOffset = linesBefore.at(-1)?.length ?? 0\n const rawLine = rawCode.split('\\n')[line - 1] ?? ''\n const ctx = rawLine.slice(Math.max(0, colOffset - 40), colOffset + name.length + 40).trim()\n\n hits.push({ global: name, offset, line, context: ctx })\n }\n }\n\n return hits\n}\n\nconst DEFAULT_FS_MODULES = [\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n]\nconst SDK_DIST_DIR = path.dirname(fileURLToPath(import.meta.url))\nconst ARWEAVE_SHIM_FILE = path.join(SDK_DIST_DIR, 'arweave-default-shim.js')\nconst DEBUG_SHIM_FILE = path.join(SDK_DIST_DIR, 'debug-default-shim.js')\n\n/** Fragile renderer deps pre-bundled for stable CJS/ESM interop (aligned with permapress). */\nconst FRAGILE_RENDERER_OPTIMIZE_INCLUDES = [\n 'debug',\n 'random',\n 'seedrandom',\n '@georgedoescode/generative-utils',\n 'nanoid-dictionary',\n] as const\n\n/**\n * Always force-include (do not gate on resolvePackageFile): under bun these live nested\n * under @seedprotocol/sdk, and eas-sdk's ESM named-imports CJS eas-contracts. Without\n * prebundling, Vite serves raw /@fs CJS and the browser throws\n * \"does not provide an export named 'EAS__factory'\" during SchemaEncoder encode.\n */\nconst EAS_OPTIMIZE_INCLUDES = [\n '@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk',\n '@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk > @ethereum-attestation-service/eas-contracts',\n] as const\n\ntype AliasEntry = { find: string | RegExp; replacement: string }\n\nfunction pushBunPackageCandidates(\n bunDir: string,\n packageName: string,\n relativePath: string,\n candidates: string[],\n): void {\n if (!fs.existsSync(bunDir)) return\n // Nested scopes (@scope/name) live under .bun as @scope+name@version/...\n const bunPrefix = packageName.startsWith('@')\n ? packageName.replace('/', '+')\n : packageName\n for (const entry of fs.readdirSync(bunDir)) {\n if (!entry.startsWith(`${bunPrefix}@`) && !entry.startsWith(`${packageName}@`)) continue\n candidates.push(path.join(bunDir, entry, `node_modules/${packageName}`, relativePath))\n }\n}\n\nfunction resolvePackageFile(packageName: string, relativePath: string): string | undefined {\n const candidates: string[] = []\n const sdkRoot = path.resolve(SDK_DIST_DIR, '..')\n\n try {\n const pkgJson = _req.resolve(`${packageName}/package.json`)\n candidates.push(path.join(path.dirname(pkgJson), relativePath))\n } catch {\n // Many packages (e.g. sqlocal) omit package.json from \"exports\". Resolve an\n // entry file and walk up to the package root instead.\n try {\n const entry = _req.resolve(packageName)\n let dir = path.dirname(entry)\n for (let i = 0; i < 8; i++) {\n const pkgJsonPath = path.join(dir, 'package.json')\n if (fs.existsSync(pkgJsonPath)) {\n try {\n const pkgName = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8')).name\n if (pkgName === packageName) {\n candidates.push(path.join(dir, relativePath))\n break\n }\n } catch {\n // ignore invalid package.json\n }\n }\n const parent = path.dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n } catch {\n // package may be hoisted/unavailable in this graph\n }\n }\n\n // Linked/file installs: deps often live under the SDK package, not the app cwd.\n candidates.push(path.join(sdkRoot, 'node_modules', packageName, relativePath))\n\n const cwdNodeModules = path.join(process.cwd(), 'node_modules')\n candidates.push(path.join(cwdNodeModules, packageName, relativePath))\n\n pushBunPackageCandidates(\n path.join(cwdNodeModules, '.bun'),\n packageName,\n relativePath,\n candidates,\n )\n pushBunPackageCandidates(\n path.join(sdkRoot, 'node_modules', '.bun'),\n packageName,\n relativePath,\n candidates,\n )\n const bunInstallRoot = findNodeModulesBunRoot(sdkRoot)\n if (bunInstallRoot) {\n pushBunPackageCandidates(\n path.join(bunInstallRoot, 'node_modules', '.bun'),\n packageName,\n relativePath,\n candidates,\n )\n }\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return undefined\n}\n\n/** Walk up from startDir looking for a directory that contains node_modules/.bun. */\nfunction findNodeModulesBunRoot(startDir: string): string | undefined {\n let dir = path.resolve(startDir)\n for (let i = 0; i < 8; i++) {\n if (fs.existsSync(path.join(dir, 'node_modules', '.bun'))) return dir\n const parent = path.dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return undefined\n}\n\nfunction isFsAllowCovering(allow: readonly string[], filePath: string): boolean {\n const child = path.resolve(filePath)\n return allow.some((uri) => {\n const parent = path.resolve(String(uri))\n return (\n child === parent ||\n child.startsWith(parent.endsWith(path.sep) ? parent : parent + path.sep)\n )\n })\n}\n\nfunction realpathOrResolve(p: string): string {\n try {\n return fs.realpathSync(p)\n } catch {\n return path.resolve(p)\n }\n}\n\n/**\n * When the SDK is linked (file:/symlink) into an external app, sqlocal's worker\n * and sqlite-wasm assets resolve into the SDK install tree (often bun's .bun\n * store). Vite's default server.fs.allow only covers the consumer workspace, so\n * those absolute /@fs requests 403 unless we allowlist the install roots.\n */\nfunction collectDevServerFsAllowPaths(): string[] {\n const paths = new Set<string>()\n const add = (p?: string) => {\n if (!p) return\n paths.add(realpathOrResolve(p))\n }\n\n let sdkPkgDir: string\n try {\n sdkPkgDir = path.dirname(_req.resolve('@seedprotocol/sdk/package.json'))\n } catch {\n sdkPkgDir = path.resolve(SDK_DIST_DIR, '..')\n }\n add(sdkPkgDir)\n\n const bunInstallRoot = findNodeModulesBunRoot(sdkPkgDir)\n if (bunInstallRoot) add(bunInstallRoot)\n\n for (const pkg of ['sqlocal', '@sqlite.org/sqlite-wasm'] as const) {\n const pkgJson = resolvePackageFile(pkg, 'package.json')\n if (pkgJson) add(path.dirname(pkgJson))\n }\n\n return [...paths]\n}\n\nfunction ensureDevServerFsAllow(allow: string[]): string[] {\n const added: string[] = []\n for (const dir of collectDevServerFsAllowPaths()) {\n if (isFsAllowCovering(allow, dir)) continue\n allow.push(dir)\n added.push(dir)\n }\n return added\n}\n\nfunction normalizeAliasEntries(\n alias: NonNullable<UserConfig['resolve']>['alias'] | undefined\n): AliasEntry[] {\n if (!alias) return []\n if (Array.isArray(alias)) {\n return alias\n .filter((entry): entry is AliasEntry => !!entry && !!(entry as AliasEntry).replacement)\n .map((entry) => ({ find: entry.find, replacement: entry.replacement }))\n }\n\n return Object.entries(alias).map(([find, replacement]) => ({\n find,\n replacement: String(replacement),\n }))\n}\n\nfunction mergeAliasEntries(existing: AliasEntry[], additions: AliasEntry[]): AliasEntry[] {\n const merged = [...existing]\n const keyOf = (find: string | RegExp) =>\n typeof find === 'string' ? `s:${find}` : `r:${find.toString()}`\n const seen = new Set(merged.map((entry) => keyOf(entry.find)))\n\n for (const entry of additions) {\n const key = keyOf(entry.find)\n if (seen.has(key)) continue\n seen.add(key)\n merged.push(entry)\n }\n\n return merged\n}\n\n/** Bare IDs that vite-plugin-node-polyfills injects into every transformed module. */\nconst NODE_POLYFILL_SHIM_IDS = [\n 'vite-plugin-node-polyfills/shims/buffer',\n 'vite-plugin-node-polyfills/shims/global',\n 'vite-plugin-node-polyfills/shims/process',\n] as const\n\ntype NodePolyfillShimPaths = {\n buffer?: string\n global?: string\n process?: string\n}\n\n/**\n * Prefer the package \"import\" ESM build (index.js). createRequire resolves the\n * \"require\" condition (index.cjs); Vite then serves `/@fs/...cjs?import` and\n * default-import fails in the browser.\n */\nfunction resolvePolyfillShimFile(shimId: string): string {\n const resolved = _req.resolve(shimId)\n if (resolved.endsWith('.cjs')) {\n const esm = resolved.slice(0, -4) + '.js'\n if (fs.existsSync(esm)) return esm\n }\n return resolved\n}\n\nfunction resolveNodePolyfillShimPaths(): {\n paths: NodePolyfillShimPaths\n unresolved: string[]\n} {\n const paths: NodePolyfillShimPaths = {}\n const unresolved: string[] = []\n for (const id of NODE_POLYFILL_SHIM_IDS) {\n try {\n const abs = resolvePolyfillShimFile(id)\n if (id.endsWith('/buffer')) paths.buffer = abs\n else if (id.endsWith('/global')) paths.global = abs\n else if (id.endsWith('/process')) paths.process = abs\n } catch {\n unresolved.push(id)\n }\n }\n return { paths, unresolved }\n}\n\n/**\n * Collapse repeated vite-plugin-node-polyfills globals banners (Vite 8 optimizer + serve).\n * Re-inject with absolute ESM paths: this runs in transform order \"post\" (after\n * import-analysis), so bare package ids would reach the browser unresolved\n * (\"Relative references must start with /, ./, or ../\").\n */\nfunction dedupeNodePolyfillBanner(\n code: string,\n paths: NodePolyfillShimPaths,\n): string | null {\n const importCount = (code.match(/import\\s+__buffer_polyfill\\b/g) || []).length\n if (importCount <= 1) return null\n if (!paths.buffer || !paths.global || !paths.process) return null\n\n const bannerRe =\n /import\\s+__buffer_polyfill\\s+from\\s+['\"][^'\"]+['\"];?\\s*\\n\\s*globalThis\\.Buffer\\s*=\\s*globalThis\\.Buffer\\s*\\|\\|\\s*__buffer_polyfill;?\\s*\\n\\s*import\\s+__global_polyfill\\s+from\\s+['\"][^'\"]+['\"];?\\s*\\n\\s*globalThis\\.global\\s*=\\s*globalThis\\.global\\s*\\|\\|\\s*__global_polyfill;?\\s*\\n\\s*import\\s+__process_polyfill\\s+from\\s+['\"][^'\"]+['\"];?\\s*\\n\\s*globalThis\\.process\\s*=\\s*globalThis\\.process\\s*\\|\\|\\s*__process_polyfill;?\\s*\\n?/g\n\n const cleaned = code.replace(bannerRe, '')\n if (cleaned === code) return null\n\n const banner =\n `import __buffer_polyfill from ${JSON.stringify(paths.buffer)};\\n` +\n 'globalThis.Buffer = globalThis.Buffer || __buffer_polyfill;\\n' +\n `import __global_polyfill from ${JSON.stringify(paths.global)};\\n` +\n 'globalThis.global = globalThis.global || __global_polyfill;\\n' +\n `import __process_polyfill from ${JSON.stringify(paths.process)};\\n` +\n 'globalThis.process = globalThis.process || __process_polyfill;\\n'\n\n return banner + cleaned\n}\n\n/** Rewrite leftover bare shim package ids to absolute ESM files (post import-analysis). */\nfunction rewriteBarePolyfillShimImports(\n code: string,\n paths: NodePolyfillShimPaths,\n): string | null {\n let next = code\n let changed = false\n const replacements: Array<[string, string]> = []\n if (paths.buffer) {\n replacements.push(['vite-plugin-node-polyfills/shims/buffer', paths.buffer])\n }\n if (paths.global) {\n replacements.push(['vite-plugin-node-polyfills/shims/global', paths.global])\n }\n if (paths.process) {\n replacements.push(['vite-plugin-node-polyfills/shims/process', paths.process])\n }\n for (const [bare, abs] of replacements) {\n const absLiteral = JSON.stringify(abs)\n for (const quote of ['\"', \"'\"] as const) {\n const from = `${quote}${bare}${quote}`\n if (!next.includes(from)) continue\n next = next.split(from).join(absLiteral)\n changed = true\n }\n }\n return changed ? next : null\n}\n\n/**\n * Alias polyfill shim bare imports + buffer/process/global module ids to absolute\n * paths resolved from this package. Nested installs under @seedprotocol/sdk are\n * invisible to consumer-project resolution (and to Vite 8's Rolldown optimizer)\n * unless we rewrite to absolute files.\n */\nfunction addNodePolyfillShimAliases(\n aliasEntries: AliasEntry[],\n paths: NodePolyfillShimPaths,\n): void {\n if (paths.buffer) {\n aliasEntries.push(\n { find: 'vite-plugin-node-polyfills/shims/buffer', replacement: paths.buffer },\n { find: /^buffer$/, replacement: paths.buffer },\n { find: /^node:buffer$/, replacement: paths.buffer },\n )\n }\n if (paths.global) {\n aliasEntries.push(\n { find: 'vite-plugin-node-polyfills/shims/global', replacement: paths.global },\n { find: /^global$/, replacement: paths.global },\n )\n }\n if (paths.process) {\n aliasEntries.push(\n { find: 'vite-plugin-node-polyfills/shims/process', replacement: paths.process },\n { find: /^process$/, replacement: paths.process },\n { find: /^node:process$/, replacement: paths.process },\n )\n }\n}\n\n/** Object-form aliases for optimizeDeps.rolldown/rollup resolve (string keys). */\nfunction nodePolyfillShimAliasObject(paths: NodePolyfillShimPaths): Record<string, string> {\n const alias: Record<string, string> = {}\n if (paths.buffer) {\n alias['vite-plugin-node-polyfills/shims/buffer'] = paths.buffer\n alias.buffer = paths.buffer\n alias['node:buffer'] = paths.buffer\n }\n if (paths.global) {\n alias['vite-plugin-node-polyfills/shims/global'] = paths.global\n alias.global = paths.global\n }\n if (paths.process) {\n alias['vite-plugin-node-polyfills/shims/process'] = paths.process\n alias.process = paths.process\n alias['node:process'] = paths.process\n }\n return alias\n}\n\nconst POLYFILL_ALIAS_FINDS_TO_REPLACE = new Set([\n 'vite-plugin-node-polyfills/shims/buffer',\n 'vite-plugin-node-polyfills/shims/global',\n 'vite-plugin-node-polyfills/shims/process',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n 'global',\n])\n\n/**\n * Put absolute polyfill aliases first and drop bare/package-id entries that\n * vite-plugin-node-polyfills may have added for the same modules (first match wins).\n */\nfunction withPreferredPolyfillAliases(\n existing: AliasEntry[],\n paths: NodePolyfillShimPaths,\n): AliasEntry[] {\n const preferred: AliasEntry[] = []\n addNodePolyfillShimAliases(preferred, paths)\n if (preferred.length === 0) return existing\n\n const filtered = existing.filter((entry) => {\n if (typeof entry.find !== 'string') return true\n return !POLYFILL_ALIAS_FINDS_TO_REPLACE.has(entry.find)\n })\n return [...preferred, ...filtered]\n}\n\nfunction addRendererCompatibilityAliases(aliasEntries: AliasEntry[]): void {\n const nanoidDictionaryEsm = resolvePackageFile(\n 'nanoid-dictionary',\n 'dist/dictionary.esm.js',\n )\n if (nanoidDictionaryEsm) {\n aliasEntries.push({\n find: /^nanoid-dictionary$/,\n replacement: nanoidDictionaryEsm,\n })\n }\n\n const zenfsCoreIndex = resolvePackageFile('@zenfs/core', 'dist/index.js')\n const zenfsCorePath = resolvePackageFile('@zenfs/core', 'dist/path.js')\n if (zenfsCoreIndex) {\n aliasEntries.push({ find: /^@zenfs\\/core$/, replacement: zenfsCoreIndex })\n }\n if (zenfsCorePath) {\n aliasEntries.push({ find: /^@zenfs\\/core\\/path$/, replacement: zenfsCorePath })\n }\n\n const zenfsDomIndex = resolvePackageFile('@zenfs/dom', 'dist/index.js')\n if (zenfsDomIndex) {\n aliasEntries.push({ find: /^@zenfs\\/dom$/, replacement: zenfsDomIndex })\n }\n\n if (fs.existsSync(DEBUG_SHIM_FILE)) {\n // Only alias the package root. Do not alias debug/src/browser.js to this shim:\n // the shim imports that path and aliasing it back creates a circular module.\n aliasEntries.push({ find: /^debug$/, replacement: DEBUG_SHIM_FILE })\n }\n\n const debugBrowserEntry = resolvePackageFile('debug', 'src/browser.js')\n if (debugBrowserEntry) {\n aliasEntries.push({\n find: /^debug\\/src\\/browser\\.js$/,\n replacement: debugBrowserEntry,\n })\n }\n}\n\n/** Object-form aliases for optimizeDeps pre-bundle (debug shim subpath). */\nfunction debugShimOptimizeAliasObject(): Record<string, string> {\n const debugBrowserEntry = resolvePackageFile('debug', 'src/browser.js')\n return debugBrowserEntry ? { 'debug/src/browser.js': debugBrowserEntry } : {}\n}\n\ntype OptimizeDepsConfig = NonNullable<UserConfig['optimizeDeps']>\n\n/** Read Rolldown optimizer options, falling back to deprecated rollup/esbuild shapes. */\nfunction readOptimizeDepsRolldownBase(\n existing: OptimizeDepsConfig | undefined,\n): Record<string, unknown> {\n const opt = existing ?? {}\n return (\n opt.rolldownOptions ??\n (opt as { rollupOptions?: Record<string, unknown> }).rollupOptions ??\n {}\n ) as Record<string, unknown>\n}\n\n/**\n * Merge Vite 8 `optimizeDeps.rolldownOptions` without returning deprecated\n * `esbuildOptions` / `rollupOptions` keys from plugin config hooks.\n */\nfunction mergeOptimizeDepsRolldownOptions(\n existing: OptimizeDepsConfig | undefined,\n patch: {\n define?: Record<string, string>\n alias?: Record<string, string>\n },\n): OptimizeDepsConfig['rolldownOptions'] {\n const base = readOptimizeDepsRolldownBase(existing)\n const existingResolve = (base.resolve as { alias?: Record<string, string> } | undefined) ?? {}\n const existingTransform = (base.transform as { define?: Record<string, string> } | undefined) ?? {}\n const legacyDefine = existing?.esbuildOptions?.define ?? {}\n\n const mergedDefine = {\n ...legacyDefine,\n ...existingTransform.define,\n ...patch.define,\n }\n const mergedAlias = {\n ...existingResolve.alias,\n ...patch.alias,\n }\n\n return {\n ...base,\n ...(Object.keys(mergedDefine).length > 0\n ? {\n transform: {\n ...existingTransform,\n define: mergedDefine,\n },\n }\n : {}),\n ...(Object.keys(mergedAlias).length > 0\n ? {\n resolve: {\n ...existingResolve,\n alias: mergedAlias,\n },\n }\n : {}),\n }\n}\n\n/** Spread optimizeDeps while omitting deprecated optimizer option keys. */\nfunction omitDeprecatedOptimizeDepsKeys(\n existing: OptimizeDepsConfig | undefined,\n): Omit<OptimizeDepsConfig, 'esbuildOptions' | 'rollupOptions'> {\n const { esbuildOptions: _e, rollupOptions: _r, ...rest } = existing ?? {}\n return rest\n}\n\n/**\n * Minimal Vite plugin to make the SDK work in browser/Electron renderer:\n * - Aliases fs → @zenfs/core (and promises variant)\n * - Aliases path → path-browserify\n * - Ensures CommonJS in SDK dist is transformed by Vite's CommonJS plugin\n * - Allowlists linked SDK / sqlocal worker paths on server.fs.allow for Vite dev\n * - Optionally injects a simple ZenFS initialization script\n * - Optionally wires up vite-plugin-node-polyfills with safe defaults\n *\n * This plugin assumes the SDK does not bundle Node-only code in the browser entry.\n * For Electron, Node-only work (e.g. better-sqlite3) should run in the\n * main process; the renderer should only use browser-safe SDK usage.\n *\n * For the renderer build:\n * - Use the SDK's ESM entry: import from '@seedprotocol/sdk' (resolves to dist/main.js).\n * - When autoInit is false (default), initialize ZenFS in your entry:\n * import { configure } from '@zenfs/core'; import { IndexedDB } from '@zenfs/dom';\n * await configure({ mounts: { '/': IndexedDB } });\n */\nexport function seedVitePlugin(options: SeedVitePluginOptions = {}): Plugin[] {\n const {\n fsModules = DEFAULT_FS_MODULES,\n autoInit = false,\n debug = false,\n includeNodePolyfills = true,\n } = options\n\n const log = (...args: unknown[]) => {\n if (debug) console.log('[seed-vite-plugin]', ...args)\n }\n\n const { paths: polyfillShimPaths, unresolved: unresolvedPolyfillShims } =\n resolveNodePolyfillShimPaths()\n const polyfillShimAliasObj = nodePolyfillShimAliasObject(polyfillShimPaths)\n\n if (includeNodePolyfills && unresolvedPolyfillShims.length > 0) {\n console.warn(\n '[seed-vite-plugin] Could not resolve vite-plugin-node-polyfills shims from the SDK package:\\n' +\n unresolvedPolyfillShims.map((id) => ` - ${id}`).join('\\n') +\n '\\nNode polyfill globals may fail to resolve. Reinstall @seedprotocol/sdk, or set includeNodePolyfills: false and configure polyfills yourself.',\n )\n } else if (unresolvedPolyfillShims.length === 0) {\n log('Resolved vite-plugin-node-polyfills shims to absolute paths')\n }\n\n /**\n * Pre-plugin: configure aliases and optimizeDeps.\n */\n const configPlugin: Plugin = {\n name: 'seed-protocol:config',\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n const addedAllowPaths = ensureDevServerFsAllow(resolvedConfig.server.fs.allow)\n if (addedAllowPaths.length > 0) {\n log(\n 'Extended server.fs.allow for linked SDK / sqlocal worker paths:',\n addedAllowPaths,\n )\n }\n },\n\n config(userConfig) {\n const aliasEntries: AliasEntry[] = []\n for (const mod of fsModules) {\n const isPromises = mod.includes('promises')\n const target = isPromises ? '@zenfs/core/promises' : '@zenfs/core'\n aliasEntries.push({ find: mod, replacement: target })\n }\n\n const eventEmitterEsm = resolvePackageFile('eventemitter3', 'dist/eventemitter3.esm.js')\n if (eventEmitterEsm) {\n aliasEntries.push(\n { find: 'eventemitter3', replacement: eventEmitterEsm },\n { find: 'eventemitter3/index.mjs', replacement: eventEmitterEsm },\n { find: 'eventemitter3/index.js', replacement: eventEmitterEsm },\n )\n }\n\n const arweaveBundle = resolvePackageFile('arweave', 'bundles/web.bundle.js')\n if (arweaveBundle) {\n aliasEntries.push(\n { find: /^arweave$/, replacement: ARWEAVE_SHIM_FILE },\n { find: /^arweave\\/web\\/index\\.js$/, replacement: ARWEAVE_SHIM_FILE },\n { find: /^arweave\\/bundles\\/web\\.bundle\\.js$/, replacement: arweaveBundle },\n )\n }\n\n addRendererCompatibilityAliases(aliasEntries)\n addNodePolyfillShimAliases(aliasEntries, polyfillShimPaths)\n\n const existingResolve = userConfig.resolve ?? {}\n const mergedAlias = mergeAliasEntries(\n normalizeAliasEntries(existingResolve.alias),\n aliasEntries,\n )\n\n const desiredOptimizeIncludes = [\n '@zenfs/core',\n '@zenfs/dom',\n 'kerium',\n 'utilium',\n 'memium',\n 'readable-stream',\n 'viem',\n 'isows',\n ...FRAGILE_RENDERER_OPTIMIZE_INCLUDES,\n ]\n const resolvableOptimizeIncludes = desiredOptimizeIncludes.filter(\n (dep) => !!resolvePackageFile(dep, 'package.json'),\n )\n\n const existingOptimize = userConfig.optimizeDeps\n const debugOptimizeAliases = debugShimOptimizeAliasObject()\n\n const optimizeDeps: UserConfig['optimizeDeps'] = {\n ...omitDeprecatedOptimizeDepsKeys(existingOptimize),\n exclude: [\n ...(existingOptimize?.exclude ?? []),\n // Do not prebundle the SDK itself or clearly node-only tools\n '@seedprotocol/sdk',\n 'drizzle-orm',\n 'better-sqlite3',\n // sqlocal uses workers and should not be prebundled\n 'sqlocal',\n ],\n include: [\n ...(existingOptimize?.include ?? []),\n ...resolvableOptimizeIncludes,\n ...EAS_OPTIMIZE_INCLUDES,\n ],\n // Keep `global` shim in optimizer Rolldown options; top-level Vite `define`\n // can be rejected by Rolldown in some consumer setups.\n rolldownOptions: mergeOptimizeDepsRolldownOptions(existingOptimize, {\n define: { global: 'globalThis' },\n alias: {\n ...debugOptimizeAliases,\n ...polyfillShimAliasObj,\n },\n }),\n }\n\n return {\n // Apply global → globalThis for Rollup production builds too.\n // optimizeDeps.rolldownOptions.transform.define only covers the dev pre-bundle step;\n // this top-level define is picked up by @rollup/plugin-replace during build\n // and covers all chunks, including code-split migrator/commonjs-helper chunks.\n define: {\n ...(userConfig.define ?? {}),\n global: 'globalThis',\n // process is referenced by path-browserify (drizzle migrator's node:path dep)\n // and other CJS modules. Point at globalThis.process which is set by the\n // synchronous inline shim script injected into index.html before any modules load.\n 'process.env.NODE_ENV': JSON.stringify('production'),\n 'process.browser': 'true',\n 'process.platform': '\"browser\"',\n },\n resolve: {\n ...existingResolve,\n alias: mergedAlias,\n // Prevent duplicate React/thirdweb instances when @seedprotocol/publish is workspace-linked.\n // Multiple copies break context (e.g. useActiveAccount must be used within ThirdwebProvider).\n // Also dedupe XState and Seed packages: two xstate copies cause Object.assign _version errors;\n // two @seedprotocol/sdk copies leave BaseDb facade / Db.appDb on different module instances\n // (\"App DB not found\", undefined.$with on PostsPage).\n dedupe: Array.from(\n new Set([\n ...(existingResolve.dedupe ?? []),\n 'react',\n 'react-dom',\n 'thirdweb',\n 'xstate',\n '@xstate/react',\n '@seedprotocol/sdk',\n '@seedprotocol/react',\n '@seedprotocol/publish',\n '@seedprotocol/feed',\n ])\n ),\n },\n optimizeDeps,\n }\n },\n }\n\n /**\n * Runs after vite-plugin-node-polyfills so absolute shim aliases win over its bare\n * package-id aliases in both resolve.alias and the Rolldown optimizeDeps graph.\n */\n const polyfillResolvePlugin: Plugin = {\n name: 'seed-protocol:polyfill-resolve',\n enforce: 'post',\n\n config(userConfig) {\n if (Object.keys(polyfillShimAliasObj).length === 0) return\n\n const existingResolve = userConfig.resolve ?? {}\n const mergedAlias = withPreferredPolyfillAliases(\n normalizeAliasEntries(existingResolve.alias),\n polyfillShimPaths,\n )\n\n const existingOptimize = userConfig.optimizeDeps\n\n return {\n resolve: {\n ...existingResolve,\n alias: mergedAlias,\n },\n optimizeDeps: {\n rolldownOptions: mergeOptimizeDepsRolldownOptions(existingOptimize, {\n // Later merge overwrites bare shim ids from vite-plugin-node-polyfills.\n alias: polyfillShimAliasObj,\n }),\n },\n }\n },\n\n resolveId: {\n order: 'pre',\n handler(id) {\n // Always rewrite injected shim package ids (safe even if nested under the SDK).\n if (id === 'vite-plugin-node-polyfills/shims/buffer') {\n return polyfillShimPaths.buffer ?? null\n }\n if (id === 'vite-plugin-node-polyfills/shims/global') {\n return polyfillShimPaths.global ?? null\n }\n if (id === 'vite-plugin-node-polyfills/shims/process') {\n return polyfillShimPaths.process ?? null\n }\n // Only remap node globals when we own the polyfills plugin config.\n if (!includeNodePolyfills) return null\n if (id === 'buffer' || id === 'node:buffer') return polyfillShimPaths.buffer ?? null\n if (id === 'global') return polyfillShimPaths.global ?? null\n if (id === 'process' || id === 'node:process') return polyfillShimPaths.process ?? null\n return null\n },\n },\n\n transform: {\n // After polyfills banner/inject so we collapse duplicates left in optimized deps.\n // Must emit absolute shim paths: order \"post\" runs after import-analysis.\n order: 'post',\n handler(code) {\n const count = (code.match(/import\\s+__buffer_polyfill\\b/g) || []).length\n let next = code\n let mutated = false\n\n if (count > 1) {\n const deduped = dedupeNodePolyfillBanner(next, polyfillShimPaths)\n if (deduped) {\n next = deduped\n mutated = true\n }\n }\n\n const rewritten = rewriteBarePolyfillShimImports(next, polyfillShimPaths)\n if (rewritten) {\n next = rewritten\n mutated = true\n }\n\n if (mutated) return { code: next, map: null }\n return null\n },\n },\n }\n\n /**\n * Post-plugin: build configuration + optional ZenFS init.\n */\n const mainPlugin: Plugin = {\n name: 'seed-protocol:main',\n enforce: 'post',\n\n config(userConfig) {\n const existingBuild = userConfig.build ?? {}\n const existingCommonjs = existingBuild.commonjsOptions ?? {}\n const existingRollupOptions = existingBuild.rollupOptions ?? {}\n const existingRolldownOptions = (existingBuild as Record<string, unknown>).rolldownOptions as\n | Record<string, unknown>\n | undefined\n const existingExternal = existingRollupOptions.external ?? []\n\n const include = [\n // Anything the user already had\n ...(Array.isArray(existingCommonjs.include)\n ? existingCommonjs.include\n : existingCommonjs.include\n ? [existingCommonjs.include]\n : []),\n // Always process node_modules and the SDK dist so require() is transformed\n /node_modules/,\n /seed-protocol-sdk[\\\\/]+dist[\\\\/]/,\n ]\n\n // Exclude packages that are already ESM or have special worker handling\n const exclude = [\n ...(Array.isArray(existingCommonjs.exclude)\n ? existingCommonjs.exclude\n : existingCommonjs.exclude\n ? [existingCommonjs.exclude]\n : []),\n // sqlocal is ESM and uses workers - don't transform it\n /node_modules[\\\\/]+sqlocal[\\\\/]/,\n ]\n\n const commonjsOptions = {\n ...existingCommonjs,\n include,\n exclude,\n transformMixedEsModules: true,\n }\n\n // Externalize Node.js-only packages that should never be bundled for the browser\n const nodeOnlyPackages = [\n 'better-sqlite3', // Native SQLite binding (Node.js only)\n ]\n\n const isNodeOnlyExternal = (id: string) =>\n nodeOnlyPackages.some(\n (pkg) =>\n id === pkg ||\n id.startsWith(`${pkg}/`) ||\n id.includes(`/${pkg}/`) ||\n id.endsWith(`/${pkg}`)\n )\n\n const externalList = (id: string, importer?: string, isResolved?: boolean) => {\n if (isNodeOnlyExternal(id)) return true\n if (typeof existingExternal === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (existingExternal as any)(id, importer, isResolved ?? false)\n }\n if (Array.isArray(existingExternal)) {\n return existingExternal.some((ext) => ext === id || id.startsWith(`${ext}/`))\n }\n return false\n }\n\n const rollupOptions = {\n ...existingRollupOptions,\n external: externalList,\n }\n\n const build: Record<string, unknown> = {\n ...existingBuild,\n commonjsOptions,\n }\n if (existingRolldownOptions) {\n build.rolldownOptions = {\n ...existingRolldownOptions,\n external: externalList,\n }\n } else {\n build.rollupOptions = rollupOptions\n }\n\n // Worker options are TOP-LEVEL in Vite config, not under build.\n // Default 'iife' breaks when workers use code-splitting (e.g. sqlocal).\n const existingWorker = userConfig.worker ?? {}\n const worker = {\n ...existingWorker,\n format: existingWorker.format ?? 'es',\n }\n\n return {\n build,\n worker,\n }\n },\n\n generateBundle(_options, bundle) {\n const allHits: Array<{ chunk: string } & GlobalHit> = []\n\n for (const [chunkName, asset] of Object.entries(bundle)) {\n if (asset.type !== 'chunk') continue\n const hits = findDangerousGlobals(asset.code)\n for (const hit of hits) {\n allHits.push({ chunk: chunkName, ...hit })\n }\n }\n\n if (allHits.length === 0) return\n\n console.warn(\n '\\n[seed-vite-plugin] ⚠️ Bare Node.js globals detected in browser bundle chunks.' +\n ' These will throw ReferenceError at runtime unless shimmed.\\n'\n )\n const byChunk = new Map<string, typeof allHits>()\n for (const hit of allHits) {\n const list = byChunk.get(hit.chunk) ?? []\n list.push(hit)\n byChunk.set(hit.chunk, list)\n }\n for (const [chunk, hits] of byChunk) {\n console.warn(` ${chunk}`)\n for (const h of hits) {\n console.warn(` line ${h.line}: \\`${h.global}\\` — ${h.context}`)\n }\n }\n console.warn('')\n },\n\n transformIndexHtml(html) {\n // Synchronous inline script runs before any <script type=\"module\">, so\n // global and process are guaranteed to exist when CJS wrappers evaluate.\n // vite-plugin-node-polyfills injects polyfills via module imports, which\n // resolve too late for @rollup/plugin-commonjs-generated wrapper code.\n const shimScript = `<script>\n(function(){\n if(typeof globalThis.global==='undefined')globalThis.global=globalThis;\n if(typeof globalThis.process==='undefined')globalThis.process={env:{NODE_ENV:'production'},browser:true,version:'v18.0.0',versions:{},platform:'browser',cwd:function(){return'/'},nextTick:function(fn){setTimeout(fn,0)}};\n})();\n</script>`\n\n let result = html\n if (result.includes('<head>')) {\n result = result.replace('<head>', `<head>\\n${shimScript}`)\n } else {\n result = shimScript + result\n }\n\n if (!autoInit) return result\n\n const initScript = `\n<script type=\"module\">\nimport { configure } from '@zenfs/core';\nimport { IndexedDB } from '@zenfs/dom';\n\nif (!window.__seedFsReady) {\n window.__seedFsReady = configure({\n mounts: { '/': IndexedDB },\n }).catch((err) => {\n console.error('[seed-vite-plugin] ZenFS initialization failed', err);\n });\n}\n</script>`\n\n if (result.includes('</head>')) {\n return result.replace('</head>', `${initScript}\\n</head>`)\n }\n\n return result + initScript\n },\n }\n\n const sdkImportFixPlugin: Plugin = {\n name: 'seed-protocol:sdk-import-fix',\n enforce: 'post',\n transform(code, id) {\n if (!id.includes('@seedprotocol/sdk') || !id.includes('FileManager')) {\n return null\n }\n const hasDefaultPathBrowserifyImport =\n /import\\s+path\\s+from\\s+['\"]path-browserify['\"]/.test(code)\n if (!hasDefaultPathBrowserifyImport) {\n return null\n }\n const transformed = code.replace(\n /import\\s+path\\s+from\\s+['\"]path-browserify['\"];/g,\n \"import * as path from 'path';\",\n )\n if (transformed === code) {\n return null\n }\n return { code: transformed, map: null }\n },\n }\n\n const plugins: Plugin[] = [configPlugin, mainPlugin, sdkImportFixPlugin]\n\n if (includeNodePolyfills) {\n log('Including vite-plugin-node-polyfills with default settings')\n // vite-plugin-node-polyfills ≥0.27 returns Plugin[]; older versions returned a single Plugin.\n const polyfillPlugins = nodePolyfills({\n // Let fs be handled by @zenfs/core instead of polyfills\n exclude: ['readline',],\n // Common set of browser-friendly polyfills used by many deps\n include: ['path', 'crypto', 'stream', 'util', 'buffer', 'events', 'string_decoder',],\n globals: {\n Buffer: true,\n global: true,\n process: true,\n },\n protocolImports: true,\n }) as unknown as Plugin | Plugin[]\n if (Array.isArray(polyfillPlugins)) {\n plugins.push(...polyfillPlugins)\n } else {\n plugins.push(polyfillPlugins)\n }\n }\n\n // After nodePolyfills so config() can overwrite its bare shim aliases.\n if (Object.keys(polyfillShimAliasObj).length > 0) {\n plugins.push(polyfillResolvePlugin)\n }\n\n return plugins\n}\n"],"mappings":";;;;;;AAOA,IAAM,IAAO,EAAc,OAAO,KAAK,GAAG,GAqCpC,IAAoD;CACxD,QAAY;CACZ,SAAY;CACZ,QAAY;CACZ,WAAY;CACZ,YAAY;AACd;AAOA,SAAS,EAAwB,GAAsB;CACrD,OAAO,EACJ,QAAQ,sBAAsB,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC,EACxD,QAAQ,gBAAgB,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC,EAClD,QAAQ,wBAAwB,MAAM,MAAM,IAAI,OAAO,EAAE,SAAS,CAAC,IAAI,GAAG,EAC1E,QAAQ,uBAAuB,MAAM,OAAM,IAAI,OAAO,EAAE,SAAS,CAAC,IAAI,IAAG,EACzE,QAAQ,uBAAuB,MAAM,MAAM,IAAI,OAAO,EAAE,SAAS,CAAC,IAAI,GAAG;AAC9E;AAYA,SAAS,EAAqB,GAA8B;CAC1D,IAAM,IAAW,EAAwB,CAAO,GAC1C,IAAoB,CAAC;CAE3B,KAAK,IAAM,CAAC,GAAM,MAAgB,OAAO,QAAQ,CAAyB,GAAG;EAE3E,IAAM,IAAS,OAAO,kBAAkB,EAAK,wBAAwB,GAAG,GACp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GE,IAHE,EAAO,SAAS,QAAQ,IACjB,EAAO,QAAQ,UAAU,WAAW,GAAY,IAEhD,IAAa,GAGpB,CAAC,GAAU,OAAO;IAEtB,IAAM,IAAa;IAkBnB,OAJI,EAAO,SAAS,SAAS,IACpB,EAAO,QAAQ,WAAW,GAAG,EAAW,UAAU,IAGpD,IAAS;GAClB;EA0BuC;EAAY;GAtBnD,MAAM;GACN,SAAS;GACT,UAAU,GAAM,GAAI;IAMlB,IALI,CAAC,EAAG,SAAS,mBAAmB,KAAK,CAAC,EAAG,SAAS,aAAa,KAK/D,CADF,iDAAiD,KAAK,CACnD,GACH,OAAO;IAET,IAAM,IAAc,EAAK,QACvB,oDACA,+BACF;IAIA,OAHI,MAAgB,IACX,OAEF;KAAE,MAAM;KAAa,KAAK;IAAK;GACxC;EAGmD;CAAkB;CAEvE,IAAI,GAAsB;EACxB,EAAI,4DAA4D;EAEhE,IAAM,IAAkB,EAAc;GAEpC,SAAS,CAAC,UAAW;GAErB,SAAS;IAAC;IAAQ;IAAU;IAAU;IAAQ;IAAU;IAAU;GAAiB;GACnF,SAAS;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;GACX;GACA,iBAAiB;EACnB,CAAC;EACD,AAAI,MAAM,QAAQ,CAAe,IAC/B,EAAQ,KAAK,GAAG,CAAe,IAE/B,EAAQ,KAAK,CAAe;CAEhC;CAOA,OAJI,OAAO,KAAK,CAAoB,EAAE,SAAS,KAC7C,EAAQ,KAAK,CAAqB,GAG7B;AACT"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@seedprotocol/vite",
3
+ "version": "0.5.1",
4
+ "description": "Vite plugin for Seed Protocol browser/renderer apps",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "rimraf dist && tsc -p tsconfig.build.json && vite build",
25
+ "test": "vitest run --reporter=default",
26
+ "prepublishOnly": "bun run build && node ../../scripts/sync-versions.js"
27
+ },
28
+ "dependencies": {
29
+ "debug": "^4.4.1",
30
+ "vite-plugin-node-polyfills": "^0.27.0"
31
+ },
32
+ "peerDependencies": {
33
+ "vite": ">=8.0.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "@zenfs/core": {
37
+ "optional": true
38
+ },
39
+ "@zenfs/dom": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "devDependencies": {
44
+ "@types/bun": "latest",
45
+ "@types/node": "^24.10.1",
46
+ "rimraf": "^6.0.1",
47
+ "typescript": "~5.9.3",
48
+ "vite": "^8.0.0",
49
+ "vitest": "^3.0.0"
50
+ },
51
+ "author": "Keith Axline <keith@journodao.xyz>",
52
+ "license": "MIT",
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
+ }