@n6k.io/build 0.0.3 → 0.0.4
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/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Virtual module provided by the `bundleN6kWorkers` Vite plugin (src/vite/workers.ts).
|
|
2
|
+
// Resolves to the DuckDB worker script URLs: stable `/_n6k/workers/*` paths in
|
|
3
|
+
// dev, content-hashed `assets/*-[hash].js` URLs in a production/static build.
|
|
4
|
+
declare module "virtual:n6k-workers" {
|
|
5
|
+
export const duckdbWorkerUrl: string;
|
|
6
|
+
export const fetchWorkerUrl: string;
|
|
7
|
+
export const wsWorkerUrl: string;
|
|
8
|
+
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { useMemo, type ReactNode } from "react";
|
|
2
2
|
import { DuckDBProvider } from "@n6k.io/db/react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
duckdbWorkerUrl,
|
|
5
|
+
fetchWorkerUrl,
|
|
6
|
+
wsWorkerUrl,
|
|
7
|
+
} from "virtual:n6k-workers";
|
|
4
8
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
9
|
|
|
10
|
+
// Worker URLs come from the `bundleN6kWorkers` Vite plugin's virtual module —
|
|
11
|
+
// the same source the real app (v3's DuckDBProviderClient) uses. This is what
|
|
12
|
+
// makes the workers actually ship: in a static build the plugin only emits the
|
|
13
|
+
// content-hashed worker assets when `virtual:n6k-workers` is imported. The old
|
|
14
|
+
// `N6K_DEFAULT_WORKER_URLS` resolved the canonical `/_n6k/workers/*` paths,
|
|
15
|
+
// which exist only via the dev middleware — so a static Storybook (GitHub Pages)
|
|
16
|
+
// 404'd on every worker. Dev still resolves those same stable paths here.
|
|
17
|
+
const duckdbOptions = {
|
|
18
|
+
fetchWorkerUrl,
|
|
19
|
+
duckdbWorkerUrl,
|
|
20
|
+
wsWorkerUrl,
|
|
21
|
+
};
|
|
22
|
+
|
|
6
23
|
/**
|
|
7
24
|
* The provider stack every n6k story needs: a fresh react-query client and a
|
|
8
|
-
* DuckDB-WASM context.
|
|
9
|
-
* manifest (`N6K_DEFAULT_WORKER_URLS`) rather than being hardcoded, so they can
|
|
10
|
-
* never drift from what the `bundleN6kWorkers` Vite middleware actually serves.
|
|
25
|
+
* DuckDB-WASM context.
|
|
11
26
|
*/
|
|
12
27
|
export function StoryShell({ children }: { children: ReactNode }) {
|
|
13
28
|
const queryClient = useMemo(() => new QueryClient(), []);
|
|
14
29
|
return (
|
|
15
30
|
<QueryClientProvider client={queryClient}>
|
|
16
|
-
<DuckDBProvider duckdbOptions={
|
|
17
|
-
{children}
|
|
18
|
-
</DuckDBProvider>
|
|
31
|
+
<DuckDBProvider duckdbOptions={duckdbOptions}>{children}</DuckDBProvider>
|
|
19
32
|
</QueryClientProvider>
|
|
20
33
|
);
|
|
21
34
|
}
|