mac: bundle web chat assets
This commit is contained in:
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/BashRenderer.d.ts
vendored
Normal file
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/BashRenderer.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
||||
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
||||
interface BashParams {
|
||||
command: string;
|
||||
}
|
||||
export declare class BashRenderer implements ToolRenderer<BashParams, undefined> {
|
||||
render(params: BashParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=BashRenderer.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BashRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/BashRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,UAAU;IACnB,OAAO,EAAE,MAAM,CAAC;CAChB;AAGD,qBAAa,YAAa,YAAW,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC;IACvE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,gBAAgB;CAsC1G"}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { html } from "lit";
|
||||
import { SquareTerminal } from "lucide";
|
||||
import { i18n } from "../../utils/i18n.js";
|
||||
import { renderHeader } from "../renderer-registry.js";
|
||||
// Bash tool has undefined details (only uses output)
|
||||
export class BashRenderer {
|
||||
render(params, result) {
|
||||
const state = result ? (result.isError ? "error" : "complete") : "inprogress";
|
||||
// With result: show command + output
|
||||
if (result && params?.command) {
|
||||
const output = result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n") || "";
|
||||
const combined = output ? `> ${params.command}\n\n${output}` : `> ${params.command}`;
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, SquareTerminal, i18n("Running command..."))}
|
||||
<console-block .content=${combined} .variant=${result.isError ? "error" : "default"}></console-block>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Just params (streaming or waiting)
|
||||
if (params?.command) {
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, SquareTerminal, i18n("Running command..."))}
|
||||
<console-block .content=${`> ${params.command}`}></console-block>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// No params yet
|
||||
return { content: renderHeader(state, SquareTerminal, i18n("Waiting for command...")), isCustom: false };
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BashRenderer.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BashRenderer.js","sourceRoot":"","sources":["../../../src/tools/renderers/BashRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,qDAAqD;AACrD,MAAM,OAAO,YAAY;IACxB,MAAM,CAAC,MAA8B,EAAE,MAAgD;QACtF,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAE9E,qCAAqC;QACrC,IAAI,MAAM,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YAC/B,MAAM,MAAM,GACX,MAAM,CAAC,OAAO;gBACb,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBACjC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;YACrF,OAAO;gBACN,OAAO,EAAE,IAAI,CAAA;;QAET,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;gCACvC,QAAQ,aAAa,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;;KAEpF;gBACD,QAAQ,EAAE,KAAK;aACf,CAAC;QACH,CAAC;QAED,qCAAqC;QACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,OAAO;gBACN,OAAO,EAAE,IAAI,CAAA;;QAET,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;gCACvC,KAAK,MAAM,CAAC,OAAO,EAAE;;KAEhD;gBACD,QAAQ,EAAE,KAAK;aACf,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC1G,CAAC;CACD"}
|
||||
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/CalculateRenderer.d.ts
vendored
Normal file
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/CalculateRenderer.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
||||
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
||||
interface CalculateParams {
|
||||
expression: string;
|
||||
}
|
||||
export declare class CalculateRenderer implements ToolRenderer<CalculateParams, undefined> {
|
||||
render(params: CalculateParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=CalculateRenderer.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CalculateRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/CalculateRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,eAAe;IACxB,UAAU,EAAE,MAAM,CAAC;CACnB;AAGD,qBAAa,iBAAkB,YAAW,YAAY,CAAC,eAAe,EAAE,SAAS,CAAC;IACjF,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,gBAAgB;CA4C/G"}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { html } from "lit";
|
||||
import { Calculator } from "lucide";
|
||||
import { i18n } from "../../utils/i18n.js";
|
||||
import { renderHeader } from "../renderer-registry.js";
|
||||
// Calculate tool has undefined details (only uses output)
|
||||
export class CalculateRenderer {
|
||||
render(params, result) {
|
||||
const state = result ? (result.isError ? "error" : "complete") : "inprogress";
|
||||
// Full params + full result
|
||||
if (result && params?.expression) {
|
||||
const output = result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n") || "";
|
||||
// Error: show expression in header, error below
|
||||
if (result.isError) {
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Calculator, params.expression)}
|
||||
<div class="text-sm text-destructive">${output}</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Success: show expression = result in header
|
||||
return { content: renderHeader(state, Calculator, `${params.expression} = ${output}`), isCustom: false };
|
||||
}
|
||||
// Full params, no result: just show header with expression in it
|
||||
if (params?.expression) {
|
||||
return {
|
||||
content: renderHeader(state, Calculator, `${i18n("Calculating")} ${params.expression}`),
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Partial params (empty expression), no result
|
||||
if (params && !params.expression) {
|
||||
return { content: renderHeader(state, Calculator, i18n("Writing expression...")), isCustom: false };
|
||||
}
|
||||
// No params, no result
|
||||
return { content: renderHeader(state, Calculator, i18n("Waiting for expression...")), isCustom: false };
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=CalculateRenderer.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CalculateRenderer.js","sourceRoot":"","sources":["../../../src/tools/renderers/CalculateRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,0DAA0D;AAC1D,MAAM,OAAO,iBAAiB;IAC7B,MAAM,CAAC,MAAmC,EAAE,MAAgD;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAE9E,4BAA4B;QAC5B,IAAI,MAAM,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC;YAClC,MAAM,MAAM,GACX,MAAM,CAAC,OAAO;gBACb,EAAE,MAAM,CAAC,C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
||||
6
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/DefaultRenderer.d.ts
vendored
Normal file
6
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/DefaultRenderer.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
||||
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
||||
export declare class DefaultRenderer implements ToolRenderer {
|
||||
render(params: any | undefined, result: ToolResultMessage | undefined, isStreaming?: boolean): ToolRenderResult;
|
||||
}
|
||||
//# sourceMappingURL=DefaultRenderer.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DefaultRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/DefaultRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,qBAAa,eAAgB,YAAW,YAAY;IACnD,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,MAAM,EAAE,iBAAiB,GAAG,SAAS,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,gBAAgB;CA8F/G"}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { html } from "lit";
|
||||
import { Code } from "lucide";
|
||||
import { i18n } from "../../utils/i18n.js";
|
||||
import { renderHeader } from "../renderer-registry.js";
|
||||
export class DefaultRenderer {
|
||||
render(params, result, isStreaming) {
|
||||
const state = result ? (result.isError ? "error" : "complete") : isStreaming ? "inprogress" : "complete";
|
||||
// Format params as JSON
|
||||
let paramsJson = "";
|
||||
if (params) {
|
||||
try {
|
||||
paramsJson = JSON.stringify(JSON.parse(params), null, 2);
|
||||
}
|
||||
catch {
|
||||
try {
|
||||
paramsJson = JSON.stringify(params, null, 2);
|
||||
}
|
||||
catch {
|
||||
paramsJson = String(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
// With result: show header + params + result
|
||||
if (result) {
|
||||
let outputJson = result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n") || i18n("(no output)");
|
||||
let outputLanguage = "text";
|
||||
// Try to parse and pretty-print if it's valid JSON
|
||||
try {
|
||||
const parsed = JSON.parse(outputJson);
|
||||
outputJson = JSON.stringify(parsed, null, 2);
|
||||
outputLanguage = "json";
|
||||
}
|
||||
catch {
|
||||
// Not valid JSON, leave as-is and use text highlighting
|
||||
}
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Code, "Tool Call")}
|
||||
${paramsJson
|
||||
? html `<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Input")}</div>
|
||||
<code-block .code=${paramsJson} language="json"></code-block>
|
||||
</div>`
|
||||
: ""}
|
||||
<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Output")}</div>
|
||||
<code-block .code=${outputJson} language="${outputLanguage}"></code-block>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Just params (streaming or waiting for result)
|
||||
if (params) {
|
||||
if (isStreaming && (!paramsJson || paramsJson === "{}" || paramsJson === "null")) {
|
||||
return {
|
||||
content: html `
|
||||
<div>
|
||||
${renderHeader(state, Code, "Preparing tool parameters...")}
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Code, "Tool Call")}
|
||||
<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Input")}</div>
|
||||
<code-block .code=${paramsJson} language="json"></code-block>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// No params or result yet
|
||||
return {
|
||||
content: html `
|
||||
<div>
|
||||
${renderHeader(state, Code, "Preparing tool...")}
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=DefaultRenderer.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DefaultRenderer.js","sourceRoot":"","sources":["../../../src/tools/renderers/DefaultRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,MAAM,OAAO,eAAe;IAC3B,MAAM,CAAC,MAAuB,EAAE,MAAqC,EAAE,WAAqB;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;QAEzG,wBAAwB;QACxB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC;gBACJ,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;YAAC,MAAM,CAAC;gBACR,IAAI,CAAC;oBACJ,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC9C,CAAC;gBAAC,MAAM,CAAC;oBACR,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC;YACF,CAAC;QACF,CAAC;QAED,6CAA6C;QAC7C,IAAI,MAAM,EAAE,CAAC;YAC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ACN,OAAO,EAAE,IAAI,CAAA;;QAET,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC;;qEAEuB,IAAI,CAAC,OAAO,CAAC;2BACvD,UAAU;;;KAGhC;gBACD,QAAQ,EAAE,KAAK;aACf,CAAC;QACH,CAAC;QAED,0BAA0B;QAC1B,OAAO;YACN,OAAO,EAAE,IAAI,CAAA;;OAET,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,mBAAmB,CAAC;;IAEjD;YACD,QAAQ,EAAE,KAAK;SACf,CAAC;IACH,CAAC;CACD"}
|
||||
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/GetCurrentTimeRenderer.d.ts
vendored
Normal file
10
apps/macos/Sources/Clawdis/Resources/WebChat/tools/renderers/GetCurrentTimeRenderer.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
||||
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
||||
interface GetCurrentTimeParams {
|
||||
timezone?: string;
|
||||
}
|
||||
export declare class GetCurrentTimeRenderer implements ToolRenderer<GetCurrentTimeParams, undefined> {
|
||||
render(params: GetCurrentTimeParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=GetCurrentTimeRenderer.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GetCurrentTimeRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/GetCurrentTimeRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,oBAAoB;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,qBAAa,sBAAuB,YAAW,YAAY,CAAC,oBAAoB,EAAE,SAAS,CAAC;IAC3F,MAAM,CACL,MAAM,EAAE,oBAAoB,GAAG,SAAS,EACxC,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,GAC9C,gBAAgB;CA2EnB"}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { html } from "lit";
|
||||
import { Clock } from "lucide";
|
||||
import { i18n } from "../../utils/i18n.js";
|
||||
import { renderHeader } from "../renderer-registry.js";
|
||||
// GetCurrentTime tool has undefined details (only uses output)
|
||||
export class GetCurrentTimeRenderer {
|
||||
render(params, result) {
|
||||
const state = result ? (result.isError ? "error" : "complete") : "inprogress";
|
||||
// Full params + full result
|
||||
if (result && params) {
|
||||
const output = result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n") || "";
|
||||
const headerText = params.timezone
|
||||
? `${i18n("Getting current time in")} ${params.timezone}`
|
||||
: i18n("Getting current date and time");
|
||||
// Error: show header, error below
|
||||
if (result.isError) {
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Clock, headerText)}
|
||||
<div class="text-sm text-destructive">${output}</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Success: show time in header
|
||||
return { content: renderHeader(state, Clock, `${headerText}: ${output}`), isCustom: false };
|
||||
}
|
||||
// Full result, no params
|
||||
if (result) {
|
||||
const output = result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n") || "";
|
||||
// Error: show header, error below
|
||||
if (result.isError) {
|
||||
return {
|
||||
content: html `
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Clock, i18n("Getting current date and time"))}
|
||||
<div class="text-sm text-destructive">${output}</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Success: show time in header
|
||||
return {
|
||||
content: renderHeader(state, Clock, `${i18n("Getting current date and time")}: ${output}`),
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Full params, no result: show timezone info in header
|
||||
if (params?.timezone) {
|
||||
return {
|
||||
content: renderHeader(state, Clock, `${i18n("Getting current time in")} ${params.timezone}`),
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
// Partial params (no timezone) or empty params, no result
|
||||
if (params) {
|
||||
return { content: renderHeader(state, Clock, i18n("Getting current date and time")), isCustom: false };
|
||||
}
|
||||
// No params, no result
|
||||
return { content: renderHeader(state, Clock, i18n("Getting time...")), isCustom: false };
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GetCurrentTimeRenderer.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GetCurrentTimeRenderer.js","sourceRoot":"","sources":["../../../src/tools/renderers/GetCurrentTimeRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,+DAA+D;AAC/D,MAAM,OAAO,sBAAsB;IAClC,MAAM,CACL,MAAwC,EACxC,MAAgD;QAEhD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAE9E,4BAA4B;QAC5B,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;YACtB,MAAM,MAAM,GACX,MAAM,CAAC,OAAO;gBACb,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBACjC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,IAAI,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