@@ -15,10 +15,10 @@ const wraptile = require('wraptile');
1515const smalltalk = require ( 'smalltalk' ) ;
1616const jssha = require ( 'jssha' ) ;
1717const restafary = require ( 'restafary/client' ) ;
18- const tryToCatch = require ( 'try-to-catch' ) ;
18+ const { tryToCatch} = require ( 'try-to-catch' ) ;
1919
20- window . load = window . load || load ;
21- window . exec = window . exec || exec ;
20+ globalThis . load = globalThis . load || load ;
21+ globalThis . exec = globalThis . exec || exec ;
2222
2323const Story = require ( './story' ) ;
2424const _clipboard = require ( './_clipboard' ) ;
@@ -101,45 +101,45 @@ Edward.prototype._init = function(fn) {
101101 exec . series ( [
102102 loadFiles ,
103103 async ( callback ) => {
104- await loadremote ( 'socket' , {
105- name : 'io' ,
106- prefix : this . _SOCKET_PATH ,
107- } ) ;
108-
109- initSocket ( ) ;
110- callback ( ) ;
111- } ,
104+ await loadremote ( 'socket' , {
105+ name : 'io' ,
106+ prefix : this . _SOCKET_PATH ,
107+ } ) ;
108+
109+ initSocket ( ) ;
110+ callback ( ) ;
111+ } ,
112112 async ( ) => {
113- this . _Emitter = Emitify ( ) ;
114- this . _Ace = ace . edit ( this . _Element ) ;
115- this . _Modelist = ace . require ( 'ace/ext/modelist' ) ;
116-
117- this . _Emitter . on ( 'auth' , ( username , password ) => {
118- this . _socket . emit ( 'auth' , username , password ) ;
119- } ) ;
120-
121- ace . require ( 'ace/ext/language_tools' ) ;
122-
123- this . _addCommands ( ) ;
124- this . _Ace . $blockScrolling = Infinity ;
125-
126- const config = await load . json ( this . _PREFIX + '/edit.json' ) ;
127-
128- const { options = { } } = config ;
129-
130- const preventOverwrite = ( ) => {
131- for ( const name of Object . keys ( this . _Config . options ) ) {
132- options [ name ] = this . _Config . options [ name ] ;
133- }
134- } ;
135-
136- fn ( ) ;
137- preventOverwrite ( ) ;
138-
139- this . _Config = config ;
140-
141- edward . setOptions ( options ) ;
142- } ,
113+ this . _Emitter = Emitify ( ) ;
114+ this . _Ace = ace . edit ( this . _Element ) ;
115+ this . _Modelist = ace . require ( 'ace/ext/modelist' ) ;
116+
117+ this . _Emitter . on ( 'auth' , ( username , password ) => {
118+ this . _socket . emit ( 'auth' , username , password ) ;
119+ } ) ;
120+
121+ ace . require ( 'ace/ext/language_tools' ) ;
122+
123+ this . _addCommands ( ) ;
124+ this . _Ace . $blockScrolling = Infinity ;
125+
126+ const config = await load . json ( this . _PREFIX + '/edit.json' ) ;
127+
128+ const { options = { } } = config ;
129+
130+ const preventOverwrite = ( ) => {
131+ for ( const name of Object . keys ( this . _Config . options ) ) {
132+ options [ name ] = this . _Config . options [ name ] ;
133+ }
134+ } ;
135+
136+ fn ( ) ;
137+ preventOverwrite ( ) ;
138+
139+ this . _Config = config ;
140+
141+ edward . setOptions ( options ) ;
142+ } ,
143143 ] ) ;
144144} ;
145145
@@ -190,7 +190,7 @@ Edward.prototype._addCommands = function() {
190190Edward . prototype . evaluate = function ( ) {
191191 const edward = this ;
192192 const focus = edward . focus . bind ( this ) ;
193- const isJS = / \. j s $ / . test ( this . _filename ) ;
193+ const isJS = this . _filename . endsWith ( '.js' ) ;
194194
195195 if ( ! isJS )
196196 return smalltalk
@@ -216,17 +216,17 @@ Edward.prototype.addKeyMap = function(keyMap) {
216216 const map = Object
217217 . keys ( keyMap )
218218 . map ( ( name , i ) => {
219- const key = {
220- name : String ( Math . random ( ) ) + i ,
221- bindKey : {
222- win : name ,
223- mac : name . replace ( 'Ctrl' , 'Command' ) ,
224- } ,
225- exec : keyMap [ name ] ,
226- } ;
227-
228- return key ;
229- } ) ;
219+ const key = {
220+ name : String ( Math . random ( ) ) + i ,
221+ bindKey : {
222+ win : name ,
223+ mac : name . replace ( 'Ctrl' , 'Command' ) ,
224+ } ,
225+ exec : keyMap [ name ] ,
226+ } ;
227+
228+ return key ;
229+ } ) ;
230230
231231 map . forEach ( this . _addKey ( ) ) ;
232232
0 commit comments