@cf-wasm/photon
Version:
Photon library for Cloudflare workers, Next.js and Node.js.
30 lines (29 loc) • 873 B
JavaScript
// src/others/index.ts
import "@cf-wasm/internals/polyfills/image-data";
import initAsync from "../lib/photon_rs.js";
export * from "../lib/photon_rs.js";
var initPhoton = async (input) => {
if (initPhoton.promise) {
throw new Error("(@cf-wasm/photon): Function already called. The `initPhoton()` function can be used only once.");
}
if (!input) {
throw new Error("(@cf-wasm/photon): Argument `input` is not valid.");
}
initPhoton.promise = (async () => {
await initAsync(input);
initPhoton.initialized = true;
})();
return initPhoton.promise;
};
initPhoton.promise = null;
initPhoton.initialized = false;
initPhoton.ensure = async () => {
if (!initPhoton.promise) {
throw new Error("(@cf-wasm/photon): Function not called. Call `initPhoton()` function first.");
}
return initPhoton.promise;
};
export {
initAsync,
initPhoton
};