elm-hot
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "elm-hot", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Hot code swapping for Elm", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -46,2 +46,31 @@ //////////////////// HMR BEGIN //////////////////// | ||
// Elm 0.19.1 introduced a '$' prefix at the beginning of the symbols it emits, | ||
// and we check for `List.map` because we expect it to be present in all Elm programs. | ||
var elmVersion; | ||
if (typeof elm$core$List$map !== 'undefined') | ||
elmVersion = '0.19.0'; | ||
else if (typeof $elm$core$List$map !== 'undefined') | ||
elmVersion = '0.19.1'; | ||
else | ||
throw new Error("Could not determine Elm version"); | ||
function elmSymbol(symbol) { | ||
try { | ||
switch (elmVersion) { | ||
case '0.19.0': | ||
return eval(symbol); | ||
case '0.19.1': | ||
return eval('$' + symbol); | ||
default: | ||
throw new Error('Cannot resolve ' + symbol + '. Elm version unknown!') | ||
} | ||
} catch (e) { | ||
if (e instanceof ReferenceError) { | ||
return undefined; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
var instances = module.hot.data | ||
@@ -136,4 +165,4 @@ ? module.hot.data.instances || {} | ||
// Returns true if the Elm app will take over the entire DOM body. | ||
return typeof elm$browser$Browser$application !== 'undefined' | ||
|| typeof elm$browser$Browser$document !== 'undefined'; | ||
return typeof elmSymbol("elm$browser$Browser$application") !== 'undefined' | ||
|| typeof elmSymbol("elm$browser$Browser$document") !== 'undefined'; | ||
} | ||
@@ -381,3 +410,3 @@ | ||
if (typeof elm$browser$Browser$application !== 'undefined') { | ||
if (typeof elmSymbol("elm$browser$Browser$application") !== 'undefined') { | ||
// attempt to find the Browser.Navigation.Key in the newly-constructed model | ||
@@ -419,3 +448,3 @@ // and bring it along with the rest of the old data. | ||
// ignore any Cmds returned by the init during hot-swap | ||
initialStateTuple.b = elm$core$Platform$Cmd$none; | ||
initialStateTuple.b = elmSymbol("elm$core$Platform$Cmd$none"); | ||
} else { | ||
@@ -426,3 +455,3 @@ // capture the initial state for later | ||
// capture Browser.application's navigation key for later | ||
if (typeof elm$browser$Browser$application !== 'undefined') { | ||
if (typeof elmSymbol("elm$browser$Browser$application") !== 'undefined') { | ||
var navKeyLoc = findNavKey(initializingInstance.lastState); | ||
@@ -429,0 +458,0 @@ if (!navKeyLoc) { |
Sorry, the diff of this file is not supported yet
1647269
128
874