mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Reload app.css and clear file resolver cache on livesync.
This commit is contained in:
@@ -4,6 +4,7 @@ import fs = require("file-system");
|
|||||||
import styleScope = require("ui/styling/style-scope");
|
import styleScope = require("ui/styling/style-scope");
|
||||||
import observable = require("data/observable");
|
import observable = require("data/observable");
|
||||||
import frame = require("ui/frame");
|
import frame = require("ui/frame");
|
||||||
|
import fileResolverModule = require("file-system/file-name-resolver");
|
||||||
|
|
||||||
var events = new observable.Observable();
|
var events = new observable.Observable();
|
||||||
global.moduleMerge(events, exports);
|
global.moduleMerge(events, exports);
|
||||||
@@ -53,5 +54,12 @@ export function loadCss() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
global.__onLiveSync = function () {
|
global.__onLiveSync = function () {
|
||||||
|
// Clear file resolver cache to respect newly added files.
|
||||||
|
fileResolverModule.clearCache();
|
||||||
|
|
||||||
|
// Reload app.css in case it was changed.
|
||||||
|
loadCss();
|
||||||
|
|
||||||
|
// Reload current page.
|
||||||
frame.reloadPage();
|
frame.reloadPage();
|
||||||
}
|
}
|
||||||
2
file-system/file-name-resolver.d.ts
vendored
2
file-system/file-name-resolver.d.ts
vendored
@@ -12,9 +12,11 @@ declare module "file-system/file-name-resolver" {
|
|||||||
export class FileNameResolver {
|
export class FileNameResolver {
|
||||||
constructor(context: PlatformContext);
|
constructor(context: PlatformContext);
|
||||||
resolveFileName(path: string, ext: string): string;
|
resolveFileName(path: string, ext: string): string;
|
||||||
|
clearCache(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveFileName(path: string, ext: string): string;
|
export function resolveFileName(path: string, ext: string): string;
|
||||||
|
export function clearCache(): void;
|
||||||
|
|
||||||
//@private
|
//@private
|
||||||
export function findFileMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string
|
export function findFileMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ export class FileNameResolver implements definition.FileNameResolver {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearCache(): void {
|
||||||
|
this._cache = {};
|
||||||
|
}
|
||||||
|
|
||||||
private resolveFileNameImpl(path: string, ext: string): string {
|
private resolveFileNameImpl(path: string, ext: string): string {
|
||||||
var result: string = null;
|
var result: string = null;
|
||||||
path = fs.path.normalize(path);
|
path = fs.path.normalize(path);
|
||||||
@@ -239,3 +243,8 @@ export function resolveFileName(path: string, ext: string): string {
|
|||||||
return resolverInstance.resolveFileName(path, ext);
|
return resolverInstance.resolveFileName(path, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearCache(): void {
|
||||||
|
if (resolverInstance) {
|
||||||
|
resolverInstance.clearCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user