@timbal-ai/timbal-react 0.5.4 → 0.6.0
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 +128 -4
- package/dist/app.cjs +5311 -0
- package/dist/app.d.cts +29 -0
- package/dist/app.d.ts +29 -0
- package/dist/app.esm.js +81 -0
- package/dist/chart-artifact-C71dk4xI.d.ts +329 -0
- package/dist/chart-artifact-CPEpOmtV.d.cts +329 -0
- package/dist/chat-CWtQWDtJ.d.cts +650 -0
- package/dist/chat-CWtQWDtJ.d.ts +650 -0
- package/dist/chat.cjs +4162 -0
- package/dist/chat.d.cts +13 -0
- package/dist/chat.d.ts +13 -0
- package/dist/chat.esm.js +51 -0
- package/dist/chunk-4TCJQSIX.esm.js +565 -0
- package/dist/chunk-IYENDIRY.esm.js +119 -0
- package/dist/chunk-KC5QLVUG.esm.js +22 -0
- package/dist/chunk-M4V6Q6XO.esm.js +1082 -0
- package/dist/chunk-OFHLFNJH.esm.js +138 -0
- package/dist/chunk-OVHR7J3J.esm.js +1574 -0
- package/dist/chunk-WLTW56MC.esm.js +66 -0
- package/dist/chunk-YJQLLFKP.esm.js +3672 -0
- package/dist/index.cjs +1823 -359
- package/dist/index.d.cts +15 -931
- package/dist/index.d.ts +15 -931
- package/dist/index.esm.js +187 -5578
- package/dist/layout-B9VayJhZ.d.cts +75 -0
- package/dist/layout-CQWngNQ7.d.ts +75 -0
- package/dist/studio.cjs +5734 -0
- package/dist/studio.d.cts +15 -0
- package/dist/studio.d.ts +15 -0
- package/dist/studio.esm.js +27 -0
- package/dist/styles.css +52 -2
- package/dist/timbal-v2-button-F4-z7m33.d.cts +40 -0
- package/dist/timbal-v2-button-F4-z7m33.d.ts +40 -0
- package/dist/ui.cjs +720 -0
- package/dist/ui.d.cts +74 -0
- package/dist/ui.d.ts +74 -0
- package/dist/ui.esm.js +44 -0
- package/dist/welcome--80i_O0p.d.cts +190 -0
- package/dist/welcome-BOizSp5h.d.ts +190 -0
- package/package.json +35 -3
- package/scripts/dev-linked.mjs +66 -0
- package/vite/local-dev.d.ts +4 -0
- package/vite/local-dev.mjs +71 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Run `bun run build:watch` in timbal-react, then a consumer dev server.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node scripts/dev-linked.mjs [consumerDir] [devCommand ...]
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* node scripts/dev-linked.mjs vite
|
|
10
|
+
* node scripts/dev-linked.mjs examples/app-kit vite
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
const timbalReactRoot = path.resolve(
|
|
18
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
19
|
+
"..",
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
let consumerDir = process.cwd();
|
|
24
|
+
let devArgs = args;
|
|
25
|
+
|
|
26
|
+
if (args[0]) {
|
|
27
|
+
const candidate = path.resolve(timbalReactRoot, args[0]);
|
|
28
|
+
if (existsSync(path.join(candidate, "package.json"))) {
|
|
29
|
+
consumerDir = candidate;
|
|
30
|
+
devArgs = args.slice(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const devCmd = devArgs[0] ?? "vite";
|
|
35
|
+
const devCmdArgs = devArgs.slice(1);
|
|
36
|
+
|
|
37
|
+
function run(cmd, args, opts) {
|
|
38
|
+
return spawn(cmd, args, {
|
|
39
|
+
cwd: opts.cwd,
|
|
40
|
+
stdio: "inherit",
|
|
41
|
+
shell: process.platform === "win32",
|
|
42
|
+
env: process.env,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log("[timbal-react] building + watching dist…");
|
|
47
|
+
const watch = run("bun", ["run", "build:watch"], { cwd: timbalReactRoot });
|
|
48
|
+
|
|
49
|
+
console.log(`[consumer] (${consumerDir}) ${devCmd} ${devCmdArgs.join(" ")}`.trim());
|
|
50
|
+
const app = run(devCmd, devCmdArgs, { cwd: consumerDir });
|
|
51
|
+
|
|
52
|
+
let exiting = false;
|
|
53
|
+
function shutdown(code = 0) {
|
|
54
|
+
if (exiting) return;
|
|
55
|
+
exiting = true;
|
|
56
|
+
watch.kill("SIGTERM");
|
|
57
|
+
app.kill("SIGTERM");
|
|
58
|
+
process.exit(code);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
process.on("SIGINT", () => shutdown(0));
|
|
62
|
+
process.on("SIGTERM", () => shutdown(0));
|
|
63
|
+
watch.on("exit", (code) => {
|
|
64
|
+
if (code) shutdown(code);
|
|
65
|
+
});
|
|
66
|
+
app.on("exit", (code) => shutdown(code ?? 0));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin for apps that depend on `@timbal-ai/timbal-react` via `file:../timbal-react`.
|
|
3
|
+
*
|
|
4
|
+
* - Skips pre-bundling so `dist/` updates are not stuck in `node_modules/.vite/deps`
|
|
5
|
+
* - Watches the linked package `dist/` and triggers a full reload when it changes
|
|
6
|
+
*/
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
|
|
11
|
+
const TIMBAL_REACT_EXPORTS = [
|
|
12
|
+
"@timbal-ai/timbal-react",
|
|
13
|
+
"@timbal-ai/timbal-react/chat",
|
|
14
|
+
"@timbal-ai/timbal-react/studio",
|
|
15
|
+
"@timbal-ai/timbal-react/ui",
|
|
16
|
+
"@timbal-ai/timbal-react/app",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function resolveLinkedPackageRoot() {
|
|
20
|
+
try {
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
const pkgJson = require.resolve("@timbal-ai/timbal-react/package.json");
|
|
23
|
+
return path.dirname(pkgJson);
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @returns {import('vite').Plugin} */
|
|
30
|
+
export function timbalReactLocalDev() {
|
|
31
|
+
/** @type {string | null} */
|
|
32
|
+
let distDir = null;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: "timbal-react-local-dev",
|
|
36
|
+
enforce: "pre",
|
|
37
|
+
config() {
|
|
38
|
+
const pkgRoot = resolveLinkedPackageRoot();
|
|
39
|
+
if (!pkgRoot) return {};
|
|
40
|
+
|
|
41
|
+
distDir = path.join(pkgRoot, "dist");
|
|
42
|
+
const distGlob = `${distDir.replace(/\\/g, "/")}/**`;
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
optimizeDeps: {
|
|
46
|
+
exclude: TIMBAL_REACT_EXPORTS,
|
|
47
|
+
},
|
|
48
|
+
server: {
|
|
49
|
+
watch: {
|
|
50
|
+
ignored: ["**/.git/**", "**/node_modules/**", `!${distGlob}`],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
handleHotUpdate({ file, server }) {
|
|
56
|
+
if (!distDir || !file.startsWith(distDir)) return;
|
|
57
|
+
|
|
58
|
+
for (const mod of server.moduleGraph.idToModuleMap.values()) {
|
|
59
|
+
if (
|
|
60
|
+
mod.id?.includes("@timbal-ai/timbal-react") ||
|
|
61
|
+
mod.id?.includes(`${path.sep}timbal-react${path.sep}dist`)
|
|
62
|
+
) {
|
|
63
|
+
server.moduleGraph.invalidateModule(mod);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
server.ws.send({ type: "full-reload" });
|
|
68
|
+
return [];
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|