extract React Native dependencies

This commit is contained in:
Roman Volosovskyi 2017-07-16 12:04:35 +03:00
parent bd80c814c9
commit 23399c63e1
65 changed files with 409 additions and 321 deletions

5
Jenkinsfile vendored
View File

@ -20,6 +20,11 @@ node {
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack' sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..' sh 'cd ios && pod install && cd ..'
} }
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') { stage('Build') {
sh 'lein prod-build' sh 'lein prod-build'
} }

View File

@ -17,12 +17,12 @@
[lein-re-frisk "0.4.7"] [lein-re-frisk "0.4.7"]
[rasom/lein-externs "0.1.7"]] [rasom/lein-externs "0.1.7"]]
:clean-targets ["target/" "index.ios.js" "index.android.js"] :clean-targets ["target/" "index.ios.js" "index.android.js"]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."} :aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean" ["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"] ["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]] ["with-profile" "prod" "cljsbuild" "once" "android"]]
"generate-externs" ["with-profile" "prod" "externs" "android" "externs/externs.js"] "generate-externs" ["with-profile" "prod" "externs" "android" "externs/externs.js"]
"test" ["doo" "phantom" "test" "once"]} "test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]}
:test-paths ["test/clj"] :test-paths ["test/clj"]
:figwheel {:nrepl-port 7888} :figwheel {:nrepl-port 7888}
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.11"] :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.11"]
@ -31,34 +31,37 @@
[com.cemerick/piggieback "0.2.1"] [com.cemerick/piggieback "0.2.1"]
[io.appium/java-client "3.4.1"] [io.appium/java-client "3.4.1"]
[hawk "0.2.10"]] [hawk "0.2.10"]]
:plugins [[lein-doo "0.1.7"]]
:source-paths ["src" "env/dev"] :source-paths ["src" "env/dev"]
:cljsbuild {:builds :cljsbuild {:builds
{:ios {:ios
{:source-paths ["src" "env/dev"] {:source-paths ["react-native/src" "src" "env/dev"]
:figwheel true :figwheel true
:compiler {:output-to "target/ios/app.js" :compiler {:output-to "target/ios/app.js"
:main "env.ios.main" :main "env.ios.main"
:output-dir "target/ios" :output-dir "target/ios"
:optimizations :none}} :optimizations :none}}
:android :android
{:source-paths ["src" "env/dev"] {:source-paths ["react-native/src" "src" "env/dev"]
:figwheel true :figwheel true
:compiler {:output-to "target/android/app.js" :compiler {:output-to "target/android/app.js"
:main "env.android.main" :main "env.android.main"
:output-dir "target/android" :output-dir "target/android"
:optimizations :none}}
:test
{:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target"
:optimizations :none}}}} :optimizations :none}}}}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl] :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]
:timeout 240000}} :timeout 240000}}
:test {:plugins [[lein-doo "0.1.7"]]
:cljsbuild {:builds
[{:id "test"
:source-paths ["src" "test/cljs"]
:compiler
{:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}]}}
:prod {:cljsbuild {:builds :prod {:cljsbuild {:builds
{:ios {:ios
{:source-paths ["src" "env/prod"] {:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.ios.js" :compiler {:output-to "index.ios.js"
:main "env.ios.main" :main "env.ios.main"
:output-dir "target/ios-prod" :output-dir "target/ios-prod"
@ -67,9 +70,9 @@
:optimizations :advanced :optimizations :advanced
:externs ["externs/externs.js"] :externs ["externs/externs.js"]
:closure-defines {"goog.DEBUG" false} :closure-defines {"goog.DEBUG" false}
:parallel-build true}} :parallel-build true}}
:android :android
{:source-paths ["src" "env/prod"] {:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.android.js" :compiler {:output-to "index.android.js"
:main "env.android.main" :main "env.android.main"
:output-dir "target/android-prod" :output-dir "target/android-prod"
@ -78,4 +81,4 @@
:optimizations :advanced :optimizations :advanced
:externs ["externs/externs.js"] :externs ["externs/externs.js"]
:closure-defines {"goog.DEBUG" false} :closure-defines {"goog.DEBUG" false}
:parallel-build true}}}}}}) :parallel-build true}}}}}})

View File

@ -0,0 +1,5 @@
(ns cljsjs.react
(:require [status-im.react-native.js-dependencies :as rn-dependencies]))
(when (exists? js/window)
(set! js/ReactNative rn-dependencies/react-native))

View File

@ -0,0 +1,35 @@
(ns status-im.react-native.js-dependencies)
(def action-button (js/require "react-native-action-button"))
(def android-sms-listener (js/require "react-native-android-sms-listener"))
(def autolink (js/require "react-native-autolink"))
(def camera (js/require "react-native-camera"))
(def circle-checkbox (js/require "react-native-circle-checkbox"))
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
(def contacts (js/require "react-native-contacts"))
(def dialogs (js/require "react-native-dialogs"))
(def dismiss-keyboard (js/require "dismissKeyboard"))
(def drawer (js/require "react-native-drawer-layout"))
(def emoji-picker (js/require "react-native-emoji-picker"))
(def fs (js/require "react-native-fs"))
(def http-bridge (js/require "react-native-http-bridge"))
(def i18n (js/require "react-native-i18n"))
(def image-crop-picker (js/require "react-native-image-crop-picker"))
(def image-resizer (js/require "react-native-image-resizer"))
(def instabug (js/require "instabug-reactnative"))
(def invertible-scroll-view (js/require "react-native-invertible-scroll-view"))
(def linear-gradient (js/require "react-native-linear-gradient"))
(def mapbox-gl (js/require "react-native-mapbox-gl"))
(def nfc (js/require "nfc-react-native"))
(def orientation (js/require "react-native-orientation"))
(def popup-menu (js/require "react-native-popup-menu"))
(def qr-code (js/require "react-native-qrcode"))
(def random-bytes (js/require "react-native-randombytes"))
(def react-native (js/require "react-native"))
(def realm (js/require "realm"))
(def sortable-listview (js/require "react-native-sortable-listview"))
(def swiper (js/require "react-native-swiper"))
(def vector-icons (js/require "react-native-vector-icons/Ionicons"))
(def webview-bridge (js/require "react-native-webview-bridge"))

View File

@ -0,0 +1,29 @@
(ns status-im.react-native.resources)
(def add-icon (js/require "./images/add.png"))
(def att (js/require "./images/att.png"))
(def chat-icon (js/require "./images/chat.png"))
(def icon-close-gray (js/require "./images/icon_close_gray.png"))
(def logo-icon (js/require "./images/logo.png"))
(def nav-back-icon (js/require "./images/nav-back.png"))
(def user-no-photo (js/require "./images/no-photo.png"))
(def online-icon (js/require "./images/online.png"))
(def play (js/require "./images/play.png"))
(def trash-icon (js/require "./images/trash.png"))
(def v (js/require "./images/v.png"))
(def contacts
{:auction-house (js/require "./images/contacts/auction-house.png")
:mkr-market (js/require "./images/contacts/mkr-market.png")
:oaken-water-meter (js/require "./images/contacts/oaken-water-meter.png")
:flight-delays-suck (js/require "./images/contacts/flight-delays-suck.png")
:jarrad (js/require "./images/contacts/jarrad.png")
:firstblood (js/require "./images/contacts/FirstBlood.png")
:gnosis (js/require "./images/contacts/gnosis.png")
:melonport (js/require "./images/contacts/melonport.png")
:bchat (js/require "./images/contacts/bchat.png")
:dentacoin (js/require "./images/contacts/Dentacoin.png")
:augur (js/require "./images/contacts/augur.png")
:ethlance (js/require "./images/contacts/ethlance.png")
:commiteth (js/require "./images/contacts/commiteth.png")
:etherplay (js/require "./images/contacts/etherplay.png")})

