#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
|
(figwheel/watch-and-reload
|
||||||
:websocket-url "ws://localhost:3449/figwheel-ws"
|
: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))
|
:jsload-callback #(om/add-root! state/reconciler core/AppRoot 1))
|
||||||
|
|
||||||
(core/init)
|
(core/init)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
(figwheel/watch-and-reload
|
(figwheel/watch-and-reload
|
||||||
:websocket-url "ws://$DEV_HOST$:3449/figwheel-ws"
|
:websocket-url "ws://$DEV_HOST$:3449/figwheel-ws"
|
||||||
:heads-up-display true
|
:heads-up-display false
|
||||||
:jsload-callback #(swap! cnt inc))
|
:jsload-callback #(swap! cnt inc))
|
||||||
|
|
||||||
(core/init)
|
(core/init)
|
|
@ -13,13 +13,25 @@ var config = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
var WebSocket = require('WebSocket');
|
||||||
var self;
|
var self;
|
||||||
var scriptQueue = [];
|
var scriptQueue = [];
|
||||||
var serverHost = null; // will be set dynamically
|
var serverHost = null; // will be set dynamically
|
||||||
var fileBasePath = 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 evaluate = eval; // This is needed, direct calls to eval does not work (RN packager???)
|
||||||
var externalModules = {};
|
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) {
|
var figwheelApp = function (platform, devHost) {
|
||||||
return React.createClass({
|
return React.createClass({
|
||||||
|
@ -40,7 +52,7 @@ var figwheelApp = function (platform, devHost) {
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
var app = this;
|
var app = this;
|
||||||
if (typeof goog === "undefined") {
|
if (typeof goog === "undefined") {
|
||||||
loadApp(platform, devHost, function(appRoot) {
|
loadApp(platform, devHost, function (appRoot) {
|
||||||
app.setState({root: appRoot, loaded: true})
|
app.setState({root: appRoot, loaded: true})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -143,25 +155,31 @@ function interceptRequire() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not show debug messages in yellow box
|
function compileWarningsToYellowBox() {
|
||||||
function debugToLog() {
|
var log = window.console.log;
|
||||||
console.debug = 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) {
|
function serverBaseUrl(host) {
|
||||||
return "http://" + host + ":" + config.serverPort
|
return "http://" + host + ":" + config.serverPort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCorrectWebSocketImpl() {
|
||||||
|
figwheel.client.socket.get_websocket_imp = function () {
|
||||||
|
return WebSocket;
|
||||||
|
};
|
||||||
|
}
|
||||||
function loadApp(platform, devHost, onLoadCb) {
|
function loadApp(platform, devHost, onLoadCb) {
|
||||||
serverHost = devHost;
|
serverHost = devHost;
|
||||||
fileBasePath = config.basePath + platform;
|
fileBasePath = config.basePath + platform;
|
||||||
|
|
||||||
evalListeners.push(function (url) {
|
|
||||||
if (url.indexOf('jsloader') > -1) {
|
|
||||||
shimJsLoader();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// callback when app is ready to get the reloadable component
|
// callback when app is ready to get the reloadable component
|
||||||
var mainJs = '/env/' + platform + '/main.js';
|
var mainJs = '/env/' + platform + '/main.js';
|
||||||
evalListeners.push(function (url) {
|
evalListeners.push(function (url) {
|
||||||
|
@ -174,12 +192,11 @@ function loadApp(platform, devHost, onLoadCb) {
|
||||||
if (typeof goog === "undefined") {
|
if (typeof goog === "undefined") {
|
||||||
console.log('Loading Closure base.');
|
console.log('Loading Closure base.');
|
||||||
interceptRequire();
|
interceptRequire();
|
||||||
|
compileWarningsToYellowBox();
|
||||||
importJs('goog/base.js', function () {
|
importJs('goog/base.js', function () {
|
||||||
shimBaseGoog();
|
shimBaseGoog();
|
||||||
fakeLocalStorageAndDocument();
|
|
||||||
importJs('cljs_deps.js');
|
importJs('cljs_deps.js');
|
||||||
importJs('goog/deps.js', function () {
|
importJs('goog/deps.js', function () {
|
||||||
debugToLog();
|
|
||||||
// This is needed because of RN packager
|
// This is needed because of RN packager
|
||||||
// seriously React packager? why.
|
// seriously React packager? why.
|
||||||
var googreq = goog.require;
|
var googreq = goog.require;
|
||||||
|
@ -209,39 +226,6 @@ function shimBaseGoog() {
|
||||||
importJs(src);
|
importJs(src);
|
||||||
return true;
|
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
|
// Figwheel fixes
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
[org.clojure/clojurescript "1.7.170"]
|
[org.clojure/clojurescript "1.7.170"]
|
||||||
$INTERFACE_DEPS$]
|
$INTERFACE_DEPS$]
|
||||||
:plugins [[lein-cljsbuild "1.1.1"]
|
: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"]
|
: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"]]}
|
||||||
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2"]
|
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-6"]
|
||||||
[com.cemerick/piggieback "0.2.1"]]
|
[com.cemerick/piggieback "0.2.1"]]
|
||||||
:source-paths ["src" "env/dev"]
|
:source-paths ["src" "env/dev"]
|
||||||
:cljsbuild {:builds {:ios {:source-paths ["src" "env/dev"]
|
:cljsbuild {:builds {:ios {:source-paths ["src" "env/dev"]
|
||||||
|
|
Loading…
Reference in New Issue