@aj-shadow/z-abs-funclayer-engine-server 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/server/_build/Server-FuncLayer-Engine-server.bld +12 -0
- package/project/server/_build/z-abs-funclayer-engine-server.prj +12 -0
- package/project/server/address/address-calculator.js +377 -0
- package/project/server/address/address-data.js +364 -0
- package/project/server/address/address-manager.js +251 -0
- package/project/server/address/address.js +176 -0
- package/project/server/address/addresses.js +122 -0
- package/project/server/address/dns-url-cache.js +130 -0
- package/project/server/address/interfaces.js +100 -0
- package/project/server/address/local-dns.js +35 -0
- package/project/server/address/login-report.js +56 -0
- package/project/server/address/networks.js +598 -0
- package/project/server/address/real-networks.js +102 -0
- package/project/server/address/subnet.js +60 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-started.js +17 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-stopped.js +14 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-debug-paused.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-log.js +25 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-started.js +21 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-state.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-stopped.js +22 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-started.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-started.js +16 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-w/message-test-case-debug-actor-index-ok.js +15 -0
- package/project/server/communication/messages/messages-w-to-s/message-test-case-debug-actor-index.js +15 -0
- package/project/server/debug/debug-step-over.js +54 -0
- package/project/server/debug/debugger.js +102 -0
- package/project/server/debug-dashboard/debug-dashboard.js +14 -0
- package/project/server/debug-dashboard/gauge-manager.js +44 -0
- package/project/server/debug-dashboard/gauge.js +37 -0
- package/project/server/engine/actor/actor-condition.js +335 -0
- package/project/server/engine/actor/actor-intercepting.js +32 -0
- package/project/server/engine/actor/actor-local.js +24 -0
- package/project/server/engine/actor/actor-mixins/asynch-mixin.js +103 -0
- package/project/server/engine/actor/actor-mixins/content-mixin.js +22 -0
- package/project/server/engine/actor/actor-mixins/logger-mixin.js +603 -0
- package/project/server/engine/actor/actor-mixins/process-mixin.js +35 -0
- package/project/server/engine/actor/actor-mixins/shared-data-mixin.js +109 -0
- package/project/server/engine/actor/actor-mixins/shared-execution-data-mixin.js +57 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-client.js +157 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-server.js +123 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin.js +128 -0
- package/project/server/engine/actor/actor-mixins/test-data-mixin.js +402 -0
- package/project/server/engine/actor/actor-mixins/timer-mixin.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-base.js +668 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-mandatory.js +46 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-optional.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-value.js +71 -0
- package/project/server/engine/actor/actor-originating.js +32 -0
- package/project/server/engine/actor/actor-part-mixins/part-asynch-mixin.js +24 -0
- package/project/server/engine/actor/actor-part-mixins/part-logger-mixin.js +39 -0
- package/project/server/engine/actor/actor-part-mixins/part-shared-runtime-data-mixin.js +33 -0
- package/project/server/engine/actor/actor-part-mixins/part-timer-mixin.js +12 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-mandatory.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-optional.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-value.js +15 -0
- package/project/server/engine/actor/actor-part-post.js +37 -0
- package/project/server/engine/actor/actor-part-pre.js +37 -0
- package/project/server/engine/actor/actor-pending.js +79 -0
- package/project/server/engine/actor/actor-proxy.js +38 -0
- package/project/server/engine/actor/actor-results.js +36 -0
- package/project/server/engine/actor/actor-state-timeout.js +35 -0
- package/project/server/engine/actor/actor-sut.js +38 -0
- package/project/server/engine/actor/actor-terminating.js +32 -0
- package/project/server/engine/actor/actor.js +553 -0
- package/project/server/engine/actor-phase.js +26 -0
- package/project/server/engine/actor-state-machine-base.js +298 -0
- package/project/server/engine/actor-state-machine-data.js +383 -0
- package/project/server/engine/actor-state-machine-exec.js +137 -0
- package/project/server/engine/actor-state-machine-post.js +177 -0
- package/project/server/engine/actor-state-machine-pre.js +142 -0
- package/project/server/engine/actor-state-machine-process.js +88 -0
- package/project/server/engine/actor-state-machine-state.js +52 -0
- package/project/server/engine/actor-state-machine.js +185 -0
- package/project/server/engine/actor-state.js +35 -0
- package/project/server/engine/actor-worker.js +68 -0
- package/project/server/engine/actors-phase.js +49 -0
- package/project/server/engine/actors.js +317 -0
- package/project/server/engine/data/content-audio.js +18 -0
- package/project/server/engine/data/content-base.js +91 -0
- package/project/server/engine/data/content-binary.js +15 -0
- package/project/server/engine/data/content-cache.js +67 -0
- package/project/server/engine/data/content-data.js +254 -0
- package/project/server/engine/data/content-documents.js +18 -0
- package/project/server/engine/data/content-image.js +20 -0
- package/project/server/engine/data/content-other.js +19 -0
- package/project/server/engine/data/content-text.js +19 -0
- package/project/server/engine/data/content-undefined.js +14 -0
- package/project/server/engine/data/content-video.js +20 -0
- package/project/server/engine/data/content.js +60 -0
- package/project/server/engine/data/runtime-data-shared.js +75 -0
- package/project/server/engine/data/test-data.js +239 -0
- package/project/server/engine/execution-context-test-case.js +48 -0
- package/project/server/engine/execution-context-test-suite.js +66 -0
- package/project/server/engine/execution-context.js +93 -0
- package/project/server/engine/stage-setter.js +132 -0
- package/project/server/engine/stage.js +83 -0
- package/project/server/engine/test-case-load.js +25 -0
- package/project/server/engine/test-case-loader.js +125 -0
- package/project/server/engine/test-case-not-found.js +29 -0
- package/project/server/engine/test-case-result-type.js +42 -0
- package/project/server/engine/test-case.js +417 -0
- package/project/server/engine/test-output.js +116 -0
- package/project/server/engine/test-statistics-test-case.js +59 -0
- package/project/server/engine/test-statistics-test-suite.js +63 -0
- package/project/server/engine/test-suite.js +276 -0
- package/project/server/stack/api/base-64.js +16 -0
- package/project/server/stack/api/const-commands-decoder.js +15 -0
- package/project/server/stack/api/const-commands-encoder.js +15 -0
- package/project/server/stack/api/hmacSha1.js +14 -0
- package/project/server/stack/api/json-web-token.js +38 -0
- package/project/server/stack/api/sdp/sdp-decoder.js +70 -0
- package/project/server/stack/api/sdp/sdp-encoder.js +40 -0
- package/project/server/stack/api/sdp/sdp-media-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-media-session.js +16 -0
- package/project/server/stack/api/sdp/sdp-message.js +17 -0
- package/project/server/stack/api/sdp/sdp-origin.js +17 -0
- package/project/server/stack/api/sdp/sdp-session-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-timing.js +15 -0
- package/project/server/stack/api/text-protocol-header.js +35 -0
- package/project/server/stack/factory/stack-components-helpers.js +22 -0
- package/project/server/stack/factory/stack-components-template-base-actors.js +124 -0
- package/project/server/stack/factory/stack-components-template-base-test-cases.js +22 -0
- package/project/server/stack/factory/stack-components-templates-actors.js +15 -0
- package/project/server/stack/factory/stack-components-templates-test-cases.js +20 -0
- package/project/server/stack/managers/client-manager/client-manager.js +193 -0
- package/project/server/stack/managers/connection-manager/connection-data.js +82 -0
- package/project/server/stack/managers/connection-manager/connection-manager.js +177 -0
- package/project/server/stack/managers/connection-manager/connection-object.js +148 -0
- package/project/server/stack/managers/connection-manager/shared-data.js +14 -0
- package/project/server/stack/managers/manager.js +95 -0
- package/project/server/stack/managers/server-manager/server-manager.js +76 -0
- package/project/server/stack/managers/server-manager/server.js +384 -0
- package/project/server/stack/managers/shared-manager.js +117 -0
- package/project/server/stack/network/buffer-manager.js +190 -0
- package/project/server/stack/network/mc/mc-connection-client-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-client.js +117 -0
- package/project/server/stack/network/mc/mc-connection-server-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-server.js +58 -0
- package/project/server/stack/network/mc/mc-connection-shared.js +26 -0
- package/project/server/stack/network/mc/mc-connection.js +33 -0
- package/project/server/stack/network/mc/mc-server.js +90 -0
- package/project/server/stack/network/network-connection-shared.js +177 -0
- package/project/server/stack/network/network-connection.js +134 -0
- package/project/server/stack/network/network-helper.js +12 -0
- package/project/server/stack/network/network-server.js +36 -0
- package/project/server/stack/network/network-type.js +46 -0
- package/project/server/stack/network/tcp/tcp-connection-client-shared.js +18 -0
- package/project/server/stack/network/tcp/tcp-connection-client.js +71 -0
- package/project/server/stack/network/tcp/tcp-connection-server-shared.js +14 -0
- package/project/server/stack/network/tcp/tcp-connection-server.js +16 -0
- package/project/server/stack/network/tcp/tcp-connection-shared.js +55 -0
- package/project/server/stack/network/tcp/tcp-connection.js +167 -0
- package/project/server/stack/network/tcp/tcp-server.js +35 -0
- package/project/server/stack/network/tls/tls-connection-client-shared.js +18 -0
- package/project/server/stack/network/tls/tls-connection-client.js +76 -0
- package/project/server/stack/network/tls/tls-connection-server-shared.js +14 -0
- package/project/server/stack/network/tls/tls-connection-server.js +16 -0
- package/project/server/stack/network/tls/tls-connection-shared.js +63 -0
- package/project/server/stack/network/tls/tls-connection.js +176 -0
- package/project/server/stack/network/tls/tls-server.js +45 -0
- package/project/server/stack/network/transport.js +19 -0
- package/project/server/stack/network/udp/udp-connection-client-shared.js +47 -0
- package/project/server/stack/network/udp/udp-connection-client.js +93 -0
- package/project/server/stack/network/udp/udp-connection-server-shared.js +51 -0
- package/project/server/stack/network/udp/udp-connection-server.js +58 -0
- package/project/server/stack/network/udp/udp-connection-shared.js +26 -0
- package/project/server/stack/network/udp/udp-connection.js +33 -0
- package/project/server/stack/network/udp/udp-server.js +74 -0
- package/project/server/stack/pending/pending-const.js +22 -0
- package/project/server/stack/pending/pending-context-receive.js +18 -0
- package/project/server/stack/pending/pending-context-send.js +18 -0
- package/project/server/stack/pending/pending-context.js +18 -0
- package/project/server/stack/pending/pending-inner.js +107 -0
- package/project/server/stack/pending/pending-switch.js +146 -0
- package/project/server/stack/stacks/ascii-dictionary.js +289 -0
- package/project/server/stack/stacks/binary-log.js +88 -0
- package/project/server/stack/stacks/bit-byte.js +51 -0
- package/project/server/stack/stacks/browser-data.js +25 -0
- package/project/server/stack/stacks/cancel-object.js +16 -0
- package/project/server/stack/stacks/connection-client.js +228 -0
- package/project/server/stack/stacks/connection-instance.js +69 -0
- package/project/server/stack/stacks/connection-ip.js +374 -0
- package/project/server/stack/stacks/connection-server.js +169 -0
- package/project/server/stack/stacks/connection-web.js +113 -0
- package/project/server/stack/stacks/connection-worker-client.js +29 -0
- package/project/server/stack/stacks/connection-worker-connection.js +41 -0
- package/project/server/stack/stacks/connection-worker-server.js +29 -0
- package/project/server/stack/stacks/connection-worker.js +99 -0
- package/project/server/stack/stacks/connection.js +132 -0
- package/project/server/stack/stacks/decoder.js +83 -0
- package/project/server/stack/stacks/encoder.js +82 -0
- package/project/server/stack/stacks/ip-log.js +24 -0
- package/project/server/stack/stacks/message-selector.js +22 -0
- package/project/server/stack/stacks/msg-ip.js +18 -0
- package/project/server/stack/stacks/stack-content-cache.js +27 -0
- package/project/z-abs-funclayer-engine-server.tree +230 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ContentBase {
|
|
6
|
+
constructor(buffers, readData) {
|
|
7
|
+
this.buffers = undefined === buffers ? [] : (Array.isArray(buffers) ? buffers : [buffers]);
|
|
8
|
+
this.readData = readData;
|
|
9
|
+
this.currentBuffer = -1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getBuffer() {
|
|
13
|
+
if(!this.readData) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if(this.readData.allRead) {
|
|
17
|
+
if(++this.currentBuffer < this.buffers.length) {
|
|
18
|
+
return this.buffers[this.currentBuffer];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.currentBuffer = -1;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
addBuffer(buffer) {
|
|
28
|
+
this.buffers.push(buffer);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getLength() {
|
|
32
|
+
if(!this.readData) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
else if(this.readData.allRead) {
|
|
36
|
+
return this.buffers.reduce((acc, current) => {
|
|
37
|
+
return acc + current.length;
|
|
38
|
+
}, 0);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
indexOf(value, start = 0) {
|
|
46
|
+
let bufferIndex = -1;
|
|
47
|
+
let index = start;
|
|
48
|
+
let length = 0;
|
|
49
|
+
let found = false;
|
|
50
|
+
while(++bufferIndex < this.buffers.length) {
|
|
51
|
+
if(start >= length) {
|
|
52
|
+
index = start - length;
|
|
53
|
+
// length = start;
|
|
54
|
+
bufferIndex -= 1;
|
|
55
|
+
found = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
length += this.buffers[bufferIndex].length;
|
|
59
|
+
}
|
|
60
|
+
if(!found) {
|
|
61
|
+
return -1;
|
|
62
|
+
}
|
|
63
|
+
while(++bufferIndex < this.buffers.length) {
|
|
64
|
+
index = this.buffers[bufferIndex].indexOf(value, index);
|
|
65
|
+
if(-1 !== index) {
|
|
66
|
+
return length + index;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
index = 0;
|
|
70
|
+
length += this.buffers[bufferIndex].length;
|
|
71
|
+
}
|
|
72
|
+
// TODO: overlapp between two buffers.
|
|
73
|
+
}
|
|
74
|
+
return -1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
slice(start = 0, end = -1) {
|
|
78
|
+
if(-1 === end) {
|
|
79
|
+
end = this.getLength();
|
|
80
|
+
}
|
|
81
|
+
// TODO: support more than one buffer.
|
|
82
|
+
return this.buffers[0].slice(start, end);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
normalize() {
|
|
86
|
+
this.currentBuffer = -1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
module.exports = ContentBase;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentText = require('./content-text');
|
|
5
|
+
const ContentDocuments = require('./content-documents');
|
|
6
|
+
const ContentVideo = require('./content-video');
|
|
7
|
+
const ContentAudio = require('./content-audio');
|
|
8
|
+
const ContentImage = require('./content-image');
|
|
9
|
+
const ContentOther = require('./content-other');
|
|
10
|
+
const ActorPathContent = require('z-abs-corelayer-server/server/path/actor-path-content');
|
|
11
|
+
const Fs = require('fs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ContentCache {
|
|
15
|
+
constructor(constantData) {
|
|
16
|
+
this.constantData = constantData;
|
|
17
|
+
this.contents = new Map();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
*get(name, hint, actor) {
|
|
21
|
+
const content = this.contents.get(name);
|
|
22
|
+
if(undefined !== content) {
|
|
23
|
+
return content;
|
|
24
|
+
}
|
|
25
|
+
return yield this._getContent(name, hint, actor);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_getContent(name, hint, actor) {
|
|
29
|
+
const pendingId = actor.setPending();
|
|
30
|
+
const contentDataC = this.constantData.get(name, hint);
|
|
31
|
+
if(!contentDataC) {
|
|
32
|
+
return actor.handlePendingId(pendingId, new Error(`Content with name: '${name}' does not exist.`));
|
|
33
|
+
}
|
|
34
|
+
Fs.readFile(ActorPathContent.getContentFile(contentDataC._repoPath, contentDataC.path), (err, buffer) => {
|
|
35
|
+
if(err) {
|
|
36
|
+
return actor.handlePendingId(pendingId, err);
|
|
37
|
+
}
|
|
38
|
+
const type = contentDataC._type;
|
|
39
|
+
let content = null;
|
|
40
|
+
if('text' === type) {
|
|
41
|
+
content = new ContentText(contentDataC, buffer, {allRead: true});
|
|
42
|
+
}
|
|
43
|
+
else if('documents' === type) {
|
|
44
|
+
content = new ContentDocuments(contentDataC, buffer, {allRead: true});
|
|
45
|
+
}
|
|
46
|
+
else if('video' === type) {
|
|
47
|
+
content = new ContentVideo(contentDataC, buffer, {allRead: true});
|
|
48
|
+
}
|
|
49
|
+
else if('audio' === type) {
|
|
50
|
+
content = new ContentAudio(contentDataC, buffer, {allRead: true});
|
|
51
|
+
}
|
|
52
|
+
else if('image' === type) {
|
|
53
|
+
content = new ContentImage(contentDataC, buffer, {allRead: true});
|
|
54
|
+
}
|
|
55
|
+
else if('other' === type) {
|
|
56
|
+
content = new ContentOther(contentDataC, buffer, {allRead: true});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return actor.handlePendingId(pendingId, new Error(`Content type: '${type}' does not exist.`));
|
|
60
|
+
}
|
|
61
|
+
this.contents.set(name, content);
|
|
62
|
+
actor.handlePendingId(pendingId, err, content);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = ContentCache;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorPathData = require('z-abs-corelayer-server/server/path/actor-path-data');
|
|
5
|
+
const ActorPathContent = require('z-abs-corelayer-server/server/path/actor-path-content');
|
|
6
|
+
const Fs = require('fs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ContentData {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.pendings = 0;
|
|
12
|
+
this.textContent = new Map();
|
|
13
|
+
this.documentsContent = new Map();
|
|
14
|
+
this.imageContent = new Map();
|
|
15
|
+
this.audioContent = new Map();
|
|
16
|
+
this.videoContent = new Map();
|
|
17
|
+
this.otherContent = new Map();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// TODO: Handle multiple errors
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
load(done) {
|
|
24
|
+
this.pendings = 0;
|
|
25
|
+
const repoPathGlobal = ActorPathContent.getContentGlobalFolder();
|
|
26
|
+
const repoPathLocal = ActorPathContent.getContentLocalFolder();
|
|
27
|
+
this._loadContent([
|
|
28
|
+
{
|
|
29
|
+
path: ActorPathData.getContentTextGlobalFile(),
|
|
30
|
+
repoPath: repoPathGlobal,
|
|
31
|
+
datas: this.textContent,
|
|
32
|
+
type: 'text'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
path: ActorPathData.getContentDocumentsGlobalFile(),
|
|
36
|
+
repoPath: repoPathGlobal,
|
|
37
|
+
datas: this.documentsContent,
|
|
38
|
+
type: 'documents'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: ActorPathData.getContentImageGlobalFile(),
|
|
42
|
+
repoPath: repoPathGlobal,
|
|
43
|
+
datas: this.imageContent,
|
|
44
|
+
type: 'image'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
path: ActorPathData.getContentAudioGlobalFile(),
|
|
48
|
+
repoPath: repoPathGlobal,
|
|
49
|
+
datas: this.audioContent,
|
|
50
|
+
type: 'audio'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: ActorPathData.getContentVideoGlobalFile(),
|
|
54
|
+
repoPath: repoPathGlobal,
|
|
55
|
+
datas: this.videoContent,
|
|
56
|
+
type: 'video'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: ActorPathData.getContentOtherGlobalFile(),
|
|
60
|
+
repoPath: repoPathGlobal,
|
|
61
|
+
datas: this.otherContent,
|
|
62
|
+
type: 'other'
|
|
63
|
+
}
|
|
64
|
+
], (err) => {
|
|
65
|
+
if(err) {
|
|
66
|
+
return done(err);
|
|
67
|
+
}
|
|
68
|
+
this._loadContent([
|
|
69
|
+
{
|
|
70
|
+
path: ActorPathData.getContentTextLocalFile(),
|
|
71
|
+
repoPath: repoPathLocal,
|
|
72
|
+
datas: this.textContent,
|
|
73
|
+
type: 'text'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
path: ActorPathData.getContentDocumentsLocalFile(),
|
|
77
|
+
repoPath: repoPathLocal,
|
|
78
|
+
datas: this.documentsContent,
|
|
79
|
+
type: 'documents'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
path: ActorPathData.getContentImageLocalFile(),
|
|
83
|
+
repoPath: repoPathLocal,
|
|
84
|
+
datas: this.imageContent,
|
|
85
|
+
type: 'image'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
path: ActorPathData.getContentAudioLocalFile(),
|
|
89
|
+
repoPath: repoPathLocal,
|
|
90
|
+
datas: this.audioContent,
|
|
91
|
+
type: 'audio'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
path: ActorPathData.getContentVideoLocalFile(),
|
|
95
|
+
repoPath: repoPathLocal,
|
|
96
|
+
datas: this.videoContent,
|
|
97
|
+
type: 'video'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
path: ActorPathData.getContentOtherLocalFile(),
|
|
101
|
+
repoPath: repoPathLocal,
|
|
102
|
+
datas: this.otherContent,
|
|
103
|
+
type: 'other'
|
|
104
|
+
}
|
|
105
|
+
], done);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get(name, hint) {
|
|
110
|
+
switch(hint) {
|
|
111
|
+
case 'image': {
|
|
112
|
+
const contentData = this.imageContent.get(name);
|
|
113
|
+
if(undefined !== contentData) {
|
|
114
|
+
return contentData;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
case 'audio': {
|
|
118
|
+
const contentData = this.audioContent.get(name);
|
|
119
|
+
if(undefined !== contentData) {
|
|
120
|
+
return contentData;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
let contentData = this.otherContent.get(name);
|
|
125
|
+
if(undefined !== contentData) {
|
|
126
|
+
return contentData;
|
|
127
|
+
}
|
|
128
|
+
contentData = this.imageContent.get(name);
|
|
129
|
+
if(undefined !== contentData) {
|
|
130
|
+
return contentData;
|
|
131
|
+
}
|
|
132
|
+
contentData = this.audioContent.get(name);
|
|
133
|
+
if(undefined !== contentData) {
|
|
134
|
+
return contentData;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_loadContent(contentsToLoad, done) {
|
|
139
|
+
let errorResponse = false;
|
|
140
|
+
for(let i = 0; i < contentsToLoad.length; ++i) {
|
|
141
|
+
++this.pendings;
|
|
142
|
+
Fs.readFile(contentsToLoad[i].path, (err, data) => {
|
|
143
|
+
if(!errorResponse) {
|
|
144
|
+
if(err) {
|
|
145
|
+
errorResponse = true;
|
|
146
|
+
done(err);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const contentDatas = JSON.parse(data);
|
|
150
|
+
const type = contentsToLoad[i].type;
|
|
151
|
+
const repoPath = contentsToLoad[i].repoPath;
|
|
152
|
+
switch(type) {
|
|
153
|
+
case 'text': {
|
|
154
|
+
contentDatas.forEach((contentData) => {
|
|
155
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
156
|
+
_repoPath: repoPath,
|
|
157
|
+
_type: type,
|
|
158
|
+
name: contentData.name,
|
|
159
|
+
path: contentData.path,
|
|
160
|
+
mime: contentData.mime,
|
|
161
|
+
encoding: contentData.encoding,
|
|
162
|
+
size: Number.parseInt(contentData.size),
|
|
163
|
+
description: contentData.description
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case 'documents': {
|
|
169
|
+
contentDatas.forEach((contentData) => {
|
|
170
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
171
|
+
_repoPath: repoPath,
|
|
172
|
+
_type: type,
|
|
173
|
+
name: contentData.name,
|
|
174
|
+
path: contentData.path,
|
|
175
|
+
mime: contentData.mime,
|
|
176
|
+
size: Number.parseInt(contentData.size),
|
|
177
|
+
description: contentData.description
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case 'image': {
|
|
183
|
+
contentDatas.forEach((contentData) => {
|
|
184
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
185
|
+
_repoPath: repoPath,
|
|
186
|
+
_type: type,
|
|
187
|
+
name: contentData.name,
|
|
188
|
+
path: contentData.path,
|
|
189
|
+
mime: contentData.mime,
|
|
190
|
+
size: Number.parseInt(contentData.size),
|
|
191
|
+
width: Number.parseInt(contentData.width),
|
|
192
|
+
height: Number.parseInt(contentData.height),
|
|
193
|
+
description: contentData.description
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'audio': {
|
|
199
|
+
contentDatas.forEach((contentData) => {
|
|
200
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
201
|
+
_repoPath: repoPath,
|
|
202
|
+
_type: type,
|
|
203
|
+
name: contentData.name,
|
|
204
|
+
path: contentData.path,
|
|
205
|
+
mime: contentData.mime,
|
|
206
|
+
size: Number.parseInt(contentData.size),
|
|
207
|
+
description: contentData.description
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 'video': {
|
|
213
|
+
contentDatas.forEach((contentData) => {
|
|
214
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
215
|
+
_repoPath: repoPath,
|
|
216
|
+
_type: type,
|
|
217
|
+
name: contentData.name,
|
|
218
|
+
path: contentData.path,
|
|
219
|
+
mime: contentData.mime,
|
|
220
|
+
size: Number.parseInt(contentData.size),
|
|
221
|
+
width: Number.parseInt(contentData.width),
|
|
222
|
+
height: Number.parseInt(contentData.height),
|
|
223
|
+
description: contentData.description
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'other': {
|
|
229
|
+
contentDatas.forEach((contentData) => {
|
|
230
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
231
|
+
_repoPath: repoPath,
|
|
232
|
+
_type: type,
|
|
233
|
+
name: contentData.name,
|
|
234
|
+
path: contentData.path,
|
|
235
|
+
mime: contentData.mime,
|
|
236
|
+
size: Number.parseInt(contentData.size),
|
|
237
|
+
properties: contentData.properties,
|
|
238
|
+
description: contentData.description
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if(0 === --this.pendings) {
|
|
245
|
+
return done();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
module.exports = ContentData;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentDocuments extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.size = contentData.size;
|
|
14
|
+
this.description = contentData.description;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = ContentDocuments;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentImage extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.size = contentData.size;
|
|
14
|
+
this.width = contentData.width;
|
|
15
|
+
this.height = contentData.height;
|
|
16
|
+
this.description = contentData.description;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = ContentImage;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentOther extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.size = contentData.size;
|
|
14
|
+
this.properties = contentData.properties;
|
|
15
|
+
this.description = contentData.description;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = ContentOther;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentText extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.encoding = contentData.encoding;
|
|
14
|
+
this.size = contentData.size;
|
|
15
|
+
this.description = contentData.description;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = ContentText;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentVideo extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.size = contentData.size;
|
|
14
|
+
this.width = contentData.width;
|
|
15
|
+
this.height = contentData.height;
|
|
16
|
+
this.description = contentData.description;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = ContentVideo;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorPathData = require('z-abs-corelayer-server/server/path/actor-path-data');
|
|
5
|
+
const ActorPathContent = require('z-abs-corelayer-server/server/path/actor-path-content');
|
|
6
|
+
const Fs = require('fs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Content {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.pendings = 0;
|
|
12
|
+
this.imageContent = new Map();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// TODO: Handle multiple errors
|
|
16
|
+
|
|
17
|
+
load(done) {
|
|
18
|
+
this._loadGlobalContent([
|
|
19
|
+
{
|
|
20
|
+
path: ActorPathData.getContentImageGlobalFile(),
|
|
21
|
+
datas: this.imageContent
|
|
22
|
+
}
|
|
23
|
+
], done);
|
|
24
|
+
this._loadGeneralContent(done);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_loadGlobalContent(contentsToLoad, done) {
|
|
28
|
+
this.pendings = 0;
|
|
29
|
+
let errorResponse = false;
|
|
30
|
+
for(let i = 0; i < contentsToLoad.length; ++i) {
|
|
31
|
+
++this.pendings;
|
|
32
|
+
Fs.readFile(contentsToLoad[i].path, (err, data) => {
|
|
33
|
+
if(!errorResponse) {
|
|
34
|
+
if(err) {
|
|
35
|
+
errorResponse = true;
|
|
36
|
+
done(err);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
let contentDatas = JSON.parse(data);
|
|
40
|
+
contentDatas.forEach((contentData) => {
|
|
41
|
+
contentsToLoad[i].datas.set(contentData.name, {
|
|
42
|
+
repoPath: ActorPathContent.getContentGlobalFolder(),
|
|
43
|
+
value: contentData
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
if(0 === --this.pendings) {
|
|
47
|
+
return done();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_loadGeneralGlobalContent(done) {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = Content;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RuntimeDataShared {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.sharedDatas = new Map();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set(key, value) {
|
|
11
|
+
const sharedDataObject = this.sharedDatas.get(key);
|
|
12
|
+
if(sharedDataObject) {
|
|
13
|
+
sharedDataObject.value = value;
|
|
14
|
+
sharedDataObject.isSet = true;
|
|
15
|
+
return sharedDataObject;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const newSharedDataObject = {
|
|
19
|
+
value: value,
|
|
20
|
+
isSet: true,
|
|
21
|
+
pendings: []
|
|
22
|
+
};
|
|
23
|
+
this.sharedDatas.set(key, newSharedDataObject);
|
|
24
|
+
return newSharedDataObject;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
wait(key, actor, expectedValue, cbGetPending) {
|
|
29
|
+
const sharedDataObject = this.sharedDatas.get(key);
|
|
30
|
+
if(sharedDataObject) {
|
|
31
|
+
if(sharedDataObject.isSet && (expectedValue === sharedDataObject.value || undefined === expectedValue)) {
|
|
32
|
+
return sharedDataObject.value;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const pending = cbGetPending();
|
|
36
|
+
sharedDataObject.pendings.push({
|
|
37
|
+
actor: actor,
|
|
38
|
+
pendingId: pending.id,
|
|
39
|
+
cancelObject: pending.cancelObject,
|
|
40
|
+
expectedValue: expectedValue
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const pending = cbGetPending();
|
|
46
|
+
this.sharedDatas.set(key, {
|
|
47
|
+
value: undefined,
|
|
48
|
+
isSet: false,
|
|
49
|
+
pendings: [{
|
|
50
|
+
actor: actor,
|
|
51
|
+
pendingId: pending.id,
|
|
52
|
+
cancelObject: pending.cancelObject,
|
|
53
|
+
expectedValue: expectedValue
|
|
54
|
+
}]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get(key) {
|
|
61
|
+
return this.sharedDatas.get(key);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
has(key) {
|
|
65
|
+
return this.sharedDatas.has(key);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
log() {
|
|
69
|
+
this.sharedDatas.forEach((sharedData, key) => {
|
|
70
|
+
ddb.info(`key: '${key}' - value: '${sharedData.value}' - pendings: ${shared.pendings.length}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = RuntimeDataShared;
|