33// (really, it's just the browser client with some Node libraries to supply fake
44// browser globals.)
55
6- // Do aliases to get around Node modules.
7- const nymphPath = require . resolve ( 'nymph-client' ) . replace ( / l i b \/ N y m p h (?: \. j s ) ? $ / , '' ) ;
8- const alias = require ( 'module-alias' ) ;
9- alias . addAliases ( {
10- 'Nymph' : nymphPath + 'lib/Nymph' ,
11- 'NymphEntity' : nymphPath + 'lib/Entity' ,
12- 'NymphPubSub' : nymphPath + 'lib/PubSub' ,
13- 'Entity' : nymphPath + 'lib/Entity' ,
14- 'PubSub' : nymphPath + 'lib/PubSub'
15- } ) ;
16-
176// Nymph expects the global browser objects XMLHttpRequest and WebSocket.
18- global . XMLHttpRequest = require ( " xmlhttprequest" ) . XMLHttpRequest ;
7+ global . XMLHttpRequest = require ( ' xmlhttprequest' ) . XMLHttpRequest ;
198global . WebSocket = require ( 'websocket' ) . w3cwebsocket ;
209// And sometimes we need the XHR object to support cookies.
2110const enableCookies = ( ) => {
22- const xhrc = require ( " xmlhttprequest-cookie" ) ;
11+ const xhrc = require ( ' xmlhttprequest-cookie' ) ;
2312 global . XMLHttpRequest = xhrc . XMLHttpRequest ;
2413} ;
2514
26- const Nymph = require ( 'Nymph' ) . Nymph ;
27- const PubSub = require ( 'NymphPubSub' ) . PubSub ;
15+ const nymphClient = require ( 'nymph-client' ) ;
16+ const { Nymph , PubSub} = nymphClient ;
2817
2918// Make a shortcut for PubSub init.
3019const _init = Nymph . init ;
@@ -35,4 +24,4 @@ Nymph.init = (nymphOptions) => {
3524 }
3625} ;
3726
38- module . exports = { Nymph, enableCookies} ;
27+ module . exports = { Nymph, PubSub , enableCookies, ... nymphClient } ;
0 commit comments