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