├── .npmignore ├── .husky ├── .gitignore └── pre-commit ├── .vscode └── settings.json ├── src ├── index.ts ├── ts-jest-integration.ts └── transform.ts ├── test ├── fixture │ ├── Deep1.tsx │ ├── Deep3.tsx │ ├── Deep2.tsx │ └── El.tsx └── transform.test.tsx ├── .github ├── dependabot.yml └── workflows │ ├── node.js.yml │ └── npm-publish.yml ├── tsconfig.jest.json ├── tsconfig.json ├── .gitignore ├── compile.ts ├── README.md ├── package.json └── LICENSE /.npmignore: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true 3 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transform' 2 | export * from './ts-jest-integration' 3 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname $0)/_/husky.sh" 3 | 4 | npm run prettier && npm t -------------------------------------------------------------------------------- /test/fixture/Deep1.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | export function Deep1() { 3 | return Deep1 4 | } 5 | -------------------------------------------------------------------------------- /test/fixture/Deep3.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | export function Deep3(props: any) { 3 | const foo = {style: {}} 4 | return Deep3{props.children} 5 | } 6 | -------------------------------------------------------------------------------- /test/fixture/Deep2.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | export function Deep2(props: any) { 3 | return ( 4 | 5 | Deep2{props.children} 6 | {props.items} 7 | 8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /src/ts-jest-integration.ts: -------------------------------------------------------------------------------- 1 | import {transform} from './transform' 2 | import * as ts from 'typescript' 3 | interface ConfigSet { 4 | compilerModule: typeof ts 5 | } 6 | export const name = 'ts-transform-react-jsx-source' 7 | export const version = 1 8 | 9 | export function factory(cs: ConfigSet) { 10 | return transform(cs.compilerModule) 11 | } 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /tsconfig.jest.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "compilerOptions": { 4 | "target": "es2016", 5 | "module": "commonjs", 6 | "declaration": true, 7 | "experimentalDecorators": true, 8 | "moduleResolution": "node", 9 | "noUnusedLocals": true, 10 | "noUnusedParameters": true, 11 | "stripInternal": true, 12 | "jsx": "react", 13 | "noImplicitAny": true, 14 | "outDir": "dist" 15 | }, 16 | "exclude": [ 17 | "node_modules", 18 | "dist" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "compilerOptions": { 4 | "target": "es2016", 5 | "module": "commonjs", 6 | "declaration": true, 7 | "experimentalDecorators": true, 8 | "moduleResolution": "node", 9 | "noUnusedLocals": true, 10 | "noUnusedParameters": true, 11 | "stripInternal": true, 12 | "jsx": "react", 13 | "noImplicitAny": true, 14 | "outDir": "dist" 15 | }, 16 | "include": [ 17 | "src/**/*" 18 | ], 19 | "exclude": [ 20 | "node_modules", 21 | "dist" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/fixture/El.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import {Deep1} from './Deep1' 3 | import {Deep2} from './Deep2' 4 | import {Deep3} from './Deep3' 5 | export interface Props { 6 | className?: string 7 | } 8 | export function Foo(props: Props) { 9 | return ( 10 |
11 | 12 |

13 | 14 | ( 16 | {t} 17 | ))} 18 | > 19 | 20 | 21 | 22 |

