w-converhp 2.0.47 → 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 +1 -1
- package/docs/WConverhpClient.html +2 -2
- package/docs/WConverhpClient.mjs.html +177 -196
- 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 +176 -195
- package/src/WConverhpServer.mjs +7 -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
|
|
|
@@ -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,22 +208,22 @@ function WConverhpClient(opt) {
|
|
|
206
208
|
//urlUse
|
|
207
209
|
let urlUse = ''
|
|
208
210
|
if (type === 'basic') {
|
|
209
|
-
urlUse = `${url}/main`
|
|
211
|
+
urlUse = `${url}/main`
|
|
210
212
|
}
|
|
211
213
|
else if (type === 'upload-controller') {
|
|
212
|
-
urlUse = `${url}/ulctr`
|
|
214
|
+
urlUse = `${url}/ulctr`
|
|
213
215
|
}
|
|
214
216
|
else if (type === 'slice') {
|
|
215
|
-
urlUse = `${url}/slc`
|
|
217
|
+
urlUse = `${url}/slc`
|
|
216
218
|
}
|
|
217
219
|
else if (type === 'download-get-filename') {
|
|
218
|
-
urlUse = `${url}/dwgfn`
|
|
220
|
+
urlUse = `${url}/dwgfn`
|
|
219
221
|
}
|
|
220
222
|
else if (type === 'download-get') {
|
|
221
|
-
urlUse = `${url}/dwgf`
|
|
223
|
+
urlUse = `${url}/dwgf`
|
|
222
224
|
}
|
|
223
225
|
else if (type === 'download') {
|
|
224
|
-
urlUse = `${url}/dw`
|
|
226
|
+
urlUse = `${url}/dw`
|
|
225
227
|
}
|
|
226
228
|
else {
|
|
227
229
|
throw new Error(`invalid type[${type}]`)
|
|
@@ -231,7 +233,7 @@ function WConverhpClient(opt) {
|
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
//res2u8arr
|
|
234
|
-
|
|
236
|
+
let res2u8arr = async(bb) => {
|
|
235
237
|
//blob(in browser) or buffer(in nodejs) to u8a
|
|
236
238
|
let u8a
|
|
237
239
|
if (env === 'browser') {
|
|
@@ -244,7 +246,7 @@ function WConverhpClient(opt) {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
//u8arr2bb
|
|
247
|
-
|
|
249
|
+
let u8arr2bb = (u8a) => {
|
|
248
250
|
//u8a to blob(in browser) or buffer(in nodejs)
|
|
249
251
|
let bb
|
|
250
252
|
if (env === 'browser') {
|
|
@@ -257,7 +259,7 @@ function WConverhpClient(opt) {
|
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
//send
|
|
260
|
-
|
|
262
|
+
let send = async(type, pkg, opt = {}) => {
|
|
261
263
|
|
|
262
264
|
//headers
|
|
263
265
|
let headers = get(opt, 'headers')
|
|
@@ -364,54 +366,6 @@ function WConverhpClient(opt) {
|
|
|
364
366
|
token = await token
|
|
365
367
|
}
|
|
366
368
|
|
|
367
|
-
//s
|
|
368
|
-
let s = {
|
|
369
|
-
method: 'POST',
|
|
370
|
-
url: urlUse,
|
|
371
|
-
data: dd,
|
|
372
|
-
headers: {
|
|
373
|
-
Authorization: `${tokenType} ${token}`,
|
|
374
|
-
...ct,
|
|
375
|
-
...headers,
|
|
376
|
-
},
|
|
377
|
-
timeout: 60 * 60 * 1000, //1hr
|
|
378
|
-
maxContentLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
379
|
-
maxBodyLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
|
|
380
|
-
responseType: rt,
|
|
381
|
-
onUploadProgress: function(ev) {
|
|
382
|
-
//console.log('onUploadProgress', ev)
|
|
383
|
-
|
|
384
|
-
//r
|
|
385
|
-
let r = 0
|
|
386
|
-
let loaded = ev.loaded
|
|
387
|
-
let total = ev.total
|
|
388
|
-
if (ispint(total)) {
|
|
389
|
-
r = (loaded * 100) / total
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
//cbProgress
|
|
393
|
-
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
394
|
-
|
|
395
|
-
},
|
|
396
|
-
onDownloadProgress: function (ev) {
|
|
397
|
-
// console.log('onDownloadProgress', ev)
|
|
398
|
-
|
|
399
|
-
//r
|
|
400
|
-
let r = 0
|
|
401
|
-
let loaded = ev.loaded
|
|
402
|
-
// let total = ev.srcElement.getResponseHeader('Content-length') //若需要得知下載進度, 需於伺服器回傳時提供Content-length
|
|
403
|
-
let total = ev.total
|
|
404
|
-
if (ispint(total)) {
|
|
405
|
-
r = (loaded * 100) / total
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
//cbProgress
|
|
409
|
-
cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
|
|
410
|
-
|
|
411
|
-
},
|
|
412
|
-
}
|
|
413
|
-
// console.log('s', s)
|
|
414
|
-
|
|
415
369
|
//getFilenameByHeader
|
|
416
370
|
let getFilenameByHeader = (contentDisposition) => {
|
|
417
371
|
let fn = 'unknow'
|
|
@@ -425,7 +379,7 @@ function WConverhpClient(opt) {
|
|
|
425
379
|
}
|
|
426
380
|
|
|
427
381
|
//downloadStream
|
|
428
|
-
let downloadStream = async
|
|
382
|
+
let downloadStream = async(res) => {
|
|
429
383
|
// console.log('res.headers', res.headers)
|
|
430
384
|
|
|
431
385
|
//pm
|
|
@@ -523,61 +477,151 @@ function WConverhpClient(opt) {
|
|
|
523
477
|
return pm
|
|
524
478
|
}
|
|
525
479
|
|
|
526
|
-
//
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
|
541
503
|
}
|
|
542
504
|
|
|
543
|
-
//
|
|
544
|
-
|
|
545
|
-
// console.log('bb', bb)
|
|
505
|
+
//cbProgress
|
|
506
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
546
507
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
// console.log('
|
|
508
|
+
},
|
|
509
|
+
onDownloadProgress: function (ev) {
|
|
510
|
+
// console.log('onDownloadProgress', ev)
|
|
550
511
|
|
|
551
|
-
//
|
|
552
|
-
let
|
|
553
|
-
|
|
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
|
|
554
591
|
|
|
555
592
|
//check
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
eeEmit('error', `data is not an effective object`)
|
|
559
|
-
pm.reject(`data is not an effective object`)
|
|
560
|
-
return
|
|
593
|
+
if (n > retry) {
|
|
594
|
+
break
|
|
561
595
|
}
|
|
562
596
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
else if (haskey(data, 'error')) {
|
|
568
|
-
eeEmit('error', data.error)
|
|
569
|
-
pm.reject(data.error)
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
// console.log('invalid data', data)
|
|
573
|
-
eeEmit('error', `invalid data`)
|
|
574
|
-
pm.reject(`invalid data`)
|
|
575
|
-
}
|
|
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)
|
|
576
601
|
|
|
602
|
+
//retry
|
|
603
|
+
console.log(`retry n=${n}...`)
|
|
604
|
+
r = await fun(s)
|
|
605
|
+
// console.log(`retry n=${n} done`)
|
|
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)
|
|
577
621
|
})
|
|
578
|
-
.catch(async
|
|
622
|
+
.catch(async(res) => {
|
|
579
623
|
// console.log('axios catch', res.toJSON())
|
|
580
|
-
//Network Error除可能是網路斷線之外, 可能被瀏覽器外掛封鎖阻擋,
|
|
624
|
+
//Network Error除可能是網路斷線之外, 可能被瀏覽器外掛封鎖阻擋, 亦可能因硬碟空間不足無法下載被瀏覽器拒絕
|
|
581
625
|
|
|
582
626
|
//data
|
|
583
627
|
let data = null
|
|
@@ -619,7 +663,7 @@ function WConverhpClient(opt) {
|
|
|
619
663
|
}
|
|
620
664
|
|
|
621
665
|
//sendPkg
|
|
622
|
-
|
|
666
|
+
let sendPkg = async(type, data, cbProgress) => {
|
|
623
667
|
|
|
624
668
|
//bb
|
|
625
669
|
let bb = null
|
|
@@ -644,35 +688,8 @@ function WConverhpClient(opt) {
|
|
|
644
688
|
return res
|
|
645
689
|
}
|
|
646
690
|
|
|
647
|
-
//sendData
|
|
648
|
-
async function sendData(type, data, cbProgress) {
|
|
649
|
-
|
|
650
|
-
//fun
|
|
651
|
-
let fun = pmConvertResolve(sendPkg)
|
|
652
|
-
|
|
653
|
-
//sendPkg
|
|
654
|
-
let r = await fun(type, data, cbProgress)
|
|
655
|
-
|
|
656
|
-
let n = 0
|
|
657
|
-
while (r.state === 'error') {
|
|
658
|
-
n += 1
|
|
659
|
-
if (n > retry) {
|
|
660
|
-
break
|
|
661
|
-
}
|
|
662
|
-
console.log(`retry n=${n}`)
|
|
663
|
-
r = await fun(type, data, cbProgress)
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
if (r.state === 'success') {
|
|
667
|
-
return r.msg
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
return Promise.reject(r.msg)
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
691
|
//calcHash
|
|
675
|
-
|
|
692
|
+
let calcHash = async(inp) => {
|
|
676
693
|
|
|
677
694
|
//bb
|
|
678
695
|
let bb = null
|
|
@@ -691,7 +708,7 @@ function WConverhpClient(opt) {
|
|
|
691
708
|
}
|
|
692
709
|
|
|
693
710
|
//sendDataSlice
|
|
694
|
-
|
|
711
|
+
let sendDataSlice = async(fileTotalName, bb, cbProgress) => {
|
|
695
712
|
|
|
696
713
|
//n
|
|
697
714
|
let n = 0
|
|
@@ -863,65 +880,29 @@ function WConverhpClient(opt) {
|
|
|
863
880
|
//chunk
|
|
864
881
|
let chunk = bb.slice(start, end)
|
|
865
882
|
|
|
866
|
-
//
|
|
867
|
-
let
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
'chunk-index': i,
|
|
872
|
-
'chunk-total': chunkTotal,
|
|
873
|
-
'package-id': packageId,
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
//send slice
|
|
877
|
-
let resSl = await send('slice', chunk, {
|
|
878
|
-
headers: hd,
|
|
879
|
-
dataType: 'blob',
|
|
880
|
-
cbProgress: (msg) => {
|
|
881
|
-
// console.log('cbProgress', msg)
|
|
882
|
-
// let perc = msg.prog
|
|
883
|
-
// let dir = msg.m
|
|
884
|
-
// if (dir === 'upload' && perc === 100) {
|
|
885
|
-
// }
|
|
886
|
-
}
|
|
887
|
-
})
|
|
888
|
-
// console.log('resSl', resSl)
|
|
889
|
-
|
|
890
|
-
//cbProgressSlice, 因其內有累加progCount, 實際代表是須成功傳輸後才能計算與回應外部進度, 故不能直接用於send的opt.cbProgress
|
|
891
|
-
cbProgressSlice()
|
|
892
|
-
|
|
893
|
-
return resSl
|
|
883
|
+
//hd
|
|
884
|
+
let hd = { //用header傳key與value時, key不分大小寫, 故使用kebabCase
|
|
885
|
+
'chunk-index': i,
|
|
886
|
+
'chunk-total': chunkTotal,
|
|
887
|
+
'package-id': packageId,
|
|
894
888
|
}
|
|
895
889
|
|
|
896
|
-
//
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
while (r.state === 'error') {
|
|
907
|
-
n += 1
|
|
908
|
-
if (n > retry) {
|
|
909
|
-
break
|
|
910
|
-
}
|
|
911
|
-
console.log(`retry n=${n}`)
|
|
912
|
-
r = await fun()
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
if (r.state === 'success') {
|
|
916
|
-
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
|
+
// }
|
|
917
900
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
}
|
|
901
|
+
})
|
|
902
|
+
// console.log('resSl', resSl)
|
|
922
903
|
|
|
923
|
-
//
|
|
924
|
-
|
|
904
|
+
//cbProgressSlice, 因其內有累加progCount, 實際代表是須成功傳輸後才能計算與回應外部進度, 故不能直接用於send的opt.cbProgress
|
|
905
|
+
cbProgressSlice()
|
|
925
906
|
|
|
926
907
|
}
|
|
927
908
|
|
|
@@ -997,7 +978,7 @@ function WConverhpClient(opt) {
|
|
|
997
978
|
}
|
|
998
979
|
|
|
999
980
|
//execute
|
|
1000
|
-
|
|
981
|
+
let execute = async(func, input, cbProgress) => {
|
|
1001
982
|
|
|
1002
983
|
//msg
|
|
1003
984
|
let msg = {
|
|
@@ -1007,10 +988,10 @@ function WConverhpClient(opt) {
|
|
|
1007
988
|
input,
|
|
1008
989
|
}
|
|
1009
990
|
|
|
1010
|
-
//
|
|
991
|
+
//sendPkg
|
|
1011
992
|
let state = ''
|
|
1012
993
|
let res = null
|
|
1013
|
-
await
|
|
994
|
+
await sendPkg('basic', msg, cbProgress)
|
|
1014
995
|
.then((msg) => {
|
|
1015
996
|
// console.log('msg', msg)
|
|
1016
997
|
|
|
@@ -1063,7 +1044,7 @@ function WConverhpClient(opt) {
|
|
|
1063
1044
|
}
|
|
1064
1045
|
|
|
1065
1046
|
//upload
|
|
1066
|
-
|
|
1047
|
+
let upload = (filename, input, cbProgress) => {
|
|
1067
1048
|
|
|
1068
1049
|
//bb
|
|
1069
1050
|
let bb = input
|
|
@@ -1072,7 +1053,7 @@ function WConverhpClient(opt) {
|
|
|
1072
1053
|
}
|
|
1073
1054
|
|
|
1074
1055
|
//downloadNodejs
|
|
1075
|
-
|
|
1056
|
+
let downloadNodejs = async(fileId, cbProgress, opt = {}) => {
|
|
1076
1057
|
|
|
1077
1058
|
//send download
|
|
1078
1059
|
let msg = { fileId }
|
|
@@ -1083,7 +1064,7 @@ function WConverhpClient(opt) {
|
|
|
1083
1064
|
}
|
|
1084
1065
|
|
|
1085
1066
|
//downloadBrowser
|
|
1086
|
-
|
|
1067
|
+
let downloadBrowser = async(fileId, cbProgress, opt = {}) => {
|
|
1087
1068
|
//交由瀏覽器下載與管理故無法監聽進度, 不使用cbProgress
|
|
1088
1069
|
|
|
1089
1070
|
//token
|
|
@@ -1120,7 +1101,7 @@ function WConverhpClient(opt) {
|
|
|
1120
1101
|
}
|
|
1121
1102
|
|
|
1122
1103
|
//download
|
|
1123
|
-
|
|
1104
|
+
let download = async(fileId, cbProgress, opt = {}) => {
|
|
1124
1105
|
if (env === 'browser') {
|
|
1125
1106
|
return downloadBrowser(fileId, cbProgress, opt)
|
|
1126
1107
|
}
|
|
@@ -1153,7 +1134,7 @@ export default WConverhpClient
|
|
|
1153
1134
|
<br class="clear">
|
|
1154
1135
|
|
|
1155
1136
|
<footer>
|
|
1156
|
-
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.
|
|
1157
1138
|
</footer>
|
|
1158
1139
|
|
|
1159
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}/main`,
|
|
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>
|