world.ts 0.2.7 → 0.2.8

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-load-worker-B_Z2qDiu.js","sources":["../src/image-load-worker.ts"],"sourcesContent":["export type Data = [\"load\" | \"cancel\", string];\n\naddEventListener(\"message\", async event => {\n const [action, url] = event.data as Data;\n if (action !== \"load\") return;\n const abortController = new AbortController();\n const { signal } = abortController;\n const handler = (event: MessageEvent) => {\n const [action, thisUrl] = event.data as Data;\n if (action === \"cancel\" && thisUrl === url) abortController.abort();\n };\n addEventListener(\"message\", handler);\n try {\n const response = await fetch(url, { mode: \"cors\", signal });\n if (!response.ok) {\n postMessage({ url, image: undefined });\n return;\n }\n const blob = await response.blob();\n const image = await createImageBitmap(blob);\n postMessage({ url, image });\n } catch (error) {\n if (\n error instanceof Error &&\n error.message === \"The user aborted a request.\"\n ) {\n // Ignore\n } else throw error;\n } finally {\n removeEventListener(\"message\", handler);\n }\n});\n"],"names":["event","action","url","abortController","signal","handler","thisUrl","response","blob","image","error"],"mappings":"yBAEA,iBAAiB,UAAW,MAAMA,GAAS,CACzC,KAAM,CAACC,EAAQC,CAAG,EAAIF,EAAM,KAC5B,GAAIC,IAAW,OAAQ,OACjB,MAAAE,EAAkB,IAAI,gBACtB,CAAE,OAAAC,CAAW,EAAAD,EACbE,EAAWL,GAAwB,CACvC,KAAM,CAACC,EAAQK,CAAO,EAAIN,EAAM,KAC5BC,IAAW,UAAYK,IAAYJ,GAAKC,EAAgB,MAAM,CAAA,EAEpE,iBAAiB,UAAWE,CAAO,EAC/B,GAAA,CACI,MAAAE,EAAW,MAAM,MAAML,EAAK,CAAE,KAAM,OAAQ,OAAAE,EAAQ,EACtD,GAAA,CAACG,EAAS,GAAI,CAChB,YAAY,CAAE,IAAAL,EAAK,MAAO,MAAW,CAAA,EACrC,MACF,CACM,MAAAM,EAAO,MAAMD,EAAS,OACtBE,EAAQ,MAAM,kBAAkBD,CAAI,EAC9B,YAAA,CAAE,IAAAN,EAAK,MAAAO,CAAA,CAAO,QACnBC,EAAO,CACd,GACE,EAAAA,aAAiB,OACjBA,EAAM,UAAY,+BAGP,MAAAA,CAAA,QACb,CACA,oBAAoB,UAAWL,CAAO,CACxC,CACF,CAAC"}