@@ -17,7 +17,7 @@ type UserScriptCandidate = {
1717 command : IUserScript ;
1818 index : number ;
1919 exportsRef ?: unknown ;
20- resolvedMember : { found : boolean ; value ?: unknown } ;
20+ resolvedMember ? : { found : boolean ; value ?: unknown } ;
2121} ;
2222
2323type MemberAccessSelection = {
@@ -98,16 +98,14 @@ export class SingleMacroEngine {
9898 throw new Error ( `macro '${ macroName } ' does not exist.` ) ;
9999 }
100100
101- const preloadedScripts = new Map < string , unknown > ( ) ;
102-
103101 // Create a dedicated engine for this macro
104102 const engine = new MacroChoiceEngine (
105103 this . app ,
106104 this . plugin ,
107105 macroChoice ,
108106 this . choiceExecutor ,
109107 this . variables ,
110- preloadedScripts ,
108+ undefined ,
111109 context ?. label ,
112110 ) ;
113111
@@ -116,7 +114,6 @@ export class SingleMacroEngine {
116114 engine ,
117115 macroChoice ,
118116 memberAccess ,
119- preloadedScripts ,
120117 ) ;
121118
122119 this . ensureNotAborted ( ) ;
@@ -154,7 +151,6 @@ export class SingleMacroEngine {
154151 engine : MacroChoiceEngine ,
155152 macroChoice : IMacroChoice ,
156153 memberAccess : string [ ] ,
157- preloadedScripts : Map < string , unknown > ,
158154 ) : Promise < { executed : boolean ; result ?: unknown } > {
159155 const originalCommands = macroChoice . macro ?. commands ;
160156 if ( ! originalCommands ?. length ) {
@@ -176,7 +172,6 @@ export class SingleMacroEngine {
176172 macroChoice ,
177173 userScriptCommands ,
178174 memberAccess ,
179- preloadedScripts ,
180175 ) ;
181176 const preCommands = originalCommands . slice ( 0 , selection . candidate . index ) ;
182177
@@ -210,11 +205,6 @@ export class SingleMacroEngine {
210205 ) ;
211206 }
212207
213- const cacheKey = userScriptCommand . path ?? userScriptCommand . id ;
214- if ( cacheKey && exportsRef !== undefined && exportsRef !== null ) {
215- preloadedScripts . set ( cacheKey , exportsRef ) ;
216- }
217-
218208 const settingsExport =
219209 typeof exportsRef === "object" || typeof exportsRef === "function"
220210 ? ( exportsRef as Record < string , unknown > ) . settings
@@ -228,9 +218,8 @@ export class SingleMacroEngine {
228218 }
229219
230220 const resolvedMember =
231- selection . candidate . exportsRef !== undefined
232- ? selection . candidate . resolvedMember
233- : this . resolveMemberAccess ( exportsRef , selection . memberAccess ) ;
221+ selection . candidate . resolvedMember ??
222+ this . resolveMemberAccess ( exportsRef , selection . memberAccess ) ;
234223
235224 if ( ! resolvedMember . found ) {
236225 throw new MacroAbortError (
@@ -327,14 +316,12 @@ export class SingleMacroEngine {
327316 macroChoice : IMacroChoice ,
328317 userScriptCommands : Array < { command : IUserScript ; index : number } > ,
329318 memberAccess : string [ ] ,
330- preloadedScripts : Map < string , unknown > ,
331319 ) : Promise < MemberAccessSelection > {
332320 if ( userScriptCommands . length === 1 ) {
333321 return {
334322 candidate : {
335323 command : userScriptCommands [ 0 ] . command ,
336324 index : userScriptCommands [ 0 ] . index ,
337- resolvedMember : { found : false } ,
338325 } ,
339326 memberAccess,
340327 } ;
@@ -347,44 +334,21 @@ export class SingleMacroEngine {
347334 ) ;
348335
349336 if ( selectorMatch ) {
350- const exportsRef = await getUserScript ( selectorMatch . command , this . app ) ;
351- const cacheKey = selectorMatch . command . path ?? selectorMatch . command . id ;
352- if ( cacheKey && exportsRef !== undefined && exportsRef !== null ) {
353- preloadedScripts . set ( cacheKey , exportsRef ) ;
354- }
355-
356- const resolvedMember = this . resolveMemberAccess (
357- exportsRef ,
358- selectorMatch . memberAccess ,
359- ) ;
360- if ( ! resolvedMember . found ) {
361- throw new MacroAbortError (
362- `Macro '${ macroChoice . name } ' targeted script '${ selectorMatch . command . name } ', but that script does not export '${ selectorMatch . memberAccess . join (
363- "::" ,
364- ) } '.`,
365- ) ;
366- }
367-
368337 return {
369338 candidate : {
370339 command : selectorMatch . command ,
371340 index : selectorMatch . index ,
372- exportsRef,
373- resolvedMember,
374341 } ,
375342 memberAccess : selectorMatch . memberAccess ,
376343 } ;
377344 }
378345
379- const candidates : UserScriptCandidate [ ] = [ ] ;
346+ const candidates : Array <
347+ UserScriptCandidate & { resolvedMember : { found : boolean ; value ?: unknown } }
348+ > = [ ] ;
380349
381350 for ( const entry of userScriptCommands ) {
382351 const exportsRef = await getUserScript ( entry . command , this . app ) ;
383- const cacheKey = entry . command . path ?? entry . command . id ;
384- if ( cacheKey && exportsRef !== undefined && exportsRef !== null ) {
385- preloadedScripts . set ( cacheKey , exportsRef ) ;
386- }
387-
388352 candidates . push ( {
389353 command : entry . command ,
390354 index : entry . index ,
0 commit comments