@seedprotocol/vite 0.7.5 → 0.7.6-next.949.g73caafc
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/README.md +33 -32
- package/dist/aliases.d.ts +15 -0
- package/dist/aliases.d.ts.map +1 -0
- package/dist/index.d.ts +29 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +280 -457
- package/dist/index.js.map +1 -1
- package/dist/nodeGlobals.d.ts +22 -0
- package/dist/nodeGlobals.d.ts.map +1 -0
- package/dist/nodePolyfills.d.ts +24 -0
- package/dist/nodePolyfills.d.ts.map +1 -0
- package/package.json +3 -4
- package/dist/arweave-default-shim.d.ts +0 -4
- package/dist/arweave-default-shim.d.ts.map +0 -1
- package/dist/arweave-default-shim.js +0 -6
- package/dist/debug-default-shim.d.ts +0 -3
- package/dist/debug-default-shim.d.ts.map +0 -1
- package/dist/debug-default-shim.js +0 -19
package/dist/index.js
CHANGED
|
@@ -1,22 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
4
|
-
import {
|
|
5
|
-
import i from "node:
|
|
1
|
+
import e from "node:fs";
|
|
2
|
+
import t from "node:path";
|
|
3
|
+
import { parseAst as n } from "vite";
|
|
4
|
+
import { attachScopes as r } from "@rollup/pluginutils";
|
|
5
|
+
import { createRequire as i } from "node:module";
|
|
6
6
|
import { fileURLToPath as a } from "node:url";
|
|
7
7
|
import { nodePolyfills as o } from "vite-plugin-node-polyfills";
|
|
8
|
-
//#region
|
|
9
|
-
|
|
8
|
+
//#region ../bundler-core/dist/index.js
|
|
9
|
+
function s(e) {
|
|
10
|
+
return e.includes("promises") ? "@zenfs/core/promises" : "@zenfs/core";
|
|
11
|
+
}
|
|
12
|
+
var c = {
|
|
13
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
14
|
+
"Cross-Origin-Embedder-Policy": "credentialless",
|
|
15
|
+
"Cross-Origin-Resource-Policy": "same-origin"
|
|
16
|
+
};
|
|
17
|
+
function l(e) {
|
|
18
|
+
if (e === !1) return null;
|
|
19
|
+
let t = typeof e == "object" && e ? e : {};
|
|
20
|
+
return {
|
|
21
|
+
"Cross-Origin-Opener-Policy": t.coop ?? c["Cross-Origin-Opener-Policy"],
|
|
22
|
+
"Cross-Origin-Embedder-Policy": t.coep ?? c["Cross-Origin-Embedder-Policy"],
|
|
23
|
+
"Cross-Origin-Resource-Policy": t.corp ?? c["Cross-Origin-Resource-Policy"]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function u(e, t) {
|
|
27
|
+
let n = new Set(Object.keys(t ?? {}).map((e) => e.toLowerCase()));
|
|
28
|
+
return Object.fromEntries(Object.entries(e).filter(([e]) => !n.has(e.toLowerCase())));
|
|
29
|
+
}
|
|
30
|
+
function d(e, t) {
|
|
31
|
+
let n = new Map(Object.entries(t ?? {}).map(([e, t]) => [e.toLowerCase(), t]));
|
|
32
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => {
|
|
33
|
+
let r = n.get(e.toLowerCase());
|
|
34
|
+
return [e, r == null ? t : String(r)];
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/aliases.ts
|
|
39
|
+
function f(e) {
|
|
40
|
+
return e ? Array.isArray(e) ? e.filter((e) => !!e && !!e.replacement).map((e) => ({
|
|
41
|
+
find: e.find,
|
|
42
|
+
replacement: e.replacement
|
|
43
|
+
})) : Object.entries(e).map(([e, t]) => ({
|
|
44
|
+
find: e,
|
|
45
|
+
replacement: String(t)
|
|
46
|
+
})) : [];
|
|
47
|
+
}
|
|
48
|
+
function p(e, t) {
|
|
49
|
+
let n = [...e], r = (e) => typeof e == "string" ? `s:${e}` : `r:${e.toString()}`, i = new Set(n.map((e) => r(e.find)));
|
|
50
|
+
for (let e of t) {
|
|
51
|
+
let t = r(e.find);
|
|
52
|
+
i.has(t) || (i.add(t), n.push(e));
|
|
53
|
+
}
|
|
54
|
+
return n;
|
|
55
|
+
}
|
|
56
|
+
function m(e, t) {
|
|
57
|
+
t.length !== 0 && (e.resolve = {
|
|
58
|
+
...e.resolve,
|
|
59
|
+
alias: p(f(e.resolve?.alias), t)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/nodeGlobals.ts
|
|
64
|
+
var h = /* @__PURE__ */ new Set([
|
|
10
65
|
"global",
|
|
11
66
|
"process",
|
|
12
67
|
"Buffer",
|
|
13
68
|
"__dirname",
|
|
14
69
|
"__filename"
|
|
15
70
|
]);
|
|
16
|
-
function
|
|
71
|
+
function g(e) {
|
|
17
72
|
return !!e && typeof e == "object" && typeof e.type == "string";
|
|
18
73
|
}
|
|
19
|
-
function
|
|
74
|
+
function _(e, t) {
|
|
20
75
|
switch (e.type) {
|
|
21
76
|
case "MemberExpression": return t !== "property" || !!e.computed;
|
|
22
77
|
case "Property":
|
|
@@ -32,32 +87,32 @@ function u(e, t) {
|
|
|
32
87
|
default: return !0;
|
|
33
88
|
}
|
|
34
89
|
}
|
|
35
|
-
function
|
|
36
|
-
if (e.type === "UnaryExpression" && e.operator === "typeof" &&
|
|
90
|
+
function v(e, t) {
|
|
91
|
+
if (e.type === "UnaryExpression" && e.operator === "typeof" && g(e.argument) && e.argument.type === "Identifier" && e.argument.name === t) return !0;
|
|
37
92
|
for (let n of Object.keys(e)) {
|
|
38
93
|
let r = e[n];
|
|
39
94
|
if (Array.isArray(r)) {
|
|
40
|
-
if (r.some((e) =>
|
|
41
|
-
} else if (
|
|
95
|
+
if (r.some((e) => g(e) && v(e, t))) return !0;
|
|
96
|
+
} else if (g(r) && v(r, t)) return !0;
|
|
42
97
|
}
|
|
43
98
|
return !1;
|
|
44
99
|
}
|
|
45
|
-
function
|
|
100
|
+
function y(e, t) {
|
|
46
101
|
for (let n = e; n.parent; n = n.parent) {
|
|
47
102
|
let e = n.parent.node, r = n.key;
|
|
48
|
-
if ((e.type === "IfStatement" || e.type === "ConditionalExpression") && r !== "test" &&
|
|
103
|
+
if ((e.type === "IfStatement" || e.type === "ConditionalExpression") && r !== "test" && v(e.test, t) || e.type === "LogicalExpression" && r === "right" && v(e.left, t) || e.type === "TryStatement" && r === "block") return !0;
|
|
49
104
|
}
|
|
50
105
|
return !1;
|
|
51
106
|
}
|
|
52
|
-
function
|
|
53
|
-
let
|
|
107
|
+
function b(e) {
|
|
108
|
+
let t, i;
|
|
54
109
|
try {
|
|
55
|
-
|
|
110
|
+
t = n(e), i = r(t, "scope");
|
|
56
111
|
} catch {
|
|
57
112
|
return [];
|
|
58
113
|
}
|
|
59
114
|
let a = [], o = [0];
|
|
60
|
-
for (let
|
|
115
|
+
for (let t = e.indexOf("\n"); t !== -1; t = e.indexOf("\n", t + 1)) o.push(t + 1);
|
|
61
116
|
let s = (e) => {
|
|
62
117
|
let t = 0, n = o.length - 1;
|
|
63
118
|
for (; t < n;) {
|
|
@@ -65,232 +120,89 @@ function p(n) {
|
|
|
65
120
|
o[r] <= e ? t = r : n = r - 1;
|
|
66
121
|
}
|
|
67
122
|
return t;
|
|
68
|
-
},
|
|
123
|
+
}, c = [{
|
|
69
124
|
path: {
|
|
70
|
-
node:
|
|
125
|
+
node: t,
|
|
71
126
|
key: "",
|
|
72
127
|
parent: null
|
|
73
128
|
},
|
|
74
129
|
scope: i
|
|
75
130
|
}];
|
|
76
|
-
for (;
|
|
77
|
-
let { path:
|
|
78
|
-
if (r.type === "Identifier" &&
|
|
79
|
-
let
|
|
80
|
-
if ((c.type !== "UnaryExpression" || c.operator !== "typeof") &&
|
|
81
|
-
let
|
|
131
|
+
for (; c.length > 0;) {
|
|
132
|
+
let { path: t, scope: n } = c.pop(), { node: r } = t, i = r.scope ?? n;
|
|
133
|
+
if (r.type === "Identifier" && h.has(r.name) && t.parent) {
|
|
134
|
+
let n = r.name, c = t.parent.node;
|
|
135
|
+
if ((c.type !== "UnaryExpression" || c.operator !== "typeof") && _(c, t.key) && !i.contains(n) && !y(t, n)) {
|
|
136
|
+
let t = s(r.start), i = o[t], c = o[t + 1] ?? e.length, l = e.slice(Math.max(i, r.start - 40), Math.min(c, r.end + 40)).trim();
|
|
82
137
|
a.push({
|
|
83
|
-
global:
|
|
138
|
+
global: n,
|
|
84
139
|
offset: r.start,
|
|
85
|
-
line:
|
|
140
|
+
line: t + 1,
|
|
86
141
|
context: l
|
|
87
142
|
});
|
|
88
143
|
}
|
|
89
144
|
continue;
|
|
90
145
|
}
|
|
91
|
-
let
|
|
92
|
-
for (let
|
|
93
|
-
if (
|
|
94
|
-
let n = r[
|
|
95
|
-
if (Array.isArray(n)) for (let r of n)
|
|
146
|
+
let l = [];
|
|
147
|
+
for (let e of Object.keys(r)) {
|
|
148
|
+
if (e === "scope") continue;
|
|
149
|
+
let n = r[e];
|
|
150
|
+
if (Array.isArray(n)) for (let r of n) g(r) && l.push({
|
|
96
151
|
node: r,
|
|
97
|
-
key:
|
|
98
|
-
parent:
|
|
152
|
+
key: e,
|
|
153
|
+
parent: t
|
|
99
154
|
});
|
|
100
|
-
else
|
|
155
|
+
else g(n) && l.push({
|
|
101
156
|
node: n,
|
|
102
|
-
key:
|
|
103
|
-
parent:
|
|
157
|
+
key: e,
|
|
158
|
+
parent: t
|
|
104
159
|
});
|
|
105
160
|
}
|
|
106
|
-
for (let e =
|
|
107
|
-
path:
|
|
161
|
+
for (let e = l.length - 1; e >= 0; e--) c.push({
|
|
162
|
+
path: l[e],
|
|
108
163
|
scope: i
|
|
109
164
|
});
|
|
110
165
|
}
|
|
111
166
|
return a;
|
|
112
167
|
}
|
|
113
|
-
|
|
114
|
-
"fs",
|
|
115
|
-
"fs/promises",
|
|
116
|
-
"node:fs",
|
|
117
|
-
"node:fs/promises"
|
|
118
|
-
], h = i.dirname(a(import.meta.url)), g = i.join(h, "arweave-default-shim.js"), _ = i.join(h, "debug-default-shim.js"), v = i.join(h, "stream-default-shim.js"), y = [
|
|
119
|
-
"debug",
|
|
120
|
-
"random",
|
|
121
|
-
"seedrandom",
|
|
122
|
-
"@georgedoescode/generative-utils",
|
|
123
|
-
"nanoid-dictionary"
|
|
124
|
-
], b = ["@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk", "@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk > @ethereum-attestation-service/eas-contracts"], x = [
|
|
125
|
-
"kerium",
|
|
126
|
-
"utilium",
|
|
127
|
-
"memium",
|
|
128
|
-
"readable-stream",
|
|
129
|
-
"viem",
|
|
130
|
-
"isows"
|
|
131
|
-
], S = [
|
|
132
|
-
"@seedprotocol/eas",
|
|
133
|
-
"@seedprotocol/arweave",
|
|
134
|
-
"@seedprotocol/query"
|
|
135
|
-
];
|
|
136
|
-
function C(e) {
|
|
137
|
-
let t = [], n = [], r = j("@seedprotocol/sdk", e);
|
|
138
|
-
for (let i of S) j(i, e) ? (t.push(i), n.push(i)) : r && t.push(`@seedprotocol/sdk > ${i}`);
|
|
139
|
-
return {
|
|
140
|
-
include: t,
|
|
141
|
-
dedupe: n
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
var w = ["pluralize"], T = {
|
|
145
|
-
"Cross-Origin-Opener-Policy": "same-origin",
|
|
146
|
-
"Cross-Origin-Embedder-Policy": "credentialless",
|
|
147
|
-
"Cross-Origin-Resource-Policy": "same-origin"
|
|
148
|
-
};
|
|
149
|
-
function E(e) {
|
|
150
|
-
if (e === !1) return null;
|
|
151
|
-
let t = typeof e == "object" && e ? e : {};
|
|
152
|
-
return {
|
|
153
|
-
"Cross-Origin-Opener-Policy": t.coop ?? T["Cross-Origin-Opener-Policy"],
|
|
154
|
-
"Cross-Origin-Embedder-Policy": t.coep ?? T["Cross-Origin-Embedder-Policy"],
|
|
155
|
-
"Cross-Origin-Resource-Policy": t.corp ?? T["Cross-Origin-Resource-Policy"]
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function D(e, t) {
|
|
159
|
-
let n = new Set(Object.keys(t ?? {}).map((e) => e.toLowerCase()));
|
|
160
|
-
return Object.fromEntries(Object.entries(e).filter(([e]) => !n.has(e.toLowerCase())));
|
|
161
|
-
}
|
|
162
|
-
function O(e, t) {
|
|
163
|
-
let n = new Map(Object.entries(t ?? {}).map(([e, t]) => [e.toLowerCase(), t]));
|
|
164
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => {
|
|
165
|
-
let r = n.get(e.toLowerCase());
|
|
166
|
-
return [e, r == null ? t : String(r)];
|
|
167
|
-
}));
|
|
168
|
-
}
|
|
169
|
-
function k(e, t) {
|
|
170
|
-
e.middlewares.use((e, n, r) => {
|
|
171
|
-
let i = () => {
|
|
172
|
-
for (let [e, r] of Object.entries(t)) n.getHeader(e) || n.setHeader(e, r);
|
|
173
|
-
}, a = n.writeHead.bind(n);
|
|
174
|
-
n.writeHead = ((...e) => (i(), a(...e))), i(), r();
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function A(e, t, r, a) {
|
|
178
|
-
if (!n.existsSync(e)) return;
|
|
179
|
-
let o = t.startsWith("@") ? t.replace("/", "+") : t;
|
|
180
|
-
for (let s of n.readdirSync(e)) (s.startsWith(`${o}@`) || s.startsWith(`${t}@`)) && a.push(i.join(e, s, `node_modules/${t}`, r));
|
|
181
|
-
}
|
|
182
|
-
function j(e, t) {
|
|
183
|
-
return (r(i.join(t, "package.json")).resolve.paths(e) ?? []).some((t) => n.existsSync(i.join(t, e, "package.json")));
|
|
184
|
-
}
|
|
185
|
-
function M(e, t) {
|
|
186
|
-
let r = [], a = i.resolve(h, "..");
|
|
187
|
-
try {
|
|
188
|
-
let n = s.resolve(`${e}/package.json`);
|
|
189
|
-
r.push(i.join(i.dirname(n), t));
|
|
190
|
-
} catch {
|
|
191
|
-
try {
|
|
192
|
-
let a = s.resolve(e), o = i.dirname(a);
|
|
193
|
-
for (let a = 0; a < 8; a++) {
|
|
194
|
-
let a = i.join(o, "package.json");
|
|
195
|
-
if (n.existsSync(a)) try {
|
|
196
|
-
if (JSON.parse(n.readFileSync(a, "utf8")).name === e) {
|
|
197
|
-
r.push(i.join(o, t));
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
} catch {}
|
|
201
|
-
let s = i.dirname(o);
|
|
202
|
-
if (s === o) break;
|
|
203
|
-
o = s;
|
|
204
|
-
}
|
|
205
|
-
} catch {}
|
|
206
|
-
}
|
|
207
|
-
r.push(i.join(a, "node_modules", e, t));
|
|
208
|
-
let o = i.join(process.cwd(), "node_modules");
|
|
209
|
-
r.push(i.join(o, e, t)), A(i.join(o, ".bun"), e, t, r), A(i.join(a, "node_modules", ".bun"), e, t, r);
|
|
210
|
-
let c = N(a);
|
|
211
|
-
c && A(i.join(c, "node_modules", ".bun"), e, t, r);
|
|
212
|
-
for (let e of r) if (n.existsSync(e)) return e;
|
|
213
|
-
}
|
|
214
|
-
function N(e) {
|
|
215
|
-
let t = i.resolve(e);
|
|
216
|
-
for (let e = 0; e < 8; e++) {
|
|
217
|
-
if (n.existsSync(i.join(t, "node_modules", ".bun"))) return t;
|
|
218
|
-
let e = i.dirname(t);
|
|
219
|
-
if (e === t) break;
|
|
220
|
-
t = e;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function P(e, t) {
|
|
224
|
-
let n = i.resolve(t);
|
|
225
|
-
return e.some((e) => {
|
|
226
|
-
let t = i.resolve(String(e));
|
|
227
|
-
return n === t || n.startsWith(t.endsWith(i.sep) ? t : t + i.sep);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
function F(e) {
|
|
231
|
-
try {
|
|
232
|
-
return n.realpathSync(e);
|
|
233
|
-
} catch {
|
|
234
|
-
return i.resolve(e);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function I() {
|
|
238
|
-
let e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
239
|
-
t && e.add(F(t));
|
|
240
|
-
}, n;
|
|
241
|
-
try {
|
|
242
|
-
n = i.dirname(s.resolve("@seedprotocol/sdk/package.json"));
|
|
243
|
-
} catch {
|
|
244
|
-
n = i.resolve(h, "..");
|
|
245
|
-
}
|
|
246
|
-
t(n);
|
|
247
|
-
let r = N(n);
|
|
248
|
-
r && t(r);
|
|
249
|
-
for (let e of ["sqlocal", "@sqlite.org/sqlite-wasm"]) {
|
|
250
|
-
let n = M(e, "package.json");
|
|
251
|
-
n && t(i.dirname(n));
|
|
252
|
-
}
|
|
253
|
-
return [...e];
|
|
254
|
-
}
|
|
255
|
-
function L(e) {
|
|
168
|
+
function x(e) {
|
|
256
169
|
let t = [];
|
|
257
|
-
for (let n of
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})) : Object.entries(e).map(([e, t]) => ({
|
|
265
|
-
find: e,
|
|
266
|
-
replacement: String(t)
|
|
267
|
-
})) : [];
|
|
268
|
-
}
|
|
269
|
-
function z(e, t) {
|
|
270
|
-
let n = [...e], r = (e) => typeof e == "string" ? `s:${e}` : `r:${e.toString()}`, i = new Set(n.map((e) => r(e.find)));
|
|
170
|
+
for (let [n, r] of Object.entries(e)) if (r.type === "chunk" && r.code !== void 0) for (let e of b(r.code)) t.push({
|
|
171
|
+
chunk: n,
|
|
172
|
+
...e
|
|
173
|
+
});
|
|
174
|
+
if (t.length === 0) return;
|
|
175
|
+
console.warn("\n[seed-vite-plugin] Bare Node.js globals in browser chunks. They throw ReferenceError at runtime if that code runs; set includeNodePolyfills: true if it does.\n");
|
|
176
|
+
let n = /* @__PURE__ */ new Map();
|
|
271
177
|
for (let e of t) {
|
|
272
|
-
let t =
|
|
273
|
-
|
|
178
|
+
let t = n.get(e.chunk) ?? [];
|
|
179
|
+
t.push(e), n.set(e.chunk, t);
|
|
274
180
|
}
|
|
275
|
-
|
|
181
|
+
for (let [e, t] of n) {
|
|
182
|
+
console.warn(` ${e}`);
|
|
183
|
+
for (let e of t) console.warn(` line ${e.line}: \`${e.global}\` — ${e.context}`);
|
|
184
|
+
}
|
|
185
|
+
console.warn("");
|
|
276
186
|
}
|
|
277
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/nodePolyfills.ts
|
|
189
|
+
var S = i(import.meta.url), C = t.join(t.dirname(a(import.meta.url)), "stream-default-shim.js"), w = [
|
|
278
190
|
"vite-plugin-node-polyfills/shims/buffer",
|
|
279
191
|
"vite-plugin-node-polyfills/shims/global",
|
|
280
192
|
"vite-plugin-node-polyfills/shims/process"
|
|
281
193
|
];
|
|
282
|
-
function
|
|
283
|
-
let
|
|
284
|
-
if (
|
|
285
|
-
let
|
|
286
|
-
if (
|
|
194
|
+
function T(t) {
|
|
195
|
+
let n = S.resolve(t);
|
|
196
|
+
if (n.endsWith(".cjs")) {
|
|
197
|
+
let t = n.slice(0, -4) + ".js";
|
|
198
|
+
if (e.existsSync(t)) return t;
|
|
287
199
|
}
|
|
288
|
-
return
|
|
200
|
+
return n;
|
|
289
201
|
}
|
|
290
|
-
function
|
|
202
|
+
function E() {
|
|
291
203
|
let e = {}, t = [];
|
|
292
|
-
for (let n of
|
|
293
|
-
let t =
|
|
204
|
+
for (let n of w) try {
|
|
205
|
+
let t = T(n);
|
|
294
206
|
n.endsWith("/buffer") ? e.buffer = t : n.endsWith("/global") ? e.global = t : n.endsWith("/process") && (e.process = t);
|
|
295
207
|
} catch {
|
|
296
208
|
t.push(n);
|
|
@@ -300,7 +212,7 @@ function H() {
|
|
|
300
212
|
unresolved: t
|
|
301
213
|
};
|
|
302
214
|
}
|
|
303
|
-
function
|
|
215
|
+
function D(e, t) {
|
|
304
216
|
let n = e, r = !1, i = [];
|
|
305
217
|
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]);
|
|
306
218
|
for (let [e, t] of i) {
|
|
@@ -312,7 +224,7 @@ function U(e, t) {
|
|
|
312
224
|
}
|
|
313
225
|
return r ? n : null;
|
|
314
226
|
}
|
|
315
|
-
function
|
|
227
|
+
function O(e, t) {
|
|
316
228
|
t.buffer && e.push({
|
|
317
229
|
find: "vite-plugin-node-polyfills/shims/buffer",
|
|
318
230
|
replacement: t.buffer
|
|
@@ -339,11 +251,11 @@ function W(e, t) {
|
|
|
339
251
|
replacement: t.process
|
|
340
252
|
});
|
|
341
253
|
}
|
|
342
|
-
function
|
|
254
|
+
function k(e) {
|
|
343
255
|
let t = {};
|
|
344
256
|
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;
|
|
345
257
|
}
|
|
346
|
-
var
|
|
258
|
+
var A = /* @__PURE__ */ new Set([
|
|
347
259
|
"vite-plugin-node-polyfills/shims/buffer",
|
|
348
260
|
"vite-plugin-node-polyfills/shims/global",
|
|
349
261
|
"vite-plugin-node-polyfills/shims/process",
|
|
@@ -353,57 +265,13 @@ var K = /* @__PURE__ */ new Set([
|
|
|
353
265
|
"node:process",
|
|
354
266
|
"global"
|
|
355
267
|
]);
|
|
356
|
-
function
|
|
268
|
+
function j(e, t) {
|
|
357
269
|
let n = [];
|
|
358
|
-
if (
|
|
359
|
-
let r = e.filter((e) => typeof e.find != "string" || !
|
|
270
|
+
if (O(n, t), n.length === 0) return e;
|
|
271
|
+
let r = e.filter((e) => typeof e.find != "string" || !A.has(e.find));
|
|
360
272
|
return [...n, ...r];
|
|
361
273
|
}
|
|
362
|
-
function
|
|
363
|
-
let t = M("nanoid-dictionary", "dist/dictionary.esm.js");
|
|
364
|
-
t && e.push({
|
|
365
|
-
find: /^nanoid-dictionary$/,
|
|
366
|
-
replacement: t
|
|
367
|
-
});
|
|
368
|
-
let r = M("@zenfs/core", "dist/index.js"), i = M("@zenfs/core", "dist/path.js");
|
|
369
|
-
r && e.push({
|
|
370
|
-
find: /^@zenfs\/core$/,
|
|
371
|
-
replacement: r
|
|
372
|
-
}), i && e.push({
|
|
373
|
-
find: /^@zenfs\/core\/path$/,
|
|
374
|
-
replacement: i
|
|
375
|
-
});
|
|
376
|
-
let a = M("@zenfs/dom", "dist/index.js");
|
|
377
|
-
a && e.push({
|
|
378
|
-
find: /^@zenfs\/dom$/,
|
|
379
|
-
replacement: a
|
|
380
|
-
}), n.existsSync(_) && e.push({
|
|
381
|
-
find: /^debug$/,
|
|
382
|
-
replacement: _
|
|
383
|
-
});
|
|
384
|
-
let o = M("debug", "src/browser.js");
|
|
385
|
-
o && e.push({
|
|
386
|
-
find: /^debug\/src\/browser\.js$/,
|
|
387
|
-
replacement: o
|
|
388
|
-
}), n.existsSync(v) && e.push({
|
|
389
|
-
find: /^stream$/,
|
|
390
|
-
replacement: v
|
|
391
|
-
}, {
|
|
392
|
-
find: /^node:stream$/,
|
|
393
|
-
replacement: v
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
function Y() {
|
|
397
|
-
let e = M("debug", "src/browser.js");
|
|
398
|
-
return e ? { "debug/src/browser.js": e } : {};
|
|
399
|
-
}
|
|
400
|
-
function X() {
|
|
401
|
-
return n.existsSync(v) ? {
|
|
402
|
-
stream: v,
|
|
403
|
-
"node:stream": v
|
|
404
|
-
} : {};
|
|
405
|
-
}
|
|
406
|
-
function Z(e, t) {
|
|
274
|
+
function M(e, t) {
|
|
407
275
|
let n = {
|
|
408
276
|
...e?.esbuildOptions?.define,
|
|
409
277
|
...t.define
|
|
@@ -413,232 +281,187 @@ function Z(e, t) {
|
|
|
413
281
|
...Object.keys(r).length > 0 ? { resolve: { alias: r } } : {}
|
|
414
282
|
};
|
|
415
283
|
}
|
|
416
|
-
function
|
|
417
|
-
let {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
284
|
+
function N(t) {
|
|
285
|
+
let { paths: n, unresolved: r } = E(), i = k(n);
|
|
286
|
+
r.length > 0 ? console.warn("[seed-vite-plugin] Could not resolve vite-plugin-node-polyfills shims:\n" + r.map((e) => ` - ${e}`).join("\n") + "\nNode polyfill globals may fail to resolve. Reinstall @seedprotocol/vite.") : t("Resolved vite-plugin-node-polyfills shims to absolute paths");
|
|
287
|
+
let a = e.existsSync(C) ? {
|
|
288
|
+
stream: C,
|
|
289
|
+
"node:stream": C
|
|
290
|
+
} : {}, s = "production", c = {
|
|
291
|
+
name: "seed-protocol:node-globals",
|
|
423
292
|
enforce: "pre",
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
n?.mode && (d = n.mode);
|
|
431
|
-
let r = [];
|
|
432
|
-
for (let e of t) {
|
|
433
|
-
let t = e.includes("promises") ? "@zenfs/core/promises" : "@zenfs/core";
|
|
434
|
-
r.push({
|
|
435
|
-
find: e,
|
|
436
|
-
replacement: t
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
let a = M("eventemitter3", "dist/eventemitter3.esm.js");
|
|
440
|
-
a && r.push({
|
|
441
|
-
find: "eventemitter3",
|
|
442
|
-
replacement: a
|
|
443
|
-
}, {
|
|
444
|
-
find: "eventemitter3/index.mjs",
|
|
445
|
-
replacement: a
|
|
446
|
-
}, {
|
|
447
|
-
find: "eventemitter3/index.js",
|
|
448
|
-
replacement: a
|
|
449
|
-
});
|
|
450
|
-
let o = M("arweave", "bundles/web.bundle.js");
|
|
451
|
-
o && r.push({
|
|
452
|
-
find: /^arweave$/,
|
|
453
|
-
replacement: g
|
|
454
|
-
}, {
|
|
455
|
-
find: /^arweave\/web\/index\.js$/,
|
|
456
|
-
replacement: g
|
|
457
|
-
}, {
|
|
458
|
-
find: /^arweave\/bundles\/web\.bundle\.js$/,
|
|
459
|
-
replacement: o
|
|
460
|
-
}), J(r), e.resolve = {
|
|
461
|
-
...e.resolve,
|
|
462
|
-
alias: z(R(e.resolve?.alias), r)
|
|
463
|
-
};
|
|
464
|
-
let s = new Set(e.resolve.dedupe ?? []), l = [
|
|
465
|
-
"@zenfs/core",
|
|
466
|
-
"@zenfs/dom",
|
|
467
|
-
...y
|
|
468
|
-
], u = i.resolve(e.root ?? process.cwd()), f = [...l.filter((e) => !!M(e, "package.json")), ...x.filter((e) => j(e, u))], p = C(u), m = e.optimizeDeps, h = Y(), _ = X(), S = {
|
|
469
|
-
exclude: [
|
|
470
|
-
"@seedprotocol/sdk",
|
|
471
|
-
"drizzle-orm",
|
|
472
|
-
"better-sqlite3",
|
|
473
|
-
"sqlocal"
|
|
474
|
-
],
|
|
475
|
-
include: [
|
|
476
|
-
...f,
|
|
477
|
-
...p.include,
|
|
478
|
-
...b,
|
|
479
|
-
...w
|
|
480
|
-
],
|
|
481
|
-
rolldownOptions: Z(m, {
|
|
482
|
-
define: { global: "globalThis" },
|
|
483
|
-
alias: {
|
|
484
|
-
...h,
|
|
485
|
-
..._,
|
|
486
|
-
...v
|
|
487
|
-
}
|
|
488
|
-
})
|
|
489
|
-
};
|
|
293
|
+
config(e, t) {
|
|
294
|
+
t?.mode && (s = t.mode), m(e, Object.entries(a).map(([e, t]) => ({
|
|
295
|
+
find: RegExp(`^${e}$`),
|
|
296
|
+
replacement: t
|
|
297
|
+
})));
|
|
298
|
+
let n = e.define ?? {};
|
|
490
299
|
return {
|
|
491
|
-
define: {
|
|
492
|
-
...e.define ?? {},
|
|
300
|
+
define: Object.fromEntries(Object.entries({
|
|
493
301
|
global: "globalThis",
|
|
494
302
|
"process.browser": "true",
|
|
495
303
|
"process.platform": "\"browser\""
|
|
496
|
-
},
|
|
497
|
-
|
|
498
|
-
"
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
"@seedprotocol/react",
|
|
505
|
-
"@seedprotocol/publish",
|
|
506
|
-
"@seedprotocol/feed",
|
|
507
|
-
...p.dedupe,
|
|
508
|
-
"@zenfs/core",
|
|
509
|
-
"@zenfs/dom"
|
|
510
|
-
])).filter((e) => !s.has(e)) },
|
|
511
|
-
optimizeDeps: S,
|
|
512
|
-
...c ? {
|
|
513
|
-
server: { headers: D(c, e.server?.headers) },
|
|
514
|
-
...e.preview?.headers ? { preview: { headers: D(c, e.preview.headers) } } : {}
|
|
515
|
-
} : {}
|
|
304
|
+
}).filter(([e]) => !(e in n))),
|
|
305
|
+
optimizeDeps: { rolldownOptions: M(e.optimizeDeps, {
|
|
306
|
+
define: { global: "globalThis" },
|
|
307
|
+
alias: {
|
|
308
|
+
...a,
|
|
309
|
+
...i
|
|
310
|
+
}
|
|
311
|
+
}) }
|
|
516
312
|
};
|
|
313
|
+
},
|
|
314
|
+
transformIndexHtml(e) {
|
|
315
|
+
let t = `<script>
|
|
316
|
+
(function(){
|
|
317
|
+
if(typeof globalThis.global==='undefined')globalThis.global=globalThis;
|
|
318
|
+
if(typeof globalThis.process==='undefined')globalThis.process={env:{NODE_ENV:${JSON.stringify(s)}},browser:true,version:'v18.0.0',versions:{},platform:'browser',cwd:function(){return'/'},nextTick:function(fn){setTimeout(fn,0)}};
|
|
319
|
+
})();
|
|
320
|
+
<\/script>`;
|
|
321
|
+
return e.includes("<head>") ? e.replace("<head>", `<head>\n${t}`) : t + e;
|
|
517
322
|
}
|
|
518
|
-
},
|
|
323
|
+
}, l = {
|
|
519
324
|
name: "seed-protocol:polyfill-resolve",
|
|
520
325
|
enforce: "post",
|
|
521
326
|
config(e) {
|
|
522
|
-
if (Object.keys(
|
|
327
|
+
if (Object.keys(i).length !== 0) return e.resolve = {
|
|
523
328
|
...e.resolve,
|
|
524
|
-
alias:
|
|
525
|
-
}, { optimizeDeps: { rolldownOptions:
|
|
329
|
+
alias: j(f(e.resolve?.alias), n)
|
|
330
|
+
}, { optimizeDeps: { rolldownOptions: M(void 0, {
|
|
526
331
|
define: { global: "globalThis" },
|
|
527
|
-
alias:
|
|
332
|
+
alias: i
|
|
528
333
|
}) } };
|
|
529
334
|
},
|
|
530
335
|
resolveId: {
|
|
531
336
|
order: "pre",
|
|
532
337
|
handler(e) {
|
|
533
|
-
return e === "vite-plugin-node-polyfills/shims/buffer"
|
|
338
|
+
return e === "vite-plugin-node-polyfills/shims/buffer" || e === "buffer" || e === "node:buffer" ? n.buffer ?? null : e === "vite-plugin-node-polyfills/shims/global" || e === "global" ? n.global ?? null : e === "vite-plugin-node-polyfills/shims/process" || e === "process" || e === "node:process" ? n.process ?? null : null;
|
|
534
339
|
}
|
|
535
340
|
},
|
|
536
341
|
transform: {
|
|
537
342
|
order: "post",
|
|
538
343
|
handler(e) {
|
|
539
|
-
let t =
|
|
344
|
+
let t = D(e, n);
|
|
540
345
|
return t ? {
|
|
541
346
|
code: t,
|
|
542
347
|
map: null
|
|
543
348
|
} : null;
|
|
544
349
|
}
|
|
545
350
|
}
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
include: [/node_modules/, /seed-protocol-sdk[\\/]+dist[\\/]/],
|
|
560
|
-
exclude: [/node_modules[\\/]+sqlocal[\\/]/],
|
|
561
|
-
transformMixedEsModules: !0
|
|
562
|
-
}, n = [/^better-sqlite3(?:\/|$)/, /[\\/]better-sqlite3(?:[\\/]|$)/], r = (e.build?.rolldownOptions ?? e.build?.rollupOptions)?.external;
|
|
563
|
-
return {
|
|
564
|
-
build: {
|
|
565
|
-
commonjsOptions: t,
|
|
566
|
-
rolldownOptions: { external: typeof r == "function" ? (e, t, i) => n.some((t) => t.test(e)) || r(e, t, i) : n }
|
|
567
|
-
},
|
|
568
|
-
...e.worker?.format ? {} : { worker: { format: "es" } }
|
|
569
|
-
};
|
|
570
|
-
},
|
|
571
|
-
generateBundle(e, t) {
|
|
572
|
-
let n = [];
|
|
573
|
-
for (let [e, r] of Object.entries(t)) {
|
|
574
|
-
if (r.type !== "chunk") continue;
|
|
575
|
-
let t = p(r.code);
|
|
576
|
-
for (let r of t) n.push({
|
|
577
|
-
chunk: e,
|
|
578
|
-
...r
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
if (n.length === 0) return;
|
|
582
|
-
console.warn("\n[seed-vite-plugin] ⚠️ Bare Node.js globals detected in browser bundle chunks. These will throw ReferenceError at runtime unless shimmed.\n");
|
|
583
|
-
let r = /* @__PURE__ */ new Map();
|
|
584
|
-
for (let e of n) {
|
|
585
|
-
let t = r.get(e.chunk) ?? [];
|
|
586
|
-
t.push(e), r.set(e.chunk, t);
|
|
587
|
-
}
|
|
588
|
-
for (let [e, t] of r) {
|
|
589
|
-
console.warn(` ${e}`);
|
|
590
|
-
for (let e of t) console.warn(` line ${e.line}: \`${e.global}\` — ${e.context}`);
|
|
591
|
-
}
|
|
592
|
-
console.warn("");
|
|
593
|
-
},
|
|
594
|
-
transformIndexHtml(e) {
|
|
595
|
-
let t = `<script>
|
|
596
|
-
(function(){
|
|
597
|
-
if(typeof globalThis.global==='undefined')globalThis.global=globalThis;
|
|
598
|
-
if(typeof globalThis.process==='undefined')globalThis.process={env:{NODE_ENV:${JSON.stringify(d)}},browser:true,version:'v18.0.0',versions:{},platform:'browser',cwd:function(){return'/'},nextTick:function(fn){setTimeout(fn,0)}};
|
|
599
|
-
})();
|
|
600
|
-
<\/script>`, r = e;
|
|
601
|
-
if (r = r.includes("<head>") ? r.replace("<head>", `<head>\n${t}`) : t + r, !n) return r;
|
|
602
|
-
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>";
|
|
603
|
-
return r.includes("</head>") ? r.replace("</head>", `${i}\n</head>`) : r + i;
|
|
604
|
-
}
|
|
351
|
+
}, u = o({
|
|
352
|
+
exclude: ["readline"],
|
|
353
|
+
include: [
|
|
354
|
+
"path",
|
|
355
|
+
"buffer",
|
|
356
|
+
"events",
|
|
357
|
+
"string_decoder",
|
|
358
|
+
"util"
|
|
359
|
+
],
|
|
360
|
+
globals: {
|
|
361
|
+
Buffer: !0,
|
|
362
|
+
global: !0,
|
|
363
|
+
process: !0
|
|
605
364
|
},
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return n === e ? null : {
|
|
613
|
-
code: n,
|
|
614
|
-
map: null
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
}
|
|
365
|
+
protocolImports: !0
|
|
366
|
+
});
|
|
367
|
+
return [
|
|
368
|
+
c,
|
|
369
|
+
...Array.isArray(u) ? u : [u],
|
|
370
|
+
...Object.keys(i).length > 0 ? [l] : []
|
|
618
371
|
];
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/index.ts
|
|
375
|
+
var P = [
|
|
376
|
+
"react",
|
|
377
|
+
"react-dom",
|
|
378
|
+
"thirdweb",
|
|
379
|
+
"xstate",
|
|
380
|
+
"@xstate/react",
|
|
381
|
+
"@zenfs/core",
|
|
382
|
+
"@zenfs/dom",
|
|
383
|
+
"@seedprotocol/sdk",
|
|
384
|
+
"@seedprotocol/react",
|
|
385
|
+
"@seedprotocol/publish",
|
|
386
|
+
"@seedprotocol/feed",
|
|
387
|
+
"@seedprotocol/eas",
|
|
388
|
+
"@seedprotocol/arweave",
|
|
389
|
+
"@seedprotocol/query"
|
|
390
|
+
];
|
|
391
|
+
function F(n, r) {
|
|
392
|
+
let i = t.resolve(r);
|
|
393
|
+
for (;;) {
|
|
394
|
+
let r = t.join(i, "node_modules", n);
|
|
395
|
+
if (e.existsSync(t.join(r, "package.json"))) return r;
|
|
396
|
+
let a = t.dirname(i);
|
|
397
|
+
if (a === i) return;
|
|
398
|
+
i = a;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function I(t) {
|
|
402
|
+
let n = F("@seedprotocol/sdk", t);
|
|
403
|
+
if (!n) return [];
|
|
404
|
+
let r = [e.realpathSync(n)];
|
|
405
|
+
for (let t of ["sqlocal", "@sqlite.org/sqlite-wasm"]) {
|
|
406
|
+
let n = F(t, r[r.length - 1]);
|
|
407
|
+
n && r.push(e.realpathSync(n));
|
|
638
408
|
}
|
|
639
|
-
return
|
|
409
|
+
return r;
|
|
410
|
+
}
|
|
411
|
+
function L(e, n) {
|
|
412
|
+
return e.some((e) => {
|
|
413
|
+
let r = t.resolve(String(e));
|
|
414
|
+
return n === r || n.startsWith(r.endsWith(t.sep) ? r : r + t.sep);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function R(e, t) {
|
|
418
|
+
e.middlewares.use((e, n, r) => {
|
|
419
|
+
let i = () => {
|
|
420
|
+
for (let [e, r] of Object.entries(t)) n.getHeader(e) || n.setHeader(e, r);
|
|
421
|
+
}, a = n.writeHead.bind(n);
|
|
422
|
+
n.writeHead = ((...e) => (i(), a(...e))), i(), r();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function z(e = {}) {
|
|
426
|
+
let { fsModules: n = [], debug: r = !1, includeNodePolyfills: i = !1, isolationHeaders: a } = e, o = l(a), c = o, f = o, p = (...e) => {
|
|
427
|
+
r && console.log("[seed-vite-plugin]", ...e);
|
|
428
|
+
};
|
|
429
|
+
return [{
|
|
430
|
+
name: "seed-protocol:config",
|
|
431
|
+
enforce: "pre",
|
|
432
|
+
config(e) {
|
|
433
|
+
m(e, n.map((e) => ({
|
|
434
|
+
find: e,
|
|
435
|
+
replacement: s(e)
|
|
436
|
+
})));
|
|
437
|
+
let r = t.resolve(e.root ?? process.cwd()), i = new Set(e.resolve?.dedupe ?? []), a = P.filter((e) => !i.has(e) && F(e, r) !== void 0);
|
|
438
|
+
return p("resolve.dedupe:", a), {
|
|
439
|
+
resolve: { dedupe: a },
|
|
440
|
+
...e.optimizeDeps?.rolldownOptions?.output && "strictExecutionOrder" in e.optimizeDeps.rolldownOptions.output ? {} : { optimizeDeps: { rolldownOptions: { output: { strictExecutionOrder: !0 } } } },
|
|
441
|
+
...e.worker?.format ? {} : { worker: { format: "es" } },
|
|
442
|
+
...o ? {
|
|
443
|
+
server: { headers: u(o, e.server?.headers) },
|
|
444
|
+
...e.preview?.headers ? { preview: { headers: u(o, e.preview.headers) } } : {}
|
|
445
|
+
} : {}
|
|
446
|
+
};
|
|
447
|
+
},
|
|
448
|
+
configResolved(e) {
|
|
449
|
+
if (o && (c = d(o, e.server.headers), f = d(o, e.preview.headers)), e.command !== "serve") return;
|
|
450
|
+
let t = e.server.fs.allow, n = I(e.root).filter((e) => !L(t, e));
|
|
451
|
+
t.push(...n), n.length > 0 && p("server.fs.allow += ", n);
|
|
452
|
+
},
|
|
453
|
+
configureServer(e) {
|
|
454
|
+
c && R(e, c);
|
|
455
|
+
},
|
|
456
|
+
configurePreviewServer(e) {
|
|
457
|
+
f && R(e, f);
|
|
458
|
+
},
|
|
459
|
+
generateBundle(e, t) {
|
|
460
|
+
r && x(t);
|
|
461
|
+
}
|
|
462
|
+
}, ...i ? N(p) : []];
|
|
640
463
|
}
|
|
641
464
|
//#endregion
|
|
642
|
-
export {
|
|
465
|
+
export { z as seedVitePlugin };
|
|
643
466
|
|
|
644
467
|
//# sourceMappingURL=index.js.map
|