starti.app 1.0.13 → 1.0.15
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/README.md +18 -0
- package/dist/app.d.ts +4 -2
- package/dist/app.js +31 -30
- package/dist/index.d.ts +11 -8
- package/dist/index.js +16 -12
- package/dist/pushnotification.d.ts +4 -4
- package/dist/pushnotification.js +12 -14
- package/dist/qrscanner.js +5 -7
- package/package.json +2 -2
- package/umd/main.js +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# starti.app API
|
|
2
|
+
|
|
3
|
+
## When should I use this package?
|
|
4
|
+
|
|
5
|
+
You've bought a [start.app](https://starti.app) and want to integrate your website and the app.
|
|
6
|
+
|
|
7
|
+
This package allows you to talk to the app using an easy API.
|
|
8
|
+
|
|
9
|
+
## How do I get started
|
|
10
|
+
|
|
11
|
+
Add the package to your project in one of two ways:
|
|
12
|
+
|
|
13
|
+
1) Add the package using npm:
|
|
14
|
+
`npm install starti.app@1.0.12`
|
|
15
|
+
|
|
16
|
+
2) Add the following line to your HTML file:
|
|
17
|
+
`<script crossorigin src="https://unpkg.com/starti.app@1.0.12/umd/main.js"></script>`
|
|
18
|
+
|
package/dist/app.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export declare const App: IApp;
|
|
2
|
+
declare type AppEvents = "appInForeground";
|
|
2
3
|
export interface IApp {
|
|
3
|
-
/** The event will be called whenever the app enters the foreground on the device and when the app starts og thus also enters the foreground on the device. */
|
|
4
|
-
onAppInForeground?: () => void;
|
|
5
4
|
/** Are the site running inside starti.app? Returns false if the site is loaded in a normal browser. */
|
|
6
5
|
isStartiappLoaded(): boolean;
|
|
7
6
|
/** Use this method to control which URL the app load when it is initialized. */
|
|
8
7
|
setAppUrl: (url: string) => void;
|
|
9
8
|
/** Returns the version number of the app (eg. 1.0.0). */
|
|
10
9
|
version(): Promise<string>;
|
|
10
|
+
/** Listen for events */
|
|
11
|
+
addEventListener(type: AppEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
11
12
|
}
|
|
13
|
+
export {};
|
package/dist/app.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.App = void 0;
|
|
5
|
-
exports.App =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
exports.App = new class extends EventTarget {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.startiappIsLoaded = false;
|
|
8
|
+
}
|
|
9
|
+
setStartiappIsLoaded() {
|
|
10
|
+
this.startiappIsLoaded = true;
|
|
11
|
+
}
|
|
12
|
+
isStartiappLoaded() {
|
|
13
|
+
return this.startiappIsLoaded;
|
|
14
|
+
}
|
|
15
|
+
setAppUrl(url) {
|
|
16
|
+
AppIntegration.setAppUrl(url);
|
|
17
|
+
}
|
|
18
|
+
version() {
|
|
19
|
+
const promise = new Promise((resolve, reject) => {
|
|
20
|
+
this.resolveString = resolve;
|
|
21
|
+
AppIntegration.version();
|
|
22
|
+
});
|
|
23
|
+
return promise;
|
|
24
|
+
}
|
|
25
|
+
appInForegroundEventRecievedEvent() {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
27
|
+
}
|
|
28
|
+
versionResult(result) {
|
|
29
|
+
this.resolveString(result);
|
|
30
|
+
}
|
|
31
|
+
addEventListener(type, callback, options) {
|
|
32
|
+
super.addEventListener(type, callback, options);
|
|
33
|
+
}
|
|
34
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { IApp } from './app';
|
|
2
2
|
import { IPushNotification } from './pushnotification';
|
|
3
3
|
import { IQrScanner } from './qrscanner';
|
|
4
|
-
|
|
4
|
+
declare const startiapp: {
|
|
5
5
|
/** Basic calls to the app. */
|
|
6
|
-
|
|
6
|
+
App: IApp;
|
|
7
7
|
/** The QR- and barcode scanning functionality. */
|
|
8
|
-
|
|
8
|
+
QrScanner: IQrScanner;
|
|
9
9
|
/** Access to push notifications using Firebase. */
|
|
10
|
-
|
|
11
|
-
/** When all integrations in the app are ready we should call initialize(). */
|
|
12
|
-
static onIntegrationsAreReady?: () => void;
|
|
10
|
+
PushNotification: IPushNotification;
|
|
13
11
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
initialize(): void;
|
|
13
|
+
addEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
14
|
+
dispatchEvent(event: Event): boolean;
|
|
15
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
16
|
+
};
|
|
17
|
+
declare type StartiappEvents = "integrationsAreReady";
|
|
18
|
+
export default startiapp;
|
package/dist/index.js
CHANGED
|
@@ -6,25 +6,29 @@ const qrscanner_1 = require("./qrscanner");
|
|
|
6
6
|
const untypedWindow = window;
|
|
7
7
|
untypedWindow.appIntegrationsAreReady = () => {
|
|
8
8
|
app_1.App.setStartiappIsLoaded();
|
|
9
|
-
|
|
10
|
-
startiapp.onIntegrationsAreReady();
|
|
9
|
+
startiapp.dispatchEvent(new CustomEvent('integrationsAreReady'));
|
|
11
10
|
};
|
|
12
11
|
untypedWindow.App = app_1.App;
|
|
13
12
|
untypedWindow.QrScanner = qrscanner_1.QrScanner;
|
|
14
13
|
untypedWindow.PushNotification = pushnotification_1.PushNotification;
|
|
15
|
-
|
|
14
|
+
const startiapp = new class extends EventTarget {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** Basic calls to the app. */
|
|
18
|
+
this.App = app_1.App;
|
|
19
|
+
/** The QR- and barcode scanning functionality. */
|
|
20
|
+
this.QrScanner = qrscanner_1.QrScanner;
|
|
21
|
+
/** Access to push notifications using Firebase. */
|
|
22
|
+
this.PushNotification = pushnotification_1.PushNotification;
|
|
23
|
+
}
|
|
16
24
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
17
|
-
|
|
25
|
+
initialize() {
|
|
18
26
|
if (app_1.App.isStartiappLoaded())
|
|
19
|
-
// @ts-ignore
|
|
20
27
|
AppIntegration.webAppIsReady();
|
|
21
28
|
}
|
|
22
|
-
|
|
29
|
+
addEventListener(type, callback, options) {
|
|
30
|
+
super.addEventListener(type, callback, options);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
23
33
|
exports.default = startiapp;
|
|
24
|
-
/** Basic calls to the app. */
|
|
25
|
-
startiapp.App = app_1.App;
|
|
26
|
-
/** The QR- and barcode scanning functionality. */
|
|
27
|
-
startiapp.QrScanner = qrscanner_1.QrScanner;
|
|
28
|
-
/** Access to push notifications using Firebase. */
|
|
29
|
-
startiapp.PushNotification = pushnotification_1.PushNotification;
|
|
30
34
|
untypedWindow.startiapp = startiapp;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare const PushNotification: IPushNotification;
|
|
2
|
+
declare type PushNotificationEvents = "tokenReceived" | "notificationReceived";
|
|
2
3
|
export interface IPushNotification {
|
|
3
|
-
/** Called with the token used to send push notifications to the current device. */
|
|
4
|
-
onTokenReceived?: (token: string) => void;
|
|
5
|
-
/** Called with the notification that has been received by the mobile. The content of notification is the content that has been sent from the backend. There will also be a special property called appWasLaunchedFromNotification which indicated wether the app entered the foreground because a notification as pressed on the device or wether the app already was in the foreground when the notification was received. */
|
|
6
|
-
onNotificationReceived?: (notification: any) => void;
|
|
7
4
|
/** This method should be called when the user want’s to receive push notifications. */
|
|
8
5
|
initialize(): Promise<boolean>;
|
|
9
6
|
/** This method returns the token which should be used to send push notifications. */
|
|
10
7
|
getLastPublishedToken(): Promise<string>;
|
|
8
|
+
/** Listen for events */
|
|
9
|
+
addEventListener(type: PushNotificationEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
11
10
|
}
|
|
11
|
+
export {};
|
package/dist/pushnotification.js
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PushNotification = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
exports.PushNotification = new class extends EventTarget {
|
|
5
|
+
initialize() {
|
|
6
6
|
const promise = new Promise((resolve, reject) => {
|
|
7
7
|
this.resolveBoolean = resolve;
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
PushNotificationIntegration.initialize();
|
|
10
9
|
});
|
|
11
10
|
return promise;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
initializeResult(result) {
|
|
14
13
|
this.resolveBoolean(result);
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
getLastPublishedToken() {
|
|
17
16
|
const promise = new Promise((resolve, reject) => {
|
|
18
17
|
this.resolveString = resolve;
|
|
19
|
-
// @ts-ignore
|
|
20
18
|
PushNotificationIntegration.getLastPublishedToken();
|
|
21
19
|
});
|
|
22
20
|
return promise;
|
|
23
21
|
}
|
|
24
|
-
|
|
22
|
+
getLastPublishedTokenResult(token) {
|
|
25
23
|
this.resolveString(token);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.onTokenReceived(token);
|
|
25
|
+
tokenReceivedEvent(token) {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('tokenReceived', { detail: token }));
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
notificationReceivedEvent(notification) {
|
|
29
|
+
this.dispatchEvent(new CustomEvent('notificationReceived', { detail: notification }));
|
|
30
|
+
}
|
|
31
|
+
addEventListener(type, callback, options) {
|
|
32
|
+
super.addEventListener(type, callback, options);
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
|
-
exports.PushNotification = PushNotification;
|
package/dist/qrscanner.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QrScanner = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
exports.QrScanner = new class extends EventTarget {
|
|
5
|
+
scan() {
|
|
6
6
|
const promise = new Promise((resolve, reject) => {
|
|
7
7
|
this.resolve = resolve;
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
if (!qrScannerIntegration) {
|
|
9
|
+
if (!QrScannerIntegration) {
|
|
11
10
|
resolve('Scanner virker kun i starti.app');
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
QrScannerIntegration.startQrCodeScanner();
|
|
15
14
|
}
|
|
16
15
|
catch (e) {
|
|
17
16
|
reject(e);
|
|
@@ -19,8 +18,7 @@ const QrScanner = class {
|
|
|
19
18
|
});
|
|
20
19
|
return promise;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
qrResultRecievedEvent(message) {
|
|
23
22
|
this.resolve(message);
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
|
-
exports.QrScanner = QrScanner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starti.app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
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",
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
"build:prod": "webpack --mode=production --node-env=production",
|
|
22
22
|
"watch": "webpack --watch"
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
package/umd/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(self,(()=>(()=>{"use strict";var e={752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0,t.App=new class extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){AppIntegration.setAppUrl(e)}version(){return new Promise(((e,t)=>{this.resolveString=e,AppIntegration.version()}))}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}versionResult(e){this.resolveString(e)}addEventListener(e,t,n){super.addEventListener(e,t,n)}}},681:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0,t.PushNotification=new class extends EventTarget{initialize(){return new Promise(((e,t)=>{this.resolveBoolean=e,PushNotificationIntegration.initialize()}))}initializeResult(e){this.resolveBoolean(e)}getLastPublishedToken(){return new Promise(((e,t)=>{this.resolveString=e,PushNotificationIntegration.getLastPublishedToken()}))}getLastPublishedTokenResult(e){this.resolveString(e)}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenReceived",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}addEventListener(e,t,n){super.addEventListener(e,t,n)}}},952:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0,t.QrScanner=new class extends EventTarget{scan(){return new Promise(((e,t)=>{this.resolve=e;try{if(!QrScannerIntegration)return void e("Scanner virker kun i starti.app");QrScannerIntegration.startQrCodeScanner()}catch(e){t(e)}}))}qrResultRecievedEvent(e){this.resolve(e)}}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}var i={};return(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:!0});const t=n(752),r=n(681),s=n(952),o=window;o.appIntegrationsAreReady=()=>{t.App.setStartiappIsLoaded(),a.dispatchEvent(new CustomEvent("integrationsAreReady"))},o.App=t.App,o.QrScanner=s.QrScanner,o.PushNotification=r.PushNotification;const a=new class extends EventTarget{constructor(){super(...arguments),this.App=t.App,this.QrScanner=s.QrScanner,this.PushNotification=r.PushNotification}initialize(){t.App.isStartiappLoaded()&&AppIntegration.webAppIsReady()}addEventListener(e,t,n){super.addEventListener(e,t,n)}};e.default=a,o.startiapp=a})(),i})()));
|