@logseq/libs
Advanced tools
@@ -115,3 +115,3 @@ import EventEmitter from 'eventemitter3' | ||
| */ | ||
| settings?: LSPluginBaseInfo.settings | ||
| settings?: LSPluginBaseInfo['settings'] | ||
@@ -118,0 +118,0 @@ /** |
| /*! 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,(function(){return(()=>{var e={227:(e,t,n)=>{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 s=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(s++,"%c"===e&&(r=s))})),t.splice(r,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){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("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:s}=e.exports;s.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,r=null;function o(...e){if(!o.enabled)return;const s=o,r=Number(new Date),i=r-(n||r);s.diff=i,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";a++;const o=t.formatters[r];if("function"==typeof o){const t=e[a];n=o.call(s,t),e.splice(a,1),a--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=s,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===r?t.enabled(e):r,set:e=>{r=e}}),"function"==typeof t.init&&t.init(o),o}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),r=s.length;for(n=0;n<r;n++)s[n]&&("-"===(e=s[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,s;for(n=0,s=t.skips.length;n<s;n++)if(t.skips[n].test(e))return!1;for(n=0,s=t.names.length;n<s;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function s(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,s,o,i){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new r(s,o||e,i),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 i(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},a.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,o=s.length,i=new Array(o);r<o;r++)i[r]=s[r].fn;return i},a.prototype.listenerCount=function(e){var t=n?n+e:e,s=this._events[t];return s?s.fn?1:s.length:0},a.prototype.emit=function(e,t,s,r,o,i){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,s),!0;case 4:return u.fn.call(u.context,t,s,r),!0;case 5:return u.fn.call(u.context,t,s,r,o),!0;case 6:return u.fn.call(u.context,t,s,r,o,i),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,s);break;case 4:u[l].fn.call(u[l].context,t,s,r);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,s,r){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return i(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||r&&!a.once||s&&a.context!==s||i(this,o);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||r&&!a[c].once||s&&a[c].context!==s)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:i(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},824:e=>{var t=1e3,n=60*t,s=60*n,r=24*s;function o(e,t,n,s){var r=t>=1.5*n;return Math.round(e/n)+" "+s+(r?"s":"")}e.exports=function(e,i){i=i||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\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(o){var i=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*r;case"hours":case"hour":case"hrs":case"hr":case"h":return i*s;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}}}(e);if("number"===l&&isFinite(e))return i.long?(a=e,(c=Math.abs(a))>=r?o(a,c,r,"day"):c>=s?o(a,c,s,"hour"):c>=n?o(a,c,n,"minute"):c>=t?o(a,c,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=r?Math.round(e/r)+"d":o>=s?Math.round(e/s)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}}},t={};function n(s){if(t[s])return t[s].exports;var r=t[s]={exports:{}};return e[s](r,r.exports,n),r.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 s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},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 s={};return(()=>{"use strict";function e(e){return e===Object(e)&&!Array.isArray(e)}function t(n,...s){if(!s.length)return n;const r=n;if(e(r)){const n=s.length;for(let o=0;o<n;o+=1){const n=s[o];if(e(n))for(const s in n)n.hasOwnProperty(s)&&(e(n[s])?(r[s]&&e(r[s])||(r[s]={}),t(r[s],n[s])):Array.isArray(r[s])&&Array.isArray(n[s])?r[s]=Array.from(new Set(r[s].concat(n[s]))):r[s]=n[s])}}return r}function r(e,t){let n,s,r=!1;const o=t=>n=>{e&&clearTimeout(e),t(n),r=!0},i=new Promise(((r,i)=>{n=o(r),s=o(i),e&&(e=setTimeout((()=>s(new Error(`[deferred timeout] ${t}`))),e))}));return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:s,promise:i,get settled(){return r}}}n.r(s),n.d(s,{LSPluginUser:()=>I,setupPluginUserInstance:()=>j});var o="application/x-postmate-v1+json",i=0,a={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},c=function(e,t){return!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==o||!a[e.data.postmate])},l=function(){function e(e){var t=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(e){if(!c(e,t.childOrigin))return!1;var n=((e||{}).data||{}).value||{},s=n.data,r=n.name;"emit"===e.data.postmate&&r in t.events&&t.events[r].call(t,s)},this.parent.addEventListener("message",this.listener,!1)}var t=e.prototype;return t.get=function(e){var t=this;return new d.Promise((function(n){var s=++i;t.parent.addEventListener("message",(function e(r){r.data.uid===s&&"reply"===r.data.postmate&&(t.parent.removeEventListener("message",e,!1),n(r.data.value))}),!1),t.child.postMessage({postmate:"request",type:o,property:e,uid:s},t.childOrigin)}))},t.call=function(e,t){this.child.postMessage({postmate:"call",type:o,property:e,data:t},this.childOrigin)},t.on=function(e,t){this.events[e]=t},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),u=function(){function e(e){var t=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(function(e){if(c(e,t.parentOrigin)){var n=e.data,s=n.property,r=n.uid,i=n.data;"call"!==e.data.postmate?function(e,t){var n="function"==typeof e[t]?e[t]():e[t];return d.Promise.resolve(n)}(t.model,s).then((function(t){return e.source.postMessage({property:s,postmate:"reply",type:o,uid:r,value:t},e.origin)})):s in t.model&&"function"==typeof t.model[s]&&t.model[s](i)}}))}return e.prototype.emit=function(e,t){this.parent.postMessage({postmate:"emit",type:o,value:{name:e,data:t}},this.parentOrigin)},e}(),d=function(){function e(e){var t=e.container,n=void 0===t?void 0!==n?n:document.body:t,s=e.model,r=e.url,o=e.name,i=e.classListArray,a=void 0===i?[]:i;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=o||"",this.frame.classList.add.apply(this.frame.classList,a),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=s||{},this.sendHandshake(r)}return e.prototype.sendHandshake=function(t){var n,s=this,r=function(e){var t=document.createElement("a");t.href=e;var n=t.protocol.length>4?t.protocol:window.location.protocol,s=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||n+"//"+s}(t),i=0;return new e.Promise((function(e,a){s.parent.addEventListener("message",(function t(o){return!!c(o,r)&&("handshake-reply"===o.data.postmate?(clearInterval(n),s.parent.removeEventListener("message",t,!1),s.childOrigin=o.origin,e(new l(s))):a("Failed handshake"))}),!1);var u=function(){i++,s.child.postMessage({postmate:"handshake",type:o,model:s.model},r),5===i&&clearInterval(n)},d=function(){u(),n=setInterval(u,500)};s.frame.attachEvent?s.frame.attachEvent("onload",d):s.frame.onload=d,s.frame.src=t}))},e}();d.debug=!1,d.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}(),d.Model=function(){function e(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var e=this;return new d.Promise((function(t,n){e.child.addEventListener("message",(function s(r){if(r.data.postmate){if("handshake"===r.data.postmate){e.child.removeEventListener("message",s,!1),r.source.postMessage({postmate:"handshake-reply",type:o},r.origin),e.parentOrigin=r.origin;var i=r.data.model;return i&&Object.keys(i).forEach((function(t){e.model[t]=i[t]})),t(new u(e))}return n("Handshake Reply Failed")}}),!1)}))},e}();const h=d;var p=n(729),f=n.n(p),m=n(227),g=n.n(m);const{importHTML:y,createSandboxContainer:v}=window.QSandbox||{};function C(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 _ extends(f()){constructor(e){super(),this._pluginLocal=e,this._loaded=!1,this._unmountFns=[],e._dispose((()=>{this._unmount()}))}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:s}=await y(t,{fetch:C});this._mount(n,document.body);const r=v(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;r.__shadow_mode__=!0,r.LSPluginLocal=this._pluginLocal,r.LSPluginShadow=this,r.LSPluginUser=r.logseq=new I(this._pluginLocal.toJSON(),this._pluginLocal.caller);const o=await s(r,!0);this._unmountFns.push(o.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=`<div>${e}</div>`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){this.frame?.parentNode?.removeChild(this.frame)}get loaded(){return this._loaded}get document(){return this._root?.firstChild}get frame(){return this._frame}}const w=g()("LSPlugin:caller"),b=e=>`#lspmsg#${e}`;class F extends(f()){constructor(e){super(),this._pluginLocal=e,this._connected=!1,this._userModel={}}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 s=0,o=0;const i=new Map,a=r(),c=this._extendUserModel({"#lspmsg#ready#":async()=>{await a.resolve()},"#lspmsg#settings#":async({type:e,payload:n})=>{t.emit("settings:changed",n)},"#lspmsg#":async({ns:e,type:n,payload:s})=>{w(`[call from host #${this._pluginLocal?.id}]`,e,n,s),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,s):t.emit(n,s)},"#lspmsg#reply#":({_sync:e,result:t})=>{w(`sync reply #${e}`,t),i.has(e)&&(i.get(e)?.resolve(t),i.delete(e))},...e});if(n)return await a.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const l=new h.Model(c);return this._status="pending",await l.then((e=>{this._child=e,this._connected=!0,this._call=async(t,n={},s)=>{if(s){const e=++o;i.set(e,s),n._sync=e,s.setTag(`async call #${e}`),w("async call #",e)}return e.emit(b(c.baseInfo.id),{type:t,payload:n}),s?.promise},s=setInterval((()=>{if(i.size>100)for(const[e,t]of i)t.settled&&i.delete(e)}),18e5)})).finally((()=>{this._status=void 0})),await a.promise,c.baseInfo}async call(e,t={}){return this.emit(e,t),this._call?.call(this,e,t)}async callAsync(e,t={}){const n=r(1e4);return this._call?.call(this,e,t,n)}async callUserModel(e,t={}){return this._callUserModel?.call(this,e,t)}async _setupIframeSandbox(){const e=this._pluginLocal,t=new h({container:document.body,url:e.options.entry,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let n;return this._status="pending",new Promise(((s,r)=>{n=setTimeout((()=>{r(new Error("handshake Timeout"))}),3e3),t.then((t=>{this._parent=t,this._connected=!0,this.emit("connected"),t.frame.setAttribute("id",e.id),t.on(b(e.id),(({type:e,payload:t})=>{w("[call from plugin] ",e,t),this._pluginLocal?.emit(e,t||{})})),this._call=async(...n)=>{await t.call(b(e.id),{type:n[0],payload:n[1]||{}})},this._callUserModel=async(...e)=>{await t.call(e[0],e[1]||{})},s(null)})).catch((e=>{r(e)})).finally((()=>{clearTimeout(n)}))})).catch((e=>{throw w("iframe sandbox error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new _(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(e,t={},n)=>(n&&(t.actor=n),this._pluginLocal?.emit(e,t),n?.promise),this._callUserModel=async(...e)=>{const t=e[0],n=e[1]||{},s=this._userModel[t];"function"==typeof s&&await s.call(null,n)}}catch(e){throw w("shadow sandbox error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame}_getSandboxShadowContainer(){return this._shadow?.frame}async destroy(){this._parent&&await this._parent.destroy(),this._shadow&&this._shadow.destroy()}}var x=function(){return(x=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function L(e){return e.toLowerCase()}Object.create,Object.create;var S=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],O=/[^A-Z0-9]+/gi;function k(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}const M=g()("LSPlugin:user"),P={},A={},E={};class I extends(f()){constructor(e,t){super(),this._baseInfo=e,this._caller=t,this._connected=!1,this._ui=new Map,t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign(this._baseInfo.settings,e);this.emit("settings:changed",n,t)}))}async ready(e,n){if(!this._connected)try{"function"==typeof e&&(n=e,e={});let s=await this._caller.connectToParent(e);s=t(this._baseInfo,s),this._connected=!0,n&&n.call(this,s)}catch(e){console.error("[LSPlugin Ready Error]",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}updateSettings(e){this.caller.call("settings:update",e)}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(){const e={key:0,visible:!1};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}showMainUI(){const e={key:0,visible:!0};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}toggleMainUI(){const e=this._ui.get(0);e&&e.visible?this.hideMainUI():this.showMainUI()}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get settings(){return this.baseInfo?.settings}get caller(){return this._caller}_makeUserProxy(e,t){const n=this.caller;return new Proxy(e,{get(e,s,r){const o=e[s];return function(...e){if(o&&o.apply(this,e),t){const o=s.toString().match(/^(once|off|on)/i);if(null!=o){const s=o[0],a=o.input.slice(s.length);return void n[s.toLowerCase()](`hook:${t}:${r=a,void 0===i&&(i={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,s=void 0===n?S:n,r=t.stripRegexp,o=void 0===r?O:r,i=t.transform,a=void 0===i?L:i,c=t.delimiter,l=void 0===c?" ":c,u=k(k(e,s,"$1\0$2"),o,"\0"),d=0,h=u.length;"\0"===u.charAt(d);)d++;for(;"\0"===u.charAt(h-1);)h--;return u.slice(d,h).split("\0").map(a).join(l)}(e,x({delimiter:"."},t))}(r,x({delimiter:"_"},i))}`,e[0])}}var r,i;return n.callAsync("api:call",{method:s,args:e})}}})}get App(){return this._makeUserProxy(P,"app")}get Editor(){return this._makeUserProxy(A,"editor")}get DB(){return this._makeUserProxy(E)}}function j(e,t){return new I(e,t)}if(null==window.__LSP__HOST__){M("Entry of iframe mode.");const e=new F(null);window.logseq=j({},e)}})(),s})()})); | ||
| !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,(function(){return(()=>{var e={227:(e,t,n)=>{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 s=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(s++,"%c"===e&&(r=s))})),t.splice(r,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){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("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:s}=e.exports;s.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,r=null;function o(...e){if(!o.enabled)return;const s=o,r=Number(new Date),i=r-(n||r);s.diff=i,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";a++;const o=t.formatters[r];if("function"==typeof o){const t=e[a];n=o.call(s,t),e.splice(a,1),a--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=s,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===r?t.enabled(e):r,set:e=>{r=e}}),"function"==typeof t.init&&t.init(o),o}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),r=s.length;for(n=0;n<r;n++)s[n]&&("-"===(e=s[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,s;for(n=0,s=t.skips.length;n<s;n++)if(t.skips[n].test(e))return!1;for(n=0,s=t.names.length;n<s;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function s(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,s,o,i){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new r(s,o||e,i),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 i(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},a.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,o=s.length,i=new Array(o);r<o;r++)i[r]=s[r].fn;return i},a.prototype.listenerCount=function(e){var t=n?n+e:e,s=this._events[t];return s?s.fn?1:s.length:0},a.prototype.emit=function(e,t,s,r,o,i){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,s),!0;case 4:return u.fn.call(u.context,t,s,r),!0;case 5:return u.fn.call(u.context,t,s,r,o),!0;case 6:return u.fn.call(u.context,t,s,r,o,i),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,s);break;case 4:u[l].fn.call(u[l].context,t,s,r);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,s,r){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return i(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||r&&!a.once||s&&a.context!==s||i(this,o);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||r&&!a[c].once||s&&a[c].context!==s)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:i(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},824:e=>{var t=1e3,n=60*t,s=60*n,r=24*s;function o(e,t,n,s){var r=t>=1.5*n;return Math.round(e/n)+" "+s+(r?"s":"")}e.exports=function(e,i){i=i||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\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(o){var i=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*r;case"hours":case"hour":case"hrs":case"hr":case"h":return i*s;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}}}(e);if("number"===l&&isFinite(e))return i.long?(a=e,(c=Math.abs(a))>=r?o(a,c,r,"day"):c>=s?o(a,c,s,"hour"):c>=n?o(a,c,n,"minute"):c>=t?o(a,c,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=r?Math.round(e/r)+"d":o>=s?Math.round(e/s)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}}},t={};function n(s){if(t[s])return t[s].exports;var r=t[s]={exports:{}};return e[s](r,r.exports,n),r.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 s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},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 s={};return(()=>{"use strict";function e(e){return e===Object(e)&&!Array.isArray(e)}function t(n,...s){if(!s.length)return n;const r=n;if(e(r)){const n=s.length;for(let o=0;o<n;o+=1){const n=s[o];if(e(n))for(const s in n)n.hasOwnProperty(s)&&(e(n[s])?(r[s]&&e(r[s])||(r[s]={}),t(r[s],n[s])):Array.isArray(r[s])&&Array.isArray(n[s])?r[s]=Array.from(new Set(r[s].concat(n[s]))):r[s]=n[s])}}return r}function r(e,t){let n,s,r=!1;const o=t=>n=>{e&&clearTimeout(e),t(n),r=!0},i=new Promise(((r,i)=>{n=o(r),s=o(i),e&&(e=setTimeout((()=>s(new Error(`[deferred timeout] ${t}`))),e))}));return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:s,promise:i,get settled(){return r}}}n.r(s),n.d(s,{LSPluginUser:()=>I,setupPluginUserInstance:()=>j});var o="application/x-postmate-v1+json",i=0,a={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},c=function(e,t){return!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==o||!a[e.data.postmate])},l=function(){function e(e){var t=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(e){if(!c(e,t.childOrigin))return!1;var n=((e||{}).data||{}).value||{},s=n.data,r=n.name;"emit"===e.data.postmate&&r in t.events&&t.events[r].call(t,s)},this.parent.addEventListener("message",this.listener,!1)}var t=e.prototype;return t.get=function(e){var t=this;return new d.Promise((function(n){var s=++i;t.parent.addEventListener("message",(function e(r){r.data.uid===s&&"reply"===r.data.postmate&&(t.parent.removeEventListener("message",e,!1),n(r.data.value))}),!1),t.child.postMessage({postmate:"request",type:o,property:e,uid:s},t.childOrigin)}))},t.call=function(e,t){this.child.postMessage({postmate:"call",type:o,property:e,data:t},this.childOrigin)},t.on=function(e,t){this.events[e]=t},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),u=function(){function e(e){var t=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(function(e){if(c(e,t.parentOrigin)){var n=e.data,s=n.property,r=n.uid,i=n.data;"call"!==e.data.postmate?function(e,t){var n="function"==typeof e[t]?e[t]():e[t];return d.Promise.resolve(n)}(t.model,s).then((function(t){return e.source.postMessage({property:s,postmate:"reply",type:o,uid:r,value:t},e.origin)})):s in t.model&&"function"==typeof t.model[s]&&t.model[s](i)}}))}return e.prototype.emit=function(e,t){this.parent.postMessage({postmate:"emit",type:o,value:{name:e,data:t}},this.parentOrigin)},e}(),d=function(){function e(e){var t=e.container,n=void 0===t?void 0!==n?n:document.body:t,s=e.model,r=e.url,o=e.name,i=e.classListArray,a=void 0===i?[]:i;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=o||"",this.frame.classList.add.apply(this.frame.classList,a),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=s||{},this.sendHandshake(r)}return e.prototype.sendHandshake=function(t){var n,s=this,r=function(e){var t=document.createElement("a");t.href=e;var n=t.protocol.length>4?t.protocol:window.location.protocol,s=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||n+"//"+s}(t),i=0;return new e.Promise((function(e,a){s.parent.addEventListener("message",(function t(o){return!!c(o,r)&&("handshake-reply"===o.data.postmate?(clearInterval(n),s.parent.removeEventListener("message",t,!1),s.childOrigin=o.origin,e(new l(s))):a("Failed handshake"))}),!1);var u=function(){i++,s.child.postMessage({postmate:"handshake",type:o,model:s.model},r),5===i&&clearInterval(n)},d=function(){u(),n=setInterval(u,500)};s.frame.attachEvent?s.frame.attachEvent("onload",d):s.frame.onload=d,s.frame.src=t}))},e}();d.debug=!1,d.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}(),d.Model=function(){function e(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var e=this;return new d.Promise((function(t,n){e.child.addEventListener("message",(function s(r){if(r.data.postmate){if("handshake"===r.data.postmate){e.child.removeEventListener("message",s,!1),r.source.postMessage({postmate:"handshake-reply",type:o},r.origin),e.parentOrigin=r.origin;var i=r.data.model;return i&&Object.keys(i).forEach((function(t){e.model[t]=i[t]})),t(new u(e))}return n("Handshake Reply Failed")}}),!1)}))},e}();const h=d;var p=n(729),f=n.n(p),m=n(227),g=n.n(m);const{importHTML:y,createSandboxContainer:v}=window.QSandbox||{};function C(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 _ extends(f()){constructor(e){super(),this._pluginLocal=e,this._loaded=!1,this._unmountFns=[],e._dispose((()=>{this._unmount()}))}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:s}=await y(t,{fetch:C});this._mount(n,document.body);const r=v(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;r.__shadow_mode__=!0,r.LSPluginLocal=this._pluginLocal,r.LSPluginShadow=this,r.LSPluginUser=r.logseq=new I(this._pluginLocal.toJSON(),this._pluginLocal.caller);const o=await s(r,!0);this._unmountFns.push(o.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=`<div>${e}</div>`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){this.frame?.parentNode?.removeChild(this.frame)}get loaded(){return this._loaded}get document(){return this._root?.firstChild}get frame(){return this._frame}}const w=g()("LSPlugin:caller"),b=e=>`#lspmsg#${e}`;class F extends(f()){constructor(e){super(),this._pluginLocal=e,this._connected=!1,this._userModel={}}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 s=0,o=0;const i=new Map,a=r(),c=this._extendUserModel({"#lspmsg#ready#":async()=>{await a.resolve()},"#lspmsg#settings#":async({type:e,payload:n})=>{t.emit("settings:changed",n)},"#lspmsg#":async({ns:e,type:n,payload:s})=>{w(`[call from host #${this._pluginLocal?.id}]`,e,n,s),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,s):t.emit(n,s)},"#lspmsg#reply#":({_sync:e,result:t})=>{w(`sync reply #${e}`,t),i.has(e)&&(i.get(e)?.resolve(t),i.delete(e))},...e});if(n)return await a.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const l=new h.Model(c);return this._status="pending",await l.then((e=>{this._child=e,this._connected=!0,this._call=async(t,n={},s)=>{if(s){const e=++o;i.set(e,s),n._sync=e,s.setTag(`async call #${e}`),w("async call #",e)}return e.emit(b(c.baseInfo.id),{type:t,payload:n}),s?.promise},s=setInterval((()=>{if(i.size>100)for(const[e,t]of i)t.settled&&i.delete(e)}),18e5)})).finally((()=>{this._status=void 0})),await a.promise,c.baseInfo}async call(e,t={}){return this.emit(e,t),this._call?.call(this,e,t)}async callAsync(e,t={}){const n=r(1e4);return this._call?.call(this,e,t,n)}async callUserModel(e,t={}){return this._callUserModel?.call(this,e,t)}async _setupIframeSandbox(){const e=this._pluginLocal,t=new h({container:document.body,url:e.options.entry,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let n;return this._status="pending",new Promise(((s,r)=>{n=setTimeout((()=>{r(new Error("handshake Timeout"))}),3e3),t.then((t=>{this._parent=t,this._connected=!0,this.emit("connected"),t.frame.setAttribute("id",e.id),t.on(b(e.id),(({type:e,payload:t})=>{w("[call from plugin] ",e,t),this._pluginLocal?.emit(e,t||{})})),this._call=async(...n)=>{await t.call(b(e.id),{type:n[0],payload:n[1]||{}})},this._callUserModel=async(...e)=>{await t.call(e[0],e[1]||{})},s(null)})).catch((e=>{r(e)})).finally((()=>{clearTimeout(n)}))})).catch((e=>{throw w("iframe sandbox error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new _(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(e,t={},n)=>(n&&(t.actor=n),this._pluginLocal?.emit(e,t),n?.promise),this._callUserModel=async(...e)=>{const t=e[0],n=e[1]||{},s=this._userModel[t];"function"==typeof s&&await s.call(null,n)}}catch(e){throw w("shadow sandbox error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame}_getSandboxShadowContainer(){return this._shadow?.frame}async destroy(){this._parent&&await this._parent.destroy(),this._shadow&&this._shadow.destroy()}}var x=function(){return(x=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function L(e){return e.toLowerCase()}Object.create,Object.create;var S=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],O=/[^A-Z0-9]+/gi;function k(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}const M=g()("LSPlugin:user"),P={},A={},E={};class I extends(f()){constructor(e,t){super(),this._baseInfo=e,this._caller=t,this._connected=!1,this._ui=new Map,t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign({},this._baseInfo.settings,e);this.emit("settings:changed",n,t)}))}async ready(e,n){if(!this._connected)try{"function"==typeof e&&(n=e,e={});let s=await this._caller.connectToParent(e);s=t(this._baseInfo,s),this._connected=!0,n&&n.call(this,s)}catch(e){console.error("[LSPlugin Ready Error]",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}updateSettings(e){this.caller.call("settings:update",e)}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(){const e={key:0,visible:!1};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}showMainUI(){const e={key:0,visible:!0};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}toggleMainUI(){const e=this._ui.get(0);e&&e.visible?this.hideMainUI():this.showMainUI()}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get settings(){return this.baseInfo?.settings}get caller(){return this._caller}_makeUserProxy(e,t){const n=this.caller;return new Proxy(e,{get(e,s,r){const o=e[s];return function(...e){if(o&&o.apply(this,e),t){const o=s.toString().match(/^(once|off|on)/i);if(null!=o){const s=o[0],a=o.input.slice(s.length);return void n[s.toLowerCase()](`hook:${t}:${r=a,void 0===i&&(i={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,s=void 0===n?S:n,r=t.stripRegexp,o=void 0===r?O:r,i=t.transform,a=void 0===i?L:i,c=t.delimiter,l=void 0===c?" ":c,u=k(k(e,s,"$1\0$2"),o,"\0"),d=0,h=u.length;"\0"===u.charAt(d);)d++;for(;"\0"===u.charAt(h-1);)h--;return u.slice(d,h).split("\0").map(a).join(l)}(e,x({delimiter:"."},t))}(r,x({delimiter:"_"},i))}`,e[0])}}var r,i;return n.callAsync("api:call",{method:s,args:e})}}})}get App(){return this._makeUserProxy(P,"app")}get Editor(){return this._makeUserProxy(A,"editor")}get DB(){return this._makeUserProxy(E)}}function j(e,t){return new I(e,t)}if(null==window.__LSP__HOST__){M("Entry of iframe mode.");const e=new F(null);window.logseq=j({},e)}})(),s})()})); |
+1
-1
| { | ||
| "name": "@logseq/libs", | ||
| "version": "0.0.1-alpha.2", | ||
| "version": "0.0.1-alpha.3", | ||
| "description": "Logseq SDK libraries", | ||
@@ -5,0 +5,0 @@ "main": "dist/lsplugin.user.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
42920
0.01%