├── ts ├── index.ts ├── pipes.ts ├── ngWhen.ts └── observableFirebase.ts ├── .gitignore ├── .npmignore ├── .vscode └── settings.json ├── CHANGELOG.md ├── tsconfig.es5.json ├── tsconfig.es6.json ├── package.json ├── README.md └── LICENSE /ts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './observableFirebase'; 2 | export * from './pipes'; 3 | export * from './ngWhen'; 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | typings/ 3 | *.log 4 | *.tgz 5 | *.d.ts 6 | *.js 7 | *.map 8 | local-* 9 | bundle/ 10 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | typings/ 3 | *.log 4 | *.tgz 5 | ts/ 6 | local-* 7 | .vscode 8 | *.json 9 | .npmignore 10 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.insertSpaces": true, 4 | "editor.tabSize": 2 5 | } 6 | 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # angular2-firebase Changelog 2 | 3 | ## 0.7.0 4 | 5 | * Rearrange sources to match newer NPM-TypeScript practices. 6 | * Update to work with Angular 2 RC new "@angular/" packaging. 7 | * Ship ES5 and ES6, but not TS files. 8 | * Ship System bundle. 9 | -------------------------------------------------------------------------------- /tsconfig.es5.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es6", "dom"], 4 | "target": "es5", 5 | "outDir": ".", 6 | "noImplicitAny": true, 7 | "preserveConstEnums": true, 8 | "sourceMap": true, 9 | "experimentalDecorators": true, 10 | "emitDecoratorMetadata": true, 11 | "moduleResolution": "node", 12 | "declaration": true 13 | }, 14 | "files": [ 15 | "ts/index.ts" 16 | ], 17 | "typeRoots": [ 18 | "../node_modules/@types" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.es6.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es6", "dom"], 4 | "target": "es6", 5 | "module": "es6", 6 | "outDir": "esm", 7 | "noImplicitAny": true, 8 | "preserveConstEnums": true, 9 | "sourceMap": true, 10 | "experimentalDecorators": true, 11 | "emitDecoratorMetadata": true, 12 | "moduleResolution": "node", 13 | "declaration": true 14 | }, 15 | "files": [ 16 | "ts/index.ts" 17 | ], 18 | "typeRoots": [ 19 | "../node_modules/@types" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-firebase", 3 | "version": "0.7.4", 4 | "description": "Angular 2 Adapter for Firebase", 5 | "keywords": [ 6 | "angular2", 7 | "firebase" 8 | ], 9 | "repository": "https://github.com/OasisDigital/angular2-firebase", 10 | "main": "index.js", 11 | "jsnext:main": "esm/index.js", 12 | "scripts": { 13 | "tsc:es5": "tsc -p tsconfig.es5.json", 14 | "tsc:es6": "tsc -p tsconfig.es6.json", 15 | "tsc:umd": "rollup esm/index.js -f umd -n angular2firebase -o bundle/angular2-firebase.umd.js", 16 | "prepublish": "npm-run-all tsc:es5 tsc:es6 tsc:umd" 17 | }, 18 | "author": "Kyle Cordes ", 19 | "license": "Apache-2.0", 20 | "peerDependencies": { 21 | "@angular/common": "^2.3.1", 22 | "@angular/core": "^2.3.1", 23 | "rxjs": "^5.0.0-rc.4" 24 | }, 25 | "devDependencies": { 26 | "@angular/common": "^2.3.1", 27 | "@angular/core": "^2.3.1", 28 | "@types/firebase": "^2.4.30", 29 | "npm-run-all": "^1.8.0", 30 | "rollup": "^0.35.3", 31 | "rxjs": "5.0.0-rc.4", 32 | "typescript": "^2.0.10", 33 | "zone.js": "^0.7.2" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ts/pipes.ts: -------------------------------------------------------------------------------- 1 | // Angular 2 Toolkit - Firebase Observable Pipes 2 | // Copyright 2015-2016 Oasis Digital - http://oasisdigital.com 3 | // written by Kyle Cordes - http://kylecordes.com 4 | // started November 2015 5 | 6 | import {Pipe, PipeTransform} from '@angular/core'; 7 | import {Observable} from 'rxjs/Observable'; 8 | 9 | import "rxjs/add/operator/map"; 10 | 11 | import {observableFirebaseObject, observableFirebaseArray} from './observableFirebase'; 12 | 13 | @Pipe({ 14 | name: 'firebaseToObservableObject' 15 | }) 16 | export class FirebaseToObservableObjectPipe implements PipeTransform { 17 | transform(input: Firebase, args: any[] = []):Observable { 18 | if (input) { 19 | return observableFirebaseObject(input); 20 | } 21 | } 22 | } 23 | 24 | @Pipe({ 25 | name: 'firebaseToObservableArray' 26 | }) 27 | export class FirebaseToObservableArrayPipe implements PipeTransform { 28 | transform(input: Firebase, args: any[] = []): Observable { 29 | if (input) { 30 | return observableFirebaseArray(input); 31 | } 32 | } 33 | } 34 | 35 | @Pipe({ 36 | name: 'arrayifyObservable' 37 | }) 38 | export class ArrayifyObservablePipe implements PipeTransform { 39 | transform(input: Observable, args: any[] = []): Observable { 40 | if (input) { 41 | return input.map(x => [x]); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED - Angular 2 Firebase Tools 2 | 3 | ## Use this instead: 4 | 5 | There is an official Angular 2 <-> Firebase library now (as of 2017) in find 6 | condition for real use, implemented by the team at Firebase / Google: 7 | 8 | https://angularfire2.com/ 9 | 10 | https://github.com/angular/angularfire2 11 | 12 | You should probably use that library. It certainly has more documentation 13 | and features than this one. 14 | 15 | # Old, Third Party A2-Firebase Library 16 | 17 | This third-party library existed because: 18 | 19 | * I started well before the official library. 20 | * I was able to get applications up and running with it. 21 | * It has a considerably more minimal approach, contrasting the 22 | "wrap outside things in Angular thing" 23 | approach used by angularfire2. 24 | 25 | ## Introduction 26 | 27 | An application should be able to consume data *without* caring 28 | about the on() Firebase API, Firebase events, or the 29 | object-as-pseudo-array convention. 30 | 31 | The library currently includes: 32 | 33 | * Firebase Observable object, a very straightforward implementation. 34 | * Firebase Observable array, which understands the pattern of events emitted 35 | by Firebase and produces an observable of the resulting array. 36 | 37 | Many areas are still under consideration and development: 38 | 39 | * Writing to Firebase. 40 | * Following references (joins) 41 | * A way to generate TS schema from Bolt schema, or vice versa. 42 | 43 | ## Demo 44 | 45 | https://github.com/OasisDigital/angular2-firebase-demo 46 | 47 | ## Why Observables? Why the async pipe? 48 | 49 | By wrapping the Firebase API behind Observables, 50 | then consuming those Observables typically via an async pipe, 51 | it should never be necessary to manually subscribe 52 | and unsubscribe the Observables, 53 | nor manually hook and unhook Firebase events. 54 | 55 | I believe that, if you find it necessary to write ngOnDestroy in a visual component, 56 | it is a sign that the component is not yet sufficienty abstracted. 57 | 58 | ## How to Consume 59 | 60 | It will generally "just work" with typescript and webpack. 61 | Other combinations might work, but still need attention. 62 | 63 | As far as I can tell, TypeScript with NPM modules is still a topic of much 64 | discussion and work. This library does the following, 65 | it appears to be the preferred approach: 66 | 67 | * Leave the TypeScript code in the repository, don't ship it in the NPM package 68 | * Ship ES5 code with .d.ts 69 | * Also ship ES6 code with .d.ts, to enable downstream "tree shaking". 70 | 71 | Older versions of this library included typings for Firebase; 72 | the "typings" and related tooling have made that obsolete. 73 | Use typings or other means to obtain the Firebase .d.ts file, 74 | and include it in your project. 75 | 76 | For examples of working tsconfig and typings, see the demo: 77 | 78 | https://github.com/OasisDigital/angular2-firebase-demo 79 | 80 | 81 | Kyle Cordes 82 | http://kylecordes.com 83 | -------------------------------------------------------------------------------- /ts/ngWhen.ts: -------------------------------------------------------------------------------- 1 | // Angular 2 Toolkit - ngWhen 2 | // Copyright 2015-2016 Oasis Digital - http://oasisdigital.com 3 | // written by Kyle Cordes - http://kylecordes.com 4 | // started November 2015 5 | 6 | import {Directive} from '@angular/core'; 7 | import {DoCheck, ChangeDetectorRef, EmbeddedViewRef} from '@angular/core'; 8 | import {ViewContainerRef, TemplateRef, ViewRef} from '@angular/core'; 9 | 10 | 11 | export class NgWhenPayload { 12 | constructor(public $implicit: any) { } 13 | } 14 | 15 | /** 16 | * TODO document this like NgIf and NgFor, 17 | * The following is some text from the docs for those things, here for reference. 18 | * 19 | * Removes or recreates a portion of the DOM tree based on an {expression}. 20 | * 21 | * If the expression assigned to `ng-if` evaluates to a false value then the element 22 | * is removed from the DOM, otherwise a clone of the element is reinserted into the DOM. 23 | * 24 | * ### Example ([live demo](http://plnkr.co/edit/fe0kgemFBtmQOY31b4tw?p=preview)): 25 | * 26 | * ``` 27 | *
28 | * 30 | * {{errorCount}} errors detected 31 | *
32 | * ``` 33 | * 34 | *##Syntax 35 | * 36 | * - `
...
` 37 | * - `
...
` 38 | * - `` 39 | 40 | * The `NgWhen` directive instantiates a template once per item from an iterable. The context for 41 | * each instantiated template inherits from the outer context with the given loop variable set 42 | * to the current item from the iterable. 43 | * 44 | * # Change Propagation 45 | * 46 | * When the contents of the iterator changes, `NgWhen` makes the corresponding changes to the DOM: 47 | * 48 | * * When the item becomes non-null, an instance of the template is added to the DOM. 49 | * * When the item becomes null, its template instance is removed from the DOM. 50 | * 51 | * # Syntax 52 | * 53 | * - `
  • ...
  • ` 54 | * - `
  • ...
  • ` 55 | * - `` 56 | * 57 | * ### Example 58 | * 59 | * See a [live demo](TODO) for a more detailed 60 | * example. 61 | */ 62 | 63 | function isPresent(obj: any): boolean { 64 | return obj !== undefined && obj !== null; 65 | } 66 | 67 | function presentNotFalse(x: any) { 68 | return isPresent(x) && x !== false; 69 | } 70 | 71 | @Directive({ selector: '[ngWhen][ngWhenIs]', inputs: ['ngWhenIs', 'ngWhenTemplate'] }) 72 | export class NgWhen { 73 | /** @internal */ 74 | private _prevCondition: any = null; 75 | // TODO remove _prevCondition, the viewRef is enough. 76 | private _viewRef: EmbeddedViewRef = null; 77 | 78 | constructor(private _viewContainer: ViewContainerRef, private _templateRef: TemplateRef, 79 | private _cdr: ChangeDetectorRef) { } 80 | 81 | set ngWhenIs(newCondition: any) { 82 | if (presentNotFalse(newCondition) && !presentNotFalse(this._prevCondition)) { 83 | this._viewRef = this._viewContainer.createEmbeddedView(this._templateRef); 84 | this._viewRef.context.$implicit = newCondition; 85 | } else if (!presentNotFalse(newCondition) && presentNotFalse(this._prevCondition)) { 86 | this._viewContainer.clear(); 87 | this._viewRef = null; 88 | } 89 | this._prevCondition = newCondition; 90 | if (presentNotFalse(newCondition)) { 91 | this._viewRef.context.$implicit = newCondition; 92 | } 93 | } 94 | 95 | set ngWhenTemplate(value: TemplateRef) { 96 | if (isPresent(value)) { 97 | this._templateRef = value; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /ts/observableFirebase.ts: -------------------------------------------------------------------------------- 1 | // Angular 2 Toolkit - Firebase Observables 2 | // Copyright 2015-2016 Oasis Digital - http://oasisdigital.com 3 | // written by Kyle Cordes - http://kylecordes.com 4 | // started November 2015 5 | 6 | // This is a first draft at two different translations of a Firebase query 7 | // to an Observable. One is suitable for "leaf" objects, these are watched 8 | // as a unit and replaced with each update. The other is suitable for Firebase 9 | // "arrays", it understands the conventions use their to make an observable 10 | // that yields an array with each change. 11 | 12 | // TODO understand TypeScript generics more fully, seek advice from a guru. 13 | 14 | // TODO Further polish this, publish as a reusable library. 15 | 16 | // TODO determine if the safe copies are compatible with performant Angular 2. 17 | 18 | import {Observable} from 'rxjs/Observable'; 19 | 20 | // TODO How do I type this without adding another dependency on @reactivex/rxjs? 21 | // import { Subscriber } from '@reactivex/rxjs/dist/cjs/Rx'; 22 | 23 | export function observableFirebaseObject(ref: FirebaseQuery): Observable { 24 | return Observable.create(function(observer: any) { 25 | function value(snapshot: FirebaseDataSnapshot) { 26 | observer.next(snapshot.val()); 27 | } 28 | ref.on('value', value); 29 | return function() { 30 | ref.off('value', value); 31 | } 32 | }); 33 | } 34 | 35 | function findInArray(list: T[], predicate: Function) { 36 | for (var i = 0; i < list.length; i++) { 37 | const value: T = list[i]; 38 | if (predicate.call(this, value, i, list)) { 39 | return value; 40 | } 41 | } 42 | } 43 | 44 | export function observableFirebaseArray(ref: FirebaseQuery): Observable { 45 | 46 | return Observable.create(function(observer: any) { 47 | // Looking for how to type this well. 48 | let arr: any[] = []; 49 | const keyFieldName = "$$fbKey"; 50 | 51 | function child_added(snapshot: FirebaseDataSnapshot, prevChildKey: string) { 52 | let child = snapshot.val(); 53 | child[keyFieldName] = snapshot.key(); 54 | let prevEntry = findInArray(arr, (y: any) => y[keyFieldName] === prevChildKey); 55 | arr.splice(arr.indexOf(prevEntry) + 1, 0, child); 56 | observer.next(arr.slice()); // Safe copy 57 | } 58 | 59 | function child_changed(snapshot: FirebaseDataSnapshot) { 60 | let key = snapshot.key(); 61 | let child = snapshot.val(); 62 | // TODO replace object rather than mutate it? 63 | let x = findInArray(arr, (y: any) => y[keyFieldName] === key); 64 | if (x) { 65 | for (var k in child) x[k] = child[k]; 66 | } 67 | observer.next(arr.slice()); // Safe copy 68 | } 69 | 70 | function child_removed(snapshot: FirebaseDataSnapshot) { 71 | let key = snapshot.key(); 72 | let child = snapshot.val(); 73 | let x = findInArray(arr, (y: any) => y[keyFieldName] === key); 74 | if (x) { 75 | arr.splice(arr.indexOf(x), 1); 76 | } 77 | observer.next(arr.slice()); // Safe copy 78 | } 79 | 80 | function child_moved(snapshot: FirebaseDataSnapshot, prevChildKey: string) { 81 | let key = snapshot.key(); 82 | let child = snapshot.val(); 83 | child[keyFieldName] = key; 84 | // Remove from old slot 85 | let x = findInArray(arr, (y: any) => y[keyFieldName] === key); 86 | if (x) { 87 | arr.splice(arr.indexOf(x), 1); 88 | } 89 | // Add in new slot 90 | let prevEntry = findInArray(arr, (y: any) => y[keyFieldName] === prevChildKey); 91 | if (prevEntry) { 92 | arr.splice(arr.indexOf(prevEntry) + 1, 0, child); 93 | } else { 94 | arr.splice(0, 0, child); 95 | } 96 | observer.next(arr.slice()); // Safe copy 97 | } 98 | 99 | // Start out empty, until data arrives 100 | observer.next(arr.slice()); // Safe copy 101 | 102 | ref.on('child_added', child_added); 103 | ref.on('child_changed', child_changed); 104 | ref.on('child_removed', child_removed); 105 | ref.on('child_moved', child_moved); 106 | 107 | return function() { 108 | ref.off('child_added', child_added); 109 | ref.off('child_changed', child_changed); 110 | ref.off('child_removed', child_removed); 111 | ref.off('child_moved', child_moved); 112 | } 113 | }); 114 | } 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------