1// Copyright 2015-present 650 Industries. All rights reserved. 2 3#if __has_include(<EXFileSystem/EXFileSystem.h>) 4#import "EXScopedFileSystemModule.h" 5#import "EXUtil.h" 6 7// TODO @sjchmiela: Should this be versioned? It is only used in detached scenario. 8NSString * const EXShellManifestResourceName = @"shell-app-manifest"; 9 10@implementation EXScopedFileSystemModule 11 12- (NSDictionary *)constantsToExport 13{ 14 NSMutableDictionary *constants = [[NSMutableDictionary alloc] initWithDictionary:[super constantsToExport]]; 15 constants[@"bundledAssets"] = [self bundledAssets] ?: [NSNull null]; 16 return constants; 17} 18 19- (NSArray<NSString *> *)bundledAssets 20{ 21 static NSArray<NSString *> *bundledAssets = nil; 22 static dispatch_once_t once; 23 dispatch_once(&once, ^{ 24 NSString *manifestBundlePath = [[NSBundle mainBundle] pathForResource:EXShellManifestResourceName ofType:@"json"]; 25 NSData *data = [NSData dataWithContentsOfFile:manifestBundlePath]; 26 if (data.length == 0) { 27 return; 28 } 29 __block NSError *error; 30 id manifest = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; 31 if (error) { 32 EXLogError(@"Error parsing bundled manifest: %@", error); 33 return; 34 } 35 bundledAssets = manifest[@"bundledAssets"]; 36 }); 37 return bundledAssets; 38} 39 40@end 41#endif 42