@grabjs/superapp-sdk 1.7.6 → 1.7.8
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/index.js +1 -1
- package/docs/ContainerModule.md +63 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).SuperAppSDK={})}(this,function(e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var o,a,i=(function(e,t){function u(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var r=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=r.indexOf(e)})}function c(o,e){var a=e.callbackNameFunc,i=e.funcToWrap;return function(e){return{subscribe:e,then:function(r,o){return new Promise(function(){try{var t=null,n=!1;t=e({next:function(e){r&&r(e),t&&t.unsubscribe(),n=!0}}),n&&t&&t.unsubscribe()}catch(e){o&&o(e)}})}}}(function(n){var t,r=a();return o[r]=function(e){if(u(e,"status_code"))if(u(e.result,"event"))switch(e.result.event){case s.StreamEvent.STREAM_TERMINATED:t.unsubscribe()}else n&&n.next&&n.next(e)},i(r),t=function(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(delete o[r],n&&n.complete&&n.complete(),t=!0)}}}()})}var s;((s=t).StreamEvent||(s.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",s.wrapModule=function(a,i){a[function(e){return"Wrapped"+e}(i)]=function(e,r,t){var o={};return{invoke:function(t,n){return function(e,t){return t.funcNameToWrap,c(e,function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}return n}(t,["funcNameToWrap"]))}(e,{funcNameToWrap:t,callbackNameFunc:function(){var e=o[t]||0;return o[t]=e+1,function(e){var t=e.moduleName,n=e.funcName,r=e.requestID;return t+"_"+n+"Callback"+(null!==r?"_"+r:"")}({moduleName:r,requestID:e,funcName:t})},funcToWrap:function(e){return function(e){if(a[i])a[i][e.method](JSON.stringify(e));else{if(!(a.webkit&&a.webkit.messageHandlers&&a.webkit.messageHandlers[i]))throw new Error("Unexpected method '"+e.method+"' for module '"+i+"'");a.webkit.messageHandlers[i].postMessage(e)}}({callback:e,method:t,module:r,parameters:null!=n?n:{}})}})}}}(a,i)},Object.defineProperty(s,"__esModule",{value:!0})}(o={exports:{}},o.exports),o.exports),u=(a=i)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,c=function(){function e(){t(this,e),u.wrapModule(window,"CheckoutModule")}return n(e,[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]),e}(),s=require("@grabjs/mobile-kit-bridge-sdk"),v={STARTED:"STARTED",PAYMENT_STATUS_UPDATED:"PAYMENT_STATUS_UPDATED",ERROR_OCCURRED:"ERROR_OCCURRED",CUSTOM:"CUSTOM"},d={WARNING:"WARNING",ERROR:"ERROR",CRITICAL:"CRITICAL"},f={SUCCESS:"SUCCESS",FAILURE:"FAILURE",CANCEL:"CANCEL",PROCESSING:"PROCESSING"},p=function(){function e(){t(this,e),s.wrapModule(window,"ContainerModule")}return n(e,[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"sendAnalyticsEvent",value:function(e){var t=this._validateAnalyticsEvent(e);return t?{then:function(e){return e({result:null,error:t})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{url:e.url,sessionId:e.sessionId,viewName:e.viewName,eventName:e.eventName,eventData:JSON.stringify(e.eventData)})}},{key:"_validateAnalyticsEvent",value:function(e){for(var t=0,n=["eventName"];t<n.length;t++){var r=n[t];if(!e[r])return"Missing required field: ".concat(r)}if(e.url&&"string"!=typeof e.url)return"url must be a string";if(e.sessionId&&"string"!=typeof e.sessionId)return"sessionId must be a string";if(e.viewName&&"string"!=typeof e.viewName)return"viewName must be a string";var o=Object.values(v);if(!o.includes(e.eventName))return"Invalid eventName. Must be one of: ".concat(o.join(", "));switch(e.eventName){case v.STARTED:return this._validateStartedEvent(e.eventData);case v.PAYMENT_STATUS_UPDATED:return this._validatePaymentStatusUpdatedEvent(e.eventData);case v.ERROR_OCCURRED:return this._validateErrorOccurredEvent(e.eventData);case v.CUSTOM:return this._validateCustomEvent(e.eventData)}return null}},{key:"_validateStartedEvent",value:function(e){return null!=e?"".concat(v.STARTED," event should have empty eventData"):null}},{key:"_validatePaymentStatusUpdatedEvent",value:function(e){if(!e)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData to be an object");var t=["transactionId","statusCode","statusMessage","products","amount","currency","promoCodes"],n=Object.keys(e).filter(function(e){return!t.includes(e)});if(0<n.length)return"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData: ").concat(n.join(", "));if(e.transactionId&&"string"!=typeof e.transactionId)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires transactionId in eventData to be a string");if(!e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be defined");if("string"!=typeof e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be a string");var r=Object.values(f);if(!r.includes(e.statusCode))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be one of: ").concat(r.join(", "));if(e.statusMessage&&"string"!=typeof e.statusMessage)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusMessage in eventData to be a string");if(e.products){if(!Array.isArray(e.products))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires products in eventData to be an array");var o=!0,a=!1,i=void 0;try{for(var u,c=function(){var e=u.value,t=["id","quantity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData.products item: ").concat(n.join(", "))}:e.id?"string"!=typeof e.id?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be a string")}:e.quantity&&"number"!=typeof e.quantity?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires quantity in eventData.products item to be a number")}:void 0:{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be defined")}},s=e.products[Symbol.iterator]();!(o=(u=s.next()).done);o=!0){var d=c();if("object"===l(d))return d.v}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e.amount&&"number"!=typeof e.amount?"".concat(v.PAYMENT_STATUS_UPDATED," event requires amount in eventData to be a number"):e.currency&&"string"!=typeof e.currency?"".concat(v.PAYMENT_STATUS_UPDATED," event requires currency in eventData to be a string"):!e.promoCodes||Array.isArray(e.promoCodes)&&e.promoCodes.every(function(e){return"string"==typeof e})?null:"".concat(v.PAYMENT_STATUS_UPDATED," event requires promoCodes in eventData to be an array of strings")}},{key:"_validateErrorOccurredEvent",value:function(e){if(!e)return"".concat(v.ERROR_OCCURRED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.ERROR_OCCURRED," event requires eventData to be an object");var t=["errorCode","errorMessage","errorSeverity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.ERROR_OCCURRED," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.errorCode?"string"!=typeof e.errorCode?"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be a string"):e.errorMessage&&"string"!=typeof e.errorMessage?"".concat(v.ERROR_OCCURRED," event requires errorMessage in eventData to be a string"):e.errorSeverity&&!Object.values(d).includes(e.errorSeverity)?"".concat(v.ERROR_OCCURRED," event requires errorSeverity in eventData to be one of: ").concat(Object.values(d).join(", ")):null:"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be defined")}},{key:"_validateCustomEvent",value:function(e){if(!e)return"".concat(v.CUSTOM," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.CUSTOM," event requires eventData to be an object");var t=["customEventName","customEventData"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.CUSTOM," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.customEventName?"string"!=typeof e.customEventName?"".concat(v.CUSTOM," event requires customEventName in eventData to be a string"):null:"".concat(v.CUSTOM," event requires customEventName in eventData to be defined")}}]),e}(),y=function(){function e(){t(this,e),u.wrapModule(window,"LocaleModule")}return n(e,[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]),e}(),w=function(){function e(){t(this,e),u.wrapModule(window,"LocationModule")}return n(e,[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}}]),e}(),T=function(){function e(){t(this,e),u.wrapModule(window,"MediaModule")}return n(e,[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]),e}(),b=require("@grabjs/mobile-kit-bridge-sdk"),S=function(){function e(){t(this,e),b.wrapModule(window,"PlatformModule")}return n(e,[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]),e}(),M=function(){function e(){t(this,e),u.wrapModule(window,"ScopeModule")}return n(e,[{key:"hasAccessTo",value:function(e,t){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:t})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]),e}(),m=require("@grabjs/mobile-kit-bridge-sdk"),E=function(){function e(){t(this,e),m.wrapModule(window,"StorageModule")}return n(e,[{key:"setBoolean",value:function(e,t){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:t})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,t){return window.WrappedStorageModule.invoke("setInt",{key:e,value:t})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,t){return window.WrappedStorageModule.invoke("setString",{key:e,value:t})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,t){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:t})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]),e}(),g=function(){function e(){t(this,e),u.wrapModule(window,"SystemWebViewKitModule")}return n(e,[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]),e}();e.CheckoutModule=c,e.ContainerModule=p,e.LocaleModule=y,e.LocationModule=w,e.MediaModule=T,e.PlatformModule=S,e.ScopeModule=M,e.StorageModule=E,e.SystemWebViewKitModule=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).SuperAppSDK={})}(this,function(e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function n(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,a,i=(function(e,t){function u(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var o=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=o.indexOf(e)})}function c(r,e){var a=e.callbackNameFunc,i=e.funcToWrap;return function(e){return{subscribe:e,then:function(o,r){return new Promise(function(){try{var t=null,n=!1;t=e({next:function(e){o&&o(e),t&&t.unsubscribe(),n=!0}}),n&&t&&t.unsubscribe()}catch(e){r&&r(e)}})}}}(function(n){var t,o=a();return r[o]=function(e){if(u(e,"status_code"))if(u(e.result,"event"))switch(e.result.event){case s.StreamEvent.STREAM_TERMINATED:t.unsubscribe()}else n&&n.next&&n.next(e)},i(o),t=function(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(delete r[o],n&&n.complete&&n.complete(),t=!0)}}}()})}var s;((s=t).StreamEvent||(s.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",s.wrapModule=function(a,i){a[function(e){return"Wrapped"+e}(i)]=function(e,o,t){var r={};return{invoke:function(t,n){return function(e,t){return t.funcNameToWrap,c(e,function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n}(t,["funcNameToWrap"]))}(e,{funcNameToWrap:t,callbackNameFunc:function(){var e=r[t]||0;return r[t]=e+1,function(e){var t=e.moduleName,n=e.funcName,o=e.requestID;return t+"_"+n+"Callback"+(null!==o?"_"+o:"")}({moduleName:o,requestID:e,funcName:t})},funcToWrap:function(e){return function(e){if(a[i])a[i][e.method](JSON.stringify(e));else{if(!(a.webkit&&a.webkit.messageHandlers&&a.webkit.messageHandlers[i]))throw new Error("Unexpected method '"+e.method+"' for module '"+i+"'");a.webkit.messageHandlers[i].postMessage(e)}}({callback:e,method:t,module:o,parameters:null!=n?n:{}})}})}}}(a,i)},Object.defineProperty(s,"__esModule",{value:!0})}(r={exports:{}},r.exports),r.exports),u=(a=i)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,c=function(){function e(){t(this,e),u.wrapModule(window,"CheckoutModule")}return n(e,[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]),e}(),s=require("@grabjs/mobile-kit-bridge-sdk"),v={STARTED:"STARTED",PAYMENT_STATUS_UPDATED:"PAYMENT_STATUS_UPDATED",ERROR_OCCURRED:"ERROR_OCCURRED",CUSTOM:"CUSTOM"},d={WARNING:"WARNING",ERROR:"ERROR",CRITICAL:"CRITICAL"},f={SUCCESS:"SUCCESS",FAILURE:"FAILURE",CANCEL:"CANCEL",PROCESSING:"PROCESSING"},p=function(){function e(){t(this,e),s.wrapModule(window,"ContainerModule")}return n(e,[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"onContentLoaded",value:function(){return window.WrappedContainerModule.invoke("onContentLoaded")}},{key:"openExternalLink",value:function(e){return window.WrappedContainerModule.invoke("openExternalLink",{url:e})}},{key:"sendAnalyticsEvent",value:function(e){var t=this._validateAnalyticsEvent(e);return t?{then:function(e){return e({result:null,error:t})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{url:e.url,sessionId:e.sessionId,viewName:e.viewName,eventName:e.eventName,eventData:JSON.stringify(e.eventData)})}},{key:"_validateAnalyticsEvent",value:function(e){for(var t=0,n=["eventName"];t<n.length;t++){var o=n[t];if(!e[o])return"Missing required field: ".concat(o)}if(e.url&&"string"!=typeof e.url)return"url must be a string";if(e.sessionId&&"string"!=typeof e.sessionId)return"sessionId must be a string";if(e.viewName&&"string"!=typeof e.viewName)return"viewName must be a string";var r=Object.values(v);if(!r.includes(e.eventName))return"Invalid eventName. Must be one of: ".concat(r.join(", "));switch(e.eventName){case v.STARTED:return this._validateStartedEvent(e.eventData);case v.PAYMENT_STATUS_UPDATED:return this._validatePaymentStatusUpdatedEvent(e.eventData);case v.ERROR_OCCURRED:return this._validateErrorOccurredEvent(e.eventData);case v.CUSTOM:return this._validateCustomEvent(e.eventData)}return null}},{key:"_validateStartedEvent",value:function(e){return null!=e?"".concat(v.STARTED," event should have empty eventData"):null}},{key:"_validatePaymentStatusUpdatedEvent",value:function(e){if(!e)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData to be an object");var t=["transactionId","statusCode","statusMessage","products","amount","currency","promoCodes"],n=Object.keys(e).filter(function(e){return!t.includes(e)});if(0<n.length)return"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData: ").concat(n.join(", "));if(e.transactionId&&"string"!=typeof e.transactionId)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires transactionId in eventData to be a string");if(!e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be defined");if("string"!=typeof e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be a string");var o=Object.values(f);if(!o.includes(e.statusCode))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be one of: ").concat(o.join(", "));if(e.statusMessage&&"string"!=typeof e.statusMessage)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusMessage in eventData to be a string");if(e.products){if(!Array.isArray(e.products))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires products in eventData to be an array");var r=!0,a=!1,i=void 0;try{for(var u,c=function(){var e=u.value,t=["id","quantity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData.products item: ").concat(n.join(", "))}:e.id?"string"!=typeof e.id?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be a string")}:e.quantity&&"number"!=typeof e.quantity?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires quantity in eventData.products item to be a number")}:void 0:{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be defined")}},s=e.products[Symbol.iterator]();!(r=(u=s.next()).done);r=!0){var d=c();if("object"===l(d))return d.v}}catch(e){a=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(a)throw i}}}return e.amount&&"number"!=typeof e.amount?"".concat(v.PAYMENT_STATUS_UPDATED," event requires amount in eventData to be a number"):e.currency&&"string"!=typeof e.currency?"".concat(v.PAYMENT_STATUS_UPDATED," event requires currency in eventData to be a string"):!e.promoCodes||Array.isArray(e.promoCodes)&&e.promoCodes.every(function(e){return"string"==typeof e})?null:"".concat(v.PAYMENT_STATUS_UPDATED," event requires promoCodes in eventData to be an array of strings")}},{key:"_validateErrorOccurredEvent",value:function(e){if(!e)return"".concat(v.ERROR_OCCURRED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.ERROR_OCCURRED," event requires eventData to be an object");var t=["errorCode","errorMessage","errorSeverity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.ERROR_OCCURRED," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.errorCode?"string"!=typeof e.errorCode?"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be a string"):e.errorMessage&&"string"!=typeof e.errorMessage?"".concat(v.ERROR_OCCURRED," event requires errorMessage in eventData to be a string"):e.errorSeverity&&!Object.values(d).includes(e.errorSeverity)?"".concat(v.ERROR_OCCURRED," event requires errorSeverity in eventData to be one of: ").concat(Object.values(d).join(", ")):null:"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be defined")}},{key:"_validateCustomEvent",value:function(e){if(!e)return"".concat(v.CUSTOM," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.CUSTOM," event requires eventData to be an object");var t=["customEventName","customEventData"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.CUSTOM," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.customEventName?"string"!=typeof e.customEventName?"".concat(v.CUSTOM," event requires customEventName in eventData to be a string"):null:"".concat(v.CUSTOM," event requires customEventName in eventData to be defined")}}]),e}(),y=function(){function e(){t(this,e),u.wrapModule(window,"LocaleModule")}return n(e,[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]),e}(),w=function(){function e(){t(this,e),u.wrapModule(window,"LocationModule")}return n(e,[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}}]),e}(),T=function(){function e(){t(this,e),u.wrapModule(window,"MediaModule")}return n(e,[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]),e}(),b=require("@grabjs/mobile-kit-bridge-sdk"),S=function(){function e(){t(this,e),b.wrapModule(window,"PlatformModule")}return n(e,[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]),e}(),k=function(){function e(){t(this,e),u.wrapModule(window,"ScopeModule")}return n(e,[{key:"hasAccessTo",value:function(e,t){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:t})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]),e}(),M=require("@grabjs/mobile-kit-bridge-sdk"),E=function(){function e(){t(this,e),M.wrapModule(window,"StorageModule")}return n(e,[{key:"setBoolean",value:function(e,t){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:t})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,t){return window.WrappedStorageModule.invoke("setInt",{key:e,value:t})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,t){return window.WrappedStorageModule.invoke("setString",{key:e,value:t})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,t){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:t})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]),e}(),m=function(){function e(){t(this,e),u.wrapModule(window,"SystemWebViewKitModule")}return n(e,[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]),e}();e.CheckoutModule=c,e.ContainerModule=p,e.LocaleModule=y,e.LocationModule=w,e.MediaModule=T,e.PlatformModule=S,e.ScopeModule=k,e.StorageModule=E,e.SystemWebViewKitModule=m,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/docs/ContainerModule.md
CHANGED
|
@@ -205,7 +205,69 @@ containerModule.close().then(({ result, error }) => {
|
|
|
205
205
|
});
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
### 8.
|
|
208
|
+
### 8. On content loaded
|
|
209
|
+
|
|
210
|
+
**Method name**: `onContentLoaded`
|
|
211
|
+
Call this method to notify the client that page content loaded
|
|
212
|
+
|
|
213
|
+
**Arguments**
|
|
214
|
+
|
|
215
|
+
`None`
|
|
216
|
+
|
|
217
|
+
**Return type**
|
|
218
|
+
|
|
219
|
+
`None`
|
|
220
|
+
|
|
221
|
+
**Code example**
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
import { ContainerModule } from "@grabjs/superapp-sdk";
|
|
225
|
+
|
|
226
|
+
// Ideally, initialize this only one and reuse across app.
|
|
227
|
+
const containerModule = new ContainerModule();
|
|
228
|
+
|
|
229
|
+
containerModule.onContentLoaded().then(({ result, error }) => {
|
|
230
|
+
if (result) {
|
|
231
|
+
// There is a valid result.
|
|
232
|
+
} else if (error) {
|
|
233
|
+
// Some error happened.
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 9. Open link in external browser
|
|
239
|
+
|
|
240
|
+
**Method name**: `openExternalLink`
|
|
241
|
+
Call this method to tell client to open the link in external browser
|
|
242
|
+
|
|
243
|
+
**Arguments**
|
|
244
|
+
|
|
245
|
+
| Name | Type | Required | Description |
|
|
246
|
+
| ----- | ------ | -------- | ----------------- |
|
|
247
|
+
| url | String | Yes | URL to open |
|
|
248
|
+
|
|
249
|
+
**Return type**
|
|
250
|
+
|
|
251
|
+
`None`
|
|
252
|
+
|
|
253
|
+
**Code example**
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
import { ContainerModule } from "@grabjs/superapp-sdk";
|
|
257
|
+
|
|
258
|
+
// Ideally, initialize this only one and reuse across app.
|
|
259
|
+
const containerModule = new ContainerModule();
|
|
260
|
+
|
|
261
|
+
containerModule.openExternalLink("https://grab.com").then(({ result, error }) => {
|
|
262
|
+
if (result) {
|
|
263
|
+
// There is a valid result.
|
|
264
|
+
} else if (error) {
|
|
265
|
+
// Some error happened.
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 10. Send analytics event
|
|
209
271
|
|
|
210
272
|
**Method name**: `sendAnalyticsEvent`
|
|
211
273
|
|