natively 2.14.0 → 2.15.0
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 +62 -4
- package/dist/classes/Natively.d.ts +22 -0
- package/dist/classes/Natively.js +139 -0
- package/dist/classes/NativelyAdmobBanner.d.ts +16 -0
- package/dist/classes/NativelyAdmobBanner.js +53 -0
- package/dist/classes/NativelyAdmobInterstitial.d.ts +17 -0
- package/dist/classes/NativelyAdmobInterstitial.js +54 -0
- package/dist/classes/NativelyAppleSignInService.d.ts +4 -0
- package/dist/classes/NativelyAppleSignInService.js +13 -0
- package/dist/classes/NativelyAudioRecorder.d.ts +4 -0
- package/dist/classes/NativelyAudioRecorder.js +16 -0
- package/dist/classes/NativelyBiometrics.d.ts +11 -0
- package/dist/classes/NativelyBiometrics.js +40 -0
- package/dist/classes/NativelyCamera.d.ts +4 -0
- package/dist/classes/NativelyCamera.js +18 -0
- package/dist/classes/NativelyClipboard.d.ts +5 -0
- package/dist/classes/NativelyClipboard.js +18 -0
- package/dist/classes/NativelyContacts.d.ts +5 -0
- package/dist/classes/NativelyContacts.js +22 -0
- package/dist/classes/NativelyDatePicker.d.ts +4 -0
- package/dist/classes/NativelyDatePicker.js +19 -0
- package/dist/classes/NativelyFirebaseNotifications.d.ts +9 -0
- package/dist/classes/NativelyFirebaseNotifications.js +32 -0
- package/dist/classes/NativelyGeolocation.d.ts +6 -0
- package/dist/classes/NativelyGeolocation.js +23 -0
- package/dist/classes/NativelyHealth.d.ts +8 -0
- package/dist/classes/NativelyHealth.js +40 -0
- package/dist/classes/NativelyInfo.d.ts +11 -0
- package/dist/classes/NativelyInfo.js +33 -0
- package/dist/classes/NativelyLocation.d.ts +10 -0
- package/dist/classes/NativelyLocation.js +47 -0
- package/dist/classes/NativelyMediaPicker.d.ts +4 -0
- package/dist/classes/NativelyMediaPicker.js +13 -0
- package/dist/classes/NativelyMessage.d.ts +5 -0
- package/dist/classes/NativelyMessage.js +25 -0
- package/dist/classes/NativelyNFCService.d.ts +11 -0
- package/dist/classes/NativelyNFCService.js +39 -0
- package/dist/classes/NativelyNotifications.d.ts +6 -0
- package/dist/classes/NativelyNotifications.js +21 -0
- package/dist/classes/NativelyPurchases.d.ts +9 -0
- package/dist/classes/NativelyPurchases.js +36 -0
- package/dist/classes/NativelyScanner.d.ts +4 -0
- package/dist/classes/NativelyScanner.js +13 -0
- package/dist/classes/NativelyStorage.d.ts +7 -0
- package/dist/classes/NativelyStorage.js +29 -0
- package/dist/events.d.ts +1 -0
- package/dist/events.js +7 -0
- package/dist/hooks/useNatively.d.ts +2 -0
- package/dist/hooks/useNatively.js +2 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +34 -0
- package/dist/inject.d.ts +1 -0
- package/dist/inject.js +7 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +1 -0
- package/dist/utils/generateID.d.ts +1 -0
- package/dist/utils/generateID.js +1 -0
- package/dist/utils/globalThis.d.ts +2 -0
- package/dist/utils/globalThis.js +25 -0
- package/natively-frontend.min.js +1 -1
- package/package.json +36 -7
- package/.vscode/settings.json +0 -13
- package/natively-frontend.js +0 -977
- package/natively-frontend.min.mjs +0 -1
- package/natively-frontend.mjs +0 -979
package/natively-frontend.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.natively = { isDebug: !1, min_app_version: 0, app_version: 0, injected: !1, observers: [], isIOSApp: window.navigator.userAgent.includes("Natively/iOS"), isAndroidApp: window.navigator.userAgent.includes("Natively/Android"), setDebug: function (i) { window.natively.isDebug = i }, notify: function (i, t) { window.natively.injected = !0, i && (window.natively.min_app_version = i), t && (window.natively.app_version = t); const e = window.natively.observers; for (natively.isDebug; e.length > 0;) { e.shift()() } }, addObserver: function (i) { window.natively.injected ? i() : (window.natively.isDebug, window.natively.observers.push(i)) }, trigger: function (i, t, e, n, o) { const a = window.natively.isDebug; if (window.natively.injected) if (t > window.natively.app_version) a && alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${t}`); else { if (e) { let t; t = i ? n + "_response_" + i : n + "_response", window[t] = function (i, t) { $agent.response(), t.message && a ? alert(`[ERROR] Error message: ${t.message}`) : e(i) }, o ? o.response_id = i : o = { response_id: i } } $agent.trigger(n, o) } else window.natively.addObserver((() => { window.natively.trigger(i, t, e, n, o) })) }, openLogger: function () { $agent.natively_logger() }, openConsole: function () { window.natively.trigger(void 0, 22, void 0, "app_console") }, closeApp: function () { window.natively.trigger(void 0, 11, void 0, "app_close") }, showProgress: function (i) { window.natively.trigger(void 0, 11, void 0, "app_show_progress", { toggle: i }) }, shareImage(i) { window.natively.trigger(void 0, 0, void 0, "share_image", { url: i }) }, shareText(i) { window.natively.trigger(void 0, 0, void 0, "share_text", { text: i }) }, shareTextAndImage(i, t) { window.natively.trigger(void 0, 0, void 0, "share_text_and_image", { url: t, text: i }) }, shareFile(i) { window.natively.trigger(void 0, 2, void 0, "share_file", { url: i }) }, openExternalURL(i, t) { const e = {}; e.url = void 0 === i ? "https://buildnatively.com" : i; const n = void 0 !== t && t; e.view = n ? "external" : "web", window.natively.trigger(void 0, 18, void 0, "open_link", e) }, openExternalAppIOS(i) { window.natively.trigger(void 0, 0, void 0, "open_app", { url: i }) }, openExternalApp(i) { window.natively.trigger(void 0, 22, void 0, "open_app", { url: i }) }, openAppSettings() { window.natively.trigger(void 0, 0, void 0, "open_appsettings") }, hapticPatternIOS(i, t) { window.natively.trigger(void 0, 7, void 0, "haptic_pattern", { pattern: i, delay: t }) }, hapticImpactIOS(i) { window.natively.trigger(void 0, 7, void 0, "haptic_impact", { type: i }) }, hapticNotificationIOS(i) { window.natively.trigger(void 0, 7, void 0, "haptic_notification", { type: i }) }, hapticPattern(i, t) { window.natively.trigger(void 0, 22, void 0, "haptic_pattern", { pattern: i, delay: t }) }, hapticImpact(i) { window.natively.trigger(void 0, 22, void 0, "haptic_impact", { type: i }) }, hapticNotification(i) { window.natively.trigger(void 0, 22, void 0, "haptic_notification", { type: i }) }, showAppToast(i, t) { const e = {}; e.text = void 0 === t ? "" : t, e.type = void 0 === i ? "DEFAULT" : i, window.natively.trigger(void 0, 0, void 0, "show_toast", e) }, showAppBanner(i, t, e) { const n = {}; n.type = void 0 === i ? "INFO" : i, n.title = void 0 === t ? "" : t, n.description = void 0 === e ? "" : e, window.natively.trigger(void 0, 0, void 0, "show_banner", n) }, requestAppReview() { window.natively.trigger(void 0, 0, void 0, "request_review") }, setAppBackgroundColor(i) { const t = { color: i }; window.natively.trigger(void 0, 1, void 0, "app_background", t) }, setAppProgressColor(i) { const t = { color: i }; window.natively.trigger(void 0, 1, void 0, "app_progress", t) }, setAppSwipeNavigationIOS(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_navigation", t) }, setAppSwipeNavigation(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_navigation", t) }, setAppPullToRefresh(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_pull", t) }, setAppOrientation(i) { const t = { orientation: i }; window.natively.trigger(void 0, 3, void 0, "app_orientation", t) }, setAppStatusBarStyleIOS(i) { const t = { style: i }; window.natively.trigger(void 0, 2, void 0, "status_bar_style", t) }, setAppStatusBarStyle(i) { const t = { style: i }; window.natively.trigger(void 0, 22, void 0, "status_bar_style", t) }, hideLoadingScreen() { const i = { show_loader: !1, auto_hide: !0 }; window.natively.trigger(void 0, 17, void 0, "loading_screen", i) }, showLoadingScreen(i) { const t = { show_loader: !0, auto_hide: void 0 !== i && i }; window.natively.trigger(void 0, 17, void 0, "loading_screen", t) }, async sendPushNotification(i, t, e, n) { const o = e.filter((i => i.length > 0)); let a = { app_id: n ? "be83022a-1d08-45d0-a07a-0c3655666e17" : i, include_player_ids: [...new Set(o)] }; t.template_id ? a.template_id = t.template_id : (a.headings = {}, a.headings.en = t.title || "Empty Title", a.contents = {}, a.contents.en = t.message || "Empty Message", t.subtitle && (a.subtitle = {}, a.subtitle.en = t.subtitle), t.redirect_url && (a.url = t.redirect_url)); const r = { method: "POST", headers: { "Content-type": "application/json" }, body: JSON.stringify(a) }; return await fetch("https://onesignal.com/api/v1/notifications", r) } }, window.natively.addObserver((() => window.natively.trigger(void 0, 0, (i => { window.natively.min_app_version = i.minSDKVersion, window.natively.app_version = i.sdkVersion }), "app_info", {}))); class NativelyInfo { constructor() { const i = generateID(); this.browserInfo = function () { return { isNativeApp: "undefined" != typeof $agent, isIOSApp: window.navigator.userAgent.includes("Natively/iOS"), isAndroidApp: window.navigator.userAgent.includes("Natively/Android") } }, this.getAppInfo = function (t) { window.natively.trigger(i, 0, t, "app_info") }, this.connectivity = function (i) { window.natively.trigger(void 0, 0, i, "connectivity") }, this.app_state = function (i) { window.natively.trigger(void 0, 19, i, "app_state") } } } class NativelyClipboard { constructor() { const i = generateID(); this.copy = function (i) { window.natively.trigger(void 0, 11, void 0, "clipboard_copy", { text: i }) }, this.paste = function (t) { window.natively.trigger(i, 11, t, "clipboard_paste") } } } class NativelyPagesCache { constructor() { const i = generateID(); this.currentPageCached = function (t) { window.natively.trigger(i, 4, t, "current_page_cached") }, this.storeCurrentPage = function (t) { window.natively.trigger(i, 4, t, "store_current_page") }, this.resetCurrentPage = function (t) { window.natively.trigger(i, 4, t, "reset_current_page") }, this.resetAll = function (t) { window.natively.trigger(i, 4, t, "reset_all") } } } class NativelyNotifications { constructor() { const i = generateID(); this.getOneSignalId = function (t) { window.natively.trigger(i, 0, t, "onesignal_playerid") }, this.requestPermission = function (t, e) { window.natively.trigger(i, 0, e, "push_register", { fallbackToSettings: t }) }, this.getPermissionStatus = function (t) { window.natively.trigger(i, 0, t, "push_permission") } } } class NativelyGeolocation { constructor() { const i = generateID(); this.getUserGeolocation = function (t, e) { window.natively.trigger(i, 0, e, "geolocation", { distance: t }) }, this.requestPermission = function (t) { window.natively.trigger(i, 0, t, "geo_register") }, this.getPermissionStatus = function (t) { window.natively.trigger(i, 0, t, "geo_permission") } } } class NativelyLocation { constructor() { const i = generateID(); this.current = function (t, e, n, o) { window.natively.trigger(i, 12, o, "location_current", { minAccuracy: t, accuracyType: e, priority: n }) }, this.permission = function (t) { window.natively.trigger(i, 6, t, "location_permission") }, this.start = function (t, e, n, o, a) { window.natively.trigger(i, 12, a, "location_start", { minAccuracy: e, accuracyType: n, priority: o, interval: t }) }, this.stop = function () { window.natively.trigger(i, 3, void 0, "location_stop", {}) }, this.startBackground = function (t, e, n, o, a, r) { const s = {}; s.identifier = void 0 === a ? "empty" : a, s.interval = void 0 === t ? 6e4 : t, s.minAccuracy = void 0 === e ? 50 : e, s.accuracyType = void 0 === n ? "Best" : n, s.priority = void 0 === o ? "BALANCED" : o, window.natively.trigger(i, 12, r, "location_start_bg", s) }, this.statusBackground = function (t) { window.natively.trigger(i, 20, t, "location_status_bg", {}) }, this.stopBackground = function (t) { window.natively.trigger(i, 4, t, "location_stop_bg", {}) } } } class NativelyMessage { constructor() { const i = generateID(); this.sendSMS = function (t, e, n) { const o = {}; o.body = void 0 === t ? "" : t, o.recipient = void 0 === e ? "" : e, window.natively.trigger(i, 0, n, "send_sms", o) }, this.sendEmail = function (t, e, n, o) { const a = {}; a.subject = void 0 === t ? "" : t, a.body = void 0 === e ? "" : e, a.recipient = void 0 === n ? "" : n, window.natively.trigger(i, 0, o, "send_email", a) } } } class NativelyStorage { constructor() { const i = generateID(); this.setStorageValue = function (t, e) { window.natively.trigger(i, 0, void 0, "set_storage_value", { key: t, value: e }) }, this.getStorageValue = function (t, e) { window.natively.trigger(i, 0, e, "get_storage_value", { key: t }) }, this.removeStorageValue = function (t) { window.natively.trigger(i, 0, void 0, "remove_storage_value", { key: t }) }, this.resetStorage = function () { window.natively.trigger(i, 0, void 0, "reset_storage") } } } class NativelyBiometrics { constructor(i) { this.allowPass = i; const t = generateID(); this.checkBiometricsSupport = function (e) { window.natively.trigger(t, 0, e, "biometrics_support", { allowPass: i }) }, this.checkCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_has_credentials") }, this.verifyUserIdentify = function (e) { window.natively.trigger(t, 0, e, "biometrics_verify", { allowPass: i }) }, this.getUserCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_auth", { allowPass: i }) }, this.removeUserCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_remove_credentials") }, this.saveUserCredentials = function (e, n, o) { window.natively.trigger(t, 0, o, "biometrics_auth", { allowPass: i, login: e, password: n }) } } } class NativelyDatePicker { constructor() { const i = generateID(); this.showDatePicker = function (t, e, n, o, a) { let r = {}; r.type = void 0 === n ? "DATE" : n, r.style = void 0 === o ? "LIGHT" : o, r.title = void 0 === t ? "" : t, r.description = void 0 === e ? "" : e, window.natively.trigger(i, 0, a, "datepicker", r) } } } class NativelyCamera { constructor() { const i = generateID(); this.showCamera = function (t, e, n, o) { let a = {}; a.type = void 0 === t ? "photo" : t, a.quality = void 0 === e ? "high" : e, a.camera = void 0 === n ? "BACK" : n, window.natively.trigger(i, 2, o, "open_camera", a) } } } class NativelyHealth { constructor() { const i = generateID(); this.available = function (t) { window.natively.trigger(i, 10, t, "health_available", {}) }, this.requestAuthorization = function (t, e, n) { window.natively.trigger(i, 10, n, "health_register", { write_data_types: t, read_data_types: e }) }, this.permissionStatus = function (t, e) { window.natively.trigger(i, 10, e, "health_permission", { data_type: t }) }, this.getAllCharacteristics = function (t) { window.natively.trigger(i, 10, t, "health_get_all_characteristics", {}) }, this.getStatisticQuantity = function (t, e, n, o, a) { const r = { data_type: t, interval: e }; void 0 !== n && (r.start_date = n.getTime()), void 0 !== o && (r.end_date = o.getTime()), window.natively.trigger(i, 10, a, "health_get_statistic_quantity", r) }, this.getDailySleepAnalysis = function (t, e, n, o) { const a = { limit: n || 100 }; void 0 !== t && (a.start_date = t.getTime()), void 0 !== e && (a.end_date = e.getTime()), window.natively.trigger(i, 10, o, "health_get_daily_sleep_analysis", a) }, this.getWorkouts = function (t, e, n, o) { const a = { limit: n || 100 }; void 0 !== t && (a.start_date = t.getTime()), void 0 !== e && (a.end_date = e.getTime()), window.natively.trigger(i, 21, o, "health_get_workouts", a) }, this.getActivitySummary = function (t, e, n) { const o = {}; void 0 !== t && (o.start_date = t.getTime()), void 0 !== e && (o.end_date = e.getTime()), window.natively.trigger(i, 10, n, "health_get_activity_summary", o) } } } class NativelyScanner { constructor() { const i = generateID(); this.showScanner = function (t) { window.natively.trigger(i, 2, t, "open_scanner", {}) } } } class NativelyPurchases { constructor() { const i = generateID(); this.login = function (t, e, n) { const o = void 0 === e ? "" : e; window.natively.trigger(i, 3, n, "purchases_login", { login: t, email: o }) }, this.logout = function (t) { window.natively.trigger(i, 3, t, "purchases_logout", {}) }, this.customerId = function (t) { window.natively.trigger(i, 3, t, "purchases_customerid", {}) }, this.restore = function (t) { window.natively.trigger(i, 10, t, "purchases_restore", {}) }, this.purchasePackage = function (t, e) { window.natively.trigger(i, 3, e, "purchases_package", { packageId: t }) }, this.packagePrice = function (t, e) { window.natively.trigger(i, 8, e, "purchases_price", { packageId: t }) } } } class NativelyContacts { constructor() { const i = generateID(); this.getAllContacts = function (t) { window.natively.trigger(i, 3, t, "contacts_all", {}) }, this.createContact = function (t, e, n, o, a) { let r = { firstName: t }; r.lastName = void 0 === e ? "" : e, r.email = void 0 === n ? "" : n, r.phone = void 0 === o ? "" : o, window.natively.trigger(i, 3, a, "contacts_save", r) } } } class NativelyMediaPicker { constructor() { const i = generateID(); this.showMediaPicker = function (t) { window.natively.trigger(i, 8, t, "mediapicker", {}) } } } class NativelyAudioRecorder { constructor() { const i = generateID(); this.showRecorder = function (t, e) { let n = {}; n.max_duration = void 0 === t ? 0 : t, window.natively.trigger(i, 13, e, "record_start", n) } } } class NativelyAdmobBanner { constructor(i, t, e = !1, n, o = !1, a) { const r = generateID(); let s = {}; window.natively.isAndroidApp ? s.unitId = void 0 === i.androidUnitId ? "ca-app-pub-3940256099942544/6300978111" : i.androidUnitId : window.natively.isIOSApp && (s.unitId = void 0 === i.iOSUnitId ? "ca-app-pub-3940256099942544/2934735716" : i.iOSUnitId), s.position = void 0 === i.position ? "BOTTOM" : i.position, s.sizeType = void 0 === i.sizeType ? "AUTO" : i.sizeType, s.width = void 0 === i.custom_width ? 320 : i.custom_width, s.height = void 0 === i.custom_height ? 50 : i.custom_height, window.natively.trigger(r, 14, (function (i) { void 0 !== t && t(i), e && window.natively.trigger(r, 14, (function (i) { void 0 !== n && n(i), o && window.natively.trigger(r, 14, a, "bannerad_show", {}) }), "bannerad_load", {}) }), "bannerad_setup", s), this.loadAd = function (i) { window.natively.trigger(r, 14, i, "bannerad_load", {}) }, this.showBanner = function (i) { window.natively.trigger(r, 14, i, "bannerad_show", {}) }, this.hideBanner = function (i) { window.natively.trigger(r, 14, i, "bannerad_hide", {}) }, this.bannerIsReady = function (i) { window.natively.trigger(r, 14, i, "bannerad_ready", {}) }, this.bannerIsVisible = function (i) { window.natively.trigger(r, 14, i, "bannerad_visible", {}) } } } class NativelyAdmobInterstitial { constructor(i = "ca-app-pub-3940256099942544/4411468910", t = "ca-app-pub-3940256099942544/1033173712", e, n = !1, o) { const a = generateID(); let r; window.natively.isAndroidApp ? r = void 0 === t ? "ca-app-pub-3940256099942544/1033173712" : t : window.natively.isIOSApp && (r = void 0 === i ? "ca-app-pub-3940256099942544/4411468910" : i), this.loadAd = function (i) { const t = {}; t.unitId = void 0 === r ? "ca-app-pub-3940256099942544/4411468910" : r, window.natively.trigger(a, 14, i, "interstitialad_setup", t) }, this.showInterstitialAd = function (i) { window.natively.trigger(a, 14, (function (t) { if (i(t), "DID_DISMISS_AD" === t.event && n) { const i = {}; i.unitId = r, setTimeout((() => { window.natively.trigger(a, 14, o, "interstitialad_setup", i) }), 500) } }), "interstitialad_show", {}) }, this.interstitialIsReady = function (i) { window.natively.trigger(a, 14, i, "interstitialad_ready", {}) }, this.loadAd(e) } } class NativelyNFCService { constructor(i, t, e, n) { const o = generateID(); this.readAlertMessage = i, this.writeAlertMessage = t, this.readDetectedMessage = e, this.writeDetectedMessage = n, this.read = function (i) { let t = {}; t.alertMessage = void 0 === this.readAlertMessage ? "please set readAlertMessage" : this.readAlertMessage, t.detectedMessage = void 0 === this.readDetectedMessage ? "readDetectedMessage" : this.readDetectedMessage, window.natively.trigger(o, 15, i, "nfc_read", t) }, this.write = function (i, t, e) { let n = {}; n.alertMessage = void 0 === this.writeAlertMessage ? "please set writeAlertMessage" : this.writeAlertMessage, n.detectedMessage = void 0 === this.writeDetectedMessage ? "please set writeDetectedMessage" : this.writeDetectedMessage, n.recordData = void 0 === t ? "please set recordData" : t, n.recordId = void 0 === i ? "please set recordId" : i, window.natively.trigger(o, 15, e, "nfc_write", n) }, this.available = function (i) { window.natively.trigger(o, 15, i, "nfc_available", {}) } } } class NativelyAppleSignInService { constructor() { const i = generateID(); this.signin = function (t) { window.natively.trigger(i, 16, t, "apple_signin", {}) } } } function generateID() { return Date.now().toString(36) + Math.random().toString(36).substring(2) }
|
|
1
|
+
(()=>{"use strict";var i={d:(e,t)=>{for(var l in t)i.o(t,l)&&!i.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})}};i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(i){if("object"==typeof window)return window}}(),i.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),i.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var e={};i.r(e),i.d(e,{Natively:()=>l,NativelyAdmobBanner:()=>w,NativelyAdmobInterstitial:()=>S,NativelyAppleSignInService:()=>n,NativelyAudioRecorder:()=>A,NativelyBiometrics:()=>c,NativelyCamera:()=>h,NativelyClipboard:()=>r,NativelyContacts:()=>m,NativelyDatePicker:()=>y,NativelyFirebaseNotifications:()=>I,NativelyGeolocation:()=>d,NativelyHealth:()=>p,NativelyInfo:()=>a,NativelyLocation:()=>g,NativelyMediaPicker:()=>f,NativelyMessage:()=>u,NativelyNFCService:()=>N,NativelyNotifications:()=>o,NativelyPurchases:()=>b,NativelyScanner:()=>_,NativelyStorage:()=>v,generateID:()=>s,useNatively:()=>k});const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==i.g?i.g:null;class l{constructor(){var i,e,l,s;this.isDebug=!1,this.min_app_version=0,this.app_version=0,this.injected=!1,this.observers=[],this.isIOSApp=(null===(e=null===(i=null==t?void 0:t.navigator)||void 0===i?void 0:i.userAgent)||void 0===e?void 0:e.includes("Natively/iOS"))||!1,this.isAndroidApp=(null===(s=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===s?void 0:s.includes("Natively/Android"))||!1}setDebug(i){t&&(t.natively.isDebug=i)}notify(i,e){t&&(t.natively.injected=!0,i&&(t.natively.min_app_version=i),e&&(t.natively.app_version=e));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 i=l.shift();null==i||i()}}addObserver(i){(null==t?void 0:t.natively.injected)?i():((null==t?void 0:t.natively.isDebug)&&console.log(`[DEBUG] addObserver: ${i}`),null==t||t.natively.observers.push(i))}trigger(i,e,l,s,n){const r=null==t?void 0:t.natively.isDebug;if(null==t?void 0:t.natively.injected)if(e>(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: ${e}`);else{if(l){let e;e=i?s+"_response_"+i:s+"_response",t&&(t[e]=function(s,n){null==t||t.$agent.response(),n.message&&r?alert(`[ERROR] Error message: ${n.message}`):(r&&console.log(`[DEBUG] Callback method: ${e}, body: ${JSON.stringify(s)}, respId: ${i}`),l(s))}),n?n.response_id=i:n={response_id:i}}r&&console.log(`[DEBUG] Trigger method: ${s}, body: ${JSON.stringify(n)}`),null==t||t.$agent.trigger(s,n)}else null==t||t.natively.addObserver((()=>{null==t||t.natively.trigger(i,e,l,s,n)}))}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(i){null==t||t.natively.trigger(void 0,11,void 0,"app_show_progress",{toggle:i})}shareImage(i){null==t||t.natively.trigger(void 0,0,void 0,"share_image",{url:i})}shareText(i){null==t||t.natively.trigger(void 0,0,void 0,"share_text",{text:i})}shareTextAndImage(i,e){null==t||t.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:e,text:i})}shareFile(i){null==t||t.natively.trigger(void 0,2,void 0,"share_file",{url:i})}openExternalURL(i,e){const l={url:void 0===i?"https://buildnatively.com":i,view:void 0!==e&&e?"external":"web"};null==t||t.natively.trigger(void 0,18,void 0,"open_link",l)}}const s=()=>Date.now().toString(36)+Math.random().toString(36).substring(2);class n{constructor(){this.id=s()}signin(i){null==t||t.natively.trigger(this.id,16,i,"apple_signin",{})}}class r{constructor(){this.id=s()}copy(i){null==t||t.natively.trigger(void 0,11,void 0,"clipboard_copy",{text:i})}paste(i){null==t||t.natively.trigger(this.id,11,i,"clipboard_paste")}}class a{constructor(){this.id=s()}browserInfo(){var i,e,l,s;return{isNativeApp:void 0!==(null==t?void 0:t.$agent),isIOSApp:(null===(e=null===(i=null==t?void 0:t.navigator)||void 0===i?void 0:i.userAgent)||void 0===e?void 0:e.includes("Natively/iOS"))||!1,isAndroidApp:(null===(s=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===s?void 0:s.includes("Natively/Android"))||!1}}getAppInfo(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(this.id,0,i,"app_info"))}connectivity(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,0,i,"connectivity"))}app_state(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,19,i,"app_state"))}}class o{constructor(){this.id=s()}getOneSignalId(i){null==t||t.natively.trigger(this.id,0,i,"onesignal_playerid")}requestPermission(i,e){null==t||t.natively.trigger(this.id,0,e,"push_register",{fallbackToSettings:i})}getPermissionStatus(i){null==t||t.natively.trigger(this.id,0,i,"push_permission")}}class d{constructor(){this.id=s()}getUserGeolocation(i,e){null==t||t.natively.trigger(this.id,0,e,"geolocation",{distance:i})}requestPermission(i){null==t||t.natively.trigger(this.id,0,i,"geo_register")}getPermissionStatus(i){null==t||t.natively.trigger(this.id,0,i,"geo_permission")}}class g{constructor(){this.id=s()}current(i,e,l,s){null==t||t.natively.trigger(this.id,12,s,"location_current",{minAccuracy:i,accuracyType:e,priority:l})}permission(i){null==t||t.natively.trigger(this.id,6,i,"location_permission")}start(i,e,l,s,n){null==t||t.natively.trigger(this.id,12,n,"location_start",{minAccuracy:e,accuracyType:l,priority:s,interval:i})}stop(){null==t||t.natively.trigger(this.id,3,void 0,"location_stop",{})}startBackground(i,e,l,s,n,r){const a={identifier:null!=n?n:"empty",interval:null!=i?i:6e4,minAccuracy:null!=e?e:50,accuracyType:null!=l?l:"Best",priority:null!=s?s:"BALANCED"};null==t||t.natively.trigger(this.id,12,r,"location_start_bg",a)}statusBackground(i){null==t||t.natively.trigger(this.id,20,i,"location_status_bg",{})}stopBackground(i){null==t||t.natively.trigger(this.id,4,i,"location_stop_bg",{})}}class u{constructor(){this.id=s()}sendSMS(i,e,l){const s={body:null!=i?i:"",recipient:null!=e?e:""};null==t||t.natively.trigger(this.id,0,l,"send_sms",s)}sendEmail(i,e,l,s){const n={subject:null!=i?i:"",body:null!=e?e:"",recipient:null!=l?l:""};null==t||t.natively.trigger(this.id,0,s,"send_email",n)}}class v{constructor(){this.id=s()}setStorageValue(i,e){null==t||t.natively.trigger(this.id,0,void 0,"set_storage_value",{key:i,value:e})}getStorageValue(i,e){null==t||t.natively.trigger(this.id,0,e,"get_storage_value",{key:i})}removeStorageValue(i){null==t||t.natively.trigger(this.id,0,void 0,"remove_storage_value",{key:i})}resetStorage(){null==t||t.natively.trigger(this.id,0,void 0,"reset_storage")}}class c{constructor(i){this.id=s(),this.allowPass=i}checkBiometricsSupport(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_support",{allowPass:this.allowPass})}checkCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_has_credentials")}verifyUserIdentify(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_verify",{allowPass:this.allowPass})}getUserCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_auth",{allowPass:this.allowPass})}removeUserCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_remove_credentials")}saveUserCredentials(i,e,l){null==t||t.natively.trigger(this.id,0,l,"biometrics_auth",{allowPass:this.allowPass,login:i,password:e})}}class y{constructor(){this.id=s()}showDatePicker(i,e,l,s,n){const r={type:null!=l?l:"DATE",style:null!=s?s:"LIGHT",title:null!=i?i:"",description:null!=e?e:""};null==t||t.natively.trigger(this.id,0,n,"datepicker",r)}}class h{constructor(){this.id=s()}showCamera(i,e,l,s){const n={type:null!=i?i:"photo",quality:null!=e?e:"high",camera:null!=l?l:"BACK"};null==t||t.natively.trigger(this.id,2,s,"open_camera",n)}}class p{constructor(){this.id=s()}available(i){null==t||t.natively.trigger(this.id,10,i,"health_available",{})}requestAuthorization(i,e,l){null==t||t.natively.trigger(this.id,10,l,"health_register",{write_data_types:i,read_data_types:e})}permissionStatus(i,e){null==t||t.natively.trigger(this.id,10,e,"health_permission",{data_type:i})}getAllCharacteristics(i){null==t||t.natively.trigger(this.id,10,i,"health_get_all_characteristics",{})}getStatisticQuantity(i,e,l,s,n){const r={data_type:i,interval:e};l&&(r.start_date=l.getTime()),s&&(r.end_date=s.getTime()),null==t||t.natively.trigger(this.id,10,n,"health_get_statistic_quantity",r)}}class _{constructor(){this.id=s()}showScanner(i){null==t||t.natively.trigger(this.id,2,i,"open_scanner",{})}}class b{constructor(){this.id=s()}login(i,e,l){const s=null!=e?e:"";null==t||t.natively.trigger(this.id,3,l,"purchases_login",{login:i,email:s})}logout(i){null==t||t.natively.trigger(this.id,3,i,"purchases_logout",{})}customerId(i){null==t||t.natively.trigger(this.id,3,i,"purchases_customerid",{})}restore(i){null==t||t.natively.trigger(this.id,10,i,"purchases_restore",{})}purchasePackage(i,e){null==t||t.natively.trigger(this.id,3,e,"purchases_package",{packageId:i})}packagePrice(i,e){null==t||t.natively.trigger(this.id,8,e,"purchases_price",{packageId:i})}}class m{constructor(){this.id=s()}getAllContacts(i){null==t||t.natively.trigger(this.id,3,i,"contacts_all",{})}createContact(i,e,l,s,n){const r={firstName:i,lastName:null!=e?e:"",email:null!=l?l:"",phone:null!=s?s:""};null==t||t.natively.trigger(this.id,3,n,"contacts_save",r)}}class f{constructor(){this.id=s()}showMediaPicker(i){null==t||t.natively.trigger(this.id,8,i,"mediapicker",{})}}class A{constructor(){this.id=s()}showRecorder(i,e){const l={max_duration:null!=i?i:0};null==t||t.natively.trigger(this.id,13,e,"record_start",l)}}class w{constructor(i,e,l=!1,n,r=!1,a){var o,d,g,u,v,c;this.id=s();const y={};(null==t?void 0:t.natively.isAndroidApp)?y.unitId=null!==(o=i.androidUnitId)&&void 0!==o?o:"ca-app-pub-3940256099942544/6300978111":(null==t?void 0:t.natively.isIOSApp)&&(y.unitId=null!==(d=i.iOSUnitId)&&void 0!==d?d:"ca-app-pub-3940256099942544/2934735716"),y.position=null!==(g=i.position)&&void 0!==g?g:"BOTTOM",y.sizeType=null!==(u=i.sizeType)&&void 0!==u?u:"AUTO",y.width=null!==(v=i.custom_width)&&void 0!==v?v:320,y.height=null!==(c=i.custom_height)&&void 0!==c?c:50,null==t||t.natively.trigger(this.id,14,(i=>{null==e||e(i),l&&(null==t||t.natively.trigger(this.id,14,(i=>{null==n||n(i),r&&(null==t||t.natively.trigger(this.id,14,a,"bannerad_show",{}))}),"bannerad_load",{}))}),"bannerad_setup",y)}loadAd(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_load",{})}showBanner(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_show",{})}hideBanner(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_hide",{})}bannerIsReady(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_ready",{})}bannerIsVisible(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_visible",{})}}class S{constructor(i="ca-app-pub-3940256099942544/4411468910",e="ca-app-pub-3940256099942544/1033173712",l,n=!1,r){this.id=s(),(null==t?void 0:t.natively.isAndroidApp)?this.unitId=e:(null==t?void 0:t.natively.isIOSApp)&&(this.unitId=i),this.auto_ad_reload=n,this.auto_ad_reload_callback=r,this.loadAd(l)}loadAd(i){var e;const l={unitId:null!==(e=this.unitId)&&void 0!==e?e:"ca-app-pub-3940256099942544/4411468910"};null==t||t.natively.trigger(this.id,14,i,"interstitialad_setup",l)}showInterstitialAd(i){null==t||t.natively.trigger(this.id,14,(e=>{i(e),"DID_DISMISS_AD"===e.event&&this.auto_ad_reload&&setTimeout((()=>{this.loadAd(this.auto_ad_reload_callback)}),500)}),"interstitialad_show",{})}interstitialIsReady(i){null==t||t.natively.trigger(this.id,14,i,"interstitialad_ready",{})}}class N{constructor(i,e,t,l){this.id=s(),this.readAlertMessage=i,this.writeAlertMessage=e,this.readDetectedMessage=t,this.writeDetectedMessage=l}read(i){var e,l;const s={alertMessage:null!==(e=this.readAlertMessage)&&void 0!==e?e:"please set readAlertMessage",detectedMessage:null!==(l=this.readDetectedMessage)&&void 0!==l?l:"readDetectedMessage"};null==t||t.natively.trigger(this.id,15,i,"nfc_read",s)}write(i,e,l){var s,n;const r={alertMessage:null!==(s=this.writeAlertMessage)&&void 0!==s?s:"please set writeAlertMessage",detectedMessage:null!==(n=this.writeDetectedMessage)&&void 0!==n?n:"please set writeDetectedMessage",recordData:null!=e?e:"please set recordData",recordId:null!=i?i:"please set recordId"};null==t||t.natively.trigger(this.id,15,l,"nfc_write",r)}available(i){null==t||t.natively.trigger(this.id,15,i,"nfc_available",{})}}class I{constructor(){this.id=s()}firebase_get_token(i){null==t||t.natively.trigger(this.id,31,i,"firebase_get_token")}firebase_get_apns_token(i){null==t||t.natively.trigger(this.id,31,i,"firebase_get_apns_token")}firebase_request_permission(i){null==t||t.natively.trigger(this.id,31,i,"firebase_request_permission")}firebase_has_permission(i){null==t||t.natively.trigger(this.id,31,i,"firebase_has_permission")}firebase_subscribe_to_topic(i,e){null==t||t.natively.trigger(this.id,31,e,"firebase_subscribe_to_topic",{topic:i})}firebase_unsubscribe_from_topic(i,e){null==t||t.natively.trigger(this.id,31,e,"firebase_unsubscribe_from_topic",{topic:i})}}const k=()=>null==t?void 0:t.natively;t&&(t.natively=new l),null==t||t.natively.addObserver((()=>null==t?void 0:t.natively.trigger(void 0,0,(i=>{t&&(t.natively.min_app_version=i.minSDKVersion,t.natively.app_version=i.sdkVersion)}),"app_info",{})))})();
|
package/package.json
CHANGED
|
@@ -1,24 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natively",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "natively-frontend.min.mjs",
|
|
3
|
+
"version": "2.15.0",
|
|
4
|
+
"description": "Natively SDK for building native-like web applications",
|
|
6
5
|
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"natively-frontend.min.js",
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"package-name": "buildnatively/js-sdk#typescript_module",
|
|
7
17
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
18
|
+
"build": "npm run build:types && npm run build:webpack && npm run build:module",
|
|
19
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
20
|
+
"build:webpack": "webpack build",
|
|
21
|
+
"build:module": "babel src --extensions \".ts\" --config-file ./babel.config.module.cjs --out-dir ./dist/"
|
|
10
22
|
},
|
|
11
23
|
"repository": {
|
|
12
24
|
"type": "git",
|
|
13
25
|
"url": "git+https://github.com/buildnatively/js-sdk.git"
|
|
14
26
|
},
|
|
15
27
|
"keywords": [
|
|
16
|
-
"natively"
|
|
28
|
+
"natively",
|
|
29
|
+
"mobile",
|
|
30
|
+
"webview",
|
|
31
|
+
"sdk",
|
|
32
|
+
"ios",
|
|
33
|
+
"android"
|
|
17
34
|
],
|
|
18
35
|
"author": "Roman Furman",
|
|
19
36
|
"license": "ISC",
|
|
20
37
|
"bugs": {
|
|
21
38
|
"url": "https://github.com/buildnatively/js-sdk/issues"
|
|
22
39
|
},
|
|
23
|
-
"homepage": "https://github.com/buildnatively/js-sdk#readme"
|
|
40
|
+
"homepage": "https://github.com/buildnatively/js-sdk#readme",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/cli": "^7.25.9",
|
|
43
|
+
"@babel/core": "^7.26.0",
|
|
44
|
+
"@babel/preset-env": "^7.26.0",
|
|
45
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
46
|
+
"babel-loader": "^9.2.1",
|
|
47
|
+
"ts-loader": "^9.5.1",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"typescript": "^5.6.3",
|
|
50
|
+
"webpack": "^5.96.1",
|
|
51
|
+
"webpack-cli": "^5.1.4"
|
|
52
|
+
}
|
|
24
53
|
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.formatOnSave": true,
|
|
3
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
4
|
-
"[javascript]": {
|
|
5
|
-
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
6
|
-
},
|
|
7
|
-
"[html]": {
|
|
8
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
9
|
-
},
|
|
10
|
-
"autominify.enableMinFileJs": false,
|
|
11
|
-
"autominify.enableJsMinification": false,
|
|
12
|
-
}
|
|
13
|
-
|