@seedprotocol/next 0.0.0-stage → 0.7.7-next.988.g7046e66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -2
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -4
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @seedprotocol/next
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@seedprotocol/next)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Next.js config helper for apps that use [`@seedprotocol/sdk`](https://www.npmjs.com/package/@seedprotocol/sdk) in the browser. It works with Turbopack (the Next.js 16 default) and webpack.
|
|
7
|
+
|
|
8
|
+
Use the SDK only in the browser in a Next.js app: in client components, initialized through `SeedClientGate` or `client.init()` in an effect. Server-side use (route handlers, server components reading seeds) isn't supported.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @seedprotocol/sdk @seedprotocol/react @zenfs/core@2.5.6 @zenfs/dom@1.2.9
|
|
14
|
+
npm install -D @seedprotocol/next
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pin the ZenFS versions the SDK declares so only one copy is installed. `next` 15.5 or later is a peer dependency.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// next.config.mjs
|
|
23
|
+
import { withSeed } from '@seedprotocol/next'
|
|
24
|
+
|
|
25
|
+
export default withSeed({
|
|
26
|
+
// your Next.js config
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`withSeed` also accepts a config function and returns one. `@seedprotocol/react` is a client module, so `app/layout.tsx` can render `SeedProvider` directly:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
// app/layout.tsx
|
|
34
|
+
import { SeedProvider } from '@seedprotocol/react'
|
|
35
|
+
|
|
36
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
37
|
+
return (
|
|
38
|
+
<html lang="en">
|
|
39
|
+
<body>
|
|
40
|
+
<SeedProvider>{children}</SeedProvider>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Pass `SeedClientGate` an `onInitError` callback from a client component; a server component can't pass functions.
|
|
48
|
+
|
|
49
|
+
## What it configures
|
|
50
|
+
|
|
51
|
+
- **Browser entries in every graph**: Next.js also bundles client components for server rendering, where Node conditions would pick the SDK's Node platform (libsql and native bindings) and `@seedprotocol/query`'s Node entry. `withSeed` points both at their browser builds in server and client graphs, so server builds don't bundle libsql or trace the whole project.
|
|
52
|
+
- **Cross-origin isolation headers** through `headers()`: `Cross-Origin-Opener-Policy: same-origin`, `Cross-Origin-Embedder-Policy: credentialless` and `Cross-Origin-Resource-Policy: same-origin` on `/:path*`. They apply under `next dev` and `next start`.
|
|
53
|
+
|
|
54
|
+
Your own aliases, `webpack` function and headers are kept. Where they set the same alias or header, yours win.
|
|
55
|
+
|
|
56
|
+
## Options
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
withSeed(nextConfig, {
|
|
60
|
+
isolationHeaders: true,
|
|
61
|
+
headersSource: '/:path*',
|
|
62
|
+
fsModules: [],
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Option | Default | Description |
|
|
67
|
+
|--------|---------|-------------|
|
|
68
|
+
| `isolationHeaders` | `true` | `false` adds no headers; `{ coop, coep, corp }` overrides individual values. |
|
|
69
|
+
| `headersSource` | `'/:path*'` | Path pattern the headers apply to, in `headers()` `source` syntax. |
|
|
70
|
+
| `fsModules` | `[]` | Modules aliased to ZenFS (`@zenfs/core`, or `@zenfs/core/promises` for ids containing "promises") in browser builds, for app code or other dependencies that import `fs` in the browser. The SDK doesn't. For example `['fs', 'fs/promises', 'node:fs', 'node:fs/promises']`. Server builds keep Node's `fs`. |
|
|
71
|
+
|
|
72
|
+
The options type is exported as `SeedNextOptions`.
|
|
73
|
+
|
|
74
|
+
## Next.js 15
|
|
75
|
+
|
|
76
|
+
Next.js 15 works with webpack: `next build`, and `next dev` without `--turbopack`. Remove `--turbopack` from your dev script if `create-next-app` added it. Under Next.js 15's Turbopack, SQLite WASM can't load in the browser (Turbopack starts workers from `blob:` URLs and gives SQLite a WASM URL that can't be resolved there), so the SDK fails to initialize; `withSeed` logs a warning when it detects that setup.
|
|
77
|
+
|
|
78
|
+
## Production hosting
|
|
79
|
+
|
|
80
|
+
`next start` sends the headers. A static export (`output: 'export'`) has no Next.js server, so your host must send `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: credentialless` (or `require-corp`) on the HTML documents.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NextConfig } from 'next';
|
|
2
|
+
export interface SeedNextOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Cross-origin isolation headers for SQLite WASM, SharedArrayBuffer and OPFS, sent on every
|
|
5
|
+
* path matched by `headersSource`. Set `false` to disable, or pass `{ coop, coep, corp }` to
|
|
6
|
+
* override values. A COOP/COEP/CORP header your own `headers()` sets for a path wins.
|
|
7
|
+
* @default true (`COOP: same-origin`, `COEP: credentialless`, `CORP: same-origin`)
|
|
8
|
+
*/
|
|
9
|
+
isolationHeaders?: boolean | {
|
|
10
|
+
coop?: string;
|
|
11
|
+
coep?: string;
|
|
12
|
+
corp?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Path pattern the isolation headers apply to, in Next.js `headers()` `source` syntax.
|
|
16
|
+
* @default '/:path*'
|
|
17
|
+
*/
|
|
18
|
+
headersSource?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Modules aliased to ZenFS in browser builds (`@zenfs/core`, or `@zenfs/core/promises` for
|
|
21
|
+
* ids containing "promises"), for app code or dependencies that import Node's `fs` in the
|
|
22
|
+
* browser. The SDK's browser build doesn't. Server builds keep Node's `fs`.
|
|
23
|
+
* @default []
|
|
24
|
+
*/
|
|
25
|
+
fsModules?: string[];
|
|
26
|
+
}
|
|
27
|
+
type NextConfigFunction = (phase: string, context: {
|
|
28
|
+
defaultConfig: NextConfig;
|
|
29
|
+
}) => NextConfig | Promise<NextConfig>;
|
|
30
|
+
/**
|
|
31
|
+
* Add the config @seedprotocol/sdk needs in the browser to a Next.js config: its browser
|
|
32
|
+
* entries in every graph and cross-origin isolation headers, plus any `fsModules` aliased to
|
|
33
|
+
* ZenFS in browser builds. Your own aliases, `webpack` function and headers are kept, and win
|
|
34
|
+
* where they overlap.
|
|
35
|
+
*
|
|
36
|
+
* Accepts a config object or a config function, and returns the same kind.
|
|
37
|
+
*/
|
|
38
|
+
export declare function withSeed(nextConfig?: NextConfig, options?: SeedNextOptions): NextConfig;
|
|
39
|
+
export declare function withSeed(nextConfig: NextConfigFunction, options?: SeedNextOptions): NextConfigFunction;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAOtC,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,gBAAgB,CAAC,EACb,OAAO,GACP;QACE,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IAEL;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,KAAK,kBAAkB,GAAG,CACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,aAAa,EAAE,UAAU,CAAA;CAAE,KACnC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAIrC;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,CAAA;AACxF,wBAAgB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import e from "node:fs";
|
|
2
|
+
import { createRequire as t } from "node:module";
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
//#region ../bundler-core/dist/index.js
|
|
5
|
+
function r(e) {
|
|
6
|
+
return e.includes("promises") ? "@zenfs/core/promises" : "@zenfs/core";
|
|
7
|
+
}
|
|
8
|
+
var i = {
|
|
9
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
10
|
+
"Cross-Origin-Embedder-Policy": "credentialless",
|
|
11
|
+
"Cross-Origin-Resource-Policy": "same-origin"
|
|
12
|
+
};
|
|
13
|
+
function a(e) {
|
|
14
|
+
if (e === !1) return null;
|
|
15
|
+
let t = typeof e == "object" && e ? e : {};
|
|
16
|
+
return {
|
|
17
|
+
"Cross-Origin-Opener-Policy": t.coop ?? i["Cross-Origin-Opener-Policy"],
|
|
18
|
+
"Cross-Origin-Embedder-Policy": t.coep ?? i["Cross-Origin-Embedder-Policy"],
|
|
19
|
+
"Cross-Origin-Resource-Policy": t.corp ?? i["Cross-Origin-Resource-Policy"]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function o(e, t) {
|
|
23
|
+
let n = new Set(Object.keys(t ?? {}).map((e) => e.toLowerCase()));
|
|
24
|
+
return Object.fromEntries(Object.entries(e).filter(([e]) => !n.has(e.toLowerCase())));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/index.ts
|
|
28
|
+
function s(e = {}, t = {}) {
|
|
29
|
+
return f(), typeof e == "function" ? async (n, r) => c(await e(n, r), t) : c(e, t);
|
|
30
|
+
}
|
|
31
|
+
function c(e, t) {
|
|
32
|
+
let n = t.fsModules ?? [], i = a(t.isolationHeaders), s = t.headersSource ?? "/:path*", c = {};
|
|
33
|
+
for (let e of n) c[e] = { browser: r(e) };
|
|
34
|
+
let d = l(), f = Object.fromEntries(Object.entries(d).map(([e, t]) => [e, u(t)])), p = e.webpack, m = e.headers;
|
|
35
|
+
return {
|
|
36
|
+
...e,
|
|
37
|
+
turbopack: {
|
|
38
|
+
...e.turbopack,
|
|
39
|
+
resolveAlias: {
|
|
40
|
+
...f,
|
|
41
|
+
...c,
|
|
42
|
+
...e.turbopack?.resolveAlias
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
webpack(e, t) {
|
|
46
|
+
let i = p ? p(e, t) : e, a = i.resolve?.alias ?? {}, o = {};
|
|
47
|
+
for (let [e, t] of Object.entries(d)) {
|
|
48
|
+
let n = e.startsWith("#") ? e : `${e}$`;
|
|
49
|
+
!(n in a) && !(e in a) && (o[n] = t);
|
|
50
|
+
}
|
|
51
|
+
if (!t.isServer) for (let e of n) e in a || (o[e] = r(e));
|
|
52
|
+
return i.resolve = {
|
|
53
|
+
...i.resolve,
|
|
54
|
+
alias: {
|
|
55
|
+
...o,
|
|
56
|
+
...a
|
|
57
|
+
}
|
|
58
|
+
}, i;
|
|
59
|
+
},
|
|
60
|
+
...i || m ? { async headers() {
|
|
61
|
+
let e = m ? await m() : [];
|
|
62
|
+
if (!i) return e;
|
|
63
|
+
let t = e.filter((e) => e.source === s).flatMap((e) => e.headers), n = Object.fromEntries(t.map((e) => [e.key, e.value])), r = Object.entries(o(i, n)).map(([e, t]) => ({
|
|
64
|
+
key: e,
|
|
65
|
+
value: t
|
|
66
|
+
}));
|
|
67
|
+
return r.length > 0 ? [{
|
|
68
|
+
source: s,
|
|
69
|
+
headers: r
|
|
70
|
+
}, ...e] : e;
|
|
71
|
+
} } : {}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function l() {
|
|
75
|
+
let e = {}, r;
|
|
76
|
+
try {
|
|
77
|
+
r = t(n.join(process.cwd(), "package.json")).resolve("@seedprotocol/sdk/package.json");
|
|
78
|
+
} catch {
|
|
79
|
+
return e;
|
|
80
|
+
}
|
|
81
|
+
e["#seed-node-platform"] = n.join(n.dirname(r), "dist", "platform.browser.js");
|
|
82
|
+
try {
|
|
83
|
+
let i = t(r).resolve("@seedprotocol/query/package.json");
|
|
84
|
+
e["@seedprotocol/query"] = n.join(n.dirname(i), "dist", "index.js");
|
|
85
|
+
} catch {}
|
|
86
|
+
return e;
|
|
87
|
+
}
|
|
88
|
+
function u(t) {
|
|
89
|
+
let r = n.relative(e.realpathSync(process.cwd()), t).split(n.sep).join("/");
|
|
90
|
+
return r.startsWith(".") ? r : `./${r}`;
|
|
91
|
+
}
|
|
92
|
+
var d = !1;
|
|
93
|
+
function f() {
|
|
94
|
+
d || process.env.TURBOPACK !== "1" || p() === 15 && (d = !0, console.warn("[@seedprotocol/next] Next.js 15 with Turbopack cannot load SQLite WASM in the browser, so the Seed SDK will fail to initialize. Run `next dev` and `next build` without --turbopack (webpack), or upgrade to Next.js 16."));
|
|
95
|
+
}
|
|
96
|
+
function p() {
|
|
97
|
+
try {
|
|
98
|
+
let { version: e } = t(n.join(process.cwd(), "package.json"))("next/package.json");
|
|
99
|
+
return Number(e.split(".")[0]);
|
|
100
|
+
} catch {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { s as withSeed };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["fs","path","zenfsModuleFor","fsModule","DEFAULT_ISOLATION_HEADERS","resolveIsolationHeaders","option","overrides","isolationHeadersNotSetBy","userKeys","headers","key","isolationHeaders","withSeed","warnIfNext15Turbopack","nextConfig","applySeedConfig","phase","context","options","fsModules","headersSource","browserFsAliases","mod","browserEntries","resolveBrowserEntries","browserEntryAliases","specifier","file","turbopackPath","userWebpack","userHeaders","result","config","existing","added","user","userSameSource","rule","header","ours","value","entries","sdkPackageJson","createRequire","queryPackageJson","relative","absolutePath","warnedNext15Turbopack","nextMajorVersion","version"],"sources":["../../bundler-core/dist/index.js","../src/index.ts"],"sourcesContent":["/**\n * Settings shared by the Seed bundler integrations (@seedprotocol/vite, @seedprotocol/next).\n * Each package inlines this module at build time, so keep it dependency-free.\n */\n/** The ZenFS module an aliased `fs` specifier resolves to. */\nexport function zenfsModuleFor(fsModule) {\n return fsModule.includes('promises') ? '@zenfs/core/promises' : '@zenfs/core';\n}\n/** Cross-origin isolation headers SQLite WASM, SharedArrayBuffer and OPFS need. */\nexport const DEFAULT_ISOLATION_HEADERS = {\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless',\n 'Cross-Origin-Resource-Policy': 'same-origin',\n};\n/** Header name to value, or `null` when the option disables the headers. */\nexport function resolveIsolationHeaders(option) {\n if (option === false)\n return null;\n const overrides = typeof option === 'object' && option ? option : {};\n return {\n 'Cross-Origin-Opener-Policy': overrides.coop ?? DEFAULT_ISOLATION_HEADERS['Cross-Origin-Opener-Policy'],\n 'Cross-Origin-Embedder-Policy': overrides.coep ?? DEFAULT_ISOLATION_HEADERS['Cross-Origin-Embedder-Policy'],\n 'Cross-Origin-Resource-Policy': overrides.corp ?? DEFAULT_ISOLATION_HEADERS['Cross-Origin-Resource-Policy'],\n };\n}\n/**\n * Isolation headers the user has not set in `headers` (case-insensitive), so an\n * integration can add them without replacing the user's values.\n */\nexport function isolationHeadersNotSetBy(isolationHeaders, headers) {\n const userKeys = new Set(Object.keys(headers ?? {}).map((key) => key.toLowerCase()));\n return Object.fromEntries(Object.entries(isolationHeaders).filter(([key]) => !userKeys.has(key.toLowerCase())));\n}\n/**\n * The isolation headers to send: the user's `headers` value where they set one, else ours.\n */\nexport function effectiveIsolationHeaders(isolationHeaders, headers) {\n const userValues = new Map(Object.entries(headers ?? {}).map(([key, value]) => [key.toLowerCase(), value]));\n return Object.fromEntries(Object.entries(isolationHeaders).map(([key, value]) => {\n const userValue = userValues.get(key.toLowerCase());\n return [key, userValue == null ? value : String(userValue)];\n }));\n}\n//# sourceMappingURL=index.js.map","import fs from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport type { NextConfig } from 'next'\nimport {\n isolationHeadersNotSetBy,\n resolveIsolationHeaders,\n zenfsModuleFor,\n} from '@seedprotocol/bundler-core'\n\nexport interface SeedNextOptions {\n /**\n * Cross-origin isolation headers for SQLite WASM, SharedArrayBuffer and OPFS, sent on every\n * path matched by `headersSource`. Set `false` to disable, or pass `{ coop, coep, corp }` to\n * override values. A COOP/COEP/CORP header your own `headers()` sets for a path wins.\n * @default true (`COOP: same-origin`, `COEP: credentialless`, `CORP: same-origin`)\n */\n isolationHeaders?:\n | boolean\n | {\n coop?: string\n coep?: string\n corp?: string\n }\n\n /**\n * Path pattern the isolation headers apply to, in Next.js `headers()` `source` syntax.\n * @default '/:path*'\n */\n headersSource?: string\n\n /**\n * Modules aliased to ZenFS in browser builds (`@zenfs/core`, or `@zenfs/core/promises` for\n * ids containing \"promises\"), for app code or dependencies that import Node's `fs` in the\n * browser. The SDK's browser build doesn't. Server builds keep Node's `fs`.\n * @default []\n */\n fsModules?: string[]\n}\n\ntype NextConfigFunction = (\n phase: string,\n context: { defaultConfig: NextConfig },\n) => NextConfig | Promise<NextConfig>\n\ntype TurbopackResolveAlias = NonNullable<NonNullable<NextConfig['turbopack']>['resolveAlias']>\n\n/**\n * Add the config @seedprotocol/sdk needs in the browser to a Next.js config: its browser\n * entries in every graph and cross-origin isolation headers, plus any `fsModules` aliased to\n * ZenFS in browser builds. Your own aliases, `webpack` function and headers are kept, and win\n * where they overlap.\n *\n * Accepts a config object or a config function, and returns the same kind.\n */\nexport function withSeed(nextConfig?: NextConfig, options?: SeedNextOptions): NextConfig\nexport function withSeed(nextConfig: NextConfigFunction, options?: SeedNextOptions): NextConfigFunction\nexport function withSeed(\n nextConfig: NextConfig | NextConfigFunction = {},\n options: SeedNextOptions = {},\n): NextConfig | NextConfigFunction {\n warnIfNext15Turbopack()\n if (typeof nextConfig === 'function') {\n return async (phase, context) => applySeedConfig(await nextConfig(phase, context), options)\n }\n return applySeedConfig(nextConfig, options)\n}\n\nfunction applySeedConfig(nextConfig: NextConfig, options: SeedNextOptions): NextConfig {\n const fsModules = options.fsModules ?? []\n const isolationHeaders = resolveIsolationHeaders(options.isolationHeaders)\n const headersSource = options.headersSource ?? '/:path*'\n\n const browserFsAliases: TurbopackResolveAlias = {}\n for (const mod of fsModules) browserFsAliases[mod] = { browser: zenfsModuleFor(mod) }\n\n // The SDK is browser-only in Next apps, but Next also bundles client components for server\n // rendering, where Node conditions pick the SDK's Node platform (libsql, native bindings) and\n // @seedprotocol/query's Node entry (a disk cache). That breaks webpack server builds and Next 15\n // Turbopack builds, and makes Next trace the whole project. Point them at their browser entries\n // in every graph; init never runs on the server.\n const browserEntries = resolveBrowserEntries()\n const browserEntryAliases: TurbopackResolveAlias = Object.fromEntries(\n Object.entries(browserEntries).map(([specifier, file]) => [specifier, turbopackPath(file)]),\n )\n\n const userWebpack = nextConfig.webpack\n const userHeaders = nextConfig.headers\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n // The user's aliases come last, so they replace ours for the same specifier.\n resolveAlias: { ...browserEntryAliases, ...browserFsAliases, ...nextConfig.turbopack?.resolveAlias },\n },\n webpack(config, context) {\n const result = userWebpack ? userWebpack(config, context) : config\n const existing = result.resolve?.alias ?? {}\n const added: Record<string, string> = {}\n for (const [specifier, file] of Object.entries(browserEntries)) {\n // `$` makes a webpack alias exact, so `@seedprotocol/query/node` keeps resolving normally.\n const key = specifier.startsWith('#') ? specifier : `${specifier}$`\n if (!(key in existing) && !(specifier in existing)) added[key] = file\n }\n if (!context.isServer) {\n for (const mod of fsModules) {\n if (!(mod in existing)) added[mod] = zenfsModuleFor(mod)\n }\n }\n result.resolve = { ...result.resolve, alias: { ...added, ...existing } }\n return result\n },\n ...(isolationHeaders || userHeaders\n ? {\n async headers() {\n const user = userHeaders ? await userHeaders() : []\n if (!isolationHeaders) return user\n // Next.js applies every matching rule and a later rule's value wins for the same\n // key, so ours go first. Also drop ours where a user rule for the same source sets\n // the header, which keeps the response clean for the common '/:path*' case.\n const userSameSource = user\n .filter((rule) => rule.source === headersSource)\n .flatMap((rule) => rule.headers)\n const userKeys = Object.fromEntries(userSameSource.map((header) => [header.key, header.value]))\n const ours = Object.entries(isolationHeadersNotSetBy(isolationHeaders, userKeys)).map(\n ([key, value]) => ({ key, value }),\n )\n return ours.length > 0 ? [{ source: headersSource, headers: ours }, ...user] : user\n },\n }\n : {}),\n }\n}\n\n/**\n * Specifier to absolute file of the browser entries the SDK imports, as installed for this app:\n * the SDK's browser platform for `#seed-node-platform`, and `@seedprotocol/query`'s browser\n * build, resolved from the SDK so it's the copy the SDK uses. Empty when the SDK isn't installed.\n */\nfunction resolveBrowserEntries(): Record<string, string> {\n const entries: Record<string, string> = {}\n let sdkPackageJson: string\n try {\n sdkPackageJson = createRequire(path.join(process.cwd(), 'package.json')).resolve('@seedprotocol/sdk/package.json')\n } catch {\n return entries\n }\n entries['#seed-node-platform'] = path.join(path.dirname(sdkPackageJson), 'dist', 'platform.browser.js')\n try {\n const queryPackageJson = createRequire(sdkPackageJson).resolve('@seedprotocol/query/package.json')\n entries['@seedprotocol/query'] = path.join(path.dirname(queryPackageJson), 'dist', 'index.js')\n } catch {\n // The SDK depends on query; without it the app has bigger problems than this alias.\n }\n return entries\n}\n\n/**\n * Turbopack's resolveAlias takes project-relative paths, not absolute ones. require.resolve\n * returns real paths, so compare against the real cwd (macOS temp and home dirs can be symlinks).\n */\nfunction turbopackPath(absolutePath: string): string {\n const relative = path.relative(fs.realpathSync(process.cwd()), absolutePath).split(path.sep).join('/')\n return relative.startsWith('.') ? relative : `./${relative}`\n}\n\nlet warnedNext15Turbopack = false\n\n/**\n * Next.js 15's Turbopack starts workers from blob: URLs and hands SQLite a root-relative WASM\n * URL, which can't be resolved there, so the SDK's database never opens. Next 15 sets\n * TURBOPACK=1 before it loads next.config for `--turbopack` dev and build runs.\n */\nfunction warnIfNext15Turbopack(): void {\n if (warnedNext15Turbopack || process.env.TURBOPACK !== '1') return\n const major = nextMajorVersion()\n if (major !== 15) return\n warnedNext15Turbopack = true\n console.warn(\n '[@seedprotocol/next] Next.js 15 with Turbopack cannot load SQLite WASM in the browser, so the ' +\n 'Seed SDK will fail to initialize. Run `next dev` and `next build` without --turbopack (webpack), ' +\n 'or upgrade to Next.js 16.',\n )\n}\n\nfunction nextMajorVersion(): number | undefined {\n try {\n const require = createRequire(path.join(process.cwd(), 'package.json'))\n const { version } = require('next/package.json') as { version: string }\n return Number(version.split('.')[0])\n } catch {\n return undefined\n }\n}\n"],"mappings":";;;;AAKA,SAAgBE,EAAe,GAAU;CACrC,OAAOC,EAAS,SAAS,UAAU,IAAI,yBAAyB;AACpE;AAEA,IAAaC,IAA4B;CACrC,8BAA8B;CAC9B,gCAAgC;CAChC,gCAAgC;AACpC;AAEA,SAAgBC,EAAwB,GAAQ;CAC5C,IAAIC,MAAW,IACX,OAAO;CACX,IAAMC,IAAY,OAAOD,KAAW,YAAYA,IAASA,IAAS,CAAC;CACnE,OAAO;EACH,8BAA8BC,EAAU,QAAQH,EAA0B;EAC1E,gCAAgCG,EAAU,QAAQH,EAA0B;EAC5E,gCAAgCG,EAAU,QAAQH,EAA0B;CAChF;AACJ;AAKA,SAAgBI,EAAyB,GAAkB,GAAS;CAChE,IAAMC,IAAW,IAAI,IAAI,OAAO,KAAKC,KAAW,CA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EAAQ,yBAAyB1C,EAAK,KAAKA,EAAK,QAAQ4C,CAAgB,GAAG,QAAQ,UAAU;CAC/F,QAAQ,CAER;CACA,OAAOH;AACT;AAMA,SAASb,EAAc,GAA8B;CACnD,IAAMiB,IAAW7C,EAAK,SAASD,EAAG,aAAa,QAAQ,IAAI,CAAC,GAAG+C,CAAY,CAAC,CAAC,MAAM9C,EAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACrG,OAAO6C,EAAS,WAAW,GAAG,IAAIA,IAAW,KAAKA;AACpD;AAEA,IAAIE,IAAwB;AAO5B,SAASlC,IAA8B;CACrC,AAAIkC,KAAyB,QAAQ,IAAI,cAAc,OACzCC,EACV,MAAU,OACd,IAAwB,IACxB,QAAQ,KACN,0NAGF;AACF;AAEA,SAASA,IAAuC;CAC9C,IAAI;EAEF,IAAM,EAAE,eADQL,EAAc3C,EAAK,KAAK,QAAQ,IAAI,GAAG,cAAc,CACjD,CAAA,CAAQ,mBAAmB;EAC/C,OAAO,OAAOiD,EAAQ,MAAM,GAAG,CAAC,CAAC,EAAE;CACrC,QAAQ;EACN;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seedprotocol/next",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.7-next.988.g7046e66",
|
|
4
|
+
"description": "Next.js config helper for apps that use @seedprotocol/sdk in the browser: ZenFS fs aliases for Turbopack and webpack, and cross-origin isolation headers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"seed-protocol",
|
|
7
|
+
"nextjs",
|
|
8
|
+
"next",
|
|
9
|
+
"turbopack",
|
|
10
|
+
"webpack",
|
|
11
|
+
"zenfs",
|
|
12
|
+
"opfs",
|
|
13
|
+
"sqlite-wasm",
|
|
14
|
+
"cross-origin-isolation"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json && vite build",
|
|
37
|
+
"test": "vitest run --reporter=default",
|
|
38
|
+
"prepublishOnly": "bun run build && node ../../scripts/sync-versions.js"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"next": ">=15.5.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@seedprotocol/bundler-core": "0.7.7-next.988.g7046e66",
|
|
45
|
+
"@seedprotocol/react": "0.7.7-next.988.g7046e66",
|
|
46
|
+
"@seedprotocol/sdk": "0.7.7-next.988.g7046e66",
|
|
47
|
+
"@types/node": "^24.10.1",
|
|
48
|
+
"@zenfs/core": "2.5.6",
|
|
49
|
+
"@zenfs/dom": "1.2.9",
|
|
50
|
+
"next": "16.4.2",
|
|
51
|
+
"react": "^19.0.0",
|
|
52
|
+
"react-dom": "^19.0.0",
|
|
53
|
+
"rimraf": "^6.0.1",
|
|
54
|
+
"typescript": "~5.9.3",
|
|
55
|
+
"vite": "^8.0.0",
|
|
56
|
+
"vitest": "^4.1.11"
|
|
57
|
+
},
|
|
58
|
+
"author": "Keith Axline <keith@journodao.xyz>",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/JournoLabs/seed-protocol-sdk.git",
|
|
63
|
+
"directory": "packages/next"
|
|
64
|
+
},
|
|
65
|
+
"homepage": "https://github.com/JournoLabs/seed-protocol-sdk/tree/main/packages/next#readme",
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/JournoLabs/seed-protocol-sdk/issues"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
}
|
|
72
|
+
}
|