import { IloadSPCore } from "../../../@types/helper/methods" ; /**
 * Loads the core SharePoint JavaScript library for JSOM.
 */ export const loadSPCore = ( ) => { return new Promise ( ( resolve ) => { let libs = [ "init" , "MicrosoftAjax" , "SP.Runtime" , "SP" ] ; for ( let i = 0 ; i < libs . length ; i ++ ) { let libName = libs [ i ] ; if ( document . querySelector ( "script[title='" + libName + "']" ) == null ) { console . debug ( "[gd-sprest] Loading the core library: " + libName ) ; let elScript = document . createElement ( "script" ) ; elScript . title = libName ; elScript . src = document . location . origin + "/_layouts/15/" + libName + ".js" ; document . head . appendChild ( elScript ) ; } else { console . debug ( "[gd-sprest] Core library already loaded: " + libName ) ; } resolve ( ) ; } } ) ; } ;