View File

@ -1,4 +0,0 @@
(ns cljsjs.react)
(when (exists? js/window)
(set! js/ReactNative (js/require "react-native")))

View File

@ -1,5 +1,6 @@
(ns status-im.android.platform (ns status-im.android.platform
(:require [status-im.components.styles :as styles])) (:require [status-im.components.styles :as styles]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def component-styles (def component-styles
{:status-bar {:default {:height 25 {:status-bar {:default {:height 25
@ -59,10 +60,8 @@
;; Dialogs ;; Dialogs
(def react-native-dialogs (js/require "react-native-dialogs"))
(defn show-dialog [{:keys [title options callback]}] (defn show-dialog [{:keys [title options callback]}]
(let [dialog (new react-native-dialogs)] (let [dialog (new rn-dependencies/dialogs)]
(.set dialog (clj->js {:title title (.set dialog (clj->js {:title title
:items (mapv :text options) :items (mapv :text options)
:itemsCallback callback})) :itemsCallback callback}))

View File

@ -14,8 +14,6 @@
[cljs.reader :refer [read-string]] [cljs.reader :refer [read-string]]
[status-im.navigation.handlers :as nav])) [status-im.navigation.handlers :as nav]))
(def web3 (js/require "web3"))
(defn by-public-key [public-key contacts] (defn by-public-key [public-key contacts]
(when-let [{:keys [address]} (contacts public-key)] (when-let [{:keys [address]} (contacts public-key)]
(when address {:address address}))) (when address {:address address})))

View File

@ -8,6 +8,7 @@
[status-im.utils.phone-number :as phone-number] [status-im.utils.phone-number :as phone-number]
[status-im.chat.utils :as chat-utils] [status-im.chat.utils :as chat-utils]
[status-im.bots.constants :as bots-constants] [status-im.bots.constants :as bots-constants]
[status-im.js-dependencies :as dependencies]
[taoensso.timbre :as log])) [taoensso.timbre :as log]))
(defn text->emoji (defn text->emoji
@ -17,7 +18,7 @@
(str/replace text (str/replace text
#":([a-z_\-+0-9]*):" #":([a-z_\-+0-9]*):"
(fn [[original emoji-id]] (fn [[original emoji-id]]
(if-let [emoji-map (aget rc/emojilib "lib" emoji-id)] (if-let [emoji-map (aget dependencies/emojis "lib" emoji-id)]
(aget emoji-map "char") (aget emoji-map "char")
original))))) original)))))
@ -266,4 +267,4 @@
(proceed) (proceed)
(set-errors [validation-message (set-errors [validation-message
{:title (i18n/label :t/phone-number) {:title (i18n/label :t/phone-number)
:description (i18n/label :t/invalid-phone)}])))) :description (i18n/label :t/invalid-phone)}]))))

View File

@ -23,7 +23,7 @@
[status-im.chat.views.message.datemark :refer [chat-datemark]] [status-im.chat.views.message.datemark :refer [chat-datemark]]
[status-im.models.commands :refer [parse-command-message-content [status-im.models.commands :refer [parse-command-message-content
parse-command-request]] parse-command-request]]
[status-im.resources :as res] [status-im.react-native.resources :as res]
[status-im.constants :refer [console-chat-id [status-im.constants :refer [console-chat-id
wallet-chat-id wallet-chat-id
text-content-type text-content-type

View File

@ -1,13 +1,13 @@
(ns status-im.components.camera (ns status-im.components.camera
(:require [reagent.core :as r] (:require [reagent.core :as r]
[clojure.walk :refer [keywordize-keys]] [clojure.walk :refer [keywordize-keys]]
[status-im.utils.platform :as platform])) [status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as rn-dependecies]))
(def camera-class (js/require "react-native-camera")) (def default-camera (.-default rn-dependecies/camera))
(def camera-default (.-default camera-class))
(defn constants [t] (defn constants [t]
(-> (aget camera-default "constants" t) (-> (aget rn-dependecies/camera "constants" t)
(js->clj) (js->clj)
(keywordize-keys))) (keywordize-keys)))
@ -17,9 +17,9 @@
(defn request-access [callback] (defn request-access [callback]
(if platform/android? (if platform/android?
(callback true) (callback true)
(-> (.checkVideoAuthorizationStatus camera-default) (-> (.checkVideoAuthorizationStatus default-camera)
(.then #(callback %)) (.then #(callback %))
(.catch #(callback false))))) (.catch #(callback false)))))
(defn camera [props] (defn camera [props]
(r/create-element camera-default (clj->js (merge {:inverted true} props)))) (r/create-element default-camera (clj->js (merge {:inverted true} props))))

View File

@ -6,11 +6,12 @@
text]] text]]
[status-im.components.carousel.styles :as st] [status-im.components.carousel.styles :as st]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.components.react :as r])) [status-im.components.react :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn window-page-width [] (defn window-page-width []
(.-width (.get (.. r/react-native -Dimensions) "window"))) (.-width (.get (.. rn-dependencies/react-native -Dimensions) "window")))
(def defaults {:gap 8 (def defaults {:gap 8
:sneak 8 :sneak 8

View File

@ -7,7 +7,7 @@
icon]] icon]]
[status-im.components.chat-icon.styles :as st] [status-im.components.chat-icon.styles :as st]
[status-im.components.styles :refer [default-chat-color]] [status-im.components.styles :refer [default-chat-color]]
[status-im.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.constants :refer [console-chat-id]] [status-im.constants :refer [console-chat-id]]
[clojure.string :as s])) [clojure.string :as s]))
@ -159,4 +159,4 @@
edit? :edit?}] edit? :edit?}]
(let [color default-chat-color (let [color default-chat-color
size (if edit? 70 56)] size (if edit? 70 56)]
[profile-icon-view photo-path name color edit? size])) [profile-icon-view photo-path name color edit? size]))

View File

