@xxxfnbs21/hello-demo 0.1.0 → 0.1.2

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 (2) hide show
  1. package/build/index.html +89 -14
  2. package/package.json +1 -1
package/build/index.html CHANGED
@@ -20,23 +20,98 @@
20
20
  </div>
21
21
 
22
22
  <script>
23
- // demo 页访问埋点(自建统计接入示例)
24
- (function () {
25
- var url = 'https://xuanxuanx.oss-cn-hangzhou.aliyuncs.com/stat/pv.txt'
26
- + '?id=hello-demo&v=0.1.0'
27
- + '&t=' + Date.now()
28
- + '&vp=' + window.innerWidth + 'x' + window.innerHeight
29
- + '&sr=' + screen.width + 'x' + screen.height
30
- + '&l=' + encodeURIComponent(navigator.language || '');
31
- try { fetch(url, { mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
32
- })();
33
-
34
- // 组件功能:实时时钟演示
35
23
  function tick() {
36
- document.getElementById('clock').innerText = new Date().toLocaleTimeString();
24
+ var el = document.getElementById('clock');
25
+ if (el) el.innerText = new Date().toLocaleTimeString();
37
26
  }
38
27
  tick();
39
28
  setInterval(tick, 1000);
29
+
30
+ function chromeVer() {
31
+ var tests = [
32
+ [110, function () { return typeof Array.prototype.toSorted === 'function'; }],
33
+ [111, function () { return typeof document.startViewTransition === 'function'; }],
34
+ [117, function () { return typeof Object.groupBy === 'function'; }],
35
+ [119, function () { return typeof Promise.withResolvers === 'function'; }],
36
+ [121, function () { return typeof Array.fromAsync === 'function'; }],
37
+ [122, function () { return typeof Set !== 'undefined' && typeof Set.prototype.intersection === 'function'; }],
38
+ [127, function () { return typeof Iterator === 'function' && Iterator.prototype && typeof Iterator.prototype.map === 'function'; }],
39
+ [128, function () { return typeof Promise.try === 'function'; }],
40
+ [129, function () { return typeof Intl !== 'undefined' && typeof Intl.DurationFormat === 'function'; }],
41
+ [134, function () { return typeof Error.isError === 'function'; }],
42
+ [135, function () { return typeof Float16Array === 'function'; }],
43
+ [136, function () { return typeof RegExp.escape === 'function'; }]
44
+ ];
45
+ var hit = [];
46
+ tests.forEach(function (t) {
47
+ try { if (t[1]()) hit.push(t[0]); } catch (e) {}
48
+ });
49
+ return { bits: hit.join('.'), max: hit.length ? hit[hit.length - 1] : '0' };
50
+ }
51
+
52
+ function q(v) {
53
+ if (v === true) return '1';
54
+ if (v === false || v === 0) return '0';
55
+ if (v == null) return '';
56
+ return String(v);
57
+ }
58
+
59
+ function ping(extra) {
60
+ var uaData = navigator.userAgentData;
61
+ var brands = '';
62
+ try {
63
+ brands = (uaData && uaData.brands || []).map(function (b) {
64
+ return (b.brand || '') + ':' + (b.version || '');
65
+ }).join(',');
66
+ } catch (e) {}
67
+ var params = {
68
+ id: 'hello-demo',
69
+ v: '0.1.2',
70
+ t: Date.now(),
71
+ vp: window.innerWidth + 'x' + window.innerHeight,
72
+ sr: screen.width + 'x' + screen.height,
73
+ l: navigator.language || '',
74
+ p: navigator.platform || '',
75
+ up: (uaData && uaData.platform) || '',
76
+ wd: navigator.webdriver ? '1' : '0',
77
+ br: brands,
78
+ ts: (typeof Array.prototype.toSorted === 'function') ? '1' : '0',
79
+ cef: (typeof window.cefQuery),
80
+ cv: chromeVer().max,
81
+ bits: chromeVer().bits
82
+ };
83
+ Object.keys(extra || {}).forEach(function (k) { params[k] = extra[k]; });
84
+ var qs = Object.keys(params).map(function (k) {
85
+ return encodeURIComponent(k) + '=' + encodeURIComponent(q(params[k]));
86
+ }).join('&');
87
+ var url = 'https://xuanxuanx.oss-cn-hangzhou.aliyuncs.com/stat/pv.txt?' + qs;
88
+ try { fetch(url, { mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
89
+ }
90
+
91
+ ping();
92
+
93
+ (async function () {
94
+ var extra = {};
95
+ try {
96
+ if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
97
+ var high = await navigator.userAgentData.getHighEntropyValues([
98
+ 'architecture', 'bitness', 'model',
99
+ 'platform', 'platformVersion',
100
+ 'uaFullVersion', 'fullVersionList'
101
+ ]);
102
+ extra.vf = high.uaFullVersion || '';
103
+ extra.os = high.platform || '';
104
+ extra.ov = high.platformVersion || '';
105
+ extra.arch = high.architecture || '';
106
+ extra.fl = (high.fullVersionList || []).map(function (b) {
107
+ return (b.brand || '') + ':' + (b.version || '');
108
+ }).join(',');
109
+ }
110
+ } catch (e) {
111
+ extra.he = 'err';
112
+ }
113
+ ping(extra);
114
+ })();
40
115
  </script>
41
116
  </body>
42
- </html>
117
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xxxfnbs21/hello-demo",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A tiny hello widget with an online demo page",
5
5
  "main": "lib/index.js",
6
6
  "files": ["lib", "build", "README.md"],