MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / fromURI

Method fromURI

packages/core/ui/styling/style-scope.ts:123–141  ·  view source on GitHub ↗
(uri: string)

Source from the content-addressed store, hash-verified

121 }
122
123 public static fromURI(uri: string): CSSSource {
124 // webpack modules require all file paths to be relative to /app folder
125 const appRelativeUri = CSSSource.pathRelativeToApp(uri);
126 const sanitizedModuleName = sanitizeModuleName(appRelativeUri);
127 const resolvedModuleName = resolveModuleName(sanitizedModuleName, 'css');
128
129 try {
130 const cssOrAst = global.loadModule(resolvedModuleName, true);
131 if (cssOrAst) {
132 return CSSSource.fromDetect(cssOrAst, resolvedModuleName);
133 }
134 } catch (e) {
135 if (Trace.isEnabled()) {
136 Trace.write(`Could not load CSS from ${uri}: ${e}`, Trace.categories.Error, Trace.messageType.warn);
137 }
138 }
139
140 return CSSSource.fromFile(appRelativeUri);
141 }
142
143 private static pathRelativeToApp(uri: string): string {
144 if (!uri.startsWith('/')) {

Callers 4

getCssFileFunction · 0.80
style-scope.tsFile · 0.80
changeCssFileMethod · 0.80
appendCssMethod · 0.80

Calls 7

sanitizeModuleNameFunction · 0.90
resolveModuleNameFunction · 0.90
pathRelativeToAppMethod · 0.80
fromDetectMethod · 0.80
isEnabledMethod · 0.80
writeMethod · 0.65
fromFileMethod · 0.45

Tested by

no test coverage detected