Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hotloader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotloader - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

package.json
{
"name": "hotloader",
"version": "1.0.1",
"version": "1.1.0",
"description": "simple lib for fast html hotloading",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -0,1 +1,3 @@

/* global HOTLOADER_CLIENT_ID location */
const virtualize = require('snabbdom-virtualize').default

@@ -12,4 +14,2 @@ const patch = require('snabbdom').init([

/* global HOTLOADER_CLIENT_ID location */
const findBody = htmlVNode => {

@@ -21,2 +21,13 @@ const { children } = htmlVNode

const handleError = html => (msg, e) => {
console.error([
msg,
'Rebuilding entire page',
'Error message: ' + e.message
].join('\n'))
document.documentElement.innerHTML = html
document.getElementsByTagName('body')[0].focus()
}
const hotloader = () => {

@@ -34,12 +45,22 @@ console.log('Starting hotloader')

const recieveUpdate = html => {
if (!html) throw new Error('got empty html!')
const newVNode = findBody(virtualize(html))
if (!html) return
if (newVNode) {
vNode = patch(vNode, virtualize(html))
const fallback = handleError(html)
// hack for chrome.
// changes to tag class were not taking effect until mouse over
document.getElementsByTagName('body')[0].focus()
let newVNode
try {
newVNode = virtualize(html)
} catch (e) {
return fallback('Failed to virtualize incoming html.', e)
}
try {
vNode = patch(vNode, findBody(newVNode))
} catch (e) {
return fallback('Patching DOM failed.', e)
}
// hack for chrome, force repaint on unfocused window.
document.getElementsByTagName('body')[0].focus()
}

@@ -46,0 +67,0 @@ self.recieveUpdate = recieveUpdate

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc