UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

34 lines (33 loc) • 1.06 kB
import { t as p5 } from "../main-Ds8DrMLz.js"; //#region src/core/init.js /** * This file setup global mode automatic instantiation * * if sketch is on window * assume "global" mode * and instantiate p5 automatically * otherwise do nothing * * @private * @return {Undefined} */ const _globalInit = () => { if (typeof window === "undefined") return; if (typeof window._setupDone !== "undefined") { console.warn("p5.js seems to have been imported multiple times. Please remove the duplicate import"); return; } if (!window.mocha) { const p5ReadyEvent = new Event("p5Ready"); window.dispatchEvent(p5ReadyEvent); if ((window.setup && typeof window.setup === "function" || window.draw && typeof window.draw === "function") && !p5.instance) new p5(); } }; const waitForDocumentReady = () => { if (typeof document !== "undefined") return new Promise((resolve, reject) => { if (document.readyState === "complete") resolve(); else window.addEventListener("load", resolve, false); }); }; //#endregion export { _globalInit, waitForDocumentReady };