natively 2.14.0 → 2.15.2

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.
Files changed (65) hide show
  1. package/README.md +63 -5
  2. package/dist/classes/Natively.d.ts +22 -0
  3. package/dist/classes/Natively.js +139 -0
  4. package/dist/classes/NativelyAdmobBanner.d.ts +16 -0
  5. package/dist/classes/NativelyAdmobBanner.js +53 -0
  6. package/dist/classes/NativelyAdmobInterstitial.d.ts +17 -0
  7. package/dist/classes/NativelyAdmobInterstitial.js +54 -0
  8. package/dist/classes/NativelyAppleSignInService.d.ts +4 -0
  9. package/dist/classes/NativelyAppleSignInService.js +13 -0
  10. package/dist/classes/NativelyAudioRecorder.d.ts +4 -0
  11. package/dist/classes/NativelyAudioRecorder.js +16 -0
  12. package/dist/classes/NativelyBiometrics.d.ts +11 -0
  13. package/dist/classes/NativelyBiometrics.js +40 -0
  14. package/dist/classes/NativelyCamera.d.ts +4 -0
  15. package/dist/classes/NativelyCamera.js +18 -0
  16. package/dist/classes/NativelyClipboard.d.ts +5 -0
  17. package/dist/classes/NativelyClipboard.js +18 -0
  18. package/dist/classes/NativelyContacts.d.ts +5 -0
  19. package/dist/classes/NativelyContacts.js +22 -0
  20. package/dist/classes/NativelyDatePicker.d.ts +4 -0
  21. package/dist/classes/NativelyDatePicker.js +19 -0
  22. package/dist/classes/NativelyFirebaseNotifications.d.ts +9 -0
  23. package/dist/classes/NativelyFirebaseNotifications.js +32 -0
  24. package/dist/classes/NativelyGeolocation.d.ts +6 -0
  25. package/dist/classes/NativelyGeolocation.js +23 -0
  26. package/dist/classes/NativelyHealth.d.ts +8 -0
  27. package/dist/classes/NativelyHealth.js +40 -0
  28. package/dist/classes/NativelyInfo.d.ts +11 -0
  29. package/dist/classes/NativelyInfo.js +33 -0
  30. package/dist/classes/NativelyLocation.d.ts +10 -0
  31. package/dist/classes/NativelyLocation.js +47 -0
  32. package/dist/classes/NativelyMediaPicker.d.ts +4 -0
  33. package/dist/classes/NativelyMediaPicker.js +13 -0
  34. package/dist/classes/NativelyMessage.d.ts +5 -0
  35. package/dist/classes/NativelyMessage.js +25 -0
  36. package/dist/classes/NativelyNFCService.d.ts +11 -0
  37. package/dist/classes/NativelyNFCService.js +39 -0
  38. package/dist/classes/NativelyNotifications.d.ts +6 -0
  39. package/dist/classes/NativelyNotifications.js +21 -0
  40. package/dist/classes/NativelyPurchases.d.ts +9 -0
  41. package/dist/classes/NativelyPurchases.js +36 -0
  42. package/dist/classes/NativelyScanner.d.ts +4 -0
  43. package/dist/classes/NativelyScanner.js +13 -0
  44. package/dist/classes/NativelyStorage.d.ts +7 -0
  45. package/dist/classes/NativelyStorage.js +29 -0
  46. package/dist/events.d.ts +1 -0
  47. package/dist/events.js +7 -0
  48. package/dist/hooks/useNatively.d.ts +2 -0
  49. package/dist/hooks/useNatively.js +2 -0
  50. package/dist/index.d.ts +27 -0
  51. package/dist/index.js +34 -0
  52. package/dist/inject.d.ts +1 -0
  53. package/dist/inject.js +50 -0
  54. package/dist/types.d.ts +54 -0
  55. package/dist/types.js +1 -0
  56. package/dist/utils/generateID.d.ts +1 -0
  57. package/dist/utils/generateID.js +1 -0
  58. package/dist/utils/globalThis.d.ts +2 -0
  59. package/dist/utils/globalThis.js +25 -0
  60. package/natively-frontend.min.js +1 -1
  61. package/package.json +36 -7
  62. package/.vscode/settings.json +0 -13
  63. package/natively-frontend.js +0 -977
  64. package/natively-frontend.min.mjs +0 -1
  65. package/natively-frontend.mjs +0 -979
