Skip to content

fix: export NgView and NgElement from element-registry #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nativescript-angular/animations/animation-driver.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/animations/animation-engine.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/animations/animation-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/animations/dom-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down
7 changes: 5 additions & 2 deletions nativescript-angular/directives/action-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/directives/list-view-comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/directives/tab-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
33 changes: 32 additions & 1 deletion nativescript-angular/element-registry.ts
Original file line number Diff line number Diff line change
@@ -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<string, boolean>;
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;

Expand Down
32 changes: 0 additions & 32 deletions nativescript-angular/element-types.ts

This file was deleted.

9 changes: 3 additions & 6 deletions nativescript-angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
2 changes: 1 addition & 1 deletion nativescript-angular/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 5 additions & 7 deletions nativescript-angular/view-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
6 changes: 5 additions & 1 deletion tests/app/tests/property-sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion tests/app/tests/renderer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<StackLayout><Label text="Layout"></Label></StackLayout>`
Expand Down