MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / HDB

Function HDB

debug-plugin/content-script.js:73–333  ·  view source on GitHub ↗
(ctx, runtime, breakpoint, _hyperscript)

Source from the content-addressed store, hash-verified

71 let hdbCounter = 0;
72
73 function HDB(ctx, runtime, breakpoint, _hyperscript) {
74 let cmd = breakpoint;
75 let cmdMap = [];
76 const bus = new EventTarget();
77 let renderedCode = "";
78
79 const consoleHistory = [];
80 let renderedConsole = "";
81
82 const brk = function (_ctx) {
83 console.log("=== HDB///_hyperscript/debugger ===");
84
85 // Print initial context at startup
86 for (const v of Object.keys(ctx)) {
87 if (v == "meta") continue;
88 consoleHistory.push(v);
89 renderedConsole += makeConsoleHistoryEntry(v, ctx[v]);
90 }
91
92 hdbCounter++;
93
94 ui();
95 return new Promise((resolve, reject) => {
96 bus.addEventListener(
97 "continue",
98 () => {
99 resolve(runtime.findNext(cmd, ctx));
100 cmd = null;
101 },
102 { once: true },
103 );
104 });
105 };
106
107 const continueExec = function () {
108 bus.dispatchEvent(new Event("continue"));
109 ui();
110 };
111
112 const stepOver = function () {
113 if (!cmd) return continueExec();
114 const result =
115 cmd && cmd.type === "breakpointCommand"
116 ? runtime.findNext(cmd, ctx)
117 : runtime.unifiedEval(cmd, ctx);
118 if (result.type === "implicitReturn") return stepOut();
119 if (result && result.then instanceof Function) {
120 return result.then((next) => {
121 cmd = next;
122 bus.dispatchEvent(new Event("step"));
123 logCommand();
124 });
125 } else if (result === runtime.HALT) {
126 bus.dispatchEvent(new Event("continue"));
127 } else {
128 cmd = result;
129 bus.dispatchEvent(new Event("step"));
130 logCommand();

Callers 1

registerCommandsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected