elm-hot
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "elm-hot", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Hot code swapping for Elm", | ||
@@ -31,5 +31,5 @@ "keywords": [ | ||
"express": "^4.16.3", | ||
"puppeteer": "^1.5.0", | ||
"puppeteer": "^1.17.0", | ||
"tap-xunit": "^2.3.0" | ||
} | ||
} |
@@ -54,3 +54,3 @@ //////////////////// HMR BEGIN //////////////////// | ||
if (Object.keys(instances).length === 0) { | ||
console.log("[elm-hot] Enabled"); | ||
log("[elm-hot] Enabled"); | ||
} | ||
@@ -79,3 +79,3 @@ | ||
if (cancellers.length) { | ||
console.log('[elm-hot] Killing ' + cancellers.length + ' running processes...'); | ||
log('[elm-hot] Killing ' + cancellers.length + ' running processes...'); | ||
try { | ||
@@ -91,2 +91,8 @@ cancellers.forEach(function (cancel) { | ||
function log(message) { | ||
if (module.hot.verbose) { | ||
console.log(message) | ||
} | ||
} | ||
function getId() { | ||
@@ -154,2 +160,3 @@ return ++uid; | ||
dummyNode.setAttribute("data-elm-hot", "true"); | ||
dummyNode.style.height = "inherit"; | ||
var parentNode = node.parentNode; | ||
@@ -193,3 +200,3 @@ parentNode.replaceChild(dummyNode, node); | ||
function swap(Elm, instance) { | ||
console.log('[elm-hot] Hot-swapping module: ' + instance.path); | ||
log('[elm-hot] Hot-swapping module: ' + instance.path); | ||
@@ -226,3 +233,3 @@ swappingInstance = instance; | ||
} | ||
console.log('[elm-hot] Reconnect ' + handlers.length + ' handler(s) to port \'' | ||
log('[elm-hot] Reconnect ' + handlers.length + ' handler(s) to port \'' | ||
+ portName + '\' (' + instance.path + ').'); | ||
@@ -234,3 +241,3 @@ handlers.forEach(function (handler) { | ||
delete instance.portSubscribes[portName]; | ||
console.log('[elm-hot] Port was removed: ' + portName); | ||
log('[elm-hot] Port was removed: ' + portName); | ||
} | ||
@@ -241,11 +248,11 @@ }); | ||
if (portName in elm.ports && 'send' in elm.ports[portName]) { | ||
console.log('[elm-hot] Replace old port send with the new send'); | ||
log('[elm-hot] Replace old port send with the new send'); | ||
instance.portSends[portName] = elm.ports[portName].send; | ||
} else { | ||
delete instance.portSends[portName]; | ||
console.log('[elm-hot] Port was removed: ' + portName); | ||
log('[elm-hot] Port was removed: ' + portName); | ||
} | ||
}); | ||
} else { | ||
console.log('[elm-hot] Module was removed: ' + instance.path); | ||
log('[elm-hot] Module was removed: ' + instance.path); | ||
} | ||
@@ -271,3 +278,3 @@ | ||
subscribe: function (handler) { | ||
console.log('[elm-hot] ports.' + portName + '.subscribe called.'); | ||
log('[elm-hot] ports.' + portName + '.subscribe called.'); | ||
if (!portSubscribes[portName]) { | ||
@@ -282,3 +289,3 @@ portSubscribes[portName] = [handler]; | ||
unsubscribe: function (handler) { | ||
console.log('[elm-hot] ports.' + portName + '.unsubscribe called.'); | ||
log('[elm-hot] ports.' + portName + '.unsubscribe called.'); | ||
var list = portSubscribes[portName]; | ||
@@ -285,0 +292,0 @@ if (list && list.indexOf(handler) !== -1) { |
@@ -58,5 +58,7 @@ /* | ||
module.hot.data = newData | ||
} | ||
}, | ||
verbose: true | ||
} | ||
}; |
847
454256
83