@ -4,12 +4,11 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific ios?]] [status-im.utils.platform :refer [platform-specific ios?]]
[re-frame.core :refer [dispatch]] [re-frame.core :refer [dispatch]]
[status-im.components.react :refer [view touchable-highlight text]])) [status-im.components.react :refer [view touchable-highlight text]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def react-native-popup-menu (js/require "react-native-popup-menu"))
(defn get-property [name] (defn get-property [name]
(aget react-native-popup-menu name)) (aget rn-dependencies/popup-menu name))
(defn adapt-class [class] (defn adapt-class [class]
(when class (when class

View File

@ -1,5 +1,6 @@
(ns status-im.components.icons.custom-icons (ns status-im.components.icons.custom-icons
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def ion-icon (def ion-icon
(r/adapt-react-class (.-default (js/require "react-native-vector-icons/Ionicons")))) (r/adapt-react-class (.-default rn-dependencies/vector-icons)))

View File

@ -1,8 +1,8 @@
(ns status-im.components.invertible-scroll-view (ns status-im.components.invertible-scroll-view
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def class (js/require "react-native-invertible-scroll-view"))
(defn invertible-scroll-view [props] (defn invertible-scroll-view [props]
(r/create-element class (clj->js (merge {:inverted true} props)))) (r/create-element rn-dependencies/invertible-scroll-view
(clj->js (merge {:inverted true} props))))

View File

@ -1,5 +1,6 @@
(ns status-im.components.item-checkbox (ns status-im.components.item-checkbox
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def item-checkbox (r/adapt-react-class (js/require "react-native-circle-checkbox"))) (def item-checkbox rn-dependencies/camera)

View File

@ -4,12 +4,11 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific ios?]] [status-im.utils.platform :refer [platform-specific ios?]]
[re-frame.core :refer [dispatch]] [re-frame.core :refer [dispatch]]
[status-im.components.react :refer [view touchable-highlight text]])) [status-im.components.react :refer [view touchable-highlight text]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def react-native-mapbox-gl (js/require "react-native-mapbox-gl"))
(defn get-property [name] (defn get-property [name]
(aget react-native-mapbox-gl name)) (aget rn-dependencies/mapbox-gl name))
(defn adapt-class [class] (defn adapt-class [class]
(when class (when class
@ -18,6 +17,6 @@
(defn get-class [name] (defn get-class [name]
(adapt-class (get-property name))) (adapt-class (get-property name)))
(.setAccessToken react-native-mapbox-gl "pk.eyJ1Ijoic3RhdHVzaW0iLCJhIjoiY2oydmtnZjRrMDA3czMzcW9kemR4N2lxayJ9.Rz8L6xdHBjfO8cR3CDf3Cw") (.setAccessToken rn-dependencies/mapbox-gl "pk.eyJ1Ijoic3RhdHVzaW0iLCJhIjoiY2oydmtnZjRrMDA3czMzcW9kemR4N2lxayJ9.Rz8L6xdHBjfO8cR3CDf3Cw")
(def mapview (get-class "MapView")) (def mapview (get-class "MapView"))

View File

@ -1,7 +1,10 @@
(ns status-im.components.native-action-button (ns status-im.components.native-action-button
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def class (js/require "react-native-action-button")) (def native-action-button
(r/adapt-react-class (.-default rn-dependencies/action-button)))
(def native-action-button (r/adapt-react-class (.-default class)))
(def native-action-button-item (r/adapt-react-class (.. class -default -Item))) (def native-action-button-item
(r/adapt-react-class (.. rn-dependencies/action-button -default -Item)))

View File

@ -1,30 +1,27 @@
(ns status-im.components.nfc (ns status-im.components.nfc
(:require [cljs.spec.alpha :as s] (:require [cljs.spec.alpha :as s]
[status-im.utils.platform :as platform])) [status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def class
(when platform/android?
(js/require "nfc-react-native")))
(def android-only-error "NFC API is available only on Android") (def android-only-error "NFC API is available only on Android")
(defn get-card-id [on-success on-error] (defn get-card-id [on-success on-error]
(if platform/android? (if platform/android?
(-> (.getCardId class) (-> (.getCardId rn-dependencies/nfc)
(.then on-success) (.then on-success)
(.catch on-error)) (.catch on-error))
(on-error android-only-error))) (on-error android-only-error)))
(defn read-tag [sectors on-success on-error] (defn read-tag [sectors on-success on-error]
(if platform/android? (if platform/android?
(-> (.readTag class (clj->js sectors)) (-> (.readTag rn-dependencies/nfc (clj->js sectors))
(.then on-success) (.then on-success)
(.catch on-error)) (.catch on-error))
(on-error android-only-error))) (on-error android-only-error)))
(defn write-tag [sectors card-id on-success on-error] (defn write-tag [sectors card-id on-success on-error]
(if platform/android? (if platform/android?
(-> (.writeTag class (clj->js sectors) card-id) (-> (.writeTag rn-dependencies/nfc (clj->js sectors) card-id)
(.then on-success) (.then on-success)
(.catch on-error)) (.catch on-error))
(on-error android-only-error))) (on-error android-only-error)))

View File

@ -1,8 +1,9 @@
(ns status-im.components.permissions (ns status-im.components.permissions
(:require [status-im.utils.platform :as platform] (:require [status-im.utils.platform :as platform]
[taoensso.timbre :as log])) [taoensso.timbre :as log]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def permissions-class (.-PermissionsAndroid js/ReactNative)) (def permissions-class (.-PermissionsAndroid rn-dependencies/react-native))
(def permissions-map (def permissions-map
{:read-external-storage "android.permission.READ_EXTERNAL_STORAGE" {:read-external-storage "android.permission.READ_EXTERNAL_STORAGE"

View File

@ -1,9 +1,8 @@
(ns status-im.components.qr-code (ns status-im.components.qr-code
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def class (js/require "react-native-qrcode"))
(defn qr-code [props] (defn qr-code [props]
(r/create-element (r/create-element
class rn-dependencies/qr-code
(clj->js (merge {:inverted true} props)))) (clj->js (merge {:inverted true} props))))

View File

@ -1,18 +1,29 @@
(ns status-im.components.react (ns status-im.components.react
(:require [reagent.core :as r] (:require [reagent.core :as r]
[status-im.components.styles :as st] [status-im.components.styles :as st]
[status-im.utils.utils :as u [status-im.utils.utils :as u]
:refer [get-react-property get-class adapt-class]]
[status-im.utils.platform :refer [platform-specific ios?]] [status-im.utils.platform :refer [platform-specific ios?]]
[status-im.i18n :as i18n])) [status-im.i18n :as i18n]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def react-native (js/require "react-native")) (defn get-react-property [name]
(def native-modules (.-NativeModules react-native)) (if rn-dependencies/react-native
(def device-event-emitter (.-DeviceEventEmitter react-native)) (aget rn-dependencies/react-native name)
(def dismiss-keyboard! (js/require "dismissKeyboard")) #js {}))
(def orientation (js/require "react-native-orientation"))
(defn adapt-class [class]
(when class
(r/adapt-react-class class)))
(defn get-class [name]
(adapt-class (get-react-property name)))
(def native-modules (.-NativeModules rn-dependencies/react-native))
(def device-event-emitter (.-DeviceEventEmitter rn-dependencies/react-native))
(def dismiss-keyboard! rn-dependencies/dismiss-keyboard)
(def orientation rn-dependencies/orientation)
(def back-android (get-react-property "BackAndroid")) (def back-android (get-react-property "BackAndroid"))
(def drawer (js/require "react-native-drawer-layout")) (def drawer rn-dependencies/drawer)
(def splash-screen (.-SplashScreen native-modules)) (def splash-screen (.-SplashScreen native-modules))
@ -20,6 +31,7 @@
(def app-registry (get-react-property "AppRegistry")) (def app-registry (get-react-property "AppRegistry"))
(def app-state (get-react-property "AppState")) (def app-state (get-react-property "AppState"))
(def net-info (get-react-property "NetInfo"))
(def navigator (get-class "Navigator")) (def navigator (get-class "Navigator"))
(def view (get-class "View")) (def view (get-class "View"))
@ -43,14 +55,14 @@
(def modal (get-class "Modal")) (def modal (get-class "Modal"))
(def picker (get-class "Picker")) (def picker (get-class "Picker"))
(def pan-responder (.-PanResponder js/ReactNative)) (def pan-responder (.-PanResponder rn-dependencies/react-native))
(def animated (.-Animated js/ReactNative)) (def animated (.-Animated rn-dependencies/react-native))
(def animated-view (r/adapt-react-class (.-View animated))) (def animated-view (r/adapt-react-class (.-View animated)))
(def animated-text (r/adapt-react-class (.-Text animated))) (def animated-text (r/adapt-react-class (.-Text animated)))
(def dimensions (.-Dimensions js/ReactNative)) (def dimensions (.-Dimensions rn-dependencies/react-native))
(def keyboard (.-Keyboard react-native)) (def keyboard (.-Keyboard rn-dependencies/react-native))
(def linking (.-Linking js/ReactNative)) (def linking (.-Linking rn-dependencies/react-native))
(def slider (get-class "Slider")) (def slider (get-class "Slider"))
;; Accessor methods for React Components ;; Accessor methods for React Components
@ -108,17 +120,17 @@
(defn get-dimensions [name] (defn get-dimensions [name]
(js->clj (.get dimensions name) :keywordize-keys true)) (js->clj (.get dimensions name) :keywordize-keys true))
(def gradient (adapt-class (.-default rn-dependencies/linear-gradient)))
(defn linear-gradient [props] (defn linear-gradient [props]
(let [class (js/require "react-native-linear-gradient") [gradient props])
gradient (adapt-class (.-default class))]
[gradient props]))
(defn list-item [component] (defn list-item [component]
(r/as-element component)) (r/as-element component))
;; Image picker ;; Image picker
(def image-picker-class (js/require "react-native-image-crop-picker")) (def image-picker-class rn-dependencies/image-crop-picker)
(defn show-access-error [o] (defn show-access-error [o]
(when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (aget o "code")) ; Do not show error when user cancel selection (when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (aget o "code")) ; Do not show error when user cancel selection
@ -132,19 +144,19 @@
(.then images-fn) (.then images-fn)
(.catch show-access-error)))) (.catch show-access-error))))
(def swiper (adapt-class (js/require "react-native-swiper"))) (def swiper (adapt-class rn-dependencies/swiper))
;; Clipboard ;; Clipboard
(def sharing (def sharing
(.-Share js/ReactNative)) (.-Share rn-dependencies/react-native))
(defn copy-to-clipboard [text] (defn copy-to-clipboard [text]
(.setString (.-Clipboard react-native) text)) (.setString (.-Clipboard rn-dependencies/react-native) text))
;; Emoji ;; Emoji
(def emoji-picker-class (js/require "react-native-emoji-picker")) (def emoji-picker-class rn-dependencies/emoji-picker)
(def emoji-picker (def emoji-picker
(let [emoji-picker (.-default emoji-picker-class)] (let [emoji-picker (.-default emoji-picker-class)]
@ -152,7 +164,7 @@
;; Autolink ;; Autolink
(def autolink-class (r/adapt-react-class (.-default (js/require "react-native-autolink")))) (def autolink-class (r/adapt-react-class (.-default rn-dependencies/autolink)))
(defn autolink [opts] (defn autolink [opts]
(r/as-element (r/as-element
@ -160,8 +172,7 @@
;; HTTP Bridge ;; HTTP Bridge
(def http-bridge (def http-bridge rn-dependencies/http-bridge)
(js/require "react-native-http-bridge"))
;; KeyboardAvoidingView ;; KeyboardAvoidingView

View File

@ -2,12 +2,14 @@
(:require [reagent.core :as r] (:require [reagent.core :as r]
[status-im.components.react :refer [view [status-im.components.react :refer [view
touchable-highlight touchable-highlight
list-item]])) list-item]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def sortable-list-view-class (r/adapt-react-class (js/require "react-native-sortable-listview"))) (def sortable-listview-class
(r/adapt-react-class rn-dependencies/sortable-listview))
(defn sortable-list-view [{:keys [on-row-moved render-row] :as props}] (defn sortable-list-view [{:keys [on-row-moved render-row] :as props}]
[sortable-list-view-class [sortable-listview-class
(assoc props :on-row-moved #(on-row-moved (js->clj % :keywordize-keys true)) (assoc props :on-row-moved #(on-row-moved (js->clj % :keywordize-keys true))
:render-row #(render-row (js->clj % :keywordize-keys true)))]) :render-row #(render-row (js->clj % :keywordize-keys true)))])
@ -17,4 +19,4 @@
inner]]) inner]])
(defn sortable-item [inner] (defn sortable-item [inner]
(list-item [touchable inner])) (list-item [touchable inner]))

View File

@ -7,9 +7,9 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[cljs.core.async :refer [<! timeout]] [cljs.core.async :refer [<! timeout]]
[status-im.utils.js-resources :as js-res] [status-im.utils.js-resources :as js-res]
[status-im.i18n :as i]
[status-im.utils.platform :as p] [status-im.utils.platform :as p]
[status-im.utils.scheduler :as scheduler])) [status-im.utils.scheduler :as scheduler]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn cljs->json [data] (defn cljs->json [data]
(.stringify js/JSON (clj->js data))) (.stringify js/JSON (clj->js data)))
@ -48,11 +48,11 @@
(recur (<! (timeout 500)))))) (recur (<! (timeout 500))))))
(def status (def status
(when (exists? (.-NativeModules r/react-native)) (when (exists? (.-NativeModules rn-dependencies/react-native))
(.-Status (.-NativeModules r/react-native)))) (.-Status (.-NativeModules rn-dependencies/react-native))))
(defn init-jail [] (defn init-jail []
(let [init-js (str js-res/status-js "I18n.locale = '" i/i18n.locale "';")] (let [init-js (str js-res/status-js "I18n.locale = '" rn-dependencies/i18n.locale "';")]
(.initJail status init-js #(log/debug "jail initialized")))) (.initJail status init-js #(log/debug "jail initialized"))))
(defonce listener-initialized (atom false)) (defonce listener-initialized (atom false))
@ -145,7 +145,7 @@
(log/debug :call-jail :params params) (log/debug :call-jail :params params)
(let [params' (update params :context assoc (let [params' (update params :context assoc
:debug js/goog.DEBUG :debug js/goog.DEBUG
:locale i/i18n.locale) :locale rn-dependencies/i18n.locale)
cb (fn [r] cb (fn [r]
(let [{:keys [result] :as r'} (t/json->clj r) (let [{:keys [result] :as r'} (t/json->clj r)
{:keys [messages]} result] {:keys [messages]} result]

View File

@ -2,8 +2,7 @@
(:require [clojure.string :as s] (:require [clojure.string :as s]
[re-frame.core :refer [subscribe dispatch dispatch-sync]] [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[reagent.core :as r] [reagent.core :as r]
[status-im.components.react :refer [react-native [status-im.components.react :refer [view
view
text text
animated-text animated-text
animated-view animated-view

View File

@ -1,8 +1,9 @@
(ns status-im.components.webview-bridge (ns status-im.components.webview-bridge
(:require [reagent.core :as r])) (:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def webview-bridge-class (def webview-bridge-class
(r/adapt-react-class (.-default (js/require "react-native-webview-bridge")))) (r/adapt-react-class (.-default rn-dependencies/webview-bridge)))
(defn webview-bridge [opts] (defn webview-bridge [opts]
[webview-bridge-class opts]) [webview-bridge-class opts])

View File

@ -8,13 +8,13 @@
[status-im.utils.utils :refer [http-post]] [status-im.utils.utils :refer [http-post]]
[status-im.utils.phone-number :refer [format-phone-number]] [status-im.utils.phone-number :refer [format-phone-number]]
[status-im.utils.handlers :as u] [status-im.utils.handlers :as u]
[status-im.utils.utils :refer [require]]
[status-im.navigation.handlers :as nav] [status-im.navigation.handlers :as nav]
[status-im.utils.random :as random] [status-im.utils.random :as random]
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[cljs.reader :refer [read-string]] [cljs.reader :refer [read-string]]
[status-im.utils.js-resources :as js-res])) [status-im.utils.js-resources :as js-res]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defmethod nav/preload-data! :group-contacts (defmethod nav/preload-data! :group-contacts
[db [_ _ group show-search?]] [db [_ _ group show-search?]]
@ -122,9 +122,6 @@
(register-handler :load-contacts load-contacts!) (register-handler :load-contacts load-contacts!)
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
(def react-native-contacts (js/require "react-native-contacts"))
(defn contact-name [contact] (defn contact-name [contact]
(->> contact (->> contact
((juxt :givenName :middleName :familyName)) ((juxt :givenName :middleName :familyName))
@ -140,7 +137,7 @@
(defn fetch-contacts-from-phone! (defn fetch-contacts-from-phone!
[_ _] [_ _]
(.getAll react-native-contacts (.getAll rn-dependencies/contacts
(fn [error contacts] (fn [error contacts]
(if error (if error
(log/debug :error-on-fetching-loading error) (log/debug :error-on-fetching-loading error)

View File

@ -3,7 +3,6 @@
[clojure.string :as str] [clojure.string :as str]
[status-im.data-store.contacts :as contacts])) [status-im.data-store.contacts :as contacts]))
(def web3 (js/require "web3"))
(defn is-address? [s] (defn is-address? [s]
(.isAddress web3.prototype s)) (.isAddress web3.prototype s))

View File

@ -14,7 +14,7 @@
[status-im.components.toolbar.styles :refer [toolbar-title-container [status-im.components.toolbar.styles :refer [toolbar-title-container
toolbar-title-text toolbar-title-text
toolbar-background1]] toolbar-background1]]
[status-im.utils.utils :refer [log http-post]] [status-im.utils.utils :refer [http-post]]
[status-im.components.styles :refer [icon-ok [status-im.components.styles :refer [icon-ok
button-input-container button-input-container
button-input button-input

View File

@ -5,23 +5,23 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.utils.fs :as fs] [status-im.utils.fs :as fs]
[clojure.string :as str] [clojure.string :as str]
[goog.string :as gstr]) [goog.string :as gstr]
[status-im.react-native.js-dependencies :as rn-dependencies])
(:refer-clojure :exclude [exists?])) (:refer-clojure :exclude [exists?]))
(def realm-class (js/require "realm"))
(defn realm-version (defn realm-version
[file-name] [file-name]
(.schemaVersion realm-class file-name)) (.schemaVersion rn-dependencies/realm file-name))
(defn open-realm (defn open-realm
[options file-name] [options file-name]
(let [options (merge options {:path file-name})] (let [options (merge options {:path file-name})]
(when (cljs.core/exists? js/window) (when (cljs.core/exists? js/window)
(realm-class. (clj->js options))))) (rn-dependencies/realm. (clj->js options)))))
(defn close [realm] (defn close [realm]
(.close realm)) (when realm
(.close realm)))
(defn migrate [file-name schemas] (defn migrate [file-name schemas]
(let [current-version (realm-version file-name)] (let [current-version (realm-version file-name)]
@ -37,7 +37,7 @@
(def new-account-filename "new-account") (def new-account-filename "new-account")
(def base-realm (open-migrated-realm (.-defaultPath realm-class) base/schemas)) (def base-realm (open-migrated-realm (.-defaultPath rn-dependencies/realm) base/schemas))
(def account-realm (atom (open-migrated-realm new-account-filename account/schemas))) (def account-realm (atom (open-migrated-realm new-account-filename account/schemas)))

View File

@ -30,7 +30,8 @@
[status-im.constants :refer [console-chat-id]] [status-im.constants :refer [console-chat-id]]
[status-im.utils.ethereum-network :as enet] [status-im.utils.ethereum-network :as enet]
[status-im.utils.instabug :as inst] [status-im.utils.instabug :as inst]
[status-im.utils.platform :as p])) [status-im.utils.platform :as p]
[status-im.js-dependencies :as dependencies]))
;; -- Common -------------------------------------------------------------- ;; -- Common --------------------------------------------------------------
@ -100,23 +101,23 @@
(dispatch [:load-commands!]) (dispatch [:load-commands!])
(when callback (callback)))))) (when callback (callback))))))
(def ecc (js/require "eccjs"))
(register-handler :initialize-crypt (register-handler :initialize-crypt
(u/side-effect! (u/side-effect!
(fn [_ _] (fn [_ _]
(log/debug "initializing crypt") (log/debug "initializing crypt")
(gen-random-bytes 1024 (fn [{:keys [error buffer]}] (gen-random-bytes
(if error 1024
(do (fn [{:keys [error buffer]}]
(log/error "Failed to generate random bytes to initialize sjcl crypto") (if error
(dispatch [:notify-user {:type :error (do
:error error}])) (log/error "Failed to generate random bytes to initialize sjcl crypto")
(do (dispatch [:notify-user {:type :error
(->> (.toString buffer "hex") :error error}]))
(.toBits (.. ecc -sjcl -codec -hex)) (do
(.addEntropy (.. ecc -sjcl -random))) (->> (.toString buffer "hex")
(dispatch [:crypt-initialized])))))))) (.toBits (.. dependencies/eccjs -sjcl -codec -hex))
(.addEntropy (.. dependencies/eccjs -sjcl -random)))
(dispatch [:crypt-initialized]))))))))
(defn node-started [_ _] (defn node-started [_ _]
(log/debug "Started Node") (log/debug "Started Node")

View File

@ -1,5 +1,6 @@
(ns status-im.i18n (ns status-im.i18n
(:require (:require
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.translations.af :as af] [status-im.translations.af :as af]
[status-im.translations.ar :as ar] [status-im.translations.ar :as ar]
[status-im.translations.bel :as be] [status-im.translations.bel :as be]
@ -48,11 +49,10 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[clojure.string :as str])) [clojure.string :as str]))
(def i18n (js/require "react-native-i18n")) (set! (.-fallbacks rn-dependencies/i18n) true)
(set! (.-fallbacks i18n) true) (set! (.-defaultSeparator rn-dependencies/i18n) "/")
(set! (.-defaultSeparator i18n) "/")
(set! (.-translations i18n) (clj->js {:af af/translations (set! (.-translations rn-dependencies/i18n) (clj->js {:af af/translations
:ar ar/translations :ar ar/translations
:be be/translations :be be/translations
:da da/translations :da da/translations
@ -124,7 +124,7 @@
(defn label-number [number] (defn label-number [number]
(when number (when number
(let [{:keys [delimiter separator]} delimeters] (let [{:keys [delimiter separator]} delimeters]
(.toNumber i18n (.toNumber rn-dependencies/i18n
(str/replace number #"," ".") (str/replace number #"," ".")
(clj->js {:precision 10 (clj->js {:precision 10
:strip_insignificant_zeros true :strip_insignificant_zeros true
@ -134,14 +134,14 @@
(defn label (defn label
([path] (label path {})) ([path] (label path {}))
([path options] ([path options]
(if (exists? i18n.t) (if (exists? rn-dependencies/i18n.t)
(let [options (update options :amount label-number)] (let [options (update options :amount label-number)]
(.t i18n (name path) (clj->js options))) (.t rn-dependencies/i18n (name path) (clj->js options)))
(name path)))) (name path))))
(defn label-pluralize [count path & options] (defn label-pluralize [count path & options]
(if (exists? i18n.t) (if (exists? rn-dependencies/i18n.t)
(.p i18n count (name path) (clj->js options)) (.p rn-dependencies/i18n count (name path) (clj->js options))
(name path))) (name path)))
(defn message-status-label [status] (defn message-status-label [status]
@ -152,7 +152,7 @@
(label))) (label)))
(def locale (def locale
(.-locale i18n)) (.-locale rn-dependencies/i18n))
(defn get-contact-translated [contact-id key fallback] (defn get-contact-translated [contact-id key fallback]
(let [translation #(get-in default-contacts [(keyword contact-id) key (keyword %)])] (let [translation #(get-in default-contacts [(keyword contact-id) key (keyword %)])]

View File

@ -1,7 +1,8 @@
(ns status-im.ios.platform (ns status-im.ios.platform
(:require [status-im.components.styles :as styles] (:require [status-im.components.styles :as styles]
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.utils.utils :as utils])) [status-im.utils.utils :as utils]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def component-styles (def component-styles
{:status-bar {:default {:height 20 {:status-bar {:default {:height 20
@ -69,8 +70,6 @@
;; Dialogs ;; Dialogs
(def react-native (js/require "react-native"))
(defn action-sheet-options [options] (defn action-sheet-options [options]
(let [destructive-opt-index (utils/first-index :destructive? options) (let [destructive-opt-index (utils/first-index :destructive? options)
cancel-option {:text (label :t/cancel)} cancel-option {:text (label :t/cancel)}
@ -80,7 +79,7 @@
(when destructive-opt-index {:destructiveButtonIndex destructive-opt-index}))))) (when destructive-opt-index {:destructiveButtonIndex destructive-opt-index})))))
(defn show-action-sheet [{:keys [options callback]}] (defn show-action-sheet [{:keys [options callback]}]
(.showActionSheetWithOptions (.-ActionSheetIOS react-native) (.showActionSheetWithOptions (.-ActionSheetIOS rn-dependencies/react-native)
(action-sheet-options options) (action-sheet-options options)
callback)) callback))

View File

@ -0,0 +1,9 @@
(ns status-im.js-dependencies)
(def awesome-phonenumber (js/require "awesome-phonenumber"))
(def Chance (js/require "chance"))
(def eccjs (js/require "eccjs"))
(def emojis (js/require "emojilib"))
(def homoglyph-finder (js/require "homoglyph-finder"))
(def identicon-js (js/require "identicon.js"))
(def Web3 (js/require "web3"))

View File

@ -1,16 +1,14 @@
(ns status-im.network.net-info (ns status-im.network.net-info
(:require [status-im.utils.utils :as u] (:require [taoensso.timbre :as log]
[taoensso.timbre :as log])) [status-im.components.react :as react-components]))
(def net-info (u/get-react-property "NetInfo"))
(defn init [callback] (defn init [callback]
(when net-info (when react-components/net-info
(.then (.fetch (.-isConnected net-info)) (.then (.fetch (.-isConnected react-components/net-info))
(fn [is-connected?] (fn [is-connected?]
(log/debug "Is connected?" is-connected?) (log/debug "Is connected?" is-connected?)
(callback is-connected?))))) (callback is-connected?)))))
(defn add-listener [listener] (defn add-listener [listener]
(when net-info (when react-components/net-info
(.addEventListener (.-isConnected net-info) "change" listener))) (.addEventListener (.-isConnected react-components/net-info) "change" listener)))

View File

@ -1,7 +1,7 @@
(ns status-im.new-group.screen-public (ns status-im.new-group.screen-public
(:require-macros [status-im.utils.views :refer [defview]]) (:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]] (:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res] [status-im.react-native.resources :as res]
[status-im.components.react :refer [view [status-im.components.react :refer [view
text text
image image

View File

@ -1,7 +1,7 @@
(ns status-im.participants.views.add (ns status-im.participants.views.add
(:require-macros [status-im.utils.views :refer [defview]]) (:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]] (:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res] [status-im.react-native.resources :as res]
[status-im.components.react :refer [view list-view list-item]] [status-im.components.react :refer [view list-view list-item]]
[status-im.components.status-bar :refer [status-bar]] [status-im.components.status-bar :refer [status-bar]]
[status-im.components.toolbar.view :refer [toolbar]] [status-im.components.toolbar.view :refer [toolbar]]

View File

@ -1,7 +1,7 @@
(ns status-im.participants.views.remove (ns status-im.participants.views.remove
(:require-macros [status-im.utils.views :refer [defview]]) (:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]] (:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res] [status-im.react-native.resources :as res]
[status-im.components.react :refer [view [status-im.components.react :refer [view
text text
image image

View File

@ -1,22 +1,21 @@
(ns status-im.protocol.encryption) (ns status-im.protocol.encryption
(:require [status-im.js-dependencies :as dependencies]))
(def default-curve 384) (def default-curve 384)
(def ecc (js/require "eccjs"))
(defn new-keypair! (defn new-keypair!
"Returns {:private \"private key\" :public \"public key\"" "Returns {:private \"private key\" :public \"public key\""
[] []
(let [{:keys [enc dec]} (let [{:keys [enc dec]}
(-> ecc (-> dependencies/eccjs
(.generate (.-ENC_DEC ecc) default-curve) (.generate (.-ENC_DEC dependencies/eccjs) default-curve)
(js->clj :keywordize-keys true))] (js->clj :keywordize-keys true))]
{:private dec {:private dec
:public enc})) :public enc}))
(defn encrypt [public-key content] (defn encrypt [public-key content]
(.encrypt ecc public-key content)) (.encrypt dependencies/eccjs public-key content))
(defn decrypt [private-key content] (defn decrypt [private-key content]
(.decrypt ecc private-key content)) (.decrypt dependencies/eccjs private-key content))

View File

@ -1,18 +1,17 @@
(ns status-im.protocol.web3.utils (ns status-im.protocol.web3.utils
(:require [cljs-time.core :refer [now]] (:require [cljs-time.core :refer [now]]
[cljs-time.coerce :refer [to-long]] [cljs-time.coerce :refer [to-long]]
[status-im.utils.web-provider :as w3])) [status-im.utils.web3-provider :as w3]
[status-im.js-dependencies :as dependencies]))
(def web3 (js/require "web3"))
(defn from-utf8 [s] (defn from-utf8 [s]
(.fromUtf8 web3.prototype s)) (.fromUtf8 dependencies/Web3.prototype s))
(defn to-ascii [s] (defn to-ascii [s]
(.toAscii web3.prototype s)) (.toAscii dependencies/Web3.prototype s))
(defn to-utf8 [s] (defn to-utf8 [s]
(.toUtf8 web3.prototype (str s))) (.toUtf8 dependencies/Web3.prototype (str s)))
(defn shh [web3] (defn shh [web3]
(.-shh web3)) (.-shh web3))
@ -20,7 +19,7 @@
(defn make-web3 [rpc-url] (defn make-web3 [rpc-url]
(->> rpc-url (->> rpc-url
w3/get-provider w3/get-provider
web3.)) dependencies/Web3.))
(defn timestamp [] (defn timestamp []
(to-long (now))) (to-long (now)))

View File

@ -1,35 +0,0 @@
(ns status-im.resources)
(def add-icon (js/require "./images/add.png"))
(def att (js/require "./images/att.png"))
(def chat-icon (js/require "./images/chat.png"))
(def delivered-icon (js/require "./images/delivered.png"))
(def delivery-failed-icon (js/require "./images/deliveryfailed.png"))
(def icon-close-gray (js/require "./images/icon_close_gray.png"))
(def leave-icon (js/require "./images/leave.png"))
(def logo-icon (js/require "./images/logo.png"))
(def mic (js/require "./images/mic.png"))
(def nav-back-icon (js/require "./images/nav-back.png"))
(def user-no-photo (js/require "./images/no-photo.png"))
(def online-icon (js/require "./images/online.png"))
(def play (js/require "./images/play.png"))
(def seen-icon (js/require "./images/seen.png"))
(def smile (js/require "./images/smile.png"))
(def trash-icon (js/require "./images/trash.png"))
(def v (js/require "./images/v.png"))
(def contacts
{:auction-house (js/require "./images/contacts/auction-house.png")
:mkr-market (js/require "./images/contacts/mkr-market.png")
:oaken-water-meter (js/require "./images/contacts/oaken-water-meter.png")
:flight-delays-suck (js/require "./images/contacts/flight-delays-suck.png")
:jarrad (js/require "./images/contacts/jarrad.png")
:firstblood (js/require "./images/contacts/FirstBlood.png")
:gnosis (js/require "./images/contacts/gnosis.png")
:melonport (js/require "./images/contacts/melonport.png")
:bchat (js/require "./images/contacts/bchat.png")
:dentacoin (js/require "./images/contacts/Dentacoin.png")
:augur (js/require "./images/contacts/augur.png")
:ethlance (js/require "./images/contacts/ethlance.png")
:commiteth (js/require "./images/contacts/commiteth.png")
:etherplay (js/require "./images/contacts/etherplay.png")})

View File

@ -1,10 +1,9 @@
(ns status-im.utils.crypt (ns status-im.utils.crypt
(:require [goog.crypt :refer [byteArrayToHex]] (:require [goog.crypt :refer [byteArrayToHex]]
[clojure.string :as s]) [clojure.string :as s]
[status-im.react-native.js-dependencies :as rn-dependencies])
(:import goog.crypt.Sha256)) (:import goog.crypt.Sha256))
(def random-bytes (js/require "react-native-randombytes"))
(def sha-256 (Sha256.)) (def sha-256 (Sha256.))
(defn bytes-to-str [arr] (defn bytes-to-str [arr]
@ -19,7 +18,9 @@
(byteArrayToHex (.digest sha-256))) (byteArrayToHex (.digest sha-256)))
(defn gen-random-bytes [length cb] (defn gen-random-bytes [length cb]
(.randomBytes random-bytes length (fn [& [err buf]] (.randomBytes rn-dependencies/random-bytes
(if err length
(cb {:error err}) (fn [& [err buf]]
(cb {:buffer buf}))))) (if err
(cb {:error err})
(cb {:buffer buf})))))

View File

@ -1,11 +1,10 @@
(ns status-im.utils.ethereum-network (ns status-im.utils.ethereum-network
(:require [status-im.constants :as c] (:require [status-im.constants :as c]
[status-im.utils.web-provider :as w3])) [status-im.utils.web3-provider :as w3]
[status-im.js-dependencies :as dependencies]))
(def Web3 (js/require "web3"))
(defn web3 [] (defn web3 []
(Web3. (w3/get-provider c/ethereum-rpc-url))) (dependencies/Web3. (w3/get-provider c/ethereum-rpc-url)))
(def networks (def networks
{"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" :mainnet {"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" :mainnet

View File

@ -1,13 +1,12 @@
(ns status-im.utils.fs) (ns status-im.utils.fs
(:require [status-im.react-native.js-dependencies :as rn-dependencies]))
(def fs (js/require "react-native-fs"))
(defn move-file [src dst handler] (defn move-file [src dst handler]
(-> (.moveFile fs src dst) (-> (.moveFile rn-dependencies/fs src dst)
(.then #(handler nil %)) (.then #(handler nil %))
(.catch #(handler % nil)))) (.catch #(handler % nil))))
(defn read-file [path encoding on-read on-error] (defn read-file [path encoding on-read on-error]
(-> (.readFile fs path encoding) (-> (.readFile rn-dependencies/fs path encoding)
(.then on-read) (.then on-read)
(.catch on-error))) (.catch on-error)))

View File

@ -1,6 +1,5 @@
(ns status-im.utils.homoglyph) (ns status-im.utils.homoglyph
(:require [status-im.js-dependencies :as dependencies]))
(def homoglyph-finder (js/require "homoglyph-finder"))
(defn matches [s1 s2] (defn matches [s1 s2]
(.isMatches homoglyph-finder s1 s2)) (.isMatches dependencies/homoglyph-finder s1 s2))

View File

@ -1,11 +1,11 @@
(ns status-im.utils.identicon) (ns status-im.utils.identicon
(:require [status-im.js-dependencies :as dependencies]))
(def default-size 40) (def default-size 40)
(def identicon-js (js/require "identicon.js"))
(defn identicon (defn identicon
([hash] (identicon hash default-size)) ([hash] (identicon hash default-size))
([hash options] ([hash options]
(str "data:image/png;base64," (str (new identicon-js hash options))))) (str "data:image/png;base64,"
(str (new dependencies/identicon-js hash options)))))

View File

@ -1,12 +1,11 @@
(ns status-im.utils.image-processing (ns status-im.utils.image-processing
(:require [status-im.utils.fs :refer [read-file]] (:require [status-im.utils.fs :refer [read-file]]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[clojure.string :as str])) [clojure.string :as str]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def resizer-class (js/require "react-native-image-resizer"))
(defn- resize [path max-width max-height on-resize on-error] (defn- resize [path max-width max-height on-resize on-error]
(let [resize-fn (aget resizer-class "default" "createResizedImage")] (let [resize-fn (aget rn-dependencies/image-resizer "default" "createResizedImage")]
(-> (resize-fn path max-width max-height "JPEG" 75 0 nil) (-> (resize-fn path max-width max-height "JPEG" 75 0 nil)
(.then on-resize) (.then on-resize)
(.catch on-error)))) (.catch on-error))))

View File

@ -1,12 +1,11 @@
(ns status-im.utils.instabug (ns status-im.utils.instabug
(:require [taoensso.timbre :as log])) (:require [taoensso.timbre :as log]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def instabug-rn (js/require "instabug-reactnative"))
(defn log [str] (defn log [str]
(if js/goog.DEBUG (if js/goog.DEBUG
(log/debug str) (log/debug str)
(.IBGLog instabug-rn str))) (.IBGLog rn-dependencies/instabug str)))
(defn instabug-appender [] (defn instabug-appender []
{:enabled? true {:enabled? true

View File

@ -1,17 +1,17 @@
(ns status-im.utils.phone-number (ns status-im.utils.phone-number
(:require [status-im.i18n :refer [label]])) (:require [status-im.i18n :refer [label]]
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.js-dependencies :as dependencies]))
(def i18n (js/require "react-native-i18n")) (def locale (or (.-locale rn-dependencies/i18n) "___en"))
(def locale (or (.-locale i18n) "___en"))
(def country-code (subs locale 3 5)) (def country-code (subs locale 3 5))
(def awesome-phonenumber (js/require "awesome-phonenumber"))
;; todo check wrong numbers, .getNumber returns empty string ;; todo check wrong numbers, .getNumber returns empty string
(defn format-phone-number [number] (defn format-phone-number [number]
(str (.getNumber (awesome-phonenumber. number country-code) "international"))) (str (.getNumber (dependencies/awesome-phonenumber number country-code) "international")))
(defn get-examples [] (defn get-examples []
(when-let [example (.getExample awesome-phonenumber country-code "mobile")] (when-let [example (.getExample dependencies/awesome-phonenumber country-code "mobile")]
[{:number (.getNumber example) [{:number (.getNumber example)
:description (label :t/phone-e164)} :description (label :t/phone-e164)}
{:number (.getNumber example "international") {:number (.getNumber example "international")
@ -23,7 +23,7 @@
(defn valid-mobile-number? [number] (defn valid-mobile-number? [number]
(when (string? number) (when (string? number)
(let [{:keys [valid type]} (-> (awesome-phonenumber. number country-code) (let [{:keys [valid type]} (-> (dependencies/awesome-phonenumber. number country-code)
(.toJSON) (.toJSON)
(js->clj :keywordize-keys true))] (js->clj :keywordize-keys true))]
(and valid (and valid

View File

@ -1,11 +1,10 @@
(ns status-im.utils.platform (ns status-im.utils.platform
(:require [status-im.android.platform :as android] (:require [status-im.android.platform :as android]
[status-im.ios.platform :as ios])) [status-im.ios.platform :as ios]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def react-native (js/require "react-native"))
(def platform (def platform
(when-let [pl (.-Platform react-native)] (when-let [pl (.-Platform rn-dependencies/react-native)]
(.-OS pl))) (.-OS pl)))
(def android? (= platform "android")) (def android? (= platform "android"))

View File

@ -1,11 +1,10 @@
(ns status-im.utils.random) (ns status-im.utils.random
(:require [status-im.js-dependencies :as dependencies]))
(defn timestamp [] (defn timestamp []
(.getTime (js/Date.))) (.getTime (js/Date.)))
(def Chance (js/require "chance")) (def chance (dependencies/Chance.))
(def chance (Chance.))
(defn id [] (defn id []
(str (timestamp) "-" (.guid chance))) (str (timestamp) "-" (.guid chance)))

View File

@ -1,16 +1,14 @@
(ns status-im.utils.sms-listener (ns status-im.utils.sms-listener
(:require [status-im.utils.platform :refer [android?]])) (:require [status-im.utils.platform :refer [android?]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def sms-listener (.-default (js/require "react-native-android-sms-listener")))
;; Only android is supported! ;; Only android is supported!
(defn add-sms-listener (defn add-sms-listener
"Message format: {:originatingAddress string, :body string}. Returns "Message format: {:originatingAddress string, :body string}. Returns
cancelable subscription." cancelable subscription."
[listen-fn] [listen-fn]
(when android? (when android?
(.addListener sms-listener (.addListener rn-dependencies/android-sms-listener
(fn [message] (fn [message]
(listen-fn (js->clj message :keywordize-keys true)))))) (listen-fn (js->clj message :keywordize-keys true))))))

View File

@ -2,20 +2,12 @@
(:require [status-im.constants :as const] (:require [status-im.constants :as const]
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[reagent.core :as r] [reagent.core :as r]
[clojure.string :as str])) [clojure.string :as str]
[taoensso.timbre :as log]
(defn require [module] [status-im.react-native.js-dependencies :as rn-dependencies]))
(if (exists? js/window)
(js/require module)
#js {}))
(defn log [obj]
(.log js/console obj))
(def react-native (js/require "react-native"))
(defn show-popup [title content] (defn show-popup [title content]
(.alert (.-Alert react-native) (.alert (.-Alert rn-dependencies/react-native)
title title
content)) content))
@ -25,7 +17,7 @@
([title content s on-accept] ([title content s on-accept]
(show-confirmation title content s on-accept nil)) (show-confirmation title content s on-accept nil))
([title content s on-accept on-cancel] ([title content s on-accept on-cancel]
(.alert (.-Alert react-native) (.alert (.-Alert rn-dependencies/react-native)
title title
content content
; Styles are only relevant on iOS. On Android first button is 'neutral' and second is 'positive' ; Styles are only relevant on iOS. On Android first button is 'neutral' and second is 'positive'
@ -45,7 +37,7 @@
:content-type "application/json"} :content-type "application/json"}
:body (.stringify js/JSON (clj->js data))})) :body (.stringify js/JSON (clj->js data))}))
(.then (fn [response] (.then (fn [response]
(log response) (log/debug response)
(.text response))) (.text response)))
(.then (fn [text] (.then (fn [text]
(let [json (.parse js/JSON text) (let [json (.parse js/JSON text)
@ -62,7 +54,7 @@
(-> (.fetch js/window url (clj->js {:method "GET" (-> (.fetch js/window url (clj->js {:method "GET"
:headers {"Cache-Control" "no-cache"}})) :headers {"Cache-Control" "no-cache"}}))
(.then (fn [response] (.then (fn [response]
(log response) (log/debug response)
(let [ok? (.-ok response) (let [ok? (.-ok response)
ok?' (if valid-response? ok?' (if valid-response?
(and ok? (valid-response? response)) (and ok? (valid-response? response))
@ -101,15 +93,5 @@
index index
(recur (inc index) cond (next coll)))))) (recur (inc index) cond (next coll))))))
(defn get-react-property [name]
(aget react-native name))
(defn adapt-class [class]
(when class
(r/adapt-react-class class)))
(defn get-class [name]
(adapt-class (get-react-property name)))
(defn hash-tag? [s] (defn hash-tag? [s]
(= \# (first s))) (= \# (first s)))

View File

@ -1,4 +1,4 @@
(ns status-im.utils.web-provider (ns status-im.utils.web3-provider
(:require [taoensso.timbre :as log] (:require [taoensso.timbre :as log]
[status-im.components.status :as status])) [status-im.components.status :as status]))

View File

@ -0,0 +1,2 @@
(ns cljsjs.react)

View File

@ -0,0 +1 @@
(ns cljsjs.react.dom)

View File

@ -0,0 +1 @@
(ns cljsjs.react.dom.server)

View File

@ -0,0 +1,14 @@
(ns reagent.core)
(defn create-element [& args])
(defn adapt-react-class [& args])
(defn atom [& args])
(defn as-element [& args])
(defn create-class [& args])
(defn set-state [& args])
(defn state [& args])
(defn after-render [& args])
(defn props [& args])
(defn current-component [& args])
(defn reactify-component [& args])

View File

@ -0,0 +1,38 @@
(ns status-im.react-native.js-dependencies)
(def action-button #js {})
(def android-sms-listener #js {})
(def autolink #js {})
(def camera #js {:constants #js {}})
(def circle-checkbox #js {})
(def contacts #js {})
(def dialogs #js {})
(def dismiss-keyboard #js {})
(def drawer #js {})
(def emoji-picker #js {})
(def fs #js {})
(def http-bridge #js {})
(def i18n #js {})
(def image-crop-picker #js {})
(def image-resizer #js {})
(def instabug #js {})
(def invertible-scroll-view #js {})
(def linear-gradient #js {})
(def mapbox-gl #js {:setAccessToken (fn [])})
(def nfc #js {})
(def orientation #js {})
(def popup-menu #js {})
(def qr-code #js {})
(def random-bytes #js {})
(def react-native
#js {:NativeModules #js {}
:Animated #js {}
:DeviceEventEmitter #js {:addListener (fn [])}})
(def realm #js {:schemaVersion (fn [])
:close (fn [])})
(def sortable-listview #js {})
(def swiper #js {})
(def vector-icons #js {})
(def webview-bridge #js {})

View File

@ -0,0 +1,29 @@
(ns status-im.react-native.resources)
(def add-icon nil)
(def att nil)
(def chat-icon nil)
(def icon-close-gray nil)
(def logo-icon nil)
(def nav-back-icon nil)
(def user-no-photo nil)
(def online-icon nil)
(def play nil)
(def trash-icon nil)
(def v nil)
(def contacts
{:auction-house nil
:mkr-market nil
:oaken-water-meter nil
:flight-delays-suck nil
:jarrad nil
:firstblood nil
:gnosis nil
:melonport nil
:bchat nil
:dentacoin nil
:augur nil
:ethlance nil
:commiteth nil
:etherplay nil})

View File

@ -1,20 +0,0 @@
(ns status-im.test.commands.handlers
(:require [cljs.test :refer-macros [deftest is]]
[status-im.commands.handlers.loading :as h]))
(deftest test-validate-hash
(let [file "some-js"
db (-> {}
(assoc-in [:chats :user :dapp-hash] -731917028)
(assoc-in [:chats :user2 :dapp-hash] 123))]
(is (::h/valid-hash (h/validate-hash db [:user file])))
(is (not (::h/valid-hash (h/validate-hash db [:user2 file]))))
(is (not (::h/valid-hash (h/validate-hash db [:user3 file]))))))
(deftest test-add-commands
(let [obj {:commands {:test {:name "name"
:description "desc"}}
:responses {:test-r {:name "r"
:description "desc-r"}}}
db (h/add-commands {} [:user nil obj])]
(is (= obj (select-keys (get-in db [:chats :user]) [:commands :responses])))))

View File

@ -1,8 +1,7 @@
(ns status-im.test.runner (ns status-im.test.runner
(:require [doo.runner :refer-macros [doo-tests]] (:require [doo.runner :refer-macros [doo-tests]]
[status-im.test.chat.models.input] [status-im.test.chat.models.input]
[status-im.test.handlers] [status-im.test.handlers]))
[status-im.test.commands.handlers]))
(enable-console-print!) (enable-console-print!)
@ -13,5 +12,4 @@
(set! goog.DEBUG false) (set! goog.DEBUG false)
(doo-tests 'status-im.test.chat.models.input (doo-tests 'status-im.test.chat.models.input
'status-im.test.handlers 'status-im.test.handlers)
'status-im.test.commands.handlers)