#4 remove fakeLocalStorageAndDocument function from figwheel-bridge.js
- using latest available version of lein-figwheel [0.5.0-6] - figwheel now 'thinks' it is running in node.js environment (thanks @artemyarulin for hints) - figwheel :heads-up-display is now disabled. Compilation warnings are still logged and shown in yellow box on screen. (thanks @seantempesta for hint)
This commit is contained in:
parent
c08541805a
commit
dfa5cdece8
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -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({
|
||||
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in New Issue