@@ -618,8 +618,37 @@ var AMDLoader;
618618 } ;
619619 return OnlyOnceScriptLoader ;
620620 } ( ) ) ;
621+ var trustedTypesPolyfill = new /** @class */ ( function ( ) {
622+ function class_1 ( ) {
623+ }
624+ class_1 . prototype . installIfNeeded = function ( ) {
625+ if ( typeof globalThis . trustedTypes !== 'undefined' ) {
626+ return ; // already defined
627+ }
628+ var _defaultRules = {
629+ createHTML : function ( ) { throw new Error ( 'Policy\'s TrustedTypePolicyOptions did not specify a \'createHTML\' member' ) ; } ,
630+ createScript : function ( ) { throw new Error ( 'Policy\'s TrustedTypePolicyOptions did not specify a \'createScript\' member' ) ; } ,
631+ createScriptURL : function ( ) { throw new Error ( 'Policy\'s TrustedTypePolicyOptions did not specify a \'createScriptURL\' member' ) ; } ,
632+ } ;
633+ globalThis . trustedTypes = {
634+ createPolicy : function ( name , rules ) {
635+ var _a , _b , _c ;
636+ return {
637+ name : name ,
638+ createHTML : ( _a = rules . createHTML ) !== null && _a !== void 0 ? _a : _defaultRules . createHTML ,
639+ createScript : ( _b = rules . createScript ) !== null && _b !== void 0 ? _b : _defaultRules . createScript ,
640+ createScriptURL : ( _c = rules . createScriptURL ) !== null && _c !== void 0 ? _c : _defaultRules . createScriptURL ,
641+ } ;
642+ }
643+ } ;
644+ } ;
645+ return class_1 ;
646+ } ( ) ) ;
647+ //#endregion
621648 var BrowserScriptLoader = /** @class */ ( function ( ) {
622649 function BrowserScriptLoader ( ) {
650+ // polyfill trustedTypes-support if missing
651+ trustedTypesPolyfill . installIfNeeded ( ) ;
623652 }
624653 /**
625654 * Attach load / error listeners to a script element and remove them when either one has fired.
@@ -662,6 +691,13 @@ var AMDLoader;
662691 script . setAttribute ( 'async' , 'async' ) ;
663692 script . setAttribute ( 'type' , 'text/javascript' ) ;
664693 this . attachListeners ( script , callback , errorback ) ;
694+ var createTrustedScriptURL = moduleManager . getConfig ( ) . getOptionsLiteral ( ) . createTrustedScriptURL ;
695+ if ( createTrustedScriptURL ) {
696+ if ( ! this . scriptSourceURLPolicy ) {
697+ this . scriptSourceURLPolicy = trustedTypes . createPolicy ( 'amdLoader' , { createScriptURL : createTrustedScriptURL } ) ;
698+ }
699+ scriptSrc = this . scriptSourceURLPolicy . createScriptURL ( scriptSrc ) ;
700+ }
665701 script . setAttribute ( 'src' , scriptSrc ) ;
666702 // Propagate CSP nonce to dynamically created script tag.
667703 var cspNonce = moduleManager . getConfig ( ) . getOptionsLiteral ( ) . cspNonce ;
@@ -675,8 +711,17 @@ var AMDLoader;
675711 } ( ) ) ;
676712 var WorkerScriptLoader = /** @class */ ( function ( ) {
677713 function WorkerScriptLoader ( ) {
714+ // polyfill trustedTypes-support if missing
715+ trustedTypesPolyfill . installIfNeeded ( ) ;
678716 }
679717 WorkerScriptLoader . prototype . load = function ( moduleManager , scriptSrc , callback , errorback ) {
718+ var createTrustedScriptURL = moduleManager . getConfig ( ) . getOptionsLiteral ( ) . createTrustedScriptURL ;
719+ if ( createTrustedScriptURL ) {
720+ if ( ! this . scriptSourceURLPolicy ) {
721+ this . scriptSourceURLPolicy = trustedTypes . createPolicy ( 'amdLoader' , { createScriptURL : createTrustedScriptURL } ) ;
722+ }
723+ scriptSrc = this . scriptSourceURLPolicy . createScriptURL ( scriptSrc ) ;
724+ }
680725 try {
681726 importScripts ( scriptSrc ) ;
682727 callback ( ) ;
0 commit comments