w-converhp 2.0.3 → 2.0.4
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 +5 -5
- 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 +13 -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/scla.mjs +1 -1
- package/sclb.mjs +1 -1
- package/sclc.mjs +1 -1
- package/src/WConverhpClient.mjs +12 -8
- package/srv.mjs +7 -1
- package/web.html +2 -2
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
<h5 class="h5-examples">Example</h5>
|
|
129
129
|
|
|
130
|
-
<pre class="prettyprint"><code>import WConverhpClient from 'w-converhp/dist/w-converhp-client.umd.js'
|
|
131
130
|
FormData,
|
|
132
131
|
url: 'http://localhost:8080',
|
|
133
132
|
apiName: 'api',
|
|
134
133
|
//p
|
|
135
134
|
let p = {
|
|
136
135
|
a: 12,
|
|
137
136
|
b: 34.56,
|
|
138
137
|
c: 'test中文',
|
|
139
138
|
d: {
|
|
140
139
|
name,
|
|
141
140
|
u8a,
|
|
142
141
|
},
|
|
143
142
|
}
|
|
144
143
|
console.log('p', p)
|
|
145
144
|
//execute
|
|
146
145
|
await wo.execute('add', { p },
|
|
147
146
|
function (prog, p, m) {
|
|
148
147
|
console.log('client web: execute: prog', prog, p, m)
|
|
149
148
|
})
|
|
150
149
|
.then(function(r) {
|
|
151
150
|
console.log('client web: execute: add', r)
|
|
152
151
|
console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
153
152
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
154
153
|
})
|
|
155
154
|
.catch(function (err) {
|
|
156
155
|
console.log('client web: execute: catch', err)
|
|
157
156
|
})
|
|
158
157
|
let core = async() => {
|
|
159
158
|
//u8a
|
|
160
159
|
let u8a = new Uint8Array([66, 97, 115])
|
|
161
160
|
console.log('executeWithU8a u8a', u8a)
|
|
162
161
|
//execute
|
|
163
162
|
await execute('zdata.b1', u8a)
|
|
164
163
|
}
|
|
165
164
|
core()
|
|
166
165
|
let core = async() => {
|
|
167
166
|
//u8a
|
|
168
167
|
let u8a = new Uint8Array(fs.readFileSync('../_data/10mb.7z'))
|
|
169
168
|
console.log('executeWithFile u8a', u8a)
|
|
170
169
|
//execute
|
|
171
170
|
await execute('10mb.7z', u8a)
|
|
172
171
|
}
|
|
173
172
|
core()
|
|
174
173
|
let core = async() => {
|
|
175
174
|
//u8a
|
|
176
175
|
let u8a = new Uint8Array(fs.readFileSync('../_data/1000mb.7z'))
|
|
177
176
|
console.log('u8a.length', u8a.length)
|
|
178
177
|
console.log('uploadLargeFile u8a', u8a)
|
|
179
178
|
await wo.upload('1000mb.7z', u8a,
|
|
180
179
|
function (prog, p, m) {
|
|
181
180
|
console.log('client web: upload: prog', prog, p, m)
|
|
182
181
|
})
|
|
183
182
|
.then(function(res) {
|
|
184
183
|
console.log('client web: upload: then', res)
|
|
185
184
|
})
|
|
186
185
|
.catch(function (err) {
|
|
187
186
|
console.log('client web: upload: catch', err)
|
|
188
187
|
})
|
|
189
188
|
}
|
|
190
189
|
core()
|
|
190
|
+
<pre class="prettyprint"><code>import WConverhpClient from 'w-converhp/dist/w-converhp-client.umd.js'
|
|
191
191
|
FormData,
|
|
192
192
|
url: 'http://localhost:8080',
|
|
193
193
|
apiName: 'api',
|
|
194
194
|
//p
|
|
195
195
|
let p = {
|
|
196
196
|
a: 12,
|
|
197
197
|
b: 34.56,
|
|
198
198
|
c: 'test中文',
|
|
199
199
|
d: {
|
|
200
200
|
name,
|
|
201
201
|
u8a,
|
|
202
202
|
},
|
|
203
203
|
}
|
|
204
204
|
console.log('p', p)
|
|
205
205
|
//execute
|
|
206
206
|
await wo.execute('add', { p },
|
|
207
207
|
function ({ prog, p, m }) {
|
|
208
208
|
console.log('client web: execute: prog', prog, p, m)
|
|
209
209
|
})
|
|
210
210
|
.then(function(r) {
|
|
211
211
|
console.log('client web: execute: add', r)
|
|
212
212
|
console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
213
213
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
214
214
|
})
|
|
215
215
|
.catch(function (err) {
|
|
216
216
|
console.log('client web: execute: catch', err)
|
|
217
217
|
})
|
|
218
218
|
let core = async() => {
|
|
219
219
|
//u8a
|
|
220
220
|
let u8a = new Uint8Array([66, 97, 115])
|
|
221
221
|
console.log('executeWithU8a u8a', u8a)
|
|
222
222
|
//execute
|
|
223
223
|
await execute('zdata.b1', u8a)
|
|
224
224
|
}
|
|
225
225
|
core()
|
|
226
226
|
let core = async() => {
|
|
227
227
|
//u8a
|
|
228
228
|
let u8a = new Uint8Array(fs.readFileSync('../_data/10mb.7z'))
|
|
229
229
|
console.log('executeWithFile u8a', u8a)
|
|
230
230
|
//execute
|
|
231
231
|
await execute('10mb.7z', u8a)
|
|
232
232
|
}
|
|
233
233
|
core()
|
|
234
234
|
let core = async() => {
|
|
235
235
|
//u8a
|
|
236
236
|
let u8a = new Uint8Array(fs.readFileSync('../_data/1000mb.7z'))
|
|
237
237
|
console.log('u8a.length', u8a.length)
|
|
238
238
|
console.log('uploadLargeFile u8a', u8a)
|
|
239
239
|
await wo.upload('1000mb.7z', u8a,
|
|
240
240
|
function ({ prog, p, m }) {
|
|
241
241
|
console.log('client web: upload: prog', prog, p, m)
|
|
242
242
|
})
|
|
243
243
|
.then(function(res) {
|
|
244
244
|
console.log('client web: upload: then', res)
|
|
245
245
|
})
|
|
246
246
|
.catch(function (err) {
|
|
247
247
|
console.log('client web: upload: catch', err)
|
|
248
248
|
})
|
|
249
249
|
}
|
|
250
250
|
core()
|
|
251
251
|
|
|
252
252
|
|
|
253
253
|
|
|
@@ -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 Sun Mar 30 2025
|
|
532
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
533
533
|
</footer>
|
|
534
534
|
|
|
535
535
|
<script>prettyPrint();</script>
|
|
@@ -109,7 +109,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
|
|
|
109
109
|
*
|
|
110
110
|
* //execute
|
|
111
111
|
* await wo.execute('add', { p },
|
|
112
|
-
* function (prog, p, m) {
|
|
112
|
+
* function ({ prog, p, m }) {
|
|
113
113
|
* console.log('client web: execute: prog', prog, p, m)
|
|
114
114
|
* })
|
|
115
115
|
* .then(function(r) {
|
|
@@ -162,7 +162,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
|
|
|
162
162
|
* console.log('uploadLargeFile u8a', u8a)
|
|
163
163
|
*
|
|
164
164
|
* await wo.upload('1000mb.7z', u8a,
|
|
165
|
-
* function (prog, p, m) {
|
|
165
|
+
* function ({ prog, p, m }) {
|
|
166
166
|
* console.log('client web: upload: prog', prog, p, m)
|
|
167
167
|
* })
|
|
168
168
|
* .then(function(res) {
|
|
@@ -410,7 +410,7 @@ function WConverhpClient(opt) {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
//cbProgress
|
|
413
|
-
cbProgress(Math.floor(r), loaded, 'upload')
|
|
413
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
414
414
|
|
|
415
415
|
},
|
|
416
416
|
onDownloadProgress: function (ev) {
|
|
@@ -426,7 +426,7 @@ function WConverhpClient(opt) {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
//cbProgress
|
|
429
|
-
cbProgress(Math.floor(r), loaded, 'download')
|
|
429
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
|
|
430
430
|
|
|
431
431
|
},
|
|
432
432
|
}
|
|
@@ -608,20 +608,24 @@ function WConverhpClient(opt) {
|
|
|
608
608
|
// let progWeightMerge = 0.01 //合併階段進度使用1%
|
|
609
609
|
|
|
610
610
|
//cbProgressSlice
|
|
611
|
-
let cbProgressSlice = (
|
|
611
|
+
let cbProgressSlice = (msg) => {
|
|
612
|
+
let perc = msg.prog
|
|
613
|
+
let dir = msg.m
|
|
612
614
|
if (dir === 'upload' && perc === 100) {
|
|
613
615
|
progCount++
|
|
614
616
|
let r = progCount / chunkTotal
|
|
615
617
|
let prog = r * progWeightSlice * 100
|
|
616
618
|
let psiz = r * n
|
|
617
|
-
cbProgress(prog, psiz, 'upload')
|
|
619
|
+
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
618
620
|
}
|
|
619
621
|
}
|
|
620
622
|
|
|
621
623
|
//cbProgressMerge
|
|
622
|
-
let cbProgressMerge = (
|
|
624
|
+
let cbProgressMerge = (msg) => {
|
|
625
|
+
let perc = msg.prog
|
|
626
|
+
let dir = msg.m
|
|
623
627
|
if (dir === 'download' && perc === 100) {
|
|
624
|
-
cbProgress(100, n, 'upload')
|
|
628
|
+
cbProgress({ prog: 100, p: n, m: 'upload' })
|
|
625
629
|
}
|
|
626
630
|
}
|
|
627
631
|
|
|
@@ -762,7 +766,7 @@ export default WConverhpClient
|
|
|
762
766
|
<br class="clear">
|
|
763
767
|
|
|
764
768
|
<footer>
|
|
765
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025
|
|
769
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
766
770
|
</footer>
|
|
767
771
|
|
|
768
772
|
<script>prettyPrint();</script>
|
|
@@ -709,7 +709,7 @@
|
|
|
709
709
|
<br class="clear">
|
|
710
710
|
|
|
711
711
|
<footer>
|
|
712
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025
|
|
712
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
713
713
|
</footer>
|
|
714
714
|
|
|
715
715
|
<script>prettyPrint();</script>
|
|
@@ -911,7 +911,7 @@ export default WConverhpServer
|
|
|
911
911
|
<br class="clear">
|
|
912
912
|
|
|
913
913
|
<footer>
|
|
914
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025
|
|
914
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
915
915
|
</footer>
|
|
916
916
|
|
|
917
917
|
<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 Sun Mar 30 2025
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 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/scla.mjs
CHANGED
package/sclb.mjs
CHANGED
package/sclc.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function uploadLargeFile() {
|
|
|
29
29
|
console.log('uploadLargeFile u8a', u8a)
|
|
30
30
|
|
|
31
31
|
await wo.upload('1000mb.7z', u8a,
|
|
32
|
-
function (prog, p, m) {
|
|
32
|
+
function ({ prog, p, m }) {
|
|
33
33
|
// console.log('client web: upload: prog', prog, p, m)
|
|
34
34
|
if (m === 'upload') {
|
|
35
35
|
console.log('client web: upload: prog', prog)
|
package/src/WConverhpClient.mjs
CHANGED
|
@@ -62,7 +62,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
|
|
|
62
62
|
*
|
|
63
63
|
* //execute
|
|
64
64
|
* await wo.execute('add', { p },
|
|
65
|
-
* function (prog, p, m) {
|
|
65
|
+
* function ({ prog, p, m }) {
|
|
66
66
|
* console.log('client web: execute: prog', prog, p, m)
|
|
67
67
|
* })
|
|
68
68
|
* .then(function(r) {
|
|
@@ -115,7 +115,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
|
|
|
115
115
|
* console.log('uploadLargeFile u8a', u8a)
|
|
116
116
|
*
|
|
117
117
|
* await wo.upload('1000mb.7z', u8a,
|
|
118
|
-
* function (prog, p, m) {
|
|
118
|
+
* function ({ prog, p, m }) {
|
|
119
119
|
* console.log('client web: upload: prog', prog, p, m)
|
|
120
120
|
* })
|
|
121
121
|
* .then(function(res) {
|
|
@@ -363,7 +363,7 @@ function WConverhpClient(opt) {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
//cbProgress
|
|
366
|
-
cbProgress(Math.floor(r), loaded, 'upload')
|
|
366
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
|
|
367
367
|
|
|
368
368
|
},
|
|
369
369
|
onDownloadProgress: function (ev) {
|
|
@@ -379,7 +379,7 @@ function WConverhpClient(opt) {
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
//cbProgress
|
|
382
|
-
cbProgress(Math.floor(r), loaded, 'download')
|
|
382
|
+
cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
|
|
383
383
|
|
|
384
384
|
},
|
|
385
385
|
}
|
|
@@ -561,20 +561,24 @@ function WConverhpClient(opt) {
|
|
|
561
561
|
// let progWeightMerge = 0.01 //合併階段進度使用1%
|
|
562
562
|
|
|
563
563
|
//cbProgressSlice
|
|
564
|
-
let cbProgressSlice = (
|
|
564
|
+
let cbProgressSlice = (msg) => {
|
|
565
|
+
let perc = msg.prog
|
|
566
|
+
let dir = msg.m
|
|
565
567
|
if (dir === 'upload' && perc === 100) {
|
|
566
568
|
progCount++
|
|
567
569
|
let r = progCount / chunkTotal
|
|
568
570
|
let prog = r * progWeightSlice * 100
|
|
569
571
|
let psiz = r * n
|
|
570
|
-
cbProgress(prog, psiz, 'upload')
|
|
572
|
+
cbProgress({ prog, p: psiz, m: 'upload' })
|
|
571
573
|
}
|
|
572
574
|
}
|
|
573
575
|
|
|
574
576
|
//cbProgressMerge
|
|
575
|
-
let cbProgressMerge = (
|
|
577
|
+
let cbProgressMerge = (msg) => {
|
|
578
|
+
let perc = msg.prog
|
|
579
|
+
let dir = msg.m
|
|
576
580
|
if (dir === 'download' && perc === 100) {
|
|
577
|
-
cbProgress(100, n, 'upload')
|
|
581
|
+
cbProgress({ prog: 100, p: n, m: 'upload' })
|
|
578
582
|
}
|
|
579
583
|
}
|
|
580
584
|
|
package/srv.mjs
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import _ from 'lodash-es'
|
|
3
|
+
import w from 'wsemi'
|
|
3
4
|
import WConverhpServer from './src/WConverhpServer.mjs'
|
|
4
5
|
|
|
5
6
|
let opt = {
|
|
6
7
|
port: 8080,
|
|
7
8
|
apiName: 'api',
|
|
8
9
|
pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
|
|
9
|
-
funCheck: ({ apiType, authorization, headers, query }) => {
|
|
10
|
+
funCheck: async ({ apiType, authorization, headers, query }) => {
|
|
10
11
|
console.log('funCheck', `apiType[${apiType}]`, `authorization[${authorization}]`)
|
|
12
|
+
let token = w.strdelleft(authorization, 7) //刪除Bearer
|
|
13
|
+
if (!w.isestr(token)) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
// await w.delay(3000)
|
|
11
17
|
return true
|
|
12
18
|
},
|
|
13
19
|
}
|
package/web.html
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
//execute
|
|
52
52
|
await wo.execute('add', { p },
|
|
53
|
-
function (prog, p, m) {
|
|
53
|
+
function ({ prog, p, m }) {
|
|
54
54
|
console.log('client web: execute: prog', prog, p, m)
|
|
55
55
|
})
|
|
56
56
|
.then(function(r) {
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
|
|
133
133
|
//upload
|
|
134
134
|
await wo.upload(file.name, file,
|
|
135
|
-
function (prog, p, m) {
|
|
135
|
+
function ({ prog, p, m }) {
|
|
136
136
|
console.log('client web: upload: prog', prog, p, m)
|
|
137
137
|
})
|
|
138
138
|
.then(function(res) {
|