From df9adea20c412b2b828d64aa7c4a4fd7142ec6b0 Mon Sep 17 00:00:00 2001 From: fengdanping Date: Thu, 12 Dec 2024 20:25:43 +0800 Subject: [PATCH] fix: fix ci build error --- packages/sdk/src/dom.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/sdk/src/dom.ts b/packages/sdk/src/dom.ts index b3059666e6..6b9a14be89 100644 --- a/packages/sdk/src/dom.ts +++ b/packages/sdk/src/dom.ts @@ -25,10 +25,8 @@ export function isStaticResourcesEqual(url1: string, url2: string): boolean { export function createScript(info: { url: string; - cb?: { - resolve: (value: void | PromiseLike) => void; - reject: (error: Error) => void; - }; + cb?: (value: void | PromiseLike) => void; + onErrorCallback?: (error: Error) => void; attrs?: Record; needDeleteScript?: boolean; createScriptHook?: CreateScriptHookDom; @@ -94,9 +92,9 @@ export function createScript(info: { clearTimeout(timeoutId); const onScriptCompleteCallback = () => { if (event.type === 'error') { - info?.cb?.reject && info?.cb?.reject(event); + info?.onErrorCallback && info?.onErrorCallback(event); } else { - info?.cb?.resolve && info?.cb?.resolve(); + info?.cb && info?.cb(); } }; @@ -139,10 +137,8 @@ export function createScript(info: { export function createLink(info: { url: string; - cb?: { - resolve: (value: void | PromiseLike) => void; - reject: (error: Error) => void; - }; + cb?: (value: void | PromiseLike) => void; + onErrorCallback?: (error: Error) => void; attrs: Record; needDeleteLink?: boolean; createLinkHook?: ( @@ -201,9 +197,9 @@ export function createLink(info: { ): void => { const onLinkCompleteCallback = () => { if (event.type === 'error') { - info?.cb?.reject && info?.cb?.reject(event); + info?.onErrorCallback && info?.onErrorCallback(event); } else { - info?.cb?.resolve && info?.cb?.resolve(); + info?.cb && info?.cb(); } }; // Prevent memory leaks in IE. @@ -243,10 +239,8 @@ export function loadScript( return new Promise((resolve, reject) => { const { script, needAttach } = createScript({ url, - cb: { - resolve, - reject, - }, + cb: resolve, + onErrorCallback: reject, attrs: { fetchpriority: 'high', ...attrs,