gap-nodejs-sdk 1.0.0 → 1.0.3
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/android/android_bridge.d.ts +2 -0
- package/dist/android/android_bridge.d.ts.map +1 -0
- package/dist/android/android_bridge.js +21 -0
- package/dist/android/android_bridge.js.map +1 -0
- package/dist/base/event_type.d.ts +1 -0
- package/dist/base/event_type.d.ts.map +1 -0
- package/{src/base/event_type.ts → dist/base/event_type.js} +0 -0
- package/dist/base/event_type.js.map +1 -0
- package/{src/base/input_data_type.ts → dist/base/input_data_type.d.ts} +8 -9
- package/dist/base/input_data_type.d.ts.map +1 -0
- package/dist/base/input_data_type.js +1 -0
- package/dist/base/input_data_type.js.map +1 -0
- package/dist/base/response_data_api_type.d.ts +8 -0
- package/dist/base/response_data_api_type.d.ts.map +1 -0
- package/dist/base/response_data_api_type.js +1 -0
- package/dist/base/response_data_type.d.ts +32 -0
- package/dist/base/response_data_type.d.ts.map +1 -0
- package/dist/base/response_data_type.js +1 -0
- package/dist/base/response_data_type.js.map +1 -0
- package/dist/base_type.d.ts +20 -0
- package/dist/base_type.d.ts.map +1 -0
- package/dist/base_type.js +23 -0
- package/dist/base_type.js.map +1 -0
- package/dist/common_bridge.d.ts +62 -0
- package/dist/common_bridge.d.ts.map +1 -0
- package/{src/common_bridge.ts → dist/common_bridge.js} +11 -62
- package/dist/common_bridge.js.map +1 -0
- package/dist/context.d.ts +23 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +35 -0
- package/dist/context.js.map +1 -0
- package/dist/error.d.ts +26 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +24 -0
- package/dist/error.js.map +1 -0
- package/dist/gap-sdk.js +1 -0
- package/dist/gci_client_api/interface/index.d.ts +7 -0
- package/dist/gci_client_api/interface/index.d.ts.map +1 -0
- package/dist/gci_client_api/interface/index.js +1 -0
- package/dist/gci_client_api/v1/repository/GciClientRepository.d.ts +8 -0
- package/dist/gci_client_api/v1/repository/GciClientRepository.d.ts.map +1 -0
- package/dist/gci_client_api/v1/repository/GciClientRepository.js +14 -0
- package/dist/http_client/http_client.d.ts +1 -0
- package/dist/http_client/http_client.d.ts.map +1 -0
- package/dist/http_client/http_client.js +0 -0
- package/dist/http_client/types.d.ts +31 -0
- package/dist/http_client/types.d.ts.map +1 -0
- package/dist/http_client/types.js +13 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/{src/interface/invoke_event_interface.ts → dist/interface/invoke_event_interface.d.ts} +2 -1
- package/dist/interface/invoke_event_interface.d.ts.map +1 -0
- package/dist/interface/invoke_event_interface.js +1 -0
- package/dist/interface/invoke_event_interface.js.map +1 -0
- package/{src/interface/native_app_interface.ts → dist/interface/native_app_interface.d.ts} +3 -3
- package/dist/interface/native_app_interface.d.ts.map +1 -0
- package/dist/interface/native_app_interface.js +1 -0
- package/dist/interface/native_app_interface.js.map +1 -0
- package/dist/ios/ios_bridge.d.ts +2 -0
- package/dist/ios/ios_bridge.d.ts.map +1 -0
- package/dist/ios/ios_bridge.js +43 -0
- package/dist/ios/ios_bridge.js.map +1 -0
- package/{src/native_app/index.ts → dist/native_app/index.d.ts} +3 -6
- package/dist/native_app/index.d.ts.map +1 -0
- package/dist/native_app/index.js +32 -0
- package/dist/native_app/index.js.map +1 -0
- package/dist/types/platform.d.ts +8 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/platform.js +8 -0
- package/dist/types/platform.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +36 -26
- package/index.ts +0 -5
- package/src/android/android_bridge.ts +0 -33
- package/src/base/response_data_type.ts +0 -36
- package/src/base_type.ts +0 -14
- package/src/context.ts +0 -72
- package/src/error.ts +0 -39
- package/src/index.ts +0 -13
- package/src/ios/ios_bridge.ts +0 -61
- package/src/types/platform.ts +0 -8
- package/src/types.ts +0 -1
- package/tsconfig.json +0 -50
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"android_bridge.d.ts","sourceRoot":"","sources":["../../src/android/android_bridge.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MiniAppBridge, mabMessageQueue, } from '../common_bridge';
|
|
2
|
+
import { Platform } from '../types/platform';
|
|
3
|
+
/* tslint:disable:no-any */
|
|
4
|
+
let uniqueId = Math.random();
|
|
5
|
+
class AndroidExecutor {
|
|
6
|
+
execEvents(event) {
|
|
7
|
+
window.dispatchEvent(event);
|
|
8
|
+
}
|
|
9
|
+
exec(action, param, onSuccess, onError) {
|
|
10
|
+
const callback = {};
|
|
11
|
+
callback.onSuccess = onSuccess;
|
|
12
|
+
callback.onError = onError;
|
|
13
|
+
callback.id = String(++uniqueId);
|
|
14
|
+
mabMessageQueue.unshift(callback);
|
|
15
|
+
window.MiniAppAndroid.postMessage(JSON.stringify({ action, param, id: callback.id }));
|
|
16
|
+
}
|
|
17
|
+
getPlatform() {
|
|
18
|
+
return Platform.ANDROID;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
window.MiniAppBridge = new MiniAppBridge(new AndroidExecutor());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"android_bridge.js","sourceRoot":"","sources":["../../src/android/android_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,aAAa,EAEb,eAAe,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,2BAA2B;AAC3B,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAE7B,MAAM,eAAe;IACjB,UAAU,CAAC,KAAK;QACX,MAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO;QAClC,MAAM,QAAQ,GAAG,EAAc,CAAC;QAChC,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;QAC/B,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,QAAQ,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACjC,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjC,MAAc,CAAC,cAAc,CAAC,WAAW,CACtC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CACrD,CAAC;IACN,CAAC;IAED,WAAW;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;CACJ;AAEA,MAAc,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=event_type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event_type.d.ts","sourceRoot":"","sources":["../../src/base/event_type.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event_type.js","sourceRoot":"","sources":["../../src/base/event_type.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export declare type LoginInput = {
|
|
2
|
-
username: string
|
|
3
|
-
password: string
|
|
2
|
+
username: string;
|
|
3
|
+
password: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
6
5
|
export declare type AppConfig = {
|
|
7
6
|
/**
|
|
8
7
|
* Title app.
|
|
@@ -29,10 +28,10 @@ export declare type AppConfig = {
|
|
|
29
28
|
*/
|
|
30
29
|
leftButton?: 'none' | 'back' | 'home' | 'both';
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
export declare type CommonRequest = {
|
|
34
|
-
channel: string
|
|
35
|
-
type: string
|
|
36
|
-
method: string
|
|
37
|
-
data?: string
|
|
38
|
-
}
|
|
32
|
+
channel: string;
|
|
33
|
+
type: string;
|
|
34
|
+
method: string;
|
|
35
|
+
data?: string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=input_data_type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input_data_type.d.ts","sourceRoot":"","sources":["../../src/base/input_data_type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,UAAU,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,SAAS,GAAG;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAChD;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAClD,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input_data_type.js","sourceRoot":"","sources":["../../src/base/input_data_type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response_data_api_type.d.ts","sourceRoot":"","sources":["../../src/base/response_data_api_type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG;IAClC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GapError } from "src/error";
|
|
2
|
+
export declare type ResponseSuccess = {
|
|
3
|
+
channel: string;
|
|
4
|
+
type: string;
|
|
5
|
+
method: string;
|
|
6
|
+
data: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ResponseError = {
|
|
9
|
+
error: object | GapError | string;
|
|
10
|
+
};
|
|
11
|
+
export declare type SystemInfo = {
|
|
12
|
+
version: string;
|
|
13
|
+
apiVersion: string;
|
|
14
|
+
};
|
|
15
|
+
export declare type BusinessInfo = {
|
|
16
|
+
name: string;
|
|
17
|
+
shortName: string;
|
|
18
|
+
phone: string;
|
|
19
|
+
address: string;
|
|
20
|
+
countryCode: string;
|
|
21
|
+
city: string;
|
|
22
|
+
stateCode: string;
|
|
23
|
+
postalCode: string;
|
|
24
|
+
description: string;
|
|
25
|
+
logoImage: string;
|
|
26
|
+
coverImage: string;
|
|
27
|
+
};
|
|
28
|
+
export declare type BusinessConfig = {
|
|
29
|
+
setting: object | string;
|
|
30
|
+
appSetting: object | string;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=response_data_type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response_data_type.d.ts","sourceRoot":"","sources":["../../src/base/response_data_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,CAAC,OAAO,MAAM,eAAe,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG;IAChC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CACrC,CAAA;AAED,MAAM,CAAC,OAAO,MAAM,UAAU,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,CAAC,OAAO,MAAM,YAAY,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG;IACjC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response_data_type.js","sourceRoot":"","sources":["../../src/base/response_data_type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum GapApiVersion {
|
|
2
|
+
V1 = "1.0.0"
|
|
3
|
+
}
|
|
4
|
+
export declare enum GapHeader {
|
|
5
|
+
GClientId = "G-ClientID"
|
|
6
|
+
}
|
|
7
|
+
export declare enum UserAgent {
|
|
8
|
+
IOS = "IOS",
|
|
9
|
+
ANDROID = "ANDROID",
|
|
10
|
+
CHROME = "CHROME",
|
|
11
|
+
SAFARI = "SAFARI"
|
|
12
|
+
}
|
|
13
|
+
/** Device platform of bridge. */
|
|
14
|
+
export declare enum Platform {
|
|
15
|
+
ANDROID = "Android",
|
|
16
|
+
IOS = "iOS",
|
|
17
|
+
WEB = "Web",
|
|
18
|
+
WINDOW = "Window"
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=base_type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_type.d.ts","sourceRoot":"","sources":["../src/base_type.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACrB,EAAE,UAAU;CACf;AAED,oBAAY,SAAS;IACjB,SAAS,eAAe;CAC3B;AAED,oBAAY,SAAS;IACjB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,iCAAiC;AACjC,oBAAY,QAAQ;IAChB,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;CACpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var GapApiVersion;
|
|
2
|
+
(function (GapApiVersion) {
|
|
3
|
+
GapApiVersion["V1"] = "1.0.0";
|
|
4
|
+
})(GapApiVersion || (GapApiVersion = {}));
|
|
5
|
+
export var GapHeader;
|
|
6
|
+
(function (GapHeader) {
|
|
7
|
+
GapHeader["GClientId"] = "G-ClientID";
|
|
8
|
+
})(GapHeader || (GapHeader = {}));
|
|
9
|
+
export var UserAgent;
|
|
10
|
+
(function (UserAgent) {
|
|
11
|
+
UserAgent["IOS"] = "IOS";
|
|
12
|
+
UserAgent["ANDROID"] = "ANDROID";
|
|
13
|
+
UserAgent["CHROME"] = "CHROME";
|
|
14
|
+
UserAgent["SAFARI"] = "SAFARI";
|
|
15
|
+
})(UserAgent || (UserAgent = {}));
|
|
16
|
+
/** Device platform of bridge. */
|
|
17
|
+
export var Platform;
|
|
18
|
+
(function (Platform) {
|
|
19
|
+
Platform["ANDROID"] = "Android";
|
|
20
|
+
Platform["IOS"] = "iOS";
|
|
21
|
+
Platform["WEB"] = "Web";
|
|
22
|
+
Platform["WINDOW"] = "Window";
|
|
23
|
+
})(Platform || (Platform = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_type.js","sourceRoot":"","sources":["../src/base_type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAEX;AAFD,WAAY,aAAa;IACrB,6BAAY,CAAA;AAChB,CAAC,EAFW,aAAa,KAAb,aAAa,QAExB;AAED,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACjB,qCAAwB,CAAA;AAC5B,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAED,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,wBAAW,CAAA;IACX,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACrB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const mabMessageQueue: Callback[];
|
|
3
|
+
declare const mabCustomEventQueue: CustomEvent[];
|
|
4
|
+
declare const mabKeyboardEventQueue: CustomEvent[];
|
|
5
|
+
export { mabMessageQueue };
|
|
6
|
+
export { mabCustomEventQueue };
|
|
7
|
+
export { mabKeyboardEventQueue };
|
|
8
|
+
/** @internal */
|
|
9
|
+
export interface Callback {
|
|
10
|
+
id: string;
|
|
11
|
+
onSuccess: (value: string) => void;
|
|
12
|
+
onError: (error: string) => void;
|
|
13
|
+
}
|
|
14
|
+
/** @internal */
|
|
15
|
+
export interface PlatformExecutor {
|
|
16
|
+
/**
|
|
17
|
+
* Method to call the native interface methods for respective platforms
|
|
18
|
+
* such as iOS & Android.
|
|
19
|
+
* @param {[string]} action Action command/interface name that native side need to execute
|
|
20
|
+
* @param {Object} param Object that contains request parameter values like permissions.
|
|
21
|
+
* For eg., {permission: 'location'}
|
|
22
|
+
* @param {[Function]} onSuccess Success callback function
|
|
23
|
+
* @param {[Function]} onError Error callback function
|
|
24
|
+
*/
|
|
25
|
+
exec(action: string, param: object | null, onSuccess: (value: string) => void, onError: (error: string) => void): void;
|
|
26
|
+
execEvents(event: CustomEvent): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get the platform which injects this bridge.
|
|
29
|
+
* @returns The platform name. It could be 'Android' or 'iOS'.
|
|
30
|
+
*/
|
|
31
|
+
getPlatform(): string;
|
|
32
|
+
}
|
|
33
|
+
export declare class MiniAppBridge {
|
|
34
|
+
executor: PlatformExecutor;
|
|
35
|
+
platform: string;
|
|
36
|
+
constructor(executor: PlatformExecutor);
|
|
37
|
+
/**
|
|
38
|
+
* Success Callback method that will be called from native side
|
|
39
|
+
* to this bridge. This method will send back the value to the
|
|
40
|
+
* mini apps that uses promises.
|
|
41
|
+
* @param {[String]} messageId Message ID which will be used to get callback object from messageQueue
|
|
42
|
+
* @param {[String]} value Response value sent from the native on invoking the action command
|
|
43
|
+
*/
|
|
44
|
+
execSuccessCallback(messageId: any, value: any): void;
|
|
45
|
+
/**
|
|
46
|
+
* Error Callback method that will be called from native side
|
|
47
|
+
* to this bridge. This method will send back the error message to the
|
|
48
|
+
* mini apps that uses promises.
|
|
49
|
+
* @param {[String]} messageId Message ID which will be used to get callback object from messageQueue
|
|
50
|
+
* @param {[String]} errorMessage Error message sent from the native on invoking the action command
|
|
51
|
+
*/
|
|
52
|
+
execErrorCallback(messageId: any, errorMessage: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Event Callback method that will be called from native side
|
|
55
|
+
* to this bridge. This method will send back the value to the
|
|
56
|
+
* mini app that listen to this eventType.
|
|
57
|
+
* @param {[String]} eventType EventType which will be used to listen for the event
|
|
58
|
+
* @param {[String]} value Additional message sent from the native on invoking for the eventType
|
|
59
|
+
*/
|
|
60
|
+
execCustomEventsCallback(eventType: string, value: string): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=common_bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common_bridge.d.ts","sourceRoot":"","sources":["../src/common_bridge.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,QAAA,MAAM,eAAe,EAAE,QAAQ,EAAO,CAAC;AACvC,QAAA,MAAM,mBAAmB,EAAE,WAAW,EAAO,CAAC;AAC9C,QAAA,MAAM,qBAAqB,EAAE,WAAW,EAAO,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,gBAAgB;AAChB,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC7B;;;;;;;;OAQG;IACH,IAAI,CACA,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EAClC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACjC,IAAI,CAAC;IAER,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,WAAW,IAAI,MAAM,CAAC;CACzB;AAED,qBAAa,aAAa;IACtB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;gBAIL,QAAQ,EAAE,gBAAgB;IAetC;;;;;;OAMG;IACH,mBAAmB,CAAC,SAAS,KAAA,EAAE,KAAK,KAAA;IAYpC;;;;;;OAMG;IACH,iBAAiB,CAAC,SAAS,KAAA,EAAE,YAAY,KAAA;IAUzC;;;;;;OAMG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAgB5D"}
|
|
@@ -1,55 +1,16 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
const mabMessageQueue
|
|
3
|
-
const mabCustomEventQueue
|
|
4
|
-
const mabKeyboardEventQueue
|
|
2
|
+
const mabMessageQueue = [];
|
|
3
|
+
const mabCustomEventQueue = [];
|
|
4
|
+
const mabKeyboardEventQueue = [];
|
|
5
5
|
export { mabMessageQueue };
|
|
6
6
|
export { mabCustomEventQueue };
|
|
7
7
|
export { mabKeyboardEventQueue };
|
|
8
|
-
|
|
9
|
-
/** @internal */
|
|
10
|
-
export interface Callback {
|
|
11
|
-
id: string;
|
|
12
|
-
onSuccess: (value: string) => void;
|
|
13
|
-
onError: (error: string) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export interface PlatformExecutor {
|
|
18
|
-
/**
|
|
19
|
-
* Method to call the native interface methods for respective platforms
|
|
20
|
-
* such as iOS & Android.
|
|
21
|
-
* @param {[string]} action Action command/interface name that native side need to execute
|
|
22
|
-
* @param {Object} param Object that contains request parameter values like permissions.
|
|
23
|
-
* For eg., {permission: 'location'}
|
|
24
|
-
* @param {[Function]} onSuccess Success callback function
|
|
25
|
-
* @param {[Function]} onError Error callback function
|
|
26
|
-
*/
|
|
27
|
-
exec(
|
|
28
|
-
action: string,
|
|
29
|
-
param: object | null,
|
|
30
|
-
onSuccess: (value: string) => void,
|
|
31
|
-
onError: (error: string) => void
|
|
32
|
-
): void;
|
|
33
|
-
|
|
34
|
-
execEvents(event: CustomEvent): void;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get the platform which injects this bridge.
|
|
38
|
-
* @returns The platform name. It could be 'Android' or 'iOS'.
|
|
39
|
-
*/
|
|
40
|
-
getPlatform(): string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
8
|
export class MiniAppBridge {
|
|
44
|
-
executor: PlatformExecutor;
|
|
45
|
-
platform: string;
|
|
46
9
|
// isSecureStorageReady = false;
|
|
47
10
|
// secureStorageLoadError: MiniAppError | null = null;
|
|
48
|
-
|
|
49
|
-
constructor(executor: PlatformExecutor) {
|
|
11
|
+
constructor(executor) {
|
|
50
12
|
this.executor = executor;
|
|
51
13
|
this.platform = executor.getPlatform();
|
|
52
|
-
|
|
53
14
|
// window.addEventListener(
|
|
54
15
|
// MiniAppSecureStorageEvents.onReady,
|
|
55
16
|
// () => (this.isSecureStorageReady = true)
|
|
@@ -60,7 +21,6 @@ export class MiniAppBridge {
|
|
|
60
21
|
// (this.secureStorageLoadError = parseMiniAppError(e.detail.message))
|
|
61
22
|
// );
|
|
62
23
|
}
|
|
63
|
-
|
|
64
24
|
/**
|
|
65
25
|
* Success Callback method that will be called from native side
|
|
66
26
|
* to this bridge. This method will send back the value to the
|
|
@@ -69,17 +29,15 @@ export class MiniAppBridge {
|
|
|
69
29
|
* @param {[String]} value Response value sent from the native on invoking the action command
|
|
70
30
|
*/
|
|
71
31
|
execSuccessCallback(messageId, value) {
|
|
72
|
-
const queueObj = mabMessageQueue.filter(
|
|
73
|
-
callback => callback.id === messageId
|
|
74
|
-
)[0];
|
|
32
|
+
const queueObj = mabMessageQueue.filter(callback => callback.id === messageId)[0];
|
|
75
33
|
if (value) {
|
|
76
34
|
queueObj.onSuccess(value);
|
|
77
|
-
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
78
37
|
queueObj.onError('Unknown Error');
|
|
79
38
|
}
|
|
80
39
|
removeFromMessageQueue(queueObj);
|
|
81
40
|
}
|
|
82
|
-
|
|
83
41
|
/**
|
|
84
42
|
* Error Callback method that will be called from native side
|
|
85
43
|
* to this bridge. This method will send back the error message to the
|
|
@@ -88,9 +46,7 @@ export class MiniAppBridge {
|
|
|
88
46
|
* @param {[String]} errorMessage Error message sent from the native on invoking the action command
|
|
89
47
|
*/
|
|
90
48
|
execErrorCallback(messageId, errorMessage) {
|
|
91
|
-
const queueObj = mabMessageQueue.filter(
|
|
92
|
-
callback => callback.id === messageId
|
|
93
|
-
)[0];
|
|
49
|
+
const queueObj = mabMessageQueue.filter(callback => callback.id === messageId)[0];
|
|
94
50
|
if (!errorMessage) {
|
|
95
51
|
errorMessage = 'Unknown Error';
|
|
96
52
|
}
|
|
@@ -104,13 +60,11 @@ export class MiniAppBridge {
|
|
|
104
60
|
* @param {[String]} eventType EventType which will be used to listen for the event
|
|
105
61
|
* @param {[String]} value Additional message sent from the native on invoking for the eventType
|
|
106
62
|
*/
|
|
107
|
-
execCustomEventsCallback(eventType
|
|
63
|
+
execCustomEventsCallback(eventType, value) {
|
|
108
64
|
const event = new CustomEvent(eventType, {
|
|
109
65
|
detail: { message: value },
|
|
110
66
|
});
|
|
111
|
-
let queueObj = mabCustomEventQueue.filter(
|
|
112
|
-
customEvent => customEvent === event
|
|
113
|
-
)[0];
|
|
67
|
+
let queueObj = mabCustomEventQueue.filter(customEvent => customEvent === event)[0];
|
|
114
68
|
if (!queueObj) {
|
|
115
69
|
if (eventType === event.type) {
|
|
116
70
|
removeFromEventQueue(event);
|
|
@@ -133,13 +87,8 @@ function removeFromMessageQueue(queueObj) {
|
|
|
133
87
|
mabMessageQueue.splice(messageObjIndex, 1);
|
|
134
88
|
}
|
|
135
89
|
}
|
|
136
|
-
|
|
137
90
|
function removeFromEventQueue(queueObj) {
|
|
138
|
-
const eventObjIndex = mabCustomEventQueue.indexOf(
|
|
139
|
-
mabCustomEventQueue.filter(
|
|
140
|
-
customEvent => customEvent.type === queueObj.type
|
|
141
|
-
)[0]
|
|
142
|
-
);
|
|
91
|
+
const eventObjIndex = mabCustomEventQueue.indexOf(mabCustomEventQueue.filter(customEvent => customEvent.type === queueObj.type)[0]);
|
|
143
92
|
if (eventObjIndex !== -1) {
|
|
144
93
|
mabCustomEventQueue.splice(eventObjIndex, 1);
|
|
145
94
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common_bridge.js","sourceRoot":"","sources":["../src/common_bridge.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GapApiVersion } from "./base_type";
|
|
2
|
+
interface ContextInterface {
|
|
3
|
+
API_KEY: string;
|
|
4
|
+
API_SECRET_KEY: string;
|
|
5
|
+
G_CLIENTID: string;
|
|
6
|
+
API_VERSION: GapApiVersion;
|
|
7
|
+
USER_AGENT: string;
|
|
8
|
+
LOG_FILE?: string;
|
|
9
|
+
USER_AGENT_PREFIX?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets up the GAP API Library
|
|
12
|
+
*
|
|
13
|
+
* @param params Settings to update
|
|
14
|
+
*/
|
|
15
|
+
initialize(params: ContextInterface): void;
|
|
16
|
+
/**
|
|
17
|
+
* Throws error if context has not been initialized.
|
|
18
|
+
*/
|
|
19
|
+
throwIfUninitialized(): void | never;
|
|
20
|
+
}
|
|
21
|
+
declare const Context: ContextInterface;
|
|
22
|
+
export { Context, ContextInterface };
|
|
23
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,UAAU,gBAAgB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,aAAa,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IAKnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE3C;;OAEG;IACH,oBAAoB,IAAI,IAAI,GAAG,KAAK,CAAC;CAExC;AAED,QAAA,MAAM,OAAO,EAAE,gBAqCd,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GapApiVersion } from "./base_type";
|
|
2
|
+
import * as GapErrors from "./error";
|
|
3
|
+
const Context = {
|
|
4
|
+
API_KEY: "",
|
|
5
|
+
API_SECRET_KEY: "",
|
|
6
|
+
G_CLIENTID: "",
|
|
7
|
+
USER_AGENT: "",
|
|
8
|
+
API_VERSION: GapApiVersion.V1,
|
|
9
|
+
initialize: function (params) {
|
|
10
|
+
// Make sure that the essential params actually have content in them
|
|
11
|
+
const missing = [];
|
|
12
|
+
if (!params.API_KEY.length) {
|
|
13
|
+
missing.push('API_KEY');
|
|
14
|
+
}
|
|
15
|
+
if (!params.API_SECRET_KEY.length) {
|
|
16
|
+
missing.push('API_SECRET_KEY');
|
|
17
|
+
}
|
|
18
|
+
if (!params.API_SECRET_KEY.length) {
|
|
19
|
+
missing.push('G_CLIENTID');
|
|
20
|
+
}
|
|
21
|
+
if (missing.length) {
|
|
22
|
+
throw new GapErrors.MissingDataContextError(`Cannot initialize GAP Library. Missing values for: ${missing.join(', ')}`);
|
|
23
|
+
}
|
|
24
|
+
this.API_KEY = params.API_KEY;
|
|
25
|
+
this.API_SECRET_KEY = params.API_SECRET_KEY;
|
|
26
|
+
this.G_CLIENTID = params.G_CLIENTID;
|
|
27
|
+
this.API_VERSION = params.API_VERSION;
|
|
28
|
+
},
|
|
29
|
+
throwIfUninitialized: function () {
|
|
30
|
+
if (!this.API_KEY || this.API_KEY.length === 0) {
|
|
31
|
+
throw new GapErrors.UninitializedContextError('Context has not been properly initialized. Please call the .initialize() method to setup your app context object.');
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export { Context };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC;AA+BrC,MAAM,OAAO,GAAqB;IAC9B,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,aAAa,CAAC,EAAE;IAC7B,UAAU,EAAE,UAAU,MAAwB;QAC1C,oEAAoE;QACpE,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE;YACxB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC3B;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE;YAC/B,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE;YAC/B,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC9B;QACD,IAAI,OAAO,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,SAAS,CAAC,uBAAuB,CACvC,8DAA8D,OAAO,CAAC,IAAI,CACtE,IAAI,CACP,EAAE,CACN,CAAC;SACL;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAC1C,CAAC;IACD,oBAAoB,EAAE;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,MAAM,IAAI,SAAS,CAAC,yBAAyB,CACzC,mHAAmH,CACtH,CAAC;SACL;IACL,CAAC;CACJ,CAAA;AAED,OAAO,EAAE,OAAO,EAAoB,CAAC"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class GapError extends Error {
|
|
2
|
+
constructor(...args: any);
|
|
3
|
+
}
|
|
4
|
+
interface HttpResponseData {
|
|
5
|
+
code: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
body?: {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
headers?: {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface HttpResponseErrorParams extends HttpResponseData {
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class HttpResponseError extends GapError {
|
|
18
|
+
readonly response: HttpResponseData;
|
|
19
|
+
constructor({ message, code, statusText, body, headers, }: HttpResponseErrorParams);
|
|
20
|
+
}
|
|
21
|
+
export declare class UninitializedContextError extends GapError {
|
|
22
|
+
}
|
|
23
|
+
export declare class MissingDataContextError extends GapError {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;gBACnB,GAAG,IAAI,EAAE,GAAG;CAI3B;AAED,UAAU,gBAAgB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAClC,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACxC;AACD,UAAU,uBAAwB,SAAQ,gBAAgB;IACtD,OAAO,EAAE,MAAM,CAAC;CACnB;AACD,qBAAa,iBAAkB,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAEjB,EACf,OAAO,EACP,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,OAAO,GACV,EAAE,uBAAuB;CAS7B;AAGD,qBAAa,yBAA0B,SAAQ,QAAQ;CAAI;AAC3D,qBAAa,uBAAwB,SAAQ,QAAQ;CAAI"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class GapError extends Error {
|
|
2
|
+
constructor(...args) {
|
|
3
|
+
super(...args);
|
|
4
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class HttpResponseError extends GapError {
|
|
8
|
+
constructor({ message, code, statusText, body, headers, }) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.response = {
|
|
11
|
+
code,
|
|
12
|
+
statusText,
|
|
13
|
+
body,
|
|
14
|
+
headers,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//Detail of error for testing purpose
|
|
19
|
+
export class UninitializedContextError extends GapError {
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
export class MissingDataContextError extends GapError {
|
|
23
|
+
}
|
|
24
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAC/B,YAAY,GAAG,IAAS;QACpB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ;AAWD,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAG3C,YAAmB,EACf,OAAO,EACP,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,OAAO,GACe;QACtB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG;YACZ,IAAI;YACJ,UAAU;YACV,IAAI;YACJ,OAAO;SACV,CAAC;IACN,CAAC;CACJ;AAED,qCAAqC;AACrC,MAAM,OAAO,yBAA0B,SAAQ,QAAQ;CAAI;AAAA,CAAC;AAC5D,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;CAAI;AAAA,CAAC"}
|
package/dist/gap-sdk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GapSdk=t():e.GapSdk=t()}(self,(()=>(()=>{"use strict";var e={363:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AndroidExecutor=void 0;const n=r(235),o=r(544);let i=Math.random();t.AndroidExecutor=class{execEvents(e){window.dispatchEvent(e)}exec(e,t,r,o){const s={};s.onSuccess=r,s.onError=o,s.id=String(++i),n.mabMessageQueue.unshift(s),window.MiniAppAndroid.postMessage(JSON.stringify({action:e,param:t,id:s.id}))}getPlatform(){return o.Platform.ANDROID}}},235:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MiniAppBridge=t.mabKeyboardEventQueue=t.mabCustomEventQueue=t.mabMessageQueue=void 0;const n=r(936),o=[];t.mabMessageQueue=o;const i=[];function s(e){const t=o.indexOf(e);-1!==t&&o.splice(t,1)}t.mabCustomEventQueue=i,t.mabKeyboardEventQueue=[],t.MiniAppBridge=class{constructor(e){this.executor=e,this.platform=e.getPlatform()}execSuccessCallback(e,t){const r=o.filter((t=>t.id===e))[0];t?r.onSuccess(t):r.onError("Unknown Error"),s(r)}execErrorCallback(e,t){const r=o.filter((t=>t.id===e))[0];t||(t="Unknown Error"),r.onError(t),s(r)}execCustomEventsCallback(e,t){const r=new CustomEvent(e,{detail:{message:t}});let n=i.filter((e=>e===r))[0];n||(e===r.type&&function(e){const t=i.indexOf(i.filter((t=>t.type===e.type))[0]);-1!==t&&i.splice(t,1)}(r),n=r,i.unshift(n)),this.executor.execEvents(n)}getUniqueId(){return new Promise(((e,t)=>this.executor.exec("getAppId",null,(t=>e(t)),(e=>t(e)))))}requestPermission(e){return new Promise(((t,r)=>this.executor.exec("requestPermission",{permission:e},(e=>t(e)),(e=>r(e)))))}shareInfo(e){return new Promise(((t,r)=>this.executor.exec("shareInfo",{shareInfo:e},(e=>t(e)),(e=>r(e)))))}getAccessToken(e,t){return new Promise(((r,o)=>this.executor.exec("getAccessToken",{audience:e,scopes:t},(e=>{const t=JSON.parse(e);r(new n.AccessTokenData(t))}),(e=>o(e)))))}setScreenOrientation(e){return new Promise(((t,r)=>this.executor.exec("setScreenOrientation",{action:e},(e=>t(e)),(e=>r(e)))))}copyToClipboard(e){return new Promise(((t,r)=>this.executor.exec("copyToClipboard",{text:e},(e=>t(e)),(e=>r(e)))))}getIpAddress(){return new Promise(((e,t)=>this.executor.exec("getIpAddress",null,(t=>e(t)),(e=>t(e)))))}getImage(){return new Promise(((e,t)=>this.executor.exec("getImage",null,(t=>e(t)),(e=>t(e)))))}saveImage(e){return new Promise(((t,r)=>this.executor.exec("saveImage",{image:e},(e=>t(e)),(e=>r(e)))))}openGapMiniApp(e){return new Promise(((t,r)=>this.executor.exec("openGapMiniApp",{appId:e},(e=>t(e)),(e=>r(e)))))}getAppVersion(){return new Promise(((e,t)=>this.executor.exec("getAppVersion",null,(t=>e(t)),(e=>t(e)))))}getSystemInfo(){return new Promise(((e,t)=>this.executor.exec("getSystemInfo",null,(t=>e(t)),(e=>t(e)))))}getBusinessInfo(){return new Promise(((e,t)=>this.executor.exec("getBusinessInfo",null,(t=>e(t)),(e=>t(e)))))}getBusinessConfig(){return new Promise(((e,t)=>this.executor.exec("getBusinessConfig",null,(t=>e(t)),(e=>t(e)))))}}},713:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingDataError=t.NotImplementedPlatform=t.UninitializedPlatformError=t.GapMiniAppError=void 0;class r extends Error{constructor(...e){super(...e),Object.setPrototypeOf(this,new.target.prototype)}}t.GapMiniAppError=r,t.UninitializedPlatformError=class extends r{},t.NotImplementedPlatform=class extends r{},t.MissingDataError=class extends r{}},374:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.GapMiniAppSdk=void 0;const s=r(727),a=r(544),c=i(r(713)),u=r(235),d=r(322),p=r(363),l=r(880);t.GapMiniAppSdk=class{setPlatformExecutor(e){switch(e){case a.Platform.WINDOW:window.MiniAppBridge=new u.MiniAppBridge(new d.WindowExecutor);break;case a.Platform.ANDROID:window.MiniAppBridge=new u.MiniAppBridge(new p.AndroidExecutor);break;case a.Platform.IOS:window.MiniAppBridge=new u.MiniAppBridge(new l.IOSExecutor);break;case a.Platform.WEB:throw new c.NotImplementedPlatform("Platform not supported yet");default:throw new c.MissingDataError("Missing platform data")}return e}getBridge(){return(0,s.getBridge)()}getAppId(){throw new Error("Method not implemented.")}getAppVersion(){return(0,s.getBridge)().getAppVersion()}getBusinessInfo(){return new Promise(((e,t)=>{(0,s.getBridge)().getBusinessInfo().then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))}))}getBusinessConfig(){return new Promise(((e,t)=>{(0,s.getBridge)().getBusinessConfig().then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))}))}}},880:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IOSExecutor=void 0;const n=r(235),o=r(544);let i=Math.random();t.IOSExecutor=class{execEvents(e){window.dispatchEvent(e)}exec(e,t,r,o){const s={};s.onSuccess=r,s.onError=o,s.id=String(++i),n.mabMessageQueue.unshift(s),window.webkit.messageHandlers.MiniAppiOS.postMessage(JSON.stringify({action:e,param:t,id:s.id}))}getPlatform(){return o.Platform.IOS}}},544:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Platform=void 0,(r=t.Platform||(t.Platform={})).ANDROID="Android",r.IOS="iOS",r.WEB="Web",r.WINDOW="Window"},936:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AccessTokenData=void 0,t.AccessTokenData=class{constructor(e){this.token=e.token,this.validUntil=new Date(e.validUntil),this.scopes=e.scopes}}},727:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getBridge=void 0,t.getBridge=function(){return window.MiniAppBridge}},322:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WindowExecutor=void 0;const n=r(235),o=r(544);let i=Math.random();t.WindowExecutor=class{execEvents(e){window.dispatchEvent(e)}exec(e,t,r,o){const s={};s.onSuccess=r,s.onError=o,s.id=String(++i),n.mabMessageQueue.unshift(s),window.chrome.webview.postMessage({action:e,param:t,id:s.id})}getPlatform(){return o.Platform.WINDOW}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{Gap:()=>p,GapApiVersion:()=>e,GapHeader:()=>t,Platform:()=>i,UserAgent:()=>o,default:()=>l});var e,t,o,i,s={};r.r(s),r.d(s,{GapError:()=>a,HttpResponseError:()=>c,MissingDataContextError:()=>d,UninitializedContextError:()=>u}),function(e){e.V1="1.0.0"}(e||(e={})),function(e){e.GClientId="G-ClientID"}(t||(t={})),function(e){e.IOS="IOS",e.ANDROID="ANDROID",e.CHROME="CHROME",e.SAFARI="SAFARI"}(o||(o={})),function(e){e.ANDROID="Android",e.IOS="iOS",e.WEB="Web",e.WINDOW="Window"}(i||(i={}));class a extends Error{constructor(...e){super(...e),Object.setPrototypeOf(this,new.target.prototype)}}class c extends a{constructor({message:e,code:t,statusText:r,body:n,headers:o}){super(e),this.response={code:t,statusText:r,body:n,headers:o}}}class u extends a{}class d extends a{}const p={Context:{API_KEY:"",API_SECRET_KEY:"",G_CLIENTID:"",USER_AGENT:"",API_VERSION:e.V1,initialize:function(e){const t=[];if(e.API_KEY.length||t.push("API_KEY"),e.API_SECRET_KEY.length||t.push("API_SECRET_KEY"),e.API_SECRET_KEY.length||t.push("G_CLIENTID"),t.length)throw new d(`Cannot initialize GAP Library. Missing values for: ${t.join(", ")}`);this.API_KEY=e.API_KEY,this.API_SECRET_KEY=e.API_SECRET_KEY,this.G_CLIENTID=e.G_CLIENTID,this.API_VERSION=e.API_VERSION},throwIfUninitialized:function(){if(!this.API_KEY||0===this.API_KEY.length)throw new u("Context has not been properly initialized. Please call the .initialize() method to setup your app context object.")}},Errors:s,MiniApp:r(374).GapMiniAppSdk},l=p})(),n})()));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ResponseDataApi } from "src/base/response_data_api_type";
|
|
2
|
+
import { GapApiVersion } from "src/base_type";
|
|
3
|
+
export interface IGciClientRepository {
|
|
4
|
+
apiVersion: GapApiVersion.V1;
|
|
5
|
+
getList: () => ResponseDataApi | null;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gci_client_api/interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,aAAa,CAAC,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResponseDataApi } from "src/base/response_data_api_type";
|
|
2
|
+
import { GapApiVersion } from "src/base_type";
|
|
3
|
+
import { IGciClientRepository } from "src/gci_client_api/interface";
|
|
4
|
+
export declare class GciClientRepository implements IGciClientRepository {
|
|
5
|
+
apiVersion: GapApiVersion.V1;
|
|
6
|
+
getList(): ResponseDataApi | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=GciClientRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GciClientRepository.d.ts","sourceRoot":"","sources":["../../../../src/gci_client_api/v1/repository/GciClientRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,qBAAa,mBAAoB,YAAW,oBAAoB;IAC5D,UAAU,EAAE,aAAa,CAAC,EAAE,CAAC;IAC7B,OAAO,IAAI,eAAe,GAAG,IAAI;CAYpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=http_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../src/http_client/http_client.ts"],"names":[],"mappings":""}
|
|
File without changes
|