From d44d0852e579ccbc05f7e1e3b5d5328bd2cd3ce2 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 14 Jun 2016 19:20:18 -0700 Subject: [PATCH] Revert "fix: cleanup public api of platform-server" This reverts commit ac84468f1cea7ec33ecf68c9ddfc3ac29245fb2f. --- .../@angular/platform-server/core_private.ts | 7 +- modules/@angular/platform-server/index.dart | 2 +- modules/@angular/platform-server/index.ts | 3 +- .../@angular/platform-server/src/server.ts | 47 ------- .../platform-server/test/integration_spec.ts | 34 ----- tools/public_api_guard/public_api_spec.ts | 126 +++++++++++++++++- 6 files changed, 130 insertions(+), 89 deletions(-) delete mode 100644 modules/@angular/platform-server/src/server.ts delete mode 100644 modules/@angular/platform-server/test/integration_spec.ts diff --git a/modules/@angular/platform-server/core_private.ts b/modules/@angular/platform-server/core_private.ts index c5b8be3d1f..1c7f41a379 100644 --- a/modules/@angular/platform-server/core_private.ts +++ b/modules/@angular/platform-server/core_private.ts @@ -1,8 +1,9 @@ import {__core_private__ as r, __core_private_types__ as t} from '@angular/core'; -export var reflector: typeof t.reflector = r.reflector; -export var ReflectionCapabilities: typeof t.ReflectionCapabilities = r.ReflectionCapabilities; -export var wtfInit: typeof t.wtfInit = r.wtfInit; +export type NoOpAnimationPlayer = t.NoOpAnimationPlayer; +export var NoOpAnimationPlayer: typeof t.NoOpAnimationPlayer = r.NoOpAnimationPlayer; +export type AnimationPlayer = t.AnimationPlayer; +export var AnimationPlayer: typeof t.AnimationPlayer = r.AnimationPlayer; export type NoOpAnimationDriver = t.NoOpAnimationDriver; export var NoOpAnimationDriver: typeof t.NoOpAnimationDriver = r.NoOpAnimationDriver; export type AnimationDriver = t.AnimationDriver; diff --git a/modules/@angular/platform-server/index.dart b/modules/@angular/platform-server/index.dart index ff9d666822..61ae1b6809 100644 --- a/modules/@angular/platform-server/index.dart +++ b/modules/@angular/platform-server/index.dart @@ -1,2 +1,2 @@ -// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APPLICATION_PROVIDERS +// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APP_PROVIDERS export 'package:angular2/src/platform/server/html_adapter.dart'; diff --git a/modules/@angular/platform-server/index.ts b/modules/@angular/platform-server/index.ts index b144175511..2676ccb72c 100644 --- a/modules/@angular/platform-server/index.ts +++ b/modules/@angular/platform-server/index.ts @@ -1 +1,2 @@ -export {SERVER_APPLICATION_PROVIDERS, SERVER_PLATFORM_PROVIDERS, serverBootstrap} from './src/server'; +// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APP_PROVIDERS +export {Parse5DomAdapter} from './src/parse5_adapter'; diff --git a/modules/@angular/platform-server/src/server.ts b/modules/@angular/platform-server/src/server.ts deleted file mode 100644 index 03b1d949cc..0000000000 --- a/modules/@angular/platform-server/src/server.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {PlatformLocation} from '@angular/common'; -import {ComponentRef, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, Type, assertPlatform, coreLoadAndBootstrap, createPlatform, getPlatform} from '@angular/core'; -import {BROWSER_APP_PROVIDERS, BrowserPlatformLocation} from '@angular/platform-browser'; -import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic'; - -import {ReflectionCapabilities, reflector, wtfInit} from '../core_private'; - -import {Parse5DomAdapter} from './parse5_adapter'; - -const SERVER_PLATFORM_MARKER = new OpaqueToken('ServerPlatformMarker'); - -/** - * A set of providers to initialize the Angular platform in a server. - * - * Used automatically by `serverBootstrap`, or can be passed to {@link platform}. - */ -export const SERVER_PLATFORM_PROVIDERS: Array = [ - {provide: SERVER_PLATFORM_MARKER, useValue: true}, PLATFORM_COMMON_PROVIDERS, - {provide: PLATFORM_INITIALIZER, useValue: initParse5Adapter, multi: true}, - {provide: PlatformLocation, useClass: BrowserPlatformLocation} -]; - -export const SERVER_APPLICATION_PROVIDERS: Array = - [BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS]; - -function initParse5Adapter() { - Parse5DomAdapter.makeCurrent(); - wtfInit(); -} - - -export function serverPlatform(): PlatformRef { - if (!getPlatform()) { - createPlatform(ReflectiveInjector.resolveAndCreate(SERVER_PLATFORM_PROVIDERS)); - } - return assertPlatform(SERVER_PLATFORM_MARKER); -} - - -export function serverBootstrap( - appComponentType: Type, - customProviders?: Array): Promise> { - reflector.reflectionCapabilities = new ReflectionCapabilities(); - let providers = [SERVER_APPLICATION_PROVIDERS, customProviders || []]; - var appInjector = ReflectiveInjector.resolveAndCreate(providers, serverPlatform().injector); - return coreLoadAndBootstrap(appComponentType, appInjector); -} diff --git a/modules/@angular/platform-server/test/integration_spec.ts b/modules/@angular/platform-server/test/integration_spec.ts deleted file mode 100644 index 57995d27fe..0000000000 --- a/modules/@angular/platform-server/test/integration_spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import {Component, disposePlatform} from '@angular/core'; -import {afterEach, async, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing'; -import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; -import {serverBootstrap} from '@angular/platform-server'; - -import {Parse5DomAdapter} from '../src/parse5_adapter'; - -function writeBody(html: string): any { - var dom = getDOM(); - var doc = dom.defaultDoc(); - var body = dom.querySelector(doc, 'body'); - dom.setInnerHTML(body, html); - return body; -} - -export function main() { - if (getDOM().supportsDOMEvents()) return; // NODE only - - describe('platform-server integration', () => { - - afterEach(() => disposePlatform()); - - it('should bootstrap', async(() => { - var body = writeBody(''); - serverBootstrap(MyServerApp).then(() => { - expect(getDOM().getText(body)).toEqual('Works!'); - }); - })); - }); -} - -@Component({selector: 'app', template: `Works!`}) -class MyServerApp { -} diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts index f7fbe85038..9436d51c37 100644 --- a/tools/public_api_guard/public_api_spec.ts +++ b/tools/public_api_guard/public_api_spec.ts @@ -1664,9 +1664,129 @@ const PLATFORM_BROWSER_DYNAMIC_TESTING = [ const PLATFORM_SERVER = [ - 'const SERVER_APPLICATION_PROVIDERS:Array', - 'const SERVER_PLATFORM_PROVIDERS:Array', - 'serverBootstrap(appComponentType:Type, customProviders?:Array):Promise>', + 'Parse5DomAdapter', + 'Parse5DomAdapter.addClass(element:any, className:string):any', + 'Parse5DomAdapter.adoptNode(node:any):any', + 'Parse5DomAdapter.animate(element:any, keyframes:any[], options:any):any', + 'Parse5DomAdapter.appendChild(el:any, node:any):any', + 'Parse5DomAdapter.attributeMap(element:any):Map', + 'Parse5DomAdapter.attrToPropMap:any', + 'Parse5DomAdapter.cancelAnimationFrame(id:number):any', + 'Parse5DomAdapter.childNodes(el:any):Node[]', + 'Parse5DomAdapter.childNodesAsList(el:any):any[]', + 'Parse5DomAdapter.classList(element:any):string[]', + 'Parse5DomAdapter.clearNodes(el:any):any', + 'Parse5DomAdapter.clone(node:Node):Node', + 'Parse5DomAdapter.content(node:any):string', + 'Parse5DomAdapter.createComment(text:string):Comment', + 'Parse5DomAdapter.createElement(tagName:any):HTMLElement', + 'Parse5DomAdapter.createElementNS(ns:any, tagName:any):HTMLElement', + 'Parse5DomAdapter.createEvent(eventType:string):Event', + 'Parse5DomAdapter.createHtmlDocument():Document', + 'Parse5DomAdapter.createMouseEvent(eventType:any):Event', + 'Parse5DomAdapter.createScriptTag(attrName:string, attrValue:string):HTMLElement', + 'Parse5DomAdapter.createShadowRoot(el:any):HTMLElement', + 'Parse5DomAdapter.createStyleElement(css:string):HTMLStyleElement', + 'Parse5DomAdapter.createTemplate(html:any):HTMLElement', + 'Parse5DomAdapter.createTextNode(text:string):Text', + 'Parse5DomAdapter.defaultDoc():Document', + 'Parse5DomAdapter.dispatchEvent(el:any, evt:any):any', + 'Parse5DomAdapter.elementMatches(node:any, selector:string, matcher:any=null):boolean', + 'Parse5DomAdapter.firstChild(el:any):Node', + 'Parse5DomAdapter.getAnimationPrefix():string', + 'Parse5DomAdapter.getAttribute(element:any, attribute:string):string', + 'Parse5DomAdapter.getAttributeNS(element:any, ns:string, attribute:string):string', + 'Parse5DomAdapter.getBaseHref():string', + 'Parse5DomAdapter.getBoundingClientRect(el:any):any', + 'Parse5DomAdapter.getChecked(el:any):boolean', + 'Parse5DomAdapter.getComputedStyle(el:any):any', + 'Parse5DomAdapter.getCookie(name:string):string', + 'Parse5DomAdapter.getData(el:any, name:string):string', + 'Parse5DomAdapter.getDistributedNodes(el:any):Node[]', + 'Parse5DomAdapter.getElementsByClassName(element:any, name:string):HTMLElement[]', + 'Parse5DomAdapter.getElementsByTagName(element:any, name:string):HTMLElement[]', + 'Parse5DomAdapter.getEventKey(event:any):string', + 'Parse5DomAdapter.getGlobalEventTarget(target:string):any', + 'Parse5DomAdapter.getHistory():History', + 'Parse5DomAdapter.getHost(el:any):string', + 'Parse5DomAdapter.getHref(el:any):string', + 'Parse5DomAdapter.getInnerHTML(el:any):string', + 'Parse5DomAdapter.getLocation():Location', + 'Parse5DomAdapter.getOuterHTML(el:any):string', + 'Parse5DomAdapter.getProperty(el:any, name:string):any', + 'Parse5DomAdapter.getShadowRoot(el:any):Element', + 'Parse5DomAdapter.getStyle(element:any, styleName:string):string', + 'Parse5DomAdapter.getTemplateContent(el:any):Node', + 'Parse5DomAdapter.getText(el:any, isRecursive?:boolean):string', + 'Parse5DomAdapter.getTitle():string', + 'Parse5DomAdapter.getTransitionEnd():string', + 'Parse5DomAdapter.getUserAgent():string', + 'Parse5DomAdapter.getValue(el:any):string', + 'Parse5DomAdapter.getXHR():Type', + 'Parse5DomAdapter.hasAttribute(element:any, attribute:string):boolean', + 'Parse5DomAdapter.hasAttributeNS(element:any, ns:string, attribute:string):boolean', + 'Parse5DomAdapter.hasClass(element:any, className:string):boolean', + 'Parse5DomAdapter.hasProperty(element:any, name:string):boolean', + 'Parse5DomAdapter.hasShadowRoot(node:any):boolean', + 'Parse5DomAdapter.hasStyle(element:any, styleName:string, styleValue:string=null):boolean', + 'Parse5DomAdapter.importIntoDoc(node:any):any', + 'Parse5DomAdapter.insertAfter(el:any, node:any):any', + 'Parse5DomAdapter.insertAllBefore(el:any, nodes:any):any', + 'Parse5DomAdapter.insertBefore(el:any, node:any):any', + 'Parse5DomAdapter.invoke(el:Element, methodName:string, args:any[]):any', + 'Parse5DomAdapter.isCommentNode(node:any):boolean', + 'Parse5DomAdapter.isElementNode(node:any):boolean', + 'Parse5DomAdapter.isPrevented(evt:any):boolean', + 'Parse5DomAdapter.isShadowRoot(node:any):boolean', + 'Parse5DomAdapter.isTemplateElement(el:any):boolean', + 'Parse5DomAdapter.isTextNode(node:any):boolean', + 'Parse5DomAdapter.log(error:any):any', + 'Parse5DomAdapter.logError(error:any):any', + 'Parse5DomAdapter.logGroup(error:any):any', + 'Parse5DomAdapter.logGroupEnd():any', + 'Parse5DomAdapter.makeCurrent():any', + 'Parse5DomAdapter.nextSibling(el:any):Node', + 'Parse5DomAdapter.nodeName(node:any):string', + 'Parse5DomAdapter.nodeValue(node:any):string', + 'Parse5DomAdapter.on(el:any, evt:any, listener:any):any', + 'Parse5DomAdapter.onAndCancel(el:any, evt:any, listener:any):Function', + 'Parse5DomAdapter.parentElement(el:any):Node', + 'Parse5DomAdapter.parse(templateHtml:string):any', + 'Parse5DomAdapter.performanceNow():number', + 'Parse5DomAdapter.preventDefault(evt:any):any', + 'Parse5DomAdapter.query(selector:any):any', + 'Parse5DomAdapter.querySelector(el:any, selector:string):any', + 'Parse5DomAdapter.querySelectorAll(el:any, selector:string):any[]', + 'Parse5DomAdapter.remove(el:any):HTMLElement', + 'Parse5DomAdapter.removeAttribute(element:any, attribute:string):any', + 'Parse5DomAdapter.removeAttributeNS(element:any, ns:string, name:string):any', + 'Parse5DomAdapter.removeChild(el:any, node:any):any', + 'Parse5DomAdapter.removeClass(element:any, className:string):any', + 'Parse5DomAdapter.removeStyle(element:any, styleName:string):any', + 'Parse5DomAdapter.replaceChild(el:any, newNode:any, oldNode:any):any', + 'Parse5DomAdapter.requestAnimationFrame(callback:any):number', + 'Parse5DomAdapter.resetBaseElement():void', + 'Parse5DomAdapter.resolveAndSetHref(el:any, baseUrl:string, href:string):any', + 'Parse5DomAdapter.setAttribute(element:any, attribute:string, value:string):any', + 'Parse5DomAdapter.setAttributeNS(element:any, ns:string, attribute:string, value:string):any', + 'Parse5DomAdapter.setChecked(el:any, value:boolean):any', + 'Parse5DomAdapter.setCookie(name:string, value:string):any', + 'Parse5DomAdapter.setData(el:any, name:string, value:string):any', + 'Parse5DomAdapter.setGlobalVar(path:string, value:any):any', + 'Parse5DomAdapter.setInnerHTML(el:any, value:any):any', + 'Parse5DomAdapter.setProperty(el:any, name:string, value:any):any', + 'Parse5DomAdapter.setStyle(element:any, styleName:string, styleValue:string):any', + 'Parse5DomAdapter.setText(el:any, value:string):any', + 'Parse5DomAdapter.setTitle(newTitle:string):any', + 'Parse5DomAdapter.setValue(el:any, value:string):any', + 'Parse5DomAdapter.supportsAnimation():boolean', + 'Parse5DomAdapter.supportsCookies():boolean', + 'Parse5DomAdapter.supportsDOMEvents():boolean', + 'Parse5DomAdapter.supportsNativeShadowDOM():boolean', + 'Parse5DomAdapter.supportsWebAnimation():boolean', + 'Parse5DomAdapter.tagName(element:any):string', + 'Parse5DomAdapter.templateAwareRoot(el:any):any', + 'Parse5DomAdapter.type(node:any):string', ]; const PLATFORM_SERVER_TESTING = [