w-converhp 2.0.46 → 2.0.48
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 +2 -2
- package/docs/WConverhpClient.mjs.html +179 -201
- package/docs/WConverhpServer.html +1 -1
- package/docs/WConverhpServer.mjs.html +8 -8
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/WConverhpClient.mjs +178 -200
- package/src/WConverhpServer.mjs +7 -7
|
@@ -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
|
|
|
@@ -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
|
|
532
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54: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>
|
|
@@ -59,12 +59,14 @@ import isobj from 'wsemi/src/isobj.mjs'
|
|
|
59
59
|
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
60
60
|
import ispm from 'wsemi/src/ispm.mjs'
|
|
61
61
|
import cint from 'wsemi/src/cint.mjs'
|
|
62
|
+
import dig from 'wsemi/src/dig.mjs'
|
|
62
63
|
import strright from 'wsemi/src/strright.mjs'
|
|
63
64
|
import b642str from 'wsemi/src/b642str.mjs'
|
|
64
65
|
import blob2u8arr from 'wsemi/src/blob2u8arr.mjs'
|
|
65
66
|
import obj2u8arr from 'wsemi/src/obj2u8arr.mjs'
|
|
66
67
|
import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
67
68
|
import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
69
|
+
import delay from 'wsemi/src/delay.mjs'
|
|
68
70
|
import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
|
|
69
71
|
|
|
70
72
|
|
|
@@ -183,7 +185,7 @@ function WConverhpClient(opt) {
|
|
|
183
185
|
//retry
|
|
184
186
|
let retry = get(opt, 'retry')
|
|
185
187
|
if (!isp0int(retry)) {
|
|
186
|
-
retry =
|
|
188
|
+
retry = 10
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
//env
|
|
@@ -206,25 +208,22 @@ function WConverhpClient(opt) {
|
|
|
206
208
|
//urlUse
|
|
207
209
|
let urlUse = ''
|
|
208
210
|
if (type === 'basic') {
|
|
209
|
-
urlUse = url
|
|
210
|
-
}
|
|
211
|
-
else if (type === 'slice') {
|
|
212
|
-
urlUse = `${url}slc`
|
|
211
|
+
urlUse = `${url}/main`
|
|
213
212
|
}
|
|
214
213
|
else if (type === 'upload-controller') {
|
|
215
|
-
urlUse = `${url}ulctr`
|
|
214
|
+
urlUse = `${url}/ulctr`
|
|
215
|
+
}
|
|
216
|
+
else if (type === 'slice') {
|
|
217
|
+
urlUse = `${url}/slc`
|
|
216
218
|
}
|
|
217
|
-
// else if (type === 'slice-merge') {
|
|
218
|
-
// urlUse = `${url}slcm`
|
|
219
|
-
// }
|
|
220
219
|
else if (type === 'download-get-filename') {
|
|
221
|
-
urlUse = `${url}dwgfn`
|
|
220
|
+
urlUse = `${url}/dwgfn`
|
|
222
221
|
}
|
|
223
222
|
else if (type === 'download-get') {
|
|
224
|
-
urlUse = `${url}dwgf`
|
|
223
|
+
urlUse = `${url}/dwgf`
|
|
225
224
|
}
|
|
226
225
|
else if (type === 'download') {
|
|
227
|
-
urlUse = `${url}dw`
|
|
226
|
+
urlUse = `${url}/dw`
|
|
228
227
|
}
|
|
229
228
|
else {
|
|
230
229
|
throw new Error(`invalid type[${type}]`)
|
|
@@ -234,7 +233,7 @@ function WConverhpClient(opt) {
|
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
//res2u8arr
|
|
237
|
-
|
|
236
|
+
let res2u8arr = async(bb) => {
|
|
238
237
|
//blob(in browser) or buffer(in nodejs) to u8a
|
|
239
238
|
let u8a
|
|
240
239
|
if (env === 'browser') {
|
|
@@ -247,7 +246,7 @@ function WConverhpClient(opt) {
|
|
|
247
246
|
}
|
|
248
247
|
|
|
249
248
|
//u8arr2bb
|
|
250
|
-
|
|
249
|
+
let u8arr2bb = (u8a) => {
|
|
251
250
|
//u8a to blob(in browser) or buffer(in nodejs)
|
|
252
251
|
let bb
|
|
253
252
|
if (env === 'browser') {
|
|
@@ -260,7 +259,7 @@ function WConverhpClient(opt) {
|
|
|
260
259
|
}
|
|
261
260
|
|
|
262
261
|
//send
|
|
263
|
-
|
|
262
|
+
let send = async(type, pkg, opt = {}) => {
|
|
264
263
|
|
|
265
264
|
//headers
|
|
266
265
|
let headers = get(opt, 'headers')
|
|
@@ -367,54 +366,6 @@ function WConverhpClient(opt) {
|
|
|
367
366
|
token = await token
|
|
368
367
|
}
|
|
369
368
|
|
|
370
|
-
//s
|
|
371
|
-
let s = {
|
|
372
|
-
method: 'POST',
|
|
373
|
-
url: urlUse,
|
|
374
|
-
data: dd,
|
|
375
|
-
headers: {
|
|
376
|
-
Authorization: `${tokenType} ${token}`,
|
|
377
|
-
...ct,
|
|
378
|
-
...headers,
|
|
379
|
-
},
|
|
380
|
-
timeout: 60 * 60 * 1000, //1hr
|
|
381
|
-
maxContentLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
382
|
-
maxBodyLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
383
|
-
responseType: rt,
|
|
384
|
-
onUploadProgress: function(ev) {
|
|
385
|
-
//console.log('onUploadProgress', ev)
|
|
386
|
-
|
|
387
|
-
//r
|
|
388
|
-
let r = 0
|
|
389
|
-
let loaded = ev.loaded
|
|
390
|
-
let total = ev.total
|
|
391
|
-
if (ispint(total)) {
|
|
392
|
-
r = (loaded * 100) / total
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
//cbProgress
|
|
396
|
-
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
397
|
-
|
|
398
|
-
},
|
|
399
|
-
onDownloadProgress: function (ev) {
|
|
400
|
-
// console.log('onDownloadProgress', ev)
|
|
401
|
-
|
|
402
|
-
//r
|
|
403
|
-
let r = 0
|
|
404
|
-
let loaded = ev.loaded
|
|
405
|
-
// let total = ev.srcElement.getResponseHeader('Content-length') //若需要得知下載進度, 需於伺服器回傳時提供Content-length
|
|
406
|
-
let total = ev.total
|
|
407
|
-
if (ispint(total)) {
|
|
408
|
-
r = (loaded * 100) / total
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
//cbProgress
|
|
412
|
-
cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
|
|
413
|
-
|
|
414
|
-
},
|
|
415
|
-
}
|
|
416
|
-
// console.log('s', s)
|
|
417
|
-
|
|
418
369
|
//getFilenameByHeader
|
|
419
370
|
let getFilenameByHeader = (contentDisposition) => {
|
|
420
371
|
let fn = 'unknow'
|
|
@@ -428,7 +379,7 @@ function WConverhpClient(opt) {
|
|
|
428
379
|
}
|
|
429
380
|
|
|
430
381
|
//downloadStream
|
|
431
|
-
let downloadStream = async
|
|
382
|
+
let downloadStream = async(res) => {
|
|
432
383
|
// console.log('res.headers', res.headers)
|
|
433
384
|
|
|
434
385
|
//pm
|
|
@@ -526,61 +477,151 @@ function WConverhpClient(opt) {
|
|
|
526
477
|
return pm
|
|
527
478
|
}
|
|
528
479
|
|
|
529
|
-
//
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
480
|
+
//s
|
|
481
|
+
let s = {
|
|
482
|
+
method: 'POST',
|
|
483
|
+
url: urlUse,
|
|
484
|
+
data: dd,
|
|
485
|
+
headers: {
|
|
486
|
+
Authorization: `${tokenType} ${token}`,
|
|
487
|
+
...ct,
|
|
488
|
+
...headers,
|
|
489
|
+
},
|
|
490
|
+
timeout: 60 * 60 * 1000, //1hr
|
|
491
|
+
maxContentLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
492
|
+
maxBodyLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
493
|
+
responseType: rt,
|
|
494
|
+
onUploadProgress: function(ev) {
|
|
495
|
+
//console.log('onUploadProgress', ev)
|
|
496
|
+
|
|
497
|
+
//r
|
|
498
|
+
let r = 0
|
|
499
|
+
let loaded = ev.loaded
|
|
500
|
+
let total = ev.total
|
|
501
|
+
if (ispint(total)) {
|
|
502
|
+
r = (loaded * 100) / total
|
|
544
503
|
}
|
|
545
504
|
|
|
546
|
-
//
|
|
547
|
-
|
|
548
|
-
// console.log('bb', bb)
|
|
505
|
+
//cbProgress
|
|
506
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
549
507
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
// console.log('
|
|
508
|
+
},
|
|
509
|
+
onDownloadProgress: function (ev) {
|
|
510
|
+
// console.log('onDownloadProgress', ev)
|
|
553
511
|
|
|
554
|
-
//
|
|
555
|
-
let
|
|
556
|
-
|
|
512
|
+
//r
|
|
513
|
+
let r = 0
|
|
514
|
+
let loaded = ev.loaded
|
|
515
|
+
// let total = ev.srcElement.getResponseHeader('Content-length') //若需要得知下載進度, 需於伺服器回傳時提供Content-length
|
|
516
|
+
let total = ev.total
|
|
517
|
+
if (ispint(total)) {
|
|
518
|
+
r = (loaded * 100) / total
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
//cbProgress
|
|
522
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
|
|
523
|
+
|
|
524
|
+
},
|
|
525
|
+
}
|
|
526
|
+
// console.log('s', s)
|
|
527
|
+
|
|
528
|
+
//callApiCore, 處理axios成功then時訊息, catch時直接向外傳遞
|
|
529
|
+
let callApiCore = async() => {
|
|
530
|
+
|
|
531
|
+
//axios, catch時直接向外傳遞
|
|
532
|
+
let res = await axios(s)
|
|
533
|
+
|
|
534
|
+
//check, download時直接轉由downloadStream處理res, catch時直接向外傳遞
|
|
535
|
+
if (type === 'download') {
|
|
536
|
+
return await downloadStream(res)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
//bb
|
|
540
|
+
let bb = get(res, 'data')
|
|
541
|
+
// console.log('bb', bb)
|
|
542
|
+
|
|
543
|
+
//res2u8arr, catch時直接向外傳遞
|
|
544
|
+
let u8a = await res2u8arr(bb)
|
|
545
|
+
// console.log('u8a', u8a)
|
|
546
|
+
|
|
547
|
+
//u8arr2obj
|
|
548
|
+
let data = u8arr2obj(u8a)
|
|
549
|
+
// console.log('data', data)
|
|
550
|
+
|
|
551
|
+
//check
|
|
552
|
+
if (!iseobj(data)) {
|
|
553
|
+
eeEmit('error', `data is not an effective object`)
|
|
554
|
+
return Promise.reject(`data is not an effective object`)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
//分離伺服器資料的success或error
|
|
558
|
+
if (haskey(data, 'success')) {
|
|
559
|
+
return Promise.resolve(data.success)
|
|
560
|
+
}
|
|
561
|
+
else if (haskey(data, 'error')) {
|
|
562
|
+
eeEmit('error', data.error)
|
|
563
|
+
return Promise.reject(data.error)
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
eeEmit('error', `data does not contain success or error`)
|
|
567
|
+
return Promise.reject(`data does not contain success or error`)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
//callApi, 處理callApiCore失敗catch時retry
|
|
573
|
+
let callApi = async() => {
|
|
574
|
+
|
|
575
|
+
//pmConvertResolve
|
|
576
|
+
let fun = pmConvertResolve(callApiCore)
|
|
577
|
+
|
|
578
|
+
//fun
|
|
579
|
+
let r = await fun(s)
|
|
580
|
+
// console.log('r', r)
|
|
581
|
+
|
|
582
|
+
//while
|
|
583
|
+
let maxRetry = 10
|
|
584
|
+
let baseDelay = 1000 //初始延遲為1秒
|
|
585
|
+
let ratio = Math.pow(180000 / baseDelay, 1 / (maxRetry - 1)) //1.888
|
|
586
|
+
let n = 0
|
|
587
|
+
while (r.state === 'error') {
|
|
588
|
+
|
|
589
|
+
//add
|
|
590
|
+
n += 1
|
|
557
591
|
|
|
558
592
|
//check
|
|
559
|
-
if (
|
|
560
|
-
|
|
561
|
-
eeEmit('error', `data is not an effective object`)
|
|
562
|
-
pm.reject(`data is not an effective object`)
|
|
563
|
-
return
|
|
593
|
+
if (n > retry) {
|
|
594
|
+
break
|
|
564
595
|
}
|
|
565
596
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
// console.log('invalid data', data)
|
|
576
|
-
eeEmit('error', `invalid data`)
|
|
577
|
-
pm.reject(`invalid data`)
|
|
578
|
-
}
|
|
597
|
+
//delay
|
|
598
|
+
let t = Math.round(baseDelay * Math.pow(ratio, n - 1))
|
|
599
|
+
console.log(`wait ${dig(t / 1000, 1)}(second) to retry...`)
|
|
600
|
+
await delay(t)
|
|
601
|
+
|
|
602
|
+
//retry
|
|
603
|
+
console.log(`retry n=${n}...`)
|
|
604
|
+
r = await fun(s)
|
|
605
|
+
// console.log(`retry n=${n} done`)
|
|
579
606
|
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (r.state === 'success') {
|
|
610
|
+
return r.msg
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
return Promise.reject(r.msg)
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
//callApi
|
|
618
|
+
await callApi()
|
|
619
|
+
.then((res) => {
|
|
620
|
+
pm.resolve(res)
|
|
580
621
|
})
|
|
581
|
-
.catch(async
|
|
622
|
+
.catch(async(res) => {
|
|
582
623
|
// console.log('axios catch', res.toJSON())
|
|
583
|
-
//Network Error除可能是網路斷線之外, 可能被瀏覽器外掛封鎖阻擋,
|
|
624
|
+
//Network Error除可能是網路斷線之外, 可能被瀏覽器外掛封鎖阻擋, 亦可能因硬碟空間不足無法下載被瀏覽器拒絕
|
|
584
625
|
|
|
585
626
|
//data
|
|
586
627
|
let data = null
|
|
@@ -622,7 +663,7 @@ function WConverhpClient(opt) {
|
|
|
622
663
|
}
|
|
623
664
|
|
|
624
665
|
//sendPkg
|
|
625
|
-
|
|
666
|
+
let sendPkg = async(type, data, cbProgress) => {
|
|
626
667
|
|
|
627
668
|
//bb
|
|
628
669
|
let bb = null
|
|
@@ -647,35 +688,8 @@ function WConverhpClient(opt) {
|
|
|
647
688
|
return res
|
|
648
689
|
}
|
|
649
690
|
|
|
650
|
-
//sendData
|
|
651
|
-
async function sendData(type, data, cbProgress) {
|
|
652
|
-
|
|
653
|
-
//fun
|
|
654
|
-
let fun = pmConvertResolve(sendPkg)
|
|
655
|
-
|
|
656
|
-
//sendPkg
|
|
657
|
-
let r = await fun(type, data, cbProgress)
|
|
658
|
-
|
|
659
|
-
let n = 0
|
|
660
|
-
while (r.state === 'error') {
|
|
661
|
-
n += 1
|
|
662
|
-
if (n > retry) {
|
|
663
|
-
break
|
|
664
|
-
}
|
|
665
|
-
console.log(`retry n=${n}`)
|
|
666
|
-
r = await fun(type, data, cbProgress)
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (r.state === 'success') {
|
|
670
|
-
return r.msg
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
return Promise.reject(r.msg)
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
691
|
//calcHash
|
|
678
|
-
|
|
692
|
+
let calcHash = async(inp) => {
|
|
679
693
|
|
|
680
694
|
//bb
|
|
681
695
|
let bb = null
|
|
@@ -694,7 +708,7 @@ function WConverhpClient(opt) {
|
|
|
694
708
|
}
|
|
695
709
|
|
|
696
710
|
//sendDataSlice
|
|
697
|
-
|
|
711
|
+
let sendDataSlice = async(fileTotalName, bb, cbProgress) => {
|
|
698
712
|
|
|
699
713
|
//n
|
|
700
714
|
let n = 0
|
|
@@ -866,65 +880,29 @@ function WConverhpClient(opt) {
|
|
|
866
880
|
//chunk
|
|
867
881
|
let chunk = bb.slice(start, end)
|
|
868
882
|
|
|
869
|
-
//
|
|
870
|
-
let
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
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
|
|
883
|
+
//hd
|
|
884
|
+
let hd = { //用header傳key與value時, key不分大小寫, 故使用kebabCase
|
|
885
|
+
'chunk-index': i,
|
|
886
|
+
'chunk-total': chunkTotal,
|
|
887
|
+
'package-id': packageId,
|
|
897
888
|
}
|
|
898
889
|
|
|
899
|
-
//
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
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
|
|
890
|
+
//send slice
|
|
891
|
+
await send('slice', chunk, {
|
|
892
|
+
headers: hd,
|
|
893
|
+
dataType: 'blob',
|
|
894
|
+
cbProgress: (msg) => {
|
|
895
|
+
// console.log('cbProgress', msg)
|
|
896
|
+
// let perc = msg.prog
|
|
897
|
+
// let dir = msg.m
|
|
898
|
+
// if (dir === 'upload' && perc === 100) {
|
|
899
|
+
// }
|
|
920
900
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
}
|
|
901
|
+
})
|
|
902
|
+
// console.log('resSl', resSl)
|
|
925
903
|
|
|
926
|
-
//
|
|
927
|
-
|
|
904
|
+
//cbProgressSlice, 因其內有累加progCount, 實際代表是須成功傳輸後才能計算與回應外部進度, 故不能直接用於send的opt.cbProgress
|
|
905
|
+
cbProgressSlice()
|
|
928
906
|
|
|
929
907
|
}
|
|
930
908
|
|
|
@@ -1000,7 +978,7 @@ function WConverhpClient(opt) {
|
|
|
1000
978
|
}
|
|
1001
979
|
|
|
1002
980
|
//execute
|
|
1003
|
-
|
|
981
|
+
let execute = async(func, input, cbProgress) => {
|
|
1004
982
|
|
|
1005
983
|
//msg
|
|
1006
984
|
let msg = {
|
|
@@ -1010,10 +988,10 @@ function WConverhpClient(opt) {
|
|
|
1010
988
|
input,
|
|
1011
989
|
}
|
|
1012
990
|
|
|
1013
|
-
//
|
|
991
|
+
//sendPkg
|
|
1014
992
|
let state = ''
|
|
1015
993
|
let res = null
|
|
1016
|
-
await
|
|
994
|
+
await sendPkg('basic', msg, cbProgress)
|
|
1017
995
|
.then((msg) => {
|
|
1018
996
|
// console.log('msg', msg)
|
|
1019
997
|
|
|
@@ -1066,7 +1044,7 @@ function WConverhpClient(opt) {
|
|
|
1066
1044
|
}
|
|
1067
1045
|
|
|
1068
1046
|
//upload
|
|
1069
|
-
|
|
1047
|
+
let upload = (filename, input, cbProgress) => {
|
|
1070
1048
|
|
|
1071
1049
|
//bb
|
|
1072
1050
|
let bb = input
|
|
@@ -1075,7 +1053,7 @@ function WConverhpClient(opt) {
|
|
|
1075
1053
|
}
|
|
1076
1054
|
|
|
1077
1055
|
//downloadNodejs
|
|
1078
|
-
|
|
1056
|
+
let downloadNodejs = async(fileId, cbProgress, opt = {}) => {
|
|
1079
1057
|
|
|
1080
1058
|
//send download
|
|
1081
1059
|
let msg = { fileId }
|
|
@@ -1086,7 +1064,7 @@ function WConverhpClient(opt) {
|
|
|
1086
1064
|
}
|
|
1087
1065
|
|
|
1088
1066
|
//downloadBrowser
|
|
1089
|
-
|
|
1067
|
+
let downloadBrowser = async(fileId, cbProgress, opt = {}) => {
|
|
1090
1068
|
//交由瀏覽器下載與管理故無法監聽進度, 不使用cbProgress
|
|
1091
1069
|
|
|
1092
1070
|
//token
|
|
@@ -1123,7 +1101,7 @@ function WConverhpClient(opt) {
|
|
|
1123
1101
|
}
|
|
1124
1102
|
|
|
1125
1103
|
//download
|
|
1126
|
-
|
|
1104
|
+
let download = async(fileId, cbProgress, opt = {}) => {
|
|
1127
1105
|
if (env === 'browser') {
|
|
1128
1106
|
return downloadBrowser(fileId, cbProgress, opt)
|
|
1129
1107
|
}
|
|
@@ -1156,7 +1134,7 @@ export default WConverhpClient
|
|
|
1156
1134
|
<br class="clear">
|
|
1157
1135
|
|
|
1158
1136
|
<footer>
|
|
1159
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
1137
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1160
1138
|
</footer>
|
|
1161
1139
|
|
|
1162
1140
|
<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
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54: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>
|
|
@@ -495,7 +495,7 @@ function WConverhpServer(opt = {}) {
|
|
|
495
495
|
|
|
496
496
|
//apiMain
|
|
497
497
|
let apiMain = {
|
|
498
|
-
path: `/${apiName}`,
|
|
498
|
+
path: `/${apiName}/main`,
|
|
499
499
|
method: 'POST',
|
|
500
500
|
options: {
|
|
501
501
|
payload: {
|
|
@@ -651,7 +651,7 @@ function WConverhpServer(opt = {}) {
|
|
|
651
651
|
|
|
652
652
|
//apiUploadCheck
|
|
653
653
|
let apiUploadCheck = {
|
|
654
|
-
path: `/${apiName}ulctr`,
|
|
654
|
+
path: `/${apiName}/ulctr`,
|
|
655
655
|
method: 'POST',
|
|
656
656
|
options: {
|
|
657
657
|
payload: {
|
|
@@ -869,7 +869,7 @@ function WConverhpServer(opt = {}) {
|
|
|
869
869
|
|
|
870
870
|
//apiUploadSlice
|
|
871
871
|
let apiUploadSlice = {
|
|
872
|
-
path: `/${apiName}slc`,
|
|
872
|
+
path: `/${apiName}/slc`,
|
|
873
873
|
method: 'POST',
|
|
874
874
|
options: {
|
|
875
875
|
payload: {
|
|
@@ -1007,7 +1007,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1007
1007
|
// console.log('u8aOut', u8aOut)
|
|
1008
1008
|
|
|
1009
1009
|
// //測試失敗重傳
|
|
1010
|
-
// if (Math.random() < 0.
|
|
1010
|
+
// if (Math.random() < 0.6) {
|
|
1011
1011
|
// out = {
|
|
1012
1012
|
// error: 'force error'
|
|
1013
1013
|
// }
|
|
@@ -1023,7 +1023,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1023
1023
|
|
|
1024
1024
|
//apiDownloadGetFilename
|
|
1025
1025
|
let apiDownloadGetFilename = {
|
|
1026
|
-
path: `/${apiName}dwgfn`,
|
|
1026
|
+
path: `/${apiName}/dwgfn`,
|
|
1027
1027
|
method: 'POST',
|
|
1028
1028
|
options: {
|
|
1029
1029
|
payload: {
|
|
@@ -1145,7 +1145,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1145
1145
|
|
|
1146
1146
|
//apiDownloadGetFile
|
|
1147
1147
|
let apiDownloadGetFile = {
|
|
1148
|
-
path: `/${apiName}dwgf`,
|
|
1148
|
+
path: `/${apiName}/dwgf`,
|
|
1149
1149
|
method: 'GET',
|
|
1150
1150
|
options: {
|
|
1151
1151
|
timeout: {
|
|
@@ -1269,7 +1269,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1269
1269
|
|
|
1270
1270
|
//apiDownload
|
|
1271
1271
|
let apiDownload = {
|
|
1272
|
-
path: `/${apiName}dw`,
|
|
1272
|
+
path: `/${apiName}/dw`,
|
|
1273
1273
|
method: 'POST',
|
|
1274
1274
|
options: {
|
|
1275
1275
|
payload: {
|
|
@@ -1485,7 +1485,7 @@ export default WConverhpServer
|
|
|
1485
1485
|
<br class="clear">
|
|
1486
1486
|
|
|
1487
1487
|
<footer>
|
|
1488
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
1488
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1489
1489
|
</footer>
|
|
1490
1490
|
|
|
1491
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
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54: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>
|