hypothesis 1.895.0 → 1.896.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function r(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var o={es2017:function(){return!r(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!r(Promise.prototype,"finally")}};var s=["es2017","es2018"];function i(t){t.setAttribute("data-hypothesis-asset","")}function a(t,e
|
|
1
|
+
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function r(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var o={es2017:function(){return!r(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!r(Promise.prototype,"finally")}};var s=["es2017","es2018"];function i(t){t.setAttribute("data-hypothesis-asset","")}function a(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,i(n),t.head.appendChild(n)}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.createElement("script");r.type="module",n&&(e+="#ts=".concat(Date.now())),r.src=e,r.async=!1,i(r),t.head.appendChild(r)}function u(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),i(o),t.head.appendChild(o)}function l(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.crossOrigin="anonymous",r.href=n,i(r),t.head.appendChild(r)}function p(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.forceModuleReload;n.forEach((function(n){var r=e.assetRoot+"build/"+e.manifest[n];r.match(/\.css/)?a(t,r):c(t,r,o)}))}function f(t){return function(t){return t.filter((function(t){var e=o[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function h(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function d(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?h(e.src):null}function y(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var n=d(e);if(!n)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",n.hostname)).replace("{current_scheme}",n.protocol)}if(function(){var t=[function(){return Promise.resolve()},function(){return new Map},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.prepend.name},function(){document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null)}];try{return t.forEach((function(t){return t()})),!0}catch(t){return!1}}()){var m=function(e){for(var n={},r=e.querySelectorAll("script.js-hypothesis-config"),o=0;o<r.length;o++){var s=void 0;try{s=JSON.parse(r[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),s={}}t(n,s)}return n}(document),v=y(m.assetRoot||"https://cdn.hypothes.is/hypothesis/1.896.0/"),b={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?ac1062","scripts/boot.bundle.js":"scripts/boot.bundle.js?c15f23","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?c4d30a","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?faa2ed","styles/annotator.css":"styles/annotator.css?0b34b9","styles/katex.min.css":"styles/katex.min.css?35ad33","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?dd8179","styles/sidebar.css":"styles/sidebar.css?6cbfab","styles/ui-playground.css":"styles/ui-playground.css?dffe1a","fonts/KaTeX_AMS-Regular.woff":"fonts/KaTeX_AMS-Regular.woff?3ba481","fonts/KaTeX_Caligraphic-Bold.woff":"fonts/KaTeX_Caligraphic-Bold.woff?a02380","fonts/KaTeX_Caligraphic-Regular.woff":"fonts/KaTeX_Caligraphic-Regular.woff?fc5e4c","fonts/KaTeX_Fraktur-Bold.woff":"fonts/KaTeX_Fraktur-Bold.woff?27e611","fonts/KaTeX_Fraktur-Regular.woff":"fonts/KaTeX_Fraktur-Regular.woff?a3eb3f","fonts/KaTeX_Main-Bold.woff":"fonts/KaTeX_Main-Bold.woff?2a1a96","fonts/KaTeX_Main-BoldItalic.woff":"fonts/KaTeX_Main-BoldItalic.woff?7b4be1","fonts/KaTeX_Main-Italic.woff":"fonts/KaTeX_Main-Italic.woff?effa4e","fonts/KaTeX_Main-Regular.woff":"fonts/KaTeX_Main-Regular.woff?e0ec75","fonts/KaTeX_Math-BoldItalic.woff":"fonts/KaTeX_Math-BoldItalic.woff?6e408d","fonts/KaTeX_Math-Italic.woff":"fonts/KaTeX_Math-Italic.woff?5bbbc8","fonts/KaTeX_SansSerif-Bold.woff":"fonts/KaTeX_SansSerif-Bold.woff?05089a","fonts/KaTeX_SansSerif-Italic.woff":"fonts/KaTeX_SansSerif-Italic.woff?6793c4","fonts/KaTeX_SansSerif-Regular.woff":"fonts/KaTeX_SansSerif-Regular.woff?7742a6","fonts/KaTeX_Script-Regular.woff":"fonts/KaTeX_Script-Regular.woff?c27731","fonts/KaTeX_Size1-Regular.woff":"fonts/KaTeX_Size1-Regular.woff?f0700f","fonts/KaTeX_Size2-Regular.woff":"fonts/KaTeX_Size2-Regular.woff?4fdf5d","fonts/KaTeX_Size3-Regular.woff":"fonts/KaTeX_Size3-Regular.woff?92cf7c","fonts/KaTeX_Size4-Regular.woff":"fonts/KaTeX_Size4-Regular.woff?47e816","fonts/KaTeX_Typewriter-Regular.woff":"fonts/KaTeX_Typewriter-Regular.woff?97f6f3"};if(document.querySelector("hypothesis-app"))!function(t,n){l(t,"fetch",n.apiUrl),l(t,"fetch",n.apiUrl+"links");var r=f(s);p(t,n,[].concat(e(r),["scripts/sidebar.bundle.js","styles/katex.min.css","styles/sidebar.css"]))}(document,{assetRoot:v,manifest:b,apiUrl:m.apiUrl});else{var _=y(m.notebookAppUrl||"https://hypothes.is/notebook"),A=y(m.sidebarAppUrl||"https://hypothes.is/app.html");!function(t,n){if(!t.querySelector('link[type="application/annotator+html"]')){u(t,"sidebar","html",n.sidebarAppUrl),u(t,"notebook","html",n.notebookAppUrl),u(t,"hypothesis-client","javascript",n.assetRoot+"build/boot.js");var r=f(s);p(t,n,[].concat(e(r),["scripts/annotator.bundle.js","styles/annotator.css","styles/pdfjs-overrides.css"]),{forceModuleReload:!0})}}(document,{assetRoot:v,manifest:b,notebookAppUrl:_,sidebarAppUrl:A})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
|
2
2
|
|
package/build/manifest.json
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?ac1062",
|
|
3
|
+
"scripts/boot.bundle.js": "scripts/boot.bundle.js?c15f23",
|
|
4
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?c4d30a",
|
|
5
|
+
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?faa2ed",
|
|
6
|
+
"styles/annotator.css": "styles/annotator.css?0b34b9",
|
|
7
|
+
"styles/katex.min.css": "styles/katex.min.css?35ad33",
|
|
8
|
+
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?dd8179",
|
|
9
|
+
"styles/sidebar.css": "styles/sidebar.css?6cbfab",
|
|
10
|
+
"styles/ui-playground.css": "styles/ui-playground.css?dffe1a",
|
|
2
11
|
"fonts/KaTeX_AMS-Regular.woff": "fonts/KaTeX_AMS-Regular.woff?3ba481",
|
|
3
12
|
"fonts/KaTeX_Caligraphic-Bold.woff": "fonts/KaTeX_Caligraphic-Bold.woff?a02380",
|
|
4
13
|
"fonts/KaTeX_Caligraphic-Regular.woff": "fonts/KaTeX_Caligraphic-Regular.woff?fc5e4c",
|
|
@@ -18,14 +27,5 @@
|
|
|
18
27
|
"fonts/KaTeX_Size2-Regular.woff": "fonts/KaTeX_Size2-Regular.woff?4fdf5d",
|
|
19
28
|
"fonts/KaTeX_Size3-Regular.woff": "fonts/KaTeX_Size3-Regular.woff?92cf7c",
|
|
20
29
|
"fonts/KaTeX_Size4-Regular.woff": "fonts/KaTeX_Size4-Regular.woff?47e816",
|
|
21
|
-
"fonts/KaTeX_Typewriter-Regular.woff": "fonts/KaTeX_Typewriter-Regular.woff?97f6f3"
|
|
22
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?ac1062",
|
|
23
|
-
"scripts/boot.bundle.js": "scripts/boot.bundle.js?e75f35",
|
|
24
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?5998c5",
|
|
25
|
-
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?faa2ed",
|
|
26
|
-
"styles/annotator.css": "styles/annotator.css?0b34b9",
|
|
27
|
-
"styles/katex.min.css": "styles/katex.min.css?35ad33",
|
|
28
|
-
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?dd8179",
|
|
29
|
-
"styles/sidebar.css": "styles/sidebar.css?6cbfab",
|
|
30
|
-
"styles/ui-playground.css": "styles/ui-playground.css?dffe1a"
|
|
30
|
+
"fonts/KaTeX_Typewriter-Regular.woff": "fonts/KaTeX_Typewriter-Regular.woff?97f6f3"
|
|
31
31
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function r(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var o={es2017:function(){return!r(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!r(Promise.prototype,"finally")}};var s=["es2017","es2018"];function i(t){t.setAttribute("data-hypothesis-asset","")}function a(t,e
|
|
1
|
+
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function r(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var o={es2017:function(){return!r(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!r(Promise.prototype,"finally")}};var s=["es2017","es2018"];function i(t){t.setAttribute("data-hypothesis-asset","")}function a(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,i(n),t.head.appendChild(n)}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.createElement("script");r.type="module",n&&(e+="#ts=".concat(Date.now())),r.src=e,r.async=!1,i(r),t.head.appendChild(r)}function u(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),i(o),t.head.appendChild(o)}function l(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.crossOrigin="anonymous",r.href=n,i(r),t.head.appendChild(r)}function p(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.forceModuleReload;n.forEach((function(n){var r=e.assetRoot+"build/"+e.manifest[n];r.match(/\.css/)?a(t,r):c(t,r,o)}))}function f(t){return function(t){return t.filter((function(t){var e=o[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function h(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function d(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?h(e.src):null}function y(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var n=d(e);if(!n)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",n.hostname)).replace("{current_scheme}",n.protocol)}if(function(){var t=[function(){return Promise.resolve()},function(){return new Map},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.prepend.name},function(){document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null)}];try{return t.forEach((function(t){return t()})),!0}catch(t){return!1}}()){var m=function(e){for(var n={},r=e.querySelectorAll("script.js-hypothesis-config"),o=0;o<r.length;o++){var s=void 0;try{s=JSON.parse(r[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),s={}}t(n,s)}return n}(document),v=y(m.assetRoot||"__ASSET_ROOT__"),b=__MANIFEST__;if(document.querySelector("hypothesis-app"))!function(t,n){l(t,"fetch",n.apiUrl),l(t,"fetch",n.apiUrl+"links");var r=f(s);p(t,n,[].concat(e(r),["scripts/sidebar.bundle.js","styles/katex.min.css","styles/sidebar.css"]))}(document,{assetRoot:v,manifest:b,apiUrl:m.apiUrl});else{var _=y(m.notebookAppUrl||"__NOTEBOOK_APP_URL__"),A=y(m.sidebarAppUrl||"__SIDEBAR_APP_URL__");!function(t,n){if(!t.querySelector('link[type="application/annotator+html"]')){u(t,"sidebar","html",n.sidebarAppUrl),u(t,"notebook","html",n.notebookAppUrl),u(t,"hypothesis-client","javascript",n.assetRoot+"build/boot.js");var r=f(s);p(t,n,[].concat(e(r),["scripts/annotator.bundle.js","styles/annotator.css","styles/pdfjs-overrides.css"]),{forceModuleReload:!0})}}(document,{assetRoot:v,manifest:b,notebookAppUrl:_,sidebarAppUrl:A})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
|
2
2
|
//# sourceMappingURL=boot.bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.bundle.js","sources":["../../src/boot/parse-json-config.js","../../src/boot/polyfills/index.js","../../src/boot/boot.js","../../src/boot/url-template.js","../../src/boot/index.js","../../src/boot/browser-check.js"],"sourcesContent":["// `Object.assign()`-like helper. Used because this script needs to work\n// in IE 10/11 without polyfills.\nfunction assign(dest, src) {\n for (const k in src) {\n if (src.hasOwnProperty(k)) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Return a parsed `js-hypothesis-config` object from the document, or `{}`.\n *\n * Find all `<script class=\"js-hypothesis-config\">` tags in the given document,\n * parse them as JSON, and return the parsed object.\n *\n * If there are no `js-hypothesis-config` tags in the document then return\n * `{}`.\n *\n * If there are multiple `js-hypothesis-config` tags in the document then merge\n * them into a single returned object (when multiple scripts contain the same\n * setting names, scripts further down in the document override those further\n * up).\n *\n * @param {Document|Element} document - The root element to search.\n */\nexport function parseJsonConfig(document) {\n const config = {};\n const settingsElements = document.querySelectorAll(\n 'script.js-hypothesis-config'\n );\n\n for (let i = 0; i < settingsElements.length; i++) {\n let settings;\n try {\n settings = JSON.parse(settingsElements[i].textContent || '');\n } catch (err) {\n console.warn(\n 'Could not parse settings from js-hypothesis-config tags',\n err\n );\n settings = {};\n }\n assign(config, settings);\n }\n\n return config;\n}\n","/**\n * Checkers to test which polyfills are required by the current browser.\n *\n * This module executes in an environment without any polyfills loaded so it\n * needs to run in old browsers, down to IE 11.\n *\n * See gulpfile.js for details of how to add a new polyfill.\n */\n\n/**\n * Return true if `obj` has all of the methods in `methods`.\n */\nfunction hasMethods(obj, ...methods) {\n return methods.every(method => typeof obj[method] === 'function');\n}\n\n/**\n * Map of polyfill set name to function to test whether the current browser\n * needs that polyfill set.\n *\n * Each checker function returns `true` if the polyfill is required or `false`\n * if the browser has the functionality natively available.\n */\nconst needsPolyfill = {\n es2017: () => {\n return !hasMethods(Object, 'entries', 'values');\n },\n\n es2018: () => {\n return (\n typeof Promise !== 'function' || !hasMethods(Promise.prototype, 'finally')\n );\n },\n};\n\n/**\n * Return the subset of polyfill sets from `needed` which are needed by the\n * current browser.\n */\nexport function requiredPolyfillSets(needed) {\n return needed.filter(set => {\n const checker = needsPolyfill[set];\n if (!checker) {\n throw new Error(`Unknown polyfill set \"${set}\"`);\n }\n return checker();\n });\n}\n","import { requiredPolyfillSets } from './polyfills';\n\n/**\n * Polyfills used by both the annotator and sidebar app.\n */\nconst commonPolyfills = [\n // ES APIs\n 'es2017',\n 'es2018',\n\n // Any other polyfills which may rely on certain ES APIs should be listed here.\n];\n\n/**\n * @typedef SidebarAppConfig\n * @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative\n * @prop {Record<string,string>} manifest -\n * A mapping from canonical asset path to cache-busted asset path\n * @prop {string} apiUrl\n */\n\n/**\n * @typedef AnnotatorConfig\n * @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative\n * @prop {string} notebookAppUrl - The URL of the sidebar's notebook\n * @prop {string} sidebarAppUrl - The URL of the sidebar's HTML page\n * @prop {Record<string,string>} manifest -\n * A mapping from canonical asset path to cache-busted asset path\n */\n\n/**\n * Mark an element as having been added by the boot script.\n *\n * This marker is later used to know which elements to remove when unloading\n * the client.\n *\n * @param {HTMLElement} el\n */\nfunction tagElement(el) {\n el.setAttribute('data-hypothesis-asset', '');\n}\n\n/**\n * @param {Document} doc\n * @param {string} href\n */\nfunction injectStylesheet(doc, href) {\n const link = doc.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = href;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * @param {Document} doc\n * @param {string} src - The script URL\n */\nfunction injectScript(doc, src) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.src = src;\n\n // Set 'async' to false to maintain execution order of scripts.\n // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script\n script.async = false;\n\n tagElement(script);\n doc.head.appendChild(script);\n}\n\n/**\n * @param {Document} doc\n * @param {string} rel\n * @param {'html'|'javascript'} type\n * @param {string} url\n */\nfunction injectLink(doc, rel, type, url) {\n const link = doc.createElement('link');\n link.rel = rel;\n link.href = url;\n link.type = `application/annotator+${type}`;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * Preload a URL using a `<link rel=\"preload\" as=\"<type>\" ...>` element\n *\n * This can be used to preload an API request or other resource which we know\n * that the client will load.\n *\n * @param {Document} doc\n * @param {string} type - Type of resource\n * @param {string} url\n */\nfunction preloadUrl(doc, type, url) {\n const link = doc.createElement('link');\n link.rel = 'preload';\n link.as = type;\n link.crossOrigin = 'anonymous';\n link.href = url;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * @param {Document} doc\n * @param {SidebarAppConfig|AnnotatorConfig} config\n * @param {string[]} assets\n */\nfunction injectAssets(doc, config, assets) {\n assets.forEach(path => {\n const url = config.assetRoot + 'build/' + config.manifest[path];\n if (url.match(/\\.css/)) {\n injectStylesheet(doc, url);\n } else {\n injectScript(doc, url);\n }\n });\n}\n\nfunction polyfillBundles(needed) {\n return requiredPolyfillSets(needed).map(\n set => `scripts/polyfills-${set}.bundle.js`\n );\n}\n\n/**\n * Bootstrap the Hypothesis client.\n *\n * This triggers loading of the necessary resources for the client\n *\n * @param {Document} doc\n * @param {AnnotatorConfig} config\n */\nexport function bootHypothesisClient(doc, config) {\n // Detect presence of Hypothesis in the page\n const appLinkEl = doc.querySelector(\n 'link[type=\"application/annotator+html\"]'\n );\n if (appLinkEl) {\n return;\n }\n\n // Register the URL of the sidebar app which the Hypothesis client should load.\n // The <link> tag is also used by browser extensions etc. to detect the\n // presence of the Hypothesis client on the page.\n injectLink(doc, 'sidebar', 'html', config.sidebarAppUrl);\n\n // Register the URL of the notebook app which the Hypothesis client should load.\n injectLink(doc, 'notebook', 'html', config.notebookAppUrl);\n\n // Register the URL of the annotation client which is currently being used to drive\n // annotation interactions.\n injectLink(\n doc,\n 'hypothesis-client',\n 'javascript',\n config.assetRoot + 'build/boot.js'\n );\n\n const polyfills = polyfillBundles(commonPolyfills);\n\n injectAssets(doc, config, [\n // Vendor code and polyfills\n ...polyfills,\n\n 'scripts/annotator.bundle.js',\n\n 'styles/annotator.css',\n 'styles/pdfjs-overrides.css',\n ]);\n}\n\n/**\n * Bootstrap the sidebar application which displays annotations.\n *\n * @param {Document} doc\n * @param {SidebarAppConfig} config\n */\nexport function bootSidebarApp(doc, config) {\n // Preload `/api/` and `/api/links` API responses.\n preloadUrl(doc, 'fetch', config.apiUrl);\n preloadUrl(doc, 'fetch', config.apiUrl + 'links');\n\n const polyfills = polyfillBundles(commonPolyfills);\n\n injectAssets(doc, config, [\n ...polyfills,\n\n 'scripts/sidebar.bundle.js',\n\n 'styles/katex.min.css',\n 'styles/sidebar.css',\n ]);\n}\n","/**\n * Extract the protocol and hostname (ie. host without port) from the URL.\n *\n * We don't use the URL constructor here because IE and early versions of Edge\n * do not support it and this code runs early in the life of the app before any\n * polyfills can be loaded.\n */\nfunction extractOrigin(url) {\n const match = url.match(/(https?):\\/\\/([^:/]+)/);\n if (!match) {\n return null;\n }\n return { protocol: match[1], hostname: match[2] };\n}\n\nfunction currentScriptOrigin(document_ = document) {\n const scriptEl = /** @type {HTMLScriptElement|null} */ (\n document_.currentScript\n );\n if (!scriptEl) {\n // Function was called outside of initial script execution.\n return null;\n }\n return extractOrigin(scriptEl.src);\n}\n\n/**\n * Replace references to `current_host` and `current_scheme` URL template\n * parameters with the corresponding elements of the current script URL.\n *\n * During local development, there are cases when the client/h needs to be accessed\n * from a device or VM that is not the system where the development server is\n * running. In that case, all references to `localhost` need to be replaced\n * with the IP/hostname of the dev server.\n *\n * @param {string} url\n * @param {Document} document_\n */\nexport default function processUrlTemplate(url, document_ = document) {\n if (url.indexOf('{') === -1) {\n // Not a template. This should always be the case in production.\n return url;\n }\n\n const origin = currentScriptOrigin(document_);\n\n if (origin) {\n url = url.replace('{current_host}', origin.hostname);\n url = url.replace('{current_scheme}', origin.protocol);\n } else {\n throw new Error(\n 'Could not process URL template because script origin is unknown'\n );\n }\n\n return url;\n}\n","// This is the main entry point for the Hypothesis client in the host page\n// and the sidebar application.\n//\n// The same boot script is used for both entry points so that the browser\n// already has it cached when it encounters the reference in the sidebar\n// application.\n\n// Variables replaced by the build script\n\n/* global __MANIFEST__ */\n\nimport { parseJsonConfig } from './parse-json-config';\n\nimport { bootHypothesisClient, bootSidebarApp } from './boot';\nimport processUrlTemplate from './url-template';\nimport { isBrowserSupported } from './browser-check';\n\nif (isBrowserSupported()) {\n const settings = parseJsonConfig(document);\n const assetRoot = processUrlTemplate(settings.assetRoot || '__ASSET_ROOT__');\n // @ts-ignore - `__MANIFEST__` is injected by the build script\n const manifest = __MANIFEST__;\n\n // Check whether this is the sidebar app (indicated by the presence of a\n // `<hypothesis-app>` element) and load the appropriate part of the client.\n if (document.querySelector('hypothesis-app')) {\n bootSidebarApp(document, { assetRoot, manifest, apiUrl: settings.apiUrl });\n } else {\n const notebookAppUrl = processUrlTemplate(\n settings.notebookAppUrl || '__NOTEBOOK_APP_URL__'\n );\n const sidebarAppUrl = processUrlTemplate(\n settings.sidebarAppUrl || '__SIDEBAR_APP_URL__'\n );\n bootHypothesisClient(document, {\n assetRoot,\n manifest,\n notebookAppUrl,\n sidebarAppUrl,\n });\n }\n} else {\n // Show a \"quiet\" warning to avoid being disruptive on non-Hypothesis sites\n // that embed the client.\n //\n // In Via or when using the bookmarklet we could show something louder.\n console.warn(\n 'The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.'\n );\n}\n","/**\n * Run a series of representative feature tests to see if the browser is new\n * enough to support Hypothesis.\n *\n * We use feature tests to try to avoid false negatives, accepting some risk of\n * false positives due to the host page having loaded polyfills for APIs in order\n * to support older browsers.\n *\n * @return {boolean}\n */\nexport function isBrowserSupported() {\n const checks = [\n // ES APIs.\n () => Promise.resolve(),\n () => new Map(),\n\n // DOM API checks for frequently-used APIs.\n () => new URL(document.location.href), // URL constructor.\n () => new Request('https://hypothes.is'), // Part of the `fetch` API.\n () => Element.prototype.prepend.name,\n\n // DOM API checks for less frequently-used APIs.\n // These are less likely to have been polyfilled by the host page.\n () => {\n document.evaluate(\n '/html/body',\n document,\n\n // These arguments are optional in the spec but required in Edge Legacy.\n null /* namespaceResolver */,\n XPathResult.ANY_TYPE,\n null /* result */\n );\n },\n ];\n\n try {\n checks.forEach(check => check());\n return true;\n } catch (err) {\n return false;\n }\n}\n"],"names":["assign","dest","src","k","hasOwnProperty","hasMethods","obj","methods","every","method","needsPolyfill","es2017","Object","es2018","Promise","prototype","commonPolyfills","tagElement","el","setAttribute","injectLink","doc","rel","type","url","link","createElement","href","head","appendChild","preloadUrl","as","crossOrigin","injectAssets","config","assets","forEach","path","assetRoot","manifest","match","injectStylesheet","script","async","injectScript","polyfillBundles","needed","filter","set","checker","Error","requiredPolyfillSets","map","extractOrigin","protocol","hostname","currentScriptOrigin","document_","document","scriptEl","currentScript","processUrlTemplate","indexOf","origin","replace","checks","resolve","Map","URL","location","Request","Element","prepend","name","evaluate","XPathResult","ANY_TYPE","check","err","isBrowserSupported","settings","settingsElements","querySelectorAll","i","length","JSON","parse","textContent","console","warn","parseJsonConfig","__MANIFEST__","querySelector","apiUrl","polyfills","bootSidebarApp","notebookAppUr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8C,UAGV9C,EI7BUwD,CAAgBhC,UAC3BpB,EAAYuB,EAAmBmB,EAAS1C,WAAa,kBAErDC,EAAWoD,gBAIbjC,SAASkC,cAAc,mBFgKtB,SAAwBvE,EAAKa,GAElCJ,EAAWT,EAAK,QAASa,EAAO2D,QAChC/D,EAAWT,EAAK,QAASa,EAAO2D,OAAS,aAEnCC,EAAYjD,EAAgB7B,GAElCiB,EAAaZ,EAAKa,cACb4D,IAEH,4BAEA,uBACA,wBE5KAC,CAAerC,SAAU,CAAEpB,UAAAA,EAAWC,SAAAA,EAAUsD,OAAQb,EAASa,aAC5D,KACCG,EAAiBnC,EACrBmB,EAASgB,gBAAkB,wBAEvBC,EAAgBpC,EACpBmB,EAASiB,eAAiB,wBF4GzB,SAA8B5E,EAAKa,OAEtBb,EAAIuE,cACpB,4CASFxE,EAAWC,EAAK,UAAW,OAAQa,EAAO+D,eAG1C7E,EAAWC,EAAK,WAAY,OAAQa,EAAO8D,gBAI3C5E,EACEC,EACA,oBACA,aACAa,EAAOI,UAAY,qBAGfwD,EAAYjD,EAAgB7B,GAElCiB,EAAaZ,EAAKa,cAEb4D,IAEH,8BAEA,uBACA,iCE7IAI,CAAqBxC,SAAU,CAC7BpB,UAAAA,EACAC,SAAAA,EACAyD,eAAAA,EACAC,cAAAA,UAQJT,QAAQC,KACN"}
|
|
1
|
+
{"version":3,"file":"boot.bundle.js","sources":["../../src/boot/parse-json-config.js","../../src/boot/polyfills/index.js","../../src/boot/boot.js","../../src/boot/url-template.js","../../src/boot/index.js","../../src/boot/browser-check.js"],"sourcesContent":["// `Object.assign()`-like helper. Used because this script needs to work\n// in IE 10/11 without polyfills.\nfunction assign(dest, src) {\n for (const k in src) {\n if (src.hasOwnProperty(k)) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Return a parsed `js-hypothesis-config` object from the document, or `{}`.\n *\n * Find all `<script class=\"js-hypothesis-config\">` tags in the given document,\n * parse them as JSON, and return the parsed object.\n *\n * If there are no `js-hypothesis-config` tags in the document then return\n * `{}`.\n *\n * If there are multiple `js-hypothesis-config` tags in the document then merge\n * them into a single returned object (when multiple scripts contain the same\n * setting names, scripts further down in the document override those further\n * up).\n *\n * @param {Document|Element} document - The root element to search.\n */\nexport function parseJsonConfig(document) {\n const config = {};\n const settingsElements = document.querySelectorAll(\n 'script.js-hypothesis-config'\n );\n\n for (let i = 0; i < settingsElements.length; i++) {\n let settings;\n try {\n settings = JSON.parse(settingsElements[i].textContent || '');\n } catch (err) {\n console.warn(\n 'Could not parse settings from js-hypothesis-config tags',\n err\n );\n settings = {};\n }\n assign(config, settings);\n }\n\n return config;\n}\n","/**\n * Checkers to test which polyfills are required by the current browser.\n *\n * This module executes in an environment without any polyfills loaded so it\n * needs to run in old browsers, down to IE 11.\n *\n * See gulpfile.js for details of how to add a new polyfill.\n */\n\n/**\n * Return true if `obj` has all of the methods in `methods`.\n */\nfunction hasMethods(obj, ...methods) {\n return methods.every(method => typeof obj[method] === 'function');\n}\n\n/**\n * Map of polyfill set name to function to test whether the current browser\n * needs that polyfill set.\n *\n * Each checker function returns `true` if the polyfill is required or `false`\n * if the browser has the functionality natively available.\n */\nconst needsPolyfill = {\n es2017: () => {\n return !hasMethods(Object, 'entries', 'values');\n },\n\n es2018: () => {\n return (\n typeof Promise !== 'function' || !hasMethods(Promise.prototype, 'finally')\n );\n },\n};\n\n/**\n * Return the subset of polyfill sets from `needed` which are needed by the\n * current browser.\n */\nexport function requiredPolyfillSets(needed) {\n return needed.filter(set => {\n const checker = needsPolyfill[set];\n if (!checker) {\n throw new Error(`Unknown polyfill set \"${set}\"`);\n }\n return checker();\n });\n}\n","import { requiredPolyfillSets } from './polyfills';\n\n/**\n * Polyfills used by both the annotator and sidebar app.\n */\nconst commonPolyfills = [\n // ES APIs\n 'es2017',\n 'es2018',\n\n // Any other polyfills which may rely on certain ES APIs should be listed here.\n];\n\n/**\n * @typedef SidebarAppConfig\n * @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative\n * @prop {Record<string,string>} manifest -\n * A mapping from canonical asset path to cache-busted asset path\n * @prop {string} apiUrl\n */\n\n/**\n * @typedef AnnotatorConfig\n * @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative\n * @prop {string} notebookAppUrl - The URL of the sidebar's notebook\n * @prop {string} sidebarAppUrl - The URL of the sidebar's HTML page\n * @prop {Record<string,string>} manifest -\n * A mapping from canonical asset path to cache-busted asset path\n */\n\n/**\n * Mark an element as having been added by the boot script.\n *\n * This marker is later used to know which elements to remove when unloading\n * the client.\n *\n * @param {HTMLElement} el\n */\nfunction tagElement(el) {\n el.setAttribute('data-hypothesis-asset', '');\n}\n\n/**\n * @param {Document} doc\n * @param {string} href\n */\nfunction injectStylesheet(doc, href) {\n const link = doc.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = href;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * @param {Document} doc\n * @param {string} src - The script URL\n * @param {boolean} forceReload - Whether to force re-evaluation of the script,\n * in case it has been loaded in the same document previously.\n */\nfunction injectScript(doc, src, forceReload = false) {\n const script = doc.createElement('script');\n script.type = 'module';\n\n if (forceReload) {\n // Module scripts are only evaluated once per URL in a document. Adding\n // a dynamic fragment forces re-evaluation without breaking browser or CDN\n // caching of the script, as a query string would do.\n //\n // See examples in https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system\n src += `#ts=${Date.now()}`;\n }\n\n script.src = src;\n\n // Set 'async' to false to maintain execution order of scripts.\n // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script\n script.async = false;\n\n tagElement(script);\n doc.head.appendChild(script);\n}\n\n/**\n * @param {Document} doc\n * @param {string} rel\n * @param {'html'|'javascript'} type\n * @param {string} url\n */\nfunction injectLink(doc, rel, type, url) {\n const link = doc.createElement('link');\n link.rel = rel;\n link.href = url;\n link.type = `application/annotator+${type}`;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * Preload a URL using a `<link rel=\"preload\" as=\"<type>\" ...>` element\n *\n * This can be used to preload an API request or other resource which we know\n * that the client will load.\n *\n * @param {Document} doc\n * @param {string} type - Type of resource\n * @param {string} url\n */\nfunction preloadUrl(doc, type, url) {\n const link = doc.createElement('link');\n link.rel = 'preload';\n link.as = type;\n link.crossOrigin = 'anonymous';\n link.href = url;\n\n tagElement(link);\n doc.head.appendChild(link);\n}\n\n/**\n * @param {Document} doc\n * @param {SidebarAppConfig|AnnotatorConfig} config\n * @param {string[]} assets\n * @param {object} options\n * @param {boolean} [options.forceModuleReload]\n */\nfunction injectAssets(doc, config, assets, { forceModuleReload } = {}) {\n assets.forEach(path => {\n const url = config.assetRoot + 'build/' + config.manifest[path];\n if (url.match(/\\.css/)) {\n injectStylesheet(doc, url);\n } else {\n injectScript(doc, url, forceModuleReload);\n }\n });\n}\n\nfunction polyfillBundles(needed) {\n return requiredPolyfillSets(needed).map(\n set => `scripts/polyfills-${set}.bundle.js`\n );\n}\n\n/**\n * Bootstrap the Hypothesis client.\n *\n * This triggers loading of the necessary resources for the client\n *\n * @param {Document} doc\n * @param {AnnotatorConfig} config\n */\nexport function bootHypothesisClient(doc, config) {\n // Detect presence of Hypothesis in the page\n const appLinkEl = doc.querySelector(\n 'link[type=\"application/annotator+html\"]'\n );\n if (appLinkEl) {\n return;\n }\n\n // Register the URL of the sidebar app which the Hypothesis client should load.\n // The <link> tag is also used by browser extensions etc. to detect the\n // presence of the Hypothesis client on the page.\n injectLink(doc, 'sidebar', 'html', config.sidebarAppUrl);\n\n // Register the URL of the notebook app which the Hypothesis client should load.\n injectLink(doc, 'notebook', 'html', config.notebookAppUrl);\n\n // Register the URL of the annotation client which is currently being used to drive\n // annotation interactions.\n injectLink(\n doc,\n 'hypothesis-client',\n 'javascript',\n config.assetRoot + 'build/boot.js'\n );\n\n const polyfills = polyfillBundles(commonPolyfills);\n\n injectAssets(\n doc,\n config,\n [\n // Vendor code and polyfills\n ...polyfills,\n\n 'scripts/annotator.bundle.js',\n\n 'styles/annotator.css',\n 'styles/pdfjs-overrides.css',\n ],\n\n // Force re-evaluation of JS module scripts, so that the annotator entry\n // point code gets re-run if the client is unloaded and later re-loaded.\n { forceModuleReload: true }\n );\n}\n\n/**\n * Bootstrap the sidebar application which displays annotations.\n *\n * @param {Document} doc\n * @param {SidebarAppConfig} config\n */\nexport function bootSidebarApp(doc, config) {\n // Preload `/api/` and `/api/links` API responses.\n preloadUrl(doc, 'fetch', config.apiUrl);\n preloadUrl(doc, 'fetch', config.apiUrl + 'links');\n\n const polyfills = polyfillBundles(commonPolyfills);\n\n injectAssets(doc, config, [\n ...polyfills,\n\n 'scripts/sidebar.bundle.js',\n\n 'styles/katex.min.css',\n 'styles/sidebar.css',\n ]);\n}\n","/**\n * Extract the protocol and hostname (ie. host without port) from the URL.\n *\n * We don't use the URL constructor here because IE and early versions of Edge\n * do not support it and this code runs early in the life of the app before any\n * polyfills can be loaded.\n */\nfunction extractOrigin(url) {\n const match = url.match(/(https?):\\/\\/([^:/]+)/);\n if (!match) {\n return null;\n }\n return { protocol: match[1], hostname: match[2] };\n}\n\nfunction currentScriptOrigin(document_ = document) {\n const scriptEl = /** @type {HTMLScriptElement|null} */ (\n document_.currentScript\n );\n if (!scriptEl) {\n // Function was called outside of initial script execution.\n return null;\n }\n return extractOrigin(scriptEl.src);\n}\n\n/**\n * Replace references to `current_host` and `current_scheme` URL template\n * parameters with the corresponding elements of the current script URL.\n *\n * During local development, there are cases when the client/h needs to be accessed\n * from a device or VM that is not the system where the development server is\n * running. In that case, all references to `localhost` need to be replaced\n * with the IP/hostname of the dev server.\n *\n * @param {string} url\n * @param {Document} document_\n */\nexport default function processUrlTemplate(url, document_ = document) {\n if (url.indexOf('{') === -1) {\n // Not a template. This should always be the case in production.\n return url;\n }\n\n const origin = currentScriptOrigin(document_);\n\n if (origin) {\n url = url.replace('{current_host}', origin.hostname);\n url = url.replace('{current_scheme}', origin.protocol);\n } else {\n throw new Error(\n 'Could not process URL template because script origin is unknown'\n );\n }\n\n return url;\n}\n","// This is the main entry point for the Hypothesis client in the host page\n// and the sidebar application.\n//\n// The same boot script is used for both entry points so that the browser\n// already has it cached when it encounters the reference in the sidebar\n// application.\n\n// Variables replaced by the build script\n\n/* global __MANIFEST__ */\n\nimport { parseJsonConfig } from './parse-json-config';\n\nimport { bootHypothesisClient, bootSidebarApp } from './boot';\nimport processUrlTemplate from './url-template';\nimport { isBrowserSupported } from './browser-check';\n\nif (isBrowserSupported()) {\n const settings = parseJsonConfig(document);\n const assetRoot = processUrlTemplate(settings.assetRoot || '__ASSET_ROOT__');\n // @ts-ignore - `__MANIFEST__` is injected by the build script\n const manifest = __MANIFEST__;\n\n // Check whether this is the sidebar app (indicated by the presence of a\n // `<hypothesis-app>` element) and load the appropriate part of the client.\n if (document.querySelector('hypothesis-app')) {\n bootSidebarApp(document, { assetRoot, manifest, apiUrl: settings.apiUrl });\n } else {\n const notebookAppUrl = processUrlTemplate(\n settings.notebookAppUrl || '__NOTEBOOK_APP_URL__'\n );\n const sidebarAppUrl = processUrlTemplate(\n settings.sidebarAppUrl || '__SIDEBAR_APP_URL__'\n );\n bootHypothesisClient(document, {\n assetRoot,\n manifest,\n notebookAppUrl,\n sidebarAppUrl,\n });\n }\n} else {\n // Show a \"quiet\" warning to avoid being disruptive on non-Hypothesis sites\n // that embed the client.\n //\n // In Via or when using the bookmarklet we could show something louder.\n console.warn(\n 'The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.'\n );\n}\n","/**\n * Run a series of representative feature tests to see if the browser is new\n * enough to support Hypothesis.\n *\n * We use feature tests to try to avoid false negatives, accepting some risk of\n * false positives due to the host page having loaded polyfills for APIs in order\n * to support older browsers.\n *\n * @return {boolean}\n */\nexport function isBrowserSupported() {\n const checks = [\n // ES APIs.\n () => Promise.resolve(),\n () => new Map(),\n\n // DOM API checks for frequently-used APIs.\n () => new URL(document.location.href), // URL constructor.\n () => new Request('https://hypothes.is'), // Part of the `fetch` API.\n () => Element.prototype.prepend.name,\n\n // DOM API checks for less frequently-used APIs.\n // These are less likely to have been polyfilled by the host page.\n () => {\n document.evaluate(\n '/html/body',\n document,\n\n // These arguments are optional in the spec but required in Edge Legacy.\n null /* namespaceResolver */,\n XPathResult.ANY_TYPE,\n null /* result */\n );\n },\n ];\n\n try {\n checks.forEach(check => check());\n return true;\n } catch (err) {\n return false;\n }\n}\n"],"names":["assign","dest","src","k","hasOwnProperty","hasMethods","obj","methods","every","method","needsPolyfill","es2017","Object","es2018","Promise","prototype","commonPolyfills","tagElement","el","setAttribute","injectStylesheet","doc","href","link","createElement","rel","type","head","appendChild","injectScript","forceReload","script","Date","now","async","injectLink","url","preloadUrl","as","crossOrigin","injectAssets","config","assets","forceModuleReload","forEach","path","assetRoot","manifest","match","polyfillBundles","needed","filter","set","checker","Error","requiredPolyfillSets","map","extractOrigin","protocol","hostname","currentScriptOrigin","document_","document","scriptEl","currentScript","processUrlTemplate","indexOf","origin","replace","checks","resolve","Map","URL","location","Request","Element","prepend","name","evaluate","XPathResult","ANY_TYPE","check","err","isBrowserSupported","settings","settingsElements","querySelectorAll","i","length","JSON","parse","textContent","console","warn","parseJsonConfig","__MANIFEST__","querySelector","apiUrl","polyfills","bootSidebarApp","notebookAppUrl","sidebarAppUrl","bootHypothesisClient"],"mappings":"yBAEA,SAASA,EAAOC,EAAMC,OACf,IAAMC,KAAKD,EACVA,EAAIE,eAAeD,KACrBF,EAAKE,GAAKD,EAAIC,WAGXF,+vBCIT,SAASI,EAAWC,8BAAQC,mCAAAA,2BACnBA,EAAQC,OAAM,SAAAC,SAAiC,mBAAhBH,EAAIG,MAU5C,IAAMC,EAAgB,CACpBC,OAAQ,kBACEN,EAAWO,OAAQ,UAAW,WAGxCC,OAAQ,iBAEe,mBAAZC,UAA2BT,EAAWS,QAAQC,UAAW,aCzBtE,IAAMC,EAAkB,CAEtB,SACA,UA8BF,SAASC,EAAWC,GAClBA,EAAGC,aAAa,wBAAyB,IAO3C,S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