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