w-converhp 2.0.13 → 2.0.15
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 +68 -99
- 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 +3 -3
- package/docs/WConverhpClient.mjs.html +104 -120
- package/docs/WConverhpServer.html +43 -3
- package/docs/WConverhpServer.mjs.html +349 -32
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/scld.mjs +5 -5
- package/src/WConverhpClient.mjs +103 -119
- package/src/WConverhpServer.mjs +348 -31
- package/srv.mjs +25 -2
- package/test/downloadLargeFile.test.mjs +12 -13
- package/test/executeWithFile.test.mjs +10 -12
- package/test/executeWithU8a.test.mjs +11 -13
- package/test/uploadLargeFile.test.mjs +10 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'assert'
|
|
2
2
|
import fs from 'fs'
|
|
3
|
-
|
|
3
|
+
import _ from 'lodash-es'
|
|
4
4
|
import w from 'wsemi'
|
|
5
5
|
import WConverhpServer from '../src/WConverhpServer.mjs'
|
|
6
6
|
import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
@@ -8,11 +8,11 @@ import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
|
8
8
|
|
|
9
9
|
describe('downloadLargeFile', function() {
|
|
10
10
|
|
|
11
|
-
let
|
|
11
|
+
let ms = []
|
|
12
12
|
|
|
13
13
|
let runServer = () => {
|
|
14
14
|
|
|
15
|
-
let ms = []
|
|
15
|
+
// let ms = []
|
|
16
16
|
|
|
17
17
|
let opt = {
|
|
18
18
|
port: 8083, //同時test故得要不同port
|
|
@@ -36,9 +36,8 @@ describe('downloadLargeFile', function() {
|
|
|
36
36
|
// console.log(`Server[port:${opt.port}]: download`, input)
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
|
-
ms.push({ '
|
|
39
|
+
ms.push({ 'server receive input': input })
|
|
40
40
|
// console.log('ms', ms)
|
|
41
|
-
msAll.push({ server: ms })
|
|
42
41
|
|
|
43
42
|
//fp
|
|
44
43
|
let fp = `./test/1mb.7z`
|
|
@@ -47,7 +46,7 @@ describe('downloadLargeFile', function() {
|
|
|
47
46
|
let streamRead = fs.createReadStream(fp) //createReadStream得指定使用test內檔案
|
|
48
47
|
|
|
49
48
|
//fileName
|
|
50
|
-
let fileName = `1mb.7z`
|
|
49
|
+
let fileName = `1mb.7z` //測試支援中文
|
|
51
50
|
|
|
52
51
|
//fileSize
|
|
53
52
|
let stats = fs.statSync(fp)
|
|
@@ -87,7 +86,7 @@ describe('downloadLargeFile', function() {
|
|
|
87
86
|
|
|
88
87
|
let runClient = () => {
|
|
89
88
|
|
|
90
|
-
let ms = []
|
|
89
|
+
// let ms = []
|
|
91
90
|
|
|
92
91
|
let opt = {
|
|
93
92
|
FormData,
|
|
@@ -108,6 +107,7 @@ describe('downloadLargeFile', function() {
|
|
|
108
107
|
function downloadLargeFile() {
|
|
109
108
|
let core = async() => {
|
|
110
109
|
|
|
110
|
+
ms.push({ 'client download input': 'id-for-file' })
|
|
111
111
|
await wo.download('id-for-file',
|
|
112
112
|
function ({ prog, p, m }) {
|
|
113
113
|
// console.log('client web: download: prog', prog, p, m)
|
|
@@ -123,7 +123,7 @@ describe('downloadLargeFile', function() {
|
|
|
123
123
|
|
|
124
124
|
//getFileName
|
|
125
125
|
res = w.getFileName(res)
|
|
126
|
-
ms.push({ 'download
|
|
126
|
+
ms.push({ 'client download done': res })
|
|
127
127
|
|
|
128
128
|
fs.unlinkSync(res) //測試完刪除臨時檔
|
|
129
129
|
|
|
@@ -133,7 +133,6 @@ describe('downloadLargeFile', function() {
|
|
|
133
133
|
})
|
|
134
134
|
|
|
135
135
|
// console.log('ms', ms)
|
|
136
|
-
msAll.push({ client: ms })
|
|
137
136
|
|
|
138
137
|
}
|
|
139
138
|
core()
|
|
@@ -148,14 +147,14 @@ describe('downloadLargeFile', function() {
|
|
|
148
147
|
runServer()
|
|
149
148
|
runClient()
|
|
150
149
|
setTimeout(() => {
|
|
151
|
-
// console.log('
|
|
152
|
-
// fs.writeFileSync('./test_downloadLargeFile.json', JSON.stringify(
|
|
153
|
-
pm.resolve(
|
|
150
|
+
// console.log('ms', ms)
|
|
151
|
+
// fs.writeFileSync('./test_downloadLargeFile.json', JSON.stringify(ms), 'utf8')
|
|
152
|
+
pm.resolve(ms)
|
|
154
153
|
}, 4000)
|
|
155
154
|
return pm
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
let res = `[{"
|
|
157
|
+
let res = `[{"client download input":"id-for-file"},{"server receive input":{"fileId":"id-for-file"}},{"client download done":"1mb.7z"}]`
|
|
159
158
|
it(`should return ${res} when test`, async function() {
|
|
160
159
|
let r = await run()
|
|
161
160
|
r = JSON.stringify(r)
|
|
@@ -8,11 +8,11 @@ import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
|
8
8
|
|
|
9
9
|
describe('executeWithFile', function() {
|
|
10
10
|
|
|
11
|
-
let
|
|
11
|
+
let ms = []
|
|
12
12
|
|
|
13
13
|
let runServer = () => {
|
|
14
14
|
|
|
15
|
-
let ms = []
|
|
15
|
+
// let ms = []
|
|
16
16
|
|
|
17
17
|
let opt = {
|
|
18
18
|
port: 8081, //同時test故得要不同port
|
|
@@ -44,7 +44,7 @@ describe('executeWithFile', function() {
|
|
|
44
44
|
// console.log('input.p.d.u8a', input.p.d.u8a)
|
|
45
45
|
let t = input.p.d.u8a
|
|
46
46
|
let ts = [t[0], t[1], t[2]]
|
|
47
|
-
ms.push({ 'input.p.d.u8a': ts })
|
|
47
|
+
ms.push({ 'server receive input.p.d.u8a': ts })
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
let r = {
|
|
@@ -80,7 +80,6 @@ describe('executeWithFile', function() {
|
|
|
80
80
|
|
|
81
81
|
setTimeout(() => {
|
|
82
82
|
// console.log('ms', JSON.stringify(ms))
|
|
83
|
-
msAll.push({ server: ms })
|
|
84
83
|
wo.stop()
|
|
85
84
|
}, 2000)
|
|
86
85
|
|
|
@@ -88,7 +87,7 @@ describe('executeWithFile', function() {
|
|
|
88
87
|
|
|
89
88
|
let runClient = () => {
|
|
90
89
|
|
|
91
|
-
let ms = []
|
|
90
|
+
// let ms = []
|
|
92
91
|
|
|
93
92
|
let opt = {
|
|
94
93
|
FormData,
|
|
@@ -121,7 +120,7 @@ describe('executeWithFile', function() {
|
|
|
121
120
|
// console.log('p', p)
|
|
122
121
|
let t = p.d.u8a
|
|
123
122
|
let ts = [t[0], t[1], t[2]]
|
|
124
|
-
ms.push({ 'execute input': ts })
|
|
123
|
+
ms.push({ 'client execute input': ts })
|
|
125
124
|
|
|
126
125
|
//execute
|
|
127
126
|
await wo.execute('add', { p },
|
|
@@ -139,7 +138,7 @@ describe('executeWithFile', function() {
|
|
|
139
138
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
140
139
|
let t = r._bin.u8a
|
|
141
140
|
let ts = [t[0], t[1], t[2]]
|
|
142
|
-
ms.push({ 'execute
|
|
141
|
+
ms.push({ 'client execute done': ts })
|
|
143
142
|
})
|
|
144
143
|
.catch(function () {
|
|
145
144
|
// console.log('client web: execute: catch', err)
|
|
@@ -158,7 +157,6 @@ describe('executeWithFile', function() {
|
|
|
158
157
|
await execute('1mb.7z', u8a)
|
|
159
158
|
|
|
160
159
|
// console.log('ms', ms)
|
|
161
|
-
msAll.push({ client: ms })
|
|
162
160
|
|
|
163
161
|
}
|
|
164
162
|
core()
|
|
@@ -173,14 +171,14 @@ describe('executeWithFile', function() {
|
|
|
173
171
|
runServer()
|
|
174
172
|
runClient()
|
|
175
173
|
setTimeout(() => {
|
|
176
|
-
// console.log('
|
|
177
|
-
// fs.writeFileSync('./test_executeWithFile.json', JSON.stringify(
|
|
178
|
-
pm.resolve(
|
|
174
|
+
// console.log('ms', JSON.stringify(ms))
|
|
175
|
+
// fs.writeFileSync('./test_executeWithFile.json', JSON.stringify(ms), 'utf8')
|
|
176
|
+
pm.resolve(ms)
|
|
179
177
|
}, 4000)
|
|
180
178
|
return pm
|
|
181
179
|
}
|
|
182
180
|
|
|
183
|
-
let res = `[{"client
|
|
181
|
+
let res = `[{"client execute input":[55,122,188]},{"server receive input.p.d.u8a":[55,122,188]},{"client execute done":[52,66,97]}]`
|
|
184
182
|
it(`should return ${res} when test`, async function() {
|
|
185
183
|
let r = await run()
|
|
186
184
|
r = JSON.stringify(r)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from 'assert'
|
|
2
|
-
|
|
2
|
+
import fs from 'fs'
|
|
3
3
|
import _ from 'lodash-es'
|
|
4
4
|
import w from 'wsemi'
|
|
5
5
|
import WConverhpServer from '../src/WConverhpServer.mjs'
|
|
@@ -8,11 +8,11 @@ import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
|
8
8
|
|
|
9
9
|
describe('executeWithU8a', function() {
|
|
10
10
|
|
|
11
|
-
let
|
|
11
|
+
let ms = []
|
|
12
12
|
|
|
13
13
|
let runServer = () => {
|
|
14
14
|
|
|
15
|
-
let ms = []
|
|
15
|
+
// let ms = []
|
|
16
16
|
|
|
17
17
|
let opt = {
|
|
18
18
|
port: 8080,
|
|
@@ -42,7 +42,7 @@ describe('executeWithU8a', function() {
|
|
|
42
42
|
|
|
43
43
|
if (_.get(input, 'p.d.u8a', null)) {
|
|
44
44
|
// console.log('input.p.d.u8a', input.p.d.u8a)
|
|
45
|
-
ms.push({ 'input.p.d.u8a': input.p.d.u8a })
|
|
45
|
+
ms.push({ 'server receive input.p.d.u8a': input.p.d.u8a })
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
let r = {
|
|
@@ -78,7 +78,6 @@ describe('executeWithU8a', function() {
|
|
|
78
78
|
|
|
79
79
|
setTimeout(() => {
|
|
80
80
|
// console.log('ms', JSON.stringify(ms))
|
|
81
|
-
msAll.push({ server: ms })
|
|
82
81
|
wo.stop()
|
|
83
82
|
}, 2000)
|
|
84
83
|
|
|
@@ -86,7 +85,7 @@ describe('executeWithU8a', function() {
|
|
|
86
85
|
|
|
87
86
|
let runClient = () => {
|
|
88
87
|
|
|
89
|
-
let ms = []
|
|
88
|
+
// let ms = []
|
|
90
89
|
|
|
91
90
|
let opt = {
|
|
92
91
|
FormData,
|
|
@@ -117,7 +116,7 @@ describe('executeWithU8a', function() {
|
|
|
117
116
|
},
|
|
118
117
|
}
|
|
119
118
|
// console.log('p', p)
|
|
120
|
-
ms.push({ 'execute input': p })
|
|
119
|
+
ms.push({ 'client execute input': p })
|
|
121
120
|
|
|
122
121
|
//execute
|
|
123
122
|
await wo.execute('add', { p },
|
|
@@ -133,7 +132,7 @@ describe('executeWithU8a', function() {
|
|
|
133
132
|
// console.log('client web: execute: add', r)
|
|
134
133
|
// console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
135
134
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
136
|
-
ms.push({ 'execute
|
|
135
|
+
ms.push({ 'client execute done': r })
|
|
137
136
|
})
|
|
138
137
|
.catch(function () {
|
|
139
138
|
// console.log('client web: execute: catch', err)
|
|
@@ -152,7 +151,6 @@ describe('executeWithU8a', function() {
|
|
|
152
151
|
await execute('zdata.b1', u8a)
|
|
153
152
|
|
|
154
153
|
// console.log('ms', JSON.stringify(ms))
|
|
155
|
-
msAll.push({ client: ms })
|
|
156
154
|
|
|
157
155
|
}
|
|
158
156
|
core()
|
|
@@ -167,14 +165,14 @@ describe('executeWithU8a', function() {
|
|
|
167
165
|
runServer()
|
|
168
166
|
runClient()
|
|
169
167
|
setTimeout(() => {
|
|
170
|
-
// console.log('
|
|
171
|
-
// fs.writeFileSync('./test_executeWithU8a.json', JSON.stringify(
|
|
172
|
-
pm.resolve(
|
|
168
|
+
// console.log('ms', JSON.stringify(ms))
|
|
169
|
+
// fs.writeFileSync('./test_executeWithU8a.json', JSON.stringify(ms), 'utf8')
|
|
170
|
+
pm.resolve(ms)
|
|
173
171
|
}, 4000)
|
|
174
172
|
return pm
|
|
175
173
|
}
|
|
176
174
|
|
|
177
|
-
let res = `[{"client
|
|
175
|
+
let res = `[{"client execute input":{"a":12,"b":34.56,"c":"test中文","d":{"name":"zdata.b1","u8a":{"0":66,"1":97,"2":115}}}},{"server receive input.p.d.u8a":{"0":66,"1":97,"2":115}},{"client execute done":{"_add":46.56,"_data":[11,22.22,"abc",{"x":"21","y":65.43,"z":"test中文"}],"_bin":{"name":"zdata.b2","u8a":{"0":52,"1":66,"2":97,"3":115}}}}]`
|
|
178
176
|
it(`should return ${res} when test`, async function() {
|
|
179
177
|
let r = await run()
|
|
180
178
|
r = JSON.stringify(r)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'assert'
|
|
2
2
|
import fs from 'fs'
|
|
3
|
-
|
|
3
|
+
import _ from 'lodash-es'
|
|
4
4
|
import w from 'wsemi'
|
|
5
5
|
import WConverhpServer from '../src/WConverhpServer.mjs'
|
|
6
6
|
import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
@@ -8,11 +8,11 @@ import WConverhpClient from '../src/WConverhpClient.mjs'
|
|
|
8
8
|
|
|
9
9
|
describe('uploadLargeFile', function() {
|
|
10
10
|
|
|
11
|
-
let
|
|
11
|
+
let ms = []
|
|
12
12
|
|
|
13
13
|
let runServer = () => {
|
|
14
14
|
|
|
15
|
-
let ms = []
|
|
15
|
+
// let ms = []
|
|
16
16
|
|
|
17
17
|
let opt = {
|
|
18
18
|
port: 8082, //同時test故得要不同port
|
|
@@ -41,7 +41,7 @@ describe('uploadLargeFile', function() {
|
|
|
41
41
|
let u8a = new Uint8Array(b)
|
|
42
42
|
let t = u8a
|
|
43
43
|
let ts = [t[0], t[1], t[2]]
|
|
44
|
-
ms.push({ 'receive
|
|
44
|
+
ms.push({ 'server receive': ts })
|
|
45
45
|
|
|
46
46
|
fs.unlinkSync(`./${input.path}`) //測試完刪除臨時檔
|
|
47
47
|
|
|
@@ -63,7 +63,6 @@ describe('uploadLargeFile', function() {
|
|
|
63
63
|
|
|
64
64
|
setTimeout(() => {
|
|
65
65
|
// console.log('ms', ms)
|
|
66
|
-
msAll.push({ server: ms })
|
|
67
66
|
wo.stop()
|
|
68
67
|
}, 2000)
|
|
69
68
|
|
|
@@ -71,8 +70,6 @@ describe('uploadLargeFile', function() {
|
|
|
71
70
|
|
|
72
71
|
let runClient = () => {
|
|
73
72
|
|
|
74
|
-
let ms = []
|
|
75
|
-
|
|
76
73
|
let opt = {
|
|
77
74
|
FormData,
|
|
78
75
|
url: 'http://localhost:8082', //同時test故得要不同port
|
|
@@ -98,7 +95,7 @@ describe('uploadLargeFile', function() {
|
|
|
98
95
|
// console.log('uploadLargeFile u8a', u8a)
|
|
99
96
|
let t = u8a
|
|
100
97
|
let ts = [t[0], t[1], t[2]]
|
|
101
|
-
ms.push({ 'upload u8a.length
|
|
98
|
+
ms.push({ 'client upload start': `u8a.length[${ts}]` })
|
|
102
99
|
|
|
103
100
|
await wo.upload('./1mb.7z', u8a,
|
|
104
101
|
function ({ prog, p, m }) {
|
|
@@ -109,14 +106,13 @@ describe('uploadLargeFile', function() {
|
|
|
109
106
|
})
|
|
110
107
|
.then(function(res) {
|
|
111
108
|
// console.log('client web: upload: then', res)
|
|
112
|
-
ms.push({ 'upload
|
|
109
|
+
ms.push({ 'client upload done': { filename: res.filename } })
|
|
113
110
|
})
|
|
114
111
|
.catch(function () {
|
|
115
112
|
// console.log('client web: upload: catch', err)
|
|
116
113
|
})
|
|
117
114
|
|
|
118
115
|
// console.log('ms', ms)
|
|
119
|
-
msAll.push({ client: ms })
|
|
120
116
|
|
|
121
117
|
}
|
|
122
118
|
core()
|
|
@@ -131,14 +127,14 @@ describe('uploadLargeFile', function() {
|
|
|
131
127
|
runServer()
|
|
132
128
|
runClient()
|
|
133
129
|
setTimeout(() => {
|
|
134
|
-
// console.log('
|
|
135
|
-
// fs.writeFileSync('./test_uploadLargeFile.json', JSON.stringify(
|
|
136
|
-
pm.resolve(
|
|
130
|
+
// console.log('ms', ms)
|
|
131
|
+
// fs.writeFileSync('./test_uploadLargeFile.json', JSON.stringify(ms), 'utf8')
|
|
132
|
+
pm.resolve(ms)
|
|
137
133
|
}, 4000)
|
|
138
134
|
return pm
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
let res = `[{"client":
|
|
137
|
+
let res = `[{"client upload start":"u8a.length[55,122,188]"},{"server receive":[55,122,188]},{"client upload done":{"filename":"./1mb.7z"}}]`
|
|
142
138
|
it(`should return ${res} when test`, async function() {
|
|
143
139
|
let r = await run()
|
|
144
140
|
r = JSON.stringify(r)
|