@dimina-kit/devkit 0.1.0-dev.20260422094158

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.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -0
  3. package/dist/index.d.ts +21 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +107 -0
  6. package/fe/dimina-fe-container/assets/container-api.js +1 -0
  7. package/fe/dimina-fe-container/assets/container.css +2 -0
  8. package/fe/dimina-fe-container/assets/index.css +1 -0
  9. package/fe/dimina-fe-container/assets/index.js +148 -0
  10. package/fe/dimina-fe-container/assets/pageFrame.css +1 -0
  11. package/fe/dimina-fe-container/assets/pageFrame.js +27 -0
  12. package/fe/dimina-fe-container/assets/service.js +6 -0
  13. package/fe/dimina-fe-container/dimina-version.json +3 -0
  14. package/fe/dimina-fe-container/favicon.ico +0 -0
  15. package/fe/dimina-fe-container/images/icon-arrow.png +0 -0
  16. package/fe/dimina-fe-container/images/mini-action-white.png +0 -0
  17. package/fe/dimina-fe-container/images/mini-action.png +0 -0
  18. package/fe/dimina-fe-container/images/mini-arrow-left-white.png +0 -0
  19. package/fe/dimina-fe-container/images/mini-arrow-left.jpg +0 -0
  20. package/fe/dimina-fe-container/images/mini-arrow-left.png +0 -0
  21. package/fe/dimina-fe-container/images/mini-close-white.png +0 -0
  22. package/fe/dimina-fe-container/images/mini-close.png +0 -0
  23. package/fe/dimina-fe-container/images/more.png +0 -0
  24. package/fe/dimina-fe-container/images/search.jpg +0 -0
  25. package/fe/dimina-fe-container/index.html +1 -0
  26. package/fe/dimina-fe-container/pageFrame.html +1 -0
  27. package/fe/dimina-fe-server/THIRD_PARTY_NOTICES.md +13 -0
  28. package/fe/dimina-fe-server/index.js +68 -0
  29. package/fe/index.js +118 -0
  30. package/fe/live-reload.js +30 -0
  31. package/fe/server-container.js +11 -0
  32. package/fe/server.js +3 -0
  33. package/package.json +73 -0
