diff --git a/nativescript-angular/animations/animation-driver.ts b/nativescript-angular/animations/animation-driver.ts index a2e6de0ca..eeb385e42 100644 --- a/nativescript-angular/animations/animation-driver.ts +++ b/nativescript-angular/animations/animation-driver.ts @@ -1,6 +1,6 @@ import { AnimationPlayer } from "@angular/animations"; -import { NgView } from "../element-types"; +import { NgView } from "../element-registry"; import { NativeScriptAnimationPlayer } from "./animation-player"; import { Keyframe } from "./utils"; diff --git a/nativescript-angular/animations/animation-engine.ts b/nativescript-angular/animations/animation-engine.ts index 527ae603c..0dcbd51ff 100644 --- a/nativescript-angular/animations/animation-engine.ts +++ b/nativescript-angular/animations/animation-engine.ts @@ -1,7 +1,7 @@ import { ɵDomAnimationEngine as DomAnimationEngine } from "@angular/animations/browser"; import { AnimationEvent, AnimationPlayer } from "@angular/animations"; -import { NgView } from "../element-types"; +import { NgView } from "../element-registry"; import { copyArray, cssClasses, diff --git a/nativescript-angular/animations/animation-player.ts b/nativescript-angular/animations/animation-player.ts index d4f648c15..fcc60d8f1 100644 --- a/nativescript-angular/animations/animation-player.ts +++ b/nativescript-angular/animations/animation-player.ts @@ -4,7 +4,7 @@ import { KeyframeAnimationInfo, } from "tns-core-modules/ui/animation/keyframe-animation"; -import { NgView } from "../element-types"; +import { NgView } from "../element-registry"; import { Keyframe, getAnimationCurve, parseAnimationKeyframe } from "./utils"; export class NativeScriptAnimationPlayer implements AnimationPlayer { diff --git a/nativescript-angular/animations/dom-utils.ts b/nativescript-angular/animations/dom-utils.ts index c6a54039b..00584f70e 100644 --- a/nativescript-angular/animations/dom-utils.ts +++ b/nativescript-angular/animations/dom-utils.ts @@ -7,7 +7,7 @@ import { } from "@angular/animations"; import { unsetValue } from "tns-core-modules/ui/core/view"; -import { NgView } from "../element-types"; +import { NgView } from "../element-registry"; // overriden to use the default 'unsetValue' // instead of empty string '' diff --git a/nativescript-angular/directives/action-bar.ts b/nativescript-angular/directives/action-bar.ts index 876befa45..a48795345 100644 --- a/nativescript-angular/directives/action-bar.ts +++ b/nativescript-angular/directives/action-bar.ts @@ -4,8 +4,11 @@ import { Page } from "tns-core-modules/ui/page"; import { View } from "tns-core-modules/ui/core/view"; import { isBlank } from "../lang-facade"; -import { registerElement } from "../element-registry"; -import { ViewClassMeta, NgView } from "../element-types"; +import { + NgView, + ViewClassMeta, + registerElement, +} from "../element-registry"; const actionBarMeta: ViewClassMeta = { skipAddToDom: true, diff --git a/nativescript-angular/directives/list-view-comp.ts b/nativescript-angular/directives/list-view-comp.ts index ccfcac8f0..546130fc1 100644 --- a/nativescript-angular/directives/list-view-comp.ts +++ b/nativescript-angular/directives/list-view-comp.ts @@ -24,7 +24,7 @@ import { View, KeyedTemplate } from "tns-core-modules/ui/core/view"; import { ObservableArray } from "tns-core-modules/data/observable-array"; import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base"; -import { CommentNode } from "../element-types"; +import { CommentNode } from "../element-registry"; import { isListLikeIterable } from "../collection-facade"; import { listViewLog, listViewError } from "../trace"; diff --git a/nativescript-angular/directives/tab-view.ts b/nativescript-angular/directives/tab-view.ts index 4a630a716..3b578be54 100644 --- a/nativescript-angular/directives/tab-view.ts +++ b/nativescript-angular/directives/tab-view.ts @@ -9,7 +9,7 @@ import { } from "@angular/core"; import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view"; -import { CommentNode } from "../element-types"; +import { CommentNode } from "../element-registry"; import { rendererLog } from "../trace"; import { isBlank } from "../lang-facade"; diff --git a/nativescript-angular/element-registry.ts b/nativescript-angular/element-registry.ts index fd889700f..6cf0c6cf0 100644 --- a/nativescript-angular/element-registry.ts +++ b/nativescript-angular/element-registry.ts @@ -1,4 +1,35 @@ -import { ViewClass, ViewClassMeta } from "./element-types"; +import { View } from "tns-core-modules/ui/core/view"; + +export type NgView = (View & ViewExtensions); +export type NgElement = NgView | CommentNode; + +export interface ViewExtensions { + nodeType: number; + nodeName: string; + templateParent: NgView; + ngCssClasses: Map; + meta: ViewClassMeta; +} + +export interface ViewClass { + new (): View; +} + +// used for creating comments and text nodes in the renderer +export class CommentNode { + meta: { skipAddToDom: true }; + templateParent: NgView; +} + +export interface ViewClassMeta { + skipAddToDom?: boolean; + insertChild?: (parent: NgView, child: NgView, atIndex: number) => void; + removeChild?: (parent: NgView, child: NgView) => void; +} + +export function isDetachedElement(element): boolean { + return (element && element.meta && element.meta.skipAddToDom); +} export type ViewResolver = () => ViewClass; diff --git a/nativescript-angular/element-types.ts b/nativescript-angular/element-types.ts deleted file mode 100644 index e04833bfc..000000000 --- a/nativescript-angular/element-types.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { View } from "tns-core-modules/ui/core/view"; - -export type NgView = (View & ViewExtensions); -export type NgElement = NgView | CommentNode; - -export interface ViewExtensions { - nodeType: number; - nodeName: string; - templateParent: NgView; - ngCssClasses: Map; - meta: ViewClassMeta; -} - -export interface ViewClass { - new (): View; -} - -// used for creating comments and text nodes in the renderer -export class CommentNode { - meta: { skipAddToDom: true }; - templateParent: NgView; -} - -export interface ViewClassMeta { - skipAddToDom?: boolean; - insertChild?: (parent: NgView, child: NgView, atIndex: number) => void; - removeChild?: (parent: NgView, child: NgView) => void; -} - -export function isDetachedElement(element): boolean { - return (element && element.meta && element.meta.skipAddToDom); -} diff --git a/nativescript-angular/index.ts b/nativescript-angular/index.ts index 8ec8eaa23..2270a8ac4 100644 --- a/nativescript-angular/index.ts +++ b/nativescript-angular/index.ts @@ -17,16 +17,13 @@ export * from "./view-util"; export * from "./resource-loader"; export { + ViewClass, + ViewClassMeta, ViewResolver, - registerElement, getViewClass, getViewMeta, isKnownView, + registerElement, } from "./element-registry"; -export { - ViewClass, - ViewClassMeta, -} from "./element-types"; - export * from "./value-accessors/base-value-accessor"; diff --git a/nativescript-angular/renderer.ts b/nativescript-angular/renderer.ts index bfe7033dd..c9ec5c122 100644 --- a/nativescript-angular/renderer.ts +++ b/nativescript-angular/renderer.ts @@ -12,7 +12,7 @@ import { topmost } from "tns-core-modules/ui/frame"; import { APP_ROOT_VIEW, DEVICE, getRootPage } from "./platform-providers"; import { isBlank } from "./lang-facade"; import { ViewUtil } from "./view-util"; -import { NgView, CommentNode } from "./element-types"; +import { NgView, CommentNode } from "./element-registry"; import { rendererLog as traceLog } from "./trace"; // CONTENT_ATTR not exported from NativeScript_renderer - we need it for styles application. diff --git a/nativescript-angular/view-util.ts b/nativescript-angular/view-util.ts index c57b390ca..6349c203f 100644 --- a/nativescript-angular/view-util.ts +++ b/nativescript-angular/view-util.ts @@ -4,18 +4,16 @@ import { Placeholder } from "tns-core-modules/ui/placeholder"; import { ContentView } from "tns-core-modules/ui/content-view"; import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base"; import { + CommentNode, + NgElement, + NgView, + ViewExtensions, getViewClass, getViewMeta, + isDetachedElement, isKnownView, } from "./element-registry"; -import { - CommentNode, - ViewExtensions, - NgElement, - NgView, - isDetachedElement, -} from "./element-types"; import { platformNames, Device } from "tns-core-modules/platform"; import { rendererLog as traceLog } from "./trace"; diff --git a/tests/app/tests/property-sets.ts b/tests/app/tests/property-sets.ts index 547dd9962..e62bb8c74 100644 --- a/tests/app/tests/property-sets.ts +++ b/tests/app/tests/property-sets.ts @@ -2,7 +2,11 @@ import {assert} from "./test-config"; import {View} from "ui/core/view"; import {ViewUtil} from "nativescript-angular/view-util"; -import {NgView, ViewExtensions, ViewClassMeta} from "nativescript-angular/element-types"; +import { + NgView, + ViewExtensions, + ViewClassMeta, +} from "nativescript-angular/element-registry"; import {Red} from "color/known-colors"; import {device, platformNames} from "platform"; import {createDevice} from "./test-utils"; diff --git a/tests/app/tests/renderer-tests.ts b/tests/app/tests/renderer-tests.ts index bce870fd1..fecbaf982 100644 --- a/tests/app/tests/renderer-tests.ts +++ b/tests/app/tests/renderer-tests.ts @@ -9,7 +9,7 @@ import { LayoutBase } from "ui/layouts/layout-base"; import { StackLayout } from "ui/layouts/stack-layout"; import { ContentView } from "ui/content-view"; import { Button } from "ui/button"; -import { NgView } from "nativescript-angular/element-types"; +import { NgView } from "nativescript-angular/element-registry"; @Component({ template: ``