w-converhp 2.0.27 → 2.0.28
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 +15 -9
- 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 +13 -7
- 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#line95">line 95</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 22:
|
|
532
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:38: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,8 +45,7 @@
|
|
|
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'
|
|
52
51
|
import evem from 'wsemi/src/evem.mjs'
|
|
@@ -121,7 +120,7 @@ import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
|
121
120
|
* }
|
|
122
121
|
* },
|
|
123
122
|
* {
|
|
124
|
-
* fdDownload: './',
|
|
123
|
+
* fdDownload: './', //於nodejs環境才能提供
|
|
125
124
|
* })
|
|
126
125
|
* .then(function(res) {
|
|
127
126
|
* console.log('client web: download: then', res)
|
|
@@ -488,11 +487,11 @@ function WConverhpClient(opt) {
|
|
|
488
487
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
489
488
|
try {
|
|
490
489
|
|
|
491
|
-
//path, fs
|
|
490
|
+
//path, fs, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
492
491
|
let path = await import('path')
|
|
493
492
|
let fs = await import('fs')
|
|
494
493
|
|
|
495
|
-
//fdDownload,
|
|
494
|
+
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
496
495
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
497
496
|
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
498
497
|
// console.log('fdDownload', fdDownload)
|
|
@@ -679,18 +678,25 @@ function WConverhpClient(opt) {
|
|
|
679
678
|
async function calcHash(inp) {
|
|
680
679
|
let pm = genPm()
|
|
681
680
|
if (env === 'browser') {
|
|
682
|
-
|
|
681
|
+
//於browser時, 因是給予blob或file上傳, 且使用非同步async版計算hash, 可支援大檔
|
|
682
|
+
|
|
683
683
|
let ab = await inp.arrayBuffer()
|
|
684
684
|
let hashBuffer = await crypto.subtle.digest('SHA-256', ab)
|
|
685
685
|
let hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
686
686
|
let hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
|
687
|
+
|
|
687
688
|
pm.resolve(hashHex)
|
|
688
689
|
}
|
|
689
690
|
else {
|
|
690
|
-
|
|
691
|
+
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer, 同步sync版無法支援大檔
|
|
692
|
+
|
|
693
|
+
//crypto, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
694
|
+
let crypto = await import('crypto')
|
|
695
|
+
|
|
691
696
|
let hash = crypto.createHash('sha256')
|
|
692
697
|
hash.update(inp, 'utf8')
|
|
693
698
|
let hashHex = hash.digest('hex')
|
|
699
|
+
|
|
694
700
|
pm.resolve(hashHex)
|
|
695
701
|
}
|
|
696
702
|
return pm
|
|
@@ -710,7 +716,7 @@ function WConverhpClient(opt) {
|
|
|
710
716
|
}
|
|
711
717
|
if (n === 0) {
|
|
712
718
|
try {
|
|
713
|
-
n = bb.length //for Uint8Array
|
|
719
|
+
n = bb.length //for Uint8Array //nodejs用fs讀有檔案大小上限, 除非改傳入檔名用stream讀, 否則無法支援超大檔
|
|
714
720
|
n = cint(n)
|
|
715
721
|
}
|
|
716
722
|
catch (err) {}
|
|
@@ -997,7 +1003,7 @@ export default WConverhpClient
|
|
|
997
1003
|
<br class="clear">
|
|
998
1004
|
|
|
999
1005
|
<footer>
|
|
1000
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:
|
|
1006
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:38:50 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1001
1007
|
</footer>
|
|
1002
1008
|
|
|
1003
1009
|
<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 22:
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:38:50 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 22:
|
|
1510
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:38:50 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 22:
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Apr 10 2025 22:38: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/src/WConverhpClient.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
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'
|
|
@@ -74,7 +73,7 @@ import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
|
74
73
|
* }
|
|
75
74
|
* },
|
|
76
75
|
* {
|
|
77
|
-
* fdDownload: './',
|
|
76
|
+
* fdDownload: './', //於nodejs環境才能提供
|
|
78
77
|
* })
|
|
79
78
|
* .then(function(res) {
|
|
80
79
|
* console.log('client web: download: then', res)
|
|
@@ -441,11 +440,11 @@ function WConverhpClient(opt) {
|
|
|
441
440
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
442
441
|
try {
|
|
443
442
|
|
|
444
|
-
//path, fs
|
|
443
|
+
//path, fs, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
445
444
|
let path = await import('path')
|
|
446
445
|
let fs = await import('fs')
|
|
447
446
|
|
|
448
|
-
//fdDownload,
|
|
447
|
+
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
449
448
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
450
449
|
fs.mkdirSync(fdDownload, { recursive: true }) //須使用mkdirSync, 不要用fsIsFolder與fsCreateFolder避免編譯
|
|
451
450
|
// console.log('fdDownload', fdDownload)
|
|
@@ -632,18 +631,25 @@ function WConverhpClient(opt) {
|
|
|
632
631
|
async function calcHash(inp) {
|
|
633
632
|
let pm = genPm()
|
|
634
633
|
if (env === 'browser') {
|
|
635
|
-
|
|
634
|
+
//於browser時, 因是給予blob或file上傳, 且使用非同步async版計算hash, 可支援大檔
|
|
635
|
+
|
|
636
636
|
let ab = await inp.arrayBuffer()
|
|
637
637
|
let hashBuffer = await crypto.subtle.digest('SHA-256', ab)
|
|
638
638
|
let hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
639
639
|
let hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
|
640
|
+
|
|
640
641
|
pm.resolve(hashHex)
|
|
641
642
|
}
|
|
642
643
|
else {
|
|
643
|
-
|
|
644
|
+
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer, 同步sync版無法支援大檔
|
|
645
|
+
|
|
646
|
+
//crypto, 使用動態import供nodejs使用, 否則會被webpack偵測報錯
|
|
647
|
+
let crypto = await import('crypto')
|
|
648
|
+
|
|
644
649
|
let hash = crypto.createHash('sha256')
|
|
645
650
|
hash.update(inp, 'utf8')
|
|
646
651
|
let hashHex = hash.digest('hex')
|
|
652
|
+
|
|
647
653
|
pm.resolve(hashHex)
|
|
648
654
|
}
|
|
649
655
|
return pm
|
|
@@ -663,7 +669,7 @@ function WConverhpClient(opt) {
|
|
|
663
669
|
}
|
|
664
670
|
if (n === 0) {
|
|
665
671
|
try {
|
|
666
|
-
n = bb.length //for Uint8Array
|
|
672
|
+
n = bb.length //for Uint8Array //nodejs用fs讀有檔案大小上限, 除非改傳入檔名用stream讀, 否則無法支援超大檔
|
|
667
673
|
n = cint(n)
|
|
668
674
|
}
|
|
669
675
|
catch (err) {}
|