world.ts 0.3.13 → 0.3.14

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-dzrjkCtK.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 (!(error instanceof Error)) throw error;\n if (\n error.message === \"The user aborted a request.\" ||\n error.message.startsWith(\"signal is aborted without reason\")\n )\n // Ignore\n return;\n else if (error.message === \"Failed to fetch\") {\n // Network error (eg. CORS issue)\n postMessage({ url, image: undefined });\n return;\n }\n 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,GAAI,EAAEA,aAAiB,OAAc,MAAAA,EACrC,GACEA,EAAM,UAAY,+BAClBA,EAAM,QAAQ,WAAW,kCAAkC,EAG3D,OACO,GAAAA,EAAM,UAAY,kBAAmB,CAE5C,YAAY,CAAE,IAAAR,EAAK,MAAO,MAAW,CAAA,EACrC,MACF,CACM,MAAAQ,CAAA,QACN,CACA,oBAAoB,UAAWL,CAAO,CACxC,CACF,CAAC"}