| 46 | type UserScriptCallable = () => unknown; |
| 47 | |
| 48 | function formatMacroOutput(value: unknown): string { |
| 49 | if (value === null || value === undefined) return ""; |
| 50 | if (typeof value === "string") return value; |
| 51 | if (typeof value === "number" || typeof value === "boolean") { |
| 52 | return String(value); |
| 53 | } |
| 54 | if (typeof value === "bigint" || typeof value === "symbol") { |
| 55 | return value.toString(); |
| 56 | } |
| 57 | if (value instanceof Error) return value.message; |
| 58 | |
| 59 | try { |
| 60 | return JSON.stringify(value); |
| 61 | } catch { |
| 62 | return Object.prototype.toString.call(value); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | export class SingleMacroEngine { |
| 67 | private readonly choiceExecutor: IChoiceExecutor; |