From 07a54e263de4f366b5c8fef741316d9da49415cd Mon Sep 17 00:00:00 2001 From: Rubenator Date: Sat, 6 May 2017 13:58:49 +0100 Subject: [PATCH] Small fixes for npm --- package.json | 22 ++++++++++------------ src/GoogleApiModule.ts | 6 +----- src/GoogleApiService.ts | 18 +++++++++++------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 0a79fa9..59ead93 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "ng-gapi", - "version": "0.0.36", + "version": "0.0.39", "description": "Angular 2 Google api module", - "main": "components.js", - "typings": "lib/index", + "main": "./lib/index.js", + "typings": "./lib/index", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -30,16 +30,14 @@ "url": "https://github.com/rubenCodeforges/angular2-google-api/issues" }, "homepage": "https://github.com/rubenCodeforges/angular2-google-api#readme", - "devDependencies": { - "typescript": "^2.2.2", + "dependencies": { "@types/gapi": "0.0.31", "@types/gapi.auth2": "0.0.35" }, - "dependencies": { - "@angular/common": "^4.0.0", - "@angular/compiler": "^4.0.0", - "@angular/core": "^4.0.0", - "@angular/http": "^4.0.0", - "rxjs": "^5.3.0" + "devDependencies": { + "@angular/core": "^4.1.1", + "rxjs": "^5.3.1", + "typescript": "^2.2.2", + "zone.js": "^0.8.10" } -} \ No newline at end of file +} diff --git a/src/GoogleApiModule.ts b/src/GoogleApiModule.ts index afa8d4c..5104af5 100644 --- a/src/GoogleApiModule.ts +++ b/src/GoogleApiModule.ts @@ -10,13 +10,9 @@ export class GoogleApiModule { return { ngModule: GoogleApiModule, providers: [ - GoogleApiService, { provide: GoogleApiService, - useFactory: GoogleApiService.factory, - deps: [ - apiConfig - ] + useFactory: () => GoogleApiService.factory(apiConfig), }, { provide: GoogleAuthService, diff --git a/src/GoogleApiService.ts b/src/GoogleApiService.ts index 6126a92..4ff5009 100644 --- a/src/GoogleApiService.ts +++ b/src/GoogleApiService.ts @@ -1,6 +1,6 @@ import {Observable} from "rxjs"; import {Injectable} from "@angular/core"; -import {GoogleApiConfig} from "./config/GoogleApiConfig"; +import {GoogleApiConfig, GapiInitConfigs} from "./config/GoogleApiConfig"; @Injectable() export class GoogleApiService { @@ -8,12 +8,12 @@ export class GoogleApiService { private isLoaded: boolean = false; private config: GoogleApiConfig; - public static factory(apiConfig: GoogleApiConfig) { - return new GoogleApiService(apiConfig); + public static factory(configs: GapiInitConfigs) { + return new GoogleApiService(configs); } - constructor(config: GoogleApiConfig) { - this.config = config; + constructor(config: GapiInitConfigs) { + this.config = new GoogleApiConfig(config); this.loadGapi(); } @@ -25,8 +25,12 @@ export class GoogleApiService { this.loadGapi().subscribe(callback); } + public getConfig(): GoogleApiConfig { + return this.config; + } + private loadGapi(): Observable { - return Observable.create((observer) => { + return Observable.create((observer: any) => { let node = document.createElement('script'); node.src = this.gapiUrl; node.type = 'text/javascript'; @@ -39,4 +43,4 @@ export class GoogleApiService { }; }); } -} \ No newline at end of file +}