app_options.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.OptionKind = exports.AppOptions = void 0;
  27. var _pdf = require("../pdf");
  28. var _viewer_compatibility = require("./viewer_compatibility");
  29. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  31. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  32. var OptionKind = {
  33. VIEWER: 'viewer',
  34. API: 'api',
  35. WORKER: 'worker'
  36. };
  37. exports.OptionKind = OptionKind;
  38. var defaultOptions = {
  39. cursorToolOnLoad: {
  40. value: 0,
  41. kind: OptionKind.VIEWER
  42. },
  43. defaultUrl: {
  44. value: 'compressed.tracemonkey-pldi-09.pdf',
  45. kind: OptionKind.VIEWER
  46. },
  47. defaultZoomValue: {
  48. value: '',
  49. kind: OptionKind.VIEWER
  50. },
  51. disableHistory: {
  52. value: false,
  53. kind: OptionKind.VIEWER
  54. },
  55. disablePageLabels: {
  56. value: false,
  57. kind: OptionKind.VIEWER
  58. },
  59. enablePrintAutoRotate: {
  60. value: false,
  61. kind: OptionKind.VIEWER
  62. },
  63. enableWebGL: {
  64. value: false,
  65. kind: OptionKind.VIEWER
  66. },
  67. eventBusDispatchToDOM: {
  68. value: false,
  69. kind: OptionKind.VIEWER
  70. },
  71. externalLinkRel: {
  72. value: 'noopener noreferrer nofollow',
  73. kind: OptionKind.VIEWER
  74. },
  75. externalLinkTarget: {
  76. value: 0,
  77. kind: OptionKind.VIEWER
  78. },
  79. historyUpdateUrl: {
  80. value: false,
  81. kind: OptionKind.VIEWER
  82. },
  83. imageResourcesPath: {
  84. value: './images/',
  85. kind: OptionKind.VIEWER
  86. },
  87. maxCanvasPixels: {
  88. value: 16777216,
  89. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  90. kind: OptionKind.VIEWER
  91. },
  92. pdfBugEnabled: {
  93. value: false,
  94. kind: OptionKind.VIEWER
  95. },
  96. renderer: {
  97. value: 'canvas',
  98. kind: OptionKind.VIEWER
  99. },
  100. renderInteractiveForms: {
  101. value: false,
  102. kind: OptionKind.VIEWER
  103. },
  104. sidebarViewOnLoad: {
  105. value: -1,
  106. kind: OptionKind.VIEWER
  107. },
  108. scrollModeOnLoad: {
  109. value: -1,
  110. kind: OptionKind.VIEWER
  111. },
  112. spreadModeOnLoad: {
  113. value: -1,
  114. kind: OptionKind.VIEWER
  115. },
  116. textLayerMode: {
  117. value: 1,
  118. kind: OptionKind.VIEWER
  119. },
  120. useOnlyCssZoom: {
  121. value: false,
  122. kind: OptionKind.VIEWER
  123. },
  124. viewOnLoad: {
  125. value: 0,
  126. kind: OptionKind.VIEWER
  127. },
  128. cMapPacked: {
  129. value: true,
  130. kind: OptionKind.API
  131. },
  132. cMapUrl: {
  133. value: '../web/cmaps/',
  134. kind: OptionKind.API
  135. },
  136. disableAutoFetch: {
  137. value: false,
  138. kind: OptionKind.API
  139. },
  140. disableCreateObjectURL: {
  141. value: false,
  142. compatibility: _pdf.apiCompatibilityParams.disableCreateObjectURL,
  143. kind: OptionKind.API
  144. },
  145. disableFontFace: {
  146. value: false,
  147. kind: OptionKind.API
  148. },
  149. disableRange: {
  150. value: false,
  151. kind: OptionKind.API
  152. },
  153. disableStream: {
  154. value: false,
  155. kind: OptionKind.API
  156. },
  157. isEvalSupported: {
  158. value: true,
  159. kind: OptionKind.API
  160. },
  161. maxImageSize: {
  162. value: -1,
  163. kind: OptionKind.API
  164. },
  165. pdfBug: {
  166. value: false,
  167. kind: OptionKind.API
  168. },
  169. postMessageTransfers: {
  170. value: true,
  171. kind: OptionKind.API
  172. },
  173. verbosity: {
  174. value: 1,
  175. kind: OptionKind.API
  176. },
  177. workerPort: {
  178. value: null,
  179. kind: OptionKind.WORKER
  180. },
  181. workerSrc: {
  182. value: '../build/pdf.worker.js',
  183. kind: OptionKind.WORKER
  184. }
  185. };
  186. {
  187. defaultOptions.disablePreferences = {
  188. value: false,
  189. kind: OptionKind.VIEWER
  190. };
  191. defaultOptions.locale = {
  192. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  193. kind: OptionKind.VIEWER
  194. };
  195. }
  196. var userOptions = Object.create(null);
  197. var AppOptions =
  198. /*#__PURE__*/
  199. function () {
  200. function AppOptions() {
  201. _classCallCheck(this, AppOptions);
  202. throw new Error('Cannot initialize AppOptions.');
  203. }
  204. _createClass(AppOptions, null, [{
  205. key: "get",
  206. value: function get(name) {
  207. var userOption = userOptions[name];
  208. if (userOption !== undefined) {
  209. return userOption;
  210. }
  211. var defaultOption = defaultOptions[name];
  212. if (defaultOption !== undefined) {
  213. return defaultOption.compatibility || defaultOption.value;
  214. }
  215. return undefined;
  216. }
  217. }, {
  218. key: "getAll",
  219. value: function getAll() {
  220. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  221. var options = Object.create(null);
  222. for (var name in defaultOptions) {
  223. var defaultOption = defaultOptions[name];
  224. if (kind && kind !== defaultOption.kind) {
  225. continue;
  226. }
  227. var userOption = userOptions[name];
  228. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  229. }
  230. return options;
  231. }
  232. }, {
  233. key: "set",
  234. value: function set(name, value) {
  235. userOptions[name] = value;
  236. }
  237. }, {
  238. key: "remove",
  239. value: function remove(name) {
  240. delete userOptions[name];
  241. }
  242. }]);
  243. return AppOptions;
  244. }();
  245. exports.AppOptions = AppOptions;