From 2568018527f0abeb6e1c556a60d8f6094c4af624 Mon Sep 17 00:00:00 2001 From: Sergey Akopkokhyants Date: Thu, 22 Dec 2016 22:59:07 +0200 Subject: [PATCH] fix(): Added AOT support --- .github/CONTRIBUTING.md | 2 +- .github/ISSUE_TEMPLATE.md | 2 +- index.ts | 12 +++++++++--- package.json | 18 +++++++++--------- src/dnd.config.ts | 4 ---- src/dnd.service.ts | 10 +++++++++- tsconfig.json | 8 ++++---- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 25d3ce1..cc2ba8d 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,4 +3,4 @@ If you're changing the structure of the repository please create an issue first ## Submitting bug reports -Make sure you are on latest changes and that you ran this command `npm run clean:install` after updating your local repository. If you can, please provide more infomation about your environment such as browser, operating system, node version, and npm version \ No newline at end of file +Make sure you are on latest changes and that you ran this command `npm install` after updating your local repository. If you can, please provide more infomation about your environment such as browser, operating system, node version, and npm version \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index a85f5cf..382f460 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -25,7 +25,7 @@ * **Please tell us about your environment:** -- Angular version: 2.0.0-rc.X +- Angular version: 2.X.X - Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] diff --git a/index.ts b/index.ts index db078f5..60d64c7 100644 --- a/index.ts +++ b/index.ts @@ -5,7 +5,7 @@ import { NgModule, ModuleWithProviders } from "@angular/core"; import {DragDropConfig} from './src/dnd.config'; -import {DragDropService, DragDropSortableService} from './src/dnd.service'; +import {DragDropService, DragDropSortableService, dragDropServiceFactory, dragDropSortableServiceFactory} from './src/dnd.service'; import {DraggableComponent} from './src/draggable.component'; import {DroppableComponent} from './src/droppable.component'; import {SortableContainer, SortableComponent} from './src/sortable.component'; @@ -17,15 +17,21 @@ export * from './src/draggable.component'; export * from './src/droppable.component'; export * from './src/sortable.component'; +export let providers = [ + { provide: DragDropService, useFactory: dragDropServiceFactory }, + { provide: DragDropSortableService, useFactory: dragDropSortableServiceFactory, deps: [DragDropConfig] } +]; + @NgModule({ declarations: [DraggableComponent, DroppableComponent, SortableContainer, SortableComponent], - exports : [DraggableComponent, DroppableComponent, SortableContainer, SortableComponent] + exports : [DraggableComponent, DroppableComponent, SortableContainer, SortableComponent], + }) export class DndModule { static forRoot(): ModuleWithProviders { return { ngModule: DndModule, - providers: [DragDropConfig, DragDropService, DragDropSortableService] + providers: providers }; } } \ No newline at end of file diff --git a/package.json b/package.json index 9a5b74b..e69ad17 100644 --- a/package.json +++ b/package.json @@ -35,13 +35,13 @@ "@angular/core": "^2.0.0" }, "devDependencies": { - "@angular/common": "2.1.2", - "@angular/compiler": "2.1.2", - "@angular/compiler-cli": "2.1.2", - "@angular/core": "2.1.2", - "@angular/platform-browser": "2.1.2", - "@angular/platform-browser-dynamic": "2.1.2", - "@angular/platform-server": "2.1.2", + "@angular/common": "^2.1.2", + "@angular/compiler": "^2.1.2", + "@angular/compiler-cli": "^2.1.2", + "@angular/core": "^2.1.2", + "@angular/platform-browser": "^2.1.2", + "@angular/platform-browser-dynamic": "^2.1.2", + "@angular/platform-server": "^2.1.2", "@types/hammerjs": "2.0.33", "@types/jasmine": "2.5.37", "@types/node": "6.0.46", @@ -63,7 +63,7 @@ "karma-webpack": "^1.8.0", "loader-utils": "~0.2.16", "reflect-metadata": "0.1.8", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "semantic-release": "4.3.5", "source-map-loader": "0.1.5", "ts-helpers": "1.1.2", @@ -71,7 +71,7 @@ "tslint-loader": "2.1.5", "typescript": "2.0.10", "webpack": "2.1.0-beta.25", - "zone.js": "0.6.26" + "zone.js": "^0.7.2" }, "config": { "commitizen": { diff --git a/src/dnd.config.ts b/src/dnd.config.ts index 86ce626..c269f43 100644 --- a/src/dnd.config.ts +++ b/src/dnd.config.ts @@ -2,10 +2,8 @@ // This project is licensed under the terms of the MIT license. // https://github.com/akserg/ng2-dnd -import {Injectable} from '@angular/core'; import {isString} from './dnd.utils'; -@Injectable() export class DataTransferEffect { static COPY = new DataTransferEffect('copy'); @@ -16,7 +14,6 @@ export class DataTransferEffect { constructor(public name: string) { } } -@Injectable() export class DragImage { constructor( public imageElement: any, @@ -31,7 +28,6 @@ export class DragImage { } } -@Injectable() export class DragDropConfig { public onDragStartClass: string = "dnd-drag-start"; public onDragEnterClass: string = "dnd-drag-enter"; diff --git a/src/dnd.service.ts b/src/dnd.service.ts index bd0b51d..1b3ed42 100644 --- a/src/dnd.service.ts +++ b/src/dnd.service.ts @@ -7,11 +7,15 @@ import {Injectable, EventEmitter} from '@angular/core'; import {DragDropConfig} from './dnd.config'; import {isPresent} from './dnd.utils'; -export interface DragDropData { +export class DragDropData { dragData: any; mouseEvent: MouseEvent; } +export function dragDropServiceFactory(): DragDropService { + return new DragDropService(); +} + @Injectable() export class DragDropService { allowedDropZones: Array = []; @@ -20,6 +24,10 @@ export class DragDropService { isDragged: boolean; } +export function dragDropSortableServiceFactory(config: DragDropConfig): DragDropSortableService { + return new DragDropSortableService(config); +} + @Injectable() export class DragDropSortableService { index: number; diff --git a/tsconfig.json b/tsconfig.json index e587c73..a665537 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,10 +24,10 @@ "./src/droppable.component.ts", "./src/sortable.component.ts", - "tests/dnd.component.factory.ts", - "tests/dnd.sortable.spec.ts", - "tests/dnd.with.draggable.data.spec.ts", - "tests/dnd.without.draggable.data.spec.ts" + "./tests/dnd.component.factory.ts", + "./tests/dnd.sortable.spec.ts", + "./tests/dnd.with.draggable.data.spec.ts", + "./tests/dnd.without.draggable.data.spec.ts" ], "exclude": [ "node_modules",