gap-nodejs-sdk 1.0.0 → 1.0.1

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.
Files changed (78) hide show
  1. package/dist/android/android_bridge.d.ts +2 -0
  2. package/dist/android/android_bridge.d.ts.map +1 -0
  3. package/dist/android/android_bridge.js +21 -0
  4. package/dist/android/android_bridge.js.map +1 -0
  5. package/dist/base/event_type.d.ts +1 -0
  6. package/dist/base/event_type.d.ts.map +1 -0
  7. package/{src/base/event_type.ts → dist/base/event_type.js} +0 -0
  8. package/dist/base/event_type.js.map +1 -0
  9. package/{src/base/input_data_type.ts → dist/base/input_data_type.d.ts} +8 -9
  10. package/dist/base/input_data_type.d.ts.map +1 -0
  11. package/dist/base/input_data_type.js +1 -0
  12. package/dist/base/input_data_type.js.map +1 -0
  13. package/dist/base/response_data_type.d.ts +32 -0
  14. package/dist/base/response_data_type.d.ts.map +1 -0
  15. package/dist/base/response_data_type.js +1 -0
  16. package/dist/base/response_data_type.js.map +1 -0
  17. package/dist/base_type.d.ts +20 -0
  18. package/dist/base_type.d.ts.map +1 -0
  19. package/dist/base_type.js +23 -0
  20. package/dist/base_type.js.map +1 -0
  21. package/dist/common_bridge.d.ts +62 -0
  22. package/dist/common_bridge.d.ts.map +1 -0
  23. package/{src/common_bridge.ts → dist/common_bridge.js} +11 -62
  24. package/dist/common_bridge.js.map +1 -0
  25. package/dist/context.d.ts +23 -0
  26. package/dist/context.d.ts.map +1 -0
  27. package/dist/context.js +35 -0
  28. package/dist/context.js.map +1 -0
  29. package/dist/error.d.ts +26 -0
  30. package/dist/error.d.ts.map +1 -0
  31. package/dist/error.js +24 -0
  32. package/dist/error.js.map +1 -0
  33. package/dist/gci_client_api/interface/index.d.ts +7 -0
  34. package/dist/gci_client_api/interface/index.d.ts.map +1 -0
  35. package/dist/gci_client_api/interface/index.js +1 -0
  36. package/dist/gci_client_api/v1/repository/GciClientRepository.d.ts +8 -0
  37. package/dist/gci_client_api/v1/repository/GciClientRepository.d.ts.map +1 -0
  38. package/dist/gci_client_api/v1/repository/GciClientRepository.js +14 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +14 -0
  42. package/dist/index.js.map +1 -0
  43. package/{src/interface/invoke_event_interface.ts → dist/interface/invoke_event_interface.d.ts} +2 -1
  44. package/dist/interface/invoke_event_interface.d.ts.map +1 -0
  45. package/dist/interface/invoke_event_interface.js +1 -0
  46. package/dist/interface/invoke_event_interface.js.map +1 -0
  47. package/{src/interface/native_app_interface.ts → dist/interface/native_app_interface.d.ts} +3 -3
  48. package/dist/interface/native_app_interface.d.ts.map +1 -0
  49. package/dist/interface/native_app_interface.js +1 -0
  50. package/dist/interface/native_app_interface.js.map +1 -0
  51. package/dist/ios/ios_bridge.d.ts +2 -0
  52. package/dist/ios/ios_bridge.d.ts.map +1 -0
  53. package/dist/ios/ios_bridge.js +43 -0
  54. package/dist/ios/ios_bridge.js.map +1 -0
  55. package/{src/native_app/index.ts → dist/native_app/index.d.ts} +3 -6
  56. package/dist/native_app/index.d.ts.map +1 -0
  57. package/dist/native_app/index.js +32 -0
  58. package/dist/native_app/index.js.map +1 -0
  59. package/dist/types/platform.d.ts +8 -0
  60. package/dist/types/platform.d.ts.map +1 -0
  61. package/dist/types/platform.js +8 -0
  62. package/dist/types/platform.js.map +1 -0
  63. package/dist/types.d.ts +2 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +1 -0
  66. package/dist/types.js.map +1 -0
  67. package/package.json +33 -25
  68. package/index.ts +0 -5
  69. package/src/android/android_bridge.ts +0 -33
  70. package/src/base/response_data_type.ts +0 -36
  71. package/src/base_type.ts +0 -14
  72. package/src/context.ts +0 -72
  73. package/src/error.ts +0 -39
  74. package/src/index.ts +0 -13
  75. package/src/ios/ios_bridge.ts +0 -61
  76. package/src/types/platform.ts +0 -8
  77. package/src/types.ts +0 -1
  78. package/tsconfig.json +0 -50
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native_app_interface.js","sourceRoot":"","sources":["../../src/interface/native_app_interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ios_bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios_bridge.d.ts","sourceRoot":"","sources":["../../src/ios/ios_bridge.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ import { MiniAppBridge, mabMessageQueue, } from '../common_bridge';
2
+ import { Platform } from '../types/platform';
3
+ /* tslint:disable:no-any */
4
+ let uniqueId = Math.random();
5
+ // tslint:disable-next-line: variable-name
6
+ const GeolocationPositionError = {
7
+ PERMISSION_DENIED: 1,
8
+ POSITION_UNAVAILABLE: 2,
9
+ TIMEOUT: 3,
10
+ };
11
+ class IOSExecutor {
12
+ execEvents(event) {
13
+ window.dispatchEvent(event);
14
+ }
15
+ exec(action, param, onSuccess, onError) {
16
+ const callback = {};
17
+ callback.onSuccess = onSuccess;
18
+ callback.onError = onError;
19
+ callback.id = String(++uniqueId);
20
+ mabMessageQueue.unshift(callback);
21
+ window.webkit.messageHandlers.MiniAppiOS.postMessage(JSON.stringify({ action, param, id: callback.id }));
22
+ }
23
+ getPlatform() {
24
+ return Platform.IOS;
25
+ }
26
+ }
27
+ const iOSExecutor = new IOSExecutor();
28
+ window.MiniAppBridge = new MiniAppBridge(iOSExecutor);
29
+ navigator.geolocation.getCurrentPosition = (success, error, options) => {
30
+ return iOSExecutor.exec('getCurrentPosition', { locationOptions: options }, value => {
31
+ try {
32
+ const parsedData = JSON.parse(value);
33
+ success(parsedData);
34
+ console.log(error);
35
+ }
36
+ catch (error) {
37
+ error({
38
+ code: GeolocationPositionError.POSITION_UNAVAILABLE,
39
+ message: 'Failed to parse location object from MiniAppBridge: ' + error,
40
+ });
41
+ }
42
+ }, error => console.error(error));
43
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios_bridge.js","sourceRoot":"","sources":["../../src/ios/ios_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,2BAA2B;AAC3B,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAE7B,0CAA0C;AAC1C,MAAM,wBAAwB,GAAG;IAC/B,iBAAiB,EAAE,CAAC;IACpB,oBAAoB,EAAE,CAAC;IACvB,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,WAAW;IACf,UAAU,CAAC,KAAK;QACb,MAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO;QACpC,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,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,WAAW,CAC3D,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CACnD,CAAC;IACJ,CAAC;IAED,WAAW;QACT,OAAO,QAAQ,CAAC,GAAG,CAAC;IACtB,CAAC;CACF;AAED,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACrC,MAAc,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AAE/D,SAAS,CAAC,WAAW,CAAC,kBAAkB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IACrE,OAAO,WAAW,CAAC,IAAI,CACrB,oBAAoB,EACpB,EAAE,eAAe,EAAE,OAAO,EAAE,EAC5B,KAAK,CAAC,EAAE;QACN,IAAI;YACF,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrC,OAAO,CAAC,UAAU,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SACpB;QAAC,OAAO,KAAK,EAAE;YACd,KAAK,CAAC;gBACJ,IAAI,EAAE,wBAAwB,CAAC,oBAAoB;gBACnD,OAAO,EACL,sDAAsD,GAAG,KAAK;aACjE,CAAC,CAAC;SACJ;IACH,CAAC,EACD,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAC9B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,11 +1,8 @@
1
1
  import * as ResponseDataType from "src/base/response_data_type";
2
2
  import NativeAppInterFace from "src/interface/native_app_interface";
3
3
  import * as InputDataType from "src/base/input_data_type";
4
-
5
- export class NativeApp implements NativeAppInterFace {
6
- public getAppId() {
7
- return "";
8
- }
4
+ export declare class NativeAppClass implements NativeAppInterFace {
5
+ getAppId(): string;
9
6
  login: (data?: InputDataType.LoginInput | undefined) => Promise<string>;
10
7
  getLoginStatus: () => boolean;
11
8
  getAccessToken: () => Promise<string | null>;
@@ -13,5 +10,5 @@ export class NativeApp implements NativeAppInterFace {
13
10
  getSystemInfo: () => ResponseDataType.SystemInfo;
14
11
  getBusinessInfo: () => ResponseDataType.BusinessInfo;
15
12
  getBusinessConfig: () => ResponseDataType.BusinessConfig;
16
-
17
13
  }
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/native_app/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,6BAA6B,CAAC;AAChE,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAE1D,qBAAa,cAAe,YAAW,kBAAkB;IACrD,QAAQ,IAAI,MAAM;IAGlB,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,GAAG,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,gBAAgB,CAAC,UAAU,CAAC;IACjD,eAAe,EAAE,MAAM,gBAAgB,CAAC,YAAY,CAAC;IACrD,iBAAiB,EAAE,MAAM,gBAAgB,CAAC,cAAc,CAAC;CAE5D"}
@@ -0,0 +1,32 @@
1
+ export class NativeAppClass {
2
+ getAppId() {
3
+ return "App ID ne hihi";
4
+ }
5
+ }
6
+ // const NativeApp: NativeAppInterFace = {
7
+ // getAppId: function (): string {
8
+ // throw new Error("Function not implemented.");
9
+ // },
10
+ // login: function (data?: LoginInput | undefined): Promise<string> {
11
+ // throw new Error("Function not implemented.");
12
+ // },
13
+ // getLoginStatus: function (): boolean {
14
+ // throw new Error("Function not implemented.");
15
+ // },
16
+ // getAccessToken: function (): Promise<string | null> {
17
+ // throw new Error("Function not implemented.");
18
+ // },
19
+ // getVersion: function (): string {
20
+ // throw new Error("Function not implemented.");
21
+ // },
22
+ // getSystemInfo: function (): SystemInfo {
23
+ // throw new Error("Function not implemented.");
24
+ // },
25
+ // getBusinessInfo: function (): BusinessInfo {
26
+ // throw new Error("Function not implemented.");
27
+ // },
28
+ // getBusinessConfig: function (): BusinessConfig {
29
+ // throw new Error("Function not implemented.");
30
+ // }
31
+ // }
32
+ // export { NativeApp };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/native_app/index.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,SAAS;IACX,QAAQ;QACX,OAAO,EAAE,CAAC;IACd,CAAC;CASJ"}
@@ -0,0 +1,8 @@
1
+ /** @internal */
2
+ /** Device platform. */
3
+ export declare enum Platform {
4
+ ANDROID = "Android",
5
+ IOS = "iOS",
6
+ WEB = "Web"
7
+ }
8
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/types/platform.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAEhB,uBAAuB;AACvB,oBAAY,QAAQ;IAChB,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACd"}
@@ -0,0 +1,8 @@
1
+ /** @internal */
2
+ /** Device platform. */
3
+ export var Platform;
4
+ (function (Platform) {
5
+ Platform["ANDROID"] = "Android";
6
+ Platform["IOS"] = "iOS";
7
+ Platform["WEB"] = "Web";
8
+ })(Platform || (Platform = {}));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/types/platform.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAEhB,uBAAuB;AACvB,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,+BAAmB,CAAA;IACnB,uBAAW,CAAA;IACX,uBAAW,CAAA;AACf,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB"}
@@ -0,0 +1,2 @@
1
+ export * from './base_type';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export * from './base_type';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,34 @@
1
- {
2
- "name": "gap-nodejs-sdk",
3
- "version": "1.0.0",
4
- "description": "GCI App Platform Library for Node",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "tsc",
10
- "lint": "eslint '**/*.{ts,tsx}' --max-warnings 0",
11
- "clean": "rimraf ./dist tsconfig.tsbuildinfo"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "https://gitlab.dtsmart.vn/gap/gap-nodejs-sdk.git"
16
- },
17
- "author": "TanNX",
18
- "license": "ISC",
19
- "devDependencies": {
20
- "rimraf": "^3.0.2",
21
- "typescript": "^4.7.2"
22
- },
23
- "dependencies": {
24
- "tslib": "^2.4.0"
25
- }
1
+ {
2
+ "name": "gap-nodejs-sdk",
3
+ "version": "1.0.1",
4
+ "description": "GCI App Platform Library for Node",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "prepare": "npm run build",
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "build": "cd gap-miniapp-sdk && tsc && cd .. && tsc",
14
+ "lint": "eslint '**/*.{ts,tsx}' --max-warnings 0",
15
+ "clean": "rimraf ./dist tsconfig.tsbuildinfo",
16
+ "bundle": "cd gap-miniapp-sdk && tsc && cd .. && tsc && browserify -p esmify dist/index.js -o javascript/bundle.js"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://gitlab.dtsmart.vn/gap/gap-nodejs-sdk.git"
21
+ },
22
+ "author": "TanNX",
23
+ "license": "ISC",
24
+ "devDependencies": {
25
+ "esmify": "^2.1.1",
26
+ "rimraf": "^3.0.2",
27
+ "typescript": "^4.7.2",
28
+ "gap-miniapp-sdk": "file:./gap-miniapp-sdk"
29
+ },
30
+ "dependencies": {
31
+ "browserify": "^17.0.0",
32
+ "tslib": "^2.4.0"
33
+ }
26
34
  }
package/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import Gap from "./src/index";
2
-
3
- (function test() {
4
-
5
- })();
@@ -1,33 +0,0 @@
1
- import {
2
- PlatformExecutor,
3
- MiniAppBridge,
4
- Callback,
5
- mabMessageQueue,
6
- } from '../common_bridge';
7
- import { Platform } from '../types/platform';
8
-
9
- /* tslint:disable:no-any */
10
- let uniqueId = Math.random();
11
-
12
- class AndroidExecutor implements PlatformExecutor {
13
- execEvents(event) {
14
- (window as any).dispatchEvent(event);
15
- }
16
- exec(action, param, onSuccess, onError) {
17
- const callback = {} as Callback;
18
- callback.onSuccess = onSuccess;
19
- callback.onError = onError;
20
- callback.id = String(++uniqueId);
21
- mabMessageQueue.unshift(callback);
22
-
23
- (window as any).MiniAppAndroid.postMessage(
24
- JSON.stringify({ action, param, id: callback.id })
25
- );
26
- }
27
-
28
- getPlatform(): string {
29
- return Platform.ANDROID;
30
- }
31
- }
32
-
33
- (window as any).MiniAppBridge = new MiniAppBridge(new AndroidExecutor());
@@ -1,36 +0,0 @@
1
- import { GapError } from "src/error"
2
-
3
- export declare type ResponseSuccess = {
4
- channel: string,
5
- type: string,
6
- method: string,
7
- data: string
8
- }
9
-
10
- export declare type ResponseError = {
11
- error: object | GapError | string,
12
- }
13
-
14
- export declare type SystemInfo = {
15
- version: string,
16
- apiVersion: string
17
- }
18
-
19
- export declare type BusinessInfo = {
20
- name: string,
21
- shortName: string,
22
- phone: string,
23
- address: string,
24
- countryCode: string,
25
- city: string,
26
- stateCode: string,
27
- postalCode: string,
28
- description: string,
29
- logoImage: string,
30
- coverImage: string
31
- }
32
-
33
- export declare type BusinessConfig = {
34
- setting: object | string,
35
- appSetting: object | string,
36
- }
package/src/base_type.ts DELETED
@@ -1,14 +0,0 @@
1
- export enum GapApiVersion {
2
- V1 = '1.0.0',
3
- }
4
-
5
- export enum GapHeader {
6
- GClientId = 'G-ClientID'
7
- }
8
-
9
- export enum UserAgent {
10
- IOS = 'IOS',
11
- ANDROID = 'ANDROID',
12
- CHROME = 'CHROME',
13
- SAFARI = 'SAFARI',
14
- }
package/src/context.ts DELETED
@@ -1,72 +0,0 @@
1
- import { GapApiVersion } from "./base-type";
2
- import * as GapErrors from "./error";
3
-
4
-
5
- interface ContextInterface {
6
- API_KEY: string;
7
- API_SECRET_KEY: string;
8
- G_CLIENTID: string;
9
- API_VERSION: GapApiVersion;
10
- USER_AGENT: string;
11
- // HOST_NAME: string;
12
- // HOST_SCHEME?: string;
13
- // IS_EMBEDDED_APP: boolean;
14
- // IS_PRIVATE_APP?: boolean;
15
- LOG_FILE?: string;
16
- USER_AGENT_PREFIX?: string;
17
-
18
-
19
- /**
20
- * Sets up the GAP API Library
21
- *
22
- * @param params Settings to update
23
- */
24
- initialize(params: ContextInterface): void;
25
-
26
- /**
27
- * Throws error if context has not been initialized.
28
- */
29
- throwIfUninitialized(): void | never;
30
-
31
- }
32
-
33
- const Context: ContextInterface = {
34
- API_KEY: "",
35
- API_SECRET_KEY: "",
36
- G_CLIENTID: "",
37
- USER_AGENT: "",
38
- API_VERSION: GapApiVersion.V1,
39
- initialize: function (params: ContextInterface): void {
40
- // Make sure that the essential params actually have content in them
41
- const missing: string[] = [];
42
- if (!params.API_KEY.length) {
43
- missing.push('API_KEY');
44
- }
45
- if (!params.API_SECRET_KEY.length) {
46
- missing.push('API_SECRET_KEY');
47
- }
48
- if (!params.API_SECRET_KEY.length) {
49
- missing.push('G_CLIENTID');
50
- }
51
- if (missing.length) {
52
- throw new GapErrors.MissingDataContextError(
53
- `Cannot initialize Shopify API Library. Missing values for: ${missing.join(
54
- ', '
55
- )}`
56
- );
57
- }
58
- this.API_KEY = params.API_KEY;
59
- this.API_SECRET_KEY = params.API_SECRET_KEY;
60
- this.G_CLIENTID = params.G_CLIENTID;
61
- this.API_VERSION = params.API_VERSION;
62
- },
63
- throwIfUninitialized: function (): void {
64
- if (!this.API_KEY || this.API_KEY.length === 0) {
65
- throw new GapErrors.UninitializedContextError(
66
- 'Context has not been properly initialized. Please call the .initialize() method to setup your app context object.'
67
- );
68
- }
69
- },
70
- }
71
-
72
- export { Context, ContextInterface };
package/src/error.ts DELETED
@@ -1,39 +0,0 @@
1
- export class GapError extends Error {
2
- constructor(...args: any) {
3
- super(...args);
4
- Object.setPrototypeOf(this, new.target.prototype);
5
- }
6
- }
7
-
8
- interface HttpResponseData {
9
- code: number;
10
- statusText: string;
11
- body?: { [key: string]: unknown };
12
- headers?: { [key: string]: unknown };
13
- }
14
- interface HttpResponseErrorParams extends HttpResponseData {
15
- message: string;
16
- }
17
- export class HttpResponseError extends GapError {
18
- readonly response: HttpResponseData;
19
-
20
- public constructor({
21
- message,
22
- code,
23
- statusText,
24
- body,
25
- headers,
26
- }: HttpResponseErrorParams) {
27
- super(message);
28
- this.response = {
29
- code,
30
- statusText,
31
- body,
32
- headers,
33
- };
34
- }
35
- }
36
-
37
- //Detail of error for testing purpose
38
- export class UninitializedContextError extends GapError { };
39
- export class MissingDataContextError extends GapError { };
package/src/index.ts DELETED
@@ -1,13 +0,0 @@
1
- import { Context } from './context';
2
- import * as NativeApp from "./native_app/index";
3
- import * as ShopifyErrors from './error';
4
-
5
- export const Gap = {
6
- Context,
7
- NativeApp,
8
- // GciClientApi,
9
- Errors: ShopifyErrors,
10
- };
11
-
12
- export default Gap;
13
- export * from './types';
@@ -1,61 +0,0 @@
1
- import {
2
- PlatformExecutor,
3
- MiniAppBridge,
4
- Callback,
5
- mabMessageQueue,
6
- } from '../common_bridge';
7
- import { Platform } from '../types/platform';
8
-
9
- /* tslint:disable:no-any */
10
- let uniqueId = Math.random();
11
-
12
- // tslint:disable-next-line: variable-name
13
- const GeolocationPositionError = {
14
- PERMISSION_DENIED: 1,
15
- POSITION_UNAVAILABLE: 2,
16
- TIMEOUT: 3,
17
- };
18
-
19
- class IOSExecutor implements PlatformExecutor {
20
- execEvents(event): void {
21
- (window as any).dispatchEvent(event);
22
- }
23
- exec(action, param, onSuccess, onError) {
24
- const callback = {} as Callback;
25
- callback.onSuccess = onSuccess;
26
- callback.onError = onError;
27
- callback.id = String(++uniqueId);
28
- mabMessageQueue.unshift(callback);
29
-
30
- (window as any).webkit.messageHandlers.MiniAppiOS.postMessage(
31
- JSON.stringify({ action, param, id: callback.id })
32
- );
33
- }
34
-
35
- getPlatform(): string {
36
- return Platform.IOS;
37
- }
38
- }
39
-
40
- const iOSExecutor = new IOSExecutor();
41
- (window as any).MiniAppBridge = new MiniAppBridge(iOSExecutor);
42
-
43
- navigator.geolocation.getCurrentPosition = (success, error, options) => {
44
- return iOSExecutor.exec(
45
- 'getCurrentPosition',
46
- { locationOptions: options },
47
- value => {
48
- try {
49
- const parsedData = JSON.parse(value);
50
- success(parsedData);
51
- } catch (error) {
52
- error({
53
- code: GeolocationPositionError.POSITION_UNAVAILABLE,
54
- message:
55
- 'Failed to parse location object from MiniAppBridge: ' + error,
56
- });
57
- }
58
- },
59
- error => console.error(error)
60
- );
61
- };
@@ -1,8 +0,0 @@
1
- /** @internal */
2
-
3
- /** Device platform. */
4
- export enum Platform {
5
- ANDROID = 'Android',
6
- IOS = 'iOS',
7
- WEB = 'Web'
8
- }
package/src/types.ts DELETED
@@ -1 +0,0 @@
1
- export * from './base-type';
package/tsconfig.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "compileOnSave": false,
3
- "compilerOptions": {
4
- "composite": true,
5
- "declaration": true,
6
- "declarationMap": true,
7
- "pretty": true,
8
- "moduleResolution": "node",
9
- "target": "es6",
10
- "downlevelIteration": true,
11
- "esModuleInterop": true,
12
- "sourceMap": false,
13
- "noEmitOnError": false,
14
- "experimentalDecorators": true,
15
- "noUnusedParameters": true,
16
- "noUnusedLocals": true,
17
- "importHelpers": true,
18
- "strictNullChecks": true,
19
- "noImplicitAny": false,
20
- "noImplicitThis": true,
21
- "resolveJsonModule": true,
22
- "skipLibCheck": true,
23
- "lib": [
24
- "dom",
25
- "dom.iterable",
26
- "es2015",
27
- "es2016",
28
- "es2017",
29
- "es2018",
30
- "es2019",
31
- "es2020",
32
- "esnext.asynciterable"
33
- ],
34
- "typeRoots": [
35
- "./node_modules/@types"
36
- ],
37
- "outDir": "./dist",
38
- "baseUrl": ".",
39
- "rootDir": "src"
40
- },
41
- "include": [
42
- "./src/**/*.ts",
43
- "./src/**/*.tsx"
44
- ],
45
- "exclude": [
46
- "**/*.test.ts",
47
- "**/*.test.tsx",
48
- "**/test/*"
49
- ]
50
- }