mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Refactor the application module to prevent cyclic dependencies, which were:
* common requires application * application requires common * application requires application Make the exports typed using @hdeshev way.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
import definition = require("application");
|
||||
import observable = require("data/observable");
|
||||
import frame = require("ui/frame");
|
||||
import cssSelector = require("ui/styling/css-selector");
|
||||
import * as fileSystemModule from "file-system";
|
||||
import * as styleScopeModule from "ui/styling/style-scope";
|
||||
|
||||
@ -21,6 +22,8 @@ export var mainEntry: frame.NavigationEntry;
|
||||
|
||||
export var cssFile: string = "app.css"
|
||||
|
||||
export var cssSelectorsCache: Array<cssSelector.CssSelector> = undefined;
|
||||
|
||||
export var resources: any = {};
|
||||
|
||||
export var onUncaughtError: (error: definition.NativeScriptError) => void = undefined;
|
||||
@ -39,18 +42,24 @@ export var android = undefined;
|
||||
|
||||
export var ios = undefined;
|
||||
|
||||
export function loadCss() {
|
||||
if (definition.cssFile) {
|
||||
var fs: typeof fileSystemModule = require("file-system");
|
||||
var styleScope: typeof styleScopeModule = require("ui/styling/style-scope");
|
||||
export function loadCss(cssFile?: string): Array<cssSelector.CssSelector> {
|
||||
if (!cssFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, definition.cssFile);
|
||||
if (fs.File.exists(cssFileName)) {
|
||||
var file = fs.File.fromPath(cssFileName);
|
||||
var applicationCss = file.readTextSync();
|
||||
if (applicationCss) {
|
||||
definition.cssSelectorsCache = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
|
||||
}
|
||||
var result: Array<cssSelector.CssSelector>;
|
||||
|
||||
var fs: typeof fileSystemModule = require("file-system");
|
||||
var styleScope: typeof styleScopeModule = require("ui/styling/style-scope");
|
||||
|
||||
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFile);
|
||||
if (fs.File.exists(cssFileName)) {
|
||||
var file = fs.File.fromPath(cssFileName);
|
||||
var applicationCss = file.readTextSync();
|
||||
if (applicationCss) {
|
||||
result = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user