w-comor-hapi 1.0.32 → 1.0.33

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/docs/global.html CHANGED
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
31
+
30
32
  <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WComorHapiClient">WComorHapiClient</a></li><li><a href="global.html#WComorHapiServer">WComorHapiServer</a></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -46,6 +49,8 @@
46
49
 
47
50
  <h2>
48
51
 
52
+
53
+
49
54
  </h2>
50
55
 
51
56
 
@@ -58,6 +63,7 @@
58
63
 
59
64
 
60
65
  <dl class="details">
66
+
61
67
 
62
68
 
63
69
 
@@ -132,6 +138,10 @@
132
138
 
133
139
 
134
140
  <dl class="details">
141
+
142
+ <dt class="tag-description">Description:</dt>
143
+ <dd class="tag-description"><ul class="dummy"><li><p>建立http API使用者(Node.js與Browser)端物件</p></li></ul></dd>
144
+
135
145
 
136
146
 
137
147
  <dt class="tag-source">Source:</dt>
@@ -175,26 +185,20 @@
175
185
 
176
186
 
177
187
 
178
- <div class="description usertext">
179
- <p>建立http API使用者(Node.js與Browser)端物件</p>
180
- </div>
181
-
182
-
183
-
184
188
 
185
189
 
186
190
 
187
191
 
188
192
 
189
193
 
190
- <h5>Example</h5>
194
+ <h5 class="h5-examples">Example</h5>
191
195
 
192
196
  <pre class="prettyprint"><code>import WComorHapiClient from 'w-comor-hapi/dist/ws-client-node.umd.js'
193
197
  url: 'http://localhost:8080/api',
194
198
  token: '*',
195
199
  error: function(err) {
196
200
  console.log('client: error:', err)
197
201
  },
198
202
  reconn: function() {
199
203
  console.log('client: reconn')
200
204
  },
201
205
  .then(function(wo) {
202
206
  console.log('client: funcs: ', wo)
203
207
  function core(ps) {
204
208
  wo.group.plus(ps)
205
209
  .then(function(r) {
206
210
  console.log('client: plus(' + JSON.stringify(ps) + ')=' + r)
207
211
  })
208
212
  .catch(function(err) {
209
213
  console.log('client: plus: catch: ', err)
210
214
  })
211
215
  wo.group.div(ps)
212
216
  .then(function(r) {
213
217
  console.log('client: div(' + JSON.stringify(ps) + ')=' + r)
214
218
  })
215
219
  .catch(function(err) {
216
220
  console.log('client: div: catch: ', err)
217
221
  })
218
222
  wo.add(ps)
219
223
  .then(function(r) {
220
224
  console.log(`client: add(${JSON.stringify(ps)})=${r}`)
221
225
  })
222
226
  .catch(function(err) {
223
227
  console.log('client: add: catch: ', err)
224
228
  })
225
229
  wo.minu(ps)
226
230
  .then(function(r) {
227
231
  console.log(`client: minu(${JSON.stringify(ps)})=${r}`)
228
232
  })
229
233
  .catch(function(err) {
230
234
  console.log('client: minu: catch: ', err)
231
235
  })
232
236
  }
233
237
  let i = 100
234
238
  setInterval(function() {
235
239
  i += 1
236
240
  core({
237
241
  p1: i,
238
242
  p2: 10,
239
243
  })
240
244
  }, 1000)
241
245
  })
242
246
  .catch(function(err) {
243
247
  console.log('client: catch', err)
244
248
  })</code></pre>
245
249
 
246
250
 
247
251
 
248
252
 
249
- <h5>Parameters:</h5>
253
+ <h5 class="h5-parameters">Parameters:</h5>
250
254
 
251
255
 
252
256
  <table class="params">
@@ -228,6 +232,7 @@
228
232
  <span class="param-type">Object</span>
229
233
 
230
234
 
235
+
231
236
 
232
237
  </td>
233
238
 
@@ -274,6 +279,7 @@
274
279
  <span class="param-type">String</span>
275
280
 
276
281
 
282
+
277
283
 
278
284
  </td>
279
285
 
@@ -313,6 +319,7 @@
313
319
  <span class="param-type">String</span>
314
320
 
315
321
 
322
+
316
323
 
