@weaveui/web 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -12
- package/README.md +15 -18
- package/THIRD_PARTY_NOTICES +2 -2
- package/dist/index.d.ts +440 -333
- package/dist/index.es.js +18408 -2694
- package/dist/index.umd.cjs +176 -6
- package/dist/style.css +1 -1
- package/package.json +11 -30
- package/dist/apm-log.es.js +0 -996
- package/dist/apm-log.umd.cjs +0 -1
- package/dist/business/apm-log/behavior-directive.d.ts +0 -9
- package/dist/business/apm-log/behavior-log.d.ts +0 -6
- package/dist/business/apm-log/behavior-types.d.ts +0 -121
- package/dist/business/apm-log/browser.d.ts +0 -3
- package/dist/business/apm-log/directive.d.ts +0 -13
- package/dist/business/apm-log/index.d.ts +0 -8
- package/dist/business/apm-log/legacy-apm-log.d.ts +0 -6
- package/dist/business/apm-log/types.d.ts +0 -147
- package/dist/business/apm-log/vue.d.ts +0 -5
- package/dist/business/monitor/index.d.ts +0 -81
- package/dist/business/monitor/monitor-plugin.d.ts +0 -9
- package/dist/business/monitor/runtime-types.d.ts +0 -166
- package/dist/business/monitor/runtime.d.ts +0 -6
- package/dist/business/monitor/types.d.ts +0 -221
- package/dist/business/permission/Permission.d.ts +0 -18
- package/dist/business/permission/PermissionPluginClass.d.ts +0 -40
- package/dist/business/permission/directive.d.ts +0 -7
- package/dist/business/permission/index.d.ts +0 -35
- package/dist/business/permission/permission-plugin.d.ts +0 -16
- package/dist/business/permission/storage.d.ts +0 -30
- package/dist/business/permission/tree.d.ts +0 -19
- package/dist/business/permission/types.d.ts +0 -115
- package/dist/business/upload-cos/index.d.ts +0 -117
- package/dist/business/upload-cos/src/UploadCos.vue.d.ts +0 -70
- package/dist/business/upload-cos/src/types.d.ts +0 -72
- package/dist/business/upload-cos/src/utils.d.ts +0 -9
- package/dist/monitor.es.js +0 -1217
- package/dist/monitor.umd.cjs +0 -1
- package/dist/permission.es.js +0 -631
- package/dist/permission.umd.cjs +0 -1
- package/dist/upload-cos.es.js +0 -426
- package/dist/upload-cos.style.css +0 -1
- package/dist/upload-cos.umd.cjs +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/is.d.ts +0 -2
- package/dist/utils/withInstall.d.ts +0 -7
package/dist/monitor.umd.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(l,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(l=typeof globalThis<"u"?globalThis:l||self,d(l.ElementCustomUIMonitor={}))})(this,function(l){"use strict";var ut=Object.defineProperty;var ht=(l,d,g)=>d in l?ut(l,d,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[d]=g;var o=(l,d,g)=>ht(l,typeof d!="symbol"?d+"":d,g);const d="element-custom-ui",g={fetch:!1,xhr:!1,includeSuccessful:!1},O="[REDACTED]",v=()=>{};function C(r){return typeof r=="object"&&r!==null}function E(r){return typeof URL<"u"&&r instanceof URL}function y(r){if(typeof r=="string")return r;if(r===null)return"null";if(r===void 0)return"undefined";if(r instanceof Error)return r.message||r.name;try{const t=JSON.stringify(r);if(typeof t=="string")return t}catch{}try{return String(r)}catch{return"Unknown error"}}function S(r){return typeof r=="number"&&Number.isFinite(r)?r:void 0}function U(r){return(r==null?void 0:r.trim().toUpperCase())||"GET"}function F(){return typeof window>"u"?void 0:window}function m(r){var e;const t=(e=r.performance)==null?void 0:e.now;return typeof t=="function"?t.call(r.performance):Date.now()}function k(r,t){try{return new URL(r,t.location.href).href}catch{return r}}function W(r,t){return typeof r=="string"?k(r,t):E(r)?r.href:r.url}function H(r,t){return t!=null&&t.method?U(t.method):typeof r=="string"||E(r)?"GET":U(r.method)}function j(r,t){return typeof t=="string"?r.toLowerCase()===t.toLowerCase():(t.lastIndex=0,t.test(r))}function M(r,t){return(t==null?void 0:t.some(e=>j(r,e)))??!1}function z(r,t){if(!t.startsWith("/"))return r.includes(t);try{const e=new URL(r,`https://${d}.invalid`),n=`${e.pathname}${e.search}`;return t.includes("?")?n===t:e.pathname===t}catch{return r.includes(t)}}function R(r){return r.XMLHttpRequest}function D(r){if(!r||!C(r))return;const t=typeof r.tagName=="string"?r.tagName.toLowerCase():"",e=typeof r.currentSrc=="string"?r.currentSrc:typeof r.src=="string"?r.src:typeof r.href=="string"?r.href:"";return t&&e?{element:t,url:e}:void 0}function A(r){if(r instanceof Error)return{name:r.name||"Error",message:r.message||r.name||"Unknown error",...r.stack?{stack:r.stack}:{}};if(C(r)){const t=typeof r.name=="string"?r.name:"Error",e=typeof r.message=="string"?r.message:y(r),n=typeof r.stack=="string"?r.stack:void 0;return{name:t,message:e,...n?{stack:n}:{}}}return{name:"Error",message:y(r)}}function B(r={}){return new _(r)}class _{constructor(t){o(this,"active",!1);o(this,"destroyed",!1);o(this,"recorderActive",!1);o(this,"lastNavigationUrl","");o(this,"browserCleanups",[]);o(this,"vueCleanups",[]);o(this,"installedVueApps",new WeakSet);o(this,"start",()=>{if(this.destroyed||this.active)return!1;const t=this.getBrowserWindow();if(!t)return!1;this.active=!0,this.lastNavigationUrl=t.location.href;try{if((this.shouldCaptureGlobalErrors()||this.shouldCaptureResourceErrors())&&this.installErrorListener(t),this.shouldCaptureUnhandledRejections()&&this.installUnhandledRejectionListener(t),this.shouldCaptureNavigation()&&this.installNavigationListeners(t),this.shouldCapturePerformance()&&this.installPerformanceListener(t),this.requiresInstrumentationHub()){const e=L(t).subscribe(this);this.browserCleanups.push(e)}return this.startRecorder(),!0}catch{return this.active=!1,this.runBrowserCleanups(),this.stopRecorder(),!1}});o(this,"stop",()=>{this.active&&(this.active=!1,this.runBrowserCleanups(),this.stopRecorder())});o(this,"destroy",()=>{if(!this.destroyed){this.stop(),this.destroyed=!0;for(const t of this.vueCleanups.splice(0).reverse())this.runSafely(t)}});o(this,"captureException",(t,e)=>{this.captureExceptionFromSource(t,"manual",e)});o(this,"captureMessage",(t,e="info",n)=>{this.emit({type:"message",level:e,timestamp:this.getTimestamp(),url:this.getCurrentUrl(),context:this.getContext(n),tags:this.getTags(),data:{message:t}})});o(this,"createVuePlugin",(t={})=>({install:e=>{if(this.destroyed||this.installedVueApps.has(e))return;this.installedVueApps.add(e);const n=e.config.errorHandler,i=this,s=(a,c,h)=>{i.captureExceptionFromSource(a,"vue",{vue:{component:(c==null?void 0:c.$options.name)??(c==null?void 0:c.$options.__name)??"anonymous",info:h}}),n==null||n(a,c,h)};e.config.errorHandler=s,this.vueCleanups.push(()=>{e.config.errorHandler===s&&(e.config.errorHandler=n)}),t.startOnInstall===!0&&this.start()}}));o(this,"needsFetchInstrumentation",()=>this.active&&this.getRequestOptions().fetch);o(this,"needsXhrInstrumentation",()=>this.active&&this.getRequestOptions().xhr);o(this,"needsHistoryInstrumentation",()=>this.active&&this.shouldCaptureNavigation());o(this,"shouldMonitorRequest",(t,e)=>{const n=this.getRequestOptions(),i=t==="fetch"?n.fetch:n.xhr;return this.active&&i&&!this.isIgnoredUrl(e)});o(this,"handleInstrumentedRequest",t=>{if(!this.active||this.isIgnoredUrl(t.url))return;const e=this.getRequestOptions(),n=e.slowThreshold!==void 0&&t.duration>=e.slowThreshold;(e.includeSuccessful||!t.ok||n)&&this.emit({type:"request",level:t.ok?"info":"error",timestamp:this.getTimestamp(),url:this.getCurrentUrl(),context:this.getContext(),tags:this.getTags(),data:t})});o(this,"handleInstrumentedNavigation",t=>{!this.active||!this.shouldCaptureNavigation()||(this.lastNavigationUrl=t.to,this.emit({type:"navigation",level:"info",timestamp:this.getTimestamp(),url:t.to,context:this.getContext(),tags:this.getTags(),data:t}))});this.options=t}get started(){return this.active}getBrowserWindow(){return this.options.window??F()}createTransportContext(){return{fetch:(t,e)=>this.fetchForTransport(t,e),createXMLHttpRequest:()=>this.createXhrForTransport()}}fetchForTransport(t,e){const n=this.getBrowserWindow();return!n||typeof n.fetch!="function"?Promise.reject(new Error("Monitor transport fetch is unavailable outside a browser.")):L(n).fetchForTransport(t,e)}createXhrForTransport(){const t=this.getBrowserWindow();if(!t||!R(t))throw new Error("Monitor transport XMLHttpRequest is unavailable outside a browser.");return L(t).createXhrForTransport()}getTimestamp(){var t,e;try{const n=((e=(t=this.options).now)==null?void 0:e.call(t))??Date.now();return Number.isFinite(n)?n:Date.now()}catch{return Date.now()}}getCurrentUrl(){var e;const t=this.getBrowserWindow();return((e=t==null?void 0:t.location)==null?void 0:e.href)??""}getContext(t){var n,i;let e;try{e=(i=(n=this.options).getContext)==null?void 0:i.call(n)}catch{e=void 0}return{...this.options.context??{},...e??{},...t??{}}}getTags(){return{...this.options.tags??{},...this.options.release?{release:this.options.release}:{},...this.options.environment?{environment:this.options.environment}:{}}}getRequestOptions(){const t=this.options.captureRequests;if(!t)return g;if(t===!0)return{fetch:!0,xhr:!0,includeSuccessful:!1};const e=t.slowThreshold;return{fetch:t.fetch===!0,xhr:t.xhr===!0,includeSuccessful:t.includeSuccessful===!0,...typeof e=="number"&&Number.isFinite(e)&&e>=0?{slowThreshold:e}:{}}}shouldCaptureGlobalErrors(){return this.options.captureGlobalErrors!==!1}shouldCaptureResourceErrors(){return this.options.captureResourceErrors!==!1}shouldCaptureUnhandledRejections(){return this.options.captureUnhandledRejections!==!1}shouldCaptureNavigation(){return this.options.captureNavigation!==!1}shouldCapturePerformance(){return this.options.capturePerformance!==!1}requiresInstrumentationHub(){const t=this.getRequestOptions();return t.fetch||t.xhr||this.shouldCaptureNavigation()}isIgnoredUrl(t){var e;return((e=this.options.ignoreUrls)==null?void 0:e.some(n=>{try{return typeof n=="function"?n(t):typeof n=="string"?z(t,n):(n.lastIndex=0,n.test(t))}catch{return!1}}))??!1}installErrorListener(t){const e=n=>{if(!this.active)return;const i=D(n.target);if(i){this.shouldCaptureResourceErrors()&&this.emit({type:"resource",level:"error",timestamp:this.getTimestamp(),url:this.getCurrentUrl(),context:this.getContext(),tags:this.getTags(),data:i});return}if(!this.shouldCaptureGlobalErrors())return;const s=n,a={...typeof s.filename=="string"?{filename:s.filename}:{},...S(s.lineno)!==void 0?{line:S(s.lineno)}:{},...S(s.colno)!==void 0?{column:S(s.colno)}:{}},c=s.error??new Error(typeof s.message=="string"?s.message:"Unknown window error");this.captureExceptionFromSource(c,"window.error",void 0,a)};t.addEventListener("error",e,!0),this.browserCleanups.push(()=>{t.removeEventListener("error",e,!0)})}installUnhandledRejectionListener(t){const e=n=>{this.active&&this.captureExceptionFromSource(n.reason,"unhandledrejection")};t.addEventListener("unhandledrejection",e),this.browserCleanups.push(()=>{t.removeEventListener("unhandledrejection",e)})}installNavigationListeners(t){const e=()=>{const i=t.location.href;this.handleInstrumentedNavigation({source:"popstate",from:this.lastNavigationUrl,to:i,duration:0})},n=i=>{this.handleInstrumentedNavigation({source:"hashchange",from:i.oldURL,to:i.newURL,duration:0})};t.addEventListener("popstate",e),t.addEventListener("hashchange",n),this.browserCleanups.push(()=>{t.removeEventListener("popstate",e),t.removeEventListener("hashchange",n)})}installPerformanceListener(t){const e=()=>{if(!this.active)return;const n=G(t);n&&this.emit({type:"performance",level:"info",timestamp:this.getTimestamp(),url:this.getCurrentUrl(),context:this.getContext(),tags:this.getTags(),data:n})};if(t.document.readyState==="complete"){e();return}t.addEventListener("load",e,{once:!0}),this.browserCleanups.push(()=>{t.removeEventListener("load",e)})}captureExceptionFromSource(t,e,n,i={}){const s={...A(t),source:e,...i};this.emit({type:e==="unhandledrejection"?"unhandledrejection":"exception",level:"error",timestamp:this.getTimestamp(),url:this.getCurrentUrl(),context:this.getContext(n),tags:this.getTags(),data:s})}emit(t){var i;if(this.destroyed||!this.isSampled())return;const e=this.sanitizeEvent(t);if(!e)return;const n=this.createTransportContext();this.options.transport&&this.runSafely(()=>{var s,a;return(a=(s=this.options).transport)==null?void 0:a.call(s,e,n)}),this.active&&((i=this.options.recorder)!=null&&i.capture)&&this.runSafely(()=>{var s,a;return(a=(s=this.options.recorder)==null?void 0:s.capture)==null?void 0:a.call(s,e,n)})}isSampled(){var n,i;const t=this.options.sampleRate,e=typeof t=="number"&&Number.isFinite(t)?Math.min(Math.max(t,0),1):1;if(e===0)return!1;if(e===1)return!0;try{return(((i=(n=this.options).random)==null?void 0:i.call(n))??Math.random())<e}catch{return!0}}sanitizeEvent(t){let e;switch(t.type){case"exception":case"unhandledrejection":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{...t.data,name:this.redactText(t.data.name,"name"),message:this.redactText(t.data.message,"message"),...t.data.stack?{stack:this.redactText(t.data.stack,"stack")}:{},...t.data.filename?{filename:this.redactUrl(t.data.filename)}:{}}};break;case"message":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{message:this.redactText(t.data.message,"message")}};break;case"resource":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{element:this.redactText(t.data.element,"element"),url:this.redactUrl(t.data.url)}};break;case"navigation":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{...t.data,from:this.redactUrl(t.data.from),to:this.redactUrl(t.data.to)}};break;case"performance":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{...t.data}};break;case"request":e={...t,url:this.redactUrl(t.url),context:this.sanitizeContext(t.context),tags:this.sanitizeTags(t.tags),data:{...t.data,method:this.redactText(t.data.method,"method"),url:this.redactUrl(t.data.url),...t.data.error?{error:this.redactText(t.data.error,"error")}:{}}};break}try{return this.options.sanitize?this.options.sanitize(e):e}catch{return null}}sanitizeContext(t){const e=new WeakSet,n=this.sanitizeUnknown(t,"",e);return C(n)?n:{}}sanitizeUnknown(t,e,n){if(e&&this.shouldRedactKey(e))return this.getRedactionReplacement();if(t==null)return t;switch(typeof t){case"string":return this.redactText(t,e);case"number":case"boolean":return t;case"bigint":return t.toString();case"symbol":return t.toString();case"function":return`[Function ${t.name||"anonymous"}]`}if(t instanceof Error)return{name:this.redactText(t.name||"Error","name"),message:this.redactText(t.message||t.name||"Unknown error","message"),...t.stack?{stack:this.redactText(t.stack,"stack")}:{}};if(t instanceof Date)return Number.isNaN(t.getTime())?"Invalid Date":t.toISOString();if(E(t))return this.redactUrl(t.href);if(!C(t))return y(t);if(n.has(t))return"[Circular]";if(n.add(t),Array.isArray(t))return t.map(s=>this.sanitizeUnknown(s,"",n));const i={};try{for(const[s,a]of Object.entries(t))i[s]=this.sanitizeUnknown(a,s,n)}catch{return"[Unserializable object]"}return i}sanitizeTags(t){const e={};for(const[n,i]of Object.entries(t))typeof i=="string"?e[n]=this.redactText(i,n):e[n]=i;return e}shouldRedactKey(t){var e;return M(t,(e=this.options.redact)==null?void 0:e.keys)}getRedactionReplacement(){var t;return((t=this.options.redact)==null?void 0:t.replacement)??O}redactText(t,e){return e&&this.shouldRedactKey(e)?this.getRedactionReplacement():t}redactUrl(t){var e,n;if(this.shouldRedactKey("url"))return this.getRedactionReplacement();if(!((n=(e=this.options.redact)==null?void 0:e.queryParams)!=null&&n.length))return t;try{const i=/^[a-z][a-z\d+.-]*:/i.test(t),s=new URL(t,`https://${d}.invalid`);for(const a of Array.from(s.searchParams.keys()))M(a,this.options.redact.queryParams)&&s.searchParams.set(a,this.getRedactionReplacement());return i?s.toString():`${s.pathname}${s.search}${s.hash}`}catch{return t}}startRecorder(){var t;!((t=this.options.recorder)!=null&&t.start)||this.recorderActive||(this.recorderActive=!0,this.runSafely(()=>{var e,n;return(n=(e=this.options.recorder)==null?void 0:e.start)==null?void 0:n.call(e,this.createTransportContext())}))}stopRecorder(){var t;!((t=this.options.recorder)!=null&&t.stop)||!this.recorderActive||(this.recorderActive=!1,this.runSafely(()=>{var e,n;return(n=(e=this.options.recorder)==null?void 0:e.stop)==null?void 0:n.call(e,this.createTransportContext())}))}runBrowserCleanups(){for(const t of this.browserCleanups.splice(0).reverse())this.runSafely(t)}runSafely(t){try{const e=t();Promise.resolve(e).catch(v)}catch{}}}class X{constructor(t){o(this,"monitors",new Set);o(this,"xhrMetadata",new WeakMap);o(this,"transportXhrs",new WeakSet);o(this,"xhrListeners",new Map);o(this,"nativeFetch");o(this,"fetchCleanup");o(this,"xhrCleanup");o(this,"historyCleanup");this.browserWindow=t}subscribe(t){return this.monitors.add(t),this.sync(),()=>{this.monitors.delete(t),this.sync(),this.monitors.size===0&&T.delete(this.browserWindow)}}fetchForTransport(t,e){return(this.nativeFetch??this.browserWindow.fetch).call(this.browserWindow,t,e)}createXhrForTransport(){const t=R(this.browserWindow);if(!t)throw new Error("Monitor transport XMLHttpRequest is unavailable outside a browser.");const e=new t;return this.transportXhrs.add(e),e}sync(){this.someMonitor(t=>t.needsFetchInstrumentation())?this.installFetchPatch():this.removeFetchPatch(),this.someMonitor(t=>t.needsXhrInstrumentation())?this.installXhrPatch():this.removeXhrPatch(),this.someMonitor(t=>t.needsHistoryInstrumentation())?this.installHistoryPatch():this.removeHistoryPatch()}someMonitor(t){for(const e of this.monitors)if(t(e))return!0;return!1}getRequestMonitors(t,e){return Array.from(this.monitors).filter(n=>n.shouldMonitorRequest(t,e))}installFetchPatch(){if(this.fetchCleanup||typeof this.browserWindow.fetch!="function")return;const t=this.browserWindow.fetch;this.nativeFetch=t;const e=this,n=function(i,s){return e.performFetch(i,s)};this.browserWindow.fetch=n,this.fetchCleanup=()=>{this.browserWindow.fetch===n&&(this.browserWindow.fetch=t),this.nativeFetch===t&&(this.nativeFetch=void 0)}}performFetch(t,e){const n=this.nativeFetch??this.browserWindow.fetch,i=W(t,this.browserWindow),s=this.getRequestMonitors("fetch",i);if(s.length===0)return n.call(this.browserWindow,t,e);const a=H(t,e),c=m(this.browserWindow);try{return n.call(this.browserWindow,t,e).then(u=>{const p=m(this.browserWindow)-c;return this.notifyRequest(s,{kind:"fetch",method:a,url:u.url||i,status:u.status,duration:p,ok:u.ok}),u},u=>{const p=m(this.browserWindow)-c;throw this.notifyRequest(s,{kind:"fetch",method:a,url:i,duration:p,ok:!1,error:y(u)}),u})}catch(h){const u=m(this.browserWindow)-c;throw this.notifyRequest(s,{kind:"fetch",method:a,url:i,duration:u,ok:!1,error:y(h)}),h}}removeFetchPatch(){var t;(t=this.fetchCleanup)==null||t.call(this),this.fetchCleanup=void 0}installXhrPatch(){if(this.xhrCleanup)return;const t=R(this.browserWindow);if(!t)return;const e=t.prototype,n=e.open,i=e.send,s=this,a=function(h,u,p,w,f){s.xhrMetadata.set(this,{method:U(h),url:k(String(u),s.browserWindow)}),n.call(this,h,u,p??!0,w,f)},c=function(h){const u=s.xhrMetadata.get(this),p=u&&!s.transportXhrs.has(this)?s.getRequestMonitors("xhr",u.url):[];if(!u||p.length===0){h===void 0?i.call(this):i.call(this,h);return}const w=s.xhrListeners.get(this);w&&(this.removeEventListener("loadend",w),s.xhrListeners.delete(this));const f={...u,startedAt:m(s.browserWindow),monitors:p},b=()=>{this.removeEventListener("loadend",b),s.xhrListeners.delete(this),s.notifyRequest(f.monitors,{kind:"xhr",method:f.method,url:this.responseURL||f.url,status:this.status,duration:m(s.browserWindow)-f.startedAt,ok:this.status>=200&&this.status<400,...this.status===0?{error:"Network request failed"}:{}})};this.addEventListener("loadend",b),s.xhrListeners.set(this,b);try{h===void 0?i.call(this):i.call(this,h)}catch(x){throw this.removeEventListener("loadend",b),s.xhrListeners.delete(this),s.notifyRequest(f.monitors,{kind:"xhr",method:f.method,url:f.url,duration:m(s.browserWindow)-f.startedAt,ok:!1,error:y(x)}),x}};e.open=a,e.send=c,this.xhrCleanup=()=>{e.open===a&&(e.open=n),e.send===c&&(e.send=i);for(const[h,u]of this.xhrListeners)h.removeEventListener("loadend",u);this.xhrListeners.clear()}}removeXhrPatch(){var t;(t=this.xhrCleanup)==null||t.call(this),this.xhrCleanup=void 0}installHistoryPatch(){if(this.historyCleanup)return;const t=this.browserWindow.history,e=t.pushState,n=t.replaceState,i=this,s=(h,u)=>function(p,w,f){const b=i.browserWindow.location.href,x=m(i.browserWindow);h.call(this,p,w,f),i.notifyNavigation({source:"history",method:u,from:b,to:i.browserWindow.location.href,duration:m(i.browserWindow)-x})},a=s(e,"pushState"),c=s(n,"replaceState");t.pushState=a,t.replaceState=c,this.historyCleanup=()=>{t.pushState===a&&(t.pushState=e),t.replaceState===c&&(t.replaceState=n)}}removeHistoryPatch(){var t;(t=this.historyCleanup)==null||t.call(this),this.historyCleanup=void 0}notifyRequest(t,e){for(const n of t)n.handleInstrumentedRequest(e)}notifyNavigation(t){for(const e of this.monitors)e.handleInstrumentedNavigation(t)}}const T=new WeakMap;function L(r){let t=T.get(r);return t||(t=new X(r),T.set(r,t)),t}function G(r){const t=r.performance;if(!(t!=null&&t.getEntriesByType))return;const e=t.getEntriesByType("navigation").find(n=>"domContentLoadedEventEnd"in n&&"loadEventEnd"in n);if(e)return{navigationType:e.type,duration:e.duration,redirect:e.redirectEnd-e.redirectStart,dns:e.domainLookupEnd-e.domainLookupStart,connection:e.connectEnd-e.connectStart,request:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,domInteractive:e.domInteractive,domContentLoaded:e.domContentLoadedEventEnd-e.startTime,load:e.loadEventEnd-e.startTime}}const P="__easyOilLegacyMonitorLog",N="easyOilLegacyMonitorSessionId",K={silentWhiteScreen:"Legacy white-screen detection is not included. Use a project-owned detector and report through transport instead.",whiteBoxElements:"Legacy white-screen container configuration is not supported because white-screen detection is not included.",skeletonProject:"Legacy skeleton-screen detection is not supported because white-screen detection is not included.",silentRecordScreen:"Legacy rrweb screen recording is not bundled. Keep the project-owned recording implementation when this capability is required.",recordScreentime:"Legacy rrweb recording duration is not supported because screen recording is not included.",recordScreenTypeList:"Legacy rrweb recording trigger types are not supported because screen recording is not included.",useImgUpload:"Legacy image-beacon reporting is not supported. The compatibility transport uses the monitor transport context instead.",silentClick:"Legacy click breadcrumb collection is not supported by this compatibility layer.",throttleDelayTime:"Legacy click throttling is not supported because click breadcrumb collection is not included.",maxBreadcrumbs:"Legacy breadcrumb buffering is not supported by this compatibility layer.",beforePushBreadcrumb:"Legacy breadcrumb hooks are not supported because breadcrumb collection is not included.",overTime:"Legacy request timeout handling is not supported. Configure timeouts in the application HTTP client.",handleHttpStatus:"Legacy response-body status inspection is not supported by this compatibility layer.",defHttp:"Legacy defHttp interception is not supported. Enable browser request capture with silentXhr or silentFetch instead.",router:"Legacy router-instance instrumentation is not supported. Enable history or hash capture with the corresponding legacy flags instead.",recordScreenPlugin:"Legacy RecordScreen plugins require rrweb and are not supported by this compatibility layer."};function q(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function $(){return!1}function V(r){if(typeof r=="string")return r;if(r instanceof Error)return r.message||r.name||"Unknown error";try{const t=JSON.stringify(r);if(typeof t=="string")return t}catch{}try{return String(r)}catch{return"Unknown message"}}function I(r){if(typeof r.getUserId=="function")try{const t=r.getUserId();if(typeof t=="string"||typeof t=="number")return t}catch{return typeof r.userId=="string"||typeof r.userId=="number"?r.userId:void 0}return typeof r.userId=="string"||typeof r.userId=="number"?r.userId:void 0}function J(){if(typeof sessionStorage>"u")return"";try{const r=sessionStorage.getItem(N);if(r)return r;const t=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;return sessionStorage.setItem(N,t),t}catch{return""}}function Y(r){switch(r.type){case"exception":return"error";case"navigation":return r.data.source==="hashchange"?"hashchange":"history";case"request":return r.data.kind;default:return r.type}}function Q(r){switch(r.type){case"exception":case"unhandledrejection":case"resource":return"client_debug";default:return"user_behavior"}}function Z(r){switch(r.type){case"exception":case"unhandledrejection":return{message:r.data.message,name:r.data.name,...r.data.stack?{stack:r.data.stack}:{},...r.data.filename?{fileName:r.data.filename}:{},...r.data.line!==void 0?{line:r.data.line}:{},...r.data.column!==void 0?{column:r.data.column}:{}};case"request":return{method:r.data.method,url:r.data.url,Status:r.data.status,status:r.data.ok?"ok":"error",elapsedTime:r.data.duration,...r.data.error?{message:r.data.error}:{}};case"navigation":return{from:r.data.from,to:r.data.to,duration:r.data.duration,source:r.data.source};case"performance":return{...r.data};case"resource":return{name:r.data.element,message:r.data.url};case"message":return{message:r.data.message}}}function tt(r){if(r.type!=="message")return;const t=r.context[P];return q(t)?t:void 0}function et(r,t){const e=I(t),n={moduleId:Q(r),type:Y(r),status:r.level==="error"||r.level==="fatal"?"error":"ok",time:r.timestamp,pageUrl:r.url,...t.appChannelId?{appChannelId:t.appChannelId}:{},...t.dataChannelId?{dataChannelId:t.dataChannelId}:{},...t.version?{version:t.version}:{},...e!==void 0?{userId:e}:{},message:r.type==="message"?r.data.message:void 0,data:Z(r)},i=tt(r);if(!i)return n;const s=i.type,a=i.moduleId,c=i.data;return{...n,...i,type:typeof s=="string"?s:n.type,moduleId:typeof a=="string"?a:n.moduleId,data:q(c)?c:{...n.data,...i}}}function rt(r,t){return r.type!=="navigation"?!0:r.data.source==="hashchange"?t.silentHashchange===!0:t.silentHistory===!0}function nt(r){const t=[];return r.dsn&&t.push(r.dsn),r.filterXhrUrlRegExp&&t.push(r.filterXhrUrlRegExp),{captureRequests:{xhr:r.silentXhr===!0,fetch:r.silentFetch===!0},captureGlobalErrors:r.silentError===!0,captureUnhandledRejections:r.silentUnhandledrejection===!0,captureNavigation:r.silentHistory===!0||r.silentHashchange===!0,capturePerformance:r.silentPerformance===!0,ignoredUrls:t}}function st(r,t){const e=I(t),n={...r,data:r.data??{}},i={moduleId:r.moduleId??"user_behavior",type:r.type,message:r.message,identityID:e??"",userIdentity:e??"",sessionId:J(),extraContent:JSON.stringify(n)};return{content:[JSON.stringify(i)]}}async function it(r,t){if(!r)return t;try{const e=await r(t);return e===!1?void 0:e??t}catch{return}}class ot{constructor(t={}){o(this,"currentMonitor");o(this,"currentOptions");o(this,"currentMapping");o(this,"plugins",new Set);o(this,"reportedErrorKeys",new Set);o(this,"dsnWarningShown",!1);o(this,"init",(t=this.defaultOptions)=>{const e=this.configure(t);return e==null||e.start(),this});o(this,"install",(t,e=this.defaultOptions)=>{const n=this.configure(e);n&&(t.use(n.createVuePlugin()),n.start())});o(this,"log",t=>{const e=this.currentMonitor;if(!e)return!1;if(typeof t=="string")return e.captureMessage(t),!0;const n=V(t.message??t);return e.captureMessage(n,"info",{[P]:t}),!0});o(this,"errorBoundary",t=>{const e=this.currentMonitor;return e?(e.captureException(t,{framework:"react"}),!0):!1});o(this,"use",(t,e)=>{let n;try{n=new t(e)}catch{return}return this.plugins.add(n),n.type==="recordScreen"&&this.notifyUnsupported("recordScreenPlugin",n.type),this.runPluginCore(n),n});o(this,"stop",()=>{var t;(t=this.currentMonitor)==null||t.stop()});o(this,"destroy",()=>{var t;(t=this.currentMonitor)==null||t.destroy(),this.currentMonitor=void 0,this.currentMapping=void 0,this.reportedErrorKeys.clear()});this.defaultOptions=t}get monitor(){return this.currentMonitor}get started(){var t;return((t=this.currentMonitor)==null?void 0:t.started)??!1}get options(){return this.currentOptions}configure(t){if(this.destroy(),this.currentOptions={...t},this.dsnWarningShown=!1,this.reportUnsupportedOptions(t),t.disabled===!0)return;const e=nt(t);this.currentMapping=e;const n=B({transport:(i,s)=>this.handleMonitorEvent(i,s),captureRequests:{xhr:e.captureRequests.xhr,fetch:e.captureRequests.fetch,includeSuccessful:!0},captureGlobalErrors:e.captureGlobalErrors,captureResourceErrors:e.captureGlobalErrors,captureUnhandledRejections:e.captureUnhandledRejections,captureNavigation:e.captureNavigation,capturePerformance:e.capturePerformance,ignoreUrls:e.ignoredUrls,context:{legacyMonitor:!0,...t.appChannelId?{appChannelId:t.appChannelId}:{},...t.dataChannelId?{dataChannelId:t.dataChannelId}:{},...t.context??{}},getContext:()=>this.getDynamicContext(t),tags:t.tags,release:t.version,environment:t.environment,redact:t.redact,window:t.window,sampleRate:t.sampleRate,random:t.random,now:t.now});this.currentMonitor=n;for(const i of this.plugins)i.type==="recordScreen"&&this.notifyUnsupported("recordScreenPlugin",i.type),this.runPluginCore(i);return n}getDynamicContext(t){const e=I(t);return e===void 0?{}:{userId:e}}async handleMonitorEvent(t,e){const n=this.currentOptions;if(!n||!rt(t,n)||!this.shouldReportEvent(t,n))return;const i=et(t,n),s=await it(n.beforeDataReport,i);if(s){if(this.runPluginTransforms(s),n.transport){await n.transport(s,t,e);return}if(!n.dsn){this.warnMissingDsn();return}await e.fetch(n.dsn,{method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8",...n.appChannelId?{"x-app_channel_id":n.appChannelId}:{},...n.dataChannelId?{"x-data_channel_id":n.dataChannelId}:{}},body:JSON.stringify(st(s,n))})}}shouldReportEvent(t,e){if(e.repeatCodeError!==!0||t.type!=="exception"&&t.type!=="unhandledrejection")return!0;const n=[t.type,t.data.name,t.data.message,t.data.filename??"",t.data.line??"",t.data.column??""].join("|");return this.reportedErrorKeys.has(n)?!1:(this.reportedErrorKeys.add(n),!0)}runPluginCore(t){const e=this.currentOptions;if(!(!e||typeof t.core!="function"))try{t.core(this.createPluginContext(e))}catch{}}createPluginContext(t){return{options:t,transportData:{send:this.log},breadcrumb:{push:this.log},notify:(e,n)=>this.log({type:e,...typeof n=="string"?{message:n}:n??{}})}}runPluginTransforms(t){for(const e of this.plugins)if(!(typeof e.transform!="function"||e.type&&e.type!==t.type&&e.type!=="*"))try{e.transform(t)}catch{}}reportUnsupportedOptions(t){var e;t.silentWhiteScreen===!0&&this.notifyUnsupported("silentWhiteScreen",t.silentWhiteScreen),t.whiteBoxElements!==void 0&&this.notifyUnsupported("whiteBoxElements",t.whiteBoxElements),t.skeletonProject===!0&&this.notifyUnsupported("skeletonProject",t.skeletonProject),t.silentRecordScreen===!0&&this.notifyUnsupported("silentRecordScreen",t.silentRecordScreen),t.recordScreentime!==void 0&&this.notifyUnsupported("recordScreentime",t.recordScreentime),(e=t.recordScreenTypeList)!=null&&e.length&&this.notifyUnsupported("recordScreenTypeList",t.recordScreenTypeList),t.useImgUpload===!0&&this.notifyUnsupported("useImgUpload",t.useImgUpload),t.silentClick===!0&&this.notifyUnsupported("silentClick",t.silentClick),t.throttleDelayTime!==void 0&&this.notifyUnsupported("throttleDelayTime",t.throttleDelayTime),t.maxBreadcrumbs!==void 0&&this.notifyUnsupported("maxBreadcrumbs",t.maxBreadcrumbs),typeof t.beforePushBreadcrumb=="function"&&this.notifyUnsupported("beforePushBreadcrumb",t.beforePushBreadcrumb),t.overTime!==void 0&&this.notifyUnsupported("overTime",t.overTime),typeof t.handleHttpStatus=="function"&&this.notifyUnsupported("handleHttpStatus",t.handleHttpStatus),t.defHttp!==void 0&&this.notifyUnsupported("defHttp",t.defHttp),t.router!==void 0&&this.notifyUnsupported("router",t.router)}notifyUnsupported(t,e){var i,s,a;const n={option:t,value:e,message:K[t]};try{(s=(i=this.currentOptions)==null?void 0:i.onUnsupportedOption)==null||s.call(i,n)}catch{}!((a=this.currentOptions)!=null&&a.onUnsupportedOption)&&$()}warnMissingDsn(){this.dsnWarningShown}}function at(r={}){return new ot(r)}const ct=at();l.default=ct,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/permission.es.js
DELETED
|
@@ -1,631 +0,0 @@
|
|
|
1
|
-
var T = Object.defineProperty;
|
|
2
|
-
var O = (t, e, n) => e in t ? T(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
-
var u = (t, e, n) => O(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { defineComponent as R, inject as k, ref as N, watch as z, h as B } from "vue";
|
|
5
|
-
const C = "permissionPluginClass";
|
|
6
|
-
function l(t) {
|
|
7
|
-
return t === void 0 ? "" : String(t).trim();
|
|
8
|
-
}
|
|
9
|
-
function h(t) {
|
|
10
|
-
const n = (Array.isArray(t) ? t : [t]).flatMap((r) => {
|
|
11
|
-
if (typeof r == "string")
|
|
12
|
-
return r.split(",").map((a) => a.trim());
|
|
13
|
-
if (typeof r == "number") return [String(r)];
|
|
14
|
-
if (r && typeof r == "object" && "pageId" in r) {
|
|
15
|
-
const a = r.pageId;
|
|
16
|
-
return typeof a == "string" || typeof a == "number" ? [String(a).trim()] : [];
|
|
17
|
-
}
|
|
18
|
-
return [];
|
|
19
|
-
});
|
|
20
|
-
return [...new Set(n.filter(Boolean))];
|
|
21
|
-
}
|
|
22
|
-
function y(t) {
|
|
23
|
-
return t === !0 || t === 1 || t === "1";
|
|
24
|
-
}
|
|
25
|
-
function g(t) {
|
|
26
|
-
var e;
|
|
27
|
-
return y((e = t.extraContent) == null ? void 0 : e.isPsMg);
|
|
28
|
-
}
|
|
29
|
-
function d(t) {
|
|
30
|
-
return Array.isArray(t.children) ? t.children : [];
|
|
31
|
-
}
|
|
32
|
-
function F(t) {
|
|
33
|
-
return { ...t ?? {} };
|
|
34
|
-
}
|
|
35
|
-
function m(t) {
|
|
36
|
-
return {
|
|
37
|
-
...t,
|
|
38
|
-
extraContent: F(t.extraContent),
|
|
39
|
-
...t.parentIds ? { parentIds: [...t.parentIds] } : {},
|
|
40
|
-
children: d(t).map((e) => m(e))
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function I(t) {
|
|
44
|
-
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
45
|
-
if (typeof t == "string" && t.trim()) {
|
|
46
|
-
const e = Number(t);
|
|
47
|
-
return Number.isFinite(e) ? e : 0;
|
|
48
|
-
}
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
function A(t) {
|
|
52
|
-
if (!t) return 0;
|
|
53
|
-
const e = Date.parse(t);
|
|
54
|
-
return Number.isFinite(e) ? e : 0;
|
|
55
|
-
}
|
|
56
|
-
function v(t) {
|
|
57
|
-
return t.sort((e, n) => {
|
|
58
|
-
const r = I(e.sort) - I(n.sort);
|
|
59
|
-
return r !== 0 ? r : A(e.createTime) - A(n.createTime);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function M(t) {
|
|
63
|
-
const e = [], n = (r, a, i) => {
|
|
64
|
-
for (const o of r) {
|
|
65
|
-
const s = m(o), c = l(s.pageId);
|
|
66
|
-
a.length > 0 && (s.parentIds = [...a]), Number(s.type) === 2 && i === !1 && (s.extraContent = {
|
|
67
|
-
...s.extraContent,
|
|
68
|
-
isPsMg: 0
|
|
69
|
-
}), e.push(s), n(
|
|
70
|
-
d(s),
|
|
71
|
-
c ? [...a, c] : a,
|
|
72
|
-
g(s)
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return n(t, [], null), e;
|
|
77
|
-
}
|
|
78
|
-
function S(t) {
|
|
79
|
-
const e = F(t.extraContent);
|
|
80
|
-
return {
|
|
81
|
-
...e,
|
|
82
|
-
path: typeof t.routingAddress == "string" ? t.routingAddress : "",
|
|
83
|
-
name: typeof e.assemblyName == "string" ? e.assemblyName : l(t.pageId),
|
|
84
|
-
component: typeof e.assemblyAddress == "string" ? e.assemblyAddress : "",
|
|
85
|
-
meta: {
|
|
86
|
-
title: typeof t.pageName == "string" ? t.pageName : "",
|
|
87
|
-
icon: typeof t.icon == "string" ? t.icon : ""
|
|
88
|
-
},
|
|
89
|
-
id: l(t.pageId),
|
|
90
|
-
eventIdList: Array.isArray(t.eventIdList) ? [...t.eventIdList] : [],
|
|
91
|
-
...t.createTime ? { createTime: t.createTime } : {},
|
|
92
|
-
...t.isShow !== void 0 ? { isShow: t.isShow } : {},
|
|
93
|
-
...t.sort !== void 0 ? { sort: t.sort } : {},
|
|
94
|
-
...t.type !== void 0 ? { type: t.type } : {},
|
|
95
|
-
...t.updateTime ? { updateTime: t.updateTime } : {},
|
|
96
|
-
children: []
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function D(t) {
|
|
100
|
-
var n;
|
|
101
|
-
const e = (n = t.extraContent) == null ? void 0 : n.menuStatus;
|
|
102
|
-
return e === void 0 || y(e);
|
|
103
|
-
}
|
|
104
|
-
function _(t, e) {
|
|
105
|
-
var o;
|
|
106
|
-
if (!g(t)) return !0;
|
|
107
|
-
const n = d(t);
|
|
108
|
-
if (y((o = t.extraContent) == null ? void 0 : o.isBigScreen))
|
|
109
|
-
return e.has(l(t.pageId)) && D(t);
|
|
110
|
-
if (n.length === 0) return !1;
|
|
111
|
-
const r = n.filter(
|
|
112
|
-
(s) => {
|
|
113
|
-
var c;
|
|
114
|
-
return y((c = s.extraContent) == null ? void 0 : c.isRelateParent);
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
if (r.length > 0)
|
|
118
|
-
return r.some(
|
|
119
|
-
(s) => !g(s) || e.has(l(s.pageId))
|
|
120
|
-
) && D(t);
|
|
121
|
-
const a = n.every(
|
|
122
|
-
(s) => e.has(l(s.pageId))
|
|
123
|
-
), i = n.every((s) => !g(s));
|
|
124
|
-
return (a || i) && D(t);
|
|
125
|
-
}
|
|
126
|
-
function J(t, e) {
|
|
127
|
-
const n = new Set(e), r = (a) => {
|
|
128
|
-
const i = [];
|
|
129
|
-
for (const o of a) {
|
|
130
|
-
const s = Number(o.type);
|
|
131
|
-
if (s === 0) {
|
|
132
|
-
const c = r(d(o));
|
|
133
|
-
if (c.length > 0) {
|
|
134
|
-
const P = S(o);
|
|
135
|
-
P.children = c, i.push(P);
|
|
136
|
-
}
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
s !== 1 || !_(o, n) || i.push(S(o));
|
|
140
|
-
}
|
|
141
|
-
return v(i);
|
|
142
|
-
};
|
|
143
|
-
return r(t);
|
|
144
|
-
}
|
|
145
|
-
function U(t) {
|
|
146
|
-
const e = (n) => {
|
|
147
|
-
const r = [];
|
|
148
|
-
for (const a of n) {
|
|
149
|
-
if (!g(a)) continue;
|
|
150
|
-
const i = m(a);
|
|
151
|
-
i.children = e(d(a)), r.push(i);
|
|
152
|
-
}
|
|
153
|
-
return v(r);
|
|
154
|
-
};
|
|
155
|
-
return e(t);
|
|
156
|
-
}
|
|
157
|
-
function G(t) {
|
|
158
|
-
const e = (n) => {
|
|
159
|
-
const r = n.map((a) => {
|
|
160
|
-
const i = m(a);
|
|
161
|
-
return i.children = e(d(a)), i;
|
|
162
|
-
});
|
|
163
|
-
return v(r);
|
|
164
|
-
};
|
|
165
|
-
return e(t);
|
|
166
|
-
}
|
|
167
|
-
function V(t) {
|
|
168
|
-
const e = (n) => {
|
|
169
|
-
const r = [];
|
|
170
|
-
for (const a of n) {
|
|
171
|
-
const i = e(d(a));
|
|
172
|
-
if (!g(a) || i.length > 0) {
|
|
173
|
-
const o = m(a);
|
|
174
|
-
o.children = i, r.push(o);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return r;
|
|
178
|
-
};
|
|
179
|
-
return e(t);
|
|
180
|
-
}
|
|
181
|
-
function $(t) {
|
|
182
|
-
const e = [], n = (r) => {
|
|
183
|
-
var a;
|
|
184
|
-
for (const i of r)
|
|
185
|
-
Number(i.type) === 1 && y(i.isShow) && y((a = i.extraContent) == null ? void 0 : a.isCache) && e.push(m(i)), n(d(i));
|
|
186
|
-
};
|
|
187
|
-
return n(t), e;
|
|
188
|
-
}
|
|
189
|
-
function q(t, e) {
|
|
190
|
-
const n = /* @__PURE__ */ new Set(), r = (a) => {
|
|
191
|
-
for (const i of a) {
|
|
192
|
-
const o = d(i);
|
|
193
|
-
if (o.length > 0) {
|
|
194
|
-
r(o);
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
(!g(i) || e.has(l(i.pageId))) && h(i.eventIdList).forEach((s) => n.add(s));
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
return r(t), [...n];
|
|
201
|
-
}
|
|
202
|
-
function x(t) {
|
|
203
|
-
if (typeof t == "boolean") return t;
|
|
204
|
-
if (typeof t == "function")
|
|
205
|
-
try {
|
|
206
|
-
return !!t();
|
|
207
|
-
} catch {
|
|
208
|
-
return !1;
|
|
209
|
-
}
|
|
210
|
-
return h(t).length === 0;
|
|
211
|
-
}
|
|
212
|
-
const W = R({
|
|
213
|
-
name: "Permission",
|
|
214
|
-
props: {
|
|
215
|
-
sign: {
|
|
216
|
-
type: [String, Number, Boolean, Array, Function],
|
|
217
|
-
default: ""
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
setup(t, { slots: e }) {
|
|
221
|
-
const n = k(
|
|
222
|
-
C,
|
|
223
|
-
null
|
|
224
|
-
), r = N(x(t.sign));
|
|
225
|
-
let a = 0;
|
|
226
|
-
const i = async () => {
|
|
227
|
-
const o = ++a, s = n ? await n.checkPermission(t.sign) : x(t.sign);
|
|
228
|
-
o === a && (r.value = s);
|
|
229
|
-
};
|
|
230
|
-
return z(
|
|
231
|
-
[
|
|
232
|
-
() => t.sign,
|
|
233
|
-
() => (n == null ? void 0 : n.revision.value) ?? 0
|
|
234
|
-
],
|
|
235
|
-
() => {
|
|
236
|
-
i();
|
|
237
|
-
},
|
|
238
|
-
{ immediate: !0, deep: !0 }
|
|
239
|
-
), () => {
|
|
240
|
-
var o, s, c;
|
|
241
|
-
return B(
|
|
242
|
-
"div",
|
|
243
|
-
r.value ? (o = e.default) == null ? void 0 : o.call(e) : ((s = e.emptySlot) == null ? void 0 : s.call(e)) ?? ((c = e.fallback) == null ? void 0 : c.call(e))
|
|
244
|
-
);
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
function p(t) {
|
|
249
|
-
return typeof t == "object" && t !== null;
|
|
250
|
-
}
|
|
251
|
-
function w(t) {
|
|
252
|
-
return JSON.parse(JSON.stringify(t));
|
|
253
|
-
}
|
|
254
|
-
function H() {
|
|
255
|
-
if (typeof window > "u") return null;
|
|
256
|
-
try {
|
|
257
|
-
return window.localStorage;
|
|
258
|
-
} catch {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function Y() {
|
|
263
|
-
return typeof window > "u" ? null : window.indexedDB ?? null;
|
|
264
|
-
}
|
|
265
|
-
function K(t) {
|
|
266
|
-
if (!p(t))
|
|
267
|
-
return { cfg: {}, data: {} };
|
|
268
|
-
const e = p(t.cfg) ? t.cfg : {}, n = p(t.data) ? t.data : {};
|
|
269
|
-
return {
|
|
270
|
-
...t,
|
|
271
|
-
cfg: Object.fromEntries(
|
|
272
|
-
Object.entries(e).filter(([, r]) => p(r))
|
|
273
|
-
),
|
|
274
|
-
data: Object.fromEntries(
|
|
275
|
-
Object.entries(n).filter(([, r]) => p(r))
|
|
276
|
-
)
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function Q(t) {
|
|
280
|
-
return new Promise((e, n) => {
|
|
281
|
-
t.onsuccess = () => e(t.result), t.onerror = () => n(t.error);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
function X(t) {
|
|
285
|
-
return new Promise((e, n) => {
|
|
286
|
-
t.oncomplete = () => e(), t.onerror = () => n(t.error), t.onabort = () => n(t.error);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
class Z {
|
|
290
|
-
constructor(e, n = {}) {
|
|
291
|
-
u(this, "memoryPayload", { cfg: {}, data: {} });
|
|
292
|
-
u(this, "storage");
|
|
293
|
-
u(this, "indexedDb");
|
|
294
|
-
u(this, "dbPromise");
|
|
295
|
-
this.dbName = e, this.storage = n.storage === void 0 ? H() : n.storage, this.indexedDb = n.indexedDB === void 0 ? Y() : n.indexedDB, this.dbPromise = this.openDatabase();
|
|
296
|
-
}
|
|
297
|
-
get supportsIndexedDb() {
|
|
298
|
-
return this.indexedDb !== null;
|
|
299
|
-
}
|
|
300
|
-
async ready() {
|
|
301
|
-
await this.dbPromise;
|
|
302
|
-
}
|
|
303
|
-
async read(e, n) {
|
|
304
|
-
const r = await this.dbPromise;
|
|
305
|
-
if (r)
|
|
306
|
-
try {
|
|
307
|
-
const a = r.transaction(e, "readonly"), i = await Q(
|
|
308
|
-
a.objectStore(e).get(n)
|
|
309
|
-
);
|
|
310
|
-
if (p(i))
|
|
311
|
-
return w(i);
|
|
312
|
-
} catch {
|
|
313
|
-
}
|
|
314
|
-
return this.readFallback(e, n);
|
|
315
|
-
}
|
|
316
|
-
async write(e, n) {
|
|
317
|
-
const r = await this.dbPromise;
|
|
318
|
-
if (r)
|
|
319
|
-
try {
|
|
320
|
-
const a = r.transaction(e, "readwrite");
|
|
321
|
-
a.objectStore(e).put(w(n)), await X(a);
|
|
322
|
-
return;
|
|
323
|
-
} catch {
|
|
324
|
-
}
|
|
325
|
-
this.writeFallback(e, n);
|
|
326
|
-
}
|
|
327
|
-
async openDatabase() {
|
|
328
|
-
if (!this.indexedDb) return null;
|
|
329
|
-
try {
|
|
330
|
-
return await new Promise((e) => {
|
|
331
|
-
var r;
|
|
332
|
-
const n = (r = this.indexedDb) == null ? void 0 : r.open(this.dbName, 1);
|
|
333
|
-
if (!n) {
|
|
334
|
-
e(null);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
n.onupgradeneeded = () => {
|
|
338
|
-
const a = n.result;
|
|
339
|
-
for (const i of ["cfg", "data"])
|
|
340
|
-
a.objectStoreNames.contains(i) || a.createObjectStore(i, { keyPath: "appChannelId" });
|
|
341
|
-
}, n.onsuccess = () => e(n.result), n.onerror = () => e(null), n.onblocked = () => e(null);
|
|
342
|
-
});
|
|
343
|
-
} catch {
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
readFallback(e, n) {
|
|
348
|
-
const a = this.getFallbackPayload()[e][n];
|
|
349
|
-
return a ? w(a) : null;
|
|
350
|
-
}
|
|
351
|
-
writeFallback(e, n) {
|
|
352
|
-
const r = this.getFallbackPayload();
|
|
353
|
-
if (r[e][n.appChannelId] = w(n), this.memoryPayload.cfg = r.cfg, this.memoryPayload.data = r.data, !!this.storage)
|
|
354
|
-
try {
|
|
355
|
-
this.storage.setItem("permissionPluginData", JSON.stringify(r));
|
|
356
|
-
} catch {
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
getFallbackPayload() {
|
|
360
|
-
if (!this.storage)
|
|
361
|
-
return {
|
|
362
|
-
cfg: { ...this.memoryPayload.cfg },
|
|
363
|
-
data: { ...this.memoryPayload.data }
|
|
364
|
-
};
|
|
365
|
-
try {
|
|
366
|
-
const e = this.storage.getItem("permissionPluginData");
|
|
367
|
-
if (!e)
|
|
368
|
-
return {
|
|
369
|
-
cfg: { ...this.memoryPayload.cfg },
|
|
370
|
-
data: { ...this.memoryPayload.data }
|
|
371
|
-
};
|
|
372
|
-
const n = K(JSON.parse(e));
|
|
373
|
-
return this.memoryPayload.cfg = n.cfg, this.memoryPayload.data = n.data, n;
|
|
374
|
-
} catch {
|
|
375
|
-
return {
|
|
376
|
-
cfg: { ...this.memoryPayload.cfg },
|
|
377
|
-
data: { ...this.memoryPayload.data }
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
function f(t) {
|
|
383
|
-
return typeof t == "object" && t !== null;
|
|
384
|
-
}
|
|
385
|
-
function E(t) {
|
|
386
|
-
return t === "cfg" ? "cfg" : "data";
|
|
387
|
-
}
|
|
388
|
-
function tt(t) {
|
|
389
|
-
return (Array.isArray(t) ? t : t ? [t] : []).filter(
|
|
390
|
-
(n) => !!n && typeof n.appChannelId == "string" && typeof n.dataChannelId == "string" && typeof n.prefixUrl == "string"
|
|
391
|
-
).map((n) => ({ ...n }));
|
|
392
|
-
}
|
|
393
|
-
function et(t) {
|
|
394
|
-
var n, r, a;
|
|
395
|
-
const e = tt(t.apiCfg);
|
|
396
|
-
return {
|
|
397
|
-
apiCfg: e,
|
|
398
|
-
dbName: ((n = t.dbName) == null ? void 0 : n.trim()) || "permissionPluginDb",
|
|
399
|
-
projectAppChannelId: ((r = t.projectAppChannelId) == null ? void 0 : r.trim()) || ((a = e[0]) == null ? void 0 : a.appChannelId) || ""
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
function nt() {
|
|
403
|
-
return typeof window > "u" || typeof window.fetch != "function" ? null : window.fetch.bind(window);
|
|
404
|
-
}
|
|
405
|
-
function rt(t) {
|
|
406
|
-
return `${t.replace(/\/+$/, "")}/getPageTree`;
|
|
407
|
-
}
|
|
408
|
-
function at(t) {
|
|
409
|
-
if (Array.isArray(t))
|
|
410
|
-
return t.filter(f);
|
|
411
|
-
if (!f(t) || !Array.isArray(t.data)) return [];
|
|
412
|
-
const e = t.code;
|
|
413
|
-
return e === void 0 || e === "00000" || e === 0 || e === 200 || e === "200" ? t.data.filter(f) : [];
|
|
414
|
-
}
|
|
415
|
-
function b(t) {
|
|
416
|
-
return f(t) && "eventIdList" in t ? h(t.eventIdList) : h(t);
|
|
417
|
-
}
|
|
418
|
-
function it(t, e) {
|
|
419
|
-
return t ? e ? t[e] ?? [] : t : [];
|
|
420
|
-
}
|
|
421
|
-
class j {
|
|
422
|
-
constructor(e = {}) {
|
|
423
|
-
u(this, "ifSupportIndexDb");
|
|
424
|
-
u(this, "pluginCfg");
|
|
425
|
-
u(this, "revision", N(0));
|
|
426
|
-
u(this, "fetcher");
|
|
427
|
-
u(this, "storage");
|
|
428
|
-
u(this, "initialization");
|
|
429
|
-
this.pluginCfg = et(e), this.storage = new Z(this.pluginCfg.dbName, {
|
|
430
|
-
storage: e.storage,
|
|
431
|
-
indexedDB: e.indexedDB
|
|
432
|
-
}), this.ifSupportIndexDb = this.storage.supportsIndexedDb, this.fetcher = e.fetcher ?? nt(), this.initialization = this.initialize(e.autoSync !== !1).catch(() => {
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
async whenReady() {
|
|
436
|
-
await this.initialization;
|
|
437
|
-
}
|
|
438
|
-
/** Legacy spelling retained for callers that invoked the old IndexedDB setup method. */
|
|
439
|
-
async excuteDbLogic() {
|
|
440
|
-
await this.whenReady();
|
|
441
|
-
}
|
|
442
|
-
/** Legacy spelling retained for callers that invoked the old storage setup method. */
|
|
443
|
-
async excuteLocalStorageLogic() {
|
|
444
|
-
await this.whenReady();
|
|
445
|
-
}
|
|
446
|
-
async loopApiCfgListForGetData() {
|
|
447
|
-
await Promise.allSettled(
|
|
448
|
-
this.pluginCfg.apiCfg.map(async (e) => {
|
|
449
|
-
await this.setData(e.appChannelId, "cfg", e), await this.getDataFromApi(e);
|
|
450
|
-
})
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
async getDataFromApi(e) {
|
|
454
|
-
const n = this.fetcher;
|
|
455
|
-
if (!n) return [];
|
|
456
|
-
try {
|
|
457
|
-
const r = await n(rt(e.prefixUrl), {
|
|
458
|
-
method: "POST",
|
|
459
|
-
headers: {
|
|
460
|
-
"Content-Type": "application/json",
|
|
461
|
-
"x-app_channel_id": e.appChannelId,
|
|
462
|
-
"x-data_channel_id": e.dataChannelId
|
|
463
|
-
},
|
|
464
|
-
body: JSON.stringify(e)
|
|
465
|
-
}), a = at(await r.json());
|
|
466
|
-
return await this.generateSaveToStorageDataAndSave(
|
|
467
|
-
e.appChannelId,
|
|
468
|
-
a
|
|
469
|
-
), a;
|
|
470
|
-
} catch {
|
|
471
|
-
return [];
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
parseStorage(e) {
|
|
475
|
-
return JSON.parse(e);
|
|
476
|
-
}
|
|
477
|
-
async generateSaveToStorageDataAndSave(e, n) {
|
|
478
|
-
await this.setData(e, "data", {
|
|
479
|
-
pageEventData: [...n],
|
|
480
|
-
horizontalPageEventData: M(n)
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
async getPageEventDataFromApiNew() {
|
|
484
|
-
await this.loopApiCfgListForGetData();
|
|
485
|
-
}
|
|
486
|
-
async getPageEventDataFromApiSync(e) {
|
|
487
|
-
return await this.setData(e.appChannelId, "cfg", e), this.getDataFromApi(e);
|
|
488
|
-
}
|
|
489
|
-
async getData(e = this.pluginCfg.projectAppChannelId, n, r = "") {
|
|
490
|
-
await this.storage.ready();
|
|
491
|
-
const a = await this.storage.read(E(n), e);
|
|
492
|
-
return it(a, r);
|
|
493
|
-
}
|
|
494
|
-
async setData(e = this.pluginCfg.projectAppChannelId, n, r, a) {
|
|
495
|
-
await this.storage.ready();
|
|
496
|
-
const i = E(n), s = {
|
|
497
|
-
...await this.storage.read(i, e) ?? { appChannelId: e },
|
|
498
|
-
appChannelId: e
|
|
499
|
-
};
|
|
500
|
-
a ? s[a] = r : f(r) ? Object.assign(s, r) : s.value = r, await this.storage.write(i, s), i === "data" && this.bumpRevision();
|
|
501
|
-
}
|
|
502
|
-
async getPageEventDataFromDbOrLocal(e = this.pluginCfg.projectAppChannelId) {
|
|
503
|
-
await this.whenReady();
|
|
504
|
-
const n = await this.getData(e, "data", "pageEventData");
|
|
505
|
-
return Array.isArray(n) ? n.filter(f) : [];
|
|
506
|
-
}
|
|
507
|
-
async getHorizontalPageEventData(e = this.pluginCfg.projectAppChannelId) {
|
|
508
|
-
await this.whenReady();
|
|
509
|
-
const n = await this.getData(
|
|
510
|
-
e,
|
|
511
|
-
"data",
|
|
512
|
-
"horizontalPageEventData"
|
|
513
|
-
);
|
|
514
|
-
return Array.isArray(n) ? n.filter(f) : [];
|
|
515
|
-
}
|
|
516
|
-
async setEventIdSync(e, n) {
|
|
517
|
-
await this.setData(e, "data", b(n), "eventIdList");
|
|
518
|
-
}
|
|
519
|
-
async getNeedCacheRouter(e = this.pluginCfg.projectAppChannelId) {
|
|
520
|
-
return $(
|
|
521
|
-
await this.getPageEventDataFromDbOrLocal(e)
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
async generateRouterNew(e = this.pluginCfg.projectAppChannelId) {
|
|
525
|
-
const [n, r] = await Promise.all([
|
|
526
|
-
this.getPageEventDataFromDbOrLocal(e),
|
|
527
|
-
this.getData(e, "data", "eventIdList")
|
|
528
|
-
]);
|
|
529
|
-
return J(n, b(r));
|
|
530
|
-
}
|
|
531
|
-
async generatePermissionMgTree(e = this.pluginCfg.projectAppChannelId) {
|
|
532
|
-
return U(
|
|
533
|
-
await this.getPageEventDataFromDbOrLocal(e)
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
|
-
async generatePermissionMgTreeForShop(e = this.pluginCfg.projectAppChannelId, n) {
|
|
537
|
-
return G(
|
|
538
|
-
await this.getPageEventDataFromDbOrLocal(e)
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
async getApiEventList(e = this.pluginCfg.projectAppChannelId, n = []) {
|
|
542
|
-
const [r, a] = await Promise.all([
|
|
543
|
-
this.getPageEventDataFromDbOrLocal(e),
|
|
544
|
-
this.getData(e, "data", "eventIdList")
|
|
545
|
-
]), i = n.length > 0 ? h(n) : b(a);
|
|
546
|
-
return q(r, new Set(i));
|
|
547
|
-
}
|
|
548
|
-
async getNoPmPageTree(e = this.pluginCfg.projectAppChannelId) {
|
|
549
|
-
return V(
|
|
550
|
-
await this.getPageEventDataFromDbOrLocal(e)
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
async checkPermission(e) {
|
|
554
|
-
if (typeof e == "boolean") return e;
|
|
555
|
-
if (typeof e == "function")
|
|
556
|
-
try {
|
|
557
|
-
return !!e();
|
|
558
|
-
} catch {
|
|
559
|
-
return !1;
|
|
560
|
-
}
|
|
561
|
-
const n = h(e);
|
|
562
|
-
if (n.length === 0) return !0;
|
|
563
|
-
const r = this.pluginCfg.projectAppChannelId, [a, i] = await Promise.all([
|
|
564
|
-
this.getData(r, "data", "eventIdList"),
|
|
565
|
-
this.getHorizontalPageEventData(r)
|
|
566
|
-
]), o = new Set(b(a));
|
|
567
|
-
return n.some((s) => o.has(s)) ? !0 : i.some(
|
|
568
|
-
(s) => n.includes(l(s.pageId)) && !g(s)
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
async initialize(e) {
|
|
572
|
-
await this.storage.ready(), await Promise.all(
|
|
573
|
-
this.pluginCfg.apiCfg.map(
|
|
574
|
-
(n) => this.setData(n.appChannelId, "cfg", n)
|
|
575
|
-
)
|
|
576
|
-
), e && await this.getPageEventDataFromApiNew();
|
|
577
|
-
}
|
|
578
|
-
bumpRevision() {
|
|
579
|
-
this.revision.value += 1;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
function st(t) {
|
|
583
|
-
if (typeof t == "boolean") return t;
|
|
584
|
-
if (typeof t == "function")
|
|
585
|
-
try {
|
|
586
|
-
return !!t();
|
|
587
|
-
} catch {
|
|
588
|
-
return !1;
|
|
589
|
-
}
|
|
590
|
-
return h(t).length === 0;
|
|
591
|
-
}
|
|
592
|
-
function ot(t) {
|
|
593
|
-
const e = /* @__PURE__ */ new WeakMap();
|
|
594
|
-
function n(a) {
|
|
595
|
-
var o, s;
|
|
596
|
-
return ((s = (o = a.instance) == null ? void 0 : o.$) == null ? void 0 : s.appContext.provides[C]) ?? t;
|
|
597
|
-
}
|
|
598
|
-
const r = async (a, i, o) => {
|
|
599
|
-
const s = (e.get(a) ?? 0) + 1;
|
|
600
|
-
e.set(a, s);
|
|
601
|
-
const c = n(o), P = c ? await c.checkPermission(i) : st(i);
|
|
602
|
-
s === e.get(a) && !P && a.remove();
|
|
603
|
-
};
|
|
604
|
-
return {
|
|
605
|
-
mounted(a, i) {
|
|
606
|
-
r(a, i.value, i);
|
|
607
|
-
},
|
|
608
|
-
updated(a, i) {
|
|
609
|
-
r(a, i.value, i);
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
const L = /* @__PURE__ */ new WeakMap();
|
|
614
|
-
function ct(t, e = {}) {
|
|
615
|
-
const n = L.get(t);
|
|
616
|
-
if (n)
|
|
617
|
-
return n;
|
|
618
|
-
const r = e.permissionPluginClass ?? new j(e);
|
|
619
|
-
L.set(t, r), t.provide(C, r), t.component("Permission", W), t.directive("permission", ot(r));
|
|
620
|
-
const a = t.config.globalProperties;
|
|
621
|
-
return a.permissionPluginClass = r, r;
|
|
622
|
-
}
|
|
623
|
-
const lt = {
|
|
624
|
-
PermissionPluginClass: j,
|
|
625
|
-
install(t, e = {}) {
|
|
626
|
-
ct(t, e);
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
export {
|
|
630
|
-
lt as default
|
|
631
|
-
};
|