@@ -5,27 +5,35 @@ import type {
5
5
TemplateManager ,
6
6
JavaScriptManager ,
7
7
} from '@garfish/loader' ;
8
- import { AppInfo } from './app' ;
8
+ import type { AppInfo } from './app' ;
9
+ import type { interfaces } from '../interface' ;
9
10
10
11
// Fetch `script`, `link` and `module meta` elements
11
12
function fetchStaticResources (
12
13
appName : string ,
13
14
loader : Loader ,
14
15
entryManager : TemplateManager ,
16
+ sandboxConfig : false | interfaces . SandboxConfig | undefined ,
15
17
) {
16
18
const toBoolean = ( val ) => typeof val !== 'undefined' && val !== 'false' ;
17
19
18
20
// Get all script elements
19
21
const jsNodes = Promise . all (
20
22
entryManager
21
23
. findAllJsNodes ( )
24
+ . filter ( ( node ) => {
25
+ if ( sandboxConfig && sandboxConfig . excludeAssetFilter ) {
26
+ const src = entryManager . findAttributeValue ( node , 'src' ) ;
27
+ if ( src && sandboxConfig . excludeAssetFilter ( src ) ) {
28
+ return false ;
29
+ }
30
+ }
31
+ return true ;
32
+ } )
22
33
. map ( ( node ) => {
23
34
const src = entryManager . findAttributeValue ( node , 'src' ) ;
24
35
const type = entryManager . findAttributeValue ( node , 'type' ) ;
25
- let crossOrigin = entryManager . findAttributeValue (
26
- node ,
27
- 'crossorigin' ,
28
- ) ;
36
+ let crossOrigin = entryManager . findAttributeValue ( node , 'crossorigin' ) ;
29
37
if ( crossOrigin === '' ) {
30
38
crossOrigin = 'anonymous' ;
31
39
}
@@ -150,6 +158,7 @@ export async function processAppResources(loader: Loader, appInfo: AppInfo) {
150
158
appInfo . name ,
151
159
loader ,
152
160
entryManager ,
161
+ appInfo . sandbox ,
153
162
) ;
154
163
resources . js = js ;
155
164
resources . link = link ;
0 commit comments