ranuts 0.1.0-alpha.11 → 0.1.0-alpha.13
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.d.ts +5 -3
- package/dist/index.js +25 -16
- package/dist/{mimeType-Clvz2Teb.js → mimeType-eRf1TlBb.js} +4 -9
- package/dist/{reactify-C4cesbXi.js → reactify-Z-V9Vblb.js} +3 -8
- package/dist/{ml.js → src/ml/index.js} +19 -24
- package/dist/src/node/body.d.ts +0 -1
- package/dist/src/node/command.d.ts +0 -1
- package/dist/src/node/ctx2req.d.ts +0 -1
- package/dist/src/node/fs.d.ts +0 -2
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.js +54 -0
- package/dist/src/node/paresUrl.d.ts +0 -1
- package/dist/src/node/readFile.d.ts +0 -1
- package/dist/src/node/server.d.ts +0 -1
- package/dist/src/node/stream.d.ts +0 -1
- package/dist/src/node/traverse.d.ts +0 -1
- package/dist/src/node/watchFile.d.ts +1 -1
- package/dist/src/node/websocket.d.ts +2 -6
- package/dist/src/node/ws.d.ts +0 -1
- package/dist/src/optimize/index.d.ts +3 -3
- package/dist/src/react/index.js +4 -0
- package/dist/src/utils/behavior.d.ts +1 -1
- package/dist/src/utils/bom.d.ts +7 -7
- package/dist/src/utils/device.d.ts +9 -3
- package/dist/src/utils/dom.d.ts +87 -2
- package/dist/src/utils/img.d.ts +1 -1
- package/dist/src/utils/index.d.ts +8 -4
- package/dist/src/utils/index.js +4021 -0
- package/dist/src/utils/number.d.ts +1 -1
- package/dist/src/utils/obj.d.ts +10 -3
- package/dist/src/utils/storage.d.ts +2 -0
- package/dist/src/utils/subscribe.d.ts +34 -4
- package/dist/src/utils/totp/sha/common.d.ts +151 -0
- package/dist/src/utils/totp/sha/converters.d.ts +88 -0
- package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
- package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
- package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
- package/dist/src/utils/totp/sha/sha.d.ts +103 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
- package/dist/src/utils/totp/totp.d.ts +23 -0
- package/dist/src/utils/visual/application.d.ts +10 -0
- package/dist/src/utils/visual/demo/index.d.ts +1 -0
- package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
- package/dist/src/utils/visual/enums.d.ts +21 -0
- package/dist/src/utils/visual/event/boundary.d.ts +22 -0
- package/dist/src/utils/visual/event/event.d.ts +14 -0
- package/dist/src/utils/visual/event/index.d.ts +3 -0
- package/dist/src/utils/visual/event/types.d.ts +32 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +19 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +10 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +10 -0
- package/dist/src/utils/visual/graphics/index.d.ts +3 -0
- package/dist/src/utils/visual/index.d.ts +4 -0
- package/dist/src/utils/visual/math/bezier.d.ts +2 -0
- package/dist/src/utils/visual/math/enums.d.ts +2 -0
- package/dist/src/utils/visual/math/index.d.ts +4 -0
- package/dist/src/utils/visual/math/matrix.d.ts +32 -0
- package/dist/src/utils/visual/math/transform.d.ts +27 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +9 -0
- package/dist/src/utils/visual/render/index.d.ts +3 -0
- package/dist/src/utils/visual/render/render.d.ts +10 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +7 -0
- package/dist/src/utils/visual/shape/circle.d.ts +11 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
- package/dist/src/utils/visual/shape/index.d.ts +5 -0
- package/dist/src/utils/visual/shape/polygon.d.ts +10 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
- package/dist/src/utils/visual/shape/shape.d.ts +7 -0
- package/dist/src/utils/visual/style/fill.d.ts +8 -0
- package/dist/src/utils/visual/style/index.d.ts +2 -0
- package/dist/src/utils/visual/style/line.d.ts +9 -0
- package/dist/src/utils/visual/types.d.ts +6 -0
- package/dist/src/utils/visual/vertex/application.d.ts +13 -0
- package/dist/src/utils/visual/vertex/container.d.ts +38 -0
- package/dist/src/utils/visual/vertex/index.d.ts +4 -0
- package/dist/src/utils/visual/vertex/point.d.ts +18 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
- package/dist/src/vnode/chainDom.d.ts +47 -0
- package/dist/{wasm.js → src/wasm/index.js} +4 -8
- package/dist/test/writeFile.test.d.ts +1 -0
- package/dist/tsconfig.json +1 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/ml/ml.umd.cjs +1 -1
- package/dist/umd/node/node.umd.cjs +1 -1
- package/dist/umd/react/react.umd.cjs +1 -1
- package/dist/umd/utils/utils.umd.cjs +1 -1
- package/dist/{ws-DoSbcWWZ.js → ws-CQA-0Bzm.js} +31 -53
- package/package.json +18 -16
- package/readme.md +6 -2
- package/typings.d.ts +4 -10
- package/dist/node.js +0 -27
- package/dist/react.js +0 -4
- package/dist/utils.js +0 -2092
- /package/dist/test/{server/encodeUrl.test.d.ts → encodeUrl.test.d.ts} +0 -0
- /package/dist/test/{server/escapeHtml.test.d.ts → escapeHtml.test.d.ts} +0 -0
- /package/dist/test/{server/mimeType.test.d.ts → mimeType.test.d.ts} +0 -0
- /package/dist/test/{server/server.test.d.ts → server.test.d.ts} +0 -0
- /package/dist/test/{server/status.test.d.ts → status.test.d.ts} +0 -0
- /package/dist/test/{file/writeFile.test.d.ts → totp.test.d.ts} +0 -0
- /package/dist/test/{server/websocket.test.d.ts → websocket.test.d.ts} +0 -0
package/dist/utils.js
DELETED
|
@@ -1,2092 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import { o as isString, p as randomString } from "./mimeType-Clvz2Teb.js";
|
|
8
|
-
import { C, a, F, H, b, M, R, c, d, e, f, g, h, i, j, k, l, m, n, r, q, s, t, u, v, w } from "./mimeType-Clvz2Teb.js";
|
|
9
|
-
const sections = {
|
|
10
|
-
172351395: { name: "EBML", type: "Container" },
|
|
11
|
-
646: { name: "EBMLVersion", type: "Uint" },
|
|
12
|
-
759: { name: "EBMLReadVersion", type: "Uint" },
|
|
13
|
-
754: { name: "EBMLMaxIDLength", type: "Uint" },
|
|
14
|
-
755: { name: "EBMLMaxSizeLength", type: "Uint" },
|
|
15
|
-
642: { name: "DocType", type: "String" },
|
|
16
|
-
647: { name: "DocTypeVersion", type: "Uint" },
|
|
17
|
-
645: { name: "DocTypeReadVersion", type: "Uint" },
|
|
18
|
-
108: { name: "Void", type: "Binary" },
|
|
19
|
-
63: { name: "CRC-32", type: "Binary" },
|
|
20
|
-
190023271: { name: "SignatureSlot", type: "Container" },
|
|
21
|
-
16010: { name: "SignatureAlgo", type: "Uint" },
|
|
22
|
-
16026: { name: "SignatureHash", type: "Uint" },
|
|
23
|
-
16037: { name: "SignaturePublicKey", type: "Binary" },
|
|
24
|
-
16053: { name: "Signature", type: "Binary" },
|
|
25
|
-
15963: { name: "SignatureElements", type: "Container" },
|
|
26
|
-
15995: { name: "SignatureElementList", type: "Container" },
|
|
27
|
-
9522: { name: "SignedElement", type: "Binary" },
|
|
28
|
-
139690087: { name: "Segment", type: "Container" },
|
|
29
|
-
21863284: { name: "SeekHead", type: "Container" },
|
|
30
|
-
3515: { name: "Seek", type: "Container" },
|
|
31
|
-
5035: { name: "SeekID", type: "Binary" },
|
|
32
|
-
5036: { name: "SeekPosition", type: "Uint" },
|
|
33
|
-
88713574: { name: "Info", type: "Container" },
|
|
34
|
-
13220: { name: "SegmentUID", type: "Binary" },
|
|
35
|
-
13188: { name: "SegmentFilename", type: "String" },
|
|
36
|
-
1882403: { name: "PrevUID", type: "Binary" },
|
|
37
|
-
1868715: { name: "PrevFilename", type: "String" },
|
|
38
|
-
2013475: { name: "NextUID", type: "Binary" },
|
|
39
|
-
1999803: { name: "NextFilename", type: "String" },
|
|
40
|
-
1092: { name: "SegmentFamily", type: "Binary" },
|
|
41
|
-
10532: { name: "ChapterTranslate", type: "Container" },
|
|
42
|
-
10748: { name: "ChapterTranslateEditionUID", type: "Uint" },
|
|
43
|
-
10687: { name: "ChapterTranslateCodec", type: "Uint" },
|
|
44
|
-
10661: { name: "ChapterTranslateID", type: "Binary" },
|
|
45
|
-
710577: { name: "TimecodeScale", type: "Uint" },
|
|
46
|
-
1161: { name: "Duration", type: "Float" },
|
|
47
|
-
1121: { name: "DateUTC", type: "Date" },
|
|
48
|
-
15273: { name: "Title", type: "String" },
|
|
49
|
-
3456: { name: "MuxingApp", type: "String" },
|
|
50
|
-
5953: { name: "WritingApp", type: "String" },
|
|
51
|
-
// 0xf43b675: { name: 'Cluster', type: 'Container' },
|
|
52
|
-
103: { name: "Timecode", type: "Uint" },
|
|
53
|
-
6228: { name: "SilentTracks", type: "Container" },
|
|
54
|
-
6359: { name: "SilentTrackNumber", type: "Uint" },
|
|
55
|
-
39: { name: "Position", type: "Uint" },
|
|
56
|
-
43: { name: "PrevSize", type: "Uint" },
|
|
57
|
-
35: { name: "SimpleBlock", type: "Binary" },
|
|
58
|
-
32: { name: "BlockGroup", type: "Container" },
|
|
59
|
-
33: { name: "Block", type: "Binary" },
|
|
60
|
-
34: { name: "BlockVirtual", type: "Binary" },
|
|
61
|
-
13729: { name: "BlockAdditions", type: "Container" },
|
|
62
|
-
38: { name: "BlockMore", type: "Container" },
|
|
63
|
-
110: { name: "BlockAddID", type: "Uint" },
|
|
64
|
-
37: { name: "BlockAdditional", type: "Binary" },
|
|
65
|
-
27: { name: "BlockDuration", type: "Uint" },
|
|
66
|
-
122: { name: "ReferencePriority", type: "Uint" },
|
|
67
|
-
123: { name: "ReferenceBlock", type: "Int" },
|
|
68
|
-
125: { name: "ReferenceVirtual", type: "Int" },
|
|
69
|
-
36: { name: "CodecState", type: "Binary" },
|
|
70
|
-
13730: { name: "DiscardPadding", type: "Int" },
|
|
71
|
-
14: { name: "Slices", type: "Container" },
|
|
72
|
-
104: { name: "TimeSlice", type: "Container" },
|
|
73
|
-
76: { name: "LaceNumber", type: "Uint" },
|
|
74
|
-
77: { name: "FrameNumber", type: "Uint" },
|
|
75
|
-
75: { name: "BlockAdditionID", type: "Uint" },
|
|
76
|
-
78: { name: "Delay", type: "Uint" },
|
|
77
|
-
79: { name: "SliceDuration", type: "Uint" },
|
|
78
|
-
72: { name: "ReferenceFrame", type: "Container" },
|
|
79
|
-
73: { name: "ReferenceOffset", type: "Uint" },
|
|
80
|
-
74: { name: "ReferenceTimeCode", type: "Uint" },
|
|
81
|
-
47: { name: "EncryptedBlock", type: "Binary" },
|
|
82
|
-
106212971: { name: "Tracks", type: "Container" },
|
|
83
|
-
46: { name: "TrackEntry", type: "Container" },
|
|
84
|
-
87: { name: "TrackNumber", type: "Uint" },
|
|
85
|
-
13253: { name: "TrackUID", type: "Uint" },
|
|
86
|
-
3: { name: "TrackType", type: "Uint" },
|
|
87
|
-
57: { name: "FlagEnabled", type: "Uint" },
|
|
88
|
-
8: { name: "FlagDefault", type: "Uint" },
|
|
89
|
-
5546: { name: "FlagForced", type: "Uint" },
|
|
90
|
-
28: { name: "FlagLacing", type: "Uint" },
|
|
91
|
-
11751: { name: "MinCache", type: "Uint" },
|
|
92
|
-
11768: { name: "MaxCache", type: "Uint" },
|
|
93
|
-
254851: { name: "DefaultDuration", type: "Uint" },
|
|
94
|
-
216698: { name: "DefaultDecodedFieldDuration", type: "Uint" },
|
|
95
|
-
209231: { name: "TrackTimecodeScale", type: "Float" },
|
|
96
|
-
4991: { name: "TrackOffset", type: "Int" },
|
|
97
|
-
5614: { name: "MaxBlockAdditionID", type: "Uint" },
|
|
98
|
-
4974: { name: "Name", type: "String" },
|
|
99
|
-
177564: { name: "Language", type: "String" },
|
|
100
|
-
6: { name: "CodecID", type: "String" },
|
|
101
|
-
9122: { name: "CodecPrivate", type: "Binary" },
|
|
102
|
-
362120: { name: "CodecName", type: "String" },
|
|
103
|
-
13382: { name: "AttachmentLink", type: "Uint" },
|
|
104
|
-
1742487: { name: "CodecSettings", type: "String" },
|
|
105
|
-
1785920: { name: "CodecInfoURL", type: "String" },
|
|
106
|
-
438848: { name: "CodecDownloadURL", type: "String" },
|
|
107
|
-
42: { name: "CodecDecodeAll", type: "Uint" },
|
|
108
|
-
12203: { name: "TrackOverlay", type: "Uint" },
|
|
109
|
-
5802: { name: "CodecDelay", type: "Uint" },
|
|
110
|
-
5819: { name: "SeekPreRoll", type: "Uint" },
|
|
111
|
-
9764: { name: "TrackTranslate", type: "Container" },
|
|
112
|
-
9980: { name: "TrackTranslateEditionUID", type: "Uint" },
|
|
113
|
-
9919: { name: "TrackTranslateCodec", type: "Uint" },
|
|
114
|
-
9893: { name: "TrackTranslateTrackID", type: "Binary" },
|
|
115
|
-
96: { name: "Video", type: "Container" },
|
|
116
|
-
26: { name: "FlagInterlaced", type: "Uint" },
|
|
117
|
-
5048: { name: "StereoMode", type: "Uint" },
|
|
118
|
-
5056: { name: "AlphaMode", type: "Uint" },
|
|
119
|
-
5049: { name: "OldStereoMode", type: "Uint" },
|
|
120
|
-
48: { name: "PixelWidth", type: "Uint" },
|
|
121
|
-
58: { name: "PixelHeight", type: "Uint" },
|
|
122
|
-
5290: { name: "PixelCropBottom", type: "Uint" },
|
|
123
|
-
5307: { name: "PixelCropTop", type: "Uint" },
|
|
124
|
-
5324: { name: "PixelCropLeft", type: "Uint" },
|
|
125
|
-
5341: { name: "PixelCropRight", type: "Uint" },
|
|
126
|
-
5296: { name: "DisplayWidth", type: "Uint" },
|
|
127
|
-
5306: { name: "DisplayHeight", type: "Uint" },
|
|
128
|
-
5298: { name: "DisplayUnit", type: "Uint" },
|
|
129
|
-
5299: { name: "AspectRatioType", type: "Uint" },
|
|
130
|
-
963876: { name: "ColourSpace", type: "Binary" },
|
|
131
|
-
1029411: { name: "GammaValue", type: "Float" },
|
|
132
|
-
230371: { name: "FrameRate", type: "Float" },
|
|
133
|
-
97: { name: "Audio", type: "Container" },
|
|
134
|
-
53: { name: "SamplingFrequency", type: "Float" },
|
|
135
|
-
14517: { name: "OutputSamplingFrequency", type: "Float" },
|
|
136
|
-
31: { name: "Channels", type: "Uint" },
|
|
137
|
-
15739: { name: "ChannelPositions", type: "Binary" },
|
|
138
|
-
8804: { name: "BitDepth", type: "Uint" },
|
|
139
|
-
98: { name: "TrackOperation", type: "Container" },
|
|
140
|
-
99: { name: "TrackCombinePlanes", type: "Container" },
|
|
141
|
-
100: { name: "TrackPlane", type: "Container" },
|
|
142
|
-
101: { name: "TrackPlaneUID", type: "Uint" },
|
|
143
|
-
102: { name: "TrackPlaneType", type: "Uint" },
|
|
144
|
-
105: { name: "TrackJoinBlocks", type: "Container" },
|
|
145
|
-
109: { name: "TrackJoinUID", type: "Uint" },
|
|
146
|
-
64: { name: "TrickTrackUID", type: "Uint" },
|
|
147
|
-
65: { name: "TrickTrackSegmentUID", type: "Binary" },
|
|
148
|
-
70: { name: "TrickTrackFlag", type: "Uint" },
|
|
149
|
-
71: { name: "TrickMasterTrackUID", type: "Uint" },
|
|
150
|
-
68: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
|
|
151
|
-
11648: { name: "ContentEncodings", type: "Container" },
|
|
152
|
-
8768: { name: "ContentEncoding", type: "Container" },
|
|
153
|
-
4145: { name: "ContentEncodingOrder", type: "Uint" },
|
|
154
|
-
4146: { name: "ContentEncodingScope", type: "Uint" },
|
|
155
|
-
4147: { name: "ContentEncodingType", type: "Uint" },
|
|
156
|
-
4148: { name: "ContentCompression", type: "Container" },
|
|
157
|
-
596: { name: "ContentCompAlgo", type: "Uint" },
|
|
158
|
-
597: { name: "ContentCompSettings", type: "Binary" },
|
|
159
|
-
4149: { name: "ContentEncryption", type: "Container" },
|
|
160
|
-
2017: { name: "ContentEncAlgo", type: "Uint" },
|
|
161
|
-
2018: { name: "ContentEncKeyID", type: "Binary" },
|
|
162
|
-
2019: { name: "ContentSignature", type: "Binary" },
|
|
163
|
-
2020: { name: "ContentSigKeyID", type: "Binary" },
|
|
164
|
-
2021: { name: "ContentSigAlgo", type: "Uint" },
|
|
165
|
-
2022: { name: "ContentSigHashAlgo", type: "Uint" },
|
|
166
|
-
206814059: { name: "Cues", type: "Container" },
|
|
167
|
-
59: { name: "CuePoint", type: "Container" },
|
|
168
|
-
51: { name: "CueTime", type: "Uint" },
|
|
169
|
-
55: { name: "CueTrackPositions", type: "Container" },
|
|
170
|
-
119: { name: "CueTrack", type: "Uint" },
|
|
171
|
-
113: { name: "CueClusterPosition", type: "Uint" },
|
|
172
|
-
112: { name: "CueRelativePosition", type: "Uint" },
|
|
173
|
-
50: { name: "CueDuration", type: "Uint" },
|
|
174
|
-
4984: { name: "CueBlockNumber", type: "Uint" },
|
|
175
|
-
106: { name: "CueCodecState", type: "Uint" },
|
|
176
|
-
91: { name: "CueReference", type: "Container" },
|
|
177
|
-
22: { name: "CueRefTime", type: "Uint" },
|
|
178
|
-
23: { name: "CueRefCluster", type: "Uint" },
|
|
179
|
-
4959: { name: "CueRefNumber", type: "Uint" },
|
|
180
|
-
107: { name: "CueRefCodecState", type: "Uint" },
|
|
181
|
-
155296873: { name: "Attachments", type: "Container" },
|
|
182
|
-
8615: { name: "AttachedFile", type: "Container" },
|
|
183
|
-
1662: { name: "FileDescription", type: "String" },
|
|
184
|
-
1646: { name: "FileName", type: "String" },
|
|
185
|
-
1632: { name: "FileMimeType", type: "String" },
|
|
186
|
-
1628: { name: "FileData", type: "Binary" },
|
|
187
|
-
1710: { name: "FileUID", type: "Uint" },
|
|
188
|
-
1653: { name: "FileReferral", type: "Binary" },
|
|
189
|
-
1633: { name: "FileUsedStartTime", type: "Uint" },
|
|
190
|
-
1634: { name: "FileUsedEndTime", type: "Uint" },
|
|
191
|
-
4433776: { name: "Chapters", type: "Container" },
|
|
192
|
-
1465: { name: "EditionEntry", type: "Container" },
|
|
193
|
-
1468: { name: "EditionUID", type: "Uint" },
|
|
194
|
-
1469: { name: "EditionFlagHidden", type: "Uint" },
|
|
195
|
-
1499: { name: "EditionFlagDefault", type: "Uint" },
|
|
196
|
-
1501: { name: "EditionFlagOrdered", type: "Uint" },
|
|
197
|
-
54: { name: "ChapterAtom", type: "Container" },
|
|
198
|
-
13252: { name: "ChapterUID", type: "Uint" },
|
|
199
|
-
5716: { name: "ChapterStringUID", type: "String" },
|
|
200
|
-
17: { name: "ChapterTimeStart", type: "Uint" },
|
|
201
|
-
18: { name: "ChapterTimeEnd", type: "Uint" },
|
|
202
|
-
24: { name: "ChapterFlagHidden", type: "Uint" },
|
|
203
|
-
1432: { name: "ChapterFlagEnabled", type: "Uint" },
|
|
204
|
-
11879: { name: "ChapterSegmentUID", type: "Binary" },
|
|
205
|
-
11964: { name: "ChapterSegmentEditionUID", type: "Uint" },
|
|
206
|
-
9155: { name: "ChapterPhysicalEquiv", type: "Uint" },
|
|
207
|
-
15: { name: "ChapterTrack", type: "Container" },
|
|
208
|
-
9: { name: "ChapterTrackNumber", type: "Uint" },
|
|
209
|
-
0: { name: "ChapterDisplay", type: "Container" },
|
|
210
|
-
5: { name: "ChapString", type: "String" },
|
|
211
|
-
892: { name: "ChapLanguage", type: "String" },
|
|
212
|
-
894: { name: "ChapCountry", type: "String" },
|
|
213
|
-
10564: { name: "ChapProcess", type: "Container" },
|
|
214
|
-
10581: { name: "ChapProcessCodecID", type: "Uint" },
|
|
215
|
-
1293: { name: "ChapProcessPrivate", type: "Binary" },
|
|
216
|
-
10513: { name: "ChapProcessCommand", type: "Container" },
|
|
217
|
-
10530: { name: "ChapProcessTime", type: "Uint" },
|
|
218
|
-
10547: { name: "ChapProcessData", type: "Binary" },
|
|
219
|
-
39109479: { name: "Tags", type: "Container" },
|
|
220
|
-
13171: { name: "Tag", type: "Container" },
|
|
221
|
-
9152: { name: "Targets", type: "Container" },
|
|
222
|
-
10442: { name: "TargetTypeValue", type: "Uint" },
|
|
223
|
-
9162: { name: "TargetType", type: "String" },
|
|
224
|
-
9157: { name: "TagTrackUID", type: "Uint" },
|
|
225
|
-
9161: { name: "TagEditionUID", type: "Uint" },
|
|
226
|
-
9156: { name: "TagChapterUID", type: "Uint" },
|
|
227
|
-
9158: { name: "TagAttachmentUID", type: "Uint" },
|
|
228
|
-
10184: { name: "SimpleTag", type: "Container" },
|
|
229
|
-
1443: { name: "TagName", type: "String" },
|
|
230
|
-
1146: { name: "TagLanguage", type: "String" },
|
|
231
|
-
1156: { name: "TagDefault", type: "Uint" },
|
|
232
|
-
1159: { name: "TagString", type: "String" },
|
|
233
|
-
1157: { name: "TagBinary", type: "Binary" }
|
|
234
|
-
};
|
|
235
|
-
class WebmBase {
|
|
236
|
-
constructor(name = "Unknown", type = "Unknown") {
|
|
237
|
-
__publicField(this, "source");
|
|
238
|
-
__publicField(this, "data");
|
|
239
|
-
this.name = name;
|
|
240
|
-
this.type = type;
|
|
241
|
-
}
|
|
242
|
-
updateBySource() {
|
|
243
|
-
}
|
|
244
|
-
setSource(source) {
|
|
245
|
-
this.source = source;
|
|
246
|
-
this.updateBySource();
|
|
247
|
-
}
|
|
248
|
-
updateByData() {
|
|
249
|
-
}
|
|
250
|
-
setData(data) {
|
|
251
|
-
this.data = data;
|
|
252
|
-
this.updateByData();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function padHex(hex) {
|
|
256
|
-
return hex.length % 2 === 1 ? "0" + hex : hex;
|
|
257
|
-
}
|
|
258
|
-
class WebmUint extends WebmBase {
|
|
259
|
-
constructor(name, type) {
|
|
260
|
-
super(name, type || "Uint");
|
|
261
|
-
}
|
|
262
|
-
updateBySource() {
|
|
263
|
-
this.data = "";
|
|
264
|
-
for (let i2 = 0; i2 < this.source.length; i2++) {
|
|
265
|
-
const hex = this.source[i2].toString(16);
|
|
266
|
-
this.data += padHex(hex);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
updateByData() {
|
|
270
|
-
const length = this.data.length / 2;
|
|
271
|
-
this.source = new Uint8Array(length);
|
|
272
|
-
for (let i2 = 0; i2 < length; i2++) {
|
|
273
|
-
const hex = this.data.substr(i2 * 2, 2);
|
|
274
|
-
this.source[i2] = parseInt(hex, 16);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
getValue() {
|
|
278
|
-
return parseInt(this.data, 16);
|
|
279
|
-
}
|
|
280
|
-
setValue(value) {
|
|
281
|
-
this.setData(padHex(value.toString(16)));
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
class WebmFloat extends WebmBase {
|
|
285
|
-
constructor(name, type) {
|
|
286
|
-
super(name, type || "Float");
|
|
287
|
-
}
|
|
288
|
-
getFloatArrayType() {
|
|
289
|
-
return this.source && this.source.length === 4 ? Float32Array : Float64Array;
|
|
290
|
-
}
|
|
291
|
-
updateBySource() {
|
|
292
|
-
const byteArray = this.source.reverse();
|
|
293
|
-
const floatArrayType = this.getFloatArrayType();
|
|
294
|
-
const floatArray = new floatArrayType(byteArray.buffer);
|
|
295
|
-
this.data = floatArray[0];
|
|
296
|
-
}
|
|
297
|
-
updateByData() {
|
|
298
|
-
const floatArrayType = this.getFloatArrayType();
|
|
299
|
-
const floatArray = new floatArrayType([this.data]);
|
|
300
|
-
const byteArray = new Uint8Array(floatArray.buffer);
|
|
301
|
-
this.source = byteArray.reverse();
|
|
302
|
-
}
|
|
303
|
-
getValue() {
|
|
304
|
-
return this.data;
|
|
305
|
-
}
|
|
306
|
-
setValue(value) {
|
|
307
|
-
this.setData(value);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
class WebmContainer extends WebmBase {
|
|
311
|
-
constructor(name, type) {
|
|
312
|
-
super(name, type || "Container");
|
|
313
|
-
__publicField(this, "offset", 0);
|
|
314
|
-
__publicField(this, "data", []);
|
|
315
|
-
}
|
|
316
|
-
readByte() {
|
|
317
|
-
return this.source[this.offset++];
|
|
318
|
-
}
|
|
319
|
-
readUint() {
|
|
320
|
-
const firstByte = this.readByte();
|
|
321
|
-
const bytes = 8 - firstByte.toString(2).length;
|
|
322
|
-
let value = firstByte - (1 << 7 - bytes);
|
|
323
|
-
for (let i2 = 0; i2 < bytes; i2++) {
|
|
324
|
-
value *= 256;
|
|
325
|
-
value += this.readByte();
|
|
326
|
-
}
|
|
327
|
-
return value;
|
|
328
|
-
}
|
|
329
|
-
updateBySource() {
|
|
330
|
-
let end = void 0;
|
|
331
|
-
this.data = [];
|
|
332
|
-
for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
|
|
333
|
-
const id = this.readUint();
|
|
334
|
-
const len = this.readUint();
|
|
335
|
-
end = Math.min(this.offset + len, this.source.length);
|
|
336
|
-
const data = this.source.slice(this.offset, end);
|
|
337
|
-
const info = sections[id] || { name: "Unknown", type: "Unknown" };
|
|
338
|
-
let ctr = WebmBase;
|
|
339
|
-
switch (info.type) {
|
|
340
|
-
case "Container":
|
|
341
|
-
ctr = WebmContainer;
|
|
342
|
-
break;
|
|
343
|
-
case "Uint":
|
|
344
|
-
ctr = WebmUint;
|
|
345
|
-
break;
|
|
346
|
-
case "Float":
|
|
347
|
-
ctr = WebmFloat;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
const section = new ctr(info.name, info.type);
|
|
351
|
-
section.setSource(data);
|
|
352
|
-
this.data.push({
|
|
353
|
-
id,
|
|
354
|
-
idHex: id.toString(16),
|
|
355
|
-
data: section
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
writeUint(x, draft = false) {
|
|
360
|
-
let bytes = 1, flag = 128;
|
|
361
|
-
while (x >= flag && bytes < 8) {
|
|
362
|
-
bytes++, flag *= 128;
|
|
363
|
-
}
|
|
364
|
-
if (!draft) {
|
|
365
|
-
let value = flag + x;
|
|
366
|
-
for (let i2 = bytes - 1; i2 >= 0; i2--) {
|
|
367
|
-
const c2 = value % 256;
|
|
368
|
-
this.source[this.offset + i2] = c2;
|
|
369
|
-
value = (value - c2) / 256;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
this.offset += bytes;
|
|
373
|
-
}
|
|
374
|
-
writeSections(draft = false) {
|
|
375
|
-
this.offset = 0;
|
|
376
|
-
for (let i2 = 0; i2 < this.data.length; i2++) {
|
|
377
|
-
const section = this.data[i2], content = section.data.source, contentLength = content.length;
|
|
378
|
-
this.writeUint(section.id, draft);
|
|
379
|
-
this.writeUint(contentLength, draft);
|
|
380
|
-
if (!draft) {
|
|
381
|
-
this.source.set(content, this.offset);
|
|
382
|
-
}
|
|
383
|
-
this.offset += contentLength;
|
|
384
|
-
}
|
|
385
|
-
return this.offset;
|
|
386
|
-
}
|
|
387
|
-
updateByData() {
|
|
388
|
-
const length = this.writeSections(true);
|
|
389
|
-
this.source = new Uint8Array(length);
|
|
390
|
-
this.writeSections();
|
|
391
|
-
}
|
|
392
|
-
getSectionById(id) {
|
|
393
|
-
for (let i2 = 0; i2 < this.data.length; i2++) {
|
|
394
|
-
const section = this.data[i2];
|
|
395
|
-
if (section.id === id) {
|
|
396
|
-
return section.data;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return void 0;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
class WebmFile extends WebmContainer {
|
|
403
|
-
constructor(source) {
|
|
404
|
-
super("File", "File");
|
|
405
|
-
this.setSource(source);
|
|
406
|
-
}
|
|
407
|
-
fixDuration(duration) {
|
|
408
|
-
const segmentSection = this.getSectionById(139690087);
|
|
409
|
-
if (!segmentSection) {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
const infoSection = segmentSection.getSectionById(88713574);
|
|
413
|
-
if (!infoSection) {
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
const timeScaleSection = infoSection.getSectionById(710577);
|
|
417
|
-
if (!timeScaleSection) {
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
let durationSection = infoSection.getSectionById(1161);
|
|
421
|
-
if (durationSection) {
|
|
422
|
-
if (durationSection.getValue() <= 0) {
|
|
423
|
-
durationSection.setValue(duration);
|
|
424
|
-
} else {
|
|
425
|
-
return false;
|
|
426
|
-
}
|
|
427
|
-
} else {
|
|
428
|
-
durationSection = new WebmFloat("Duration", "Float");
|
|
429
|
-
durationSection.setValue(duration);
|
|
430
|
-
infoSection.data.push({
|
|
431
|
-
id: 1161,
|
|
432
|
-
data: durationSection
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
timeScaleSection.setValue(1e6);
|
|
436
|
-
infoSection.updateByData();
|
|
437
|
-
segmentSection.updateByData();
|
|
438
|
-
this.updateByData();
|
|
439
|
-
return true;
|
|
440
|
-
}
|
|
441
|
-
toBlob(type = "video/webm") {
|
|
442
|
-
return new Blob([this.source.buffer], { type });
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
const webmFixDuration = (blob, duration, type = "video/webm") => {
|
|
446
|
-
return new Promise((resolve, reject) => {
|
|
447
|
-
try {
|
|
448
|
-
const reader = new FileReader();
|
|
449
|
-
reader.addEventListener("loadend", () => {
|
|
450
|
-
try {
|
|
451
|
-
const result = reader.result;
|
|
452
|
-
const file = new WebmFile(new Uint8Array(result));
|
|
453
|
-
if (file.fixDuration(duration)) {
|
|
454
|
-
resolve(file.toBlob(type));
|
|
455
|
-
} else {
|
|
456
|
-
resolve(blob);
|
|
457
|
-
}
|
|
458
|
-
} catch (ex) {
|
|
459
|
-
reject(ex);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
reader.addEventListener("error", () => reject());
|
|
463
|
-
reader.readAsArrayBuffer(blob);
|
|
464
|
-
} catch (ex) {
|
|
465
|
-
reject(ex);
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
};
|
|
469
|
-
function getMimeType() {
|
|
470
|
-
const types = ["audio/webm", "audio/mp4", "audio/ogg", "audio/wav", "audio/aac"];
|
|
471
|
-
for (let i2 = 0; i2 < types.length; i2++) {
|
|
472
|
-
if (MediaRecorder.isTypeSupported(types[i2])) {
|
|
473
|
-
return types[i2];
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return void 0;
|
|
477
|
-
}
|
|
478
|
-
class AudioRecorder {
|
|
479
|
-
constructor() {
|
|
480
|
-
__publicField(this, "startTime");
|
|
481
|
-
__publicField(this, "chunks");
|
|
482
|
-
__publicField(this, "mediaRecorder");
|
|
483
|
-
__publicField(this, "blob");
|
|
484
|
-
this.startTime = Date.now();
|
|
485
|
-
this.chunks = [];
|
|
486
|
-
navigator.mediaDevices.getUserMedia({
|
|
487
|
-
audio: true
|
|
488
|
-
}).then((stream) => {
|
|
489
|
-
this.init(stream);
|
|
490
|
-
}).catch((error) => {
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
init(stream) {
|
|
494
|
-
var _a, _b;
|
|
495
|
-
const mimeType = getMimeType();
|
|
496
|
-
this.mediaRecorder = new MediaRecorder(stream, {
|
|
497
|
-
mimeType
|
|
498
|
-
});
|
|
499
|
-
(_a = this.mediaRecorder) == null ? void 0 : _a.addEventListener("dataavailable", async (event) => {
|
|
500
|
-
var _a2;
|
|
501
|
-
if (event.data.size > 0) {
|
|
502
|
-
this.chunks.push(event.data);
|
|
503
|
-
}
|
|
504
|
-
if (((_a2 = this.mediaRecorder) == null ? void 0 : _a2.state) === "inactive") {
|
|
505
|
-
const duration = Date.now() - this.startTime;
|
|
506
|
-
this.blob = new Blob(this.chunks, { type: mimeType });
|
|
507
|
-
if (mimeType === "audio/webm") {
|
|
508
|
-
this.blob = await webmFixDuration(this.blob, duration, this.blob.type);
|
|
509
|
-
}
|
|
510
|
-
this.chunks = [];
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
(_b = this.mediaRecorder) == null ? void 0 : _b.start();
|
|
514
|
-
}
|
|
515
|
-
start() {
|
|
516
|
-
var _a;
|
|
517
|
-
if (((_a = this.mediaRecorder) == null ? void 0 : _a.state) === "paused") {
|
|
518
|
-
this.mediaRecorder.resume();
|
|
519
|
-
}
|
|
520
|
-
return this.mediaRecorder;
|
|
521
|
-
}
|
|
522
|
-
pause() {
|
|
523
|
-
var _a;
|
|
524
|
-
if (((_a = this.mediaRecorder) == null ? void 0 : _a.state) === "recording") {
|
|
525
|
-
this.mediaRecorder.pause();
|
|
526
|
-
}
|
|
527
|
-
return this.mediaRecorder;
|
|
528
|
-
}
|
|
529
|
-
stop() {
|
|
530
|
-
var _a;
|
|
531
|
-
(_a = this.mediaRecorder) == null ? void 0 : _a.stop();
|
|
532
|
-
return this.blob;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
const noop = () => {
|
|
536
|
-
};
|
|
537
|
-
const handleClick = (hooks = noop) => {
|
|
538
|
-
if (typeof document !== "undefined") {
|
|
539
|
-
document.addEventListener(
|
|
540
|
-
"click",
|
|
541
|
-
function(event) {
|
|
542
|
-
hooks(event);
|
|
543
|
-
},
|
|
544
|
-
true
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
const webglVendor = () => {
|
|
549
|
-
const glCanvas = document.createElement("canvas");
|
|
550
|
-
const gl = glCanvas.getContext("webgl2");
|
|
551
|
-
function getHardwareInfo(gl2) {
|
|
552
|
-
const debugInfo = gl2.getExtension("WEBGL_debug_renderer_info");
|
|
553
|
-
if (!debugInfo) {
|
|
554
|
-
return null;
|
|
555
|
-
}
|
|
556
|
-
const vendor = gl2.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
|
|
557
|
-
const renderer = gl2.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
|
|
558
|
-
return {
|
|
559
|
-
vendor,
|
|
560
|
-
renderer
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
if (gl) {
|
|
564
|
-
return getHardwareInfo(gl);
|
|
565
|
-
}
|
|
566
|
-
return null;
|
|
567
|
-
};
|
|
568
|
-
const canvasVendor = () => {
|
|
569
|
-
const outScreenCanvas = document.createElement("canvas");
|
|
570
|
-
const ctx = outScreenCanvas.getContext("2d");
|
|
571
|
-
const txt = "BrowserLeaks,com <canvas> 1.0";
|
|
572
|
-
if (!ctx)
|
|
573
|
-
return null;
|
|
574
|
-
ctx.textBaseline = "top";
|
|
575
|
-
ctx.font = "14px 'Arial'";
|
|
576
|
-
ctx.textBaseline = "alphabetic";
|
|
577
|
-
ctx.fillStyle = "#f60";
|
|
578
|
-
ctx.fillRect(125, 1, 62, 20);
|
|
579
|
-
ctx.fillStyle = "#069";
|
|
580
|
-
ctx.fillText(txt, 2, 15);
|
|
581
|
-
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
|
|
582
|
-
ctx.fillText(txt, 4, 17);
|
|
583
|
-
const canvasImageData = outScreenCanvas.toDataURL();
|
|
584
|
-
return canvasImageData;
|
|
585
|
-
};
|
|
586
|
-
const audioVendor = () => {
|
|
587
|
-
return new Promise((resolve, reject) => {
|
|
588
|
-
const each = function(obj, iterator) {
|
|
589
|
-
if (Array.prototype.forEach && obj.forEach === Array.prototype.forEach) {
|
|
590
|
-
obj.forEach(iterator);
|
|
591
|
-
} else if (obj.length === +obj.length) {
|
|
592
|
-
for (let i2 = 0, l2 = obj.length; i2 < l2; i2++) {
|
|
593
|
-
iterator(obj[i2], i2, obj);
|
|
594
|
-
}
|
|
595
|
-
} else {
|
|
596
|
-
for (const key in obj) {
|
|
597
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
598
|
-
iterator(obj[key], Number(key), obj);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
const AudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
|
604
|
-
const context = new AudioContext(1, 44100, 44100);
|
|
605
|
-
const oscillator = context.createOscillator();
|
|
606
|
-
oscillator.type = "triangle";
|
|
607
|
-
oscillator.frequency.setValueAtTime(1e4, context.currentTime);
|
|
608
|
-
const compressor = context.createDynamicsCompressor();
|
|
609
|
-
each(
|
|
610
|
-
[
|
|
611
|
-
["threshold", -50],
|
|
612
|
-
["knee", 40],
|
|
613
|
-
["ratio", 12],
|
|
614
|
-
["reduction", -20],
|
|
615
|
-
["attack", 0],
|
|
616
|
-
["release", 0.25]
|
|
617
|
-
],
|
|
618
|
-
function(item) {
|
|
619
|
-
if (compressor[item[0]] && typeof compressor[item[0]] !== "number") {
|
|
620
|
-
const { setValueAtTime } = compressor[item[0]];
|
|
621
|
-
setValueAtTime(item[1], context.currentTime);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
);
|
|
625
|
-
oscillator.connect(compressor);
|
|
626
|
-
compressor.connect(context.destination);
|
|
627
|
-
oscillator.start(0);
|
|
628
|
-
context.startRendering();
|
|
629
|
-
const audioTimeoutId = setTimeout(function() {
|
|
630
|
-
context.oncomplete = function() {
|
|
631
|
-
};
|
|
632
|
-
reject("audioTimeout");
|
|
633
|
-
return "audioTimeout";
|
|
634
|
-
}, 100);
|
|
635
|
-
context.oncomplete = (event) => {
|
|
636
|
-
try {
|
|
637
|
-
clearTimeout(audioTimeoutId);
|
|
638
|
-
const result = event.renderedBuffer.getChannelData(0).slice(4500, 5e3).reduce(function(acc, val) {
|
|
639
|
-
return acc + Math.abs(val);
|
|
640
|
-
}, 0).toString();
|
|
641
|
-
oscillator.disconnect();
|
|
642
|
-
compressor.disconnect();
|
|
643
|
-
resolve(result);
|
|
644
|
-
return result;
|
|
645
|
-
} catch (error) {
|
|
646
|
-
reject(error);
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
});
|
|
651
|
-
};
|
|
652
|
-
function formatDuration(time) {
|
|
653
|
-
return time < 10 ? `0${time}` : time;
|
|
654
|
-
}
|
|
655
|
-
function timestampToTime(timestamp) {
|
|
656
|
-
let date = /* @__PURE__ */ new Date();
|
|
657
|
-
if (timestamp) {
|
|
658
|
-
date = new Date(timestamp);
|
|
659
|
-
}
|
|
660
|
-
date.format = (format = "YYYY-MM-DD HH:mm:ss") => {
|
|
661
|
-
const year = date.getFullYear();
|
|
662
|
-
const month = formatDuration(date.getMonth() + 1);
|
|
663
|
-
const day = formatDuration(date.getDate());
|
|
664
|
-
const hour = formatDuration(date.getHours());
|
|
665
|
-
const minute = formatDuration(date.getMinutes());
|
|
666
|
-
const second = formatDuration(date.getSeconds());
|
|
667
|
-
return format.replace(/Y+/gi, `${year}`).replace(/M+/g, `${month}`).replace(/D+/gi, `${day}`).replace(/H+/gi, `${hour}`).replace(/m+/g, `${minute}`).replace(/S+/gi, `${second}`);
|
|
668
|
-
};
|
|
669
|
-
return date;
|
|
670
|
-
}
|
|
671
|
-
const timeFormat = (time) => {
|
|
672
|
-
if (time === 0)
|
|
673
|
-
return "00:00";
|
|
674
|
-
if (!time)
|
|
675
|
-
return "";
|
|
676
|
-
const hour = Math.trunc(time / 3600);
|
|
677
|
-
const minute = Math.trunc(time % 3600 / 60);
|
|
678
|
-
const second = formatDuration(Math.trunc(time - hour * 3600 - minute * 60));
|
|
679
|
-
if (hour === 0) {
|
|
680
|
-
return `${formatDuration(minute)}:${second}`;
|
|
681
|
-
}
|
|
682
|
-
return `${formatDuration(hour)}:${formatDuration(minute)}:${second}`;
|
|
683
|
-
};
|
|
684
|
-
const performanceTime = () => {
|
|
685
|
-
if (typeof document !== "undefined") {
|
|
686
|
-
return performance.now();
|
|
687
|
-
}
|
|
688
|
-
if (typeof process !== "undefined") {
|
|
689
|
-
const [seconds, nanosecond] = process.hrtime();
|
|
690
|
-
return seconds * 1e3 + nanosecond / 1e6;
|
|
691
|
-
}
|
|
692
|
-
return Date.now();
|
|
693
|
-
};
|
|
694
|
-
const retain = (callback = noop) => {
|
|
695
|
-
const historyReturnCb = () => {
|
|
696
|
-
callback();
|
|
697
|
-
window.removeEventListener("popstate", historyReturnCb);
|
|
698
|
-
};
|
|
699
|
-
window.history.pushState(null, "", window.location.href);
|
|
700
|
-
setTimeout(() => {
|
|
701
|
-
window.addEventListener("popstate", historyReturnCb);
|
|
702
|
-
}, 500);
|
|
703
|
-
};
|
|
704
|
-
const getCookie = (objName) => {
|
|
705
|
-
const arrStr = document.cookie.split("; ");
|
|
706
|
-
for (let i2 = 0; i2 < arrStr.length; i2++) {
|
|
707
|
-
const item = arrStr[i2].split("=");
|
|
708
|
-
if (item[0] == objName) {
|
|
709
|
-
return decodeURIComponent(item[1]);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return "";
|
|
713
|
-
};
|
|
714
|
-
const requestUrlToBuffer = (src, options) => {
|
|
715
|
-
return new Promise(function(resolve, reject) {
|
|
716
|
-
const xhr = new XMLHttpRequest();
|
|
717
|
-
xhr.open(options.method || "GET", src, true);
|
|
718
|
-
xhr.responseType = options.responseType || "arraybuffer";
|
|
719
|
-
xhr.onload = function() {
|
|
720
|
-
if (xhr.status === 200) {
|
|
721
|
-
resolve({ success: true, data: xhr.response, message: "" });
|
|
722
|
-
} else {
|
|
723
|
-
reject({
|
|
724
|
-
success: false,
|
|
725
|
-
data: xhr.status,
|
|
726
|
-
message: `The request status is${xhr.status}`
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
xhr.onerror = function(e2) {
|
|
731
|
-
reject({ success: false, data: e2, message: `` });
|
|
732
|
-
};
|
|
733
|
-
xhr.onprogress = (event) => {
|
|
734
|
-
options.onProgress && options.onProgress(event);
|
|
735
|
-
};
|
|
736
|
-
xhr.withCredentials = options.withCredentials || false;
|
|
737
|
-
if (options.headers) {
|
|
738
|
-
Object.keys(options.headers).forEach(function(key) {
|
|
739
|
-
var _a;
|
|
740
|
-
((_a = options.headers) == null ? void 0 : _a[key]) && xhr.setRequestHeader(key, options.headers[key]);
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
xhr.send(options.body);
|
|
744
|
-
});
|
|
745
|
-
};
|
|
746
|
-
const getPixelRatio = (context) => {
|
|
747
|
-
const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || 1;
|
|
748
|
-
return (window.devicePixelRatio || 1) / backingStore;
|
|
749
|
-
};
|
|
750
|
-
const createObjectURL = async (src) => {
|
|
751
|
-
if (typeof src === "string") {
|
|
752
|
-
return src;
|
|
753
|
-
} else if (src instanceof Blob) {
|
|
754
|
-
return URL.createObjectURL(src);
|
|
755
|
-
} else if (src instanceof ArrayBuffer) {
|
|
756
|
-
return URL.createObjectURL(new Blob([src]));
|
|
757
|
-
} else if (src instanceof Response) {
|
|
758
|
-
const result = await src.blob();
|
|
759
|
-
return URL.createObjectURL(result);
|
|
760
|
-
} else {
|
|
761
|
-
return src;
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
const getFrame = (n2 = 10) => {
|
|
765
|
-
const frameList = [];
|
|
766
|
-
let lastFrame = 0;
|
|
767
|
-
let requestAnimationFrameRef;
|
|
768
|
-
return new Promise((resolve) => {
|
|
769
|
-
const a2 = () => {
|
|
770
|
-
const now = performanceTime();
|
|
771
|
-
const frame = now - lastFrame;
|
|
772
|
-
if (lastFrame !== 0) {
|
|
773
|
-
frameList.push(frame);
|
|
774
|
-
}
|
|
775
|
-
lastFrame = now;
|
|
776
|
-
if (frameList.length > n2) {
|
|
777
|
-
const num = frameList.reduce((i2, j2) => i2 + j2);
|
|
778
|
-
resolve(1 / (num / n2));
|
|
779
|
-
cancelAnimationFrame(requestAnimationFrameRef);
|
|
780
|
-
}
|
|
781
|
-
requestAnimationFrameRef = requestAnimationFrame(a2);
|
|
782
|
-
};
|
|
783
|
-
if (frameList.length <= n2) {
|
|
784
|
-
requestAnimationFrameRef = requestAnimationFrame(a2);
|
|
785
|
-
}
|
|
786
|
-
});
|
|
787
|
-
};
|
|
788
|
-
const getHost = (env) => {
|
|
789
|
-
if (typeof window !== "undefined") {
|
|
790
|
-
if (env && isString(env))
|
|
791
|
-
;
|
|
792
|
-
else {
|
|
793
|
-
const env2 = /\w(\.trunk|\.neibu|\.release|test)\./.exec(window.location.hostname);
|
|
794
|
-
if (env2) {
|
|
795
|
-
env2[1];
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
return "//log.chaxus.com";
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
const getAllQueryString = (url) => {
|
|
802
|
-
if (typeof window !== "undefined") {
|
|
803
|
-
const r2 = {};
|
|
804
|
-
const href = url || window.location.href;
|
|
805
|
-
if (href.split("?")[1]) {
|
|
806
|
-
const str = href.split("?")[1];
|
|
807
|
-
const strList = str.split("&");
|
|
808
|
-
strList.forEach((item) => {
|
|
809
|
-
const [key, val] = item.split("=");
|
|
810
|
-
if (key && val) {
|
|
811
|
-
r2[key] = decodeURIComponent(val);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
return r2;
|
|
816
|
-
}
|
|
817
|
-
return {};
|
|
818
|
-
};
|
|
819
|
-
function appendUrl(url, params = {}) {
|
|
820
|
-
let _url = url;
|
|
821
|
-
if (_url.indexOf("//") === 0) {
|
|
822
|
-
_url = _url.replace("//", "https://");
|
|
823
|
-
}
|
|
824
|
-
const urlObj = new URL(_url);
|
|
825
|
-
if (params) {
|
|
826
|
-
Object.keys(params).forEach((key) => {
|
|
827
|
-
params[key] && urlObj.searchParams.set(key, params[key]);
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
return urlObj.href;
|
|
831
|
-
}
|
|
832
|
-
const removeGhosting = (event) => {
|
|
833
|
-
const dragIcon = document.createElement("img");
|
|
834
|
-
const url = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
835
|
-
dragIcon.src = url;
|
|
836
|
-
dragIcon.width = 0;
|
|
837
|
-
dragIcon.height = 0;
|
|
838
|
-
dragIcon.style.opacity = "0";
|
|
839
|
-
if (event.dataTransfer) {
|
|
840
|
-
event.dataTransfer.setDragImage(dragIcon, 0, 0);
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
function getCookieByName(name) {
|
|
844
|
-
if (typeof window !== "undefined") {
|
|
845
|
-
const cookieList = document.cookie.match(new RegExp(`(^| )${name}(?:=([^;]*))?(;|$)`));
|
|
846
|
-
if (cookieList && cookieList[2])
|
|
847
|
-
return cookieList[2];
|
|
848
|
-
}
|
|
849
|
-
return "";
|
|
850
|
-
}
|
|
851
|
-
const getWindow = () => {
|
|
852
|
-
if (typeof window.innerWidth !== "undefined") {
|
|
853
|
-
return {
|
|
854
|
-
width: window.innerWidth,
|
|
855
|
-
height: window.innerHeight
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
return {
|
|
859
|
-
width: 0,
|
|
860
|
-
height: 0
|
|
861
|
-
};
|
|
862
|
-
};
|
|
863
|
-
const connection = () => {
|
|
864
|
-
if (typeof window !== "undefined") {
|
|
865
|
-
return window.navigator.connection;
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
const ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^\dA-Fa-f]|[\dA-Fa-f][^\dA-Fa-f]|$))+/g;
|
|
869
|
-
const UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
|
|
870
|
-
const UNMATCHED_SURROGATE_PAIR_REPLACE = "$1�$2";
|
|
871
|
-
function encodeUrl(url) {
|
|
872
|
-
return String(url).replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE).replace(ENCODE_CHARS_REGEXP, encodeURI);
|
|
873
|
-
}
|
|
874
|
-
const imageRequest = (url) => {
|
|
875
|
-
return new Promise((resolve, reject) => {
|
|
876
|
-
const img = new Image();
|
|
877
|
-
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
878
|
-
img.src = url ? url : `https://github.com/favicon.ico?d=${startTime}`;
|
|
879
|
-
img.onload = () => {
|
|
880
|
-
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
881
|
-
const delta = endTime - startTime;
|
|
882
|
-
resolve(delta);
|
|
883
|
-
};
|
|
884
|
-
img.onerror = (err) => {
|
|
885
|
-
reject(err);
|
|
886
|
-
};
|
|
887
|
-
});
|
|
888
|
-
};
|
|
889
|
-
const durationHandler = (handler, ...params) => (duration) => new Promise((resolve, reject) => {
|
|
890
|
-
setTimeout(async () => {
|
|
891
|
-
try {
|
|
892
|
-
const result = await handler(...params);
|
|
893
|
-
resolve(result);
|
|
894
|
-
} catch (error) {
|
|
895
|
-
reject(error);
|
|
896
|
-
}
|
|
897
|
-
}, duration);
|
|
898
|
-
});
|
|
899
|
-
const networkSpeed = async (options) => {
|
|
900
|
-
const { url, duration = 3e3, count = 5 } = options;
|
|
901
|
-
let jitter = 0;
|
|
902
|
-
let ping = 0;
|
|
903
|
-
const pingList = [];
|
|
904
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
905
|
-
const handler = durationHandler(imageRequest, url);
|
|
906
|
-
const delta = await handler(duration);
|
|
907
|
-
pingList.push(delta);
|
|
908
|
-
}
|
|
909
|
-
const maxPing = Math.max(...pingList);
|
|
910
|
-
const minPing = Math.min(...pingList);
|
|
911
|
-
jitter = maxPing - minPing;
|
|
912
|
-
ping = pingList.reduce((a2, b2) => a2 + b2) / pingList.length;
|
|
913
|
-
return { ping, jitter };
|
|
914
|
-
};
|
|
915
|
-
function compose(middleware) {
|
|
916
|
-
if (!Array.isArray(middleware))
|
|
917
|
-
throw new TypeError("Middleware stack must be an array!");
|
|
918
|
-
for (const fn of middleware) {
|
|
919
|
-
if (typeof fn !== "function")
|
|
920
|
-
throw new TypeError("Middleware must be composed of functions!");
|
|
921
|
-
}
|
|
922
|
-
return function(context, next) {
|
|
923
|
-
let index = -1;
|
|
924
|
-
return dispatch(0);
|
|
925
|
-
function dispatch(i2) {
|
|
926
|
-
if (i2 <= index)
|
|
927
|
-
return Promise.reject(new Error("next() called multiple times"));
|
|
928
|
-
index = i2;
|
|
929
|
-
let fn = middleware[i2];
|
|
930
|
-
if (i2 === middleware.length && next)
|
|
931
|
-
fn = next;
|
|
932
|
-
if (!fn)
|
|
933
|
-
return Promise.resolve();
|
|
934
|
-
try {
|
|
935
|
-
return Promise.resolve(fn(context, dispatch.bind(null, i2 + 1)));
|
|
936
|
-
} catch (err) {
|
|
937
|
-
return Promise.reject(err);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
const memoize = (fn) => {
|
|
943
|
-
let cache = false;
|
|
944
|
-
let result = void 0;
|
|
945
|
-
return (...args) => {
|
|
946
|
-
if (cache) {
|
|
947
|
-
return result;
|
|
948
|
-
} else {
|
|
949
|
-
result = typeof fn === "function" ? fn(...args) : fn;
|
|
950
|
-
cache = true;
|
|
951
|
-
fn = void 0;
|
|
952
|
-
return result;
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
};
|
|
956
|
-
function querystring(data = {}) {
|
|
957
|
-
if (typeof data !== "object") {
|
|
958
|
-
throw new TypeError("param must be object");
|
|
959
|
-
}
|
|
960
|
-
return Object.entries(data).reduce(
|
|
961
|
-
(searchParams, [name, value]) => value === void 0 || value === null ? searchParams : (searchParams.append(decodeURIComponent(name), decodeURIComponent(value)), searchParams),
|
|
962
|
-
new URLSearchParams()
|
|
963
|
-
).toString();
|
|
964
|
-
}
|
|
965
|
-
const transitionJsonToString = (jsonObj, callback = (error) => {
|
|
966
|
-
}) => {
|
|
967
|
-
let _jsonObj = "";
|
|
968
|
-
if (Object.prototype.toString.call(jsonObj) !== "[object String]") {
|
|
969
|
-
try {
|
|
970
|
-
_jsonObj = JSON.stringify(jsonObj);
|
|
971
|
-
} catch (error) {
|
|
972
|
-
callback(error);
|
|
973
|
-
}
|
|
974
|
-
} else {
|
|
975
|
-
try {
|
|
976
|
-
jsonObj = typeof jsonObj === "string" ? jsonObj.replace(/(')/g, '"') : JSON.stringify(jsonObj);
|
|
977
|
-
_jsonObj = JSON.stringify(JSON.parse(jsonObj));
|
|
978
|
-
} catch (error) {
|
|
979
|
-
callback(error);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return _jsonObj;
|
|
983
|
-
};
|
|
984
|
-
const formatJson = (jsonObj, callback = () => {
|
|
985
|
-
}) => {
|
|
986
|
-
let formatted = "";
|
|
987
|
-
let pad = 0;
|
|
988
|
-
const PADDING = " ";
|
|
989
|
-
let jsonString = transitionJsonToString(jsonObj, callback);
|
|
990
|
-
if (!jsonString) {
|
|
991
|
-
return jsonString;
|
|
992
|
-
}
|
|
993
|
-
const _index = [];
|
|
994
|
-
let _indexStart = null;
|
|
995
|
-
let _indexEnd = null;
|
|
996
|
-
let jsonArray = [];
|
|
997
|
-
jsonString = jsonString.replace(/([{}])/g, "\r\n$1\r\n");
|
|
998
|
-
jsonString = jsonString.replace(/([[\]])/g, "\r\n$1\r\n");
|
|
999
|
-
jsonString = jsonString.replace(/(,)/g, "$1\r\n");
|
|
1000
|
-
jsonString = jsonString.replace(/(\r\n\r\n)/g, "\r\n");
|
|
1001
|
-
jsonString = jsonString.replace(/\r\n,/g, ",");
|
|
1002
|
-
jsonArray = jsonString.split("\r\n");
|
|
1003
|
-
jsonArray.forEach(function(node, index) {
|
|
1004
|
-
var _a;
|
|
1005
|
-
const num = node.match(/"/g) ? ((_a = node.match(/"/g)) == null ? void 0 : _a.length) || 0 : 0;
|
|
1006
|
-
if (num % 2 && !_indexStart) {
|
|
1007
|
-
_indexStart = index;
|
|
1008
|
-
}
|
|
1009
|
-
if (num % 2 && _indexStart && _indexStart != index) {
|
|
1010
|
-
_indexEnd = index;
|
|
1011
|
-
}
|
|
1012
|
-
if (_indexStart && _indexEnd) {
|
|
1013
|
-
_index.push({
|
|
1014
|
-
start: _indexStart,
|
|
1015
|
-
end: _indexEnd
|
|
1016
|
-
});
|
|
1017
|
-
_indexStart = null;
|
|
1018
|
-
_indexEnd = null;
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
_index.reverse().forEach(function(item, index) {
|
|
1022
|
-
const newArray = jsonArray.slice(item.start, item.end + 1);
|
|
1023
|
-
jsonArray.splice(item.start, item.end + 1 - item.start, newArray.join(""));
|
|
1024
|
-
});
|
|
1025
|
-
jsonString = jsonArray.join("\r\n");
|
|
1026
|
-
jsonString = jsonString.replace(/:\r\n\{/g, ":{");
|
|
1027
|
-
jsonString = jsonString.replace(/:\r\n\[/g, ":[");
|
|
1028
|
-
jsonArray = jsonString.split("\r\n");
|
|
1029
|
-
jsonArray.forEach(function(item, index) {
|
|
1030
|
-
let i2 = 0;
|
|
1031
|
-
let indent = 0;
|
|
1032
|
-
let padding = "";
|
|
1033
|
-
if (item.match(/\{$/) || item.match(/\[$/)) {
|
|
1034
|
-
indent += 1;
|
|
1035
|
-
} else if (item.match(/\}$/) || item.match(/\]$/) || item.match(/\},$/) || item.match(/\],$/)) {
|
|
1036
|
-
if (pad !== 0) {
|
|
1037
|
-
pad -= 1;
|
|
1038
|
-
}
|
|
1039
|
-
} else {
|
|
1040
|
-
indent = 0;
|
|
1041
|
-
}
|
|
1042
|
-
for (i2 = 0; i2 < pad; i2++) {
|
|
1043
|
-
padding += PADDING;
|
|
1044
|
-
}
|
|
1045
|
-
formatted += padding + item + "\r\n";
|
|
1046
|
-
pad += indent;
|
|
1047
|
-
});
|
|
1048
|
-
return formatted.trim();
|
|
1049
|
-
};
|
|
1050
|
-
const filterObj = (obj, list) => {
|
|
1051
|
-
const result = {};
|
|
1052
|
-
Object.keys(obj).forEach((item) => {
|
|
1053
|
-
if (!list.includes(item)) {
|
|
1054
|
-
result[item] = obj[item];
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
return result;
|
|
1058
|
-
};
|
|
1059
|
-
const merge = (a2, b2) => {
|
|
1060
|
-
if (a2 && b2) {
|
|
1061
|
-
for (const key in b2) {
|
|
1062
|
-
a2[key] = b2[key];
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
return a2;
|
|
1066
|
-
};
|
|
1067
|
-
function replaceOld(source, name, replacement, isForced) {
|
|
1068
|
-
if (typeof source === "undefined")
|
|
1069
|
-
return;
|
|
1070
|
-
if (name in source || isForced) {
|
|
1071
|
-
const original = source[name];
|
|
1072
|
-
const wrapped = replacement(original);
|
|
1073
|
-
if (typeof wrapped === "function") {
|
|
1074
|
-
source[name] = wrapped;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
const mergeExports = (obj, exports) => {
|
|
1079
|
-
const descriptors = Object.getOwnPropertyDescriptors(exports);
|
|
1080
|
-
for (const name of Object.keys(descriptors)) {
|
|
1081
|
-
const descriptor = descriptors[name];
|
|
1082
|
-
if (descriptor.get) {
|
|
1083
|
-
const fn = descriptor.get;
|
|
1084
|
-
Object.defineProperty(obj, name, {
|
|
1085
|
-
configurable: false,
|
|
1086
|
-
enumerable: true,
|
|
1087
|
-
get: memoize(fn)
|
|
1088
|
-
});
|
|
1089
|
-
} else if (typeof descriptor.value === "object") {
|
|
1090
|
-
Object.defineProperty(obj, name, {
|
|
1091
|
-
configurable: false,
|
|
1092
|
-
enumerable: true,
|
|
1093
|
-
writable: false,
|
|
1094
|
-
value: mergeExports({}, descriptor.value)
|
|
1095
|
-
});
|
|
1096
|
-
} else {
|
|
1097
|
-
throw new Error("Exposed values must be either a getter or an nested object");
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
return Object.freeze(obj);
|
|
1101
|
-
};
|
|
1102
|
-
const handleConsole = (hooks = noop) => {
|
|
1103
|
-
const consoleTypeList = ["log", "info", "warn", "error", "assert"];
|
|
1104
|
-
consoleTypeList.forEach((type) => {
|
|
1105
|
-
const replacement = (originalConsole) => {
|
|
1106
|
-
return function(...args) {
|
|
1107
|
-
if (originalConsole) {
|
|
1108
|
-
hooks(type, ...args);
|
|
1109
|
-
originalConsole.apply(console, args);
|
|
1110
|
-
}
|
|
1111
|
-
};
|
|
1112
|
-
};
|
|
1113
|
-
replaceOld(console, type, replacement);
|
|
1114
|
-
});
|
|
1115
|
-
};
|
|
1116
|
-
const debounce = (fn, ms = 500) => {
|
|
1117
|
-
let timeout;
|
|
1118
|
-
return (...args) => {
|
|
1119
|
-
clearTimeout(timeout);
|
|
1120
|
-
timeout = setTimeout(() => {
|
|
1121
|
-
fn.apply(void 0, args);
|
|
1122
|
-
}, ms);
|
|
1123
|
-
};
|
|
1124
|
-
};
|
|
1125
|
-
const currentDevice = () => {
|
|
1126
|
-
if (typeof window !== "undefined") {
|
|
1127
|
-
const ua = navigator.userAgent.toLowerCase();
|
|
1128
|
-
if (/ipad|ipod/.test(ua))
|
|
1129
|
-
return "ipad";
|
|
1130
|
-
if (/android/.test(ua))
|
|
1131
|
-
return "android";
|
|
1132
|
-
if (/iphone/.test(ua))
|
|
1133
|
-
return "iphone";
|
|
1134
|
-
return "pc";
|
|
1135
|
-
}
|
|
1136
|
-
return "pc";
|
|
1137
|
-
};
|
|
1138
|
-
const isClient = typeof window !== "undefined";
|
|
1139
|
-
const isWeiXin = () => {
|
|
1140
|
-
if (isClient) {
|
|
1141
|
-
const ua = window.navigator.userAgent.toLowerCase();
|
|
1142
|
-
return ua.includes("micromessenger");
|
|
1143
|
-
}
|
|
1144
|
-
return false;
|
|
1145
|
-
};
|
|
1146
|
-
const isMobile = () => {
|
|
1147
|
-
const ua = window.navigator.userAgent;
|
|
1148
|
-
if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(ua)) {
|
|
1149
|
-
return true;
|
|
1150
|
-
}
|
|
1151
|
-
return false;
|
|
1152
|
-
};
|
|
1153
|
-
const addClassToElement = (element, addClass) => {
|
|
1154
|
-
if (typeof document === "undefined")
|
|
1155
|
-
return void 0;
|
|
1156
|
-
const classList = element.classList;
|
|
1157
|
-
if (!classList.contains(addClass)) {
|
|
1158
|
-
classList.add(addClass);
|
|
1159
|
-
}
|
|
1160
|
-
};
|
|
1161
|
-
const removeClassToElement = (element, removeClass) => {
|
|
1162
|
-
if (typeof document === "undefined")
|
|
1163
|
-
return void 0;
|
|
1164
|
-
const classList = element.classList;
|
|
1165
|
-
if (classList.contains(removeClass)) {
|
|
1166
|
-
classList.remove(removeClass);
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
const createDocumentFragment = (list) => {
|
|
1170
|
-
if (typeof document === "undefined")
|
|
1171
|
-
return void 0;
|
|
1172
|
-
const Fragment = document.createDocumentFragment();
|
|
1173
|
-
list.forEach((item) => Fragment.appendChild(item));
|
|
1174
|
-
return Fragment;
|
|
1175
|
-
};
|
|
1176
|
-
const matchHtmlRegExp = /["'&<>]/;
|
|
1177
|
-
function escapeHtml(string) {
|
|
1178
|
-
const str = "" + string;
|
|
1179
|
-
const match = matchHtmlRegExp.exec(str);
|
|
1180
|
-
if (!match) {
|
|
1181
|
-
return str;
|
|
1182
|
-
}
|
|
1183
|
-
let escape;
|
|
1184
|
-
let html = "";
|
|
1185
|
-
let index = 0;
|
|
1186
|
-
let lastIndex = 0;
|
|
1187
|
-
for (index = match.index; index < str.length; index++) {
|
|
1188
|
-
switch (str.charCodeAt(index)) {
|
|
1189
|
-
case 34:
|
|
1190
|
-
escape = """;
|
|
1191
|
-
break;
|
|
1192
|
-
case 38:
|
|
1193
|
-
escape = "&";
|
|
1194
|
-
break;
|
|
1195
|
-
case 39:
|
|
1196
|
-
escape = "'";
|
|
1197
|
-
break;
|
|
1198
|
-
case 60:
|
|
1199
|
-
escape = "<";
|
|
1200
|
-
break;
|
|
1201
|
-
case 62:
|
|
1202
|
-
escape = ">";
|
|
1203
|
-
break;
|
|
1204
|
-
default:
|
|
1205
|
-
continue;
|
|
1206
|
-
}
|
|
1207
|
-
if (lastIndex !== index) {
|
|
1208
|
-
html += str.substring(lastIndex, index);
|
|
1209
|
-
}
|
|
1210
|
-
lastIndex = index + 1;
|
|
1211
|
-
html += escape;
|
|
1212
|
-
}
|
|
1213
|
-
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
1214
|
-
}
|
|
1215
|
-
const handleError = (hooks = noop) => {
|
|
1216
|
-
if (typeof window !== "undefined") {
|
|
1217
|
-
window.addEventListener(
|
|
1218
|
-
"unhandledrejection",
|
|
1219
|
-
(error) => {
|
|
1220
|
-
hooks(error);
|
|
1221
|
-
},
|
|
1222
|
-
true
|
|
1223
|
-
);
|
|
1224
|
-
window.addEventListener(
|
|
1225
|
-
"error",
|
|
1226
|
-
(error) => {
|
|
1227
|
-
hooks(error);
|
|
1228
|
-
return false;
|
|
1229
|
-
},
|
|
1230
|
-
true
|
|
1231
|
-
);
|
|
1232
|
-
}
|
|
1233
|
-
};
|
|
1234
|
-
const isImageSize = (file, width, height) => {
|
|
1235
|
-
return new Promise((resolve) => {
|
|
1236
|
-
const _URL = window.URL || window.webkitURL;
|
|
1237
|
-
const img = new Image();
|
|
1238
|
-
img.onload = function() {
|
|
1239
|
-
let valid = false;
|
|
1240
|
-
if (width) {
|
|
1241
|
-
valid = img.width === width;
|
|
1242
|
-
}
|
|
1243
|
-
if (height) {
|
|
1244
|
-
valid = img.height === height;
|
|
1245
|
-
}
|
|
1246
|
-
_URL.revokeObjectURL(img.src);
|
|
1247
|
-
resolve(valid);
|
|
1248
|
-
};
|
|
1249
|
-
img.src = _URL.createObjectURL(file);
|
|
1250
|
-
});
|
|
1251
|
-
};
|
|
1252
|
-
const convertImageToBase64 = (file) => {
|
|
1253
|
-
return new Promise((resolve, reject) => {
|
|
1254
|
-
const reader = new FileReader();
|
|
1255
|
-
reader.onload = function() {
|
|
1256
|
-
resolve({ success: true, data: reader.result, message: "" });
|
|
1257
|
-
};
|
|
1258
|
-
reader.onerror = (e2) => {
|
|
1259
|
-
reject({ success: false, data: e2, message: "" });
|
|
1260
|
-
};
|
|
1261
|
-
reader.readAsDataURL(file);
|
|
1262
|
-
});
|
|
1263
|
-
};
|
|
1264
|
-
function getPerformance() {
|
|
1265
|
-
if (typeof window !== "undefined") {
|
|
1266
|
-
const [performanceNavigationTiming] = performance.getEntriesByType("navigation");
|
|
1267
|
-
const [firstPaint = {}, firstContentfulPaint = {}] = performance.getEntriesByType("paint");
|
|
1268
|
-
const { startTime: fp } = firstPaint;
|
|
1269
|
-
const { startTime: fcp } = firstContentfulPaint;
|
|
1270
|
-
const {
|
|
1271
|
-
domainLookupEnd,
|
|
1272
|
-
domainLookupStart,
|
|
1273
|
-
connectEnd,
|
|
1274
|
-
connectStart,
|
|
1275
|
-
secureConnectionStart,
|
|
1276
|
-
loadEventStart,
|
|
1277
|
-
domInteractive,
|
|
1278
|
-
domContentLoadedEventEnd,
|
|
1279
|
-
duration,
|
|
1280
|
-
responseStart,
|
|
1281
|
-
requestStart,
|
|
1282
|
-
responseEnd,
|
|
1283
|
-
fetchStart,
|
|
1284
|
-
transferSize,
|
|
1285
|
-
encodedBodySize,
|
|
1286
|
-
redirectEnd,
|
|
1287
|
-
redirectStart,
|
|
1288
|
-
redirectCount
|
|
1289
|
-
} = performanceNavigationTiming;
|
|
1290
|
-
return {
|
|
1291
|
-
dnsSearch: domainLookupEnd - domainLookupStart,
|
|
1292
|
-
tcpConnect: connectEnd - connectStart,
|
|
1293
|
-
sslConnect: connectEnd - secureConnectionStart,
|
|
1294
|
-
request: responseStart - requestStart,
|
|
1295
|
-
response: responseEnd - responseStart,
|
|
1296
|
-
parseDomTree: domInteractive - responseEnd,
|
|
1297
|
-
resource: loadEventStart - domContentLoadedEventEnd,
|
|
1298
|
-
domReady: domContentLoadedEventEnd - fetchStart,
|
|
1299
|
-
interactive: domInteractive - fetchStart,
|
|
1300
|
-
complete: loadEventStart - fetchStart,
|
|
1301
|
-
httpHead: transferSize - encodedBodySize,
|
|
1302
|
-
redirect: redirectCount,
|
|
1303
|
-
redirectTime: redirectEnd - redirectStart,
|
|
1304
|
-
duration,
|
|
1305
|
-
fp,
|
|
1306
|
-
fcp
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
const sendBeacon = ({ url = "", type = "application/json; charset=UTF-8", payload = {} }) => {
|
|
1311
|
-
const requestUrl = url ? url : getHost();
|
|
1312
|
-
if (navigator.sendBeacon && requestUrl) {
|
|
1313
|
-
const param = new Blob([JSON.stringify(payload)], { type });
|
|
1314
|
-
return navigator.sendBeacon(requestUrl, param);
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
const sendImage = ({ url = "", payload = {} }) => {
|
|
1318
|
-
const requestUrl = url ? url : getHost();
|
|
1319
|
-
if (typeof document !== "undefined" && requestUrl) {
|
|
1320
|
-
const image = new Image();
|
|
1321
|
-
image.width = 1;
|
|
1322
|
-
image.height = 1;
|
|
1323
|
-
image.src = `${requestUrl}?${querystring(payload)}`;
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
const report = ({
|
|
1327
|
-
url = "",
|
|
1328
|
-
type = "application/json; charset=UTF-8",
|
|
1329
|
-
payload = {}
|
|
1330
|
-
}) => {
|
|
1331
|
-
const requestUrl = url ? url : getHost();
|
|
1332
|
-
if (typeof navigator !== "undefined") {
|
|
1333
|
-
return sendBeacon({ url: requestUrl, type, payload });
|
|
1334
|
-
}
|
|
1335
|
-
return sendImage({ url: requestUrl, payload });
|
|
1336
|
-
};
|
|
1337
|
-
function createData(params = {}) {
|
|
1338
|
-
if (typeof window !== "undefined") {
|
|
1339
|
-
const { width, height } = getWindow();
|
|
1340
|
-
return Object.assign(
|
|
1341
|
-
{},
|
|
1342
|
-
{
|
|
1343
|
-
id: randomString(),
|
|
1344
|
-
path: window.location.href,
|
|
1345
|
-
time: Date.now(),
|
|
1346
|
-
referrer: document.referrer,
|
|
1347
|
-
ip: window.returnCitySN || { cid: "", cip: "", cname: "" },
|
|
1348
|
-
userId: getCookie("chaxus_prod"),
|
|
1349
|
-
ratio: `${width}x${height}`,
|
|
1350
|
-
userAgent: window.navigator.userAgent
|
|
1351
|
-
},
|
|
1352
|
-
params
|
|
1353
|
-
);
|
|
1354
|
-
}
|
|
1355
|
-
return {};
|
|
1356
|
-
}
|
|
1357
|
-
const handleFetchHook = (options = {}) => {
|
|
1358
|
-
if (typeof window !== "undefined") {
|
|
1359
|
-
const { requestHook = noop, responseHook = noop, errorHook = noop } = options;
|
|
1360
|
-
const replacement = (originalFetch) => {
|
|
1361
|
-
return (url, config) => {
|
|
1362
|
-
requestHook(url, config);
|
|
1363
|
-
return originalFetch.apply(window, [url, config]).then((response) => {
|
|
1364
|
-
responseHook(url, config, response);
|
|
1365
|
-
return response;
|
|
1366
|
-
}).catch((error) => {
|
|
1367
|
-
errorHook(url, error);
|
|
1368
|
-
throw error;
|
|
1369
|
-
});
|
|
1370
|
-
};
|
|
1371
|
-
};
|
|
1372
|
-
replaceOld(window, "fetch", replacement);
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
const handleXhrHook = (options = {}) => {
|
|
1376
|
-
if (typeof window !== "undefined") {
|
|
1377
|
-
const originalXhrProto = XMLHttpRequest.prototype;
|
|
1378
|
-
const { requestHook = noop, responseHook = noop, errorHook = noop } = options;
|
|
1379
|
-
const replacementXhrOpen = (originalOpen) => {
|
|
1380
|
-
return function(...args) {
|
|
1381
|
-
requestHook(args);
|
|
1382
|
-
originalOpen.apply(this, args);
|
|
1383
|
-
};
|
|
1384
|
-
};
|
|
1385
|
-
replaceOld(originalXhrProto, "open", replacementXhrOpen);
|
|
1386
|
-
const replacementXhrSend = (originalSend) => {
|
|
1387
|
-
return function(...args) {
|
|
1388
|
-
this.addEventListener("loadend", function() {
|
|
1389
|
-
responseHook(this);
|
|
1390
|
-
});
|
|
1391
|
-
this.addEventListener("error", function() {
|
|
1392
|
-
errorHook(this);
|
|
1393
|
-
});
|
|
1394
|
-
originalSend.apply(this, args);
|
|
1395
|
-
};
|
|
1396
|
-
};
|
|
1397
|
-
replaceOld(originalXhrProto, "send", replacementXhrSend);
|
|
1398
|
-
}
|
|
1399
|
-
};
|
|
1400
|
-
const throttle = (fn, wait = 300) => {
|
|
1401
|
-
let timer;
|
|
1402
|
-
return function() {
|
|
1403
|
-
const context = this;
|
|
1404
|
-
const args = arguments;
|
|
1405
|
-
if (!timer) {
|
|
1406
|
-
timer = setTimeout(() => {
|
|
1407
|
-
timer = null;
|
|
1408
|
-
fn.apply(context, args);
|
|
1409
|
-
}, wait);
|
|
1410
|
-
}
|
|
1411
|
-
};
|
|
1412
|
-
};
|
|
1413
|
-
const generateThrottle = () => {
|
|
1414
|
-
let timer;
|
|
1415
|
-
return function(fn, wait = 300) {
|
|
1416
|
-
return function(...args) {
|
|
1417
|
-
if (timer) {
|
|
1418
|
-
clearTimeout(timer);
|
|
1419
|
-
timer = void 0;
|
|
1420
|
-
}
|
|
1421
|
-
const context = this;
|
|
1422
|
-
if (!timer) {
|
|
1423
|
-
timer = setTimeout(() => {
|
|
1424
|
-
fn.apply(context, args);
|
|
1425
|
-
clearTimeout(timer);
|
|
1426
|
-
timer = void 0;
|
|
1427
|
-
}, wait);
|
|
1428
|
-
}
|
|
1429
|
-
};
|
|
1430
|
-
};
|
|
1431
|
-
};
|
|
1432
|
-
const requestAnimation = (fn) => {
|
|
1433
|
-
let ticking = false;
|
|
1434
|
-
return function() {
|
|
1435
|
-
const context = this;
|
|
1436
|
-
const args = arguments;
|
|
1437
|
-
if (!ticking) {
|
|
1438
|
-
window.requestAnimationFrame(function() {
|
|
1439
|
-
fn.apply(context, args);
|
|
1440
|
-
ticking = false;
|
|
1441
|
-
});
|
|
1442
|
-
ticking = true;
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
|
-
};
|
|
1446
|
-
class Monitor {
|
|
1447
|
-
constructor() {
|
|
1448
|
-
__publicField(this, "init", () => {
|
|
1449
|
-
this.reportClick();
|
|
1450
|
-
this.reportError();
|
|
1451
|
-
this.reportFetch();
|
|
1452
|
-
this.reportPerformance();
|
|
1453
|
-
this.reportXhr();
|
|
1454
|
-
});
|
|
1455
|
-
this.initialize();
|
|
1456
|
-
}
|
|
1457
|
-
/**
|
|
1458
|
-
* @description: 页面加载性能上报
|
|
1459
|
-
* @param {Payload} param1
|
|
1460
|
-
*/
|
|
1461
|
-
reportPerformance() {
|
|
1462
|
-
const params = getPerformance();
|
|
1463
|
-
const payload = createData();
|
|
1464
|
-
report({
|
|
1465
|
-
payload: {
|
|
1466
|
-
...params,
|
|
1467
|
-
...payload
|
|
1468
|
-
}
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
/**
|
|
1472
|
-
* @description: 手动触发的上报
|
|
1473
|
-
* @param {Record} payload
|
|
1474
|
-
* @param {*} unknown
|
|
1475
|
-
*/
|
|
1476
|
-
log(payload) {
|
|
1477
|
-
report({ payload });
|
|
1478
|
-
}
|
|
1479
|
-
/**
|
|
1480
|
-
* @description: 点击上报
|
|
1481
|
-
* @return {*}
|
|
1482
|
-
*/
|
|
1483
|
-
reportClick() {
|
|
1484
|
-
const throttleReport = throttle(report);
|
|
1485
|
-
const payload = createData();
|
|
1486
|
-
const hook = (event) => {
|
|
1487
|
-
const { pageX, pageY, screenX, screenY, type } = event;
|
|
1488
|
-
throttleReport({
|
|
1489
|
-
payload: {
|
|
1490
|
-
...payload,
|
|
1491
|
-
data: { pageX, pageY, screenX, screenY, type },
|
|
1492
|
-
type: "click"
|
|
1493
|
-
}
|
|
1494
|
-
});
|
|
1495
|
-
};
|
|
1496
|
-
handleClick(hook);
|
|
1497
|
-
}
|
|
1498
|
-
// ajax 上报
|
|
1499
|
-
reportXhr() {
|
|
1500
|
-
const throttleReport = throttle(report);
|
|
1501
|
-
const payload = createData();
|
|
1502
|
-
const requestHook = (...args) => {
|
|
1503
|
-
throttleReport({
|
|
1504
|
-
payload: { ...payload, data: { ...args }, type: "xhrRequest" }
|
|
1505
|
-
});
|
|
1506
|
-
};
|
|
1507
|
-
const responseHook = (...args) => {
|
|
1508
|
-
throttleReport({
|
|
1509
|
-
payload: { ...payload, data: { ...args }, type: "xhrResponse" }
|
|
1510
|
-
});
|
|
1511
|
-
};
|
|
1512
|
-
const errorHook = (...args) => {
|
|
1513
|
-
throttleReport({
|
|
1514
|
-
payload: { ...payload, data: { ...args }, type: "xhrError" }
|
|
1515
|
-
});
|
|
1516
|
-
};
|
|
1517
|
-
handleXhrHook({ requestHook, responseHook, errorHook });
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* @description: fetch上报
|
|
1521
|
-
*/
|
|
1522
|
-
reportFetch() {
|
|
1523
|
-
const throttleReport = throttle(report);
|
|
1524
|
-
const payload = createData();
|
|
1525
|
-
const requestHook = (...args) => {
|
|
1526
|
-
throttleReport({
|
|
1527
|
-
payload: { ...payload, data: { ...args }, type: "fetchRequest" }
|
|
1528
|
-
});
|
|
1529
|
-
};
|
|
1530
|
-
const responseHook = (...args) => {
|
|
1531
|
-
throttleReport({
|
|
1532
|
-
payload: { ...payload, data: { ...args }, type: "fetchResponse" }
|
|
1533
|
-
});
|
|
1534
|
-
};
|
|
1535
|
-
const errorHook = (...args) => {
|
|
1536
|
-
throttleReport({
|
|
1537
|
-
payload: { ...payload, data: { ...args }, type: "fetchError" }
|
|
1538
|
-
});
|
|
1539
|
-
};
|
|
1540
|
-
handleFetchHook({ requestHook, responseHook, errorHook });
|
|
1541
|
-
}
|
|
1542
|
-
/**
|
|
1543
|
-
* @description: 错误上报
|
|
1544
|
-
*/
|
|
1545
|
-
reportError() {
|
|
1546
|
-
const throttleReport = throttle(report);
|
|
1547
|
-
const payload = createData();
|
|
1548
|
-
const hook = (...args) => {
|
|
1549
|
-
throttleReport({
|
|
1550
|
-
payload: { ...payload, data: { ...args }, type: "error" }
|
|
1551
|
-
});
|
|
1552
|
-
};
|
|
1553
|
-
handleError(hook);
|
|
1554
|
-
}
|
|
1555
|
-
/**
|
|
1556
|
-
* @description: 上报console
|
|
1557
|
-
*/
|
|
1558
|
-
reportConsole() {
|
|
1559
|
-
const throttleReport = throttle(report);
|
|
1560
|
-
const payload = createData();
|
|
1561
|
-
const hook = (...args) => {
|
|
1562
|
-
throttleReport({
|
|
1563
|
-
payload: { ...payload, data: { ...args }, type: "console" }
|
|
1564
|
-
});
|
|
1565
|
-
};
|
|
1566
|
-
handleConsole(hook);
|
|
1567
|
-
}
|
|
1568
|
-
initialize() {
|
|
1569
|
-
if (typeof window !== "undefined" && !window.ranlog) {
|
|
1570
|
-
window.ranlog = true;
|
|
1571
|
-
this.init();
|
|
1572
|
-
}
|
|
1573
|
-
if (typeof process !== "undefined" && !process.ranlog) {
|
|
1574
|
-
process.ranlog = true;
|
|
1575
|
-
this.init();
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
const codes = /* @__PURE__ */ new Map([
|
|
1580
|
-
[100, "Continue"],
|
|
1581
|
-
[101, "Switching Protocols"],
|
|
1582
|
-
[102, "Processing"],
|
|
1583
|
-
[103, "Early Hints"],
|
|
1584
|
-
[200, "OK"],
|
|
1585
|
-
[201, "Created"],
|
|
1586
|
-
[202, "Accepted"],
|
|
1587
|
-
[203, "Non-Authoritative Information"],
|
|
1588
|
-
[204, "No Content"],
|
|
1589
|
-
[205, "Reset Content"],
|
|
1590
|
-
[206, "Partial Content"],
|
|
1591
|
-
[207, "Multi-Status"],
|
|
1592
|
-
[208, "Already Reported"],
|
|
1593
|
-
[226, "IM Used"],
|
|
1594
|
-
[300, "Multiple Choices"],
|
|
1595
|
-
[301, "Moved Permanently"],
|
|
1596
|
-
[302, "Found"],
|
|
1597
|
-
[303, "See Other"],
|
|
1598
|
-
[304, "Not Modified"],
|
|
1599
|
-
[305, "Use Proxy"],
|
|
1600
|
-
[307, "Temporary Redirect"],
|
|
1601
|
-
[308, "Permanent Redirect"],
|
|
1602
|
-
[400, "Bad Request"],
|
|
1603
|
-
[401, "Unauthorized"],
|
|
1604
|
-
[402, "Payment Required"],
|
|
1605
|
-
[403, "Forbidden"],
|
|
1606
|
-
[404, "Not Found"],
|
|
1607
|
-
[405, "Method Not Allowed"],
|
|
1608
|
-
[406, "Not Acceptable"],
|
|
1609
|
-
[407, "Proxy Authentication Required"],
|
|
1610
|
-
[408, "Request Timeout"],
|
|
1611
|
-
[409, "Conflict"],
|
|
1612
|
-
[410, "Gone"],
|
|
1613
|
-
[411, "Length Required"],
|
|
1614
|
-
[412, "Precondition Failed"],
|
|
1615
|
-
[413, "Payload Too Large"],
|
|
1616
|
-
[414, "URI Too Long"],
|
|
1617
|
-
[415, "Unsupported Media Type"],
|
|
1618
|
-
[416, "Range Not Satisfiable"],
|
|
1619
|
-
[417, "Expectation Failed"],
|
|
1620
|
-
[418, "I'm a Teapot"],
|
|
1621
|
-
[421, "Misdirected Request"],
|
|
1622
|
-
[422, "Unprocessable Entity"],
|
|
1623
|
-
[423, "Locked"],
|
|
1624
|
-
[424, "Failed Dependency"],
|
|
1625
|
-
[425, "Too Early"],
|
|
1626
|
-
[426, "Upgrade Required"],
|
|
1627
|
-
[428, "Precondition Required"],
|
|
1628
|
-
[429, "Too Many Requests"],
|
|
1629
|
-
[431, "Request Header Fields Too Large"],
|
|
1630
|
-
[451, "Unavailable For Legal Reasons"],
|
|
1631
|
-
[500, "Internal Server Error"],
|
|
1632
|
-
[501, "Not Implemented"],
|
|
1633
|
-
[502, "Bad Gateway"],
|
|
1634
|
-
[503, "Service Unavailable"],
|
|
1635
|
-
[504, "Gateway Timeout"],
|
|
1636
|
-
[505, "HTTP Version Not Supported"],
|
|
1637
|
-
[506, "Variant Also Negotiates"],
|
|
1638
|
-
[507, "Insufficient Storage"],
|
|
1639
|
-
[508, "Loop Detected"],
|
|
1640
|
-
[509, "Bandwidth Limit Exceeded"],
|
|
1641
|
-
[510, "Not Extended"],
|
|
1642
|
-
[511, "Network Authentication Required"]
|
|
1643
|
-
]);
|
|
1644
|
-
const status = {
|
|
1645
|
-
// status code to message map
|
|
1646
|
-
message: codes,
|
|
1647
|
-
// status message (lower-case) to code map
|
|
1648
|
-
code: createMessageToStatusCodeMap(codes),
|
|
1649
|
-
// array of status codes
|
|
1650
|
-
codes: createStatusCodeList(codes),
|
|
1651
|
-
// status codes for redirects
|
|
1652
|
-
redirect: {
|
|
1653
|
-
300: true,
|
|
1654
|
-
301: true,
|
|
1655
|
-
302: true,
|
|
1656
|
-
303: true,
|
|
1657
|
-
305: true,
|
|
1658
|
-
307: true,
|
|
1659
|
-
308: true
|
|
1660
|
-
},
|
|
1661
|
-
// status codes for empty bodies
|
|
1662
|
-
empty: {
|
|
1663
|
-
204: true,
|
|
1664
|
-
205: true,
|
|
1665
|
-
304: true
|
|
1666
|
-
},
|
|
1667
|
-
// status codes for when you should retry the request
|
|
1668
|
-
retry: {
|
|
1669
|
-
502: true,
|
|
1670
|
-
503: true,
|
|
1671
|
-
504: true
|
|
1672
|
-
}
|
|
1673
|
-
};
|
|
1674
|
-
function createMessageToStatusCodeMap(codes2) {
|
|
1675
|
-
const map = /* @__PURE__ */ new Map();
|
|
1676
|
-
for (const [status2, message] of codes2) {
|
|
1677
|
-
map.set(message.toLowerCase(), status2);
|
|
1678
|
-
}
|
|
1679
|
-
return map;
|
|
1680
|
-
}
|
|
1681
|
-
function createStatusCodeList(codes2) {
|
|
1682
|
-
const codeList = [];
|
|
1683
|
-
for (const [status2, _] of codes2) {
|
|
1684
|
-
codeList.push(status2);
|
|
1685
|
-
}
|
|
1686
|
-
return codeList;
|
|
1687
|
-
}
|
|
1688
|
-
function getStatusCode(message) {
|
|
1689
|
-
const msg = message.toLowerCase();
|
|
1690
|
-
status.code.has(msg);
|
|
1691
|
-
if (!status.code.has(msg)) {
|
|
1692
|
-
throw new Error('invalid status message: "' + message + '"');
|
|
1693
|
-
}
|
|
1694
|
-
return status.code.get(msg);
|
|
1695
|
-
}
|
|
1696
|
-
function getStatusMessage(code) {
|
|
1697
|
-
if (!status.message.has(code)) {
|
|
1698
|
-
throw new Error("invalid status code: " + code);
|
|
1699
|
-
}
|
|
1700
|
-
return status.message.get(code);
|
|
1701
|
-
}
|
|
1702
|
-
function getStatus(code) {
|
|
1703
|
-
if (typeof code === "number") {
|
|
1704
|
-
return getStatusMessage(code);
|
|
1705
|
-
}
|
|
1706
|
-
if (typeof code !== "string") {
|
|
1707
|
-
throw new TypeError("code must be a number or string");
|
|
1708
|
-
}
|
|
1709
|
-
const n2 = parseInt(code, 10);
|
|
1710
|
-
if (!isNaN(n2) && status.codes.includes(n2)) {
|
|
1711
|
-
return getStatusMessage(n2);
|
|
1712
|
-
}
|
|
1713
|
-
return getStatusCode(code);
|
|
1714
|
-
}
|
|
1715
|
-
const perToNum = (str = "") => {
|
|
1716
|
-
if (str.length === 0)
|
|
1717
|
-
return 0;
|
|
1718
|
-
if (str.endsWith("%")) {
|
|
1719
|
-
const value = Number(str.replace("%", ""));
|
|
1720
|
-
return value > 1 ? value / 100 : value;
|
|
1721
|
-
} else {
|
|
1722
|
-
return Number(str);
|
|
1723
|
-
}
|
|
1724
|
-
};
|
|
1725
|
-
const range = (num, min = 0, max = 1) => {
|
|
1726
|
-
return Math.min(max, Math.max(min, num));
|
|
1727
|
-
};
|
|
1728
|
-
const _Mathjs = class _Mathjs {
|
|
1729
|
-
constructor() {
|
|
1730
|
-
/**
|
|
1731
|
-
* 获取数字小数点的长度
|
|
1732
|
-
* @param {number} n 数字
|
|
1733
|
-
*/
|
|
1734
|
-
__publicField(this, "getDecimalLength", (n2) => {
|
|
1735
|
-
const [_, decimal] = n2.toString().split(".");
|
|
1736
|
-
return decimal ? decimal.length : 0;
|
|
1737
|
-
});
|
|
1738
|
-
__publicField(this, "amend", (n2, precision = 15) => parseFloat(Number(n2).toPrecision(precision)));
|
|
1739
|
-
__publicField(this, "power", (a2, b2) => Math.pow(10, Math.max(this.getDecimalLength(a2), this.getDecimalLength(b2))));
|
|
1740
|
-
}
|
|
1741
|
-
};
|
|
1742
|
-
__publicField(_Mathjs, "handleMethod", (l2, r2) => {
|
|
1743
|
-
const mathjs2 = new _Mathjs();
|
|
1744
|
-
const { power, amend } = mathjs2;
|
|
1745
|
-
const pow = power(l2, r2);
|
|
1746
|
-
const a2 = amend(l2 * pow);
|
|
1747
|
-
const b2 = amend(r2 * pow);
|
|
1748
|
-
return (type) => {
|
|
1749
|
-
switch (type) {
|
|
1750
|
-
case "+":
|
|
1751
|
-
return (a2 + b2) / pow;
|
|
1752
|
-
case "-":
|
|
1753
|
-
return (a2 - b2) / pow;
|
|
1754
|
-
case "*":
|
|
1755
|
-
return a2 * b2 / (pow * pow);
|
|
1756
|
-
case "/":
|
|
1757
|
-
return a2 / b2;
|
|
1758
|
-
}
|
|
1759
|
-
};
|
|
1760
|
-
});
|
|
1761
|
-
__publicField(_Mathjs, "add", (a2, b2) => {
|
|
1762
|
-
return _Mathjs.handleMethod(a2, b2)("+");
|
|
1763
|
-
});
|
|
1764
|
-
__publicField(_Mathjs, "divide", (a2, b2) => {
|
|
1765
|
-
return _Mathjs.handleMethod(a2, b2)("/");
|
|
1766
|
-
});
|
|
1767
|
-
__publicField(_Mathjs, "multiply", (a2, b2) => {
|
|
1768
|
-
return _Mathjs.handleMethod(a2, b2)("*");
|
|
1769
|
-
});
|
|
1770
|
-
__publicField(_Mathjs, "subtract", (a2, b2) => {
|
|
1771
|
-
return _Mathjs.handleMethod(a2, b2)("-");
|
|
1772
|
-
});
|
|
1773
|
-
let Mathjs = _Mathjs;
|
|
1774
|
-
function mathjs(a2, type, b2) {
|
|
1775
|
-
function getDecimalLength(n2) {
|
|
1776
|
-
const [_, decimal] = n2.toString().split(".");
|
|
1777
|
-
return decimal ? decimal.length : 0;
|
|
1778
|
-
}
|
|
1779
|
-
const amend = (n2, precision = 15) => parseFloat(Number(n2).toPrecision(precision));
|
|
1780
|
-
const power = Math.pow(10, Math.max(getDecimalLength(a2), getDecimalLength(b2)));
|
|
1781
|
-
let result = 0;
|
|
1782
|
-
a2 = amend(a2 * power);
|
|
1783
|
-
b2 = amend(b2 * power);
|
|
1784
|
-
switch (type) {
|
|
1785
|
-
case "+":
|
|
1786
|
-
result = (a2 + b2) / power;
|
|
1787
|
-
break;
|
|
1788
|
-
case "-":
|
|
1789
|
-
result = (a2 - b2) / power;
|
|
1790
|
-
break;
|
|
1791
|
-
case "*":
|
|
1792
|
-
result = a2 * b2 / (power * power);
|
|
1793
|
-
break;
|
|
1794
|
-
case "/":
|
|
1795
|
-
result = a2 / b2;
|
|
1796
|
-
break;
|
|
1797
|
-
}
|
|
1798
|
-
result = amend(result);
|
|
1799
|
-
return {
|
|
1800
|
-
/** 计算结果 */
|
|
1801
|
-
result,
|
|
1802
|
-
/**
|
|
1803
|
-
* 继续计算
|
|
1804
|
-
* @param {"+"|"-"|"*"|"/"} nextType 继续计算方式
|
|
1805
|
-
* @param {number} nextValue 继续计算的值
|
|
1806
|
-
*/
|
|
1807
|
-
next: (nextType, nextValue) => {
|
|
1808
|
-
return mathjs(result, nextType, nextValue);
|
|
1809
|
-
}
|
|
1810
|
-
};
|
|
1811
|
-
}
|
|
1812
|
-
class QuestQueue {
|
|
1813
|
-
constructor({ simultaneous, total }) {
|
|
1814
|
-
__publicField(this, "current");
|
|
1815
|
-
__publicField(this, "queue");
|
|
1816
|
-
__publicField(this, "simultaneous");
|
|
1817
|
-
// 并发的请求
|
|
1818
|
-
__publicField(this, "executed");
|
|
1819
|
-
__publicField(this, "total");
|
|
1820
|
-
/**
|
|
1821
|
-
* @description: 传入异步函数,添加到队列并执行
|
|
1822
|
-
* @param {Fun} asynchronous
|
|
1823
|
-
* @return {*}
|
|
1824
|
-
*/
|
|
1825
|
-
__publicField(this, "add", (asynchronous) => {
|
|
1826
|
-
if (typeof asynchronous !== "function")
|
|
1827
|
-
return;
|
|
1828
|
-
const task = () => {
|
|
1829
|
-
return new Promise((resolve, reject) => {
|
|
1830
|
-
this.current++;
|
|
1831
|
-
asynchronous().then(resolve).catch(reject).finally(() => {
|
|
1832
|
-
this.current--;
|
|
1833
|
-
this.running();
|
|
1834
|
-
});
|
|
1835
|
-
});
|
|
1836
|
-
};
|
|
1837
|
-
this.queue.push(task);
|
|
1838
|
-
});
|
|
1839
|
-
/**
|
|
1840
|
-
* @description: 执行异步函数
|
|
1841
|
-
* @param {*} Promise
|
|
1842
|
-
* @return {*}
|
|
1843
|
-
*/
|
|
1844
|
-
__publicField(this, "running", () => {
|
|
1845
|
-
return new Promise((resolve, reject) => {
|
|
1846
|
-
if (this.current <= this.simultaneous && this.queue.length) {
|
|
1847
|
-
const task = this.queue.pop();
|
|
1848
|
-
if (task) {
|
|
1849
|
-
task().then(resolve).catch(reject).finally(() => {
|
|
1850
|
-
this.executed++;
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1853
|
-
} else {
|
|
1854
|
-
resolve({});
|
|
1855
|
-
}
|
|
1856
|
-
});
|
|
1857
|
-
});
|
|
1858
|
-
/**
|
|
1859
|
-
* @description: 并发执行所有的异步函数,并返回所有的结果
|
|
1860
|
-
* @param {*} Promise
|
|
1861
|
-
* @return {*}
|
|
1862
|
-
*/
|
|
1863
|
-
__publicField(this, "allSettled", () => {
|
|
1864
|
-
let index = 0;
|
|
1865
|
-
return new Promise((resolve, reject) => {
|
|
1866
|
-
const result = [];
|
|
1867
|
-
if (this.current < this.simultaneous && this.queue.length) {
|
|
1868
|
-
const task = this.queue.pop();
|
|
1869
|
-
index++;
|
|
1870
|
-
if (task) {
|
|
1871
|
-
task().then((x) => {
|
|
1872
|
-
result[index] = x;
|
|
1873
|
-
resolve(x);
|
|
1874
|
-
}).catch((x) => {
|
|
1875
|
-
result[index] = x;
|
|
1876
|
-
reject(x);
|
|
1877
|
-
}).finally(() => {
|
|
1878
|
-
this.executed++;
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
if (this.executed >= this.total) {
|
|
1883
|
-
resolve(result);
|
|
1884
|
-
}
|
|
1885
|
-
});
|
|
1886
|
-
});
|
|
1887
|
-
this.current = 0;
|
|
1888
|
-
this.queue = [];
|
|
1889
|
-
this.simultaneous = simultaneous;
|
|
1890
|
-
this.executed = 0;
|
|
1891
|
-
this.total = total;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
const scriptOnLoad = (urls, append, callback) => {
|
|
1895
|
-
urls = Array.isArray(urls) ? urls : [urls];
|
|
1896
|
-
const array = urls.map((src) => {
|
|
1897
|
-
const cssReg = /\w*.css$/;
|
|
1898
|
-
let script;
|
|
1899
|
-
if (cssReg.test(src)) {
|
|
1900
|
-
const link = document.createElement("link");
|
|
1901
|
-
link.type = "text/css";
|
|
1902
|
-
link.rel = "stylesheet";
|
|
1903
|
-
link.href = src;
|
|
1904
|
-
script = link;
|
|
1905
|
-
} else {
|
|
1906
|
-
script = document.createElement("script");
|
|
1907
|
-
script.type = "text/javascript";
|
|
1908
|
-
script.src = src;
|
|
1909
|
-
}
|
|
1910
|
-
const bodyElement = document.getElementsByTagName("body")[0];
|
|
1911
|
-
const currentAppend = append || bodyElement;
|
|
1912
|
-
currentAppend.appendChild(script);
|
|
1913
|
-
return new Promise((resolve) => {
|
|
1914
|
-
script.onload = () => {
|
|
1915
|
-
resolve();
|
|
1916
|
-
};
|
|
1917
|
-
});
|
|
1918
|
-
});
|
|
1919
|
-
return new Promise((resolve) => {
|
|
1920
|
-
Promise.all(array).then(() => {
|
|
1921
|
-
if (typeof callback === "function") {
|
|
1922
|
-
callback();
|
|
1923
|
-
}
|
|
1924
|
-
resolve();
|
|
1925
|
-
});
|
|
1926
|
-
});
|
|
1927
|
-
};
|
|
1928
|
-
const NEW_LISTENER = "NEW_LISTENER";
|
|
1929
|
-
class SyncHook {
|
|
1930
|
-
constructor() {
|
|
1931
|
-
__publicField(this, "_events");
|
|
1932
|
-
__publicField(this, "tap", (eventName, eventItem) => {
|
|
1933
|
-
if (this._events[eventName] && eventName !== Symbol.for(NEW_LISTENER)) {
|
|
1934
|
-
this.call(Symbol.for(NEW_LISTENER), eventName);
|
|
1935
|
-
}
|
|
1936
|
-
const callbacks = this._events[eventName] || [];
|
|
1937
|
-
if (typeof eventItem === "function") {
|
|
1938
|
-
callbacks.push({
|
|
1939
|
-
name: eventName,
|
|
1940
|
-
callback: eventItem
|
|
1941
|
-
});
|
|
1942
|
-
} else {
|
|
1943
|
-
callbacks.push(eventItem);
|
|
1944
|
-
}
|
|
1945
|
-
this._events[eventName] = callbacks;
|
|
1946
|
-
});
|
|
1947
|
-
__publicField(this, "call", (eventName, ...args) => {
|
|
1948
|
-
const callbacks = this._events[eventName] || [];
|
|
1949
|
-
callbacks.forEach((item) => {
|
|
1950
|
-
const { callback } = item;
|
|
1951
|
-
callback(...args);
|
|
1952
|
-
});
|
|
1953
|
-
});
|
|
1954
|
-
__publicField(this, "callSync", async (eventName, ...args) => {
|
|
1955
|
-
const callbacks = this._events[eventName] || [];
|
|
1956
|
-
for (const item of callbacks) {
|
|
1957
|
-
const { callback } = item;
|
|
1958
|
-
await callback(...args);
|
|
1959
|
-
}
|
|
1960
|
-
});
|
|
1961
|
-
__publicField(this, "once", (eventName, eventItem) => {
|
|
1962
|
-
let one;
|
|
1963
|
-
if (typeof eventItem === "function") {
|
|
1964
|
-
one = {
|
|
1965
|
-
name: eventName,
|
|
1966
|
-
callback: (...args) => {
|
|
1967
|
-
eventItem(...args);
|
|
1968
|
-
this.off(eventName, one);
|
|
1969
|
-
},
|
|
1970
|
-
initialCallback: eventItem
|
|
1971
|
-
};
|
|
1972
|
-
} else {
|
|
1973
|
-
const { callback } = eventItem;
|
|
1974
|
-
one = {
|
|
1975
|
-
name: eventName,
|
|
1976
|
-
callback: (...args) => {
|
|
1977
|
-
callback(...args);
|
|
1978
|
-
this.off(eventName, one);
|
|
1979
|
-
},
|
|
1980
|
-
initialCallback: callback
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
this.tap(eventName, one);
|
|
1984
|
-
});
|
|
1985
|
-
__publicField(this, "off", (eventName, eventItem) => {
|
|
1986
|
-
const callbacks = this._events[eventName] || [];
|
|
1987
|
-
const newCallbacks = callbacks.filter((item) => {
|
|
1988
|
-
if (typeof eventItem === "function") {
|
|
1989
|
-
return item.callback !== eventItem && item.initialCallback !== eventItem;
|
|
1990
|
-
} else {
|
|
1991
|
-
const { callback } = eventItem;
|
|
1992
|
-
return item.callback !== callback && item.initialCallback !== callback;
|
|
1993
|
-
}
|
|
1994
|
-
});
|
|
1995
|
-
this._events[eventName] = newCallbacks;
|
|
1996
|
-
});
|
|
1997
|
-
this._events = {};
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
export {
|
|
2001
|
-
AudioRecorder,
|
|
2002
|
-
C as Color,
|
|
2003
|
-
a as ColorScheme,
|
|
2004
|
-
F as FMT,
|
|
2005
|
-
H as Hsl,
|
|
2006
|
-
b as Hsla,
|
|
2007
|
-
Mathjs,
|
|
2008
|
-
M as MimeType,
|
|
2009
|
-
Monitor,
|
|
2010
|
-
QuestQueue,
|
|
2011
|
-
R as Rgb,
|
|
2012
|
-
c as Rgba,
|
|
2013
|
-
SyncHook,
|
|
2014
|
-
addClassToElement,
|
|
2015
|
-
appendUrl,
|
|
2016
|
-
audioVendor,
|
|
2017
|
-
canvasVendor,
|
|
2018
|
-
d as changeHumpToLowerCase,
|
|
2019
|
-
e as clearBr,
|
|
2020
|
-
f as clearStr,
|
|
2021
|
-
g as componentToHex,
|
|
2022
|
-
compose,
|
|
2023
|
-
connection,
|
|
2024
|
-
convertImageToBase64,
|
|
2025
|
-
createData,
|
|
2026
|
-
createDocumentFragment,
|
|
2027
|
-
createObjectURL,
|
|
2028
|
-
currentDevice,
|
|
2029
|
-
debounce,
|
|
2030
|
-
durationHandler,
|
|
2031
|
-
encodeUrl,
|
|
2032
|
-
escapeHtml,
|
|
2033
|
-
filterObj,
|
|
2034
|
-
formatJson,
|
|
2035
|
-
generateThrottle,
|
|
2036
|
-
getAllQueryString,
|
|
2037
|
-
getCookie,
|
|
2038
|
-
getCookieByName,
|
|
2039
|
-
getFrame,
|
|
2040
|
-
getHost,
|
|
2041
|
-
h as getMime,
|
|
2042
|
-
getPerformance,
|
|
2043
|
-
getPixelRatio,
|
|
2044
|
-
getStatus,
|
|
2045
|
-
getWindow,
|
|
2046
|
-
handleConsole,
|
|
2047
|
-
handleError,
|
|
2048
|
-
handleFetchHook,
|
|
2049
|
-
i as hexToRgb,
|
|
2050
|
-
j as hsbToRgb,
|
|
2051
|
-
k as hslToRgb,
|
|
2052
|
-
l as hsvToHsl,
|
|
2053
|
-
m as hsvToRgb,
|
|
2054
|
-
n as hue2rgb,
|
|
2055
|
-
imageRequest,
|
|
2056
|
-
isClient,
|
|
2057
|
-
isImageSize,
|
|
2058
|
-
isMobile,
|
|
2059
|
-
isString,
|
|
2060
|
-
isWeiXin,
|
|
2061
|
-
mathjs,
|
|
2062
|
-
memoize,
|
|
2063
|
-
merge,
|
|
2064
|
-
mergeExports,
|
|
2065
|
-
networkSpeed,
|
|
2066
|
-
noop,
|
|
2067
|
-
perToNum,
|
|
2068
|
-
performanceTime,
|
|
2069
|
-
querystring,
|
|
2070
|
-
r as randomColor,
|
|
2071
|
-
randomString,
|
|
2072
|
-
range,
|
|
2073
|
-
removeClassToElement,
|
|
2074
|
-
removeGhosting,
|
|
2075
|
-
replaceOld,
|
|
2076
|
-
report,
|
|
2077
|
-
requestAnimation,
|
|
2078
|
-
requestUrlToBuffer,
|
|
2079
|
-
retain,
|
|
2080
|
-
q as rgbToHex,
|
|
2081
|
-
s as rgbToHsb,
|
|
2082
|
-
t as rgbToHsl,
|
|
2083
|
-
scriptOnLoad,
|
|
2084
|
-
u as setMime,
|
|
2085
|
-
status,
|
|
2086
|
-
v as str2Xml,
|
|
2087
|
-
w as strParse,
|
|
2088
|
-
throttle,
|
|
2089
|
-
timeFormat,
|
|
2090
|
-
timestampToTime,
|
|
2091
|
-
webglVendor
|
|
2092
|
-
};
|