diff --git a/e2e-tests/logseq-api.spec.ts b/e2e-tests/logseq-api.spec.ts
index 69a533cdc..d46e3e171 100644
--- a/e2e-tests/logseq-api.spec.ts
+++ b/e2e-tests/logseq-api.spec.ts
@@ -99,7 +99,33 @@ test('block related apis',
*/
export async function callPageAPI(page, method, ...args) {
return await page.evaluate(([method, args]) => {
+ const hasNs = method.indexOf('.') !== -1
+ const ns = hasNs ? method.split('.') : method
// @ts-ignore
- return window.logseq.api[method]?.(...args)
+ const ctx = hasNs ? window.logseq.sdk[ns[0].toLowerCase()] : window.logseq.api
+ return ctx[hasNs ? ns[1] : method]?.(...args)
}, [method, args])
}
+
+/**
+ * load local tests plugin
+ */
+export async function loadLocalE2eTestsPlugin(page) {
+ const pid = 'a-logseq-plugin-for-e2e-tests'
+ const hasLoaded = await page.evaluate(([pid]) => {
+ // @ts-ignore
+ const p = window.LSPluginCore.registeredPlugins.get(pid)
+ return p != null
+ }, [pid])
+
+ if (hasLoaded) return true
+
+ await callPageAPI(page, 'set_state_from_store',
+ 'ui/developer-mode?', true)
+ await page.keyboard.press('t+p')
+ await page.locator('text=Load unpacked plugin')
+ await callPageAPI(page, 'set_state_from_store',
+ 'plugin/selected-unpacked-pkg', `${__dirname}/plugin`)
+ await page.keyboard.press('Escape')
+ await page.keyboard.press('Escape')
+}
\ No newline at end of file
diff --git a/e2e-tests/plugin/index.html b/e2e-tests/plugin/index.html
new file mode 100644
index 000000000..19efb4b1b
--- /dev/null
+++ b/e2e-tests/plugin/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/e2e-tests/plugin/index.js b/e2e-tests/plugin/index.js
new file mode 100644
index 000000000..6a662e2ce
--- /dev/null
+++ b/e2e-tests/plugin/index.js
@@ -0,0 +1,49 @@
+async function main () {
+ logseq.UI.showMsg('Hi, e2e tests from a local plugin!')
+
+ // await (new Promise(resolve => setTimeout(resolve, 3000)))
+
+ let msg = 0
+
+ const logPane = (input) => {
+ logseq.provideUI({
+ key: `log-${++msg}`,
+ path: `#a-plugin-for-e2e-tests > ul`,
+ template: `${input}`
+ })
+ }
+
+ // log pane
+ logseq.provideUI({
+ key: 'logseq-e2e-tests',
+ template: `
+
Plugin e2e tests ...
+
+
`,
+ path: 'body',
+ style: {
+ width: '300px',
+ position: 'fixed',
+ top: '300px',
+ left: '300px',
+ zIndex: 99,
+ },
+ })
+
+ logseq.provideStyle(`
+ #a-plugin-for-e2e-tests {
+ padding: 20px;
+ background-color: red;
+ color: white;
+ width: 300px;
+ }
+ `)
+
+ // test log
+ setTimeout(() => {
+ logPane(`DB: hook changed`)
+ }, 2000)
+}
+
+// bootstrap
+logseq.ready(main).catch(null)
\ No newline at end of file
diff --git a/e2e-tests/plugin/lsplugin.user.js b/e2e-tests/plugin/lsplugin.user.js
new file mode 100644
index 000000000..a72c65e74
--- /dev/null
+++ b/e2e-tests/plugin/lsplugin.user.js
@@ -0,0 +1,2 @@
+/*! For license information please see lsplugin.user.js.LICENSE.txt */
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LSPluginEntry=t():e.LSPluginEntry=t()}(self,(()=>(()=>{var e={227:(e,t,n)=>{var r=n(155);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(447)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)};var n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map((function(e){return r(e,n)}))}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function a(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach((function(t){o[t]=r(e[t],n)})),i(t).forEach((function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(i,n)(e[i],t[i],n):o[i]=r(t[i],n))})),o}function c(e,n,i){(i=i||{}).arrayMerge=i.arrayMerge||o,i.isMergeableObject=i.isMergeableObject||t,i.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(n);return s===Array.isArray(e)?s?i.arrayMerge(e,n,i):a(e,n,i):r(n,i)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return c(e,n,t)}),{})};var l=c;e.exports=l},856:function(e){e.exports=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,i){return r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(e,o));return r&&t(i,r.prototype),i},r.apply(null,arguments)}function o(e){return i(e)||s(e)||a(e)||l()}function i(e){if(Array.isArray(e))return c(e)}function s(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),o=1;o/gm),V=g(/^data-[\-\w.\u00B7-\uFFFF]/),K=g(/^aria-[\-\w]+$/),Y=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q=g(/^(?:\w+script|data):/i),X=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ee=g(/^html$/i),te=function(){return"undefined"==typeof window?null:window},ne=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,o="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(o)&&(r=n.currentScript.getAttribute(o));var i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function re(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:te(),n=function(e){return re(e)};if(n.version="2.3.8",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,i=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,c=t.Node,l=t.Element,u=t.NodeFilter,f=t.NamedNodeMap,p=void 0===f?t.NamedNodeMap||t.MozNamedAttrMap:f,h=t.HTMLFormElement,d=t.DOMParser,g=t.trustedTypes,y=l.prototype,v=N(y,"cloneNode"),b=N(y,"nextSibling"),_=N(y,"childNodes"),I=N(y,"parentNode");if("function"==typeof a){var M=i.createElement("template");M.content&&M.content.ownerDocument&&(i=M.content.ownerDocument)}var oe=ne(g,r),ie=oe?oe.createHTML(""):"",se=i,ae=se.implementation,ce=se.createNodeIterator,le=se.createDocumentFragment,ue=se.getElementsByTagName,fe=r.importNode,pe={};try{pe=L(i).documentMode?i.documentMode:{}}catch(e){}var he={};n.isSupported="function"==typeof I&&ae&&void 0!==ae.createHTMLDocument&&9!==pe;var de,me,ge=J,ye=Z,ve=V,be=K,_e=Q,we=X,xe=Y,Ce=null,Se=F({},[].concat(o(P),o(R),o(D),o($),o(H))),Oe=null,je=F({},[].concat(o(B),o(q),o(W),o(G))),Ae=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ee=null,ke=null,Te=!0,Ie=!0,Me=!1,Fe=!1,Le=!1,Ne=!1,Pe=!1,Re=!1,De=!1,Ue=!1,$e=!0,ze=!0,He=!1,Be={},qe=null,We=F({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Ge=null,Je=F({},["audio","video","img","source","image","track"]),Ze=null,Ve=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ye="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",Xe=Qe,et=!1,tt=["application/xhtml+xml","text/html"],nt="text/html",rt=null,ot=i.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},st=function(t){rt&&rt===t||(t&&"object"===e(t)||(t={}),t=L(t),Ce="ALLOWED_TAGS"in t?F({},t.ALLOWED_TAGS):Se,Oe="ALLOWED_ATTR"in t?F({},t.ALLOWED_ATTR):je,Ze="ADD_URI_SAFE_ATTR"in t?F(L(Ve),t.ADD_URI_SAFE_ATTR):Ve,Ge="ADD_DATA_URI_TAGS"in t?F(L(Je),t.ADD_DATA_URI_TAGS):Je,qe="FORBID_CONTENTS"in t?F({},t.FORBID_CONTENTS):We,Ee="FORBID_TAGS"in t?F({},t.FORBID_TAGS):{},ke="FORBID_ATTR"in t?F({},t.FORBID_ATTR):{},Be="USE_PROFILES"in t&&t.USE_PROFILES,Te=!1!==t.ALLOW_ARIA_ATTR,Ie=!1!==t.ALLOW_DATA_ATTR,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Fe=t.SAFE_FOR_TEMPLATES||!1,Le=t.WHOLE_DOCUMENT||!1,Re=t.RETURN_DOM||!1,De=t.RETURN_DOM_FRAGMENT||!1,Ue=t.RETURN_TRUSTED_TYPE||!1,Pe=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,ze=!1!==t.KEEP_CONTENT,He=t.IN_PLACE||!1,xe=t.ALLOWED_URI_REGEXP||xe,Xe=t.NAMESPACE||Qe,t.CUSTOM_ELEMENT_HANDLING&&it(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&it(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ae.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),de=de=-1===tt.indexOf(t.PARSER_MEDIA_TYPE)?nt:t.PARSER_MEDIA_TYPE,me="application/xhtml+xml"===de?function(e){return e}:S,Fe&&(Ie=!1),De&&(Re=!0),Be&&(Ce=F({},o(H)),Oe=[],!0===Be.html&&(F(Ce,P),F(Oe,B)),!0===Be.svg&&(F(Ce,R),F(Oe,q),F(Oe,G)),!0===Be.svgFilters&&(F(Ce,D),F(Oe,q),F(Oe,G)),!0===Be.mathMl&&(F(Ce,$),F(Oe,W),F(Oe,G))),t.ADD_TAGS&&(Ce===Se&&(Ce=L(Ce)),F(Ce,t.ADD_TAGS)),t.ADD_ATTR&&(Oe===je&&(Oe=L(Oe)),F(Oe,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&F(Ze,t.ADD_URI_SAFE_ATTR),t.FORBID_CONTENTS&&(qe===We&&(qe=L(qe)),F(qe,t.FORBID_CONTENTS)),ze&&(Ce["#text"]=!0),Le&&F(Ce,["html","head","body"]),Ce.table&&(F(Ce,["tbody"]),delete Ee.tbody),m&&m(t),rt=t)},at=F({},["mi","mo","mn","ms","mtext"]),ct=F({},["foreignobject","desc","title","annotation-xml"]),lt=F({},["title","style","font","a","script"]),ut=F({},R);F(ut,D),F(ut,U);var ft=F({},$);F(ft,z);var pt=function(e){var t=I(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});var n=S(e.tagName),r=S(t.tagName);return e.namespaceURI===Ye?t.namespaceURI===Qe?"svg"===n:t.namespaceURI===Ke?"svg"===n&&("annotation-xml"===r||at[r]):Boolean(ut[n]):e.namespaceURI===Ke?t.namespaceURI===Qe?"math"===n:t.namespaceURI===Ye?"math"===n&&ct[r]:Boolean(ft[n]):e.namespaceURI===Qe&&!(t.namespaceURI===Ye&&!ct[r])&&!(t.namespaceURI===Ke&&!at[r])&&!ft[n]&&(lt[n]||!ut[n])},ht=function(e){C(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},dt=function(e,t){try{C(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){C(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Oe[e])if(Re||De)try{ht(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},mt=function(e){var t,n;if(Pe)e=""+e;else{var r=O(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===de&&(e=''+e+"");var o=oe?oe.createHTML(e):e;if(Xe===Qe)try{t=(new d).parseFromString(o,de)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Xe,"template",null);try{t.documentElement.innerHTML=et?"":o}catch(e){}}var s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),Xe===Qe?ue.call(t,Le?"html":"body")[0]:Le?t.documentElement:s},gt=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},yt=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},vt=function(t){return"object"===e(c)?t instanceof c:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},bt=function(e,t,r){he[e]&&w(he[e],(function(e){e.call(n,t,r,rt)}))},_t=function(e){var t;if(bt("beforeSanitizeElements",e,null),yt(e))return ht(e),!0;if(k(/[\u0080-\uFFFF]/,e.nodeName))return ht(e),!0;var r=me(e.nodeName);if(bt("uponSanitizeElement",e,{tagName:r,allowedTags:Ce}),e.hasChildNodes()&&!vt(e.firstElementChild)&&(!vt(e.content)||!vt(e.content.firstElementChild))&&k(/<[/\w]/g,e.innerHTML)&&k(/<[/\w]/g,e.textContent))return ht(e),!0;if("select"===r&&k(/=0;--s)o.insertBefore(v(i[s],!0),b(e))}return ht(e),!0}return e instanceof l&&!pt(e)?(ht(e),!0):"noscript"!==r&&"noembed"!==r||!k(/<\/no(script|embed)/i,e.innerHTML)?(Fe&&3===e.nodeType&&(t=e.textContent,t=j(t,ge," "),t=j(t,ye," "),e.textContent!==t&&(C(n.removed,{element:e.cloneNode()}),e.textContent=t)),bt("afterSanitizeElements",e,null),!1):(ht(e),!0)},wt=function(e,t,n){if($e&&("id"===t||"name"===t)&&(n in i||n in ot))return!1;if(Ie&&!ke[t]&&k(ve,t));else if(Te&&k(be,t));else if(!Oe[t]||ke[t]){if(!(xt(e)&&(Ae.tagNameCheck instanceof RegExp&&k(Ae.tagNameCheck,e)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(e))&&(Ae.attributeNameCheck instanceof RegExp&&k(Ae.attributeNameCheck,t)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(t))||"is"===t&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&k(Ae.tagNameCheck,n)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))))return!1}else if(Ze[t]);else if(k(xe,j(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==A(n,"data:")||!Ge[e])if(Me&&!k(_e,j(n,we,"")));else if(n)return!1;return!0},xt=function(e){return e.indexOf("-")>0},Ct=function(e){var t,r,o,i;bt("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe};for(i=s.length;i--;){var c=t=s[i],l=c.name,u=c.namespaceURI;if(r="value"===l?t.value:E(t.value),o=me(l),a.attrName=o,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,bt("uponSanitizeAttribute",e,a),r=a.attrValue,!a.forceKeepAttr&&(dt(l,e),a.keepAttr))if(k(/\/>/i,r))dt(l,e);else{Fe&&(r=j(r,ge," "),r=j(r,ye," "));var f=me(e.nodeName);if(wt(f,o,r))try{u?e.setAttributeNS(u,l,r):e.setAttribute(l,r),x(n.removed)}catch(e){}}}bt("afterSanitizeAttributes",e,null)}},St=function e(t){var n,r=gt(t);for(bt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)bt("uponSanitizeShadowNode",n,null),_t(n)||(n.content instanceof s&&e(n.content),Ct(n));bt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(o,i){var a,l,u,f,p;if((et=!o)&&(o="\x3c!--\x3e"),"string"!=typeof o&&!vt(o)){if("function"!=typeof o.toString)throw T("toString is not a function");if("string"!=typeof(o=o.toString()))throw T("dirty is not a string, aborting")}if(!n.isSupported){if("object"===e(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof o)return t.toStaticHTML(o);if(vt(o))return t.toStaticHTML(o.outerHTML)}return o}if(Ne||st(i),n.removed=[],"string"==typeof o&&(He=!1),He){if(o.nodeName){var h=me(o.nodeName);if(!Ce[h]||Ee[h])throw T("root node is forbidden and cannot be sanitized in-place")}}else if(o instanceof c)1===(l=(a=mt("\x3c!----\x3e")).ownerDocument.importNode(o,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!Re&&!Fe&&!Le&&-1===o.indexOf("<"))return oe&&Ue?oe.createHTML(o):o;if(!(a=mt(o)))return Re?null:Ue?ie:""}a&&Pe&&ht(a.firstChild);for(var d=gt(He?o:a);u=d.nextNode();)3===u.nodeType&&u===f||_t(u)||(u.content instanceof s&&St(u.content),Ct(u),f=u);if(f=null,He)return o;if(Re){if(De)for(p=le.call(a.ownerDocument);a.firstChild;)p.appendChild(a.firstChild);else p=a;return Oe.shadowroot&&(p=fe.call(r,p,!0)),p}var m=Le?a.outerHTML:a.innerHTML;return Le&&Ce["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&k(ee,a.ownerDocument.doctype.name)&&(m="\n"+m),Fe&&(m=j(m,ge," "),m=j(m,ye," ")),oe&&Ue?oe.createHTML(m):m},n.setConfig=function(e){st(e),Ne=!0},n.clearConfig=function(){rt=null,Ne=!1},n.isValidAttribute=function(e,t,n){rt||st({});var r=me(e),o=me(t);return wt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(he[e]=he[e]||[],C(he[e],t))},n.removeHook=function(e){if(he[e])return x(he[e])},n.removeHooks=function(e){he[e]&&(he[e]=[])},n.removeAllHooks=function(){he={}},n}return re()}()},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o{"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},824:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},520:(e,t,n)=>{"use strict";var r=n(155),o="win32"===r.platform,i=n(539);function s(e,t){for(var n=[],r=0;r=0&&!e[r];r--);return 0===n&&r===t?e:n>r?[]:e.slice(n,r+1)}var c=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,l=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,u={};function f(e){var t=c.exec(e),n=(t[1]||"")+(t[2]||""),r=t[3]||"",o=l.exec(r);return[n,o[1],o[2],o[3]]}function p(e){var t=c.exec(e),n=t[1]||"",r=!!n&&":"!==n[1];return{device:n,isUnc:r,isAbsolute:r||!!t[2],tail:t[3]}}function h(e){return"\\\\"+e.replace(/^[\\\/]+/,"").replace(/[\\\/]+/g,"\\")}u.resolve=function(){for(var e="",t="",n=!1,o=arguments.length-1;o>=-1;o--){var a;if(o>=0?a=arguments[o]:e?(a=r.env["="+e])&&a.substr(0,3).toLowerCase()===e.toLowerCase()+"\\"||(a=e+"\\"):a=r.cwd(),!i.isString(a))throw new TypeError("Arguments to path.resolve must be strings");if(a){var c=p(a),l=c.device,u=c.isUnc,f=c.isAbsolute,d=c.tail;if((!l||!e||l.toLowerCase()===e.toLowerCase())&&(e||(e=l),n||(t=d+"\\"+t,n=f),e&&n))break}}return u&&(e=h(e)),e+(n?"\\":"")+(t=s(t.split(/[\\\/]+/),!n).join("\\"))||"."},u.normalize=function(e){var t=p(e),n=t.device,r=t.isUnc,o=t.isAbsolute,i=t.tail,a=/[\\\/]$/.test(i);return(i=s(i.split(/[\\\/]+/),!o).join("\\"))||o||(i="."),i&&a&&(i+="\\"),r&&(n=h(n)),n+(o?"\\":"")+i},u.isAbsolute=function(e){return p(e).isAbsolute},u.join=function(){for(var e=[],t=0;t=-1&&!t;n--){var o=n>=0?arguments[n]:r.cwd();if(!i.isString(o))throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,t="/"===o[0])}return(t?"/":"")+(e=s(e.split("/"),!t).join("/"))||"."},m.normalize=function(e){var t=m.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=s(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},m.isAbsolute=function(e){return"/"===e.charAt(0)},m.join=function(){for(var e="",t=0;t{var t,n,r=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var a,c=[],l=!1,u=-1;function f(){l&&a&&(l=!1,a.length?c=a.concat(c):u=-1,c.length&&p())}function p(){if(!l){var e=s(f);l=!0;for(var t=c.length;t;){for(a=c,c=[];++u1)for(var n=1;n{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},539:(e,t,n)=>{var r=n(155),o=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),v(r.showHidden)&&(r.showHidden=!1),v(r.depth)&&(r.depth=2),v(r.colors)&&(r.colors=!1),v(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),u(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function u(e,n,r){if(e.customInspect&&n&&C(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,e);return y(o)||(o=u(e,o,r)),o}var i=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,n);if(i)return i;var s=Object.keys(n),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),x(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(n);if(0===s.length){if(C(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(b(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return e.stylize(Date.prototype.toString.call(n),"date");if(x(n))return f(n)}var l,_="",S=!1,O=["{","}"];(h(n)&&(S=!0,O=["[","]"]),C(n))&&(_=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(_=" "+RegExp.prototype.toString.call(n)),w(n)&&(_=" "+Date.prototype.toUTCString.call(n)),x(n)&&(_=" "+f(n)),0!==s.length||S&&0!=n.length?r<0?b(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),l=S?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(l,_,O)):O[0]+_+O[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,n,r,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),E(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),v(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function y(e){return"string"==typeof e}function v(e){return void 0===e}function b(e){return _(e)&&"[object RegExp]"===S(e)}function _(e){return"object"==typeof e&&null!==e}function w(e){return _(e)&&"[object Date]"===S(e)}function x(e){return _(e)&&("[object Error]"===S(e)||e instanceof Error)}function C(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(i)&&(i=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=h,t.isBoolean=d,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=b,t.isObject=_,t.isDate=w,t.isError=x,t.isFunction=C,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(384);var j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(){var e=new Date,t=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":");return[e.getDate(),j[e.getMonth()],t].join(" ")}function E(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",A(),t.format.apply(t,arguments))},t.inherits=n(717),t._extend=function(e,t){if(!t||!_(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{LSPluginUser:()=>Nr,setupPluginUserInstance:()=>Pr});var e=n(520),t=(n(856),n(996)),o=n.n(t);var i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n(t&&t instanceof Error?e+=`${t.message} ${t.stack}`:e+=t.toString(),e)),`[${this._tag}][${(new Date).toLocaleTimeString()}] `);var i;(this._logs.push([e,o]),n||null!==(r=this._opts)&&void 0!==r&&r.console)&&(null===(i=console)||void 0===i||i["ERROR"===e?"error":"debug"](`${e}: ${o}`));this.emit("change")}clear(){this._logs=[],this.emit("change")}info(...e){this.write("INFO",e)}error(...e){this.write("ERROR",e)}warn(...e){this.write("WARN",e)}setTag(e){this._tag=e}toJSON(){return this._logs}}function y(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=d.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return d.join(e,...t)}}function v(e,t){let n,r,o=!1;const i=t=>n=>{e&&clearTimeout(e),t(n),o=!0},s=new Promise(((o,s)=>{n=i(o),r=i(s),e&&(e=setTimeout((()=>r(new Error(`[deferred timeout] ${t}`))),e))}));return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:r,promise:s,get settled(){return o}}}const b=new Map;window.__injectedUIEffects=b;var _=n(227),w=n.n(_);function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const C="application/x-postmate-v1+json";let S=0;const O={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},j=(e,t)=>("string"!=typeof t||e.origin===t)&&(!!e.data&&(("object"!=typeof e.data||"postmate"in e.data)&&(e.data.type===C&&!!O[e.data.postmate])));class A{constructor(e){x(this,"parent",void 0),x(this,"frame",void 0),x(this,"child",void 0),x(this,"events",{}),x(this,"childOrigin",void 0),x(this,"listener",void 0),this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.listener=e=>{if(!j(e,this.childOrigin))return!1;const{data:t,name:n}=((e||{}).data||{}).value||{};"emit"===e.data.postmate&&n in this.events&&this.events[n].forEach((e=>{e.call(this,t)}))},this.parent.addEventListener("message",this.listener,!1)}get(e,...t){return new Promise(((n,r)=>{const o=++S,i=e=>{e.data.uid===o&&"reply"===e.data.postmate&&(this.parent.removeEventListener("message",i,!1),e.data.error?r(e.data.error):n(e.data.value))};this.parent.addEventListener("message",i,!1),this.child.postMessage({postmate:"request",type:C,property:e,args:t,uid:o},this.childOrigin)}))}call(e,t){this.child.postMessage({postmate:"call",type:C,property:e,data:t},this.childOrigin)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}destroy(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)}}class E{constructor(e){x(this,"model",void 0),x(this,"parent",void 0),x(this,"parentOrigin",void 0),x(this,"child",void 0),this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(e=>{if(!j(e,this.parentOrigin))return;const{property:t,uid:n,data:r,args:o}=e.data;"call"!==e.data.postmate?((e,t,n)=>{const r="function"==typeof e[t]?e[t].apply(null,n):e[t];return Promise.resolve(r)})(this.model,t,o).then((r=>{e.source.postMessage({property:t,postmate:"reply",type:C,uid:n,value:r},e.origin)})).catch((r=>{e.source.postMessage({property:t,postmate:"reply",type:C,uid:n,error:r},e.origin)})):t in this.model&&"function"==typeof this.model[t]&&this.model[t](r)}))}emit(e,t){this.parent.postMessage({postmate:"emit",type:C,value:{name:e,data:t}},this.parentOrigin)}}class k{constructor(e){x(this,"container",void 0),x(this,"parent",void 0),x(this,"frame",void 0),x(this,"child",void 0),x(this,"childOrigin",void 0),x(this,"url",void 0),x(this,"model",void 0),this.container=e.container,this.url=e.url,this.parent=window,this.frame=document.createElement("iframe"),e.id&&(this.frame.id=e.id),e.name&&(this.frame.name=e.name),this.frame.classList.add.apply(this.frame.classList,e.classListArray||[]),this.container.appendChild(this.frame),this.child=this.frame.contentWindow,this.model=e.model||{}}sendHandshake(e){const t=(e=>{const t=document.createElement("a");t.href=e;const n=t.protocol.length>4?t.protocol:window.location.protocol,r=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||`${n}//${r}`})(e=e||this.url);let n,r=0;return new Promise(((o,i)=>{const s=e=>!!j(e,t)&&("handshake-reply"===e.data.postmate?(clearInterval(n),this.parent.removeEventListener("message",s,!1),this.childOrigin=e.origin,o(new A(this))):i("Failed handshake"));this.parent.addEventListener("message",s,!1);const a=()=>{r++,this.child.postMessage({postmate:"handshake",type:C,model:this.model},t),5===r&&clearInterval(n)};this.frame.addEventListener("load",(()=>{a(),n=setInterval(a,500)})),this.frame.src=e}))}destroy(){this.frame.parentNode.removeChild(this.frame)}}x(k,"debug",!1),x(k,"Model",void 0);class T{constructor(e){x(this,"child",void 0),x(this,"model",void 0),x(this,"parent",void 0),x(this,"parentOrigin",void 0),this.child=window,this.model=e,this.parent=this.child.parent}sendHandshakeReply(){return new Promise(((e,t)=>{const n=r=>{if(r.data.postmate){if("handshake"===r.data.postmate){0,this.child.removeEventListener("message",n,!1),r.source.postMessage({postmate:"handshake-reply",type:C},r.origin),this.parentOrigin=r.origin;const t=r.data.model;return t&&Object.keys(t).forEach((e=>{this.model[e]=t[e]})),e(new E(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)}))}}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{importHTML:M,createSandboxContainer:F}=window.QSandbox||{};function L(e,t){return e.startsWith("http")?fetch(e,t):(e=e.replace("file://",""),new Promise((async(t,n)=>{try{const n=await window.apis.doAction(["readFile",e]);t({text:()=>n})}catch(e){console.error(e),n(e)}})))}class N extends(p()){constructor(e){super(),I(this,"_pluginLocal",void 0),I(this,"_frame",void 0),I(this,"_root",void 0),I(this,"_loaded",!1),I(this,"_unmountFns",[]),this._pluginLocal=e,e._dispose((()=>{this._unmount()}))}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:r}=await M(t,{fetch:L});this._mount(n,document.body);const o=F(e,{elementGetter:()=>{var e;return null===(e=this._root)||void 0===e?void 0:e.firstChild}}).instance.proxy;o.__shadow_mode__=!0,o.LSPluginLocal=this._pluginLocal,o.LSPluginShadow=this,o.LSPluginUser=o.logseq=new Nr(this._pluginLocal.toJSON(),this._pluginLocal.caller);const i=await r(o,!0);this._unmountFns.push(i.unmount),this._loaded=!0}_mount(e,t){const n=this._frame=document.createElement("div");n.classList.add("lsp-shadow-sandbox"),n.id=this._pluginLocal.id,this._root=n.attachShadow({mode:"open"}),this._root.innerHTML=`${e}
`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){var e,t;null===(e=this.frame)||void 0===e||null===(t=e.parentNode)||void 0===t||t.removeChild(this.frame)}get loaded(){return this._loaded}get document(){var e;return null===(e=this._root)||void 0===e?void 0:e.firstChild}get frame(){return this._frame}}function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const R=w()("LSPlugin:caller"),D="#await#response#",U="#lspmsg#",$="#lspmsg#error#",z=e=>`#lspmsg#${e}`;class H extends(p()){constructor(e){super(),P(this,"_pluginLocal",void 0),P(this,"_connected",!1),P(this,"_parent",void 0),P(this,"_child",void 0),P(this,"_shadow",void 0),P(this,"_status",void 0),P(this,"_userModel",{}),P(this,"_call",void 0),P(this,"_callUserModel",void 0),P(this,"_debugTag",""),this._pluginLocal=e,e&&(this._debugTag=e.debugTag)}async connectToChild(){if(this._connected)return;const{shadow:e}=this._pluginLocal;e?await this._setupShadowSandbox():await this._setupIframeSandbox()}async connectToParent(e={}){if(this._connected)return;const t=this,n=null!=this._pluginLocal;let r=0,o=0;const i=new Map,s=v(6e4),a=this._extendUserModel({"#lspmsg#ready#":async e=>{a[z(null==e?void 0:e.pid)]=({type:e,payload:n})=>{R(`[host (_call) -> *user] ${this._debugTag}`,e,n),t.emit(e,n)},await s.resolve()},"#lspmsg#beforeunload#":async e=>{const n=v(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},"#lspmsg#settings#":async({type:e,payload:n})=>{t.emit("settings:changed",n)},[U]:async({ns:e,type:n,payload:r})=>{R(`[host (async) -> *user] ${this._debugTag} ns=${e} type=${n}`,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},"#lspmsg#reply#":({_sync:e,result:t})=>{if(R(`[sync host -> *user] #${e}`,t),i.has(e)){const n=i.get(e);n&&(null!=t&&t.hasOwnProperty($)?n.reject(t[$]):n.resolve(t),i.delete(e))}},...e});var c;if(n)return await s.promise,JSON.parse(JSON.stringify(null===(c=this._pluginLocal)||void 0===c?void 0:c.toJSON()));const l=new T(a).sendHandshakeReply();return this._status="pending",await l.then((e=>{this._child=e,this._connected=!0,this._call=async(t,n={},r)=>{if(r){const e=++o;i.set(e,r),n._sync=e,r.setTag(`async call #${e}`),R(`async call #${e}`)}return e.emit(z(a.baseInfo.id),{type:t,payload:n}),null==r?void 0:r.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){R(`[model method] #${e} not existed`)}},r=setInterval((()=>{if(i.size>100)for(const[e,t]of i)t.settled&&i.delete(e)}),18e5)})).finally((()=>{this._status=void 0})),await s.promise,a.baseInfo}async call(e,t={}){var n;return null===(n=this._call)||void 0===n?void 0:n.call(this,e,t)}async callAsync(e,t={}){var n;const r=v(1e4);return null===(n=this._call)||void 0===n?void 0:n.call(this,e,t,r)}async callUserModel(e,...t){var n;return null===(n=this._callUserModel)||void 0===n?void 0:n.apply(this,[e,...t])}async callUserModelAsync(e,...t){var n;return e=`${D}${e}`,null===(n=this._callUserModel)||void 0===n?void 0:n.apply(this,[e,...t])}async _setupIframeSandbox(){const e=this._pluginLocal,t=e.id,n=`${t}_lsp_main`,r=new URL(e.options.entry);r.searchParams.set("__v__",e.options.version);const o=document.querySelector(`#${n}`);o&&o.parentElement.removeChild(o);const i=document.createElement("div");i.classList.add("lsp-iframe-sandbox-container"),i.id=n,i.dataset.pid=t;try{var s;const e=null===(s=await this._pluginLocal._loadLayoutsData())||void 0===s?void 0:s.$$0;if(e){i.dataset.inited_layout="true";let{width:t,height:n,left:r,top:o,vw:s,vh:a}=e;r=Math.max(r,0),r="number"==typeof s?`${Math.min(100*r/s,99)}%`:`${r}px`,o=Math.max(o,45),o="number"==typeof a?`${Math.min(100*o/a,99)}%`:`${o}px`,Object.assign(i.style,{width:t+"px",height:n+"px",left:r,top:o})}}catch(e){console.error("[Restore Layout Error]",e)}document.body.appendChild(i);const a=new k({id:t+"_iframe",container:i,url:r.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let c,l=a.sendHandshake();return this._status="pending",new Promise(((t,n)=>{c=setTimeout((()=>{n(new Error("handshake Timeout")),a.destroy()}),4e3),l.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on(z(e.id),(({type:e,payload:t})=>{var n,r;R("[user -> *host] ",e,t),null===(n=this._pluginLocal)||void 0===n||n.emit(e,t||{}),null===(r=this._pluginLocal)||void 0===r||r.caller.emit(e,t||{})})),this._call=async(...t)=>{await n.call(z(e.id),{type:t[0],payload:Object.assign(t[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,...t)=>{if(e.startsWith(D))return await n.get(e.replace(D,""),...t);n.call(e,null==t?void 0:t[0])},t(null)})).catch((e=>{n(e)})).finally((()=>{clearTimeout(c)}))})).catch((e=>{throw R("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new N(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(t,n={},r)=>{var o;return r&&(n.actor=r),null===(o=this._pluginLocal)||void 0===o||o.emit(t,Object.assign(n,{$$pid:e.id})),null==r?void 0:r.promise},this._callUserModel=async(...e)=>{var t;let n=e[0];null!==(t=n)&&void 0!==t&&t.startsWith(D)&&(n=n.replace(D,""));const r=e[1]||{},o=this._userModel[n];"function"==typeof o&&await o.call(null,r)}}catch(e){throw R("[shadow sandbox] error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){var e;return null===(e=this._parent)||void 0===e?void 0:e.frame.parentNode}_getSandboxShadowContainer(){var e;return null===(e=this._shadow)||void 0===e?void 0:e.frame.parentNode}_getSandboxIframeRoot(){var e;return null===(e=this._parent)||void 0===e?void 0:e.frame}_getSandboxShadowRoot(){var e;return null===(e=this._shadow)||void 0===e?void 0:e.frame}set debugTag(e){this._debugTag=e}async destroy(){var e;let t=null;this._parent&&(t=this._getSandboxIframeContainer(),await this._parent.destroy()),this._shadow&&(t=this._getSandboxShadowContainer(),this._shadow.destroy()),null===(e=t)||void 0===e||e.parentNode.removeChild(t)}}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class q{constructor(e,t){B(this,"ctx",void 0),B(this,"opts",void 0),this.ctx=e,this.opts=t}get ctxId(){return this.ctx.baseInfo.id}setItem(e,t){var n;return this.ctx.caller.callAsync("api:call",{method:"write-plugin-storage-file",args:[this.ctxId,e,t,null===(n=this.opts)||void 0===n?void 0:n.assets]})}getItem(e){var t;return this.ctx.caller.callAsync("api:call",{method:"read-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}removeItem(e){var t;return this.ctx.caller.call("api:call",{method:"unlink-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}allKeys(){var e;return this.ctx.caller.callAsync("api:call",{method:"list-plugin-storage-files",args:[this.ctxId,null===(e=this.opts)||void 0===e?void 0:e.assets]})}clear(){var e;return this.ctx.caller.call("api:call",{method:"clear-plugin-storage-files",args:[this.ctxId,null===(e=this.opts)||void 0===e?void 0:e.assets]})}hasItem(e){var t;return this.ctx.caller.callAsync("api:call",{method:"exist-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}}class W{constructor(e){var t,n,r;r=void 0,(n="ctx")in(t=this)?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,this.ctx=e}get React(){return this.ensureHostScope().React}get ReactDOM(){return this.ensureHostScope().ReactDOM}get pluginLocal(){return this.ensureHostScope().LSPluginCore.ensurePlugin(this.ctx.baseInfo.id)}invokeExperMethod(e,...t){var n,r;const o=this.ensureHostScope();return e=null===(n=m(e))||void 0===n?void 0:n.toLowerCase(),null===(r=o.logseq.api["exper_"+e])||void 0===r?void 0:r.apply(o,t)}async loadScripts(...e){(e=e.map((e=>null!=e&&e.startsWith("http")?e:this.ctx.resolveResourceFullUrl(e)))).unshift(this.ctx.baseInfo.id),await this.invokeExperMethod("loadScripts",...e)}registerFencedCodeRenderer(e,t){return this.ensureHostScope().logseq.api.exper_register_fenced_code_renderer(this.ctx.baseInfo.id,e,t)}registerExtensionsEnhancer(e,t){const n=this.ensureHostScope();if("katex"===e)n.katex&&t(n.katex).catch(console.error);return n.logseq.api.exper_register_extensions_enhancer(this.ctx.baseInfo.id,e,t)}ensureHostScope(){if(window===top)throw new Error("Can not access host scope!");return top}}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const J=e=>`task_callback_${e}`;class Z{constructor(e,t,n={}){G(this,"_client",void 0),G(this,"_requestId",void 0),G(this,"_requestOptions",void 0),G(this,"_promise",void 0),G(this,"_aborted",!1),this._client=e,this._requestId=t,this._requestOptions=n,this._promise=new Promise(((e,t)=>{if(!this._requestId)return t(null);this._client.once(J(this._requestId),(n=>{n&&n instanceof Error?t(n):e(n)}))}));const{success:r,fail:o,final:i}=this._requestOptions;this._promise.then((e=>{null==r||r(e)})).catch((e=>{null==o||o(e)})).finally((()=>{null==i||i()}))}abort(){this._requestOptions.abortable&&!this._aborted&&(this._client.ctx._execCallableAPI("http_request_abort",this._requestId),this._aborted=!0)}get promise(){return this._promise}get client(){return this._client}get requestId(){return this._requestId}}class V extends f.EventEmitter{constructor(e){super(),G(this,"_ctx",void 0),this._ctx=e,this.ctx.caller.on("#lsp#request#callback",(e=>{const t=null==e?void 0:e.requestId;t&&this.emit(J(t),null==e?void 0:e.payload)}))}static createRequestTask(e,t,n){return new Z(e,t,n)}async _request(e){const t=this.ctx.baseInfo.id,{success:n,fail:r,final:o,...i}=e,s=this.ctx.Experiments.invokeExperMethod("request",t,i),a=V.createRequestTask(this.ctx.Request,s,e);return i.abortable?a:a.promise}get ctx(){return this._ctx}}const K=Array.isArray;const Y="object"==typeof global&&global&&global.Object===Object&&global;var Q="object"==typeof self&&self&&self.Object===Object&&self;const X=Y||Q||Function("return this")();const ee=X.Symbol;var te=Object.prototype,ne=te.hasOwnProperty,re=te.toString,oe=ee?ee.toStringTag:void 0;const ie=function(e){var t=ne.call(e,oe),n=e[oe];try{e[oe]=void 0;var r=!0}catch(e){}var o=re.call(e);return r&&(t?e[oe]=n:delete e[oe]),o};var se=Object.prototype.toString;const ae=function(e){return se.call(e)};var ce=ee?ee.toStringTag:void 0;const le=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ce&&ce in Object(e)?ie(e):ae(e)};const ue=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const fe=function(e){if(!ue(e))return!1;var t=le(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const pe=X["__core-js_shared__"];var he,de=(he=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+he:"";const me=function(e){return!!de&&de in e};var ge=Function.prototype.toString;const ye=function(e){if(null!=e){try{return ge.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var ve=/^\[object .+?Constructor\]$/,be=Function.prototype,_e=Object.prototype,we=be.toString,xe=_e.hasOwnProperty,Ce=RegExp("^"+we.call(xe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Se=function(e){return!(!ue(e)||me(e))&&(fe(e)?Ce:ve).test(ye(e))};const Oe=function(e,t){return null==e?void 0:e[t]};const je=function(e,t){var n=Oe(e,t);return Se(n)?n:void 0};const Ae=function(){try{var e=je(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const Ee=function(e,t,n){"__proto__"==t&&Ae?Ae(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n};const ke=function(e){return function(t,n,r){for(var o=-1,i=Object(t),s=r(t),a=s.length;a--;){var c=s[e?a:++o];if(!1===n(i[c],c,i))break}return t}}();const Te=function(e,t){for(var n=-1,r=Array(e);++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var We={};We["[object Float32Array]"]=We["[object Float64Array]"]=We["[object Int8Array]"]=We["[object Int16Array]"]=We["[object Int32Array]"]=We["[object Uint8Array]"]=We["[object Uint8ClampedArray]"]=We["[object Uint16Array]"]=We["[object Uint32Array]"]=!0,We["[object Arguments]"]=We["[object Array]"]=We["[object ArrayBuffer]"]=We["[object Boolean]"]=We["[object DataView]"]=We["[object Date]"]=We["[object Error]"]=We["[object Function]"]=We["[object Map]"]=We["[object Number]"]=We["[object Object]"]=We["[object RegExp]"]=We["[object Set]"]=We["[object String]"]=We["[object WeakMap]"]=!1;const Ge=function(e){return Ie(e)&&qe(e.length)&&!!We[le(e)]};const Je=function(e){return function(t){return e(t)}};var Ze="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ve=Ze&&"object"==typeof module&&module&&!module.nodeType&&module,Ke=Ve&&Ve.exports===Ze&&Y.process,Ye=function(){try{var e=Ve&&Ve.require&&Ve.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}();var Qe=Ye&&Ye.isTypedArray;const Xe=Qe?Je(Qe):Ge;var et=Object.prototype.hasOwnProperty;const tt=function(e,t){var n=K(e),r=!n&&Pe(e),o=!n&&!r&&ze(e),i=!n&&!r&&!o&&Xe(e),s=n||r||o||i,a=s?Te(e.length,String):[],c=a.length;for(var l in e)!t&&!et.call(e,l)||s&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Be(l,c))||a.push(l);return a};var nt=Object.prototype;const rt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||nt)};const ot=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object);var it=Object.prototype.hasOwnProperty;const st=function(e){if(!rt(e))return ot(e);var t=[];for(var n in Object(e))it.call(e,n)&&"constructor"!=n&&t.push(n);return t};const at=function(e){return null!=e&&qe(e.length)&&!fe(e)};const ct=function(e){return at(e)?tt(e):st(e)};const lt=function(e,t){return e&&ke(e,t,ct)};const ut=function(){this.__data__=[],this.size=0};const ft=function(e,t){return e===t||e!=e&&t!=t};const pt=function(e,t){for(var n=e.length;n--;)if(ft(e[n][0],t))return n;return-1};var ht=Array.prototype.splice;const dt=function(e){var t=this.__data__,n=pt(t,e);return!(n<0)&&(n==t.length-1?t.pop():ht.call(t,n,1),--this.size,!0)};const mt=function(e){var t=this.__data__,n=pt(t,e);return n<0?void 0:t[n][1]};const gt=function(e){return pt(this.__data__,e)>-1};const yt=function(e,t){var n=this.__data__,r=pt(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function vt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++ta))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var f=-1,p=!0,h=2&n?new Kt:void 0;for(i.set(e,t),i.set(t,e);++f(K(null==e?void 0:e.blocks)&&(e.blocks=e.blocks.map((e=>e&&yr(e,((e,t)=>`block/${t}`))))),e)},rebuildBlocksIndice:{f:"onIndiceInit",args:["graph","blocks"]},transactBlocks:{f:"onBlocksChanged",args:["graph","data"]},truncateBlocks:{f:"onIndiceReset",args:["graph"]},removeDb:{f:"onGraph",args:["graph"]}}).forEach((([n,r])=>{const o=(e=>`service:search:${e}:${t.name}`)(n);e.caller.on(o,(async n=>{if(fe(null==t?void 0:t[r.f])){let i=null;try{i=await t[r.f].apply(t,(r.args||[]).map((e=>{if(n){if(!0===e)return n;if(n.hasOwnProperty(e)){const t=n[e];return delete n[e],t}}}))),r.transformOutput&&(i=r.transformOutput(i))}catch(e){console.error("[SearchService] ",e),i=e}finally{r.reply&&e.caller.call(`${o}:reply`,i)}}}))}))}}function _r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const wr=Symbol.for("proxy-continue"),xr=w()("LSPlugin:user"),Cr=new g("",{console:!0});function Sr(e,t,n){var r;const{key:o,label:i,desc:s,palette:a,keybinding:c,extras:l}=t;if("function"!=typeof n)return this.logger.error(`${o||i}: command action should be function.`),!1;const u=function(e){if("string"==typeof e)return e.trim().replace(/\s/g,"_").toLowerCase()}(o);if(!u)return this.logger.error(`${i}: command key is required.`),!1;const f=`SimpleCommandHook${u}${++kr}`;this.Editor["on"+f](n),null===(r=this.caller)||void 0===r||r.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:u,label:i,type:e,desc:s,keybinding:c,extras:l},["editor/hook",f]],a]})}function Or(e){return!("string"!=typeof(t=e)||36!==t.length||!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(t))||(Cr.error(`#${e} is not a valid UUID string.`),!1);var t}let jr=null,Ar=new Map;const Er={async getInfo(e){return jr||(jr=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?jr[e]:jr},registerCommand:Sr,registerSearchService(e){if(Ar.has(e.name))throw new Error(`SearchService: #${e.name} has registered!`);Ar.set(e.name,new br(this,e))},registerCommandPalette(e,t){const{key:n,label:r,keybinding:o}=e;return Sr.call(this,"$palette$",{key:n,label:r,palette:!0,keybinding:o},t)},registerCommandShortcut(e,t,n={}){"string"==typeof e&&(e={mode:"global",binding:e});const{binding:r}=e,o="$shortcut$",i=n.key||o+m(null==r?void 0:r.toString());return Sr.call(this,o,{...n,key:i,palette:!1,keybinding:e},t)},registerUIItem(e,t){var n;const r=this.baseInfo.id;null===(n=this.caller)||void 0===n||n.call("api:call",{method:"register-plugin-ui-item",args:[r,e,t]})},registerPageMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;Sr.call(this,"page-menu-item",{key:n,label:r},t)},onBlockRendererSlotted(e,t){if(!Or(e))return;const n=this.baseInfo.id,r=`hook:editor:${m(`slot:${e}`)}`;return this.caller.on(r,t),this.App._installPluginHook(n,r),()=>{this.caller.off(r,t),this.App._uninstallPluginHook(n,r)}},invokeExternalPlugin(e,...t){var n;if(!(e=null===(n=e)||void 0===n?void 0:n.trim()))return;let[r,o]=e.split(".");if(!["models","commands"].includes(null==o?void 0:o.toLowerCase()))throw new Error("Type only support '.models' or '.commands' currently.");const i=e.replace(`${r}.${o}.`,"");if(!r||!o||!i)throw new Error(`Illegal type of #${e} to invoke external plugin.`);return this._execCallableAPIAsync("invoke_external_plugin_cmd",r,o.toLowerCase(),i,t)},setFullScreen(e){const t=(...e)=>this._callWin("setFullScreen",...e);"toggle"===e?this._callWin("isFullScreen").then((e=>{e?t():t(!0)})):e?t(!0):t()}};let kr=0;const Tr={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},registerSlashCommand(e,t){var n;xr("Register slash command #",this.baseInfo.id,e,t),"function"==typeof t&&(t=[["editor/clear-current-slash",!1],["editor/restore-saved-cursor"],["editor/hook",t]]),t=t.map((e=>{const[t,...n]=e;if("editor/hook"===t){let r=n[0],o=()=>{var e;null===(e=this.caller)||void 0===e||e.callUserModel(r)};"function"==typeof r&&(o=r);const i=`SlashCommandHook${t}${++kr}`;e[1]=i,this.Editor["on"+i](o)}return e})),null===(n=this.caller)||void 0===n||n.call("api:call",{method:"register-plugin-slash-command",args:[this.baseInfo.id,[e,t]]})},registerBlockContextMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id;Sr.call(this,"block-context-menu-item",{key:n,label:e},t)},registerHighlightContextMenuItem(e,t,n){if("function"!=typeof t)return!1;const r=e+"_"+this.baseInfo.id;Sr.call(this,"highlight-context-menu-item",{key:r,label:e,extras:n},t)},scrollToBlockInPage(e,t,n){const r="block-content-"+t;null!=n&&n.replaceState?this.App.replaceState("page",{name:e},{anchor:r}):this.App.pushState("page",{name:e},{anchor:r})}},Ir={onBlockChanged(e,t){if(!Or(e))return;const n=this.baseInfo.id,r=`hook:db:${m(`block:${e}`)}`,o=({block:n,txData:r,txMeta:o})=>{n.uuid===e&&t(n,r,o)};return this.caller.on(r,o),this.App._installPluginHook(n,r),()=>{this.caller.off(r,o),this.App._uninstallPluginHook(n,r)}},datascriptQuery(e,...t){if(t.pop(),null!=t&&t.some((e=>"function"==typeof e))){return this.Experiments.ensureHostScope().logseq.api.datascript_query(e,...t)}return this._execCallableAPIAsync("datascript_query",e,...t)}},Mr={},Fr={},Lr={makeSandboxStorage(){return new q(this,{assets:!0})}};class Nr extends(p()){constructor(e,t){super(),_r(this,"_baseInfo",void 0),_r(this,"_caller",void 0),_r(this,"_version","0.0.16"),_r(this,"_debugTag",""),_r(this,"_settingsSchema",void 0),_r(this,"_connected",!1),_r(this,"_ui",new Map),_r(this,"_mFileStorage",void 0),_r(this,"_mRequest",void 0),_r(this,"_mExperiments",void 0),_r(this,"_beforeunloadCallback",void 0),this._baseInfo=e,this._caller=t,t.on("sys:ui:visible",(e=>{null!=e&&e.toggle&&this.toggleMainUI()})),t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign(this._baseInfo.settings,e);this.emit("settings:changed",{...n},t)})),t.on("beforeunload",(async e=>{const{actor:t,...n}=e,r=this._beforeunloadCallback;try{r&&await r(n),null==t||t.resolve(null)}catch(e){this.logger.error("[beforeunload] ",e),null==t||t.reject(e)}}))}async ready(e,t){var n,r;if(!this._connected)try{var i;"function"==typeof e&&(t=e,e={});let s=await this._caller.connectToParent(e);this._connected=!0,n=this._baseInfo,r=s,s=o()(n,r,{arrayMerge:(e,t)=>t}),this._baseInfo=s,null!==(i=s)&&void 0!==i&&i.id&&(this._debugTag=this._caller.debugTag=`#${s.id} [${s.name}]`,this.logger.setTag(this._debugTag)),this._settingsSchema&&(s.settings=function(e,t){const n=(t||[]).reduce(((e,t)=>("default"in t&&(e[t.key]=t.default),e)),{});return Object.assign(n,e)}(s.settings,this._settingsSchema),await this.useSettingsSchema(this._settingsSchema));try{await this._execCallableAPIAsync("setSDKMetadata",{version:this._version})}catch(e){console.warn(e)}t&&t.call(this,s)}catch(e){console.error(`${this._debugTag} [Ready Error]`,e)}}ensureConnected(){if(!this._connected)throw new Error("not connected")}beforeunload(e){"function"==typeof e&&(this._beforeunloadCallback=e)}provideModel(e){return this.caller._extendUserModel(e),this}provideTheme(e){return this.caller.call("provider:theme",e),this}provideStyle(e){return this.caller.call("provider:style",e),this}provideUI(e){return this.caller.call("provider:ui",e),this}useSettingsSchema(e){return this.connected&&this.caller.call("settings:schema",{schema:e,isSync:!0}),this._settingsSchema=e,this}updateSettings(e){this.caller.call("settings:update",e)}onSettingsChanged(e){const t="settings:changed";return this.on(t,e),()=>this.off(t,e)}showSettingsUI(){this.caller.call("settings:visible:changed",{visible:!0})}hideSettingsUI(){this.caller.call("settings:visible:changed",{visible:!1})}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(e){const t={key:0,visible:!1,cursor:null==e?void 0:e.restoreEditingCursor};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}showMainUI(e){const t={key:0,visible:!0,autoFocus:null==e?void 0:e.autoFocus};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}toggleMainUI(){const e=0,t=this._ui.get(e);t&&t.visible?this.hideMainUI():this.showMainUI()}get version(){return this._version}get isMainUIVisible(){const e=this._ui.get(0);return Boolean(e&&e.visible)}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get effect(){return(e=this)&&((null===(t=e.baseInfo)||void 0===t?void 0:t.effect)||!(null!==(n=e.baseInfo)&&void 0!==n&&n.iir));var e,t,n}get logger(){return Cr}get settings(){var e;return null===(e=this.baseInfo)||void 0===e?void 0:e.settings}get caller(){return this._caller}resolveResourceFullUrl(e){if(this.ensureConnected(),e)return e=e.replace(/^[.\\/]+/,""),y(this._baseInfo.lsr,e)}_makeUserProxy(e,t){const n=this,r=this.caller;return new Proxy(e,{get(e,o,i){const s=e[o];return function(...e){if(s){const r=s.apply(n,e.concat(t));if(r!==wr)return r}if(t){const i=o.toString().match(/^(once|off|on)/i);if(null!=i){const o=i[0].toLowerCase(),s=i.input,a="off"===o,c=n.baseInfo.id;let l=s.slice(o.length),u=e[0],f=e[1];"string"==typeof u&&"function"==typeof f&&(u=u.replace(/^logseq./,":"),l=`${l}${u}`,u=f,f=e[2]),l=`hook:${t}:${m(l)}`,r[o](l,u);const p=()=>{r.off(l,u),r.listenerCount(l)||n.App._uninstallPluginHook(c,l)};return a?void p():(n.App._installPluginHook(c,l,f),p)}}let i=o;return["git","ui","assets"].includes(t)&&(i=t+"_"+i),r.callAsync("api:call",{tag:t,method:i,args:e})}}})}_execCallableAPIAsync(e,...t){return this._caller.callAsync("api:call",{method:e,args:t})}_execCallableAPI(e,...t){this._caller.call("api:call",{method:e,args:t})}_callWin(...e){return this._execCallableAPIAsync("_callMainWin",...e)}get App(){return this._makeUserProxy(Er,"app")}get Editor(){return this._makeUserProxy(Tr,"editor")}get DB(){return this._makeUserProxy(Ir,"db")}get Git(){return this._makeUserProxy(Mr,"git")}get UI(){return this._makeUserProxy(Fr,"ui")}get Assets(){return this._makeUserProxy(Lr,"assets")}get FileStorage(){let e=this._mFileStorage;return e||(e=this._mFileStorage=new q(this)),e}get Request(){let e=this._mRequest;return e||(e=this._mRequest=new V(this)),e}get Experiments(){let e=this._mExperiments;return e||(e=this._mExperiments=new W(this)),e}}function Pr(e,t){return new Nr(e,t)}if(null==window.__LSP__HOST__){const e=new H(null);window.logseq=Pr({},e)}})(),r})()));
\ No newline at end of file
diff --git a/e2e-tests/plugin/package.json b/e2e-tests/plugin/package.json
new file mode 100644
index 000000000..13cd517bc
--- /dev/null
+++ b/e2e-tests/plugin/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "e2e-plugin",
+ "description": "A plugin for e2e tests",
+ "main": "./index.html",
+ "logseq": {
+ "id": "a-logseq-plugin-for-e2e-tests"
+ }
+}
\ No newline at end of file
diff --git a/e2e-tests/plugins.spec.ts b/e2e-tests/plugins.spec.ts
index 8011ba55b..c62625d39 100644
--- a/e2e-tests/plugins.spec.ts
+++ b/e2e-tests/plugins.spec.ts
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test'
import { test } from './fixtures'
-import { callPageAPI } from './logseq-api.spec'
+import { callPageAPI, loadLocalE2eTestsPlugin } from './logseq-api.spec'
test.skip('enabled plugin system default', async ({ page }) => {
const callAPI = callPageAPI.bind(null, page)
@@ -60,3 +60,18 @@ test.skip('play a plugin from the Marketplace', async
await expect(page.locator('body[data-page="page"]')).toBeVisible()
})
+test(`play a plugin from local`, async ({ page }) => {
+ const callAPI = callPageAPI.bind(null, page)
+ const _pLoaded = await loadLocalE2eTestsPlugin(page)
+ await callAPI(`ui.show_msg`, 1)
+
+ const loc = page.locator('#a-plugin-for-e2e-tests')
+ await loc.waitFor({state: 'visible'})
+
+ await callAPI(`ui.show_msg`, 1)
+
+ await expect(page.locator('text=DB: hook changed')).toBeVisible()
+
+ // await page.waitForSelector('#test-pause')
+})
+