A tiny zero-dependency compression middleware for polka (& express!) with native Brotli support.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(c,b,cs,r,d){ | |
| b.frameBorder=0; | |
| b.style = 'position:fixed;bottom:0;left:0;width:100%;height:30vh;background:#fff;border-top:4px solid #bbb;box-shadow:0 0 2px #000;z-index:999;cursor:ns-resize;'; | |
| b.onpointerdown=function(e){b.setPointerCapture(e.pointerId);b.e=e;b.h=b.offsetHeight-4;b.style.borderTopColor='#59f'} | |
| b.onpointermove=function(e){if(b.e)b.style.height=(b.h-e.y+b.e.y)+'px'} | |
| b.onpointerup=function(){b.e=null;b.style.borderTopColor='#aaa'} | |
| document.documentElement.appendChild(b); | |
| (d=b.contentWindow.document).open(); | |
| d.write('<style>html,body{width:100%;height:100%;overflow:hidden;font:12px/1.2 system-ui,sans-serif;flex:1;display:flex;flex-direction:column;margin:0;}*{box-sizing:border-box;}button{font:inherit;}pre{margin:0;padding:4px;border-bottom:1px solid #ddd;}</style><div style="background:#ddd;border-bottom:1px solid #ccc;display:flex;padding:3px 5px 4px;align-items:center;"><div style="color:#555;flex:1;">Console</div><button onclick="console.clear()">clear</button></div> |
Experimental hooks-based bindings for Unistore. Available on npm:
npm i unistore-hooks
Note: this should also work with React, just alias
"preact"and"preact/hooks"to"react"in your bundler.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package-lock.json | |
| node_modules | |
| .cache | |
| dist |
Greenlet for Node worker_threads
Works with ESM and CommonJS.
import greenlet from 'greenlet-node';
const add = greenlet(async (a, b) => {
return a + b;
});Preact now supports seamless progressive hydration.
Any component can throw during hydration (or new tree creation like a route change!), and if a component somewhere
higher in the tree catches that via componentDidCatch, hydration gets paused.
Re-rendering the tree (via setState, etc) simply resumes hydration where it left off.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * cloneNode(true), but also clones shadow roots. | |
| * @param {Element} | |
| * @param {ShadowRoot[]} [shadowRoots] Any closed shadow roots passed here will be included. | |
| */ | |
| function cloneWithShadowRoots(node, shadowRoots) { | |
| function walk(node, clone) { | |
| let shadow = node.shadowRoot || shadowRoots.find(r => r.host === node); | |
| if (shadow) { | |
| clone.attachShadow({ mode: shadow.mode }).append(...[].map.call(shadow.childNodes, c => c.cloneNode(true))); |