@whitesev/pops 3.2.2 → 3.3.0
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 +35 -282
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +35 -282
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +35 -282
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +35 -282
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +35 -282
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +35 -282
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/PopsCore.d.ts +15 -7
- package/package.json +3 -4
- package/src/PopsCore.ts +30 -14
- package/src/utils/PopsUtils.ts +4 -34
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const OriginPrototype: {
|
|
2
|
+
Object: {
|
|
3
|
+
defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
declare const PopsCoreDefaultApi: {
|
|
2
7
|
document: Document;
|
|
3
8
|
window: Window & typeof globalThis;
|
|
4
9
|
globalThis: typeof globalThis;
|
|
5
10
|
self: Window & typeof globalThis;
|
|
11
|
+
setTimeout: typeof setTimeout;
|
|
12
|
+
setInterval: typeof setInterval;
|
|
13
|
+
clearTimeout: typeof clearTimeout;
|
|
14
|
+
clearInterval: typeof clearInterval;
|
|
6
15
|
};
|
|
7
16
|
declare const PopsCore: {
|
|
8
|
-
init(option?: typeof
|
|
17
|
+
init(option?: typeof PopsCoreDefaultApi): void;
|
|
9
18
|
readonly document: Document;
|
|
10
19
|
readonly window: Window & typeof globalThis;
|
|
11
20
|
readonly globalThis: typeof globalThis;
|
|
12
21
|
readonly self: Window & typeof globalThis;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
22
|
+
readonly setTimeout: typeof setTimeout;
|
|
23
|
+
readonly setInterval: typeof setInterval;
|
|
24
|
+
readonly clearTimeout: typeof clearTimeout;
|
|
25
|
+
readonly clearInterval: typeof clearInterval;
|
|
18
26
|
};
|
|
19
27
|
export { PopsCore, OriginPrototype };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitesev/pops",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "弹窗库,包含了alert、confirm、prompt、drawer、loading、iframe、rightClickMenu
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "弹窗库,包含了alert、confirm、prompt、drawer、folder、loading、iframe、panel、tooltip、searchSuggestion、rightClickMenu组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ScriptCat",
|
|
7
7
|
"TamperMonkey",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"any-touch": "^2.2.0"
|
|
44
|
-
"worker-timers": "8.0.30"
|
|
43
|
+
"any-touch": "^2.2.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@eslint/js": "^9.39.2",
|
package/src/PopsCore.ts
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
|
-
const
|
|
1
|
+
const OriginPrototype = {
|
|
2
|
+
Object: {
|
|
3
|
+
defineProperty: Object.defineProperty,
|
|
4
|
+
},
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const PopsCoreDefaultApi = {
|
|
2
8
|
document: document,
|
|
3
9
|
window: window,
|
|
4
10
|
globalThis: globalThis,
|
|
5
11
|
self: self,
|
|
12
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
13
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
14
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
15
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
6
16
|
};
|
|
7
17
|
|
|
8
|
-
const
|
|
18
|
+
const PopsCoreApi = Object.assign({}, PopsCoreDefaultApi);
|
|
9
19
|
|
|
10
20
|
const PopsCore = {
|
|
11
|
-
init(option?: typeof
|
|
21
|
+
init(option?: typeof PopsCoreDefaultApi) {
|
|
12
22
|
if (!option) {
|
|
13
|
-
option = Object.assign({},
|
|
23
|
+
option = Object.assign({}, PopsCoreDefaultApi);
|
|
14
24
|
}
|
|
15
|
-
Object.assign(
|
|
25
|
+
Object.assign(PopsCoreApi, option);
|
|
16
26
|
},
|
|
17
27
|
get document() {
|
|
18
|
-
return
|
|
28
|
+
return PopsCoreApi.document;
|
|
19
29
|
},
|
|
20
30
|
get window() {
|
|
21
|
-
return
|
|
31
|
+
return PopsCoreApi.window;
|
|
22
32
|
},
|
|
23
33
|
get globalThis() {
|
|
24
|
-
return
|
|
34
|
+
return PopsCoreApi.globalThis;
|
|
25
35
|
},
|
|
26
36
|
get self() {
|
|
27
|
-
return
|
|
37
|
+
return PopsCoreApi.self;
|
|
28
38
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
get setTimeout() {
|
|
40
|
+
return PopsCoreApi.setTimeout;
|
|
41
|
+
},
|
|
42
|
+
get setInterval() {
|
|
43
|
+
return PopsCoreApi.setInterval;
|
|
44
|
+
},
|
|
45
|
+
get clearTimeout() {
|
|
46
|
+
return PopsCoreApi.clearTimeout;
|
|
47
|
+
},
|
|
48
|
+
get clearInterval() {
|
|
49
|
+
return PopsCoreApi.clearInterval;
|
|
34
50
|
},
|
|
35
51
|
};
|
|
36
52
|
|
package/src/utils/PopsUtils.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { PopsCore } from "../PopsCore";
|
|
2
2
|
import type { PopsUtilsOwnObject } from "../types/main";
|
|
3
|
-
import {
|
|
4
|
-
clearInterval as WorkerClearInterval,
|
|
5
|
-
clearTimeout as WorkerClearTimeout,
|
|
6
|
-
setInterval as WorkerSetInterval,
|
|
7
|
-
setTimeout as WorkerSetTimeout,
|
|
8
|
-
} from "worker-timers";
|
|
9
3
|
import AnyTouch from "any-touch";
|
|
10
4
|
|
|
11
5
|
class PopsUtils {
|
|
@@ -356,49 +350,25 @@ class PopsUtils {
|
|
|
356
350
|
* 自动使用 Worker 执行 setTimeout
|
|
357
351
|
*/
|
|
358
352
|
setTimeout(callback: (...args: any[]) => any, timeout: number = 0) {
|
|
359
|
-
|
|
360
|
-
return WorkerSetTimeout(callback, timeout);
|
|
361
|
-
} catch {
|
|
362
|
-
return setTimeout(callback, timeout);
|
|
363
|
-
}
|
|
353
|
+
return PopsCore.setTimeout(callback, timeout);
|
|
364
354
|
}
|
|
365
355
|
/**
|
|
366
356
|
* 配合 .setTimeout 使用
|
|
367
357
|
*/
|
|
368
358
|
clearTimeout(timeId: number | undefined) {
|
|
369
|
-
|
|
370
|
-
if (timeId != null) {
|
|
371
|
-
WorkerClearTimeout(timeId);
|
|
372
|
-
}
|
|
373
|
-
} catch {
|
|
374
|
-
// TODO
|
|
375
|
-
} finally {
|
|
376
|
-
clearTimeout(timeId);
|
|
377
|
-
}
|
|
359
|
+
return PopsCore.clearTimeout(timeId);
|
|
378
360
|
}
|
|
379
361
|
/**
|
|
380
362
|
* 自动使用 Worker 执行 setInterval
|
|
381
363
|
*/
|
|
382
364
|
setInterval(callback: (...args: any[]) => any, timeout: number = 0) {
|
|
383
|
-
|
|
384
|
-
return WorkerSetInterval(callback, timeout);
|
|
385
|
-
} catch {
|
|
386
|
-
return setInterval(callback, timeout);
|
|
387
|
-
}
|
|
365
|
+
return PopsCore.setInterval(callback, timeout);
|
|
388
366
|
}
|
|
389
367
|
/**
|
|
390
368
|
* 配合 .setInterval 使用
|
|
391
369
|
*/
|
|
392
370
|
clearInterval(timeId: number | undefined) {
|
|
393
|
-
|
|
394
|
-
if (timeId != null) {
|
|
395
|
-
WorkerClearInterval(timeId);
|
|
396
|
-
}
|
|
397
|
-
} catch {
|
|
398
|
-
// 忽略
|
|
399
|
-
} finally {
|
|
400
|
-
clearInterval(timeId);
|
|
401
|
-
}
|
|
371
|
+
return PopsCore.clearInterval(timeId);
|
|
402
372
|
}
|
|
403
373
|
/**
|
|
404
374
|
* 覆盖对象中的数组新值
|