1- import { Notice , TFile } from "obsidian" ;
1+ import { TFile } from "obsidian" ;
22import { IGenerateObject } from "automations/IGenerateObject" ;
33import { get_tfiles_from_folder } from "helpers/FileManagement" ;
44import { LocalSettings } from "cdm/SettingsModel" ;
55import { LOGGER } from "services/Logger" ;
66
7- export class UserScriptFunctions implements IGenerateObject {
7+ export class ScriptFunctions implements IGenerateObject {
88 constructor ( private config : LocalSettings ) { }
99
10- async generate_user_script_functions (
10+ async generate_script_functions (
1111 ) : Promise < Map < string , Function > > {
12- const user_script_functions : Map < string , Function > = new Map ( ) ;
12+ const script_functions : Map < string , Function > = new Map ( ) ;
1313 const files =
1414 get_tfiles_from_folder (
1515 this . config . formula_folder_path ,
@@ -21,18 +21,18 @@ export class UserScriptFunctions implements IGenerateObject {
2121
2222 for ( const file of files ) {
2323 if ( file . extension . toLowerCase ( ) === "js" ) {
24- await this . load_user_script_function (
24+ await this . load_script_function (
2525 file ,
26- user_script_functions
26+ script_functions
2727 ) ;
2828 }
2929 }
30- return user_script_functions ;
30+ return script_functions ;
3131 }
3232
33- async load_user_script_function (
33+ async load_script_function (
3434 file : TFile ,
35- user_script_functions : Map < string , Function >
35+ script_functions : Map < string , Function >
3636 ) : Promise < void > {
3737 let req = ( s : string ) => {
3838 return window . require && window . require ( s ) ;
@@ -48,20 +48,20 @@ export class UserScriptFunctions implements IGenerateObject {
4848 const formula_function = exp [ 'default' ] || mod . exports ;
4949
5050 if ( ! formula_function ) {
51- const msg = `Failed to load user script ${ file . path } . No exports detected.` ;
51+ const msg = `Failed to load script ${ file . path } . No exports detected.` ;
5252 LOGGER . error ( msg ) ;
5353 return ;
5454 }
5555 if ( ! ( formula_function instanceof Function ) ) {
56- const msg = `Failed to load user script ${ file . path } . Default export is not a function.`
56+ const msg = `Failed to load script ${ file . path } . Default export is not a function.`
5757 LOGGER . error ( msg ) ;
5858 return ;
5959 }
60- user_script_functions . set ( `${ file . basename } ` , formula_function ) ;
60+ script_functions . set ( `${ file . basename } ` , formula_function ) ;
6161 }
6262
6363 async generate_object ( ) : Promise < Record < string , unknown > > {
64- const user_script_functions = await this . generate_user_script_functions ( ) ;
65- return Object . fromEntries ( user_script_functions ) ;
64+ const script_functions = await this . generate_script_functions ( ) ;
65+ return Object . fromEntries ( script_functions ) ;
6666 }
6767}
0 commit comments