@n6k.io/serve 0.2.2 → 0.2.3
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 +1 -1
- package/src/bundle.ts +1 -0
- package/src/cli.ts +3 -1
- package/src/css.ts +1 -1
- package/src/root.tsx +6 -1
package/package.json
CHANGED
package/src/bundle.ts
CHANGED
package/src/cli.ts
CHANGED
|
@@ -67,6 +67,7 @@ if (positionals[0] === "sql") {
|
|
|
67
67
|
fail(USAGE);
|
|
68
68
|
await servePage(
|
|
69
69
|
path.join(SRC_DIR, "sql", values.console ? "console.mdx" : "editor.mdx"),
|
|
70
|
+
true,
|
|
70
71
|
);
|
|
71
72
|
} else if (values.mcp) {
|
|
72
73
|
if (
|
|
@@ -84,7 +85,7 @@ if (positionals[0] === "sql") {
|
|
|
84
85
|
servePages(values.pages);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
async function servePage(arg: string): Promise<void> {
|
|
88
|
+
async function servePage(arg: string, bare = false): Promise<void> {
|
|
88
89
|
const mdxPath = path.resolve(arg);
|
|
89
90
|
if (!mdxPath.endsWith(".mdx")) fail(`${arg}: not an .mdx file`);
|
|
90
91
|
if (!existsSync(mdxPath)) fail(`${arg}: no such file`);
|
|
@@ -101,6 +102,7 @@ async function servePage(arg: string): Promise<void> {
|
|
|
101
102
|
bundlePage(mdxPath, {
|
|
102
103
|
data: Object.fromEntries(entries.map(([a, s]) => [a, s.url])),
|
|
103
104
|
tokens: Object.fromEntries(entries.map(([a, s]) => [a, s.token])),
|
|
105
|
+
bare,
|
|
104
106
|
}),
|
|
105
107
|
buildCss(mdxPath),
|
|
106
108
|
]);
|
package/src/css.ts
CHANGED
|
@@ -14,7 +14,7 @@ export async function buildCss(mdxPath: string): Promise<string> {
|
|
|
14
14
|
const base = readFileSync(path.join(SRC_DIR, "globals.css"), "utf8");
|
|
15
15
|
await Bun.write(
|
|
16
16
|
input,
|
|
17
|
-
`${base}\n@source ${JSON.stringify(path.dirname(mdxPath))};\n`,
|
|
17
|
+
`${base}\n@source ${JSON.stringify(SRC_DIR)};\n@source ${JSON.stringify(path.dirname(mdxPath))};\n`,
|
|
18
18
|
);
|
|
19
19
|
const proc = Bun.spawn([TAILWIND, "-i", input, "-o", output], {
|
|
20
20
|
stdout: "ignore",
|
package/src/root.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { duckdbBundle } from "virtual:n6k-duckdb-bundle";
|
|
|
4
4
|
import { N6kDuckDB, type DatabaseSpec, type SocketSpec } from "@n6k.io/db";
|
|
5
5
|
import { DuckDBProvider, QueryProvider } from "@n6k.io/ui/duckdb";
|
|
6
6
|
import { ConnectionLost, DuckDBConnectionGuard } from "@n6k.io/runtime";
|
|
7
|
+
import { Page } from "@n6k.io/ui/components";
|
|
7
8
|
|
|
8
9
|
function engine(
|
|
9
10
|
data: Record<string, string>,
|
|
@@ -31,16 +32,20 @@ export default function Root({
|
|
|
31
32
|
children,
|
|
32
33
|
data = {},
|
|
33
34
|
tokens = {},
|
|
35
|
+
bare = false,
|
|
34
36
|
}: {
|
|
35
37
|
children: ReactNode;
|
|
36
38
|
data?: Record<string, string>;
|
|
37
39
|
tokens?: Record<string, string>;
|
|
40
|
+
bare?: boolean;
|
|
38
41
|
}) {
|
|
39
42
|
const [duckdb] = useState(() => engine(data, tokens));
|
|
40
43
|
return (
|
|
41
44
|
<QueryProvider>
|
|
42
45
|
<DuckDBProvider connect={duckdb.connect} metadataFns={duckdb.metadataFns}>
|
|
43
|
-
<DuckDBConnectionGuard>
|
|
46
|
+
<DuckDBConnectionGuard>
|
|
47
|
+
{bare ? children : <Page>{children}</Page>}
|
|
48
|
+
</DuckDBConnectionGuard>
|
|
44
49
|
<ConnectionLost duckdb={duckdb} />
|
|
45
50
|
</DuckDBProvider>
|
|
46
51
|
</QueryProvider>
|