tools-min-ns 1.18.4 → 1.18.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/README.md CHANGED
@@ -5,6 +5,8 @@ pnpm i tools-min-ns --save
5
5
  ```
6
6
 
7
7
  # updates
8
+ ## v1.18.5
9
+ 减小包体积
8
10
  ## v1.18.3/4
9
11
  请求校验
10
12
  ## v1.18.2
@@ -10,8 +10,7 @@ declare namespace BrowserUtil {
10
10
  /**
11
11
  * 获取浏览器id
12
12
  */
13
- const getId: () => Promise<any>;
14
- function getIdSync(): string;
13
+ function getId(): string;
15
14
  /**
16
15
  * 获取浏览器类型
17
16
  * @returns Opera | IE | Edge | Firefox | Safari | Chrome | OverIE10 | ""
@@ -1,148 +1,15 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) {
9
- try {
10
- step(generator.next(value));
11
- } catch (e) {
12
- reject(e);
13
- }
14
- }
15
- function rejected(value) {
16
- try {
17
- step(generator["throw"](value));
18
- } catch (e) {
19
- reject(e);
20
- }
21
- }
22
- function step(result) {
23
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
24
- }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
- var __generator = this && this.__generator || function (thisArg, body) {
29
- var _ = {
30
- label: 0,
31
- sent: function sent() {
32
- if (t[0] & 1) throw t[1];
33
- return t[1];
34
- },
35
- trys: [],
36
- ops: []
37
- },
38
- f,
39
- y,
40
- t,
41
- g;
42
- return g = {
43
- next: verb(0),
44
- "throw": verb(1),
45
- "return": verb(2)
46
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
47
- return this;
48
- }), g;
49
- function verb(n) {
50
- return function (v) {
51
- return step([n, v]);
52
- };
53
- }
54
- function step(op) {
55
- if (f) throw new TypeError("Generator is already executing.");
56
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
57
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
- if (y = 0, t) op = [op[0] & 2, t.value];
59
- switch (op[0]) {
60
- case 0:
61
- case 1:
62
- t = op;
63
- break;
64
- case 4:
65
- _.label++;
66
- return {
67
- value: op[1],
68
- done: false
69
- };
70
- case 5:
71
- _.label++;
72
- y = op[1];
73
- op = [0];
74
- continue;
75
- case 7:
76
- op = _.ops.pop();
77
- _.trys.pop();
78
- continue;
79
- default:
80
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
81
- _ = 0;
82
- continue;
83
- }
84
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
85
- _.label = op[1];
86
- break;
87
- }
88
- if (op[0] === 6 && _.label < t[1]) {
89
- _.label = t[1];
90
- t = op;
91
- break;
92
- }
93
- if (t && _.label < t[2]) {
94
- _.label = t[2];
95
- _.ops.push(op);
96
- break;
97
- }
98
- if (t[2]) _.ops.pop();
99
- _.trys.pop();
100
- continue;
101
- }
102
- op = body.call(thisArg, _);
103
- } catch (e) {
104
- op = [6, e];
105
- y = 0;
106
- } finally {
107
- f = t = 0;
108
- }
109
- if (op[0] & 5) throw op[1];
110
- return {
111
- value: op[0] ? op[1] : void 0,
112
- done: true
113
- };
114
- }
115
- };
116
1
  import BaseUtil from '../base/BaseUtil';
117
2
  import env from '../env/env';
118
- import fingerprint from './fingerprint';
119
3
  function isInUserAgent(v) {
120
4
  var _a, _b;
121
5
  return !!((_b = (_a = env.getGlobal()) === null || _a === void 0 ? void 0 : _a.navigator.userAgent) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(v));
122
6
  }
123
7
  var BrowserUtil;
124
8
  (function (BrowserUtil) {
125
- var _this = this;
126
9
  /**
127
10
  * 获取浏览器id
128
11
  */
129
- BrowserUtil.getId = function () {
130
- return __awaiter(_this, void 0, void 0, function () {
131
- var visitorId;
132
- return __generator(this, function (_a) {
133
- switch (_a.label) {
134
- case 0:
135
- return [4 /*yield*/, fingerprint.load()];
136
- case 1:
137
- return [4 /*yield*/, _a.sent().get()];
138
- case 2:
139
- visitorId = _a.sent().visitorId;
140
- return [2 /*return*/, visitorId];
141
- }
142
- });
143
- });
144
- };
145
- function getIdSync() {
12
+ function getId() {
146
13
  var fingerprint;
147
14
  var canvas = document.createElement('canvas');
148
15
  var ctx = canvas.getContext('2d');
@@ -162,7 +29,7 @@ var BrowserUtil;
162
29
  fingerprint = crc;
163
30
  return fingerprint;
164
31
  }
165
- BrowserUtil.getIdSync = getIdSync;
32
+ BrowserUtil.getId = getId;
166
33
  /**
167
34
  * 获取浏览器类型
168
35
  * @returns Opera | IE | Edge | Firefox | Safari | Chrome | OverIE10 | ""
@@ -1,12 +1,3 @@
1
- // Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
2
- // This work is free. You can redistribute it and/or modify it
3
- // under the terms of the WTFPL, Version 2
4
- // For more information see LICENSE.txt or http://www.wtfpl.net/
5
- //
6
- // For more information, the home page:
7
- // http://pieroxy.net/blog/pages/lz-string/testing.html
8
- //
9
- // LZ-based compression algorithm, version 1.4.5
10
1
  var LZString = function () {
11
2
  // private property
12
3
  var f = String.fromCharCode;
@@ -10,8 +10,7 @@ declare namespace BrowserUtil {
10
10
  /**
11
11
  * 获取浏览器id
12
12
  */
13
- const getId: () => Promise<any>;
14
- function getIdSync(): string;
13
+ function getId(): string;
15
14
  /**
16
15
  * 获取浏览器类型
17
16
  * @returns Opera | IE | Edge | Firefox | Safari | Chrome | OverIE10 | ""
@@ -1,120 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) {
5
- return value instanceof P ? value : new P(function (resolve) {
6
- resolve(value);
7
- });
8
- }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) {
11
- try {
12
- step(generator.next(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- }
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
- function step(result) {
25
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
- }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = this && this.__generator || function (thisArg, body) {
31
- var _ = {
32
- label: 0,
33
- sent: function sent() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- },
40
- f,
41
- y,
42
- t,
43
- g;
44
- return g = {
45
- next: verb(0),
46
- "throw": verb(1),
47
- "return": verb(2)
48
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
49
- return this;
50
- }), g;
51
- function verb(n) {
52
- return function (v) {
53
- return step([n, v]);
54
- };
55
- }
56
- function step(op) {
57
- if (f) throw new TypeError("Generator is already executing.");
58
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
59
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
60
- if (y = 0, t) op = [op[0] & 2, t.value];
61
- switch (op[0]) {
62
- case 0:
63
- case 1:
64
- t = op;
65
- break;
66
- case 4:
67
- _.label++;
68
- return {
69
- value: op[1],
70
- done: false
71
- };
72
- case 5:
73
- _.label++;
74
- y = op[1];
75
- op = [0];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
105
- } catch (e) {
106
- op = [6, e];
107
- y = 0;
108
- } finally {
109
- f = t = 0;
110
- }
111
- if (op[0] & 5) throw op[1];
112
- return {
113
- value: op[0] ? op[1] : void 0,
114
- done: true
115
- };
116
- }
117
- };
118
3
  var __importDefault = this && this.__importDefault || function (mod) {
119
4
  return mod && mod.__esModule ? mod : {
120
5
  "default": mod
@@ -125,34 +10,16 @@ Object.defineProperty(exports, "__esModule", {
125
10
  });
126
11
  var BaseUtil_1 = __importDefault(require("../base/BaseUtil"));
127
12
  var env_1 = __importDefault(require("../env/env"));
128
- var fingerprint_1 = __importDefault(require("./fingerprint"));
129
13
  function isInUserAgent(v) {
130
14
  var _a, _b;
131
15
  return !!((_b = (_a = env_1.default.getGlobal()) === null || _a === void 0 ? void 0 : _a.navigator.userAgent) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(v));
132
16
  }
133
17
  var BrowserUtil;
134
18
  (function (BrowserUtil) {
135
- var _this = this;
136
19
  /**
137
20
  * 获取浏览器id
138
21
  */
139
- BrowserUtil.getId = function () {
140
- return __awaiter(_this, void 0, void 0, function () {
141
- var visitorId;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0:
145
- return [4 /*yield*/, fingerprint_1.default.load()];
146
- case 1:
147
- return [4 /*yield*/, _a.sent().get()];
148
- case 2:
149
- visitorId = _a.sent().visitorId;
150
- return [2 /*return*/, visitorId];
151
- }
152
- });
153
- });
154
- };
155
- function getIdSync() {
22
+ function getId() {
156
23
  var fingerprint;
157
24
  var canvas = document.createElement('canvas');
158
25
  var ctx = canvas.getContext('2d');
@@ -172,7 +39,7 @@ var BrowserUtil;
172
39
  fingerprint = crc;
173
40
  return fingerprint;
174
41
  }
175
- BrowserUtil.getIdSync = getIdSync;
42
+ BrowserUtil.getId = getId;
176
43
  /**
177
44
  * 获取浏览器类型
178
45
  * @returns Opera | IE | Edge | Firefox | Safari | Chrome | OverIE10 | ""
@@ -3,15 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- // Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
7
- // This work is free. You can redistribute it and/or modify it
8
- // under the terms of the WTFPL, Version 2
9
- // For more information see LICENSE.txt or http://www.wtfpl.net/
10
- //
11
- // For more information, the home page:
12
- // http://pieroxy.net/blog/pages/lz-string/testing.html
13
- //
14
- // LZ-based compression algorithm, version 1.4.5
15
6
  var LZString = function () {
16
7
  // private property
17
8
  var f = String.fromCharCode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tools-min-ns",
3
3
  "description": "工具包适用于前端以及node",
4
- "version": "1.18.4",
4
+ "version": "1.18.5",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",
7
7
  "author": "nanshen",
@@ -1,120 +0,0 @@
1
- declare function Fe(n: any): string;
2
- declare namespace Xe {
3
- export { je as load };
4
- export { Ge as hashComponents };
5
- export { Fe as componentsToDebugString };
6
- }
7
- declare function z(): boolean;
8
- declare function A(): any;
9
- declare function _(): any;
10
- declare function K(e: any): any;
11
- declare function re(): () => any;
12
- declare function ee(): any[];
13
- declare function ke(e: any): any;
14
- declare function be(e: any): -2 | -3;
15
- declare function Ge(e: any): string;
16
- declare function N(): boolean;
17
- declare function j(): boolean;
18
- declare function P(): boolean;
19
- declare function Y(): boolean;
20
- declare function C(): boolean;
21
- declare function I(): boolean;
22
- declare function X(): boolean;
23
- declare function je(e: any): any;
24
- declare function F(e: any, r: any, o: any): () => any;
25
- declare function Pe(e: any, n: any): string;
26
- declare function Ie(e: any): Promise<any>;
27
- declare function O(e: any): Promise<any>;
28
- declare namespace Me {
29
- function fonts(): any;
30
- function domBlockers(e: any): any;
31
- function fontPreferences(): any;
32
- function audio(): any;
33
- function screenFrame(): () => any;
34
- function canvas(): any;
35
- function osCpu(): any;
36
- function languages(): any[];
37
- function colorDepth(): number;
38
- function deviceMemory(): any;
39
- function screenResolution(): any[] | undefined;
40
- function hardwareConcurrency(): any;
41
- function timezone(): string;
42
- function sessionStorage(): boolean;
43
- function localStorage(): boolean;
44
- function indexedDB(): true | undefined;
45
- function openDatabase(): boolean;
46
- function cpuClass(): any;
47
- function platform(): string;
48
- function plugins(): {
49
- name: string;
50
- description: string;
51
- mimeTypes: {
52
- type: string;
53
- suffixes: string;
54
- }[];
55
- }[] | undefined;
56
- function touchSupport(): {
57
- maxTouchPoints: number;
58
- touchEvent: boolean;
59
- touchStart: boolean;
60
- };
61
- function vendor(): string;
62
- function vendorFlavors(): string[];
63
- function cookiesEnabled(): boolean;
64
- function colorGamut(): string | undefined;
65
- function invertedColors(): boolean | undefined;
66
- function forcedColors(): boolean | undefined;
67
- function monochrome(): number | undefined;
68
- function contrast(): 0 | 10 | 1 | -1 | undefined;
69
- function reducedMotion(): boolean | undefined;
70
- function reducedTransparency(): boolean | undefined;
71
- function hdr(): boolean | undefined;
72
- function math(): {
73
- acos: number;
74
- acosh: number;
75
- acoshPf: number;
76
- asin: number;
77
- asinh: number;
78
- asinhPf: number;
79
- atanh: number;
80
- atanhPf: number;
81
- atan: number;
82
- sin: number;
83
- sinh: number;
84
- sinhPf: number;
85
- cos: number;
86
- cosh: number;
87
- coshPf: number;
88
- tan: number;
89
- tanh: number;
90
- tanhPf: number;
91
- exp: number;
92
- expm1: number;
93
- expm1Pf: number;
94
- log1p: number;
95
- log1pPf: number;
96
- powPI: number;
97
- };
98
- function pdfViewerEnabled(): boolean;
99
- function architecture(): number;
100
- function applePay(): 0 | 1 | -1 | -2 | -3;
101
- function privateClickMeasurement(): string | undefined;
102
- function webGlBasics(e: any): -1 | -2 | {
103
- version: any;
104
- vendor: any;
105
- vendorUnmasked: any;
106
- renderer: any;
107
- rendererUnmasked: any;
108
- shadingLanguageVersion: any;
109
- };
110
- function webGlExtensions(e: any): -1 | -2 | {
111
- contextAttributes: string[];
112
- parameters: string[];
113
- shaderPrecisions: string[];
114
- extensions: any;
115
- extensionParameters: string[];
116
- };
117
- }
118
- declare function G(e: any, n: any): (n: any) => any;
119
- declare function J(e: any, r: any, i: any): any;
120
- export { Fe as componentsToDebugString, Xe as default, z as doesBrowserSuspendAudioContext, A as getFullscreenElement, _ as getUnstableAudioFingerprint, K as getUnstableCanvasFingerprint, re as getUnstableScreenFrame, ee as getUnstableScreenResolution, ke as getWebGLContext, be as handleApplePayError, Ge as hashComponents, N as isAndroid, j as isChromium, P as isDesktopWebKit, Y as isEdgeHTML, C as isGecko, I as isTrident, X as isWebKit, je as load, F as loadSources, Pe as murmurX64Hash128, Ie as prepareForSources, O as renderAudio, Me as sources, G as transformSource, J as withIframe };