@@ -0,0 +1,54 @@
1
+ import { Natively } from "./classes/Natively";
2
+ import { NativelyAdmobBanner } from "./classes/NativelyAdmobBanner";
3
+ import { NativelyAdmobInterstitial } from "./classes/NativelyAdmobInterstitial";
4
+ import { NativelyAppleSignInService } from "./classes/NativelyAppleSignInService";
5
+ import { NativelyAudioRecorder } from "./classes/NativelyAudioRecorder";
6
+ import { NativelyBiometrics } from "./classes/NativelyBiometrics";
7
+ import { NativelyCamera } from "./classes/NativelyCamera";
8
+ import { NativelyClipboard } from "./classes/NativelyClipboard";
9
+ import { NativelyContacts } from "./classes/NativelyContacts";
10
+ import { NativelyDatePicker } from "./classes/NativelyDatePicker";
11
+ import { NativelyGeolocation } from "./classes/NativelyGeolocation";
12
+ import { NativelyHealth } from "./classes/NativelyHealth";
13
+ import { NativelyInfo } from "./classes/NativelyInfo";
14
+ import { NativelyLocation } from "./classes/NativelyLocation";
15
+ import { NativelyMediaPicker } from "./classes/NativelyMediaPicker";
16
+ import { NativelyMessage } from "./classes/NativelyMessage";
17
+ import { NativelyNFCService } from "./classes/NativelyNFCService";
18
+ import { NativelyNotifications } from "./classes/NativelyNotifications";
19
+ import { NativelyPurchases } from "./classes/NativelyPurchases";
20
+ import { NativelyScanner } from "./classes/NativelyScanner";
21
+ import { NativelyStorage } from "./classes/NativelyStorage";
22
+ import { NativelyFirebaseNotifications } from "./classes/NativelyFirebaseNotifications";
23
+ interface NativelyProps {
24
+ natively: Natively;
25
+ NativelyAdmobBanner: NativelyAdmobBanner;
26
+ NativelyAdmobInterstitial: NativelyAdmobInterstitial;
27
+ NativelyAppleSignInService: NativelyAppleSignInService;
28
+ NativelyAudioRecorder: NativelyAudioRecorder;
29
+ NativelyBiometrics: NativelyBiometrics;
30
+ NativelyCamera: NativelyCamera;
31
+ NativelyClipboard: NativelyClipboard;
32
+ NativelyContacts: NativelyContacts;
33
+ NativelyDatePicker: NativelyDatePicker;
34
+ NativelyGeolocation: NativelyGeolocation;
35
+ NativelyHealth: NativelyHealth;
36
+ NativelyInfo: NativelyInfo;
37
+ NativelyLocation: NativelyLocation;
38
+ NativelyMediaPicker: NativelyMediaPicker;
39
+ NativelyMessage: NativelyMessage;
40
+ NativelyNFCService: NativelyNFCService;
41
+ NativelyNotifications: NativelyNotifications;
42
+ NativelyPurchases: NativelyPurchases;
43
+ NativelyScanner: NativelyScanner;
44
+ NativelyStorage: NativelyStorage;
45
+ NativelyFirebaseNotifications: NativelyFirebaseNotifications;
46
+ $agent: never;
47
+ }
48
+ declare global {
49
+ const natively: Natively;
50
+ const $agent: never;
51
+ interface Window extends NativelyProps {
52
+ }
53
+ }
54
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const generateID: () => string;
@@ -0,0 +1 @@
1
+ export var generateID = () => Date.now().toString(36) + Math.random().toString(36).substring(2);
@@ -0,0 +1,2 @@
1
+ declare const globalContext: any;
2
+ export default globalContext;
@@ -0,0 +1,25 @@
1
+ function getGlobalContext() {
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-ignore
4
+ if (typeof globalThis !== 'undefined') {
5
+ return globalThis;
6
+ }
7
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
+ // @ts-ignore
9
+ if (typeof self !== 'undefined') {
10
+ return self;
11
+ }
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ if (typeof window !== 'undefined') {
15
+ return window;
16
+ }
17
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
+ // @ts-ignore
19
+ if (typeof global !== 'undefined') {
20
+ return global;
21
+ }
22
+ return null;
23
+ }
24
+ var globalContext = getGlobalContext();
25
+ export default globalContext;
@@ -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:()=>A,NativelyAdmobInterstitial:()=>w,NativelyAppleSignInService:()=>s,NativelyAudioRecorder:()=>N,NativelyBiometrics:()=>c,NativelyCamera:()=>h,NativelyClipboard:()=>n,NativelyContacts:()=>m,NativelyDatePicker:()=>y,NativelyFirebaseNotifications:()=>I,NativelyGeolocation:()=>d,NativelyHealth:()=>p,NativelyInfo:()=>r,NativelyLocation:()=>g,NativelyMediaPicker:()=>f,NativelyMessage:()=>u,NativelyNFCService:()=>S,NativelyNotifications:()=>o,NativelyPurchases:()=>b,NativelyScanner:()=>_,NativelyStorage:()=>v,generateID:()=>a,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,a;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===(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(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,a,s){const n=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))n&&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?a+"_response_"+i:a+"_response",t&&(t[e]=function(a,s){null==t||t.$agent.response(),s.message&&n?alert(`[ERROR] Error message: ${s.message}`):(n&&console.log(`[DEBUG] Callback method: ${e}, body: ${JSON.stringify(a)}, respId: ${i}`),l(a))}),s?s.response_id=i:s={response_id:i}}n&&console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(s)}`),null==t||t.$agent.trigger(a,s)}else null==t||t.natively.addObserver((()=>{null==t||t.natively.trigger(i,e,l,a,s)}))}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 a=()=>Date.now().toString(36)+Math.random().toString(36).substring(2);class s{constructor(){this.id=a()}signin(i){null==t||t.natively.trigger(this.id,16,i,"apple_signin",{})}}class n{constructor(){this.id=a()}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 r{constructor(){this.id=a()}browserInfo(){var i,e,l,a;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===(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(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=a()}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=a()}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=a()}current(i,e,l,a){null==t||t.natively.trigger(this.id,12,a,"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,a,s){null==t||t.natively.trigger(this.id,12,s,"location_start",{minAccuracy:e,accuracyType:l,priority:a,interval:i})}stop(){null==t||t.natively.trigger(this.id,3,void 0,"location_stop",{})}startBackground(i,e,l,a,s,n){const r={identifier:null!=s?s:"empty",interval:null!=i?i:6e4,minAccuracy:null!=e?e:50,accuracyType:null!=l?l:"Best",priority:null!=a?a:"BALANCED"};null==t||t.natively.trigger(this.id,12,n,"location_start_bg",r)}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=a()}sendSMS(i,e,l){const a={body:null!=i?i:"",recipient:null!=e?e:""};null==t||t.natively.trigger(this.id,0,l,"send_sms",a)}sendEmail(i,e,l,a){const s={subject:null!=i?i:"",body:null!=e?e:"",recipient:null!=l?l:""};null==t||t.natively.trigger(this.id,0,a,"send_email",s)}}class v{constructor(){this.id=a()}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=a(),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=a()}showDatePicker(i,e,l,a,s){const n={type:null!=l?l:"DATE",style:null!=a?a:"LIGHT",title:null!=i?i:"",description:null!=e?e:""};null==t||t.natively.trigger(this.id,0,s,"datepicker",n)}}class h{constructor(){this.id=a()}showCamera(i,e,l,a){const s={type:null!=i?i:"photo",quality:null!=e?e:"high",camera:null!=l?l:"BACK"};null==t||t.natively.trigger(this.id,2,a,"open_camera",s)}}class p{constructor(){this.id=a()}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,a,s){const n={data_type:i,interval:e};l&&(n.start_date=l.getTime()),a&&(n.end_date=a.getTime()),null==t||t.natively.trigger(this.id,10,s,"health_get_statistic_quantity",n)}}class _{constructor(){this.id=a()}showScanner(i){null==t||t.natively.trigger(this.id,2,i,"open_scanner",{})}}class b{constructor(){this.id=a()}login(i,e,l){const a=null!=e?e:"";null==t||t.natively.trigger(this.id,3,l,"purchases_login",{login:i,email:a})}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=a()}getAllContacts(i){null==t||t.natively.trigger(this.id,3,i,"contacts_all",{})}createContact(i,e,l,a,s){const n={firstName:i,lastName:null!=e?e:"",email:null!=l?l:"",phone:null!=a?a:""};null==t||t.natively.trigger(this.id,3,s,"contacts_save",n)}}class f{constructor(){this.id=a()}showMediaPicker(i){null==t||t.natively.trigger(this.id,8,i,"mediapicker",{})}}class N{constructor(){this.id=a()}showRecorder(i,e){const l={max_duration:null!=i?i:0};null==t||t.natively.trigger(this.id,13,e,"record_start",l)}}class A{constructor(i,e,l=!1,s,n=!1,r){var o,d,g,u,v,c;this.id=a();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==s||s(i),n&&(null==t||t.natively.trigger(this.id,14,r,"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 w{constructor(i="ca-app-pub-3940256099942544/4411468910",e="ca-app-pub-3940256099942544/1033173712",l,s=!1,n){this.id=a(),(null==t?void 0:t.natively.isAndroidApp)?this.unitId=e:(null==t?void 0:t.natively.isIOSApp)&&(this.unitId=i),this.auto_ad_reload=s,this.auto_ad_reload_callback=n,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 S{constructor(i,e,t,l){this.id=a(),this.readAlertMessage=i,this.writeAlertMessage=e,this.readDetectedMessage=t,this.writeDetectedMessage=l}read(i){var e,l;const a={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",a)}write(i,e,l){var a,s;const n={alertMessage:null!==(a=this.writeAlertMessage)&&void 0!==a?a:"please set writeAlertMessage",detectedMessage:null!==(s=this.writeDetectedMessage)&&void 0!==s?s:"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",n)}available(i){null==t||t.natively.trigger(this.id,15,i,"nfc_available",{})}}class I{constructor(){this.id=a()}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,t.NativelyAdmobBanner=A,t.NativelyAdmobInterstitial=w,t.NativelyAppleSignInService=s,t.NativelyAudioRecorder=N,t.NativelyBiometrics=c,t.NativelyCamera=h,t.NativelyClipboard=n,t.NativelyContacts=m,t.NativelyDatePicker=y,t.NativelyGeolocation=d,t.NativelyHealth=p,t.NativelyInfo=r,t.NativelyLocation=g,t.NativelyMediaPicker=f,t.NativelyMessage=u,t.NativelyNFCService=S,t.NativelyNotifications=o,t.NativelyPurchases=b,t.NativelyScanner=_,t.NativelyStorage=v,t.NativelyFirebaseNotifications=I),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.14.0",
4
- "description": "",
5
- "main": "natively-frontend.min.mjs",
3
+ "version": "2.15.2",
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": "rollup -c && terser natively-frontend.mjs -o natively-frontend.min.mjs",
9
- "test": "echo \"Error: no test specified\" && exit 1"
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
  }
@@ -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
-