@trimjs/web-app 0.1.0 → 0.1.1

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/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var ve=Object.defineProperty;var Ee=(r,e,t)=>e in r?ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var A=(r,e,t)=>Ee(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class Se{constructor(){A(this,"debug",!1)}setDebug(e){this.debug=e}isDebug(){return this.debug}log(...e){this.debug&&console.log("[Trim App]",...e)}warn(...e){this.debug&&console.warn("[Trim App]",...e)}error(...e){this.debug&&console.error("[Trim App]",...e)}info(...e){this.debug&&console.info("[Trim App]",...e)}}const d=new Se;function Ae(r){const e=/FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g,t={};let n;for(;(n=e.exec(r))!==null;)n[1]&&(t.fnOSVersion=n[1]),n[2]&&(t.fnAppType=n[2]),n[3]&&(t.fnAppVersion=n[3]);return t}const ce=()=>Ae(navigator.userAgent).fnAppVersion;let ae=!1;window.addEventListener("flutterInAppWebViewPlatformReady",()=>{ae=!0});const $e=()=>new Promise(r=>{var e;ae||(e=window.flutter_inappwebview)!=null&&e._platformReady?(d.log("flutter_inappwebview is ready"),r(window.flutter_inappwebview)):window.addEventListener("flutterInAppWebViewPlatformReady",()=>{d.log("flutter_inappwebview is ready"),r(window.flutter_inappwebview)})}),Pe=async(r,e,t)=>{d.log(`callHandler: ${e}, params: ${t}`);const n=await r.callHandler(e,t);if(n)try{const o=JSON.parse(n);d.log(`messageData: ${JSON.stringify(o)}`);const i=JSON.parse(o.result);return d.log(`appMessage: ${JSON.stringify(i)}`),i}catch(o){return d.error(`error: ${o}`),null}return null},Q=new Map;function Me(){window.fnAppMessage=r=>{d.log("app-message",r);const e=JSON.parse(r),t=Q.get(e.reqId);t&&(t(e),Q.delete(e.reqId))}}ce()&&Me();var F=(r=>(r.Call="call",r.Reply="reply",r.Syn="syn",r.SynAck="synAck",r.Ack="ack",r))(F||{}),j=(r=>(r.Fulfilled="fulfilled",r.Rejected="rejected",r))(j||{}),z=(r=>(r.ConnectionDestroyed="ConnectionDestroyed",r.ConnectionTimeout="ConnectionTimeout",r.NoIframeSrc="NoIframeSrc",r))(z||{}),le=(r=>(r.DataCloneError="DataCloneError",r))(le||{}),R=(r=>(r.Message="message",r))(R||{});const _e=(r,e)=>{const t=[];let n=!1;return{destroy(o){n||(n=!0,e(`${r}: Destroying connection`),t.forEach(i=>{i(o)}))},onDestroy(o){n?o():t.push(o)}}},Ce=r=>(...e)=>{r&&console.log("[Penpal]",...e)},G=({name:r,message:e,stack:t})=>({name:r,message:e,stack:t}),Te=r=>{const e=new Error;return Object.keys(r).forEach(t=>e[t]=r[t]),e},Fe=(r,e,t)=>{const{localName:n,local:o,remote:i,originForSending:s,originForReceiving:c}=r;let f=!1;const w=m=>{if(m.source!==i||m.data.penpal!==F.Call)return;if(c!=="*"&&m.origin!==c){t(`${n} received message from origin ${m.origin} which did not match expected origin ${c}`);return}const v=m.data,{methodName:g,args:p,id:b}=v;t(`${n}: Received ${g}() call`);const a=y=>S=>{if(t(`${n}: Sending ${g}() reply`),f){t(`${n}: Unable to send ${g}() reply due to destroyed connection`);return}const $={penpal:F.Reply,id:b,resolution:y,returnValue:S};y===j.Rejected&&S instanceof Error&&($.returnValue=G(S),$.returnValueIsError=!0);try{i.postMessage($,s)}catch(M){if(M.name===le.DataCloneError){const _={penpal:F.Reply,id:b,resolution:j.Rejected,returnValue:G(M),returnValueIsError:!0};i.postMessage(_,s)}throw M}};new Promise(y=>y(e[g].apply(e,p))).then(a(j.Fulfilled),a(j.Rejected))};return o.addEventListener(R.Message,w),()=>{f=!0,o.removeEventListener(R.Message,w)}};let Oe=0;const Re=()=>++Oe,ue=".",fe=r=>r?r.split(ue):[],xe=r=>r.join(ue),De=(r,e)=>{const t=fe(e||"");return t.push(r),xe(t)},Ie=(r,e,t)=>{const n=fe(e);return n.reduce((o,i,s)=>(typeof o[i]>"u"&&(o[i]={}),s===n.length-1&&(o[i]=t),o[i]),r),r},pe=(r,e)=>{const t={};return Object.keys(r).forEach(n=>{const o=r[n],i=De(n,e);typeof o=="object"&&Object.assign(t,pe(o,i)),typeof o=="function"&&(t[i]=o)}),t},je=r=>{const e={};for(const t in r)Ie(e,t,r[t]);return e},ke=(r,e,t,n,o)=>{const{localName:i,local:s,remote:c,originForSending:f,originForReceiving:w}=e;let m=!1;o(`${i}: Connecting call sender`);const v=p=>(...b)=>{o(`${i}: Sending ${p}() call`);let a;try{c.closed&&(a=!0)}catch{a=!0}if(a&&n(),m){const y=new Error(`Unable to send ${p}() call due to destroyed connection`);throw y.code=z.ConnectionDestroyed,y}return new Promise((y,S)=>{const $=Re(),M=C=>{if(C.source!==c||C.data.penpal!==F.Reply||C.data.id!==$)return;if(w!=="*"&&C.origin!==w){o(`${i} received message from origin ${C.origin} which did not match expected origin ${w}`);return}const k=C.data;o(`${i}: Received ${p}() reply`),s.removeEventListener(R.Message,M);let V=k.returnValue;k.returnValueIsError&&(V=Te(V)),(k.resolution===j.Fulfilled?y:S)(V)};s.addEventListener(R.Message,M);const _={penpal:F.Call,id:$,methodName:p,args:b};c.postMessage(_,f)})},g=t.reduce((p,b)=>(p[b]=v(b),p),{});return Object.assign(r,je(g)),()=>{m=!0}},Ve=(r,e)=>{let t;return r!==void 0&&(t=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${r}ms`);n.code=z.ConnectionTimeout,e(n)},r)),()=>{clearTimeout(t)}},We="@fn/micro-app-postmate",qe="0.1.2",Le="module",Ne="src/index.ts",He={dev:"vite",build:"tsc -b && vite build",lint:"eslint ."},Ue=["src","dist"],Be={"@fn/micro-app-event":"^0.0.1",rxjs:"^7.8.0"},Je={"@eslint/js":"^9.13.0","@fn/micro-app-event":"workspace:*",eslint:"^9.13.0",globals:"^15.11.0",typescript:"~5.6.2","typescript-eslint":"^8.11.0",rxjs:"^7.8.0",vite:"^5.4.10"},Ye={registry:"http://verdaccio.teiron-inc.cn:4873"},ze={name:We,version:qe,type:Le,main:Ne,scripts:He,files:Ue,peerDependencies:Be,devDependencies:Je,publishConfig:Ye},Ke=(r,e,t,n,o)=>{const{destroy:i,onDestroy:s}=n;return c=>{if(!(r instanceof RegExp?r.test(c.origin):r==="*"||r===c.origin)){o(`Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${r}`);return}o("Child: Handshake - Received SYN-ACK, responding with ACK");const w=c.origin==="null"?"*":c.origin,m={penpal:F.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(m,w);const v={localName:"Child",local:window,remote:window.parent,originForSending:w,originForReceiving:c.origin},g=Fe(v,e,o);s(g);const p={},b=ke(p,v,c.data.methodNames,i,o);return s(b),p}};function X(r,e){console==null||console.warn(`[fnApp warn]: ${r}`,e)}function Z(r,e){console==null||console.error(`[fnApp error]: ${r}`,e)}const I="_fn_all_event",ee="事件订阅数量为空",W=window.__POWERED_BY_FNAPP__?window.__FNAPP.inject.appEventObjMap:new Map;class te{constructor(e,t){A(this,"id");A(this,"appName");A(this,"eventObj");A(this,"getEventCallBackLength",e=>{var t;return((t=this.eventObj[e])==null?void 0:t.length)||0});console.log("id",e,t),this.id=e,this.appName=t,this.$clear(),W.get(this.id)||W.set(this.id,{}),this.eventObj=W.get(this.id)}$on(e,t){const n=this.eventObj[e];return n?(n.includes(t)||n.push(t),this):(this.eventObj[e]=[t],this)}$onAll(e){return this.$on(I,e)}$once(e,t){t.$__once=!0,this.$on(e,t)}$off(e,t){const n=this.eventObj[e];if(!e||!n||!n.length)return X(`${e} ${ee}`),this;let o,i=n.length;for(;i--;)if(o=n[i],o===t){n.splice(i,1);break}return this}$offAll(e){return this.$off(I,e)}$emit(e,...t){return e=`${this.appName}/${e}`,this.$pureEmit(e,...t)}$pureEmit(e,...t){let n=0,o=0;return W.forEach(i=>{if(i[e])for(let s=i[e].length-1;s>=0;s--){n++;const c=i[e][s];c.$__once&&i[e].splice(s,1);try{c(...t)}catch(f){Z(f)}}if(i[I])for(let s=i[I].length-1;s>=0;s--){n++;const c=i[I][s];c.$__once&&i[I].splice(s,1);try{c(...t)}catch(f){Z(f)}}}),(!e||n===0&&o===0)&&X(`${e} ${ee}`),this}$clear(){const e=W.get(this.id)??{};return Object.keys(e).forEach(n=>delete e[n]),this}}var U=function(r,e){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])},U(r,e)};function de(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");U(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function re(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return i}function J(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))}function O(r){return typeof r=="function"}function Qe(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var N=Qe(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
2
- `+t.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function ne(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var K=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=re(s),f=c.next();!f.done;f=c.next()){var w=f.value;w.remove(this)}}catch(a){e={error:a}}finally{try{f&&!f.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else s.remove(this);var m=this.initialTeardown;if(O(m))try{m()}catch(a){i=a instanceof N?a.errors:[a]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var g=re(v),p=g.next();!p.done;p=g.next()){var b=p.value;try{ie(b)}catch(a){i=i??[],a instanceof N?i=J(J([],B(i)),B(a.errors)):i.push(a)}}}catch(a){n={error:a}}finally{try{p&&!p.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}}if(i)throw new N(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)ie(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ne(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&ne(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();K.EMPTY;function he(r){return r instanceof K||r&&"closed"in r&&O(r.remove)&&O(r.add)&&O(r.unsubscribe)}function ie(r){O(r)?r():r.unsubscribe()}var ge={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ge={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,J([r,e],B(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Xe(r){Ge.setTimeout(function(){throw r})}function oe(){}function Ze(r){r()}var ye=function(r){de(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,he(t)&&t.add(n)):n.destination=nt,n}return e.create=function(t,n,o){return new Y(t,n,o)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(K),et=Function.prototype.bind;function H(r,e){return et.call(r,e)}var tt=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){L(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){L(n)}else L(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){L(t)}},r}(),Y=function(r){de(e,r);function e(t,n,o){var i=r.call(this)||this,s;if(O(t)||!t)s={next:t??void 0,error:n??void 0,complete:o??void 0};else{var c;i&&ge.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},s={next:t.next&&H(t.next,c),error:t.error&&H(t.error,c),complete:t.complete&&H(t.complete,c)}):s=t}return i.destination=new tt(s),i}return e}(ye);function L(r){Xe(r)}function rt(r){throw r}var nt={closed:!0,next:oe,error:rt,complete:oe},it=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ot(r){return r}function st(r){return r.length===0?ot:r.length===1?r[0]:function(t){return r.reduce(function(n,o){return o(n)},t)}}var ct=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var o=this,i=lt(e)?e:new Y(e,t,n);return Ze(function(){var s=o,c=s.operator,f=s.source;i.add(c?c.call(i,f):f?o._subscribe(i):o._trySubscribe(i))}),i},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=se(t),new t(function(o,i){var s=new Y({next:function(c){try{e(c)}catch(f){i(f),s.unsubscribe()}},error:i,complete:o});n.subscribe(s)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[it]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return st(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=se(e),new e(function(n,o){var i;t.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},r.create=function(e){return new r(e)},r}();function se(r){var e;return(e=r??ge.Promise)!==null&&e!==void 0?e:Promise}function at(r){return r&&O(r.next)&&O(r.error)&&O(r.complete)}function lt(r){return r&&r instanceof ye||at(r)&&he(r)}const ut=()=>{try{clearTimeout(void 0)}catch{return!1}return!0},ft=(r={})=>{const{parentOrigin:e="*",timeout:t,debug:n=!1,config:o={}}=r,i=Ce(n),s=_e("App",i),{destroy:c,onDestroy:f}=s,w=()=>{i("Child: Handshake - Sending SYN");const v={penpal:F.Syn},g=e instanceof RegExp?"*":e;window.parent.postMessage(v,g)};return{promise:new Promise((v,g)=>{const p=Ve(t,c),b=a=>{if(ut()&&!(a.source!==parent||!a.data)&&a.data.penpal===F.SynAck){const y=a.data,S=new te(y.id,y.appName),$=new te(y.id+"/api",y.appName),M=y.id,_={},C=l=>"api/"+l,k={$emit:(l,...u)=>{S.getEventCallBackLength(l)>0?S.$pureEmit(l,...u):_==null||_.$off(l,()=>{},!0)},onQueryResult:l=>{$.$pureEmit(C(l.reqid),l)},onOsNotify:l=>{}},V=l=>function(h){const P=C(l);$.$on(P,function D(E){h.next(E),E.reqid&&E.result==="succ"&&(h.complete(),$.$off(P,D))})},me=pe(k),x=Ke(e,me,{...o,postmateVersion:ze.version},s,i)(a),T={},q=x.bus;if(q){const l=(u,h,P)=>{P?(h.$__once=!0,S.$once(u,h)):S.$on(u,h),T[u]?T[u].push(h):(T[u]=[h],q.$on(u,M))};Object.assign(_,q,{$on:l,$off:(u,h,P)=>{var D;if(T[u]){const E=T[u].indexOf(h);E>-1&&(T[u].splice(E,1),S.$off(u,h))}P&&delete T[u],(D=T[u])!=null&&D.length||(q.$off(u,M),delete T[u])},$once:(u,h)=>{l(u,h,!0)}})}const we={...x,bus:_,query:async(l,u)=>{const h=(l==null?void 0:l.reqid)||await x.genReqId();return new Promise((P,D)=>{x.query({...l,reqid:h},u).then(E=>{(E==null?void 0:E.result)==="succ"?P(E):D(E)})})},createObservableQuery:async(l,u={})=>{const h=(l==null?void 0:l.reqid)||await x.genReqId(),P=new ct(V(h));return x.query({...l,reqid:h},{...u,observable:!0}),P}};x&&(window.removeEventListener(R.Message,b),p(),v({methods:we,config:a.data.config}))}};window.addEventListener(R.Message,b),w(),f(a=>{window.removeEventListener(R.Message,b),a&&g(a)})}),destroy(){c()}}},pt=r=>ft({debug:r==null?void 0:r.debug}).promise;class be{constructor(e={}){A(this,"options");A(this,"flutterInAppWebView",null);A(this,"osConnector",null);A(this,"initPromise");A(this,"isWeb",!0);this.options=e,e.debug&&(d.setDebug(!0),d.log("Trim App initialized with debug mode")),d.log("Options:",e),this.initPromise=this.init()}async init(){return d.log("Starting initialization..."),new Promise(e=>{ce()?(this.isWeb=!1,d.log("Initializing mobile platform..."),$e().then(t=>{this.flutterInAppWebView=t,d.log("Mobile platform initialized"),e()})):(this.isWeb=!0,d.log("Initializing web platform..."),pt().then(t=>{this.osConnector=t,d.log("Web platform initialized"),e()}))})}async callAppMethod(e,t){return this.flutterInAppWebView?Pe(this.flutterInAppWebView,e,t):null}async ready(){return this.initPromise}getOptions(){return this.options}setOptions(e){this.options={...this.options,...e},e.debug!==void 0&&d.setDebug(e.debug),d.log("Options updated:",this.options)}async getPlatformConfig(){var e;if(await this.initPromise,this.isWeb){const t=await((e=this.osConnector)==null?void 0:e.methods.getPlatformConfig());if(!t)throw new Error("Failed to get platform config");return t}else{const t=await this.callAppMethod("getAppMessage");if(!t)throw new Error("Failed to get platform config");return{theme:t.nightMode,language:t.language,appVersion:t.appVersion,systemVersion:t.systemVersion,format:{date:t.dateFormat,time:t.timeFormat}}}}async setTitle(e){var t;return await this.initPromise,d.log("Setting title:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setTitle(e):this.callAppMethod("updateTitle",e)}async setExitPageTips(e){var t;return await this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setExitPageTips(e):this.callAppMethod("setExitPageTips",e?JSON.stringify(e):"")}async openFile(e){var t;return await this.initPromise,d.log("Opening file:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFile(e):this.callAppMethod("openFile",e)}async openFileManager(e){var t;return await this.initPromise,d.log("Opening file manager:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFileManagerApp(e):this.callAppMethod("openFileManager",e)}async close(){var e;return await this.initPromise,this.isWeb?(e=this.osConnector)==null?void 0:e.methods.close():this.callAppMethod("exitPage")}async query(e,t){var n;if(await this.initPromise,this.isWeb){const o=await((n=this.osConnector)==null?void 0:n.methods.query(e,t));if(!o)throw new Error("Failed to query");return o}else throw new Error("query is not supported on mobile platform")}async pickFile(e){var t;return await this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.pickFile(e):this.callAppMethod("openFolder",JSON.stringify(e))}}exports.TrimApp=be;exports.default=be;
1
+ "use strict";var Pe=Object.defineProperty,Me=Object.defineProperties;var _e=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var B=(n,e,t)=>e in n?Pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))Ce.call(e,t)&&B(n,t,e[t]);if(ee)for(var t of ee(e))Te.call(e,t)&&B(n,t,e[t]);return n},k=(n,e)=>Me(n,_e(e));var $=(n,e,t)=>B(n,typeof e!="symbol"?e+"":e,t);var w=(n,e,t)=>new Promise((r,i)=>{var o=a=>{try{c(t.next(a))}catch(h){i(h)}},s=a=>{try{c(t.throw(a))}catch(h){i(h)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(o,s);c((t=t.apply(n,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class Fe{constructor(){$(this,"debug",!1)}setDebug(e){this.debug=e}isDebug(){return this.debug}log(...e){this.debug&&console.log("[Trim App]",...e)}warn(...e){this.debug&&console.warn("[Trim App]",...e)}error(...e){this.debug&&console.error("[Trim App]",...e)}info(...e){this.debug&&console.info("[Trim App]",...e)}}const d=new Fe;function Oe(n){const e=/FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g,t={};let r;for(;(r=e.exec(n))!==null;)r[1]&&(t.fnOSVersion=r[1]),r[2]&&(t.fnAppType=r[2]),r[3]&&(t.fnAppVersion=r[3]);return t}const pe=()=>Oe(navigator.userAgent).fnAppVersion;let de=!1;window.addEventListener("flutterInAppWebViewPlatformReady",()=>{de=!0});const Re=()=>new Promise(n=>{var e;de||(e=window.flutter_inappwebview)!=null&&e._platformReady?(d.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)):window.addEventListener("flutterInAppWebViewPlatformReady",()=>{d.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)})}),xe=(n,e,t)=>w(exports,null,function*(){d.log(`callHandler: ${e}, params: ${t}`);const r=yield n.callHandler(e,t);if(r)try{const i=JSON.parse(r);d.log(`messageData: ${JSON.stringify(i)}`);const o=JSON.parse(i.result);return d.log(`appMessage: ${JSON.stringify(o)}`),o}catch(i){return d.error(`error: ${i}`),null}return null}),te=new Map;function De(){window.fnAppMessage=n=>{d.log("app-message",n);const e=JSON.parse(n),t=te.get(e.reqId);t&&(t(e),te.delete(e.reqId))}}pe()&&De();var O=(n=>(n.Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",n))(O||{}),W=(n=>(n.Fulfilled="fulfilled",n.Rejected="rejected",n))(W||{}),X=(n=>(n.ConnectionDestroyed="ConnectionDestroyed",n.ConnectionTimeout="ConnectionTimeout",n.NoIframeSrc="NoIframeSrc",n))(X||{}),he=(n=>(n.DataCloneError="DataCloneError",n))(he||{}),I=(n=>(n.Message="message",n))(I||{});const Ie=(n,e)=>{const t=[];let r=!1;return{destroy(i){r||(r=!0,e(`${n}: Destroying connection`),t.forEach(o=>{o(i)}))},onDestroy(i){r?i():t.push(i)}}},je=n=>(...e)=>{n&&console.log("[Penpal]",...e)},ne=({name:n,message:e,stack:t})=>({name:n,message:e,stack:t}),ke=n=>{const e=new Error;return Object.keys(n).forEach(t=>e[t]=n[t]),e},Ve=(n,e,t)=>{const{localName:r,local:i,remote:o,originForSending:s,originForReceiving:c}=n;let a=!1;const h=v=>{if(v.source!==o||v.data.penpal!==O.Call)return;if(c!=="*"&&v.origin!==c){t(`${r} received message from origin ${v.origin} which did not match expected origin ${c}`);return}const S=v.data,{methodName:g,args:p,id:b}=S;t(`${r}: Received ${g}() call`);const l=y=>A=>{if(t(`${r}: Sending ${g}() reply`),a){t(`${r}: Unable to send ${g}() reply due to destroyed connection`);return}const P={penpal:O.Reply,id:b,resolution:y,returnValue:A};y===W.Rejected&&A instanceof Error&&(P.returnValue=ne(A),P.returnValueIsError=!0);try{o.postMessage(P,s)}catch(M){if(M.name===he.DataCloneError){const _={penpal:O.Reply,id:b,resolution:W.Rejected,returnValue:ne(M),returnValueIsError:!0};o.postMessage(_,s)}throw M}};new Promise(y=>y(e[g].apply(e,p))).then(l(W.Fulfilled),l(W.Rejected))};return i.addEventListener(I.Message,h),()=>{a=!0,i.removeEventListener(I.Message,h)}};let We=0;const qe=()=>++We,ge=".",ye=n=>n?n.split(ge):[],Le=n=>n.join(ge),Ne=(n,e)=>{const t=ye(e||"");return t.push(n),Le(t)},He=(n,e,t)=>{const r=ye(e);return r.reduce((i,o,s)=>(typeof i[o]=="undefined"&&(i[o]={}),s===r.length-1&&(i[o]=t),i[o]),n),n},be=(n,e)=>{const t={};return Object.keys(n).forEach(r=>{const i=n[r],o=Ne(r,e);typeof i=="object"&&Object.assign(t,be(i,o)),typeof i=="function"&&(t[o]=i)}),t},Ue=n=>{const e={};for(const t in n)He(e,t,n[t]);return e},Be=(n,e,t,r,i)=>{const{localName:o,local:s,remote:c,originForSending:a,originForReceiving:h}=e;let v=!1;i(`${o}: Connecting call sender`);const S=p=>(...b)=>{i(`${o}: Sending ${p}() call`);let l;try{c.closed&&(l=!0)}catch(y){l=!0}if(l&&r(),v){const y=new Error(`Unable to send ${p}() call due to destroyed connection`);throw y.code=X.ConnectionDestroyed,y}return new Promise((y,A)=>{const P=qe(),M=C=>{if(C.source!==c||C.data.penpal!==O.Reply||C.data.id!==P)return;if(h!=="*"&&C.origin!==h){i(`${o} received message from origin ${C.origin} which did not match expected origin ${h}`);return}const q=C.data;i(`${o}: Received ${p}() reply`),s.removeEventListener(I.Message,M);let L=q.returnValue;q.returnValueIsError&&(L=ke(L)),(q.resolution===W.Fulfilled?y:A)(L)};s.addEventListener(I.Message,M);const _={penpal:O.Call,id:P,methodName:p,args:b};c.postMessage(_,a)})},g=t.reduce((p,b)=>(p[b]=S(b),p),{});return Object.assign(n,Ue(g)),()=>{v=!0}},Je=(n,e)=>{let t;return n!==void 0&&(t=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${n}ms`);r.code=X.ConnectionTimeout,e(r)},n)),()=>{clearTimeout(t)}},Ye="@fn/micro-app-postmate",ze="0.1.2",Ke="module",Qe="src/index.ts",Ge={dev:"vite",build:"tsc -b && vite build",lint:"eslint ."},Xe=["src","dist"],Ze={"@fn/micro-app-event":"^0.0.1",rxjs:"^7.8.0"},et={"@eslint/js":"^9.13.0","@fn/micro-app-event":"workspace:*",eslint:"^9.13.0",globals:"^15.11.0",typescript:"~5.6.2","typescript-eslint":"^8.11.0",rxjs:"^7.8.0",vite:"^5.4.10"},tt={registry:"http://verdaccio.teiron-inc.cn:4873"},nt={name:Ye,version:ze,type:Ke,main:Qe,scripts:Ge,files:Xe,peerDependencies:Ze,devDependencies:et,publishConfig:tt},rt=(n,e,t,r,i)=>{const{destroy:o,onDestroy:s}=r;return c=>{if(!(n instanceof RegExp?n.test(c.origin):n==="*"||n===c.origin)){i(`Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${n}`);return}i("Child: Handshake - Received SYN-ACK, responding with ACK");const h=c.origin==="null"?"*":c.origin,v={penpal:O.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(v,h);const S={localName:"Child",local:window,remote:window.parent,originForSending:h,originForReceiving:c.origin},g=Ve(S,e,i);s(g);const p={},b=Be(p,S,c.data.methodNames,o,i);return s(b),p}};function re(n,e){console==null||console.warn(`[fnApp warn]: ${n}`,e)}function ie(n,e){console==null||console.error(`[fnApp error]: ${n}`,e)}const V="_fn_all_event",oe="事件订阅数量为空",N=window.__POWERED_BY_FNAPP__?window.__FNAPP.inject.appEventObjMap:new Map;class se{constructor(e,t){$(this,"id");$(this,"appName");$(this,"eventObj");$(this,"getEventCallBackLength",e=>{var t;return((t=this.eventObj[e])==null?void 0:t.length)||0});console.log("id",e,t),this.id=e,this.appName=t,this.$clear(),N.get(this.id)||N.set(this.id,{}),this.eventObj=N.get(this.id)}$on(e,t){const r=this.eventObj[e];return r?(r.includes(t)||r.push(t),this):(this.eventObj[e]=[t],this)}$onAll(e){return this.$on(V,e)}$once(e,t){t.$__once=!0,this.$on(e,t)}$off(e,t){const r=this.eventObj[e];if(!e||!r||!r.length)return re(`${e} ${oe}`),this;let i,o=r.length;for(;o--;)if(i=r[o],i===t){r.splice(o,1);break}return this}$offAll(e){return this.$off(V,e)}$emit(e,...t){return e=`${this.appName}/${e}`,this.$pureEmit(e,...t)}$pureEmit(e,...t){let r=0,i=0;return N.forEach(o=>{if(o[e])for(let s=o[e].length-1;s>=0;s--){r++;const c=o[e][s];c.$__once&&o[e].splice(s,1);try{c(...t)}catch(a){ie(a)}}if(o[V])for(let s=o[V].length-1;s>=0;s--){r++;const c=o[V][s];c.$__once&&o[V].splice(s,1);try{c(...t)}catch(a){ie(a)}}}),(!e||r===0&&i===0)&&re(`${e} ${oe}`),this}$clear(){var r;const e=(r=N.get(this.id))!=null?r:{};return Object.keys(e).forEach(i=>delete e[i]),this}}var z=function(n,e){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},z(n,e)};function me(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ce(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(s)throw s.error}}return o}function Q(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))}function R(n){return typeof n=="function"}function it(n){var e=function(r){Error.call(r),r.stack=new Error().stack},t=n(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var J=it(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
2
+ `+t.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function ae(n,e){if(n){var t=n.indexOf(e);0<=t&&n.splice(t,1)}}var Z=function(){function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var e,t,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=ce(s),a=c.next();!a.done;a=c.next()){var h=a.value;h.remove(this)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else s.remove(this);var v=this.initialTeardown;if(R(v))try{v()}catch(l){o=l instanceof J?l.errors:[l]}var S=this._finalizers;if(S){this._finalizers=null;try{for(var g=ce(S),p=g.next();!p.done;p=g.next()){var b=p.value;try{le(b)}catch(l){o=o!=null?o:[],l instanceof J?o=Q(Q([],K(o)),K(l.errors)):o.push(l)}}}catch(l){r={error:l}}finally{try{p&&!p.done&&(i=g.return)&&i.call(g)}finally{if(r)throw r.error}}}if(o)throw new J(o)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)le(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ae(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&ae(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=function(){var e=new n;return e.closed=!0,e}(),n}();Z.EMPTY;function we(n){return n instanceof Z||n&&"closed"in n&&R(n.remove)&&R(n.add)&&R(n.unsubscribe)}function le(n){R(n)?n():n.unsubscribe()}var ve={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ot={setTimeout:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setTimeout.apply(void 0,Q([n,e],K(t)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function st(n){ot.setTimeout(function(){throw n})}function ue(){}function ct(n){n()}var Ee=function(n){me(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,we(t)&&t.add(r)):r.destination=ft,r}return e.create=function(t,r,i){return new G(t,r,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Z),at=Function.prototype.bind;function Y(n,e){return at.call(n,e)}var lt=function(){function n(e){this.partialObserver=e}return n.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){U(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){U(r)}else U(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){U(t)}},n}(),G=function(n){me(e,n);function e(t,r,i){var o=n.call(this)||this,s;if(R(t)||!t)s={next:t!=null?t:void 0,error:r!=null?r:void 0,complete:i!=null?i:void 0};else{var c;o&&ve.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&Y(t.next,c),error:t.error&&Y(t.error,c),complete:t.complete&&Y(t.complete,c)}):s=t}return o.destination=new lt(s),o}return e}(Ee);function U(n){st(n)}function ut(n){throw n}var ft={closed:!0,next:ue,error:ut,complete:ue},pt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function dt(n){return n}function ht(n){return n.length===0?dt:n.length===1?n[0]:function(t){return n.reduce(function(r,i){return i(r)},t)}}var gt=function(){function n(e){e&&(this._subscribe=e)}return n.prototype.lift=function(e){var t=new n;return t.source=this,t.operator=e,t},n.prototype.subscribe=function(e,t,r){var i=this,o=bt(e)?e:new G(e,t,r);return ct(function(){var s=i,c=s.operator,a=s.source;o.add(c?c.call(o,a):a?i._subscribe(o):i._trySubscribe(o))}),o},n.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},n.prototype.forEach=function(e,t){var r=this;return t=fe(t),new t(function(i,o){var s=new G({next:function(c){try{e(c)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},n.prototype[pt]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ht(e)(this)},n.prototype.toPromise=function(e){var t=this;return e=fe(e),new e(function(r,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(e){return new n(e)},n}();function fe(n){var e;return(e=n!=null?n:ve.Promise)!==null&&e!==void 0?e:Promise}function yt(n){return n&&R(n.next)&&R(n.error)&&R(n.complete)}function bt(n){return n&&n instanceof Ee||yt(n)&&we(n)}const mt=()=>{try{clearTimeout(void 0)}catch(n){return!1}return!0},wt=(n={})=>{const{parentOrigin:e="*",timeout:t,debug:r=!1,config:i={}}=n,o=je(r),s=Ie("App",o),{destroy:c,onDestroy:a}=s,h=()=>{o("Child: Handshake - Sending SYN");const S={penpal:O.Syn},g=e instanceof RegExp?"*":e;window.parent.postMessage(S,g)};return{promise:new Promise((S,g)=>{const p=Je(t,c),b=l=>{if(mt()&&!(l.source!==parent||!l.data)&&l.data.penpal===O.SynAck){const y=l.data,A=new se(y.id,y.appName),P=new se(y.id+"/api",y.appName),M=y.id,_={},C=u=>"api/"+u,q={$emit:(u,...f)=>{A.getEventCallBackLength(u)>0?A.$pureEmit(u,...f):_==null||_.$off(u,()=>{},!0)},onQueryResult:u=>{P.$pureEmit(C(u.reqid),u)},onOsNotify:u=>{}},L=u=>function(m){const x=C(u);P.$on(x,function F(E){m.next(E),E.reqid&&E.result==="succ"&&(m.complete(),P.$off(x,F))})},Ae=be(q),j=rt(e,Ae,k(D({},i),{postmateVersion:nt.version}),s,o)(l),T={},H=j.bus;if(H){const u=(f,m,x)=>{x?(m.$__once=!0,A.$once(f,m)):A.$on(f,m),T[f]?T[f].push(m):(T[f]=[m],H.$on(f,M))};Object.assign(_,H,{$on:u,$off:(f,m,x)=>{var F;if(T[f]){const E=T[f].indexOf(m);E>-1&&(T[f].splice(E,1),A.$off(f,m))}x&&delete T[f],(F=T[f])!=null&&F.length||(H.$off(f,M),delete T[f])},$once:(f,m)=>{u(f,m,!0)}})}const $e=k(D({},j),{bus:_,query:(u,f)=>w(exports,null,function*(){const m=(u==null?void 0:u.reqid)||(yield j.genReqId());return new Promise((x,F)=>{j.query(k(D({},u),{reqid:m}),f).then(E=>{(E==null?void 0:E.result)==="succ"?x(E):F(E)})})}),createObservableQuery:(m,...x)=>w(exports,[m,...x],function*(u,f={}){const F=(u==null?void 0:u.reqid)||(yield j.genReqId()),E=new gt(L(F));return j.query(k(D({},u),{reqid:F}),k(D({},f),{observable:!0})),E})});j&&(window.removeEventListener(I.Message,b),p(),S({methods:$e,config:l.data.config}))}};window.addEventListener(I.Message,b),h(),a(l=>{window.removeEventListener(I.Message,b),l&&g(l)})}),destroy(){c()}}},vt=n=>wt({debug:n==null?void 0:n.debug}).promise;class Se{constructor(e={}){$(this,"options");$(this,"flutterInAppWebView",null);$(this,"osConnector",null);$(this,"initPromise");$(this,"isWeb",!0);this.options=e,e.debug&&(d.setDebug(!0),d.log("Trim App initialized with debug mode")),d.log("Options:",e),this.initPromise=this.init()}init(){return w(this,null,function*(){return d.log("Starting initialization..."),new Promise(e=>{pe()?(this.isWeb=!1,d.log("Initializing mobile platform..."),Re().then(t=>{this.flutterInAppWebView=t,d.log("Mobile platform initialized"),e()})):(this.isWeb=!0,d.log("Initializing web platform..."),vt().then(t=>{this.osConnector=t,d.log("Web platform initialized"),e()}))})})}callAppMethod(e,t){return w(this,null,function*(){return this.flutterInAppWebView?xe(this.flutterInAppWebView,e,t):null})}ready(){return w(this,null,function*(){return this.initPromise})}getOptions(){return this.options}setOptions(e){this.options=D(D({},this.options),e),e.debug!==void 0&&d.setDebug(e.debug),d.log("Options updated:",this.options)}getPlatformConfig(){return w(this,null,function*(){var e;if(yield this.initPromise,this.isWeb){const t=yield(e=this.osConnector)==null?void 0:e.methods.getPlatformConfig();if(!t)throw new Error("Failed to get platform config");return t}else{const t=yield this.callAppMethod("getAppMessage");if(!t)throw new Error("Failed to get platform config");return{theme:t.nightMode,language:t.language,appVersion:t.appVersion,systemVersion:t.systemVersion,format:{date:t.dateFormat,time:t.timeFormat}}}})}setTitle(e){return w(this,null,function*(){var t;return yield this.initPromise,d.log("Setting title:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setTitle(e):this.callAppMethod("updateTitle",e)})}setExitPageTips(e){return w(this,null,function*(){var t;return yield this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setExitPageTips(e):this.callAppMethod("setExitPageTips",e?JSON.stringify(e):"")})}openFile(e){return w(this,null,function*(){var t;return yield this.initPromise,d.log("Opening file:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFile(e):this.callAppMethod("openFile",e)})}openFileManager(e){return w(this,null,function*(){var t;return yield this.initPromise,d.log("Opening file manager:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFileManagerApp(e):this.callAppMethod("openFileManager",e)})}close(){return w(this,null,function*(){var e;return yield this.initPromise,this.isWeb?(e=this.osConnector)==null?void 0:e.methods.close():this.callAppMethod("exitPage")})}query(e,t){return w(this,null,function*(){var r;if(yield this.initPromise,this.isWeb){const i=yield(r=this.osConnector)==null?void 0:r.methods.query(e,t);if(!i)throw new Error("Failed to query");return i}else throw new Error("query is not supported on mobile platform")})}pickFile(e){return w(this,null,function*(){var t;return yield this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.pickFile(e):this.callAppMethod("openFolder",JSON.stringify(e))})}}exports.TrimApp=Se;exports.default=Se;
@@ -1,3 +1,3 @@
1
- var TrimApp=function($){"use strict";var rt=Object.defineProperty;var it=($,_,l)=>_ in $?rt($,_,{enumerable:!0,configurable:!0,writable:!0,value:l}):$[_]=l;var A=($,_,l)=>it($,typeof _!="symbol"?_+"":_,l);class _{constructor(){A(this,"debug",!1)}setDebug(e){this.debug=e}isDebug(){return this.debug}log(...e){this.debug&&console.log("[Trim App]",...e)}warn(...e){this.debug&&console.warn("[Trim App]",...e)}error(...e){this.debug&&console.error("[Trim App]",...e)}info(...e){this.debug&&console.info("[Trim App]",...e)}}const l=new _;function ve(n){const e=/FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g,t={};let r;for(;(r=e.exec(n))!==null;)r[1]&&(t.fnOSVersion=r[1]),r[2]&&(t.fnAppType=r[2]),r[3]&&(t.fnAppVersion=r[3]);return t}const X=()=>ve(navigator.userAgent).fnAppVersion;let Z=!1;window.addEventListener("flutterInAppWebViewPlatformReady",()=>{Z=!0});const Ee=()=>new Promise(n=>{var e;Z||(e=window.flutter_inappwebview)!=null&&e._platformReady?(l.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)):window.addEventListener("flutterInAppWebViewPlatformReady",()=>{l.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)})}),Se=async(n,e,t)=>{l.log(`callHandler: ${e}, params: ${t}`);const r=await n.callHandler(e,t);if(r)try{const o=JSON.parse(r);l.log(`messageData: ${JSON.stringify(o)}`);const i=JSON.parse(o.result);return l.log(`appMessage: ${JSON.stringify(i)}`),i}catch(o){return l.error(`error: ${o}`),null}return null},ee=new Map;function Ae(){window.fnAppMessage=n=>{l.log("app-message",n);const e=JSON.parse(n),t=ee.get(e.reqId);t&&(t(e),ee.delete(e.reqId))}}X()&&Ae();var C=(n=>(n.Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",n))(C||{}),j=(n=>(n.Fulfilled="fulfilled",n.Rejected="rejected",n))(j||{}),U=(n=>(n.ConnectionDestroyed="ConnectionDestroyed",n.ConnectionTimeout="ConnectionTimeout",n.NoIframeSrc="NoIframeSrc",n))(U||{}),te=(n=>(n.DataCloneError="DataCloneError",n))(te||{}),x=(n=>(n.Message="message",n))(x||{});const $e=(n,e)=>{const t=[];let r=!1;return{destroy(o){r||(r=!0,e(`${n}: Destroying connection`),t.forEach(i=>{i(o)}))},onDestroy(o){r?o():t.push(o)}}},Pe=n=>(...e)=>{n&&console.log("[Penpal]",...e)},ne=({name:n,message:e,stack:t})=>({name:n,message:e,stack:t}),Me=n=>{const e=new Error;return Object.keys(n).forEach(t=>e[t]=n[t]),e},_e=(n,e,t)=>{const{localName:r,local:o,remote:i,originForSending:s,originForReceiving:c}=n;let p=!1;const w=b=>{if(b.source!==i||b.data.penpal!==C.Call)return;if(c!=="*"&&b.origin!==c){t(`${r} received message from origin ${b.origin} which did not match expected origin ${c}`);return}const v=b.data,{methodName:g,args:d,id:m}=v;t(`${r}: Received ${g}() call`);const a=y=>S=>{if(t(`${r}: Sending ${g}() reply`),p){t(`${r}: Unable to send ${g}() reply due to destroyed connection`);return}const P={penpal:C.Reply,id:m,resolution:y,returnValue:S};y===j.Rejected&&S instanceof Error&&(P.returnValue=ne(S),P.returnValueIsError=!0);try{i.postMessage(P,s)}catch(F){if(F.name===te.DataCloneError){const O={penpal:C.Reply,id:m,resolution:j.Rejected,returnValue:ne(F),returnValueIsError:!0};i.postMessage(O,s)}throw F}};new Promise(y=>y(e[g].apply(e,d))).then(a(j.Fulfilled),a(j.Rejected))};return o.addEventListener(x.Message,w),()=>{p=!0,o.removeEventListener(x.Message,w)}};let Ce=0;const Te=()=>++Ce,re=".",ie=n=>n?n.split(re):[],Fe=n=>n.join(re),Oe=(n,e)=>{const t=ie(e||"");return t.push(n),Fe(t)},Re=(n,e,t)=>{const r=ie(e);return r.reduce((o,i,s)=>(typeof o[i]>"u"&&(o[i]={}),s===r.length-1&&(o[i]=t),o[i]),n),n},oe=(n,e)=>{const t={};return Object.keys(n).forEach(r=>{const o=n[r],i=Oe(r,e);typeof o=="object"&&Object.assign(t,oe(o,i)),typeof o=="function"&&(t[i]=o)}),t},De=n=>{const e={};for(const t in n)Re(e,t,n[t]);return e},xe=(n,e,t,r,o)=>{const{localName:i,local:s,remote:c,originForSending:p,originForReceiving:w}=e;let b=!1;o(`${i}: Connecting call sender`);const v=d=>(...m)=>{o(`${i}: Sending ${d}() call`);let a;try{c.closed&&(a=!0)}catch{a=!0}if(a&&r(),b){const y=new Error(`Unable to send ${d}() call due to destroyed connection`);throw y.code=U.ConnectionDestroyed,y}return new Promise((y,S)=>{const P=Te(),F=R=>{if(R.source!==c||R.data.penpal!==C.Reply||R.data.id!==P)return;if(w!=="*"&&R.origin!==w){o(`${i} received message from origin ${R.origin} which did not match expected origin ${w}`);return}const q=R.data;o(`${i}: Received ${d}() reply`),s.removeEventListener(x.Message,F);let L=q.returnValue;q.returnValueIsError&&(L=Me(L)),(q.resolution===j.Fulfilled?y:S)(L)};s.addEventListener(x.Message,F);const O={penpal:C.Call,id:P,methodName:d,args:m};c.postMessage(O,p)})},g=t.reduce((d,m)=>(d[m]=v(m),d),{});return Object.assign(n,De(g)),()=>{b=!0}},Ie=(n,e)=>{let t;return n!==void 0&&(t=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${n}ms`);r.code=U.ConnectionTimeout,e(r)},n)),()=>{clearTimeout(t)}},je={name:"@fn/micro-app-postmate",version:"0.1.2",type:"module",main:"src/index.ts",scripts:{dev:"vite",build:"tsc -b && vite build",lint:"eslint ."},files:["src","dist"],peerDependencies:{"@fn/micro-app-event":"^0.0.1",rxjs:"^7.8.0"},devDependencies:{"@eslint/js":"^9.13.0","@fn/micro-app-event":"workspace:*",eslint:"^9.13.0",globals:"^15.11.0",typescript:"~5.6.2","typescript-eslint":"^8.11.0",rxjs:"^7.8.0",vite:"^5.4.10"},publishConfig:{registry:"http://verdaccio.teiron-inc.cn:4873"}},ke=(n,e,t,r,o)=>{const{destroy:i,onDestroy:s}=r;return c=>{if(!(n instanceof RegExp?n.test(c.origin):n==="*"||n===c.origin)){o(`Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${n}`);return}o("Child: Handshake - Received SYN-ACK, responding with ACK");const w=c.origin==="null"?"*":c.origin,b={penpal:C.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(b,w);const v={localName:"Child",local:window,remote:window.parent,originForSending:w,originForReceiving:c.origin},g=_e(v,e,o);s(g);const d={},m=xe(d,v,c.data.methodNames,i,o);return s(m),d}};function se(n,e){console==null||console.warn(`[fnApp warn]: ${n}`,e)}function ce(n,e){console==null||console.error(`[fnApp error]: ${n}`,e)}const k="_fn_all_event",ae="事件订阅数量为空",W=window.__POWERED_BY_FNAPP__?window.__FNAPP.inject.appEventObjMap:new Map;class le{constructor(e,t){A(this,"id");A(this,"appName");A(this,"eventObj");A(this,"getEventCallBackLength",e=>{var t;return((t=this.eventObj[e])==null?void 0:t.length)||0});console.log("id",e,t),this.id=e,this.appName=t,this.$clear(),W.get(this.id)||W.set(this.id,{}),this.eventObj=W.get(this.id)}$on(e,t){const r=this.eventObj[e];return r?(r.includes(t)||r.push(t),this):(this.eventObj[e]=[t],this)}$onAll(e){return this.$on(k,e)}$once(e,t){t.$__once=!0,this.$on(e,t)}$off(e,t){const r=this.eventObj[e];if(!e||!r||!r.length)return se(`${e} ${ae}`),this;let o,i=r.length;for(;i--;)if(o=r[i],o===t){r.splice(i,1);break}return this}$offAll(e){return this.$off(k,e)}$emit(e,...t){return e=`${this.appName}/${e}`,this.$pureEmit(e,...t)}$pureEmit(e,...t){let r=0,o=0;return W.forEach(i=>{if(i[e])for(let s=i[e].length-1;s>=0;s--){r++;const c=i[e][s];c.$__once&&i[e].splice(s,1);try{c(...t)}catch(p){ce(p)}}if(i[k])for(let s=i[k].length-1;s>=0;s--){r++;const c=i[k][s];c.$__once&&i[k].splice(s,1);try{c(...t)}catch(p){ce(p)}}}),(!e||r===0&&o===0)&&se(`${e} ${ae}`),this}$clear(){const e=W.get(this.id)??{};return Object.keys(e).forEach(r=>delete e[r]),this}}var B=function(n,e){return B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])},B(n,e)};function ue(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");B(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function fe(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(s)throw s.error}}return i}function Y(n,e,t){if(t||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;function T(n){return typeof n=="function"}function Ve(n){var e=function(r){Error.call(r),r.stack=new Error().stack},t=n(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var z=Ve(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
1
+ var TrimApp=function(g){"use strict";var at=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ce=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var ae=(g,d,a)=>d in g?at(g,d,{enumerable:!0,configurable:!0,writable:!0,value:a}):g[d]=a,V=(g,d)=>{for(var a in d||(d={}))ft.call(d,a)&&ae(g,a,d[a]);if(Ce)for(var a of Ce(d))pt.call(d,a)&&ae(g,a,d[a]);return g},N=(g,d)=>lt(g,ut(d));var M=(g,d,a)=>ae(g,typeof d!="symbol"?d+"":d,a);var v=(g,d,a)=>new Promise((X,H)=>{var K=_=>{try{U(a.next(_))}catch(B){H(B)}},Z=_=>{try{U(a.throw(_))}catch(B){H(B)}},U=_=>_.done?X(_.value):Promise.resolve(_.value).then(K,Z);U((a=a.apply(g,d)).next())});class d{constructor(){M(this,"debug",!1)}setDebug(e){this.debug=e}isDebug(){return this.debug}log(...e){this.debug&&console.log("[Trim App]",...e)}warn(...e){this.debug&&console.warn("[Trim App]",...e)}error(...e){this.debug&&console.error("[Trim App]",...e)}info(...e){this.debug&&console.info("[Trim App]",...e)}}const a=new d;function X(n){const e=/FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g,t={};let r;for(;(r=e.exec(n))!==null;)r[1]&&(t.fnOSVersion=r[1]),r[2]&&(t.fnAppType=r[2]),r[3]&&(t.fnAppVersion=r[3]);return t}const H=()=>X(navigator.userAgent).fnAppVersion;let K=!1;window.addEventListener("flutterInAppWebViewPlatformReady",()=>{K=!0});const Z=()=>new Promise(n=>{var e;K||(e=window.flutter_inappwebview)!=null&&e._platformReady?(a.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)):window.addEventListener("flutterInAppWebViewPlatformReady",()=>{a.log("flutter_inappwebview is ready"),n(window.flutter_inappwebview)})}),U=(n,e,t)=>v(this,null,function*(){a.log(`callHandler: ${e}, params: ${t}`);const r=yield n.callHandler(e,t);if(r)try{const o=JSON.parse(r);a.log(`messageData: ${JSON.stringify(o)}`);const i=JSON.parse(o.result);return a.log(`appMessage: ${JSON.stringify(i)}`),i}catch(o){return a.error(`error: ${o}`),null}return null}),_=new Map;function B(){window.fnAppMessage=n=>{a.log("app-message",n);const e=JSON.parse(n),t=_.get(e.reqId);t&&(t(e),_.delete(e.reqId))}}H()&&B();var T=(n=>(n.Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",n))(T||{}),q=(n=>(n.Fulfilled="fulfilled",n.Rejected="rejected",n))(q||{}),ee=(n=>(n.ConnectionDestroyed="ConnectionDestroyed",n.ConnectionTimeout="ConnectionTimeout",n.NoIframeSrc="NoIframeSrc",n))(ee||{}),le=(n=>(n.DataCloneError="DataCloneError",n))(le||{}),j=(n=>(n.Message="message",n))(j||{});const Te=(n,e)=>{const t=[];let r=!1;return{destroy(o){r||(r=!0,e(`${n}: Destroying connection`),t.forEach(i=>{i(o)}))},onDestroy(o){r?o():t.push(o)}}},Fe=n=>(...e)=>{n&&console.log("[Penpal]",...e)},ue=({name:n,message:e,stack:t})=>({name:n,message:e,stack:t}),Oe=n=>{const e=new Error;return Object.keys(n).forEach(t=>e[t]=n[t]),e},Re=(n,e,t)=>{const{localName:r,local:o,remote:i,originForSending:s,originForReceiving:c}=n;let p=!1;const A=E=>{if(E.source!==i||E.data.penpal!==T.Call)return;if(c!=="*"&&E.origin!==c){t(`${r} received message from origin ${E.origin} which did not match expected origin ${c}`);return}const $=E.data,{methodName:y,args:h,id:b}=$;t(`${r}: Received ${y}() call`);const l=m=>P=>{if(t(`${r}: Sending ${y}() reply`),p){t(`${r}: Unable to send ${y}() reply due to destroyed connection`);return}const C={penpal:T.Reply,id:b,resolution:m,returnValue:P};m===q.Rejected&&P instanceof Error&&(C.returnValue=ue(P),C.returnValueIsError=!0);try{i.postMessage(C,s)}catch(O){if(O.name===le.DataCloneError){const R={penpal:T.Reply,id:b,resolution:q.Rejected,returnValue:ue(O),returnValueIsError:!0};i.postMessage(R,s)}throw O}};new Promise(m=>m(e[y].apply(e,h))).then(l(q.Fulfilled),l(q.Rejected))};return o.addEventListener(j.Message,A),()=>{p=!0,o.removeEventListener(j.Message,A)}};let De=0;const xe=()=>++De,fe=".",pe=n=>n?n.split(fe):[],Ie=n=>n.join(fe),je=(n,e)=>{const t=pe(e||"");return t.push(n),Ie(t)},ke=(n,e,t)=>{const r=pe(e);return r.reduce((o,i,s)=>(typeof o[i]=="undefined"&&(o[i]={}),s===r.length-1&&(o[i]=t),o[i]),n),n},de=(n,e)=>{const t={};return Object.keys(n).forEach(r=>{const o=n[r],i=je(r,e);typeof o=="object"&&Object.assign(t,de(o,i)),typeof o=="function"&&(t[i]=o)}),t},Ve=n=>{const e={};for(const t in n)ke(e,t,n[t]);return e},We=(n,e,t,r,o)=>{const{localName:i,local:s,remote:c,originForSending:p,originForReceiving:A}=e;let E=!1;o(`${i}: Connecting call sender`);const $=h=>(...b)=>{o(`${i}: Sending ${h}() call`);let l;try{c.closed&&(l=!0)}catch(m){l=!0}if(l&&r(),E){const m=new Error(`Unable to send ${h}() call due to destroyed connection`);throw m.code=ee.ConnectionDestroyed,m}return new Promise((m,P)=>{const C=xe(),O=D=>{if(D.source!==c||D.data.penpal!==T.Reply||D.data.id!==C)return;if(A!=="*"&&D.origin!==A){o(`${i} received message from origin ${D.origin} which did not match expected origin ${A}`);return}const Y=D.data;o(`${i}: Received ${h}() reply`),s.removeEventListener(j.Message,O);let z=Y.returnValue;Y.returnValueIsError&&(z=Oe(z)),(Y.resolution===q.Fulfilled?m:P)(z)};s.addEventListener(j.Message,O);const R={penpal:T.Call,id:C,methodName:h,args:b};c.postMessage(R,p)})},y=t.reduce((h,b)=>(h[b]=$(b),h),{});return Object.assign(n,Ve(y)),()=>{E=!0}},qe=(n,e)=>{let t;return n!==void 0&&(t=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${n}ms`);r.code=ee.ConnectionTimeout,e(r)},n)),()=>{clearTimeout(t)}},Le={name:"@fn/micro-app-postmate",version:"0.1.2",type:"module",main:"src/index.ts",scripts:{dev:"vite",build:"tsc -b && vite build",lint:"eslint ."},files:["src","dist"],peerDependencies:{"@fn/micro-app-event":"^0.0.1",rxjs:"^7.8.0"},devDependencies:{"@eslint/js":"^9.13.0","@fn/micro-app-event":"workspace:*",eslint:"^9.13.0",globals:"^15.11.0",typescript:"~5.6.2","typescript-eslint":"^8.11.0",rxjs:"^7.8.0",vite:"^5.4.10"},publishConfig:{registry:"http://verdaccio.teiron-inc.cn:4873"}},Ne=(n,e,t,r,o)=>{const{destroy:i,onDestroy:s}=r;return c=>{if(!(n instanceof RegExp?n.test(c.origin):n==="*"||n===c.origin)){o(`Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${n}`);return}o("Child: Handshake - Received SYN-ACK, responding with ACK");const A=c.origin==="null"?"*":c.origin,E={penpal:T.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(E,A);const $={localName:"Child",local:window,remote:window.parent,originForSending:A,originForReceiving:c.origin},y=Re($,e,o);s(y);const h={},b=We(h,$,c.data.methodNames,i,o);return s(b),h}};function he(n,e){console==null||console.warn(`[fnApp warn]: ${n}`,e)}function ge(n,e){console==null||console.error(`[fnApp error]: ${n}`,e)}const L="_fn_all_event",ye="事件订阅数量为空",J=window.__POWERED_BY_FNAPP__?window.__FNAPP.inject.appEventObjMap:new Map;class me{constructor(e,t){M(this,"id");M(this,"appName");M(this,"eventObj");M(this,"getEventCallBackLength",e=>{var t;return((t=this.eventObj[e])==null?void 0:t.length)||0});console.log("id",e,t),this.id=e,this.appName=t,this.$clear(),J.get(this.id)||J.set(this.id,{}),this.eventObj=J.get(this.id)}$on(e,t){const r=this.eventObj[e];return r?(r.includes(t)||r.push(t),this):(this.eventObj[e]=[t],this)}$onAll(e){return this.$on(L,e)}$once(e,t){t.$__once=!0,this.$on(e,t)}$off(e,t){const r=this.eventObj[e];if(!e||!r||!r.length)return he(`${e} ${ye}`),this;let o,i=r.length;for(;i--;)if(o=r[i],o===t){r.splice(i,1);break}return this}$offAll(e){return this.$off(L,e)}$emit(e,...t){return e=`${this.appName}/${e}`,this.$pureEmit(e,...t)}$pureEmit(e,...t){let r=0,o=0;return J.forEach(i=>{if(i[e])for(let s=i[e].length-1;s>=0;s--){r++;const c=i[e][s];c.$__once&&i[e].splice(s,1);try{c(...t)}catch(p){ge(p)}}if(i[L])for(let s=i[L].length-1;s>=0;s--){r++;const c=i[L][s];c.$__once&&i[L].splice(s,1);try{c(...t)}catch(p){ge(p)}}}),(!e||r===0&&o===0)&&he(`${e} ${ye}`),this}$clear(){var r;const e=(r=J.get(this.id))!=null?r:{};return Object.keys(e).forEach(o=>delete e[o]),this}}var te=function(n,e){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])},te(n,e)};function be(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");te(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function we(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ne(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(s)throw s.error}}return i}function re(n,e,t){if(t||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;function F(n){return typeof n=="function"}function He(n){var e=function(r){Error.call(r),r.stack=new Error().stack},t=n(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ie=He(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
2
2
  `+t.map(function(r,o){return o+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function pe(n,e){if(n){var t=n.indexOf(e);0<=t&&n.splice(t,1)}}var K=function(){function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var e,t,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=fe(s),p=c.next();!p.done;p=c.next()){var w=p.value;w.remove(this)}}catch(a){e={error:a}}finally{try{p&&!p.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else s.remove(this);var b=this.initialTeardown;if(T(b))try{b()}catch(a){i=a instanceof z?a.errors:[a]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var g=fe(v),d=g.next();!d.done;d=g.next()){var m=d.value;try{he(m)}catch(a){i=i??[],a instanceof z?i=Y(Y([],J(i)),J(a.errors)):i.push(a)}}}catch(a){r={error:a}}finally{try{d&&!d.done&&(o=g.return)&&o.call(g)}finally{if(r)throw r.error}}}if(i)throw new z(i)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)he(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&pe(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&pe(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=function(){var e=new n;return e.closed=!0,e}(),n}();K.EMPTY;function de(n){return n instanceof K||n&&"closed"in n&&T(n.remove)&&T(n.add)&&T(n.unsubscribe)}function he(n){T(n)?n():n.unsubscribe()}var ge={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},We={setTimeout:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setTimeout.apply(void 0,Y([n,e],J(t)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function qe(n){We.setTimeout(function(){throw n})}function ye(){}function Le(n){n()}var me=function(n){ue(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,de(t)&&t.add(r)):r.destination=Be,r}return e.create=function(t,r,o){return new G(t,r,o)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(K),Ne=Function.prototype.bind;function Q(n,e){return Ne.call(n,e)}var He=function(){function n(e){this.partialObserver=e}return n.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){N(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){N(r)}else N(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){N(t)}},n}(),G=function(n){ue(e,n);function e(t,r,o){var i=n.call(this)||this,s;if(T(t)||!t)s={next:t??void 0,error:r??void 0,complete:o??void 0};else{var c;i&&ge.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},s={next:t.next&&Q(t.next,c),error:t.error&&Q(t.error,c),complete:t.complete&&Q(t.complete,c)}):s=t}return i.destination=new He(s),i}return e}(me);function N(n){qe(n)}function Ue(n){throw n}var Be={closed:!0,next:ye,error:Ue,complete:ye},Je=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ye(n){return n}function ze(n){return n.length===0?Ye:n.length===1?n[0]:function(t){return n.reduce(function(r,o){return o(r)},t)}}var Ke=function(){function n(e){e&&(this._subscribe=e)}return n.prototype.lift=function(e){var t=new n;return t.source=this,t.operator=e,t},n.prototype.subscribe=function(e,t,r){var o=this,i=Ge(e)?e:new G(e,t,r);return Le(function(){var s=o,c=s.operator,p=s.source;i.add(c?c.call(i,p):p?o._subscribe(i):o._trySubscribe(i))}),i},n.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},n.prototype.forEach=function(e,t){var r=this;return t=be(t),new t(function(o,i){var s=new G({next:function(c){try{e(c)}catch(p){i(p),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},n.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},n.prototype[Je]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ze(e)(this)},n.prototype.toPromise=function(e){var t=this;return e=be(e),new e(function(r,o){var i;t.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},n.create=function(e){return new n(e)},n}();function be(n){var e;return(e=n??ge.Promise)!==null&&e!==void 0?e:Promise}function Qe(n){return n&&T(n.next)&&T(n.error)&&T(n.complete)}function Ge(n){return n&&n instanceof me||Qe(n)&&de(n)}const Xe=()=>{try{clearTimeout(void 0)}catch{return!1}return!0},Ze=(n={})=>{const{parentOrigin:e="*",timeout:t,debug:r=!1,config:o={}}=n,i=Pe(r),s=$e("App",i),{destroy:c,onDestroy:p}=s,w=()=>{i("Child: Handshake - Sending SYN");const v={penpal:C.Syn},g=e instanceof RegExp?"*":e;window.parent.postMessage(v,g)};return{promise:new Promise((v,g)=>{const d=Ie(t,c),m=a=>{if(Xe()&&!(a.source!==parent||!a.data)&&a.data.penpal===C.SynAck){const y=a.data,S=new le(y.id,y.appName),P=new le(y.id+"/api",y.appName),F=y.id,O={},R=u=>"api/"+u,q={$emit:(u,...f)=>{S.getEventCallBackLength(u)>0?S.$pureEmit(u,...f):O==null||O.$off(u,()=>{},!0)},onQueryResult:u=>{P.$pureEmit(R(u.reqid),u)},onOsNotify:u=>{}},L=u=>function(h){const M=R(u);P.$on(M,function V(E){h.next(E),E.reqid&&E.result==="succ"&&(h.complete(),P.$off(M,V))})},tt=oe(q),I=ke(e,tt,{...o,postmateVersion:je.version},s,i)(a),D={},H=I.bus;if(H){const u=(f,h,M)=>{M?(h.$__once=!0,S.$once(f,h)):S.$on(f,h),D[f]?D[f].push(h):(D[f]=[h],H.$on(f,F))};Object.assign(O,H,{$on:u,$off:(f,h,M)=>{var V;if(D[f]){const E=D[f].indexOf(h);E>-1&&(D[f].splice(E,1),S.$off(f,h))}M&&delete D[f],(V=D[f])!=null&&V.length||(H.$off(f,F),delete D[f])},$once:(f,h)=>{u(f,h,!0)}})}const nt={...I,bus:O,query:async(u,f)=>{const h=(u==null?void 0:u.reqid)||await I.genReqId();return new Promise((M,V)=>{I.query({...u,reqid:h},f).then(E=>{(E==null?void 0:E.result)==="succ"?M(E):V(E)})})},createObservableQuery:async(u,f={})=>{const h=(u==null?void 0:u.reqid)||await I.genReqId(),M=new Ke(L(h));return I.query({...u,reqid:h},{...f,observable:!0}),M}};I&&(window.removeEventListener(x.Message,m),d(),v({methods:nt,config:a.data.config}))}};window.addEventListener(x.Message,m),w(),p(a=>{window.removeEventListener(x.Message,m),a&&g(a)})}),destroy(){c()}}},et=n=>Ze({debug:n==null?void 0:n.debug}).promise;class we{constructor(e={}){A(this,"options");A(this,"flutterInAppWebView",null);A(this,"osConnector",null);A(this,"initPromise");A(this,"isWeb",!0);this.options=e,e.debug&&(l.setDebug(!0),l.log("Trim App initialized with debug mode")),l.log("Options:",e),this.initPromise=this.init()}async init(){return l.log("Starting initialization..."),new Promise(e=>{X()?(this.isWeb=!1,l.log("Initializing mobile platform..."),Ee().then(t=>{this.flutterInAppWebView=t,l.log("Mobile platform initialized"),e()})):(this.isWeb=!0,l.log("Initializing web platform..."),et().then(t=>{this.osConnector=t,l.log("Web platform initialized"),e()}))})}async callAppMethod(e,t){return this.flutterInAppWebView?Se(this.flutterInAppWebView,e,t):null}async ready(){return this.initPromise}getOptions(){return this.options}setOptions(e){this.options={...this.options,...e},e.debug!==void 0&&l.setDebug(e.debug),l.log("Options updated:",this.options)}async getPlatformConfig(){var e;if(await this.initPromise,this.isWeb){const t=await((e=this.osConnector)==null?void 0:e.methods.getPlatformConfig());if(!t)throw new Error("Failed to get platform config");return t}else{const t=await this.callAppMethod("getAppMessage");if(!t)throw new Error("Failed to get platform config");return{theme:t.nightMode,language:t.language,appVersion:t.appVersion,systemVersion:t.systemVersion,format:{date:t.dateFormat,time:t.timeFormat}}}}async setTitle(e){var t;return await this.initPromise,l.log("Setting title:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setTitle(e):this.callAppMethod("updateTitle",e)}async setExitPageTips(e){var t;return await this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setExitPageTips(e):this.callAppMethod("setExitPageTips",e?JSON.stringify(e):"")}async openFile(e){var t;return await this.initPromise,l.log("Opening file:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFile(e):this.callAppMethod("openFile",e)}async openFileManager(e){var t;return await this.initPromise,l.log("Opening file manager:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFileManagerApp(e):this.callAppMethod("openFileManager",e)}async close(){var e;return await this.initPromise,this.isWeb?(e=this.osConnector)==null?void 0:e.methods.close():this.callAppMethod("exitPage")}async query(e,t){var r;if(await this.initPromise,this.isWeb){const o=await((r=this.osConnector)==null?void 0:r.methods.query(e,t));if(!o)throw new Error("Failed to query");return o}else throw new Error("query is not supported on mobile platform")}async pickFile(e){var t;return await this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.pickFile(e):this.callAppMethod("openFolder",JSON.stringify(e))}}return $.TrimApp=we,$.default=we,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),$}({});
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function ve(n,e){if(n){var t=n.indexOf(e);0<=t&&n.splice(t,1)}}var oe=function(){function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var e,t,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=we(s),p=c.next();!p.done;p=c.next()){var A=p.value;A.remove(this)}}catch(l){e={error:l}}finally{try{p&&!p.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else s.remove(this);var E=this.initialTeardown;if(F(E))try{E()}catch(l){i=l instanceof ie?l.errors:[l]}var $=this._finalizers;if($){this._finalizers=null;try{for(var y=we($),h=y.next();!h.done;h=y.next()){var b=h.value;try{Se(b)}catch(l){i=i!=null?i:[],l instanceof ie?i=re(re([],ne(i)),ne(l.errors)):i.push(l)}}}catch(l){r={error:l}}finally{try{h&&!h.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}if(i)throw new ie(i)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Se(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ve(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&ve(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=function(){var e=new n;return e.closed=!0,e}(),n}();oe.EMPTY;function Ee(n){return n instanceof oe||n&&"closed"in n&&F(n.remove)&&F(n.add)&&F(n.unsubscribe)}function Se(n){F(n)?n():n.unsubscribe()}var Ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ue={setTimeout:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setTimeout.apply(void 0,re([n,e],ne(t)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function Be(n){Ue.setTimeout(function(){throw n})}function $e(){}function Je(n){n()}var Pe=function(n){be(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ee(t)&&t.add(r)):r.destination=Qe,r}return e.create=function(t,r,o){return new ce(t,r,o)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(oe),Ye=Function.prototype.bind;function se(n,e){return Ye.call(n,e)}var ze=function(){function n(e){this.partialObserver=e}return n.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){Q(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){Q(r)}else Q(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Q(t)}},n}(),ce=function(n){be(e,n);function e(t,r,o){var i=n.call(this)||this,s;if(F(t)||!t)s={next:t!=null?t:void 0,error:r!=null?r:void 0,complete:o!=null?o:void 0};else{var c;i&&Ae.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},s={next:t.next&&se(t.next,c),error:t.error&&se(t.error,c),complete:t.complete&&se(t.complete,c)}):s=t}return i.destination=new ze(s),i}return e}(Pe);function Q(n){Be(n)}function Ke(n){throw n}var Qe={closed:!0,next:$e,error:Ke,complete:$e},Ge=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xe(n){return n}function Ze(n){return n.length===0?Xe:n.length===1?n[0]:function(t){return n.reduce(function(r,o){return o(r)},t)}}var et=function(){function n(e){e&&(this._subscribe=e)}return n.prototype.lift=function(e){var t=new n;return t.source=this,t.operator=e,t},n.prototype.subscribe=function(e,t,r){var o=this,i=nt(e)?e:new ce(e,t,r);return Je(function(){var s=o,c=s.operator,p=s.source;i.add(c?c.call(i,p):p?o._subscribe(i):o._trySubscribe(i))}),i},n.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},n.prototype.forEach=function(e,t){var r=this;return t=Me(t),new t(function(o,i){var s=new ce({next:function(c){try{e(c)}catch(p){i(p),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},n.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},n.prototype[Ge]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ze(e)(this)},n.prototype.toPromise=function(e){var t=this;return e=Me(e),new e(function(r,o){var i;t.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},n.create=function(e){return new n(e)},n}();function Me(n){var e;return(e=n!=null?n:Ae.Promise)!==null&&e!==void 0?e:Promise}function tt(n){return n&&F(n.next)&&F(n.error)&&F(n.complete)}function nt(n){return n&&n instanceof Pe||tt(n)&&Ee(n)}const rt=()=>{try{clearTimeout(void 0)}catch(n){return!1}return!0},it=(n={})=>{const{parentOrigin:e="*",timeout:t,debug:r=!1,config:o={}}=n,i=Fe(r),s=Te("App",i),{destroy:c,onDestroy:p}=s,A=()=>{i("Child: Handshake - Sending SYN");const $={penpal:T.Syn},y=e instanceof RegExp?"*":e;window.parent.postMessage($,y)};return{promise:new Promise(($,y)=>{const h=qe(t,c),b=l=>{if(rt()&&!(l.source!==parent||!l.data)&&l.data.penpal===T.SynAck){const m=l.data,P=new me(m.id,m.appName),C=new me(m.id+"/api",m.appName),O=m.id,R={},D=u=>"api/"+u,Y={$emit:(u,...f)=>{P.getEventCallBackLength(u)>0?P.$pureEmit(u,...f):R==null||R.$off(u,()=>{},!0)},onQueryResult:u=>{C.$pureEmit(D(u.reqid),u)},onOsNotify:u=>{}},z=u=>function(w){const k=D(u);C.$on(k,function I(S){w.next(S),S.reqid&&S.result==="succ"&&(w.complete(),C.$off(k,I))})},st=de(Y),W=Ne(e,st,N(V({},o),{postmateVersion:Le.version}),s,i)(l),x={},G=W.bus;if(G){const u=(f,w,k)=>{k?(w.$__once=!0,P.$once(f,w)):P.$on(f,w),x[f]?x[f].push(w):(x[f]=[w],G.$on(f,O))};Object.assign(R,G,{$on:u,$off:(f,w,k)=>{var I;if(x[f]){const S=x[f].indexOf(w);S>-1&&(x[f].splice(S,1),P.$off(f,w))}k&&delete x[f],(I=x[f])!=null&&I.length||(G.$off(f,O),delete x[f])},$once:(f,w)=>{u(f,w,!0)}})}const ct=N(V({},W),{bus:R,query:(u,f)=>v(this,null,function*(){const w=(u==null?void 0:u.reqid)||(yield W.genReqId());return new Promise((k,I)=>{W.query(N(V({},u),{reqid:w}),f).then(S=>{(S==null?void 0:S.result)==="succ"?k(S):I(S)})})}),createObservableQuery:(w,...k)=>v(this,[w,...k],function*(u,f={}){const I=(u==null?void 0:u.reqid)||(yield W.genReqId()),S=new et(z(I));return W.query(N(V({},u),{reqid:I}),N(V({},f),{observable:!0})),S})});W&&(window.removeEventListener(j.Message,b),h(),$({methods:ct,config:l.data.config}))}};window.addEventListener(j.Message,b),A(),p(l=>{window.removeEventListener(j.Message,b),l&&y(l)})}),destroy(){c()}}},ot=n=>it({debug:n==null?void 0:n.debug}).promise;class _e{constructor(e={}){M(this,"options");M(this,"flutterInAppWebView",null);M(this,"osConnector",null);M(this,"initPromise");M(this,"isWeb",!0);this.options=e,e.debug&&(a.setDebug(!0),a.log("Trim App initialized with debug mode")),a.log("Options:",e),this.initPromise=this.init()}init(){return v(this,null,function*(){return a.log("Starting initialization..."),new Promise(e=>{H()?(this.isWeb=!1,a.log("Initializing mobile platform..."),Z().then(t=>{this.flutterInAppWebView=t,a.log("Mobile platform initialized"),e()})):(this.isWeb=!0,a.log("Initializing web platform..."),ot().then(t=>{this.osConnector=t,a.log("Web platform initialized"),e()}))})})}callAppMethod(e,t){return v(this,null,function*(){return this.flutterInAppWebView?U(this.flutterInAppWebView,e,t):null})}ready(){return v(this,null,function*(){return this.initPromise})}getOptions(){return this.options}setOptions(e){this.options=V(V({},this.options),e),e.debug!==void 0&&a.setDebug(e.debug),a.log("Options updated:",this.options)}getPlatformConfig(){return v(this,null,function*(){var e;if(yield this.initPromise,this.isWeb){const t=yield(e=this.osConnector)==null?void 0:e.methods.getPlatformConfig();if(!t)throw new Error("Failed to get platform config");return t}else{const t=yield this.callAppMethod("getAppMessage");if(!t)throw new Error("Failed to get platform config");return{theme:t.nightMode,language:t.language,appVersion:t.appVersion,systemVersion:t.systemVersion,format:{date:t.dateFormat,time:t.timeFormat}}}})}setTitle(e){return v(this,null,function*(){var t;return yield this.initPromise,a.log("Setting title:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setTitle(e):this.callAppMethod("updateTitle",e)})}setExitPageTips(e){return v(this,null,function*(){var t;return yield this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.setExitPageTips(e):this.callAppMethod("setExitPageTips",e?JSON.stringify(e):"")})}openFile(e){return v(this,null,function*(){var t;return yield this.initPromise,a.log("Opening file:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFile(e):this.callAppMethod("openFile",e)})}openFileManager(e){return v(this,null,function*(){var t;return yield this.initPromise,a.log("Opening file manager:",e),this.isWeb?(t=this.osConnector)==null?void 0:t.methods.openFileManagerApp(e):this.callAppMethod("openFileManager",e)})}close(){return v(this,null,function*(){var e;return yield this.initPromise,this.isWeb?(e=this.osConnector)==null?void 0:e.methods.close():this.callAppMethod("exitPage")})}query(e,t){return v(this,null,function*(){var r;if(yield this.initPromise,this.isWeb){const o=yield(r=this.osConnector)==null?void 0:r.methods.query(e,t);if(!o)throw new Error("Failed to query");return o}else throw new Error("query is not supported on mobile platform")})}pickFile(e){return v(this,null,function*(){var t;return yield this.initPromise,this.isWeb?(t=this.osConnector)==null?void 0:t.methods.pickFile(e):this.callAppMethod("openFolder",JSON.stringify(e))})}}return g.TrimApp=_e,g.default=_e,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),g}({});