@seedprotocol/sdk 0.4.30 → 0.4.32
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/dist/{ArweaveClient-BA7b13Dl.js → ArweaveClient-CZpZgmR2.js} +3 -3
- package/dist/{ArweaveClient-BA7b13Dl.js.map → ArweaveClient-CZpZgmR2.js.map} +1 -1
- package/dist/{ArweaveClient-DJ8Q63JQ.js → ArweaveClient-Cs7AL9dp.js} +3 -3
- package/dist/{ArweaveClient-DJ8Q63JQ.js.map → ArweaveClient-Cs7AL9dp.js.map} +1 -1
- package/dist/{Db-BHMXF86s.js → Db-CF6R7HIy.js} +4 -4
- package/dist/{Db-BHMXF86s.js.map → Db-CF6R7HIy.js.map} +1 -1
- package/dist/{Db-qgwjsLKI.js → Db-CZkONsdT.js} +4 -4
- package/dist/{Db-qgwjsLKI.js.map → Db-CZkONsdT.js.map} +1 -1
- package/dist/{EasClient-BqU4c27A.js → EasClient-PXOzSzPG.js} +2 -2
- package/dist/{EasClient-DjSKI-Jp.js.map → EasClient-PXOzSzPG.js.map} +1 -1
- package/dist/{EasClient-DjSKI-Jp.js → EasClient-qfTiM2we.js} +2 -2
- package/dist/{EasClient-BqU4c27A.js.map → EasClient-qfTiM2we.js.map} +1 -1
- package/dist/{FileManager-DJ-mFSmc.js → FileManager-5GkHtxF7.js} +2 -2
- package/dist/{FileManager-DJ-mFSmc.js.map → FileManager-5GkHtxF7.js.map} +1 -1
- package/dist/{FileManager-DIbVCWke.js → FileManager-jORQ8Bb6.js} +2 -2
- package/dist/{FileManager-DIbVCWke.js.map → FileManager-jORQ8Bb6.js.map} +1 -1
- package/dist/{ModelProperty-jBpPbg3l.js → ModelProperty-e_hXSFvf.js} +17 -17
- package/dist/{ModelProperty-jBpPbg3l.js.map → ModelProperty-e_hXSFvf.js.map} +1 -1
- package/dist/{PathResolver-DmFG4fR1.js → PathResolver-B4_X69Rd.js} +2 -2
- package/dist/{PathResolver-DmFG4fR1.js.map → PathResolver-B4_X69Rd.js.map} +1 -1
- package/dist/{PathResolver-CxmIkVyO.js → PathResolver-Dz0RVGIz.js} +2 -2
- package/dist/{PathResolver-CxmIkVyO.js.map → PathResolver-Dz0RVGIz.js.map} +1 -1
- package/dist/{QueryClient-7vk66LoN.js → QueryClient-CXHZ239d.js} +2 -2
- package/dist/{QueryClient-7vk66LoN.js.map → QueryClient-CXHZ239d.js.map} +1 -1
- package/dist/{QueryClient-CHayftHv.js → QueryClient-D_UK4YLm.js} +2 -2
- package/dist/{QueryClient-CHayftHv.js.map → QueryClient-D_UK4YLm.js.map} +1 -1
- package/dist/{Schema-CyWoCyDH.js → Schema-DonRkUOJ.js} +22 -22
- package/dist/{Schema-CyWoCyDH.js.map → Schema-DonRkUOJ.js.map} +1 -1
- package/dist/{SchemaValidationService-ByxyqvS9.js → SchemaValidationService-DcmfhQae.js} +2 -2
- package/dist/{SchemaValidationService-ByxyqvS9.js.map → SchemaValidationService-DcmfhQae.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-CUenpA6t.js → backfillMetadataPropertyIds-CKTfvFgQ.js} +2 -2
- package/dist/{backfillMetadataPropertyIds-CUenpA6t.js.map → backfillMetadataPropertyIds-CKTfvFgQ.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BEpPD4wH.js → ModelProperty-BQYU5hPQ.js} +17 -17
- package/dist/cjs/{ModelProperty-BEpPD4wH.js.map → ModelProperty-BQYU5hPQ.js.map} +1 -1
- package/dist/cjs/{Schema-DgvWd1wc.js → Schema-BcRHcQ0W.js} +20 -20
- package/dist/cjs/{Schema-DgvWd1wc.js.map → Schema-BcRHcQ0W.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-DazyAm6l.js → SchemaValidationService-CQNDgyZl.js} +2 -2
- package/dist/cjs/{SchemaValidationService-DazyAm6l.js.map → SchemaValidationService-CQNDgyZl.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-BHJnW-NK.js → backfillMetadataPropertyIds-Dn4oVmEv.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds-BHJnW-NK.js.map → backfillMetadataPropertyIds-Dn4oVmEv.js.map} +1 -1
- package/dist/cjs/{getItem-CStbsCge.js → getItem-DpnPrzl3.js} +2 -2
- package/dist/cjs/{getItem-CStbsCge.js.map → getItem-DpnPrzl3.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-Bws1mdNc.js → getPublishPayload-CGKMEL3H.js} +11 -11
- package/dist/cjs/{getPublishPayload-Bws1mdNc.js.map → getPublishPayload-CGKMEL3H.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-BNYeCNf_.js → getPublishUploads-DeI0f2UN.js} +4 -4
- package/dist/cjs/{getPublishUploads-BNYeCNf_.js.map → getPublishUploads-DeI0f2UN.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-CkhTBPSP.js → getSegmentedItemProperties-BgS_FhAx.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-CkhTBPSP.js.map → getSegmentedItemProperties-BgS_FhAx.js.map} +1 -1
- package/dist/cjs/{index-BLco2YiE.js → index-BnAqr2le.js} +3 -3
- package/dist/cjs/index-BnAqr2le.js.map +1 -0
- package/dist/cjs/{index-CZ7yR-bZ.js → index-ByozbTn_.js} +50 -38
- package/dist/cjs/index-ByozbTn_.js.map +1 -0
- package/dist/cjs/{ownership-B1I8eLiv.js → ownership-CsWuaNfH.js} +2 -2
- package/dist/cjs/{ownership-B1I8eLiv.js.map → ownership-CsWuaNfH.js.map} +1 -1
- package/dist/cjs/{property-sm3N2yBU.js → property-CeR45LMx.js} +4 -4
- package/dist/cjs/{property-sm3N2yBU.js.map → property-CeR45LMx.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-Dh9HSiwm.js → syncDbWithEas-CA2Lum5V.js} +5 -5
- package/dist/cjs/{syncDbWithEas-Dh9HSiwm.js.map → syncDbWithEas-CA2Lum5V.js.map} +1 -1
- package/dist/debug-default-shim.js +27 -0
- package/dist/{getItem-CdgsloEB.js → getItem-GOXWo_Iy.js} +2 -2
- package/dist/{getItem-CdgsloEB.js.map → getItem-GOXWo_Iy.js.map} +1 -1
- package/dist/{getPublishPayload-DlkHAsOA.js → getPublishPayload-D16enahU.js} +11 -11
- package/dist/{getPublishPayload-DlkHAsOA.js.map → getPublishPayload-D16enahU.js.map} +1 -1
- package/dist/{getPublishUploads-BeukCBiR.js → getPublishUploads-wGqH19UY.js} +4 -4
- package/dist/{getPublishUploads-BeukCBiR.js.map → getPublishUploads-wGqH19UY.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-B_yciZHD.js → getSegmentedItemProperties-Be3kYWY3.js} +3 -3
- package/dist/{getSegmentedItemProperties-B_yciZHD.js.map → getSegmentedItemProperties-Be3kYWY3.js.map} +1 -1
- package/dist/{index-CfZAy_U1.js → index-BFyMxc7e.js} +2 -2
- package/dist/index-BFyMxc7e.js.map +1 -0
- package/dist/{index-C3oIxmh-.js → index-BcXKZQpX.js} +64 -52
- package/dist/index-BcXKZQpX.js.map +1 -0
- package/dist/{index-j0nIoPTo.js → index-C9p-skT3.js} +3 -3
- package/dist/index-C9p-skT3.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +13 -13
- package/dist/node.js +10 -10
- package/dist/{ownership-Br40yugt.js → ownership-C17YhE7J.js} +2 -2
- package/dist/{ownership-Br40yugt.js.map → ownership-C17YhE7J.js.map} +1 -1
- package/dist/{property-DlfKPjHu.js → property-CRAau-Q-.js} +5 -5
- package/dist/{property-DlfKPjHu.js.map → property-CRAau-Q-.js.map} +1 -1
- package/dist/{queries-CIlWKRoN.js → queries-Ct7CcQ3g.js} +2 -2
- package/dist/{queries-CIlWKRoN.js.map → queries-Ct7CcQ3g.js.map} +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/helpers/mediaRef.d.ts.map +1 -1
- package/dist/src/vite/debug-default-shim.d.ts +3 -0
- package/dist/src/vite/debug-default-shim.d.ts.map +1 -0
- package/dist/src/vite/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-Dsa5kEMM.js → syncDbWithEas-CB5aXPtf.js} +6 -6
- package/dist/{syncDbWithEas-Dsa5kEMM.js.map → syncDbWithEas-CB5aXPtf.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-DHDIH0zy.js → updateSeedRevokedAt-BIu5Q4Po.js} +2 -2
- package/dist/{updateSeedRevokedAt-DHDIH0zy.js.map → updateSeedRevokedAt-BIu5Q4Po.js.map} +1 -1
- package/dist/vite.cjs +67 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +67 -1
- package/dist/vite.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/index-BLco2YiE.js.map +0 -1
- package/dist/cjs/index-CZ7yR-bZ.js.map +0 -1
- package/dist/index-C3oIxmh-.js.map +0 -1
- package/dist/index-CfZAy_U1.js.map +0 -1
- package/dist/index-j0nIoPTo.js.map +0 -1
package/dist/vite.cjs
CHANGED
|
@@ -63,6 +63,25 @@ const DEFAULT_FS_MODULES = [
|
|
|
63
63
|
];
|
|
64
64
|
const SDK_DIST_DIR = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.cjs', document.baseURI).href))));
|
|
65
65
|
const ARWEAVE_SHIM_FILE = path.join(SDK_DIST_DIR, 'arweave-default-shim.js');
|
|
66
|
+
const DEBUG_SHIM_FILE = path.join(SDK_DIST_DIR, 'debug-default-shim.js');
|
|
67
|
+
/** Fragile renderer deps pre-bundled for stable CJS/ESM interop (aligned with permapress). */
|
|
68
|
+
const FRAGILE_RENDERER_OPTIMIZE_INCLUDES = [
|
|
69
|
+
'debug',
|
|
70
|
+
'random',
|
|
71
|
+
'seedrandom',
|
|
72
|
+
'@georgedoescode/generative-utils',
|
|
73
|
+
'nanoid-dictionary',
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Always force-include (do not gate on resolvePackageFile): under bun these live nested
|
|
77
|
+
* under @seedprotocol/sdk, and eas-sdk's ESM named-imports CJS eas-contracts. Without
|
|
78
|
+
* prebundling, Vite serves raw /@fs CJS and the browser throws
|
|
79
|
+
* "does not provide an export named 'EAS__factory'" during SchemaEncoder encode.
|
|
80
|
+
*/
|
|
81
|
+
const EAS_OPTIMIZE_INCLUDES = [
|
|
82
|
+
'@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk',
|
|
83
|
+
'@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk > @ethereum-attestation-service/eas-contracts',
|
|
84
|
+
];
|
|
66
85
|
function resolvePackageFile(packageName, relativePath) {
|
|
67
86
|
const candidates = [];
|
|
68
87
|
try {
|
|
@@ -114,6 +133,32 @@ function mergeAliasEntries(existing, additions) {
|
|
|
114
133
|
}
|
|
115
134
|
return merged;
|
|
116
135
|
}
|
|
136
|
+
function addRendererCompatibilityAliases(aliasEntries) {
|
|
137
|
+
const nanoidDictionaryEsm = resolvePackageFile('nanoid-dictionary', 'dist/dictionary.esm.js');
|
|
138
|
+
if (nanoidDictionaryEsm) {
|
|
139
|
+
aliasEntries.push({
|
|
140
|
+
find: /^nanoid-dictionary$/,
|
|
141
|
+
replacement: nanoidDictionaryEsm,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const zenfsCoreIndex = resolvePackageFile('@zenfs/core', 'dist/index.js');
|
|
145
|
+
const zenfsCorePath = resolvePackageFile('@zenfs/core', 'dist/path.js');
|
|
146
|
+
if (zenfsCoreIndex) {
|
|
147
|
+
aliasEntries.push({ find: /^@zenfs\/core$/, replacement: zenfsCoreIndex });
|
|
148
|
+
}
|
|
149
|
+
if (zenfsCorePath) {
|
|
150
|
+
aliasEntries.push({ find: /^@zenfs\/core\/path$/, replacement: zenfsCorePath });
|
|
151
|
+
}
|
|
152
|
+
const zenfsDomIndex = resolvePackageFile('@zenfs/dom', 'dist/index.js');
|
|
153
|
+
if (zenfsDomIndex) {
|
|
154
|
+
aliasEntries.push({ find: /^@zenfs\/dom$/, replacement: zenfsDomIndex });
|
|
155
|
+
}
|
|
156
|
+
if (fs.existsSync(DEBUG_SHIM_FILE)) {
|
|
157
|
+
// Only alias the package root. Do not alias debug/src/browser.js to this shim:
|
|
158
|
+
// the shim imports that path and aliasing it back creates a circular module.
|
|
159
|
+
aliasEntries.push({ find: /^debug$/, replacement: DEBUG_SHIM_FILE });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
117
162
|
/**
|
|
118
163
|
* Minimal Vite plugin to make the SDK work in browser/Electron renderer:
|
|
119
164
|
* - Aliases fs → @zenfs/core (and promises variant)
|
|
@@ -155,6 +200,7 @@ function seedVitePlugin(options = {}) {
|
|
|
155
200
|
if (arweaveBundle) {
|
|
156
201
|
aliasEntries.push({ find: /^arweave$/, replacement: ARWEAVE_SHIM_FILE }, { find: /^arweave\/web\/index\.js$/, replacement: ARWEAVE_SHIM_FILE }, { find: /^arweave\/bundles\/web\.bundle\.js$/, replacement: arweaveBundle });
|
|
157
202
|
}
|
|
203
|
+
addRendererCompatibilityAliases(aliasEntries);
|
|
158
204
|
const existingResolve = userConfig.resolve ?? {};
|
|
159
205
|
const mergedAlias = mergeAliasEntries(normalizeAliasEntries(existingResolve.alias), aliasEntries);
|
|
160
206
|
const desiredOptimizeIncludes = [
|
|
@@ -166,6 +212,7 @@ function seedVitePlugin(options = {}) {
|
|
|
166
212
|
'readable-stream',
|
|
167
213
|
'viem',
|
|
168
214
|
'isows',
|
|
215
|
+
...FRAGILE_RENDERER_OPTIMIZE_INCLUDES,
|
|
169
216
|
];
|
|
170
217
|
const resolvableOptimizeIncludes = desiredOptimizeIncludes.filter((dep) => !!resolvePackageFile(dep, 'package.json'));
|
|
171
218
|
const optimizeDeps = {
|
|
@@ -183,6 +230,7 @@ function seedVitePlugin(options = {}) {
|
|
|
183
230
|
include: [
|
|
184
231
|
...(userConfig.optimizeDeps?.include ?? []),
|
|
185
232
|
...resolvableOptimizeIncludes,
|
|
233
|
+
...EAS_OPTIMIZE_INCLUDES,
|
|
186
234
|
],
|
|
187
235
|
// Keep `global` shim in optimizer esbuild options; top-level Vite `define`
|
|
188
236
|
// can be rejected by Rolldown in some consumer setups.
|
|
@@ -399,7 +447,25 @@ if (!window.__seedFsReady) {
|
|
|
399
447
|
return result + initScript;
|
|
400
448
|
},
|
|
401
449
|
};
|
|
402
|
-
const
|
|
450
|
+
const sdkImportFixPlugin = {
|
|
451
|
+
name: 'seed-protocol:sdk-import-fix',
|
|
452
|
+
enforce: 'post',
|
|
453
|
+
transform(code, id) {
|
|
454
|
+
if (!id.includes('@seedprotocol/sdk') || !id.includes('FileManager')) {
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
const hasDefaultPathBrowserifyImport = /import\s+path\s+from\s+['"]path-browserify['"]/.test(code);
|
|
458
|
+
if (!hasDefaultPathBrowserifyImport) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
const transformed = code.replace(/import\s+path\s+from\s+['"]path-browserify['"];/g, "import * as path from 'path';");
|
|
462
|
+
if (transformed === code) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
return { code: transformed, map: null };
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
const plugins = [configPlugin, mainPlugin, sdkImportFixPlugin];
|
|
403
469
|
if (includeNodePolyfills) {
|
|
404
470
|
plugins.push(vitePluginNodePolyfills.nodePolyfills({
|
|
405
471
|
// Let fs be handled by @zenfs/core instead of polyfills
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","sources":["../../src/vite/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 <script type=\"module\"> 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 * @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[linesBefore.length - 1].length\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')\n\ntype AliasEntry = { find: string | RegExp; replacement: string }\n\nfunction resolvePackageFile(packageName: string, relativePath: string): string | undefined {\n const candidates: string[] = []\n\n try {\n const pkgJson = _req.resolve(`${packageName}/package.json`)\n candidates.push(path.join(path.dirname(pkgJson), relativePath))\n } catch {\n // package may be hoisted/unavailable in this graph\n }\n\n const cwdNodeModules = path.join(process.cwd(), 'node_modules')\n candidates.push(path.join(cwdNodeModules, packageName, relativePath))\n\n const bunDir = path.join(cwdNodeModules, '.bun')\n if (fs.existsSync(bunDir)) {\n for (const entry of fs.readdirSync(bunDir)) {\n if (!entry.startsWith(`${packageName}@`)) continue\n candidates.push(path.join(bunDir, entry, `node_modules/${packageName}`, relativePath))\n }\n }\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return undefined\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/**\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 * - 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. drizzle-kit, 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 }\n\n /**\n * Pre-plugin: configure aliases and optimizeDeps.\n */\n const configPlugin: Plugin = {\n name: 'seed-protocol:config',\n enforce: 'pre',\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 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 ]\n const resolvableOptimizeIncludes = desiredOptimizeIncludes.filter(\n (dep) => !!resolvePackageFile(dep, 'package.json')\n )\n\n const optimizeDeps: UserConfig['optimizeDeps'] = {\n ...(userConfig.optimizeDeps ?? {}),\n exclude: [\n ...(userConfig.optimizeDeps?.exclude ?? []),\n // Do not prebundle the SDK itself or clearly node-only tools\n '@seedprotocol/sdk',\n 'drizzle-kit',\n 'drizzle-orm',\n 'better-sqlite3',\n // sqlocal uses workers and should not be prebundled\n 'sqlocal',\n ],\n include: [\n ...(userConfig.optimizeDeps?.include ?? []),\n ...resolvableOptimizeIncludes,\n ],\n // Keep `global` shim in optimizer esbuild options; top-level Vite `define`\n // can be rejected by Rolldown in some consumer setups.\n esbuildOptions: {\n ...(userConfig.optimizeDeps?.esbuildOptions ?? {}),\n define: {\n ...(userConfig.optimizeDeps?.esbuildOptions?.define ?? {}),\n global: 'globalThis',\n },\n },\n }\n\n return {\n // Apply global → globalThis for Rollup production builds too.\n // optimizeDeps.esbuildOptions.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.PlatformClass / 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 * 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 dev/build tools that should never be bundled\n const nodeOnlyPackages = [\n 'drizzle-kit',\n 'better-sqlite3', // Native SQLite binding (Node.js only)\n // Database drivers that drizzle-kit dynamically imports (should not be bundled)\n '@electric-sql/pglite',\n 'pg',\n 'postgres',\n '@vercel/postgres',\n '@neondatabase/serverless',\n 'mysql2',\n 'mysql2/promise',\n '@planetscale/database',\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 plugins: Plugin[] = [configPlugin, mainPlugin]\n\n if (includeNodePolyfills) {\n log('Including vite-plugin-node-polyfills with default settings')\n plugins.push(\n 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,\n )\n }\n\n return plugins\n}\n"],"names":["createRequire","fileURLToPath","nodePolyfills"],"mappings":";;;;;;;;;AAOA,MAAM,IAAI,GAAGA,yBAAa,CAAC,0PAAe,CAAC;AAiC3C;AACA;AACA,MAAM,yBAAyB,GAA2B;AACxD,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,OAAO,EAAK,sBAAsB;AAClC,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,SAAS,EAAG,wBAAwB;AACpC,IAAA,UAAU,EAAE,yBAAyB;CACtC;AAED;;;;AAIG;AACH,SAAS,uBAAuB,CAAC,IAAY,EAAA;AAC3C,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,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C5D;YAEA,OAAO,MAAM,GAAG,UAAU;QAC5B,CAAC;KACF;AAED,IAAA,MAAM,OAAO,GAAa,CAAC,YAAY,EAAE,UAAU,CAAC;IAEpD,IAAI,oBAAoB,EAAE;AAExB,QAAA,OAAO,CAAC,IAAI,CACVC,qCAAa,CAAC;;YAEZ,OAAO,EAAE,CAAC,UAAU,EAAE;;AAEtB,YAAA,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE;AACpF,YAAA,OAAO,EAAE;AACP,gBAAA,MAAM,EAAE,IAAI;AACZ,gBAAA,MAAM,EAAE,IAAI;AACZ,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAsB,CACxB;IACH;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"vite.cjs","sources":["../../src/vite/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 <script type=\"module\"> 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 * @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[linesBefore.length - 1].length\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 resolvePackageFile(packageName: string, relativePath: string): string | undefined {\n const candidates: string[] = []\n\n try {\n const pkgJson = _req.resolve(`${packageName}/package.json`)\n candidates.push(path.join(path.dirname(pkgJson), relativePath))\n } catch {\n // package may be hoisted/unavailable in this graph\n }\n\n const cwdNodeModules = path.join(process.cwd(), 'node_modules')\n candidates.push(path.join(cwdNodeModules, packageName, relativePath))\n\n const bunDir = path.join(cwdNodeModules, '.bun')\n if (fs.existsSync(bunDir)) {\n for (const entry of fs.readdirSync(bunDir)) {\n if (!entry.startsWith(`${packageName}@`)) continue\n candidates.push(path.join(bunDir, entry, `node_modules/${packageName}`, relativePath))\n }\n }\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return undefined\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\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\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 * - 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. drizzle-kit, 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 }\n\n /**\n * Pre-plugin: configure aliases and optimizeDeps.\n */\n const configPlugin: Plugin = {\n name: 'seed-protocol:config',\n enforce: 'pre',\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\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 optimizeDeps: UserConfig['optimizeDeps'] = {\n ...(userConfig.optimizeDeps ?? {}),\n exclude: [\n ...(userConfig.optimizeDeps?.exclude ?? []),\n // Do not prebundle the SDK itself or clearly node-only tools\n '@seedprotocol/sdk',\n 'drizzle-kit',\n 'drizzle-orm',\n 'better-sqlite3',\n // sqlocal uses workers and should not be prebundled\n 'sqlocal',\n ],\n include: [\n ...(userConfig.optimizeDeps?.include ?? []),\n ...resolvableOptimizeIncludes,\n ...EAS_OPTIMIZE_INCLUDES,\n ],\n // Keep `global` shim in optimizer esbuild options; top-level Vite `define`\n // can be rejected by Rolldown in some consumer setups.\n esbuildOptions: {\n ...(userConfig.optimizeDeps?.esbuildOptions ?? {}),\n define: {\n ...(userConfig.optimizeDeps?.esbuildOptions?.define ?? {}),\n global: 'globalThis',\n },\n },\n }\n\n return {\n // Apply global → globalThis for Rollup production builds too.\n // optimizeDeps.esbuildOptions.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.PlatformClass / 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 * 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 dev/build tools that should never be bundled\n const nodeOnlyPackages = [\n 'drizzle-kit',\n 'better-sqlite3', // Native SQLite binding (Node.js only)\n // Database drivers that drizzle-kit dynamically imports (should not be bundled)\n '@electric-sql/pglite',\n 'pg',\n 'postgres',\n '@vercel/postgres',\n '@neondatabase/serverless',\n 'mysql2',\n 'mysql2/promise',\n '@planetscale/database',\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 plugins.push(\n 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,\n )\n }\n\n return plugins\n}\n"],"names":["createRequire","fileURLToPath","nodePolyfills"],"mappings":";;;;;;;;;AAOA,MAAM,IAAI,GAAGA,yBAAa,CAAC,0PAAe,CAAC;AAiC3C;AACA;AACA,MAAM,yBAAyB,GAA2B;AACxD,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,OAAO,EAAK,sBAAsB;AAClC,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,SAAS,EAAG,wBAAwB;AACpC,IAAA,UAAU,EAAE,yBAAyB;CACtC;AAED;;;;AAIG;AACH,SAAS,uBAAuB,CAAC,IAAY,EAAA;AAC3C,IAAA,O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IAAI;AACZ,gBAAA,MAAM,EAAE,IAAI;AACZ,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAsB,CACxB;IACH;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
package/dist/vite.js
CHANGED
|
@@ -60,6 +60,25 @@ const DEFAULT_FS_MODULES = [
|
|
|
60
60
|
];
|
|
61
61
|
const SDK_DIST_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
62
62
|
const ARWEAVE_SHIM_FILE = path.join(SDK_DIST_DIR, 'arweave-default-shim.js');
|
|
63
|
+
const DEBUG_SHIM_FILE = path.join(SDK_DIST_DIR, 'debug-default-shim.js');
|
|
64
|
+
/** Fragile renderer deps pre-bundled for stable CJS/ESM interop (aligned with permapress). */
|
|
65
|
+
const FRAGILE_RENDERER_OPTIMIZE_INCLUDES = [
|
|
66
|
+
'debug',
|
|
67
|
+
'random',
|
|
68
|
+
'seedrandom',
|
|
69
|
+
'@georgedoescode/generative-utils',
|
|
70
|
+
'nanoid-dictionary',
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Always force-include (do not gate on resolvePackageFile): under bun these live nested
|
|
74
|
+
* under @seedprotocol/sdk, and eas-sdk's ESM named-imports CJS eas-contracts. Without
|
|
75
|
+
* prebundling, Vite serves raw /@fs CJS and the browser throws
|
|
76
|
+
* "does not provide an export named 'EAS__factory'" during SchemaEncoder encode.
|
|
77
|
+
*/
|
|
78
|
+
const EAS_OPTIMIZE_INCLUDES = [
|
|
79
|
+
'@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk',
|
|
80
|
+
'@seedprotocol/sdk > @ethereum-attestation-service/eas-sdk > @ethereum-attestation-service/eas-contracts',
|
|
81
|
+
];
|
|
63
82
|
function resolvePackageFile(packageName, relativePath) {
|
|
64
83
|
const candidates = [];
|
|
65
84
|
try {
|
|
@@ -111,6 +130,32 @@ function mergeAliasEntries(existing, additions) {
|
|
|
111
130
|
}
|
|
112
131
|
return merged;
|
|
113
132
|
}
|
|
133
|
+
function addRendererCompatibilityAliases(aliasEntries) {
|
|
134
|
+
const nanoidDictionaryEsm = resolvePackageFile('nanoid-dictionary', 'dist/dictionary.esm.js');
|
|
135
|
+
if (nanoidDictionaryEsm) {
|
|
136
|
+
aliasEntries.push({
|
|
137
|
+
find: /^nanoid-dictionary$/,
|
|
138
|
+
replacement: nanoidDictionaryEsm,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const zenfsCoreIndex = resolvePackageFile('@zenfs/core', 'dist/index.js');
|
|
142
|
+
const zenfsCorePath = resolvePackageFile('@zenfs/core', 'dist/path.js');
|
|
143
|
+
if (zenfsCoreIndex) {
|
|
144
|
+
aliasEntries.push({ find: /^@zenfs\/core$/, replacement: zenfsCoreIndex });
|
|
145
|
+
}
|
|
146
|
+
if (zenfsCorePath) {
|
|
147
|
+
aliasEntries.push({ find: /^@zenfs\/core\/path$/, replacement: zenfsCorePath });
|
|
148
|
+
}
|
|
149
|
+
const zenfsDomIndex = resolvePackageFile('@zenfs/dom', 'dist/index.js');
|
|
150
|
+
if (zenfsDomIndex) {
|
|
151
|
+
aliasEntries.push({ find: /^@zenfs\/dom$/, replacement: zenfsDomIndex });
|
|
152
|
+
}
|
|
153
|
+
if (fs.existsSync(DEBUG_SHIM_FILE)) {
|
|
154
|
+
// Only alias the package root. Do not alias debug/src/browser.js to this shim:
|
|
155
|
+
// the shim imports that path and aliasing it back creates a circular module.
|
|
156
|
+
aliasEntries.push({ find: /^debug$/, replacement: DEBUG_SHIM_FILE });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
114
159
|
/**
|
|
115
160
|
* Minimal Vite plugin to make the SDK work in browser/Electron renderer:
|
|
116
161
|
* - Aliases fs → @zenfs/core (and promises variant)
|
|
@@ -152,6 +197,7 @@ function seedVitePlugin(options = {}) {
|
|
|
152
197
|
if (arweaveBundle) {
|
|
153
198
|
aliasEntries.push({ find: /^arweave$/, replacement: ARWEAVE_SHIM_FILE }, { find: /^arweave\/web\/index\.js$/, replacement: ARWEAVE_SHIM_FILE }, { find: /^arweave\/bundles\/web\.bundle\.js$/, replacement: arweaveBundle });
|
|
154
199
|
}
|
|
200
|
+
addRendererCompatibilityAliases(aliasEntries);
|
|
155
201
|
const existingResolve = userConfig.resolve ?? {};
|
|
156
202
|
const mergedAlias = mergeAliasEntries(normalizeAliasEntries(existingResolve.alias), aliasEntries);
|
|
157
203
|
const desiredOptimizeIncludes = [
|
|
@@ -163,6 +209,7 @@ function seedVitePlugin(options = {}) {
|
|
|
163
209
|
'readable-stream',
|
|
164
210
|
'viem',
|
|
165
211
|
'isows',
|
|
212
|
+
...FRAGILE_RENDERER_OPTIMIZE_INCLUDES,
|
|
166
213
|
];
|
|
167
214
|
const resolvableOptimizeIncludes = desiredOptimizeIncludes.filter((dep) => !!resolvePackageFile(dep, 'package.json'));
|
|
168
215
|
const optimizeDeps = {
|
|
@@ -180,6 +227,7 @@ function seedVitePlugin(options = {}) {
|
|
|
180
227
|
include: [
|
|
181
228
|
...(userConfig.optimizeDeps?.include ?? []),
|
|
182
229
|
...resolvableOptimizeIncludes,
|
|
230
|
+
...EAS_OPTIMIZE_INCLUDES,
|
|
183
231
|
],
|
|
184
232
|
// Keep `global` shim in optimizer esbuild options; top-level Vite `define`
|
|
185
233
|
// can be rejected by Rolldown in some consumer setups.
|
|
@@ -396,7 +444,25 @@ if (!window.__seedFsReady) {
|
|
|
396
444
|
return result + initScript;
|
|
397
445
|
},
|
|
398
446
|
};
|
|
399
|
-
const
|
|
447
|
+
const sdkImportFixPlugin = {
|
|
448
|
+
name: 'seed-protocol:sdk-import-fix',
|
|
449
|
+
enforce: 'post',
|
|
450
|
+
transform(code, id) {
|
|
451
|
+
if (!id.includes('@seedprotocol/sdk') || !id.includes('FileManager')) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
const hasDefaultPathBrowserifyImport = /import\s+path\s+from\s+['"]path-browserify['"]/.test(code);
|
|
455
|
+
if (!hasDefaultPathBrowserifyImport) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const transformed = code.replace(/import\s+path\s+from\s+['"]path-browserify['"];/g, "import * as path from 'path';");
|
|
459
|
+
if (transformed === code) {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
return { code: transformed, map: null };
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
const plugins = [configPlugin, mainPlugin, sdkImportFixPlugin];
|
|
400
466
|
if (includeNodePolyfills) {
|
|
401
467
|
plugins.push(nodePolyfills({
|
|
402
468
|
// Let fs be handled by @zenfs/core instead of polyfills
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sources":["../../src/vite/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 <script type=\"module\"> 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 * @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[linesBefore.length - 1].length\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')\n\ntype AliasEntry = { find: string | RegExp; replacement: string }\n\nfunction resolvePackageFile(packageName: string, relativePath: string): string | undefined {\n const candidates: string[] = []\n\n try {\n const pkgJson = _req.resolve(`${packageName}/package.json`)\n candidates.push(path.join(path.dirname(pkgJson), relativePath))\n } catch {\n // package may be hoisted/unavailable in this graph\n }\n\n const cwdNodeModules = path.join(process.cwd(), 'node_modules')\n candidates.push(path.join(cwdNodeModules, packageName, relativePath))\n\n const bunDir = path.join(cwdNodeModules, '.bun')\n if (fs.existsSync(bunDir)) {\n for (const entry of fs.readdirSync(bunDir)) {\n if (!entry.startsWith(`${packageName}@`)) continue\n candidates.push(path.join(bunDir, entry, `node_modules/${packageName}`, relativePath))\n }\n }\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return undefined\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/**\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 * - 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. drizzle-kit, 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 }\n\n /**\n * Pre-plugin: configure aliases and optimizeDeps.\n */\n const configPlugin: Plugin = {\n name: 'seed-protocol:config',\n enforce: 'pre',\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 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 ]\n const resolvableOptimizeIncludes = desiredOptimizeIncludes.filter(\n (dep) => !!resolvePackageFile(dep, 'package.json')\n )\n\n const optimizeDeps: UserConfig['optimizeDeps'] = {\n ...(userConfig.optimizeDeps ?? {}),\n exclude: [\n ...(userConfig.optimizeDeps?.exclude ?? []),\n // Do not prebundle the SDK itself or clearly node-only tools\n '@seedprotocol/sdk',\n 'drizzle-kit',\n 'drizzle-orm',\n 'better-sqlite3',\n // sqlocal uses workers and should not be prebundled\n 'sqlocal',\n ],\n include: [\n ...(userConfig.optimizeDeps?.include ?? []),\n ...resolvableOptimizeIncludes,\n ],\n // Keep `global` shim in optimizer esbuild options; top-level Vite `define`\n // can be rejected by Rolldown in some consumer setups.\n esbuildOptions: {\n ...(userConfig.optimizeDeps?.esbuildOptions ?? {}),\n define: {\n ...(userConfig.optimizeDeps?.esbuildOptions?.define ?? {}),\n global: 'globalThis',\n },\n },\n }\n\n return {\n // Apply global → globalThis for Rollup production builds too.\n // optimizeDeps.esbuildOptions.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.PlatformClass / 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 * 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 dev/build tools that should never be bundled\n const nodeOnlyPackages = [\n 'drizzle-kit',\n 'better-sqlite3', // Native SQLite binding (Node.js only)\n // Database drivers that drizzle-kit dynamically imports (should not be bundled)\n '@electric-sql/pglite',\n 'pg',\n 'postgres',\n '@vercel/postgres',\n '@neondatabase/serverless',\n 'mysql2',\n 'mysql2/promise',\n '@planetscale/database',\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 plugins: Plugin[] = [configPlugin, mainPlugin]\n\n if (includeNodePolyfills) {\n log('Including vite-plugin-node-polyfills with default settings')\n plugins.push(\n 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,\n )\n }\n\n return plugins\n}\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAiC3C;AACA;AACA,MAAM,yBAAyB,GAA2B;AACxD,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,OAAO,EAAK,sBAAsB;AAClC,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,SAAS,EAAG,wBAAwB;AACpC,IAAA,UAAU,EAAE,yBAAyB;CACtC;AAED;;;;AAIG;AACH,SAAS,uBAAuB,CAAC,IAAY,EAAA;AAC3C,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,SAAA,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;SACnD,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC3E,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC1E,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAA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A,OAAO,OAAO;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"vite.js","sources":["../../src/vite/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 <script type=\"module\"> 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 * @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[linesBefore.length - 1].length\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 resolvePackageFile(packageName: string, relativePath: string): string | undefined {\n const candidates: string[] = []\n\n try {\n const pkgJson = _req.resolve(`${packageName}/package.json`)\n candidates.push(path.join(path.dirname(pkgJson), relativePath))\n } catch {\n // package may be hoisted/unavailable in this graph\n }\n\n const cwdNodeModules = path.join(process.cwd(), 'node_modules')\n candidates.push(path.join(cwdNodeModules, packageName, relativePath))\n\n const bunDir = path.join(cwdNodeModules, '.bun')\n if (fs.existsSync(bunDir)) {\n for (const entry of fs.readdirSync(bunDir)) {\n if (!entry.startsWith(`${packageName}@`)) continue\n candidates.push(path.join(bunDir, entry, `node_modules/${packageName}`, relativePath))\n }\n }\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return undefined\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\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\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 * - 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. drizzle-kit, 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 }\n\n /**\n * Pre-plugin: configure aliases and optimizeDeps.\n */\n const configPlugin: Plugin = {\n name: 'seed-protocol:config',\n enforce: 'pre',\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\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 optimizeDeps: UserConfig['optimizeDeps'] = {\n ...(userConfig.optimizeDeps ?? {}),\n exclude: [\n ...(userConfig.optimizeDeps?.exclude ?? []),\n // Do not prebundle the SDK itself or clearly node-only tools\n '@seedprotocol/sdk',\n 'drizzle-kit',\n 'drizzle-orm',\n 'better-sqlite3',\n // sqlocal uses workers and should not be prebundled\n 'sqlocal',\n ],\n include: [\n ...(userConfig.optimizeDeps?.include ?? []),\n ...resolvableOptimizeIncludes,\n ...EAS_OPTIMIZE_INCLUDES,\n ],\n // Keep `global` shim in optimizer esbuild options; top-level Vite `define`\n // can be rejected by Rolldown in some consumer setups.\n esbuildOptions: {\n ...(userConfig.optimizeDeps?.esbuildOptions ?? {}),\n define: {\n ...(userConfig.optimizeDeps?.esbuildOptions?.define ?? {}),\n global: 'globalThis',\n },\n },\n }\n\n return {\n // Apply global → globalThis for Rollup production builds too.\n // optimizeDeps.esbuildOptions.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.PlatformClass / 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 * 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 dev/build tools that should never be bundled\n const nodeOnlyPackages = [\n 'drizzle-kit',\n 'better-sqlite3', // Native SQLite binding (Node.js only)\n // Database drivers that drizzle-kit dynamically imports (should not be bundled)\n '@electric-sql/pglite',\n 'pg',\n 'postgres',\n '@vercel/postgres',\n '@neondatabase/serverless',\n 'mysql2',\n 'mysql2/promise',\n '@planetscale/database',\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 plugins.push(\n 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,\n )\n }\n\n return plugins\n}\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAiC3C;AACA;AACA,MAAM,yBAAyB,GAA2B;AACxD,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,OAAO,EAAK,sBAAsB;AAClC,IAAA,MAAM,EAAM,qBAAqB;AACjC,IAAA,SAAS,EAAG,wBAAwB;AACpC,IAAA,UAAU,EAAE,yBAAyB;CACtC;AAED;;;;AAIG;AACH,SAAS,uBAAuB,CAAC,IAAY,EAAA;AAC3C,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,SAAA,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;SACnD,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC3E,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC1E,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC,KAAK,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8B,GAClC,gDAAgD,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7D,IAAI,CAAC,8BAA8B,EAAE;AACnC,gBAAA,OAAO,IAAI;YACb;YACA,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAC9B,kDAAkD,EAClD,+BAA+B,CAChC;AACD,YAAA,IAAI,WAAW,KAAK,IAAI,EAAE;AACxB,gBAAA,OAAO,IAAI;YACb;YACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE;QACzC,CAAC;KACF;IAED,MAAM,OAAO,GAAa,CAAC,YAAY,EAAE,UAAU,EAAE,kBAAkB,CAAC;IAExE,IAAI,oBAAoB,EAAE;AAExB,QAAA,OAAO,CAAC,IAAI,CACV,aAAa,CAAC;;YAEZ,OAAO,EAAE,CAAC,UAAU,EAAE;;AAEtB,YAAA,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE;AACpF,YAAA,OAAO,EAAE;AACP,gBAAA,MAAM,EAAE,IAAI;AACZ,gBAAA,MAAM,EAAE,IAAI;AACZ,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAsB,CACxB;IACH;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seedprotocol/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"description": "The SDK for Seed Protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.cjs",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "node ../../scripts/build-with-tests.js \"tsc -p packages/sdk/tsconfig.declarations.json && node scripts/rewrite-dts-alias-to-relative.js\"",
|
|
17
17
|
"build:watch": "tsc -w -p tsconfig.json",
|
|
18
|
-
"build:dev": "node ../../scripts/build-with-tests.js \"cd packages/sdk && rm -rf dist && NODE_ENV=production rollup -c && node ../../scripts/check-dist-fragile-dynamic-imports.js --fail && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-dts-alias-to-relative.js && node ../../scripts/check-dist-no-alias.js\"",
|
|
19
|
-
"build:publish": "node ../../scripts/build-with-tests.js \"bun run sync-versions && cd packages/sdk && rm -rf dist && NODE_ENV=production rollup -c && node ../../scripts/check-dist-fragile-dynamic-imports.js --fail && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-dts-alias-to-relative.js && node ../../scripts/check-dist-no-alias.js\"",
|
|
18
|
+
"build:dev": "node ../../scripts/build-with-tests.js \"cd packages/sdk && rm -rf dist && NODE_ENV=production rollup -c && node ../../scripts/check-dist-fragile-dynamic-imports.js --fail && node ../../scripts/check-dist-fragile-imports.js --fail && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-dts-alias-to-relative.js && node ../../scripts/check-dist-no-alias.js\"",
|
|
19
|
+
"build:publish": "node ../../scripts/build-with-tests.js \"bun run sync-versions && cd packages/sdk && rm -rf dist && NODE_ENV=production rollup -c && node ../../scripts/check-dist-fragile-dynamic-imports.js --fail && node ../../scripts/check-dist-fragile-imports.js --fail && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-dts-alias-to-relative.js && node ../../scripts/check-dist-no-alias.js\"",
|
|
20
20
|
"compile": "graphql-codegen --config codegen.ts",
|
|
21
21
|
"watch": "graphql-codegen -w",
|
|
22
22
|
"test": "vitest run --reporter=default",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"use-immer": "^0.11.0",
|
|
82
82
|
"use-isomorphic-layout-effect": "^1.2.1",
|
|
83
83
|
"use-sync-external-store": "^1.6.0",
|
|
84
|
-
"vite-plugin-node-polyfills": "^0.
|
|
84
|
+
"vite-plugin-node-polyfills": "^0.25.0",
|
|
85
85
|
"webpack": "^5.98.0",
|
|
86
86
|
"xstate": "^5.28.0"
|
|
87
87
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BLco2YiE.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|