mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:01:23 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -59,7 +59,7 @@ function defaultIndexHTML() {
|
||||
return `<!doctype html>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clawdbot Canvas</title>
|
||||
<title>Moltbot Canvas</title>
|
||||
<style>
|
||||
html, body { height: 100%; margin: 0; background: #000; color: #fff; font: 16px/1.4 -apple-system, BlinkMacSystemFont, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
|
||||
.wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
|
||||
@@ -77,7 +77,7 @@ function defaultIndexHTML() {
|
||||
<div class="wrap">
|
||||
<div class="card">
|
||||
<div class="title">
|
||||
<h1>Clawdbot Canvas</h1>
|
||||
<h1>Moltbot Canvas</h1>
|
||||
<div class="sub">Interactive test page (auto-reload enabled)</div>
|
||||
</div>
|
||||
|
||||
@@ -98,26 +98,51 @@ function defaultIndexHTML() {
|
||||
const statusEl = document.getElementById("status");
|
||||
const log = (msg) => { logEl.textContent = String(msg); };
|
||||
|
||||
const hasIOS = () => !!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clawdbotCanvasA2UIAction);
|
||||
const hasAndroid = () => !!(window.clawdbotCanvasA2UIAction && typeof window.clawdbotCanvasA2UIAction.postMessage === "function");
|
||||
const hasHelper = () => typeof window.clawdbotSendUserAction === "function";
|
||||
const hasIOS = () =>
|
||||
!!(
|
||||
window.webkit &&
|
||||
window.webkit.messageHandlers &&
|
||||
(window.webkit.messageHandlers.moltbotCanvasA2UIAction ||
|
||||
window.webkit.messageHandlers.clawdbotCanvasA2UIAction)
|
||||
);
|
||||
const hasAndroid = () =>
|
||||
!!(
|
||||
(window.moltbotCanvasA2UIAction &&
|
||||
typeof window.moltbotCanvasA2UIAction.postMessage === "function") ||
|
||||
(window.clawdbotCanvasA2UIAction &&
|
||||
typeof window.clawdbotCanvasA2UIAction.postMessage === "function")
|
||||
);
|
||||
const legacySend = typeof window.clawdbotSendUserAction === "function" ? window.clawdbotSendUserAction : undefined;
|
||||
if (!window.moltbotSendUserAction && legacySend) {
|
||||
window.moltbotSendUserAction = legacySend;
|
||||
}
|
||||
if (!window.clawdbotSendUserAction && typeof window.moltbotSendUserAction === "function") {
|
||||
window.clawdbotSendUserAction = window.moltbotSendUserAction;
|
||||
}
|
||||
const hasHelper = () =>
|
||||
typeof window.moltbotSendUserAction === "function" ||
|
||||
typeof window.clawdbotSendUserAction === "function";
|
||||
statusEl.innerHTML =
|
||||
"Bridge: " +
|
||||
(hasHelper() ? "<span class='ok'>ready</span>" : "<span class='bad'>missing</span>") +
|
||||
" · iOS=" + (hasIOS() ? "yes" : "no") +
|
||||
" · Android=" + (hasAndroid() ? "yes" : "no");
|
||||
|
||||
window.addEventListener("clawdbot:a2ui-action-status", (ev) => {
|
||||
window.addEventListener("moltbot:a2ui-action-status", (ev) => {
|
||||
const d = ev && ev.detail || {};
|
||||
log("Action status: id=" + (d.id || "?") + " ok=" + String(!!d.ok) + (d.error ? (" error=" + d.error) : ""));
|
||||
});
|
||||
|
||||
function send(name, sourceComponentId) {
|
||||
if (!hasHelper()) {
|
||||
log("No action bridge found. Ensure you're viewing this on an iOS/Android Clawdbot node canvas.");
|
||||
log("No action bridge found. Ensure you're viewing this on an iOS/Android Moltbot node canvas.");
|
||||
return;
|
||||
}
|
||||
const ok = window.clawdbotSendUserAction({
|
||||
const sendUserAction =
|
||||
typeof window.moltbotSendUserAction === "function"
|
||||
? window.moltbotSendUserAction
|
||||
: window.clawdbotSendUserAction;
|
||||
const ok = sendUserAction({
|
||||
name,
|
||||
surfaceId: "main",
|
||||
sourceComponentId,
|
||||
@@ -319,7 +344,7 @@ export async function createCanvasHostHandler(
|
||||
res.statusCode = 404;
|
||||
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
||||
res.end(
|
||||
`<!doctype html><meta charset="utf-8" /><title>Clawdbot Canvas</title><pre>Missing file.\nCreate ${rootDir}/index.html</pre>`,
|
||||
`<!doctype html><meta charset="utf-8" /><title>Moltbot Canvas</title><pre>Missing file.\nCreate ${rootDir}/index.html</pre>`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user