UNPKG

@coze/uniapp-api

Version:

Official Coze UniApp SDK for seamless AI integration into your applications | 扣子官方 UniApp SDK,助您轻松集成 AI 能力到应用中

61 lines (60 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbortSignal = exports.AbortController = exports.AbortControllerPonyfill = exports.AbortSignalPonyfill = void 0; const types_1 = require("../types"); class AbortSignalPonyfill { constructor() { Object.defineProperty(this, "events", { enumerable: true, configurable: true, writable: true, value: new types_1.Events() }); Object.defineProperty(this, "aborted", { enumerable: true, configurable: true, writable: true, value: false }); Object.defineProperty(this, "reason", { enumerable: true, configurable: true, writable: true, value: void 0 }); } onabort(reason) { this.aborted = true; this.reason = reason; this.events.trigger('abort'); } addEventListener(_, cb) { this.events.on('abort', cb); } removeEventListener(_, cb) { this.events.off('abort', cb); } } exports.AbortSignalPonyfill = AbortSignalPonyfill; class AbortControllerPonyfill { constructor() { Object.defineProperty(this, "signal", { enumerable: true, configurable: true, writable: true, value: new AbortSignalPonyfill() }); } abort(reason) { this.signal.onabort(reason); } } exports.AbortControllerPonyfill = AbortControllerPonyfill; // 在字节跳动小程序初始化期间globalThis是undefined const supportAbortController = typeof (globalThis || window).AbortController === 'function'; exports.AbortController = supportAbortController ? (globalThis || window).AbortController : AbortControllerPonyfill; exports.AbortSignal = supportAbortController ? (globalThis || window).AbortSignal : AbortSignalPonyfill;