diff --git a/packages/page-spy-mp-base/src/plugins/network/proxy/request.ts b/packages/page-spy-mp-base/src/plugins/network/proxy/request.ts index db4e0890..95fd6330 100644 --- a/packages/page-spy-mp-base/src/plugins/network/proxy/request.ts +++ b/packages/page-spy-mp-base/src/plugins/network/proxy/request.ts @@ -25,6 +25,9 @@ export default class MPWeixinRequestProxy extends MPNetworkProxyBase { const mp = getMPSDK(); Object.defineProperty(mp, 'request', { value: this.request, + configurable: true, + writable: true, + enumerable: true, }); } } @@ -165,6 +168,9 @@ export default class MPWeixinRequestProxy extends MPNetworkProxyBase { psLog.warn('The request object is not found on request event'); return null; }, + configurable: true, + writable: true, + enumerable: true, }); } } diff --git a/packages/page-spy-mp-base/src/plugins/storage.ts b/packages/page-spy-mp-base/src/plugins/storage.ts index 5b2cef3a..872def74 100644 --- a/packages/page-spy-mp-base/src/plugins/storage.ts +++ b/packages/page-spy-mp-base/src/plugins/storage.ts @@ -12,6 +12,12 @@ import socketStore from '../helpers/socket'; import { getMPSDK, utilAPI } from '../utils'; import type { MPStorageAPI } from '../types'; +const descriptor = { + configurable: true, + writable: true, + enumerable: true, +}; + export function mpDataStringify(data: any) { const typeOfValue = typeof data; let vStr: string = data; @@ -57,6 +63,7 @@ export default class StoragePlugin implements PageSpyPlugin { Object.entries(StoragePlugin.originFunctions).forEach(([key, fn]) => { Object.defineProperty(mp, key, { value: fn, + ...descriptor, }); }); StoragePlugin.hasInitd = false; @@ -129,6 +136,7 @@ export default class StoragePlugin implements PageSpyPlugin { }, }); }, + ...descriptor, }, setStorageSync: { value(keyOrObj: string | { key: string; data: any }, data: any) { @@ -156,6 +164,7 @@ export default class StoragePlugin implements PageSpyPlugin { throw e; } }, + ...descriptor, }, removeStorage: { @@ -168,6 +177,7 @@ export default class StoragePlugin implements PageSpyPlugin { }, }); }, + ...descriptor, }, removeStorageSync: { @@ -185,6 +195,7 @@ export default class StoragePlugin implements PageSpyPlugin { throw e; } }, + ...descriptor, }, clearStorage: { @@ -197,6 +208,7 @@ export default class StoragePlugin implements PageSpyPlugin { }, }); }, + ...descriptor, }, clearStorageSync: { @@ -211,6 +223,7 @@ export default class StoragePlugin implements PageSpyPlugin { throw e; } }, + ...descriptor, }, }); @@ -235,6 +248,7 @@ export default class StoragePlugin implements PageSpyPlugin { throw e; } }, + ...descriptor, }); } if (mp.canIUse('batchSetStorage')) { @@ -250,6 +264,7 @@ export default class StoragePlugin implements PageSpyPlugin { }, }); }, + ...descriptor, }); } } diff --git a/packages/page-spy-plugin-rn-async-storage/src/index.ts b/packages/page-spy-plugin-rn-async-storage/src/index.ts index 5d00d973..0139b8b4 100644 --- a/packages/page-spy-plugin-rn-async-storage/src/index.ts +++ b/packages/page-spy-plugin-rn-async-storage/src/index.ts @@ -12,6 +12,12 @@ import type { MultiCallback, } from '@react-native-async-storage/async-storage/lib/typescript/types'; +const descriptor = { + configurable: true, + writable: true, + enumerable: true, +}; + export default class RNAsyncStoragePlugin implements PageSpyPlugin { public name = 'RNAsyncStoragePlugin'; @@ -39,6 +45,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { ([key, fn]) => { Object.defineProperty(AsyncStorage, key, { value: fn, + ...descriptor, }); }, ); @@ -108,6 +115,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { that.sendSetItem(key, value); }); }, + ...descriptor, }, mergeItem: { value(key: string, value: string, callback?: Callback) { @@ -126,6 +134,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { return res; }); }, + ...descriptor, }, multiSet: { @@ -139,6 +148,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { }); }); }, + ...descriptor, }, multiMerge: { value(kvPairs: [string, string][], callback?: MultiCallback) { @@ -158,6 +168,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { }); }); }, + ...descriptor, }, removeItem: { @@ -169,6 +180,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { that.sendRemoveItem(key); }); }, + ...descriptor, }, multiRemove: { @@ -182,6 +194,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { }); }); }, + ...descriptor, }, clear: { @@ -192,6 +205,7 @@ export default class RNAsyncStoragePlugin implements PageSpyPlugin { }, ); }, + ...descriptor, }, }); }