hypothesis 1.1178.0 → 1.1179.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";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,
|
|
1
|
+
!function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?2131ee","styles/annotator.css":"styles/annotator.css?c10c10","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e9b69c","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","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?9948ec","styles/sidebar.css.map":"styles/sidebar.css.map?e2a8a3","styles/ui-playground.css":"styles/ui-playground.css?29f7ea","styles/ui-playground.css.map":"styles/ui-playground.css.map?3fceb8","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?bbe7cc","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?8a1a4b","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?921f5f","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?0070d9","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?0e7c7b"};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 p=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),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1179.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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?2131ee",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?c10c10",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?02fa76",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"styles/ui-playground.css": "styles/ui-playground.css?29f7ea",
|
|
14
14
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?3fceb8",
|
|
15
15
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?bbe7cc",
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?8a1a4b",
|
|
17
17
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?921f5f",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?0070d9",
|
|
19
19
|
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?0e7c7b"
|
|
@@ -127,7 +127,7 @@ this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)}
|
|
|
127
127
|
;const n=No(t);if(!n)return;const i=en(n,null===(e=t.annotation)||void 0===e?void 0:e.$cluster);i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&rn(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=je.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&on(e.highlights);this._updateAnchors(n,e)}
|
|
128
128
|
_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+Et(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),ko(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);rn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue
|
|
129
129
|
;const t=sn(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Ze(n),o=Qe(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=So(),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(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){
|
|
130
|
-
t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Jt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function To(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Ro(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.
|
|
130
|
+
t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Jt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function To(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Ro(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1179.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0]
|
|
131
131
|
;t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function Lo({config:t,groupId:e}){return ht("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:To(t.notebookAppUrl,{...Ro(t.notebookAppUrl,t),group:e})})}function Po({eventBus:t,config:e}){const[n,i]=K(0),[o,r]=K(!0),[s,a]=K(null),l=tt(""),c=tt(null);Q((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Q((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Q((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ht("div",{className:h("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",
|
|
132
132
|
children:ht("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ht("div",{className:"absolute right-0 text-xl m-3",children:ht(Se,{icon:oe,title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),ht(Lo,{config:e,groupId:s},n)]})})}class Oo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ie(this._outerContainer),B(ht(Po,{eventBus:e,config:n}),this.shadowRoot)}destroy(){B(null,this.shadowRoot),this._outerContainer.remove()}}var Mo={},Io={get exports(){return Mo},set exports(t){Mo=t}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i
|
|
133
133
|
;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var g=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),m=p((function(t,e){return g(t,e,!0)
|
|
@@ -633,7 +633,7 @@ align:n.align,isWindow:n.isWindow||Ov,maxSynchronousAlignments:d,end:u,scrollAnc
|
|
|
633
633
|
variant:"primary",onClick:e,children:"Log in"})]})]})}function Uv({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()},s=t>0?`${o} (${t} available)`:o;return Qr(Kc,{classes:Kn("bg-transparent min-w-[5.25rem]",{"font-bold":r}),color:"text",onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,underline:"none",children:Qr(nr,{children:[e,t>0&&!n&&Qr("span",{className:"relative bottom-[3px] left-[2px] text-tiny",children:t})]})})}var qv=Po((function({annotationsService:e,isLoading:t,settings:n}){const r=ls(),o=r.selectedTab(),i=r.noteCount(),a=r.annotationCount(),s=r.orphanCount(),l=r.isWaitingToAnchorAnnotations(),c=e=>{r.clearSelection(),r.selectTab(e)},u="annotation"===o&&0===a&&!l,d="note"===o&&0===i;return Qr("div",{className:Kn("space-y-3 pb-[9px]"),children:[Qr("div",{className:"flex gap-x-6 theme-clean:ml-[15px]",role:"tablist",children:[Qr(Uv,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",onSelect:()=>c("annotation"),
|
|
634
634
|
children:"Annotations"}),Qr(Uv,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),children:"Page Notes"}),s>0&&Qr(Uv,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&Qr("div",{className:"flex justify-end",children:Qr(Hc,{"data-testid":"new-note-button",onClick:()=>e.createPageNote(),variant:"primary",style:Do(["ctaBackgroundColor"],n),children:[Qr(pc,{}),"New note"]})}),!t&&d&&Qr($c,{"data-testid":"notes-unavailable-message",variant:"flat",children:Qr(Gc,{classes:"text-center",children:"There are no page notes in this group."})}),!t&&u&&Qr($c,{"data-testid":"annotations-unavailable-message",variant:"flat",children:Qr(Gc,{classes:"text-center !space-y-1",children:[Qr("p",{children:"There are no annotations in this group."}),Qr("p",{children:["Create one by selecting some text and clicking the"," ",Qr(sl,{className:"w-em h-em inline m-0.5 -mt-0.5",
|
|
635
635
|
title:"Annotate"})," ","button."]})]})})]})}),["annotationsService","settings"]);var $v=Po((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Fs(),a=ls(),s=a.focusedGroupId(),l=a.hasAppliedFilter()||a.hasSelectedAnnotations(),c=a.isLoading(),u=a.isLoggedIn(),d=a.directLinkedAnnotationId(),h=d?a.findAnnotationByID(d):void 0,p=h?Ts(h):"annotation",m=a.searchUris(),f=a.hasSidebarOpened(),g=a.profile().userid,v=!(c||!d)&&!h,b=a.directLinkedGroupFetchFailed(),_=v||b,y=!_,w=!_&&!l,x=d&&!u&&!v&&!c,k=jr(s);Hr((()=>{if(!k.current||k.current!==s){if(k.current){let e=a.focusState().active;a.clearSelection(),e&&a.toggleFocusMode(!0)}k.current=s}s&&m.length&&r.load({groupId:s,uris:m})}),[a,r,s,g,m]),Hr((()=>{h&&!1===h.$orphan?(e.hoverAnnotation(h),e.scrollToAnnotation(h),a.selectTab(p)):h&&a.selectTab(p)}),[p,e,h,a]);const S=a.hasFetchedProfile();return Hr((()=>{S&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[S,u,f,o]),Qr("div",{children:[Qr("h2",{className:"sr-only",
|
|
636
|
-
children:"Annotations"}),y&&Qr(Lv,{}),Qr(jv,{onLogin:t,onSignUp:n}),v&&Qr(Av,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Qr(Av,{errorType:"group",onLoginRequest:t}),w&&Qr(qv,{isLoading:c}),Qr(Ev,{threads:i.children}),x&&Qr(zv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Gv=Po((function({api:e,toastMessenger:t}){const n=ls(),r=n.routeParams().q,o=qr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...xs(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Hr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Qr(Ev,{threads:Fs().children})}),["api","toastMessenger"]);class Vv{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.
|
|
636
|
+
children:"Annotations"}),y&&Qr(Lv,{}),Qr(jv,{onLogin:t,onSignUp:n}),v&&Qr(Av,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Qr(Av,{errorType:"group",onLoginRequest:t}),w&&Qr(qv,{isLoading:c}),Qr(Ev,{threads:i.children}),x&&Qr(zv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Gv=Po((function({api:e,toastMessenger:t}){const n=ls(),r=n.routeParams().q,o=qr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...xs(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Hr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Qr(Ev,{threads:Fs().children})}),["api","toastMessenger"]);class Vv{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1179.0",this.userAgent=n.navigator.userAgent,
|
|
637
637
|
this.urls=t.map((e=>e.uri)).join(", ")||s,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:s,this.account=l,this.timestamp=(new Date).toString();const c=null===(a=t[0])||void 0===a?void 0:a.segment;if(c){const e=[];c.cfi&&e.push(["CFI",c.cfi]),c.url&&e.push(["URL",c.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}function Yv(e){const n=t(e);return!(null==n||!n.authority)&&n.authority!==e.authDomain}function Wv({commandName:e,icon:t}){return Qr("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Qr(t,{className:Kn("w-em h-em","mx-1 -mt-1","text-color-text-light inline")}),Qr("em",{"data-testid":"command-name",children:e})]})}
|
|
638
638
|
var Kv=Po((function({settings:e}){const t=!Yv(e);return Qr("ol",{className:"list-decimal pl-10 space-y-2",children:[Qr("li",{children:["To create an annotation, select text and then select the"," ",Qr(Wv,{icon:sl,commandName:"Annotate"})," button."]}),Qr("li",{children:["To create a highlight (",Qr(Wc,{href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",underline:"always",children:"visible only to you"}),"), select text and then select the"," ",Qr(Wv,{icon:Xl,commandName:"Highlight"})," button."]}),t&&Qr("li",{children:["To annotate in a private group, select the group from the groups dropdown. Don't see your group? Ask the group creator to send a"," ",Qr(Wc,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Qr("li",{children:["To reply to an annotation, select the"," ",Qr(Wv,{icon:kc,commandName:"Reply"})," button."]})]})}),["settings"]);function Zv({label:e,children:t,classes:n}){
|
|
639
639
|
return Qr(nr,{children:[Qr("dt",{className:"col-span-1 sm:text-right font-medium",children:e}),Qr("dd",{className:Kn("col-span-1 sm:col-span-3 text-color-text-light break-words",n),children:t})]})}var Xv=Po((function({toastMessenger:e,versionData:t}){return Qr("div",{className:"space-y-4",children:[Qr("dl",{className:"grid grid-cols-1 sm:grid-cols-4 sm:gap-x-2",children:[Qr(Zv,{label:"Version",children:t.version}),Qr(Zv,{label:"User Agent",children:t.userAgent}),Qr(Zv,{classes:Kn("break-all"),label:"URL",children:t.urls}),Qr(Zv,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Qr(Zv,{label:"Segment",children:t.segment}),Qr(Zv,{label:"Account",children:t.account}),Qr(Zv,{label:"Date",children:t.timestamp})]}),Qr("div",{className:"flex items-center justify-center",children:Qr(Hc,{onClick:()=>{try{au(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:El,children:"Copy version details"})})]})}),["toastMessenger"])
|
|
@@ -664,7 +664,7 @@ children:[Qr(vb,{}),Qr(eb,{}),Qr(fb,{}),l&&Qr("main",{children:["annotation"===l
|
|
|
664
664
|
permissions:ru(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:s,$tag:l,hidden:!1,links:{},document:{title:""}},e);return Ci(c)&&(c.permissions=tu(i)),c}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Ci(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!xi(n)}),Ai(n)?this._store.selectTab("note"):Ti(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(){const e=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!e)return;const t={target:[],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,
|
|
665
665
|
permissions:xi(e)?nu(t,e.group):tu(t),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e){let t,n;const r=this._applyDraftChanges(e);let o;yi(e)?(t=this._api.annotation.update({id:e.id},r),n="update"):(t=this._api.annotation.create({},r),n="create"),this._store.annotationSaveStarted(e);try{o=await t,this._activity.reportActivity(n,o)}finally{this._store.annotationSaveFinished(e)}for(let[t,n]of Object.entries(e))if(t.startsWith("$")){o[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([o]),o}}Ob.$inject=["annotationActivity","api","store"];class Db{constructor(e){this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":n=new Date(t.created).toISOString();break;case"update":n=new Date(t.updated).toISOString();break;default:n=(new Date).toISOString()}const r={date:n,annotation:{id:t.id,isShared:ou(t.permissions)}}
|
|
666
666
|
;this._reportConfig.events.includes(e)&&function(e,t,n,r=[]){const o={jsonrpc:"2.0",method:n,params:r};e.postMessage(o,t)}(this._rpc.targetFrame,this._rpc.origin,this._reportConfig.method,[e,r])}}Db.$inject=["settings"];class Bb extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function Pb(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Bb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Bb(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Bb(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Hb(e){const t={};for(let[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}function Fb(e){return"url"in e}function jb(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".")
|
|
667
|
-
;for(let[e,t]of r.entries()){const o=n[t];if(!o||Fb(o)){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.
|
|
667
|
+
;for(let[e,t]of r.entries()){const o=n[t];if(!o||Fb(o)){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1179.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=Ia(c.url,a),m=new URL(h);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Pb(m.toString(),{body:s?JSON.stringify(Hb(s)):null,headers:u,method:c.method})}finally{i()}}}class Ub{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>jb(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),
|
|
668
668
|
hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}Ub.$inject=["apiRoutes","auth","store"];var qb={},$b={get exports(){return qb},set exports(e){qb=e}},Gb={};function Vb(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Yb=Vb;Vb.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},Vb.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),
|
|
669
669
|
this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},Vb.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},Vb.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){
|
|
670
670
|
n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},Vb.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},Vb.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},Vb.prototype.start=Vb.prototype.try,Vb.prototype.errors=function(){return this._errors},Vb.prototype.attempts=function(){return this._attempts},Vb.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},function(e){var t=Yb;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n]
|
|
@@ -701,7 +701,7 @@ this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAtte
|
|
|
701
701
|
if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${p(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}C_.$inject=["localStorage"];class E_{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}E_.$inject=["store"];class A_{constructor(e){this._store=e}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}
|
|
702
702
|
_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1}={}){if(this._store.hasToastMessage(e,t))return;const i=a(10),s={type:e,id:i,message:t,moreInfoURL:r,visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),n&&setTimeout((()=>{this.dismiss(i)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}A_.$inject=["store"];class T_{constructor(){this._providers=new Map,this._instances=new Map,this._constructing=new Set}get(e){if(this._instances.has(e))return this._instances.get(e);const t=this._providers.get(e);if(!t)throw new Error(`"${e}" is not registered`);if("value"in t)return this._instances.set(e,t.value),t.value;if(this._constructing.has(e))throw new Error(`Encountered a circular dependency when constructing "${e}"`);this._constructing.add(e);try{const n=[],r="class"in t&&t.class.$inject||"factory"in t&&t.factory.$inject||[];for(const t of r)try{n.push(this.get(t))}catch(n){
|
|
703
703
|
const r=new Error(`Failed to construct dependency "${t}" of "${e}": ${n.message}`);throw r.cause=n,r}let o;if(t.class)o=new t.class(...n);else{o=(0,t.factory)(...n)}return this._instances.set(e,o),o}finally{this._constructing.delete(e)}}register(e,t){if("function"==typeof t)t={class:t};else if(!function(e){return"object"==typeof e&&null!==e&&("value"in e||"function"==typeof e.class||"function"==typeof e.factory)}(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const M_=function(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),L_=function(t){const{version:n,origin:r}=e(t.location.href)
|
|
704
|
-
;return"1.
|
|
704
|
+
;return"1.1179.0"!==n?(console.warn(`The Hypothesis sidebar is using a different version (1.1179.0) than the host page (${n}). It may not work.`),!1):"null"===t.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):t.origin===r||(console.warn(`The Hypothesis sidebar is running in a different origin (${t.origin}) than expected (${r}). It may not work.`),!1)}(window);function z_(e,t){e.setClientId(t.clientId)}function R_(e,t,n){e.load(),t.load(),n.sync()}function I_(e,t,n){e.init(),t.init(),n.init()}function O_(e,t){"sidebar"===t.route()&&e.connect()}M_.sentry&&L_&&function(t){const n=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),r=n?[n]:void 0;Dn({dsn:t.dsn,environment:t.environment,allowUrls:r,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1179.0",beforeSend:(e,t)=>{if(Hn>=5)return u("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Hn;try{const n=t&&t.originalException
|
|
705
705
|
;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch(e){}return e}});try{bt("host_config",e(window.location.href))}catch(e){}bt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Pn(((e,t)=>{vt(e,{tags:{context:t}})}))}(M_.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),z_.$inject=["api","streamer"],R_.$inject=["groups","session","router"],I_.$inject=["autosaveService","persistedDefaults","serviceURL"],O_.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&eo.clear();for(let[t,n]of Object.entries(e))eo.set(t,n)}(Ro);const D_=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",v)}(),async function(i,a=window){const c=function(t){
|
|
706
706
|
const i=e(t.location.href),a=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],s={openSidebar:n,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:o(t.origin),ancestorLevel:r(t.ancestorLevel)}}},l={};for(let[e,t]of Object.entries(i))a.includes(e)&&null!==t&&(s[e]?l[e]=s[e](t):l[e]=t);return l}(window),u=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:l(n.ancestorLevel,t),origin:n.origin}}(c,a);let d;if(u){const e=await async function(e,t){return{...await s(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(c,u);d=function(e,t){const n=e.services
|
|
707
707
|
;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=s(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,u)}else d=c;const h={...i,...d};return u&&(h.rpc=u),h.apiUrl=function(e){const n=t(e);if(n){if(n.apiUrl)return n.apiUrl;throw new Error("Service should contain an apiUrl value.")}return e.apiUrl}(h),h}(M_).then((e=>{!function(e,t){const n=new T_;n.register("annotationsService",Ob).register("annotationActivity",Db).register("api",Ub).register("apiRoutes",Xb).register("auth",e_).register("autosaveService",t_).register("frameSync",d_).register("groups",m_).register("loadAnnotationsService",f_).register("localStorage",v_).register("persistedDefaults",__).register("router",y_).register("serviceURL",w_).register("session",x_).register("streamer",N_).register("streamFilter",k_).register("tags",C_).register("threadsService",E_).register("toastMessenger",A_).register("store",{factory:ss}),n.register("$window",{
|