317
324
  </td>
318
325
 
@@ -352,6 +359,7 @@
352
359
  <span class="param-type">function</span>
353
360
 
354
361
 
362
+
355
363
 
356
364
  </td>
357
365
 
@@ -387,6 +395,7 @@
387
395
  <span class="param-type">function</span>
388
396
 
389
397
 
398
+
390
399
 
391
400
  </td>
392
401
 
@@ -435,7 +444,7 @@
435
444
 
436
445
 
437
446
 
438
- <h5>Returns:</h5>
447
+ <h5 class="h5-returns">Returns:</h5>
439
448
 
440
449
 
441
450
  <div class="param-desc">
@@ -453,6 +462,7 @@
453
462
  <span class="param-type">Promise</span>
454
463
 
455
464
 
465
+
456
466
  </dd>
457
467
  </dl>
458
468
 
@@ -473,6 +483,10 @@
473
483
 
474
484
 
475
485
  <dl class="details">
486
+
487
+ <dt class="tag-description">Description:</dt>
488
+ <dd class="tag-description"><ul class="dummy"><li><p>建立http API伺服器</p></li></ul></dd>
489
+
476
490
 
477
491
 
478
492
  <dt class="tag-source">Source:</dt>
@@ -516,26 +530,20 @@
516
530
 
517
531
 
518
532
 
519
- <div class="description usertext">
520
- <p>建立http API伺服器</p>
521
- </div>
522
-
523
-
524
-
525
533
 
526
534
 
527
535
 
528
536
 
529
537
 
530
538
 
531
- <h5>Example</h5>
539
+ <h5 class="h5-examples">Example</h5>
532
540
 
533
541
  <pre class="prettyprint"><code>import WComorHapiServer from 'w-comor-hapi/dist/w-comor-hapi-server.umd.js'
534
542
  return Math.floor(Math.random() * max) + min
535
543
  port: 8080,
536
544
  apiName: 'api',
537
545
  authenticate: function(token) {
538
546
  //使用token驗證使用者身份
539
547
  return new Promise(function(resolve, reject) {
540
548
  setTimeout(function() {
541
549
  resolve(true)
542
550
  }, 1000)
543
551
  })
544
552
  },
545
553
  filterFuncs: function(token, funcs) {
546
554
  //使用token驗證使用者身份與過濾可用funcs
547
555
  return new Promise(function(resolve, reject) {
548
556
  funcs = funcs.filter(function(v) {
549
557
  return v.indexOf('Hide') &lt; 0
550
558
  })
551
559
  resolve(funcs)
552
560
  })
553
561
  },
554
562
  onClientChange: function(conns, opt) {
555
563
  console.log(`Server[port:${opt.port}] now conns: ${conns.length}`)
556
564
  },
557
565
  funcs: {
558
566
  'group.plus': function({ p1, p2 }) {
559
567
  return new Promise(function(resolve, reject) {
560
568
  setTimeout(function() {
561
569
  resolve(p1 * p2)
562
570
  }, random(100, 3000))
563
571
  })
564
572
  },
565
573
  'group.div': function({ p1, p2 }) {
566
574
  return new Promise(function(resolve, reject) {
567
575
  setTimeout(function() {
568
576
  resolve(p1 / p2)
569
577
  }, random(100, 3000))
570
578
  })
571
579
  },
572
580
  'add': function({ p1, p2 }) {
573
581
  return new Promise(function(resolve, reject) {
574
582
  setTimeout(function() {
575
583
  resolve(p1 + p2)
576
584
  }, random(100, 3000))
577
585
  })
578
586
  },
579
587
  'addHide': function({ p1, p2 }) {
580
588
  return new Promise(function(resolve, reject) {
581
589
  setTimeout(function() {
582
590
  resolve(p1 + p2)
583
591
  }, random(100, 3000))
584
592
  })
585
593
  },
586
594
  'minu': function({ p1, p2 }) {
587
595
  return new Promise(function(resolve, reject) {
588
596
  setTimeout(function() {
589
597
  resolve(p1 - p2)
590
598
  }, random(100, 3000))
591
599
  })
592
600
  },
593
601
  },
