diff --git a/resources/cljs-om-next/main_dev.cljs b/resources/cljs-om-next/main_dev.cljs index 96910f7..83b2f98 100644 --- a/resources/cljs-om-next/main_dev.cljs +++ b/resources/cljs-om-next/main_dev.cljs @@ -8,7 +8,7 @@ (figwheel/watch-and-reload :websocket-url "ws://localhost:3449/figwheel-ws" - :heads-up-display true + :heads-up-display false :jsload-callback #(om/add-root! state/reconciler core/AppRoot 1)) (core/init) diff --git a/resources/cljs-reagent/main_dev.cljs b/resources/cljs-reagent/main_dev.cljs index 4ee24b4..00bedb7 100644 --- a/resources/cljs-reagent/main_dev.cljs +++ b/resources/cljs-reagent/main_dev.cljs @@ -11,7 +11,7 @@ (figwheel/watch-and-reload :websocket-url "ws://$DEV_HOST$:3449/figwheel-ws" - :heads-up-display true + :heads-up-display false :jsload-callback #(swap! cnt inc)) (core/init) \ No newline at end of file diff --git a/resources/figwheel-bridge.js b/resources/figwheel-bridge.js index 2a7cb1c..126dee2 100644 --- a/resources/figwheel-bridge.js +++ b/resources/figwheel-bridge.js @@ -13,13 +13,25 @@ var config = { }; var React = require('react-native'); +var WebSocket = require('WebSocket'); var self; var scriptQueue = []; var serverHost = null; // will be set dynamically var fileBasePath = null; // will be set dynamically var evaluate = eval; // This is needed, direct calls to eval does not work (RN packager???) var externalModules = {}; -var evalListeners = []; // functions to be called when a script is evaluated +var evalListeners = [ // Functions to be called after js file is loaded and evaluated + function (url) { + if (url.indexOf('jsloader') > -1) { + shimJsLoader(); + } + }, + function (url) { + if (url.indexOf('/figwheel/client/socket') > -1) { + setCorrectWebSocketImpl(); + } + } +]; var figwheelApp = function (platform, devHost) { return React.createClass({ @@ -40,7 +52,7 @@ var figwheelApp = function (platform, devHost) { componentDidMount: function () { var app = this; if (typeof goog === "undefined") { - loadApp(platform, devHost, function(appRoot) { + loadApp(platform, devHost, function (appRoot) { app.setState({root: appRoot, loaded: true}) }); } @@ -143,25 +155,31 @@ function interceptRequire() { }; } -// do not show debug messages in yellow box -function debugToLog() { - console.debug = console.log; +function compileWarningsToYellowBox() { + var log = window.console.log; + var compileWarningRx = /Figwheel: Compile Warning/; + window.console.log = function (msg) { + if (msg.match(compileWarningRx) != null) { + console.warn(msg); + } else { + log.call(window.console, msg); + } + }; } function serverBaseUrl(host) { return "http://" + host + ":" + config.serverPort } +function setCorrectWebSocketImpl() { + figwheel.client.socket.get_websocket_imp = function () { + return WebSocket; + }; +} function loadApp(platform, devHost, onLoadCb) { serverHost = devHost; fileBasePath = config.basePath + platform; - evalListeners.push(function (url) { - if (url.indexOf('jsloader') > -1) { - shimJsLoader(); - } - }); - // callback when app is ready to get the reloadable component var mainJs = '/env/' + platform + '/main.js'; evalListeners.push(function (url) { @@ -174,12 +192,11 @@ function loadApp(platform, devHost, onLoadCb) { if (typeof goog === "undefined") { console.log('Loading Closure base.'); interceptRequire(); + compileWarningsToYellowBox(); importJs('goog/base.js', function () { shimBaseGoog(); - fakeLocalStorageAndDocument(); importJs('cljs_deps.js'); importJs('goog/deps.js', function () { - debugToLog(); // This is needed because of RN packager // seriously React packager? why. var googreq = goog.require; @@ -209,39 +226,6 @@ function shimBaseGoog() { importJs(src); return true; }; - goog.inHtmlDocument_ = function () { - return true; - }; -} - -function fakeLocalStorageAndDocument() { - window.localStorage = {}; - window.localStorage.getItem = function () { - return 'true'; - }; - window.localStorage.setItem = function () { - }; - - window.document = {}; - window.document.body = {}; - window.document.body.dispatchEvent = function () { - }; - window.document.createElement = function () { - }; - - if (typeof window.location === 'undefined') { - window.location = {}; - } - console.debug = console.warn; - window.addEventListener = function () { - }; - // make figwheel think that heads-up-display divs are there - window.document.querySelector = function (selector) { - return {}; - }; - window.document.getElementById = function (id) { - return {style:{}}; - }; } // Figwheel fixes diff --git a/resources/project.clj b/resources/project.clj index 4937031..af50e96 100644 --- a/resources/project.clj +++ b/resources/project.clj @@ -7,13 +7,13 @@ [org.clojure/clojurescript "1.7.170"] $INTERFACE_DEPS$] :plugins [[lein-cljsbuild "1.1.1"] - [lein-figwheel "0.5.0-2"]] + [lein-figwheel "0.5.0-6"]] :clean-targets ["target/" "index.ios.js" "index.android.js"] :aliases {"prod-build" ^{:doc "Recompile code with prod profile."} ["do" "clean" ["with-profile" "prod" "cljsbuild" "once" "ios"] ["with-profile" "prod" "cljsbuild" "once" "android"]]} - :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2"] + :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-6"] [com.cemerick/piggieback "0.2.1"]] :source-paths ["src" "env/dev"] :cljsbuild {:builds {:ios {:source-paths ["src" "env/dev"]