@vived/app 2.31.0 → 2.33.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.
@@ -4,6 +4,20 @@ export interface AssetMetaDTO {
4
4
  name: string;
5
5
  description: string;
6
6
  }
7
+ export interface ShowAlertDTO {
8
+ title: string;
9
+ message: string;
10
+ closeButtonLabel: string;
11
+ closeCallback: () => void;
12
+ }
13
+ export interface ShowConfirmDTO {
14
+ title: string;
15
+ message: string;
16
+ confirmButtonLabel: string;
17
+ cancelButtonLabel: string;
18
+ confirmCallback: () => void;
19
+ cancelCallback: () => void;
20
+ }
7
21
  export declare abstract class AppDispatcher {
8
22
  abstract registerHostHandler: (hostHandler: Handler) => void;
9
23
  abstract dispatch: (request: Request) => void;
@@ -21,6 +35,7 @@ export declare abstract class AppDispatcher {
21
35
  abstract logError: (sender: string, message: string) => void;
22
36
  abstract logFatalError: (sender: string, message: string) => void;
23
37
  abstract submitHitResult: (success: boolean, description: string) => void;
38
+ abstract submitProgressResult: (progress: number, description: string) => void;
24
39
  abstract submitMultiHitResult: (hits: number, misses: number, unanswered: number, description: string) => void;
25
40
  abstract submitQualityResult: (stars: number, maxStars: number, description: string) => void;
26
41
  abstract submitScoreResult: (score: number, maxScore: number, description: string) => void;
@@ -29,5 +44,7 @@ export declare abstract class AppDispatcher {
29
44
  abstract getAssetsForOwner: (ownerID: string) => Promise<AssetMetaDTO[]>;
30
45
  abstract submitNewActivityAsset: (file: File) => Promise<string>;
31
46
  abstract stopZSpace: () => void;
47
+ abstract showAlert: (data: ShowAlertDTO) => void;
48
+ abstract showConfirm: (data: ShowConfirmDTO) => void;
32
49
  }
33
50
  export declare function makeAppDispatcher(): AppDispatcher;
@@ -111,6 +111,16 @@ class AppDistpatcherImp extends AppDispatcher {
111
111
  };
112
112
  this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
113
113
  };
114
+ this.submitProgressResult = (progress, description) => {
115
+ const payload = {
116
+ resultType: "PROGRESS_V1",
117
+ description,
118
+ result: {
119
+ progress,
120
+ },
121
+ };
122
+ this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
123
+ };
114
124
  this.submitMultiHitResult = (hits, misses, unanswered, description) => {
115
125
  const payload = {
116
126
  resultType: "MULTIHIT_V1",
@@ -269,6 +279,26 @@ class AppDistpatcherImp extends AppDispatcher {
269
279
  }
270
280
  });
271
281
  };
282
+ this.showAlert = (data) => {
283
+ const payload = {
284
+ title: data.title,
285
+ message: data.message,
286
+ closeButtonLabel: data.closeButtonLabel,
287
+ closeCallback: data.closeCallback,
288
+ };
289
+ this.formRequestAndDispatch("SHOW_ALERT", 1, payload);
290
+ };
291
+ this.showConfirm = (data) => {
292
+ const payload = {
293
+ title: data.title,
294
+ message: data.message,
295
+ confirmCallback: data.confirmCallback,
296
+ cancelButtonLabel: data.cancelButtonLabel,
297
+ cancelCallback: data.cancelCallback,
298
+ confirmButtonLabel: data.confirmButtonLabel,
299
+ };
300
+ this.formRequestAndDispatch("SHOW_CONFIRM", 1, payload);
301
+ };
272
302
  }
273
303
  formRequestAndDispatch(type, version, payload) {
274
304
  const request = {
@@ -1,14 +1,8 @@
1
- import { Result } from "../ValueObjects";
2
1
  export declare type MessageDataFile = {
3
2
  [key: string]: string;
4
3
  };
5
4
  export interface MessageSystem {
6
5
  setMessages: (messages: MessageDataFile) => void;
7
- getMessage: (keyword: string) => Result<string, Error>;
8
- }
9
- export declare class MessageSystemImp implements MessageSystem {
10
- private messages;
11
- setMessages: (messages: MessageDataFile) => void;
12
- getMessage: (keyword: string) => Result<string, Error>;
6
+ getMessage: (keyword: string, fallbackMessage?: string) => string | undefined;
13
7
  }
14
8
  export declare function makeMessageSystem(): MessageSystem;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMessageSystem = exports.MessageSystemImp = void 0;
4
- const ValueObjects_1 = require("../ValueObjects");
3
+ exports.makeMessageSystem = void 0;
5
4
  class MessageSystemImp {
6
5
  constructor() {
7
6
  this.messages = new Map();
@@ -13,19 +12,15 @@ class MessageSystemImp {
13
12
  }
14
13
  }
15
14
  };
16
- this.getMessage = (keyword) => {
17
- const message = this.messages.get(keyword);
18
- if (message) {
19
- return new ValueObjects_1.Resolved(message);
20
- }
21
- else {
22
- const err = new Error("Message System cant find message from keyword: " + keyword);
23
- return new ValueObjects_1.Rejected(err);
15
+ this.getMessage = (keyword, fallbackMessage) => {
16
+ let msg = this.messages.get(keyword);
17
+ if (msg === undefined) {
18
+ msg = fallbackMessage;
24
19
  }
20
+ return msg;
25
21
  };
26
22
  }
27
23
  }
28
- exports.MessageSystemImp = MessageSystemImp;
29
24
  function makeMessageSystem() {
30
25
  return new MessageSystemImp();
31
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "2.31.0",
3
+ "version": "2.33.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",