@ikas/app-helpers
Advanced tools
Comparing version 1.0.1 to 1.0.2-alpha.0
@@ -11,2 +11,3 @@ export declare class AppBridgeHelper { | ||
static getNewToken(): Promise<string | undefined>; | ||
static getDashboardLanguage(): Promise<string | undefined>; | ||
static sendEvent(event: AppEvent): void; | ||
@@ -21,6 +22,10 @@ } | ||
REQUEST_TOKEN = "REQUEST_TOKEN", | ||
CLOSE_APP = "CLOSE_APP" | ||
CLOSE_APP = "CLOSE_APP", | ||
AUTHORIZED_APP_ID = "AUTHORIZED_APP_ID", | ||
GET_DASHBOARD_LANGUAGE = "GET_DASHBOARD_LANGUAGE" | ||
} | ||
export declare enum AppBridgeCallbackMessageType { | ||
REQUEST_TOKEN_RESPONSE = "REQUEST_TOKEN_RESPONSE" | ||
REQUEST_TOKEN_RESPONSE = "REQUEST_TOKEN_RESPONSE", | ||
AUTHORIZED_APP_ID_RESPONSE = "AUTHORIZED_APP_ID_RESPONSE", | ||
GET_DASHBOARD_LANGUAGE_RESPONSE = "GET_DASHBOARD_LANGUAGE_RESPONSE" | ||
} | ||
@@ -27,0 +32,0 @@ export declare type AppEvent = { |
@@ -85,2 +85,28 @@ "use strict"; | ||
} | ||
static getDashboardLanguage() { | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject('Timed out'), 30000); | ||
try { | ||
const callback = (msg) => { | ||
var _a, _b, _c; | ||
if (((_a = msg.data) === null || _a === void 0 ? void 0 : _a.type) === AppBridgeCallbackMessageType.GET_DASHBOARD_LANGUAGE_RESPONSE) { | ||
const lang = (_c = (_b = msg.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.lang; | ||
resolve(lang); | ||
AppBridgeHelper.stopListener(callback); | ||
clearTimeout(timer); | ||
} | ||
}; | ||
AppBridgeHelper.startListener(callback); | ||
const event = { | ||
type: AppBridgeMessageType.GET_DASHBOARD_LANGUAGE, | ||
data: {}, | ||
}; | ||
AppBridgeHelper.sendEvent(event); | ||
} | ||
catch (e) { | ||
clearTimeout(timer); | ||
reject(e); | ||
} | ||
}); | ||
} | ||
static sendEvent(event) { | ||
@@ -101,2 +127,4 @@ //@ts-ignore | ||
AppBridgeMessageType["CLOSE_APP"] = "CLOSE_APP"; | ||
AppBridgeMessageType["AUTHORIZED_APP_ID"] = "AUTHORIZED_APP_ID"; | ||
AppBridgeMessageType["GET_DASHBOARD_LANGUAGE"] = "GET_DASHBOARD_LANGUAGE"; | ||
})(AppBridgeMessageType = exports.AppBridgeMessageType || (exports.AppBridgeMessageType = {})); | ||
@@ -106,3 +134,5 @@ var AppBridgeCallbackMessageType; | ||
AppBridgeCallbackMessageType["REQUEST_TOKEN_RESPONSE"] = "REQUEST_TOKEN_RESPONSE"; | ||
AppBridgeCallbackMessageType["AUTHORIZED_APP_ID_RESPONSE"] = "AUTHORIZED_APP_ID_RESPONSE"; | ||
AppBridgeCallbackMessageType["GET_DASHBOARD_LANGUAGE_RESPONSE"] = "GET_DASHBOARD_LANGUAGE_RESPONSE"; | ||
})(AppBridgeCallbackMessageType = exports.AppBridgeCallbackMessageType || (exports.AppBridgeCallbackMessageType = {})); | ||
//# sourceMappingURL=app-bridge.js.map |
{ | ||
"name": "@ikas/app-helpers", | ||
"version": "1.0.1", | ||
"version": "1.0.2-alpha.0", | ||
"description": "ikas store app helpers", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -99,2 +99,31 @@ export class AppBridgeHelper { | ||
static getDashboardLanguage(): Promise<string | undefined> { | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject('Timed out'), 30000); | ||
try { | ||
const callback = (msg: MessageEvent) => { | ||
if (msg.data?.type === AppBridgeCallbackMessageType.GET_DASHBOARD_LANGUAGE_RESPONSE) { | ||
const lang = msg.data?.data?.lang; | ||
resolve(lang); | ||
AppBridgeHelper.stopListener(callback); | ||
clearTimeout(timer); | ||
} | ||
}; | ||
AppBridgeHelper.startListener(callback); | ||
const event: AppEvent = { | ||
type: AppBridgeMessageType.GET_DASHBOARD_LANGUAGE, | ||
data: {}, | ||
}; | ||
AppBridgeHelper.sendEvent(event); | ||
} catch (e) { | ||
clearTimeout(timer); | ||
reject(e); | ||
} | ||
}); | ||
} | ||
static sendEvent(event: AppEvent) { | ||
@@ -114,2 +143,4 @@ //@ts-ignore | ||
CLOSE_APP = 'CLOSE_APP', | ||
AUTHORIZED_APP_ID = 'AUTHORIZED_APP_ID', | ||
GET_DASHBOARD_LANGUAGE = 'GET_DASHBOARD_LANGUAGE', | ||
} | ||
@@ -119,2 +150,4 @@ | ||
REQUEST_TOKEN_RESPONSE = 'REQUEST_TOKEN_RESPONSE', | ||
AUTHORIZED_APP_ID_RESPONSE = 'AUTHORIZED_APP_ID_RESPONSE', | ||
GET_DASHBOARD_LANGUAGE_RESPONSE = 'GET_DASHBOARD_LANGUAGE_RESPONSE', | ||
} | ||
@@ -121,0 +154,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21886
361
2