Skip to content

Commit

Permalink
misc: refactor code base in preparation for AoT support
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacplmann authored and Shlomi Assaf (shlassaf) committed Oct 1, 2016
1 parent 494d567 commit bf54101
Show file tree
Hide file tree
Showing 28 changed files with 66 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ node_modules
/build
/dist
.idea
/compiled
2 changes: 1 addition & 1 deletion gulp/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function prepareCommands(pluginName) {
const rollupRoot = pluginName ? path.join(config.PATHS.pluginDir, pluginName) : '';

return {
ts: `./node_modules/.bin/tsc --out ${path.join(config.PATHS.dist.bundles, filename)} --target es5 --allowJs ${path.join(config.PATHS.tmp, filename)}`,
ts: `./node_modules/.bin/ngc -p tsconfig.json --out ${path.join(config.PATHS.dist.bundles, filename)} --target es5 --allowJs ${path.join(config.PATHS.tmp, filename)}`,
rollup: `./node_modules/.bin/rollup -c ${path.join(rollupRoot, ROLLUP_CONFIG)}`
}
}
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@
"start": "npm run server:dev"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/common": "2.0.1",
"@angular/compiler": "2.0.1",
"@angular/core": "2.0.1",
"@angular/forms": "2.0.1",
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/router": "3.0.1",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@angular/compiler-cli": "^0.6.3",
"@angular/platform-server": "^2.0.1",
"@types/core-js": "^0.9.28",
"@types/hammerjs": "^2.0.28",
"@types/node": "^4.0.29",
Expand Down
2 changes: 2 additions & 0 deletions src/components/angular2-modal/components/css-backdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { BaseDynamicComponent } from './base-dynamic-component';
template: ``
})
export class CSSBackdrop extends BaseDynamicComponent {
public cssClass: string;
public styleStr: string;

constructor(el: ElementRef, renderer: Renderer) {
super(el, renderer);
Expand Down
2 changes: 0 additions & 2 deletions src/components/angular2-modal/framework/createComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ function getInjector(viewContainer: ViewContainerRef, bindings: ResolvedReflecti
ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector;

}

export default createComponent;
4 changes: 2 additions & 2 deletions src/components/angular2-modal/overlay/overlay.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export interface EmbedComponentConfig {
})
export class ModalOverlay extends BaseDynamicComponent {
private beforeDestroyHandlers: Array<() => Promise<void>>;
@ViewChild('innerView', {read: ViewContainerRef}) private innerVcr: ViewContainerRef;
@ViewChild('template') private template: TemplateRef<any>;
@ViewChild('innerView', {read: ViewContainerRef}) public innerVcr: ViewContainerRef;
@ViewChild('template') public template: TemplateRef<any>;

constructor(private dialogRef: DialogRef<any>,
private vcr: ViewContainerRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import {
BSModalFooter
} from './message-modal.component';

function getProviders(): any[] {
return [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];
}
export const providers: any[] = [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];

@NgModule({
imports: [ ModalModule, CommonModule ],
Expand All @@ -28,15 +26,15 @@ function getProviders(): any[] {
BSMessageModal,
BSModalContainer
],
providers: getProviders(),
providers,
entryComponents: [
BSModalContainer,
BSMessageModal
]
})
export class BootstrapModalModule {
static getProviders(): any[] {
return getProviders();
return providers;
}
}

2 changes: 1 addition & 1 deletion src/components/angular2-modal/plugins/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export {
} from './presets/two-button-preset';
export { Modal } from './modal';

export { BootstrapModalModule } from './bootstrap.module';
export { BootstrapModalModule, providers } from './bootstrap.module';
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class BSMessageModalTitle {
`
})
export class BSMessageModalBody {
private context: MessageModalPreset;
public context: MessageModalPreset;

constructor(public dialog: DialogRef<MessageModalPreset>) {
this.context = dialog.context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface MessageModalPreset extends BSModalContext {
footerClass: string;

buttons: BSMessageModalButtonConfig[];
showInput?: any;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/angular2-modal/plugins/js-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export {
export { JSNativeModalRenderer } from './js-native-modal-renderer';
export { JSNativePresetBuilder } from './presets/js-native-preset';

export { JSNativeModalModule } from './js-native.module';
export { JSNativeModalModule, providers } from './js-native.module';
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import { Modal as BaseModal } from '../../../../components/angular2-modal';

import { Modal } from './modal';

function getProviders(): any[] {
return [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];
}
export const providers: any[] = [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];

@NgModule({
providers: getProviders()
providers
})
export class JSNativeModalModule {

static getProviders(): any[] {
return getProviders();
return providers;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class VEXDialogButtons {
</form>`
})
export class DialogFormModal implements ModalComponent<DialogPreset> {
private context: DialogPreset;
public context: DialogPreset;

constructor(public dialog: DialogRef<DialogPreset>) {
this.context = dialog.context;
Expand Down Expand Up @@ -108,7 +108,7 @@ export class DialogFormModal implements ModalComponent<DialogPreset> {
(click)="dialog.dismiss()"></div>`
})
export class FormDropIn implements ModalComponent<DropInPreset> {
private context: DropInPreset;
public context: DropInPreset;

constructor(public dialog: DialogRef<DropInPreset>) {
this.context = dialog.context;
Expand Down
2 changes: 1 addition & 1 deletion src/components/angular2-modal/plugins/vex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export {
export { DialogPreset, DialogPresetBuilder } from './presets/dialog-preset';


export { VexModalModule } from './vex.module';
export { VexModalModule, providers } from './vex.module';

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class DialogPreset extends VEXModalContext {
defaultResult: any;
content: Type<any>;
buttons: VEXButtonConfig[];
showInput: any;
}

/**
Expand Down
14 changes: 6 additions & 8 deletions src/components/angular2-modal/plugins/vex/vex.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import { ModalModule, Modal as BaseModal } from '../../../../components/angular2
import { Modal } from './modal';
import { DialogFormModal, FormDropIn, VEXDialogButtons } from './dialog-form-modal';

function getProviders(): any[] {
return [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];
}
export const providers: any[] = [
{ provide: BaseModal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];

@NgModule({
imports: [ ModalModule, CommonModule ],
Expand All @@ -20,7 +18,7 @@ function getProviders(): any[] {
FormDropIn,
DialogFormModal
],
providers: getProviders(),
providers,
entryComponents: [
DialogFormModal,
FormDropIn
Expand All @@ -29,7 +27,7 @@ function getProviders(): any[] {
export class VexModalModule {

static getProviders(): any[] {
return getProviders();
return providers;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ReflectiveInjector
} from '@angular/core';

import createComponent from '../framework/createComponent';
import { createComponent } from '../framework/createComponent';
import { DialogRef } from '../models/dialog-ref';
import { OverlayRenderer } from '../models/tokens';
import { ModalOverlay } from '../overlay/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as presets from '../presets';
})
export class BootstrapDemoPage {
modalCommands: ModalCommandDescriptor[];
@ViewChild('templateRef') private templateRef: TemplateRef<any>;
@ViewChild('templateRef') public templateRef: TemplateRef<any>;

constructor(public modal: Modal) {
this.modalCommands = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class CustomModal implements CloseGuard, ModalComponent<CustomModalContex
context: CustomModalContext;

public wrongAnswer: boolean;
public shouldUseMyClass: boolean;

constructor(public dialog: DialogRef<CustomModalContext>) {
this.context = dialog.context;
Expand Down
4 changes: 2 additions & 2 deletions src/demo/app/bootstrap-demo/bootstrap-demo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { BootstrapModalModule } from '../../../components/angular2-modal/plugins/bootstrap';
import { providers } from '../../../components/angular2-modal/plugins/bootstrap';


@Component({
Expand All @@ -8,7 +8,7 @@ import { BootstrapModalModule } from '../../../components/angular2-modal/plugins
// We override providers set by the Module since this app is using multiple module plugins
// (js-native, vex, bootstrap) which messes up the provider tree (last plugin wins)
// usually an app will use one plugin and this line is not needed.
providers: BootstrapModalModule.getProviders(),
providers: providers,
encapsulation: ViewEncapsulation.None
})
export class BootstrapDemo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class ModalCustomisationWizard {
fluent.open();
}

public logForm(value: any) {
// do something
}

get code(): string {
let p = this.preset,
code = `modal.${this.type}()\n`;
Expand Down
2 changes: 1 addition & 1 deletion src/demo/app/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { InAppModalModule, Modal } from './in-app-plugin/index';
encapsulation: ViewEncapsulation.None
})
export class Home {
@ViewChild('myTemplate', {read: TemplateRef}) private myTemplate: TemplateRef<any>;
@ViewChild('myTemplate', {read: TemplateRef}) public myTemplate: TemplateRef<any>;

constructor(private modal: Modal) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/demo/app/home/in-app-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export { Modal } from './modal';
export { InAppModalContext, InAppModalContextBuilder } from './modal-context';


function getProviders(): any[] {
export function getProviders(): any[] {
return [
{ provide: Modal_, useClass: InAppModal },
InAppModal
Expand Down
4 changes: 2 additions & 2 deletions src/demo/app/home/in-app-plugin/modal-backdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ article .content {
</div>`
})
export class InAppModalBackdrop {
private zoomState: 'in' | 'out' = 'in';
public zoomState: 'in' | 'out' = 'in';

constructor(private dialog: DialogRef<InAppModalContext>) {
constructor(public dialog: DialogRef<InAppModalContext>) {
}
}
4 changes: 2 additions & 2 deletions src/demo/app/js-native-demo/js-native-demo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, ViewEncapsulation } from '@angular/core';

import { Modal, JSNativeModalModule } from '../../../components/angular2-modal/plugins/js-native';
import { Modal, JSNativeModalModule, providers } from '../../../components/angular2-modal/plugins/js-native';
import { ModalCommandDescriptor } from '../demo-head/index';
import * as presets from './presets';

Expand All @@ -10,7 +10,7 @@ import * as presets from './presets';
// We override providers set by the Module since this app is using multiple module plugins
// (js-native, vex, bootstrap) which messes up the provider tree (last plugin wins)
// usually an app will use one plugin and this line is not needed.
providers: JSNativeModalModule.getProviders(),
providers: providers,
encapsulation: ViewEncapsulation.None
})
export class JSNativeDemo {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/app/vex-demo/login-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
})

