w-converhp 2.0.27 → 2.0.29
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 +3 -3
- package/docs/WConverhpClient.mjs.html +23 -11
- 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 +21 -9
- 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#line94">line 94</a>
|
|
84
84
|
</li></ul></dd>
|
|
85
85
|
|
|
86
86
|
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
<h5 class="h5-examples">Example</h5>
|
|
129
129
|
|
|
130
|
-
<pre class="prettyprint"><code>import path from 'path'
|
|
131
130
|
FormData,
|
|
132
131
|
url: 'http://localhost:8080',
|
|
133
132
|
apiName: 'api',
|
|
134
133
|
getToken: () => {
|
|
135
134
|
return 'token-for-test'
|
|
136
135
|
},
|
|
137
136
|
console.log(`error`, err)
|
|
138
137
|
let core = async() => {
|
|
139
138
|
await wo.download('id-for-file',
|
|
140
139
|
function ({ prog, p, m }) {
|
|
141
140
|
// console.log('client web: download: prog', prog, p, m)
|
|
142
141
|
if (m === 'download') {
|
|
143
142
|
console.log('client web: download: prog', prog)
|
|
144
143
|
}
|
|
145
144
|
},
|
|
146
145
|
{
|
|
147
146
|
fdDownload: './', //於後端nodejs環境才能提供
|
|
148
147
|
})
|
|
149
148
|
.then(function(res) {
|
|
150
149
|
console.log('client web: download: then', res)
|
|
151
150
|
ms.push({ 'download output': res })
|
|
152
151
|
})
|
|
153
152
|
.catch(function (err) {
|
|
154
153
|
console.log('client web: download: catch', err)
|
|
155
154
|
})
|
|
156
155
|
console.log('ms', ms)
|
|
157
156
|
}
|
|
158
157
|
core()
|
|
158
|
+
<pre class="prettyprint"><code>import path from 'path'
|
|
159
159
|
FormData,
|
|
160
160
|
url: 'http://localhost:8080',
|
|
161
161
|
apiName: 'api',
|
|
162
162
|
getToken: () => {
|
|
163
163
|
return 'token-for-test'
|
|
164
164
|
},
|
|
165
165
|
console.log(`error`, err)
|
|
166
166
|
let core = async() => {
|
|
167
167
|
await wo.download('id-for-file',
|
|
168
168
|
function ({ prog, p, m }) {
|
|
169
169
|
// console.log('client web: download: prog', prog, p, m)
|
|
170
170
|
if (m === 'download') {
|
|
171
171
|
console.log('client web: download: prog', prog)
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
fdDownload: './', //於nodejs環境才能提供
|
|
176
176
|
})
|
|
177
177
|
.then(function(res) {
|
|
178
178
|
console.log('client web: download: then', res)
|
|
179
179
|
ms.push({ 'download output': res })
|
|
180
180
|
})
|
|
181
181
|
.catch(function (err) {
|
|
182
182
|
console.log('client web: download: catch', err)
|
|
183
183
|
})
|
|
184
184
|
console.log('ms', ms)
|
|
185
185
|
}
|
|
186
186
|
core()
|
|
187
187
|
|
|
188
188
|
|
|
189
189
|
|
|
@@ -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 Thu Apr 10 2025
|
|
532
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 23:50:30 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,14 +45,12 @@
|
|
|
45
45
|
|
|
46
46
|
<section>
|
|
47
47
|
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code>import
|
|
49
|
-
import axios from 'axios'
|
|
48
|
+
<pre class="prettyprint source linenums"><code>import axios from 'axios'
|
|
50
49
|
import get from 'lodash-es/get.js'
|
|
51
50
|
import isWindow from 'wsemi/src/isWindow.mjs'
|
|
51
|
+
import getGlobal from 'wsemi/src/getGlobal.mjs'
|
|
52
52
|
import evem from 'wsemi/src/evem.mjs'
|
|
53
53
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
54
|
-
// import genID from 'wsemi/src/genID.mjs'
|
|
55
|
-
// import now2strp from 'wsemi/src/now2strp.mjs'
|
|
56
54
|
import haskey from 'wsemi/src/haskey.mjs'
|
|
57
55
|
import isfun from 'wsemi/src/isfun.mjs'
|
|
58
56
|
import ispint from 'wsemi/src/ispint.mjs'
|
|
@@ -121,7 +119,7 @@ import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
|
121
119
|
* }
|
|
122
120
|
* },
|
|
123
121
|
* {
|
|
124
|
-
* fdDownload: './',
|
|
122
|
+
* fdDownload: './', //於nodejs環境才能提供
|
|
125
123
|
* })
|
|
126
124
|
* .then(function(res) {
|
|
127
125
|
* console.log('client web: download: then', res)
|
|
@@ -488,11 +486,11 @@ function WConverhpClient(opt) {
|
|
|
488
486
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
489
487
|
try {
|
|
490
488
|
|
|
491
|
-
//path, fs
|
|
489
|
+
//path, fs, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
492
490
|
let path = await import('path')
|
|
493
491
|
let fs = await import('fs')
|
|
494
492
|
|
|
495
|
-
//fdDownload,
|
|
493
|
+
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
496
494
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
497
495
|
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
498
496
|
// console.log('fdDownload', fdDownload)
|
|
@@ -679,18 +677,32 @@ function WConverhpClient(opt) {
|
|
|
679
677
|
async function calcHash(inp) {
|
|
680
678
|
let pm = genPm()
|
|
681
679
|
if (env === 'browser') {
|
|
682
|
-
|
|
680
|
+
//於browser時, 因是給予blob或file上傳, 且使用非同步async版計算hash, 可支援大檔
|
|
681
|
+
|
|
682
|
+
//crypto, 須通過global取得crypto, 否則會被舊版webpack偵測報錯
|
|
683
|
+
let g = getGlobal()
|
|
684
|
+
let crypto = get(g, 'crypto')
|
|
685
|
+
|
|
686
|
+
//hashHex
|
|
683
687
|
let ab = await inp.arrayBuffer()
|
|
684
688
|
let hashBuffer = await crypto.subtle.digest('SHA-256', ab)
|
|
685
689
|
let hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
686
690
|
let hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
|
691
|
+
|
|
687
692
|
pm.resolve(hashHex)
|
|
688
693
|
}
|
|
689
694
|
else {
|
|
690
|
-
|
|
695
|
+
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer, 同步sync版無法支援大檔
|
|
696
|
+
|
|
697
|
+
//crypto, 使用動態import供nodejs使用, 且須用變數給予crypto, 否則會被舊版webpack偵測報錯
|
|
698
|
+
let key = 'crypto'
|
|
699
|
+
let crypto = await import(key)
|
|
700
|
+
|
|
701
|
+
//hashHex
|
|
691
702
|
let hash = crypto.createHash('sha256')
|
|
692
703
|
hash.update(inp, 'utf8')
|
|
693
704
|
let hashHex = hash.digest('hex')
|
|
705
|
+
|
|
694
706
|
pm.resolve(hashHex)
|
|
695
707
|
}
|
|
696
708
|
return pm
|
|
@@ -710,7 +722,7 @@ function WConverhpClient(opt) {
|
|
|
710
722
|
}
|
|
711
723
|
if (n === 0) {
|
|
712
724
|
try {
|
|
713
|
-
n = bb.length //for Uint8Array
|
|
725
|
+
n = bb.length //for Uint8Array //nodejs用fs讀有檔案大小上限, 除非改傳入檔名用stream讀, 否則無法支援超大檔
|
|
714
726
|
n = cint(n)
|
|
715
727
|
}
|
|
716
728
|
catch (err) {}
|
|
@@ -997,7 +1009,7 @@ export default WConverhpClient
|
|
|
997
1009
|
<br class="clear">
|
|
998
1010
|
|
|
999
1011
|
<footer>
|
|
1000
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025
|
|
1012
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 23:50:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1001
1013
|
</footer>
|
|
1002
1014
|
|
|
1003
1015
|
<script>prettyPrint();</script>
|
|
@@ -749,7 +749,7 @@
|
|
|
749
749
|
<br class="clear">
|
|
750
750
|
|
|
751
751
|
<footer>
|
|
752
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 23:50:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
753
753
|
</footer>
|
|
754
754
|
|
|
755
755
|
<script>prettyPrint();</script>
|
|
@@ -1507,7 +1507,7 @@ export default WConverhpServer
|
|
|
1507
1507
|
<br class="clear">
|
|
1508
1508
|
|
|
1509
1509
|
<footer>
|
|
1510
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025
|
|
1510
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 23:50:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1511
1511
|
</footer>
|
|
1512
1512
|
|
|
1513
1513
|
<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 Thu Apr 10 2025
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 23:50:30 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,11 +1,9 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
2
1
|
import axios from 'axios'
|
|
3
2
|
import get from 'lodash-es/get.js'
|
|
4
3
|
import isWindow from 'wsemi/src/isWindow.mjs'
|
|
4
|
+
import getGlobal from 'wsemi/src/getGlobal.mjs'
|
|
5
5
|
import evem from 'wsemi/src/evem.mjs'
|
|
6
6
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
7
|
-
// import genID from 'wsemi/src/genID.mjs'
|
|
8
|
-
// import now2strp from 'wsemi/src/now2strp.mjs'
|
|
9
7
|
import haskey from 'wsemi/src/haskey.mjs'
|
|
10
8
|
import isfun from 'wsemi/src/isfun.mjs'
|
|
11
9
|
import ispint from 'wsemi/src/ispint.mjs'
|
|
@@ -74,7 +72,7 @@ import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
|
74
72
|
* }
|
|
75
73
|
* },
|
|
76
74
|
* {
|
|
77
|
-
* fdDownload: './',
|
|
75
|
+
* fdDownload: './', //於nodejs環境才能提供
|
|
78
76
|
* })
|
|
79
77
|
* .then(function(res) {
|
|
80
78
|
* console.log('client web: download: then', res)
|
|
@@ -441,11 +439,11 @@ function WConverhpClient(opt) {
|
|
|
441
439
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
442
440
|
try {
|
|
443
441
|
|
|
444
|
-
//path, fs
|
|
442
|
+
//path, fs, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
445
443
|
let path = await import('path')
|
|
446
444
|
let fs = await import('fs')
|
|
447
445
|
|
|
448
|
-
//fdDownload,
|
|
446
|
+
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
449
447
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
450
448
|
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
451
449
|
// console.log('fdDownload', fdDownload)
|
|
@@ -632,18 +630,32 @@ function WConverhpClient(opt) {
|
|
|
632
630
|
async function calcHash(inp) {
|
|
633
631
|
let pm = genPm()
|
|
634
632
|
if (env === 'browser') {
|
|
635
|
-
|
|
633
|
+
//於browser時, 因是給予blob或file上傳, 且使用非同步async版計算hash, 可支援大檔
|
|
634
|
+
|
|
635
|
+
//crypto, 須通過global取得crypto, 否則會被舊版webpack偵測報錯
|
|
636
|
+
let g = getGlobal()
|
|
637
|
+
let crypto = get(g, 'crypto')
|
|
638
|
+
|
|
639
|
+
//hashHex
|
|
636
640
|
let ab = await inp.arrayBuffer()
|
|
637
641
|
let hashBuffer = await crypto.subtle.digest('SHA-256', ab)
|
|
638
642
|
let hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
639
643
|
let hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
|
644
|
+
|
|
640
645
|
pm.resolve(hashHex)
|
|
641
646
|
}
|
|
642
647
|
else {
|
|
643
|
-
|
|
648
|
+
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer, 同步sync版無法支援大檔
|
|
649
|
+
|
|
650
|
+
//crypto, 使用動態import供nodejs使用, 且須用變數給予crypto, 否則會被舊版webpack偵測報錯
|
|
651
|
+
let key = 'crypto'
|
|
652
|
+
let crypto = await import(key)
|
|
653
|
+
|
|
654
|
+
//hashHex
|
|
644
655
|
let hash = crypto.createHash('sha256')
|
|
645
656
|
hash.update(inp, 'utf8')
|
|
646
657
|
let hashHex = hash.digest('hex')
|
|
658
|
+
|
|
647
659
|
pm.resolve(hashHex)
|
|
648
660
|
}
|
|
649
661
|
return pm
|
|
@@ -663,7 +675,7 @@ function WConverhpClient(opt) {
|
|
|
663
675
|
}
|
|
664
676
|
if (n === 0) {
|
|
665
677
|
try {
|
|
666
|
-
n = bb.length //for Uint8Array
|
|
678
|
+
n = bb.length //for Uint8Array //nodejs用fs讀有檔案大小上限, 除非改傳入檔名用stream讀, 否則無法支援超大檔
|
|
667
679
|
n = cint(n)
|
|
668
680
|
}
|
|
669
681
|
catch (err) {}
|