gap-nodejs-sdk 1.0.1 → 1.0.2
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/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/gap-sdk.js +1 -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/package.json +8 -6
|
@@ -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 {};
|
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.Gap=t():e.Gap=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};window.Gap=p;const l=p})(),n})()));
|
|
@@ -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
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface HeaderParams {
|
|
2
|
+
[key: string]: string | number;
|
|
3
|
+
}
|
|
4
|
+
export declare enum DataType {
|
|
5
|
+
JSON = "application/json"
|
|
6
|
+
}
|
|
7
|
+
export declare type QueryParams = string | number | string[] | number[] | {
|
|
8
|
+
[key: string]: QueryParams;
|
|
9
|
+
};
|
|
10
|
+
export interface GetRequestParams {
|
|
11
|
+
path: string;
|
|
12
|
+
type?: DataType;
|
|
13
|
+
data?: {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
} | string;
|
|
16
|
+
query?: {
|
|
17
|
+
[key: string]: QueryParams;
|
|
18
|
+
};
|
|
19
|
+
extraHeaders?: HeaderParams;
|
|
20
|
+
tries?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare type PostRequestParams = GetRequestParams & {
|
|
23
|
+
type: DataType;
|
|
24
|
+
data: {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
} | string;
|
|
27
|
+
};
|
|
28
|
+
export declare type PutRequestParams = PostRequestParams;
|
|
29
|
+
export declare type DeleteRequestParams = GetRequestParams;
|
|
30
|
+
export declare type RequestParams = (GetRequestParams | PostRequestParams);
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/http_client/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,oBAAY,QAAQ;IAClB,IAAI,qBAAqB;CAG1B;AAED,oBAAY,WAAW,GACnB,MAAM,GACN,MAAM,GACN,MAAM,EAAE,GACR,MAAM,EAAE,GACR;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC;IAC3C,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC;IACvC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC;CAC3C,CAAC;AAEF,oBAAY,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,oBAAY,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD,oBAAY,aAAa,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var DataType;
|
|
2
|
+
(function (DataType) {
|
|
3
|
+
DataType["JSON"] = "application/json";
|
|
4
|
+
// GraphQL = "application/graphql", // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
|
|
5
|
+
// URLEncoded = "application/x-www-form-urlencoded", // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
|
|
6
|
+
})(DataType || (DataType = {}));
|
|
7
|
+
// & {
|
|
8
|
+
// method: Method;
|
|
9
|
+
// };
|
|
10
|
+
// export interface RequestReturn {
|
|
11
|
+
// body: unknown;
|
|
12
|
+
// headers: Headers;
|
|
13
|
+
// }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gap-nodejs-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "GCI App Platform Library
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "GCI App Platform Library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepare": "npm run build",
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
-
"build": "cd gap-miniapp-sdk && tsc && cd .. && tsc",
|
|
13
|
+
"build": "cd gap-miniapp-sdk && tsc && cd .. && tsc && webpack",
|
|
14
14
|
"lint": "eslint '**/*.{ts,tsx}' --max-warnings 0",
|
|
15
15
|
"clean": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
16
16
|
"bundle": "cd gap-miniapp-sdk && tsc && cd .. && tsc && browserify -p esmify dist/index.js -o javascript/bundle.js"
|
|
@@ -23,12 +23,14 @@
|
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"esmify": "^2.1.1",
|
|
26
|
+
"gap-miniapp-sdk": "file:./gap-miniapp-sdk",
|
|
26
27
|
"rimraf": "^3.0.2",
|
|
27
28
|
"typescript": "^4.7.2",
|
|
28
|
-
"
|
|
29
|
+
"webpack": "^5.73.0",
|
|
30
|
+
"webpack-cli": "^4.10.0",
|
|
31
|
+
"browserify": "^17.0.0"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"browserify": "^17.0.0",
|
|
32
34
|
"tslib": "^2.4.0"
|
|
33
35
|
}
|
|
34
|
-
}
|
|
36
|
+
}
|