├── .npmrc ├── .eslintignore ├── versions.json ├── docs ├── search.png └── status.png ├── .editorconfig ├── .prettierrc ├── manifest.json ├── .gitignore ├── styles.css ├── tsconfig.json ├── version-bump.mjs ├── .eslintrc ├── package.json ├── .github └── workflows │ └── release.yml ├── esbuild.config.mjs ├── README.md ├── main.ts └── LICENSE /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | main.js 4 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0.0": "0.15.0" 3 | } 4 | -------------------------------------------------------------------------------- /docs/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SilverEzhik/obsidian-note-codes/HEAD/docs/search.png -------------------------------------------------------------------------------- /docs/status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SilverEzhik/obsidian-note-codes/HEAD/docs/status.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | max_line_length = 100 -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "semi": true, 4 | "singleQuote": false, 5 | "quoteProps": "consistent", 6 | "trailingComma": "all", 7 | "bracketSpacing": true, 8 | "bracketSameLine": false, 9 | "arrowParens": "avoid", 10 | "endOfLine": "lf" 11 | } -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "note-codes", 3 | "name": "Note Codes", 4 | "version": "0.0.2", 5 | "minAppVersion": "0.15.0", 6 | "description": "Reference your notes from anywhere with simple 4-character codes.", 7 | "author": "Ezhik", 8 | "authorUrl": "https://ezhik.jp", 9 | "fundingUrl": "https://ezhik.jp/donate", 10 | "isDesktopOnly": false 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | main.js 14 | 15 | # Exclude sourcemaps 16 | *.map 17 | 18 | # obsidian 19 | data.json 20 | 21 | # Exclude macOS Finder (System Explorer) View States 22 | .DS_Store 23 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This CSS file will be included with your plugin, and 4 | available in the app when your plugin is enabled. 5 | 6 | If your plugin does not need CSS, delete this file. 7 | 8 | */ 9 | 10 | .note-code, 11 | input.note-code { 12 | font-family: var(--font-monospace); 13 | white-space: nowrap; 14 | } 15 | 16 | .workspace-drawer-header-name .note-code { 17 | margin-inline-start: auto; 18 | align-self: center; 19 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "ES6", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "isolatedModules": true, 13 | "strictNullChecks": true, 14 | "lib": [ 15 | "DOM", 16 | "ES5", 17 | "ES6", 18 | "ES7" 19 | ] 20 | }, 21 | "include": [ 22 | "**/*.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /version-bump.mjs: -------------------------------------------------------------------------------- 1 | import { readFileSync, writeFileSync } from "fs"; 2 | 3 | const targetVersion = process.env.npm_package_version; 4 | 5 | // read minAppVersion from manifest.json and bump version to target version 6 | let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); 7 | const { minAppVersion } = manifest; 8 | manifest.version = targetVersion; 9 | writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); 10 | 11 | // update versions.json with target version and minAppVersion from manifest.json 12 | let versions = JSON.parse(readFileSync("versions.json", "utf8")); 13 | versions[targetVersion] = minAppVersion; 14 | writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); 15 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "note-codes", 3 | "version": "0.0.2", 4 | "description": "Reference your notes from anywhere with simple 4-character codes.", 5 | "main": "main.js", 6 | "scripts": { 7 | "dev": "node esbuild.config.mjs", 8 | "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", 9 | "version": "node version-bump.mjs && git add manifest.json versions.json" 10 | }, 11 | "keywords": [ ], 12 | "author": "Ezhik", 13 | "license": "MPL-2.0", 14 | "devDependencies": { 15 | "@types/node": "^16.11.6", 16 | "@typescript-eslint/eslint-plugin": "5.29.0", 17 | "@typescript-eslint/parser": "5.29.0", 18 | "builtin-modules": "3.3.0", 19 | "esbuild": "0.17.3", 20 | "obsidian": "latest", 21 | "tslib": "2.4.0", 22 | "typescript": "4.7.4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Obsidian plugin 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | permissions: 12 | contents: write 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: Use Node.js 17 | uses: actions/setup-node@v3 18 | with: 19 | node-version: "18.x" 20 | 21 | - name: Build plugin 22 | run: | 23 | npm install 24 | npm run build 25 | 26 | - name: Create release 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | run: | 30 | tag="${GITHUB_REF#refs/tags/}" 31 | 32 | gh release create "$tag" \ 33 | --title="$tag" \ 34 | --draft \ 35 | main.js manifest.json styles.css 36 | -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from "builtin-modules"; 4 | 5 | const banner = 6 | `/* 7 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 8 | if you want to view the source, please visit the github repository of this plugin 9 | */ 10 | `; 11 | 12 | const prod = (process.argv[2] === "production"); 13 | 14 | const context = await esbuild.context({ 15 | banner: { 16 | js: banner, 17 | }, 18 | entryPoints: ["main.ts"], 19 | bundle: true, 20 | external: [ 21 | "obsidian", 22 | "electron", 23 | "@codemirror/autocomplete", 24 | "@codemirror/collab", 25 | "@codemirror/commands", 26 | "@codemirror/language", 27 | "@codemirror/lint", 28 | "@codemirror/search", 29 | "@codemirror/state", 30 | "@codemirror/view", 31 | "@lezer/common", 32 | "@lezer/highlight", 33 | "@lezer/lr", 34 | ...builtins], 35 | format: "cjs", 36 | target: "es2018", 37 | logLevel: "info", 38 | sourcemap: prod ? false : "inline", 39 | treeShaking: true, 40 | outfile: "main.js", 41 | minify: prod, 42 | }); 43 | 44 | if (prod) { 45 | await context.rebuild(); 46 | process.exit(0); 47 | } else { 48 | await context.watch(); 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Note Codes 2 | 3 | This plugin assigns 4-character codes to every note in your Obsidian vault. 4 | 5 | You can use these to quickly reference the notes in your vault from other places, such as hand-written notes. 6 | 7 | These note codes are displayed in the **status bar** on desktop and in the **note metadata sidebar** on phones and tablets. You can click on the code to instantly open the note code search, or right click on it to see additional options for copying the current note's code. 8 | 9 | The **Search for Note Codes** action will let you look up note codes in a quick switcher. 10 | 11 |
12 | Note code in the status bar 13 | Note code search 14 |
15 | 16 | There is a **protocol handler** for quickly opening notes by their note codes: 17 | 18 | ``` 19 | obsidian://note-codes/open?code=XX-XX 20 | ``` 21 | 22 | ## Command Palette Actions 23 | 24 | - **Search for note codes**: Opens the search modal to find notes by their codes 25 | - **Copy note code**: Copies the current note's code to clipboard 26 | - **Copy note code URL**: Copies the `obsidian://note-codes/open` URL for the current note 27 | 28 | ## What's in a note code? 29 | 30 | Note codes are generated based on a note's name and path, meaning that the note code will change if you rename your note. 31 | 32 | Each note code consists of 4 alphanumeric characters. For clarity, `O`, `I`, `L`, and `U` are excluded from the codes, but this plugin will automatically handle these correctly - so `OI-LU` will automatically be treated as `01-1V` when searching. Same with the missing dash or lowercase letters. 33 | 34 | Note codes are generated by SHA-256-hashing the note's path in the vault, then taking the first 20 bits of the hash and encoding them using [Douglas Crockford's Base32 encoding scheme](https://www.crockford.com/base32.html). 35 | 36 | 32^4 = 1,048,576, which is hopefully enough. 37 | -------------------------------------------------------------------------------- /main.ts: -------------------------------------------------------------------------------- 1 | import { App, Menu, Notice, Plugin, SuggestModal, TFile } from "obsidian"; 2 | 3 | type Attrs = Partial< 4 | HTMLElementTagNameMap[T] | Record 5 | >; 6 | function h( 7 | tag: T | ((attrs: Attrs) => HTMLElement), 8 | attributes: Attrs = {}, 9 | ...children: (Node | string)[] 10 | ) { 11 | const el: HTMLElement = 12 | typeof tag === "function" 13 | ? tag(attributes) 14 | : Object.assign(document.createElement(tag), attributes); 15 | el.append(...children); 16 | return el; 17 | } 18 | 19 | // eslint-disable-next-line @typescript-eslint/no-empty-interface 20 | interface NCSettings { 21 | // TODO: codes in quick switcher optionally? 22 | // codesInQuickSwitcher: boolean; 23 | } 24 | 25 | const DEFAULT_SETTINGS: NCSettings = { 26 | // codesInQuickSwitcher: false, 27 | }; 28 | 29 | // we use Crockford's Base32 alphabet that avoids similar-looking characters 30 | const jsBase32Alphabet = "0123456789abcdefghijklmnopqrstuv"; 31 | const base32Alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; 32 | const ALPHABET_LENGTH = base32Alphabet.length; 33 | const jsBase32Mapping = Object.fromEntries( 34 | jsBase32Alphabet.split("").map((char, index) => [char, base32Alphabet[index]]), 35 | ); 36 | const base32Mapping: Record = { 37 | O: "0", 38 | L: "1", 39 | I: "1", 40 | U: "V", 41 | }; 42 | 43 | const encoder = new TextEncoder(); 44 | async function hashString(string: string): Promise { 45 | const data = encoder.encode(string); 46 | const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", data)); 47 | 48 | // 1,048,576 possible hashes 49 | const num = ((bytes[0] << 16) | (bytes[1] << 8) | (bytes[2] << 0)) % ALPHABET_LENGTH ** 4; 50 | 51 | const [a, b, c, d] = num 52 | .toString(ALPHABET_LENGTH) 53 | .padStart(4, "0") 54 | .split("") 55 | .map(char => jsBase32Mapping[char]); 56 | 57 | return `${a}${b}-${c}${d}`; 58 | } 59 | 60 | type Entry = { hash: string; path: string }; 61 | function formatHash(hash: string): string { 62 | hash = hash 63 | .toUpperCase() 64 | .split("") 65 | .map(c => base32Mapping[c] ?? c) 66 | .filter(c => base32Alphabet.includes(c)) 67 | .slice(0, 4) 68 | .join(""); 69 | 70 | if (hash.length > 2) { 71 | hash = hash.slice(0, 2) + "-" + hash.slice(2); 72 | } 73 | 74 | return hash; 75 | } 76 | 77 | class NCSuggestModal extends SuggestModal { 78 | plugin: NoteCodes; 79 | 80 | constructor(app: App, plugin: NoteCodes) { 81 | super(app); 82 | this.plugin = plugin; 83 | 84 | this.setPlaceholder("__-__"); 85 | this.inputEl.classList.add("note-code"); 86 | } 87 | 88 | renderSuggestion({ hash, path }: Entry, el: HTMLElement): void { 89 | el.append( 90 | h("div", {}, path), 91 | h( 92 | "small", 93 | { className: "note-code" }, 94 | 95 | h("strong", {}, this.inputEl.value), 96 | hash.slice(this.inputEl.value.length), 97 | ), 98 | ); 99 | } 100 | 101 | getSuggestions(query: string): Entry[] { 102 | query = formatHash(query); 103 | this.inputEl.value = query; // Update the input value to match the formatted query 104 | 105 | const results: Entry[] = []; 106 | 107 | for (const [hash, path] of this.plugin.hashesToPaths.entries()) { 108 | if (hash.startsWith(query)) { 109 | results.push({ hash, path }); 110 | } 111 | } 112 | return results; 113 | } 114 | 115 | onChooseSuggestion({ hash, path }: Entry, evt: MouseEvent | KeyboardEvent): void { 116 | this.plugin.openNoteForHash(hash); 117 | } 118 | } 119 | 120 | export default class NoteCodes extends Plugin { 121 | settings: NCSettings; 122 | 123 | hashesToPaths = new Map(); 124 | pathsToHashes = new Map(); 125 | 126 | async addPath(path: string) { 127 | const hash = await hashString(path); 128 | this.hashesToPaths.set(hash, path); 129 | this.pathsToHashes.set(path, hash); 130 | return hash; 131 | } 132 | 133 | async removePath(path: string) { 134 | const hash = this.pathsToHashes.get(path); 135 | if (hash) { 136 | this.hashesToPaths.delete(hash); 137 | this.pathsToHashes.delete(path); 138 | } 139 | } 140 | 141 | async getHashForPath(path: string): Promise { 142 | const hash = this.pathsToHashes.get(path); 143 | if (hash) { 144 | return hash; 145 | } else { 146 | return await this.addPath(path); 147 | } 148 | } 149 | 150 | menu: Menu = (() => { 151 | const menu = new Menu(); 152 | menu.addItem(item => 153 | item 154 | .setTitle("Copy note code") 155 | .setIcon("binary") 156 | .onClick(() => this.copyNoteCode()), 157 | ); 158 | 159 | menu.addItem(item => 160 | item 161 | .setTitle("Copy note code URL") 162 | .setIcon("link") 163 | .onClick(() => this.copyNoteCodeURL()), 164 | ); 165 | 166 | menu.addItem(item => 167 | item 168 | .setTitle("Search note codes") 169 | .setIcon("search") 170 | .onClick(() => this.openSearchModal()), 171 | ); 172 | 173 | return menu; 174 | })(); 175 | 176 | async getHashForActiveFile(): Promise { 177 | const file = this.app.workspace.getActiveFile(); 178 | if (!file) { 179 | return; 180 | } 181 | return this.getHashForPath(file.path); 182 | } 183 | 184 | async copyNoteCode(): Promise { 185 | const hash = await this.getHashForActiveFile(); 186 | if (hash) { 187 | navigator.clipboard.writeText(hash); 188 | } 189 | } 190 | 191 | async copyNoteCodeURL(): Promise { 192 | const hash = await this.getHashForActiveFile(); 193 | if (hash) { 194 | navigator.clipboard.writeText(`obsidian://note-codes/open?code=${hash}`); 195 | } 196 | } 197 | 198 | async openNoteForHash(hash: string): Promise { 199 | hash = formatHash(hash); 200 | const path = this.hashesToPaths.get(hash); 201 | if (!path) { 202 | const fragment = new DocumentFragment(); 203 | fragment.append( 204 | h( 205 | "span", 206 | {}, 207 | "No such note code: ", 208 | h("strong", { className: "note-code" }, hash.padEnd(5, "_")), 209 | ), 210 | ); 211 | new Notice(fragment); 212 | return; 213 | } 214 | const file = path && this.app.vault.getFileByPath(path); 215 | if (file) { 216 | this.app.workspace.getLeaf().openFile(file); 217 | } else { 218 | new Notice(`File not found: ${path}`); 219 | } 220 | } 221 | 222 | statusBarItemEl: HTMLElement; 223 | 224 | async setStatusBar(file: TFile | null) { 225 | let hash = "__-__"; 226 | if (file) { 227 | hash = await this.getHashForPath(file.path); 228 | } 229 | this.statusBarItemEl.setText(hash); 230 | 231 | // add to drawer on mobile 232 | const drawerFileName = document.querySelector( 233 | `.is-mobile .workspace-drawer:not(:has(.side-dock-ribbon)) .workspace-drawer-header-name`, 234 | ); 235 | 236 | if (!drawerFileName) { 237 | return; 238 | } 239 | 240 | document 241 | .querySelectorAll(".workspace-drawer-header-name .note-code") 242 | .forEach(el => el.remove()); 243 | 244 | const el = h("div", { className: "note-code clickable-icon" }, hash); 245 | drawerFileName.append(el); 246 | 247 | this.registerDomEvent(el, "click", ev => this.openSearchModal()); 248 | this.registerDomEvent(el, "contextmenu", ev => this.menu.showAtMouseEvent(ev)); 249 | } 250 | 251 | openSearchModal() { 252 | new NCSuggestModal(this.app, this).open(); 253 | } 254 | 255 | async onload() { 256 | await this.loadSettings(); 257 | 258 | // initial load of hashes 259 | for (const file of this.app.vault.getFiles()) { 260 | this.addPath(file.path); 261 | } 262 | 263 | // register events 264 | this.registerEvent( 265 | this.app.vault.on("rename", (file, oldPath) => { 266 | this.removePath(oldPath); 267 | this.addPath(file.path); 268 | this.setStatusBar(this.app.workspace.getActiveFile()); 269 | }), 270 | ); 271 | this.registerEvent(this.app.vault.on("create", file => this.addPath(file.path))); 272 | this.registerEvent(this.app.vault.on("delete", file => this.removePath(file.path))); 273 | 274 | this.registerEvent(this.app.workspace.on("file-open", file => this.setStatusBar(file))); 275 | 276 | // add status bar item 277 | this.statusBarItemEl = this.addStatusBarItem(); 278 | this.statusBarItemEl.addClass("mod-clickable"); 279 | this.statusBarItemEl.addClass("note-code"); 280 | this.registerDomEvent(this.statusBarItemEl, "click", () => this.openSearchModal()); 281 | this.registerDomEvent(this.statusBarItemEl, "contextmenu", ev => { 282 | this.menu.showAtMouseEvent(ev); 283 | }); 284 | this.setStatusBar(this.app.workspace.getActiveFile()); 285 | 286 | // register commands 287 | this.addCommand({ 288 | id: "search", 289 | name: "Search for note codes", 290 | callback: () => this.openSearchModal(), 291 | }); 292 | this.addCommand({ 293 | id: "copy", 294 | name: "Copy note code", 295 | callback: () => this.copyNoteCode(), 296 | }); 297 | this.addCommand({ 298 | id: "copy-url", 299 | name: "Copy note code URL", 300 | callback: () => this.copyNoteCodeURL(), 301 | }); 302 | 303 | // register obsidian:// handler 304 | this.registerObsidianProtocolHandler("note-codes/open", async ({ action, code: hash }) => { 305 | this.openNoteForHash(hash); 306 | }); 307 | } 308 | 309 | onunload() { 310 | document 311 | .querySelectorAll(".workspace-drawer-header-name .note-code") 312 | .forEach(el => el.remove()); 313 | } 314 | 315 | async loadSettings() { 316 | this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); 317 | } 318 | 319 | async saveSettings() { 320 | await this.saveData(this.settings); 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # Mozilla Public License Version 2.0 2 | 3 | 1. Definitions 4 | 5 | --- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | 88 | --- 89 | 90 | 2.1. Grants 91 | 92 | Each Contributor hereby grants You a world-wide, royalty-free, 93 | non-exclusive license: 94 | 95 | (a) under intellectual property rights (other than patent or trademark) 96 | Licensable by such Contributor to use, reproduce, make available, 97 | modify, display, perform, distribute, and otherwise exploit its 98 | Contributions, either on an unmodified basis, with Modifications, or 99 | as part of a Larger Work; and 100 | 101 | (b) under Patent Claims of such Contributor to make, use, sell, offer 102 | for sale, have made, import, and otherwise transfer either its 103 | Contributions or its Contributor Version. 104 | 105 | 2.2. Effective Date 106 | 107 | The licenses granted in Section 2.1 with respect to any Contribution 108 | become effective for each Contribution on the date the Contributor first 109 | distributes such Contribution. 110 | 111 | 2.3. Limitations on Grant Scope 112 | 113 | The licenses granted in this Section 2 are the only rights granted under 114 | this License. No additional rights or licenses will be implied from the 115 | distribution or licensing of Covered Software under this License. 116 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 117 | Contributor: 118 | 119 | (a) for any code that a Contributor has removed from Covered Software; 120 | or 121 | 122 | (b) for infringements caused by: (i) Your and any other third party's 123 | modifications of Covered Software, or (ii) the combination of its 124 | Contributions with other software (except as part of its Contributor 125 | Version); or 126 | 127 | (c) under Patent Claims infringed by Covered Software in the absence of 128 | its Contributions. 129 | 130 | This License does not grant any rights in the trademarks, service marks, 131 | or logos of any Contributor (except as may be necessary to comply with 132 | the notice requirements in Section 3.4). 133 | 134 | 2.4. Subsequent Licenses 135 | 136 | No Contributor makes additional grants as a result of Your choice to 137 | distribute the Covered Software under a subsequent version of this 138 | License (see Section 10.2) or under the terms of a Secondary License (if 139 | permitted under the terms of Section 3.3). 140 | 141 | 2.5. Representation 142 | 143 | Each Contributor represents that the Contributor believes its 144 | Contributions are its original creation(s) or it has sufficient rights 145 | to grant the rights to its Contributions conveyed by this License. 146 | 147 | 2.6. Fair Use 148 | 149 | This License is not intended to limit any rights You have under 150 | applicable copyright doctrines of fair use, fair dealing, or other 151 | equivalents. 152 | 153 | 2.7. Conditions 154 | 155 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 156 | in Section 2.1. 157 | 158 | 3. Responsibilities 159 | 160 | --- 161 | 162 | 3.1. Distribution of Source Form 163 | 164 | All distribution of Covered Software in Source Code Form, including any 165 | Modifications that You create or to which You contribute, must be under 166 | the terms of this License. You must inform recipients that the Source 167 | Code Form of the Covered Software is governed by the terms of this 168 | License, and how they can obtain a copy of this License. You may not 169 | attempt to alter or restrict the recipients' rights in the Source Code 170 | Form. 171 | 172 | 3.2. Distribution of Executable Form 173 | 174 | If You distribute Covered Software in Executable Form then: 175 | 176 | (a) such Covered Software must also be made available in Source Code 177 | Form, as described in Section 3.1, and You must inform recipients of 178 | the Executable Form how they can obtain a copy of such Source Code 179 | Form by reasonable means in a timely manner, at a charge no more 180 | than the cost of distribution to the recipient; and 181 | 182 | (b) You may distribute such Executable Form under the terms of this 183 | License, or sublicense it under different terms, provided that the 184 | license for the Executable Form does not attempt to limit or alter 185 | the recipients' rights in the Source Code Form under this License. 186 | 187 | 3.3. Distribution of a Larger Work 188 | 189 | You may create and distribute a Larger Work under terms of Your choice, 190 | provided that You also comply with the requirements of this License for 191 | the Covered Software. If the Larger Work is a combination of Covered 192 | Software with a work governed by one or more Secondary Licenses, and the 193 | Covered Software is not Incompatible With Secondary Licenses, this 194 | License permits You to additionally distribute such Covered Software 195 | under the terms of such Secondary License(s), so that the recipient of 196 | the Larger Work may, at their option, further distribute the Covered 197 | Software under the terms of either this License or such Secondary 198 | License(s). 199 | 200 | 3.4. Notices 201 | 202 | You may not remove or alter the substance of any license notices 203 | (including copyright notices, patent notices, disclaimers of warranty, 204 | or limitations of liability) contained within the Source Code Form of 205 | the Covered Software, except that You may alter any license notices to 206 | the extent required to remedy known factual inaccuracies. 207 | 208 | 3.5. Application of Additional Terms 209 | 210 | You may choose to offer, and to charge a fee for, warranty, support, 211 | indemnity or liability obligations to one or more recipients of Covered 212 | Software. However, You may do so only on Your own behalf, and not on 213 | behalf of any Contributor. You must make it absolutely clear that any 214 | such warranty, support, indemnity, or liability obligation is offered by 215 | You alone, and You hereby agree to indemnify every Contributor for any 216 | liability incurred by such Contributor as a result of warranty, support, 217 | indemnity or liability terms You offer. You may include additional 218 | disclaimers of warranty and limitations of liability specific to any 219 | jurisdiction. 220 | 221 | 4. Inability to Comply Due to Statute or Regulation 222 | 223 | --- 224 | 225 | If it is impossible for You to comply with any of the terms of this 226 | License with respect to some or all of the Covered Software due to 227 | statute, judicial order, or regulation then You must: (a) comply with 228 | the terms of this License to the maximum extent possible; and (b) 229 | describe the limitations and the code they affect. Such description must 230 | be placed in a text file included with all distributions of the Covered 231 | Software under this License. Except to the extent prohibited by statute 232 | or regulation, such description must be sufficiently detailed for a 233 | recipient of ordinary skill to be able to understand it. 234 | 235 | 5. Termination 236 | 237 | --- 238 | 239 | 5.1. The rights granted under this License will terminate automatically 240 | if You fail to comply with any of its terms. However, if You become 241 | compliant, then the rights granted under this License from a particular 242 | Contributor are reinstated (a) provisionally, unless and until such 243 | Contributor explicitly and finally terminates Your grants, and (b) on an 244 | ongoing basis, if such Contributor fails to notify You of the 245 | non-compliance by some reasonable means prior to 60 days after You have 246 | come back into compliance. Moreover, Your grants from a particular 247 | Contributor are reinstated on an ongoing basis if such Contributor 248 | notifies You of the non-compliance by some reasonable means, this is the 249 | first time You have received notice of non-compliance with this License 250 | from such Contributor, and You become compliant prior to 30 days after 251 | Your receipt of the notice. 252 | 253 | 5.2. If You initiate litigation against any entity by asserting a patent 254 | infringement claim (excluding declaratory judgment actions, 255 | counter-claims, and cross-claims) alleging that a Contributor Version 256 | directly or indirectly infringes any patent, then the rights granted to 257 | You by any and all Contributors for the Covered Software under Section 258 | 2.1 of this License shall terminate. 259 | 260 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 261 | end user license agreements (excluding distributors and resellers) which 262 | have been validly granted by You or Your distributors under this License 263 | prior to termination shall survive termination. 264 | 265 | --- 266 | 267 | - * 268 | - 6. Disclaimer of Warranty \* 269 | - ------------------------- \* 270 | - * 271 | - Covered Software is provided under this License on an "as is" \* 272 | - basis, without warranty of any kind, either expressed, implied, or \* 273 | - statutory, including, without limitation, warranties that the \* 274 | - Covered Software is free of defects, merchantable, fit for a \* 275 | - particular purpose or non-infringing. The entire risk as to the \* 276 | - quality and performance of the Covered Software is with You. \* 277 | - Should any Covered Software prove defective in any respect, You \* 278 | - (not any Contributor) assume the cost of any necessary servicing, \* 279 | - repair, or correction. This disclaimer of warranty constitutes an \* 280 | - essential part of this License. No use of any Covered Software is \* 281 | - authorized under this License except under this disclaimer. \* 282 | - * 283 | 284 | --- 285 | 286 | --- 287 | 288 | - * 289 | - 7. Limitation of Liability \* 290 | - -------------------------- \* 291 | - * 292 | - Under no circumstances and under no legal theory, whether tort \* 293 | - (including negligence), contract, or otherwise, shall any \* 294 | - Contributor, or anyone who distributes Covered Software as \* 295 | - permitted above, be liable to You for any direct, indirect, \* 296 | - special, incidental, or consequential damages of any character \* 297 | - including, without limitation, damages for lost profits, loss of \* 298 | - goodwill, work stoppage, computer failure or malfunction, or any \* 299 | - and all other commercial damages or losses, even if such party \* 300 | - shall have been informed of the possibility of such damages. This \* 301 | - limitation of liability shall not apply to liability for death or \* 302 | - personal injury resulting from such party's negligence to the \* 303 | - extent applicable law prohibits such limitation. Some \* 304 | - jurisdictions do not allow the exclusion or limitation of \* 305 | - incidental or consequential damages, so this exclusion and \* 306 | - limitation may not apply to You. \* 307 | - * 308 | 309 | --- 310 | 311 | 8. Litigation 312 | 313 | --- 314 | 315 | Any litigation relating to this License may be brought only in the 316 | courts of a jurisdiction where the defendant maintains its principal 317 | place of business and such litigation shall be governed by laws of that 318 | jurisdiction, without reference to its conflict-of-law provisions. 319 | Nothing in this Section shall prevent a party's ability to bring 320 | cross-claims or counter-claims. 321 | 322 | 9. Miscellaneous 323 | 324 | --- 325 | 326 | This License represents the complete agreement concerning the subject 327 | matter hereof. If any provision of this License is held to be 328 | unenforceable, such provision shall be reformed only to the extent 329 | necessary to make it enforceable. Any law or regulation which provides 330 | that the language of a contract shall be construed against the drafter 331 | shall not be used to construe this License against a Contributor. 332 | 333 | 10. Versions of the License 334 | 335 | --- 336 | 337 | 10.1. New Versions 338 | 339 | Mozilla Foundation is the license steward. Except as provided in Section 340 | 10.3, no one other than the license steward has the right to modify or 341 | publish new versions of this License. Each version will be given a 342 | distinguishing version number. 343 | 344 | 10.2. Effect of New Versions 345 | 346 | You may distribute the Covered Software under the terms of the version 347 | of the License under which You originally received the Covered Software, 348 | or under the terms of any subsequent version published by the license 349 | steward. 350 | 351 | 10.3. Modified Versions 352 | 353 | If you create software not governed by this License, and you want to 354 | create a new license for such software, you may create and use a 355 | modified version of this License if you rename the license and remove 356 | any references to the name of the license steward (except to note that 357 | such modified license differs from this License). 358 | 359 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 360 | Licenses 361 | 362 | If You choose to distribute Source Code Form that is Incompatible With 363 | Secondary Licenses under the terms of this version of the License, the 364 | notice described in Exhibit B of this License must be attached. 365 | 366 | ## Exhibit A - Source Code Form License Notice 367 | 368 | This Source Code Form is subject to the terms of the Mozilla Public 369 | License, v. 2.0. If a copy of the MPL was not distributed with this 370 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 371 | 372 | If it is not possible or desirable to put the notice in a particular 373 | file, then You may include the notice in a location (such as a LICENSE 374 | file in a relevant directory) where a recipient would be likely to look 375 | for such a notice. 376 | 377 | You may add additional accurate notices of copyright ownership. 378 | 379 | ## Exhibit B - "Incompatible With Secondary Licenses" Notice 380 | 381 | This Source Code Form is "Incompatible With Secondary Licenses", as 382 | defined by the Mozilla Public License, v. 2.0. 383 | --------------------------------------------------------------------------------