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.
- package/README.md +1 -1
- package/dist/w-converhp-client.umd.js +2 -2
- package/dist/w-converhp-client.umd.js.map +1 -1
- package/dist/w-converhp-server.umd.js +1 -1
- package/docs/WConverhpClient.html +2 -2
- package/docs/WConverhpClient.mjs.html +50 -35
- package/docs/WConverhpServer.html +1 -1
- package/docs/WConverhpServer.mjs.html +1 -1
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/WConverhpClient.mjs +48 -33
- package/srv.mjs +1 -1
|
@@ -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#
|
|
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
|
|
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
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
-
|
|
535
|
-
let fdDownload = get(opt, 'fdDownload', '')
|
|
536
|
-
if (!fsIsFolder(fdDownload)) {
|
|
537
|
-
fsCreateFolder(fdDownload)
|
|
538
|
-
}
|
|
539
|
-
// console.log('fdDownload', fdDownload)
|
|
538
|
+
try {
|
|
540
539
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
540
|
+
//path, fs
|
|
541
|
+
let path = await import('path')
|
|
542
|
+
let fs = await import('fs')
|
|
544
543
|
|
|
545
|
-
|
|
546
|
-
|
|
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
|
-
|
|
549
|
-
|
|
551
|
+
//fp
|
|
552
|
+
let fp = path.resolve(fdDownload, filename)
|
|
553
|
+
// console.log('fp', fp)
|
|
550
554
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
pm.resolve(fp)
|
|
554
|
-
})
|
|
555
|
+
//streamWriter
|
|
556
|
+
let streamWriter = fs.createWriteStream(fp)
|
|
555
557
|
|
|
556
|
-
|
|
557
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
package/src/WConverhpClient.mjs
CHANGED
|
@@ -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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
488
|
-
let fdDownload = get(opt, 'fdDownload', '')
|
|
489
|
-
if (!fsIsFolder(fdDownload)) {
|
|
490
|
-
fsCreateFolder(fdDownload)
|
|
491
|
-
}
|
|
492
|
-
// console.log('fdDownload', fdDownload)
|
|
491
|
+
try {
|
|
493
492
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
//path, fs
|
|
494
|
+
let path = await import('path')
|
|
495
|
+
let fs = await import('fs')
|
|
497
496
|
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
502
|
-
|
|
504
|
+
//fp
|
|
505
|
+
let fp = path.resolve(fdDownload, filename)
|
|
506
|
+
// console.log('fp', fp)
|
|
503
507
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
pm.resolve(fp)
|
|
507
|
-
})
|
|
508
|
+
//streamWriter
|
|
509
|
+
let streamWriter = fs.createWriteStream(fp)
|
|
508
510
|
|
|
509
|
-
|
|
510
|
-
|
|
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
|
|