w-converhp 2.0.11 → 2.0.13
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 +48 -37
- 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/scla.mjs +2 -0
- package/sclb.mjs +2 -0
- package/sclc.mjs +2 -0
- package/scld.mjs +3 -0
- package/src/WConverhpClient.mjs +46 -35
- 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#line163">line 163</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 13:20:50 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'
|
|
@@ -68,8 +66,6 @@ import obj2u8arr from 'wsemi/src/obj2u8arr.mjs'
|
|
|
68
66
|
import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
69
67
|
import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
70
68
|
import now2strp from 'wsemi/src/now2strp.mjs'
|
|
71
|
-
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
72
|
-
import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
|
|
73
69
|
|
|
74
70
|
|
|
75
71
|
/**
|
|
@@ -484,7 +480,7 @@ function WConverhpClient(opt) {
|
|
|
484
480
|
}
|
|
485
481
|
|
|
486
482
|
//downloadStream
|
|
487
|
-
let downloadStream = (res) => {
|
|
483
|
+
let downloadStream = async (res) => {
|
|
488
484
|
// console.log('res.headers', res.headers)
|
|
489
485
|
|
|
490
486
|
//pm
|
|
@@ -518,45 +514,60 @@ function WConverhpClient(opt) {
|
|
|
518
514
|
if (env === 'browser') {
|
|
519
515
|
|
|
520
516
|
//通過createObjectURL與a元素下載
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
517
|
+
try {
|
|
518
|
+
let url = URL.createObjectURL(streamRecv)
|
|
519
|
+
let a = document.createElement('a')
|
|
520
|
+
a.href = url
|
|
521
|
+
a.download = filename // 動態設置檔名
|
|
522
|
+
document.body.appendChild(a)
|
|
523
|
+
a.click()
|
|
524
|
+
a.remove()
|
|
525
|
+
URL.revokeObjectURL(url)
|
|
526
|
+
pm.resolve(filename)
|
|
527
|
+
}
|
|
528
|
+
catch (err) {
|
|
529
|
+
console.log(err)
|
|
530
|
+
pm.reject(err)
|
|
531
|
+
}
|
|
532
|
+
|
|
531
533
|
}
|
|
532
534
|
else {
|
|
533
535
|
|
|
534
|
-
|
|
535
|
-
let fdDownload = get(opt, 'fdDownload', '')
|
|
536
|
-
if (!fsIsFolder(fdDownload)) {
|
|
537
|
-
fsCreateFolder(fdDownload)
|
|
538
|
-
}
|
|
539
|
-
// console.log('fdDownload', fdDownload)
|
|
536
|
+
try {
|
|
540
537
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
538
|
+
//path, fs
|
|
539
|
+
let path = await import('path')
|
|
540
|
+
let fs = await import('fs')
|
|
544
541
|
|
|
545
|
-
|
|
546
|
-
|
|
542
|
+
//fdDownload, 只有後端下載才使用fdDownload
|
|
543
|
+
let fdDownload = get(opt, 'fdDownload', '')
|
|
544
|
+
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
545
|
+
// console.log('fdDownload', fdDownload)
|
|
547
546
|
|
|
548
|
-
|
|
549
|
-
|
|
547
|
+
//fp
|
|
548
|
+
let fp = path.resolve(fdDownload, filename)
|
|
549
|
+
// console.log('fp', fp)
|
|
550
550
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
pm.resolve(fp)
|
|
554
|
-
})
|
|
551
|
+
//streamWriter
|
|
552
|
+
let streamWriter = fs.createWriteStream(fp)
|
|
555
553
|
|
|
556
|
-
|
|
557
|
-
|
|
554
|
+
//pipe
|
|
555
|
+
streamRecv.pipe(streamWriter)
|
|
556
|
+
|
|
557
|
+
//finish
|
|
558
|
+
streamWriter.on('finish', () => {
|
|
559
|
+
pm.resolve(fp)
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
//error
|
|
563
|
+
streamWriter.on('error', (err) => {
|
|
564
|
+
pm.reject(err)
|
|
565
|
+
})
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
catch (err) {
|
|
558
569
|
pm.reject(err)
|
|
559
|
-
}
|
|
570
|
+
}
|
|
560
571
|
|
|
561
572
|
}
|
|
562
573
|
|
|
@@ -925,7 +936,7 @@ export default WConverhpClient
|
|
|
925
936
|
<br class="clear">
|
|
926
937
|
|
|
927
938
|
<footer>
|
|
928
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025
|
|
939
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 08 2025 13:20:50 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
929
940
|
</footer>
|
|
930
941
|
|
|
931
942
|
<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 13:20:50 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 13:20:50 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 13:20:50 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/scla.mjs
CHANGED
package/sclb.mjs
CHANGED
package/sclc.mjs
CHANGED
package/scld.mjs
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'
|
|
@@ -21,8 +19,6 @@ import obj2u8arr from 'wsemi/src/obj2u8arr.mjs'
|
|
|
21
19
|
import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
22
20
|
import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
23
21
|
import now2strp from 'wsemi/src/now2strp.mjs'
|
|
24
|
-
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
25
|
-
import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
|
|
26
22
|
|
|
27
23
|
|
|
28
24
|
/**
|
|
@@ -437,7 +433,7 @@ function WConverhpClient(opt) {
|
|
|
437
433
|
}
|
|
438
434
|
|
|
439
435
|
//downloadStream
|
|
440
|
-
let downloadStream = (res) => {
|
|
436
|
+
let downloadStream = async (res) => {
|
|
441
437
|
// console.log('res.headers', res.headers)
|
|
442
438
|
|
|
443
439
|
//pm
|
|
@@ -471,45 +467,60 @@ function WConverhpClient(opt) {
|
|
|
471
467
|
if (env === 'browser') {
|
|
472
468
|
|
|
473
469
|
//通過createObjectURL與a元素下載
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
470
|
+
try {
|
|
471
|
+
let url = URL.createObjectURL(streamRecv)
|
|
472
|
+
let a = document.createElement('a')
|
|
473
|
+
a.href = url
|
|
474
|
+
a.download = filename // 動態設置檔名
|
|
475
|
+
document.body.appendChild(a)
|
|
476
|
+
a.click()
|
|
477
|
+
a.remove()
|
|
478
|
+
URL.revokeObjectURL(url)
|
|
479
|
+
pm.resolve(filename)
|
|
480
|
+
}
|
|
481
|
+
catch (err) {
|
|
482
|
+
console.log(err)
|
|
483
|
+
pm.reject(err)
|
|
484
|
+
}
|
|
485
|
+
|
|
484
486
|
}
|
|
485
487
|
else {
|
|
486
488
|
|
|
487
|
-
|
|
488
|
-
let fdDownload = get(opt, 'fdDownload', '')
|
|
489
|
-
if (!fsIsFolder(fdDownload)) {
|
|
490
|
-
fsCreateFolder(fdDownload)
|
|
491
|
-
}
|
|
492
|
-
// console.log('fdDownload', fdDownload)
|
|
489
|
+
try {
|
|
493
490
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
491
|
+
//path, fs
|
|
492
|
+
let path = await import('path')
|
|
493
|
+
let fs = await import('fs')
|
|
497
494
|
|
|
498
|
-
|
|
499
|
-
|
|
495
|
+
//fdDownload, 只有後端下載才使用fdDownload
|
|
496
|
+
let fdDownload = get(opt, 'fdDownload', '')
|
|
497
|
+
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
498
|
+
// console.log('fdDownload', fdDownload)
|
|
500
499
|
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
//fp
|
|
501
|
+
let fp = path.resolve(fdDownload, filename)
|
|
502
|
+
// console.log('fp', fp)
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
pm.resolve(fp)
|
|
507
|
-
})
|
|
504
|
+
//streamWriter
|
|
505
|
+
let streamWriter = fs.createWriteStream(fp)
|
|
508
506
|
|
|
509
|
-
|
|
510
|
-
|
|
507
|
+
//pipe
|
|
508
|
+
streamRecv.pipe(streamWriter)
|
|
509
|
+
|
|
510
|
+
//finish
|
|
511
|
+
streamWriter.on('finish', () => {
|
|
512
|
+
pm.resolve(fp)
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
//error
|
|
516
|
+
streamWriter.on('error', (err) => {
|
|
517
|
+
pm.reject(err)
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
catch (err) {
|
|
511
522
|
pm.reject(err)
|
|
512
|
-
}
|
|
523
|
+
}
|
|
513
524
|
|
|
514
525
|
}
|
|
515
526
|
|