### Install Dependencies Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/CONTRIBUTING.md Install all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Run Development Server with Hot Reload Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/CONTRIBUTING.md Start the development server which builds the obsidian-annotator on code changes, recommended for active development. ```bash npm run dev ``` -------------------------------- ### Get Asset Path Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/cdn.hypothes.is/hypothesis.html Constructs the full path to an asset using the asset root and manifest. ```javascript function p(t,e){return t.assetRoot+"build/"+t.manifest[e]} ``` -------------------------------- ### Get Polyfill Script Paths Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/cdn.hypothes.is/hypothesis.html Filters and maps polyfill sets to their corresponding script file paths. ```javascript function h(t){return function(t){return t.filter((function(t){var e=s[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))} ``` -------------------------------- ### Get Configuration Setting Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-ff5e78d0f0a5e.html Retrieves a configuration setting from New Relic's initialization object. Useful for accessing specific agent configurations. ```javascript function r(t){if(NREUM.init){for(var e=NREUM.init,n=t.split("."),r=0;r1&&void 0!==arguments[1]?arguments[1]:document;if(t.currentScript)return f(t.currentScript.src);throw new Error("Could not process URL template because script origin is unknown")} ``` -------------------------------- ### Dataview Annotation Target (Markdown) Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/README.md Use Dataview syntax to specify the annotation target, allowing for obsidian-style links to files. This requires the Dataview plugin to be installed. ```markdown ```dataview "annotation-target" :: "Pdfs/mypdf.pdf" ``` ``` -------------------------------- ### Get URL Templates Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/hypothes.is/api/index.html Retrieves URL templates for generating links to HTML pages. ```APIDOC ## GET /api/links ### Description URL templates for generating URLs for HTML pages. ### Method GET ### Endpoint https://hypothes.is/api/links ### Parameters (Not specified in source) ``` -------------------------------- ### Get Configuration Value Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-c3c18bf3bf5c4.html Retrieve a specific configuration value from the New Relic initialization settings. This is useful for checking or dynamically adjusting settings. ```javascript var ajaxConfig = NREUM.getConfiguration('ajax'); ``` -------------------------------- ### Frontmatter Annotation Target (Markdown) Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/README.md Specify the PDF or EPUB file location in the frontmatter of an Obsidian note. This is used when the Dataview plugin is not installed. ```markdown --- annotation-target: https://arxiv.org/pdf/2104.13478.pdf --- ``` -------------------------------- ### Context Management Utility Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-a7fb31186f33c.html Provides a utility function to get or set the context for operations. This is useful for managing state and associating data with specific operations. ```javascript function o(t){return u(t,c,a)} ``` -------------------------------- ### Get High-Resolution Timestamp Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-ff5e78d0f0a5e.html Provides a high-resolution timestamp using `performance.now()` or falls back to `Date.now()`. Essential for accurate performance measurements. ```javascript function r(){return c.exists&&performance.now()?Math.round(performance.now()):(o=Math.max((new Date).getTime(),o))-a}function i(){return o}var o=(new Date).getTime(),a=o,c=t(12);e.exports=r,e.exports.offset=a,e.exports.getLastTimestamp=i ``` -------------------------------- ### Performance Timing Measurement Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-a7fb31186f33c.html Provides a high-resolution timestamp using `performance.now()` or falls back to `Date.now()`. Includes an offset for accurate timing relative to navigation start. ```javascript function r(){return f.exists&&performance.now?Math.round(performance.now()):(o=Math.max((new Date).getTime(),o))-a}function i(){return o}var o=(new Date).getTime(),a=o,f=t(10);e.exports=r,e.exports.offset=a,e.exports.getLastTimestamp=i ``` -------------------------------- ### Get or Set Context Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/pdf.html Retrieves or creates a context object associated with a given object. This is used to maintain state and identity across different parts of the application. ```javascript function r(t,e,n){if(i.call(t,e))return t\[e\];var r=n();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!1}),r}catch(o){}return t\[e\]=r,r}var i=Object.prototype.hasOwnProperty; ``` -------------------------------- ### Wrap Function for Instrumentation Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-ff5e78d0f0a5e.html Wraps a function to enable instrumentation, such as timing execution or capturing errors. It allows for custom start, error, and end event handlers. ```javascript function r(t,e){function n(e,n,r,f,u){function nrWrapper(){var o,a,s,p;try{a=this,o=d(arguments),s="function"==typeof r?r(o,a):r||{}}catch(l){i([l,"",[o,a,f],s],t)}c(n+"start",[o,a,f],s,u);try{return p=e.apply(a,o)}catch(v){throw c(n+"err",[o,a,v],s,u),v}finally{c(n+"end",[o,a,p],s,u)}}return a(e)?e:(n||(n=""),nrWrapper[p]=e,o(e,nrWrapper,t),nrWrapper)}function r(t,e,r,i,o){r||""===r.charAt(0)||(r="");var c,f,u,s="-"===r.charAt(0);for(u=0;u0){var r=n[n.length-1];if(f&&fl.offset&&e<=Date.now()?(e-=l.offset,n.fid=l.now()-e):e=l.now(),y=!0,p("timing",["fi",e,n])}}function c(t){"hidden"===t&&("hidden"===t&&(f=l.now(),p("pageHide",[f])))}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var f,u,s,d,p=t("handle"),l=t("loader"),v=t(9),m=t(3),g=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){u=new PerformanceObserver(r);try{u.observe({entryTypes:["paint"]})}catch(h){}s=new PerformanceObserver(i);try{s.observe({entryTypes:["largest-contentful-paint"]})}catch(h){}d=new PerformanceObserver(o);try{d.observe({type:"layout-shift",buffered:!0})}catch(h){}}if("addEventListener"in document){var y=!1,w=["click","keydown","mousedown","pointerdown","touchstart"];w.forEach(function(t){document.addEventListener(t,a,m(!1))})}v(c)}}},{} ``` -------------------------------- ### Performance Observer for Page Visibility and Timing Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/pdf.html Sets up PerformanceObservers to capture various page performance metrics like First Paint (FP), First Contentful Paint (FCP), Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), and First Input Delay (FID). It also handles page visibility changes. ```javascript if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var f,u,s,d,p=t("handle"),l=t("loader"),v=t(9),m=t(3),g=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){u=new PerformanceObserver(r);try{u.observe({entryTypes:["paint"]})}catch(h){}s=new PerformanceObserver(i);try{s.observe({entryTypes:["largest-contentful-paint"]})}catch(h){}d=new PerformanceObserver(o);try{d.observe({type:"layout-shift",buffered:!0})}catch(h){}}if("addEventListener"in document){var y=!1,w=["click","keydown","mousedown","pointerdown","touchstart"];w.forEach(function(t){document.addEventListener(t,a,m(!1))})}v(c)}} ``` -------------------------------- ### New Relic Interaction API: Get Interaction Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-c3c18bf3bf5c4.html Retrieve the current interaction object. This is useful for chaining methods or accessing interaction properties. ```javascript var currentInteraction = newrelic.interaction.get(); ``` -------------------------------- ### Initialize Annotator Configuration Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/cdn.hypothes.is/hypothesis.html Initializes the annotator configuration by processing script tags and applying settings. ```javascript var v=function(e){for(var s={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r0&&d("lcp",[n[n.length-1]])}function o(t){t.getEntries().forEach(function(t){t.hadRecentInput||d("cls",[t])})}function a(t){if(t instanceof m&&!g){var e=Math.round(t.timeStamp),n={type:t.type};e<=p.now()?n.fid=p.now()-e:e>p.offset&&e<=Date.now()?(e-=p.offset,n.fid=p.now()-e):e=p.now(),g=!0,d("timing",["fi",e,n])}}function f(t){"hidden"===t&&d("pageHide",[p.now()])}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var c,u,s,d=t("handle"),p=t("loader"),l=t(7),m=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){c=new PerformanceObserver(r);try{c.observe({entryTypes:["paint"]})}catch(v){}u=new PerformanceObserver(i);try{u.observe({entryTypes:["largest-contentful-paint"]})}catch(v){}s=new PerformanceObserver(o);try{s.observe({type:"layout-shift",buffered:!0})}catch(v){}}if("addEventListener"in document){var g=!1,h=["click","keydown","mousedown","pointerdown","touchstart"];h.forEach(function(t){document.addEventListener(t,a,!1)})}l(f)} ``` -------------------------------- ### New Relic API Initialization and Interaction Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https.html Sets up various New Relic API functions for tracking page views, custom attributes, errors, and interactions. It also defines methods for creating and managing tracers. ```javascript window.NREUM||(NREUM={}),__nr_require=function(t,e,n){function r(n){if(!e[n]){var i=e[n]={exports:{}};t[n][0].call(i.exports,function(e){var i=t[n][1][e];return r(i||e)},i,i.exports)}return e[n].exports}if("function"==typeof __nr_require)return __nr_require;for(var i=0;i0){var r=n[n.length-1];if(f&&fl.offset&&e<=Date.now()?(e-=l.offset,n.fid=l.now()-e):e=l.now(),y=!0,p("timing",["fi",e,n])}}function c(t){"hidden"===t&&(f=l.now(),p("pageHide",[f]))}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var f,u,s,d,p=t("handle"),l=t("loader"),v=t(9),m=t(3),g=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){u=new PerformanceObserver(r);try{u.observe({entryTypes:["paint"]})}catch(h){}s=new PerformanceObserver(i);try{s.observe({entryTypes:["largest-contentful-paint"]})}catch(h){}d=new PerformanceObserver(o);try{d.observe({type:"layout-shift",buffered:!0})}catch(h){}}if("addEventListener"in document){var y=!1,w=["click","keydown","mousedown","pointerdown","touchstart"];w.forEach(function(t){document.addEventListener(t,a,m(!1))})}v(c)}},{}]},8:[function(t,e,n){function r(t,e){if(!i)return!1;if(t!==i)return!1;if(!e)return!0;if(!o)return!1;for(var n=o.split("."),r=e.split("."),a=0;a3&&void 0!==arguments.length?arguments[3]:{};var r=n.forceModuleReload,a=t.createElement("script");a.type="module",s&&(e+="#ts=".concat(Date.now())),a.src=e,a.async=!1,t.head.appendChild(a)} ``` -------------------------------- ### Hypothesis Client Embed URL Configuration Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/pdf.html Defines the URL for the Hypothesis client's boot script. This is required to load and initialize the Hypothesis annotation functionality. ```javascript // URL of the Hypothesis client's boot script. window.CLIENT_EMBED_URL = "https://hypothes.is/embed.js"; ``` -------------------------------- ### Load Multiple Assets Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/cdn.hypothes.is/hypothesis.html Loads multiple assets (CSS or JS) based on a list of asset keys. Can force module reloads. ```javascript function d(t,e,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};s.forEach((function(s){var n=p(e,s);n.match(/\.css/)?i(t,n):c(t,n,n.forceModuleReload)}))} ``` -------------------------------- ### Modify Manifest File for Windows Path Handling Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/CONTRIBUTING.md Update the manifest.js file to correctly handle relative paths on Windows by replacing backslashes with forward slashes. ```javascript const relativePath = path.relative(manifestDir, file).replace("\\","/"); ``` -------------------------------- ### Load Annotator CSS Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/cdn.hypothes.is/hypothesis.html Loads the main annotator CSS file. This ensures the annotator's styles are applied correctly. ```javascript function i(t,e){var s=t.createElement("link");s.rel="stylesheet",s.type="text/css",s.href=e,t.head.appendChild(s)} ``` -------------------------------- ### New Relic Interaction API: Create Tracer Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-c3c18bf3bf5c4.html Create a tracer for a specific interaction. This allows for detailed timing and error tracking of asynchronous operations within an interaction. ```javascript var tracer = newrelic.interaction().createTracer('my_async_operation'); ``` -------------------------------- ### Create Group Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/hypothes.is/api/index.html Creates a new group on the Hypothes.is platform. ```APIDOC ## POST /api/groups ### Description Create a new group. ### Method POST ### Endpoint https://hypothes.is/api/groups ### Parameters #### Request Body (Not specified in source) ``` -------------------------------- ### Create Annotation Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/hypothes.is/api/index.html Creates a new annotation on the Hypothes.is platform. ```APIDOC ## POST /api/annotations ### Description Creates a new annotation. ### Method POST ### Endpoint https://hypothes.is/api/annotations ### Parameters #### Request Body (Not specified in source) ``` -------------------------------- ### Performance Observer: Layout Shift (CLS) Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-c3c18bf3bf5c4.html Observes 'layout-shift' entries to capture Cumulative Layout Shift (CLS). CLS measures unexpected layout shifts that can negatively impact user experience. ```javascript var clsObserver = new PerformanceObserver(function(entryList) { entryList.getEntries().forEach(function(entry) { if (!entry.hadRecentInput) { newrelic.recordSupportability('cls', [entry]); } }); }); clsObserver.observe({ type: 'layout-shift', buffered: true }); ``` -------------------------------- ### Record Supportability Metric Source: https://github.com/elias-sundqvist/obsidian-annotator/blob/master/resources/via.hypothes.is/https-c3c18bf3bf5c4.html Records a supportability metric, which is used internally by New Relic to track the usage and performance of its own features. ```javascript NREUM.recordSupportability('API/setCustomAttribute/called'); ```