594
602
  routes: [
595
603
  {
596
604
  method: 'GET',
597
605
  path: '/code',
598
606
  handler: function (req, res) {
599
607
  //console.log(req)
600
608
  return 'get code query: ' + JSON.stringify(req.query)
601
609
  //http://localhost:8080/code?a=1&amp;bb=23.45
602
610
  // => get code query: {"a":"1","bb":"23.45"}
603
611
  }
604
612
  },
605
613
  ],
606
614
 
607
615
 
608
616
 
609
617
 
610
- <h5>Parameters:</h5>
618
+ <h5 class="h5-parameters">Parameters:</h5>
611
619
 
612
620
 
613
621
  <table class="params">
@@ -569,6 +577,7 @@
569
577
  <span class="param-type">Object</span>
570
578
 
571
579
 
580
+
572
581
 
573
582
  </td>
574
583
 
@@ -615,6 +624,7 @@
615
624
  <span class="param-type">Object</span>
616
625
 
617
626
 
627
+
618
628
 
619
629
  </td>
620
630
 
@@ -654,6 +664,7 @@
654
664
  <span class="param-type">Integer</span>
655
665
 
656
666
 
667
+
657
668
 
658
669
  </td>
659
670
 
@@ -693,6 +704,7 @@
693
704
  <span class="param-type">String</span>
694
705
 
695
706
 
707
+
696
708
 
697
709
  </td>
698
710
 
@@ -732,6 +744,7 @@
732
744
  <span class="param-type">function</span>
733
745
 
734
746
 
747
+
735
748
 
736
749
  </td>
737
750
 
@@ -767,6 +780,7 @@
767
780
  <span class="param-type">Object</span>
768
781
 
769
782
 
783
+
770
784
 
771
785
  </td>
772
786
 
@@ -806,6 +820,7 @@
806
820
  <span class="param-type">Array</span>
807
821
 
808
822
 
823
+
809
824
 
810
825
  </td>
811
826
 
@@ -881,7 +896,7 @@
881
896
  <br class="clear">
882
897
 
883
898
  <footer>
884
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Jan 19 2023 15:14:09 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
899
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Mar 31 2023 14:29:53 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
885
900
  </footer>
886
901
 
887
902
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
31
+
30
32
  <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WComorHapiClient">WComorHapiClient</a></li><li><a href="global.html#WComorHapiServer">WComorHapiServer</a></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -68,7 +71,7 @@
68
71
  <br class="clear">
69
72
 
70
73
  <footer>
71
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Jan 19 2023 15:14:09 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Mar 31 2023 14:29:53 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
72
75
  </footer>
73
76
 
74
77
  <script>prettyPrint();</script>
@@ -1,15 +1,34 @@
1
1
  function hideAllButCurrent(){
2
2
  //by default all submenut items are hidden
3
3
  //but we need to rehide them for search
4
+ document.querySelectorAll("nav > ul").forEach(function(parent) {
5
+ if (parent.className.indexOf("collapse_top") !== -1) {
6
+ parent.style.display = "none";
7
+ }
8
+ });
4
9
  document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
5
10
  parent.style.display = "none";
6
11
  });
12
+ document.querySelectorAll("nav > h3").forEach(function(section) {
13
+ if (section.className.indexOf("collapsed_header") !== -1) {
14
+ section.addEventListener("click", function(){
15
+ if (section.nextSibling.style.display === "none") {
16
+ section.nextSibling.style.display = "block";
17
+ } else {
18
+ section.nextSibling.style.display = "none";
19
+ }
20
+ });
21
+ }
22
+ });
7
23
 
8
24
  //only current page (if it exists) should be opened
9
25
  var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
10
26
  document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
11
27
  var href = parent.attributes.href.value.replace(/\.html/, '');
12
28
  if (file === href) {
29
+ if (parent.parentNode.parentNode.className.indexOf("collapse_top") !== -1) {
30
+ parent.parentNode.parentNode.style.display = "block";
31
+ }
13
32
  parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
14
33
  elem.style.display = "block";
15
34
  });
