w-converhp 2.0.44 → 2.0.46
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 +2 -2
- package/dist/w-converhp-server.umd.js.map +1 -1
- package/docs/WConverhpClient.html +1 -1
- package/docs/WConverhpClient.mjs.html +72 -23
- package/docs/WConverhpServer.html +1 -1
- package/docs/WConverhpServer.mjs.html +12 -1
- package/docs/index.html +1 -1
- package/package.json +4 -4
- package/src/WConverhpClient.mjs +71 -22
- package/src/WConverhpServer.mjs +11 -0
- package/src/checkSlicesHash.wk.umd.js +1 -1
- package/src/checkTotalHash.wk.umd.js +1 -1
- package/src/mergeSlices.wk.umd.js +1 -1
|
@@ -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
|
|
532
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 15 2025 21:00:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
533
533
|
</footer>
|
|
534
534
|
|
|
535
535
|
<script>prettyPrint();</script>
|
|
@@ -485,9 +485,11 @@ function WConverhpClient(opt) {
|
|
|
485
485
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
486
486
|
try {
|
|
487
487
|
|
|
488
|
-
//path, fs, 使用動態import供nodejs使用,
|
|
489
|
-
let
|
|
490
|
-
let
|
|
488
|
+
//path, fs, 使用動態import供nodejs使用, 須用變數字串給予載入套件, 否則用於前端時會被webpack偵測而報錯
|
|
489
|
+
let cImPath = 'path'
|
|
490
|
+
let cImFs = 'fs'
|
|
491
|
+
let path = await import(cImPath)
|
|
492
|
+
let fs = await import(cImFs)
|
|
491
493
|
|
|
492
494
|
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
493
495
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
@@ -729,17 +731,13 @@ function WConverhpClient(opt) {
|
|
|
729
731
|
let progWeightSlice = 0.99 //上傳階段進度使用99%
|
|
730
732
|
// let progWeightMerge = 0.01 //合併階段進度使用1%
|
|
731
733
|
|
|
732
|
-
//cbProgressSlice
|
|
733
|
-
let cbProgressSlice = (
|
|
734
|
-
|
|
735
|
-
let
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
let prog = r * progWeightSlice * 100
|
|
740
|
-
let psiz = r * fileTotalSize
|
|
741
|
-
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
742
|
-
}
|
|
734
|
+
//cbProgressSlice, 以累積機制計算進度, 累積片數配合總切片數量即可算出進度, 故不須輸入msg
|
|
735
|
+
let cbProgressSlice = () => {
|
|
736
|
+
progCount++
|
|
737
|
+
let r = progCount / chunkTotal
|
|
738
|
+
let prog = r * progWeightSlice * 100
|
|
739
|
+
let psiz = r * fileTotalSize
|
|
740
|
+
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
743
741
|
}
|
|
744
742
|
|
|
745
743
|
//cbProgressMerge
|
|
@@ -855,7 +853,7 @@ function WConverhpClient(opt) {
|
|
|
855
853
|
//check
|
|
856
854
|
if (resUpCkt.slks.indexOf(i) >= 0) {
|
|
857
855
|
// console.log('已有上傳切片檔')
|
|
858
|
-
cbProgressSlice(
|
|
856
|
+
cbProgressSlice() //直接觸發更新進度
|
|
859
857
|
continue
|
|
860
858
|
}
|
|
861
859
|
|
|
@@ -868,14 +866,65 @@ function WConverhpClient(opt) {
|
|
|
868
866
|
//chunk
|
|
869
867
|
let chunk = bb.slice(start, end)
|
|
870
868
|
|
|
871
|
-
//
|
|
872
|
-
let
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
869
|
+
//sendDataSlice
|
|
870
|
+
let sendDataSlice = async() => {
|
|
871
|
+
|
|
872
|
+
//hd
|
|
873
|
+
let hd = { //用header傳key與value時, key不分大小寫, 故使用kebabCase
|
|
874
|
+
'chunk-index': i,
|
|
875
|
+
'chunk-total': chunkTotal,
|
|
876
|
+
'package-id': packageId,
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
//send slice
|
|
880
|
+
let resSl = await send('slice', chunk, {
|
|
881
|
+
headers: hd,
|
|
882
|
+
dataType: 'blob',
|
|
883
|
+
cbProgress: (msg) => {
|
|
884
|
+
// console.log('cbProgress', msg)
|
|
885
|
+
// let perc = msg.prog
|
|
886
|
+
// let dir = msg.m
|
|
887
|
+
// if (dir === 'upload' && perc === 100) {
|
|
888
|
+
// }
|
|
889
|
+
}
|
|
890
|
+
})
|
|
891
|
+
// console.log('resSl', resSl)
|
|
892
|
+
|
|
893
|
+
//cbProgressSlice, 因其內有累加progCount, 實際代表是須成功傳輸後才能計算與回應外部進度, 故不能直接用於send的opt.cbProgress
|
|
894
|
+
cbProgressSlice()
|
|
895
|
+
|
|
896
|
+
return resSl
|
|
876
897
|
}
|
|
877
|
-
|
|
878
|
-
//
|
|
898
|
+
|
|
899
|
+
//sendDataSliceRetry
|
|
900
|
+
let sendDataSliceRetry = async() => {
|
|
901
|
+
|
|
902
|
+
//fun
|
|
903
|
+
let fun = pmConvertResolve(sendDataSlice)
|
|
904
|
+
|
|
905
|
+
//sendPkg
|
|
906
|
+
let r = await fun()
|
|
907
|
+
|
|
908
|
+
let n = 0
|
|
909
|
+
while (r.state === 'error') {
|
|
910
|
+
n += 1
|
|
911
|
+
if (n > retry) {
|
|
912
|
+
break
|
|
913
|
+
}
|
|
914
|
+
console.log(`retry n=${n}`)
|
|
915
|
+
r = await fun()
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (r.state === 'success') {
|
|
919
|
+
return r.msg
|
|
920
|
+
}
|
|
921
|
+
else {
|
|
922
|
+
return Promise.reject(r.msg)
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
//sendDataSliceRetry
|
|
927
|
+
await sendDataSliceRetry()
|
|
879
928
|
|
|
880
929
|
}
|
|
881
930
|
|
|
@@ -1107,7 +1156,7 @@ export default WConverhpClient
|
|
|
1107
1156
|
<br class="clear">
|
|
1108
1157
|
|
|
1109
1158
|
<footer>
|
|
1110
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu
|
|
1159
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 15 2025 21:00:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1111
1160
|
</footer>
|
|
1112
1161
|
|
|
1113
1162
|
<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
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 15 2025 21:00:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
753
753
|
</footer>
|
|
754
754
|
|
|
755
755
|
<script>prettyPrint();</script>
|
|
@@ -1006,6 +1006,17 @@ function WConverhpServer(opt = {}) {
|
|
|
1006
1006
|
let u8aOut = obj2u8arr(out)
|
|
1007
1007
|
// console.log('u8aOut', u8aOut)
|
|
1008
1008
|
|
|
1009
|
+
// //測試失敗重傳
|
|
1010
|
+
// if (Math.random() < 0.9) {
|
|
1011
|
+
// out = {
|
|
1012
|
+
// error: 'force error'
|
|
1013
|
+
// }
|
|
1014
|
+
// returnType = 'error'
|
|
1015
|
+
// returnMsg = 'force error'
|
|
1016
|
+
// // console.log('out', out)
|
|
1017
|
+
// u8aOut = obj2u8arr(out)
|
|
1018
|
+
// }
|
|
1019
|
+
|
|
1009
1020
|
return responseU8aStream(res, u8aOut, { returnType, returnMsg })
|
|
1010
1021
|
},
|
|
1011
1022
|
}
|
|
@@ -1474,7 +1485,7 @@ export default WConverhpServer
|
|
|
1474
1485
|
<br class="clear">
|
|
1475
1486
|
|
|
1476
1487
|
<footer>
|
|
1477
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu
|
|
1488
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 15 2025 21:00:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1478
1489
|
</footer>
|
|
1479
1490
|
|
|
1480
1491
|
<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
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 15 2025 21:00:14 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,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-converhp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.46",
|
|
4
4
|
"main": "dist/w-converhp-server.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/hapi": "^21.4.0",
|
|
7
7
|
"@hapi/inert": "^7.1.0",
|
|
8
|
-
"axios": "^1.
|
|
8
|
+
"axios": "^1.9.0",
|
|
9
9
|
"lodash-es": "^4.17.21",
|
|
10
|
-
"wsemi": "^1.7.
|
|
10
|
+
"wsemi": "^1.7.90"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"form-data": "^4.0.2",
|
|
14
|
-
"w-package-tools": "^1.0.
|
|
14
|
+
"w-package-tools": "^1.0.90"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"@hapi/hapi": "^20.2.1",
|
package/src/WConverhpClient.mjs
CHANGED
|
@@ -438,9 +438,11 @@ function WConverhpClient(opt) {
|
|
|
438
438
|
//nodejs通過fs與stream接收檔案, stream出錯只會觸發error事件, 此處try catch為攔截其他非stream程式碼錯誤
|
|
439
439
|
try {
|
|
440
440
|
|
|
441
|
-
//path, fs, 使用動態import供nodejs使用,
|
|
442
|
-
let
|
|
443
|
-
let
|
|
441
|
+
//path, fs, 使用動態import供nodejs使用, 須用變數字串給予載入套件, 否則用於前端時會被webpack偵測而報錯
|
|
442
|
+
let cImPath = 'path'
|
|
443
|
+
let cImFs = 'fs'
|
|
444
|
+
let path = await import(cImPath)
|
|
445
|
+
let fs = await import(cImFs)
|
|
444
446
|
|
|
445
447
|
//fdDownload, 只有nodejs下載才使用fdDownload
|
|
446
448
|
let fdDownload = get(opt, 'fdDownload', '')
|
|
@@ -682,17 +684,13 @@ function WConverhpClient(opt) {
|
|
|
682
684
|
let progWeightSlice = 0.99 //上傳階段進度使用99%
|
|
683
685
|
// let progWeightMerge = 0.01 //合併階段進度使用1%
|
|
684
686
|
|
|
685
|
-
//cbProgressSlice
|
|
686
|
-
let cbProgressSlice = (
|
|
687
|
-
|
|
688
|
-
let
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
let prog = r * progWeightSlice * 100
|
|
693
|
-
let psiz = r * fileTotalSize
|
|
694
|
-
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
695
|
-
}
|
|
687
|
+
//cbProgressSlice, 以累積機制計算進度, 累積片數配合總切片數量即可算出進度, 故不須輸入msg
|
|
688
|
+
let cbProgressSlice = () => {
|
|
689
|
+
progCount++
|
|
690
|
+
let r = progCount / chunkTotal
|
|
691
|
+
let prog = r * progWeightSlice * 100
|
|
692
|
+
let psiz = r * fileTotalSize
|
|
693
|
+
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
696
694
|
}
|
|
697
695
|
|
|
698
696
|
//cbProgressMerge
|
|
@@ -808,7 +806,7 @@ function WConverhpClient(opt) {
|
|
|
808
806
|
//check
|
|
809
807
|
if (resUpCkt.slks.indexOf(i) >= 0) {
|
|
810
808
|
// console.log('已有上傳切片檔')
|
|
811
|
-
cbProgressSlice(
|
|
809
|
+
cbProgressSlice() //直接觸發更新進度
|
|
812
810
|
continue
|
|
813
811
|
}
|
|
814
812
|
|
|
@@ -821,14 +819,65 @@ function WConverhpClient(opt) {
|
|
|
821
819
|
//chunk
|
|
822
820
|
let chunk = bb.slice(start, end)
|
|
823
821
|
|
|
824
|
-
//
|
|
825
|
-
let
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
822
|
+
//sendDataSlice
|
|
823
|
+
let sendDataSlice = async() => {
|
|
824
|
+
|
|
825
|
+
//hd
|
|
826
|
+
let hd = { //用header傳key與value時, key不分大小寫, 故使用kebabCase
|
|
827
|
+
'chunk-index': i,
|
|
828
|
+
'chunk-total': chunkTotal,
|
|
829
|
+
'package-id': packageId,
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
//send slice
|
|
833
|
+
let resSl = await send('slice', chunk, {
|
|
834
|
+
headers: hd,
|
|
835
|
+
dataType: 'blob',
|
|
836
|
+
cbProgress: (msg) => {
|
|
837
|
+
// console.log('cbProgress', msg)
|
|
838
|
+
// let perc = msg.prog
|
|
839
|
+
// let dir = msg.m
|
|
840
|
+
// if (dir === 'upload' && perc === 100) {
|
|
841
|
+
// }
|
|
842
|
+
}
|
|
843
|
+
})
|
|
844
|
+
// console.log('resSl', resSl)
|
|
845
|
+
|
|
846
|
+
//cbProgressSlice, 因其內有累加progCount, 實際代表是須成功傳輸後才能計算與回應外部進度, 故不能直接用於send的opt.cbProgress
|
|
847
|
+
cbProgressSlice()
|
|
848
|
+
|
|
849
|
+
return resSl
|
|
829
850
|
}
|
|
830
|
-
|
|
831
|
-
//
|
|
851
|
+
|
|
852
|
+
//sendDataSliceRetry
|
|
853
|
+
let sendDataSliceRetry = async() => {
|
|
854
|
+
|
|
855
|
+
//fun
|
|
856
|
+
let fun = pmConvertResolve(sendDataSlice)
|
|
857
|
+
|
|
858
|
+
//sendPkg
|
|
859
|
+
let r = await fun()
|
|
860
|
+
|
|
861
|
+
let n = 0
|
|
862
|
+
while (r.state === 'error') {
|
|
863
|
+
n += 1
|
|
864
|
+
if (n > retry) {
|
|
865
|
+
break
|
|
866
|
+
}
|
|
867
|
+
console.log(`retry n=${n}`)
|
|
868
|
+
r = await fun()
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
if (r.state === 'success') {
|
|
872
|
+
return r.msg
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
return Promise.reject(r.msg)
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
//sendDataSliceRetry
|
|
880
|
+
await sendDataSliceRetry()
|
|
832
881
|
|
|
833
882
|
}
|
|
834
883
|
|
package/src/WConverhpServer.mjs
CHANGED
|
@@ -959,6 +959,17 @@ function WConverhpServer(opt = {}) {
|
|
|
959
959
|
let u8aOut = obj2u8arr(out)
|
|
960
960
|
// console.log('u8aOut', u8aOut)
|
|
961
961
|
|
|
962
|
+
// //測試失敗重傳
|
|
963
|
+
// if (Math.random() < 0.9) {
|
|
964
|
+
// out = {
|
|
965
|
+
// error: 'force error'
|
|
966
|
+
// }
|
|
967
|
+
// returnType = 'error'
|
|
968
|
+
// returnMsg = 'force error'
|
|
969
|
+
// // console.log('out', out)
|
|
970
|
+
// u8aOut = obj2u8arr(out)
|
|
971
|
+
// }
|
|
972
|
+
|
|
962
973
|
return responseU8aStream(res, u8aOut, { returnType, returnMsg })
|
|
963
974
|
},
|
|
964
975
|
}
|