w-converhp 2.0.11 → 2.0.12

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * w-converhp-server v2.0.11
2
+ * w-converhp-server v2.0.12
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="tag-source">Source:</dt>
82
82
  <dd class="tag-source"><ul class="dummy"><li>
83
- <a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line167">line 167</a>
83
+ <a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line165">line 165</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -529,7 +529,7 @@
529
529
  <br class="clear">
530
530
 
531
531
  <footer>
532
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 09:12:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
532
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 12:28:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
533
533
  </footer>
534
534
 
535
535
  <script>prettyPrint();</script>
@@ -45,9 +45,7 @@
45
45
 
46
46
  <section>
47
47
  <article>
48
- <pre class="prettyprint source linenums"><code>import path from 'path'
49
- import fs from 'fs'
50
- import axios from 'axios'
48
+ <pre class="prettyprint source linenums"><code>import axios from 'axios'
51
49
  import get from 'lodash-es/get.js'
52
50
  import isWindow from 'wsemi/src/isWindow.mjs'
53
51
  import genPm from 'wsemi/src/genPm.mjs'
@@ -484,7 +482,7 @@ function WConverhpClient(opt) {
484
482
  }
485
483
 
486
484
  //downloadStream
487
- let downloadStream = (res) => {
485
+ let downloadStream = async (res) => {
488
486
  // console.log('res.headers', res.headers)
489
487
 
490
488
  //pm
@@ -518,45 +516,62 @@ function WConverhpClient(opt) {
518
516
  if (env === 'browser') {
519
517
 
520
518
  //通過createObjectURL與a元素下載
521
- let url = URL.createObjectURL(streamRecv)
522
- let a = document.createElement('a')
523
- a.href = url
524
- a.download = filename // 動態設置檔名
525
- document.body.appendChild(a)
526
- a.click()
527
- a.remove()
528
- URL.revokeObjectURL(url)
529
-
530
- pm.resolve(filename)
519
+ try {
520
+ let url = URL.createObjectURL(streamRecv)
521
+ let a = document.createElement('a')
522
+ a.href = url
523
+ a.download = filename // 動態設置檔名
524
+ document.body.appendChild(a)
525
+ a.click()
526
+ a.remove()
527
+ URL.revokeObjectURL(url)
528
+ pm.resolve(filename)
529
+ }
530
+ catch (err) {
531
+ console.log(err)
532
+ pm.reject(err)
533
+ }
534
+
531
535
  }
532
536
  else {
533
537
 
534
- //fdDownload, 只有後端下載才使用fdDownload
535
- let fdDownload = get(opt, 'fdDownload', '')
536
- if (!fsIsFolder(fdDownload)) {
537
- fsCreateFolder(fdDownload)
538
- }
539
- // console.log('fdDownload', fdDownload)
538
+ try {
540
539
 
541
- //fp
542
- let fp = path.resolve(fdDownload, filename)
543
- // console.log('fp', fp)
540
+ //path, fs
541
+ let path = await import('path')
542
+ let fs = await import('fs')
544
543
 
545
- //streamWriter
546
- let streamWriter = fs.createWriteStream(fp)
544
+ //fdDownload, 只有後端下載才使用fdDownload
545
+ let fdDownload = get(opt, 'fdDownload', '')
546
+ if (!fsIsFolder(fdDownload)) {
547
+ fsCreateFolder(fdDownload)
548
+ }
549
+ // console.log('fdDownload', fdDownload)
547
550
 
548
- //pipe
549
- streamRecv.pipe(streamWriter)
551
+ //fp
552
+ let fp = path.resolve(fdDownload, filename)
553
+ // console.log('fp', fp)
550
554
 
551
- //finish
552
- streamWriter.on('finish', () => {
553
- pm.resolve(fp)
554
- })
555
+ //streamWriter
556
+ let streamWriter = fs.createWriteStream(fp)
555
557
 
556
- //error
557
- streamWriter.on('error', (err) => {
558
+ //pipe
559
+ streamRecv.pipe(streamWriter)
560
+
561
+ //finish
562
+ streamWriter.on('finish', () => {
563
+ pm.resolve(fp)
564
+ })
565
+
566
+ //error
567
+ streamWriter.on('error', (err) => {
568
+ pm.reject(err)
569
+ })
570
+
571
+ }
572
+ catch (err) {
558
573
  pm.reject(err)
559
- })
574
+ }
560
575
 
561
576
  }
562
577
 
@@ -925,7 +940,7 @@ export default WConverhpClient
925
940
  <br class="clear">
926
941
 
927
942
  <footer>
928
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 09:12:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
943
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 12:28:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
929
944
  </footer>
930
945
 
931
946
  <script>prettyPrint();</script>
@@ -709,7 +709,7 @@
709
709
  <br class="clear">
710
710
 
711
711
  <footer>
712
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 09:12:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
712
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 12:28:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
713
713
  </footer>
714
714
 
715
715
  <script>prettyPrint();</script>
@@ -1045,7 +1045,7 @@ export default WConverhpServer
1045
1045
  <br class="clear">
1046
1046
 
1047
1047
  <footer>
1048
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 09:12:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1048
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 12:28:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1049
1049
  </footer>
1050
1050
 
1051
1051
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 09:12:35 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 Tue Apr 08 2025 12:28:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-converhp",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "main": "dist/w-converhp-server.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.0",
@@ -1,5 +1,3 @@
1
- import path from 'path'
2
- import fs from 'fs'
3
1
  import axios from 'axios'
4
2
  import get from 'lodash-es/get.js'
5
3
  import isWindow from 'wsemi/src/isWindow.mjs'
@@ -437,7 +435,7 @@ function WConverhpClient(opt) {
437
435
  }
438
436
 
439
437
  //downloadStream
440
- let downloadStream = (res) => {
438
+ let downloadStream = async (res) => {
441
439
  // console.log('res.headers', res.headers)
442
440
 
443
441
  //pm
@@ -471,45 +469,62 @@ function WConverhpClient(opt) {
471
469
  if (env === 'browser') {
472
470
 
473
471
  //通過createObjectURL與a元素下載
474
- let url = URL.createObjectURL(streamRecv)
475
- let a = document.createElement('a')
476
- a.href = url
477
- a.download = filename // 動態設置檔名
478
- document.body.appendChild(a)
479
- a.click()
480
- a.remove()
481
- URL.revokeObjectURL(url)
482
-
483
- pm.resolve(filename)
472
+ try {
473
+ let url = URL.createObjectURL(streamRecv)
474
+ let a = document.createElement('a')
475
+ a.href = url
476
+ a.download = filename // 動態設置檔名
477
+ document.body.appendChild(a)
478
+ a.click()
479
+ a.remove()
480
+ URL.revokeObjectURL(url)
481
+ pm.resolve(filename)
482
+ }
483
+ catch (err) {
484
+ console.log(err)
485
+ pm.reject(err)
486
+ }
487
+
484
488
  }
485
489
  else {
486
490
 
487
- //fdDownload, 只有後端下載才使用fdDownload
488
- let fdDownload = get(opt, 'fdDownload', '')
489
- if (!fsIsFolder(fdDownload)) {
490
- fsCreateFolder(fdDownload)
491
- }
492
- // console.log('fdDownload', fdDownload)
491
+ try {
493
492
 
494
- //fp
495
- let fp = path.resolve(fdDownload, filename)
496
- // console.log('fp', fp)
493
+ //path, fs
494
+ let path = await import('path')
495
+ let fs = await import('fs')
497
496
 
498
- //streamWriter
499
- let streamWriter = fs.createWriteStream(fp)
497
+ //fdDownload, 只有後端下載才使用fdDownload
498
+ let fdDownload = get(opt, 'fdDownload', '')
499
+ if (!fsIsFolder(fdDownload)) {
500
+ fsCreateFolder(fdDownload)
501
+ }
502
+ // console.log('fdDownload', fdDownload)
500
503
 
501
- //pipe
502
- streamRecv.pipe(streamWriter)
504
+ //fp
505
+ let fp = path.resolve(fdDownload, filename)
506
+ // console.log('fp', fp)
503
507
 
504
- //finish
505
- streamWriter.on('finish', () => {
506
- pm.resolve(fp)
507
- })
508
+ //streamWriter
509
+ let streamWriter = fs.createWriteStream(fp)
508
510
 
509
- //error
510
- streamWriter.on('error', (err) => {
511
+ //pipe
512
+ streamRecv.pipe(streamWriter)
513
+
514
+ //finish
515
+ streamWriter.on('finish', () => {
516
+ pm.resolve(fp)
517
+ })
518
+
519
+ //error
520
+ streamWriter.on('error', (err) => {
521
+ pm.reject(err)
522
+ })
523
+
524
+ }
525
+ catch (err) {
511
526
  pm.reject(err)
512
- })
527
+ }
513
528
 
514
529
  }
515
530
 
package/srv.mjs CHANGED
@@ -123,7 +123,7 @@ setTimeout(() => {
123
123
  console.log('ms', ms)
124
124
  // console.log('ms', JSON.stringify(ms))
125
125
  wo.stop()
126
- }, 1003000)
126
+ }, 3000)
127
127
 
128
128
 
129
129
  //node --experimental-modules srv.mjs