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

Method fromDetect

packages/core/ui/styling/style-scope.ts:104–121  ·  view source on GitHub ↗
(cssOrAst: any, fileName?: string)

Source from the content-addressed store, hash-verified

102 }
103
104 public static fromDetect(cssOrAst: any, fileName?: string): CSSSource {
105 if (typeof cssOrAst === 'string') {
106 // raw-loader
107 return CSSSource.fromSource(cssOrAst, fileName);
108 } else if (typeof cssOrAst === 'object') {
109 if (cssOrAst.default) {
110 cssOrAst = cssOrAst.default;
111 }
112
113 if (cssOrAst.type === 'stylesheet' && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
114 // css-loader
115 return CSSSource.fromAST(cssOrAst, fileName);
116 }
117 }
118
119 // css2json-loader
120 return CSSSource.fromSource(cssOrAst.toString(), fileName);
121 }
122
123 public static fromURI(uri: string): CSSSource {
124 // webpack modules require all file paths to be relative to /app folder

Callers 2

fromURIMethod · 0.80
addTaggedAdditionalCSSFunction · 0.80

Calls 3

fromSourceMethod · 0.80
fromASTMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected