Skip to content

Commit ff476d9

Browse files
authored
refactor: rename HmrContext to ModuleContext (NativeScript#6843)
* refactor: rename HmrContext to ModuleContext * refactor(ModuleContext): rename module to path
1 parent 408614d commit ff476d9

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

tests/app/livesync/livesync-tests.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,40 @@ const pageTemplate = `
3131
</StackLayout>
3232
</Page>`;
3333

34-
export function test_onLiveSync_HmrContext_AppStyle_AppNewCss() {
35-
_test_onLiveSync_HmrContext_AppStyle(appNewCssFileName);
34+
export function test_onLiveSync_ModuleContext_AppStyle_AppNewCss() {
35+
_test_onLiveSync_ModuleContext_AppStyle(appNewCssFileName);
3636
}
3737

38-
export function test_onLiveSync_HmrContext_AppStyle_AppNewScss() {
39-
_test_onLiveSync_HmrContext_AppStyle(appNewScssFileName);
38+
export function test_onLiveSync_ModuleContext_AppStyle_AppNewScss() {
39+
_test_onLiveSync_ModuleContext_AppStyle(appNewScssFileName);
4040
}
4141

42-
export function test_onLiveSync_HmrContext_ContextUndefined() {
43-
_test_onLiveSync_HmrContext({ type: undefined, module: undefined });
42+
export function test_onLiveSync_ModuleContext_ContextUndefined() {
43+
_test_onLiveSync_ModuleContext({ type: undefined, path: undefined });
4444
}
4545

46-
export function test_onLiveSync_HmrContext_ModuleUndefined() {
47-
_test_onLiveSync_HmrContext({ type: "script", module: undefined });
46+
export function test_onLiveSync_ModuleContext_ModuleUndefined() {
47+
_test_onLiveSync_ModuleContext({ type: "script", path: undefined });
4848
}
4949

50-
export function test_onLiveSync_HmrContext_Script_AppJs() {
51-
_test_onLiveSync_HmrContext({ type: "script", module: appJsFileName });
50+
export function test_onLiveSync_ModuleContext_Script_AppJs() {
51+
_test_onLiveSync_ModuleContext({ type: "script", path: appJsFileName });
5252
}
5353

54-
export function test_onLiveSync_HmrContext_Script_AppTs() {
55-
_test_onLiveSync_HmrContext({ type: "script", module: appTsFileName });
54+
export function test_onLiveSync_ModuleContext_Script_AppTs() {
55+
_test_onLiveSync_ModuleContext({ type: "script", path: appTsFileName });
5656
}
5757

58-
export function test_onLiveSync_HmrContext_Style_MainPageCss() {
59-
_test_onLiveSync_HmrContext({ type: "style", module: mainPageCssFileName });
58+
export function test_onLiveSync_ModuleContext_Style_MainPageCss() {
59+
_test_onLiveSync_ModuleContext({ type: "style", path: mainPageCssFileName });
6060
}
6161

62-
export function test_onLiveSync_HmrContext_Markup_MainPageHtml() {
63-
_test_onLiveSync_HmrContext({ type: "markup", module: mainPageHtmlFileName });
62+
export function test_onLiveSync_ModuleContext_Markup_MainPageHtml() {
63+
_test_onLiveSync_ModuleContext({ type: "markup", path: mainPageHtmlFileName });
6464
}
6565

66-
export function test_onLiveSync_HmrContext_Markup_MainPageXml() {
67-
_test_onLiveSync_HmrContext({ type: "markup", module: mainPageXmlFileName });
66+
export function test_onLiveSync_ModuleContext_Markup_MainPageXml() {
67+
_test_onLiveSync_ModuleContext({ type: "markup", path: mainPageXmlFileName });
6868
}
6969

7070
export function setUpModule() {
@@ -76,15 +76,15 @@ export function tearDown() {
7676
app.setCssFileName(appCssFileName);
7777
}
7878

79-
function _test_onLiveSync_HmrContext_AppStyle(styleFileName: string) {
79+
function _test_onLiveSync_ModuleContext_AppStyle(styleFileName: string) {
8080
const pageBeforeNavigation = helper.getCurrentPage();
8181

8282
const page = <Page>parse(pageTemplate);
8383
helper.navigateWithHistory(() => page);
8484
app.setCssFileName(styleFileName);
8585

8686
const pageBeforeLiveSync = helper.getCurrentPage();
87-
global.__onLiveSync({ type: "style", module: styleFileName });
87+
global.__onLiveSync({ type: "style", path: styleFileName });
8888

8989
const pageAfterLiveSync = helper.getCurrentPage();
9090
TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById("button").style.color.toString() === green.toString());
@@ -101,10 +101,10 @@ function _test_onLiveSync_HmrContext_AppStyle(styleFileName: string) {
101101
TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!");
102102
}
103103

104-
function _test_onLiveSync_HmrContext(context: { type, module }) {
104+
function _test_onLiveSync_ModuleContext(context: { type, path }) {
105105
const page = <Page>parse(pageTemplate);
106106
helper.navigateWithHistory(() => page);
107-
global.__onLiveSync({ type: context.type, module: context.module });
107+
global.__onLiveSync({ type: context.type, path: context.path });
108108

109109
TKUnit.waitUntilReady(() => !!frame.topmost());
110110
const topmostFrame = frame.topmost();

tns-core-modules/application/application-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function setApplication(instance: iOSApplication | AndroidApplication): v
7979
app = instance;
8080
}
8181

82-
export function livesync(rootView: View, context?: HmrContext) {
82+
export function livesync(rootView: View, context?: ModuleContext) {
8383
events.notify(<EventData>{ eventName: "livesync", object: app });
8484
const liveSyncCore = global.__onLiveSyncCore;
8585
let reapplyAppCss = false;
@@ -88,7 +88,7 @@ export function livesync(rootView: View, context?: HmrContext) {
8888
const fullFileName = getCssFileName();
8989
const fileName = fullFileName.substring(0, fullFileName.lastIndexOf(".") + 1);
9090
const extensions = ["css", "scss"];
91-
reapplyAppCss = extensions.some(ext => context.module === fileName.concat(ext));
91+
reapplyAppCss = extensions.some(ext => context.path === fileName.concat(ext));
9292
}
9393

9494
if (reapplyAppCss && rootView) {

tns-core-modules/application/application.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export function getNativeApplication(): android.app.Application {
212212
return nativeApp;
213213
}
214214

215-
global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
215+
global.__onLiveSync = function __onLiveSync(context?: ModuleContext) {
216216
if (androidApp && androidApp.paused) {
217217
return;
218218
}

tns-core-modules/application/application.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function setViewControllerView(view: View): void {
373373
}
374374
}
375375

376-
global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
376+
global.__onLiveSync = function __onLiveSync(context?: ModuleContext) {
377377
if (!started) {
378378
return;
379379
}

tns-core-modules/module.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare namespace NodeJS {
5151
__native?: any;
5252
__inspector?: any;
5353
__extends: any;
54-
__onLiveSync: (context?: { type: string, module: string }) => void;
54+
__onLiveSync: (context?: { type: string, path: string }) => void;
5555
__onLiveSyncCore: () => void;
5656
__onUncaughtError: (error: NativeScriptError) => void;
5757
__onDiscardedError: (error: NativeScriptError) => void;
@@ -65,25 +65,25 @@ declare function clearTimeout(timeoutId: number): void;
6565
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
6666
declare function clearInterval(intervalId: number): void;
6767

68-
declare enum HmrType {
68+
declare enum ModuleType {
6969
markup = "markup",
7070
script = "script",
7171
style = "style"
7272
}
7373

7474
/**
75-
* Define a context for Hot Module Replacement.
75+
* Define a module context for Hot Module Replacement.
7676
*/
77-
interface HmrContext {
77+
interface ModuleContext {
7878
/**
79-
* The type of module for replacement.
79+
* The type of the module for replacement.
8080
*/
81-
type: HmrType;
81+
type: ModuleType;
8282

8383
/**
84-
* The module for replacement.
84+
* The path of the module for replacement.
8585
*/
86-
module: string;
86+
path: string;
8787
}
8888

8989
/**

0 commit comments

Comments
 (0)