@aj-shadow/z-abs-corelayer-client 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/client/_build/Bundle-CoreLayer-client.bld +28 -0
- package/project/client/_build/Client-CoreLayer-client-jsx.bld +10 -0
- package/project/client/_build/Client-CoreLayer-client.bld +10 -0
- package/project/client/_build/Client-css-CoreLayer-bundle.bld +9 -0
- package/project/client/_build/z-abs-corelayer-client.prj +36 -0
- package/project/client/actions/action-client.js +19 -0
- package/project/client/actions/action-dialog-file.js +31 -0
- package/project/client/communication/action.js +59 -0
- package/project/client/communication/core-protocol/decoder.js +412 -0
- package/project/client/communication/core-protocol/encoder.js +553 -0
- package/project/client/communication/core-protocol/pooled-buffers.js +51 -0
- package/project/client/communication/core-protocol/pooled-decoder.js +396 -0
- package/project/client/communication/core-protocol/pooled-encoder.js +505 -0
- package/project/client/communication/data-action-multi.js +11 -0
- package/project/client/communication/data-action.js +37 -0
- package/project/client/communication/data-config.js +36 -0
- package/project/client/communication/data-fetcher-thread.js +46 -0
- package/project/client/communication/data-fetcher.js +58 -0
- package/project/client/communication/messages/messages-c-to-s/message-persistent-init-request.js +16 -0
- package/project/client/communication/messages/messages-client/message-realtime-closed.js +12 -0
- package/project/client/communication/messages/messages-client/message-realtime-error.js +12 -0
- package/project/client/communication/messages/messages-client/message-realtime-open.js +12 -0
- package/project/client/communication/realtime-action.js +42 -0
- package/project/client/communication/subscription-action.js +21 -0
- package/project/client/components/helper-tab.js +40 -0
- package/project/client/components/not-found.jsx +38 -0
- package/project/client/css/not-found.css +9 -0
- package/project/client/react-component/context.js +26 -0
- package/project/client/react-component/react-component-base.js +225 -0
- package/project/client/react-component/react-component-realtime-renderer.js +86 -0
- package/project/client/react-component/react-component-realtime.js +200 -0
- package/project/client/react-component/react-component-store.js +62 -0
- package/project/client/state/state-updater.js +389 -0
- package/project/client/state/verbose.js +28 -0
- package/project/client/store/store-base-data.js +136 -0
- package/project/client/store/store-base-realtime-worker-thread.js +26 -0
- package/project/client/store/store-base-realtime.js +265 -0
- package/project/client/store/store-base.js +217 -0
- package/project/client/stores/client-store.js +25 -0
- package/project/client/stores/dialog-file-store.js +86 -0
- package/project/client/worker/worker-main-core-protocol.js +47 -0
- package/project/client/worker/worker-main-websocket.js +64 -0
- package/project/client/worker/worker-main.js +86 -0
- package/project/client/worker/worker-thread-core-protocol.js +74 -0
- package/project/client/worker/worker-thread-websocket.js +83 -0
- package/project/client/worker/worker-thread.js +71 -0
- package/project/z-abs-corelayer-client.tree +61 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import EncoderConst from 'z-abs-corelayer-cs/clientServer/communication/core-protocol/encoder-const';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Encoder {
|
|
8
|
+
static totalSize = 0;
|
|
9
|
+
static GuidSize = EncoderConst.GuidSize;
|
|
10
|
+
static Int8Size = EncoderConst.Int8Size;
|
|
11
|
+
static Int16Size = EncoderConst.Int16Size;
|
|
12
|
+
static Int32Size = EncoderConst.Int32Size;
|
|
13
|
+
static Int64Size = EncoderConst.Int64Size;
|
|
14
|
+
static Uint8Size = EncoderConst.Uint8Size;
|
|
15
|
+
static Uint16Size = EncoderConst.Uint16Size;
|
|
16
|
+
static Uint32Size = EncoderConst.Uint32Size;
|
|
17
|
+
static Uint64Size = EncoderConst.Uint64Size;
|
|
18
|
+
static Float32Size = EncoderConst.Float32Size;
|
|
19
|
+
static Float64Size = EncoderConst.Float64Size;
|
|
20
|
+
static CtSize = EncoderConst.CtSize;
|
|
21
|
+
|
|
22
|
+
static textEncoder = new TextEncoder();
|
|
23
|
+
static ASCII = [
|
|
24
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
25
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
26
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
27
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
28
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
29
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
30
|
+
0, 1, 2, 3, 4, 5, 6, 7,
|
|
31
|
+
8, 9, -1, -1, -1, -1, -1, -1,
|
|
32
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
33
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
34
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
35
|
+
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
36
|
+
-1, 10, 11, 12, 13, 14, 15, -1
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
constructor(textCache) {
|
|
40
|
+
this.textCache = textCache;
|
|
41
|
+
this.offset = 0;
|
|
42
|
+
this.dataView = null;
|
|
43
|
+
this.doCalculate = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
clear() {
|
|
47
|
+
this.offset = 0;
|
|
48
|
+
this.dataView = null;
|
|
49
|
+
this.doCalculate = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
createBuffer(size) {
|
|
53
|
+
Encoder.totalSize += size;
|
|
54
|
+
const buffer = new ArrayBuffer(size);
|
|
55
|
+
this.dataView = new DataView(buffer);
|
|
56
|
+
return buffer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
calculate(doCalculate) {
|
|
60
|
+
this.doCalculate = doCalculate;
|
|
61
|
+
this.offset = 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static calculateBytesFromString(s) {
|
|
65
|
+
if(!s) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
const length = s.length;
|
|
69
|
+
let stringBytes = 0;
|
|
70
|
+
let ch = null;
|
|
71
|
+
let notFirst = false;
|
|
72
|
+
for(let i = 0; i < length; ++i) {
|
|
73
|
+
ch = s.charCodeAt(i);
|
|
74
|
+
if(ch >= 0xdc00 && ch <= 0xdfff) {
|
|
75
|
+
if(notFirst && (ch >= 0xd800 && ch <= 0xdbff)) {
|
|
76
|
+
++stringBytes;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
stringBytes += 3;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if(ch <= 0x7f) {
|
|
83
|
+
stringBytes += 1;
|
|
84
|
+
}
|
|
85
|
+
else if(ch >= 0x80 && ch <= 0x7ff) {
|
|
86
|
+
stringBytes += 2;
|
|
87
|
+
}
|
|
88
|
+
else if(ch >= 0x800 && ch <= 0xffff) {
|
|
89
|
+
stringBytes += 3;
|
|
90
|
+
}
|
|
91
|
+
notFirst = true;
|
|
92
|
+
}
|
|
93
|
+
return stringBytes;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
calculateBytesFromString(s) {
|
|
97
|
+
return Encoder.calculateBytesFromString(s);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static calculateBytesFromBin(b) {
|
|
101
|
+
return b.byteLength;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
calculateBytesFromBin(b) {
|
|
105
|
+
return b.byteLength;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static calculateDynamicBytes(size) {
|
|
109
|
+
if(size <= 253) {
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
else if(size <= 65535) {
|
|
113
|
+
return 3;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return 5;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
calculateDynamicBytes(size) {
|
|
121
|
+
return Encoder.calculateDynamicBytes(size);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static getStringBytes(s) {
|
|
125
|
+
const stringBytes = Encoder.calculateBytesFromString(s);
|
|
126
|
+
return stringBytes + Encoder.calculateDynamicBytes(stringBytes);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getStringBytes(s) {
|
|
130
|
+
return Encoder.getStringBytes(s);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static getStringArrayBytes(array) {
|
|
134
|
+
let size = Encoder.calculateDynamicBytes(array.length);
|
|
135
|
+
for(let i = 0; i < array.length; ++i) {
|
|
136
|
+
size += Encoder.getStringBytes(array[i]);
|
|
137
|
+
}
|
|
138
|
+
return size;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getStringArrayBytes(array) {
|
|
142
|
+
return Encoder.getStringArrayBytes(array);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static getGuidArrayBytes(array) {
|
|
146
|
+
return Encoder.calculateDynamicBytes(array.length) + (array.length * EncoderConst.GuidSize);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getGuidArrayBytes(array) {
|
|
150
|
+
Encoder.getGuidArrayBytes(array);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
setDynamicBytes(size) {
|
|
154
|
+
const sizeBytes = this.calculateDynamicBytes(size);
|
|
155
|
+
if(1 === sizeBytes) {
|
|
156
|
+
this.setUint8(size);
|
|
157
|
+
}
|
|
158
|
+
else if(3 === sizeBytes) {
|
|
159
|
+
this.setUint8(254);
|
|
160
|
+
this.setUint16(size);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.setUint8(255);
|
|
164
|
+
this.setUint32(size);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setInt8(value) {
|
|
169
|
+
if(!this.doCalculate) {
|
|
170
|
+
this.dataView.setInt8(this.offset, value);
|
|
171
|
+
}
|
|
172
|
+
this.offset += Encoder.Int8Size;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setInt16(value) {
|
|
176
|
+
if(!this.doCalculate) {
|
|
177
|
+
this.dataView.setInt16(this.offset, value);
|
|
178
|
+
}
|
|
179
|
+
this.offset += Encoder.Int16Size;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
setInt32(value) {
|
|
183
|
+
if(!this.doCalculate) {
|
|
184
|
+
this.dataView.setInt32(this.offset, value);
|
|
185
|
+
}
|
|
186
|
+
this.offset += Encoder.Int32Size;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
setBigInt64(value) {
|
|
190
|
+
if(!this.doCalculate) {
|
|
191
|
+
this.dataView.setBigInt64(this.offset, value);
|
|
192
|
+
}
|
|
193
|
+
this.offset += Encoder.Int64Size;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
setUint1_0(value, ready) {
|
|
197
|
+
if(!this.doCalculate) {
|
|
198
|
+
const v = 0x7f & this.dataView.getUint8(this.offset);
|
|
199
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 7));
|
|
200
|
+
}
|
|
201
|
+
if(ready) {
|
|
202
|
+
this.offset += Encoder.Int8Size;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setUint1_1(value, ready) {
|
|
207
|
+
if(!this.doCalculate) {
|
|
208
|
+
const v = 0xbf & this.dataView.getUint8(this.offset);
|
|
209
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 6));
|
|
210
|
+
}
|
|
211
|
+
if(ready) {
|
|
212
|
+
this.offset += Encoder.Int8Size;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setUint1_2(value, ready) {
|
|
217
|
+
if(!this.doCalculate) {
|
|
218
|
+
const v = 0xdf & this.dataView.getUint8(this.offset);
|
|
219
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 5));
|
|
220
|
+
}
|
|
221
|
+
if(ready) {
|
|
222
|
+
this.offset += Encoder.Int8Size;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
setUint1_3(value, ready) {
|
|
227
|
+
if(!this.doCalculate) {
|
|
228
|
+
const v = 0xef & this.dataView.getUint8(this.offset);
|
|
229
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 4));
|
|
230
|
+
}
|
|
231
|
+
if(ready) {
|
|
232
|
+
this.offset += Encoder.Int8Size;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
setUint1_4(value, ready) {
|
|
237
|
+
if(!this.doCalculate) {
|
|
238
|
+
const v = 0xf7 & this.dataView.getUint8(this.offset);
|
|
239
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 3));
|
|
240
|
+
}
|
|
241
|
+
if(ready) {
|
|
242
|
+
this.offset += Encoder.Int8Size;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
setUint1_5(value, ready) {
|
|
247
|
+
if(!this.doCalculate) {
|
|
248
|
+
const v = 0xfb & this.dataView.getUint8(this.offset);
|
|
249
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 2));
|
|
250
|
+
}
|
|
251
|
+
if(ready) {
|
|
252
|
+
this.offset += Encoder.Int8Size;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
setUint1_6(value, ready) {
|
|
257
|
+
if(!this.doCalculate) {
|
|
258
|
+
const v = 0xfd & this.dataView.getUint8(this.offset);
|
|
259
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value) << 1));
|
|
260
|
+
}
|
|
261
|
+
if(ready) {
|
|
262
|
+
this.offset += Encoder.Int8Size;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
setUint1_7(value, ready) {
|
|
267
|
+
if(!this.doCalculate) {
|
|
268
|
+
const v = 0xfe & this.dataView.getUint8(this.offset);
|
|
269
|
+
this.dataView.setUint8(this.offset, v + ((0x1 & value)));
|
|
270
|
+
}
|
|
271
|
+
if(ready) {
|
|
272
|
+
this.offset += Encoder.Int8Size;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
setUint2_0(value, ready) {
|
|
277
|
+
const v = 0x3f & this.dataView.getUint8(this.offset);
|
|
278
|
+
this.dataView.setUint8(this.offset, v + ((0x3 & value) << 6));
|
|
279
|
+
if(ready) {
|
|
280
|
+
this.offset += Encoder.Int8Size;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
setUint2_1(value, ready) {
|
|
285
|
+
const v = 0xcf & this.dataView.getUint8(this.offset);
|
|
286
|
+
this.dataView.setUint8(this.offset, v + ((0x3 & value) << 4));
|
|
287
|
+
if(ready) {
|
|
288
|
+
this.offset += Encoder.Int8Size;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
setUint2_2(value, ready) {
|
|
293
|
+
if(!this.doCalculate) {
|
|
294
|
+
const v = 0xf3 & this.dataView.getUint8(this.offset);
|
|
295
|
+
this.dataView.setUint8(this.offset, v + ((0x3 & value) << 2));
|
|
296
|
+
}
|
|
297
|
+
if(ready) {
|
|
298
|
+
this.offset += Encoder.Int8Size;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
setUint2_3(value, ready) {
|
|
303
|
+
if(!this.doCalculate) {
|
|
304
|
+
const v = 0xfc & this.dataView.getUint8(this.offset);
|
|
305
|
+
this.dataView.setUint8(this.offset, v + (0x3 & value));
|
|
306
|
+
}
|
|
307
|
+
if(ready) {
|
|
308
|
+
this.offset += Encoder.Int8Size;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
setUint4_0(value, ready) {
|
|
313
|
+
if(!this.doCalculate) {
|
|
314
|
+
const v = 0xf & this.dataView.getUint8(this.offset);
|
|
315
|
+
this.dataView.setUint8(this.offset, v + ((0xf & value) << 4));
|
|
316
|
+
}
|
|
317
|
+
if(ready) {
|
|
318
|
+
this.offset += Encoder.Int8Size;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
setUint4_1(value, ready) {
|
|
323
|
+
if(!this.doCalculate) {
|
|
324
|
+
const v = 0xf0 & this.dataView.getUint8(this.offset);
|
|
325
|
+
this.dataView.setUint8(this.offset, v + (0xf & value));
|
|
326
|
+
}
|
|
327
|
+
if(ready) {
|
|
328
|
+
this.offset += Encoder.Int8Size;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
setUint8(value) {
|
|
333
|
+
if(!this.doCalculate) {
|
|
334
|
+
this.dataView.setUint8(this.offset, value);
|
|
335
|
+
}
|
|
336
|
+
this.offset += Encoder.Uint8Size;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
setUint16(value) {
|
|
340
|
+
if(!this.doCalculate) {
|
|
341
|
+
this.dataView.setUint16(this.offset, value);
|
|
342
|
+
}
|
|
343
|
+
this.offset += Encoder.Uint16Size;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
setUint32(value) {
|
|
347
|
+
if(!this.doCalculate) {
|
|
348
|
+
this.dataView.setUint32(this.offset, value);
|
|
349
|
+
}
|
|
350
|
+
this.offset += Encoder.Uint32Size;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
setBigUint64(value) {
|
|
354
|
+
if(!this.doCalculate) {
|
|
355
|
+
this.dataView.setBigUint64(this.offset, value);
|
|
356
|
+
}
|
|
357
|
+
this.offset += Encoder.Uint64Size;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
setFloat32(value) {
|
|
361
|
+
if(!this.doCalculate) {
|
|
362
|
+
this.dataView.setFloat32(this.offset, value);
|
|
363
|
+
}
|
|
364
|
+
this.offset += Encoder.Float32Size;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
setFloat64(value) {
|
|
368
|
+
if(!this.doCalculate) {
|
|
369
|
+
this.dataView.setFloat64(this.offset, value);
|
|
370
|
+
}
|
|
371
|
+
this.offset += Encoder.Float64Size;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
setBool1_0(value, ready) {
|
|
375
|
+
this.setUint1_0(value ? 1 : 0, ready);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
setBool1_1(value, ready) {
|
|
379
|
+
this.setUint1_1(value ? 1 : 0, ready);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
setBool1_2(value, ready) {
|
|
383
|
+
this.setUint1_2(value ? 1 : 0, ready);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
setBool1_3(value, ready) {
|
|
387
|
+
this.setUint1_3(value ? 1 : 0, ready);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
setBool1_4(value, ready) {
|
|
391
|
+
this.setUint1_4(value ? 1 : 0, ready);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
setBool1_5(value, ready) {
|
|
395
|
+
this.setUint1_5(value ? 1 : 0, ready);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
setBool1_6(value, ready) {
|
|
399
|
+
this.setUint1_6(value ? 1 : 0, ready);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
setBool1_7(value, ready) {
|
|
403
|
+
this.setUint1_7(value ? 1 : 0, ready);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
_setCt(value) {
|
|
407
|
+
if(!this.doCalculate) {
|
|
408
|
+
this.dataView.setInt16(this.offset, value);
|
|
409
|
+
}
|
|
410
|
+
this.offset += Encoder.CtSize;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
setCtString(text, cachedTexts) {
|
|
414
|
+
if(!this.doCalculate) {
|
|
415
|
+
if(!text) {
|
|
416
|
+
text = '';
|
|
417
|
+
}
|
|
418
|
+
const ctId = this.textCache.setExternal(text, cachedTexts);
|
|
419
|
+
this._setCt(ctId);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this.offset += Encoder.CtSize;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
setCtStringArray(array, cachedTexts) {
|
|
427
|
+
this.setUint16(array.length);
|
|
428
|
+
for(let i = 0; i < array.length; ++i) {
|
|
429
|
+
this.setCtString(array[i], cachedTexts);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
setCtStringInternal(text) {
|
|
434
|
+
if(!this.doCalculate) {
|
|
435
|
+
const ctId = this.textCache.setInternal(text);
|
|
436
|
+
this._setCt(ctId);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
this.offset += Encoder.CtSize;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
setCtStringArrayInternal(array) {
|
|
444
|
+
this.setUint16(array.length);
|
|
445
|
+
for(let i = 0; i < array.length; ++i) {
|
|
446
|
+
this.setCtStringInternal(array[i]);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
setRawString(value, size) {
|
|
451
|
+
if(!this.doCalculate) {
|
|
452
|
+
if(0 !== size) {
|
|
453
|
+
const result = Encoder.textEncoder.encodeInto(value, new Uint8Array(this.dataView.buffer, this.offset, size));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
this.offset += size;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
setString(value) {
|
|
460
|
+
const stringBytes = this.calculateBytesFromString(value);
|
|
461
|
+
this.setDynamicBytes(stringBytes);
|
|
462
|
+
this.setRawString(value, stringBytes);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
setStringArray(array) {
|
|
466
|
+
this.setDynamicBytes(array.length);
|
|
467
|
+
for(let i = 0; i < array.length; ++i) {
|
|
468
|
+
this.setString(array[i]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
setRawBinary(value, size) {
|
|
473
|
+
if(!this.doCalculate) {
|
|
474
|
+
let srcArray = null;
|
|
475
|
+
let srcDataView = null;
|
|
476
|
+
if(value instanceof ArrayBuffer) {
|
|
477
|
+
srcDataView = new DataView(value);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
srcDataView = new DataView(value.buffer, value.byteOffset);
|
|
481
|
+
}
|
|
482
|
+
srcArray = new Uint8Array(srcDataView.buffer, srcDataView.byteOffset);
|
|
483
|
+
const dstArray = new Uint8Array(this.dataView.buffer, this.dataView.byteOffset + this.offset, srcArray.byteLength);
|
|
484
|
+
dstArray.set(srcArray);
|
|
485
|
+
this.offset += size;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
this.offset += size;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
setBinary(value) {
|
|
493
|
+
const binaryBytes = value.byteLength;
|
|
494
|
+
this.setDynamicBytes(binaryBytes);
|
|
495
|
+
this.setRawBinary(value, binaryBytes);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
setUint8Array(array) {
|
|
499
|
+
this.setUint16(array.length);
|
|
500
|
+
for(let i = 0; i < array.length; ++i) {
|
|
501
|
+
this.setUint8(array[i]);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
setGuid(value) {
|
|
506
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(0)], false);
|
|
507
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(1)], true);
|
|
508
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(2)], false);
|
|
509
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(3)], true);
|
|
510
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(4)], false);
|
|
511
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(5)], true);
|
|
512
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(6)], false);
|
|
513
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(7)], true);
|
|
514
|
+
|
|
515
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(9)], false);
|
|
516
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(10)], true);
|
|
517
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(11)], false);
|
|
518
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(12)], true);
|
|
519
|
+
|
|
520
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(14)], false);
|
|
521
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(15)], true);
|
|
522
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(16)], false);
|
|
523
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(17)], true);
|
|
524
|
+
|
|
525
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(19)], false);
|
|
526
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(20)], true);
|
|
527
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(21)], false);
|
|
528
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(22)], true);
|
|
529
|
+
|
|
530
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(24)], false);
|
|
531
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(25)], true);
|
|
532
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(26)], false);
|
|
533
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(27)], true);
|
|
534
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(28)], false);
|
|
535
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(29)], true);
|
|
536
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(30)], false);
|
|
537
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(31)], true);
|
|
538
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(32)], false);
|
|
539
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(33)], true);
|
|
540
|
+
this.setUint4_0(Encoder.ASCII[value.charCodeAt(34)], false);
|
|
541
|
+
this.setUint4_1(Encoder.ASCII[value.charCodeAt(35)], true);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
setGuidArray(array) {
|
|
545
|
+
this.setDynamicBytes(array.length);
|
|
546
|
+
for(let i = 0; i < array.length; ++i) {
|
|
547
|
+
this.setGuid(array[i]);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
module.exports = Encoder;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class PooledBuffers {
|
|
6
|
+
static BUFFER_SIZE = 2 ** 18;
|
|
7
|
+
static dynamicBuffers = new Map();
|
|
8
|
+
|
|
9
|
+
constructor(name) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.buffersIndex = 0;
|
|
12
|
+
this.buffersOffset = 0;
|
|
13
|
+
this.dataViews = [new DataView(new ArrayBuffer(PooledBuffers.BUFFER_SIZE))];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getBuffer(size) {
|
|
17
|
+
if(this.buffersOffset + size < PooledBuffers.BUFFER_SIZE) {
|
|
18
|
+
this.buffersOffset += size;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
++this.buffersIndex;
|
|
22
|
+
this.buffersOffset = size;
|
|
23
|
+
this.dataViews.push(new DataView(new ArrayBuffer(PooledBuffers.BUFFER_SIZE)));
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
buffersIndex: this.buffersIndex,
|
|
27
|
+
offset: this.buffersOffset - size
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getDynamicBuffer(key) {
|
|
32
|
+
return PooledBuffers.dynamicBuffers.get(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setDynamicBuffer(key, data) {
|
|
36
|
+
PooledBuffers.dynamicBuffers.set(key, data);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
clear() {
|
|
40
|
+
this.buffersIndex = 0;
|
|
41
|
+
this.buffersOffset = 0;
|
|
42
|
+
this.dataViews = [new DataView(new ArrayBuffer(PooledBuffers.BUFFER_SIZE))];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static clear() {
|
|
46
|
+
PooledBuffers.dynamicBuffers.clear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
module.exports = PooledBuffers;
|