| 1 | /** |
| 2 | * Add all the libraries that you want to expose to the client here. |
| 3 | * They are bundled and exposed by Webpack in the /lib.js file. |
| 4 | */ |
| 5 | import lodash from 'lodash'; |
| 6 | import Fuse from 'fuse.js'; |
| 7 | import DOMPurify from 'dompurify'; |
| 8 | import hljs from 'highlight.js'; |
| 9 | import localforage from 'localforage'; |
| 10 | import Handlebars from 'handlebars'; |
| 11 | import css from '@adobe/css-tools'; |
| 12 | import Bowser from 'bowser'; |
| 13 | import DiffMatchPatch from 'diff-match-patch'; |
| 14 | import { isProbablyReaderable, Readability } from '@mozilla/readability'; |
| 15 | import SVGInject from '@iconfu/svg-inject'; |
| 16 | import showdown from 'showdown'; |
| 17 | import moment from 'moment'; |
| 18 | import seedrandom from 'seedrandom'; |
| 19 | import * as Popper from '@popperjs/core'; |
| 20 | import droll from 'droll'; |
| 21 | import morphdom from 'morphdom'; |
| 22 | import { toggle as slideToggle } from 'slidetoggle'; |
| 23 | import chalk from 'chalk'; |
| 24 | import yaml from 'yaml'; |
| 25 | import * as chevrotain from 'chevrotain'; |
| 26 | import { gzipSync, gzip } from 'fflate'; |
| 27 | import { sha256 } from 'js-sha256'; |
| 28 | |
| 29 | /** |
| 30 | * Expose the libraries to the 'window' object. |
| 31 | * Needed for compatibility with old extensions. |
| 32 | * Note: New extensions are encouraged to import the libraries directly from lib.js. |
| 33 | */ |
| 34 | export function initLibraryShims() { |
| 35 | if (!window) { |
| 36 | return; |
| 37 | } |
| 38 | if (!('Fuse' in window)) { |
| 39 | // @ts-ignore |
| 40 | window.Fuse = Fuse; |
| 41 | } |
| 42 | if (!('DOMPurify' in window)) { |
| 43 | // @ts-ignore |
| 44 | window.DOMPurify = DOMPurify; |
| 45 | } |
| 46 | if (!('hljs' in window)) { |
| 47 | // @ts-ignore |
| 48 | window.hljs = hljs; |
| 49 | } |
| 50 | if (!('localforage' in window)) { |
| 51 | // @ts-ignore |
| 52 | window.localforage = localforage; |
| 53 | } |
| 54 | if (!('Handlebars' in window)) { |
| 55 | // @ts-ignore |
| 56 | window.Handlebars = Handlebars; |
| 57 | } |
| 58 | if (!('diff_match_patch' in window)) { |
| 59 | // @ts-ignore |
| 60 | window.diff_match_patch = DiffMatchPatch; |
| 61 | } |
| 62 | if (!('SVGInject' in window)) { |
| 63 | // @ts-ignore |
| 64 | window.SVGInject = SVGInject; |
| 65 | } |
| 66 | if (!('showdown' in window)) { |
| 67 | // @ts-ignore |
| 68 | window.showdown = showdown; |
| 69 | } |
| 70 | if (!('moment' in window)) { |
| 71 | // @ts-ignore |
| 72 | window.moment = moment; |
| 73 | } |
| 74 | if (!('Popper' in window)) { |
| 75 | // @ts-ignore |
| 76 | window.Popper = Popper; |
| 77 | } |
| 78 | if (!('droll' in window)) { |
| 79 | // @ts-ignore |
| 80 | window.droll = droll; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | export default { |
| 85 | lodash, |
| 86 | Fuse, |
| 87 | DOMPurify, |
| 88 | hljs, |
| 89 | localforage, |
| 90 | Handlebars, |
| 91 | css, |
| 92 | Bowser, |
| 93 | DiffMatchPatch, |
| 94 | Readability, |
| 95 | isProbablyReaderable, |
| 96 | SVGInject, |
| 97 | showdown, |
| 98 | moment, |
| 99 | seedrandom, |
| 100 | Popper, |
| 101 | droll, |
| 102 | morphdom, |
| 103 | slideToggle, |
| 104 | chalk, |
| 105 | yaml, |
| 106 | chevrotain, |
| 107 | gzipSync, |
| 108 | gzip, |
| 109 | sha256, |
| 110 | }; |
| 111 | |
| 112 | export { |
| 113 | lodash, |
| 114 | Fuse, |
| 115 | DOMPurify, |
| 116 | hljs, |
| 117 | localforage, |
| 118 | Handlebars, |
| 119 | css, |
| 120 | Bowser, |
| 121 | DiffMatchPatch, |
| 122 | Readability, |
| 123 | isProbablyReaderable, |
| 124 | SVGInject, |
| 125 | showdown, |
| 126 | moment, |
| 127 | seedrandom, |
| 128 | Popper, |
| 129 | droll, |
| 130 | morphdom, |
| 131 | slideToggle, |
| 132 | chalk, |
| 133 | yaml, |
| 134 | chevrotain, |
| 135 | gzipSync, |
| 136 | gzip, |
| 137 | sha256, |
| 138 | }; |