FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
runtimes/NativeScript/cli/BundleLoader.mm at main · NativeScript/runtimes · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
NativeScript
/
runtimes
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2
Star
26
Code
Issues
13
Pull requests
5
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
runtimes
/
NativeScript
/
cli
/
BundleLoader.mm
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (44 loc) · 2.02 KB
Breadcrumbs
runtimes
/
NativeScript
/
cli
/
BundleLoader.mm
Copy path
File metadata and controls
51 lines (44 loc) · 2.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
include
"
BundleLoader.h
"
#
include
<
Foundation/Foundation.h
>
//
Check if Resources/app/ exists, then load package.json["main"] || app/index.js full file path
std::string
resolveMainPath
() {
NSFileManager
* fileManager = [
NSFileManager
defaultManager
];
NSString
* resourcesPath = [[
NSBundle
mainBundle
]
resourcePath
];
NSString
* appPath = [resourcesPath
stringByAppendingPathComponent:
@"
app
"
];
BOOL
isDir;
if
([fileManager
fileExistsAtPath:
appPath
isDirectory:
&isDir] && isDir) {
NSString
* packageJsonPath = [appPath
stringByAppendingPathComponent:
@"
package.json
"
];
if
([fileManager
fileExistsAtPath:
packageJsonPath]) {
NSData
* jsonData = [
NSData
dataWithContentsOfFile:
packageJsonPath];
NSError
* error;
NSDictionary
* packageDict = [
NSJSONSerialization
JSONObjectWithData:
jsonData
options:
0
error:
&error];
if
(error ==
nil
) {
NSString
* mainEntry = packageDict[
@"
main
"
];
if
(mainEntry !=
nil
) {
NSString
* mainPath = [appPath
stringByAppendingPathComponent:
mainEntry];
if
([fileManager
fileExistsAtPath:
mainPath]) {
return
std::string
([mainPath
UTF8String
]);
}
if
([[mainEntry
pathExtension
]
length
] ==
0
) {
NSString
* mainPathMjs = [mainPath
stringByAppendingPathExtension:
@"
mjs
"
];
if
([fileManager
fileExistsAtPath:
mainPathMjs]) {
return
std::string
([mainPathMjs
UTF8String
]);
}
NSString
* mainPathJs = [mainPath
stringByAppendingPathExtension:
@"
js
"
];
if
([fileManager
fileExistsAtPath:
mainPathJs]) {
return
std::string
([mainPathJs
UTF8String
]);
}
}
}
}
}
//
Fallback to app/index.js
NSString
* indexPath = [appPath
stringByAppendingPathComponent:
@"
index.js
"
];
if
([fileManager
fileExistsAtPath:
indexPath]) {
return
std::string
([indexPath
UTF8String
]);
}
}
return
"
"
;
}
Back
|
FazBrowse Home
|
New Git URL