web-tracing-core 2.1.0 → 2.1.1

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.
Files changed (61) hide show
  1. package/{dist/README.md → README.md} +8 -0
  2. package/{dist/index.cjs → index.cjs} +24 -5
  3. package/{dist/index.iife.js → index.iife.js} +24 -5
  4. package/{dist/index.iife.min.js → index.iife.min.js} +9 -9
  5. package/{dist/index.mjs → index.mjs} +24 -5
  6. package/package.json +9 -9
  7. package/__test__/css/performance.css +0 -3
  8. package/__test__/err-batch.spec.ts +0 -47
  9. package/__test__/err.spec.ts +0 -82
  10. package/__test__/event.spec.ts +0 -62
  11. package/__test__/html/performance.html +0 -57
  12. package/__test__/html/recordscreen.html +0 -39
  13. package/__test__/http.spec.ts +0 -143
  14. package/__test__/img/performance.png +0 -0
  15. package/__test__/js/performance.js +0 -3
  16. package/__test__/performance.spec.ts +0 -112
  17. package/__test__/recordscreen.spec.ts +0 -50
  18. package/__test__/utils/index.ts +0 -99
  19. package/__test__/utils/pollify.ts +0 -14
  20. package/__test__/utils.spec.ts +0 -18
  21. package/dist/package.json +0 -49
  22. package/index.ts +0 -75
  23. package/src/common/config.ts +0 -13
  24. package/src/common/constant.ts +0 -57
  25. package/src/common/index.ts +0 -2
  26. package/src/lib/base.ts +0 -129
  27. package/src/lib/err-batch.ts +0 -134
  28. package/src/lib/err.ts +0 -323
  29. package/src/lib/event-dwell.ts +0 -63
  30. package/src/lib/event.ts +0 -252
  31. package/src/lib/eventBus.ts +0 -97
  32. package/src/lib/exportMethods.ts +0 -208
  33. package/src/lib/http.ts +0 -197
  34. package/src/lib/intersectionObserver.ts +0 -164
  35. package/src/lib/line-status.ts +0 -45
  36. package/src/lib/options.ts +0 -325
  37. package/src/lib/performance.ts +0 -302
  38. package/src/lib/pv.ts +0 -199
  39. package/src/lib/recordscreen.ts +0 -169
  40. package/src/lib/replace.ts +0 -371
  41. package/src/lib/sendData.ts +0 -264
  42. package/src/observer/computed.ts +0 -52
  43. package/src/observer/config.ts +0 -1
  44. package/src/observer/dep.ts +0 -21
  45. package/src/observer/index.ts +0 -91
  46. package/src/observer/ref.ts +0 -80
  47. package/src/observer/types.ts +0 -22
  48. package/src/observer/watch.ts +0 -19
  49. package/src/observer/watcher.ts +0 -88
  50. package/src/types/index.ts +0 -126
  51. package/src/utils/debug.ts +0 -17
  52. package/src/utils/element.ts +0 -47
  53. package/src/utils/fingerprintjs.ts +0 -2132
  54. package/src/utils/getIps.ts +0 -127
  55. package/src/utils/global.ts +0 -49
  56. package/src/utils/index.ts +0 -551
  57. package/src/utils/is.ts +0 -78
  58. package/src/utils/localStorage.ts +0 -70
  59. package/src/utils/session.ts +0 -27
  60. /package/{dist/LICENSE → LICENSE} +0 -0
  61. /package/{dist/index.d.ts → index.d.ts} +0 -0
