@pi-oxide/extension-js 0.4.1 → 0.5.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pi-oxide/extension-js",
3
3
  "type": "module",
4
- "version": "0.4.1",
4
+ "version": "0.5.0",
5
5
  "license": "LicenseRef-PiccoloNotebook-Fair-BYOK-1.0",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
package/worker.js CHANGED
@@ -1,5 +1,5 @@
1
- import x, { setLogLevel as C, ExtensionSession as ee, registerJsCallBatch as re } from "./extension_js.js";
2
- const T = {
1
+ import x, { setLogLevel as L, ExtensionSession as ee, registerJsCallBatch as re } from "./extension_js.js";
2
+ const I = {
3
3
  trace: 0,
4
4
  debug: 1,
5
5
  info: 2,
@@ -18,15 +18,15 @@ function se(r) {
18
18
  const e = Math.max(0, Math.min(5, Math.round(r)));
19
19
  return te[e] ?? "error";
20
20
  }
21
- let P = "trace", L = null;
21
+ let P = "trace", C = null;
22
22
  function ne(r) {
23
- P = r, L && L(T[r]);
24
- }
25
- function ae(r) {
26
- L = r, r(T[P]);
23
+ P = r, C && C(I[r]);
27
24
  }
28
25
  function oe(r) {
29
- return T[r] >= T[P];
26
+ C = r, r(I[P]);
27
+ }
28
+ function ae(r) {
29
+ return I[r] >= I[P];
30
30
  }
31
31
  function V(r, e = "info") {
32
32
  var s;
@@ -65,7 +65,7 @@ function le(r, e) {
65
65
  }
66
66
  return s.length > 0 ? ` ${s.join(" ")}` : "";
67
67
  }
68
- function E(r, e) {
68
+ function b(r, e) {
69
69
  return e.length === 0 ? { event: r } : e.length === 1 && typeof e[0] == "object" && e[0] !== null && !Array.isArray(e[0]) ? { event: r, metadata: e[0] } : {
70
70
  event: r,
71
71
  metadata: { _args: e.map((s) => V(s)).join(" ") }
@@ -77,8 +77,8 @@ class $ {
77
77
  }
78
78
  log(e, s, t) {
79
79
  try {
80
- if (!oe(e)) return;
81
- const n = ie(this.namespace), o = le(t, e), i = `${n} ${s}${o}`;
80
+ if (!ae(e)) return;
81
+ const n = ie(this.namespace), a = le(t, e), i = `${n} ${s}${a}`;
82
82
  switch (e) {
83
83
  case "trace":
84
84
  case "debug":
@@ -94,7 +94,7 @@ class $ {
94
94
  case "none":
95
95
  break;
96
96
  default: {
97
- const a = e;
97
+ const o = e;
98
98
  break;
99
99
  }
100
100
  }
@@ -102,33 +102,33 @@ class $ {
102
102
  }
103
103
  }
104
104
  trace(e, ...s) {
105
- const { event: t, metadata: n } = E(e, s);
105
+ const { event: t, metadata: n } = b(e, s);
106
106
  this.log("trace", t, n);
107
107
  }
108
108
  debug(e, ...s) {
109
- const { event: t, metadata: n } = E(e, s);
109
+ const { event: t, metadata: n } = b(e, s);
110
110
  this.log("debug", t, n);
111
111
  }
112
112
  info(e, ...s) {
113
- const { event: t, metadata: n } = E(e, s);
113
+ const { event: t, metadata: n } = b(e, s);
114
114
  this.log("info", t, n);
115
115
  }
116
116
  warn(e, ...s) {
117
- const { event: t, metadata: n } = E(e, s);
117
+ const { event: t, metadata: n } = b(e, s);
118
118
  this.log("warn", t, n);
119
119
  }
120
120
  error(e, ...s) {
121
- const { event: t, metadata: n } = E(e, s);
121
+ const { event: t, metadata: n } = b(e, s);
122
122
  this.log("error", t, n);
123
123
  }
124
124
  child(e) {
125
125
  return new $(`${this.namespace}.${e}`);
126
126
  }
127
127
  timer(e, s, t = "info") {
128
- const n = typeof performance < "u" && performance.now, o = n ? performance.now() : Date.now();
128
+ const n = typeof performance < "u" && performance.now, a = n ? performance.now() : Date.now();
129
129
  return (i) => {
130
130
  try {
131
- const a = n ? performance.now() : Date.now(), g = Math.round(a - o), u = {
131
+ const o = n ? performance.now() : Date.now(), g = Math.round(o - a), u = {
132
132
  ...s,
133
133
  ...i,
134
134
  duration_ms: g
@@ -139,35 +139,7 @@ class $ {
139
139
  };
140
140
  }
141
141
  }
142
- const l = new $("root"), ce = /* @__PURE__ */ new Set([
143
- "page_url",
144
- "page_title",
145
- "page_click",
146
- "page_fill",
147
- "page_type",
148
- "page_append",
149
- "page_press",
150
- "page_select",
151
- "page_check",
152
- "page_hover",
153
- "page_unhover",
154
- "page_scroll",
155
- "page_scroll_to",
156
- "page_dblclick",
157
- "page_back",
158
- "tab_click",
159
- "tab_fill",
160
- "tab_type",
161
- "tab_press",
162
- "tab_select",
163
- "tab_check",
164
- "tab_hover",
165
- "tab_unhover",
166
- "tab_scroll",
167
- "tab_scroll_to",
168
- "tab_dblclick",
169
- "tab_back"
170
- ]);
142
+ const l = new $("root"), ce = /* @__PURE__ */ new Set();
171
143
  function ue(r) {
172
144
  return ce.has(r);
173
145
  }
@@ -193,7 +165,7 @@ function ye(r, e) {
193
165
  tabPolicy: ge(r)
194
166
  };
195
167
  }
196
- function _e(r) {
168
+ function he(r) {
197
169
  for (const e of r)
198
170
  de(e.action, ye(e.action, e.owner));
199
171
  }
@@ -202,7 +174,7 @@ function k(r) {
202
174
  [...r.entries()].map(([e, s]) => [e, k(s)])
203
175
  ) : Array.isArray(r) ? r.map(k) : r;
204
176
  }
205
- function be(r) {
177
+ function Ee(r) {
206
178
  return {
207
179
  action: r.action,
208
180
  namespace: r.namespace,
@@ -228,13 +200,17 @@ function be(r) {
228
200
  errorCode: r.errorCode,
229
201
  errorCategory: r.errorCategory ?? null,
230
202
  permission: r.permission ?? null,
231
- example: r.example ?? null
203
+ example: r.example ?? null,
204
+ prerequisites: r.prerequisites ?? null,
205
+ notes: r.notes ?? null,
206
+ tags: r.tags ?? null,
207
+ relatedApis: r.relatedApis ?? null
232
208
  };
233
209
  }
234
210
  l.child("tool-registry");
235
- let _ = null, v = !1;
236
- const b = /* @__PURE__ */ new Map();
237
- function A(r, e) {
211
+ let h = null, v = !1;
212
+ const E = /* @__PURE__ */ new Map();
213
+ function T(r, e) {
238
214
  try {
239
215
  return r.postMessage(e), !0;
240
216
  } catch (s) {
@@ -244,21 +220,21 @@ function A(r, e) {
244
220
  }
245
221
  const G = 1e3;
246
222
  function K(r, e, s) {
247
- e === "main-thread" || e === "content-script" ? A(s, { type: "relayCancel", id: r, owner: e }) : A(s, { type: "registryCallCancel", id: r });
223
+ e === "main-thread" || e === "content-script" ? T(s, { type: "relayCancel", id: r, owner: e }) : T(s, { type: "registryCallCancel", id: r });
248
224
  }
249
- function z(r, e) {
250
- for (const [s, t] of b)
225
+ function q(r, e) {
226
+ for (const [s, t] of E)
251
227
  clearTimeout(t.timeoutId), K(s, t.owner, t.port), t.settle({
252
228
  ok: !1,
253
229
  error: { message: e, code: r }
254
- }), b.delete(s);
230
+ }), E.delete(s);
255
231
  }
256
- const h = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
257
- let q = Promise.resolve(), f = null;
258
- function he(r) {
232
+ const _ = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
233
+ let z = Promise.resolve(), f = null;
234
+ function _e(r) {
259
235
  l.trace("sessionQueue_enqueue");
260
- const e = q.then(r);
261
- return q = e.then(
236
+ const e = z.then(r);
237
+ return z = e.then(
262
238
  () => {
263
239
  },
264
240
  () => {
@@ -286,16 +262,16 @@ self.addEventListener("unhandledrejection", (r) => {
286
262
  l.error("worker_unhandled_rejection", { error: s }), Y(s);
287
263
  });
288
264
  function c(r, e) {
289
- h.set(r, e);
265
+ _.set(r, e);
290
266
  }
291
- function Ee() {
267
+ function be() {
292
268
  const r = new Uint8Array(16);
293
269
  return crypto.getRandomValues(r), Array.from(r, (e) => e.toString(16).padStart(2, "0")).join("");
294
270
  }
295
271
  function we(r) {
296
272
  return se(r);
297
273
  }
298
- const O = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
274
+ const O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
299
275
  function ke(r, e) {
300
276
  var s;
301
277
  if (O.has(r))
@@ -303,20 +279,20 @@ function ke(r, e) {
303
279
  if (typeof e.addEventListener != "function")
304
280
  throw new Error(`Worker port for owner "${r}" cannot receive responses`);
305
281
  O.set(r, e), e.addEventListener("message", async (t) => {
306
- var o;
282
+ var a;
307
283
  const n = t.data;
308
284
  if (n !== null && (n.type === "asyncRelayResult" || n.type === "registryCallResult") && typeof n.id == "string") {
309
285
  N(n.id, n.result);
310
286
  return;
311
287
  }
312
288
  if (n !== null && n.type === "registryCallCancel" && typeof n.id == "string") {
313
- (o = I.get(n.id)) == null || o.abort(), I.delete(n.id);
289
+ (a = A.get(n.id)) == null || a.abort(), A.delete(n.id);
314
290
  return;
315
291
  }
316
292
  if (n !== null && n.type === "registryCall" && typeof n.id == "string" && typeof n.action == "string") {
317
- const i = n.id, a = new AbortController();
318
- I.set(i, a);
319
- const g = h.get(n.action);
293
+ const i = n.id, o = new AbortController();
294
+ A.set(i, o);
295
+ const g = _.get(n.action);
320
296
  let u;
321
297
  if (!g)
322
298
  u = {
@@ -329,19 +305,19 @@ function ke(r, e) {
329
305
  action: n.action,
330
306
  callId: n.callId,
331
307
  runId: n.runId,
332
- signal: a.signal
308
+ signal: o.signal
333
309
  });
334
- u = a.signal.aborted ? { ok: !1, error: { message: "Relay aborted", code: "E_ABORT" } } : { ok: !0, value: d };
310
+ u = o.signal.aborted ? { ok: !1, error: { message: "Relay aborted", code: "E_ABORT" } } : { ok: !0, value: d };
335
311
  } catch (d) {
336
312
  u = {
337
313
  ok: !1,
338
314
  error: {
339
315
  message: d instanceof Error ? d.message : String(d),
340
- code: a.signal.aborted ? "E_ABORT" : "E_WORKER_HANDLER"
316
+ code: o.signal.aborted ? "E_ABORT" : "E_WORKER_HANDLER"
341
317
  }
342
318
  };
343
319
  }
344
- I.delete(i), A(e, { type: "registryCallResult", id: i, result: u }) || N(i, {
320
+ A.delete(i), T(e, { type: "registryCallResult", id: i, result: u }) || N(i, {
345
321
  ok: !1,
346
322
  error: { message: "Failed to deliver worker handler response", code: "E_PORT" }
347
323
  });
@@ -350,64 +326,64 @@ function ke(r, e) {
350
326
  }
351
327
  function N(r, e) {
352
328
  l.trace("resolveAsyncRelayResult", { id: r });
353
- const s = b.get(r);
329
+ const s = E.get(r);
354
330
  return s ? (s.settle(e), !0) : (l.warn("asyncRelayResult_no_pending_relay", { id: r }), !1);
355
331
  }
356
- function Re(r) {
332
+ function Me(r) {
357
333
  if (r === "main-thread" || r === "content-script")
358
334
  return self;
359
335
  const e = O.get(r);
360
336
  return e || null;
361
337
  }
362
338
  function Q(r) {
363
- const { owner: e, action: s, tabPolicy: t, resolveTimeoutMs: n } = r, o = r.timeoutMs ?? w;
364
- return (i, a) => {
365
- l.trace("safePostAsCall_invoke", { owner: e, action: s, callId: a == null ? void 0 : a.callId, runId: a == null ? void 0 : a.runId });
366
- const g = (n == null ? void 0 : n(i)) ?? o;
339
+ const { owner: e, action: s, tabPolicy: t, resolveTimeoutMs: n } = r, a = r.timeoutMs ?? w;
340
+ return (i, o) => {
341
+ l.trace("safePostAsCall_invoke", { owner: e, action: s, callId: o == null ? void 0 : o.callId, runId: o == null ? void 0 : o.runId });
342
+ const g = (n == null ? void 0 : n(i)) ?? a;
367
343
  return new Promise((u, d) => {
368
344
  var j;
369
- if ((j = a == null ? void 0 : a.signal) != null && j.aborted) {
345
+ if ((j = o == null ? void 0 : o.signal) != null && j.aborted) {
370
346
  const m = new Error(`Relay aborted for action: ${s}`);
371
347
  m.code = "E_ABORT", d(m);
372
348
  return;
373
349
  }
374
- const y = Re(e);
350
+ const y = Me(e);
375
351
  if (!y) {
376
352
  d(new Error(`No port available for action: ${s}`));
377
353
  return;
378
354
  }
379
- if (b.size >= G) {
355
+ if (E.size >= G) {
380
356
  d(new Error(
381
357
  `Too many pending calls (${G} limit exceeded). Action: ${s}`
382
358
  ));
383
359
  return;
384
360
  }
385
- const R = Ee();
361
+ const M = be();
386
362
  let W = !1;
387
- const M = (m) => {
388
- W || (W = !0, clearTimeout(U), a != null && a.signal && a.signal.removeEventListener("abort", S), b.delete(R), m());
363
+ const R = (m) => {
364
+ W || (W = !0, clearTimeout(U), o != null && o.signal && o.signal.removeEventListener("abort", S), E.delete(M), m());
389
365
  }, D = () => {
390
- K(R, e, y);
366
+ K(M, e, y);
391
367
  }, S = () => {
392
368
  D();
393
369
  const m = new Error(`Relay aborted for action: ${s}`);
394
- m.code = "E_ABORT", M(() => d(m));
370
+ m.code = "E_ABORT", R(() => d(m));
395
371
  };
396
- a != null && a.signal && a.signal.addEventListener("abort", S);
372
+ o != null && o.signal && o.signal.addEventListener("abort", S);
397
373
  const U = setTimeout(() => {
398
- D(), M(() => d(new Error(`Relay timeout for action: ${s}`)));
374
+ D(), R(() => d(new Error(`Relay timeout for action: ${s}`)));
399
375
  }, g);
400
- b.set(R, {
401
- settle: (m) => M(() => u(m)),
376
+ E.set(M, {
377
+ settle: (m) => R(() => u(m)),
402
378
  timeoutId: U,
403
379
  abort: S,
404
380
  owner: e,
405
381
  port: y
406
382
  });
407
- const F = a == null ? void 0 : a.runId, B = a == null ? void 0 : a.callId;
408
- A(y, {
383
+ const F = o == null ? void 0 : o.runId, B = o == null ? void 0 : o.callId;
384
+ T(y, {
409
385
  type: e === "main-thread" || e === "content-script" ? "asyncRelay" : "registryCall",
410
- id: R,
386
+ id: M,
411
387
  owner: e,
412
388
  action: s,
413
389
  params: i,
@@ -415,11 +391,11 @@ function Q(r) {
415
391
  tabPolicy: t,
416
392
  command: { action: s, params: i, runId: F, callId: B },
417
393
  runId: F
418
- }) || M(() => d(new Error(`Failed to post relay for action: ${s}`)));
394
+ }) || R(() => d(new Error(`Failed to post relay for action: ${s}`)));
419
395
  });
420
396
  };
421
397
  }
422
- const Me = "worker", w = 3e4, H = 5e3, Ie = 500, Te = {
398
+ const Re = "worker", w = 3e4, H = 5e3, Ae = 500, Ie = {
423
399
  page_goto: "timeout",
424
400
  page_wait_for: "timeout",
425
401
  tab_wait_for_load: "timeout",
@@ -428,26 +404,26 @@ const Me = "worker", w = 3e4, H = 5e3, Ie = 500, Te = {
428
404
  page_wait: "duration",
429
405
  sidepanel_wait: "duration"
430
406
  }, X = /* @__PURE__ */ new Set(["page_goto"]);
431
- function Ae(r, e) {
407
+ function Te(r, e) {
432
408
  if (r === null || typeof r != "object" || Array.isArray(r))
433
409
  return null;
434
410
  const s = r[e];
435
411
  return typeof s == "bigint" ? Number(s) : typeof s == "number" && Number.isFinite(s) ? s : null;
436
412
  }
437
413
  function Se(r, e) {
438
- return X.has(r) ? e * 2 + Ie + H : e + H;
414
+ return X.has(r) ? e * 2 + Ae + H : e + H;
439
415
  }
440
416
  function Z(r, e) {
441
- const s = Te[r];
417
+ const s = Ie[r];
442
418
  if (!s) return w;
443
- let t = Ae(e, s);
419
+ let t = Te(e, s);
444
420
  return t === null && X.has(r) && (t = w), t === null ? w : Math.max(
445
421
  w,
446
422
  Se(r, t)
447
423
  );
448
424
  }
449
425
  function Ne(r, e) {
450
- var o, i;
426
+ var a, i;
451
427
  r = k(r);
452
428
  const s = e == null ? void 0 : e.action;
453
429
  if (l.trace("extensionDispatch", { action: s, callId: e == null ? void 0 : e.callId, runId: e == null ? void 0 : e.runId }), !s)
@@ -455,11 +431,11 @@ function Ne(r, e) {
455
431
  ok: !1,
456
432
  error: { message: "Missing action in dispatch context", code: "E_MISSING_ACTION" }
457
433
  });
458
- if (h.has(s)) {
459
- const a = h.get(s), g = (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (o = p.get(e.runId)) == null ? void 0 : o.signal : void 0);
434
+ if (_.has(s)) {
435
+ const o = _.get(s), g = (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (a = p.get(e.runId)) == null ? void 0 : a.signal : void 0);
460
436
  return (async () => {
461
437
  try {
462
- return { ok: !0, value: await a(r, { ...e, signal: g }) };
438
+ return { ok: !0, value: await o(r, { ...e, signal: g }) };
463
439
  } catch (u) {
464
440
  const d = u instanceof Error ? u.message : String(u), y = typeof u == "object" && u !== null && "code" in u && typeof u.code == "string" ? u.code : "E_WORKER_HANDLER";
465
441
  return { ok: !1, error: { message: d, code: y } };
@@ -470,7 +446,7 @@ function Ne(r, e) {
470
446
  return t ? Q({
471
447
  owner: t.endpoint,
472
448
  action: s,
473
- resolveTimeoutMs: (a) => Z(s, a),
449
+ resolveTimeoutMs: (o) => Z(s, o),
474
450
  tabPolicy: t.tabPolicy
475
451
  })(r, {
476
452
  ...e,
@@ -480,22 +456,22 @@ function Ne(r, e) {
480
456
  error: { message: `No route registered for action: ${s}`, code: "E_NO_ROUTE" }
481
457
  });
482
458
  }
483
- function Ce(r) {
484
- if (r.owner === Me) {
485
- const e = h.get(r.action);
459
+ function Le(r) {
460
+ if (r.owner === Re) {
461
+ const e = _.get(r.action);
486
462
  if (!e)
487
463
  throw new Error(
488
464
  `No worker-local handler registered for action: ${r.action}`
489
465
  );
490
466
  return async (s, t) => {
491
- var o;
467
+ var a;
492
468
  s = k(s);
493
- const n = (t == null ? void 0 : t.signal) ?? (t != null && t.runId ? (o = p.get(t.runId)) == null ? void 0 : o.signal : void 0);
469
+ const n = (t == null ? void 0 : t.signal) ?? (t != null && t.runId ? (a = p.get(t.runId)) == null ? void 0 : a.signal : void 0);
494
470
  try {
495
471
  return { ok: !0, value: await e(s, { ...t, action: r.action, signal: n }) };
496
472
  } catch (i) {
497
- const a = i instanceof Error ? i.message : String(i), g = typeof i == "object" && i !== null && "code" in i && typeof i.code == "string" ? i.code : r.errorCode;
498
- return { ok: !1, error: { message: a, code: g } };
473
+ const o = i instanceof Error ? i.message : String(i), g = typeof i == "object" && i !== null && "code" in i && typeof i.code == "string" ? i.code : r.errorCode;
474
+ return { ok: !1, error: { message: o, code: g } };
499
475
  }
500
476
  };
501
477
  } else {
@@ -513,33 +489,33 @@ function Ce(r) {
513
489
  };
514
490
  }
515
491
  }
516
- function Le(r) {
492
+ function Ce(r) {
517
493
  c("exists", (e) => r.fsExists(e)), c("stat", (e) => r.fsStat(e)), c("read", (e) => r.fsRead(e)), c("readText", (e) => r.fsReadText(e)), c("readBase64", (e) => r.fsReadBase64(e)), c("list", (e) => r.fsList(e)), c("mkdir", (e) => r.fsMkdir(e)), c("delete", (e) => r.fsDelete(e)), c("copy", (e) => r.fsCopy(e)), c("move", (e) => r.fsMove(e)), c("write", (e) => r.fsWrite(e)), c("writeText", (e) => r.fsWriteText(e)), c("writeBase64", (e) => r.fsWriteBase64(e)), c("append", (e) => r.fsAppend(e)), c("appendText", (e) => r.fsAppendText(e)), c("appendBase64", (e) => r.fsAppendBase64(e)), c("readRange", (e) => r.fsReadRange(e)), c("update", (e) => r.fsUpdate(e)), c("hash", (e) => r.fsHash(e));
518
494
  }
519
495
  async function ve(r, e) {
520
496
  if (v) return;
521
- await x(), _ = new ee(), C(0), ae(C), l.trace("initWasm_start"), Le(_), _e(r);
522
- const t = r.map((o) => ({
523
- entry: be(o),
524
- callback: Ce(o)
497
+ await x(), h = new ee(), L(0), oe(L), l.trace("initWasm_start"), Ce(h), he(r);
498
+ const t = r.map((a) => ({
499
+ entry: Ee(a),
500
+ callback: Le(a)
525
501
  }));
526
502
  try {
527
503
  re(t);
528
- } catch (o) {
529
- const i = o instanceof Error ? o.message : String(o);
504
+ } catch (a) {
505
+ const i = a instanceof Error ? a.message : String(a);
530
506
  throw new Error(`Registry registration failed: ${i}`);
531
507
  }
532
508
  const { freezeManifest: n } = await import("./extension_js.js");
533
509
  try {
534
510
  n();
535
- } catch (o) {
536
- const i = o instanceof Error ? o.message : String(o);
511
+ } catch (a) {
512
+ const i = a instanceof Error ? a.message : String(a);
537
513
  throw new Error(`Manifest freeze failed: ${i}`);
538
514
  }
539
- if (_.injectRegistryBindings(), e) {
540
- const o = JSON.stringify(e);
541
- await _.runCellAsync(
542
- `(function(){var r=globalThis.chrome&&globalThis.chrome.runtime;if(!r){r={};if(!globalThis.chrome)globalThis.chrome={};globalThis.chrome.runtime=r;}r.id=${o};})();`,
515
+ if (h.injectRegistryBindings(), e) {
516
+ const a = JSON.stringify(e);
517
+ await h.runCellAsync(
518
+ `(function(){var r=globalThis.chrome&&globalThis.chrome.runtime;if(!r){r={};if(!globalThis.chrome)globalThis.chrome={};globalThis.chrome.runtime=r;}r.id=${a};})();`,
543
519
  "",
544
520
  "inject-runtime-id"
545
521
  );
@@ -571,10 +547,10 @@ self.onmessage = async (r) => {
571
547
  return;
572
548
  }
573
549
  if (e.type === "setLogLevel") {
574
- C(e.level), ne(we(e.level)), l.trace("set_log_level", { level: e.level });
550
+ L(e.level), ne(we(e.level)), l.trace("set_log_level", { level: e.level });
575
551
  return;
576
552
  }
577
- if (!v || !_) {
553
+ if (!v || !h) {
578
554
  self.postMessage({
579
555
  type: "error",
580
556
  id: e.id,
@@ -582,26 +558,26 @@ self.onmessage = async (r) => {
582
558
  });
583
559
  return;
584
560
  }
585
- const s = _;
586
- await he(async () => {
561
+ const s = h;
562
+ await _e(async () => {
587
563
  switch (e.type) {
588
564
  case "runCell": {
589
565
  const t = e.runId, n = new AbortController();
590
566
  t && p.set(t, n), f = { id: e.id, runId: t }, l.trace("runCell_start", { runId: t, callId: e.id, codeLen: e.code.length });
591
567
  try {
592
- const o = await s.runCellAsync(
568
+ const a = await s.runCellAsync(
593
569
  e.code,
594
570
  e.stdin || "",
595
571
  t || ""
596
572
  );
597
- l.trace("runCell_done", { runId: t, callId: e.id, status: o.status }), self.postMessage({
573
+ l.trace("runCell_done", { runId: t, callId: e.id, status: a.status }), self.postMessage({
598
574
  type: "result",
599
575
  id: e.id,
600
- data: o,
576
+ data: a,
601
577
  runId: t
602
578
  });
603
- } catch (o) {
604
- const i = o instanceof Error ? o.message : String(o);
579
+ } catch (a) {
580
+ const i = a instanceof Error ? a.message : String(a);
605
581
  l.error("runCell_error", { runId: t, error: i }), self.postMessage({
606
582
  type: "error",
607
583
  id: e.id,
@@ -616,7 +592,7 @@ self.onmessage = async (r) => {
616
592
  case "reset": {
617
593
  s.setAborted(!0);
618
594
  for (const t of p.values()) t.abort();
619
- p.clear(), z("E_RESET", "Worker reset");
595
+ p.clear(), q("E_RESET", "Worker reset");
620
596
  try {
621
597
  s.reset(), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
622
598
  } catch (t) {
@@ -628,7 +604,7 @@ self.onmessage = async (r) => {
628
604
  case "stop": {
629
605
  s.setAborted(!0);
630
606
  for (const t of p.values()) t.abort();
631
- p.clear(), z("E_STOPPED", "Worker stopped"), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
607
+ p.clear(), q("E_STOPPED", "Worker stopped"), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
632
608
  break;
633
609
  }
634
610
  case "setFuelLimit": {
@@ -673,7 +649,7 @@ self.onmessage = async (r) => {
673
649
  break;
674
650
  }
675
651
  case "fsCall": {
676
- const t = h.get(e.action);
652
+ const t = _.get(e.action);
677
653
  if (!t) {
678
654
  self.postMessage({
679
655
  type: "error",
@@ -686,8 +662,8 @@ self.onmessage = async (r) => {
686
662
  const n = await t(e.params);
687
663
  self.postMessage({ type: "result", id: e.id, data: n });
688
664
  } catch (n) {
689
- const o = n instanceof Error ? n.message : String(n);
690
- self.postMessage({ type: "error", id: e.id, error: o });
665
+ const a = n instanceof Error ? n.message : String(n);
666
+ self.postMessage({ type: "error", id: e.id, error: a });
691
667
  }
692
668
  break;
693
669
  }
@@ -700,12 +676,12 @@ self.onmessage = async (r) => {
700
676
  };
701
677
  export {
702
678
  w as DEFAULT_RELAY_TIMEOUT_MS,
703
- Ce as createExecutableCallback,
679
+ Le as createExecutableCallback,
704
680
  Ne as extensionDispatch,
705
681
  c as registerWorkerHandler,
706
682
  ke as registerWorkerPort,
707
683
  N as resolveAsyncRelayResult,
708
684
  Z as resolveRelayTimeoutMs,
709
685
  Q as safePostAsCall,
710
- z as settleAllPendingRelays
686
+ q as settleAllPendingRelays
711
687
  };