@@ -96,7 +96,7 @@ function init() {
96
96
pendingScripts : { __proto__ : null } ,
97
97
pendingWrites : { __proto__ : null } ,
98
98
reloaded : false ,
99
- safeGlobal : Function ( "return this" ) ( ) ,
99
+ safeGlobal : __global__ ,
100
100
support,
101
101
symbol,
102
102
unsafeGlobal : global ,
@@ -115,7 +115,8 @@ function init() {
115
115
} )
116
116
117
117
setDeferred ( shared , "customInspectKey" , ( ) => {
118
- const { customInspectSymbol } = shared . module . safeUtil
118
+ const { safeUtil } = shared . module
119
+ const { customInspectSymbol } = safeUtil
119
120
120
121
return typeof customInspectSymbol === "symbol"
121
122
? customInspectSymbol
@@ -129,7 +130,10 @@ function init() {
129
130
} )
130
131
131
132
setDeferred ( shared , "originalConsole" , ( ) => {
132
- const { safeInspector, safeVM } = shared . module
133
+ const {
134
+ safeInspector,
135
+ safeVM
136
+ } = shared . module
133
137
134
138
return ( safeInspector && safeInspector . console ) ||
135
139
new safeVM . Script ( "console" ) . runInNewContext ( )
@@ -146,37 +150,48 @@ function init() {
146
150
} )
147
151
148
152
setDeferred ( shared , "runtimeName" , ( ) => {
153
+ const { safeCrypto } = shared . module
154
+
149
155
return encodeId (
150
156
"_" +
151
- shared . module . safeCrypto . createHash ( "md5" )
157
+ safeCrypto . createHash ( "md5" )
152
158
. update ( Date . now ( ) . toString ( ) )
153
159
. digest ( "hex" )
154
160
. slice ( 0 , 3 )
155
161
)
156
162
} )
157
163
158
164
setDeferred ( shared , "unsafeContext" , ( ) => {
159
- const { safeVM, utilPrepareContext } = shared . module
165
+ const {
166
+ safeVM,
167
+ utilPrepareContext
168
+ } = shared . module
160
169
161
170
return utilPrepareContext ( safeVM . createContext ( shared . unsafeGlobal ) )
162
171
} )
163
172
164
173
setDeferred ( support , "await" , ( ) => {
174
+ const { safeVM } = shared . module
175
+
165
176
try {
166
- Function ( "async()=>await 1" ) ( )
177
+ new safeVM . Script ( "async()=>await 1" ) . runInThisContext ( )
167
178
return true
168
179
} catch { }
169
180
170
181
return false
171
182
} )
172
183
173
184
setDeferred ( support , "createCachedData" , ( ) => {
174
- return typeof shared . module . safeVM . Script . prototype . createCachedData === "function"
185
+ const { safeVM } = shared . module
186
+
187
+ return typeof safeVM . Script . prototype . createCachedData === "function"
175
188
} )
176
189
177
190
setDeferred ( support , "inspectProxies" , ( ) => {
191
+ const { safeUtil } = shared . module
192
+
178
193
// Node < 6.1.0 does not support inspecting proxies.
179
- const inspected = shared . module . safeUtil . inspect ( dummyProxy , {
194
+ const inspected = safeUtil . inspect ( dummyProxy , {
180
195
depth : 1 ,
181
196
showProxy : true
182
197
} )
@@ -203,10 +218,12 @@ function init() {
203
218
} )
204
219
205
220
setDeferred ( support , "nativeProxyReceiver" , ( ) => {
221
+ const { SafeBuffer } = shared . module
222
+
206
223
// Detect support for invoking native functions with a proxy receiver.
207
224
// https://bugs.chromium.org/p/v8/issues/detail?id=5773
208
225
try {
209
- const proxy = new Proxy ( shared . module . SafeBuffer . alloc ( 0 ) , {
226
+ const proxy = new Proxy ( SafeBuffer . alloc ( 0 ) , {
210
227
get : ( target , name ) => target [ name ]
211
228
} )
212
229
@@ -220,7 +237,10 @@ function init() {
220
237
} )
221
238
222
239
setDeferred ( support , "replShowProxy" , ( ) => {
223
- const { safeProcess, utilSatisfies } = shared . module
240
+ const {
241
+ safeProcess,
242
+ utilSatisfies
243
+ } = shared . module
224
244
225
245
return utilSatisfies ( safeProcess . version , ">=10" )
226
246
} )
@@ -238,7 +258,10 @@ function init() {
238
258
} )
239
259
240
260
setDeferred ( utilBinding , "hiddenKeyType" , ( ) => {
241
- const { safeProcess, utilSatisfies } = shared . module
261
+ const {
262
+ safeProcess,
263
+ utilSatisfies
264
+ } = shared . module
242
265
243
266
return utilSatisfies ( safeProcess . version , "<7" )
244
267
? "string"
0 commit comments