File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change 1
1
/* wenyan-catsrc-ignore */
2
2
3
3
( ( ) => {
4
- const { compile } = require ( "./parser" ) ;
4
+ const { execute } = require ( "./parser" ) ;
5
5
6
6
const isDev = false ;
7
7
8
8
async function run ( script ) {
9
9
const scoped = ! ! script . attributes . scoped ;
10
+ let code = script . innerText ;
10
11
if ( script . src ) {
11
12
const response = await fetch ( script . src ) ;
12
- const code = await response . text ( ) ;
13
- await exec ( code . toString ( ) , scoped ) ;
14
- } else {
15
- await exec ( script . innerText , scoped ) ;
13
+ code = ( await response . text ( ) ) . toString ( ) ;
16
14
}
17
- }
18
-
19
- async function exec ( code , scoped = false ) {
20
- let compiled = compile ( "js" , code , {
15
+ execute ( code , {
16
+ scoped,
21
17
logCallback : isDev ? console . log : ( ) => { } ,
22
18
resetVarCnt : false
23
19
} ) ;
24
-
25
- // wrap for scoped scripts that won't expose any variables to global
26
- if ( scoped ) compiled = `(()=>{${ compiled } })()` ;
27
-
28
- // executing
29
- window . eval ( compiled ) ;
30
20
}
31
21
32
22
document . addEventListener ( "DOMContentLoaded" , async ( ) => {
Original file line number Diff line number Diff line change @@ -818,7 +818,7 @@ function evalCompiled(compiledCode, options = {}) {
818
818
function execute ( source , options = { } ) {
819
819
const { lang = "js" } = options ;
820
820
isLangSupportedForEval ( lang ) ;
821
- const compiled = compile ( options . lang , source , options ) ;
821
+ const compiled = compile ( lang , source , options ) ;
822
822
evalCompiled ( compiled , options ) ;
823
823
}
824
824
You can’t perform that action at this time.
0 commit comments