@trimjs/web-app 0.0.3 → 0.0.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
@@ -74,11 +74,6 @@ console.log("语言:", config.language);
74
74
  console.log("日期格式:", config.format.date);
75
75
  console.log("时间格式:", config.format.time);
76
76
 
77
- // 关闭应用(仅 Web 平台)
78
- if (app.isWeb) {
79
- await app.close();
80
- }
81
-
82
77
  // 请求接口(仅 Web 平台)
83
78
  if (app.isWeb) {
84
79
  const response = await app.query({
@@ -309,9 +304,9 @@ async close(): Promise<void>
309
304
  ```typescript
310
305
  // 检查是否为 Web 平台
311
306
  if (app.isWeb) {
312
- await app.close();
307
+ await app.query();
313
308
  } else {
314
- console.log("close 方法仅在 Web 平台可用");
309
+ console.log("query 方法仅在 Web 平台可用");
315
310
  }
316
311
  ```
317
312
 
@@ -680,7 +675,7 @@ interface PlatformConfig {
680
675
  - ✅ `openFile` - 打开文件
681
676
  - ✅ `openFileManager` - 打开文件管理器
682
677
  - ✅ `getPlatformConfig` - 获取平台配置
683
- - ❌ `close` - 不支持(会抛出错误)
678
+ - ✅ `close` - 关闭页面
684
679
  - ❌ `query` - 不支持(会抛出错误)
685
680
  - ✅ `pickFile` - 选择文件
686
681
  - ✅ `callAppMethod` - 调用自定义 App 方法
@@ -791,7 +786,7 @@ async function saveData() {
791
786
 
792
787
  2. **平台检测**:SDK 会自动检测运行环境(Web 或移动端),通过 `isWeb` 属性可以判断当前平台。
793
788
 
794
- 3. **错误处理**:某些方法在特定平台可能不可用(如 `close`、`query` 在移动端),调用前建议检查 `isWeb` 属性。
789
+ 3. **错误处理**:某些方法在特定平台可能不可用(如 `query` 在移动端),调用前建议检查 `isWeb` 属性。
795
790
 
796
791
  4. **调试模式**:开启 `debug` 选项后,SDK 会在控制台输出详细的运行日志,方便开发和调试。
797
792
 
@@ -822,16 +817,16 @@ if (app.isWeb) {
822
817
 
823
818
  A: 某些方法只在特定平台可用:
824
819
 
825
- - `close()` 和 `query()` 仅在 Web 平台可用
820
+ - `query()` 仅在 Web 平台可用
826
821
  - 在移动端调用这些方法会抛出错误
827
822
 
828
823
  建议在调用前检查平台:
829
824
 
830
825
  ```typescript
831
826
  if (app.isWeb) {
832
- await app.close();
827
+ await app.query();
833
828
  } else {
834
- console.log("当前平台不支持 close 方法");
829
+ console.log("当前平台不支持 query 方法");
835
830
  }
836
831
  ```
837
832
 
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var we=Object.defineProperty;var ve=(r,e,t)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var A=(r,e,t)=>ve(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class Ee{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 Ee;function Se(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=()=>Se(navigator.userAgent).fnAppVersion,Ae=()=>new Promise(r=>{var e;(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)})}),$e=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 Pe(){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()&&Pe();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||{}),ae=(r=>(r.DataCloneError="DataCloneError",r))(ae||{}),R=(r=>(r.Message="message",r))(R||{});const Me=(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)}}},_e=r=>(...e)=>{r&&console.log("[Penpal]",...e)},G=({name:r,message:e,stack:t})=>({name:r,message:e,stack:t}),Ce=r=>{const e=new Error;return Object.keys(r).forEach(t=>e[t]=r[t]),e},Te=(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===ae.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 Fe=0;const Oe=()=>++Fe,le=".",ue=r=>r?r.split(le):[],Re=r=>r.join(le),xe=(r,e)=>{const t=ue(e||"");return t.push(r),Re(t)},De=(r,e,t)=>{const n=ue(e);return n.reduce((o,i,s)=>(typeof o[i]>"u"&&(o[i]={}),s===n.length-1&&(o[i]=t),o[i]),r),r},fe=(r,e)=>{const t={};return Object.keys(r).forEach(n=>{const o=r[n],i=xe(n,e);typeof o=="object"&&Object.assign(t,fe(o,i)),typeof o=="function"&&(t[i]=o)}),t},Ie=r=>{const e={};for(const t in r)De(e,t,r[t]);return e},je=(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 $=Oe(),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=Ce(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,Ie(g)),()=>{b=!0}},ke=(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)}},Ve="@fn/micro-app-postmate",qe="0.1.2",We="module",Ne="src/index.ts",Le={dev:"vite",build:"tsc -b && vite build",lint:"eslint ."},He=["src","dist"],Ue={"@fn/micro-app-event":"^0.0.1",rxjs:"^7.8.0"},Be={"@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"},Je={registry:"http://verdaccio.teiron-inc.cn:4873"},Ye={name:Ve,version:qe,type:We,main:Ne,scripts:Le,files:He,peerDependencies:Ue,devDependencies:Be,publishConfig:Je},ze=(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=Te(v,e,o);s(g);const p={},m=je(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="事件订阅数量为空",q=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(),q.get(this.id)||q.set(this.id,{}),this.eventObj=q.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 q.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=q.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 pe(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 Ke(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=Ke(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
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
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 de(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 he={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Qe={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 Ge(r){Qe.setTimeout(function(){throw r})}function oe(){}function Xe(r){r()}var ge=function(r){pe(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,de(t)&&t.add(n)):n.destination=rt,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),Ze=Function.prototype.bind;function H(r,e){return Ze.call(r,e)}var et=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){pe(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&&he.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 et(s),i}return e}(ge);function N(r){Ge(r)}function tt(r){throw r}var rt={closed:!0,next:oe,error:tt,complete:oe},nt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function it(r){return r}function ot(r){return r.length===0?it:r.length===1?r[0]:function(t){return r.reduce(function(n,o){return o(n)},t)}}var st=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=at(e)?e:new Y(e,t,n);return Xe(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[nt]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ot(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??he.Promise)!==null&&e!==void 0?e:Promise}function ct(r){return r&&O(r.next)&&O(r.error)&&O(r.complete)}function at(r){return r&&r instanceof ge||ct(r)&&de(r)}const lt=()=>{try{clearTimeout(void 0)}catch{return!1}return!0},ut=(r={})=>{const{parentOrigin:e="*",timeout:t,debug:n=!1,config:o={}}=r,i=_e(n),s=Me("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=ke(t,c),m=a=>{if(lt()&&!(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=fe(k),x=ze(e,me,{...o,postmateVersion:Ye.version},s,i)(a),T={},W=x.bus;if(W){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],W.$on(u,M))};Object.assign(_,W,{$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||(W.$off(u,M),delete T[u])},$once:(u,h)=>{l(u,h,!0)}})}const be={...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 st(V(h));return x.query({...l,reqid:h},{...u,observable:!0}),P}};x&&(window.removeEventListener(R.Message,m),p(),v({methods:be,config:a.data.config}))}};window.addEventListener(R.Message,m),w(),f(a=>{window.removeEventListener(R.Message,m),a&&g(a)})}),destroy(){c()}}},ft=r=>ut({debug:r==null?void 0:r.debug}).promise;class ye{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..."),Ae().then(t=>{this.flutterInAppWebView=t,d.log("Mobile platform initialized"),e()})):(this.isWeb=!0,d.log("Initializing web platform..."),ft().then(t=>{this.osConnector=t,d.log("Web platform initialized"),e()}))})}async callAppMethod(e,t){return this.flutterInAppWebView?$e(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;if(await this.initPromise,this.isWeb)return(e=this.osConnector)==null?void 0:e.methods.close();throw new Error("close is not supported on mobile platform")}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=ye;exports.default=ye;
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,3 +1,3 @@
1
- var TrimApp=function($){"use strict";var nt=Object.defineProperty;var rt=($,_,l)=>_ in $?nt($,_,{enumerable:!0,configurable:!0,writable:!0,value:l}):$[_]=l;var A=($,_,l)=>rt($,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 we(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=()=>we(navigator.userAgent).fnAppVersion,ve=()=>new Promise(n=>{var e;(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)})}),Ee=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},Z=new Map;function Se(){window.fnAppMessage=n=>{l.log("app-message",n);const e=JSON.parse(n),t=Z.get(e.reqId);t&&(t(e),Z.delete(e.reqId))}}X()&&Se();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||{}),ee=(n=>(n.DataCloneError="DataCloneError",n))(ee||{}),x=(n=>(n.Message="message",n))(x||{});const Ae=(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)}}},$e=n=>(...e)=>{n&&console.log("[Penpal]",...e)},te=({name:n,message:e,stack:t})=>({name:n,message:e,stack:t}),Pe=n=>{const e=new Error;return Object.keys(n).forEach(t=>e[t]=n[t]),e},Me=(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=te(S),P.returnValueIsError=!0);try{i.postMessage(P,s)}catch(F){if(F.name===ee.DataCloneError){const O={penpal:C.Reply,id:m,resolution:j.Rejected,returnValue:te(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 _e=0;const Ce=()=>++_e,ne=".",re=n=>n?n.split(ne):[],Te=n=>n.join(ne),Fe=(n,e)=>{const t=re(e||"");return t.push(n),Te(t)},Oe=(n,e,t)=>{const r=re(e);return r.reduce((o,i,s)=>(typeof o[i]>"u"&&(o[i]={}),s===r.length-1&&(o[i]=t),o[i]),n),n},ie=(n,e)=>{const t={};return Object.keys(n).forEach(r=>{const o=n[r],i=Fe(r,e);typeof o=="object"&&Object.assign(t,ie(o,i)),typeof o=="function"&&(t[i]=o)}),t},Re=n=>{const e={};for(const t in n)Oe(e,t,n[t]);return e},De=(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=Ce(),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 W=R.data;o(`${i}: Received ${d}() reply`),s.removeEventListener(x.Message,F);let N=W.returnValue;W.returnValueIsError&&(N=Pe(N)),(W.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,Re(g)),()=>{b=!0}},xe=(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)}},Ie={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"}},je=(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=Me(v,e,o);s(g);const d={},m=De(d,v,c.data.methodNames,i,o);return s(m),d}};function oe(n,e){console==null||console.warn(`[fnApp warn]: ${n}`,e)}function se(n,e){console==null||console.error(`[fnApp error]: ${n}`,e)}const k="_fn_all_event",ce="事件订阅数量为空",q=window.__POWERED_BY_FNAPP__?window.__FNAPP.inject.appEventObjMap:new Map;class ae{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(),q.get(this.id)||q.set(this.id,{}),this.eventObj=q.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 oe(`${e} ${ce}`),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 q.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){se(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){se(p)}}}),(!e||r===0&&o===0)&&oe(`${e} ${ce}`),this}$clear(){const e=q.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 le(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 ue(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 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 z=ke(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
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:
2
2
  `+t.map(function(r,o){return o+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function fe(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=ue(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=ue(v),d=g.next();!d.done;d=g.next()){var m=d.value;try{de(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)de(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)&&fe(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&fe(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=function(){var e=new n;return e.closed=!0,e}(),n}();K.EMPTY;function pe(n){return n instanceof K||n&&"closed"in n&&T(n.remove)&&T(n.add)&&T(n.unsubscribe)}function de(n){T(n)?n():n.unsubscribe()}var he={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ve={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){Ve.setTimeout(function(){throw n})}function ge(){}function We(n){n()}var ye=function(n){le(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,pe(t)&&t.add(r)):r.destination=Ue,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 Le=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){le(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&&he.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 Le(s),i}return e}(ye);function L(n){qe(n)}function He(n){throw n}var Ue={closed:!0,next:ge,error:He,complete:ge},Be=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Je(n){return n}function Ye(n){return n.length===0?Je:n.length===1?n[0]:function(t){return n.reduce(function(r,o){return o(r)},t)}}var ze=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=Qe(e)?e:new G(e,t,r);return We(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 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[Be]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ye(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??he.Promise)!==null&&e!==void 0?e:Promise}function Ke(n){return n&&T(n.next)&&T(n.error)&&T(n.complete)}function Qe(n){return n&&n instanceof ye||Ke(n)&&pe(n)}const Ge=()=>{try{clearTimeout(void 0)}catch{return!1}return!0},Xe=(n={})=>{const{parentOrigin:e="*",timeout:t,debug:r=!1,config:o={}}=n,i=$e(r),s=Ae("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=xe(t,c),m=a=>{if(Ge()&&!(a.source!==parent||!a.data)&&a.data.penpal===C.SynAck){const y=a.data,S=new ae(y.id,y.appName),P=new ae(y.id+"/api",y.appName),F=y.id,O={},R=u=>"api/"+u,W={$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))})},et=ie(W),I=je(e,et,{...o,postmateVersion:Ie.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 tt={...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 ze(N(h));return I.query({...u,reqid:h},{...f,observable:!0}),M}};I&&(window.removeEventListener(x.Message,m),d(),v({methods:tt,config:a.data.config}))}};window.addEventListener(x.Message,m),w(),p(a=>{window.removeEventListener(x.Message,m),a&&g(a)})}),destroy(){c()}}},Ze=n=>Xe({debug:n==null?void 0:n.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&&(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..."),ve().then(t=>{this.flutterInAppWebView=t,l.log("Mobile platform initialized"),e()})):(this.isWeb=!0,l.log("Initializing web platform..."),Ze().then(t=>{this.osConnector=t,l.log("Web platform initialized"),e()}))})}async callAppMethod(e,t){return this.flutterInAppWebView?Ee(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;if(await this.initPromise,this.isWeb)return(e=this.osConnector)==null?void 0:e.methods.close();throw new Error("close is not supported on mobile platform")}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=be,$.default=be,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),$}({});
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"}}),$}({});