starti.app 1.0.4 → 1.0.7

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/dist/app.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const App: IApp;
2
+ export interface IApp {
3
+ onAppInForeground?: () => void;
4
+ isStartiappLoaded(): boolean;
5
+ setAppUrl: (url: string) => void;
6
+ version(): Promise<string>;
7
+ }
package/dist/app.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.App = (_a = class {
5
+ static setStartiappIsLoaded() {
6
+ this.startiappIsLoaded = true;
7
+ }
8
+ static isStartiappLoaded() {
9
+ return this.startiappIsLoaded;
10
+ }
11
+ static setAppUrl(url) {
12
+ // @ts-ignore
13
+ AppIntegration.setAppUrl(url);
14
+ }
15
+ static version() {
16
+ const promise = new Promise((resolve, reject) => {
17
+ this.resolveString = resolve;
18
+ // @ts-ignore
19
+ AppIntegration.version();
20
+ });
21
+ return promise;
22
+ }
23
+ static appInForegroundEventRecievedEvent() {
24
+ if (this.onAppInForeground)
25
+ this.onAppInForeground();
26
+ }
27
+ static versionResult(result) {
28
+ this.resolveString(result);
29
+ }
30
+ },
31
+ _a.startiappIsLoaded = false,
32
+ _a);
package/dist/index.d.ts CHANGED
@@ -1,2 +1,9 @@
1
- import QrScanner from './qrscanner';
2
- export { QrScanner };
1
+ import { IApp } from './app';
2
+ import { IPushNotification } from './pushnotification';
3
+ import { IQrScanner } from './qrscanner';
4
+ export default class startiapp {
5
+ static App: IApp;
6
+ static QrScanner: IQrScanner;
7
+ static PushNotification: IPushNotification;
8
+ static initialize(): void;
9
+ }
package/dist/index.js CHANGED
@@ -1,4 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const app_1 = require("./app");
4
+ const pushnotification_1 = require("./pushnotification");
3
5
  const qrscanner_1 = require("./qrscanner");
4
- exports.QrScanner = qrscanner_1.default;
6
+ const untypedWindow = window;
7
+ untypedWindow.appIntegrationsAreReady = () => {
8
+ app_1.App.setStartiappIsLoaded();
9
+ };
10
+ untypedWindow.App = app_1.App;
11
+ untypedWindow.QrScanner = qrscanner_1.QrScanner;
12
+ untypedWindow.PushNotification = pushnotification_1.PushNotification;
13
+ class startiapp {
14
+ static initialize() {
15
+ // @ts-ignore
16
+ AppIntegration.webAppIsReady();
17
+ }
18
+ }
19
+ exports.default = startiapp;
20
+ startiapp.App = app_1.App;
21
+ startiapp.QrScanner = qrscanner_1.QrScanner;
22
+ startiapp.PushNotification = pushnotification_1.PushNotification;
@@ -0,0 +1,7 @@
1
+ export declare const PushNotification: IPushNotification;
2
+ export interface IPushNotification {
3
+ onTokenReceived?: (token: string) => void;
4
+ onNotificationReceived?: (notification: any) => void;
5
+ initialize(): Promise<boolean>;
6
+ getLastPublishedToken(): Promise<string>;
7
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushNotification = class {
4
+ static initialize() {
5
+ const promise = new Promise((resolve, reject) => {
6
+ this.resolveBoolean = resolve;
7
+ // @ts-ignore
8
+ PushNotificationIntegration.initialize();
9
+ });
10
+ return promise;
11
+ }
12
+ static initializeResult(result) {
13
+ this.resolveBoolean(result);
14
+ }
15
+ static getLastPublishedToken() {
16
+ const promise = new Promise((resolve, reject) => {
17
+ this.resolveString = resolve;
18
+ // @ts-ignore
19
+ PushNotificationIntegration.getLastPublishedToken();
20
+ });
21
+ return promise;
22
+ }
23
+ static getLastPublishedTokenResult(token) {
24
+ this.resolveString(token);
25
+ }
26
+ static tokenReceivedEvent(token) {
27
+ if (this.onTokenReceived)
28
+ this.onTokenReceived(token);
29
+ }
30
+ static notificationReceivedEvent(notification) {
31
+ if (this.onNotificationReceived)
32
+ this.onNotificationReceived(notification);
33
+ }
34
+ };
@@ -0,0 +1,6 @@
1
+ export declare const PushNotifications: {
2
+ new (): {};
3
+ resolve: (value: string | PromiseLike<string>) => void;
4
+ scan(): Promise<string>;
5
+ qrResultRecievedEvent(message: string): void;
6
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushNotifications = class {
4
+ static scan() {
5
+ const promise = new Promise((resolve, reject) => {
6
+ this.resolve = resolve;
7
+ try {
8
+ const qrScannerIntegration = window.QrScannerIntegration;
9
+ if (!qrScannerIntegration) {
10
+ resolve('Scanner virker kun i starti.app');
11
+ return;
12
+ }
13
+ qrScannerIntegration.startQrCodeScanner();
14
+ }
15
+ catch (e) {
16
+ reject(e);
17
+ }
18
+ });
19
+ return promise;
20
+ }
21
+ static qrResultRecievedEvent(message) {
22
+ this.resolve(message);
23
+ }
24
+ };
@@ -0,0 +1,6 @@
1
+ export declare const QrScanner: {
2
+ new (): {};
3
+ resolve: (value: string | PromiseLike<string>) => void;
4
+ scan(): Promise<string>;
5
+ qrResultRecievedEvent(message: string): void;
6
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QrScanner = class {
4
+ static scan() {
5
+ const promise = new Promise((resolve, reject) => {
6
+ this.resolve = resolve;
7
+ try {
8
+ const qrScannerIntegration = window.QrScannerIntegration;
9
+ if (!qrScannerIntegration) {
10
+ resolve('Scanner virker kun i starti.app');
11
+ return;
12
+ }
13
+ qrScannerIntegration.startQrCodeScanner();
14
+ }
15
+ catch (e) {
16
+ reject(e);
17
+ }
18
+ });
19
+ return promise;
20
+ }
21
+ static qrResultRecievedEvent(message) {
22
+ this.resolve(message);
23
+ }
24
+ };
@@ -1,4 +1,4 @@
1
- export default class QrScanner {
2
- static webAppIsReady(): void;
3
- static scan(): Promise<string>;
1
+ export declare const QrScanner: IQrScanner;
2
+ export interface IQrScanner {
3
+ scan(): Promise<string>;
4
4
  }
package/dist/qrscanner.js CHANGED
@@ -1,21 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- class QrScanner {
4
- static webAppIsReady() {
5
- try {
6
- // @ts-ignore
7
- AppIntegration.webAppIsReady();
8
- }
9
- catch (_a) { }
10
- }
3
+ exports.QrScanner = class {
11
4
  static scan() {
12
5
  const promise = new Promise((resolve, reject) => {
13
- window.QrScanner = {
14
- qrResultRecievedEvent: (message) => {
15
- resolve(message);
16
- window.QrScanner = null;
17
- }
18
- };
6
+ this.resolve = resolve;
19
7
  try {
20
8
  const qrScannerIntegration = window.QrScannerIntegration;
21
9
  if (!qrScannerIntegration) {
@@ -30,5 +18,7 @@ class QrScanner {
30
18
  });
31
19
  return promise;
32
20
  }
33
- }
34
- exports.default = QrScanner;
21
+ static qrResultRecievedEvent(message) {
22
+ this.resolve(message);
23
+ }
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starti.app",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "Use this package for easy communication with the starti.app API.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",