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