@antglobal/copilot-cards-core 0.0.20260915071159-dev.1 → 0.0.20260915071159-dev.9

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/dist/index.cjs CHANGED
@@ -434,27 +434,34 @@ function getByPath(obj, path) {
434
434
  * @param silent - If true, write to variables without triggering re-render.
435
435
  */
436
436
  async function executeRequest(fetcher, url, init, ctx, varKey, silent = false, timeoutMs) {
437
- // Combine the card-level abortSignal with a per-request timeout signal
438
- const signals = [];
439
- if (ctx.abortSignal)
440
- signals.push(ctx.abortSignal);
441
- if (timeoutMs && timeoutMs > 0)
442
- signals.push(AbortSignal.timeout(timeoutMs));
443
- const combinedSignal = signals.length > 0
444
- ? (signals.length === 1 ? signals[0] : AbortSignal.any(signals))
445
- : undefined;
446
- const response = await fetcher(url, { ...init, signal: combinedSignal });
447
- const body = await parseResponseBody(response);
448
- const result = {
449
- ok: response.ok,
450
- status: response.status,
451
- data: body,
452
- };
453
- writeResponseVariable(ctx, varKey, result, silent);
454
- if (!response.ok) {
455
- throw new Error(`HTTP ${response.status}`);
437
+ // Older WebViews have AbortController but not AbortSignal.timeout/any.
438
+ // Keep the deadline active through body parsing and release it on every exit.
439
+ const controller = timeoutMs && timeoutMs > 0 ? new AbortController() : undefined;
440
+ let timer;
441
+ const abort = () => controller?.abort();
442
+ if (controller) {
443
+ if (ctx.abortSignal?.aborted)
444
+ controller.abort();
445
+ else {
446
+ ctx.abortSignal?.addEventListener('abort', abort, { once: true });
447
+ timer = setTimeout(abort, timeoutMs);
448
+ }
449
+ }
450
+ try {
451
+ const response = await fetcher(url, { ...init, signal: controller?.signal ?? ctx.abortSignal });
452
+ const body = await parseResponseBody(response);
453
+ const result = { ok: response.ok, status: response.status, data: body };
454
+ writeResponseVariable(ctx, varKey, result, silent);
455
+ if (!response.ok)
456
+ throw new Error(`HTTP ${response.status}`);
457
+ return result;
458
+ }
459
+ finally {
460
+ if (timer !== undefined)
461
+ clearTimeout(timer);
462
+ if (controller)
463
+ ctx.abortSignal?.removeEventListener('abort', abort);
456
464
  }
457
- return result;
458
465
  }
459
466
  /**
460
467
  * Create a delay that can be aborted via AbortSignal.
package/dist/index.js CHANGED
@@ -432,27 +432,34 @@ function getByPath(obj, path) {
432
432
  * @param silent - If true, write to variables without triggering re-render.
433
433
  */
434
434
  async function executeRequest(fetcher, url, init, ctx, varKey, silent = false, timeoutMs) {
435
- // Combine the card-level abortSignal with a per-request timeout signal
436
- const signals = [];
437
- if (ctx.abortSignal)
438
- signals.push(ctx.abortSignal);
439
- if (timeoutMs && timeoutMs > 0)
440
- signals.push(AbortSignal.timeout(timeoutMs));
441
- const combinedSignal = signals.length > 0
442
- ? (signals.length === 1 ? signals[0] : AbortSignal.any(signals))
443
- : undefined;
444
- const response = await fetcher(url, { ...init, signal: combinedSignal });
445
- const body = await parseResponseBody(response);
446
- const result = {
447
- ok: response.ok,
448
- status: response.status,
449
- data: body,
450
- };
451
- writeResponseVariable(ctx, varKey, result, silent);
452
- if (!response.ok) {
453
- throw new Error(`HTTP ${response.status}`);
435
+ // Older WebViews have AbortController but not AbortSignal.timeout/any.
436
+ // Keep the deadline active through body parsing and release it on every exit.
437
+ const controller = timeoutMs && timeoutMs > 0 ? new AbortController() : undefined;
438
+ let timer;
439
+ const abort = () => controller?.abort();
440
+ if (controller) {
441
+ if (ctx.abortSignal?.aborted)
442
+ controller.abort();
443
+ else {
444
+ ctx.abortSignal?.addEventListener('abort', abort, { once: true });
445
+ timer = setTimeout(abort, timeoutMs);
446
+ }
447
+ }
448
+ try {
449
+ const response = await fetcher(url, { ...init, signal: controller?.signal ?? ctx.abortSignal });
450
+ const body = await parseResponseBody(response);
451
+ const result = { ok: response.ok, status: response.status, data: body };
452
+ writeResponseVariable(ctx, varKey, result, silent);
453
+ if (!response.ok)
454
+ throw new Error(`HTTP ${response.status}`);
455
+ return result;
456
+ }
457
+ finally {
458
+ if (timer !== undefined)
459
+ clearTimeout(timer);
460
+ if (controller)
461
+ ctx.abortSignal?.removeEventListener('abort', abort);
454
462
  }
455
- return result;
456
463
  }
457
464
  /**
458
465
  * Create a delay that can be aborted via AbortSignal.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antglobal/copilot-cards-core",
3
- "version": "0.0.20260915071159-dev.1",
3
+ "version": "0.0.20260915071159-dev.9",
4
4
  "description": "Core logic engine for copilot bot card SDK — no UI, pure logic (Expression Engine, Action Runner, Schema Parser, Lifecycle Manager)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",