next-blurhash-previews 0.0.3-beta69 → 0.0.3-beta71

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.
@@ -76,7 +76,6 @@ 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
79
 
81
80
  function updateBlurHashPreview(canvasEl: HTMLCanvasElement, preview: blurhash) {
82
81
  const { w: width, h: height, blurhash } = preview;
@@ -84,6 +83,27 @@ function updateBlurHashPreview(canvasEl: HTMLCanvasElement, preview: blurhash) {
84
83
  canvasEl.height = height;
85
84
 
86
85
  if (true) {
86
+ const worker = new Worker(window.URL.createObjectURL(workerBlob));
87
+
88
+ const s = +new Date();
89
+
90
+ const emptyCanv = document
91
+ .createElement("canvas")
92
+ // @ts-ignore
93
+ .transferControlToOffscreen();
94
+
95
+ worker.postMessage(
96
+ {
97
+ canvas: emptyCanv,
98
+ width: 50,
99
+ height: 50,
100
+ blurhash: "L05E$[offQofoffQfQfQfQfQfQfQ",
101
+ },
102
+ [emptyCanv]
103
+ );
104
+ const e = +new Date();
105
+ console.log("bootstrap", e - s);
106
+
87
107
  const offscreen = (canvasEl as any).transferControlToOffscreen();
88
108
  worker.postMessage({ canvas: offscreen, width, height, blurhash }, [
89
109
  offscreen,
@@ -279,7 +279,6 @@ 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
282
  function updateBlurHashPreview(canvasEl, preview) {
284
283
  const {
285
284
  w: width,
@@ -289,6 +288,17 @@ function updateBlurHashPreview(canvasEl, preview) {
289
288
  canvasEl.width = width;
290
289
  canvasEl.height = height;
291
290
  {
291
+ const worker = new Worker(window.URL.createObjectURL(workerBlob));
292
+ const s = +new Date();
293
+ const emptyCanv = document.createElement("canvas").transferControlToOffscreen();
294
+ worker.postMessage({
295
+ canvas: emptyCanv,
296
+ width: 50,
297
+ height: 50,
298
+ blurhash: "L05E$[offQofoffQfQfQfQfQfQfQ"
299
+ }, [emptyCanv]);
300
+ const e = +new Date();
301
+ console.log("bootstrap", e - s);
292
302
  const offscreen = canvasEl.transferControlToOffscreen();
293
303
  worker.postMessage({
294
304
  canvas: offscreen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-blurhash-previews",
3
- "version": "0.0.3-beta69",
3
+ "version": "0.0.3-beta71",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",