@@ -29,6 +29,7 @@ import {LocationDelegationConfig} from './features/LocationDelegationFeature';
2929import { PlayBillingConfig } from './features/PlayBillingFeature' ;
3030import { FirstRunFlagConfig } from './features/FirstRunFlagFeature' ;
3131import { ArCoreConfig } from './features/ArCoreFeature' ;
32+ import { FileHandler , processFileHandlers } from './types/FileHandler' ;
3233
3334// The minimum size needed for the app icon.
3435const MIN_ICON_SIZE = 512 ;
@@ -171,6 +172,7 @@ export class TwaManifest {
171172 additionalTrustedOrigins : string [ ] ;
172173 retainedBundles : number [ ] ;
173174 protocolHandlers ?: ProtocolHandler [ ] ;
175+ fileHandlers ?: FileHandler [ ] ;
174176
175177 private static log = new ConsoleLog ( 'twa-manifest' ) ;
176178
@@ -222,6 +224,7 @@ export class TwaManifest {
222224 this . additionalTrustedOrigins = data . additionalTrustedOrigins || [ ] ;
223225 this . retainedBundles = data . retainedBundles || [ ] ;
224226 this . protocolHandlers = data . protocolHandlers ;
227+ this . fileHandlers = data . fileHandlers ;
225228 }
226229
227230 /**
@@ -321,6 +324,12 @@ export class TwaManifest {
321324 fullScopeUrl ,
322325 ) ;
323326
327+ const fileHandlers = processFileHandlers (
328+ webManifest . file_handlers ?? [ ] ,
329+ fullStartUrl ,
330+ fullScopeUrl ,
331+ ) ;
332+
324333 const twaManifest = new TwaManifest ( {
325334 packageId : generatePackageId ( webManifestUrl . host ) || '' ,
326335 host : webManifestUrl . host ,
@@ -353,6 +362,7 @@ export class TwaManifest {
353362 orientation : asOrientation ( webManifest . orientation ) || DEFAULT_ORIENTATION ,
354363 fullScopeUrl : fullScopeUrl . toString ( ) ,
355364 protocolHandlers : processedProtocolHandlers ,
365+ fileHandlers,
356366 } ) ;
357367 return twaManifest ;
358368 }
@@ -505,6 +515,18 @@ export class TwaManifest {
505515 const fullStartUrl : URL = new URL ( webManifest [ 'start_url' ] || '/' , webManifestUrl ) ;
506516 const fullScopeUrl : URL = new URL ( webManifest [ 'scope' ] || '.' , webManifestUrl ) ;
507517
518+ let fileHandlers = oldTwaManifestJson . fileHandlers ;
519+ if ( ! ( fieldsToIgnore . includes ( 'file_handlers' ) ) ) {
520+ fileHandlers = processFileHandlers (
521+ webManifest . file_handlers ?? [ ] ,
522+ fullStartUrl ,
523+ fullScopeUrl ,
524+ ) ;
525+ if ( fileHandlers . length == 0 ) {
526+ fileHandlers = oldTwaManifestJson . fileHandlers ;
527+ }
528+ }
529+
508530 const twaManifest = new TwaManifest ( {
509531 ...oldTwaManifestJson ,
510532 name : this . getNewFieldValue ( 'name' , fieldsToIgnore , oldTwaManifest . name ,
@@ -527,6 +549,7 @@ export class TwaManifest {
527549 monochromeIconUrl : monochromeIconUrl || oldTwaManifestJson . monochromeIconUrl ,
528550 shortcuts : shortcuts ,
529551 protocolHandlers : protocolHandlers ,
552+ fileHandlers,
530553 } ) ;
531554 return twaManifest ;
532555 }
@@ -583,6 +606,7 @@ export interface TwaManifestJson {
583606 additionalTrustedOrigins ?: string [ ] ;
584607 retainedBundles ?: number [ ] ;
585608 protocolHandlers ?: ProtocolHandler [ ] ;
609+ fileHandlers ?: FileHandler [ ] ;
586610}
587611
588612export interface SigningKeyInfo {
0 commit comments