@@ -1,127 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * 获取ip
4
- * 注:此文件为 webrtc-ip[https://github.com/joeymalvinni/webrtc-ip] v3.0.1 离线版本
5
- */
6
- function is_ipv4(d) {
7
- return regex_v4.test(d)
8
- }
9
- function is_ipv6(d) {
10
- return regex_v6.test(d)
11
- }
12
- const simpleIPRegex =
13
- /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g
14
- const regex_v4 =
15
- /((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/,
16
- regex_v6 =
17
- /((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))/,
18
- ip_regex_array = [regex_v6, regex_v4]
19
- function peer(d) {
20
- let e,
21
- t =
22
- window.RTCPeerConnection ||
23
- window.mozRTCPeerConnection ||
24
- window.webkitRTCPeerConnection
25
- function n() {
26
- ;((e = new t({
27
- iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
28
- })).onicecandidate = d => f(d)),
29
- e.createDataChannel('fake_data_channel')
30
- }
31
- function a() {
32
- return e.createOffer().then(d => e.setLocalDescription(d))
33
- }
34
- function f(e) {
35
- e &&
36
- e.candidate &&
37
- e.candidate.candidate &&
38
- d(e && e.candidate && e.candidate.candidate)
39
- }
40
- return {
41
- start: function () {
42
- n(), a()
43
- },
44
- stop: function () {
45
- if (e)
46
- try {
47
- e.close()
48
- } finally {
49
- ;(e.onicecandidate = () => {}), (e = null)
50
- }
51
- },
52
- createConnection: n,
53
- createStunRequest: a,
54
- handleCandidates: f
55
- }
56
- }
57
- function publicIPs(d) {
58
- if (d && d < 100)
59
- throw new Error('Custom timeout cannot be under 100 milliseconds.')
60
- const e = [],
61
- t = peer(function (d) {
62
- const t = []
63
- for (const e of ip_regex_array) {
64
- const n = [],
65
- a = e.exec(d)
66
- if (a) {
67
- for (let d = 0; d < a.length; d++)
68
- (is_ipv4(a[d]) || is_ipv6(a[d])) && n.push(a[d])
69
- t.push(n)
70
- }
71
- }
72
- !(function (d) {
73
- e.includes(d) || e.push(n(d.flat(1 / 0)))
74
- })(t.flat(1 / 0))
75
- })
76
- function n(d) {
77
- return Array.from(new Set(d))
78
- }
79
- return new Promise(function (a, f) {
80
- t.start(),
81
- setTimeout(() => {
82
- e && e !== [] ? a(n(e.flat(1 / 0))) : f('No IP addresses were found.'),
83
- t.stop()
84
- }, d || 500)
85
- })
86
- }
87
- function getIPTypes(d) {
88
- return new Promise(function (e, t) {
89
- const n = []
90
- publicIPs(d)
91
- .then(d => {
92
- d.forEach(d => {
93
- d.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)
94
- ? n.push({ ip: d, type: 'private', IPv4: !0 })
95
- : d.match(
96
- /((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))/
97
- )
98
- ? n.push({ ip: d, type: 'IPv6', IPv4: !1 })
99
- : n.push({ ip: d, type: 'public', IPv4: !0 })
100
- }),
101
- e(n)
102
- })
103
- .catch(t)
104
- })
105
- }
106
- function getIPv4(d) {
107
- return getIPTypes(d).then(d => {
108
- const e = d.filter(d => d.IPv4)
109
- for (let d = 0; d < e.length; d++) e[d] = e[d].ip
110
- return e || ''
111
- })
112
- }
113
- function getIPv6(d) {
114
- return getIPTypes(d).then(d => {
115
- const e = d.filter(d => 'IPv6' === d.type)
116
- for (let d = 0; d < e.length; d++) e[d] = e[d].ip
117
- return e ? e.ip : ''
118
- })
119
- }
120
- export function getIPs(d?: any) {
121
- return Object.assign(publicIPs(d), {
122
- types: getIPTypes,
123
- public: publicIPs,
124
- IPv4: getIPv4,
125
- IPv6: getIPv6
126
- })
127
- }
@@ -1,49 +0,0 @@
1
- import { isWindow } from './is'
2
- import { WebTracing } from '../types'
3
-
4
- /**
5
- * 是否为浏览器环境
6
- */
7
- export const isBrowserEnv = isWindow(typeof window !== 'undefined' ? window : 0)
8
-
9
- /**
10
- * 是否为 electron 环境
11
- */
12
- export const isElectronEnv = !!window?.process?.versions?.electron
13
-
14
- /**
15
- * 是否为测试环境
16
- */
17
- export const isTestEnv =
18
- (typeof navigator !== 'undefined' && navigator.userAgent.includes('jsdom')) ||
19
- // @ts-expect-error: jsdom
20
- (typeof window !== 'undefined' && window.jsdom)
21
-
22
- /**
23
- * 获取全局变量
24
- */
25
- export function getGlobal(): Window {
26
- if (isBrowserEnv || isElectronEnv || isTestEnv) return window
27
- return {} as Window
28
- }
29
-
30
- /**
31
- * 获取全部变量 __webTracing__ 的引用地址
32
- */
33
- export function getGlobalSupport(): WebTracing {
34
- _global.__webTracing__ = _global.__webTracing__ || ({} as WebTracing)
35
- return _global.__webTracing__
36
- }
37
-
38
- /**
39
- * 判断sdk是否初始化
40
- * @returns sdk是否初始化
41
- */
42
- export function isInit(): boolean {
43
- return !!_global.__webTracingInit__
44
- }
45
-
46
- const _global = getGlobal()
47
- const _support = getGlobalSupport()
48
-
49
- export { _global, _support }