next-blurhash-previews 0.0.3-beta70 → 0.0.3-beta73

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,6 +76,22 @@ const workerBlob = new Blob(
76
76
  [document.querySelector("#next-blurhash-worker-script")!.textContent!],
77
77
  { type: "text/javascript" }
78
78
  );
79
+ const worker = new Worker(window.URL.createObjectURL(workerBlob));
80
+
81
+ const emptyCanvas = document
82
+ .createElement("canvas")
83
+ // @ts-ignore
84
+ .transferControlToOffscreen();
85
+
86
+ worker.postMessage(
87
+ {
88
+ canvas: emptyCanvas,
89
+ width: 25,
90
+ height: 25,
91
+ blurhash: "L05E$[offQofoffQfQfQfQfQfQfQ",
92
+ },
93
+ [emptyCanvas]
94
+ );
79
95
 
80
96
  function updateBlurHashPreview(canvasEl: HTMLCanvasElement, preview: blurhash) {
81
97
  const { w: width, h: height, blurhash } = preview;
@@ -83,7 +99,6 @@ function updateBlurHashPreview(canvasEl: HTMLCanvasElement, preview: blurhash) {
83
99
  canvasEl.height = height;
84
100
 
85
101
  if (true) {
86
- const worker = new Worker(window.URL.createObjectURL(workerBlob));
87
102
  const offscreen = (canvasEl as any).transferControlToOffscreen();
88
103
  worker.postMessage({ canvas: offscreen, width, height, blurhash }, [
89
104
  offscreen,
@@ -279,6 +279,14 @@ if (!customElements.get("blurhash-image")) {
279
279
  const workerBlob = new Blob([document.querySelector("#next-blurhash-worker-script").textContent], {
280
280
  type: "text/javascript"
281
281
  });
282
+ const worker = new Worker(window.URL.createObjectURL(workerBlob));
283
+ const emptyCanvas = document.createElement("canvas").transferControlToOffscreen();
284
+ worker.postMessage({
285
+ canvas: emptyCanvas,
286
+ width: 25,
287
+ height: 25,
288
+ blurhash: "L05E$[offQofoffQfQfQfQfQfQfQ"
289
+ }, [emptyCanvas]);
282
290
  function updateBlurHashPreview(canvasEl, preview) {
283
291
  const {
284
292
  w: width,
@@ -288,7 +296,6 @@ function updateBlurHashPreview(canvasEl, preview) {
288
296
  canvasEl.width = width;
289
297
  canvasEl.height = height;
290
298
  {
291
- const worker = new Worker(window.URL.createObjectURL(workerBlob));
292
299
  const offscreen = canvasEl.transferControlToOffscreen();
293
300
  worker.postMessage({
294
301
  canvas: offscreen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-blurhash-previews",
3
- "version": "0.0.3-beta70",
3
+ "version": "0.0.3-beta73",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",