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
|
@@ -1 +0,0 @@
|
|
|
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 (e) { window.natively.isDebug = e }, notify: function (e, t) { window.natively.injected = !0, e && (window.natively.min_app_version = e), t && (window.natively.app_version = t); let i = window.natively.observers; for (natively.isDebug && console.log("[INFO] Notify observers: ", i.length); i.length > 0;) { let a = i.shift(); a() } }, addObserver: function (e) { window.natively.injected ? e() : (window.natively.isDebug && console.log(`[DEBUG] addObserver: ${e}`), window.natively.observers.push(e)) }, trigger: function (e, t, i, a, r) { let n = window.natively.isDebug; if (!window.natively.injected) { window.natively.addObserver(() => { window.natively.trigger(e, t, i, a, r) }); return } if (t > window.natively.app_version) { n && alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${t}`); return } if (i) { let o; o = e ? a + "_response_" + e : a + "_response", window[o] = function (t, a) { if ($agent.response(), a.message && n) { alert(`[ERROR] Error message: ${a.message}`); return } n && console.log(`[DEBUG] Callback method: ${o}, body: ${JSON.stringify(t)}, respId: ${e}`), i(t) }, r ? r.response_id = e : r = { response_id: e } } n && console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(r)}`), $agent.trigger(a, r) }, 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 (e) { window.natively.trigger(void 0, 11, void 0, "app_show_progress", { toggle: e }) }, shareImage(e) { window.natively.trigger(void 0, 0, void 0, "share_image", { url: e }) }, shareText(e) { window.natively.trigger(void 0, 0, void 0, "share_text", { text: e }) }, shareTextAndImage(e, t) { window.natively.trigger(void 0, 0, void 0, "share_text_and_image", { url: t, text: e }) }, shareFile(e) { window.natively.trigger(void 0, 2, void 0, "share_file", { url: e }) }, openExternalURL(e, t) { let i = {}; i.url = void 0 === e ? "https://buildnatively.com" : e, i.view = void 0 !== t && t ? "external" : "web", window.natively.trigger(void 0, 18, void 0, "open_link", i) }, openExternalAppIOS(e) { window.natively.trigger(void 0, 0, void 0, "open_app", { url: e }) }, openExternalApp(e) { window.natively.trigger(void 0, 22, void 0, "open_app", { url: e }) }, openAppSettings() { window.natively.trigger(void 0, 0, void 0, "open_appsettings") }, hapticPatternIOS(e, t) { window.natively.trigger(void 0, 7, void 0, "haptic_pattern", { pattern: e, delay: t }) }, hapticImpactIOS(e) { window.natively.trigger(void 0, 7, void 0, "haptic_impact", { type: e }) }, hapticNotificationIOS(e) { window.natively.trigger(void 0, 7, void 0, "haptic_notification", { type: e }) }, hapticPattern(e, t) { window.natively.trigger(void 0, 22, void 0, "haptic_pattern", { pattern: e, delay: t }) }, hapticImpact(e) { window.natively.trigger(void 0, 22, void 0, "haptic_impact", { type: e }) }, hapticNotification(e) { window.natively.trigger(void 0, 22, void 0, "haptic_notification", { type: e }) }, showAppToast(e, t) { let i = {}; i.text = void 0 === t ? "" : t, i.type = void 0 === e ? "DEFAULT" : e, window.natively.trigger(void 0, 0, void 0, "show_toast", i) }, showAppBanner(e, t, i) { let a = {}; a.type = void 0 === e ? "INFO" : e, a.title = void 0 === t ? "" : t, a.description = void 0 === i ? "" : i, window.natively.trigger(void 0, 0, void 0, "show_banner", a) }, requestAppReview() { window.natively.trigger(void 0, 0, void 0, "request_review") }, setAppBackgroundColor(e) { window.natively.trigger(void 0, 1, void 0, "app_background", { color: e }) }, setAppProgressColor(e) { window.natively.trigger(void 0, 1, void 0, "app_progress", { color: e }) }, setAppSwipeNavigationIOS(e) { window.natively.trigger(void 0, 1, void 0, "app_navigation", { toggle: e }) }, setAppSwipeNavigation(e) { window.natively.trigger(void 0, 22, void 0, "app_navigation", { toggle: e }) }, setAppPullToRefresh(e) { window.natively.trigger(void 0, 1, void 0, "app_pull", { toggle: e }) }, setAppOrientation(e) { window.natively.trigger(void 0, 3, void 0, "app_orientation", { orientation: e }) }, setAppStatusBarStyleIOS(e) { window.natively.trigger(void 0, 2, void 0, "status_bar_style", { style: e }) }, setAppStatusBarStyle(e) { window.natively.trigger(void 0, 22, void 0, "status_bar_style", { style: e }) }, hideLoadingScreen() { window.natively.trigger(void 0, 17, void 0, "loading_screen", { show_loader: !1, auto_hide: !0 }) }, showLoadingScreen(e) { window.natively.trigger(void 0, 17, void 0, "loading_screen", { show_loader: !0, auto_hide: void 0 !== e && e }) }, async sendPushNotification(e, t, i, a) { let r = i.filter(e => e.length > 0), n = [...new Set(r)], o = { app_id: a ? "be83022a-1d08-45d0-a07a-0c3655666e17" : e, include_player_ids: n }; t.template_id ? o.template_id = t.template_id : (o.headings = {}, o.headings.en = t.title || "Empty Title", o.contents = {}, o.contents.en = t.message || "Empty Message", t.subtitle && (o.subtitle = {}, o.subtitle.en = t.subtitle), t.redirect_url && (o.url = t.redirect_url)); let s = { method: "POST", headers: { "Content-type": "application/json" }, body: JSON.stringify(o) }; return await fetch("https://onesignal.com/api/v1/notifications", s) } }, window.natively.addObserver(() => window.natively.trigger(void 0, 0, e => { window.natively.min_app_version = e.minSDKVersion, window.natively.app_version = e.sdkVersion }, "app_info", {})); class NativelyInfo { constructor() { let e = generateID(); this.browserInfo = function () { let e = "undefined" != typeof $agent, t = window.navigator.userAgent.includes("Natively/iOS"), i = window.navigator.userAgent.includes("Natively/Android"); return { isNativeApp: e, isIOSApp: t, isAndroidApp: i } }, this.getAppInfo = function (t) { window.natively.trigger(e, 0, t, "app_info") }, this.connectivity = function (e) { window.natively.trigger(void 0, 0, e, "connectivity") }, this.app_state = function (e) { window.natively.trigger(void 0, 19, e, "app_state") } } } class NativelyClipboard { constructor() { let e = generateID(); this.copy = function (e) { window.natively.trigger(void 0, 11, void 0, "clipboard_copy", { text: e }) }, this.paste = function (t) { window.natively.trigger(e, 11, t, "clipboard_paste") } } } class NativelyPagesCache { constructor() { let e = generateID(); this.currentPageCached = function (t) { window.natively.trigger(e, 4, t, "current_page_cached") }, this.storeCurrentPage = function (t) { window.natively.trigger(e, 4, t, "store_current_page") }, this.resetCurrentPage = function (t) { window.natively.trigger(e, 4, t, "reset_current_page") }, this.resetAll = function (t) { window.natively.trigger(e, 4, t, "reset_all") } } } class NativelyNotifications { constructor() { let e = generateID(); this.getOneSignalId = function (t) { window.natively.trigger(e, 0, t, "onesignal_playerid") }, this.requestPermission = function (t, i) { window.natively.trigger(e, 0, i, "push_register", { fallbackToSettings: t }) }, this.getPermissionStatus = function (t) { window.natively.trigger(e, 0, t, "push_permission") } } } class NativelyGeolocation { constructor() { let e = generateID(); this.getUserGeolocation = function (t, i) { window.natively.trigger(e, 0, i, "geolocation", { distance: t }) }, this.requestPermission = function (t) { window.natively.trigger(e, 0, t, "geo_register") }, this.getPermissionStatus = function (t) { window.natively.trigger(e, 0, t, "geo_permission") } } } class NativelyLocation { constructor() { let e = generateID(); this.current = function (t, i, a, r) { window.natively.trigger(e, 12, r, "location_current", { minAccuracy: t, accuracyType: i, priority: a }) }, this.permission = function (t) { window.natively.trigger(e, 6, t, "location_permission") }, this.start = function (t, i, a, r, n) { window.natively.trigger(e, 12, n, "location_start", { minAccuracy: i, accuracyType: a, priority: r, interval: t }) }, this.stop = function () { window.natively.trigger(e, 3, void 0, "location_stop", {}) }, this.startBackground = function (t, i, a, r, n, o) { let s = {}; s.identifier = void 0 === n ? "empty" : n, s.interval = void 0 === t ? 6e4 : t, s.minAccuracy = void 0 === i ? 50 : i, s.accuracyType = void 0 === a ? "Best" : a, s.priority = void 0 === r ? "BALANCED" : r, window.natively.trigger(e, 12, o, "location_start_bg", s) }, this.statusBackground = function (t) { window.natively.trigger(e, 20, t, "location_status_bg", {}) }, this.stopBackground = function (t) { window.natively.trigger(e, 4, t, "location_stop_bg", {}) } } } class NativelyMessage { constructor() { let e = generateID(); this.sendSMS = function (t, i, a) { let r = {}; r.body = void 0 === t ? "" : t, r.recipient = void 0 === i ? "" : i, window.natively.trigger(e, 0, a, "send_sms", r) }, this.sendEmail = function (t, i, a, r) { let n = {}; n.subject = void 0 === t ? "" : t, n.body = void 0 === i ? "" : i, n.recipient = void 0 === a ? "" : a, window.natively.trigger(e, 0, r, "send_email", n) } } } class NativelyStorage { constructor() { let e = generateID(); this.setStorageValue = function (t, i) { window.natively.trigger(e, 0, void 0, "set_storage_value", { key: t, value: i }) }, this.getStorageValue = function (t, i) { window.natively.trigger(e, 0, i, "get_storage_value", { key: t }) }, this.removeStorageValue = function (t) { window.natively.trigger(e, 0, void 0, "remove_storage_value", { key: t }) }, this.resetStorage = function () { window.natively.trigger(e, 0, void 0, "reset_storage") } } } class NativelyBiometrics { constructor(e) { this.allowPass = e; let t = generateID(); this.checkBiometricsSupport = function (i) { window.natively.trigger(t, 0, i, "biometrics_support", { allowPass: e }) }, this.checkCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_has_credentials") }, this.verifyUserIdentify = function (i) { window.natively.trigger(t, 0, i, "biometrics_verify", { allowPass: e }) }, this.getUserCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_auth", { allowPass: e }) }, this.removeUserCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_remove_credentials") }, this.saveUserCredentials = function (i, a, r) { window.natively.trigger(t, 0, r, "biometrics_auth", { allowPass: e, login: i, password: a }) } } } class NativelyDatePicker { constructor() { let e = generateID(); this.showDatePicker = function (t, i, a, r, n) { let o = {}; o.type = void 0 === a ? "DATE" : a, o.style = void 0 === r ? "LIGHT" : r, o.title = void 0 === t ? "" : t, o.description = void 0 === i ? "" : i, window.natively.trigger(e, 0, n, "datepicker", o) } } } class NativelyCamera { constructor() { let e = generateID(); this.showCamera = function (t, i, a, r) { let n = {}; n.type = void 0 === t ? "photo" : t, n.quality = void 0 === i ? "high" : i, n.camera = void 0 === a ? "BACK" : a, window.natively.trigger(e, 2, r, "open_camera", n) } } } class NativelyHealth { constructor() { let e = generateID(); this.available = function (t) { window.natively.trigger(e, 10, t, "health_available", {}) }, this.requestAuthorization = function (t, i, a) { window.natively.trigger(e, 10, a, "health_register", { write_data_types: t, read_data_types: i }) }, this.permissionStatus = function (t, i) { window.natively.trigger(e, 10, i, "health_permission", { data_type: t }) }, this.getAllCharacteristics = function (t) { window.natively.trigger(e, 10, t, "health_get_all_characteristics", {}) }, this.getStatisticQuantity = function (t, i, a, r, n) { let o = { data_type: t, interval: i }; void 0 !== a && (o.start_date = a.getTime()), void 0 !== r && (o.end_date = r.getTime()), window.natively.trigger(e, 10, n, "health_get_statistic_quantity", o) }, this.getDailySleepAnalysis = function (t, i, a, r) { let n = { limit: a || 100 }; void 0 !== t && (n.start_date = t.getTime()), void 0 !== i && (n.end_date = i.getTime()), window.natively.trigger(e, 10, r, "health_get_daily_sleep_analysis", n) }, this.getWorkouts = function (t, i, a, r) { let n = { limit: a || 100 }; void 0 !== t && (n.start_date = t.getTime()), void 0 !== i && (n.end_date = i.getTime()), window.natively.trigger(e, 21, r, "health_get_workouts", n) }, this.getActivitySummary = function (t, i, a) { let r = {}; void 0 !== t && (r.start_date = t.getTime()), void 0 !== i && (r.end_date = i.getTime()), window.natively.trigger(e, 10, a, "health_get_activity_summary", r) } } } class NativelyScanner { constructor() { let e = generateID(); this.showScanner = function (t) { window.natively.trigger(e, 2, t, "open_scanner", {}) } } } class NativelyPurchases { constructor() { let e = generateID(); this.login = function (t, i, a) { window.natively.trigger(e, 3, a, "purchases_login", { login: t, email: void 0 === i ? "" : i }) }, this.logout = function (t) { window.natively.trigger(e, 3, t, "purchases_logout", {}) }, this.customerId = function (t) { window.natively.trigger(e, 3, t, "purchases_customerid", {}) }, this.restore = function (t) { window.natively.trigger(e, 10, t, "purchases_restore", {}) }, this.purchasePackage = function (t, i) { window.natively.trigger(e, 3, i, "purchases_package", { packageId: t }) }, this.packagePrice = function (t, i) { window.natively.trigger(e, 8, i, "purchases_price", { packageId: t }) } } } class NativelyContacts { constructor() { let e = generateID(); this.getAllContacts = function (t) { window.natively.trigger(e, 3, t, "contacts_all", {}) }, this.createContact = function (t, i, a, r, n) { let o = { firstName: t }; o.lastName = void 0 === i ? "" : i, o.email = void 0 === a ? "" : a, o.phone = void 0 === r ? "" : r, window.natively.trigger(e, 3, n, "contacts_save", o) } } } class NativelyMediaPicker { constructor() { let e = generateID(); this.showMediaPicker = function (t) { window.natively.trigger(e, 8, t, "mediapicker", {}) } } } class NativelyAudioRecorder { constructor() { let e = generateID(); this.showRecorder = function (t, i) { let a = {}; a.max_duration = void 0 === t ? 0 : t, window.natively.trigger(e, 13, i, "record_start", a) } } } class NativelyAdmobBanner { constructor(e, t, i = !1, a, r = !1, n) { let o = generateID(), s = {}; window.natively.isAndroidApp ? s.unitId = void 0 === e.androidUnitId ? "ca-app-pub-3940256099942544/6300978111" : e.androidUnitId : window.natively.isIOSApp && (s.unitId = void 0 === e.iOSUnitId ? "ca-app-pub-3940256099942544/2934735716" : e.iOSUnitId), s.position = void 0 === e.position ? "BOTTOM" : e.position, s.sizeType = void 0 === e.sizeType ? "AUTO" : e.sizeType, s.width = void 0 === e.custom_width ? 320 : e.custom_width, s.height = void 0 === e.custom_height ? 50 : e.custom_height, window.natively.trigger(o, 14, function (e) { void 0 !== t && t(e), i && window.natively.trigger(o, 14, function (e) { void 0 !== a && a(e), r && window.natively.trigger(o, 14, n, "bannerad_show", {}) }, "bannerad_load", {}) }, "bannerad_setup", s), this.loadAd = function (e) { window.natively.trigger(o, 14, e, "bannerad_load", {}) }, this.showBanner = function (e) { window.natively.trigger(o, 14, e, "bannerad_show", {}) }, this.hideBanner = function (e) { window.natively.trigger(o, 14, e, "bannerad_hide", {}) }, this.bannerIsReady = function (e) { window.natively.trigger(o, 14, e, "bannerad_ready", {}) }, this.bannerIsVisible = function (e) { window.natively.trigger(o, 14, e, "bannerad_visible", {}) } } } class NativelyAdmobInterstitial { constructor(e = "ca-app-pub-3940256099942544/4411468910", t = "ca-app-pub-3940256099942544/1033173712", i, a = !1, r) { let n = generateID(), o; window.natively.isAndroidApp ? o = void 0 === t ? "ca-app-pub-3940256099942544/1033173712" : t : window.natively.isIOSApp && (o = void 0 === e ? "ca-app-pub-3940256099942544/4411468910" : e), this.loadAd = function (e) { let t = {}; t.unitId = void 0 === o ? "ca-app-pub-3940256099942544/4411468910" : o, window.natively.trigger(n, 14, e, "interstitialad_setup", t) }, this.showInterstitialAd = function (e) { window.natively.trigger(n, 14, function (t) { if (e(t), "DID_DISMISS_AD" === t.event && a) { let i = {}; i.unitId = o, setTimeout(() => { window.natively.trigger(n, 14, r, "interstitialad_setup", i) }, 500) } }, "interstitialad_show", {}) }, this.interstitialIsReady = function (e) { window.natively.trigger(n, 14, e, "interstitialad_ready", {}) }, this.loadAd(i) } } class NativelyNFCService { constructor(e, t, i, a) { let r = generateID(); this.readAlertMessage = e, this.writeAlertMessage = t, this.readDetectedMessage = i, this.writeDetectedMessage = a, this.read = function (e) { 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(r, 15, e, "nfc_read", t) }, this.write = function (e, t, i) { let a = {}; a.alertMessage = void 0 === this.writeAlertMessage ? "please set writeAlertMessage" : this.writeAlertMessage, a.detectedMessage = void 0 === this.writeDetectedMessage ? "please set writeDetectedMessage" : this.writeDetectedMessage, a.recordData = void 0 === t ? "please set recordData" : t, a.recordId = void 0 === e ? "please set recordId" : e, window.natively.trigger(r, 15, i, "nfc_write", a) }, this.available = function (e) { window.natively.trigger(r, 15, e, "nfc_available", {}) } } } class NativelyAppleSignInService { constructor() { let e = generateID(); this.signin = function (t) { window.natively.trigger(e, 16, t, "apple_signin", {}) } } } function generateID() { return Date.now().toString(36) + Math.random().toString(36).substring(2) } export { NativelyAdmobBanner, NativelyAdmobInterstitial, NativelyAppleSignInService, NativelyAudioRecorder, NativelyBiometrics, NativelyCamera, NativelyClipboard, NativelyContacts, NativelyDatePicker, NativelyGeolocation, NativelyHealth, NativelyInfo, NativelyLocation, NativelyMediaPicker, NativelyMessage, NativelyNFCService, NativelyNotifications, NativelyPagesCache, NativelyPurchases, NativelyScanner, NativelyStorage };
|