hypothesis 1.1684.0 → 1.1685.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-template.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?4bb7b1","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?ee8f84","styles/annotator.css":"styles/annotator.css?d8c51f","styles/annotator.css.map":"styles/annotator.css.map?4a856f","styles/highlights.css":"styles/highlights.css?470b72","styles/highlights.css.map":"styles/highlights.css.map?d94fe5","styles/katex.min.css":"styles/katex.min.css?921c28","styles/katex.min.css.map":"styles/katex.min.css.map?e7e03f","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?a0cd6a","styles/sidebar.css.map":"styles/sidebar.css.map?bf9048","styles/ui-playground.css":"styles/ui-playground.css?51ddbc","styles/ui-playground.css.map":"styles/ui-playground.css.map?133fd0","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?706134","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?19cf86","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?f3e15d","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?f0e4fa"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.esModule,o=void 0===n||n,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function n(s,t,r,n){var o=s.createElement("link");o.rel=t,o.href=n,o.type="application/annotator+".concat(r),e(o),s.head.appendChild(o)}function o(s,t,r){var n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,"fetch"===t&&(n.crossOrigin="anonymous"),e(n),s.head.appendChild(n)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var n=void 0;try{n=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),n={}}Object.assign(e,n)}return e}(document),c=a(l.assetRoot||"__ASSET_ROOT__");if(document.querySelector("hypothesis-app")){!function(s,e){o(s,"fetch",e.apiUrl),o(s,"fetch",e.apiUrl+"links");for(var n=0,a=["scripts/sidebar.bundle.js"];n<a.length;n++)r(s,i(e,a[n]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=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(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"__NOTEBOOK_APP_URL__"),h=a(d.profileAppUrl||"__PROFILE_APP_URL__"),y=a(d.sidebarAppUrl||"__SIDEBAR_APP_URL__");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",e.sidebarAppUrl),n(s,"notebook","html",e.notebookAppUrl),n(s,"profile","html",e.profileAppUrl),o(s,"style",i(e,"styles/annotator.css")),n(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,i(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,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/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?4bb7b1","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?ee8f84","styles/annotator.css":"styles/annotator.css?d8c51f","styles/annotator.css.map":"styles/annotator.css.map?4a856f","styles/highlights.css":"styles/highlights.css?470b72","styles/highlights.css.map":"styles/highlights.css.map?d94fe5","styles/katex.min.css":"styles/katex.min.css?921c28","styles/katex.min.css.map":"styles/katex.min.css.map?e7e03f","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?a0cd6a","styles/sidebar.css.map":"styles/sidebar.css.map?bf9048","styles/ui-playground.css":"styles/ui-playground.css?51ddbc","styles/ui-playground.css.map":"styles/ui-playground.css.map?133fd0","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?706134","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?19cf86","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?f3e15d","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?f0e4fa"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.esModule,o=void 0===n||n,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function n(s,t,r,n){var o=s.createElement("link");o.rel=t,o.href=n,o.type="application/annotator+".concat(r),e(o),s.head.appendChild(o)}function o(s,t,r){var n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,"fetch"===t&&(n.crossOrigin="anonymous"),e(n),s.head.appendChild(n)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var n=void 0;try{n=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),n={}}Object.assign(e,n)}return e}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1685.0/");if(document.querySelector("hypothesis-app")){!function(s,e){o(s,"fetch",e.apiUrl),o(s,"fetch",e.apiUrl+"links");for(var n=0,a=["scripts/sidebar.bundle.js"];n<a.length;n++)r(s,i(e,a[n]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=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(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"https://hypothes.is/notebook"),h=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",e.sidebarAppUrl),n(s,"notebook","html",e.notebookAppUrl),n(s,"profile","html",e.profileAppUrl),o(s,"style",i(e,"styles/annotator.css")),n(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,i(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,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?4bb7b1",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?ee8f84",
|
|
4
4
|
"styles/annotator.css": "styles/annotator.css?d8c51f",
|
|
5
5
|
"styles/annotator.css.map": "styles/annotator.css.map?4a856f",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"styles/sidebar.css.map": "styles/sidebar.css.map?bf9048",
|
|
14
14
|
"styles/ui-playground.css": "styles/ui-playground.css?51ddbc",
|
|
15
15
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?133fd0",
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
17
|
-
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?706134",
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?19cf86",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?f3e15d",
|
|
19
19
|
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?f0e4fa"
|
|
20
20
|
}
|
|
@@ -64,8 +64,8 @@ className:Ne("absolute left-1/2 -translate-x-1/2 z-2","fill-white text-grey-3",{
|
|
|
64
64
|
"data-testid":"annotate-shortcuts-announce",children:t&&Se(b,{children:[e>0&&Se("li",{children:["Press ","'S'"," to show annotations."]}),Se("li",{children:["Press ","'A'"," to annotate."]}),Se("li",{children:["Press ","'H'"," to highlight."]})]})})]})}function wn({arrowDirection:e,isVisible:t,onCommand:n,annotationCount:o=0}){const i=t?"a":null,r=t?"h":null,s=t?"s":null;return un(t?"Escape":null,(()=>n("hide"))),Se("div",{className:Ne("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-intense","opacity-5",{"animate-adder-pop-up":"up"===e&&t,"animate-adder-pop-down":"down"===e&&t}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:t?"visible":"hidden"},children:[Se("div",{className:Ne("flex group"),children:[Se(_n,{icon:Ie,onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),Se(_n,{icon:$e,onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&&Se(b,{children:[Se("div",{className:Ne("m-1.5 border-r border-grey-4 border-solid")}),Se(_n,{
|
|
65
65
|
badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),Se(gn,{arrowDirection:e}),Se(mn,{annotationCount:o,isVisible:t})]})}function bn(e){const t=e.attachShadow({mode:"open"});return function(e){const t=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]')?.href;if(!t)return;const n=document.createElement("link");n.rel="stylesheet",n.href=t,e.appendChild(n)}(t),t}class yn{constructor(e,t){const n=`hypothesis-${e}`;this._element=document.createElement(n),this._shadowRoot=bn(this._element),this._render=t}destroy(){D(null,this._shadowRoot),this._element.remove()}get element(){return this._element}render(){D(this._render(),this._shadowRoot)}}let vn=function(e){return e[e.DOWN=1]="DOWN",e[e.UP=2]="UP",e}({});function xn(e){return e.toString()+"px"}class Cn{constructor(e,t){this._view=e.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=t.onAnnotate,this._onHighlight=t.onHighlight,
|
|
66
66
|
this._onShowAnnotations=t.onShowAnnotations,this._container=new yn("adder",(()=>this._render())),e.appendChild(this._container.element),Object.assign(this._container.element.style,{position:"absolute",top:0,left:0}),this._container.render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(e){this._annotationsForSelection=e,this._container.render()}hide(){this._isVisible=!1,this._container.render(),Object.assign(this._container.element.style,{top:0,left:0})}destroy(){this._container.destroy()}show(e,t){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(e,t);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=i===vn.UP?"up":"down",this._container.render()}_firstChild(){return this._container.element.shadowRoot.firstChild}_width(){return this._firstChild().getBoundingClientRect().width}_height(){return this._firstChild().getBoundingClientRect().height}_calculateTarget(e,t){let n,o,i;n=t&&!fn()?vn.DOWN:vn.UP
|
|
67
|
-
;const r=Math.min(20,e.width),s=this._width(),a=fn()?10:0,l=this._height();return i=t?e.left-s/2+r:e.left+e.width-s/2-r,e.top-l<0&&n===vn.DOWN?n=vn.UP:e.top+l>this._view.innerHeight&&(n=vn.DOWN),o=n===vn.UP?e.top+e.height+10+a:e.top-l-10,i=Math.max(i,0),i=Math.min(i,this._view.innerWidth-s),o=Math.max(o,0),o=Math.min(o,this._view.innerHeight-l),{top:o,left:i,arrowDirection:n}}_findZindex(e,t){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=e
|
|
68
|
-
;return t}(this._container.element).getBoundingClientRect(),o=this._findZindex(e,t);Object.assign(this._container.element.style,{left:xn(e-n.left),top:xn(t-n.top),zIndex:o})}_render(){return Se(wn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:e=>{switch(e){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length})}}var Sn=function(e){return e[e.Forwards=1]="Forwards",e[e.Backwards=2]="Backwards",e}(Sn||{});function An(e,t,n){const o=n===Sn.Forwards?t:t-1;if(""!==e.charAt(o).trim())return t;let i,r;if(n===Sn.Backwards?(i=e.substring(0,t),r=i.trimEnd()):(i=e.substring(t),r=i.trimStart()),!r.length)return-1;const s=i.length-r.length;return n===Sn.Backwards?t-s:t+s}function En(e,t){
|
|
67
|
+
;const r=Math.min(20,e.width),s=this._width(),a=fn()?10:0,l=this._height();return i=t?e.left-s/2+r:e.left+e.width-s/2-r,e.top-l<0&&n===vn.DOWN?n=vn.UP:e.top+l>this._view.innerHeight&&(n=vn.DOWN),o=n===vn.UP?e.top+e.height+10+a:e.top-l-10,i=Math.max(i,0),i=Math.min(i,this._view.innerWidth-s),o=Math.max(o,0),o=Math.min(o,this._view.innerHeight-l),{top:o,left:i,arrowDirection:n}}_findZindex(e,t){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=e=>{const t=parseInt(getComputedStyle(e).zIndex);return Number.isInteger(t)?t:0},r=[...new Set([...document.elementsFromPoint(e,t),...document.elementsFromPoint(e,t+o),...document.elementsFromPoint(e+n/2,t+o/2),...document.elementsFromPoint(e+n,t),...document.elementsFromPoint(e+n,t+o)])].map(i).filter(Number.isInteger);let s=0;for(const e of document.querySelectorAll("hypothesis-highlight"))s=Math.max(s,i(e));return r.push(s),Math.max(...r)+1}_showAt(e,t){const n=function(e){let t=e.parentElement
|
|
68
|
+
;for(;t.parentElement&&"static"===getComputedStyle(t).position;)t=t.parentElement;return t}(this._container.element).getBoundingClientRect(),o=this._findZindex(e,t);Object.assign(this._container.element.style,{left:xn(e-n.left),top:xn(t-n.top),zIndex:o})}_render(){return Se(wn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:e=>{switch(e){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length})}}var Sn=function(e){return e[e.Forwards=1]="Forwards",e[e.Backwards=2]="Backwards",e}(Sn||{});function An(e,t,n){const o=n===Sn.Forwards?t:t-1;if(""!==e.charAt(o).trim())return t;let i,r;if(n===Sn.Backwards?(i=e.substring(0,t),r=i.trimEnd()):(i=e.substring(t),r=i.trimStart()),!r.length)return-1;const s=i.length-r.length;return n===Sn.Backwards?t-s:t+s}function En(e,t){
|
|
69
69
|
const n=e.commonAncestorContainer.ownerDocument.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT),o=t===Sn.Forwards?e.startContainer:e.endContainer,i=t===Sn.Forwards?e.endContainer:e.startContainer;let r=n.nextNode();for(;r&&r!==o;)r=n.nextNode();t===Sn.Backwards&&(r=n.previousNode());let s=-1;const a=()=>{if(r=t===Sn.Forwards?n.nextNode():n.previousNode(),r){const e=r.textContent,n=t===Sn.Forwards?0:e.length;s=An(e,n,t)}};for(;r&&-1===s&&r!==i;)a();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function Rn(e){switch(e.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return e.textContent?.length??0;default:return 0}}function kn(e){let t=e.previousSibling,n=0;for(;t;)n+=Rn(t),t=t.previousSibling;return n}function Pn(e,...t){let n=t.shift();const o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),
|
|
70
70
|
n=t.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=t.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}let Tn=function(e){return e[e.FORWARDS=1]="FORWARDS",e[e.BACKWARDS=2]="BACKWARDS",e}({});class Nn{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,n=this.offset;for(;t!==e;)n+=kn(t),t=t.parentElement;return new Nn(t,n)}resolve(e={}){try{return Pn(this.element,this.offset)[0]}catch(t){if(0===this.offset&&void 0!==e.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=e.direction===Tn.FORWARDS,i=o?n.nextNode():n.previousNode();if(!i)throw t;return{node:i,offset:o?0:i.data.length}}throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return Nn.fromPoint(e,t)
|
|
71
71
|
;case Node.ELEMENT_NODE:return new Nn(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range");if(!e.parentElement)throw new Error("Text node has no parent");const n=kn(e)+t;return new Nn(e.parentElement,n)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let o=0;o<t;o++)n+=Rn(e.childNodes[o]);return new Nn(e,n)}default:throw new Error("Point is not in an element or text node")}}}class Mn{constructor(e,t){this.start=e,this.end=t}relativeTo(e){return new Mn(this.start.relativeTo(e),this.end.relativeTo(e))}toRange(){let e,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[e,t]=Pn(this.start.element,this.start.offset,this.end.offset):(e=this.start.resolve({direction:Tn.FORWARDS}),t=this.end.resolve({direction:Tn.BACKWARDS}));const n=new Range
|
|
@@ -148,7 +148,7 @@ this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.des
|
|
|
148
148
|
;if(o instanceof Range){const i=Mn.fromRange(o);n={annotation:e,target:t,region:i}}else n={annotation:e,target:t,region: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.region)),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&&this._highlighter.removeHighlights(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation(e){if("selection"===e)return this.createAnnotationFromSelection();if(!["rect","point"].includes(e))throw new Error("Unsupported annotation tool");{let t=!1;try{this._hostRPC.call("activeToolChanged",e)
|
|
149
149
|
;const t=await this._drawTool.draw(e),n=await this.getDocumentInfo(),o=[{source:n.uri,selector:await this._integration.describe(this.element,t)}],i={uri:n.uri,document:n.metadata,target:o,$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}catch(e){if(e instanceof no&&["canceled","restarted"].includes(e.kind))return t="restarted"===e.kind,null;throw e}finally{t||this._hostRPC.call("activeToolChanged",null)}}}async createAnnotationFromSelection({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({source:n.uri,selector:e}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),or(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)))
|
|
150
150
|
;for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);this._highlighter.setHighlightsFocused(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(),o=Fn(n),i=Vn(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=er(),this._isAdderVisible=!0,this._adder.show(i,o)):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}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){this._highlighter.setHighlightsVisible(e),this._highlightsVisible=e,
|
|
151
|
-
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){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Qi(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function sr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function ar(e,t){const n={};for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.
|
|
151
|
+
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){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Qi(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function sr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function ar(e,t){const n={};for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1685.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),
|
|
152
152
|
e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function lr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=ie(null);return ne((()=>{e?r.current?.close():r.current?.showModal()}),[e]),ne((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Se("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function cr({closed:e,children:t,...n}){return Se("div",{...n,className:Ne("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Se("div",{className:"relative w-full h-full",children:t})})}function hr({document_:e=document,...t}){return Se(re((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?lr:cr),[e]),{...t})}function dr({config:e,groupId:t}){
|
|
153
153
|
return Se("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:sr(e.notebookAppUrl,{...ar(e.notebookAppUrl,e),group:t})})}function ur({eventBus:e,config:t}){const[n,o]=te(0),[i,r]=te(!0),[s,a]=te(null),l=ie(""),c=ie(null);ne((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),ne((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),ne((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const h=se((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Se(hr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close notebook",onClick:h,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Se(Le,{className:"w-4 h-4"})})}),Se(dr,{
|
|
154
154
|
config:t,groupId:s},n)]})}class fr{constructor(e,t,n){this._container=new yn("notebook",(()=>Se(ur,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function pr({eventBus:e,config:t}){const[n,o]=te(!0),i=ie(null);ne((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Se(hr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),children:Se(Le,{className:"w-4 h-4"})})}),Se("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class gr{constructor(e,t,n){this._container=new yn("profile",(()=>Se(pr,{eventBus:t,config:n}))),e.append(this._container.element),
|