@braincrew-lab/langchain-canvas 0.1.3 → 0.1.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/dist/index.js +21 -4
- package/dist/styles.css +6 -3
- package/package.json +22 -16
package/dist/index.js
CHANGED
|
@@ -1553,10 +1553,11 @@ function HtmlRenderer({ artifact: artifact2 }) {
|
|
|
1553
1553
|
const lastSelfHtml = useRef(null);
|
|
1554
1554
|
const srcDocRef = useRef("");
|
|
1555
1555
|
const srcDoc = useMemo(() => {
|
|
1556
|
-
if (artifact2.data.html === lastSelfHtml.current) return srcDocRef.current;
|
|
1556
|
+
if (mode === "design" && artifact2.data.html === lastSelfHtml.current) return srcDocRef.current;
|
|
1557
1557
|
srcDocRef.current = withInspector(artifact2.data.html);
|
|
1558
|
+
lastSelfHtml.current = null;
|
|
1558
1559
|
return srcDocRef.current;
|
|
1559
|
-
}, [artifact2.data.html]);
|
|
1560
|
+
}, [artifact2.data.html, mode]);
|
|
1560
1561
|
const selected = selections.filter((s) => s.artifactId === artifact2.id);
|
|
1561
1562
|
const single = selected.length === 1 ? selected[0] : null;
|
|
1562
1563
|
useEffect(() => {
|
|
@@ -2528,18 +2529,34 @@ function EmptyState({ onOpenFiles }) {
|
|
|
2528
2529
|
] })
|
|
2529
2530
|
] });
|
|
2530
2531
|
}
|
|
2531
|
-
var
|
|
2532
|
+
var TYPE_META = {
|
|
2532
2533
|
html: { icon: "\u{1F310}", label: "Web page" },
|
|
2533
2534
|
document: { icon: "\u{1F4C4}", label: "Word document" },
|
|
2534
2535
|
chart: { icon: "\u{1F4CA}", label: "Chart" },
|
|
2535
2536
|
table: { icon: "\u{1F522}", label: "Excel sheet" },
|
|
2536
2537
|
slides: { icon: "\u{1F4FD}\uFE0F", label: "PowerPoint deck" }
|
|
2537
2538
|
};
|
|
2539
|
+
var KIND_META = {
|
|
2540
|
+
web: TYPE_META.html,
|
|
2541
|
+
html: TYPE_META.html,
|
|
2542
|
+
document: TYPE_META.document,
|
|
2543
|
+
doc: TYPE_META.document,
|
|
2544
|
+
chart: TYPE_META.chart,
|
|
2545
|
+
table: TYPE_META.table,
|
|
2546
|
+
sheet: TYPE_META.table,
|
|
2547
|
+
slide: TYPE_META.slides,
|
|
2548
|
+
slides: TYPE_META.slides
|
|
2549
|
+
};
|
|
2550
|
+
function resolveCardMeta(artifact2) {
|
|
2551
|
+
const kind = typeof artifact2.meta?.kind === "string" ? artifact2.meta.kind : void 0;
|
|
2552
|
+
const byKind = kind ? KIND_META[kind] : void 0;
|
|
2553
|
+
return byKind ?? TYPE_META[artifact2.type] ?? { icon: "\u{1F4CE}", label: artifact2.type };
|
|
2554
|
+
}
|
|
2538
2555
|
function ArtifactCard({ artifactId }) {
|
|
2539
2556
|
const artifact2 = useCanvasStore((s) => s.canvas.artifacts[artifactId]);
|
|
2540
2557
|
const setActive = useCanvasStore((s) => s.setActiveArtifact);
|
|
2541
2558
|
if (!artifact2) return null;
|
|
2542
|
-
const meta =
|
|
2559
|
+
const meta = resolveCardMeta(artifact2);
|
|
2543
2560
|
return /* @__PURE__ */ jsxs("button", { className: "cv-card", onClick: () => setActive(artifact2.id), title: "Open on the canvas", children: [
|
|
2544
2561
|
/* @__PURE__ */ jsx("span", { className: "cv-card__icon", children: meta.icon }),
|
|
2545
2562
|
/* @__PURE__ */ jsxs("span", { className: "cv-card__meta", children: [
|
package/dist/styles.css
CHANGED
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
|
|
209
209
|
/* --- body --------------------------------------------------------------------- */
|
|
210
210
|
|
|
211
|
-
.cv-body { flex: 1; overflow: auto; padding: 24px; }
|
|
211
|
+
.cv-body { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
|
|
212
212
|
.cv-body--flush { padding: 0; overflow: hidden; }
|
|
213
213
|
.cv-fallback { color: var(--cv-muted); font-size: 14px; }
|
|
214
214
|
|
|
@@ -750,7 +750,7 @@
|
|
|
750
750
|
|
|
751
751
|
/* --- html renderer (base substrate) ------------------------------------------- */
|
|
752
752
|
|
|
753
|
-
.cv-html-wrap { display: flex; flex-direction: column; height: 100%; gap: 10px; }
|
|
753
|
+
.cv-html-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 10px; }
|
|
754
754
|
.cv-html-bar {
|
|
755
755
|
display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
|
|
756
756
|
padding: 7px 9px; border: 1px solid var(--cv-border); border-radius: 9px; background: var(--cv-surface);
|
|
@@ -807,7 +807,10 @@
|
|
|
807
807
|
.cv-html {
|
|
808
808
|
width: 100%;
|
|
809
809
|
height: 100%;
|
|
810
|
-
|
|
810
|
+
/* Fill the (now height-bounded) stage exactly so the sandboxed page scrolls
|
|
811
|
+
inside the iframe. A forced min-height would push the iframe taller than the
|
|
812
|
+
stage and defeat the stage's overflow, so the panel couldn't scroll at all. */
|
|
813
|
+
min-height: 0;
|
|
811
814
|
border: 0;
|
|
812
815
|
border-radius: 10px;
|
|
813
816
|
background: #fff;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@braincrew-lab/langchain-canvas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A live canvas for LangChain agents — stream documents, charts, and rich artifacts into a React panel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,17 +18,29 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"comment": "Dev resolves to source (no build needed; Next transpiles via transpilePackages). publishConfig swaps to dist for npm.",
|
|
21
|
-
"main": "./
|
|
22
|
-
"types": "./
|
|
21
|
+
"main": "./src/index.ts",
|
|
22
|
+
"types": "./src/index.ts",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
|
|
26
|
-
"import": "./dist/index.js"
|
|
27
|
-
},
|
|
28
|
-
"./styles.css": "./dist/styles.css"
|
|
24
|
+
".": "./src/index.ts",
|
|
25
|
+
"./styles.css": "./src/styles/canvas.css"
|
|
29
26
|
},
|
|
30
27
|
"publishConfig": {
|
|
31
|
-
"access": "public"
|
|
28
|
+
"access": "public",
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./styles.css": "./dist/styles.css"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "vitest run"
|
|
32
44
|
},
|
|
33
45
|
"peerDependencies": {
|
|
34
46
|
"react": "^18 || ^19",
|
|
@@ -53,11 +65,5 @@
|
|
|
53
65
|
"tsup": "^8.2.4",
|
|
54
66
|
"typescript": "^5.5.4",
|
|
55
67
|
"vitest": "^2"
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"build": "tsup",
|
|
59
|
-
"dev": "tsup --watch",
|
|
60
|
-
"typecheck": "tsc --noEmit",
|
|
61
|
-
"test": "vitest run"
|
|
62
68
|
}
|
|
63
|
-
}
|
|
69
|
+
}
|