@@ -0,0 +1,6 @@
1
+ var service=(function(){var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){return e===`__proto__`}function r(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}function i(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function a(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(a).join(`,`);let t=String(e);return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function o(e){if(Array.isArray(e))return e.map(i);if(typeof e==`symbol`)return[e];e=a(e);let t=[],n=e.length;if(n===0)return t;let r=0,o=``,s=``,c=!1;for(e.charCodeAt(0)===46&&(t.push(``),r++);r<n;){let i=e[r];s?i===`\\`&&r+1<n?(r++,o+=e[r]):i===s?s=``:o+=i:c?i===`"`||i===`'`?s=i:i===`]`?(c=!1,t.push(o),o=``):o+=i:i===`[`?(c=!0,o&&=(t.push(o),``)):i===`.`?o&&=(t.push(o),``):o+=i,r++}return o&&t.push(o),t}function s(e,t,a){if(e==null)return a;switch(typeof t){case`string`:{if(n(t))return a;let i=e[t];return i===void 0?r(t)?s(e,o(t),a):a:i}case`number`:case`symbol`:{typeof t==`number`&&(t=i(t));let n=e[t];return n===void 0?a:n}default:{if(Array.isArray(t))return c(e,t,a);if(t=Object.is(t?.valueOf(),-0)?`-0`:String(t),n(t))return a;let r=e[t];return r===void 0?a:r}}}function c(e,t,r){if(t.length===0)return r;let i=e;for(let e=0;e<t.length;e++){if(i==null||n(t[e]))return r;i=i[t[e]]}return i===void 0?r:i}function l(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function u(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}var d=/^(?:0|[1-9]\d*)$/;function f(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e<t;case`symbol`:return!1;case`string`:return d.test(e)}}function p(e){return typeof e==`symbol`||e instanceof Symbol}var m=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/;function te(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||p(e)?!0:typeof e==`string`&&(ee.test(e)||!m.test(e))||t!=null&&Object.hasOwn(t,e)}var ne=(e,t,n)=>{let r=e[t];(!(Object.hasOwn(e,t)&&u(r,n))||n===void 0&&!(t in e))&&(e[t]=n)};function re(e,t,r,a){if(e==null&&!l(e))return e;let c;c=te(t,e)?[t]:Array.isArray(t)?t:o(t);let u=r(s(e,c)),d=e;for(let t=0;t<c.length&&d!=null;t++){let r=i(c[t]);if(n(r))continue;let o;if(t===c.length-1)o=u;else{let n=d[r],i=a?.(n,r,e);o=i===void 0?l(n)?n:f(c[t+1])?[]:{}:i}ne(d,r,o),d=d[r]}return e}function ie(e,t,n){return re(e,t,()=>n,()=>void 0)}function h(e){return typeof e==`function`}function ae(e){return typeof e==`string`}function oe(e){return e==null}function se(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>se(e[n],t[n])):!1}function g(e,t){return s(e,t)}function ce(e,t,n){ie(e,t,n)}function le(){return Math.random().toString(36).slice(2,7)}function ue(e){return e.toLowerCase().replace(/-(.)/g,(e,t)=>t.toUpperCase())}function de(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}var _=typeof window<`u`&&typeof navigator<`u`;_&&/Android/i.test(navigator.userAgent),_&&/iPad|iPhone|iPod/.test(navigator.userAgent),_&&/OpenHarmony|harmony/.test(navigator.userAgent),_&&/Android|iPad|iPhone|iPod|OpenHarmony|harmony|Mobile/.test(navigator.userAgent);var v=typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function fe(e,t){if(t.startsWith(`/`))return t.slice(1);let n=e.split(`/`),r=t.split(`/`);for(let e of r){let t=e;t===`..`?n.length>0&&n.pop():t!==`.`&&t!==``&&n.push(t)}return n.join(`/`)}function y(e,t){let n=e.split(`/`).slice(0,-1).join(`/`),r=t.split(`?`),i=r[0],a=r[1],o=fe(n,i);return a&&(o+=`?${a}`),o}function b(e){return typeof e==`number`&&Number.isFinite(e)&&!Number.isNaN(e)?`${e}px`:e}function pe(e){if(typeof e!=`object`||!e)return e;let t=new WeakMap;function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){if(t.has(e))return t.get(e);let r=[];return t.set(e,r),r.push(...e.map(n)),r}if(t.has(e))return t.get(e);let r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.assign(r,...Object.keys(e).map(t=>({[t]:n(e[t])})))}return n(e)}var x={},S=1,me=2;function he(e,t){x[e]||(x[e]={factory:t,status:S,exports:void 0})}function C(e,t,n){if(typeof e!=`string`)throw TypeError(`require args must be a string`);let r=x[e];if(!r)throw Error(`module ${e} not found`);if(r.status===S){r.status=me;let t={exports:{}},i;try{r.factory&&(i=r.factory.call(null,C,t,t.exports))}catch(t){r.status=S;let i=`
2
+ name: ${t.name}
3
+ msg: ${t.message}
4
+ stack:
5
+ ${t.stack}
6
+ `;console.error(`require ${e} error: ${i}`),h(n)&&n({mod:e,errMsg:t.message})}r.exports=t.exports===void 0?i:t.exports}return h(t)&&t(r.exports),r.exports}C.async=async e=>new Promise((t,n)=>{try{t(C(e))}catch(t){n(Error(`${t.message}: Failed to initialize asynchronous loading for module '${e}'`))}});var w=new class{constructor(){this.callbacks={}}store(e,t,n=le()){if(t){for(let[t,n]of Object.entries(this.callbacks))if(n.callback===e)return t}return this.callbacks[n]={callback:e,keep:t},n}invoke(e,t){if(e===void 0)return;let n=this.callbacks[e];n&&h(n.callback)&&(n.callback(t),n.keep||delete this.callbacks[e])}remove(e){e?Object.keys(this.callbacks).forEach(t=>{e===t&&delete this.callbacks[t]}):Object.entries(this.callbacks).forEach(([e,t])=>{t.keep&&delete this.callbacks[e]})}},T=new class{constructor(){this.reset()}reset(){this.active=!1,this.snapshot={systemInfo:null,menuRect:null}}init(e={}){this.active=!0,this.snapshot={...this.snapshot,...e}}update(e={}){this.snapshot={...this.snapshot,...e}}get(e){return this.active?this.snapshot[e]??null:null}getSystemInfo(){return this.get(`systemInfo`)}getMenuRect(){return this.get(`menuRect`)}};function ge(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}var E=new class e{constructor(){this.event=ge(),this.init()}init(){v?globalThis.onmessage=e=>{this.handleMsg(e.data)}:DiminaServiceBridge.onMessage=this.handleMsg.bind(this)}handleMsg(e){console.log(`[service] receive msg: `,v?e:JSON.stringify(e));let{type:t,body:n}=e;this.event.emit(t,n)}on(e,t){this.event.on(e,t)}off(e){this.event.off(e)}send(t){return v?e.prototype.send=function(e){e.method=`publish`,globalThis.postMessage(e)}:e.prototype.send=function(e){return DiminaServiceBridge.publish(e.body.bridgeId||``,e)},this.send(t)}invoke(t){return v?e.prototype.invoke=function(e){e.method=`invoke`,globalThis.postMessage(e)}:e.prototype.invoke=function(e){return DiminaServiceBridge.invoke(e)},this.invoke(t)}},D=new class{#e=[];#t=``;setInitId(e){this.#t=e}push(e,t){this.stack(t).push(e)}pop(){this.stack().length>0&&this.stack().pop()}getPageInfo(){return this.stack().at(-1)||{id:this.#t}}pushStack(e){let t={id:e,pages:[]};return this.#e.push(t),t}popStack(e){if(e){let t=this.#e.findIndex(t=>t.id===e);t!==-1&&this.#e.splice(t,1)}else this.#e.length>0&&this.#e.pop()}stack(e){if(e){let t=this.#e.find(t=>t.id===e);return t||=this.pushStack(e),t.pages}else{let e=this.#e.at(-1);return e?e.pages:this.pushStack(Date.now()).pages}}},_e={getWindowInfo:()=>T.getSystemInfo(),getSystemInfoSync:()=>T.getSystemInfo(),getAppBaseInfo:()=>T.getSystemInfo(),getDeviceInfo:()=>T.getSystemInfo(),getMenuButtonBoundingClientRect:()=>T.getMenuRect()};function O(e,t,n=`container`){let r=_e[e];if(n===`container`&&r){let e=r();if(e)return e}let i;if(t===void 0||typeof t==`string`||Array.isArray(t))i=t;else if(h(t))i={success:w.store(t,!0)};else{let{success:e,fail:n,complete:r,keep:a,evtId:o,...s}=t;i=s,h(e)?i.success=w.store(e,a,o):i.success=e,h(n)&&(i.fail=w.store(n,a,o)),h(r)&&(i.complete=w.store(r,a,o))}let a={type:`invokeAPI`,target:n,body:{name:e,bridgeId:D.getPageInfo().id,params:i}};return n===`container`?E.invoke(a):E.send(a)}var ve=t({navigateBack:()=>Ce,navigateTo:()=>Se,reLaunch:()=>be,redirectTo:()=>xe,switchTab:()=>ye});function ye(e){e.url=y(D.getPageInfo().route,e.url),O(`switchTab`,e)}function be(e){e.url=y(D.getPageInfo().route,e.url),O(`reLaunch`,e)}function xe(e){let t=y(D.getPageInfo().route,e.url);D.getPageInfo().route!==t&&(e.url=t,O(`redirectTo`,e))}function Se(e){e.url=y(D.getPageInfo().route,e.url),O(`navigateTo`,e)}function Ce(e){O(`navigateBack`,e)}var we=t({offAppHide:()=>Ae,offAppShow:()=>ke,offError:()=>Ee,onAppHide:()=>Oe,onAppRoute:()=>Ne,onAppShow:()=>De,onError:()=>Te,onPageNotFound:()=>Me,onUnhandledRejection:()=>je});function Te(e){O(`onError`,e)}function Ee(e){O(`offError`,e)}function De(e){O(`onAppShow`,e)}function Oe(e){O(`onAppHide`,e)}function ke(e){O(`offAppShow`,e)}function Ae(e){O(`offAppHide`,e)}function je(){}function Me(){}function Ne(){}var Pe=t({canIUse:()=>Le,env:()=>Fe});function Fe(){return{USER_DATA_PATH:`difile://`}}var Ie=new Set([`nextTick`,`getUpdateManager`,`getPerformance`]);function Le(e){if(Ie.has(e))return!0;try{return O(`canIUse`,e)}catch(t){return console.warn(`[canIUse] check ${e} error:`,t),!1}}var Re=t({getPerformance:()=>ze});function ze(){return Be.getInstance()}var Be=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one Performance instance.`);this.entryList=new Ve,e.#e=this}static getInstance(){return e.#e||=new e,e.#e}createObserver(e){let t=new He(e);return e&&O(`addPerformanceObserver`,{success:w.store(e=>{let n=e?.data?.entryList&&JSON.parse(e?.data?.entryList)||[];n&&(this.entryList.push(n),t.notify(n))},!0)},`render`),t}getEntries(){return this.entryList.getEntries()}getEntriesByName(e,t){return this.entryList.getEntriesByName(e,t)}getEntriesByType(e){return this.entryList.getEntriesByType(e)}setBufferSize(e){this.entryList.maxEntrySize=e}},Ve=class{constructor(){this._list=[],this.maxEntrySize=30}push(e){for(let t of e)this._list.length>=this.maxEntrySize&&this._list.shift(),this._list.push(t)}getEntriesByName(e,t){return this._entryFilter(e,t)}getEntriesByType(e){return this._entryFilter(null,e)}_entryFilter(e,t){return this._list.filter(n=>!(e&&e!==n.name||t&&t!==n.entryType))}getEntries(){return this._list}},He=class{constructor(e){this.entryTypes=[],this.callback=e}observe(e){this.connected=!0,this.entryTypes=e.entryTypes}notify(e){if(this.connected){let t=new Ve;t.push(e.filter(e=>{let t=!1;return this.entryTypes&&this.entryTypes.length>0&&this.entryTypes.forEach(n=>{e.entryType===n&&(t=!0)}),t})),this.callback(t)}}disconnect(){this.connected=!1}},Ue=t({loadSubpackage:()=>Ge,preDownloadSubpackage:()=>We});function We(e){O(`preDownloadSubpackage`,e)}function Ge(e){O(`loadSubpackage`,e)}var Ke=t({getAppBaseInfo:()=>$e,getDeviceInfo:()=>et,getSystemInfo:()=>Xe,getSystemInfoAsync:()=>Qe,getSystemInfoSync:()=>Ze,getWindowInfo:()=>Je,openAppAuthorizeSetting:()=>Ye,openSystemBluetoothSetting:()=>qe});function qe(e){O(`openSystemBluetoothSetting`,e)}function Je(e){return O(`getWindowInfo`,e)}function Ye(e){O(`openAppAuthorizeSetting`,e)}function Xe(e){return new Promise(t=>{t(O(`getSystemInfo`,e))})}function Ze(){return O(`getSystemInfoSync`)}function Qe(e){O(`getSystemInfoAsync`,e)}function $e(){return O(`getAppBaseInfo`)}function et(){return O(`getDeviceInfo`)}var tt=t({getUpdateManager:()=>nt});function nt(){return rt.getInstance()}var rt=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one UpdateManager instance.`);this.hasApplyUpdate=!1,this.updateFailFlag=null,this.updateFailCbQueue=[],this.updateReadyCbQueue=[],this.updateReadyStatus=null,this.updateReadyFlag=!1,this.updateStatus=null,this.updateStatusCbQueue=[],E.on(`onUpdateStatusChange`,e=>{let{event:t,strategy:n}=e;t===`updatefail`?(this.updateFailFlag={},this.flashUpdateFailCb()):t===`updateready`?(this.updateReadyFlag=!0,this.updateReadyStatus={strategy:n},this.flushUpdateReadyCb()):t===`noupdate`?(this.updateStatus={hasUpdate:!0},this.flushUpdateStatusCb()):t===`updating`&&(this.updateStatus={hasUpdate:!1},this.flushUpdateStatusCb())}),e.#e=this}flashUpdateFailCb(){this.updateFailCbQueue.forEach(e=>{typeof e==`function`&&e()}),this.updateFailCbQueue.length=0}flushUpdateStatusCb(){this.updateStatusCbQueue.forEach(e=>{typeof e==`function`&&e(this.updateStatus)}),this.updateStatusCbQueue.length=0}flushUpdateReadyCb(){this.updateReadyCbQueue.forEach(e=>{typeof e==`function`&&e(this.updateReadyStatus)}),this.updateReadyCbQueue.length=0}static getInstance(){return e.#e||=new e,e.#e}applyUpdate(){this.updateReadyFlag&&this.hasApplyUpdate?console.error(`[applyUpdate]: applyUpdate has been called`):this.updateReadyFlag?O(`applyUpdate`):console.error(`[applyUpdate]: update is not ready`)}onCheckForUpdate(e){this.updateStatus?typeof e==`function`&&e(this.updateStatus):this.updateStatusCbQueue.push(e)}onUpdateFailed(e){this.updateFailFlag?typeof e==`function`&&e(this.updateFailFlag):this.updateFailCbQueue.push(e)}onUpdateReady(e){this.updateReadyFlag?typeof e==`function`&&e(this.updateReadyStatus):this.updateReadyCbQueue.push(e)}},it=t({createCameraContext:()=>at});function at(){return new ot}var ot=class{constructor(){this.bridgeId=D.getPageInfo().id}takePhoto(e){O(`takePhoto`,e)}startRecord(){O(`startRecord`)}stopRecord(){O(`stopRecord`)}},st=t({reportAnalytics:()=>ct,reportEvent:()=>lt});function ct(...e){O(`reportAnalytics`,e)}function lt(e,t){O(`reportAnalytics`,{eventId:e,data:t})}var ut=t({closeBluetoothAdapter:()=>xt,getBluetoothAdapterState:()=>bt,getBluetoothDevices:()=>yt,getConnectedBluetoothDevices:()=>vt,offBluetoothAdapterStateChange:()=>_t,offBluetoothDeviceFound:()=>gt,onBluetoothAdapterStateChange:()=>ht,onBluetoothDeviceFound:()=>mt,openBluetoothAdapter:()=>pt,startBluetoothDevicesDiscovery:()=>ft,stopBluetoothDevicesDiscovery:()=>dt});function dt(e){O(`stopBluetoothDevicesDiscovery`,e)}function ft(e){O(`startBluetoothDevicesDiscovery`,e)}function pt(e){O(`openBluetoothAdapter`,e)}function mt(e){O(`onBluetoothDeviceFound`,e)}function ht(e){O(`onBluetoothAdapterStateChange`,e)}function gt(){O(`offBluetoothDeviceFound`)}function _t(){O(`offBluetoothAdapterStateChange`)}function vt(e){O(`getConnectedBluetoothDevices`,e)}function yt(e){O(`getBluetoothDevices`,e)}function bt(e){O(`getBluetoothAdapterState`,e)}function xt(e){O(`closeBluetoothAdapter`,e)}var St=t({closeBLEConnection:()=>Ft,createBLEConnection:()=>Pt,getBLEDeviceCharacteristics:()=>Nt,getBLEDeviceRSSI:()=>Mt,getBLEDeviceServices:()=>jt,notifyBLECharacteristicValueChange:()=>At,offBLECharacteristicValueChange:()=>kt,offBLEConnectionStateChange:()=>Ot,onBLECharacteristicValueChange:()=>Dt,onBLEConnectionStateChange:()=>Et,readBLECharacteristicValue:()=>Tt,setBLEMTU:()=>wt,writeBLECharacteristicValue:()=>Ct});function Ct(e){O(`writeBLECharacteristicValue`,e)}function wt(e){O(`setBLEMTU`,e)}function Tt(e){O(`readBLECharacteristicValue`,e)}function Et(e){O(`onBLEConnectionStateChange`,e)}function Dt(e){O(`onBLECharacteristicValueChange`,e)}function Ot(e){O(`offBLEConnectionStateChange`,e)}function kt(){O(`offBLECharacteristicValueChange`)}function At(e){O(`notifyBLECharacteristicValueChange`,e)}function jt(e){O(`getBLEDeviceServices`,e)}function Mt(e){O(`getBLEDeviceRSSI`,e)}function Nt(e){O(`getBLEDeviceCharacteristics`,e)}function Pt(e){O(`createBLEConnection`,e)}function Ft(e){O(`closeBLEConnection`,e)}var It=t({getClipboardData:()=>Rt,setClipboardData:()=>Lt});function Lt(e){O(`setClipboardData`,e)}function Rt(e){O(`getClipboardData`,e)}var zt=t({addPhoneContact:()=>Vt,chooseContact:()=>Bt});function Bt(e){O(`chooseContact`,e)}function Vt(e){O(`addPhoneContact`,e)}var Ht=t({hideKeyboard:()=>Ut});function Ut(e){O(`hideKeyboard`,e)}var Wt=t({offMemoryWarning:()=>Kt,onMemoryWarning:()=>Gt});function Gt(e){O(`onMemoryWarning`,e)}function Kt(e){O(`offMemoryWarning`,e)}var qt=t({getNetworkType:()=>Jt});function Jt(e){O(`getNetworkType`,e)}var Yt=t({makePhoneCall:()=>Xt});function Xt(e){O(`makePhoneCall`,e)}var Zt=t({scanCode:()=>Qt});function Qt(e){O(`scanCode`,e)}var $t=t({vibrateLong:()=>tn,vibrateShort:()=>en});function en(e){O(`vibrateShort`,e)}function tn(e){O(`vibrateLong`,e)}var nn=t({extBridge:()=>rn,extOffBridge:()=>on,extOnBridge:()=>an,offLoginStatusChanged:()=>cn,onLoginStatusChanged:()=>sn});function rn({event:e,module:t,data:n={},success:r,fail:i,complete:a},o){let s,c,l;h(o)?(s=o,c=o):(s=r,c=i,l=a),O(e,{module:t,data:n,keep:n.isSustain??!0,success:s,fail:c,complete:l})}function an({event:e,module:t,callBack:n,isSustain:r=!0}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOnBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOnBridge 参数 event 为空`);return}if(!n){console.error(`[ERROR]: extOnBridge 参数 callBack 为空`);return}let i=`${t}_${e}`;O(i,{evtId:i,keep:r,success:n})}function on({event:e,module:t,callBack:n}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOffBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOffBridge 参数 event 为空`);return}O(`${t}_${e}`,{success:n})}function sn(e){E.on(`notifyLoginStatusChanged`,t=>{e?.(t)})}function cn(){E.off(`notifyLoginStatusChanged`)}var ln=t({USER_DATA_PATH:()=>un,getFileSystemManager:()=>gn}),un=`difile://`,k=`not supported in simulator`,dn=class{constructor(e){this.size=e.size||0,this.mode=e.mode||438,this.lastAccessedTime=e.lastAccessedTime||0,this.lastModifiedTime=e.lastModifiedTime||0,this._isFile=e.isFile===void 0?!0:e.isFile,this._isDirectory=e.isDirectory===void 0?!1:e.isDirectory}isFile(){return this._isFile}isDirectory(){return this._isDirectory}};function A(e){throw Error(`FileSystemManager.${e} ${k}`)}function j(e,t={}){let{fail:n,complete:r}=t;n?.({errMsg:`${e}:fail ${k}`}),r?.()}function fn(e){return e&&new dn(e)}function pn(e){if(!e||typeof e!=`object`)return e;let t={};for(let[n,r]of Object.entries(e))t[n]=new dn(r);return t}var mn=class{access(e){O(`fsAccess`,e)}accessSync(){A(`accessSync`)}stat(e={}){let{success:t,recursive:n,...r}=e;O(`fsStat`,{...r,recursive:n,success:e=>{if(!t)return;let r=n?pn(e?.stats):fn(e?.stats);t({...e,stats:r})}})}statSync(){A(`statSync`)}readFile(e){O(`fsReadFile`,e)}readFileSync(){A(`readFileSync`)}writeFile(e){O(`fsWriteFile`,e)}writeFileSync(){A(`writeFileSync`)}appendFile(e){O(`fsAppendFile`,e)}appendFileSync(){A(`appendFileSync`)}copyFile(e){O(`fsCopyFile`,e)}copyFileSync(){A(`copyFileSync`)}rename(e){O(`fsRename`,e)}renameSync(){A(`renameSync`)}unlink(e){O(`fsUnlink`,e)}unlinkSync(){A(`unlinkSync`)}mkdir(e){O(`fsMkdir`,e)}mkdirSync(){A(`mkdirSync`)}rmdir(e){O(`fsRmdir`,e)}rmdirSync(){A(`rmdirSync`)}readdir(e){O(`fsReaddir`,e)}readdirSync(){A(`readdirSync`)}getFileInfo(e){O(`fsGetFileInfo`,e)}saveFile(e){O(`fsSaveFile`,e)}saveFileSync(){A(`saveFileSync`)}getSavedFileList(e){O(`fsGetSavedFileList`,e)}removeSavedFile(e){O(`fsRemoveSavedFile`,e)}truncate(e){O(`fsTruncate`,e)}truncateSync(){A(`truncateSync`)}unzip(e){O(`fsUnzip`,e)}open(e){j(`open`,e)}openSync(){A(`openSync`)}close(e){j(`close`,e)}closeSync(){A(`closeSync`)}read(e){j(`read`,e)}readSync(){A(`readSync`)}write(e){j(`write`,e)}writeSync(){A(`writeSync`)}fstat(e){j(`fstat`,e)}fstatSync(){A(`fstatSync`)}ftruncate(e){j(`ftruncate`,e)}ftruncateSync(){A(`ftruncateSync`)}readCompressedFile(e){j(`readCompressedFile`,e)}readCompressedFileSync(){A(`readCompressedFileSync`)}readZipEntry(e){j(`readZipEntry`,e)}},hn;function gn(){return hn||=new mn,hn}var _n=[`onLaunch`,`onShow`,`onHide`],vn=[`globalData`],yn=class{constructor(e,t){this.appModule=e,this.options=t,this.init()}init(){this.initGlobalData(),this.initLifecycle(),this.initCustomMethods(),this.invokeSomeLifecycle()}initGlobalData(){this.globalData=this.appModule.moduleInfo.globalData}initLifecycle(){_n.forEach(e=>{let t=this.appModule.moduleInfo[e];h(t)&&(this[e]=t.bind(this))})}initCustomMethods(){let e=this.appModule.moduleInfo;for(let t in e)_n.includes(t)||vn.includes(t)||(h(e[t])?this[t]=e[t].bind(this):this[t]=e[t])}invokeSomeLifecycle(){this.onLaunch?.(this.options),this.onShow?.(this.options)}appShow(){this.onShow?.(this.options)}appHide(){this.onHide?.()}},bn=t({createSelectorQuery:()=>M});function M(){return new xn}var xn=class{constructor(){this.__componentId=D.getPageInfo().id,this.__taskQueue=[],this.__cbQueue=[]}in(e){return this.__componentId=e.__id__,this}select(e){return new N(this,this.__componentId,e,!0)}selectAll(e){return new N(this,this.__componentId,e,!1)}selectViewport(){return new N(this,D.getPageInfo().id,``,!0)}__push(e,t,n,r,i){this.__taskQueue.push({moduleId:t,selector:e,single:n,fields:r}),this.__cbQueue.push(i)}exec(e){let t=this;O(`selectorQuery`,{tasks:this.__taskQueue,success:n=>{n.forEach((e,n)=>{let r=t.__cbQueue[n];h(r)&&r.call(t,e)}),h(e)&&e.call(t,n)}},`render`)}},N=class{constructor(e,t,n,r){this.__selectorQuery=e,this.__moduleId=t,this.__selector=n,this.__single=r}fields(e,t){return this.__selectorQuery.__push(this.__selector,this.__moduleId,this.__single,e,t),this.__selectorQuery}boundingClientRect(e){return this.fields({id:!0,dataset:!0,rect:!0,size:!0},e)}context(e){return this.fields({context:!0},e)}node(e){return this.fields({node:!0},e)}scrollOffset(e){return this.fields({id:!0,dataset:!0,scrollOffset:!0},e)}},Sn=t({createIntersectionObserver:()=>Cn});function Cn(e,t={}){let{thresholds:n=[0],initialRatio:r=0,observeAll:i=!1}=t;return new wn(e,{thresholds:n,initialRatio:r,observeAll:i})}var wn=class{constructor(e,t){this._component=e,this._options=t,this._relativeInfo=[],this._observerId=null,this._disconnected=!1}relativeTo(e,t={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:e,margins:[`left`,`right`,`top`,`bottom`].map(e=>`${t[e]===void 0?0:t[e]}px`).join(` `)}),this}relativeToViewport(e={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:null,margins:[`left`,`right`,`top`,`bottom`].map(t=>`${e[t]===void 0?0:e[t]}px`).join(` `)}),this}observe(e,t){let n=this,r=w.store(e=>{n._disconnected||(n._observerId=e.observerId),e.info&&t.call(n,e.info)},!0);O(`addIntersectionObserver`,{moduleId:this._component.__id__,targetSelector:e,relativeInfo:this._relativeInfo,options:this._options,success:r},`render`)}disconnect(){O(`removeIntersectionObserver`,{observerId:this._observerId},`render`),this._disconnected=!0}},P=new Map;function F(e){return P.has(e)||P.set(e,{depth:0,scheduled:!1,updates:[],byModuleId:new Map,callbackIds:[]}),P.get(e)}function I(e,t){let n=(Array.isArray(t)?t:[t]).filter(h);if(n.length!==0)return w.store(()=>{n.forEach(t=>t.call(e))})}function Tn(e){let t=F(e);t.depth++}function En(e){let t=F(e);t.depth>0&&t.depth--,t.depth===0&&R(e)}function L(e,t,n,r){let i=F(e),a=i.byModuleId.get(t);if(a)Object.assign(a.data,n);else{let e={moduleId:t,data:{...n}};i.byModuleId.set(t,e),i.updates.push(e)}r&&i.callbackIds.push(r),i.depth===0&&!i.scheduled&&(i.scheduled=!0,Promise.resolve().then(()=>{i.scheduled=!1,i.depth===0&&R(e)}))}function R(e){let t=P.get(e);if(!t||t.updates.length===0)return;let n=t.updates,r=t.callbackIds;t.updates=[],t.byModuleId=new Map,t.callbackIds=[],t.scheduled=!1,E.send({type:`ub`,target:`render`,body:{bridgeId:e,updates:n,callbackIds:r}})}function Dn(e){let t=e.__mpxProxy?.options?.computed;if(t)for(let n of Object.keys(t))Object.hasOwn(e.data,n)||(e.data[n]=null)}function z(e){return oe(e)?e:Object.entries(e).reduce((e,[t,n])=>t.startsWith(`$`)?e:h(n)?(console.warn(`[service] 值不支持函数引用`,t),e):(Array.isArray(n)?e[t]=n.map(e=>typeof e==`object`&&e?e instanceof Date?e.getTime():z(e):e):n&&typeof n==`object`&&!Array.isArray(n)?n instanceof Date?e[t]=n.getTime():e[t]=z(n):e[t]=n,e),{})}function On(e){if(e){let t={};for(let n in e){let r=e[n];t[n]=t[n]||{};let i=B(r&&typeof r==`object`&&Object.hasOwn(r,`type`)?r.type:r),a=null;if(a=Array.isArray(i)?[...i]:[i],r&&r.optionalTypes){let e=B(r.optionalTypes);Array.isArray(e)?a=[...e]:a.push(e)}t[n].type=a,t[n].type.length>0&&(r&&h(r.value)?t[n].default=r.value():r&&(t[n].default=r.value))}return t}}var kn=new Map([[String,`s`],[Number,`n`],[Boolean,`b`],[Object,`o`],[Array,`a`],[Function,`f`]]);function B(e){return Array.isArray(e)?e.map(e=>B(e)):e===null||e===``?null:kn.get(e)||(console.warn(`[service] ignore unknown props type ${e}`),null)}function An(e,t,n,r,i){let a=new Set;for(let o of e)for(let e in t){if(a.has(e))continue;let s=e.split(`,`).map(e=>e.trim());if(s.includes(o)){a.add(e);let c=t[e],l=s.map(e=>g(n,e));s.length===1?c.call(r,...l,i[o]):c.call(r,...l);continue}if(e===`**`){a.add(e),t[e].call(r,n);continue}let c=e.split(`.`),l=o.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u&&c.length>1){a.add(e);let s=n;for(let e of c)e!==`**`&&(s=s?.[e]);e===o?t[e].call(r,s,i[o]):t[e].call(r,s)}}}function jn(e,t,n,r,i){for(let a in t){let o=t[a],s=a.split(`,`).map(e=>e.trim());if(s.includes(e)){let t=s.map(e=>g(n,e));s.length===1&&s[0]===e?o.call(r,...t,i):o.call(r,...t);continue}if(a===`**`){o.call(r,n);continue}let c=a.split(`.`),l=e.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u){let t=n;for(let e of c)e!==`**`&&(t=t[e]);a===e?o.call(r,t,i):o.call(r,t);continue}let d=a.match(/^(.+)\[(\d+)\]$/);if(d){let t=d[1],i=Number.parseInt(d[2],10);if(t===e.split(`[`)[0]&&n[t]&&n[t][i]!==void 0){o.call(r,n[t][i]);continue}}if(e.startsWith(a)){let e=a.split(`.`).reduce((e,t)=>e&&e[t],n);if(e!==void 0){o.call(r,e);continue}}}}function Mn(e={},t=``){let n=t.trim();if(!n)return;let r=n.replace(/-/g,``).toLowerCase(),i=[n,ue(n),de(n),r];for(let t of i)if(t&&e[t]!==void 0)return e[t]}function V(e,t,n){let r=e.__info__||{};if(r.behaviorObservers)for(let i in r.behaviorObservers){let a=r.behaviorObservers[i];if(!(!Array.isArray(a)||a.length===0))for(let r of t)a.forEach(t=>{jn(r,{[i]:t},e.data,e,n[r])})}}function Nn(e,t,n){Fn(e,t,n)}function Pn(e,t,n){let r=[];for(let i of t){let t=e.__info__.properties?.[i]?.observer,a=e.data[i],o=n[i];ae(t)?r.push(()=>e[t]?.(a,o)):h(t)&&r.push(()=>t.call(e,a,o))}return r}function Fn(e,t,n){Pn(e,t,n).reverse().forEach(e=>e())}function In(e,t){if(!Array.isArray(t))return;let n=new WeakMap;function r(e,t){let n={...e};for(let e in t)if(Object.hasOwn(t,e)){let i=n[e],a=t[e];i&&typeof i==`object`&&!Array.isArray(i)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=r(i,a):n[e]=a}return n}function i(e,t){if(typeof t==`string`){a(e,t);return}if(!t||typeof t!=`object`||n.has(t))return;n.set(t,!0),Array.isArray(t.behaviors)&&t.behaviors.forEach(t=>i(e,t)),t.properties&&(e.properties={...t.properties,...e.properties}),t.data&&(e.data||={},e.data=r(t.data,e.data));let o=[`created`,`attached`,`ready`,`detached`];e.behaviorLifetimes=e.behaviorLifetimes||{};for(let n of o)h(t[n])&&(e.behaviorLifetimes[n]=e.behaviorLifetimes[n]||[],e.behaviorLifetimes[n].push(t[n]));if(t.observers){e.behaviorObservers=e.behaviorObservers||{};for(let n in t.observers)e.behaviorObservers[n]||(e.behaviorObservers[n]=[]),e.behaviorObservers[n].push(t.observers[n])}if(t.methods&&(e.methods={...t.methods,...e.methods}),t.relations&&(e.relations={...e.relations,...t.relations}),t.export&&(e.export=t.export),t.pageLifetimes){e.behaviorPageLifetimes=e.behaviorPageLifetimes||{};for(let n of[`show`,`hide`,`resize`,`routeDone`])h(t.pageLifetimes[n])&&(e.behaviorPageLifetimes[n]=e.behaviorPageLifetimes[n]||[],e.behaviorPageLifetimes[n].push(t.pageLifetimes[n]))}}function a(e,t){switch(t){case`wx://component-export`:break;case`wx://form-field`:break;case`wx://form-field-button`:break;default:console.warn(`[service] 未知的内置 behavior: ${t}`)}}t.forEach(t=>i(e,t))}function H(e,t,n){let r=e;for(;r&&r.__parentId__;){if(r.__parentId__===t)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}function U(e,t){if(!e||!t)return!1;if(e.startsWith(`#`)){let n=e.slice(1);return t.id===n}if(e.startsWith(`.`)){let n=e.slice(1);return t.__targetInfo__?.class&&t.__targetInfo__.class.split(` `).includes(n)}if(e.startsWith(`[`)&&e.endsWith(`]`)){let n=e.slice(1,-1).match(/^(\w+)(?:=["']?([^"']*)["']?)?$/);if(n){let[,e,r]=n,i=t.__targetInfo__?.dataset||{};return r===void 0?Object.hasOwn(i,e):i[e]===r}return!1}return t.is?t.is.split(`/`).pop()===e||t.is===e:!1}function Ln(e,t){if(!e||!Array.isArray(e.dependencies))return!1;for(let n of e.dependencies){if(n in t)return!0;for(let e of Object.keys(t))if(e.startsWith(n+`.`)||e.startsWith(n+`[`)||n.startsWith(e+`.`)||n.startsWith(e+`[`))return!0}return!1}function Rn(e,t){if(!(!e||!e.expression)){if(e.isSimple)return g(t,e.expression);try{return Function(`data`,`with(data) { return ${e.expression} }`)(t)}catch(t){console.warn(`[service] 计算表达式失败:`,e.expression,t);return}}}function W(e,t,n){let r=Object.values(t||{}),i=[];for(let t of r){if(!H(t,e.__id__,r)||t.__parentId__!==e.__id__)continue;let a=t.__info__?.properties||{},o={};for(let r in a){let i=e.__childPropsBindings__?.[t.__id__]?.[r];i&&Ln(i,n)&&(o[r]=Rn(i,e.data))}Object.keys(o).length>0&&(t.tO?.(o),t.__pendingSyncedProps__=t.__pendingSyncedProps__||{},Object.assign(t.__pendingSyncedProps__,o),i.push({child:t,data:o}))}return i}var zn=[`created`,`attached`,`ready`,`moved`,`detached`,`error`],Bn=[`show`,`hide`,`resize`,`routeDone`],Vn=class{constructor(e,t){this.initd=!1,this.opts=t,t.targetInfo&&(this.id=t.targetInfo.id,this.dataset=t.targetInfo.dataset,this.__targetInfo__=t.targetInfo),this.is=t.path,this.route=t.path,this.query=t.query,this.renderer=`webview`,this.bridgeId=t.bridgeId,this.id||=t.bridgeId,this.behaviors=e.behaviors,this.data=pe(e.noReferenceData),Object.defineProperty(this,`properties`,{get(){return this.data},enumerable:!0,configurable:!1}),this.__isComponent__=e.isComponent,this.__type__=e.type,this.__id__=this.opts.moduleId,this.__info__=e.moduleInfo,this.__eventAttr__=t.eventAttr,this.__pageId__=t.pageId,this.__parentId__=t.parentId,this.__relations__=new Map,this.__relationPaths__=new Map,this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[],this.__pendingInitSetDataCallbacks__=[],this.__childPropsBindings__={},this.__pendingSyncedProps__={},this.__initialPropertyObserversInvoked__=!1}init(){if(this.__isComponent__)for(let e in this.__info__.properties)!Object.hasOwn(this.opts.properties,e)||this.opts.properties[e]===void 0?this.data[e]=this.__info__.properties[e]?.value??null:this.data[e]=this.opts.properties[e];return this.#d(),this.#f(),this.#t(),this.#e(),this.#m().then(()=>{Dn(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],L(this.bridgeId,this.__id__,{},I(this,e))}#e(){this.hasBehavior(`wx://component-export`)&&this.__info__.export&&h(this.__info__.export)&&(this.export=this.__info__.export.bind(this))}#t(){let e=this.__info__.relations;if(!(!e||typeof e!=`object`))for(let[t]of Object.entries(e)){let e=this.#n(t);this.__relationPaths__.set(t,e),this.__relations__.has(t)||this.__relations__.set(t,[])}}#n(e){if(e.startsWith(`./`)){let t=this.is.lastIndexOf(`/`);return t===-1?e.substring(2):`${this.is.substring(0,t)}/${e.substring(2)}`}else if(e.startsWith(`../`)){let t=this.is.split(`/`),n=e.split(`/`),r=t.slice(0,-1);for(let e of n)e===`..`?r.pop():e!==`.`&&r.push(e);return r.join(`/`)}else return e}#r(){let e=this.__info__.relations;if(!e)return;let t=Object.values(Y.instances[this.bridgeId]||{});for(let[n,r]of Object.entries(e)){let{type:e,target:i}=r,a=this.__relationPaths__.get(n),o=t.filter(e=>i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`)).filter(t=>this.#o(t,e)||this.#a(t,e));for(let e of o)this.#c(n,e,r)}this.#i()}#i(){let e=Object.values(Y.instances[this.bridgeId]||{});for(let t of e)t!==this&&t._checkRelationsWithTarget&&t._checkRelationsWithTarget(this)}_checkRelationsWithTarget(e){let t=this.__info__.relations;if(t)for(let[n,r]of Object.entries(t)){let{type:t,target:i}=r,a=this.__relationPaths__.get(n),o=!1;o=i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`);let s=this.#o(e,t),c=this.#a(e,t);o&&(s||c)&&this.#c(n,e,r)}}#a(e,t){if(t!==`descendant`&&t!==`ancestor`)return!1;let n=t===`descendant`?`ancestor`:`descendant`,r=e.__info__?.relations;return r?Object.entries(r).some(([t,r])=>{let i=e.__relationPaths__?.get(t);return r.type===n&&(this.is===i||this.is.endsWith(`/${i}`))}):!1}#o(e,t){let n=Object.values(Y.instances[this.bridgeId]||{});switch(t){case`parent`:return e.__id__===this.__parentId__;case`child`:return e.__parentId__===this.__id__;case`ancestor`:return this.#s(e.__id__,this.__id__,n);case`descendant`:return this.#s(this.__id__,e.__id__,n);default:return!1}}#s(e,t,n){let r=n.find(e=>e.__id__===t);for(;r&&r.__parentId__;){if(r.__parentId__===e)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}#c(e,t,n){let r=this.__relations__.get(e)||[];if(!r.includes(t)&&(r.push(t),this.__relations__.set(e,r),h(n.linked)))try{n.linked.call(this,t)}catch(e){console.error(`[service] relation linked error:`,e)}}#l(e,t,n){let r=this.__relations__.get(e)||[],i=r.indexOf(t);if(i!==-1&&(r.splice(i,1),this.__relations__.set(e,r),h(n.unlinked)))try{n.unlinked.call(this,t)}catch(e){console.error(`[service] relation unlinked error:`,e)}}#u(e,t,n){if(h(n.linkChanged))try{n.linkChanged.call(this,t)}catch(e){console.error(`[service] relation linkChanged error:`,e)}}setData(e,t){let n=z(e),r={};for(let e in n)r[e]=this.data[e],ce(this.data,e,n[e]);if(this.__info__.observers&&An(Object.keys(n),this.__info__.observers,this.data,this,r),V(this,Object.keys(n),r),Nn(this,Object.keys(n),r),!this.initd){h(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}if(this.__groupSetDataMode__){for(let e in n)this.__groupSetDataBuffer__[e]=n[e];h(t)&&this.__groupSetDataCallbacks__.push(t);return}let i=W(this,Y.instances[this.bridgeId],n);L(this.bridgeId,this.__id__,n,I(this,t)),i.forEach(({child:e,data:t})=>{L(this.bridgeId,e.__id__,t)})}#d(){zn.forEach(e=>{let t=this.__info__.lifetimes?.[e]||this.__info__[e];h(t)&&(this[e]=t.bind(this))}),this.__isComponent__&&Bn.forEach(e=>{let t=this.__info__.pageLifetimes?.[e];h(t)&&(e===`show`?e=`onShow`:e===`hide`&&(e=`onHide`),this[e]=t.bind(this))})}#f(){let e=this.__info__.methods;for(let t in e)h(e[t])&&(this[t]=e[t].bind(this))}#p(){if(!this.__isComponent__||!this.__info__.properties||this.__initialPropertyObserversInvoked__)return;let e=[];for(let t of Object.keys(this.__info__.properties)){let n=this.__info__.properties[t]?.observer,r=this.data[t];ae(n)?e.push(()=>this[n]?.(r,void 0)):h(n)&&e.push(()=>n.call(this,r,void 0))}e.forEach(e=>e()),this.__initialPropertyObserversInvoked__=!0}async#m(){this.__isComponent__?(await this.componentCreated(),await this.componentAttached()):(await this.componentCreated(),await this.componentAttached(),await this.onLoad?.(this.opts.query||{})),this.initd=!0}tO(e){let t={};for(let[n,r]of Object.entries(e)){if(this.__pendingSyncedProps__&&Object.hasOwn(this.__pendingSyncedProps__,n)&&se(this.__pendingSyncedProps__[n],r)){this.data[n]=r,delete this.__pendingSyncedProps__[n];continue}t[n]=r}if(Object.keys(t).length===0)return;let n=[],r={};for(let[e,i]of Object.entries(t)){let t=this.data[e];r[e]=t,this.data[e]=i,this.__info__.observers&&n.push(()=>jn(e,this.__info__.observers,this.data,this,t))}n.forEach(e=>e()),V(this,Object.keys(t),Object.fromEntries(Object.keys(t).map(e=>[e,void 0]))),Fn(this,Object.keys(t),r)}getPageId(){return this.__id__}hasBehavior(e){let t=function(n){if(!Array.isArray(n))return!1;if(n.includes(e))return!0;for(let e of n)if(e&&e.behaviors&&t(e.behaviors))return!0;return!1};return t(this.behaviors)}createSelectorQuery(){return M().in(this)}selectComponent(e){let t=Object.values(Y.instances[this.bridgeId]),n=t.find(n=>H(n,this.__id__,t)&&U(e,n));return n?n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values(Y.instances[this.bridgeId]);return t.filter(n=>H(n,this.__id__,t)&&U(e,n))}selectOwnerComponent(){let e=Object.values(Y.instances[this.bridgeId]);for(let t of e)if(t.id===this.__parentId__)return t;return null}createIntersectionObserver(e){return Cn(this,e)}groupSetData(e){if(!h(e)){console.warn(`[service] groupSetData callback must be a function`);return}this.__groupSetDataMode__=!0,Tn(this.bridgeId),this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];try{e.call(this)}catch(e){console.error(`[service] groupSetData callback error:`,e)}finally{if(this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__&&Object.keys(this.__groupSetDataBuffer__).length>0){let e=this.__groupSetDataBuffer__,t=this.__groupSetDataCallbacks__;this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];let n=W(this,Y.instances[this.bridgeId],e);L(this.bridgeId,this.__id__,e,I(this,t)),n.forEach(({child:e,data:t})=>{L(this.bridgeId,e.__id__,t)})}else this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];En(this.bridgeId)}}createMediaQueryObserver(){console.warn(`[service] 暂不支持 createMediaQueryObserver`)}getRelationNodes(e){return e?[...this.__relations__.get(e)||[]]:(console.warn(`[service] getRelationNodes 需要传入关系路径参数`),[])}animate(){console.warn(`[service] 暂不支持 animate`)}clearAnimation(){console.warn(`[service] 暂不支持 clearAnimation`)}async triggerEvent(e,t,n={}){if(!e)return;let r=e.trim(),i=Mn(this.__eventAttr__,r);i&&await Y.triggerEvent({bridgeId:this.bridgeId,moduleId:this.__pageId__,methodName:i,event:{type:r,detail:t,currentTarget:{id:this.id,dataset:this.dataset},target:{id:this.id,dataset:this.dataset}}}),n.bubbles&&await Y.instances[this.bridgeId][this.__parentId__]?.triggerEvent(e,t),n.composed,n.capturePhase}pageReady(){this.__isComponent__||this.ready?.()}pageUnload(){this.__isComponent__||this.onUnload?.()}pageScrollTop(e){if(!this.__isComponent__){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.resize?.(e)}componentRouteDone(){this.__info__.behaviorPageLifetimes?.routeDone?.forEach(e=>e.call(this)),this.routeDone?.()}async componentCreated(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.()}async componentAttached(){this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),this.#r()}componentReadied(){this.#p(),this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.()}componentMoved(){this.moved?.();let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=this.__relations__.get(t)||[];for(let r of e)this.#u(t,r,n)}}componentDetached(){let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=[...this.__relations__.get(t)||[]];for(let r of e)this.#l(t,r,n)}this.#h(),this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.initd=!1}#h(){let e=Object.values(Y.instances[this.bridgeId]||{});for(let t of e)if(!(t===this||!t.__relations__))for(let[e,n]of t.__relations__.entries()){let r=n.indexOf(this);if(r!==-1){n.splice(r,1),t.__relations__.set(e,n);let i=t.__info__.relations?.[e];if(i&&h(i.unlinked))try{i.unlinked.call(t,this)}catch(e){console.error(`[service] relation unlinked error:`,e)}}}}componentError(e){this.error?.(e)}},G=class e{static type=`component`;constructor(t,n){this.moduleInfo=t,this.extraInfo=n,this.type=e.type,this.isComponent=this.extraInfo.component,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,In(this.moduleInfo,this.behaviors),this.noReferenceData=z(this.moduleInfo.data||{})}getProps(){let e=On(this.moduleInfo.properties);if(Array.isArray(this.moduleInfo.externalClasses)&&this.moduleInfo.externalClasses.length>0){e||={};for(let t of this.moduleInfo.externalClasses)e[t]={type:[`s`],cls:!0}}return e}},Hn=class{constructor(e,t){this.initd=!1,this.opts=t,this.is=t.path,this.route=t.path,this.bridgeId=t.bridgeId,this.id=t.bridgeId,this.query=t.query,this.data=pe(e.noReferenceData),this.__type__=e.type,this.__id__=t.moduleId,this.__info__=e.moduleInfo,this.__childPropsBindings__={},this.__pendingInitSetDataCallbacks__=[]}init(){return this.#e(),this.#t().then(()=>{Dn(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],L(this.bridgeId,this.__id__,{},I(this,e))}setData(e,t){let n=z(e),r={},i=this.__info__||{};for(let e in n)r[e]=this.data[e],ce(this.data,e,n[e]);if(i.observers&&An(Object.keys(n),i.observers,this.data,this,r),V(this,Object.keys(n),r),!this.initd){h(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}let a=W(this,Y.instances[this.bridgeId],n);L(this.bridgeId,this.__id__,n,I(this,t)),a.forEach(({child:e,data:t})=>{L(this.bridgeId,e.__id__,t)})}createSelectorQuery(){return M().in(this)}selectComponent(e){let t=Object.values(Y.instances[this.bridgeId]||{}),n=t.find(n=>H(n,this.__id__,t)&&U(e,n));return n?n.hasBehavior&&n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values(Y.instances[this.bridgeId]||{});return t.filter(n=>H(n,this.__id__,t)&&U(e,n)).map(e=>e.hasBehavior&&e.hasBehavior(`wx://component-export`)&&e.export?e.export():e)}#e(){for(let e in this.__info__){let t=this.__info__[e];h(t)?this[e]=t.bind(this):this[e]=t}}async#t(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.(),this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),await this.onLoad?.(this.opts.query||{}),this.initd=!0}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageReady(){this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.(),this.onReady?.()}pageUnload(){this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.onUnload?.(),this.initd=!1}pageScrollTop(e){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.onResize?.(e)}},K=class e{static type=`page`;constructor(t,n){if(this.moduleInfo=t,this.extraInfo=n,this.type=e.type,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,In(this.moduleInfo,this.behaviors),this.moduleInfo.methods)for(let[e,t]of Object.entries(this.moduleInfo.methods))!(e in this.moduleInfo)&&h(t)&&(this.moduleInfo[e]=t);this.noReferenceData=z(this.moduleInfo.data||{})}},q=class{static type=`app`;constructor(e){this.moduleInfo=e}},J=new class{constructor(){this.staticModules={}}loadResource(e){let{appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a}=e;if(v&&(this.isScriptLoaded=this.isScriptLoaded||{},!this.isScriptLoaded[i])){let e=`${a}${t}/${i}/logic.js`;globalThis.importScripts(e),this.isScriptLoaded[i]=!0}D.setInitId(n),C(`app`),C(r),E.invoke({type:`serviceResourceLoaded`,target:`service`,body:{bridgeId:n}})}createAppModule(e){let t=new q(e);this.staticModules[q.type]=t}createModule(e,t,n){let{path:r,usingComponents:i}=t;if(!this.staticModules[r]){if(i)for(let e of Object.values(i))C(e);if(n===K.type){let n=new K(e,t);this.staticModules[r]=n}else if(n===G.type){let n=new G(e,t);this.staticModules[r]=n}else console.error(`[service] createModule ${n} error`)}}getPropsByPath(e){let t={};return this.getComponentProps(t,e),t}getComponentProps(e,t){if(t)for(let n of Object.values(t)){let t=this.staticModules[n];!t||e[n]||(e[n]=t.getProps(),this.getComponentProps(e,t.usingComponents))}}getAppModule(){return this.staticModules[q.type]}getModuleByPath(e){return this.staticModules[e]}},Y=new class{constructor(){this.app=null,this.instances={}}queuePendingEvent(e,t){return e.__pendingRuntimeEvents__=e.__pendingRuntimeEvents__||[],new Promise((n,r)=>{e.__pendingRuntimeEvents__.push({...t,resolve:n,reject:r})})}async flushPendingEvents(e){let t=e?.__pendingRuntimeEvents__||[];e.__pendingRuntimeEvents__=[];for(let e of t)try{let t=await this.dispatchEvent(e);e.resolve(t)}catch(t){e.reject(t)}}async dispatchEvent({instance:e,bridgeId:t,moduleId:n,methodName:r,event:i}){if(h(e[r]))return await e[r](i);console.warn(`[service] triggerEvent ${t} ${n}, is: ${e.is}, method: ${r} is not exist`)}createApp(e){if(this.app){console.log(`[service] app instance already existed`);return}let{scene:t,pagePath:n,query:r}=e,i=J.getAppModule();if(!i){console.log(`[service] app instance is not exist`);return}console.log(`[service] create app instance`),this.app=new yn(i,{scene:t,path:n,query:r})}appShow(){this.app?.appShow()}appHide(){this.app?.appHide()}stackShow(e){D.pushStack(e)}stackHide(e){D.popStack(e)}createInstance(e){let{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l,stackId:u}=e,d=J.getModuleByPath(r);if(!d){console.error(`[service] ${r} not exist`);return}if(console.log(`[service] create instance ${r}`),this.instances[t]=this.instances[t]||{},d.type===G.type){let e=new Vn(d,{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l});return this.instances[t][n]=e,d.isComponent||D.push(e,u),e.init(),e}else if(d.type===K.type){let e=new Hn(d,{bridgeId:t,moduleId:n,path:r,query:i});return this.instances[t][n]=e,D.push(e,u),e.init(),e}else console.error(`[service] ${d.type} instance is not exist.`)}moduleReady(e){let{bridgeId:t,moduleId:n,propBindings:r}=e,i=this.instances[t][n];if(i){if(r&&i.__parentId__){let e=this.instances[t]?.[i.__parentId__];e&&(e.__childPropsBindings__||={},e.__childPropsBindings__[n]=r)}if(i.__type__===G.type){i.componentReadied(),i.__componentReadied__=!0,this.flushPendingEvents(i),i.flushInitSetDataCallbacks?.();let e=this.getPageInstance(t);e&&this.checkAndCallPageReady(t,e.__id__)}}}moduleUnmounted(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(r.__type__===G.type&&r.componentDetached(),delete this.instances[t][n])}pageShow(e){let{bridgeId:t}=e,n=this.instances[t];if(!n)return;let r=[];Object.values(n).forEach(e=>{e&&(e.__type__===K.type?r.push(e):e.__type__===G.type&&(e.__isComponent__?e.pageShow():r.push(e)))}),r.forEach(e=>{e.pageShow()})}pageReady(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(this.pageShow(e),r.__pageReadyPending__=!0,r.flushInitSetDataCallbacks?.(),this.checkAndCallPageReady(t,n))}getPageInstance(e){let t=this.instances[e];return t?Object.values(t).find(e=>e&&(e.__type__===K.type||e.__type__===G.type&&!e.__isComponent__)):null}checkAndCallPageReady(e,t){let n=this.instances[e][t];if(!n||!n.__pageReadyPending__)return;let r=this.instances[e];if(!r){n.__pageReadyPending__=!1,n.pageReady();return}Object.values(r).filter(e=>e&&e.__type__===G.type&&e.__isComponent__&&e.initd&&!e.__componentReadied__).length===0&&(n.__pageReadyPending__=!1,n.pageReady())}pageHide(e){let{bridgeId:t}=e,n=this.instances[t],r=[];Object.values(n).forEach(e=>{e&&(e.__type__===K.type?r.push(e):e.__type__===G.type&&(e.__isComponent__?e.pageHide():r.push(e)))}),r.forEach(e=>{e&&e.pageHide()})}pageUnload(e){let{bridgeId:t}=e,n=this.instances[t];n&&(Object.values(n).forEach(e=>{e&&(e.__type__===G.type&&e.componentDetached(),e.pageUnload())}),D.pop(),delete this.instances[t])}pageScroll(e){let{bridgeId:t,moduleId:n,scrollTop:r}=e,i=this.instances[t][n];i&&i.pageScrollTop({scrollTop:r})}pageResize(e){let{bridgeId:t,size:n}=e,r=this.instances[t];r&&Object.values(r).forEach(e=>{e&&(e.__type__===K.type?e.pageResize(n):e.__type__===G.type&&(e.__isComponent__,e.pageResize(n)))})}componentError(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&r.__type__===G.type&&r.componentError()}componentRouteDone(e){let{bridgeId:t}=e,n=this.instances[t];n&&Object.values(n).forEach(e=>{e?.__type__===G.type&&e.componentRouteDone()})}async triggerEvent(e){let{bridgeId:t,moduleId:n,methodName:r,event:i}=e;if(r===void 0)return;let a=this.instances[t];if(!a){console.warn(`[service] No instances found for bridgeId: ${t}`);return}let o=a[n];if(!o){console.warn(`[service] triggerEvent ${t} ${n} ${r}, instance is not exist`);return}return o.__type__===G.type&&o.__isComponent__&&!o.__componentReadied__?this.queuePendingEvent(o,{instance:o,bridgeId:t,moduleId:n,methodName:r,event:i}):this.dispatchEvent({instance:o,bridgeId:t,moduleId:n,methodName:r,event:i})}},Un=t({getEnterOptionsSync:()=>Gn,getLaunchOptionsSync:()=>Wn});function Wn(){return Y.app?.options}function Gn(){return Y.app?.options}var Kn=t({getLocation:()=>qn,offLocationChange:()=>Qn,onLocationChange:()=>Zn,openLocation:()=>Yn,startLocationUpdate:()=>Jn,stopLocationUpdate:()=>Xn});function qn(e){O(`getLocation`,e)}function Jn(e){O(`startLocationUpdate`,e)}function Yn(e){O(`openLocation`,e)}function Xn(e){O(`stopLocationUpdate`,e)}function Zn(e){e&&O(`onLocationChange`,{success:w.store(e,!0)})}function Qn(e){if(e){let t=w.store(e,!0);O(`offLocationChange`,{success:t}),w.remove(t)}else O(`offLocationChange`),w.remove()}var $n=t({createMapContext:()=>er});function er(e,t){return new tr({mapId:e,obj:t})}var tr=class{constructor(e){this.opts=e}addMarkers(e){O(`addMarkers`,e)}removeMarkers(e){O(`removeMarkers`,e)}includePoints(e){O(`includePoints`,e)}setCenterOffset(e){O(`setCenterOffset`,e)}getCenterLocation(e){O(`getCenterLocation`,e)}getScale(e){O(`getScale`,e)}moveToLocation(e){O(`moveToLocation`,e)}translateMarker(e){O(`translateMarker`,e)}addArc(e){O(`addArc`,e)}removeArc(e){O(`removeArc`,e)}},nr=t({createInnerAudioContext:()=>ar}),rr=1,ir=class{constructor(){this._audioId=rr++,this._src=``,this._startTime=0,this._autoplay=!1,this._loop=!1,this._volume=1,this._playbackRate=1,this._paused=!0,this._listeners={},O(`audioCreate`,{audioId:this._audioId})}get src(){return this._src}set src(e){this._src=e,O(`audioSetProp`,{audioId:this._audioId,prop:`src`,value:e,startTime:this._startTime,loop:this._loop,volume:this._volume,playbackRate:this._playbackRate,autoplay:this._autoplay})}get startTime(){return this._startTime}set startTime(e){this._startTime=Number(e)||0,O(`audioSetProp`,{audioId:this._audioId,prop:`startTime`,value:this._startTime})}get autoplay(){return this._autoplay}set autoplay(e){this._autoplay=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`autoplay`,value:this._autoplay})}get loop(){return this._loop}set loop(e){this._loop=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`loop`,value:this._loop})}get volume(){return this._volume}set volume(e){this._volume=Math.max(0,Math.min(1,Number(e)||0)),O(`audioSetProp`,{audioId:this._audioId,prop:`volume`,value:this._volume})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=Number(e)||1,O(`audioSetProp`,{audioId:this._audioId,prop:`playbackRate`,value:this._playbackRate})}get duration(){return 0}get currentTime(){return 0}get paused(){return this._paused}get buffered(){return 0}play(){this._paused=!1,O(`audioPlay`,{audioId:this._audioId,src:this._src})}pause(){this._paused=!0,O(`audioPause`,{audioId:this._audioId})}stop(){this._paused=!0,O(`audioStop`,{audioId:this._audioId})}seek(e){O(`audioSeek`,{audioId:this._audioId,position:Number(e)||0})}destroy(){O(`audioDestroy`,{audioId:this._audioId}),this._listeners={}}_on(e,t){typeof t==`function`&&(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t))}_off(e,t){this._listeners[e]&&(t?this._listeners[e]=this._listeners[e].filter(e=>e!==t):this._listeners[e]=[])}onPlay(e){this._on(`play`,e)}onPause(e){this._on(`pause`,e)}onStop(e){this._on(`stop`,e)}onEnded(e){this._on(`ended`,e)}onError(e){this._on(`error`,e)}onTimeUpdate(e){this._on(`timeUpdate`,e)}onWaiting(e){this._on(`waiting`,e)}onSeeking(e){this._on(`seeking`,e)}onSeeked(e){this._on(`seeked`,e)}onCanplay(e){this._on(`canplay`,e)}offPlay(e){this._off(`play`,e)}offPause(e){this._off(`pause`,e)}offStop(e){this._off(`stop`,e)}offEnded(e){this._off(`ended`,e)}offError(e){this._off(`error`,e)}offTimeUpdate(e){this._off(`timeUpdate`,e)}offWaiting(e){this._off(`waiting`,e)}offSeeking(e){this._off(`seeking`,e)}offSeeked(e){this._off(`seeked`,e)}offCanplay(e){this._off(`canplay`,e)}};function ar(){return new ir}var or=t({chooseImage:()=>ur,compressImage:()=>lr,previewImage:()=>cr,saveImageToPhotosAlbum:()=>sr});function sr(e){O(`saveImageToPhotosAlbum`,e)}function cr(e){O(`previewImage`,e)}function lr(e){O(`compressImage`,e)}function ur(e){O(`chooseImage`,e)}var dr=t({chooseMedia:()=>pr,chooseVideo:()=>fr});function fr(e){O(`chooseVideo`,e)}function pr(e){O(`chooseMedia`,e)}var mr=t({exitMiniProgram:()=>vr,navigateBackMiniProgram:()=>_r,navigateToMiniProgram:()=>gr,restartMiniProgram:()=>hr});function hr(e){O(`restartMiniProgram`,e)}function gr(e){O(`navigateToMiniProgram`,e)}function _r(e){O(`navigateBackMiniProgram`,e)}function vr(e){O(`exitMiniProgram`,e)}var yr=t({downloadFile:()=>br});function br(e){O(`downloadFile`,e)}var xr=t({request:()=>Sr});function Sr(e){O(`request`,e)}var Cr=t({uploadFile:()=>wr});function wr(e){O(`uploadFile`,e)}var Tr=t({closeSocket:()=>Or,connectSocket:()=>Er,onSocketClose:()=>Mr,onSocketError:()=>jr,onSocketMessage:()=>Ar,onSocketOpen:()=>kr,sendSocketMessage:()=>Dr}),X=class{constructor(e){this.socketId=e,this._readyState=0}send(e={}){let{data:t,success:n,fail:r,complete:i,...a}=e,o={socketId:this.socketId,data:t,...a};return h(n)&&(o.success=w.store(n)),h(r)&&(o.fail=w.store(r)),h(i)&&(o.complete=w.store(i)),O(`sendSocketMessage`,o)}close(e={}){let{code:t=1e3,reason:n=``,success:r,fail:i,complete:a,...o}=e,s={socketId:this.socketId,code:t,reason:n,...o};return h(r)&&(s.success=w.store(r)),h(i)&&(s.fail=w.store(i)),h(a)&&(s.complete=w.store(a)),O(`closeSocket`,s)}onOpen(e){if(h(e))return O(`onSocketOpen`,{socketId:this.socketId,callback:w.store(e,!0)})}offOpen(e){return O(`offSocketOpen`,{socketId:this.socketId,callback:e})}onMessage(e){if(h(e))return O(`onSocketMessage`,{socketId:this.socketId,callback:w.store(e,!0)})}offMessage(e){return O(`offSocketMessage`,{socketId:this.socketId,callback:e})}onError(e){if(h(e))return O(`onSocketError`,{socketId:this.socketId,callback:w.store(e,!0)})}offError(e){return O(`offSocketError`,{socketId:this.socketId,callback:e})}onClose(e){if(h(e))return O(`onSocketClose`,{socketId:this.socketId,callback:w.store(e,!0)})}offClose(e){return O(`offSocketClose`,{socketId:this.socketId,callback:e})}get readyState(){return this._readyState}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}};function Er(e={}){let{url:t,header:n={},protocols:r=[],tcpNoDelay:i=!1,perMessageDeflate:a=!1,timeout:o,forceCellularNetwork:s=!1,success:c,fail:l,complete:u,...d}=e;if(!t){let e=Error(`url is required`);throw h(l)&&l(e),h(u)&&u(e),e}let f=`socket_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,p=new X(f),m={socketId:f,url:t,header:n,protocols:r,tcpNoDelay:i,perMessageDeflate:a,timeout:o,forceCellularNetwork:s,...d};return h(c)&&(m.success=w.store(e=>{p._readyState=X.OPEN,c(e)})),h(l)&&(m.fail=w.store(e=>{p._readyState=X.CLOSED,l(e)})),h(u)&&(m.complete=w.store(u)),O(`connectSocket`,m),p}function Dr(e){return O(`sendSocketMessage`,e)}function Or(e){return O(`closeSocket`,e)}function kr(e){return O(`onSocketOpen`,{callback:w.store(e,!0)})}function Ar(e){return O(`onSocketMessage`,{callback:w.store(e,!0)})}function jr(e){return O(`onSocketError`,{callback:w.store(e,!0)})}function Mr(e){return O(`onSocketClose`,{callback:w.store(e,!0)})}var Nr=t({getAccountInfoSync:()=>Pr});function Pr(){return O(`getAccountInfoSync`)}var Fr=t({authorize:()=>Ir});function Ir(e){O(`authorize`,e)}var Lr=t({login:()=>Rr});function Rr(e){O(`login`,e)}var zr=t({login:()=>Br});function Br(e){O(`login`,e)}var Vr=t({getPrivacySetting:()=>Hr});function Hr(e){O(`getPrivacySetting`,e)}var Ur=t({getSetting:()=>Gr,openSetting:()=>Wr});function Wr(e){O(`openSetting`,e)}function Gr(e){O(`getSetting`,e)}var Kr=t({getUserInfo:()=>qr});function qr(e){O(`getUserInfo`,e)}var Jr=t({requestPayment:()=>Yr});function Yr(e){O(`requestPayment`,e)}var Xr=t({hideShareMenu:()=>$r,showShareImageMenu:()=>Qr,showShareMenu:()=>Zr});function Zr(e){O(`shareShareMenu`,e)}function Qr(e){O(`showShareImageMenu`,e)}function $r(e){O(`hideShareMenu`,e)}var ei=t({clearStorage:()=>ci,clearStorageSync:()=>ii,getStorage:()=>oi,getStorageInfo:()=>ui,getStorageInfoSync:()=>li,getStorageSync:()=>ni,removeStorage:()=>si,removeStorageSync:()=>ri,setStorage:()=>ai,setStorageSync:()=>ti});function ti(...e){O(`setStorageSync`,e)}function ni(e){return O(`getStorageSync`,e)}function ri(e){return O(`removeStorageSync`,e)}function ii(){O(`clearStorageSync`)}function ai(e){O(`setStorage`,e)}function oi(e){O(`getStorage`,e)}function si(e){O(`removeStorage`,e)}function ci(){O(`clearStorage`)}function li(){return O(`getStorageInfoSync`)}function ui(e){O(`getStorageInfo`,e)}var di=t({createAnimation:()=>fi});function fi(e={}){return new pi(e)}var pi=class{constructor({duration:e=400,timingFunction:t=`linear`,delay:n=0,transformOrigin:r=`50% 50% 0`}={}){this.actions=[],this.currentTransform={},this.currentStepAnimates=[],this.option={transition:{duration:e,timingFunction:t,delay:n},transformOrigin:r}}export(){let e=this.actions;return this.actions=[],{actions:e}}step(e={}){for(let e of this.currentStepAnimates)e.type===`style`?this.currentTransform[`${e.type}.${e.args[0]}`]=e:this.currentTransform[e.type]=e;return this.actions.push({animates:Object.keys(this.currentTransform).reduce((e,t)=>[].concat(...e,[this.currentTransform[t]]),[]),option:{transformOrigin:e.transformOrigin===void 0?this.option.transformOrigin:e.transformOrigin,transition:{duration:e.duration===void 0?this.option.transition.duration:e.duration,timingFunction:e.timingFunction===void 0?this.option.transition.timingFunction:e.timingFunction,delay:e.delay===void 0?this.option.transition.delay:e.delay}}}),this.currentStepAnimates=[],this}backgroundColor(e){return this.currentStepAnimates.push({type:`style`,args:[`background-color`,e]}),this}bottom(e){return this.currentStepAnimates.push({type:`style`,args:[`bottom`,b(e)]}),this}height(e){return this.currentStepAnimates.push({type:`style`,args:[`height`,b(e)]}),this}left(e){return this.currentStepAnimates.push({type:`style`,args:[`left`,b(e)]}),this}matrix(e=1,t=0,n=0,r=1,i=1,a=1){return this.currentStepAnimates.push({type:`matrix`,args:[e,t,n,r,i,a]}),this}matrix3d(e=1,t=0,n=0,r=0,i=0,a=1,o=0,s=0,c=0,l=0,u=1,d=0,f=0,p=0,m=0,ee=1){return this.currentStepAnimates.push({type:`matrix3d`,args:[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,ee]}),this}opacity(e){return this.currentStepAnimates.push({type:`style`,args:[`opacity`,e]}),this}right(e){return this.currentStepAnimates.push({type:`style`,args:[`right`,b(e)]}),this}rotate(e=0){return this.currentStepAnimates.push({type:`rotate`,args:[e]}),this}rotate3d(e=0,t=0,n=0,r=0){return this.currentStepAnimates.push({type:`rotate3d`,args:[e,t,n,r]}),this}rotateX(e){return this.currentStepAnimates.push({type:`rotateX`,args:[e]}),this}rotateY(e){return this.currentStepAnimates.push({type:`rotateY`,args:[e]}),this}rotateZ(e){return this.currentStepAnimates.push({type:`rotateZ`,args:[e]}),this}scale(e=1,t=1){return this.currentStepAnimates.push({type:`scale`,args:[e,t]}),this}scale3d(e=1,t=1,n=1){return this.currentStepAnimates.push({type:`scale3d`,args:[e,t,n]}),this}scaleX(e=1){return this.currentStepAnimates.push({type:`scaleX`,args:[e]}),this}scaleY(e=1){return this.currentStepAnimates.push({type:`scaleY`,args:[e]}),this}scaleZ(e=1){return this.currentStepAnimates.push({type:`scaleZ`,args:[e]}),this}skew(e=0,t=0){return this.currentStepAnimates.push({type:`skew`,args:[e,t]}),this}skewX(e=0){return this.currentStepAnimates.push({type:`skewX`,args:[e]}),this}skewY(e=0){return this.currentStepAnimates.push({type:`skewY`,args:[e]}),this}top(e){return this.currentStepAnimates.push({type:`style`,args:[`top`,b(e)]}),this}translate(e=0,t=0){return this.currentStepAnimates.push({type:`translate`,args:[e,t]}),this}translate3d(e=0,t=0,n=0){return this.currentStepAnimates.push({type:`translate3d`,args:[e,t,n]}),this}translateX(e=0){return this.currentStepAnimates.push({type:`translateX`,args:[e]}),this}translateY(e=0){return this.currentStepAnimates.push({type:`translateY`,args:[e]}),this}width(e){return this.currentStepAnimates.push({type:`style`,args:[`width`,b(e)]}),this}},mi=t({setBackgroundColor:()=>gi,setBackgroundTextStyle:()=>hi});function hi(e){O(`setBackgroundTextStyle`,e)}function gi(e){O(`setBackgroundColor`,e)}var _i=t({canvasToTempFilePath:()=>xi,createCanvasContext:()=>yi,createContext:()=>vi,drawCanvas:()=>bi});function vi(){return new Si}function yi(e,t){return new Si(e,Z(t))}function bi(e={}){let t={...e,moduleId:e.moduleId||Z(e.component)};delete t.component,O(`drawCanvas`,t,`render`)}function xi(e={},t){let n={...e,moduleId:e.moduleId||Z(t||e.component)};delete n.component,O(`canvasToTempFilePath`,n,`render`)}function Z(e){return e?.__id__||D.getPageInfo()?.id}var Si=class{constructor(e=``,t=null){this.canvasId=e,this.moduleId=t,this.actions=[]}pushAction(e,...t){return this.actions.push({type:e,args:t}),this}getActions(){return this.actions.slice()}draw(e=!1,t){this.canvasId&&(bi({canvasId:this.canvasId,moduleId:this.moduleId,actions:this.getActions(),reserve:e,success:t}),this.actions=[])}beginPath(){return this.pushAction(`beginPath`)}closePath(){return this.pushAction(`closePath`)}moveTo(e,t){return this.pushAction(`moveTo`,e,t)}lineTo(e,t){return this.pushAction(`lineTo`,e,t)}rect(e,t,n,r){return this.pushAction(`rect`,e,t,n,r)}arc(e,t,n,r,i,a=!1){return this.pushAction(`arc`,e,t,n,r,i,a)}quadraticCurveTo(e,t,n,r){return this.pushAction(`quadraticCurveTo`,e,t,n,r)}bezierCurveTo(e,t,n,r,i,a){return this.pushAction(`bezierCurveTo`,e,t,n,r,i,a)}fill(){return this.pushAction(`fill`)}stroke(){return this.pushAction(`stroke`)}clearRect(e,t,n,r){return this.pushAction(`clearRect`,e,t,n,r)}fillText(e,t,n,r){return this.pushAction(`fillText`,e,t,n,r)}drawImage(e,...t){return this.pushAction(`drawImage`,e,...t)}save(){return this.pushAction(`save`)}restore(){return this.pushAction(`restore`)}translate(e,t){return this.pushAction(`translate`,e,t)}rotate(e){return this.pushAction(`rotate`,e)}scale(e,t){return this.pushAction(`scale`,e,t)}setShadow(e,t,n,r){return this.pushAction(`setShadow`,e,t,n,r)}setFillStyle(e){return this.pushAction(`setFillStyle`,e)}setStrokeStyle(e){return this.pushAction(`setStrokeStyle`,e)}setGlobalAlpha(e){return this.pushAction(`setGlobalAlpha`,e)}setLineCap(e){return this.pushAction(`setLineCap`,e)}setLineJoin(e){return this.pushAction(`setLineJoin`,e)}setLineWidth(e){return this.pushAction(`setLineWidth`,e)}setMiterLimit(e){return this.pushAction(`setMiterLimit`,e)}setFontSize(e){return this.pushAction(`setFontSize`,e)}},Ci=t({nextTick:()=>Ei}),Q=[],wi=null;function Ti(){let e=Q;Q=[],wi=null;for(let t=0;t<e.length;t++)e[t]()}function Ei(e){h(e)&&(Q.push(e),wi||=setTimeout(Ti,0))}var Di=t({disableAlertBeforeUnload:()=>Fi,enableAlertBeforeUnload:()=>Pi,hideLoading:()=>Ni,hideToast:()=>ki,showActionSheet:()=>Mi,showLoading:()=>ji,showModal:()=>Ai,showToast:()=>Oi});function Oi(e){O(`showToast`,e)}function ki(e){O(`hideToast`,e)}function Ai(e){O(`showModal`,e)}function ji(e){O(`showLoading`,e)}function Mi(e){O(`showActionSheet`,e)}function Ni(e){O(`hideLoading`,e)}function Pi(e){O(`enableAlertBeforeUnload`,e)}function Fi(e){O(`disableAlertBeforeUnload`,e)}var Ii=t({getMenuButtonBoundingClientRect:()=>Li,offMenuButtonBoundingClientRectWeightChange:()=>zi,onMenuButtonBoundingClientRectWeightChange:()=>Ri}),$=new Set;function Li(){return O(`getMenuButtonBoundingClientRect`)}function Ri(e){h(e)&&$.add(e)}function zi(e){h(e)?$.delete(e):$.clear()}var Bi=t({hideNavigationBarLoading:()=>Wi,setNavigationBarColor:()=>Ui,setNavigationBarTitle:()=>Hi,showNavigationBarLoading:()=>Vi});function Vi(e){O(`showNavigationBarLoading`,e)}function Hi(e){O(`setNavigationBarTitle`,e)}function Ui(e){O(`setNavigationBarColor`,e)}function Wi(e){O(`hideNavigationBarLoading`,e)}var Gi=t({startPullDownRefresh:()=>qi,stopPullDownRefresh:()=>Ki});function Ki(e){O(`stopPullDownRefresh`,e)}function qi(e){O(`startPullDownRefresh`,e)}var Ji=t({pageScrollTo:()=>Yi});function Yi(e){O(`pageScrollTo`,e)}var Xi=t({onWindowResize:()=>Zi});function Zi(e){e&&O(`onWindowResize`,{success:e})}var Qi=Object.assign({"./core/base/app-event/index.js":we,"./core/base/index.js":Pe,"./core/base/performance/index.js":Re,"./core/base/subpackage/index.js":Ue,"./core/base/system/index.js":Ke,"./core/base/update/index.js":tt,"./core/camera/index.js":it,"./core/data-analysis/index.js":st,"./core/device/bluetooth/index.js":ut,"./core/device/bluetooth-ble/index.js":St,"./core/device/clipboard/index.js":It,"./core/device/contact/index.js":zt,"./core/device/keyboard/index.js":Ht,"./core/device/memory/index.js":Wt,"./core/device/network/index.js":qt,"./core/device/phone/index.js":Yt,"./core/device/scan/index.js":Zt,"./core/device/vibrate/index.js":$t,"./core/ext/index.js":nn,"./core/file/index.js":ln,"./core/life-cycle/index.js":Un,"./core/location/index.js":Kn,"./core/map/index.js":$n,"./core/media/audio/index.js":nr,"./core/media/image/index.js":or,"./core/media/video/index.js":dr,"./core/navigate/index.js":mr,"./core/network/download/index.js":yr,"./core/network/request/index.js":xr,"./core/network/upload/index.js":Cr,"./core/network/websocket/index.js":Tr,"./core/open-api/account-info/index.js":Nr,"./core/open-api/authorize/index.js":Fr,"./core/open-api/index.js":Lr,"./core/open-api/login/index.js":zr,"./core/open-api/privacy/index.js":Vr,"./core/open-api/setting/index.js":Ur,"./core/open-api/user-info/index.js":Kr,"./core/payment/index.js":Jr,"./core/route/index.js":ve,"./core/share/index.js":Xr,"./core/storage/index.js":ei,"./core/ui/animation/index.js":di,"./core/ui/background/index.js":mi,"./core/ui/canvas/index.js":_i,"./core/ui/custom-component/index.js":Ci,"./core/ui/interaction/index.js":Di,"./core/ui/menu/index.js":Ii,"./core/ui/navigation-bar/index.js":Bi,"./core/ui/pull-down-refresh/index.js":Gi,"./core/ui/scroll/index.js":Ji,"./core/ui/window/index.js":Xi,"./core/wxml/intersection-observer/index.js":Sn,"./core/wxml/selector-query/index.js":bn}),$i={};for(let e of Object.values(Qi))for(let[t,n]of Object.entries(e))$i[t]=n;var ea=new Proxy($i,{get(e,t,n){let r=Reflect.get(e,t,n);return typeof r==`function`||r!==void 0||t===`webpackJsonp`?r:(...e)=>O(t,...e)},set(e,t,n,r){return Reflect.set(e,t,n,r)}}),ta=new class{constructor(){this.init()}init(){let e=globalThis.__diminaApiNamespaces||[];if(e.length===0&&globalThis.name)try{e=JSON.parse(globalThis.name).apiNamespaces||[]}catch{}for(let t of[`dd`,`wx`,...e])globalThis[t]=ea;globalThis.modRequire=C,globalThis.modDefine=he,globalThis.global={},globalThis.App=e=>J.createAppModule(e),globalThis.Page=e=>{J.createModule(e,globalThis.__extraInfo,K.type)},globalThis.Component=e=>{J.createModule(e,globalThis.__extraInfo,G.type)},globalThis.Behavior=e=>e,globalThis.getApp=e=>{let t=Y.app;return!t&&e?.allowDefault?{}:t},globalThis.getCurrentPages=()=>D.stack()}},na={navigateBack:Ce,navigateTo:Se,reLaunch:be,redirectTo:xe,switchTab:ye};return new class{constructor(){console.log(`[service] init`),this.env=ta,this.message=E,this.init()}init(){this.message.on(`loadResource`,e=>{let{appId:t,bridgeId:n,pagePath:r,root:i=`.`,baseUrl:a=`/`,hostEnv:o}=e;o&&T.init(o),J.loadResource({appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a})}),this.message.on(`t`,async e=>{let{bridgeId:t,moduleId:n,methodName:r,event:i,success:a}=e;if(r===void 0)return;let o=await Y.triggerEvent({bridgeId:t,moduleId:n,methodName:r,event:i});o!==void 0&&this.message.send({type:`triggerCallback`,target:`render`,body:{bridgeId:t,moduleId:n,success:a,data:o}})}),this.message.on(`triggerCallback`,e=>{let{id:t,args:n}=e;w.invoke(t,n)}),this.onAppMsg(),this.onModuleMsg()}onAppMsg(){this.message.on(`resourceLoaded`,e=>{let{bridgeId:t,scene:n,pagePath:r,query:i,stackId:a}=e;Y.createApp({scene:n,pagePath:r,query:i});let o=J.getModuleByPath(r);if(!o){console.error(`[service] resourceLoaded: module not found, pagePath: ${r}`);return}let s=J.getPropsByPath(o.usingComponents),c=`page_${le()}`;Y.createInstance({bridgeId:t,moduleId:c,path:r,query:i,stackId:a}),E.send({type:`firstRender`,target:`render`,body:{bridgeId:t,pageId:c,pagePath:r,initialProps:s,query:i}})}),this.message.on(`appShow`,()=>{Y.appShow()}),this.message.on(`appHide`,()=>{Y.appHide()}),this.message.on(`stackShow`,({stackId:e})=>{Y.stackShow(e)}),this.message.on(`stackHide`,({stackId:e})=>{Y.stackHide(e)})}onModuleMsg(){this.message.on(`mC`,e=>{Y.createInstance(e)}),this.message.on(`mR`,e=>{Y.moduleReady(e)}),this.message.on(`mU`,e=>{Y.moduleUnmounted(e)}),this.message.on(`pageUnload`,e=>{Y.pageUnload(e)}),this.message.on(`pageShow`,e=>{Y.pageShow(e)}),this.message.on(`pageReady`,e=>{Y.pageReady(e)}),this.message.on(`pageHide`,e=>{Y.pageHide(e)}),this.message.on(`pagePullDownRefresh`,()=>{}),this.message.on(`pageReachBottom`,()=>{}),this.message.on(`pageShareAppMessage`,()=>{}),this.message.on(`pageScroll`,e=>{Y.pageScroll(e)}),this.message.on(`pageResize`,e=>{Y.pageResize(e)}),this.message.on(`onTabItemTap`,()=>{}),this.message.on(`pageRouteDone`,e=>{let{bridgeId:t}=e;Y.componentRouteDone({bridgeId:t})}),this.message.on(`componentError`,e=>{Y.componentError(e)}),this.message.on(`h5SdkAction`,async(e={})=>{let t=e?.name?.replace(/h5/i,``),{url:n}=e?.params?.data?.params||{};if(e.params&&(e.params.data={...e.params?.data,...e.params?.data?.params||{}}),t===`postMessage`&&e.parentWebViewId){let{moduleId:t,attrs:n,params:r}=e,i={detail:{data:[r?.data?.params?.data]}},a=n.message,o=e.parentWebViewId,s=await Y.triggerEvent({bridgeId:o,moduleId:t,methodName:a,event:i});s!==void 0&&this.message.send({type:`triggerCallback`,target:`service`,body:{bridgeId:o,moduleId:t,success:r?.success,data:s}})}na[t]?.({url:n,...e.params})})}}})();
@@ -0,0 +1,3 @@
1
+ {
2
+ "diminaGitHash": "cb88dc339b87e6cbc11fd31b27e5f526093b648c"
3
+ }
@@ -0,0 +1 @@
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"><title>星河小程序</title><script type="module" crossorigin src="/assets/index.js"></script><link rel="stylesheet" crossorigin href="/assets/index.css"></head><body><div id="root"></div></body></html>
@@ -0,0 +1 @@
1
+ <!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"/><title>pageFrame</title><script type="module" crossorigin src="/assets/pageFrame.js"></script><link rel="stylesheet" crossorigin href="/assets/pageFrame.css"><body></body></head></html>
@@ -0,0 +1,13 @@
1
+ # Third-Party Notices
2
+
3
+ This directory contains prebuilt assets from the Dimina mini-app runtime:
4
+
5
+ - Upstream: https://github.com/didi/dimina
6
+ - License: Apache License 2.0
7
+ - Copyright: (C) Beijing Didi Infinity Technology and Development Co., Ltd.
8
+
9
+ The prebuilt assets in this directory are derived from the upstream project,
10
+ distributed under the terms of the Apache License, Version 2.0. A copy of
11
+ the license is available at:
12
+
13
+ https://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,68 @@
1
+ import axios from 'axios'
2
+ import cors from 'cors'
3
+ import express from 'express'
4
+ import { app } from '../server.js'
5
+
6
+ // 使用cors中间件来允许所有跨域请求
7
+ // 注意:在实际生产环境中,你应该更具体地配置CORS策略
8
+ app.use(cors())
9
+ app.use(express.json())
10
+
11
+ app.post('/proxy', async (req, res) => {
12
+ try {
13
+ // Input validation
14
+ const { url, data, header = {}, timeout = 30000, method = 'GET', responseType = 'json' } = req.body
15
+
16
+ if (!url) {
17
+ return res.status(400).json({ error: 'URL is required' })
18
+ }
19
+ if (!['GET', 'POST', 'PUT', 'DELETE', 'PATCH'].includes(method.toUpperCase())) {
20
+ return res.status(400).json({ error: 'Invalid HTTP method' })
21
+ }
22
+
23
+ // Build request config
24
+ const axiosConfig = {
25
+ method: method.toUpperCase(),
26
+ url,
27
+ timeout: Number.parseInt(timeout, 10) || 30000,
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ ...header,
31
+ },
32
+ // Only include data for non-GET requests
33
+ ...(method.toUpperCase() !== 'GET' && { data }),
34
+ // For GET requests, move data to params
35
+ ...(method.toUpperCase() === 'GET' && data && { params: data }),
36
+ responseType,
37
+ validateStatus: () => true, // Ensure we get the response even for error status codes
38
+ }
39
+
40
+ // Send request to target service
41
+ const response = await axios(axiosConfig)
42
+
43
+ // Set appropriate content type based on response type
44
+ if (responseType === 'arraybuffer') {
45
+ // For arraybuffer responses, set appropriate content type from response headers or default to application/octet-stream
46
+ const contentType = response.headers['content-type'] || 'application/octet-stream'
47
+ res.set('Content-Type', contentType)
48
+ res.status(response.status).send(response.data)
49
+ }
50
+ else {
51
+ // For JSON responses, ensure we have proper content type
52
+ res.set('Content-Type', 'application/json')
53
+ res.status(response.status).json(response.data)
54
+ }
55
+ }
56
+ catch (error) {
57
+ console.error('Error forwarding request:', error.message)
58
+ const statusCode = error.response?.status || 500
59
+ const errorMessage = error.response?.data?.message || error.message || 'Internal Server Error'
60
+
61
+ res.status(statusCode).json({
62
+ error: errorMessage,
63
+ status: statusCode,
64
+ timestamp: new Date().toISOString(),
65
+ })
66
+ }
67
+ })
68
+
package/fe/index.js ADDED
@@ -0,0 +1,118 @@
1
+ import open from 'open'
2
+ import express from 'express'
3
+ import path from 'path'
4
+ import fs from 'fs'
5
+ import { fileURLToPath } from 'url'
6
+ import { app } from './server.js'
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
+
10
+ /**
11
+ * Start the dimina-fe server
12
+ * @param {object} opts
13
+ * @param {number} [opts.port=7788] - Port to listen on
14
+ * @param {string} opts.containerDir - Path to the dimina-fe-container directory
15
+ * @param {string} [opts.simulatorDir] - Optional directory containing simulator shell assets
16
+ * @param {boolean} [opts.liveReload=false] - Enable live reload via SSE
17
+ * @param {Array<{ appId: string; name: string; path: string }>} [opts.sessionApps=[]] - Runtime app list injected by caller
18
+ * @returns {Promise<import('http').Server | { server: import('http').Server, reload: () => void }>}
19
+ */
20
+ export async function start({ port = 7788, containerDir, outputDir, simulatorDir, liveReload = false, sessionApps = [] } = {}) {
21
+ let liveReloadModule
22
+ const appsDir = outputDir || containerDir
23
+
24
+ app.get('/appList.json', (_req, res) => {
25
+ const appListPath = path.join(appsDir, 'appList.json')
26
+ let baseApps = []
27
+
28
+ if (fs.existsSync(appListPath)) {
29
+ try {
30
+ baseApps = JSON.parse(fs.readFileSync(appListPath, 'utf-8'))
31
+ }
32
+ catch (error) {
33
+ console.warn(`Failed to parse ${appListPath}:`, error)
34
+ }
35
+ }
36
+
37
+ const merged = new Map()
38
+ baseApps.forEach((appInfo) => {
39
+ if (appInfo?.appId) {
40
+ merged.set(appInfo.appId, appInfo)
41
+ }
42
+ })
43
+ sessionApps.forEach((appInfo) => {
44
+ if (appInfo?.appId) {
45
+ merged.set(appInfo.appId, appInfo)
46
+ }
47
+ })
48
+
49
+ const filtered = Array.from(merged.values()).filter(appInfo =>
50
+ fs.existsSync(path.join(appsDir, appInfo.appId)),
51
+ )
52
+
53
+ res.json(filtered)
54
+ })
55
+
56
+ if (outputDir && outputDir !== containerDir) {
57
+ app.use(express.static(outputDir, { index: false }))
58
+ }
59
+
60
+ if (liveReload) {
61
+ liveReloadModule = await import('./live-reload.js')
62
+ // Disable auto index so SPA fallback handles script injection
63
+ app.use(express.static(containerDir, { index: false }))
64
+ }
65
+ else {
66
+ app.use(express.static(containerDir))
67
+ }
68
+
69
+ if (simulatorDir && fs.existsSync(simulatorDir)) {
70
+ app.use('/simulator', express.static(simulatorDir))
71
+ app.get('/simulator.html', (_req, res) => {
72
+ res.sendFile(path.join(simulatorDir, 'simulator.html'))
73
+ })
74
+ }
75
+
76
+ // Load proxy server middleware (cors, json, /proxy route)
77
+ await import('./dimina-fe-server/index.js')
78
+
79
+ // SPA fallback: serve index.html for all unmatched routes so that
80
+ // Vue Router history-mode navigation works after a hard refresh
81
+ // Express 5 requires a named wildcard parameter instead of bare '*'
82
+ app.get('/{*path}', liveReload ? liveReloadModule.injectScript(containerDir) : (_req, res) => {
83
+ res.sendFile('index.html', { root: containerDir })
84
+ })
85
+
86
+ return new Promise((resolve, reject) => {
87
+ const server = app.listen(port, async () => {
88
+ console.log(`Server is running on port ${port}`)
89
+ console.log('Press Ctrl+C to stop')
90
+ if (!process.env.DIMINA_NO_OPEN_BROWSER) await open(`http://localhost:${port}`)
91
+ resolve(liveReload ? { server, reload: liveReloadModule.reload } : server)
92
+ })
93
+ server.on('error', (err) => {
94
+ if (err.code === 'EADDRINUSE') {
95
+ console.error(`Port ${port} is already in use. Kill it with: kill $(lsof -t -i :${port})`)
96
+ }
97
+ else {
98
+ console.error('Server error:', err)
99
+ }
100
+ reject(err)
101
+ })
102
+ })
103
+ }
104
+
105
+ // Support direct invocation: node index.js
106
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
107
+ process.on('uncaughtException', (err) => {
108
+ console.error('Uncaught Exception:', err)
109
+ process.exit(1)
110
+ })
111
+ process.on('unhandledRejection', (reason, promise) => {
112
+ console.error('Unhandled Rejection at:', promise, 'reason:', reason)
113
+ process.exit(1)
114
+ })
115
+
116
+ const containerDir = path.join(__dirname, 'dimina-fe-container')
117
+ start({ port: 7788, containerDir })
118
+ }
@@ -0,0 +1,30 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { app } from './server.js'
4
+
5
+ const LIVERELOAD_SCRIPT = `<script>(function(){var es=new EventSource('/__livereload');es.addEventListener('reload',function(){window.location.reload();});}());</script>`
6
+
7
+ const clients = new Set()
8
+
9
+ app.get('/__livereload', (req, res) => {
10
+ res.setHeader('Content-Type', 'text/event-stream')
11
+ res.setHeader('Cache-Control', 'no-cache')
12
+ res.setHeader('Connection', 'keep-alive')
13
+ res.flushHeaders()
14
+ clients.add(res)
15
+ req.on('close', () => clients.delete(res))
16
+ })
17
+
18
+ export function reload() {
19
+ for (const client of clients) {
20
+ client.write('event: reload\ndata: \n\n')
21
+ }
22
+ }
23
+
24
+ export function injectScript(containerDir) {
25
+ return (_req, res) => {
26
+ const html = fs.readFileSync(path.join(containerDir, 'index.html'), 'utf-8')
27
+ res.setHeader('Content-Type', 'text/html')
28
+ res.send(html.replace('</body>', `${LIVERELOAD_SCRIPT}</body>`))
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ import express from 'express'
2
+ import path from 'path'
3
+ import { fileURLToPath } from 'url'
4
+ import { app } from './server.js'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+
8
+ // Serve dimina-fe-container static files (HTML, JS, CSS, JSON, etc.)
9
+ // Must be loaded before dimina-fe-server so static files are served first
10
+ const containerPath = path.join(__dirname, 'dimina-fe-container')
11
+ app.use(express.static(containerPath))
package/fe/server.js ADDED
@@ -0,0 +1,3 @@
1
+ import express from 'express'
2
+
3
+ export const app = express()
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@dimina-kit/devkit",
3
+ "version": "0.1.0-dev.20260422094158",
4
+ "description": "Development toolkit for Dimina mini-apps with H5 container preview",
5
+ "keywords": [
6
+ "dimina",
7
+ "mini-app",
8
+ "miniprogram",
9
+ "h5",
10
+ "preview",
11
+ "compiler",
12
+ "dev-server",
13
+ "container"
14
+ ],
15
+ "type": "module",
16
+ "engines": {
17
+ "node": ">=20"
18
+ },
19
+ "license": "MIT",
20
+ "author": "EchoTechFE",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/EchoTechFE/dimina-kit.git",
24
+ "directory": "packages/devkit"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/EchoTechFE/dimina-kit/issues"
28
+ },
29
+ "homepage": "https://github.com/EchoTechFE/dimina-kit/tree/main/packages/devkit#readme",
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "fe/index.js",
41
+ "fe/server.js",
42
+ "fe/server-container.js",
43
+ "fe/live-reload.js",
44
+ "fe/dimina-fe-container",
45
+ "fe/dimina-fe-server/index.js",
46
+ "fe/dimina-fe-server/THIRD_PARTY_NOTICES.md",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "devDependencies": {
51
+ "@types/node": "^22.15.3",
52
+ "eslint": "^10.2.1",
53
+ "typescript": "5.9.2",
54
+ "@dimina-kit/eslint-config": "0.1.0",
55
+ "@dimina-kit/typescript-config": "0.1.0"
56
+ },
57
+ "dependencies": {
58
+ "@dimina/compiler": "1.0.12",
59
+ "axios": "^1.15.0",
60
+ "chokidar": "^5.0.0",
61
+ "cors": "^2.8.6",
62
+ "express": "^5.2.1",
63
+ "open": "^11.0.0"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "scripts": {
69
+ "build": "tsc",
70
+ "check-types": "tsc --noEmit",
71
+ "lint": "eslint . --max-warnings 0"
72
+ }
73
+ }