@kohaku-ui/renderer-wc 0.1.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/LICENSE +201 -0
- package/README.md +18 -0
- package/dist/dom.d.ts +23 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +132 -0
- package/dist/dom.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/kohaku-surface.d.ts +42 -0
- package/dist/kohaku-surface.d.ts.map +1 -0
- package/dist/kohaku-surface.js +157 -0
- package/dist/kohaku-surface.js.map +1 -0
- package/dist/parts/action-button.d.ts +8 -0
- package/dist/parts/action-button.d.ts.map +1 -0
- package/dist/parts/action-button.js +38 -0
- package/dist/parts/action-button.js.map +1 -0
- package/dist/parts/chart-svg.d.ts +21 -0
- package/dist/parts/chart-svg.d.ts.map +1 -0
- package/dist/parts/chart-svg.js +181 -0
- package/dist/parts/chart-svg.js.map +1 -0
- package/dist/parts/chart.d.ts +9 -0
- package/dist/parts/chart.d.ts.map +1 -0
- package/dist/parts/chart.js +107 -0
- package/dist/parts/chart.js.map +1 -0
- package/dist/parts/control-select.d.ts +9 -0
- package/dist/parts/control-select.d.ts.map +1 -0
- package/dist/parts/control-select.js +56 -0
- package/dist/parts/control-select.js.map +1 -0
- package/dist/parts/form.d.ts +10 -0
- package/dist/parts/form.d.ts.map +1 -0
- package/dist/parts/form.js +346 -0
- package/dist/parts/form.js.map +1 -0
- package/dist/parts/kit.d.ts +25 -0
- package/dist/parts/kit.d.ts.map +1 -0
- package/dist/parts/kit.js +41 -0
- package/dist/parts/kit.js.map +1 -0
- package/dist/parts/layout.d.ts +6 -0
- package/dist/parts/layout.d.ts.map +1 -0
- package/dist/parts/layout.js +29 -0
- package/dist/parts/layout.js.map +1 -0
- package/dist/parts/list.d.ts +8 -0
- package/dist/parts/list.d.ts.map +1 -0
- package/dist/parts/list.js +60 -0
- package/dist/parts/list.js.map +1 -0
- package/dist/parts/loading.d.ts +7 -0
- package/dist/parts/loading.d.ts.map +1 -0
- package/dist/parts/loading.js +37 -0
- package/dist/parts/loading.js.map +1 -0
- package/dist/parts/metric.d.ts +11 -0
- package/dist/parts/metric.d.ts.map +1 -0
- package/dist/parts/metric.js +37 -0
- package/dist/parts/metric.js.map +1 -0
- package/dist/parts/overlay.d.ts +20 -0
- package/dist/parts/overlay.d.ts.map +1 -0
- package/dist/parts/overlay.js +131 -0
- package/dist/parts/overlay.js.map +1 -0
- package/dist/parts/spreadsheet.d.ts +11 -0
- package/dist/parts/spreadsheet.d.ts.map +1 -0
- package/dist/parts/spreadsheet.js +206 -0
- package/dist/parts/spreadsheet.js.map +1 -0
- package/dist/parts/tabs.d.ts +11 -0
- package/dist/parts/tabs.d.ts.map +1 -0
- package/dist/parts/tabs.js +109 -0
- package/dist/parts/tabs.js.map +1 -0
- package/dist/parts/text.d.ts +9 -0
- package/dist/parts/text.d.ts.map +1 -0
- package/dist/parts/text.js +72 -0
- package/dist/parts/text.js.map +1 -0
- package/dist/registry.d.ts +8 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +38 -0
- package/dist/registry.js.map +1 -0
- package/dist/sandbox-mount.d.ts +10 -0
- package/dist/sandbox-mount.d.ts.map +1 -0
- package/dist/sandbox-mount.js +73 -0
- package/dist/sandbox-mount.js.map +1 -0
- package/dist/tree.d.ts +24 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +156 -0
- package/dist/tree.js.map +1 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { parseMarkdownBlocks } from "@kohaku-ui/renderer-core";
|
|
2
|
+
import { el, text } from "../dom.js";
|
|
3
|
+
import { tokenStr } from "./kit.js";
|
|
4
|
+
/** text.heading — a heading (same markup as renderer-react's TextHeading). */
|
|
5
|
+
export const textHeading = (rt, parent, node) => {
|
|
6
|
+
const level = Math.min(6, Math.max(1, node.props["level"] ?? 2));
|
|
7
|
+
const color = tokenStr(rt, "color.text");
|
|
8
|
+
const heading = el(`h${level}`, { "data-kohaku": node.id }, { margin: 0, color, fontWeight: 650, lineHeight: 1.3 });
|
|
9
|
+
heading.appendChild(text(String(node.props["text"] ?? "")));
|
|
10
|
+
parent.appendChild(heading);
|
|
11
|
+
return () => heading.remove();
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* presentMarkdown — zero-dependency rendering of a Markdown subset (same as renderer-react's PresentMarkdown).
|
|
15
|
+
* The AST is shared via renderer-core's parseMarkdownBlocks / parseMarkdownInline (empty text segments are also preserved).
|
|
16
|
+
*/
|
|
17
|
+
export const presentMarkdown = (rt, parent, node) => {
|
|
18
|
+
const markdown = String(node.props["markdown"] ?? "");
|
|
19
|
+
const color = tokenStr(rt, "color.text");
|
|
20
|
+
const muted = tokenStr(rt, "color.muted");
|
|
21
|
+
const surface = tokenStr(rt, "color.surface");
|
|
22
|
+
const container = el("div", { "data-kohaku": node.id }, { color, fontSize: 14, lineHeight: 1.7 });
|
|
23
|
+
for (const block of parseMarkdownBlocks(markdown)) {
|
|
24
|
+
if (block.type === "code") {
|
|
25
|
+
const pre = el("pre", {}, { background: surface, borderRadius: 6, padding: "10px 12px", overflowX: "auto", fontSize: 12.5 });
|
|
26
|
+
const code = el("code");
|
|
27
|
+
code.appendChild(text(block.code));
|
|
28
|
+
pre.appendChild(code);
|
|
29
|
+
container.appendChild(pre);
|
|
30
|
+
}
|
|
31
|
+
else if (block.type === "heading") {
|
|
32
|
+
const h = el(`h${block.level}`, {}, { margin: "8px 0 4px", fontWeight: 650 });
|
|
33
|
+
appendInline(h, block.inline, surface);
|
|
34
|
+
container.appendChild(h);
|
|
35
|
+
}
|
|
36
|
+
else if (block.type === "list") {
|
|
37
|
+
const ul = el("ul", {}, { margin: "4px 0", paddingLeft: 20 });
|
|
38
|
+
for (const item of block.items) {
|
|
39
|
+
const li = el("li");
|
|
40
|
+
appendInline(li, item, surface);
|
|
41
|
+
ul.appendChild(li);
|
|
42
|
+
}
|
|
43
|
+
container.appendChild(ul);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const p = el("p", {}, { margin: "4px 0", ...(block.muted ? { color: muted } : {}) });
|
|
47
|
+
appendInline(p, block.inline, surface);
|
|
48
|
+
container.appendChild(p);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
parent.appendChild(container);
|
|
52
|
+
return () => container.remove();
|
|
53
|
+
};
|
|
54
|
+
/** Flows the inline AST into an element (emits a node even for empty text to keep textContent matching). */
|
|
55
|
+
function appendInline(host, inline, surface) {
|
|
56
|
+
for (const part of inline) {
|
|
57
|
+
if (part.type === "code") {
|
|
58
|
+
const code = el("code", {}, { background: surface, borderRadius: 4, padding: "1px 5px", fontSize: 12.5 });
|
|
59
|
+
code.appendChild(text(part.text));
|
|
60
|
+
host.appendChild(code);
|
|
61
|
+
}
|
|
62
|
+
else if (part.type === "strong") {
|
|
63
|
+
const strong = el("strong");
|
|
64
|
+
strong.appendChild(text(part.text));
|
|
65
|
+
host.appendChild(strong);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
host.appendChild(text(part.text));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/parts/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAgB,CAAC,EAA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I,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC5B,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PartBuilder } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* DOM builder table for core-catalog parts (the counterpart to renderer-react's createCoreRegistry).
|
|
4
|
+
* type → PartBuilder. <kohaku-surface> uses this table to detect unknown types and emits a placeholder if absent.
|
|
5
|
+
* sandbox.html is handled not by the registry but directly by tree.ts via rt.mountSandbox (equivalent to renderSandbox).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createCoreRenderRegistry(): Map<string, PartBuilder>;
|
|
8
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAmBnE"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { actionButton } from "./parts/action-button.js";
|
|
2
|
+
import { presentChart } from "./parts/chart.js";
|
|
3
|
+
import { controlSelect } from "./parts/control-select.js";
|
|
4
|
+
import { presentForm } from "./parts/form.js";
|
|
5
|
+
import { layoutGrid, layoutStack } from "./parts/layout.js";
|
|
6
|
+
import { presentList } from "./parts/list.js";
|
|
7
|
+
import { uiLoading } from "./parts/loading.js";
|
|
8
|
+
import { presentMetric } from "./parts/metric.js";
|
|
9
|
+
import { overlayDialog, overlayToast } from "./parts/overlay.js";
|
|
10
|
+
import { presentSpreadsheet } from "./parts/spreadsheet.js";
|
|
11
|
+
import { layoutTab, layoutTabs } from "./parts/tabs.js";
|
|
12
|
+
import { presentMarkdown, textHeading } from "./parts/text.js";
|
|
13
|
+
/**
|
|
14
|
+
* DOM builder table for core-catalog parts (the counterpart to renderer-react's createCoreRegistry).
|
|
15
|
+
* type → PartBuilder. <kohaku-surface> uses this table to detect unknown types and emits a placeholder if absent.
|
|
16
|
+
* sandbox.html is handled not by the registry but directly by tree.ts via rt.mountSandbox (equivalent to renderSandbox).
|
|
17
|
+
*/
|
|
18
|
+
export function createCoreRenderRegistry() {
|
|
19
|
+
return new Map([
|
|
20
|
+
["layout.stack", layoutStack],
|
|
21
|
+
["layout.grid", layoutGrid],
|
|
22
|
+
["layout.tabs", layoutTabs],
|
|
23
|
+
["layout.tab", layoutTab],
|
|
24
|
+
["text.heading", textHeading],
|
|
25
|
+
["presentMarkdown", presentMarkdown],
|
|
26
|
+
["presentChart", presentChart],
|
|
27
|
+
["presentMetric", presentMetric],
|
|
28
|
+
["presentSpreadsheet", presentSpreadsheet],
|
|
29
|
+
["presentList", presentList],
|
|
30
|
+
["presentForm", presentForm],
|
|
31
|
+
["action.button", actionButton],
|
|
32
|
+
["control.select", controlSelect],
|
|
33
|
+
["ui.loading", uiLoading],
|
|
34
|
+
["overlay.dialog", overlayDialog],
|
|
35
|
+
["overlay.toast", overlayToast],
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,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,CAAC,eAAe,EAAE,YAAY,CAAC;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentNode } from "@kohaku-ui/spec-core";
|
|
2
|
+
import type { RenderRuntime, Teardown } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* WC wrapper for the sandbox.html node (equivalent to renderer-react's SandboxFrame; a ~30-line bridge).
|
|
5
|
+
* mountSandbox is already raw-DOM and framework-free, so it is called directly against the container inside the shadow root.
|
|
6
|
+
* The capability token stays with the parent of ctx.sandbox.bridge and never enters the iframe (reusing the sandbox design unmodified).
|
|
7
|
+
* Bridges the invalidation-bus subscription to SandboxHandle.invalidate, conveying the write loop's data invalidation to the guest.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mountSandboxNode(rt: RenderRuntime, parent: ParentNode, node: ComponentNode): Teardown;
|
|
10
|
+
//# sourceMappingURL=sandbox-mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-mount.d.ts","sourceRoot":"","sources":["../src/sandbox-mount.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,GAAG,QAAQ,CAiErG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { sandboxArtifactMissingText, sandboxBadgeDescriptionStyle, sandboxBadgeDescriptionText, sandboxBadgePillStyle, sandboxBadgeRowStyle, sandboxBadgeText, sandboxBridgeMissingText, sandboxErrorNoticeText, sandboxLoadingNoticeText, sandboxNoticeBaseStyle, sandboxNoticeToneStyle, } from "@kohaku-ui/renderer-core";
|
|
2
|
+
import { mountSandbox } from "@kohaku-ui/sandbox";
|
|
3
|
+
import { el, noop, text } from "./dom.js";
|
|
4
|
+
/**
|
|
5
|
+
* WC wrapper for the sandbox.html node (equivalent to renderer-react's SandboxFrame; a ~30-line bridge).
|
|
6
|
+
* mountSandbox is already raw-DOM and framework-free, so it is called directly against the container inside the shadow root.
|
|
7
|
+
* The capability token stays with the parent of ctx.sandbox.bridge and never enters the iframe (reusing the sandbox design unmodified).
|
|
8
|
+
* Bridges the invalidation-bus subscription to SandboxHandle.invalidate, conveying the write loop's data invalidation to the guest.
|
|
9
|
+
*/
|
|
10
|
+
export function mountSandboxNode(rt, parent, node) {
|
|
11
|
+
const wrapper = el("div", { "data-kohaku": node.id }, { width: "100%" });
|
|
12
|
+
parent.appendChild(wrapper);
|
|
13
|
+
const messages = rt.messages;
|
|
14
|
+
const artifact = node.artifact;
|
|
15
|
+
if (artifact?.inline == null) {
|
|
16
|
+
wrapper.appendChild(notice("error", sandboxArtifactMissingText(messages)));
|
|
17
|
+
return noop;
|
|
18
|
+
}
|
|
19
|
+
if (rt.sandbox == null) {
|
|
20
|
+
wrapper.appendChild(notice("error", sandboxBridgeMissingText(node.type, messages)));
|
|
21
|
+
return noop;
|
|
22
|
+
}
|
|
23
|
+
// L2 badge (makes it explicit that isolated execution is in progress). Same wording as renderer-react
|
|
24
|
+
// (both consume renderer-core's sandbox-chrome presenter, the single source of truth).
|
|
25
|
+
const badgeRow = el("div", {}, sandboxBadgeRowStyle);
|
|
26
|
+
const badge = el("span", {}, sandboxBadgePillStyle);
|
|
27
|
+
badge.appendChild(text(sandboxBadgeText(messages)));
|
|
28
|
+
const badgeNote = el("span", {}, sandboxBadgeDescriptionStyle);
|
|
29
|
+
badgeNote.appendChild(text(sandboxBadgeDescriptionText(messages)));
|
|
30
|
+
badgeRow.append(badge, badgeNote);
|
|
31
|
+
const statusHolder = el("div", {}, { width: "100%" });
|
|
32
|
+
const container = el("div", {}, { width: "100%" });
|
|
33
|
+
wrapper.append(badgeRow, statusHolder, container);
|
|
34
|
+
const allowedEvents = rt.spec.events
|
|
35
|
+
.filter((e) => e.on.startsWith(`${node.id}.`))
|
|
36
|
+
.map((e) => e.on.slice(node.id.length + 1));
|
|
37
|
+
const handle = mountSandbox({
|
|
38
|
+
container,
|
|
39
|
+
componentId: node.id,
|
|
40
|
+
artifact: { inline: artifact.inline, sha256: artifact.sha256 },
|
|
41
|
+
...(node.data?.$ref != null ? { allowedRef: node.data.$ref } : {}),
|
|
42
|
+
allowedEvents,
|
|
43
|
+
initialProps: node.props,
|
|
44
|
+
bridge: rt.sandbox.bridge,
|
|
45
|
+
...(rt.sandbox.policy != null ? { policy: rt.sandbox.policy } : {}),
|
|
46
|
+
// Inject theme tokens into the srcdoc (the same handoff as SandboxFrame). A theme change rides on the surface's
|
|
47
|
+
// full re-render (rt rebuild → teardown / mount), so no subscription is needed here.
|
|
48
|
+
theme: rt.theme,
|
|
49
|
+
});
|
|
50
|
+
// Keep the loading / error display in sync with state transitions (cleared on ready).
|
|
51
|
+
const renderStatus = (state, detail) => {
|
|
52
|
+
statusHolder.replaceChildren();
|
|
53
|
+
if (state === "loading")
|
|
54
|
+
statusHolder.appendChild(notice("info", sandboxLoadingNoticeText(messages)));
|
|
55
|
+
else if (state === "error") {
|
|
56
|
+
statusHolder.appendChild(notice("error", sandboxErrorNoticeText(detail, messages)));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
handle.onStateChange(renderStatus);
|
|
60
|
+
// Bridge the write loop's data invalidation to the guest's in-place refetch (the capability stays with the parent).
|
|
61
|
+
const ref = node.data?.$ref;
|
|
62
|
+
const unsub = ref != null ? rt.bus.subscribe(ref, () => handle.invalidate(ref)) : noop;
|
|
63
|
+
return () => {
|
|
64
|
+
unsub();
|
|
65
|
+
handle.destroy();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function notice(tone, message) {
|
|
69
|
+
const node = el("div", {}, { ...sandboxNoticeBaseStyle, ...sandboxNoticeToneStyle(tone) });
|
|
70
|
+
node.appendChild(text(message));
|
|
71
|
+
return node;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=sandbox-mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-mount.js","sourceRoot":"","sources":["../src/sandbox-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAiB,EAAE,MAAkB,EAAE,IAAmB;IACzF,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAE5B,MAAM,QAAQ,GAAqB,EAAE,CAAC,QAAQ,CAAC;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,IAAI,QAAQ,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,EAAE,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE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CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEvF,OAAO,GAAG,EAAE;QACV,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,IAAuB,EAAE,OAAe;IACtD,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,sBAAsB,EAAE,GAAG,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3F,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DataInvalidationBus, type RendererMessages, type SpecStateStore, type SurfaceEvent } from "@kohaku-ui/renderer-core";
|
|
2
|
+
import { type ThemeTokens, type UISpec } from "@kohaku-ui/spec-core";
|
|
3
|
+
import type { PartBuilder, RenderRuntime, SurfaceContext, Teardown } from "./types.js";
|
|
4
|
+
export interface RuntimeDeps {
|
|
5
|
+
spec: UISpec;
|
|
6
|
+
store: SpecStateStore;
|
|
7
|
+
bus: DataInvalidationBus;
|
|
8
|
+
theme: ThemeTokens;
|
|
9
|
+
locale: string;
|
|
10
|
+
messages: RendererMessages;
|
|
11
|
+
ctx: SurfaceContext;
|
|
12
|
+
registry: Map<string, PartBuilder>;
|
|
13
|
+
/** Upstream notification of a forward event (CustomEvent dispatch; the onEvent call is done by the glue inside this). */
|
|
14
|
+
dispatchForward(event: SurfaceEvent): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Assembles a RenderRuntime scoped to a single Spec render. mountNode/mountChildren, etc. are closures
|
|
18
|
+
* that reference rt, so the part builders (parts/*) can recurse via rt without importing tree.ts
|
|
19
|
+
* (avoiding an import cycle).
|
|
20
|
+
*/
|
|
21
|
+
export declare function createRuntime(deps: RuntimeDeps): RenderRuntime;
|
|
22
|
+
/** Builds the entire tree into parent via DFS from the root. The return value can tear down the whole tree. */
|
|
23
|
+
export declare function mountTree(rt: RenderRuntime, parent: ParentNode, rootId: string): Teardown;
|
|
24
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAMrB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAe,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpG,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,mBAAmB,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,yHAAyH;IACzH,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAkC9D;AAED,+GAA+G;AAC/G,wBAAgB,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAEzF"}
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { createBoundDataController, resolveEmit, resolveInvokeTarget, resolveRowProps, resolveToken, runInvokeTarget, } from "@kohaku-ui/renderer-core";
|
|
2
|
+
import { evaluateVisibleWhen, SANDBOX_HTML_TYPE, } from "@kohaku-ui/spec-core";
|
|
3
|
+
import { nodeNotice, noop } from "./dom.js";
|
|
4
|
+
import { mountSandboxNode } from "./sandbox-mount.js";
|
|
5
|
+
/**
|
|
6
|
+
* Assembles a RenderRuntime scoped to a single Spec render. mountNode/mountChildren, etc. are closures
|
|
7
|
+
* that reference rt, so the part builders (parts/*) can recurse via rt without importing tree.ts
|
|
8
|
+
* (avoiding an import cycle).
|
|
9
|
+
*/
|
|
10
|
+
export function createRuntime(deps) {
|
|
11
|
+
const byId = new Map(deps.spec.components.map((c) => [c.id, c]));
|
|
12
|
+
const controller = createBoundDataController({
|
|
13
|
+
binding: deps.ctx.binding,
|
|
14
|
+
bus: deps.bus,
|
|
15
|
+
state: deps.store,
|
|
16
|
+
messages: deps.messages,
|
|
17
|
+
});
|
|
18
|
+
const rt = {
|
|
19
|
+
spec: deps.spec,
|
|
20
|
+
byId,
|
|
21
|
+
store: deps.store,
|
|
22
|
+
bus: deps.bus,
|
|
23
|
+
controller,
|
|
24
|
+
binding: deps.ctx.binding,
|
|
25
|
+
theme: deps.theme,
|
|
26
|
+
locale: deps.locale,
|
|
27
|
+
messages: deps.messages,
|
|
28
|
+
onNodeError: deps.ctx.onNodeError,
|
|
29
|
+
onActionResult: deps.ctx.onActionResult,
|
|
30
|
+
sandbox: deps.ctx.sandbox,
|
|
31
|
+
registry: deps.registry,
|
|
32
|
+
dispatchForward: deps.dispatchForward,
|
|
33
|
+
mountNode: (parent, id, row) => mountNode(rt, parent, id, row),
|
|
34
|
+
mountChildren: (parent, childIds, row) => mountChildren(rt, parent, childIds, row),
|
|
35
|
+
mountSandbox: (parent, node) => mountSandboxNode(rt, parent, node),
|
|
36
|
+
emit: (node, eventName, runtime, row) => emitEvent(rt, node, eventName, runtime, row),
|
|
37
|
+
invoke: (node, eventName, runtime, row, onPhase) => invokeAction(rt, node, eventName, runtime, row, onPhase),
|
|
38
|
+
};
|
|
39
|
+
return rt;
|
|
40
|
+
}
|
|
41
|
+
/** Builds the entire tree into parent via DFS from the root. The return value can tear down the whole tree. */
|
|
42
|
+
export function mountTree(rt, parent, rootId) {
|
|
43
|
+
return mountNode(rt, parent, rootId, null);
|
|
44
|
+
}
|
|
45
|
+
function mountChildren(rt, parent, childIds, row) {
|
|
46
|
+
if (childIds == null || childIds.length === 0)
|
|
47
|
+
return noop;
|
|
48
|
+
const teardowns = childIds.map((id) => mountNode(rt, parent, id, row));
|
|
49
|
+
return () => {
|
|
50
|
+
for (const t of teardowns)
|
|
51
|
+
t();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function mountNode(rt, parent, id, row) {
|
|
55
|
+
const rawNode = rt.byId.get(id);
|
|
56
|
+
if (rawNode == null)
|
|
57
|
+
return noop;
|
|
58
|
+
if (rawNode.visibleWhen != null)
|
|
59
|
+
return mountReactiveVisible(rt, parent, rawNode, row);
|
|
60
|
+
return mountVisibleNode(rt, parent, rawNode, row);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Reactive slot for nodes that have visibleWhen. Places an anchor comment and, on every $state change, re-evaluates
|
|
64
|
+
* the condition to mount / unmount the subtree (same semantics as renderer-react's NodeView conditional display = subtree unmount).
|
|
65
|
+
*/
|
|
66
|
+
function mountReactiveVisible(rt, parent, rawNode, row) {
|
|
67
|
+
const anchor = document.createComment(`kohaku:vw:${rawNode.id}`);
|
|
68
|
+
parent.appendChild(anchor);
|
|
69
|
+
let inner = null;
|
|
70
|
+
const evalVisible = () => {
|
|
71
|
+
const visible = evaluateVisibleWhen(rawNode.visibleWhen, rt.store.values);
|
|
72
|
+
if (visible && inner == null) {
|
|
73
|
+
// Build in a detached container first, then move it right after the anchor (preserves sibling order).
|
|
74
|
+
const holder = document.createElement("div");
|
|
75
|
+
const teardown = mountVisibleNode(rt, holder, rawNode, row);
|
|
76
|
+
const inserted = [...holder.childNodes];
|
|
77
|
+
let ref = anchor;
|
|
78
|
+
for (const n of inserted) {
|
|
79
|
+
ref.after(n);
|
|
80
|
+
ref = n;
|
|
81
|
+
}
|
|
82
|
+
inner = () => {
|
|
83
|
+
teardown();
|
|
84
|
+
for (const n of inserted)
|
|
85
|
+
n.remove();
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
else if (!visible && inner != null) {
|
|
89
|
+
inner();
|
|
90
|
+
inner = null;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
evalVisible();
|
|
94
|
+
const unsub = rt.store.subscribe(evalVisible);
|
|
95
|
+
return () => {
|
|
96
|
+
unsub();
|
|
97
|
+
inner?.();
|
|
98
|
+
anchor.remove();
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Builds a single display-confirmed node (row-template substitution + per-node try/catch → fallback notice). */
|
|
102
|
+
function mountVisibleNode(rt, parent, rawNode, row) {
|
|
103
|
+
// Row-template mechanism (presentList): if there is a row context, substitute props' "$row.<column>" with that row's value.
|
|
104
|
+
const node = row != null ? resolveRowProps(rawNode, row) : rawNode;
|
|
105
|
+
try {
|
|
106
|
+
if (node.type === SANDBOX_HTML_TYPE) {
|
|
107
|
+
return rt.mountSandbox(parent, node);
|
|
108
|
+
}
|
|
109
|
+
const builder = rt.registry.get(node.type);
|
|
110
|
+
if (builder == null) {
|
|
111
|
+
parent.appendChild(nodeNotice(`Unimplemented component type: ${node.type}`, String(resolveToken(rt.theme, "color.negative.text"))));
|
|
112
|
+
return noop;
|
|
113
|
+
}
|
|
114
|
+
return builder(rt, parent, node, row);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
// Isolate a single node's render exception and keep siblings / the whole surface alive (equivalent to NodeErrorBoundary).
|
|
118
|
+
rt.onNodeError?.({ componentId: node.id, componentType: node.type, error });
|
|
119
|
+
parent.appendChild(nodeNotice(rt.messages.nodeRenderFailed(node.type, node.id), String(resolveToken(rt.theme, "color.negative.text"))));
|
|
120
|
+
return noop;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Applies event-emission governance (the glue for resolveEmit). Sink presence is not decided in resolveEmit;
|
|
125
|
+
* here (the glue) dispatchForward handles both the CustomEvent and onEvent.
|
|
126
|
+
*/
|
|
127
|
+
function emitEvent(rt, node, eventName, runtime, row) {
|
|
128
|
+
const res = resolveEmit(rt.spec, node, eventName, runtime, row);
|
|
129
|
+
if (res.kind === "state.set") {
|
|
130
|
+
rt.store.set(res.key, res.value);
|
|
131
|
+
}
|
|
132
|
+
else if (res.kind === "forward") {
|
|
133
|
+
rt.dispatchForward(res.event);
|
|
134
|
+
}
|
|
135
|
+
// drop: undeclared events are discarded (SPEC-EVT-002).
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Applies the write path (the glue for resolveInvokeTarget). Whether binding exists is passed as a boolean.
|
|
139
|
+
* For invoke, delegates the pending/invokeAction/phase/publish/onActionResult sequence to renderer-core's
|
|
140
|
+
* runInvokeTarget (shared with renderer-react); otherwise delegates to emit.
|
|
141
|
+
*/
|
|
142
|
+
async function invokeAction(rt, node, eventName, runtime, row, onPhase) {
|
|
143
|
+
const target = resolveInvokeTarget(rt.spec, node, eventName, runtime, {
|
|
144
|
+
hasBinding: rt.binding != null,
|
|
145
|
+
row,
|
|
146
|
+
});
|
|
147
|
+
if (target.kind === "forward") {
|
|
148
|
+
emitEvent(rt, node, eventName, runtime, row);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const binding = rt.binding;
|
|
152
|
+
// The pending → invokeAction → succeeded/failed phase → bus.publish → onActionResult sequence has
|
|
153
|
+
// renderer-core's runInvokeTarget as the single source of truth (shared with renderer-react).
|
|
154
|
+
await runInvokeTarget(target, { binding, bus: rt.bus, onActionResult: rt.onActionResult }, node.id, onPhase);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=tree.js.map
|
package/dist/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EAGzB,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,GAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAgBtD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAiB;IAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,yBAAyB,CAAC;QAC3C,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;QACzB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,GAAkB;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,UAAU;QACV,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;QACzB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ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AAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC7B,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,wDAAwD;AAC1D,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,YAAY,CACzB,EAAiB,EACjB,IAAmB,EACnB,SAAiB,EACjB,OAAmB,EACnB,GAAsB,EACtB,OAAqC;IAErC,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;QACpE,UAAU,EAAE,EAAE,CAAC,OAAO,IAAI,IAAI;QAC9B,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,CAAC,OAAwB,CAAC;IAC5C,kGAAkG;IAClG,8FAA8F;IAC9F,MAAM,eAAe,CACnB,MAAM,EACN,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,CAAC,cAAc,EAAE,EAC3D,IAAI,CAAC,EAAE,EACP,OAAO,CACR,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { BindingClient } from "@kohaku-ui/data-binding";
|
|
2
|
+
import type { ActionPhase, BoundDataController, DataInvalidationBus, RendererMessages, SpecStateStore, SurfaceEvent } from "@kohaku-ui/renderer-core";
|
|
3
|
+
import type { SandboxBridge, SandboxPolicy } from "@kohaku-ui/sandbox";
|
|
4
|
+
import type { ComponentNode, JsonObject, ThemeTokens, UISpec } from "@kohaku-ui/spec-core";
|
|
5
|
+
export type { ActionPhase, SurfaceEvent } from "@kohaku-ui/renderer-core";
|
|
6
|
+
/** Teardown function (unsubscribe / controller detach / sandbox destroy, etc.). */
|
|
7
|
+
export type Teardown = () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Context passed to <kohaku-surface> as properties. Corresponds to React's RendererContextValue.
|
|
10
|
+
* binding / theme / messages / onEvent, etc. are received as properties (objects/functions).
|
|
11
|
+
*/
|
|
12
|
+
export interface SurfaceContext {
|
|
13
|
+
/** Reference-resolution client. If unset, parts that carry data become a bindingMissing error. */
|
|
14
|
+
binding?: BindingClient;
|
|
15
|
+
/** Theme tokens. Inline expansion for pixel-match; :host CSS variables as the external override point. */
|
|
16
|
+
theme?: ThemeTokens;
|
|
17
|
+
/** Display language tag (default "en-US", see renderer-core's DEFAULT_LOCALE). Used for number formatting and sort collation. */
|
|
18
|
+
locale?: string;
|
|
19
|
+
/** Partial override of the default messages (DEFAULT_MESSAGES). */
|
|
20
|
+
messages?: Partial<RendererMessages>;
|
|
21
|
+
/** Only events declared in the Spec's events are delivered (state.set is not delivered). */
|
|
22
|
+
onEvent?: (event: SurfaceEvent) => void;
|
|
23
|
+
/** Notification of exceptions thrown during node rendering (invoked by the per-node try/catch when it catches). */
|
|
24
|
+
onNodeError?: (args: {
|
|
25
|
+
componentId: string;
|
|
26
|
+
componentType: string;
|
|
27
|
+
error: unknown;
|
|
28
|
+
}) => void;
|
|
29
|
+
/** Completion notification for writes (action.invoke). */
|
|
30
|
+
onActionResult?: (args: {
|
|
31
|
+
componentId: string;
|
|
32
|
+
action: string;
|
|
33
|
+
phase: "succeeded" | "failed";
|
|
34
|
+
result?: unknown;
|
|
35
|
+
message?: string;
|
|
36
|
+
}) => void;
|
|
37
|
+
/** Bridge required to run L2 (sandbox.html) parts. If unset, L2 becomes an injection-request placeholder. */
|
|
38
|
+
sandbox?: {
|
|
39
|
+
bridge: SandboxBridge;
|
|
40
|
+
policy?: SandboxPolicy;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Execution context scoped to a single Spec render. <kohaku-surface> rebuilds it on every Spec swap.
|
|
45
|
+
* The store is retained by intent.hash, and the bus stays the same for the lifetime of the surface.
|
|
46
|
+
*/
|
|
47
|
+
export interface RenderRuntime {
|
|
48
|
+
spec: UISpec;
|
|
49
|
+
byId: Map<string, ComponentNode>;
|
|
50
|
+
store: SpecStateStore;
|
|
51
|
+
bus: DataInvalidationBus;
|
|
52
|
+
controller: BoundDataController;
|
|
53
|
+
binding: BindingClient | undefined;
|
|
54
|
+
theme: ThemeTokens;
|
|
55
|
+
locale: string;
|
|
56
|
+
messages: RendererMessages;
|
|
57
|
+
onNodeError: SurfaceContext["onNodeError"];
|
|
58
|
+
onActionResult: SurfaceContext["onActionResult"];
|
|
59
|
+
sandbox: SurfaceContext["sandbox"];
|
|
60
|
+
/** Table of type → part builder (createCoreRenderRegistry). */
|
|
61
|
+
registry: Map<string, PartBuilder>;
|
|
62
|
+
/** Flows a forward event upstream via CustomEvent + onEvent (regardless of whether a sink is present). */
|
|
63
|
+
dispatchForward(event: SurfaceEvent): void;
|
|
64
|
+
/** Builds node id directly under parent (encapsulates visibleWhen / row template / per-node try-catch). */
|
|
65
|
+
mountNode(parent: ParentNode, id: string, row: JsonObject | null): Teardown;
|
|
66
|
+
/** Builds a group of child ids in order directly under parent. */
|
|
67
|
+
mountChildren(parent: ParentNode, childIds: string[] | undefined, row: JsonObject | null): Teardown;
|
|
68
|
+
/** Builds a sandbox.html node (the WC wrapper around mountSandbox). */
|
|
69
|
+
mountSandbox(parent: ParentNode, node: ComponentNode): Teardown;
|
|
70
|
+
/**
|
|
71
|
+
* Applies event-emission governance (the glue for resolveEmit). state.set updates the store, forward calls
|
|
72
|
+
* dispatchForward, and drop discards. row is the current row within a presentList template.
|
|
73
|
+
*/
|
|
74
|
+
emit(node: ComponentNode, eventName: string, runtime: JsonObject, row: JsonObject | null): void;
|
|
75
|
+
/**
|
|
76
|
+
* Applies the write path (the glue for resolveInvokeTarget). For invoke, runs binding.invokeAction directly
|
|
77
|
+
* and publishes invalidates to the bus; otherwise falls back to emit. Reports progress state via onPhase.
|
|
78
|
+
*/
|
|
79
|
+
invoke(node: ComponentNode, eventName: string, runtime: JsonObject, row: JsonObject | null, onPhase: (phase: ActionPhase) => void): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A part's DOM builder. Appends its own element to parent and returns a teardown function.
|
|
83
|
+
* (Making append the builder's responsibility lets a bound part safely perform an asynchronous
|
|
84
|
+
* state-swapping replaceWith against an already-appended element.)
|
|
85
|
+
*/
|
|
86
|
+
export type PartBuilder = (rt: RenderRuntime, parent: ParentNode, node: ComponentNode, row: JsonObject | null) => Teardown;
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE3F,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE1E,mFAAmF;AACnF,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,kGAAkG;I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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kohaku-ui/renderer-wc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web Components renderer for kohaku UI Specs: a single <kohaku-surface> custom element with Shadow DOM.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@kohaku-ui/spec-core": "^0.1.0",
|
|
15
|
+
"@kohaku-ui/data-binding": "^0.1.0",
|
|
16
|
+
"@kohaku-ui/sandbox": "^0.1.0",
|
|
17
|
+
"@kohaku-ui/renderer-core": "^0.1.0",
|
|
18
|
+
"@kohaku-ui/registry": "^0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@testing-library/react": "^16.3.3",
|
|
22
|
+
"axe-core": "^4.13.0",
|
|
23
|
+
"@types/react": "^19.3.0",
|
|
24
|
+
"@types/react-dom": "^19.3.0",
|
|
25
|
+
"jsdom": "^30.0.1",
|
|
26
|
+
"react": "19.3.0",
|
|
27
|
+
"react-dom": "19.3.0",
|
|
28
|
+
"recharts": "^3.10.1",
|
|
29
|
+
"typescript": "7.0.2",
|
|
30
|
+
"vitest": "^4.1.11",
|
|
31
|
+
"@kohaku-ui/renderer-react": "^0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"homepage": "https://github.com/yosuque/kohaku/tree/main/packages/renderer-wc#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/yosuque/kohaku/issues"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/yosuque/kohaku.git",
|
|
41
|
+
"directory": "packages/renderer-wc"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22"
|
|
45
|
+
},
|
|
46
|
+
"sideEffects": false,
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"LICENSE",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json"
|
|
58
|
+
},
|
|
59
|
+
"main": "./dist/index.js",
|
|
60
|
+
"types": "./dist/index.d.ts"
|
|
61
|
+
}
|