├── dist └── .gitkeep ├── .npmignore ├── .gitignore ├── tslint.json ├── CONTRIBUTING.md ├── tsconfig-esm.json ├── tsconfig-ngc.json ├── README.md ├── LICENSE ├── scripts └── watch.sh ├── package.json └── src └── index.ts /dist/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | gulpfile.js 2 | src 3 | tsconfig.json 4 | tslint.json 5 | dist/es5/node_modules 6 | dist/es5/src 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist/**/* 4 | .idea/ 5 | npm-debug.log 6 | *.sw[mnpcod] 7 | .vscode/ 8 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint-ionic-rules", 3 | "rules": { 4 | "no-unused-variable": [true] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Pull Requests 4 | 5 | Pull requests are welcome! 6 | 7 | The bleeding edge is `master`, so you'll want to make your changes off of that. 8 | The source code is Typescript and lives in `src/`. 9 | 10 | ### Local Setup 11 | 12 | After cloning and installing npm dependencies, there are a variety of npm 13 | scripts to help you during development. 14 | 15 | * `npm run lint` - Lint your code. 16 | * `npm run build` - Run lint and transpile the TypeScript source files. 17 | -------------------------------------------------------------------------------- /tsconfig-esm.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": false, 4 | "emitDecoratorMetadata": true, 5 | "experimentalDecorators": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "module": "es2015", 8 | "moduleResolution": "node", 9 | "noImplicitAny": false, 10 | "noImplicitReturns": true, 11 | "outDir": "dist/esm", 12 | "removeComments": false, 13 | "skipLibCheck": true, 14 | "strictNullChecks": true, 15 | "target": "es5" 16 | }, 17 | "files": [ 18 | "src/index.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig-ngc.json: -------------------------------------------------------------------------------- 1 | { 2 | "angularCompilerOptions": { 3 | "genDir": "dist/es5" 4 | }, 5 | "compilerOptions": { 6 | "allowJs": false, 7 | "declaration": true, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "module": "commonjs", 12 | "moduleResolution": "node", 13 | "noImplicitAny": false, 14 | "noImplicitReturns": true, 15 | "outDir": "dist/es5", 16 | "removeComments": false, 17 | "skipLibCheck": true, 18 | "sourceMap": true, 19 | "target": "es5" 20 | }, 21 | "files": [ 22 | "src/index.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## NOTE: Ionic Cloud is evolving into Ionic Pro and this client is deprecated. See the [Migration Guide](http://ionicframework.com/docs/pro/migration/) for more info. 2 | 3 | # Ionic Cloud Client for Angular 2 4 | 5 | Angular 2 integration for the [Ionic Cloud 6 | Client](https://github.com/driftyco/ionic-cloud). Check out [our 7 | documentation](http://docs.ionic.io/). 8 | 9 | ## Issues 10 | 11 | * For bugs and issues with this library specifically, feel free to post a github issue here. 12 | * For issues with the Ionic API and/or the services, file a ticket [here](https://ionic.zendesk.com/hc/en-us/requests/new). 13 | 14 | ## Local Development 15 | 16 | See the [`CONTRIBUTING.md` 17 | file](https://github.com/driftyco/ionic-cloud-angular/blob/master/CONTRIBUTING.md). 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ionic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/watch.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | 3 | if [ -z $1 ]; then 4 | cat <<-EOF 5 | Please supply the destination project path 6 | Ex: 7 | npm run watch -- ~/ionic/ionic-conference-app 8 | or 9 | ./scripts/watch.sh ~/ionic/ionic-conference-app 10 | EOF 11 | exit 1 12 | fi 13 | 14 | if [ ! -d $1 ]; then 15 | echo "The supplied project path doesn't exist." 16 | exit 1 17 | fi 18 | 19 | IONIC_CONFIG="${1%/}/ionic.config.json" 20 | if [ ! -f $IONIC_CONFIG ]; then 21 | echo "Are you sure this is an ionic project? $IONIC_CONFIG doesn't exist." 22 | exit 1 23 | fi 24 | 25 | CLOUD_NG_DIR="${1%/}/node_modules/@ionic/cloud-angular/" 26 | NPM_BIN=$(npm bin) 27 | 28 | # tidy up 29 | [ -d $CLOUD_NG_DIR ] && rm -r $CLOUD_NG_DIR 30 | mkdir -p $CLOUD_NG_DIR 31 | cp package.json $CLOUD_NG_DIR || exit 1 32 | rm -r dist/* 2>/dev/null 33 | 34 | # watch for file changes, copy to dest node_modules/@ionic/cloud-angular/ 35 | $NPM_BIN/chokidar "dist/**/*" --silent --t=-1 --d=-1 -c "rsync --relative {path} $CLOUD_NG_DIR" & 36 | 37 | # let watchers init before transpiling 38 | # if you're missing files in node_modules, up this number 39 | sleep 2 && ($NPM_BIN/tsc -w -p tsconfig-esm.json &) 40 | $NPM_BIN/tsc -w -p tsconfig-es5.json && fg 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ionic/cloud-angular", 3 | "version": "0.12.1-beta.1", 4 | "description": "Ionic Cloud Client for Angular 2", 5 | "main": "dist/es5/index.js", 6 | "module": "dist/esm/index.js", 7 | "typings": "dist/es5/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint 'src/**/*.ts'", 10 | "tsc": "tsc -p tsconfig-esm.json", 11 | "ngc": "ngc -p tsconfig-ngc.json", 12 | "prepublish": "npm run build", 13 | "build": "npm run lint && npm run ngc && npm run tsc", 14 | "watch": "./scripts/watch.sh" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/driftyco/ionic-cloud-angular.git" 19 | }, 20 | "keywords": [ 21 | "Ionic", 22 | "ionic", 23 | "cloud", 24 | "web", 25 | "client", 26 | "angular" 27 | ], 28 | "author": "Ionic", 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/driftyco/ionic-cloud-angular/issues" 32 | }, 33 | "homepage": "https://github.com/driftyco/ionic-cloud-angular#readme", 34 | "dependencies": { 35 | "@ionic/cloud": "0.16.1-beta.1" 36 | }, 37 | "peerDependencies": { 38 | "@angular/core": "^2.1.1 || ^4.0.0", 39 | "rxjs": "^5.1.1" 40 | }, 41 | "devDependencies": { 42 | "@angular/compiler": "4.0.2", 43 | "@angular/compiler-cli": "4.0.2", 44 | "chokidar-cli": "tlancina/chokidar-cli", 45 | "tslint": "^3.10.2", 46 | "tslint-ionic-rules": "*", 47 | "typescript": "^2.2.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from '@ionic/cloud'; 2 | 3 | import { Observable } from 'rxjs'; 4 | import { Injectable, ModuleWithProviders, NgModule, OpaqueToken } from '@angular/core'; 5 | import { 6 | Auth as _Auth, 7 | FacebookAuth as _FacebookAuth, 8 | GoogleAuth as _GoogleAuth, 9 | Client as _Client, 10 | CloudSettings, 11 | Config as _Config, 12 | Deploy as _Deploy, 13 | DIContainer as _DIContainer, 14 | EventHandler, 15 | IEventEmitter, 16 | IAuth, 17 | IClient, 18 | IConfig, 19 | IDeploy, 20 | IFacebookAuth, 21 | IGoogleAuth, 22 | IPush as _IPush, 23 | IPushMessage, 24 | IUser, 25 | Insights as _Insights, 26 | Push as _Push, 27 | PushNotificationEvent, 28 | User as _User, 29 | } from '@ionic/cloud'; 30 | 31 | export class Rx { 32 | constructor(protected emitter: IEventEmitter) {} 33 | } 34 | 35 | export class PushRx extends Rx { 36 | notification(): Observable { 37 | return Observable.fromEventPattern((h: EventHandler) => { 38 | return this.emitter.on('push:notification', (data: PushNotificationEvent) => { 39 | return h(data.message); 40 | }); 41 | }, (_: Function) => { 42 | // https://github.com/ReactiveX/rxjs/issues/1900 43 | // this.emitter.off(signal); 44 | }); 45 | } 46 | } 47 | 48 | export interface IPush extends _IPush { 49 | rx: PushRx; 50 | } 51 | 52 | @Injectable() 53 | export class FacebookAuth extends _FacebookAuth {} 54 | 55 | @Injectable() 56 | export class GoogleAuth extends _GoogleAuth {} 57 | 58 | @Injectable() 59 | export class Auth extends _Auth {} 60 | 61 | @Injectable() 62 | export class Client extends _Client {} 63 | 64 | @Injectable() 65 | export class Config extends _Config {} 66 | 67 | @Injectable() 68 | export class Deploy extends _Deploy {} 69 | 70 | @Injectable() 71 | export class DIContainer extends _DIContainer {} 72 | 73 | @Injectable() 74 | export class Insights extends _Insights {} 75 | 76 | @Injectable() 77 | export class Push extends _Push implements IPush { 78 | 79 | /** 80 | * Observables for the push service. 81 | */ 82 | public rx: PushRx; 83 | } 84 | 85 | @Injectable() 86 | export class User extends _User {} 87 | 88 | export const CloudSettingsToken = new OpaqueToken('CloudSettings'); 89 | 90 | export function provideContainer(settings: CloudSettings): DIContainer { 91 | let container = new DIContainer(); 92 | container.config.register(settings); 93 | container.core.init(); 94 | container.cordova.bootstrap(); 95 | 96 | return container; 97 | } 98 | 99 | export function provideConfig(container: DIContainer): IConfig { 100 | return container.config; 101 | } 102 | 103 | export function provideAuth(container: DIContainer): IAuth { 104 | return container.auth; 105 | } 106 | 107 | export function provideClient(container: DIContainer): IClient { 108 | return container.client; 109 | } 110 | 111 | export function provideDeploy(container: DIContainer): IDeploy { 112 | return container.deploy; 113 | } 114 | 115 | export function provideUser(container: DIContainer): IUser { 116 | return container.singleUserService.current(); 117 | } 118 | 119 | export function providePush(container: DIContainer): IPush { 120 | let push = container.push as IPush; 121 | push.rx = new PushRx(container.eventEmitter); 122 | return push; 123 | } 124 | 125 | export function provideFacebookAuth(container: DIContainer): IFacebookAuth { 126 | return container.facebookAuth; 127 | } 128 | 129 | export function provideGoogleAuth(container: DIContainer): IGoogleAuth { 130 | return container.googleAuth; 131 | } 132 | 133 | @NgModule() 134 | export class CloudModule { 135 | static forRoot(settings: CloudSettings): ModuleWithProviders { 136 | return { 137 | ngModule: CloudModule, 138 | providers: [ 139 | { provide: CloudSettingsToken, useValue: settings }, 140 | { provide: DIContainer, useFactory: provideContainer, deps: [ CloudSettingsToken ] }, 141 | { provide: Auth, useFactory: provideAuth, deps: [ DIContainer ] }, 142 | { provide: Client, useFactory: provideClient, deps: [ DIContainer ] }, 143 | { provide: Config, useFactory: provideConfig, deps: [ DIContainer ] }, 144 | { provide: Deploy, useFactory: provideDeploy, deps: [ DIContainer ] }, 145 | { provide: Push, useFactory: providePush, deps: [ DIContainer ] }, 146 | { provide: User, useFactory: provideUser, deps: [ DIContainer ] }, 147 | { provide: FacebookAuth, useFactory: provideFacebookAuth, deps: [ DIContainer ]}, 148 | { provide: GoogleAuth, useFactory: provideGoogleAuth, deps: [ DIContainer ]} 149 | ] 150 | }; 151 | } 152 | } 153 | --------------------------------------------------------------------------------