23 |
24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | test/fixture/*.js 40 | test/fixture/*.d.ts 41 | dist/ -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [10.x, 12.x, 14.x] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - run: npm ci 28 | - run: npm run build --if-present 29 | - run: npm test 30 | -------------------------------------------------------------------------------- /test/transform.test.tsx: -------------------------------------------------------------------------------- 1 | import {resolve} from 'path' 2 | import {readFileSync} from 'fs-extra' 3 | import * as ReactDOM from 'react-dom' 4 | import * as React from 'react' 5 | import {Foo} from './fixture/El' 6 | import * as ts from 'typescript' 7 | import {transform} from '../src' 8 | 9 | describe('transformer', function () { 10 | it('should insert lineNumber correctly', function () { 11 | const fileName = resolve(__dirname, 'fixture/El.tsx') 12 | const {outputText} = ts.transpileModule(readFileSync(fileName, 'utf8'), { 13 | transformers: { 14 | before: [transform(ts)], 15 | }, 16 | fileName, 17 | }) 18 | expect(outputText).toContain('test/fixture/El.tsx", lineNumber: 9 }') 19 | expect(outputText).toContain('test/fixture/El.tsx", lineNumber: 11 }') 20 | expect(outputText).toContain('test/fixture/El.tsx", lineNumber: 12 }') 21 | }) 22 | it('should integrate with ts-jest', function () { 23 | const el = document.createElement('div') 24 | document.body.appendChild(el) 25 | expect(() => ReactDOM.render(, el)).not.toThrow() 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v1 16 | with: 17 | node-version: 14 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - uses: actions/setup-node@v1 27 | with: 28 | node-version: 14 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | 35 | publish-gpr: 36 | needs: build 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | - uses: actions/setup-node@v1 41 | with: 42 | node-version: 14 43 | registry-url: https://npm.pkg.github.com/ 44 | - run: npm ci 45 | - run: npm publish 46 | env: 47 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 48 | -------------------------------------------------------------------------------- /compile.ts: -------------------------------------------------------------------------------- 1 | import * as ts from "typescript"; 2 | import { sync as globSync } from "glob"; 3 | import { transform } from "./src"; 4 | 5 | declare module "fs-extra" { 6 | export function outputJsonSync(file: string, data: any, opts?: {}): void; 7 | } 8 | const CJS_CONFIG: ts.CompilerOptions = { 9 | experimentalDecorators: true, 10 | jsx: ts.JsxEmit.React, 11 | module: ts.ModuleKind.ESNext, 12 | moduleResolution: ts.ModuleResolutionKind.NodeJs, 13 | noEmitOnError: false, 14 | noUnusedLocals: true, 15 | noUnusedParameters: true, 16 | stripInternal: true, 17 | declaration: true, 18 | baseUrl: __dirname, 19 | target: ts.ScriptTarget.ES2016 20 | }; 21 | 22 | export default function compile( 23 | input: string, 24 | options: ts.CompilerOptions = CJS_CONFIG 25 | ) { 26 | const files = globSync(input); 27 | const compilerHost = ts.createCompilerHost(options); 28 | const program = ts.createProgram(files, options, compilerHost); 29 | 30 | const msgs = {}; 31 | 32 | let emitResult = program.emit(undefined, undefined, undefined, undefined, { 33 | before: [transform()] 34 | }); 35 | 36 | let allDiagnostics = ts 37 | .getPreEmitDiagnostics(program) 38 | .concat(emitResult.diagnostics); 39 | 40 | allDiagnostics.forEach(diagnostic => { 41 | let { line, character } = diagnostic.file.getLineAndCharacterOfPosition( 42 | diagnostic.start 43 | ); 44 | let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); 45 | console.log( 46 | `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` 47 | ); 48 | }); 49 | 50 | return msgs; 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ts-transform-react-jsx-source 2 | 3 | ![build status](https://travis-ci.org/dropbox/ts-transform-react-jsx-source.svg?branch=master) 4 | 5 | This is a TypeScript AST Transformer that adds source file and line number to JSX elements, similar to [babel-plugin-transform-react-jsx-source](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx-source). 6 | 7 | ## Usage 8 | ### Custom compiler 9 | First of all, you need some level of familiarity with the [TypeScript Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API). 10 | 11 | `compile.ts` & tests should have examples of how this works. 12 | 13 | ### ts-loader 14 | You can add this in your webpack config `ts-loader`. 15 | ``` 16 | import {transform} from 'ts-transform-react-jsx-source'; 17 | // webpack config 18 | ... 19 | rules: [ 20 | { 21 | test: /\.tsx?$/, 22 | use: [ 23 | { 24 | loader: 'ts-loader', 25 | options: { 26 | getCustomTransformers() { 27 | return { 28 | before: [transform()], 29 | }; 30 | }, 31 | }, 32 | }, 33 | ], 34 | exclude: /node_modules/, 35 | }, 36 | ``` 37 | 38 | ## License 39 | 40 | Copyright (c) 2018 Dropbox, Inc. 41 | 42 | Licensed under the Apache License, Version 2.0 (the "License"); 43 | you may not use this file except in compliance with the License. 44 | You may obtain a copy of the License at 45 | 46 | http://www.apache.org/licenses/LICENSE-2.0 47 | 48 | Unless required by applicable law or agreed to in writing, software 49 | distributed under the License is distributed on an "AS IS" BASIS, 50 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 | See the License for the specific language governing permissions and 52 | limitations under the License. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts-transform-react-jsx-source", 3 | "version": "2.0.3", 4 | "description": "Adds source file and line number to JSX elements.", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "test": "rm -rf test/fixture/*.js && tsc && jest", 8 | "prettier": "prettier --write '{src,test}/**/*.ts*' || true", 9 | "prepublishOnly": "tsc" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/dropbox/ts-transform-react-jsx-source.git" 14 | }, 15 | "keywords": [ 16 | "typescript", 17 | "transform", 18 | "ts", 19 | "react", 20 | "jsx", 21 | "source" 22 | ], 23 | "author": "Long Ho ", 24 | "license": "Apache-2.0", 25 | "bugs": { 26 | "url": "https://github.com/dropbox/ts-transform-react-jsx-source/issues" 27 | }, 28 | "homepage": "https://github.com/dropbox/ts-transform-react-jsx-source#readme", 29 | "dependencies": { 30 | "typescript": "4" 31 | }, 32 | "peerDependencies": { 33 | "ts-jest": "^26.4.4" 34 | }, 35 | "devDependencies": { 36 | "@types/fs-extra": "^9.0.4", 37 | "@types/glob": "^7.1.3", 38 | "@types/jest": "^26.0.15", 39 | "@types/node": "^14.14.9", 40 | "@types/react-dom": "^17.0.0", 41 | "fs-extra": "^9.0.1", 42 | "glob": "^7.1.6", 43 | "husky": "5", 44 | "jest": "^26.6.3", 45 | "mocha": "^8.2.1", 46 | "prettier": "^2.2.0", 47 | "react": "^17.0.1", 48 | "react-dom": "^17.0.1", 49 | "ts-jest": "^26.4.4", 50 | "ts-node": "^9.0.0" 51 | }, 52 | "jest": { 53 | "preset": "ts-jest", 54 | "globals": { 55 | "ts-jest": { 56 | "tsconfig": "./tsconfig.jest.json", 57 | "astTransformers": { 58 | "before": [ 59 | "./dist/ts-jest-integration.js" 60 | ] 61 | } 62 | } 63 | } 64 | }, 65 | "prettier": { 66 | "tabWidth": 2, 67 | "singleQuote": true, 68 | "semi": false, 69 | "trailingComma": "es5", 70 | "bracketSpacing": false, 71 | "parser": "typescript" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/transform.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This plugin works the same way as 3 | * https://www.npmjs.com/package/babel-plugin-transform-react-jsx-source 4 | * which inject __source={{ fileName, lineNumber }} into 5 | * every React Element so React can debug 6 | * Ref: https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/shared/describeComponentFrame.js#L35 7 | */ 8 | import * as TYPESCRIPT from 'typescript' 9 | 10 | function nodeVisitor( 11 | ts: typeof TYPESCRIPT, 12 | ctx: TYPESCRIPT.TransformationContext, 13 | sf: TYPESCRIPT.SourceFile 14 | ) { 15 | let sourceJsxAttr: TYPESCRIPT.JsxAttributeLike | undefined 16 | const visitor: TYPESCRIPT.Visitor = (node) => { 17 | if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) { 18 | // Create fileName attr 19 | const fileNameAttr = ctx.factory.createPropertyAssignment( 20 | 'fileName', 21 | ctx.factory.createStringLiteral(sf.fileName) 22 | ) 23 | // Create lineNumber attr 24 | const lineNumberAttr = ctx.factory.createPropertyAssignment( 25 | 'lineNumber', 26 | ctx.factory.createNumericLiteral( 27 | ts.getLineAndCharacterOfPosition(sf, node.pos).line + 1 28 | ) 29 | ) 30 | 31 | // Create __source={{fileName, lineNumber}} JSX Attribute 32 | sourceJsxAttr = ctx.factory.createJsxAttribute( 33 | ctx.factory.createIdentifier('__source'), 34 | ctx.factory.createJsxExpression( 35 | undefined, 36 | ctx.factory.createObjectLiteralExpression([ 37 | fileNameAttr, 38 | lineNumberAttr, 39 | ]) 40 | ) 41 | ) 42 | } else if (ts.isJsxAttributes(node) && sourceJsxAttr) { 43 | const attrs = [...node.properties, sourceJsxAttr] 44 | sourceJsxAttr = undefined 45 | return ctx.factory.updateJsxAttributes(node, attrs) 46 | } 47 | return ts.visitEachChild(node, visitor, ctx) 48 | } 49 | return visitor 50 | } 51 | 52 | export function transform( 53 | ts: typeof TYPESCRIPT = TYPESCRIPT 54 | ): TYPESCRIPT.TransformerFactory { 55 | return (ctx) => (sf) => ts.visitNode(sf, nodeVisitor(ts, ctx, sf)) 56 | } 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2018 Dropbox 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. --------------------------------------------------------------------------------