export class LoginDialog implements ModalComponent<DialogPreset> {
private context: DialogPreset;
public context: DialogPreset;

constructor(public dialog: DialogRef<DialogPreset>) {
this.context = dialog.context;
Expand Down
9 changes: 5 additions & 4 deletions src/demo/app/vex-demo/vex-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
DialogFormModal,
DialogPresetBuilder,
VEXModalContext,
VexModalModule
VexModalModule,
providers
} from '../../../components/angular2-modal/plugins/vex';

import { DemoHead, ModalCommandDescriptor } from '../demo-head/index';
Expand All @@ -31,14 +32,14 @@ import { LoginDialog } from './login-dialog';
// We override providers set by the Module since this app is using multiple module plugins
// (js-native, vex, bootstrap) which messes up the provider tree (last plugin wins)
// usually an app will use one plugin and this line is not needed.
providers: VexModalModule.getProviders(),
providers: providers,
encapsulation: ViewEncapsulation.None
})
export class VexDemo {
modalCommands: ModalCommandDescriptor[];
theme: VEXBuiltInThemes = <VEXBuiltInThemes>'default';
@ViewChild(DemoHead) private demoHead: DemoHead;
@ViewChild('templateRef') private templateRef: TemplateRef<any>;
@ViewChild(DemoHead) public demoHead: DemoHead;
@ViewChild('templateRef') public templateRef: TemplateRef<any>;

constructor(public modal: Modal) {

Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"dist",
"gulp",
"typings"
]
],
"angularCompilerOptions": {
"genDir": "compiled"
}
}

0 comments on commit bf54101

Please sign in to comment.