mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: rename HmrContext to ModuleContext (#6843)
* refactor: rename HmrContext to ModuleContext * refactor(ModuleContext): rename module to path
This commit is contained in:
@@ -79,7 +79,7 @@ export function setApplication(instance: iOSApplication | AndroidApplication): v
|
||||
app = instance;
|
||||
}
|
||||
|
||||
export function livesync(rootView: View, context?: HmrContext) {
|
||||
export function livesync(rootView: View, context?: ModuleContext) {
|
||||
events.notify(<EventData>{ eventName: "livesync", object: app });
|
||||
const liveSyncCore = global.__onLiveSyncCore;
|
||||
let reapplyAppCss = false;
|
||||
@@ -88,7 +88,7 @@ export function livesync(rootView: View, context?: HmrContext) {
|
||||
const fullFileName = getCssFileName();
|
||||
const fileName = fullFileName.substring(0, fullFileName.lastIndexOf(".") + 1);
|
||||
const extensions = ["css", "scss"];
|
||||
reapplyAppCss = extensions.some(ext => context.module === fileName.concat(ext));
|
||||
reapplyAppCss = extensions.some(ext => context.path === fileName.concat(ext));
|
||||
}
|
||||
|
||||
if (reapplyAppCss && rootView) {
|
||||
|
||||
@@ -212,7 +212,7 @@ export function getNativeApplication(): android.app.Application {
|
||||
return nativeApp;
|
||||
}
|
||||
|
||||
global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
|
||||
global.__onLiveSync = function __onLiveSync(context?: ModuleContext) {
|
||||
if (androidApp && androidApp.paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ function setViewControllerView(view: View): void {
|
||||
}
|
||||
}
|
||||
|
||||
global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
|
||||
global.__onLiveSync = function __onLiveSync(context?: ModuleContext) {
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
|
||||
16
tns-core-modules/module.d.ts
vendored
16
tns-core-modules/module.d.ts
vendored
@@ -51,7 +51,7 @@ declare namespace NodeJS {
|
||||
__native?: any;
|
||||
__inspector?: any;
|
||||
__extends: any;
|
||||
__onLiveSync: (context?: { type: string, module: string }) => void;
|
||||
__onLiveSync: (context?: { type: string, path: string }) => void;
|
||||
__onLiveSyncCore: () => void;
|
||||
__onUncaughtError: (error: NativeScriptError) => void;
|
||||
__onDiscardedError: (error: NativeScriptError) => void;
|
||||
@@ -65,25 +65,25 @@ declare function clearTimeout(timeoutId: number): void;
|
||||
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
|
||||
declare function clearInterval(intervalId: number): void;
|
||||
|
||||
declare enum HmrType {
|
||||
declare enum ModuleType {
|
||||
markup = "markup",
|
||||
script = "script",
|
||||
style = "style"
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a context for Hot Module Replacement.
|
||||
* Define a module context for Hot Module Replacement.
|
||||
*/
|
||||
interface HmrContext {
|
||||
interface ModuleContext {
|
||||
/**
|
||||
* The type of module for replacement.
|
||||
* The type of the module for replacement.
|
||||
*/
|
||||
type: HmrType;
|
||||
type: ModuleType;
|
||||
|
||||
/**
|
||||
* The module for replacement.
|
||||
* The path of the module for replacement.
|
||||
*/
|
||||
module: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user