UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

40 lines 1.67 kB
/** * SSR-safe base classes for browser globals that are not available in Node/SSR environments. * * Use these instead of extending browser globals directly so that class definitions * do not throw a ReferenceError at module evaluation time in SSR/Node contexts * (SvelteKit, Next.js, etc.). * * In browser environments each constant is the real global; in SSR it falls back * to a plain empty class so that `class Foo extends HTMLElementBase` is valid. */ /** True when running in an SSR/Node environment (no browser globals). */ export const SSR = typeof window === "undefined"; /** SSR-safe base class for web components. */ export const HTMLElementBase = typeof HTMLElement !== "undefined" ? HTMLElement : class { }; /** SSR-safe base class for pointer events. */ export const PointerEventBase = typeof PointerEvent !== "undefined" ? PointerEvent : class { }; /** SSR-safe base class for keyboard events. */ export const KeyboardEventBase = typeof KeyboardEvent !== "undefined" ? KeyboardEvent : class { }; // #region minimal polyfills // Three.js FileLoader uses ProgressEvent in fetch stream callbacks. // It doesn't exist in Node — install a minimal stub so SSR doesn't crash. if (typeof globalThis.ProgressEvent === "undefined") { globalThis.ProgressEvent = class ProgressEvent { type; lengthComputable; loaded; total; constructor(type, init) { this.type = type; this.lengthComputable = init?.lengthComputable ?? false; this.loaded = init?.loaded ?? 0; this.total = init?.total ?? 0; } }; } // #endregion //# sourceMappingURL=engine_ssr.js.map