@cf-wasm/photon
Version:
Photon library for Cloudflare workers, Next.js and Node.js.
68 lines (66 loc) • 2.82 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/others/index.ts
var others_exports = {};
__export(others_exports, {
initAsync: () => import_photon_rs.default,
initPhoton: () => initPhoton
});
module.exports = __toCommonJS(others_exports);
var import_image_data = require("@cf-wasm/internals/polyfills/image-data");
var import_photon_rs = __toESM(require("../lib/photon_rs.js"), 1);
__reExport(others_exports, require("../lib/photon_rs.js"), module.exports);
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 (0, import_photon_rs.default)(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;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
initAsync,
initPhoton,
...require("../lib/photon_rs.js")
});