@@ -221,6 +221,12 @@ function tokenRomanize(tokens, method) {
221
221
}
222
222
}
223
223
224
+ function defaultLogCallback ( x ) {
225
+ return typeof x == "string"
226
+ ? console . log ( x )
227
+ : console . dir ( x , { depth : null , maxArrayLength : null } ) ;
228
+ }
229
+
224
230
function tokens2asc (
225
231
tokens ,
226
232
assert = ( msg , pos , b ) => {
@@ -648,18 +654,24 @@ async function compile(arg1, arg2, arg3) {
648
654
const {
649
655
lang = "js" ,
650
656
romanizeIdentifiers = "none" ,
651
- resetVarCnt,
652
- logCallback = x =>
653
- typeof x == "string"
654
- ? console . log ( x )
655
- : console . dir ( x , { depth : null , maxArrayLength : null } ) ,
657
+ resetVarCnt = true ,
658
+ logCallback = defaultLogCallback ,
656
659
errorCallback = process . exit ,
657
660
lib = typeof STDLIB == "undefined" ? { } : STDLIB ,
658
661
reader = defaultImportReader ,
659
662
importPaths = [ ] ,
660
- strict = false
663
+ strict = false ,
664
+ allowHttp = false ,
665
+ trustedHosts = [ ] ,
666
+ requestTimeout = 2000
661
667
} = options ;
662
668
669
+ const requestOptions = {
670
+ allowHttp,
671
+ trustedHosts,
672
+ requestTimeout
673
+ } ;
674
+
663
675
if ( resetVarCnt ) idenMap = { } ;
664
676
txt = ( txt || "" ) . replace ( / \r \n / g, "\n" ) ;
665
677
@@ -689,7 +701,13 @@ async function compile(arg1, arg2, arg3) {
689
701
return 0 ;
690
702
}
691
703
692
- var macros = await extractMacros ( txt , { lib, reader, lang, importPaths } ) ;
704
+ var macros = await extractMacros ( txt , {
705
+ lib,
706
+ reader,
707
+ lang,
708
+ importPaths,
709
+ requestOptions
710
+ } ) ;
693
711
txt = expandMacros ( txt , macros ) ;
694
712
695
713
logCallback ( "\n\n=== [PASS 0] EXPAND-MACROS ===" ) ;
@@ -743,15 +761,9 @@ async function compile(arg1, arg2, arg3) {
743
761
mwrapper (
744
762
imports [ i ] ,
745
763
await compile ( isrc , {
746
- lang,
747
- romanizeIdentifiers,
764
+ ...options ,
748
765
resetVarCnt : false ,
749
- strict : false ,
750
- logCallback,
751
- errorCallback,
752
- lib,
753
- reader,
754
- importPaths
766
+ strict : false
755
767
} )
756
768
) + targ ;
757
769
}
0 commit comments