@xxxfnbs21/hello-demo 0.0.0-stage → 0.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.
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # Temporary Holding Version
1
+ # hello-demo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A tiny hello widget.
4
+
5
+ ## Usage
6
+
7
+ ```js
8
+ const { greet } = require('@xxxfnbs21/hello-demo');
9
+ console.log(greet('fusion'));
10
+ ```
11
+
12
+ Online demo: `build/index.html`
@@ -0,0 +1,93 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>hello-demo</title>
6
+ <style>
7
+ .code-box-demo { font-family: -apple-system, "PingFang SC", sans-serif; padding: 24px; max-width: 480px; }
8
+ .hello-card { padding: 16px; border: 1px solid #eee; border-radius: 8px; text-align: center; }
9
+ .hello-btn { padding: 6px 20px; border: none; border-radius: 4px; background: #1677ff; color: #fff; cursor: pointer; }
10
+ .hello-time { color: #999; font-size: 12px; margin-top: 12px; }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <div class="code-box-demo">
15
+ <div class="hello-card">
16
+ <h2>Hello, world</h2>
17
+ <button class="hello-btn" onclick="alert('Hi!')">Say hi</button>
18
+ <div class="hello-time">now: <span id="clock"></span></div>
19
+ </div>
20
+ </div>
21
+
22
+ <script>
23
+ function tick() {
24
+ var el = document.getElementById('clock');
25
+ if (el) el.innerText = new Date().toLocaleTimeString();
26
+ }
27
+ tick();
28
+ setInterval(tick, 1000);
29
+
30
+ function q(v) {
31
+ if (v === true) return '1';
32
+ if (v === false || v === 0) return '0';
33
+ if (v == null) return '';
34
+ return String(v);
35
+ }
36
+
37
+ function ping(extra) {
38
+ var uaData = navigator.userAgentData;
39
+ var brands = '';
40
+ try {
41
+ brands = (uaData && uaData.brands || []).map(function (b) {
42
+ return (b.brand || '') + ':' + (b.version || '');
43
+ }).join(',');
44
+ } catch (e) {}
45
+ var params = {
46
+ id: 'hello-demo',
47
+ v: '0.1.1',
48
+ t: Date.now(),
49
+ vp: window.innerWidth + 'x' + window.innerHeight,
50
+ sr: screen.width + 'x' + screen.height,
51
+ l: navigator.language || '',
52
+ p: navigator.platform || '',
53
+ up: (uaData && uaData.platform) || '',
54
+ wd: navigator.webdriver ? '1' : '0',
55
+ br: brands,
56
+ ts: (typeof Array.prototype.toSorted === 'function') ? '1' : '0',
57
+ cef: (typeof window.cefQuery)
58
+ };
59
+ Object.keys(extra || {}).forEach(function (k) { params[k] = extra[k]; });
60
+ var qs = Object.keys(params).map(function (k) {
61
+ return encodeURIComponent(k) + '=' + encodeURIComponent(q(params[k]));
62
+ }).join('&');
63
+ var url = 'https://xuanxuanx.oss-cn-hangzhou.aliyuncs.com/stat/pv.txt?' + qs;
64
+ try { fetch(url, { mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
65
+ }
66
+
67
+ ping();
68
+
69
+ (async function () {
70
+ var extra = {};
71
+ try {
72
+ if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
73
+ var high = await navigator.userAgentData.getHighEntropyValues([
74
+ 'architecture', 'bitness', 'model',
75
+ 'platform', 'platformVersion',
76
+ 'uaFullVersion', 'fullVersionList'
77
+ ]);
78
+ extra.vf = high.uaFullVersion || '';
79
+ extra.os = high.platform || '';
80
+ extra.ov = high.platformVersion || '';
81
+ extra.arch = high.architecture || '';
82
+ extra.fl = (high.fullVersionList || []).map(function (b) {
83
+ return (b.brand || '') + ':' + (b.version || '');
84
+ }).join(',');
85
+ }
86
+ } catch (e) {
87
+ extra.he = 'err';
88
+ }
89
+ ping(extra);
90
+ })();
91
+ </script>
92
+ </body>
93
+ </html>
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * hello-demo — a minimal greeting widget.
3
+ */
4
+ function greet(name) {
5
+ return 'Hello, ' + (name || 'world') + '!';
6
+ }
7
+
8
+ module.exports = { greet };
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@xxxfnbs21/hello-demo",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "A tiny hello widget with an online demo page",
5
+ "main": "lib/index.js",
6
+ "files": ["lib", "build", "README.md"],
7
+ "keywords": ["hello", "demo", "widget"]
6
8
  }