@vived/app 3.2.1 → 3.3.0
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/lib/AppObjectComponents/Dispatcher/Entities/AppDispatcher.d.ts +16 -0
- package/lib/AppObjectComponents/Dispatcher/Entities/AppDispatcher.js +40 -0
- package/lib/AppObjectComponents/Dispatcher/Factories/makeBasicDispatcher.d.ts +4 -0
- package/lib/AppObjectComponents/Dispatcher/Factories/makeBasicDispatcher.js +12 -0
- package/lib/AppObjectComponents/Dispatcher/UC/DispatchStopZSpaceUC.d.ts +10 -0
- package/lib/AppObjectComponents/Dispatcher/UC/DispatchStopZSpaceUC.js +44 -0
- package/lib/AppObjectComponents/Dispatcher/index.d.ts +3 -0
- package/lib/AppObjectComponents/Dispatcher/index.js +15 -0
- package/lib/Entities/AppDispatcher.d.ts +0 -1
- package/lib/Entities/AppDispatcher.js +0 -3
- package/lib/UseCases/Handlers/StartZSpaceBase.d.ts +3 -3
- package/lib/UseCases/Handlers/StartZSpaceBase.js +7 -4
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppObject } from "../../../AppObject/AppObject";
|
|
2
|
+
import { AppObjectEntity } from "../../../AppObject/AppObjectEntity";
|
|
3
|
+
import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
|
|
4
|
+
export declare type Handler = (request: Request) => void;
|
|
5
|
+
export interface Request {
|
|
6
|
+
type: string;
|
|
7
|
+
version: number;
|
|
8
|
+
payload?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class AppDispatcher extends AppObjectEntity {
|
|
11
|
+
static readonly type = "APP_DISPATCHER";
|
|
12
|
+
abstract dispatch: (request: Request) => void;
|
|
13
|
+
abstract formRequestAndDispatch: (type: string, version: number, payload?: object | undefined) => void;
|
|
14
|
+
static get(appObjects: AppObjectRepo): AppDispatcher | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function makeAppDispatcher(appObject: AppObject, hostHandler: Handler): AppDispatcher;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAppDispatcher = exports.AppDispatcher = void 0;
|
|
4
|
+
const AppObjectEntity_1 = require("../../../AppObject/AppObjectEntity");
|
|
5
|
+
class AppDispatcher extends AppObjectEntity_1.AppObjectEntity {
|
|
6
|
+
static get(appObjects) {
|
|
7
|
+
const selectionEntities = appObjects.getAllComponents(AppDispatcher.type);
|
|
8
|
+
if (selectionEntities.length === 0) {
|
|
9
|
+
console.warn("Unable to find a App Dispatcher. Add one on Mount");
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
else if (selectionEntities.length > 1) {
|
|
13
|
+
console.warn("Multiple App Dispatcher have been found. There should only be one. Using the first one");
|
|
14
|
+
}
|
|
15
|
+
return selectionEntities[0];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AppDispatcher = AppDispatcher;
|
|
19
|
+
AppDispatcher.type = "APP_DISPATCHER";
|
|
20
|
+
function makeAppDispatcher(appObject, hostHandler) {
|
|
21
|
+
return new AppDispatcherImp(appObject, hostHandler);
|
|
22
|
+
}
|
|
23
|
+
exports.makeAppDispatcher = makeAppDispatcher;
|
|
24
|
+
class AppDispatcherImp extends AppDispatcher {
|
|
25
|
+
constructor(appObject, hostHandler) {
|
|
26
|
+
super(appObject, AppDispatcher.type);
|
|
27
|
+
this.hostHandler = hostHandler;
|
|
28
|
+
this.dispatch = (request) => {
|
|
29
|
+
this.hostHandler(request);
|
|
30
|
+
};
|
|
31
|
+
this.formRequestAndDispatch = (type, version, payload) => {
|
|
32
|
+
const request = {
|
|
33
|
+
type,
|
|
34
|
+
version,
|
|
35
|
+
payload
|
|
36
|
+
};
|
|
37
|
+
this.hostHandler(request);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
|
|
2
|
+
import { Handler } from "../Entities/AppDispatcher";
|
|
3
|
+
export declare const APP_DISPATCHER_ID = "AppDispatcher";
|
|
4
|
+
export declare function makeBasicDispatcher(appObjects: AppObjectRepo, hostHandler: Handler): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeBasicDispatcher = exports.APP_DISPATCHER_ID = void 0;
|
|
4
|
+
const AppDispatcher_1 = require("../Entities/AppDispatcher");
|
|
5
|
+
const DispatchStopZSpaceUC_1 = require("../UC/DispatchStopZSpaceUC");
|
|
6
|
+
exports.APP_DISPATCHER_ID = "AppDispatcher";
|
|
7
|
+
function makeBasicDispatcher(appObjects, hostHandler) {
|
|
8
|
+
const dispatcherAO = appObjects.getOrCreate(exports.APP_DISPATCHER_ID);
|
|
9
|
+
AppDispatcher_1.makeAppDispatcher(dispatcherAO, hostHandler);
|
|
10
|
+
DispatchStopZSpaceUC_1.makeDispatchStopZSpaceUC(dispatcherAO);
|
|
11
|
+
}
|
|
12
|
+
exports.makeBasicDispatcher = makeBasicDispatcher;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AppObject } from "../../../AppObject/AppObject";
|
|
2
|
+
import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
|
|
3
|
+
import { AppObjectUC } from "../../../AppObject/AppObjectUC";
|
|
4
|
+
export declare abstract class DispatchStopZSpaceUC extends AppObjectUC {
|
|
5
|
+
static readonly type = "DispatchStopZSpaceUC";
|
|
6
|
+
readonly requestType = "STOP_ZSPACE";
|
|
7
|
+
abstract doDispatch(): void;
|
|
8
|
+
static get(appObjects: AppObjectRepo): DispatchStopZSpaceUC | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function makeDispatchStopZSpaceUC(appObject: AppObject): DispatchStopZSpaceUC;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeDispatchStopZSpaceUC = exports.DispatchStopZSpaceUC = void 0;
|
|
4
|
+
const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
|
|
5
|
+
const AppDispatcher_1 = require("../Entities/AppDispatcher");
|
|
6
|
+
class DispatchStopZSpaceUC extends AppObjectUC_1.AppObjectUC {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.requestType = "STOP_ZSPACE";
|
|
10
|
+
}
|
|
11
|
+
static get(appObjects) {
|
|
12
|
+
const selectionEntities = appObjects.getAllComponents(DispatchStopZSpaceUC.type);
|
|
13
|
+
if (selectionEntities.length === 0) {
|
|
14
|
+
console.warn("Unable to find a DispatchStopZSpaceUC. Add one on Mount");
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
else if (selectionEntities.length > 1) {
|
|
18
|
+
console.warn("Multiple DispatchStopZSpaceUC have been found. There should only be one. Using the first one");
|
|
19
|
+
}
|
|
20
|
+
return selectionEntities[0];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.DispatchStopZSpaceUC = DispatchStopZSpaceUC;
|
|
24
|
+
DispatchStopZSpaceUC.type = "DispatchStopZSpaceUC";
|
|
25
|
+
function makeDispatchStopZSpaceUC(appObject) {
|
|
26
|
+
return new DispatchStateChangeUCImp(appObject);
|
|
27
|
+
}
|
|
28
|
+
exports.makeDispatchStopZSpaceUC = makeDispatchStopZSpaceUC;
|
|
29
|
+
class DispatchStateChangeUCImp extends DispatchStopZSpaceUC {
|
|
30
|
+
constructor(appObject) {
|
|
31
|
+
super(appObject, DispatchStopZSpaceUC.type);
|
|
32
|
+
this.requestVersion = 1;
|
|
33
|
+
this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
|
|
34
|
+
if (!this.appDispatcher) {
|
|
35
|
+
console.warn("DispatchStopZSpaceUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
|
|
36
|
+
this.dispose();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
doDispatch() {
|
|
40
|
+
if (!this.appDispatcher)
|
|
41
|
+
return;
|
|
42
|
+
this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Entities/AppDispatcher"), exports);
|
|
14
|
+
__exportStar(require("./Factories/makeBasicDispatcher"), exports);
|
|
15
|
+
__exportStar(require("./UC/DispatchStopZSpaceUC"), exports);
|
|
@@ -58,7 +58,6 @@ export declare abstract class AppDispatcher {
|
|
|
58
58
|
abstract getAssetsForOwner: (ownerID: string) => Promise<AssetMetaDTO[]>;
|
|
59
59
|
abstract isAssetFetched: (data: IsAssetFetchedDTO) => void;
|
|
60
60
|
abstract submitNewActivityAsset: (file: File) => Promise<string>;
|
|
61
|
-
abstract stopZSpace: () => void;
|
|
62
61
|
abstract showAlert: (data: ShowAlertDTO) => void;
|
|
63
62
|
abstract showConfirm: (data: ShowConfirmDTO) => void;
|
|
64
63
|
abstract showMarkDownEditor: (data: ShowMarkDownEditorDTO) => void;
|
|
@@ -268,9 +268,6 @@ class AppDistpatcherImp extends AppDispatcher {
|
|
|
268
268
|
this.goToNextState = () => {
|
|
269
269
|
this.formRequestAndDispatch("GO_TO_NEXT_STATE", 1);
|
|
270
270
|
};
|
|
271
|
-
this.stopZSpace = () => {
|
|
272
|
-
this.formRequestAndDispatch("STOP_ZSPACE", 1);
|
|
273
|
-
};
|
|
274
271
|
this.hasNextState = () => {
|
|
275
272
|
return new Promise((resolve, reject) => {
|
|
276
273
|
const callback = (hasNextState) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AppHandler, RequestHandler } from "../../Entities";
|
|
2
|
-
export declare type StartZSpaceAction = (device: string, session: any) => void;
|
|
2
|
+
export declare type StartZSpaceAction = (device: string, session: any, emulate: boolean) => void;
|
|
3
3
|
export declare class StartZSpaceBase extends RequestHandler {
|
|
4
4
|
readonly requestType = "START_ZSPACE";
|
|
5
|
-
readonly payloadVersion =
|
|
5
|
+
readonly payloadVersion = 2;
|
|
6
6
|
action: StartZSpaceAction;
|
|
7
7
|
handleRequest: (version: number, payload: unknown) => void;
|
|
8
|
-
private
|
|
8
|
+
private castPayloadV2;
|
|
9
9
|
constructor(handler: AppHandler);
|
|
10
10
|
}
|
|
@@ -6,14 +6,14 @@ class StartZSpaceBase extends Entities_1.RequestHandler {
|
|
|
6
6
|
constructor(handler) {
|
|
7
7
|
super();
|
|
8
8
|
this.requestType = "START_ZSPACE";
|
|
9
|
-
this.payloadVersion =
|
|
9
|
+
this.payloadVersion = 2;
|
|
10
10
|
this.action = () => {
|
|
11
11
|
throw new Entities_1.ActionNotImplemented(this.requestType);
|
|
12
12
|
};
|
|
13
13
|
this.handleRequest = (version, payload) => {
|
|
14
14
|
if (version === this.payloadVersion) {
|
|
15
|
-
const { device, session } = this.
|
|
16
|
-
this.action(device, session);
|
|
15
|
+
const { device, session, emulate } = this.castPayloadV2(payload);
|
|
16
|
+
this.action(device, session, emulate);
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
|
|
@@ -21,11 +21,14 @@ class StartZSpaceBase extends Entities_1.RequestHandler {
|
|
|
21
21
|
};
|
|
22
22
|
handler.registerRequestHandler(this);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
castPayloadV2(payload) {
|
|
25
25
|
const castPayload = payload;
|
|
26
26
|
if (castPayload.device === undefined || castPayload.session === undefined) {
|
|
27
27
|
throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
|
|
28
28
|
}
|
|
29
|
+
if (castPayload.emulate === undefined) {
|
|
30
|
+
castPayload.emulate = false;
|
|
31
|
+
}
|
|
29
32
|
return castPayload;
|
|
30
33
|
}
|
|
31
34
|
}
|