@lingxia/bridge 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge-runtime.es2020.js +1 -0
- package/dist/bridge-runtime.es5.js +1 -0
- package/dist/bridge.d.ts +5 -2
- package/dist/es2020/boot.js +34 -0
- package/dist/es2020/bridge.js +1597 -0
- package/dist/es2020/error.js +89 -0
- package/dist/es2020/image-proxy.js +82 -0
- package/dist/es2020/index.js +19 -0
- package/dist/es2020/invocation.js +77 -0
- package/dist/es2020/nativecomponents/coverage-monitor.js +159 -0
- package/dist/es2020/runtime-env.js +31 -0
- package/dist/es2020/types.js +16 -0
- package/dist/es2020/ui/action-sheet.js +138 -0
- package/dist/es2020/ui/index.js +10 -0
- package/dist/es2020/ui/modal.js +170 -0
- package/dist/es2020/ui/toast.js +145 -0
- package/dist/es5/boot.js +34 -0
- package/dist/es5/bridge.js +1930 -0
- package/dist/es5/error.js +35 -0
- package/dist/es5/image-proxy.js +83 -0
- package/dist/es5/index.js +19 -0
- package/dist/es5/invocation.js +103 -0
- package/dist/es5/nativecomponents/coverage-monitor.js +219 -0
- package/dist/es5/runtime-env.js +32 -0
- package/dist/es5/types.js +16 -0
- package/dist/es5/ui/action-sheet.js +82 -0
- package/dist/es5/ui/index.js +10 -0
- package/dist/es5/ui/modal.js +84 -0
- package/dist/es5/ui/toast.js +102 -0
- package/dist/index.d.ts +3 -2
- package/dist/invocation.d.ts +14 -0
- package/dist/types.d.ts +42 -15
- package/package.json +21 -9
- package/dist/runtime.es2020.js +0 -1663
- package/dist/runtime.es5.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const __LX_RUNTIME_PLATFORM__="all";var __LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="BRIDGE_TIMEOUT",n="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",s="BRIDGE_CAPABILITY_DENIED",a="BRIDGE_INTERNAL_ERROR",l="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED";var d=class extends Error{constructor(e,t,n){super(t),this.name="BridgeInvocationError",this.code=e,this.data=n}};function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){const t=e;let n=a;("string"==typeof t.code&&""!==t.code.trim()||"number"==typeof t.code&&Number.isFinite(t.code))&&(n=t.code);const o="string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error";return new d(n,o,"data"in t?t.data:void 0)}const t=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(a,t)}function m(e){const t=u(e);return{code:String(t.code||a),message:"string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error",...void 0===t.data?{}:{data:t.data}}}function f({os:e,send:t}){if("undefined"==typeof window)return;if("undefined"==typeof document)return;const n="iOS"===e;if(!n&&"Android"!==e)return;const o=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(window[o]?.installed)return;const r={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};function i(e){const t=e.getBoundingClientRect?.();if(!t)return!1;if(t.width<2||t.height<2)return!1;const n=t.left+t.width/2,o=t.top+t.height/2;if(n<0||o<0||n>=window.innerWidth||o>=window.innerHeight)return!1;const r=document.elementFromPoint?.(n,o);return!!r&&(r!==document.documentElement&&r!==document.body&&!(r===e||e.contains(r)))}function s(){r.scheduled=!1;const e=document.querySelectorAll("lx-video[id]");if(r.hasAnyVideo=e.length>0,!r.hasAnyVideo&&0===r.coveredById.size&&!r.anyCovered)return;const o=new Set;for(const n of Array.from(e)){const e=n.id;if(!e)continue;o.add(e);const s=i(n),a=r.coveredById.get(e);a!==s&&(!0===a&&(r.coveredCount-=1),!0===s&&(r.coveredCount+=1),r.coveredById.set(e,s),t({id:e,action:"component.coverage",covered:s}))}const s=[];for(const[e,t]of r.coveredById.entries())o.has(e)||(s.push(e),!0===t&&(r.coveredCount-=1));for(const e of s)r.coveredById.delete(e),t({id:e,action:"component.coverage",covered:!1});const a=r.coveredCount>0;a!==r.anyCovered&&(r.anyCovered=a,n&&(a?function(){if(!n)return;if(r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!0,r.scrollY=window.scrollY||e.scrollTop||0,r.htmlOverflow=e.style.overflow||"",r.bodyOverflow=t.style.overflow||"",r.bodyPosition=t.style.position||"",r.bodyTop=t.style.top||"",r.bodyWidth=t.style.width||"",e.style.overflow="hidden",t.style.overflow="hidden",t.style.position="fixed",t.style.top=-r.scrollY+"px",t.style.width="100%")}():function(){if(!n)return;if(!r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!1,e.style.overflow=r.htmlOverflow,t.style.overflow=r.bodyOverflow,t.style.position=r.bodyPosition,t.style.top=r.bodyTop,t.style.width=r.bodyWidth,window.scrollTo(0,r.scrollY))}()))}function a(){r.scheduled||(r.scheduled=!0,requestAnimationFrame(s))}window[o]=r,new MutationObserver(a).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});const l={handleEvent:()=>{(r.hasAnyVideo||0!==r.coveredById.size)&&a()}},c={handleEvent:()=>a()};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",c),a()}const p="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function h(){return p.os||"unknown"}function g(){return"iOS"===p.os}function v(){return"macOS"===p.os}const y="__LingXiaRecvMessage",x=5e3,w="[LX.Bridge]",b="messageport",k="jsinterface",E={data:!1,proto:!1,all:!1},I=[];function C(e){return E.all||E[e]}function _(...e){console.log(w,...e)}function T(...e){console.warn(w,...e)}function L(...e){console.error(w,...e)}function S(e){try{return JSON.stringify(e)}catch{return function(e,t){const n=new WeakSet;return JSON.stringify(e,(e,t)=>{if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t},t)}(e)}}function M(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch{return{}}}const N="iOS"===p.os||"macOS"===p.os?"webkit":"Harmony"===p.os?"messageport":"Android"===p.os?window.LingXiaProxy?.supportsMessagePort?.()?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=e=>{I.push(e)});let A=null,O=!1,P=null,B=null,j=null,R=200;const F={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},D={handleEvent:e=>{const t=e;if("LingXia-port-init"!==t.data)return;const n=t.ports?.[0];n&&(He._connectWebMessagePort(n),F.resolve?.(n))}};function $(){F.listenerInstalled||(F.listenerInstalled=!0,window.addEventListener("message",D))}function X(){null!==F.timer&&(window.clearTimeout(F.timer),F.timer=null),F.resolve=null,F.reject=null,F.promise=null}function H(){return"webkit"===N&&(g()||v())}function q(){null!==j&&(clearTimeout(j),j=null)}function z(e){for(const t of Array.from(oe.keys()))ve(t,{code:c,message:e});for(const t of Array.from(re.keys()))ye(t,{code:c,message:e});!function(e){for(const[t,n]of Array.from(ie.entries()))ie.delete(t),n._emitClose(c,e)}(e)}function G(e){let t=e;for(;;){const e=t.indexOf("\n");if(e<0)break;const n=t.slice(0,e).trim();if(t=t.slice(e+1),n)try{Ne(JSON.parse(n))}catch(e){T("Apple downstream parse error:",e,n)}}return t}function W(){H()&&(P||(q(),P=async function(){const e=new AbortController;let t;B=e;try{t=await fetch("lx-apple://bridge/downstream",{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal})}catch(t){if(e.signal.aborted)return;throw t}if(!t.ok)throw new Error(`Apple downstream HTTP ${t.status}`);if(!t.body)throw new Error("Apple downstream response body unavailable");O=!0,R=200,C("proto")&&_("Apple downstream connected"),Ce();const n=t.body.getReader(),o=new TextDecoder;let r="";try{for(;;){const{value:e,done:t}=await n.read();if(t)break;r+=o.decode(e,{stream:!0}),r=G(r)}r+=o.decode();const e=r.trim();if(e)try{Ne(JSON.parse(e))}catch(t){T("Apple downstream trailing parse error:",t,e)}}finally{try{n.releaseLock()}catch{}}}().catch(e=>{B?.signal.aborted||T("Apple downstream failed:",e)}).finally(()=>{const e=B?.signal.aborted??!1;P=null,B=null;const t=O;var n,o;O=!1,n="Apple downstream closed",o=t,Ie(),J=null,Y=!1,V=!1,K=0,o&&z(n),e||function(e){if(!H())return;q();const t=R;R=Math.min(2*R,2e3);const n=`Apple downstream disconnected, retrying in ${t}ms: ${e}`;t<=200?_(n):T(n),j=setTimeout(()=>{j=null,W()},t)}("stream closed")})))}function U(e){const t=e.kind;"req"!==t&&"notify"!==t||_(`postToNative: ${t} ${e.method}`),C("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===N)return void window.webkit?.messageHandlers.LingXia?.postMessage(e);const t=S(e);if(N===b&&A)return void A.postMessage(t);if(N===k&&window.LingXiaProxy?.postMessage)return void window.LingXiaProxy.postMessage(t);T("Transport not ready")}catch(e){L("Send error:",e)}}let J=null,Y=!1,V=!1,K=0,Q=null;const Z={};let ee=0;function te(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function ne(e,t){const n=te();let o=!1,r=()=>{},i=()=>{};const s=[],a=[],l=new Promise((e,t)=>{r=e,i=t});return{id:e,result:l,on(e,t){return"data"===e&&n.data.add(t),"end"===e&&n.end.add(t),"error"===e&&n.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>s.length>0?Promise.resolve({done:!1,value:s.shift()}):o?l.then(e=>({done:!0,value:e}),e=>Promise.reject(e)):new Promise((e,t)=>{a.push({resolve:e,reject:t})})}),cancel(){o||t()},_emitData(e){if(!o){a.length>0?a.shift().resolve({done:!1,value:e}):s.push(e);for(const t of n.data)try{t(e)}catch(e){T("Stream data listener failed:",e)}}},_resolve(e){if(!o){for(o=!0,r(e);a.length>0;)a.shift().resolve({done:!0,value:e});for(const t of n.end)try{t(e)}catch(e){T("Stream end listener failed:",e)}}},_reject(e){if(!o){for(o=!0,i(e);a.length>0;)a.shift().reject(e);for(const t of n.error)try{t(e)}catch(e){T("Stream error listener failed:",e)}}}}}const oe=new Map,re=new Map,ie=new Map,se=[];let ae=-1,le={};const ce=new Set,de=new WeakMap,ue=new Map;function me(e,t){ue.set(e,t)}function fe(e){if(e.startsWith("host."))return"host";const t=e.indexOf(".");return t>0?e.slice(0,t):"page"}function pe(e){if(null!=e)return e}function he(){return N===b?!!A:H()?O:"webkit"===N||N===k}function ge(){return he()&&Y}function ve(e,t){const n=oe.get(e);if(n){oe.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);if("stream"===n.mode&&n.stream)return void n.stream._reject(o);n.reject?.(o)}}function ye(e,t){const n=re.get(e);if(!n)return;re.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);n.channel._reject(o),n.reject(o)}function xe(e,t){oe.has(e)?ve(e,t):re.has(e)&&ye(e,t)}function we(e){const n=oe.get(e);n&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0?null!==n.timerId&&(clearTimeout(n.timerId),n.timerId=null):(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{oe.has(e)&&ve(e,{code:t,message:`'${n.method}' timed out`})},n.timeoutMs)))}function be(e){oe.has(e)?we(e):re.has(e)&&function(e){const n=re.get(e);n&&(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{ye(e,{code:t,message:`Channel '${n.topic}' timed out`})},x))}(e)}function ke(e){for(let t=se.length-1;t>=0;t--)if(se[t]?.reqId===e)return se.splice(t,1),!0;return!1}function Ee(e,t){const n=e.kind,o="hello"===n||"helloAck"===n||"ready"===n;if(!ge()&&!o)return se.length>=256?(L("Outbox full"),void(t&&xe(t,{code:l,message:"Bridge outbox is full"}))):void se.push({msg:e,reqId:t});t&&be(t),U(e)}function Ie(){null!==Q&&(clearTimeout(Q),Q=null)}function Ce(){if(Y)return;if(!he())return;Ie();const e={v:2,kind:"hello",nonce:p.nonce||"",role:"view",protocolsSupported:[2]};V=!0,U(e),Q=setTimeout(()=>{if(!Y)if(K++,K<3)T(`Handshake timeout (${K}/3), retrying...`),V=!1,Ce();else{for(L("Handshake failed"),Ie(),V=!1,K=0;se.length;){const e=se.shift();e?.reqId&&xe(e.reqId,{code:o,message:"Bridge handshake failed"})}for(const e of Array.from(re.keys()))ye(e,{code:o,message:"Bridge handshake failed"})}},1e4)}function _e(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Te(e,t,n=!1){const o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.split("/").slice(1).map(_e)}(t);if(0===o.length)return{container:{$root:e},key:"$root"};let r=e;for(let e=0;e<o.length-1;e++){const t=o[e];if(Array.isArray(r))r=r[Number(t)];else{if(!r||"object"!=typeof r)throw new Error(`Invalid container at ${t}`);{const i=r;if(n&&void 0===i[t]){const n=o[e+1];i[t]=n&&/^\d+$/.test(n)?[]:{}}r=i[t]}}}return{container:r,key:o[o.length-1]}}function Le(e){ce.forEach(t=>{try{if(!de.has(t))return de.set(t,!0),void t(M(le),{rev:ae,initial:!0});t(M(le),{rev:ae,initial:e})}catch(e){T("Subscriber error:",e)}})}function Se(e){if("function"!=typeof e)return()=>{};if(ce.add(e),ae>=0){de.set(e,!0);try{e(M(le),{rev:ae,initial:!0})}catch(e){L("Callback error:",e)}}return()=>{ce.delete(e),de.delete(e)}}function Me(e){Xe.call("state.getSnapshot",{scope:e}).catch(()=>{})}function Ne(e){if(e&&"object"==typeof e){const t=e;if("event"===t.type&&"nativecomponent"===t.name&&t.payload){const e=t.payload,n=e.id||e.componentId;if("string"==typeof n){const t=Ae.get(n);if(t)try{t(e)}catch(e){L("NC handler error:",e)}}return}}const t=function(e){if(!e||"object"!=typeof e)return null;const t=e.v,n=e.kind;return 2!==t||"string"!=typeof n?null:e}(e);if(t)switch(t.kind){case"helloAck":return void(J=t.sessionId);case"ready":if(J&&t.sessionId!==J)return void T("sessionId mismatch");if(Ie(),Y=!0,K=0,t.hostMethods)for(const[e,n]of Object.entries(t.hostMethods))Z[e]=n;return C("proto")&&_("Handshake complete, hostMethods:",Object.keys(Z).length),void function(){if(ge())for(;se.length;){const e=se.shift();e&&(e.reqId&&be(e.reqId),U(e.msg))}}();case"res":{const e=oe.get(t.id);if(!e)return;if(oe.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok){if("state.getSnapshot"===e.method&&(function(e){if(!e||"object"!=typeof e)return!1;const t=e;return!("number"!=typeof t.rev||!Number.isFinite(t.rev)||!t.state||"object"!=typeof t.state||(le=t.state,ae=t.rev,C("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",ae,"state:",M(le)),console.groupEnd()),Le(!0),0))}(t.result)||T("Invalid state.getSnapshot result")),"stream"===e.mode&&e.stream)return void e.stream._resolve(t.result);e.resolve?.(t.result)}else{const n=u(t.error);if("stream"===e.mode&&e.stream)return void e.stream._reject(n);e.reject?.(n)}return}case"event":if(oe.has(t.id)){const e=oe.get(t.id);return void("stream"===e?.mode&&e.stream?(we(t.id),e.stream._emitData(t.payload)):T(`Received event for non-stream request '${t.id}'`))}return;case"state.snapshot":return le=t.state||{},ae=t.rev,C("data")&&(console.group("[LX] snapshot"),console.log("rev:",ae,"state:",M(le)),console.groupEnd()),void Le(!0);case"state.patch":if(t.baseRev!==ae)return T("baseRev mismatch",{have:ae,want:t.baseRev}),void Me(t.scope);try{!function(e,t){for(const n of t){const t="add"===n.op||"replace"===n.op,{container:o,key:r}=Te(e,n.path,t);if("$root"===r){for(const t of Object.keys(e))delete e[t];if("remove"!==n.op){const t=n.value;t&&"object"==typeof t&&Object.assign(e,t)}continue}if(Array.isArray(o)){const e="-"===r?o.length:Number(r);if(!Number.isFinite(e)||e<0)throw new Error("Invalid index");"remove"===n.op?o.splice(e,1):"add"===n.op?o.splice(e,0,n.value):"replace"===n.op&&(o[e]=n.value);continue}if(!o||"object"!=typeof o)throw new Error("Invalid container");const i=o;"remove"===n.op?delete i[r]:i[r]=n.value}}(le,t.ops||[]),ae=t.rev}catch(e){return L("Patch failed:",e),void Me(t.scope)}return C("data")&&(console.group("[LX] patch"),console.log("rev:",ae,"ops:",t.ops),console.groupEnd()),Le(!1),void(t.ack&&Ee({v:2,kind:"state.ack",scope:t.scope,rev:t.rev}));case"ch.ack":{const e=re.get(t.id);if(!e)return;if(re.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok)e.channel._markOpen(),ie.set(t.id,e.channel),e.resolve(e.channel);else{const n=u(t.error);e.channel._reject(n),e.reject(n)}return}case"ch.data":{const e=ie.get(t.id);if(!e)return;return void e._emitData(t.payload)}case"ch.close":{const e=re.get(t.id);if(e)return re.delete(t.id),void e.channel._emitClose(t.code,t.reason);const n=ie.get(t.id);if(!n)return;return ie.delete(t.id),void n._emitClose(t.code,t.reason)}case"req":{const e=t,n=fe(e.method);if(!e.cap||e.cap!==n)return void Ee({v:2,kind:"res",id:e.id,ok:!1,error:{code:s,message:`Invalid cap for ${e.method}`}});const o=ue.get(e.method);return o?void Promise.resolve().then(()=>o(e.params)).then(t=>{Ee({v:2,kind:"res",id:e.id,ok:!0,result:t})}).catch(t=>{Ee({v:2,kind:"res",id:e.id,ok:!1,error:u(t)})}):void Ee({v:2,kind:"res",id:e.id,ok:!1,error:{code:i,message:`View handler not found: ${e.method}`}})}}else T("Invalid V2 message:",e)}const Ae=new Map,Oe=[];let Pe=!1;function Be(){return"undefined"!=typeof window&&!(!window.webkit?.messageHandlers?.NativeComponent&&!window.NativeComponentBridge?.postMessage)}function je(e){try{if(window.webkit?.messageHandlers?.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(window.NativeComponentBridge?.postMessage)return void window.NativeComponentBridge.postMessage(S(e))}catch(e){L("NativeComponent send error:",e)}}function Re(){if(Be()&&0!==Oe.length)for(Pe=!0;Oe.length;){const e=Oe.shift();try{je(e)}catch{break}}}function Fe(e){try{if(!Be())return void Oe.push(e);Pe||Re(),je(e)}catch(e){L("NC send failed:",e)}}function De(e){return`${e}_${Date.now()}_${ee++}`}function $e(e,t,n){if(!t)return;if(t.aborted)return void n();let o={handleEvent:()=>{t.removeEventListener("abort",o),n()}};t.addEventListener("abort",o)}const Xe={call:(e,t,o)=>new Promise((i,s)=>{if(!e||"string"!=typeof e)return void s({code:r,message:"Method name must be a non-empty string"});V||Ce();const a=De("c"),l=o?.cap||fe(e),c=o?.timeoutMs??x;oe.set(a,{method:e,mode:"call",resolve:i,reject:e=>s(e),timeoutMs:c,timerId:null}),Ee({v:2,kind:"req",id:a,method:e,params:pe(t),cap:l},a),$e(0,o?.signal,()=>{const e=ke(a);ve(a,{code:n,message:"Bridge request aborted"}),!e&&Y&&Ee({v:2,kind:"cancel",id:a})})}),stream(e,t,o){if(!e||"string"!=typeof e){const e=ne("invalid",()=>{});return e._reject({code:r,message:"Method name must be a non-empty string"}),e}V||Ce();const i=De("c"),s=ne(i,()=>{ke(i)?ve(i,{code:n,message:"Bridge request aborted"}):Y&&Ee({v:2,kind:"cancel",id:i})}),a=o?.cap||fe(e),l=o?.timeoutMs??x;return oe.set(i,{method:e,mode:"stream",stream:s,timeoutMs:l,timerId:null}),Ee({v:2,kind:"req",id:i,method:e,params:pe(t),cap:a},i),$e(0,o?.signal,()=>s.cancel()),s},notify(e,t,n){e&&"string"==typeof e&&(V||Ce(),Ee({v:2,kind:"notify",method:e,params:pe(t),cap:n?.cap||fe(e)}))},state:{subscribe:Se},channel:{open:(e,t,n)=>e&&"string"==typeof e?(V||Ce(),new Promise((o,r)=>{const i=De("ch"),s=function(e,t,n){const o=te();let r=!1,i=0,s=!1;const a=[],l=[],d={id:e,send(n){r?t(n,i++):d._reject({code:c,message:`Channel '${e}' is closed`})},on(e,t){return"data"===e&&o.data.add(t),"close"===e&&o.close.add(t),"error"===e&&o.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>a.length>0?Promise.resolve({done:!1,value:a.shift()}):s?Promise.resolve({done:!0,value:void 0}):new Promise((e,t)=>{l.push({resolve:e,reject:t})})}),close(e,t){r&&(r=!1,s=!0,n(e,t),d._emitClose(e,t))},_emitData(e){if(r){l.length>0?l.shift().resolve({done:!1,value:e}):a.push(e);for(const t of o.data)try{t(e)}catch(e){T("Channel listener failed:",e)}}},_emitClose(e,t){for(s=!0;l.length>0;)l.shift().resolve({done:!0,value:void 0});for(const n of o.close)try{n(e,t)}catch(e){T("Channel close listener failed:",e)}},_reject(e){for(s=!0;l.length>0;)l.shift().reject(e);for(const t of o.error)try{t(e)}catch(e){T("Channel error listener failed:",e)}},_markOpen(){r=!0,s=!1},_isOpen:()=>r,_nextSeq:()=>i++};return d}(i,(e,t)=>{Ee({v:2,kind:"ch.data",id:i,seq:t,payload:e})},(e,t)=>{const n=re.get(i);n&&null!==n.timerId&&clearTimeout(n.timerId),re.delete(i),ie.delete(i),Ee({v:2,kind:"ch.close",id:i,code:e,reason:t})});re.set(i,{topic:e,channel:s,resolve:o,reject:r,timerId:null}),Ee({v:2,kind:"ch.open",id:i,topic:e,params:pe(t),cap:n?.cap||fe(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}},He={invoke:(e,t,n)=>Xe.call(qe(e),t,ze(n)).then(e=>e).catch(e=>Promise.reject(m(e))),notify(e,t,n){Xe.notify(qe(e),t,ze(n))},stream:(e,t,n)=>Ge(Xe.stream(qe(e),t,ze(n))),channel:(e,t,n)=>Xe.channel.open(qe(e),t,ze(n)).then(e=>function(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("close",(e,t)=>{const o={code:e,reason:t};for(const e of n)e(o)}),{send(t){e.send(t)},onMessage:e=>(t.add(e),()=>{t.delete(e)}),onClose:e=>(n.add(e),()=>{n.delete(e)}),close(t,n){e.close(t,n)}}}(e)).catch(e=>Promise.reject(m(e))),raw:Xe,state:{subscribe:Se},_connectWebMessagePort(e){if(N===b){if(A&&A!==e)try{A.onmessage=null,A.close()}catch{}A=e,e.onmessage=e=>{let t=e.data;if("string"==typeof t)try{t=JSON.parse(t)}catch{return}Ne(t)};try{e.start()}catch{}_("Port connected"),Ce()}},_receiveEvaluateMessage(e){try{e&&Ne(JSON.parse(e))}catch(e){L("Parse error:",e)}},debug:new Proxy(E,{get:(e,t)=>e[t],set:(e,t,n)=>t in e&&(e[t]=!!n,console.log(`[LX] ${t}: ${n}`),!0)}),platform:{isHarmony:function(){return"Harmony"===p.os},isIOS:g,isAndroid:function(){return"Android"===p.os},isMacOS:v,isDesktop:function(){return v()},getOS:h},dom:{measureById(e){try{if(!e)return null;const t=document.getElementById(e);if(!t)return null;const n=t.getBoundingClientRect();let o=0;try{o=parseFloat(getComputedStyle(t).borderRadius)||0}catch{}return[n.left+window.scrollX,n.top+window.scrollY,n.width,n.height,o]}catch{return null}}},nativeComponents:{send:Fe,hasHandler:Be,flush:Re,register:(e,t)=>e&&"function"==typeof t?(Ae.set(e,t),()=>Ae.delete(e)):()=>{},unregister(e){Ae.delete(e)}},isReady:()=>Y};function qe(e){return e.startsWith("host.")?e:`host.${e}`}function ze(e){return{...e||{},cap:e?.cap||"host"}}function Ge(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("error",e=>{const t=m(e);for(const e of n)e(t)}),{onEvent:e=>(t.add(e),()=>{t.delete(e)}),onError:e=>(n.add(e),()=>{n.delete(e)}),result:e.result.catch(e=>Promise.reject(m(e))),cancel(){e.cancel()}}}function We(){if(window.__LX_BRIDGE_INIT_STATE)_(`Bridge already ${window.__LX_BRIDGE_INIT_STATE}, skipping duplicate init`);else{window.__LX_BRIDGE_INIT_STATE="initializing";try{_(`Method: ${N}`),function(e){if("undefined"==typeof window)return;if(window[y]=e,0===I.length)return;const t=I.splice(0,I.length);for(const n of t)try{e(n)}catch(e){T("Failed to replay queued native message:",e)}}(He._receiveEvaluateMessage),H()?W():N===b?($(),function(){if(A)return Promise.resolve(A);if(F.promise)return F.promise;$(),F.promise=new Promise((e,t)=>{F.resolve=t=>{X(),e(t)},F.reject=e=>{X(),t(e)},F.timer=window.setTimeout(()=>{F.reject?.(new Error("MessagePort init timed out after 5000ms"))},5e3)});try{window.LingXiaProxy?.getPort("LingXiaPort")}catch(e){F.reject?.(e)}return F.promise}().catch(e=>T("Port init failed:",e))):"webkit"===N||N===k?Ce():T("Unknown method"),window.LingXiaBridge=He,f({os:h(),send:Fe}),window.__LX_BRIDGE_INIT_STATE="initialized",_("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function Ue(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Je(e){const{failedPath:t,reason:n}=e,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";const r=document.createElement("div");r.className="lx-error";let i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",t&&(i+=`<div class="lx-error-path">${Ue(t)}</div>`),n&&(i+=`<p class="lx-error-desc" style="margin-top:12px">${Ue(n)}</p>`),r.innerHTML=i,document.body.appendChild(r)}function Ye(){const e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function Ve(){return window.__LX_RUNTIME_CONFIG?.error||null}const Ke={handleEvent:()=>Qe()};function Qe(){if(Ye()){const e=Ve();e&&Je(e)}}function Ze(){We(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ke):Qe()}function et(e){const t=e.trim();return function(e){return 0!==e.length&&!(e.startsWith("lx://")||e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("file:"))&&(e.startsWith("http://")||e.startsWith("https://"))}(t)?function(e){return`lx://proxy/${btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}`}(t):e}const tt="lx-action-sheet-style";let nt=null;function ot(e){const t=e,n=t?.itemList??[],o=t?.cancelText??"Cancel",r=t?.itemColor??"#007AFF",i=(nt??Promise.resolve()).then(()=>rt(n,o,r),()=>rt(n,o,r));return nt=i,i}function rt(e,t,n){return new Promise(o=>{let r=!1;const i="macOS"===h();!function(){if(document.getElementById(tt))return;const e=document.createElement("style");e.id=tt,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 300ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform 300ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n",document.head.appendChild(e)}();const s=document.createElement("div");s.className="lx-as-backdrop";const a=document.createElement("div");a.className="lx-as-sheet",i&&a.classList.add("lx-as-desktop");const l=document.createElement("div");l.className="lx-as-container",i&&l.classList.add("lx-as-desktop"),e.forEach((e,t)=>{const o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=n,o.addEventListener("click",()=>u(t)),l.appendChild(o)});const c=document.createElement("div");c.className="lx-as-separator",l.appendChild(c);const d=document.createElement("button");function u(e){r||(r=!0,s.classList.remove("lx-as-visible"),a.classList.remove("lx-as-visible"),setTimeout(()=>{s.remove(),a.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=t,d.addEventListener("click",()=>u(-1)),l.appendChild(d),a.appendChild(l),document.body.appendChild(s),document.body.appendChild(a),requestAnimationFrame(()=>{s.classList.add("lx-as-visible"),a.classList.add("lx-as-visible")}),s.addEventListener("click",()=>u(-1))})}const it=200,st="lx-modal-style";let at=null;function lt(e){const t=e,n=t?.title??"",o=t?.content??"",r=t?.showCancel??!0,i=t?.cancelText??"Cancel",s=t?.cancelColor,a=t?.confirmText??"OK",l=t?.confirmColor??"#007AFF",c=(at??Promise.resolve()).then(()=>ct(n,o,r,i,s,a,l),()=>ct(n,o,r,i,s,a,l));return at=c,c}function ct(e,t,n,o,r,i,s){return new Promise(a=>{let l=!1;!function(){if(document.getElementById(st))return;const e=document.createElement("style");e.id=st,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 200ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n",document.head.appendChild(e)}();const c=document.createElement("div");c.className="lx-modal-backdrop";const d=document.createElement("div");d.className="lx-modal-dialog";const u=document.createElement("div");u.className="lx-modal-body";const m=document.createElement("div");if(m.className="lx-modal-title",m.textContent=e,u.appendChild(m),t){const e=document.createElement("p");e.className="lx-modal-content",e.textContent=t,u.appendChild(e)}d.appendChild(u);const f=document.createElement("div");if(f.className="lx-modal-footer",n){const e=document.createElement("button");e.className="lx-modal-btn lx-modal-btn-cancel",e.textContent=o,r&&(e.style.color=r),e.addEventListener("click",()=>h(!1)),f.appendChild(e)}const p=document.createElement("button");function h(e){l||(l=!0,c.classList.remove("lx-modal-visible"),setTimeout(()=>{c.remove(),a({confirm:e,cancel:!e})},it))}p.className="lx-modal-btn lx-modal-btn-confirm",p.textContent=i,p.style.color=s,p.addEventListener("click",()=>h(!0)),f.appendChild(p),d.appendChild(f),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(()=>{c.classList.add("lx-modal-visible")})})}const dt="lx-toast-style";let ut=null;function mt(e){const t=e,n=t?.title??"",o=t?.icon??"none",r=t?.duration??1500,i=t?.mask??!1,s=t?.position??"center";ut&&(ut.dismiss(),ut=null),function(){if(document.getElementById(dt))return;const e=document.createElement("style");e.id=dt,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n",document.head.appendChild(e)}();let a=null;i&&(a=document.createElement("div"),a.className="lx-toast-mask",document.body.appendChild(a));const l=document.createElement("div");l.className="lx-toast-container","top"===s?l.classList.add("lx-toast-top"):"bottom"===s?l.classList.add("lx-toast-bottom"):l.classList.add("lx-toast-center");const c=document.createElement("div");c.className="lx-toast-box";const d="none"!==o;if(d||c.classList.add("lx-toast-no-icon"),d){const e=document.createElement("div");e.className="lx-toast-icon","success"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===o&&(e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),c.appendChild(e)}const u=document.createElement("div");u.className="lx-toast-title",u.textContent=n,c.appendChild(u),l.appendChild(c),document.body.appendChild(l),requestAnimationFrame(()=>{c.classList.add("lx-toast-visible")});let m=!1;function f(){m||(m=!0,ut?.dismiss===f&&(ut=null),c.classList.remove("lx-toast-visible"),p&&clearTimeout(p),setTimeout(()=>{l.remove(),a?.remove()},200))}let p=null;return r>0&&(p=setTimeout(f,r)),ut={dismiss:f,timer:p},Promise.resolve()}function ft(){return ut&&(ut.dismiss(),ut=null),Promise.resolve()}return me("ui.showActionSheet",ot),me("ui.showModal",lt),me("ui.showToast",mt),me("ui.hideToast",ft),function(){const e=h();if("iOS"!==e&&"macOS"!==e)return;if("undefined"==typeof window||"undefined"==typeof document)return;if("undefined"==typeof HTMLImageElement)return;const t=HTMLImageElement.prototype;if(t.__lxProxyPatched)return;t.__lxProxyPatched=!0;const n=t.setAttribute;t.setAttribute=function(e,t){return"string"==typeof e&&"src"===e.toLowerCase()&&"string"==typeof t?n.call(this,e,et(t)):n.call(this,e,t)};const o=Object.getOwnPropertyDescriptor(t,"src");o?.set&&Object.defineProperty(t,"src",{configurable:o.configurable,enumerable:o.enumerable,get:o.get,set(e){"string"==typeof e?o.set?.call(this,et(e)):o.set?.call(this,e)}});const r=()=>{document.querySelectorAll("img[src]").forEach(e=>{const t=e.getAttribute("src");if(!t)return;const o=et(t);o!==t&&n.call(e,"src",o)})},i={handleEvent:()=>r()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",i):r()}(),Ze(),e.LingXiaBridge=He,e.boot=function(){We(),Qe()},e.bootWhenReady=Ze,e.channel=function(e,t,n){return He.channel(e,t,n)},e.getErrorInfo=Ve,e.hasError=Ye,e.initBridge=We,e.invoke=function(e,t,n){return He.invoke(e,t,n)},e.isNativeError=function(e,t){if(!e||"object"!=typeof e)return!1;const n=e;return"string"==typeof n.code&&""!==n.code.trim()&&("string"==typeof n.message&&(void 0===t||n.code===t))},e.notify=function(e,t,n){Xe.notify(qe(e),t,ze(n))},e.renderErrorUI=Je,e.stream=function(e,t,n){return Ge(Xe.stream(qe(e),t,ze(n)))},e}({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __extends=this&&this.__extends||function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},e(n,t)};return function(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},__assign.apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,l)}s((o=o.apply(e,n||[])).next())})},__generator=this&&this.__generator||function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],o=0}finally{t=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},__spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||2===arguments.length)for(var o,r=0,i=n.length;r<i;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))},__LX_RUNTIME_PLATFORM__="mobile",__LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n="BRIDGE_TIMEOUT",t="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",a="BRIDGE_CAPABILITY_DENIED",l="BRIDGE_INTERNAL_ERROR",s="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED",d=function(e){function n(n,t,o){var r=e.call(this,t)||this;return r.name="BridgeInvocationError",r.code=n,r.data=o,r}return __extends(n,e),n}(Error);function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){var n=e,t=l;("string"==typeof n.code&&""!==n.code.trim()||"number"==typeof n.code&&Number.isFinite(n.code))&&(t=n.code);var o="string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error";return new d(t,o,"data"in n?n.data:void 0)}var r=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(l,r)}function f(e){var n=u(e);return __assign({code:String(n.code||l),message:"string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error"},void 0===n.data?{}:{data:n.data})}function m(e){var n,t=e.os,o=e.send;if("undefined"!=typeof window&&"undefined"!=typeof document){var r="iOS"===t;if(r||"Android"===t){var i=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(!(null===(n=window[i])||void 0===n?void 0:n.installed)){var a={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};window[i]=a,new MutationObserver(u).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});var l={handleEvent:function(){(a.hasAnyVideo||0!==a.coveredById.size)&&u()}},s={handleEvent:function(){return u()}};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",s),u()}}}function c(e){var n,t,o=null===(n=e.getBoundingClientRect)||void 0===n?void 0:n.call(e);if(!o)return!1;if(o.width<2||o.height<2)return!1;var r=o.left+o.width/2,i=o.top+o.height/2;if(r<0||i<0||r>=window.innerWidth||i>=window.innerHeight)return!1;var a=null===(t=document.elementFromPoint)||void 0===t?void 0:t.call(document,r,i);return!!a&&(a!==document.documentElement&&a!==document.body&&!(a===e||e.contains(a)))}function d(){a.scheduled=!1;var e=document.querySelectorAll("lx-video[id]");if(a.hasAnyVideo=e.length>0,a.hasAnyVideo||0!==a.coveredById.size||a.anyCovered){for(var n=new Set,t=0,i=Array.from(e);t<i.length;t++){var l=i[t];if(p=l.id){n.add(p);var s=c(l),d=a.coveredById.get(p);d!==s&&(!0===d&&(a.coveredCount-=1),!0===s&&(a.coveredCount+=1),a.coveredById.set(p,s),o({id:p,action:"component.coverage",covered:s}))}}for(var u=[],f=0,m=a.coveredById.entries();f<m.length;f++){var v=m[f],p=v[0];s=v[1];n.has(p)||(u.push(p),!0===s&&(a.coveredCount-=1))}for(var h=0,g=u;h<g.length;h++){p=g[h];a.coveredById.delete(p),o({id:p,action:"component.coverage",covered:!1})}var y=a.coveredCount>0;y!==a.anyCovered&&(a.anyCovered=y,r&&(y?function(){if(r&&!a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!0,a.scrollY=window.scrollY||e.scrollTop||0,a.htmlOverflow=e.style.overflow||"",a.bodyOverflow=n.style.overflow||"",a.bodyPosition=n.style.position||"",a.bodyTop=n.style.top||"",a.bodyWidth=n.style.width||"",e.style.overflow="hidden",n.style.overflow="hidden",n.style.position="fixed",n.style.top="".concat(-a.scrollY,"px"),n.style.width="100%")}}():function(){if(r&&a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!1,e.style.overflow=a.htmlOverflow,n.style.overflow=a.bodyOverflow,n.style.position=a.bodyPosition,n.style.top=a.bodyTop,n.style.width=a.bodyWidth,window.scrollTo(0,a.scrollY))}}()))}}function u(){a.scheduled||(a.scheduled=!0,requestAnimationFrame(d))}}var v="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function p(){return v.os||"unknown"}function h(){return"iOS"===v.os}function g(){return"macOS"===v.os}var y="__LingXiaRecvMessage",x=5e3,b="[LX.Bridge]",w="messageport",_="jsinterface",k={data:!1,proto:!1,all:!1},E=[];function I(e){return k.all||k[e]}function C(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.log.apply(console,__spreadArray([b],e,!1))}function T(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.warn.apply(console,__spreadArray([b],e,!1))}function L(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.error.apply(console,__spreadArray([b],e,!1))}function S(e){try{return JSON.stringify(e)}catch(n){return function(e,n){var t=new WeakSet;return JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n},n)}(e)}}function M(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(e){return{}}}var N,O,A="iOS"===v.os||"macOS"===v.os?"webkit":"Harmony"===v.os?"messageport":"Android"===v.os?(null===(O=null===(N=window.LingXiaProxy)||void 0===N?void 0:N.supportsMessagePort)||void 0===O?void 0:O.call(N))?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=function(e){E.push(e)});var P=null,j=!1,B=null,R=null,F=null,D=200,X={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},H={handleEvent:function(e){var n,t,o=e;if("LingXia-port-init"===o.data){var r=null===(n=o.ports)||void 0===n?void 0:n[0];r&&(Ge._connectWebMessagePort(r),null===(t=X.resolve)||void 0===t||t.call(X,r))}}};function q(){X.listenerInstalled||(X.listenerInstalled=!0,window.addEventListener("message",H))}function z(){null!==X.timer&&(window.clearTimeout(X.timer),X.timer=null),X.resolve=null,X.reject=null,X.promise=null}function G(){return"webkit"===A&&(h()||g())}function U(){null!==F&&(clearTimeout(F),F=null)}function W(e){for(var n=0,t=Array.from(ie.keys());n<t.length;n++){xe(t[n],{code:c,message:e})}for(var o=0,r=Array.from(ae.keys());o<r.length;o++){be(r[o],{code:c,message:e})}!function(e){for(var n=0,t=Array.from(le.entries());n<t.length;n++){var o=t[n],r=o[0],i=o[1];le.delete(r),i._emitClose(c,e)}}(e)}function J(){return __awaiter(this,void 0,void 0,function(){var e,n,t,o,r,i,a,l,s;return __generator(this,function(c){switch(c.label){case 0:e=new AbortController,R=e,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch("lx-apple://bridge/downstream",{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal})];case 2:return n=c.sent(),[3,4];case 3:if(t=c.sent(),e.signal.aborted)return[2];throw t;case 4:if(!n.ok)throw new Error("Apple downstream HTTP ".concat(n.status));if(!n.body)throw new Error("Apple downstream response body unavailable");j=!0,D=200,I("proto")&&C("Apple downstream connected"),Te(),o=n.body.getReader(),r=new TextDecoder,i="",c.label=5;case 5:c.trys.push([5,,9,10]),c.label=6;case 6:return[4,o.read()];case 7:return a=c.sent(),l=a.value,a.done?[3,8]:(i=function(e){for(var n=e;;){var t=n.indexOf("\n");if(t<0)break;var o=n.slice(0,t).trim();if(n=n.slice(t+1),o)try{Ae(JSON.parse(o))}catch(e){T("Apple downstream parse error:",e,o)}}return n}(i+=r.decode(l,{stream:!0})),[3,6]);case 8:if(i+=r.decode(),s=i.trim())try{Ae(JSON.parse(s))}catch(e){T("Apple downstream trailing parse error:",e,s)}return[3,10];case 9:try{o.releaseLock()}catch(e){}return[7];case 10:return[2]}})})}function Y(){G()&&(B||(U(),B=J().catch(function(e){(null==R?void 0:R.signal.aborted)||T("Apple downstream failed:",e)}).finally(function(){var e,n=null!==(e=null==R?void 0:R.signal.aborted)&&void 0!==e&&e;B=null,R=null;var t,o,r=j;j=!1,t="Apple downstream closed",o=r,Ce(),$=null,K=!1,Q=!1,Z=0,o&&W(t),n||function(e){if(G()){U();var n=D;D=Math.min(2*D,2e3);var t="Apple downstream disconnected, retrying in ".concat(n,"ms: ").concat(e);n<=200?C(t):T(t),F=setTimeout(function(){F=null,Y()},n)}}("stream closed")})))}function V(e){var n,t,o,r=e.kind;"req"!==r&&"notify"!==r||C("postToNative: ".concat(r," ").concat(e.method)),I("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===A)return void(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers.LingXia)||void 0===t||t.postMessage(e));var i=S(e);if(A===w&&P)return void P.postMessage(i);if(A===_&&(null===(o=window.LingXiaProxy)||void 0===o?void 0:o.postMessage))return void window.LingXiaProxy.postMessage(i);T("Transport not ready")}catch(e){L("Send error:",e)}}var $=null,K=!1,Q=!1,Z=0,ee=null,ne={},te=0;function oe(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function re(e,n){var t,o=oe(),r=!1,i=function(){},a=function(){},l=[],s=[],c=new Promise(function(e,n){i=e,a=n});return(t={id:e,result:c,on:function(e,n){return"data"===e&&o.data.add(n),"end"===e&&o.end.add(n),"error"===e&&o.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return l.length>0?Promise.resolve({done:!1,value:l.shift()}):r?c.then(function(e){return{done:!0,value:e}},function(e){return Promise.reject(e)}):new Promise(function(e,n){s.push({resolve:e,reject:n})})}}},t.cancel=function(){r||n()},t._emitData=function(e){if(!r){s.length>0?s.shift().resolve({done:!1,value:e}):l.push(e);for(var n=0,t=o.data;n<t.length;n++){var i=t[n];try{i(e)}catch(e){T("Stream data listener failed:",e)}}}},t._resolve=function(e){if(!r){for(r=!0,i(e);s.length>0;)s.shift().resolve({done:!0,value:e});for(var n=0,t=o.end;n<t.length;n++){var a=t[n];try{a(e)}catch(e){T("Stream end listener failed:",e)}}}},t._reject=function(e){if(!r){for(r=!0,a(e);s.length>0;)s.shift().reject(e);for(var n=0,t=o.error;n<t.length;n++){var i=t[n];try{i(e)}catch(e){T("Stream error listener failed:",e)}}}},t}var ie=new Map,ae=new Map,le=new Map,se=[],ce=-1,de={},ue=new Set,fe=new WeakMap,me=new Map;function ve(e,n){me.set(e,n)}function pe(e){if(e.startsWith("host."))return"host";var n=e.indexOf(".");return n>0?e.slice(0,n):"page"}function he(e){if(null!=e)return e}function ge(){return A===w?!!P:G()?j:"webkit"===A||A===_}function ye(){return ge()&&K}function xe(e,n){var t,o=ie.get(e);if(o){ie.delete(e),null!==o.timerId&&clearTimeout(o.timerId);var r=u(n);if("stream"===o.mode&&o.stream)return void o.stream._reject(r);null===(t=o.reject)||void 0===t||t.call(o,r)}}function be(e,n){var t=ae.get(e);if(t){ae.delete(e),null!==t.timerId&&clearTimeout(t.timerId);var o=u(n);t.channel._reject(o),t.reject(o)}}function we(e,n){ie.has(e)?xe(e,n):ae.has(e)&&be(e,n)}function _e(e){var t=ie.get(e);t&&(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0?null!==t.timerId&&(clearTimeout(t.timerId),t.timerId=null):(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){ie.has(e)&&xe(e,{code:n,message:"'".concat(t.method,"' timed out")})},t.timeoutMs)))}function ke(e){ie.has(e)?_e(e):ae.has(e)&&function(e){var t=ae.get(e);t&&(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){be(e,{code:n,message:"Channel '".concat(t.topic,"' timed out")})},x))}(e)}function Ee(e){for(var n,t=se.length-1;t>=0;t--)if((null===(n=se[t])||void 0===n?void 0:n.reqId)===e)return se.splice(t,1),!0;return!1}function Ie(e,n){var t=e.kind,o="hello"===t||"helloAck"===t||"ready"===t;if(!ye()&&!o)return se.length>=256?(L("Outbox full"),void(n&&we(n,{code:s,message:"Bridge outbox is full"}))):void se.push({msg:e,reqId:n});n&&ke(n),V(e)}function Ce(){null!==ee&&(clearTimeout(ee),ee=null)}function Te(){if(!K&&ge()){Ce();var e={v:2,kind:"hello",nonce:v.nonce||"",role:"view",protocolsSupported:[2]};Q=!0,V(e),ee=setTimeout(function(){if(!K)if(++Z<3)T("Handshake timeout (".concat(Z,"/").concat(3,"), retrying...")),Q=!1,Te();else{for(L("Handshake failed"),Ce(),Q=!1,Z=0;se.length;){var e=se.shift();(null==e?void 0:e.reqId)&&we(e.reqId,{code:o,message:"Bridge handshake failed"})}for(var n=0,t=Array.from(ae.keys());n<t.length;n++){be(t[n],{code:o,message:"Bridge handshake failed"})}}},1e4)}}function Le(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Se(e,n,t){void 0===t&&(t=!1);var o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error("Invalid JSON pointer: ".concat(e));return e.split("/").slice(1).map(Le)}(n);if(0===o.length)return{container:{$root:e},key:"$root"};for(var r=e,i=0;i<o.length-1;i++){var a=o[i];if(Array.isArray(r))r=r[Number(a)];else{if(!r||"object"!=typeof r)throw new Error("Invalid container at ".concat(a));var l=r;if(t&&void 0===l[a]){var s=o[i+1];l[a]=s&&/^\d+$/.test(s)?[]:{}}r=l[a]}}return{container:r,key:o[o.length-1]}}function Me(e){ue.forEach(function(n){try{if(!fe.has(n))return fe.set(n,!0),void n(M(de),{rev:ce,initial:!0});n(M(de),{rev:ce,initial:e})}catch(e){T("Subscriber error:",e)}})}function Ne(e){if("function"!=typeof e)return function(){};if(ue.add(e),ce>=0){fe.set(e,!0);try{e(M(de),{rev:ce,initial:!0})}catch(e){L("Callback error:",e)}}return function(){ue.delete(e),fe.delete(e)}}function Oe(e){ze.call("state.getSnapshot",{scope:e}).catch(function(){})}function Ae(e){var n,t;if(e&&"object"==typeof e){var o=e;if("event"===o.type&&"nativecomponent"===o.name&&o.payload){var r=o.payload,l=r.id||r.componentId;if("string"==typeof l){var s=Pe.get(l);if(s)try{s(r)}catch(e){L("NC handler error:",e)}}return}}var c=function(e){if(!e||"object"!=typeof e)return null;var n=e.v,t=e.kind;return 2!==n||"string"!=typeof t?null:e}(e);if(c)switch(c.kind){case"helloAck":return void($=c.sessionId);case"ready":if($&&c.sessionId!==$)return void T("sessionId mismatch");if(Ce(),K=!0,Z=0,c.hostMethods)for(var d=0,f=Object.entries(c.hostMethods);d<f.length;d++){var m=f[d],v=m[0],p=m[1];ne[v]=p}return I("proto")&&C("Handshake complete, hostMethods:",Object.keys(ne).length),void function(){if(ye())for(;se.length;){var e=se.shift();e&&(e.reqId&&ke(e.reqId),V(e.msg))}}();case"res":var h=ie.get(c.id);if(!h)return;if(ie.delete(c.id),null!==h.timerId&&clearTimeout(h.timerId),c.ok){if("state.getSnapshot"===h.method&&(function(e){if(!e||"object"!=typeof e)return!1;var n=e;return!("number"!=typeof n.rev||!Number.isFinite(n.rev)||!n.state||"object"!=typeof n.state||(de=n.state,ce=n.rev,I("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",ce,"state:",M(de)),console.groupEnd()),Me(!0),0))}(c.result)||T("Invalid state.getSnapshot result")),"stream"===h.mode&&h.stream)return void h.stream._resolve(c.result);null===(n=h.resolve)||void 0===n||n.call(h,c.result)}else{var g=u(c.error);if("stream"===h.mode&&h.stream)return void h.stream._reject(g);null===(t=h.reject)||void 0===t||t.call(h,g)}return;case"event":if(ie.has(c.id)){var y=ie.get(c.id);return void("stream"===(null==y?void 0:y.mode)&&y.stream?(_e(c.id),y.stream._emitData(c.payload)):T("Received event for non-stream request '".concat(c.id,"'")))}return;case"state.snapshot":return de=c.state||{},ce=c.rev,I("data")&&(console.group("[LX] snapshot"),console.log("rev:",ce,"state:",M(de)),console.groupEnd()),void Me(!0);case"state.patch":if(c.baseRev!==ce)return T("baseRev mismatch",{have:ce,want:c.baseRev}),void Oe(c.scope);try{!function(e,n){for(var t=0,o=n;t<o.length;t++){var r=o[t],i="add"===r.op||"replace"===r.op,a=Se(e,r.path,i),l=a.container,s=a.key;if("$root"!==s)if(Array.isArray(l)){var c="-"===s?l.length:Number(s);if(!Number.isFinite(c)||c<0)throw new Error("Invalid index");"remove"===r.op?l.splice(c,1):"add"===r.op?l.splice(c,0,r.value):"replace"===r.op&&(l[c]=r.value)}else{if(!l||"object"!=typeof l)throw new Error("Invalid container");var d=l;"remove"===r.op?delete d[s]:d[s]=r.value}else{for(var u=0,f=Object.keys(e);u<f.length;u++)delete e[f[u]];if("remove"!==r.op){var m=r.value;m&&"object"==typeof m&&Object.assign(e,m)}}}}(de,c.ops||[]),ce=c.rev}catch(e){return L("Patch failed:",e),void Oe(c.scope)}return I("data")&&(console.group("[LX] patch"),console.log("rev:",ce,"ops:",c.ops),console.groupEnd()),Me(!1),void(c.ack&&Ie({v:2,kind:"state.ack",scope:c.scope,rev:c.rev}));case"ch.ack":if(!(b=ae.get(c.id)))return;if(ae.delete(c.id),null!==b.timerId&&clearTimeout(b.timerId),c.ok)b.channel._markOpen(),le.set(c.id,b.channel),b.resolve(b.channel);else{g=u(c.error);b.channel._reject(g),b.reject(g)}return;case"ch.data":var x=le.get(c.id);if(!x)return;return void x._emitData(c.payload);case"ch.close":var b;if(b=ae.get(c.id))return ae.delete(c.id),void b.channel._emitClose(c.code,c.reason);var w=le.get(c.id);if(!w)return;return le.delete(c.id),void w._emitClose(c.code,c.reason);case"req":var _=c,k=pe(_.method);if(!_.cap||_.cap!==k)return void Ie({v:2,kind:"res",id:_.id,ok:!1,error:{code:a,message:"Invalid cap for ".concat(_.method)}});var E=me.get(_.method);return E?void Promise.resolve().then(function(){return E(_.params)}).then(function(e){Ie({v:2,kind:"res",id:_.id,ok:!0,result:e})}).catch(function(e){Ie({v:2,kind:"res",id:_.id,ok:!1,error:u(e)})}):void Ie({v:2,kind:"res",id:_.id,ok:!1,error:{code:i,message:"View handler not found: ".concat(_.method)}})}else T("Invalid V2 message:",e)}var Pe=new Map,je=[],Be=!1;function Re(){var e,n,t;return"undefined"!=typeof window&&!(!(null===(n=null===(e=window.webkit)||void 0===e?void 0:e.messageHandlers)||void 0===n?void 0:n.NativeComponent)&&!(null===(t=window.NativeComponentBridge)||void 0===t?void 0:t.postMessage))}function Fe(e){var n,t,o;try{if(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers)||void 0===t?void 0:t.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(null===(o=window.NativeComponentBridge)||void 0===o?void 0:o.postMessage)return void window.NativeComponentBridge.postMessage(S(e))}catch(e){L("NativeComponent send error:",e)}}function De(){if(Re()&&0!==je.length)for(Be=!0;je.length;){var e=je.shift();try{Fe(e)}catch(e){break}}}function Xe(e){try{if(!Re())return void je.push(e);Be||De(),Fe(e)}catch(e){L("NC send failed:",e)}}function He(e){return"".concat(e,"_").concat(Date.now(),"_").concat(te++)}function qe(e,n,t){if(n)if(n.aborted)t();else{var o={handleEvent:function(){n.removeEventListener("abort",o),t()}};n.addEventListener("abort",o)}}var ze={call:function(e,n,o){return new Promise(function(i,a){var l;if(e&&"string"==typeof e){Q||Te();var s=He("c"),c=(null==o?void 0:o.cap)||pe(e),d=null!==(l=null==o?void 0:o.timeoutMs)&&void 0!==l?l:x;ie.set(s,{method:e,mode:"call",resolve:i,reject:function(e){return a(e)},timeoutMs:d,timerId:null}),Ie({v:2,kind:"req",id:s,method:e,params:he(n),cap:c},s),qe(0,null==o?void 0:o.signal,function(){var e=Ee(s);xe(s,{code:t,message:"Bridge request aborted"}),!e&&K&&Ie({v:2,kind:"cancel",id:s})})}else a({code:r,message:"Method name must be a non-empty string"})})},stream:function(e,n,o){var i;if(!e||"string"!=typeof e){var a=re("invalid",function(){});return a._reject({code:r,message:"Method name must be a non-empty string"}),a}Q||Te();var l=He("c"),s=re(l,function(){Ee(l)?xe(l,{code:t,message:"Bridge request aborted"}):K&&Ie({v:2,kind:"cancel",id:l})}),c=(null==o?void 0:o.cap)||pe(e),d=null!==(i=null==o?void 0:o.timeoutMs)&&void 0!==i?i:x;return ie.set(l,{method:e,mode:"stream",stream:s,timeoutMs:d,timerId:null}),Ie({v:2,kind:"req",id:l,method:e,params:he(n),cap:c},l),qe(0,null==o?void 0:o.signal,function(){return s.cancel()}),s},notify:function(e,n,t){e&&"string"==typeof e&&(Q||Te(),Ie({v:2,kind:"notify",method:e,params:he(n),cap:(null==t?void 0:t.cap)||pe(e)}))},state:{subscribe:Ne},channel:{open:function(e,n,t){return e&&"string"==typeof e?(Q||Te(),new Promise(function(o,r){var i=He("ch"),a=function(e,n,t){var o,r=oe(),i=!1,a=0,l=!1,s=[],d=[],u=((o={id:e,send:function(t){i?n(t,a++):u._reject({code:c,message:"Channel '".concat(e,"' is closed")})},on:function(e,n){return"data"===e&&r.data.add(n),"close"===e&&r.close.add(n),"error"===e&&r.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return s.length>0?Promise.resolve({done:!1,value:s.shift()}):l?Promise.resolve({done:!0,value:void 0}):new Promise(function(e,n){d.push({resolve:e,reject:n})})}}},o.close=function(e,n){i&&(i=!1,l=!0,t(e,n),u._emitClose(e,n))},o._emitData=function(e){if(i){d.length>0?d.shift().resolve({done:!1,value:e}):s.push(e);for(var n=0,t=r.data;n<t.length;n++){var o=t[n];try{o(e)}catch(e){T("Channel listener failed:",e)}}}},o._emitClose=function(e,n){for(l=!0;d.length>0;)d.shift().resolve({done:!0,value:void 0});for(var t=0,o=r.close;t<o.length;t++){var i=o[t];try{i(e,n)}catch(e){T("Channel close listener failed:",e)}}},o._reject=function(e){for(l=!0;d.length>0;)d.shift().reject(e);for(var n=0,t=r.error;n<t.length;n++){var o=t[n];try{o(e)}catch(e){T("Channel error listener failed:",e)}}},o._markOpen=function(){i=!0,l=!1},o._isOpen=function(){return i},o._nextSeq=function(){return a++},o);return u}(i,function(e,n){Ie({v:2,kind:"ch.data",id:i,seq:n,payload:e})},function(e,n){var t=ae.get(i);t&&null!==t.timerId&&clearTimeout(t.timerId),ae.delete(i),le.delete(i),Ie({v:2,kind:"ch.close",id:i,code:e,reason:n})});ae.set(i,{topic:e,channel:a,resolve:o,reject:r,timerId:null}),Ie({v:2,kind:"ch.open",id:i,topic:e,params:he(n),cap:(null==t?void 0:t.cap)||pe(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}}},Ge={invoke:function(e,n,t){return ze.call(Ue(e),n,We(t)).then(function(e){return e}).catch(function(e){return Promise.reject(f(e))})},notify:function(e,n,t){ze.notify(Ue(e),n,We(t))},stream:function(e,n,t){return Je(ze.stream(Ue(e),n,We(t)))},channel:function(e,n,t){return ze.channel.open(Ue(e),n,We(t)).then(function(e){return function(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("close",function(e,n){for(var o={code:e,reason:n},r=0,i=t;r<i.length;r++){(0,i[r])(o)}}),{send:function(n){e.send(n)},onMessage:function(e){return n.add(e),function(){n.delete(e)}},onClose:function(e){return t.add(e),function(){t.delete(e)}},close:function(n,t){e.close(n,t)}}}(e)}).catch(function(e){return Promise.reject(f(e))})},raw:ze,state:{subscribe:Ne},_connectWebMessagePort:function(e){if(A===w){if(P&&P!==e)try{P.onmessage=null,P.close()}catch(e){}P=e,e.onmessage=function(e){var n=e.data;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return}Ae(n)};try{e.start()}catch(e){}C("Port connected"),Te()}},_receiveEvaluateMessage:function(e){try{e&&Ae(JSON.parse(e))}catch(e){L("Parse error:",e)}},debug:new Proxy(k,{get:function(e,n){return e[n]},set:function(e,n,t){return n in e&&(e[n]=!!t,console.log("[LX] ".concat(n,": ").concat(t)),!0)}}),platform:{isHarmony:function(){return"Harmony"===v.os},isIOS:h,isAndroid:function(){return"Android"===v.os},isMacOS:g,isDesktop:function(){return g()},getOS:p},dom:{measureById:function(e){try{if(!e)return null;var n=document.getElementById(e);if(!n)return null;var t=n.getBoundingClientRect(),o=0;try{o=parseFloat(getComputedStyle(n).borderRadius)||0}catch(e){}return[t.left+window.scrollX,t.top+window.scrollY,t.width,t.height,o]}catch(e){return null}}},nativeComponents:{send:Xe,hasHandler:Re,flush:De,register:function(e,n){return e&&"function"==typeof n?(Pe.set(e,n),function(){return Pe.delete(e)}):function(){}},unregister:function(e){Pe.delete(e)}},isReady:function(){return K}};function Ue(e){return e.startsWith("host.")?e:"host.".concat(e)}function We(e){return __assign(__assign({},e||{}),{cap:(null==e?void 0:e.cap)||"host"})}function Je(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("error",function(e){for(var n=f(e),o=0,r=t;o<r.length;o++){(0,r[o])(n)}}),{onEvent:function(e){return n.add(e),function(){n.delete(e)}},onError:function(e){return t.add(e),function(){t.delete(e)}},result:e.result.catch(function(e){return Promise.reject(f(e))}),cancel:function(){e.cancel()}}}function Ye(){if(window.__LX_BRIDGE_INIT_STATE)C("Bridge already ".concat(window.__LX_BRIDGE_INIT_STATE,", skipping duplicate init"));else{window.__LX_BRIDGE_INIT_STATE="initializing";try{C("Method: ".concat(A)),function(e){if("undefined"!=typeof window&&(window[y]=e,0!==E.length))for(var n=0,t=E.splice(0,E.length);n<t.length;n++){var o=t[n];try{e(o)}catch(e){T("Failed to replay queued native message:",e)}}}(Ge._receiveEvaluateMessage),G()?Y():A===w?(q(),function(){var e,n;if(P)return Promise.resolve(P);if(X.promise)return X.promise;q(),X.promise=new Promise(function(e,n){X.resolve=function(n){z(),e(n)},X.reject=function(e){z(),n(e)},X.timer=window.setTimeout(function(){var e;null===(e=X.reject)||void 0===e||e.call(X,new Error("MessagePort init timed out after ".concat(5e3,"ms")))},5e3)});try{null===(e=window.LingXiaProxy)||void 0===e||e.getPort("LingXiaPort")}catch(e){null===(n=X.reject)||void 0===n||n.call(X,e)}return X.promise}().catch(function(e){return T("Port init failed:",e)})):"webkit"===A||A===_?Te():T("Unknown method"),window.LingXiaBridge=Ge,m({os:p(),send:Xe}),window.__LX_BRIDGE_INIT_STATE="initialized",C("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function Ve(e){var n=document.createElement("div");return n.textContent=e,n.innerHTML}function $e(e){var n=e.failedPath,t=e.reason,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";var r=document.createElement("div");r.className="lx-error";var i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",n&&(i+='<div class="lx-error-path">'.concat(Ve(n),"</div>")),t&&(i+='<p class="lx-error-desc" style="margin-top:12px">'.concat(Ve(t),"</p>")),r.innerHTML=i,document.body.appendChild(r)}function Ke(){var e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function Qe(){var e;return(null===(e=window.__LX_RUNTIME_CONFIG)||void 0===e?void 0:e.error)||null}var Ze={handleEvent:function(){return en()}};function en(){if(Ke()){var e=Qe();e&&$e(e)}}function nn(){Ye(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ze):en()}function tn(e){var n=e.trim();return function(e){return 0!==e.length&&!(e.startsWith("lx://")||e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("file:"))&&(e.startsWith("http://")||e.startsWith("https://"))}(n)?function(e){return"".concat("lx://proxy/").concat(btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""))}(n):e}var on="lx-action-sheet-style",rn=null;function an(e){var n,t,o,r=e,i=null!==(n=null==r?void 0:r.itemList)&&void 0!==n?n:[],a=null!==(t=null==r?void 0:r.cancelText)&&void 0!==t?t:"Cancel",l=null!==(o=null==r?void 0:r.itemColor)&&void 0!==o?o:"#007AFF",s=(null!=rn?rn:Promise.resolve()).then(function(){return ln(i,a,l)},function(){return ln(i,a,l)});return rn=s,s}function ln(e,n,t){return new Promise(function(o){var r=!1,i="macOS"===p();!function(){if(!document.getElementById(on)){var e=document.createElement("style");e.id=on,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(300,"ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform ").concat(300,"ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n"),document.head.appendChild(e)}}();var a=document.createElement("div");a.className="lx-as-backdrop";var l=document.createElement("div");l.className="lx-as-sheet",i&&l.classList.add("lx-as-desktop");var s=document.createElement("div");s.className="lx-as-container",i&&s.classList.add("lx-as-desktop"),e.forEach(function(e,n){var o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=t,o.addEventListener("click",function(){return u(n)}),s.appendChild(o)});var c=document.createElement("div");c.className="lx-as-separator",s.appendChild(c);var d=document.createElement("button");function u(e){r||(r=!0,a.classList.remove("lx-as-visible"),l.classList.remove("lx-as-visible"),setTimeout(function(){a.remove(),l.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=n,d.addEventListener("click",function(){return u(-1)}),s.appendChild(d),l.appendChild(s),document.body.appendChild(a),document.body.appendChild(l),requestAnimationFrame(function(){a.classList.add("lx-as-visible"),l.classList.add("lx-as-visible")}),a.addEventListener("click",function(){return u(-1)})})}var sn=200,cn="lx-modal-style",dn=null;function un(e){var n,t,o,r,i,a,l=e,s=null!==(n=null==l?void 0:l.title)&&void 0!==n?n:"",c=null!==(t=null==l?void 0:l.content)&&void 0!==t?t:"",d=null===(o=null==l?void 0:l.showCancel)||void 0===o||o,u=null!==(r=null==l?void 0:l.cancelText)&&void 0!==r?r:"Cancel",f=null==l?void 0:l.cancelColor,m=null!==(i=null==l?void 0:l.confirmText)&&void 0!==i?i:"OK",v=null!==(a=null==l?void 0:l.confirmColor)&&void 0!==a?a:"#007AFF",p=(null!=dn?dn:Promise.resolve()).then(function(){return fn(s,c,d,u,f,m,v)},function(){return fn(s,c,d,u,f,m,v)});return dn=p,p}function fn(e,n,t,o,r,i,a){return new Promise(function(l){var s=!1;!function(){if(!document.getElementById(cn)){var e=document.createElement("style");e.id=cn,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(sn,"ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform ").concat(sn,"ms ease, opacity ").concat(sn,"ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n"),document.head.appendChild(e)}}();var c=document.createElement("div");c.className="lx-modal-backdrop";var d=document.createElement("div");d.className="lx-modal-dialog";var u=document.createElement("div");u.className="lx-modal-body";var f=document.createElement("div");if(f.className="lx-modal-title",f.textContent=e,u.appendChild(f),n){var m=document.createElement("p");m.className="lx-modal-content",m.textContent=n,u.appendChild(m)}d.appendChild(u);var v=document.createElement("div");if(v.className="lx-modal-footer",t){var p=document.createElement("button");p.className="lx-modal-btn lx-modal-btn-cancel",p.textContent=o,r&&(p.style.color=r),p.addEventListener("click",function(){return g(!1)}),v.appendChild(p)}var h=document.createElement("button");function g(e){s||(s=!0,c.classList.remove("lx-modal-visible"),setTimeout(function(){c.remove(),l({confirm:e,cancel:!e})},sn))}h.className="lx-modal-btn lx-modal-btn-confirm",h.textContent=i,h.style.color=a,h.addEventListener("click",function(){return g(!0)}),v.appendChild(h),d.appendChild(v),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(function(){c.classList.add("lx-modal-visible")})})}var mn="lx-toast-style",vn=null;function pn(e){var n,t,o,r,i,a=e,l=null!==(n=null==a?void 0:a.title)&&void 0!==n?n:"",s=null!==(t=null==a?void 0:a.icon)&&void 0!==t?t:"none",c=null!==(o=null==a?void 0:a.duration)&&void 0!==o?o:1500,d=null!==(r=null==a?void 0:a.mask)&&void 0!==r&&r,u=null!==(i=null==a?void 0:a.position)&&void 0!==i?i:"center";vn&&(vn.dismiss(),vn=null),function(){if(!document.getElementById(mn)){var e=document.createElement("style");e.id=mn,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform ".concat(200,"ms ease, opacity ").concat(200,"ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n"),document.head.appendChild(e)}}();var f=null;d&&((f=document.createElement("div")).className="lx-toast-mask",document.body.appendChild(f));var m=document.createElement("div");m.className="lx-toast-container","top"===u?m.classList.add("lx-toast-top"):"bottom"===u?m.classList.add("lx-toast-bottom"):m.classList.add("lx-toast-center");var v=document.createElement("div");v.className="lx-toast-box";var p="none"!==s;if(p||v.classList.add("lx-toast-no-icon"),p){var h=document.createElement("div");h.className="lx-toast-icon","success"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===s&&(h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),v.appendChild(h)}var g=document.createElement("div");g.className="lx-toast-title",g.textContent=l,v.appendChild(g),m.appendChild(v),document.body.appendChild(m),requestAnimationFrame(function(){v.classList.add("lx-toast-visible")});var y=!1;function x(){y||(y=!0,(null==vn?void 0:vn.dismiss)===x&&(vn=null),v.classList.remove("lx-toast-visible"),b&&clearTimeout(b),setTimeout(function(){m.remove(),null==f||f.remove()},200))}var b=null;return c>0&&(b=setTimeout(x,c)),vn={dismiss:x,timer:b},Promise.resolve()}function hn(){return vn&&(vn.dismiss(),vn=null),Promise.resolve()}return"all"!==__LX_RUNTIME_PLATFORM__&&"desktop"!==__LX_RUNTIME_PLATFORM__||(ve("ui.showActionSheet",an),ve("ui.showModal",un),ve("ui.showToast",pn),ve("ui.hideToast",hn)),function(){var e=p();if(("iOS"===e||"macOS"===e)&&"undefined"!=typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement){var n=HTMLImageElement.prototype;if(!n.__lxProxyPatched){n.__lxProxyPatched=!0;var t=n.setAttribute;n.setAttribute=function(e,n){return"string"==typeof e&&"src"===e.toLowerCase()&&"string"==typeof n?t.call(this,e,tn(n)):t.call(this,e,n)};var o=Object.getOwnPropertyDescriptor(n,"src");(null==o?void 0:o.set)&&Object.defineProperty(n,"src",{configurable:o.configurable,enumerable:o.enumerable,get:o.get,set:function(e){var n,t;"string"==typeof e?null===(n=o.set)||void 0===n||n.call(this,tn(e)):null===(t=o.set)||void 0===t||t.call(this,e)}});var r=function(){document.querySelectorAll("img[src]").forEach(function(e){var n=e.getAttribute("src");if(n){var o=tn(n);o!==n&&t.call(e,"src",o)}})},i={handleEvent:function(){return r()}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",i):r()}}}(),nn(),e.LingXiaBridge=Ge,e.boot=function(){Ye(),en()},e.bootWhenReady=nn,e.channel=function(e,n,t){return Ge.channel(e,n,t)},e.getErrorInfo=Qe,e.hasError=Ke,e.initBridge=Ye,e.invoke=function(e,n,t){return Ge.invoke(e,n,t)},e.isNativeError=function(e,n){if(!e||"object"!=typeof e)return!1;var t=e;return"string"==typeof t.code&&""!==t.code.trim()&&("string"==typeof t.message&&(void 0===n||t.code===n))},e.notify=function(e,n,t){ze.notify(Ue(e),n,We(t))},e.renderErrorUI=$e,e.stream=function(e,n,t){return Je(ze.stream(Ue(e),n,We(t)))},e}({});
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChannelOptions, LingXiaBridgeInterface, NativeChannel, NativeStream, NotifyOptions, InvokeOptions, StreamOptions } from "./types";
|
|
2
2
|
export declare function registerViewMethodHandler(method: string, handler: (params: unknown) => unknown | Promise<unknown>): void;
|
|
3
3
|
export declare const LingXiaBridge: LingXiaBridgeInterface;
|
|
4
|
-
export declare
|
|
4
|
+
export declare function invoke<TResult = unknown, TInput = void>(route: string, input?: TInput, options?: InvokeOptions): Promise<TResult>;
|
|
5
|
+
export declare function notify<TInput = void>(route: string, input?: TInput, options?: NotifyOptions): void;
|
|
6
|
+
export declare function stream<TEvent = unknown, TResult = void, TInput = void>(route: string, input?: TInput, options?: StreamOptions): NativeStream<TEvent, TResult>;
|
|
7
|
+
export declare function channel<TIn = unknown, TOut = unknown>(route: string, input?: unknown, options?: ChannelOptions): Promise<NativeChannel<TIn, TOut>>;
|
|
5
8
|
export declare function initBridge(): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { initBridge } from './bridge';
|
|
2
|
+
import { hasError, getErrorInfo, renderErrorUI } from './error';
|
|
3
|
+
const domReadyListener = {
|
|
4
|
+
handleEvent: () => maybeRenderErrorUI(),
|
|
5
|
+
};
|
|
6
|
+
function maybeRenderErrorUI() {
|
|
7
|
+
if (hasError()) {
|
|
8
|
+
const errorInfo = getErrorInfo();
|
|
9
|
+
if (errorInfo) {
|
|
10
|
+
renderErrorUI(errorInfo);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Immediately initialize bridge and render error UI if present.
|
|
16
|
+
* Use this when DOM is already ready.
|
|
17
|
+
*/
|
|
18
|
+
export function boot() {
|
|
19
|
+
initBridge();
|
|
20
|
+
maybeRenderErrorUI();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Initialize bridge immediately, but wait for DOM to render error UI.
|
|
24
|
+
* Use this at page load time.
|
|
25
|
+
*/
|
|
26
|
+
export function bootWhenReady() {
|
|
27
|
+
initBridge();
|
|
28
|
+
if (document.readyState === 'loading') {
|
|
29
|
+
document.addEventListener('DOMContentLoaded', domReadyListener);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
maybeRenderErrorUI();
|
|
33
|
+
}
|
|
34
|
+
}
|