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