@whitesev/utils 2.11.3 → 2.11.5
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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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/Utils.d.ts +20 -0
- package/package.json +1 -1
- package/src/Utils.ts +73 -2
package/dist/index.system.js
CHANGED
|
@@ -242,7 +242,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
242
242
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
243
243
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
244
244
|
|
|
245
|
-
const version = "2.11.
|
|
245
|
+
const version = "2.11.5";
|
|
246
246
|
|
|
247
247
|
/* eslint-disable */
|
|
248
248
|
// ==UserScript==
|
|
@@ -7516,8 +7516,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7516
7516
|
}
|
|
7517
7517
|
async init() {
|
|
7518
7518
|
let copyStatus = false;
|
|
7519
|
-
|
|
7520
|
-
console.log(requestPermissionStatus);
|
|
7519
|
+
await this.requestClipboardPermission();
|
|
7521
7520
|
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7522
7521
|
try {
|
|
7523
7522
|
copyStatus = await this.copyDataByClipboard();
|
|
@@ -8485,6 +8484,58 @@ System.register('Utils', [], (function (exports) {
|
|
|
8485
8484
|
}
|
|
8486
8485
|
});
|
|
8487
8486
|
}
|
|
8487
|
+
calcPositionDistance(...args) {
|
|
8488
|
+
let position = {
|
|
8489
|
+
x: 0,
|
|
8490
|
+
y: 0,
|
|
8491
|
+
};
|
|
8492
|
+
let otherPosition = {
|
|
8493
|
+
x: 0,
|
|
8494
|
+
y: 0,
|
|
8495
|
+
};
|
|
8496
|
+
if (typeof args[0] === "object" && args[0] != null && typeof args[1] === "object" && args[1] != null) {
|
|
8497
|
+
position = args[0];
|
|
8498
|
+
otherPosition = args[1];
|
|
8499
|
+
}
|
|
8500
|
+
else if (args.length === 4) {
|
|
8501
|
+
position = {
|
|
8502
|
+
x: args[0],
|
|
8503
|
+
y: args[1],
|
|
8504
|
+
};
|
|
8505
|
+
otherPosition = {
|
|
8506
|
+
x: args[2],
|
|
8507
|
+
y: args[3],
|
|
8508
|
+
};
|
|
8509
|
+
}
|
|
8510
|
+
else {
|
|
8511
|
+
throw new Error("Invalid arguments");
|
|
8512
|
+
}
|
|
8513
|
+
if (typeof position.x === "string") {
|
|
8514
|
+
position.x = Number(position.x);
|
|
8515
|
+
}
|
|
8516
|
+
if (isNaN(position.x)) {
|
|
8517
|
+
throw new Error(`Invalid x: ${position.x}`);
|
|
8518
|
+
}
|
|
8519
|
+
if (typeof position.y === "string") {
|
|
8520
|
+
position.y = Number(position.y);
|
|
8521
|
+
}
|
|
8522
|
+
if (isNaN(position.y)) {
|
|
8523
|
+
throw new Error(`Invalid y: ${position.y}`);
|
|
8524
|
+
}
|
|
8525
|
+
if (typeof otherPosition.x === "string") {
|
|
8526
|
+
otherPosition.x = Number(otherPosition.x);
|
|
8527
|
+
}
|
|
8528
|
+
if (isNaN(otherPosition.x)) {
|
|
8529
|
+
throw new Error(`Invalid x: ${otherPosition.x}`);
|
|
8530
|
+
}
|
|
8531
|
+
if (typeof otherPosition.y === "string") {
|
|
8532
|
+
otherPosition.y = Number(otherPosition.y);
|
|
8533
|
+
}
|
|
8534
|
+
if (isNaN(otherPosition.y)) {
|
|
8535
|
+
throw new Error(`Invalid y: ${otherPosition.y}`);
|
|
8536
|
+
}
|
|
8537
|
+
return Math.sqrt(Math.pow(otherPosition.x - position.x, 2) + Math.pow(otherPosition.y - position.y, 2));
|
|
8538
|
+
}
|
|
8488
8539
|
}
|
|
8489
8540
|
const utils = exports("default", new Utils());
|
|
8490
8541
|
|