@@ -160,6 +160,7 @@ const WHATWG = Object.freeze({
160160 ImageData,
161161 ImageBitmap,
162162 ProgressEvent,
163+ Promise,
163164 Storage,
164165 WebSocket,
165166 XMLHttpRequest,
@@ -227,13 +228,22 @@ const OTHER = Object.freeze({
227228const tabrisMain = Object . assign ( new Tabris ( ) , WIDGETS , POPUPS , WHATWG , NATIVE_OBJECT , UTILS , OTHER ) ;
228229
229230/** @typedef {typeof tabrisMain } TabrisMain */
230- module . exports = tabrisMain ;
231- // @ts -ignore
232- global . tabris = tabrisMain ;
233- // @ts -ignore
234- global . tabris . tabris = tabrisMain ;
231+ if ( typeof module !== 'undefined' ) { // Allow loading in browser
232+ module . exports = tabrisMain ;
233+ }
235234
236- Object . assign ( global , WHATWG , { $} ) ;
235+ if ( global . document ) {
236+ // Running in browser
237+ global . tabris = tabrisMain ;
238+ global . JSX = tabrisMain . JSX ;
239+ } else {
240+ global . tabris = tabrisMain ;
241+ global . tabris . tabris = tabrisMain ;
242+ Object . assign ( global , WHATWG , { $} ) ;
243+ addDOMDocument ( global ) ;
244+ addDOMEventTargetMethods ( global ) ;
245+ addWindowTimerMethods ( global ) ;
246+ }
237247
238248tabrisMain . on ( 'start' , ( options ) => {
239249 // @ts -ignore
@@ -287,7 +297,3 @@ tabrisMain.on('start', (options) => {
287297 global . process = tabrisMain . process ;
288298 }
289299} ) ;
290-
291- addDOMDocument ( global ) ;
292- addDOMEventTargetMethods ( global ) ;
293- addWindowTimerMethods ( global ) ;
0 commit comments