@@ -0,0 +1,28 @@
1
+ if (typeof fetch === 'function') {
2
+ const init = () => {
3
+ if (typeof scrollToNavItem !== 'function') return false
4
+ scrollToNavItem()
5
+ // hideAllButCurrent not always loaded
6
+ if (typeof hideAllButCurrent === 'function') hideAllButCurrent()
7
+ return true
8
+ }
9
+ fetch('./nav.inc.html')
10
+ .then(response => response.ok ? response.text() : `${response.url} => ${response.status} ${response.statusText}`)
11
+ .then(body => {
12
+ document.querySelector('nav').innerHTML += body
13
+ // nav.js should be quicker to load than nav.inc.html, a fallback just in case
14
+ return init()
15
+ })
16
+ .then(done => {
17
+ if (done) return
18
+ let i = 0
19
+ ;(function waitUntilNavJs () {
20
+ if (init()) return
21
+ if (i++ < 100) return setTimeout(waitUntilNavJs, 300)
22
+ console.error(Error('nav.js not loaded after 30s waiting for it'))
23
+ })()
24
+ })
25
+ .catch(error => console.error(error))
26
+ } else {
27
+ console.error(Error('Browser too old to display commonNav (remove commonNav docdash option)'))
28
+ }
@@ -33,6 +33,9 @@ document.getElementById("nav-search").addEventListener("keyup", function(event)
33
33
  document.querySelectorAll("nav > ul > li").forEach(function(elem) {
34
34
  elem.style.display = "block";
35
35
  });
36
+ document.querySelectorAll("nav > ul").forEach(function(elem) {
37
+ elem.style.display = "block";
38
+ });
36
39
  //hide all results
37
40
  document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
38
41
  elem.style.display = "none";
@@ -79,5 +82,18 @@ document.getElementById("nav-search").addEventListener("keyup", function(event)
79
82
  parent.style.display = "none";
80
83
  }
81
84
  });
85
+ document.querySelectorAll("nav > ul.collapse_top").forEach(function(parent) {
86
+ var countVisible = 0;
87
+ parent.querySelectorAll("li").forEach(function(elem) {
88
+ if (elem.style.display !== "none") {
89
+ countVisible++;
90
+ }
91
+ });
92
+
93
+ if (countVisible == 0) {
94
+ //has no child at all and does not contain text
95
+ parent.style.display = "none";
96
+ }
97
+ });
82
98
  }
83
99
  });
@@ -162,12 +162,19 @@ h6 {
162
162
  }
163
163
 
164
164
 
165
- tt, code, kbd, samp {
165
+ tt, code, kbd, samp, pre {
166
166
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
167
167
  background: #f4f4f4;
168
+ }
169
+
170
+ tt, code, kbd, samp{
168
171
  padding: 1px 5px;
169
172
  }
170
173
 
174
+ pre {
175
+ padding-bottom: 1em;
176
+ }
177
+
171
178
  .class-description {
172
179
  font-size: 130%;
173
180
  line-height: 140%;
@@ -242,6 +249,10 @@ nav h3 {
242
249
  color: #000;
243
250
  }
244
251
 
252
+ nav h3.collapsed_header {
253
+ cursor: pointer;
254
+ }
255
+
245
256
  nav ul {
246
257
  font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
247
258
  font-size: 100%;
@@ -762,4 +773,4 @@ html[data-search-mode] .level-hide {
762
773
  font-weight: 300;
763
774
  font-style: normal;
764
775
 
765
- }
776
+ }
@@ -76,4 +76,5 @@
76
76
  ol.linenums {
77
77
  margin-top: 0;
78
78
  margin-bottom: 0;
79
+ padding-bottom: 2px;
79
80
  }
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "w-comor-hapi",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "main": "dist/w-comor-hapi-server.umd.js",
5
5
  "dependencies": {
6
- "@hapi/hapi": "^21.2.0",
7
- "@hapi/inert": "^7.0.0",
8
- "axios": "^1.2.3",
6
+ "@hapi/hapi": "^21.3.1",
7
+ "@hapi/inert": "^7.1.0",
8
+ "axios": "^1.3.4",
9
9
  "lodash": "^4.17.21",
10
- "wsemi": "^1.6.87",
10
+ "wsemi": "^1.7.2",
11
11
  "xss": "^1.0.14"
12
12
  },
13
13
  "devDependencies": {
14
- "w-package-tools": "^1.0.66"
14
+ "w-package-tools": "^1.0.69"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",