@@ -7,42 +7,42 @@ import { resizePNG } from './icon/index.js'
7
7
8
8
import * as monaco from 'monaco-editor'
9
9
10
- function rgbaToHex ( rgbaString ) {
11
- const rgbaValues = rgbaString . match ( / \d + / g) ;
12
-
13
- const r = parseInt ( rgbaValues [ 0 ] ) ;
14
- const g = parseInt ( rgbaValues [ 1 ] ) ;
15
- const b = parseInt ( rgbaValues [ 2 ] ) ;
16
-
17
- const a = Math . round ( parseFloat ( rgbaValues [ 3 ] ) * 255 ) ;
18
-
19
- const rHex = r . toString ( 16 ) . padStart ( 2 , '0' ) ;
20
- const gHex = g . toString ( 16 ) . padStart ( 2 , '0' ) ;
21
- const bHex = b . toString ( 16 ) . padStart ( 2 , '0' ) ;
22
- const aHex = a . toString ( 16 ) . padStart ( 2 , '0' ) ;
23
-
24
- return `#${ rHex } ${ gHex } ${ bHex } ${ aHex } ` ;
10
+ function rgbaToHex ( rgbaString ) {
11
+ const rgbaValues = rgbaString . match ( / \d + / g)
12
+
13
+ const r = parseInt ( rgbaValues [ 0 ] )
14
+ const g = parseInt ( rgbaValues [ 1 ] )
15
+ const b = parseInt ( rgbaValues [ 2 ] )
16
+
17
+ const a = Math . round ( parseFloat ( rgbaValues [ 3 ] ) * 255 )
18
+
19
+ const rHex = r . toString ( 16 ) . padStart ( 2 , '0' )
20
+ const gHex = g . toString ( 16 ) . padStart ( 2 , '0' )
21
+ const bHex = b . toString ( 16 ) . padStart ( 2 , '0' )
22
+ const aHex = a . toString ( 16 ) . padStart ( 2 , '0' )
23
+
24
+ return `#${ rHex } ${ gHex } ${ bHex } ${ aHex } `
25
25
}
26
26
27
27
globalThis . MonacoEnvironment = {
28
28
getWorkerUrl : function ( moduleId , label ) {
29
29
if ( label === 'json' ) {
30
- return 'vs/language/json/json.worker.js' ;
30
+ return 'vs/language/json/json.worker.js'
31
31
}
32
32
33
33
if ( label === 'css' || label === 'scss' || label === 'less' ) {
34
- return 'vs/language/css/css.worker.js' ;
34
+ return 'vs/language/css/css.worker.js'
35
35
}
36
36
37
37
if ( label === 'html' || label === 'handlebars' || label === 'razor' ) {
38
- return 'vs/language/html/html.worker.js' ;
38
+ return 'vs/language/html/html.worker.js'
39
39
}
40
40
41
41
if ( label === 'typescript' || label === 'javascript' ) {
42
- return 'vs/language/typescript/ts.worker.js' ;
42
+ return 'vs/language/typescript/ts.worker.js'
43
43
}
44
44
45
- return 'vs/editor/editor.worker.js' ;
45
+ return 'vs/editor/editor.worker.js'
46
46
}
47
47
}
48
48
@@ -60,14 +60,14 @@ class AppEditor extends Tonic {
60
60
const pickerOpts = {
61
61
types : [
62
62
{
63
- description : " Images" ,
63
+ description : ' Images' ,
64
64
accept : {
65
- " image/*" : [ '.png' ] ,
66
- } ,
67
- } ,
65
+ ' image/*' : [ '.png' ]
66
+ }
67
+ }
68
68
] ,
69
69
excludeAcceptAllOption : true ,
70
- multiple : false ,
70
+ multiple : false
71
71
}
72
72
73
73
if ( event === 'size' ) {
@@ -119,7 +119,6 @@ class AppEditor extends Tonic {
119
119
120
120
if ( type . length ) {
121
121
if ( / i m a g e / . test ( type [ 0 ] . mime ) ) {
122
-
123
122
// Display a preview for this type.
124
123
return
125
124
}
@@ -209,43 +208,43 @@ class AppEditor extends Tonic {
209
208
monaco . editor . setTheme ( theme )
210
209
}
211
210
212
- async loadAPIs ( directoryPath = './socket' ) {
211
+ async loadAPIs ( directoryPath = './socket' ) {
213
212
const readDir = async ( dirPath ) => {
214
- const entries = await fs . promises . readdir ( dirPath , { withFileTypes : true } ) ;
213
+ const entries = await fs . promises . readdir ( dirPath , { withFileTypes : true } )
215
214
216
215
entries . forEach ( async ( entry ) => {
217
- const fullPath = path . join ( dirPath , entry . name ) ;
216
+ const fullPath = path . join ( dirPath , entry . name )
218
217
219
218
if ( entry . isDirectory ( ) ) {
220
- readDir ( fullPath ) . catch ( err => console . error ( `Error reading directory ${ fullPath } :` , err ) ) ;
219
+ readDir ( fullPath ) . catch ( err => console . error ( `Error reading directory ${ fullPath } :` , err ) )
221
220
} else {
222
221
if ( path . extname ( fullPath ) === '.ts' ) {
223
222
fs . promises . readFile ( fullPath , 'utf8' )
224
223
. then ( sourceText => {
225
- monaco . languages . typescript . javascriptDefaults . addExtraLib ( sourceText , `socket/${ fullPath } ` ) ;
226
- monaco . languages . typescript . typescriptDefaults . addExtraLib ( sourceText , `socket/${ fullPath } ` ) ;
224
+ monaco . languages . typescript . javascriptDefaults . addExtraLib ( sourceText , `socket/${ fullPath } ` )
225
+ monaco . languages . typescript . typescriptDefaults . addExtraLib ( sourceText , `socket/${ fullPath } ` )
227
226
} )
228
- . catch ( err => console . error ( `Error reading file ${ fullPath } :` , err ) ) ;
227
+ . catch ( err => console . error ( `Error reading file ${ fullPath } :` , err ) )
229
228
}
230
229
}
231
- } ) ;
232
- } ;
230
+ } )
231
+ }
233
232
234
233
try {
235
- await readDir ( directoryPath ) ;
234
+ await readDir ( directoryPath )
236
235
} catch ( err ) {
237
- console . error ( 'Error initiating read directory operation:' , err ) ;
236
+ console . error ( 'Error initiating read directory operation:' , err )
238
237
}
239
238
}
240
239
241
240
async refreshSettings ( ) {
242
- let parent = this . props . parent
241
+ const parent = this . props . parent
243
242
this . editor . updateOptions ( parent . state . settings ?. editorOptions || { } )
244
243
}
245
244
246
245
connected ( ) {
247
246
let theme
248
- let parent = this . props . parent
247
+ const parent = this . props . parent
249
248
250
249
this . editor = monaco . editor . create ( this . querySelector ( '.editor' ) , {
251
250
value : '' ,
0 commit comments