natively 2.26.2 → 2.26.4

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/README.md CHANGED
@@ -18,6 +18,12 @@ function nativelyOnLoad() {
18
18
 
19
19
  You can specify an SDK version by replacing version number 2.14.0. The latest version number can be found in this repo. Debug mode which enables native alerts with errors. It's can be very useful while you developing a website.
20
20
 
21
+ ### Flutter Web iframe mode
22
+
23
+ When a website is embedded in Flutter Web as an iframe, the website page must load this SDK itself, for example from a CDN script tag or bundled application code. The outer Flutter Web app cannot inject `window.$agent` into a cross-origin iframe.
24
+
25
+ The SDK supports both native WebView injection and Flutter Web iframe messaging. In native WebViews it calls `window.flutter_inappwebview.callHandler(...)`. When the SDK is running inside an iframe and that native handler is unavailable, it sends the same serialized trigger payload to the parent window with `postMessage`.
26
+
21
27
  ### Usage
22
28
 
23
29
 
@@ -9,5 +9,4 @@ export declare class NativelyPurchases {
9
9
  purchasePackage(packageId: string, purchase_callback: Function, oldProductId?: string | null, prorationMode?: string | null): void;
10
10
  packagePrice(packageId: string, purchase_callback: Function): void;
11
11
  showCustomerCenter(show_customer_center_callback: Function): void;
12
- getOfferings(get_offerings_callback: Function): void;
13
12
  }
@@ -53,7 +53,4 @@ export class NativelyPurchases {
53
53
  showCustomerCenter(show_customer_center_callback) {
54
54
  globalContext === null || globalContext === void 0 || globalContext.natively.trigger(this.id, 42, show_customer_center_callback, "purchases_show_customer_center", {});
55
55
  }
56
- getOfferings(get_offerings_callback) {
57
- globalContext === null || globalContext === void 0 || globalContext.natively.trigger(this.id, 44, get_offerings_callback, "purchases_get_offerings", {});
58
- }
59
56
  }
package/dist/index.d.ts CHANGED
@@ -25,6 +25,6 @@ export { NativelyKlaviyoNotifications } from './classes/NativelyKlaviyoNotificat
25
25
  export { NativelyCalendar } from "./classes/NativelyCalendar";
26
26
  export { useNatively } from './hooks/useNatively';
27
27
  export { generateID } from "./utils/generateID";
28
- import "./types";
29
- import "./inject";
30
- import "./events";
28
+ import "./types.js";
29
+ import "./inject.js";
30
+ import "./events.js";
package/dist/index.js CHANGED
@@ -32,6 +32,6 @@ export { useNatively } from './hooks/useNatively.js';
32
32
  export { generateID } from "./utils/generateID.js";
33
33
 
34
34
  // Global stuff
35
- import "./types";
36
- import "./inject";
37
- import "./events";
35
+ import "./types.js";
36
+ import "./inject.js";
37
+ import "./events.js";
package/dist/inject.js CHANGED
@@ -24,10 +24,72 @@ import { NativelyStorage } from "./classes/NativelyStorage.js";
24
24
  import { NativelyFirebaseNotifications } from "./classes/NativelyFirebaseNotifications.js";
25
25
  import { NativelyKlaviyoNotifications } from './classes/NativelyKlaviyoNotifications.js';
26
26
  import { NativelyCalendar } from "./classes/NativelyCalendar.js";
27
+ var HANDLER_NAME = "💙";
28
+ var isIframe = context => {
29
+ try {
30
+ return context.self !== context.top;
31
+ } catch (_unused) {
32
+ return true;
33
+ }
34
+ };
35
+ var installAgent = context => {
36
+ var _context$$agent, _context$flutter_inap;
37
+ if (typeof ((_context$$agent = context.$agent) === null || _context$$agent === void 0 ? void 0 : _context$$agent.trigger) === "function") return true;
38
+ var runningInIframe = isIframe(context);
39
+ var hasNativeHandler = typeof ((_context$flutter_inap = context.flutter_inappwebview) === null || _context$flutter_inap === void 0 ? void 0 : _context$flutter_inap.callHandler) === "function";
40
+ if (!runningInIframe && !hasNativeHandler) return false;
41
+ var agent = {
42
+ __nativelyAgent: true,
43
+ trigger(eventName, eventData) {
44
+ var _context$flutter_inap2, _context$parent;
45
+ var serializedArgs = JSON.stringify({
46
+ trigger: {
47
+ name: eventName,
48
+ data: eventData
49
+ }
50
+ });
51
+ if (typeof ((_context$flutter_inap2 = context.flutter_inappwebview) === null || _context$flutter_inap2 === void 0 ? void 0 : _context$flutter_inap2.callHandler) === "function") {
52
+ context.flutter_inappwebview.callHandler(HANDLER_NAME, serializedArgs);
53
+ return;
54
+ }
55
+ if (runningInIframe && typeof ((_context$parent = context.parent) === null || _context$parent === void 0 ? void 0 : _context$parent.postMessage) === "function") {
56
+ context.parent.postMessage({
57
+ source: "natively-webview",
58
+ handlerName: HANDLER_NAME,
59
+ args: [serializedArgs]
60
+ }, "*");
61
+ }
62
+ },
63
+ response() {},
64
+ natively_logger() {
65
+ this.trigger("natively_logger");
66
+ }
67
+ };
68
+ context.$agent = agent;
69
+ context.natively = context.natively || agent;
70
+ if (runningInIframe && typeof context.addEventListener === "function") {
71
+ context.addEventListener("message", event => {
72
+ var data = event.data || {};
73
+ if (data.source !== "natively-flutter" || data.type !== "evaluate") return;
74
+ if (typeof data.script === "string") {
75
+ context.eval(data.script);
76
+ }
77
+ });
78
+ }
79
+ return true;
80
+ };
27
81
 
28
82
  // Assign natively to the global object
29
83
  if (globalContext) {
30
- globalContext.natively = new Natively();
84
+ var agentInstalled = installAgent(globalContext);
85
+ if (!globalContext.natively || globalContext.natively.__nativelyAgent) {
86
+ globalContext.natively = new Natively();
87
+ }
88
+ globalContext.natively.injected = agentInstalled;
89
+ if (agentInstalled && !globalContext.natively.app_version) {
90
+ globalContext.natively.app_version = Number.MAX_SAFE_INTEGER;
91
+ }
92
+
31
93
  // All other classes must be global to make a possibility to create any number of their instances
32
94
  globalContext.NativelyAdmobBanner = NativelyAdmobBanner;
33
95
  globalContext.NativelyAdmobInterstitial = NativelyAdmobInterstitial;
package/dist/types.d.ts CHANGED
@@ -49,11 +49,17 @@ interface NativelyProps {
49
49
  NativelyStorage: NativelyStorage;
50
50
  NativelyFirebaseNotifications: NativelyFirebaseNotifications;
51
51
  NativelyKlaviyoNotifications: NativelyKlaviyoNotifications;
52
- $agent: never;
52
+ $agent: NativelyAgent;
53
+ }
54
+ interface NativelyAgent {
55
+ __nativelyAgent: boolean;
56
+ trigger(eventName: string, eventData?: any): void;
57
+ response(): void;
58
+ natively_logger(): void;
53
59
  }
54
60
  declare global {
55
61
  const natively: Natively;
56
- const $agent: never;
62
+ const $agent: NativelyAgent;
57
63
  interface Window extends NativelyProps {
58
64
  }
59
65
  }
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(i,t)=>{for(var l in t)e.o(t,l)&&!e.o(i,l)&&Object.defineProperty(i,l,{enumerable:!0,get:t[l]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};e.r(i),e.d(i,{Natively:()=>l,NativelyAdmobBanner:()=>A,NativelyAdmobInterstitial:()=>S,NativelyAppleSignInService:()=>n,NativelyAudioPlayer:()=>N,NativelyAudioRecorder:()=>w,NativelyBiometrics:()=>c,NativelyCalendar:()=>D,NativelyCamera:()=>h,NativelyClipboard:()=>r,NativelyContacts:()=>m,NativelyDatePicker:()=>y,NativelyFirebaseNotifications:()=>I,NativelyGeolocation:()=>d,NativelyHealth:()=>p,NativelyInfo:()=>s,NativelyKlaviyoNotifications:()=>T,NativelyLocation:()=>g,NativelyMediaPicker:()=>f,NativelyMessage:()=>u,NativelyNFCService:()=>k,NativelyNotifications:()=>o,NativelyPurchases:()=>b,NativelyScanner:()=>_,NativelyStorage:()=>v,generateID:()=>a,useNatively:()=>P});const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e.g?e.g:null;class l{constructor(){var e,i,l,a;this.isDebug=!1,this.min_app_version=0,this.app_version=0,this.injected=!1,this.observers=[],this.onNativeError=null,this.onTabChanged=null,this.isIOSApp=(null===(i=null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.userAgent)||void 0===i?void 0:i.includes("Natively/iOS"))||!1,this.isAndroidApp=(null===(a=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}setDebug(e){t&&(t.natively.isDebug=e)}notify(e,i){t&&(t.natively.injected=!0,e&&(t.natively.min_app_version=e),i&&(t.natively.app_version=i));const l=null==t?void 0:t.natively.observers;for((null==t?void 0:t.natively.isDebug)&&console.log("[INFO] Notify observers: ",l.length);l.length>0;){const e=l.shift();null==e||e()}}addObserver(e){(null==t?void 0:t.natively.injected)?e():((null==t?void 0:t.natively.isDebug)&&console.log(`[DEBUG] addObserver: ${e}`),null==t||t.natively.observers.push(e))}trigger(e,i,l,a,n){const r=null==t?void 0:t.natively.isDebug;if(null==t?void 0:t.natively.injected)if(i>(null==t?void 0:t.natively.app_version))r&&alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${null==t?void 0:t.natively.app_version}, feature version: ${i}`);else{if(l){let i;i=e?a+"_response_"+e:a+"_response",t&&(t[i]=function(a,n){null==t||t.$agent.response(),n.message&&r?alert(`[ERROR] Error message: ${n.message}`):(r&&console.log(`[DEBUG] Callback method: ${i}, body: ${JSON.stringify(a)}, respId: ${e}`),l(a))}),n?n.response_id=e:n={response_id:e}}r&&console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(n)}`),null==t||t.$agent.trigger(a,n)}else null==t||t.natively.addObserver((()=>{null==t||t.natively.trigger(e,i,l,a,n)}))}setTabChangedHandler(e){"function"==typeof e?this.onTabChanged=e:console.warn("[Natively] Tab changed handler must be a function")}removeTabChangedHandler(){this.onTabChanged=null}setErrorHandler(e){"function"==typeof e&&(this.onNativeError=e)}removeErrorHandler(){this.onNativeError=null}setErrorScreen(e){null==t||t.natively.trigger(void 0,0,void 0,"error_screen",{show_error:e})}openLogger(){null==t||t.$agent.natively_logger()}openConsole(){null==t||t.natively.trigger(void 0,22,void 0,"app_console")}closeApp(){null==t||t.natively.trigger(void 0,11,void 0,"app_close")}showProgress(e){null==t||t.natively.trigger(void 0,11,void 0,"app_show_progress",{toggle:e})}shareImage(e){null==t||t.natively.trigger(void 0,0,void 0,"share_image",{url:e})}shareText(e){null==t||t.natively.trigger(void 0,0,void 0,"share_text",{text:e})}shareTextAndImage(e,i){null==t||t.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:i,text:e})}shareFile(e){null==t||t.natively.trigger(void 0,2,void 0,"share_file",{url:e})}openExternalURL(e,i){const l={url:void 0===e?"https://buildnatively.com":e,view:void 0!==i&&i?"external":"web"};null==t||t.natively.trigger(void 0,18,void 0,"open_link",l)}openExternalApp(e){null==t||t.natively.trigger(void 0,22,void 0,"open_app",{url:e})}showAppToast(e,i){null==t||t.natively.trigger(void 0,0,void 0,"show_toast",{text:i||"",type:e||"DEFAULT"})}showAppBanner(e,i,l){null==t||t.natively.trigger(void 0,0,void 0,"show_banner",{type:e||"INFO",title:i||"",description:l||""})}analyticsTrackEvent(e,i){const l={name:e};i&&(l.data=i),null==t||t.natively.trigger(void 0,37,void 0,"analytics_log_event",l)}analyticsSetUserId(e){const i={id:e.id};null==t||t.natively.trigger(void 0,37,void 0,"analytics_set_user_id",i)}analyticsSetUserProperty(e){const i={key:e.key,value:e.value};null==t||t.natively.trigger(void 0,37,void 0,"analytics_set_user_property",i)}requestAppReview(){null==t||t.natively.trigger(void 0,0,void 0,"request_review")}attShowPopup(e){null==t||t.natively.trigger(void 0,41,e,"att_show_popup")}attGetStatus(e){null==t||t.natively.trigger(void 0,41,e,"att_get_status")}getInsets(e){null==t||t.natively.trigger(void 0,36,e,"get_insets")}getLocales(e){null==t||t.natively.trigger(void 0,40,e,"get_locales")}setLocale(e,i){null==t||t.natively.trigger(void 0,40,i,"set_locale",{locale:e})}setAppBackgroundColor(e){null==t||t.natively.trigger(void 0,1,void 0,"app_background",{color:e})}setAppProgressColor(e){null==t||t.natively.trigger(void 0,1,void 0,"app_progress",{color:e})}setAppSwipeNavigation(e){null==t||t.natively.trigger(void 0,22,void 0,"app_navigation",{toggle:e})}setAppPullToRefresh(e){null==t||t.natively.trigger(void 0,1,void 0,"app_pull",{toggle:e})}setAppOrientation(e){null==t||t.natively.trigger(void 0,3,void 0,"app_orientation",{orientation:e})}setAppStatusBarStyle(e){null==t||t.natively.trigger(void 0,22,void 0,"status_bar_style",{style:e})}hideLoadingScreen(){null==t||t.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!1,auto_hide:!0})}showLoadingScreen(e){null==t||t.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!0,auto_hide:e||!1})}openAppSettings(){null==t||t.natively.trigger(void 0,0,void 0,"open_appsettings")}showTabBar(){null==t||t.natively.trigger(void 0,33,void 0,"show_tab_bar")}enableWakelock(){null==t||t.natively.trigger(void 0,34,void 0,"wakelock_enable")}disableWakelock(){null==t||t.natively.trigger(void 0,34,void 0,"wakelock_disable")}hideTabBar(){null==t||t.natively.trigger(void 0,33,void 0,"hide_tab_bar")}reloadWebview(){null==t||t.natively.trigger(void 0,35,void 0,"reset_webview")}getBatteryInfo(e){null==t||t.natively.trigger(void 0,43,e,"battery_info")}hapticPattern(e,i){null==t||t.natively.trigger(void 0,22,void 0,"haptic_pattern",{pattern:e,delay:i})}openPDF(e,i){const l={url:e.url||"",base64:e.base64||"",fileName:e.fileName||`pdf-${(new Date).getTime()}.pdf`,download:!0===e.download};null==t||t.natively.trigger(void 0,38,i,"open_pdf",l)}hapticImpact(e){null==t||t.natively.trigger(void 0,22,void 0,"haptic_impact",{type:e})}hapticNotification(e){null==t||t.natively.trigger(void 0,22,void 0,"haptic_notification",{type:e})}}const a=()=>Date.now().toString(36)+Math.random().toString(36).substring(2);class n{constructor(){this.id=a()}signin(e){null==t||t.natively.trigger(this.id,16,e,"apple_signin",{})}}class r{constructor(){this.id=a()}copy(e){null==t||t.natively.trigger(void 0,11,void 0,"clipboard_copy",{text:e})}paste(e){null==t||t.natively.trigger(this.id,11,e,"clipboard_paste")}}class s{constructor(){this.id=a()}browserInfo(){var e,i,l,a;return{isNativeApp:void 0!==(null==t?void 0:t.$agent),isIOSApp:(null===(i=null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.userAgent)||void 0===i?void 0:i.includes("Natively/iOS"))||!1,isAndroidApp:(null===(a=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}}getAppInfo(e){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(this.id,0,e,"app_info"))}connectivity(e){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,0,e,"connectivity"))}app_state(e){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,19,e,"app_state"))}keyboard_visibility(e){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,34,e,"keyboard_visibility"))}}class o{constructor(){this.id=a()}getOneSignalId(e){null==t||t.natively.trigger(this.id,0,e,"onesignal_playerid")}requestPermission(e,i){null==t||t.natively.trigger(this.id,0,i,"push_register",{fallbackToSettings:e})}getPermissionStatus(e){null==t||t.natively.trigger(this.id,0,e,"push_permission")}getExternalId(e){null==t||t.natively.trigger(this.id,0,e,"onesignal_externalid")}setExternalId(e,i){null==t||t.natively.trigger(this.id,0,i,"onesignal_setexternalid",e)}removeExternalId(e){null==t||t.natively.trigger(this.id,0,e,"onesignal_removeexternalid")}}class d{constructor(){this.id=a()}getUserGeolocation(e,i){null==t||t.natively.trigger(this.id,0,i,"geolocation",{distance:e})}requestPermission(e){null==t||t.natively.trigger(this.id,0,e,"geo_register")}getPermissionStatus(e){null==t||t.natively.trigger(this.id,0,e,"geo_permission")}}class g{constructor(){this.id=a()}current(e,i,l,a,n=!0){null==t||t.natively.trigger(this.id,12,a,"location_current",{minAccuracy:e,accuracyType:i,priority:l,fallbackToSettings:n})}permission(e){null==t||t.natively.trigger(this.id,6,e,"location_permission")}start(e,i,l,a,n,r=!0){null==t||t.natively.trigger(this.id,12,n,"location_start",{minAccuracy:i,accuracyType:l,priority:a,fallbackToSettings:r,interval:e})}stop(){null==t||t.natively.trigger(this.id,3,void 0,"location_stop",{})}startBackground(e,i,l,a,n,r,s=!0){const o={identifier:null!=n?n:"empty",interval:null!=e?e:6e4,minAccuracy:null!=i?i:50,accuracyType:null!=l?l:"Best",priority:null!=a?a:"BALANCED",fallbackToSettings:s};null==t||t.natively.trigger(this.id,12,r,"location_start_bg",o)}statusBackground(e){null==t||t.natively.trigger(this.id,20,e,"location_status_bg",{})}stopBackground(e){null==t||t.natively.trigger(this.id,4,e,"location_stop_bg",{})}}class u{constructor(){this.id=a()}sendSMS(e,i,l){const a={body:null!=e?e:"",recipient:null!=i?i:""};null==t||t.natively.trigger(this.id,0,l,"send_sms",a)}sendEmail(e,i,l,a){const n={subject:null!=e?e:"",body:null!=i?i:"",recipient:null!=l?l:""};null==t||t.natively.trigger(this.id,0,a,"send_email",n)}}class v{constructor(){this.id=a()}setStorageValue(e,i){null==t||t.natively.trigger(this.id,0,void 0,"set_storage_value",{key:e,value:i})}getStorageValue(e,i){null==t||t.natively.trigger(this.id,0,i,"get_storage_value",{key:e})}removeStorageValue(e){null==t||t.natively.trigger(this.id,0,void 0,"remove_storage_value",{key:e})}resetStorage(){null==t||t.natively.trigger(this.id,0,void 0,"reset_storage")}}class c{constructor(e){this.id=a(),this.allowPass=e}checkBiometricsSupport(e){null==t||t.natively.trigger(this.id,0,e,"biometrics_support",{allowPass:this.allowPass})}checkCredentials(e){null==t||t.natively.trigger(this.id,0,e,"biometrics_has_credentials")}verifyUserIdentify(e){null==t||t.natively.trigger(this.id,0,e,"biometrics_verify",{allowPass:this.allowPass})}getUserCredentials(e){null==t||t.natively.trigger(this.id,0,e,"biometrics_auth",{allowPass:this.allowPass})}removeUserCredentials(e){null==t||t.natively.trigger(this.id,0,e,"biometrics_remove_credentials")}saveUserCredentials(e,i,l){null==t||t.natively.trigger(this.id,0,l,"biometrics_auth",{allowPass:this.allowPass,login:e,password:i})}}class y{constructor(){this.id=a()}showDatePicker(e,i,l,a,n){const r={type:null!=l?l:"DATE",style:null!=a?a:"LIGHT",title:null!=e?e:"",description:null!=i?i:""};null==t||t.natively.trigger(this.id,0,n,"datepicker",r)}}class h{constructor(){this.id=a()}showCamera(e,i,l,a){const n={type:null!=e?e:"photo",quality:null!=i?i:"high",camera:null!=l?l:"BACK"};null==t||t.natively.trigger(this.id,2,a,"open_camera",n)}}class p{constructor(){this.id=a()}available(e){null==t||t.natively.trigger(this.id,10,e,"health_available",{})}requestAuthorization(e,i,l){null==t||t.natively.trigger(this.id,10,l,"health_register",{write_data_types:e,read_data_types:i})}permissionStatus(e,i){null==t||t.natively.trigger(this.id,10,i,"health_permission",{data_type:e})}getAllCharacteristics(e){null==t||t.natively.trigger(this.id,10,e,"health_get_all_characteristics",{})}getStatisticQuantity(e,i,l,a,n){const r={data_type:e,interval:i};l&&(r.start_date=l.getTime()),a&&(r.end_date=a.getTime()),null==t||t.natively.trigger(this.id,10,n,"health_get_statistic_quantity",r)}getDailySleepAnalysis(e,i,l,a){const n={limit:l||100};e&&(n.start_date=e.getTime()),i&&(n.end_date=i.getTime()),null==t||t.natively.trigger(this.id,10,a,"health_get_daily_sleep_analysis",n)}getWorkouts(e,i,l,a){const n={limit:l||100};e&&(n.start_date=e.getTime()),i&&(n.end_date=i.getTime()),null==t||t.natively.trigger(this.id,21,a,"health_get_workouts",n)}getHealthConnectStatus(e){null==t||t.natively.trigger(this.id,40,e,"health_connect_status",{})}installHealthConnect(e){null==t||t.natively.trigger(this.id,40,e,"health_connect_install",{})}writeWorkout(e,i){const l=Object.assign({},e);(null==e?void 0:e.start_date)instanceof Date&&(l.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(l.end_date=e.end_date.getTime()),null==t||t.natively.trigger(this.id,39,i,"health_write_workout",l)}writeNutrition(e,i){const l=Object.assign({},e);(null==e?void 0:e.start_date)instanceof Date&&(l.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(l.end_date=e.end_date.getTime()),Array.isArray(null==e?void 0:e.items)&&(l.items=e.items.map((e=>{const i=Object.assign({},e);return(null==e?void 0:e.start_date)instanceof Date&&(i.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(i.end_date=e.end_date.getTime()),i}))),null==t||t.natively.trigger(this.id,39,i,"health_write_nutrition",l)}getActivitySummary(e,i,l){const a={};e&&(a.start_date=e.getTime()),i&&(a.end_date=i.getTime()),null==t||t.natively.trigger(this.id,10,l,"health_get_activity_summary",a)}}class _{constructor(){this.id=a()}showScanner(e){null==t||t.natively.trigger(this.id,2,e,"open_scanner",{})}showDocumentScanner(e,i,l,a,n,r,s,o,d,g,u,v,c){const y={};o&&(y.source=o),n&&(y.menuColor=n),g&&(y.pageMode=g),null==e||isNaN(e)||(y.jpegQuality=e),a&&(y.highlightColor=a),i&&(y.foregroundColor=i),l&&(y.backgroundColor=l),r&&(y.defaultFlashMode=r),s&&(y.defaultScanOrientation=s),u&&(y.defaultFilter=u),v&&(y.availableFilters=v),d&&(y.ocrConfiguration={languages:[d]}),null==t||t.natively.trigger(this.id,21,c,"open_document_scanner",y)}}class b{constructor(){this.id=a()}login(e,i,l){const a=null!=i?i:"";null==t||t.natively.trigger(this.id,3,l,"purchases_login",{login:e,email:a})}logout(e){null==t||t.natively.trigger(this.id,3,e,"purchases_logout",{})}customerId(e){null==t||t.natively.trigger(this.id,3,e,"purchases_customerid",{})}restore(e){null==t||t.natively.trigger(this.id,10,e,"purchases_restore",{})}showPaywall(e,i,l){const a={offeringId:i,shouldShowCloseButton:e};null==t||t.natively.trigger(this.id,38,l,"purchases_show_paywall",a)}showPaywallIfNeeded(e,i,l,a){const n={offeringName:l,entitlementId:e,shouldShowCloseButton:i};null==t||t.natively.trigger(this.id,38,a,"purchases_show_paywall_if_needed",n)}purchasePackage(e,i,l,a){null==t||t.natively.trigger(this.id,3,i,"purchases_package",{packageId:e,oldProductId:null!=l?l:null,prorationMode:null!=a?a:null})}packagePrice(e,i){null==t||t.natively.trigger(this.id,8,i,"purchases_price",{packageId:e})}showCustomerCenter(e){null==t||t.natively.trigger(this.id,42,e,"purchases_show_customer_center",{})}getOfferings(e){null==t||t.natively.trigger(this.id,44,e,"purchases_get_offerings",{})}}class m{constructor(){this.id=a()}getAllContacts(e){null==t||t.natively.trigger(this.id,3,e,"contacts_all",{})}createContact(e,i,l,a,n){const r={firstName:e,lastName:null!=i?i:"",email:null!=l?l:"",phone:null!=a?a:""};null==t||t.natively.trigger(this.id,3,n,"contacts_save",r)}}class f{constructor(){this.id=a()}showMediaPicker(e){null==t||t.natively.trigger(this.id,8,e,"mediapicker",{})}}class w{constructor(){this.id=a()}showRecorder(e,i){const l={max_duration:null!=e?e:0};null==t||t.natively.trigger(this.id,13,i,"record_start",l)}}class N{constructor(){this.id=a()}buildMetadata(e){const i={};return e?(void 0!==e.id&&(i.id=e.id),void 0!==e.title&&(i.title=e.title),void 0!==e.artist&&(i.artist=e.artist),void 0!==e.album&&(i.album=e.album),void 0!==e.genre&&(i.genre=e.genre),void 0!==e.artwork&&(i.artwork=e.artwork),null!=e.duration&&(i.duration=e.duration),void 0!==e.extras&&(i.extras=e.extras),i):i}play(e,i,l){var a,n;const r=Object.assign({source:e,is_stream:null!==(a=null==i?void 0:i.is_stream)&&void 0!==a&&a,autoplay:null===(n=null==i?void 0:i.autoplay)||void 0===n||n},this.buildMetadata(i));void 0!==(null==i?void 0:i.headers)&&(r.headers=i.headers),null!=(null==i?void 0:i.start_position)&&(r.start_position=i.start_position),null!=(null==i?void 0:i.volume)&&(r.volume=i.volume),null!=(null==i?void 0:i.speed)&&(r.speed=i.speed),null==t||t.natively.trigger(this.id,39,l,"audio_play",r)}pause(e){null==t||t.natively.trigger(this.id,39,e,"audio_pause",{})}stop(e){null==t||t.natively.trigger(this.id,39,e,"audio_stop",{})}seek(e,i){null==t||t.natively.trigger(this.id,39,i,"audio_seek",{position:e})}queueAdd(e,i,l){var a,n;const r=Object.assign({source:e,play_now:null!==(a=null==i?void 0:i.play_now)&&void 0!==a&&a,is_stream:null!==(n=null==i?void 0:i.is_stream)&&void 0!==n&&n},this.buildMetadata(i));void 0!==(null==i?void 0:i.headers)&&(r.headers=i.headers),null==t||t.natively.trigger(this.id,39,l,"audio_queue_add",r)}queueGet(e){null==t||t.natively.trigger(this.id,39,e,"audio_queue_get",{})}queueRemove(e,i){null==t||t.natively.trigger(this.id,39,i,"audio_queue_remove",{index:e})}setMetadata(e,i){const l=this.buildMetadata(e);null==t||t.natively.trigger(this.id,39,i,"audio_set_metadata",l)}setVolume(e,i){null==t||t.natively.trigger(this.id,39,i,"audio_set_volume",{volume:e})}setSpeed(e,i){null==t||t.natively.trigger(this.id,39,i,"audio_set_speed",{speed:e})}}class A{constructor(e,i,l=!1,n,r=!1,s){var o,d,g,u,v,c;this.id=a();const y={};(null==t?void 0:t.natively.isAndroidApp)?y.unitId=null!==(o=e.androidUnitId)&&void 0!==o?o:"ca-app-pub-3940256099942544/6300978111":(null==t?void 0:t.natively.isIOSApp)&&(y.unitId=null!==(d=e.iOSUnitId)&&void 0!==d?d:"ca-app-pub-3940256099942544/2934735716"),y.position=null!==(g=e.position)&&void 0!==g?g:"BOTTOM",y.sizeType=null!==(u=e.sizeType)&&void 0!==u?u:"AUTO",y.width=null!==(v=e.custom_width)&&void 0!==v?v:320,y.height=null!==(c=e.custom_height)&&void 0!==c?c:50,null==t||t.natively.trigger(this.id,14,(e=>{null==i||i(e),l&&(null==t||t.natively.trigger(this.id,14,(e=>{null==n||n(e),r&&(null==t||t.natively.trigger(this.id,14,s,"bannerad_show",{}))}),"bannerad_load",{}))}),"bannerad_setup",y)}loadAd(e){null==t||t.natively.trigger(this.id,14,e,"bannerad_load",{})}showBanner(e){null==t||t.natively.trigger(this.id,14,e,"bannerad_show",{})}hideBanner(e){null==t||t.natively.trigger(this.id,14,e,"bannerad_hide",{})}bannerIsReady(e){null==t||t.natively.trigger(this.id,14,e,"bannerad_ready",{})}bannerIsVisible(e){null==t||t.natively.trigger(this.id,14,e,"bannerad_visible",{})}}class S{constructor(e="ca-app-pub-3940256099942544/4411468910",i="ca-app-pub-3940256099942544/1033173712",l,n=!1,r){this.id=a(),(null==t?void 0:t.natively.isAndroidApp)?this.unitId=i:(null==t?void 0:t.natively.isIOSApp)&&(this.unitId=e),this.auto_ad_reload=n,this.auto_ad_reload_callback=r,this.loadAd(l)}loadAd(e){var i;const l={unitId:null!==(i=this.unitId)&&void 0!==i?i:"ca-app-pub-3940256099942544/4411468910"};null==t||t.natively.trigger(this.id,14,e,"interstitialad_setup",l)}showInterstitialAd(e){null==t||t.natively.trigger(this.id,14,(i=>{e(i),"DID_DISMISS_AD"===i.event&&this.auto_ad_reload&&setTimeout((()=>{this.loadAd(this.auto_ad_reload_callback)}),500)}),"interstitialad_show",{})}interstitialIsReady(e){null==t||t.natively.trigger(this.id,14,e,"interstitialad_ready",{})}}class k{constructor(e,i,t,l){this.id=a(),this.readAlertMessage=e,this.writeAlertMessage=i,this.readDetectedMessage=t,this.writeDetectedMessage=l}read(e){var i,l;const a={alertMessage:null!==(i=this.readAlertMessage)&&void 0!==i?i:"please set readAlertMessage",detectedMessage:null!==(l=this.readDetectedMessage)&&void 0!==l?l:"readDetectedMessage"};null==t||t.natively.trigger(this.id,15,e,"nfc_read",a)}write(e,i,l,a){var n,r;const s={alertMessage:null!==(n=this.writeAlertMessage)&&void 0!==n?n:"please set writeAlertMessage",detectedMessage:null!==(r=this.writeDetectedMessage)&&void 0!==r?r:"please set writeDetectedMessage",recordData:null!=i?i:"please set recordData",recordId:null!=e?e:"please set recordId",recordDataType:null!=l?l:"please set recordDataType"};null==t||t.natively.trigger(this.id,15,a,"nfc_write",s)}available(e){null==t||t.natively.trigger(this.id,15,e,"nfc_available",{})}}class I{constructor(){this.id=a()}firebase_get_token(e){null==t||t.natively.trigger(this.id,31,e,"firebase_get_token")}firebase_get_apns_token(e){null==t||t.natively.trigger(this.id,31,e,"firebase_get_apns_token")}firebase_request_permission(e){null==t||t.natively.trigger(this.id,31,e,"firebase_request_permission")}firebase_has_permission(e){null==t||t.natively.trigger(this.id,31,e,"firebase_has_permission")}firebase_subscribe_to_topic(e,i){null==t||t.natively.trigger(this.id,31,i,"firebase_subscribe_to_topic",{topic:e})}firebase_unsubscribe_from_topic(e,i){null==t||t.natively.trigger(this.id,31,i,"firebase_unsubscribe_from_topic",{topic:e})}}class T{constructor(){this.id=a()}setProfile(e,i){null==t||t.natively.trigger(this.id,32,i,"klaviyo_set_profile",e)}getExternalId(e){null==t||t.natively.trigger(this.id,32,e,"klaviyo_external_id")}resetProfile(e){null==t||t.natively.trigger(this.id,32,e,"klaviyo_reset_profile")}registerToken(e,i){null==t||t.natively.trigger(this.id,32,e,"klaviyo_register_token",{token:i})}pushPermission(e){null==t||t.natively.trigger(this.id,32,e,"klaviyo_push_permission")}pushRegister(e){null==t||t.natively.trigger(this.id,32,e,"klaviyo_push_register")}}class D{constructor(){this.id=a()}createCalendarEvent(e,i,l,a,n,r,s){const o={title:e,timezone:a,calendarId:n,description:r,endDate:null==i?void 0:i.toISOString(),startDate:l.toISOString()};null==t||t.natively.trigger(void 0,37,s,"calendar_event",o)}retrieveCalendars(e){null==t||t.natively.trigger(void 0,37,e,"retrieve_calendars",{})}}const P=()=>null==t?void 0:t.natively;t&&(t.natively=new l,t.NativelyAdmobBanner=A,t.NativelyAdmobInterstitial=S,t.NativelyAppleSignInService=n,t.NativelyAudioRecorder=w,t.NativelyAudioPlayer=N,t.NativelyBiometrics=c,t.NativelyCamera=h,t.NativelyClipboard=r,t.NativelyContacts=m,t.NativelyDatePicker=y,t.NativelyGeolocation=d,t.NativelyHealth=p,t.NativelyInfo=s,t.NativelyLocation=g,t.NativelyMediaPicker=f,t.NativelyMessage=u,t.NativelyNFCService=k,t.NativelyNotifications=o,t.NativelyPurchases=b,t.NativelyScanner=_,t.NativelyStorage=v,t.NativelyCalendar=D,t.NativelyFirebaseNotifications=I,t.NativelyKlaviyoNotifications=T),null==t||t.natively.addObserver((()=>null==t?void 0:t.natively.trigger(void 0,0,(e=>{t&&(t.natively.min_app_version=e.minSDKVersion,t.natively.app_version=e.sdkVersion)}),"app_info",{})))})();
1
+ (()=>{"use strict";var e={d:(t,i)=>{for(var l in i)e.o(i,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:i[l]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{Natively:()=>l,NativelyAdmobBanner:()=>A,NativelyAdmobInterstitial:()=>S,NativelyAppleSignInService:()=>n,NativelyAudioPlayer:()=>N,NativelyAudioRecorder:()=>w,NativelyBiometrics:()=>c,NativelyCalendar:()=>D,NativelyCamera:()=>p,NativelyClipboard:()=>r,NativelyContacts:()=>m,NativelyDatePicker:()=>y,NativelyFirebaseNotifications:()=>I,NativelyGeolocation:()=>d,NativelyHealth:()=>h,NativelyInfo:()=>s,NativelyKlaviyoNotifications:()=>T,NativelyLocation:()=>g,NativelyMediaPicker:()=>f,NativelyMessage:()=>u,NativelyNFCService:()=>k,NativelyNotifications:()=>o,NativelyPurchases:()=>b,NativelyScanner:()=>_,NativelyStorage:()=>v,generateID:()=>a,useNatively:()=>P});const i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e.g?e.g:null;class l{constructor(){var e,t,l,a;this.isDebug=!1,this.min_app_version=0,this.app_version=0,this.injected=!1,this.observers=[],this.onNativeError=null,this.onTabChanged=null,this.isIOSApp=(null===(t=null===(e=null==i?void 0:i.navigator)||void 0===e?void 0:e.userAgent)||void 0===t?void 0:t.includes("Natively/iOS"))||!1,this.isAndroidApp=(null===(a=null===(l=null==i?void 0:i.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}setDebug(e){i&&(i.natively.isDebug=e)}notify(e,t){i&&(i.natively.injected=!0,e&&(i.natively.min_app_version=e),t&&(i.natively.app_version=t));const l=null==i?void 0:i.natively.observers;for((null==i?void 0:i.natively.isDebug)&&console.log("[INFO] Notify observers: ",l.length);l.length>0;){const e=l.shift();null==e||e()}}addObserver(e){(null==i?void 0:i.natively.injected)?e():((null==i?void 0:i.natively.isDebug)&&console.log(`[DEBUG] addObserver: ${e}`),null==i||i.natively.observers.push(e))}trigger(e,t,l,a,n){const r=null==i?void 0:i.natively.isDebug;if(null==i?void 0:i.natively.injected)if(t>(null==i?void 0:i.natively.app_version))r&&alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${null==i?void 0:i.natively.app_version}, feature version: ${t}`);else{if(l){let t;t=e?a+"_response_"+e:a+"_response",i&&(i[t]=function(a,n){null==i||i.$agent.response(),n.message&&r?alert(`[ERROR] Error message: ${n.message}`):(r&&console.log(`[DEBUG] Callback method: ${t}, body: ${JSON.stringify(a)}, respId: ${e}`),l(a))}),n?n.response_id=e:n={response_id:e}}r&&console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(n)}`),null==i||i.$agent.trigger(a,n)}else null==i||i.natively.addObserver((()=>{null==i||i.natively.trigger(e,t,l,a,n)}))}setTabChangedHandler(e){"function"==typeof e?this.onTabChanged=e:console.warn("[Natively] Tab changed handler must be a function")}removeTabChangedHandler(){this.onTabChanged=null}setErrorHandler(e){"function"==typeof e&&(this.onNativeError=e)}removeErrorHandler(){this.onNativeError=null}setErrorScreen(e){null==i||i.natively.trigger(void 0,0,void 0,"error_screen",{show_error:e})}openLogger(){null==i||i.$agent.natively_logger()}openConsole(){null==i||i.natively.trigger(void 0,22,void 0,"app_console")}closeApp(){null==i||i.natively.trigger(void 0,11,void 0,"app_close")}showProgress(e){null==i||i.natively.trigger(void 0,11,void 0,"app_show_progress",{toggle:e})}shareImage(e){null==i||i.natively.trigger(void 0,0,void 0,"share_image",{url:e})}shareText(e){null==i||i.natively.trigger(void 0,0,void 0,"share_text",{text:e})}shareTextAndImage(e,t){null==i||i.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:t,text:e})}shareFile(e){null==i||i.natively.trigger(void 0,2,void 0,"share_file",{url:e})}openExternalURL(e,t){const l={url:void 0===e?"https://buildnatively.com":e,view:void 0!==t&&t?"external":"web"};null==i||i.natively.trigger(void 0,18,void 0,"open_link",l)}openExternalApp(e){null==i||i.natively.trigger(void 0,22,void 0,"open_app",{url:e})}showAppToast(e,t){null==i||i.natively.trigger(void 0,0,void 0,"show_toast",{text:t||"",type:e||"DEFAULT"})}showAppBanner(e,t,l){null==i||i.natively.trigger(void 0,0,void 0,"show_banner",{type:e||"INFO",title:t||"",description:l||""})}analyticsTrackEvent(e,t){const l={name:e};t&&(l.data=t),null==i||i.natively.trigger(void 0,37,void 0,"analytics_log_event",l)}analyticsSetUserId(e){const t={id:e.id};null==i||i.natively.trigger(void 0,37,void 0,"analytics_set_user_id",t)}analyticsSetUserProperty(e){const t={key:e.key,value:e.value};null==i||i.natively.trigger(void 0,37,void 0,"analytics_set_user_property",t)}requestAppReview(){null==i||i.natively.trigger(void 0,0,void 0,"request_review")}attShowPopup(e){null==i||i.natively.trigger(void 0,41,e,"att_show_popup")}attGetStatus(e){null==i||i.natively.trigger(void 0,41,e,"att_get_status")}getInsets(e){null==i||i.natively.trigger(void 0,36,e,"get_insets")}getLocales(e){null==i||i.natively.trigger(void 0,40,e,"get_locales")}setLocale(e,t){null==i||i.natively.trigger(void 0,40,t,"set_locale",{locale:e})}setAppBackgroundColor(e){null==i||i.natively.trigger(void 0,1,void 0,"app_background",{color:e})}setAppProgressColor(e){null==i||i.natively.trigger(void 0,1,void 0,"app_progress",{color:e})}setAppSwipeNavigation(e){null==i||i.natively.trigger(void 0,22,void 0,"app_navigation",{toggle:e})}setAppPullToRefresh(e){null==i||i.natively.trigger(void 0,1,void 0,"app_pull",{toggle:e})}setAppOrientation(e){null==i||i.natively.trigger(void 0,3,void 0,"app_orientation",{orientation:e})}setAppStatusBarStyle(e){null==i||i.natively.trigger(void 0,22,void 0,"status_bar_style",{style:e})}hideLoadingScreen(){null==i||i.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!1,auto_hide:!0})}showLoadingScreen(e){null==i||i.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!0,auto_hide:e||!1})}openAppSettings(){null==i||i.natively.trigger(void 0,0,void 0,"open_appsettings")}showTabBar(){null==i||i.natively.trigger(void 0,33,void 0,"show_tab_bar")}enableWakelock(){null==i||i.natively.trigger(void 0,34,void 0,"wakelock_enable")}disableWakelock(){null==i||i.natively.trigger(void 0,34,void 0,"wakelock_disable")}hideTabBar(){null==i||i.natively.trigger(void 0,33,void 0,"hide_tab_bar")}reloadWebview(){null==i||i.natively.trigger(void 0,35,void 0,"reset_webview")}getBatteryInfo(e){null==i||i.natively.trigger(void 0,43,e,"battery_info")}hapticPattern(e,t){null==i||i.natively.trigger(void 0,22,void 0,"haptic_pattern",{pattern:e,delay:t})}openPDF(e,t){const l={url:e.url||"",base64:e.base64||"",fileName:e.fileName||`pdf-${(new Date).getTime()}.pdf`,download:!0===e.download};null==i||i.natively.trigger(void 0,38,t,"open_pdf",l)}hapticImpact(e){null==i||i.natively.trigger(void 0,22,void 0,"haptic_impact",{type:e})}hapticNotification(e){null==i||i.natively.trigger(void 0,22,void 0,"haptic_notification",{type:e})}}const a=()=>Date.now().toString(36)+Math.random().toString(36).substring(2);class n{constructor(){this.id=a()}signin(e){null==i||i.natively.trigger(this.id,16,e,"apple_signin",{})}}class r{constructor(){this.id=a()}copy(e){null==i||i.natively.trigger(void 0,11,void 0,"clipboard_copy",{text:e})}paste(e){null==i||i.natively.trigger(this.id,11,e,"clipboard_paste")}}class s{constructor(){this.id=a()}browserInfo(){var e,t,l,a;return{isNativeApp:void 0!==(null==i?void 0:i.$agent),isIOSApp:(null===(t=null===(e=null==i?void 0:i.navigator)||void 0===e?void 0:e.userAgent)||void 0===t?void 0:t.includes("Natively/iOS"))||!1,isAndroidApp:(null===(a=null===(l=null==i?void 0:i.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}}getAppInfo(e){(null==i?void 0:i.natively)&&(null==i||i.natively.trigger(this.id,0,e,"app_info"))}connectivity(e){(null==i?void 0:i.natively)&&(null==i||i.natively.trigger(void 0,0,e,"connectivity"))}app_state(e){(null==i?void 0:i.natively)&&(null==i||i.natively.trigger(void 0,19,e,"app_state"))}keyboard_visibility(e){(null==i?void 0:i.natively)&&(null==i||i.natively.trigger(void 0,34,e,"keyboard_visibility"))}}class o{constructor(){this.id=a()}getOneSignalId(e){null==i||i.natively.trigger(this.id,0,e,"onesignal_playerid")}requestPermission(e,t){null==i||i.natively.trigger(this.id,0,t,"push_register",{fallbackToSettings:e})}getPermissionStatus(e){null==i||i.natively.trigger(this.id,0,e,"push_permission")}getExternalId(e){null==i||i.natively.trigger(this.id,0,e,"onesignal_externalid")}setExternalId(e,t){null==i||i.natively.trigger(this.id,0,t,"onesignal_setexternalid",e)}removeExternalId(e){null==i||i.natively.trigger(this.id,0,e,"onesignal_removeexternalid")}}class d{constructor(){this.id=a()}getUserGeolocation(e,t){null==i||i.natively.trigger(this.id,0,t,"geolocation",{distance:e})}requestPermission(e){null==i||i.natively.trigger(this.id,0,e,"geo_register")}getPermissionStatus(e){null==i||i.natively.trigger(this.id,0,e,"geo_permission")}}class g{constructor(){this.id=a()}current(e,t,l,a,n=!0){null==i||i.natively.trigger(this.id,12,a,"location_current",{minAccuracy:e,accuracyType:t,priority:l,fallbackToSettings:n})}permission(e){null==i||i.natively.trigger(this.id,6,e,"location_permission")}start(e,t,l,a,n,r=!0){null==i||i.natively.trigger(this.id,12,n,"location_start",{minAccuracy:t,accuracyType:l,priority:a,fallbackToSettings:r,interval:e})}stop(){null==i||i.natively.trigger(this.id,3,void 0,"location_stop",{})}startBackground(e,t,l,a,n,r,s=!0){const o={identifier:null!=n?n:"empty",interval:null!=e?e:6e4,minAccuracy:null!=t?t:50,accuracyType:null!=l?l:"Best",priority:null!=a?a:"BALANCED",fallbackToSettings:s};null==i||i.natively.trigger(this.id,12,r,"location_start_bg",o)}statusBackground(e){null==i||i.natively.trigger(this.id,20,e,"location_status_bg",{})}stopBackground(e){null==i||i.natively.trigger(this.id,4,e,"location_stop_bg",{})}}class u{constructor(){this.id=a()}sendSMS(e,t,l){const a={body:null!=e?e:"",recipient:null!=t?t:""};null==i||i.natively.trigger(this.id,0,l,"send_sms",a)}sendEmail(e,t,l,a){const n={subject:null!=e?e:"",body:null!=t?t:"",recipient:null!=l?l:""};null==i||i.natively.trigger(this.id,0,a,"send_email",n)}}class v{constructor(){this.id=a()}setStorageValue(e,t){null==i||i.natively.trigger(this.id,0,void 0,"set_storage_value",{key:e,value:t})}getStorageValue(e,t){null==i||i.natively.trigger(this.id,0,t,"get_storage_value",{key:e})}removeStorageValue(e){null==i||i.natively.trigger(this.id,0,void 0,"remove_storage_value",{key:e})}resetStorage(){null==i||i.natively.trigger(this.id,0,void 0,"reset_storage")}}class c{constructor(e){this.id=a(),this.allowPass=e}checkBiometricsSupport(e){null==i||i.natively.trigger(this.id,0,e,"biometrics_support",{allowPass:this.allowPass})}checkCredentials(e){null==i||i.natively.trigger(this.id,0,e,"biometrics_has_credentials")}verifyUserIdentify(e){null==i||i.natively.trigger(this.id,0,e,"biometrics_verify",{allowPass:this.allowPass})}getUserCredentials(e){null==i||i.natively.trigger(this.id,0,e,"biometrics_auth",{allowPass:this.allowPass})}removeUserCredentials(e){null==i||i.natively.trigger(this.id,0,e,"biometrics_remove_credentials")}saveUserCredentials(e,t,l){null==i||i.natively.trigger(this.id,0,l,"biometrics_auth",{allowPass:this.allowPass,login:e,password:t})}}class y{constructor(){this.id=a()}showDatePicker(e,t,l,a,n){const r={type:null!=l?l:"DATE",style:null!=a?a:"LIGHT",title:null!=e?e:"",description:null!=t?t:""};null==i||i.natively.trigger(this.id,0,n,"datepicker",r)}}class p{constructor(){this.id=a()}showCamera(e,t,l,a){const n={type:null!=e?e:"photo",quality:null!=t?t:"high",camera:null!=l?l:"BACK"};null==i||i.natively.trigger(this.id,2,a,"open_camera",n)}}class h{constructor(){this.id=a()}available(e){null==i||i.natively.trigger(this.id,10,e,"health_available",{})}requestAuthorization(e,t,l){null==i||i.natively.trigger(this.id,10,l,"health_register",{write_data_types:e,read_data_types:t})}permissionStatus(e,t){null==i||i.natively.trigger(this.id,10,t,"health_permission",{data_type:e})}getAllCharacteristics(e){null==i||i.natively.trigger(this.id,10,e,"health_get_all_characteristics",{})}getStatisticQuantity(e,t,l,a,n){const r={data_type:e,interval:t};l&&(r.start_date=l.getTime()),a&&(r.end_date=a.getTime()),null==i||i.natively.trigger(this.id,10,n,"health_get_statistic_quantity",r)}getDailySleepAnalysis(e,t,l,a){const n={limit:l||100};e&&(n.start_date=e.getTime()),t&&(n.end_date=t.getTime()),null==i||i.natively.trigger(this.id,10,a,"health_get_daily_sleep_analysis",n)}getWorkouts(e,t,l,a){const n={limit:l||100};e&&(n.start_date=e.getTime()),t&&(n.end_date=t.getTime()),null==i||i.natively.trigger(this.id,21,a,"health_get_workouts",n)}getHealthConnectStatus(e){null==i||i.natively.trigger(this.id,40,e,"health_connect_status",{})}installHealthConnect(e){null==i||i.natively.trigger(this.id,40,e,"health_connect_install",{})}writeWorkout(e,t){const l=Object.assign({},e);(null==e?void 0:e.start_date)instanceof Date&&(l.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(l.end_date=e.end_date.getTime()),null==i||i.natively.trigger(this.id,39,t,"health_write_workout",l)}writeNutrition(e,t){const l=Object.assign({},e);(null==e?void 0:e.start_date)instanceof Date&&(l.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(l.end_date=e.end_date.getTime()),Array.isArray(null==e?void 0:e.items)&&(l.items=e.items.map((e=>{const t=Object.assign({},e);return(null==e?void 0:e.start_date)instanceof Date&&(t.start_date=e.start_date.getTime()),(null==e?void 0:e.end_date)instanceof Date&&(t.end_date=e.end_date.getTime()),t}))),null==i||i.natively.trigger(this.id,39,t,"health_write_nutrition",l)}getActivitySummary(e,t,l){const a={};e&&(a.start_date=e.getTime()),t&&(a.end_date=t.getTime()),null==i||i.natively.trigger(this.id,10,l,"health_get_activity_summary",a)}}class _{constructor(){this.id=a()}showScanner(e){null==i||i.natively.trigger(this.id,2,e,"open_scanner",{})}showDocumentScanner(e,t,l,a,n,r,s,o,d,g,u,v,c){const y={};o&&(y.source=o),n&&(y.menuColor=n),g&&(y.pageMode=g),null==e||isNaN(e)||(y.jpegQuality=e),a&&(y.highlightColor=a),t&&(y.foregroundColor=t),l&&(y.backgroundColor=l),r&&(y.defaultFlashMode=r),s&&(y.defaultScanOrientation=s),u&&(y.defaultFilter=u),v&&(y.availableFilters=v),d&&(y.ocrConfiguration={languages:[d]}),null==i||i.natively.trigger(this.id,21,c,"open_document_scanner",y)}}class b{constructor(){this.id=a()}login(e,t,l){const a=null!=t?t:"";null==i||i.natively.trigger(this.id,3,l,"purchases_login",{login:e,email:a})}logout(e){null==i||i.natively.trigger(this.id,3,e,"purchases_logout",{})}customerId(e){null==i||i.natively.trigger(this.id,3,e,"purchases_customerid",{})}restore(e){null==i||i.natively.trigger(this.id,10,e,"purchases_restore",{})}showPaywall(e,t,l){const a={offeringId:t,shouldShowCloseButton:e};null==i||i.natively.trigger(this.id,38,l,"purchases_show_paywall",a)}showPaywallIfNeeded(e,t,l,a){const n={offeringName:l,entitlementId:e,shouldShowCloseButton:t};null==i||i.natively.trigger(this.id,38,a,"purchases_show_paywall_if_needed",n)}purchasePackage(e,t,l,a){null==i||i.natively.trigger(this.id,3,t,"purchases_package",{packageId:e,oldProductId:null!=l?l:null,prorationMode:null!=a?a:null})}packagePrice(e,t){null==i||i.natively.trigger(this.id,8,t,"purchases_price",{packageId:e})}showCustomerCenter(e){null==i||i.natively.trigger(this.id,42,e,"purchases_show_customer_center",{})}}class m{constructor(){this.id=a()}getAllContacts(e){null==i||i.natively.trigger(this.id,3,e,"contacts_all",{})}createContact(e,t,l,a,n){const r={firstName:e,lastName:null!=t?t:"",email:null!=l?l:"",phone:null!=a?a:""};null==i||i.natively.trigger(this.id,3,n,"contacts_save",r)}}class f{constructor(){this.id=a()}showMediaPicker(e){null==i||i.natively.trigger(this.id,8,e,"mediapicker",{})}}class w{constructor(){this.id=a()}showRecorder(e,t){const l={max_duration:null!=e?e:0};null==i||i.natively.trigger(this.id,13,t,"record_start",l)}}class N{constructor(){this.id=a()}buildMetadata(e){const t={};return e?(void 0!==e.id&&(t.id=e.id),void 0!==e.title&&(t.title=e.title),void 0!==e.artist&&(t.artist=e.artist),void 0!==e.album&&(t.album=e.album),void 0!==e.genre&&(t.genre=e.genre),void 0!==e.artwork&&(t.artwork=e.artwork),null!=e.duration&&(t.duration=e.duration),void 0!==e.extras&&(t.extras=e.extras),t):t}play(e,t,l){var a,n;const r=Object.assign({source:e,is_stream:null!==(a=null==t?void 0:t.is_stream)&&void 0!==a&&a,autoplay:null===(n=null==t?void 0:t.autoplay)||void 0===n||n},this.buildMetadata(t));void 0!==(null==t?void 0:t.headers)&&(r.headers=t.headers),null!=(null==t?void 0:t.start_position)&&(r.start_position=t.start_position),null!=(null==t?void 0:t.volume)&&(r.volume=t.volume),null!=(null==t?void 0:t.speed)&&(r.speed=t.speed),null==i||i.natively.trigger(this.id,39,l,"audio_play",r)}pause(e){null==i||i.natively.trigger(this.id,39,e,"audio_pause",{})}stop(e){null==i||i.natively.trigger(this.id,39,e,"audio_stop",{})}seek(e,t){null==i||i.natively.trigger(this.id,39,t,"audio_seek",{position:e})}queueAdd(e,t,l){var a,n;const r=Object.assign({source:e,play_now:null!==(a=null==t?void 0:t.play_now)&&void 0!==a&&a,is_stream:null!==(n=null==t?void 0:t.is_stream)&&void 0!==n&&n},this.buildMetadata(t));void 0!==(null==t?void 0:t.headers)&&(r.headers=t.headers),null==i||i.natively.trigger(this.id,39,l,"audio_queue_add",r)}queueGet(e){null==i||i.natively.trigger(this.id,39,e,"audio_queue_get",{})}queueRemove(e,t){null==i||i.natively.trigger(this.id,39,t,"audio_queue_remove",{index:e})}setMetadata(e,t){const l=this.buildMetadata(e);null==i||i.natively.trigger(this.id,39,t,"audio_set_metadata",l)}setVolume(e,t){null==i||i.natively.trigger(this.id,39,t,"audio_set_volume",{volume:e})}setSpeed(e,t){null==i||i.natively.trigger(this.id,39,t,"audio_set_speed",{speed:e})}}class A{constructor(e,t,l=!1,n,r=!1,s){var o,d,g,u,v,c;this.id=a();const y={};(null==i?void 0:i.natively.isAndroidApp)?y.unitId=null!==(o=e.androidUnitId)&&void 0!==o?o:"ca-app-pub-3940256099942544/6300978111":(null==i?void 0:i.natively.isIOSApp)&&(y.unitId=null!==(d=e.iOSUnitId)&&void 0!==d?d:"ca-app-pub-3940256099942544/2934735716"),y.position=null!==(g=e.position)&&void 0!==g?g:"BOTTOM",y.sizeType=null!==(u=e.sizeType)&&void 0!==u?u:"AUTO",y.width=null!==(v=e.custom_width)&&void 0!==v?v:320,y.height=null!==(c=e.custom_height)&&void 0!==c?c:50,null==i||i.natively.trigger(this.id,14,(e=>{null==t||t(e),l&&(null==i||i.natively.trigger(this.id,14,(e=>{null==n||n(e),r&&(null==i||i.natively.trigger(this.id,14,s,"bannerad_show",{}))}),"bannerad_load",{}))}),"bannerad_setup",y)}loadAd(e){null==i||i.natively.trigger(this.id,14,e,"bannerad_load",{})}showBanner(e){null==i||i.natively.trigger(this.id,14,e,"bannerad_show",{})}hideBanner(e){null==i||i.natively.trigger(this.id,14,e,"bannerad_hide",{})}bannerIsReady(e){null==i||i.natively.trigger(this.id,14,e,"bannerad_ready",{})}bannerIsVisible(e){null==i||i.natively.trigger(this.id,14,e,"bannerad_visible",{})}}class S{constructor(e="ca-app-pub-3940256099942544/4411468910",t="ca-app-pub-3940256099942544/1033173712",l,n=!1,r){this.id=a(),(null==i?void 0:i.natively.isAndroidApp)?this.unitId=t:(null==i?void 0:i.natively.isIOSApp)&&(this.unitId=e),this.auto_ad_reload=n,this.auto_ad_reload_callback=r,this.loadAd(l)}loadAd(e){var t;const l={unitId:null!==(t=this.unitId)&&void 0!==t?t:"ca-app-pub-3940256099942544/4411468910"};null==i||i.natively.trigger(this.id,14,e,"interstitialad_setup",l)}showInterstitialAd(e){null==i||i.natively.trigger(this.id,14,(t=>{e(t),"DID_DISMISS_AD"===t.event&&this.auto_ad_reload&&setTimeout((()=>{this.loadAd(this.auto_ad_reload_callback)}),500)}),"interstitialad_show",{})}interstitialIsReady(e){null==i||i.natively.trigger(this.id,14,e,"interstitialad_ready",{})}}class k{constructor(e,t,i,l){this.id=a(),this.readAlertMessage=e,this.writeAlertMessage=t,this.readDetectedMessage=i,this.writeDetectedMessage=l}read(e){var t,l;const a={alertMessage:null!==(t=this.readAlertMessage)&&void 0!==t?t:"please set readAlertMessage",detectedMessage:null!==(l=this.readDetectedMessage)&&void 0!==l?l:"readDetectedMessage"};null==i||i.natively.trigger(this.id,15,e,"nfc_read",a)}write(e,t,l,a){var n,r;const s={alertMessage:null!==(n=this.writeAlertMessage)&&void 0!==n?n:"please set writeAlertMessage",detectedMessage:null!==(r=this.writeDetectedMessage)&&void 0!==r?r:"please set writeDetectedMessage",recordData:null!=t?t:"please set recordData",recordId:null!=e?e:"please set recordId",recordDataType:null!=l?l:"please set recordDataType"};null==i||i.natively.trigger(this.id,15,a,"nfc_write",s)}available(e){null==i||i.natively.trigger(this.id,15,e,"nfc_available",{})}}class I{constructor(){this.id=a()}firebase_get_token(e){null==i||i.natively.trigger(this.id,31,e,"firebase_get_token")}firebase_get_apns_token(e){null==i||i.natively.trigger(this.id,31,e,"firebase_get_apns_token")}firebase_request_permission(e){null==i||i.natively.trigger(this.id,31,e,"firebase_request_permission")}firebase_has_permission(e){null==i||i.natively.trigger(this.id,31,e,"firebase_has_permission")}firebase_subscribe_to_topic(e,t){null==i||i.natively.trigger(this.id,31,t,"firebase_subscribe_to_topic",{topic:e})}firebase_unsubscribe_from_topic(e,t){null==i||i.natively.trigger(this.id,31,t,"firebase_unsubscribe_from_topic",{topic:e})}}class T{constructor(){this.id=a()}setProfile(e,t){null==i||i.natively.trigger(this.id,32,t,"klaviyo_set_profile",e)}getExternalId(e){null==i||i.natively.trigger(this.id,32,e,"klaviyo_external_id")}resetProfile(e){null==i||i.natively.trigger(this.id,32,e,"klaviyo_reset_profile")}registerToken(e,t){null==i||i.natively.trigger(this.id,32,e,"klaviyo_register_token",{token:t})}pushPermission(e){null==i||i.natively.trigger(this.id,32,e,"klaviyo_push_permission")}pushRegister(e){null==i||i.natively.trigger(this.id,32,e,"klaviyo_push_register")}}class D{constructor(){this.id=a()}createCalendarEvent(e,t,l,a,n,r,s){const o={title:e,timezone:a,calendarId:n,description:r,endDate:null==t?void 0:t.toISOString(),startDate:l.toISOString()};null==i||i.natively.trigger(void 0,37,s,"calendar_event",o)}retrieveCalendars(e){null==i||i.natively.trigger(void 0,37,e,"retrieve_calendars",{})}}const P=()=>null==i?void 0:i.natively;if(i){const e=(e=>{var t,i;if("function"==typeof(null===(t=e.$agent)||void 0===t?void 0:t.trigger))return!0;const l=(e=>{try{return e.self!==e.top}catch(e){return!0}})(e),a="function"==typeof(null===(i=e.flutter_inappwebview)||void 0===i?void 0:i.callHandler);if(!l&&!a)return!1;const n={__nativelyAgent:!0,trigger(t,i){var a,n;const r=JSON.stringify({trigger:{name:t,data:i}});"function"!=typeof(null===(a=e.flutter_inappwebview)||void 0===a?void 0:a.callHandler)?l&&"function"==typeof(null===(n=e.parent)||void 0===n?void 0:n.postMessage)&&e.parent.postMessage({source:"natively-webview",handlerName:"💙",args:[r]},"*"):e.flutter_inappwebview.callHandler("💙",r)},response(){},natively_logger(){this.trigger("natively_logger")}};return e.$agent=n,e.natively=e.natively||n,l&&"function"==typeof e.addEventListener&&e.addEventListener("message",(t=>{const i=t.data||{};"natively-flutter"===i.source&&"evaluate"===i.type&&"string"==typeof i.script&&e.eval(i.script)})),!0})(i);i.natively&&!i.natively.__nativelyAgent||(i.natively=new l),i.natively.injected=e,e&&!i.natively.app_version&&(i.natively.app_version=Number.MAX_SAFE_INTEGER),i.NativelyAdmobBanner=A,i.NativelyAdmobInterstitial=S,i.NativelyAppleSignInService=n,i.NativelyAudioRecorder=w,i.NativelyAudioPlayer=N,i.NativelyBiometrics=c,i.NativelyCamera=p,i.NativelyClipboard=r,i.NativelyContacts=m,i.NativelyDatePicker=y,i.NativelyGeolocation=d,i.NativelyHealth=h,i.NativelyInfo=s,i.NativelyLocation=g,i.NativelyMediaPicker=f,i.NativelyMessage=u,i.NativelyNFCService=k,i.NativelyNotifications=o,i.NativelyPurchases=b,i.NativelyScanner=_,i.NativelyStorage=v,i.NativelyCalendar=D,i.NativelyFirebaseNotifications=I,i.NativelyKlaviyoNotifications=T}null==i||i.natively.addObserver((()=>null==i?void 0:i.natively.trigger(void 0,0,(e=>{i&&(i.natively.min_app_version=e.minSDKVersion,i.natively.app_version=e.sdkVersion)}),"app_info",{})))})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natively",
3
- "version": "2.26.2",
3
+ "version": "2.26.4",
4
4
  "description": "Natively SDK for building native-like web applications",
5
5
  "type": "module",
6
6
  "exports": {