@whitesev/utils 2.5.6 → 2.5.8

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.amd.js CHANGED
@@ -245,7 +245,7 @@ define((function () { 'use strict';
245
245
  throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
246
246
  }
247
247
  let cookies = this.windowApi.document.cookie.split(";");
248
- let findValue = void 0;
248
+ let findValue = undefined;
249
249
  for (const cookieItem of cookies) {
250
250
  let item = cookieItem.trim();
251
251
  let itemSplit = item.split("=");
@@ -1279,14 +1279,14 @@ define((function () { 'use strict';
1279
1279
  const option = menuOption[index];
1280
1280
  this.MenuHandle.$data.data.push({
1281
1281
  data: option,
1282
- id: void 0,
1282
+ id: undefined,
1283
1283
  });
1284
1284
  }
1285
1285
  }
1286
1286
  else {
1287
1287
  this.MenuHandle.$data.data.push({
1288
1288
  data: menuOption,
1289
- id: void 0,
1289
+ id: undefined,
1290
1290
  });
1291
1291
  }
1292
1292
  }
@@ -2414,13 +2414,13 @@ define((function () { 'use strict';
2414
2414
  status: fetchResponse.status,
2415
2415
  statusText: fetchResponse.statusText,
2416
2416
  // @ts-ignore
2417
- response: void 0,
2417
+ response: undefined,
2418
2418
  responseFetchHeaders: fetchResponse.headers,
2419
2419
  responseHeaders: "",
2420
2420
  // @ts-ignore
2421
- responseText: void 0,
2421
+ responseText: undefined,
2422
2422
  responseType: option.responseType,
2423
- responseXML: void 0,
2423
+ responseXML: undefined,
2424
2424
  };
2425
2425
  Object.assign(httpxResponse, option.context || {});
2426
2426
  // 把headers转为字符串
@@ -2532,30 +2532,30 @@ define((function () { 'use strict';
2532
2532
  * 默认配置
2533
2533
  */
2534
2534
  #defaultDetails = {
2535
- url: void 0,
2535
+ url: undefined,
2536
2536
  timeout: 5000,
2537
2537
  async: false,
2538
- responseType: void 0,
2539
- headers: void 0,
2540
- data: void 0,
2541
- redirect: void 0,
2542
- cookie: void 0,
2543
- cookiePartition: void 0,
2544
- binary: void 0,
2545
- nocache: void 0,
2546
- revalidate: void 0,
2547
- context: void 0,
2548
- overrideMimeType: void 0,
2549
- anonymous: void 0,
2550
- fetch: void 0,
2551
- fetchInit: void 0,
2538
+ responseType: undefined,
2539
+ headers: undefined,
2540
+ data: undefined,
2541
+ redirect: undefined,
2542
+ cookie: undefined,
2543
+ cookiePartition: undefined,
2544
+ binary: undefined,
2545
+ nocache: undefined,
2546
+ revalidate: undefined,
2547
+ context: undefined,
2548
+ overrideMimeType: undefined,
2549
+ anonymous: undefined,
2550
+ fetch: undefined,
2551
+ fetchInit: undefined,
2552
2552
  allowInterceptConfig: {
2553
2553
  beforeRequest: true,
2554
2554
  afterResponseSuccess: true,
2555
2555
  afterResponseError: true,
2556
2556
  },
2557
- user: void 0,
2558
- password: void 0,
2557
+ user: undefined,
2558
+ password: undefined,
2559
2559
  onabort() { },
2560
2560
  onerror() { },
2561
2561
  ontimeout() { },
@@ -3039,7 +3039,7 @@ define((function () { 'use strict';
3039
3039
  success: false,
3040
3040
  code: that.#statusCode.getFailed.code,
3041
3041
  msg: that.#statusCode.getFailed.msg,
3042
- data: void 0,
3042
+ data: undefined,
3043
3043
  });
3044
3044
  }
3045
3045
  else {
@@ -3049,7 +3049,7 @@ define((function () { 'use strict';
3049
3049
  let result = target.result;
3050
3050
  /* result 返回的是 {key: string, value: any} */
3051
3051
  /* 键值对存储 */
3052
- let data = result ? result.value : void 0;
3052
+ let data = result ? result.value : undefined;
3053
3053
  if (data == null) {
3054
3054
  resolve({
3055
3055
  success: true,
@@ -3076,7 +3076,7 @@ define((function () { 'use strict';
3076
3076
  success: false,
3077
3077
  code: that.#statusCode.getFailed.code,
3078
3078
  msg: that.#statusCode.getFailed.msg,
3079
- data: void 0,
3079
+ data: undefined,
3080
3080
  event: event,
3081
3081
  });
3082
3082
  };
@@ -3656,7 +3656,7 @@ define((function () { 'use strict';
3656
3656
  context = __context__ || this;
3657
3657
  let result = executeTryCatch(callbackFunction, handleError, context);
3658
3658
  // @ts-ignore
3659
- return result !== void 0 ? result : TryCatchCore;
3659
+ return result !== undefined ? result : TryCatchCore;
3660
3660
  },
3661
3661
  };
3662
3662
  /**
@@ -3667,7 +3667,7 @@ define((function () { 'use strict';
3667
3667
  * @returns 如果函数有返回值,则返回该返回值;否则返回 undefined。
3668
3668
  */
3669
3669
  function executeTryCatch(callback, handleErrorFunc, funcThis) {
3670
- let result = void 0;
3670
+ let result = undefined;
3671
3671
  try {
3672
3672
  if (typeof callback === "string") {
3673
3673
  (function () {
@@ -3735,7 +3735,7 @@ define((function () { 'use strict';
3735
3735
  */
3736
3736
  getStartsWith(key) {
3737
3737
  let allKeys = this.keys();
3738
- let result = void 0;
3738
+ let result = undefined;
3739
3739
  for (const keyName of allKeys) {
3740
3740
  if (String(keyName).startsWith(String(key))) {
3741
3741
  result = this.get(keyName);
@@ -3750,7 +3750,7 @@ define((function () { 'use strict';
3750
3750
  * @param val 值,默认为""
3751
3751
  */
3752
3752
  set(key, val) {
3753
- if (key === void 0) {
3753
+ if (key === undefined) {
3754
3754
  throw new Error("Utils.Dictionary().set 参数 key 不能为空");
3755
3755
  }
3756
3756
  Reflect.set(this.items, key, val);
@@ -4135,13 +4135,411 @@ define((function () { 'use strict';
4135
4135
  }
4136
4136
  }
4137
4137
 
4138
+ // ==UserScript==
4139
+ // @name ModuleRaid.js
4140
+ // @namespace http://tampermonkey.net/
4141
+ // @version 6.2.0
4142
+ // @description 检索调用webpackJsonp模块,可指定检索的window
4143
+ // @author empyrealtear
4144
+ // @license MIT
4145
+ // @original-script https://github.com/pixeldesu/moduleRaid
4146
+ // ==/UserScript==
4147
+
4148
+
4149
+ /**
4150
+ * Main moduleRaid class
4151
+ * @link https://scriptcat.org/zh-CN/script-show-page/2628
4152
+ */
4153
+ class ModuleRaid {
4154
+ /**
4155
+ * moduleRaid constructor
4156
+ *
4157
+ * @example
4158
+ * Constructing an instance without any arguments:
4159
+ * ```ts
4160
+ * const mR = new ModuleRaid()
4161
+ * ```
4162
+ *
4163
+ * Constructing an instance with the optional `opts` object:
4164
+ * ```ts
4165
+ * const mR = new ModuleRaid({ entrypoint: 'webpackChunk_custom_name' })
4166
+ * ```
4167
+ *
4168
+ * @param opts a object containing options to initialize moduleRaid with
4169
+ * - **opts:**
4170
+ * - _target_: the window object being searched for
4171
+ * - _entrypoint_: the Webpack entrypoint present on the global window object
4172
+ * - _debug_: whether debug mode is enabled or not
4173
+ * - _strict_: whether strict mode is enabled or not
4174
+ */
4175
+ constructor(opts) {
4176
+ /**
4177
+ * A random generated module ID we use for injecting into Webpack
4178
+ */
4179
+ this.moduleID = Math.random().toString(36).substring(7);
4180
+ /**
4181
+ * An array containing different argument injection methods for
4182
+ * Webpack (before version 4), and subsequently pulling out methods and modules
4183
+ * @internal
4184
+ */
4185
+ this.functionArguments = [
4186
+ [
4187
+ [0],
4188
+ [
4189
+ (_e, _t, i) => {
4190
+ this.modules = i.c;
4191
+ this.constructors = i.m;
4192
+ this.get = i;
4193
+ },
4194
+ ],
4195
+ ],
4196
+ [
4197
+ [1e3],
4198
+ {
4199
+ [this.moduleID]: (_e, _t, i) => {
4200
+ this.modules = i.c;
4201
+ this.constructors = i.m;
4202
+ this.get = i;
4203
+ },
4204
+ },
4205
+ [[this.moduleID]],
4206
+ ],
4207
+ ];
4208
+ /**
4209
+ * An array containing different argument injection methods for
4210
+ * Webpack (after version 4), and subsequently pulling out methods and modules
4211
+ * @internal
4212
+ */
4213
+ this.arrayArguments = [
4214
+ [
4215
+ [this.moduleID],
4216
+ {},
4217
+ (e) => {
4218
+ const mCac = e.m;
4219
+ Object.keys(mCac).forEach((mod) => {
4220
+ try {
4221
+ this.modules[mod] = e(mod);
4222
+ }
4223
+ catch (err) {
4224
+ this.log(`[arrayArguments/1] Failed to require(${mod}) with error:\n${err}\n${err.stack}`);
4225
+ }
4226
+ });
4227
+ this.get = e;
4228
+ },
4229
+ ],
4230
+ this.functionArguments[1],
4231
+ ];
4232
+ /**
4233
+ * Storage for the modules we extracted from Webpack
4234
+ */
4235
+ this.modules = {};
4236
+ /**
4237
+ * Storage for the constructors we extracted from Webpack
4238
+ */
4239
+ this.constructors = [];
4240
+ let options = {
4241
+ target: window,
4242
+ entrypoint: 'webpackJsonp',
4243
+ debug: false,
4244
+ strict: false,
4245
+ };
4246
+ if (typeof opts === 'object') {
4247
+ options = Object.assign(Object.assign({}, options), opts);
4248
+ }
4249
+ this.target = options.target;
4250
+ this.entrypoint = options.entrypoint;
4251
+ this.debug = options.debug;
4252
+ this.strict = options.strict;
4253
+ this.detectEntrypoint();
4254
+ this.fillModules();
4255
+ this.replaceGet();
4256
+ this.setupPushEvent();
4257
+ }
4258
+ /**
4259
+ * Debug logging method, outputs to the console when {@link ModuleRaid.debug} is true
4260
+ *
4261
+ * @param {*} message The message to be logged
4262
+ * @internal
4263
+ */
4264
+ log(message) {
4265
+ if (this.debug) {
4266
+ console.warn(`[moduleRaid] ${message}`);
4267
+ }
4268
+ }
4269
+ /**
4270
+ * Method to set an alternative getter if we weren't able to extract __webpack_require__
4271
+ * from Webpack
4272
+ * @internal
4273
+ */
4274
+ replaceGet() {
4275
+ if (this.get === null) {
4276
+ this.get = (key) => this.modules[key];
4277
+ }
4278
+ }
4279
+ /**
4280
+ * Method that will try to inject a module into Webpack or get modules
4281
+ * depending on it's success it might be more or less brute about it
4282
+ * @internal
4283
+ */
4284
+ fillModules() {
4285
+ if (typeof this.target[this.entrypoint] === 'function') {
4286
+ this.functionArguments.forEach((argument, index) => {
4287
+ try {
4288
+ if (this.modules && Object.keys(this.modules).length > 0)
4289
+ return;
4290
+ this.target[this.entrypoint](...argument);
4291
+ }
4292
+ catch (err) {
4293
+ this.log(`moduleRaid.functionArguments[${index}] failed:\n${err}\n${err.stack}`);
4294
+ }
4295
+ });
4296
+ }
4297
+ else {
4298
+ this.arrayArguments.forEach((argument, index) => {
4299
+ try {
4300
+ if (this.modules && Object.keys(this.modules).length > 0)
4301
+ return;
4302
+ this.target[this.entrypoint].push(argument);
4303
+ }
4304
+ catch (err) {
4305
+ this.log(`Pushing moduleRaid.arrayArguments[${index}] into ${this.entrypoint} failed:\n${err}\n${err.stack}`);
4306
+ }
4307
+ });
4308
+ }
4309
+ if (this.modules && Object.keys(this.modules).length == 0) {
4310
+ let moduleEnd = false;
4311
+ let moduleIterator = 0;
4312
+ if (typeof this.target[this.entrypoint] != 'function' || !this.target[this.entrypoint]([], [], [moduleIterator])) {
4313
+ throw Error('Unknown Webpack structure');
4314
+ }
4315
+ while (!moduleEnd) {
4316
+ try {
4317
+ this.modules[moduleIterator] = this.target[this.entrypoint]([], [], [moduleIterator]);
4318
+ moduleIterator++;
4319
+ }
4320
+ catch (err) {
4321
+ moduleEnd = true;
4322
+ }
4323
+ }
4324
+ }
4325
+ }
4326
+ /**
4327
+ * Method to hook into `window[this.entrypoint].push` adding a listener for new
4328
+ * chunks being pushed into Webpack
4329
+ *
4330
+ * @example
4331
+ * You can listen for newly pushed packages using the `moduleraid:webpack-push` event
4332
+ * on `document`
4333
+ *
4334
+ * ```ts
4335
+ * document.addEventListener('moduleraid:webpack-push', (e) => {
4336
+ * // e.detail contains the arguments push() was called with
4337
+ * console.log(e.detail)
4338
+ * })
4339
+ * ```
4340
+ * @internal
4341
+ */
4342
+ setupPushEvent() {
4343
+ const originalPush = this.target[this.entrypoint].push;
4344
+ this.target[this.entrypoint].push = (...args) => {
4345
+ const result = Reflect.apply(originalPush, this.target[this.entrypoint], args);
4346
+ document.dispatchEvent(new CustomEvent('moduleraid:webpack-push', { detail: args }));
4347
+ return result;
4348
+ };
4349
+ }
4350
+ /**
4351
+ * Method to try autodetecting a Webpack JSONP entrypoint based on common naming
4352
+ *
4353
+ * If the default entrypoint, or the entrypoint that's passed to the moduleRaid constructor
4354
+ * already matches, the method exits early
4355
+ *
4356
+ * If `options.strict` has been set in the constructor and the initial entrypoint cannot
4357
+ * be found, this method will error, demanding a strictly set entrypoint
4358
+ * @internal
4359
+ */
4360
+ detectEntrypoint() {
4361
+ if (this.target[this.entrypoint] != undefined) {
4362
+ return;
4363
+ }
4364
+ if (this.strict) {
4365
+ throw Error(`Strict mode is enabled and entrypoint at window.${this.entrypoint} couldn't be found. Please specify the correct one!`);
4366
+ }
4367
+ let windowObjects = Object.keys(this.target);
4368
+ windowObjects = windowObjects
4369
+ .filter((object) => object.toLowerCase().includes('chunk') || object.toLowerCase().includes('webpack'))
4370
+ .filter((object) => typeof this.target[object] === 'function' || Array.isArray(this.target[object]));
4371
+ if (windowObjects.length > 1) {
4372
+ throw Error(`Multiple possible endpoints have been detected, please create a new moduleRaid instance with a specific one:\n${windowObjects.join(', ')}`);
4373
+ }
4374
+ if (windowObjects.length === 0) {
4375
+ throw Error('No Webpack JSONP entrypoints could be detected');
4376
+ }
4377
+ this.log(`Entrypoint has been detected at window.${windowObjects[0]} and set for injection`);
4378
+ this.entrypoint = windowObjects[0];
4379
+ }
4380
+ /**
4381
+ * Recursive object-search function for modules
4382
+ *
4383
+ * @param object the object to search through
4384
+ * @param query the query the object keys/values are searched for
4385
+ * @returns boolean state of `object` containing `query` somewhere in it
4386
+ * @internal
4387
+ */
4388
+ searchObject(object, query) {
4389
+ for (const key in object) {
4390
+ const value = object[key];
4391
+ const lowerCaseQuery = query.toLowerCase();
4392
+ if (typeof value != 'object') {
4393
+ const lowerCaseKey = key.toString().toLowerCase();
4394
+ if (lowerCaseKey.includes(lowerCaseQuery))
4395
+ return true;
4396
+ if (typeof value != 'object') {
4397
+ const lowerCaseValue = value.toString().toLowerCase();
4398
+ if (lowerCaseValue.includes(lowerCaseQuery))
4399
+ return true;
4400
+ }
4401
+ else {
4402
+ if (this.searchObject(value, query))
4403
+ return true;
4404
+ }
4405
+ }
4406
+ }
4407
+ return false;
4408
+ }
4409
+ /**
4410
+ * Method to search through the module object, searching for the fitting content
4411
+ * if a string is supplied
4412
+ *
4413
+ * If query is supplied as a function, everything that returns true when passed
4414
+ * to the query function will be returned
4415
+ *
4416
+ * @example
4417
+ * With a string as query argument:
4418
+ * ```ts
4419
+ * const results = mR.findModule('feature')
4420
+ * // => Array of module results
4421
+ * ```
4422
+ *
4423
+ * With a function as query argument:
4424
+ * ```ts
4425
+ * const results = mR.findModule((module) => { typeof module === 'function' })
4426
+ * // => Array of module results
4427
+ * ```
4428
+ *
4429
+ * @param query query to search the module list for
4430
+ * @return a list of modules fitting the query
4431
+ */
4432
+ findModule(query) {
4433
+ const results = [];
4434
+ const modules = Object.keys(this.modules);
4435
+ if (modules.length === 0) {
4436
+ throw new Error('There are no modules to search through!');
4437
+ }
4438
+ modules.forEach((key) => {
4439
+ const module = this.modules[key.toString()];
4440
+ if (module === undefined)
4441
+ return;
4442
+ try {
4443
+ if (typeof query === 'string') {
4444
+ query = query.toLowerCase();
4445
+ switch (typeof module) {
4446
+ case 'string':
4447
+ if (module.toLowerCase().includes(query))
4448
+ results.push(module);
4449
+ break;
4450
+ case 'function':
4451
+ if (module.toString().toLowerCase().includes(query))
4452
+ results.push(module);
4453
+ break;
4454
+ case 'object':
4455
+ if (this.searchObject(module, query))
4456
+ results.push(module);
4457
+ break;
4458
+ }
4459
+ }
4460
+ else if (typeof query === 'function') {
4461
+ if (query(module))
4462
+ results.push(module);
4463
+ }
4464
+ else {
4465
+ throw new TypeError(`findModule can only find via string and function, ${typeof query} was passed`);
4466
+ }
4467
+ }
4468
+ catch (err) {
4469
+ this.log(`There was an error while searching through module '${key}':\n${err}\n${err.stack}`);
4470
+ }
4471
+ });
4472
+ return results;
4473
+ }
4474
+ /**
4475
+ * Method to search through the constructor array, searching for the fitting content
4476
+ * if a string is supplied
4477
+ *
4478
+ * If query is supplied as a function, everything that returns true when passed
4479
+ * to the query function will be returned
4480
+ *
4481
+ * @example
4482
+ * With a string as query argument:
4483
+ * ```ts
4484
+ * const results = mR.findConstructor('feature')
4485
+ * // => Array of constructor/module tuples
4486
+ * ```
4487
+ *
4488
+ * With a function as query argument:
4489
+ * ```ts
4490
+ * const results = mR.findConstructor((constructor) => { constructor.prototype.value !== undefined })
4491
+ * // => Array of constructor/module tuples
4492
+ * ```
4493
+ *
4494
+ * Accessing the resulting data:
4495
+ * ```ts
4496
+ * // With array destructuring (ES6)
4497
+ * const [constructor, module] = results[0]
4498
+ *
4499
+ * // ...or...
4500
+ *
4501
+ * // regular access
4502
+ * const constructor = results[0][0]
4503
+ * const module = results[0][1]
4504
+ * ```
4505
+ *
4506
+ * @param query query to search the constructor list for
4507
+ * @returns a list of constructor/module tuples fitting the query
4508
+ */
4509
+ findConstructor(query) {
4510
+ const results = [];
4511
+ const constructors = Object.keys(this.constructors);
4512
+ if (constructors.length === 0) {
4513
+ throw new Error('There are no constructors to search through!');
4514
+ }
4515
+ constructors.forEach((key) => {
4516
+ const constructor = this.constructors[key];
4517
+ try {
4518
+ if (typeof query === 'string') {
4519
+ query = query.toLowerCase();
4520
+ if (constructor.toString().toLowerCase().includes(query))
4521
+ results.push([this.constructors[key], this.modules[key]]);
4522
+ }
4523
+ else if (typeof query === 'function') {
4524
+ if (query(constructor))
4525
+ results.push([this.constructors[key], this.modules[key]]);
4526
+ }
4527
+ }
4528
+ catch (err) {
4529
+ this.log(`There was an error while searching through constructor '${key}':\n${err}\n${err.stack}`);
4530
+ }
4531
+ });
4532
+ return results;
4533
+ }
4534
+ }
4535
+
4138
4536
  class Utils {
4139
4537
  windowApi;
4140
4538
  constructor(option) {
4141
4539
  this.windowApi = new WindowApi(option);
4142
4540
  }
4143
4541
  /** 版本号 */
4144
- version = "2024.12.25";
4542
+ version = "2025.1.11";
4145
4543
  addStyle(cssText) {
4146
4544
  if (typeof cssText !== "string") {
4147
4545
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -4364,8 +4762,8 @@ define((function () { 'use strict';
4364
4762
  ColorConversion = ColorConversion;
4365
4763
  deepClone(obj) {
4366
4764
  let UtilsContext = this;
4367
- if (obj === void 0)
4368
- return void 0;
4765
+ if (obj === undefined)
4766
+ return undefined;
4369
4767
  if (obj === null)
4370
4768
  return null;
4371
4769
  let clone = obj instanceof Array ? [] : {};
@@ -5811,36 +6209,36 @@ define((function () { 'use strict';
5811
6209
  * + true 监听以 target 为根节点的整个子树。包括子树中所有节点的属性,而不仅仅是针对 target
5812
6210
  * + false (默认) 不生效
5813
6211
  */
5814
- subtree: void 0,
6212
+ subtree: undefined,
5815
6213
  /**
5816
6214
  * + true 监听 target 节点中发生的节点的新增与删除(同时,如果 subtree 为 true,会针对整个子树生效)
5817
6215
  * + false (默认) 不生效
5818
6216
  */
5819
- childList: void 0,
6217
+ childList: undefined,
5820
6218
  /**
5821
6219
  * + true 观察所有监听的节点属性值的变化。默认值为 true,当声明了 attributeFilter 或 attributeOldValue
5822
6220
  * + false (默认) 不生效
5823
6221
  */
5824
- attributes: void 0,
6222
+ attributes: undefined,
5825
6223
  /**
5826
6224
  * 一个用于声明哪些属性名会被监听的数组。如果不声明该属性,所有属性的变化都将触发通知
5827
6225
  */
5828
- attributeFilter: void 0,
6226
+ attributeFilter: undefined,
5829
6227
  /**
5830
6228
  * + true 记录上一次被监听的节点的属性变化;可查阅 MutationObserver 中的 Monitoring attribute values 了解关于观察属性变化和属性值记录的详情
5831
6229
  * + false (默认) 不生效
5832
6230
  */
5833
- attributeOldValue: void 0,
6231
+ attributeOldValue: undefined,
5834
6232
  /**
5835
6233
  * + true 监听声明的 target 节点上所有字符的变化。默认值为 true,如果声明了 characterDataOldValue
5836
6234
  * + false (默认) 不生效
5837
6235
  */
5838
- characterData: void 0,
6236
+ characterData: undefined,
5839
6237
  /**
5840
6238
  * + true 记录前一个被监听的节点中发生的文本变化
5841
6239
  * + false (默认) 不生效
5842
6240
  */
5843
- characterDataOldValue: void 0,
6241
+ characterDataOldValue: undefined,
5844
6242
  },
5845
6243
  immediate: false,
5846
6244
  };
@@ -6415,7 +6813,7 @@ define((function () { 'use strict';
6415
6813
  }
6416
6814
  return new Promise((resolve) => {
6417
6815
  setTimeout(() => {
6418
- resolve(void 0);
6816
+ resolve(undefined);
6419
6817
  }, delayTime);
6420
6818
  });
6421
6819
  }
@@ -6755,9 +7153,42 @@ define((function () { 'use strict';
6755
7153
  await UtilsContext.tryCatch(index, item).run(handleFunc);
6756
7154
  }));
6757
7155
  }
7156
+ wait(checkFn, timeout, parent) {
7157
+ const UtilsContext = this;
7158
+ let __timeout__ = typeof timeout === "number" ? timeout : 0;
7159
+ return new Promise((resolve) => {
7160
+ let observer = UtilsContext.mutationObserver(parent || UtilsContext.windowApi.document, {
7161
+ config: {
7162
+ subtree: true,
7163
+ childList: true,
7164
+ attributes: true,
7165
+ },
7166
+ immediate: true,
7167
+ callback(mutations, __observer__) {
7168
+ let result = checkFn();
7169
+ if (result.success) {
7170
+ // 取消观察器
7171
+ if (typeof __observer__?.disconnect === "function") {
7172
+ __observer__.disconnect();
7173
+ }
7174
+ resolve(result.data);
7175
+ }
7176
+ },
7177
+ });
7178
+ if (__timeout__ > 0) {
7179
+ setTimeout(() => {
7180
+ // 取消观察器
7181
+ if (typeof observer?.disconnect === "function") {
7182
+ observer.disconnect();
7183
+ }
7184
+ resolve(null);
7185
+ }, __timeout__);
7186
+ }
7187
+ });
7188
+ }
6758
7189
  waitNode(...args) {
6759
7190
  // 过滤掉undefined
6760
- args = args.filter((arg) => arg !== void 0);
7191
+ args = args.filter((arg) => arg !== undefined);
6761
7192
  let UtilsContext = this;
6762
7193
  // 选择器
6763
7194
  let selector = args[0];
@@ -6765,8 +7196,10 @@ define((function () { 'use strict';
6765
7196
  let parent = UtilsContext.windowApi.document;
6766
7197
  // 超时时间
6767
7198
  let timeout = 0;
6768
- if (typeof args[0] !== "string" && !Array.isArray(args[0])) {
6769
- throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]");
7199
+ if (typeof args[0] !== "string" &&
7200
+ !Array.isArray(args[0]) &&
7201
+ typeof args[0] !== "function") {
7202
+ throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
6770
7203
  }
6771
7204
  if (args.length === 1) ;
6772
7205
  else if (args.length === 2) {
@@ -6806,57 +7239,45 @@ define((function () { 'use strict';
6806
7239
  else {
6807
7240
  throw new TypeError("Utils.waitNode 参数个数错误");
6808
7241
  }
6809
- return new Promise((resolve) => {
6810
- function getNode() {
6811
- if (Array.isArray(selector)) {
6812
- let result = [];
6813
- for (let index = 0; index < selector.length; index++) {
6814
- let node = parent.querySelector(selector[index]);
6815
- if (node) {
6816
- result.push(node);
6817
- }
6818
- }
6819
- if (result.length === selector.length) {
6820
- return result;
7242
+ function getNode() {
7243
+ if (Array.isArray(selector)) {
7244
+ let result = [];
7245
+ for (let index = 0; index < selector.length; index++) {
7246
+ let node = parent.querySelector(selector[index]);
7247
+ if (node) {
7248
+ result.push(node);
6821
7249
  }
6822
7250
  }
6823
- else {
6824
- return parent.querySelector(selector);
7251
+ if (result.length === selector.length) {
7252
+ return result;
6825
7253
  }
6826
7254
  }
6827
- var observer = UtilsContext.mutationObserver(parent, {
6828
- config: {
6829
- subtree: true,
6830
- childList: true,
6831
- attributes: true,
6832
- },
6833
- callback() {
6834
- let node = getNode();
6835
- if (node) {
6836
- // 取消观察器
6837
- if (typeof observer?.disconnect === "function") {
6838
- observer.disconnect();
6839
- }
6840
- resolve(node);
6841
- return;
6842
- }
6843
- },
6844
- immediate: true,
6845
- });
6846
- if (timeout > 0) {
6847
- setTimeout(() => {
6848
- // 取消观察器
6849
- if (typeof observer?.disconnect === "function") {
6850
- observer.disconnect();
6851
- }
6852
- resolve(null);
6853
- }, timeout);
7255
+ else if (typeof selector === "function") {
7256
+ return selector();
6854
7257
  }
6855
- });
7258
+ else {
7259
+ return parent.querySelector(selector);
7260
+ }
7261
+ }
7262
+ return UtilsContext.wait(() => {
7263
+ let node = getNode();
7264
+ if (node) {
7265
+ return {
7266
+ success: true,
7267
+ data: node,
7268
+ };
7269
+ }
7270
+ else {
7271
+ return {
7272
+ success: false,
7273
+ data: node,
7274
+ };
7275
+ }
7276
+ }, timeout, parent);
6856
7277
  }
6857
7278
  waitAnyNode(...args) {
6858
7279
  // 过滤掉undefined
6859
- args = args.filter((arg) => arg !== void 0);
7280
+ args = args.filter((arg) => arg !== undefined);
6860
7281
  let UtilsContext = this;
6861
7282
  // 选择器
6862
7283
  let selectorList = args[0];
@@ -6912,7 +7333,7 @@ define((function () { 'use strict';
6912
7333
  }
6913
7334
  waitNodeList(...args) {
6914
7335
  // 过滤掉undefined
6915
- args = args.filter((arg) => arg !== void 0);
7336
+ args = args.filter((arg) => arg !== undefined);
6916
7337
  let UtilsContext = this;
6917
7338
  // 选择器数组
6918
7339
  let selector = args[0];
@@ -6961,61 +7382,45 @@ define((function () { 'use strict';
6961
7382
  else {
6962
7383
  throw new TypeError("Utils.waitNodeList 参数个数错误");
6963
7384
  }
6964
- return new Promise((resolve) => {
6965
- function getNodeList() {
6966
- if (Array.isArray(selector)) {
6967
- let result = [];
6968
- for (let index = 0; index < selector.length; index++) {
6969
- let nodeList = parent.querySelectorAll(selector[index]);
6970
- if (nodeList.length) {
6971
- result.push(nodeList);
6972
- }
6973
- }
6974
- if (result.length === selector.length) {
6975
- return result;
6976
- }
6977
- }
6978
- else {
6979
- let nodeList = parent.querySelectorAll(selector);
7385
+ function getNodeList() {
7386
+ if (Array.isArray(selector)) {
7387
+ let result = [];
7388
+ for (let index = 0; index < selector.length; index++) {
7389
+ let nodeList = parent.querySelectorAll(selector[index]);
6980
7390
  if (nodeList.length) {
6981
- return nodeList;
7391
+ result.push(nodeList);
6982
7392
  }
6983
7393
  }
7394
+ if (result.length === selector.length) {
7395
+ return result;
7396
+ }
6984
7397
  }
6985
- var observer = UtilsContext.mutationObserver(parent, {
6986
- config: {
6987
- subtree: true,
6988
- childList: true,
6989
- attributes: true,
6990
- },
6991
- callback() {
6992
- let node = getNodeList();
6993
- if (node) {
6994
- // 取消观察器
6995
- try {
6996
- observer.disconnect();
6997
- }
6998
- catch (error) { }
6999
- resolve(node);
7000
- return;
7001
- }
7002
- },
7003
- immediate: true,
7004
- });
7005
- if (timeout > 0) {
7006
- setTimeout(() => {
7007
- // 取消观察器
7008
- if (typeof observer?.disconnect === "function") {
7009
- observer.disconnect();
7010
- }
7011
- resolve(null);
7012
- }, timeout);
7398
+ else {
7399
+ let nodeList = parent.querySelectorAll(selector);
7400
+ if (nodeList.length) {
7401
+ return nodeList;
7402
+ }
7013
7403
  }
7014
- });
7404
+ }
7405
+ return UtilsContext.wait(() => {
7406
+ let node = getNodeList();
7407
+ if (node) {
7408
+ return {
7409
+ success: true,
7410
+ data: node,
7411
+ };
7412
+ }
7413
+ else {
7414
+ return {
7415
+ success: false,
7416
+ data: node,
7417
+ };
7418
+ }
7419
+ }, timeout, parent);
7015
7420
  }
7016
7421
  waitAnyNodeList(...args) {
7017
7422
  // 过滤掉undefined
7018
- args = args.filter((arg) => arg !== void 0);
7423
+ args = args.filter((arg) => arg !== undefined);
7019
7424
  let UtilsContext = this;
7020
7425
  // 选择器数组
7021
7426
  let selectorList = args[0];
@@ -7313,6 +7718,7 @@ define((function () { 'use strict';
7313
7718
  * > "测试"
7314
7719
  */
7315
7720
  Vue = Vue;
7721
+ ModuleRaid = ModuleRaid;
7316
7722
  }
7317
7723
  let utils = new Utils();
7318
7724