hypothesis 1.1532.0 → 1.1534.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 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?916854","styles/annotator.css":"styles/annotator.css?15d6dc","styles/annotator.css.map":"styles/annotator.css.map?e40ad0","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?58e394","styles/katex.min.css.map":"styles/katex.min.css.map?1785d7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?25caae","styles/sidebar.css":"styles/sidebar.css?7147f4","styles/ui-playground.css":"styles/ui-playground.css?307238","styles/ui-playground.css.map":"styles/ui-playground.css.map?690766","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?79ccbd","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?f784e0","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?061f73","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?add63e","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?3501aa"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1534.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,u=p;c<u.length;c++)e(s,i(t,u[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}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/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?916854",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?15d6dc",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?e40ad0",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"styles/katex.min.css.map": "styles/katex.min.css.map?1785d7",
|
|
9
9
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
10
10
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
11
|
-
"styles/sidebar.css": "styles/sidebar.css?7147f4",
|
|
12
11
|
"styles/sidebar.css.map": "styles/sidebar.css.map?25caae",
|
|
13
|
-
"styles/
|
|
12
|
+
"styles/sidebar.css": "styles/sidebar.css?7147f4",
|
|
14
13
|
"styles/ui-playground.css": "styles/ui-playground.css?307238",
|
|
15
|
-
"
|
|
14
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?690766",
|
|
15
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?79ccbd",
|
|
16
16
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?f784e0",
|
|
17
|
-
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?
|
|
18
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?061f73",
|
|
18
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?add63e",
|
|
19
19
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?3501aa"
|
|
20
20
|
}
|
|
@@ -6,9 +6,9 @@ constructor(e){super(e)}}class l{constructor({hostFrame:e,source:t,sourceId:n}){
|
|
|
6
6
|
once:function(e,t,n){var i=this;function o(){i.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),i=n[e],o=[];if(i&&t)for(var r=0,s=i.length;r<s;r++)i[r].fn!==t&&i[r].fn._!==t&&o.push(i[r]);return o.length?n[e]=o:delete n[e],this}},u.exports=e,u.exports.TinyEmitter=e,u.exports}();let d=null;function f(e){return e instanceof Error?{message:e.message,stack:e.stack}:{message:String(e),stack:void 0}}function m(e,t){if(!d)return;const n={type:"hypothesis-error",error:e instanceof Error?e:f(e),context:t};try{try{d.postMessage(n,"*")}catch(e){if(!(e instanceof DOMException&&"DataCloneError"===e.name))throw e;n.error=f(n.error),d.postMessage(n,"*")}}catch(e){console.warn("Unable to report Hypothesis error",e)}}function p(e){d=e}class g{constructor(e){this._hypothesisAppsOrigin=e,this._emitter=new h.TinyEmitter,
|
|
7
7
|
this._handledRequests=new Set,this._sidebarHostChannel=new MessageChannel,this._sidebarConnected=!1,this._listeners=new i,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}],this._listen()}_listen(){const e="Handling port request",t=new Set,n=n=>{t.has(n)||(t.add(n),m(new Error(n),e))};var i,o;this._listeners.add(window,"message",(i=e=>{const{data:t,origin:i,source:o}=e;if(!o)return;if(!s(t)||"request"!==t.type)return;const{frame1:r,frame2:a,requestId:l,sourceId:c}=t,u=`${r}-${a}`;if(!function(e){return!(null===e||e instanceof MessagePort||window.ServiceWorker&&e instanceof ServiceWorker)}(o))return void n(`Ignored port request for channel ${u} from non-Window source`)
|
|
8
8
|
;if(void 0===this._allowedMessages.find((({allowedOrigin:e,...n})=>this._messageMatches({allowedMessage:n,allowedOrigin:e,data:t,origin:i}))))return void n(`Ignored invalid port request for channel ${u} from ${i}`);if(this._handledRequests.has(l))return;this._handledRequests.add(l);const h="null"===i?"*":i,d="sidebar-host"===u?this._sidebarHostChannel:new MessageChannel,f={frame1:r,frame2:a,type:"offer",requestId:l,sourceId:c};if(d===this._sidebarHostChannel){if(this._sidebarConnected)return console.warn("Ignoring second request from Hypothesis sidebar to connect to host frame"),f.error="Received duplicate port request",void o.postMessage(f,h);this._sidebarConnected=!0}o.postMessage(f,h,[d.port1]),"sidebar"===a?this._sidebarHostChannel.port2.postMessage(f,[d.port2]):"host"===a&&this._emitter.emit("frameConnected",r,d.port2)},o=e,(...e)=>{try{return i(...e)}catch(e){throw m(e,o),e}}))}_messageMatches({allowedMessage:e,allowedOrigin:t,data:n,origin:i}){return("*"===t||i===t)&&function(e,t){
|
|
9
|
-
return!!s(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}(n,e)}on(e,t){this._emitter.on(e,t)}destroy(){this._listeners.removeAll()}}const _="1.0.0",b="frame-rpc";function v(e,t=[],n=-1){return{protocol:b,version:_,arguments:t,method:e,sequence:n}}function y(e,t,n=[],i=-1){e.postMessage(v(t,n,i))}function w(e){const t=e.match(/\bAppleWebKit\/([0-9]+)\b/);if(!t)return!1;if(parseInt(t[1])<=537)return!1;const n=e.match(/\bVersion\/([0-9]+)\b/);if(!n)return!1;return!(parseInt(n[1])>=16)}class x{constructor({userAgent:e=navigator.userAgent,currentWindow:t=window,forceUnloadListener:n=!1}={}){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new i,"onclose"in MessagePort.prototype&&!n||this._listeners.add(t,"unload",(
|
|
10
|
-
if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(e,t)}connect(e){this._port=e,this._listeners.add(e,"message",(e=>this._handle(e))),this._listeners.add(e,"close",(()=>{e.dispatchEvent(new MessageEvent("message",{data:v("close")}))})),e.start(),y(e,"connect");for(const[e,t]of this._pendingCalls)this.call(e,...t);this._pendingCalls=[]}destroy(){this._port&&(y(this._port,"close"),this._port.close()),this._destroyed=!0,this._listeners.removeAll()}call(e,...t){if(this._port||this._pendingCalls.push([e,t]),!this._port||this._destroyed)return;const n=this._sequence++,i=t[t.length-1];"function"==typeof i&&(this._callbacks.set(n,i),t=t.slice(0,-1)),y(this._port,e,t,n)}_parseMessage({data:e}){return e&&"object"==typeof e?e.protocol!==b||e.version!==_?null:Array.isArray(e.arguments)?e:null:null}_handle(e){const t=this._parseMessage(e),n=this._port;if(t&&n)if("method"in t){if("close"===t.method){if(this._receivedCloseEvent)return
|
|
11
|
-
const e=this._methods.get(t.method);if(!e)return;const i=(...e)=>{const i={arguments:e,protocol:b,response:t.sequence,version:_};n.postMessage(i)};e(...t.arguments,i)}else if("response"in t){const e=this._callbacks.get(t.response);this._callbacks.delete(t.response),e&&e(...t.arguments)}}}function C(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function N(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),i=0;i<n.length;i++){var o=void 0;try{o=JSON.parse(n[i].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function E(e){return e.width<=0||e.height<=0}function A(e,t,n,i){return Math.max(e,n)<Math.min(t,i)}function k(e,t){return!E(e)&&!E(t)&&(A(e.left,e.right,t.left,t.right)&&A(e.top,e.bottom,t.top,t.bottom))}function T(e,t){
|
|
9
|
+
return!!s(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}(n,e)}on(e,t){this._emitter.on(e,t)}destroy(){this._listeners.removeAll()}}const _="1.0.0",b="frame-rpc";function v(e,t=[],n=-1){return{protocol:b,version:_,arguments:t,method:e,sequence:n}}function y(e,t,n=[],i=-1){e.postMessage(v(t,n,i))}function w(e){const t=e.match(/\bAppleWebKit\/([0-9]+)\b/);if(!t)return!1;if(parseInt(t[1])<=537)return!1;const n=e.match(/\bVersion\/([0-9]+)\b/);if(!n)return!1;return!(parseInt(n[1])>=16)}class x{constructor({userAgent:e=navigator.userAgent,currentWindow:t=window,forceUnloadListener:n=!1}={}){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new i,"onclose"in MessagePort.prototype&&!n||this._listeners.add(t,"unload",(n=>{n instanceof CustomEvent||this._port&&(y(this._port,"close"),t!==t.parent&&w(e)&&t.parent.postMessage({type:"hypothesisPortClosed"},"*",[this._port]))})),this._pendingCalls=[],this._destroyed=!1,
|
|
10
|
+
this._receivedCloseEvent=!1}on(e,t){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(e,t)}connect(e){this._port=e,this._listeners.add(e,"message",(e=>this._handle(e))),this._listeners.add(e,"close",(()=>{e.dispatchEvent(new MessageEvent("message",{data:v("close")}))})),e.start(),y(e,"connect");for(const[e,t]of this._pendingCalls)this.call(e,...t);this._pendingCalls=[]}destroy(){this._port&&(y(this._port,"close"),this._port.close()),this._destroyed=!0,this._listeners.removeAll()}call(e,...t){if(this._port||this._pendingCalls.push([e,t]),!this._port||this._destroyed)return;const n=this._sequence++,i=t[t.length-1];"function"==typeof i&&(this._callbacks.set(n,i),t=t.slice(0,-1)),y(this._port,e,t,n)}_parseMessage({data:e}){return e&&"object"==typeof e?e.protocol!==b||e.version!==_?null:Array.isArray(e.arguments)?e:null:null}_handle(e){const t=this._parseMessage(e),n=this._port;if(t&&n)if("method"in t){if("close"===t.method){if(this._receivedCloseEvent)return
|
|
11
|
+
;this._receivedCloseEvent=!0}const e=this._methods.get(t.method);if(!e)return;const i=(...e)=>{const i={arguments:e,protocol:b,response:t.sequence,version:_};n.postMessage(i)};e(...t.arguments,i)}else if("response"in t){const e=this._callbacks.get(t.response);this._callbacks.delete(t.response),e&&e(...t.arguments)}}}function C(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function N(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),i=0;i<n.length;i++){var o=void 0;try{o=JSON.parse(n[i].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function E(e){return e.width<=0||e.height<=0}function A(e,t,n,i){return Math.max(e,n)<Math.min(t,i)}function k(e,t){return!E(e)&&!E(t)&&(A(e.left,e.right,t.left,t.right)&&A(e.top,e.bottom,t.top,t.bottom))}function T(e,t){
|
|
12
12
|
return A(e.top,e.bottom,t.top,t.bottom)}function R(e,t){return A(e.left,e.right,t.left,t.right)}function P(e,t){if(E(e))return t;if(E(t))return e;const n=Math.min(e.left,t.left),i=Math.min(e.top,t.top),o=Math.max(e.right,t.right),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,i,o-n,r-i)}function O(e){return new DOMPoint((e.left+e.right)/2,(e.top+e.bottom)/2)}function I(e){return e.nodeType===Node.ELEMENT_NODE}function M(e){return e.nodeType===Node.TEXT_NODE}const L=["p",".para"];let B;function D(e,t=0,n=e.data.length){return B||(B=document.createRange()),B.setStart(e,t),B.setEnd(e,n),B.getBoundingClientRect()}function F(e){const t=e.getBoundingClientRect();return t.x-=e.scrollLeft,t.y-=e.scrollTop,t.height=Math.max(t.height,e.scrollHeight),t.width=Math.max(t.width,e.scrollWidth),t}function*H(e,t,n){let i=e.firstChild;for(;i;){if(I(i)){const e=k(F(i),t);n(i)&&e&&(yield*H(i,t,n))}else M(i)&&k(D(i),t)&&(yield i);i=i.nextSibling}}function V(e,t){let n=null;const i=e=>!function(e){
|
|
13
13
|
switch(getComputedStyle(e).position){case"fixed":case"sticky":return!0;default:return!1}}(e);e:for(const s of H(e,t,i)){let e=0;for(const i of s.data.split(/\b/)){if(/\S/.test(i)){const a=e,l=e+i.length,c=D(s,a,l);if(r=c,!E(o=t)&&!E(r)&&r.left>=o.left&&r.right<=o.right&&r.top>=o.top&&r.bottom<=o.bottom){n=document.createRange(),n.setStart(s,a),n.setEnd(s,l);break e}}e+=i.length}}var o,r;return n}function U(e,t=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const i=V(t,n);if(!i)return e(),0;const o=i.getBoundingClientRect().top;e();const r=i.getBoundingClientRect().top-o;return t.scrollTop+=r,r}function q(e,t,n){const i=e.document.querySelector(`link[type="application/annotator+${n}"][rel="${t}"]`);if(!i)throw new Error(`No application/annotator+${n} (rel="${t}") link in the document`);if(!i.href)throw new Error(`application/annotator+${n} (rel="${t}") link has no href`);return i.href}function W(e){return"string"==typeof e?e:null}function $(e){const t=function(e){
|
|
14
14
|
if(!S(e,"hypothesisConfig"))return{};if("function"!=typeof e.hypothesisConfig){const e="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+e),{}}return e.hypothesisConfig()}(e),n=C(t.ignoreOtherConfiguration)?{}:N(e.document);function i(e){return S(t,e)?t[e]:S(n,e)?n[e]:void 0}return{get annotations(){return W(n.annotations)||function(){const t=e.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get clientUrl(){return q(e,"hypothesis-client","javascript")},get group(){return W(n.group)||function(){const t=e.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get notebookAppUrl(){return q(e,"notebook","html")},get profileAppUrl(){return q(e,"profile","html")},get showHighlights(){return function(){const e=i("showHighlights");switch(e){case"always":case"never":case"whenSidebarOpen":return e;case!0:return"always";case!1:return"never";default:
|
|
@@ -144,7 +144,7 @@ this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){var e;this._po
|
|
|
144
144
|
const i=await this._integration.anchor(this.element,t.selector),o=ci.fromRange(i);n={annotation:e,target:t,range:o}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&xi(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(t.map((e=>this._integration.describe(i,e))))).map((e=>({source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:o,$highlight:e,
|
|
145
145
|
$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),xr(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);Ci(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),i=mi(n),o=_i(n);o?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=vr(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){
|
|
146
146
|
t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){lt(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new gr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Sr(e,t){const n=new URL(e),i=new URLSearchParams;return i.append("config",JSON.stringify(t)),n.hash=i.toString(),n.toString()}function Er(e,t){const n={}
|
|
147
|
-
;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.
|
|
147
|
+
;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.1534.0";const i=new URL(window.location.href);if(i.hash="",n.hostURL=i.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Ar({closed:e,onClose:t,children:n,"data-testid":i,"aria-label":o}){const r=Ge(null);return Xe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Xe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Nt("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":i,"aria-label":o,children:n})}function kr({closed:e,children:t,...n}){return Nt("div",{...n,
|
|
148
148
|
className:xt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Nt("div",{className:"relative w-full h-full",children:t})})}function Tr({document_:e=document,...t}){return Nt(Ke((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Ar:kr),[e]),{...t})}function Rr({config:e,groupId:t}){return Nt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Sr(e.notebookAppUrl,{...Er(e.notebookAppUrl,e),group:t})})}function Pr({eventBus:e,config:t}){const[n,i]=je(0),[o,r]=je(!0),[s,a]=je(null),l=Ge(""),c=Ge(null);Xe((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Xe((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Xe((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),i((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const u=Qe((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
|
|
149
149
|
;return null===s?null:Nt(Tr,{closed:o,onClose:u,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Nt("div",{className:"absolute right-0 m-3",children:Nt(yn,{title:"Close notebook",onClick:u,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Nt(Ot,{className:"w-4 h-4"})})}),Nt(Rr,{config:t,groupId:s},n)]})}class Or{constructor(e,t,n){this._container=new Qn("notebook",(()=>Nt(Pr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Ir({eventBus:e,config:t}){const[n,i]=je(!0),o=Ge(null);Xe((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{i(!1)})),o.current=t,()=>{t.destroy()}}),[e]);const r=()=>{i(!0),o.current?.publish("closeProfile")};return n?null:Nt(Tr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Nt("div",{className:"absolute right-0 m-3",children:Nt(yn,{
|
|
150
150
|
title:"Close profile dialog",onClick:r,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),children:Nt(Ot,{className:"w-4 h-4"})})}),Nt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Mr{constructor(e,t,n){this._container=new Qn("profile",(()=>Nt(Ir,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Lr,Br={exports:{}};var Dr=(Lr||(Lr=1,function(e){!function(t,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,u=Math.abs,h=Date.now;function d(e,t,n){return setTimeout(v(e,n),t)}function f(e,t,n){return!!Array.isArray(e)&&(m(e,n[t],n),!0)}function m(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==o)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(e,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
|