next-blurhash-previews 0.0.3-beta34 → 0.0.3-beta35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,9 +77,10 @@ function updateBlurHashPreview(canvasEl: HTMLCanvasElement, preview: blurhash) {
|
|
77
77
|
worker.postMessage({ canvas: offscreen, width, height, blurhash }, [
|
78
78
|
offscreen,
|
79
79
|
]);
|
80
|
+
|
81
|
+
return;
|
80
82
|
canvasEl.width = width;
|
81
83
|
canvasEl.height = height;
|
82
|
-
|
83
84
|
const pixels = decode(blurhash, width, height);
|
84
85
|
const ctx = canvasEl.getContext("2d")!;
|
85
86
|
const imageData = ctx.createImageData(width, height);
|
package/imagePreviewBootstrap.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createElement } from "react";
|
2
2
|
|
3
3
|
export const imagePreviewBootstrap = createElement("script", {
|
4
|
-
dangerouslySetInnerHTML: { __html: `(() => { "use strict";
|
4
|
+
dangerouslySetInnerHTML: { __html: `(() => { "use strict";class h extends HTMLElement{sd;mo;static observedAttributes=["preview"];get#e(){return this.querySelector("img")}get#t(){return this.querySelector("canvas")}constructor(){super(),this.sd=this.attachShadow({mode:"open"}),this.sd.innerHTML='<slot name="preview"></slot>'}#s=()=>{if(this.#e&&this.#t)return this.mo?.disconnect(),this.#e.complete?this.#i():(this.#r(),this.#e.addEventListener("load",this.#i)),!0};connectedCallback(){this.#s()||(this.mo=new MutationObserver(this.#s),this.mo.observe(this,{subtree:!0,childList:!0,attributes:!1}))}#i=()=>{this.sd.innerHTML='<slot name="image"></slot>'};attributeChangedCallback(e){this.#t&&e==="preview"&&this.#r()}#r(){const e=JSON.parse(this.getAttribute("preview"));o(this.#t,e)}}customElements.get("blurhash-image")||customElements.define("blurhash-image",h);function o(t,e){const{w:i,h:r,blurhash:a}=e,n=new Worker("/canvas-worker.js"),s=t.transferControlToOffscreen();n.postMessage({canvas:s,width:i,height:r,blurhash:a},[s])} })();` },
|
5
5
|
});
|