From 66528a21f6c1e0e4b8c43a37581946ba238571c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Tue, 19 Dec 2017 15:01:05 -0800 Subject: [PATCH] build: fix benchmarks for render3 (#20855) PR Close #20855 --- .../src/largetable/render3/index.ts | 2 +- .../src/largetable/render3/table.ts | 2 +- modules/benchmarks/src/tree/render3/index.ts | 2 +- modules/benchmarks/src/tree/render3/tree.ts | 10 +++---- .../src/tree/render3_function/index.ts | 2 +- packages/core/src/core.ts | 1 + .../core/src/core_render3_private_export.ts | 30 +++++++++++++++++++ packages/core/src/render3/di.ts | 4 +-- packages/core/src/render3/instructions.ts | 8 ++--- packages/core/src/render3/ng_dev_mode.ts | 2 ++ .../core/src/render3/node_selector_matcher.ts | 6 ++-- packages/core/test/render3/query_spec.ts | 6 ++-- 12 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 packages/core/src/core_render3_private_export.ts diff --git a/modules/benchmarks/src/largetable/render3/index.ts b/modules/benchmarks/src/largetable/render3/index.ts index 4f2b51bad9..e8eb07fceb 100644 --- a/modules/benchmarks/src/largetable/render3/index.ts +++ b/modules/benchmarks/src/largetable/render3/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {renderComponent} from '@angular/core/src/render3/index'; +import {ɵrenderComponent as renderComponent} from '@angular/core'; import {bindAction, profile} from '../../util'; diff --git a/modules/benchmarks/src/largetable/render3/table.ts b/modules/benchmarks/src/largetable/render3/table.ts index c0a72afcd7..702b83a456 100644 --- a/modules/benchmarks/src/largetable/render3/table.ts +++ b/modules/benchmarks/src/largetable/render3/table.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {C, E, T, V, b, c, cR, cr, defineComponent, detectChanges, e, s, t, v} from '@angular/core/src/render3/index'; +import {ɵC as C, ɵE as E, ɵT as T, ɵV as V, ɵb as b, ɵc as c, ɵcR as cR, ɵcr as cr, ɵdefineComponent as defineComponent, ɵdetectChanges as detectChanges, ɵe as e, ɵs as s, ɵt as t, ɵv as v} from '@angular/core'; import {ComponentDef} from '@angular/core/src/render3/public_interfaces'; import {TableCell, buildTable, emptyTable} from '../util'; diff --git a/modules/benchmarks/src/tree/render3/index.ts b/modules/benchmarks/src/tree/render3/index.ts index fd4b719c90..9c28ec9399 100644 --- a/modules/benchmarks/src/tree/render3/index.ts +++ b/modules/benchmarks/src/tree/render3/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {renderComponent} from '@angular/core/src/render3/index'; +import {ɵrenderComponent as renderComponent} from '@angular/core'; import {bindAction, profile} from '../../util'; import {TreeComponent, createDom, destroyDom, detectChanges} from './tree'; diff --git a/modules/benchmarks/src/tree/render3/tree.ts b/modules/benchmarks/src/tree/render3/tree.ts index a2680c0195..f786442f5d 100644 --- a/modules/benchmarks/src/tree/render3/tree.ts +++ b/modules/benchmarks/src/tree/render3/tree.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {C, D, E, T, V, b, b1, c, cR, cr, defineComponent, detectChanges as _detectChanges, e, p, s, t, v} from '@angular/core/src/render3/index'; +import {ɵC as C, ɵD as D, ɵE as E, ɵT as T, ɵV as V, ɵb as b, ɵb1 as b1, ɵc as c, ɵcR as cR, ɵcr as cr, ɵdefineComponent as defineComponent, ɵdetectChanges as _detectChanges, ɵe as e, ɵp as p, ɵs as s, ɵt as t, ɵv as v} from '@angular/core'; import {ComponentDef} from '@angular/core/src/render3/public_interfaces'; import {TreeNode, buildTree, emptyTree} from '../util'; @@ -57,11 +57,11 @@ export class TreeComponent { { if (cm0) { E(0, TreeComponent.ngComponentDef); - { D(0, TreeComponent.ngComponentDef.n(), TreeComponent.ngComponentDef); } + { D(1, TreeComponent.ngComponentDef.n(), TreeComponent.ngComponentDef); } e(); } p(0, 'data', b(ctx.data.left)); - TreeComponent.ngComponentDef.r(0, 0); + TreeComponent.ngComponentDef.r(1, 0); } v(); } @@ -74,11 +74,11 @@ export class TreeComponent { { if (cm0) { E(0, TreeComponent.ngComponentDef); - { D(0, TreeComponent.ngComponentDef.n(), TreeComponent.ngComponentDef); } + { D(1, TreeComponent.ngComponentDef.n(), TreeComponent.ngComponentDef); } e(); } p(0, 'data', b(ctx.data.right)); - TreeComponent.ngComponentDef.r(0, 0); + TreeComponent.ngComponentDef.r(1, 0); } v(); } diff --git a/modules/benchmarks/src/tree/render3_function/index.ts b/modules/benchmarks/src/tree/render3_function/index.ts index 28fecff68b..3c4b0dc978 100644 --- a/modules/benchmarks/src/tree/render3_function/index.ts +++ b/modules/benchmarks/src/tree/render3_function/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {renderComponent} from '@angular/core/src/render3/index'; +import {ɵrenderComponent as renderComponent} from '@angular/core'; import {bindAction, profile} from '../../util'; import {TreeFunction, createDom, destroyDom, detectChanges} from '../render3/tree'; diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 2ce897f2de..713c99fe06 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -32,6 +32,7 @@ export {Type} from './type'; export {EventEmitter} from './event_emitter'; export {ErrorHandler} from './error_handler'; export * from './core_private_export'; +export * from './core_render3_private_export'; export {Sanitizer, SecurityContext} from './security'; export * from './codegen_private_exports'; export * from './animation/animation_metadata_wrapped'; diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts new file mode 100644 index 0000000000..42daa7c96c --- /dev/null +++ b/packages/core/src/core_render3_private_export.ts @@ -0,0 +1,30 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// clang-format off +export { + defineComponent as ɵdefineComponent, + detectChanges as ɵdetectChanges, + renderComponent as ɵrenderComponent, + C as ɵC, + D as ɵD, + E as ɵE, + T as ɵT, + V as ɵV, + b as ɵb, + b1 as ɵb1, + c as ɵc, + cR as ɵcR, + cr as ɵcr, + e as ɵe, + p as ɵp, + s as ɵs, + t as ɵt, + v as ɵv, +} from './render3/index'; +// clang-format on diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index a206cc51ba..6ad9eb27f7 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -82,8 +82,8 @@ export function bloomAdd(injector: LNodeInjector, type: viewEngine.Type): v /** * Creates (or gets an existing) injector for a given element or container. * - * @param {LElement | LContainer} node for which an injector should be retrieved / created. - * @returns {LNodeInjector} Node injector + * @param node for which an injector should be retrieved / created. + * @returns Node injector */ export function getOrCreateNodeInjectorForNode(node: LElement | LContainer): LNodeInjector { const nodeInjector = node.nodeInjector; diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 04cca17157..a10a99b3b7 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -1162,7 +1162,7 @@ export const componentRefresh: * each projected node belongs (it re-distributes nodes among "buckets" where each "bucket" is * backed by a selector). * - * @param {CssSelector[]} selectors + * @param selectors */ export function projectionDef(selectors?: CssSelector[]): LNode[][] { const noOfNodeBuckets = selectors ? selectors.length + 1 : 1; @@ -1212,9 +1212,9 @@ export function projectionDef(selectors?: CssSelector[]): LNode[][] { * Inserts previously re-distributed projected nodes. This instruction must be preceded by a call * to the projectionDef instruction. * - * @param {number} nodeIndex - * @param {number} localIndex - index under which distribution of projected nodes was memorized - * @param {number} selectorIndex - 0 means without any selector + * @param nodeIndex + * @param localIndex - index under which distribution of projected nodes was memorized + * @param selectorIndex - 0 means without any selector */ export function projection(nodeIndex: number, localIndex: number, selectorIndex: number = 0): void { const projectedNodes: ProjectionState = []; diff --git a/packages/core/src/render3/ng_dev_mode.ts b/packages/core/src/render3/ng_dev_mode.ts index 89a5627e4a..00fcad5c5d 100644 --- a/packages/core/src/render3/ng_dev_mode.ts +++ b/packages/core/src/render3/ng_dev_mode.ts @@ -11,6 +11,8 @@ declare global { const ngDevMode: boolean; } +declare let global: any; + if (typeof ngDevMode == 'undefined') { if (typeof window != 'undefined') (window as any).ngDevMode = true; if (typeof self != 'undefined') (self as any).ngDevMode = true; diff --git a/packages/core/src/render3/node_selector_matcher.ts b/packages/core/src/render3/node_selector_matcher.ts index 99823f4e3e..add2f62c32 100644 --- a/packages/core/src/render3/node_selector_matcher.ts +++ b/packages/core/src/render3/node_selector_matcher.ts @@ -29,9 +29,9 @@ function isCssClassMatching(nodeClassAttrVal: string, cssClassToMatch: string): /** * A utility function to match an Ivy node static data against a simple CSS selector * - * @param {LNodeStatic} node static data to match - * @param {SimpleCssSelector} selector - * @returns {boolean} + * @param node static data to match + * @param selector + * @returns true if node matches the selector. */ export function isNodeMatchingSimpleSelector( lNodeStaticData: LNodeStatic, selector: SimpleCssSelector): boolean { diff --git a/packages/core/test/render3/query_spec.ts b/packages/core/test/render3/query_spec.ts index 9e99f34204..eb1e8eba74 100644 --- a/packages/core/test/render3/query_spec.ts +++ b/packages/core/test/render3/query_spec.ts @@ -14,7 +14,7 @@ import {createComponent, renderComponent} from './render_util'; /** * Helper function to check if a given candidate object resembles ElementRef * @param candidate - * @returns {boolean} + * @returns true if `ElementRef`. */ function isElementRef(candidate: any): boolean { return candidate.nativeElement != null; @@ -23,7 +23,7 @@ function isElementRef(candidate: any): boolean { /** * Helper function to check if a given candidate object resembles TemplateRef * @param candidate - * @returns {boolean} + * @returns true if `TemplateRef`. */ function isTemplateRef(candidate: any): boolean { return candidate.createEmbeddedView != null && candidate.createComponent == null; @@ -32,7 +32,7 @@ function isTemplateRef(candidate: any): boolean { /** * Helper function to check if a given candidate object resembles ViewContainerRef * @param candidate - * @returns {boolean} + * @returns true if `ViewContainerRef`. */ function isViewContainerRef(candidate: any): boolean { return candidate.createEmbeddedView != null && candidate.createComponent != null;