@trimjs/web-app 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -288,26 +288,16 @@ const dateFormatter = new Intl.DateTimeFormat(config.language, {
288
288
  async close(): Promise<void>
289
289
  ```
290
290
 
291
- 关闭应用(仅支持 Web 平台)。
291
+ 关闭应用。
292
292
 
293
293
  **返回值:**
294
294
 
295
295
  - `Promise<void>`
296
296
 
297
- **注意:**
298
-
299
- - 此方法仅在 Web 平台(iframe)中可用
300
- - 在移动端调用会抛出错误
301
-
302
297
  **示例:**
303
298
 
304
299
  ```typescript
305
- // 检查是否为 Web 平台
306
- if (app.isWeb) {
307
- await app.query();
308
- } else {
309
- console.log("query 方法仅在 Web 平台可用");
310
- }
300
+ app.close();
311
301
  ```
312
302
 
313
303
  ---
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=b=>{if(b.source!==i||b.data.penpal!==F.Call)return;if(c!=="*"&&b.origin!==c){t(`${n} received message from origin ${b.origin} which did not match expected origin ${c}`);return}const v=b.data,{methodName:g,args:p,id:m}=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:m,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:m,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 b=!1;o(`${i}: Connecting call sender`);const v=p=>(...m)=>{o(`${i}: Sending ${p}() call`);let a;try{c.closed&&(a=!0)}catch{a=!0}if(a&&n(),b){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:m};c.postMessage(_,f)})},g=t.reduce((p,m)=>(p[m]=v(m),p),{});return Object.assign(r,je(g)),()=>{b=!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",Ne="module",Le="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:Ne,main:Le,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,b={penpal:F.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=Fe(v,e,o);s(g);const p={},m=ke(p,v,c.data.methodNames,i,o);return s(m),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});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 L=Qe(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
1
+ "use strict";var Pe=Object.defineProperty,Me=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var B=(r,e,t)=>e in r?Pe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,D=(r,e)=>{for(var t in e||(e={}))Te.call(e,t)&&B(r,t,e[t]);if(ee)for(var t of ee(e))_e.call(e,t)&&B(r,t,e[t]);return r},V=(r,e)=>Me(r,Ce(e));var $=(r,e,t)=>B(r,typeof e!="symbol"?e+"":e,t);var w=(r,e,t)=>new Promise((n,o)=>{var i=a=>{try{c(t.next(a))}catch(h){o(h)}},s=a=>{try{c(t.throw(a))}catch(h){o(h)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(i,s);c((t=t.apply(r,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(){if(this.debug){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.log("[Trim App]",...t)}}warn(){if(this.debug){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.warn("[Trim App]",...t)}}error(){if(this.debug){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.error("[Trim App]",...t)}}info(){if(this.debug){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.info("[Trim App]",...t)}}}const d=new Fe;function Oe(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 pe=()=>Oe(navigator.userAgent).fnAppVersion;let de=!1;window.addEventListener("flutterInAppWebViewPlatformReady",()=>{de=!0});const Re=()=>new Promise(r=>{var e;de||(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)})}),xe=(r,e,t)=>w(exports,null,function*(){d.log(`callHandler: ${e}, params: ${t}`);const n=yield 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}),te=new Map;function De(){window.fnAppMessage=r=>{d.log("app-message",r);const e=JSON.parse(r),t=te.get(e.reqId);t&&(t(e),te.delete(e.reqId))}}pe()&&De();var O=(r=>(r.Call="call",r.Reply="reply",r.Syn="syn",r.SynAck="synAck",r.Ack="ack",r))(O||{}),q=(r=>(r.Fulfilled="fulfilled",r.Rejected="rejected",r))(q||{}),X=(r=>(r.ConnectionDestroyed="ConnectionDestroyed",r.ConnectionTimeout="ConnectionTimeout",r.NoIframeSrc="NoIframeSrc",r))(X||{}),he=(r=>(r.DataCloneError="DataCloneError",r))(he||{}),I=(r=>(r.Message="message",r))(I||{});const Ie=(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)}}},je=r=>(...e)=>{r&&console.log("[Penpal]",...e)},re=({name:r,message:e,stack:t})=>({name:r,message:e,stack:t}),Ve=r=>{const e=new Error;return Object.keys(r).forEach(t=>e[t]=r[t]),e},We=(r,e,t)=>{const{localName:n,local:o,remote:i,originForSending:s,originForReceiving:c}=r;let a=!1;const h=v=>{if(v.source!==i||v.data.penpal!==O.Call)return;if(c!=="*"&&v.origin!==c){t(`${n} received message from origin ${v.origin} which did not match expected origin ${c}`);return}const A=v.data,{methodName:g,args:p,id:m}=A;t(`${n}: Received ${g}() call`);const l=y=>S=>{if(t(`${n}: Sending ${g}() reply`),a){t(`${n}: Unable to send ${g}() reply due to destroyed connection`);return}const P={penpal:O.Reply,id:m,resolution:y,returnValue:S};y===q.Rejected&&S instanceof Error&&(P.returnValue=re(S),P.returnValueIsError=!0);try{i.postMessage(P,s)}catch(M){if(M.name===he.DataCloneError){const C={penpal:O.Reply,id:m,resolution:q.Rejected,returnValue:re(M),returnValueIsError:!0};i.postMessage(C,s)}throw M}};new Promise(y=>y(e[g].apply(e,p))).then(l(q.Fulfilled),l(q.Rejected))};return o.addEventListener(I.Message,h),()=>{a=!0,o.removeEventListener(I.Message,h)}};let qe=0;const Ne=()=>++qe,ge=".",ye=r=>r?r.split(ge):[],Le=r=>r.join(ge),He=(r,e)=>{const t=ye(e||"");return t.push(r),Le(t)},ke=(r,e,t)=>{const n=ye(e);return n.reduce((o,i,s)=>(typeof o[i]=="undefined"&&(o[i]={}),s===n.length-1&&(o[i]=t),o[i]),r),r},me=(r,e)=>{const t={};return Object.keys(r).forEach(n=>{const o=r[n],i=He(n,e);typeof o=="object"&&Object.assign(t,me(o,i)),typeof o=="function"&&(t[i]=o)}),t},Ue=r=>{const e={};for(const t in r)ke(e,t,r[t]);return e},Be=(r,e,t,n,o)=>{const{localName:i,local:s,remote:c,originForSending:a,originForReceiving:h}=e;let v=!1;o(`${i}: Connecting call sender`);const A=p=>(...m)=>{o(`${i}: Sending ${p}() call`);let l;try{c.closed&&(l=!0)}catch(y){l=!0}if(l&&n(),v){const y=new Error(`Unable to send ${p}() call due to destroyed connection`);throw y.code=X.ConnectionDestroyed,y}return new Promise((y,S)=>{const P=Ne(),M=T=>{if(T.source!==c||T.data.penpal!==O.Reply||T.data.id!==P)return;if(h!=="*"&&T.origin!==h){o(`${i} received message from origin ${T.origin} which did not match expected origin ${h}`);return}const N=T.data;o(`${i}: Received ${p}() reply`),s.removeEventListener(I.Message,M);let L=N.returnValue;N.returnValueIsError&&(L=Ve(L)),(N.resolution===q.Fulfilled?y:S)(L)};s.addEventListener(I.Message,M);const C={penpal:O.Call,id:P,methodName:p,args:m};c.postMessage(C,a)})},g=t.reduce((p,m)=>(p[m]=A(m),p),{});return Object.assign(r,Ue(g)),()=>{v=!0}},Je=(r,e)=>{let t;return r!==void 0&&(t=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${r}ms`);n.code=X.ConnectionTimeout,e(n)},r)),()=>{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"},rt={name:Ye,version:ze,type:Ke,main:Qe,scripts:Ge,files:Xe,peerDependencies:Ze,devDependencies:et,publishConfig:tt},nt=(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 h=c.origin==="null"?"*":c.origin,v={penpal:O.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(v,h);const A={localName:"Child",local:window,remote:window.parent,originForSending:h,originForReceiving:c.origin},g=We(A,e,o);s(g);const p={},m=Be(p,A,c.data.methodNames,i,o);return s(m),p}};function ne(r,e){console==null||console.warn(`[fnApp warn]: ${r}`,e)}function ie(r,e){console==null||console.error(`[fnApp error]: ${r}`,e)}const W="_fn_all_event",oe="事件订阅数量为空",H=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});this.id=e,this.appName=t,this.$clear(),H.get(this.id)||H.set(this.id,{}),this.eventObj=H.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(W,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 ne(`${e} ${oe}`),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(W,e)}$emit(e,...t){return e=`${this.appName}/${e}`,this.$pureEmit(e,...t)}$pureEmit(e,...t){let n=0,o=0;return H.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(a){ie(a)}}if(i[W])for(let s=i[W].length-1;s>=0;s--){n++;const c=i[W][s];c.$__once&&i[W].splice(s,1);try{c(...t)}catch(a){ie(a)}}}),(!e||n===0&&o===0)&&ne(`${e} ${oe}`),this}$clear(){const e=H.get(this.id)||{};return Object.keys(e).forEach(n=>delete e[n]),this}}var z=function(r,e){return z=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])},z(r,e)};function be(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ce(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 K(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 Q(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 R(r){return typeof r=="function"}function it(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 J=it(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
2
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 b=this.initialTeardown;if(O(b))try{b()}catch(a){i=a instanceof L?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 m=p.value;try{ie(m)}catch(a){i=i??[],a instanceof L?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 L(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){N(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){N(n)}else N(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){N(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 N(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),m=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))})},be=pe(k),x=Ke(e,be,{...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,m),p(),v({methods:we,config:a.data.config}))}};window.addEventListener(R.Message,m),w(),f(a=>{window.removeEventListener(R.Message,m),a&&g(a)})}),destroy(){c()}}},pt=r=>ft({debug:r==null?void 0:r.debug}).promise;class me{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=me;exports.default=me;
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function ae(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Z=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=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){i=l instanceof J?l.errors:[l]}var A=this._finalizers;if(A){this._finalizers=null;try{for(var g=ce(A),p=g.next();!p.done;p=g.next()){var m=p.value;try{le(m)}catch(l){i=i!=null?i:[],l instanceof J?i=Q(Q([],K(i)),K(l.errors)):i.push(l)}}}catch(l){n={error:l}}finally{try{p&&!p.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}}if(i)throw new J(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)le(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)&&ae(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&ae(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();Z.EMPTY;function we(r){return r instanceof Z||r&&"closed"in r&&R(r.remove)&&R(r.add)&&R(r.unsubscribe)}function le(r){R(r)?r():r.unsubscribe()}var ve={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ot={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,Q([r,e],K(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function st(r){ot.setTimeout(function(){throw r})}function ue(){}function ct(r){r()}var Ee=function(r){be(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,we(t)&&t.add(n)):n.destination=ft,n}return e.create=function(t,n,o){return new G(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}(Z),at=Function.prototype.bind;function Y(r,e){return at.call(r,e)}var lt=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){U(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){U(n)}else U(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){U(t)}},r}(),G=function(r){be(e,r);function e(t,n,o){var i=r.call(this)||this,s;if(R(t)||!t)s={next:t!=null?t:void 0,error:n!=null?n:void 0,complete:o!=null?o:void 0};else{var c;i&&ve.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.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 i.destination=new lt(s),i}return e}(Ee);function U(r){st(r)}function ut(r){throw r}var ft={closed:!0,next:ue,error:ut,complete:ue},pt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function dt(r){return r}function ht(r){return r.length===0?dt:r.length===1?r[0]:function(t){return r.reduce(function(n,o){return o(n)},t)}}var gt=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=mt(e)?e:new G(e,t,n);return ct(function(){var s=o,c=s.operator,a=s.source;i.add(c?c.call(i,a):a?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=fe(t),new t(function(o,i){var s=new G({next:function(c){try{e(c)}catch(a){i(a),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[pt]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ht(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=fe(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 fe(r){var e;return(e=r!=null?r:ve.Promise)!==null&&e!==void 0?e:Promise}function yt(r){return r&&R(r.next)&&R(r.error)&&R(r.complete)}function mt(r){return r&&r instanceof Ee||yt(r)&&we(r)}const bt=()=>{try{clearTimeout(void 0)}catch(r){return!1}return!0},wt=(r={})=>{const{parentOrigin:e="*",timeout:t,debug:n=!1,config:o={}}=r,i=je(n),s=Ie("App",i),{destroy:c,onDestroy:a}=s,h=()=>{i("Child: Handshake - Sending SYN");const A={penpal:O.Syn},g=e instanceof RegExp?"*":e;window.parent.postMessage(A,g)};return{promise:new Promise((A,g)=>{const p=Je(t,c),m=l=>{if(bt()&&!(l.source!==parent||!l.data)&&l.data.penpal===O.SynAck){const y=l.data,S=new se(y.id,y.appName),P=new se(y.id+"/api",y.appName),M=y.id,C={},T=u=>"api/"+u,N={$emit:(u,...f)=>{S.getEventCallBackLength(u)>0?S.$pureEmit(u,...f):C==null||C.$off(u,()=>{},!0)},onQueryResult:u=>{P.$pureEmit(T(u.reqid),u)},onOsNotify:u=>{}},L=u=>function(b){const x=T(u);P.$on(x,function F(E){b.next(E),E.reqid&&E.result==="succ"&&(b.complete(),P.$off(x,F))})},Se=me(N),j=nt(e,Se,V(D({},o),{postmateVersion:rt.version}),s,i)(l),_={},k=j.bus;if(k){const u=(f,b,x)=>{x?(b.$__once=!0,S.$once(f,b)):S.$on(f,b),_[f]?_[f].push(b):(_[f]=[b],k.$on(f,M))};Object.assign(C,k,{$on:u,$off:(f,b,x)=>{var F;if(_[f]){const E=_[f].indexOf(b);E>-1&&(_[f].splice(E,1),S.$off(f,b))}x&&delete _[f],(F=_[f])!=null&&F.length||(k.$off(f,M),delete _[f])},$once:(f,b)=>{u(f,b,!0)}})}const $e=V(D({},j),{bus:C,query:(u,f)=>w(exports,null,function*(){const b=(u==null?void 0:u.reqid)||(yield j.genReqId());return new Promise((x,F)=>{j.query(V(D({},u),{reqid:b}),f).then(E=>{(E==null?void 0:E.result)==="succ"?x(E):F(E)})})}),createObservableQuery:(b,...x)=>w(exports,[b,...x],function*(u,f={}){const F=(u==null?void 0:u.reqid)||(yield j.genReqId()),E=new gt(L(F));return j.query(V(D({},u),{reqid:F}),V(D({},f),{observable:!0})),E})});j&&(window.removeEventListener(I.Message,m),p(),A({methods:$e,config:l.data.config}))}};window.addEventListener(I.Message,m),h(),a(l=>{window.removeEventListener(I.Message,m),l&&g(l)})}),destroy(){c()}}},vt=r=>wt({debug:r==null?void 0:r.debug}).promise;class Ae{constructor(){$(this,"options");$(this,"flutterInAppWebView",null);$(this,"osConnector",null);$(this,"initPromise");$(this,"isWeb",!0);let e=arguments.length>0&&arguments[0]!==void 0?arguments[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 n;if(yield this.initPromise,this.isWeb){const o=yield(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")})}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=Ae;exports.default=Ae;
@@ -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 N=q.returnValue;q.returnValueIsError&&(N=Me(N)),(q.resolution===j.Fulfilled?y:S)(N)};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});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 Te=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,W=(g,d)=>{for(var a in d||(d={}))ft.call(d,a)&&ae(g,a,d[a]);if(Te)for(var a of Te(d))pt.call(d,a)&&ae(g,a,d[a]);return g},H=(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,k)=>{var K=C=>{try{U(a.next(C))}catch(B){k(B)}},Z=C=>{try{U(a.throw(C))}catch(B){k(B)}},U=C=>C.done?X(C.value):Promise.resolve(C.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(){if(this.debug){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log("[Trim App]",...t)}}warn(){if(this.debug){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.warn("[Trim App]",...t)}}error(){if(this.debug){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.error("[Trim App]",...t)}}info(){if(this.debug){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.info("[Trim App]",...t)}}}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 k=()=>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}),C=new Map;function B(){window.fnAppMessage=n=>{a.log("app-message",n);const e=JSON.parse(n),t=C.get(e.reqId);t&&(t(e),C.delete(e.reqId))}}k()&&B();var _=(n=>(n.Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",n))(_||{}),N=(n=>(n.Fulfilled="fulfilled",n.Rejected="rejected",n))(N||{}),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 _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)}}},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 S=E=>{if(E.source!==i||E.data.penpal!==_.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 T={penpal:_.Reply,id:b,resolution:m,returnValue:P};m===N.Rejected&&P instanceof Error&&(T.returnValue=ue(P),T.returnValueIsError=!0);try{i.postMessage(T,s)}catch(O){if(O.name===le.DataCloneError){const R={penpal:_.Reply,id:b,resolution:N.Rejected,returnValue:ue(O),returnValueIsError:!0};i.postMessage(R,s)}throw O}};new Promise(m=>m(e[y].apply(e,h))).then(l(N.Fulfilled),l(N.Rejected))};return o.addEventListener(j.Message,S),()=>{p=!0,o.removeEventListener(j.Message,S)}};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)},Ve=(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},We=n=>{const e={};for(const t in n)Ve(e,t,n[t]);return e},qe=(n,e,t,r,o)=>{const{localName:i,local:s,remote:c,originForSending:p,originForReceiving:S}=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 T=xe(),O=D=>{if(D.source!==c||D.data.penpal!==_.Reply||D.data.id!==T)return;if(S!=="*"&&D.origin!==S){o(`${i} received message from origin ${D.origin} which did not match expected origin ${S}`);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===N.Fulfilled?m:P)(z)};s.addEventListener(j.Message,O);const R={penpal:_.Call,id:T,methodName:h,args:b};c.postMessage(R,p)})},y=t.reduce((h,b)=>(h[b]=$(b),h),{});return Object.assign(n,We(y)),()=>{E=!0}},Ne=(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"}},He=(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 S=c.origin==="null"?"*":c.origin,E={penpal:_.Ack,methodNames:Object.keys(e),config:t};window.parent.postMessage(E,S);const $={localName:"Child",local:window,remote:window.parent,originForSending:S,originForReceiving:c.origin},y=Re($,e,o);s(y);const h={},b=qe(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});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(){const e=J.get(this.id)||{};return Object.keys(e).forEach(r=>delete e[r]),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 ke(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=ke(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 Ne(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),Le=Function.prototype.bind;function Q(n,e){return Le.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){L(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){L(r)}else L(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){L(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 L(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 Ne(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=>{}},N=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(N(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 S=p.value;S.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{Ae(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)Ae(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 Ae(n){F(n)?n():n.unsubscribe()}var Se={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&&Se.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:Se.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=_e("App",i),{destroy:c,onDestroy:p}=s,S=()=>{i("Child: Handshake - Sending SYN");const $={penpal:_.Syn},y=e instanceof RegExp?"*":e;window.parent.postMessage($,y)};return{promise:new Promise(($,y)=>{const h=Ne(t,c),b=l=>{if(rt()&&!(l.source!==parent||!l.data)&&l.data.penpal===_.SynAck){const m=l.data,P=new me(m.id,m.appName),T=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=>{T.$pureEmit(D(u.reqid),u)},onOsNotify:u=>{}},z=u=>function(w){const V=D(u);T.$on(V,function I(A){w.next(A),A.reqid&&A.result==="succ"&&(w.complete(),T.$off(V,I))})},st=de(Y),q=He(e,st,H(W({},o),{postmateVersion:Le.version}),s,i)(l),x={},G=q.bus;if(G){const u=(f,w,V)=>{V?(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,V)=>{var I;if(x[f]){const A=x[f].indexOf(w);A>-1&&(x[f].splice(A,1),P.$off(f,w))}V&&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=H(W({},q),{bus:R,query:(u,f)=>v(this,null,function*(){const w=(u==null?void 0:u.reqid)||(yield q.genReqId());return new Promise((V,I)=>{q.query(H(W({},u),{reqid:w}),f).then(A=>{(A==null?void 0:A.result)==="succ"?V(A):I(A)})})}),createObservableQuery:(w,...V)=>v(this,[w,...V],function*(u,f={}){const I=(u==null?void 0:u.reqid)||(yield q.genReqId()),A=new et(z(I));return q.query(H(W({},u),{reqid:I}),H(W({},f),{observable:!0})),A})});q&&(window.removeEventListener(j.Message,b),h(),$({methods:ct,config:l.data.config}))}};window.addEventListener(j.Message,b),S(),p(l=>{window.removeEventListener(j.Message,b),l&&y(l)})}),destroy(){c()}}},ot=n=>it({debug:n==null?void 0:n.debug}).promise;class Ce{constructor(){M(this,"options");M(this,"flutterInAppWebView",null);M(this,"osConnector",null);M(this,"initPromise");M(this,"isWeb",!0);let e=arguments.length>0&&arguments[0]!==void 0?arguments[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=>{k()?(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=W(W({},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=Ce,g.default=Ce,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),g}({});