@dimina-kit/devtools 0.4.0-dev.20260728095034 → 0.4.0-dev.20260728110120
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/main/index.bundle.js +1 -2
- package/dist/main/ipc/bridge-router.js +1 -2
- package/dist/main/services/views/native-simulator-view.js +4 -0
- package/dist/preload/runtime/native-host.d.ts +8 -0
- package/dist/preload/runtime/native-host.js +2 -0
- package/dist/preload/windows/main.cjs.map +1 -1
- package/dist/preload/windows/simulator.cjs +1 -0
- package/dist/preload/windows/simulator.cjs.map +2 -2
- package/dist/preload/windows/simulator.js +1 -0
- package/dist/render-host/preload.cjs +18 -0
- package/dist/shared/bridge-channels.d.ts +5 -2
- package/dist/simulator/assets/{device-shell-Cs-rmP1f.js → device-shell-Sbkjw8Nb.js} +2 -2
- package/dist/simulator/assets/{simulator-BG-5CADK.js → simulator-CRyLSz1N.js} +3 -3
- package/dist/simulator/assets/{simulator-mini-app-DzfMfnVM.js → simulator-mini-app-w1Bhwkld.js} +2 -2
- package/dist/simulator/simulator.html +1 -1
- package/package.json +5 -5
|
@@ -995,6 +995,7 @@ function buildBridge2(cfg) {
|
|
|
995
995
|
url.searchParams.set("appId", opts.appId);
|
|
996
996
|
url.searchParams.set("pagePath", opts.pagePath);
|
|
997
997
|
if (opts.isTab) url.searchParams.set("isTab", "1");
|
|
998
|
+
if (opts.backgroundColor) url.searchParams.set("bgColor", opts.backgroundColor);
|
|
998
999
|
return url.toString();
|
|
999
1000
|
},
|
|
1000
1001
|
renderPreloadUrl: cfg.renderPreloadUrl,
|
|
@@ -9,6 +9,7 @@ const CHANNELS = {
|
|
|
9
9
|
const params = new URLSearchParams(globalThis.location && globalThis.location.search || '')
|
|
10
10
|
const bridgeId = params.get('bridgeId')
|
|
11
11
|
const pagePath = params.get('pagePath') || 'pages/index/index'
|
|
12
|
+
const bgColor = params.get('bgColor')
|
|
12
13
|
const pendingMessages = []
|
|
13
14
|
let onMessageFn = null
|
|
14
15
|
let drainScheduled = false
|
|
@@ -17,6 +18,23 @@ if (!bridgeId) {
|
|
|
17
18
|
throw new Error('[render-host] missing bridgeId in URL query')
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
// WeChat parity: prime the page's OWN document with its configured
|
|
22
|
+
// `window.backgroundColor` before pageFrame.css / @dimina/render load — mirrors
|
|
23
|
+
// the real dimina/fe container's `webview.js` (`applyPageStyle()` sets
|
|
24
|
+
// `root.style.backgroundColor` before the inner iframe navigates). Without
|
|
25
|
+
// this the guest's document background is UA-default white until the page's
|
|
26
|
+
// own CSS paints, which is the white flash on every page transition. Applied
|
|
27
|
+
// as early as the preload can reach `document.documentElement` and again on
|
|
28
|
+
// DOMContentLoaded in case the element wasn't attached yet.
|
|
29
|
+
if (bgColor) {
|
|
30
|
+
const applyBackgroundColor = () => {
|
|
31
|
+
if (document.documentElement) document.documentElement.style.backgroundColor = bgColor
|
|
32
|
+
if (document.body) document.body.style.backgroundColor = bgColor
|
|
33
|
+
}
|
|
34
|
+
applyBackgroundColor()
|
|
35
|
+
globalThis.addEventListener('DOMContentLoaded', applyBackgroundColor)
|
|
36
|
+
}
|
|
37
|
+
|
|
20
38
|
function reportError(stage, error) {
|
|
21
39
|
const message = error && error.stack ? error.stack : String(error)
|
|
22
40
|
console.error(`[render-host] ${stage}`, error)
|
|
@@ -164,8 +164,11 @@ export interface HostEnvSnapshot {
|
|
|
164
164
|
export declare function deviceInfoToHostEnv(d: NativeDeviceInfo): Partial<HostEnvSnapshot>;
|
|
165
165
|
/**
|
|
166
166
|
* Subset of WeChat page `window` config plus tabBar list, parsed from
|
|
167
|
-
* `app-config.json` (`{app:{window,tabBar,pages,entryPagePath}, modules:{[pagePath]:{
|
|
168
|
-
*
|
|
167
|
+
* `app-config.json` (`{app:{window,tabBar,pages,entryPagePath}, modules:{[pagePath]:{...flat page.json fields,root?}}}`).
|
|
168
|
+
* `modules[pagePath]` is FLAT — the compiler assigns the page's own `.json` file
|
|
169
|
+
* content as-is (see `dimina/fe/packages/compiler/src/env.js` `collectionPageJson()`),
|
|
170
|
+
* not wrapped under a `.window` key. Mirrors mergePageConfig in dimina-fe:
|
|
171
|
+
* page-level keys override app-level.
|
|
169
172
|
*/
|
|
170
173
|
export interface PageWindowConfig {
|
|
171
174
|
navigationBarTitleText?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./jsx-runtime-BDTY6fEq.js";import{t as r}from"./bridge-channels-zhsumfky.js";var i=e(),a=new Set([`audioListen`]);function o(e){return a.has(e)}function s(e,t,n,r){let i=e.apiRegistry[t];if(!i)return r({ok:!1,errMsg:`${t}:fail no handler`}),Promise.resolve();let a=o(t)||(n&&typeof n==`object`&&!Array.isArray(n)?n.keep===!0:!1);return new Promise(o=>{let s=!1,c=e=>{if(s){a&&e.ok&&r({...e,keep:!0});return}s=!0,r(a&&e.ok?{...e,keep:!0}:e),o()},l=Symbol(`sim-cb-success`),u=Symbol(`sim-cb-fail`),d=Symbol(`sim-cb-complete`),f=!1,p=Object.create(e);p.createCallbackFunction=e=>{if(e!=null)return(e===l||e===u)&&(f=!0),(...n)=>{let r=n[0];e===l?c({ok:!0,result:r}):e===u?c({ok:!1,errMsg:r&&typeof r==`object`&&`errMsg`in r?String(r.errMsg):`${t}:fail`,result:r}):e===d&&!a&&c({ok:!0,result:r})}};let m=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:{};m.success=l,m.fail=u,m.complete=d;try{let e=i.call(p,m);if(e&&typeof e.then==`function`){Promise.resolve(e).then(e=>c({ok:!0,result:e}),e=>{c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})});return}if(s)return;if(a){o();return}if(f){o();return}c({ok:!0,result:e})}catch(e){c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})}})}var c={ios:44,android:64};function l(e){return(c[e]-32)/2}var u=n();function d({platform:e,statusBarHeight:t,onMoreClick:n}){return(0,u.jsxs)(`div`,{className:`menu-capsule`,style:{width:87,height:32,top:t+l(e),right:10},"aria-hidden":`true`,children:[(0,u.jsxs)(`div`,{className:`menu-capsule__more`,onClick:n,children:[(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--mid`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`})]}),(0,u.jsx)(`div`,{className:`menu-capsule__divider`}),(0,u.jsx)(`div`,{className:`menu-capsule__close`,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 22 22`,width:`22`,height:`22`,"aria-hidden":`true`,children:[(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7.8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`}),(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`3.1`,fill:`currentColor`})]})})]})}var f={linear:`linear`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`},p={ios:`M17.51 3.87L15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z`,android:`M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z`};function m({state:e,stackDepth:t,platform:n,statusBarHeight:r,navBarHeight:a,onBack:o,onHome:s,onMoreClick:c}){let l=(0,i.useMemo)(()=>{if(!e.colorAnimation||e.colorAnimation.durationMs<=0)return;let t=f[e.colorAnimation.timingFunc]??`linear`;return`background-color ${e.colorAnimation.durationMs}ms ${t}, color ${e.colorAnimation.durationMs}ms ${t}`},[e.colorAnimation]),m=e.style===`custom`,h=t>1,g=!h&&e.homeButtonVisible,_=n===`ios`?`center`:`left`,v=n===`android`?30:24,y={backgroundColor:e.backgroundColor,color:e.textStyle===`white`?`#ffffff`:`#000000`,height:r+a,paddingTop:r,transition:l};return(0,u.jsxs)(`header`,{className:`nav-bar nav-bar--${n} nav-bar--${e.textStyle}${m?` nav-bar--custom`:``}`,style:y,"aria-hidden":m,children:[!m&&(0,u.jsxs)(`div`,{className:`nav-bar__row`,style:{height:a,justifyContent:_===`center`?`center`:`flex-start`},children:[(h||g)&&(0,u.jsxs)(`div`,{className:`nav-bar__leading`,children:[h&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__back`,"aria-label":`Back`,onClick:o,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:v,height:v,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:p[n],fill:`currentColor`})})}),g&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__home`,"aria-label":`Home`,onClick:s,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M3 12l9-9 9 9M5 10v10h14V10`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(0,u.jsxs)(`div`,{className:`nav-bar__title nav-bar__title--${_}`,style:{color:e.textStyle===`white`?`#ffffff`:`#000000`},children:[e.loading&&(0,u.jsx)(`span`,{className:`nav-bar__spinner`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`nav-bar__title-text`,children:e.title})]})]}),(0,u.jsx)(d,{platform:n,statusBarHeight:r,onMoreClick:c})]})}function h(e){return{title:e?.title??``,backgroundColor:e?.backgroundColor??`#000000`,textStyle:e?.textStyle??`white`,style:e?.style??`default`,loading:e?.loading??!1,homeButtonVisible:e?.homeButtonVisible??!1,colorAnimation:e?.colorAnimation}}function g(e){switch(e){case`notch`:return{width:164,height:30,top:0,bottomOnly:!0};case`dynamic-island`:return{width:124,height:36,top:11,bottomOnly:!1};default:return null}}function _({height:e,notchType:t,textStyle:n}){let r=g(t);return(0,u.jsxs)(`div`,{className:`device-statusbar`,style:{height:e,color:n===`black`?`#000000`:`#ffffff`},"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__time`,children:`9:41`}),r&&(0,u.jsx)(`div`,{className:`device-statusbar__notch`,style:{width:r.width,height:r.height,top:r.top,borderRadius:r.bottomOnly?`0 0 ${Math.round(r.height*.6)}px ${Math.round(r.height*.6)}px`:`${r.height/2}px`}}),(0,u.jsxs)(`div`,{className:`device-statusbar__icons`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__signal`}),(0,u.jsx)(`span`,{className:`device-statusbar__wifi`}),(0,u.jsx)(`span`,{className:`device-statusbar__battery`})]})]})}function v({state:e,currentPath:t,resourceBaseUrl:n,appId:r,onSwitch:i,bottomInset:a=0}){if(!e.config||!e.visible)return null;let{color:o,selectedColor:s,backgroundColor:c,borderStyle:l,list:d}=e.config,f=o||`#999999`,p=s||`#1890ff`;return(0,u.jsx)(`div`,{className:`dmb-tab-bar`,style:{backgroundColor:c||`#ffffff`,borderTopColor:l===`white`?`#ffffff`:`#e0e0e0`,paddingBottom:a},role:`tablist`,"aria-label":`TabBar`,children:d.map((a,o)=>{let s=y(a.pagePath),c=s===t,l=b(c?a.selectedIconPath??a.iconPath:a.iconPath,n,r),d=e.badges[o]??``,m=e.redDots[o]??!1;return(0,u.jsxs)(`button`,{type:`button`,className:`dmb-tab-bar__item${c?` is-selected`:``}`,role:`tab`,"aria-selected":c,onClick:()=>i(s),children:[l&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__icon-slot`,children:(0,u.jsx)(`img`,{className:`dmb-tab-bar__icon`,src:l,alt:``,onError:e=>{e.currentTarget.style.display=`none`}})}),(0,u.jsx)(`span`,{className:`dmb-tab-bar__text`,style:{color:c?p:f},children:a.text||``}),d&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__badge`,children:d}),!d&&m&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__red-dot`})]},`${s}-${o}`)})})}function y(e){return e?e.replace(/^\/+/,``):``}function b(e,t,n){if(!e)return null;let r=e.trim();if(!r)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(r))return r;if(!t)return null;let i=r.replace(/^\/+/,``).replace(/^\.\//,``);return i.startsWith(`${n}/`)?x(t,i):x(t,`${n}/main/${i}`)}function x(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t.replace(/^\/+/,``)}`}var S=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M23.1221%2013.3855C23.1221%2018.5302%2018.2862%2022.7007%2012.321%2022.7007C10.9486%2022.7007%209.63581%2022.48%208.42807%2022.0774C7.60996%2022.48%204.89408%2023.8264%204.89408%2023.8264C4.89408%2023.8264%205.25692%2022.0774%205.51715%2020.6206C3.07834%2018.9126%201.52002%2016.306%201.52002%2013.3855C1.52002%208.241%206.35572%204.07031%2012.321%204.07031C18.2862%204.07031%2023.1221%208.241%2023.1221%2013.3855Z'%20fill='url(%23paint0_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.2446%2019.4912C12.2446%2023.6844%2016.326%2027.0838%2021.3605%2027.0838C22.5189%2027.0838%2023.6267%2026.9038%2024.646%2026.5756C25.4567%2026.9038%2027.6286%2028.0012%2027.6286%2028.0012C27.6286%2028.0012%2027.3134%2026.3862%2027.103%2025.3882C29.1612%2023.9961%2030.4764%2021.8715%2030.4764%2019.4912C30.4764%2015.2977%2026.3951%2011.8984%2021.3605%2011.8984C16.326%2011.8984%2012.2446%2015.2977%2012.2446%2019.4912Z'%20fill='url(%23paint1_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.45121%208.49023C9.2684%208.49023%209.93086%209.14537%209.93086%209.95365C9.93086%2010.7618%209.2684%2011.4171%208.45121%2011.4171C7.63403%2011.4171%206.97168%2010.7618%206.97168%209.95365C6.97168%209.14537%207.63403%208.49023%208.45121%208.49023Z'%20fill='url(%23paint2_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.2077%208.49023C17.0247%208.49023%2017.6872%209.14537%2017.6872%209.95365C17.6872%2010.7618%2017.0247%2011.4171%2016.2077%2011.4171C15.3905%2011.4171%2014.728%2010.7618%2014.728%209.95365C14.728%209.14537%2015.3905%208.49023%2016.2077%208.49023Z'%20fill='url(%23paint3_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.402%2016.9363C19.402%2017.6636%2018.8059%2018.2533%2018.0704%2018.2533C17.3349%2018.2533%2016.7388%2017.6636%2016.7388%2016.9363C16.7388%2016.2089%2017.3349%2015.6191%2018.0704%2015.6191C18.8059%2015.6191%2019.402%2016.2089%2019.402%2016.9363Z'%20fill='url(%23paint4_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M24.6296%2015.6191C25.3649%2015.6191%2025.9611%2016.2089%2025.9611%2016.9363C25.9611%2017.6636%2025.3649%2018.2533%2024.6296%2018.2533C23.8942%2018.2533%2023.2979%2017.6636%2023.2979%2016.9363C23.2979%2016.2089%2023.8942%2015.6191%2024.6296%2015.6191Z'%20fill='url(%23paint5_linear_87227_8743)'/%3e%3cdefs%3e%3cradialGradient%20id='paint0_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(12.321%204.07031)%20rotate(90)%20scale(25.1081%2027.4541)'%3e%3cstop%20stop-color='%2395FF00'/%3e%3cstop%20offset='1'%20stop-color='%2369CC15'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(21.3441%2011.8984)%20rotate(90)%20scale(15.2975%2017.2945)'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23DFEAEB'/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint2_linear_87227_8743'%20x1='6.97168'%20y1='8.49023'%20x2='6.97168'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint3_linear_87227_8743'%20x1='14.728'%20y1='8.49023'%20x2='14.728'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint4_linear_87227_8743'%20x1='16.7388'%20y1='15.6191'%20x2='16.7388'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%235C7564'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint5_linear_87227_8743'%20x1='23.2979'%20y1='15.6191'%20x2='23.2979'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23607B68'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,C=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16%203C23.1797%203%2029%208.82027%2029%2016C29%2023.1796%2023.1797%2029%2016%2029C8.82027%2029%203%2023.1796%203%2016C3%208.82027%208.82027%203%2016%203ZM16.1243%2011.9418C18.3423%2011.9418%2020.1402%2013.7398%2020.1402%2015.9578C20.1402%2018.1756%2018.3423%2019.9737%2016.1243%2019.9737C13.9064%2019.9737%2012.1084%2018.1756%2012.1084%2015.9578C12.1084%2013.7398%2013.9064%2011.9418%2016.1243%2011.9418Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27.2082%2011.9995L19%2019.9898L27.3144%2019.9995C27.3144%2019.9995%2028.9256%2016.3089%2027.2082%2011.9995Z'%20fill='%235E9FF1'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27%2020.9995H15L21.0382%2026.9995C21.0382%2026.9995%2025.0194%2025.4292%2027%2020.9995Z'%20fill='%2367E4EE'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20%2027.1955L12.0097%2018.9995L12%2027.349C12%2027.349%2015.6906%2028.9102%2020%2027.1955Z'%20fill='%236DEE63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11%2026.9995V14.9995L5%2021.1662C5%2021.1662%206.63005%2025.0188%2011%2026.9995Z'%20fill='%23BEEE65'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M4.81275%2019.9995L13%2012.0092L4.62657%2011.9995C4.62657%2011.9995%203.09985%2015.6901%204.81275%2019.9995Z'%20fill='%23F0DC63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5%2010.9995H17L10.7953%204.99951C10.7953%204.99951%206.98064%206.62957%205%2010.9995Z'%20fill='%23EDB262'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%204.80358L19.9903%2012.9995L20%204.65008C20%204.65008%2016.3094%203.08878%2012%204.80358Z'%20fill='%23F1775B'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M21%204.99951V16.9995L27%2010.9995C27%2010.9995%2025.4298%206.9801%2021%204.99951Z'%20fill='%236961EC'/%3e%3c/svg%3e`,w=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.3485%202.17401C19.7864%200.611917%2017.2537%200.611917%2015.6916%202.17401L11.2336%206.63201L12.6478%208.04622L17.1058%203.58823C17.8869%202.80718%2019.1532%202.80718%2019.9343%203.58823L20.412%204.06598C21.1931%204.84703%2021.1931%206.11336%2020.412%206.89441L14.4202%2012.8863C13.6391%2013.6673%2012.3728%2013.6673%2011.5917%2012.8863L10.7628%2012.0573L9.3486%2013.4715L10.1775%2014.3005C11.7396%2015.8626%2014.2723%2015.8626%2015.8344%2014.3005L21.8262%208.30862C23.3883%206.74652%2023.3883%204.21386%2021.8262%202.65177L21.3485%202.17401ZM2.77902%2021.8258C4.34112%2023.3879%206.87378%2023.3879%208.43588%2021.8258L12.8913%2017.3704L11.4771%2015.9562L7.02166%2020.4116C6.24062%2021.1926%204.97429%2021.1926%204.19324%2020.4116L3.58798%2019.8063C2.80694%2019.0253%202.80694%2017.759%203.58798%2016.9779L9.57583%2010.9901C10.3569%2010.209%2011.6232%2010.209%2012.4043%2010.9901L13.3129%2011.8987L14.7271%2010.4845L13.8185%209.57586C12.2564%208.01376%209.72372%208.01376%208.16162%209.57586L2.17377%2015.5637C0.611673%2017.1258%200.611673%2019.6585%202.17377%2021.2206L2.77902%2021.8258Z'%20fill='%232B263B'/%3e%3c/svg%3e`,T=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%201H11V2V14.5858L5.70719%209.2929L4.29297%2010.7071L11.2223%2017.6365C11.6518%2018.066%2012.3483%2018.066%2012.7779%2017.6365L19.7072%2010.7071L18.293%209.2929L13%2014.5859V2V1H12ZM3.5%2020.5001V16.7501H1.5V20.5001C1.5%2021.6047%202.39543%2022.5001%203.5%2022.5001H20.5C21.6046%2022.5001%2022.5%2021.6047%2022.5%2020.5001V16.7501H20.5V20.5001H3.5Z'%20fill='%232B263B'/%3e%3c/svg%3e`,E=50,D=3e3;function O({dialog:e}){let[t,n]=(0,i.useState)(``),[r,a]=(0,i.useState)(``),[o,s]=(0,i.useState)(!0),c=r.trim().length>0;return(0,u.jsxs)(`div`,{className:`dmui-publish`,children:[(0,u.jsxs)(`div`,{className:`dmui-publish__nav`,children:[(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__back`,onClick:()=>e.onResult(!1),children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,children:(0,u.jsx)(`path`,{d:`M15 19l-7-7 7-7`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,u.jsxs)(`div`,{className:`dmui-publish__island-chip`,children:[e.islandImage?(0,u.jsx)(`img`,{className:`dmui-publish__chip-avatar`,src:e.islandImage,alt:``}):(0,u.jsx)(`div`,{className:`dmui-publish__chip-avatar dmui-publish__chip-avatar--placeholder`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-name`,children:e.islandName||`未命名岛`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-tag`,children:`岛`})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__submit${c?``:` dmui-publish__submit--disabled`}`,disabled:!c,onClick:()=>e.onResult(!0),children:`发布`})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__body`,children:[(0,u.jsx)(`div`,{className:`dmui-publish__images`,children:(0,u.jsx)(`div`,{className:`dmui-publish__image-add`,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,children:(0,u.jsx)(`path`,{d:`M12 5v14M5 12h14`,fill:`none`,stroke:`#999`,strokeWidth:`2`,strokeLinecap:`round`})})})}),(0,u.jsx)(`input`,{className:`dmui-publish__title`,placeholder:`标题 (50字以内)`,value:t,maxLength:E,onChange:e=>n(e.target.value)}),(0,u.jsx)(`textarea`,{className:`dmui-publish__content`,placeholder:`写下你的想法...`,value:r,maxLength:D,onChange:e=>a(e.target.value)})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__toolbar`,children:[(0,u.jsxs)(`span`,{className:`dmui-publish__count`,children:[r.length,`/`,D]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__privacy`,onClick:()=>s(!o),children:o?`公开`:`私密`})]})]})}function ee(){let[{toast:e,dialog:n},r]=(0,i.useState)(()=>t.getState());return(0,i.useEffect)(()=>t.subscribe(r),[]),(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)(k,{toast:e}),n?.kind===`modal`&&(0,u.jsx)(j,{dialog:n}),n?.kind===`actionSheet`&&(0,u.jsx)(M,{dialog:n}),n?.kind===`halfSheet`&&(0,u.jsx)(te,{dialog:n}),n?.kind===`capsuleMenu`&&(0,u.jsx)(ne,{dialog:n}),n?.kind===`share`&&(0,u.jsx)(P,{dialog:n}),n?.kind===`openPost`&&(0,u.jsx)(O,{dialog:n})]})}function k({toast:e}){(0,i.useEffect)(()=>{if(!Number.isFinite(e.duration))return;let n=window.setTimeout(()=>t.dismissToast(e),e.duration);return()=>window.clearTimeout(n)},[e]);let n=e.icon!==`none`||!!e.image;return(0,u.jsxs)(`div`,{className:`dmui-overlay`,"aria-live":`polite`,children:[e.mask&&(0,u.jsx)(`div`,{className:`dmui-mask dmui-mask--transparent`}),(0,u.jsxs)(`div`,{className:`dmui-toast${n?``:` dmui-toast--text`}`,role:`alert`,children:[e.image?(0,u.jsx)(`img`,{className:`dmui-toast__image`,src:e.image,alt:``}):(0,u.jsx)(A,{icon:e.icon}),e.title&&(0,u.jsx)(`div`,{className:`dmui-toast__title`,children:e.title})]})]})}function A({icon:e}){return e===`success`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M5 13l4 4L19 7`})}):e===`error`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})}):e===`loading`?(0,u.jsx)(`span`,{className:`dmui-toast__spinner`,"aria-hidden":`true`}):null}function j({dialog:e}){let[t,n]=(0,i.useState)(``),r=(0,i.useRef)(null);return(0,i.useEffect)(()=>{e.editable&&r.current?.focus()},[e.editable]),(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`}),(0,u.jsxs)(`div`,{className:`dmui-modal`,role:`dialog`,"aria-modal":`true`,children:[e.title&&(0,u.jsx)(`div`,{className:`dmui-modal__title`,children:e.title}),e.editable?(0,u.jsx)(`input`,{ref:r,className:`dmui-modal__input`,value:t,placeholder:e.placeholderText,onChange:e=>n(e.target.value)}):e.content&&(0,u.jsx)(`div`,{className:`dmui-modal__content`,children:e.content}),(0,u.jsxs)(`div`,{className:`dmui-modal__actions`,children:[e.showCancel&&(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.cancelColor},onClick:()=>e.onResult(!1),children:e.cancelText}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.confirmColor},onClick:()=>e.onResult(!0,t),children:e.confirmText})]})]})]})}function M({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-action-sheet`,role:`menu`,children:[(0,u.jsx)(`div`,{className:`dmui-action-sheet__items`,children:e.itemList.map((t,n)=>(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__item`,style:{color:e.itemColor},onClick:()=>e.onSelect(n),children:t},n))}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function te({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onResult(!1)}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__title`,children:`加入岛即可发布讨论`}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__row`,children:[e.islandAvatar&&(0,u.jsx)(`img`,{className:`dmui-half-sheet__avatar`,src:e.islandAvatar,alt:``}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__info`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__name`,children:e.islandName}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__members`,children:[e.memberCount,`人加入`]})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__join`,onClick:()=>e.onResult(!0),children:`加入`})]}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__cancel`,onClick:()=>e.onResult(!1),children:`取消`})]})]})}function ne({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__header`,children:[e.appAvatar?(0,u.jsx)(`img`,{className:`dmui-capsule-menu__avatar`,src:e.appAvatar,alt:``}):(0,u.jsx)(`div`,{className:`dmui-capsule-menu__avatar dmui-capsule-menu__avatar--placeholder`}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-info`,children:[(0,u.jsx)(`div`,{className:`dmui-capsule-menu__app-name`,children:e.appName}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-version`,children:[`V`,e.appVersion]})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__grid`,children:e.items.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:t.icon}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n))}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}var N=[{label:`微信`,icon:S},{label:`朋友圈`,icon:C}];function P({dialog:e}){let t=e.type===`image`?{label:`保存图片`,icon:T}:{label:`复制链接`,icon:w};return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__title`,children:`分享到`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet__grid`,children:[N.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n)),(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(N.length),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function F(e,n){let r={kind:`capsuleMenu`,appName:n||`小程序`,appAvatar:``,appVersion:`1.0.0`,items:[{label:`复制链接`,icon:`🔗`}],onSelect(n){n===0&&navigator.clipboard.writeText(`https://qiandao.com/miniapp?appId=${e}`),t.hideDialog()}};t.showDialog(r)}function I(e){if(!e)return{config:null,visible:!1,badges:[],redDots:[]};let t=e.list.length;return{config:L(e),visible:!0,badges:Array.from({length:t},()=>``),redDots:Array.from({length:t},()=>!1)}}function L(e){return{...e,list:e.list.map(e=>({...e}))}}function R(e,t){switch(t.kind){case`reset`:return{state:I(t.config),ok:!0,errMsg:`reset:ok`};case`visibility`:return{state:{...e,visible:t.visible},ok:!0,errMsg:t.visible?`showTabBar:ok`:`hideTabBar:ok`};case`apply`:return z(e,t.name,t.params)}}function z(e,t,n){if(!e.config)return{state:e,ok:!1,errMsg:`${t}:fail tabBar not configured`};switch(t){case`setTabBarStyle`:return B(e,n);case`setTabBarItem`:return V(e,n);case`showTabBar`:return{state:{...e,visible:!0},ok:!0,errMsg:`showTabBar:ok`};case`hideTabBar`:return{state:{...e,visible:!1},ok:!0,errMsg:`hideTabBar:ok`};case`setTabBarBadge`:return H(e,n);case`removeTabBarBadge`:return U(e,n);case`showTabBarRedDot`:return W(e,n,!0);case`hideTabBarRedDot`:return W(e,n,!1)}}function B(e,t){if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarStyle:fail tabBar not configured`};let n={...e.config},r=(e,t)=>{let r=K(t);r&&(n[e]=r)};return r(`color`,t.color),r(`selectedColor`,t.selectedColor),r(`backgroundColor`,t.backgroundColor),(t.borderStyle===`black`||t.borderStyle===`white`)&&(n.borderStyle=t.borderStyle),{state:{...e,config:n},ok:!0,errMsg:`setTabBarStyle:ok`}}function V(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarItem:fail ${n.err}`};if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarItem:fail tabBar not configured`};let r=e.config.list[n.index],i={...r,text:typeof t.text==`string`?t.text:r.text,iconPath:typeof t.iconPath==`string`?t.iconPath:r.iconPath,selectedIconPath:typeof t.selectedIconPath==`string`?t.selectedIconPath:r.selectedIconPath},a=[...e.config.list];return a[n.index]=i,{state:{...e,config:{...e.config,list:a}},ok:!0,errMsg:`setTabBarItem:ok`}}function H(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarBadge:fail ${n.err}`};let r=[...e.badges];r[n.index]=String(t.text??``);let i=[...e.redDots];return i[n.index]=!1,{state:{...e,badges:r,redDots:i},ok:!0,errMsg:`setTabBarBadge:ok`}}function U(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`removeTabBarBadge:fail ${n.err}`};let r=[...e.badges];return r[n.index]=``,{state:{...e,badges:r},ok:!0,errMsg:`removeTabBarBadge:ok`}}function W(e,t,n){let r=G(e,t);if(r.err)return{state:e,ok:!1,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:fail ${r.err}`};let i=[...e.redDots];i[r.index]=n;let a=[...e.badges];return n&&(a[r.index]=``),{state:{...e,redDots:i,badges:a},ok:!0,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:ok`}}function G(e,t){let n=e.config?.list??[],r=t.index,i=Number(r);return n.length?r==null||!Number.isInteger(i)||i<0||i>=n.length?{index:-1,err:`invalid index ${r}`}:{index:i,err:null}:{index:-1,err:`tabBar not configured`}}function K(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>64?null:/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:null:t}function q(e){return e?e.replace(/^\/+/,``):``}function J(e){if(!e)return null;let t=e.indexOf(`=`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``;return n?[decodeURIComponent(n),decodeURIComponent(r)]:null}function Y(e){let t={};for(let n of e.split(`&`)){let e=J(n);e&&(t[e[0]]=e[1])}return t}function X(e){let[t,n]=(typeof e==`string`?e:``).split(`?`);return{pagePath:q(t),query:n?Y(n):{}}}function Z(e){let t={};return e.isTab&&(t[e.pagePath]=[e]),{stack:[e],tabStacks:t,currentTabPath:e.isTab?e.pagePath:null}}function re(e){return e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:[...e.stack]}:e.tabStacks}function ie(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack,t];return{next:{...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},effects:n?[{kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageHide`}]:[]}}function ae(e,t){if(e.stack.length<=1)return{error:`no page to back`};let n=Math.min(Math.max(1,Number.isFinite(t)?t:1),e.stack.length-1),r=e.stack.slice(e.stack.length-n),i=e.stack.slice(0,e.stack.length-n),a=i[i.length-1],o={...e,stack:i,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:i}:e.tabStacks,currentTabPath:a.isTab?a.pagePath:e.currentTabPath},s=[];for(let e of r)s.push({kind:`lifecycle`,bridgeId:e.bridgeId,event:`pageUnload`}),s.push({kind:`closePage`,bridgeId:e.bridgeId});return s.push({kind:`lifecycle`,bridgeId:a.bridgeId,event:`pageShow`}),{next:o,effects:s}}function oe(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack.slice(0,e.stack.length-1),t],i={...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},a=[];return n&&(a.push({kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:n.bridgeId})),{next:i,effects:a}}function se(e,t){let n=new Set;for(let t of e.stack)n.add(t.bridgeId);for(let t of Object.values(e.tabStacks))for(let e of t)n.add(e.bridgeId);n.delete(t.bridgeId);let r=t.isTab?{[t.pagePath]:[t]}:{},i={stack:[t],tabStacks:r,currentTabPath:t.isTab?t.pagePath:null},a=[];for(let e of n)a.push({kind:`lifecycle`,bridgeId:e,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:e});return{next:i,effects:a}}function ce(e,t,n){let r=e.stack[e.stack.length-1],i=re(e),a,o=i[t];if(o&&o.length>0)a=o;else if(n)a=[n];else throw Error(`[page-stack] switchTab to ${t} requires either a cached substack or a freshly-opened entry`);let s={...e,stack:a,tabStacks:{...i,[t]:a},currentTabPath:t},c=a[a.length-1],l=[];return r&&r.bridgeId!==c.bridgeId&&l.push({kind:`lifecycle`,bridgeId:r.bridgeId,event:`pageHide`}),n||l.push({kind:`lifecycle`,bridgeId:c.bridgeId,event:`pageShow`}),{next:s,effects:l}}function le(e){let t=new Map,n=e.stack[e.stack.length-1]?.bridgeId,r=e=>{t.has(e.bridgeId)||t.set(e.bridgeId,{entry:e,visible:e.bridgeId===n})};for(let t of Object.values(e.tabStacks))for(let e of t)r(e);for(let t of e.stack)r(t);return Array.from(t.values())}function Q(e,t){let n=e.navigationBarBackgroundColor??`#ffffff`,r=e.navigationBarTextStyle??`black`,i=e.navigationStyle??`default`;return h({title:e.navigationBarTitleText??t,backgroundColor:n,textStyle:r,style:i,homeButtonVisible:e.homeButton===!0})}function ue(e,t,n){switch(t){case`setNavigationBarTitle`:return{...e,title:typeof n.title==`string`?n.title:e.title};case`setNavigationBarColor`:return fe(e,n);case`showNavigationBarLoading`:return{...e,loading:!0};case`hideNavigationBarLoading`:return{...e,loading:!1};case`hideHomeButton`:return{...e,homeButtonVisible:!1};default:return e}}var de=[`linear`,`easeIn`,`easeOut`,`easeInOut`];function fe(e,t){let n=typeof t.frontColor==`string`?t.frontColor.toLowerCase():void 0,r=n===`#ffffff`?`white`:n===`#000000`?`black`:e.textStyle,i=typeof t.backgroundColor==`string`?t.backgroundColor:e.backgroundColor,a=(()=>{let e=t.animation;if(!e||typeof e!=`object`)return;let n=e,r=typeof n.duration==`number`&&Number.isFinite(n.duration)?Math.max(0,n.duration):0,i=typeof n.timingFunc==`string`?n.timingFunc:`linear`;return{durationMs:r,timingFunc:de.includes(i)?i:`linear`}})();return{...e,textStyle:r,backgroundColor:i,colorAnimation:a}}function pe(e,t,n){let r=e=>e.bridgeId===t?{...e,navBar:n(e.navBar)}:e,i=e.stack.map(r),a={};for(let[t,n]of Object.entries(e.tabStacks))a[t]=n.map(r);return{...e,stack:i,tabStacks:a}}var $=44,me=24,he=44;function ge({miniApp:e,bridgeId:t,platform:n=`ios`}){let[a,o]=(0,i.useState)(()=>e.getInitialDevice());(0,i.useEffect)(()=>e.onSimulatorEvent(r.DEVICE_CHANGE,o),[e]);let c=a?.safeAreaInsets.top??(n===`ios`?$:me),l=a?.safeAreaInsets.bottom??0,d=a?.notchType??`none`,f=(0,i.useMemo)(()=>e.getRenderPreloadUrl(),[e]),p=(0,i.useMemo)(()=>e.getTabBarConfig(),[e]),h=(0,i.useMemo)(()=>({bridgeId:t,pagePath:q(e.pagePath),query:{...e.query},isTab:!!e.getTabBarConfig()?.list.some(t=>q(t.pagePath)===q(e.pagePath)),windowConfig:e.rootWindowConfig??{},navBar:Q(e.rootWindowConfig??{},e.appId)}),[e,t]),[{shell:g,tabBar:y},b]=(0,i.useState)(()=>({shell:Z(h),tabBar:I(p)})),x=(0,i.useRef)({shell:g,tabBar:y});(0,i.useEffect)(()=>{x.current={shell:g,tabBar:y}},[g,y]);let S=(0,i.useCallback)(t=>{for(let n of t)n.kind===`lifecycle`?e.notifyLifecycle(n.bridgeId,n.event):n.kind===`closePage`&&e.closePage(n.bridgeId)},[e]);(0,i.useEffect)(()=>e.onSimulatorEvent(r.NAV_BAR,e=>{b(t=>({...t,shell:pe(t.shell,e.bridgeId,t=>ue(t,e.name,e.params))}))}),[e]),(0,i.useEffect)(()=>e.onSessionEvent(r.TAB_ACTION,t=>{let n=R(x.current.tabBar,{kind:`apply`,name:t.name,params:t.params});b(e=>({...e,tabBar:n.state})),e.notifyNavCallback({ok:n.ok,errMsg:n.errMsg,callbacks:t.callbacks})}),[e]);let C=(0,i.useCallback)(async t=>{let n=(n,r)=>e.notifyNavCallback({ok:n,errMsg:r,callbacks:t.callbacks});try{switch(t.name){case`navigateTo`:await _e(e,x,b,S,t,n);break;case`navigateBack`:ve(x,b,S,t,n);break;case`redirectTo`:await ye(e,x,b,S,t,n);break;case`reLaunch`:await be(e,x,b,S,t,n);break;case`switchTab`:await xe(e,x,b,S,t,n);break}}catch(e){n(!1,`${t.name}:fail ${e instanceof Error?e.message:String(e)}`)}},[e,S]);(0,i.useEffect)(()=>e.onSessionEvent(r.NAV_ACTION,e=>{C(e)}),[C,e]),(0,i.useEffect)(()=>e.onSessionEvent(r.API_CALL,t=>{s(e,t.name,t.params,n=>{e.notifyApiResponse({requestId:t.requestId,ok:n.ok,result:n.result,errMsg:n.errMsg,keep:n.keep})})}),[e]);let w=(0,i.useCallback)(()=>{if(x.current.shell.stack.length<=1)return;let t=x.current.shell.stack;C({appSessionId:e.appSessionId??``,bridgeId:t[t.length-1].bridgeId,name:`navigateBack`,params:{delta:1},callbacks:{}})},[e,C]),T=(0,i.useCallback)(t=>{let n=x.current.shell;t===n.currentTabPath&&n.stack.length===1||C({appSessionId:e.appSessionId??``,bridgeId:n.stack[n.stack.length-1].bridgeId,name:`switchTab`,params:{url:`/${t}`},callbacks:{}})},[e,C]),E=(0,i.useCallback)(()=>{let t=x.current.shell.stack;F(e.appId,t[t.length-1].navBar.title)},[e]),D=g.stack[g.stack.length-1],O=le(g);return(0,i.useEffect)(()=>{e.notifyActivePage(D.bridgeId)},[e,D.bridgeId]),(0,i.useEffect)(()=>{e.notifyPageStack(g.stack.map(e=>({pagePath:e.pagePath,query:e.query})))},[e,g.stack]),(0,u.jsx)(`main`,{className:`device-shell-root`,children:(0,u.jsxs)(`section`,{className:`device-shell`,"aria-label":`Dimina simulator`,style:a?{width:a.screenWidth,height:a.screenHeight}:void 0,children:[(0,u.jsx)(_,{height:c,notchType:d,textStyle:D.navBar.textStyle}),(0,u.jsx)(m,{state:D.navBar,stackDepth:g.stack.length,platform:n,statusBarHeight:c,navBarHeight:he,onBack:w,onMoreClick:E}),(0,u.jsx)(`div`,{className:`device-shell__viewport`,children:O.map(({entry:t,visible:n})=>(0,u.jsx)(`webview`,{className:`device-shell__webview`,src:e.createRenderHostUrl(t.bridgeId,t.pagePath,t.isTab),preload:f,allowpopups:`true`,style:{display:n?`flex`:`none`,zIndex:n?100:1}},t.bridgeId))}),D.isTab&&(0,u.jsx)(v,{state:y,currentPath:g.currentTabPath,resourceBaseUrl:e.resourceBaseUrl,appId:e.appId,onSwitch:T,bottomInset:l}),(0,u.jsx)(ee,{}),l>0&&(0,u.jsx)(`div`,{className:`device-shell__home-indicator`,style:{height:l},"aria-hidden":`true`})]})})}async function _e(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`navigateTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`navigateTo:fail can not navigateTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=ie(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`navigateTo:ok`)}function ve(e,t,n,r,i){let a=r.params.delta,o=Number.isFinite(Number(a))?Number(a):1,s=ae(e.current.shell,o);if(`error`in s){i(!1,`navigateBack:fail ${s.error}`);return}t(e=>({...e,shell:s.next})),n(s.effects),i(!0,`navigateBack:ok`)}async function ye(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`redirectTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`redirectTo:fail can not redirectTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=oe(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`redirectTo:ok`)}async function be(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`reLaunch:fail invalid url`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=se(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`reLaunch:ok`)}async function xe(e,t,n,r,i,a){let{pagePath:o}=X(i.params.url);if(!o){a(!1,`switchTab:fail invalid url`);return}if(!e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`switchTab:fail not a tabBar page: ${o}`);return}let s=t.current.shell.tabStacks[o],c=null;if(!s||s.length===0){let t=await e.openPage(o,{});c={bridgeId:t.bridgeId,pagePath:t.pagePath,query:{},isTab:!0,windowConfig:t.windowConfig,navBar:Q(t.windowConfig,e.appId)}}let{next:l,effects:u}=ce(t.current.shell,o,c);n(e=>({...e,shell:l})),r(u),a(!0,`switchTab:ok`)}export{ge as DeviceShell};
|
|
2
|
-
//# sourceMappingURL=device-shell-
|
|
1
|
+
import{i as e,n as t,t as n}from"./jsx-runtime-BDTY6fEq.js";import{t as r}from"./bridge-channels-zhsumfky.js";var i=e(),a=new Set([`audioListen`]);function o(e){return a.has(e)}function s(e,t,n,r){let i=e.apiRegistry[t];if(!i)return r({ok:!1,errMsg:`${t}:fail no handler`}),Promise.resolve();let a=o(t)||(n&&typeof n==`object`&&!Array.isArray(n)?n.keep===!0:!1);return new Promise(o=>{let s=!1,c=e=>{if(s){a&&e.ok&&r({...e,keep:!0});return}s=!0,r(a&&e.ok?{...e,keep:!0}:e),o()},l=Symbol(`sim-cb-success`),u=Symbol(`sim-cb-fail`),d=Symbol(`sim-cb-complete`),f=!1,p=Object.create(e);p.createCallbackFunction=e=>{if(e!=null)return(e===l||e===u)&&(f=!0),(...n)=>{let r=n[0];e===l?c({ok:!0,result:r}):e===u?c({ok:!1,errMsg:r&&typeof r==`object`&&`errMsg`in r?String(r.errMsg):`${t}:fail`,result:r}):e===d&&!a&&c({ok:!0,result:r})}};let m=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:{};m.success=l,m.fail=u,m.complete=d;try{let e=i.call(p,m);if(e&&typeof e.then==`function`){Promise.resolve(e).then(e=>c({ok:!0,result:e}),e=>{c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})});return}if(s)return;if(a){o();return}if(f){o();return}c({ok:!0,result:e})}catch(e){c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})}})}var c={ios:44,android:64};function l(e){return(c[e]-32)/2}var u=n();function d({platform:e,statusBarHeight:t,onMoreClick:n}){return(0,u.jsxs)(`div`,{className:`menu-capsule`,style:{width:87,height:32,top:t+l(e),right:10},"aria-hidden":`true`,children:[(0,u.jsxs)(`div`,{className:`menu-capsule__more`,onClick:n,children:[(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--mid`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`})]}),(0,u.jsx)(`div`,{className:`menu-capsule__divider`}),(0,u.jsx)(`div`,{className:`menu-capsule__close`,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 22 22`,width:`22`,height:`22`,"aria-hidden":`true`,children:[(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7.8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`}),(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`3.1`,fill:`currentColor`})]})})]})}var f={linear:`linear`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`},p={ios:`M17.51 3.87L15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z`,android:`M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z`};function m({state:e,stackDepth:t,platform:n,statusBarHeight:r,navBarHeight:a,onBack:o,onHome:s,onMoreClick:c}){let l=(0,i.useMemo)(()=>{if(!e.colorAnimation||e.colorAnimation.durationMs<=0)return;let t=f[e.colorAnimation.timingFunc]??`linear`;return`background-color ${e.colorAnimation.durationMs}ms ${t}, color ${e.colorAnimation.durationMs}ms ${t}`},[e.colorAnimation]),m=e.style===`custom`,h=t>1,g=!h&&e.homeButtonVisible,_=n===`ios`?`center`:`left`,v=n===`android`?30:24,y={backgroundColor:e.backgroundColor,color:e.textStyle===`white`?`#ffffff`:`#000000`,height:r+a,paddingTop:r,transition:l};return(0,u.jsxs)(`header`,{className:`nav-bar nav-bar--${n} nav-bar--${e.textStyle}${m?` nav-bar--custom`:``}`,style:y,"aria-hidden":m,children:[!m&&(0,u.jsxs)(`div`,{className:`nav-bar__row`,style:{height:a,justifyContent:_===`center`?`center`:`flex-start`},children:[(h||g)&&(0,u.jsxs)(`div`,{className:`nav-bar__leading`,children:[h&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__back`,"aria-label":`Back`,onClick:o,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:v,height:v,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:p[n],fill:`currentColor`})})}),g&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__home`,"aria-label":`Home`,onClick:s,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M3 12l9-9 9 9M5 10v10h14V10`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(0,u.jsxs)(`div`,{className:`nav-bar__title nav-bar__title--${_}`,style:{color:e.textStyle===`white`?`#ffffff`:`#000000`},children:[e.loading&&(0,u.jsx)(`span`,{className:`nav-bar__spinner`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`nav-bar__title-text`,children:e.title})]})]}),(0,u.jsx)(d,{platform:n,statusBarHeight:r,onMoreClick:c})]})}function h(e){return{title:e?.title??``,backgroundColor:e?.backgroundColor??`#000000`,textStyle:e?.textStyle??`white`,style:e?.style??`default`,loading:e?.loading??!1,homeButtonVisible:e?.homeButtonVisible??!1,colorAnimation:e?.colorAnimation}}function g(e){switch(e){case`notch`:return{width:164,height:30,top:0,bottomOnly:!0};case`dynamic-island`:return{width:124,height:36,top:11,bottomOnly:!1};default:return null}}function _({height:e,notchType:t,textStyle:n}){let r=g(t);return(0,u.jsxs)(`div`,{className:`device-statusbar`,style:{height:e,color:n===`black`?`#000000`:`#ffffff`},"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__time`,children:`9:41`}),r&&(0,u.jsx)(`div`,{className:`device-statusbar__notch`,style:{width:r.width,height:r.height,top:r.top,borderRadius:r.bottomOnly?`0 0 ${Math.round(r.height*.6)}px ${Math.round(r.height*.6)}px`:`${r.height/2}px`}}),(0,u.jsxs)(`div`,{className:`device-statusbar__icons`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__signal`}),(0,u.jsx)(`span`,{className:`device-statusbar__wifi`}),(0,u.jsx)(`span`,{className:`device-statusbar__battery`})]})]})}function v({state:e,currentPath:t,resourceBaseUrl:n,appId:r,onSwitch:i,bottomInset:a=0}){if(!e.config||!e.visible)return null;let{color:o,selectedColor:s,backgroundColor:c,borderStyle:l,list:d}=e.config,f=o||`#999999`,p=s||`#1890ff`;return(0,u.jsx)(`div`,{className:`dmb-tab-bar`,style:{backgroundColor:c||`#ffffff`,borderTopColor:l===`white`?`#ffffff`:`#e0e0e0`,paddingBottom:a},role:`tablist`,"aria-label":`TabBar`,children:d.map((a,o)=>{let s=y(a.pagePath),c=s===t,l=b(c?a.selectedIconPath??a.iconPath:a.iconPath,n,r),d=e.badges[o]??``,m=e.redDots[o]??!1;return(0,u.jsxs)(`button`,{type:`button`,className:`dmb-tab-bar__item${c?` is-selected`:``}`,role:`tab`,"aria-selected":c,onClick:()=>i(s),children:[l&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__icon-slot`,children:(0,u.jsx)(`img`,{className:`dmb-tab-bar__icon`,src:l,alt:``,onError:e=>{e.currentTarget.style.display=`none`}})}),(0,u.jsx)(`span`,{className:`dmb-tab-bar__text`,style:{color:c?p:f},children:a.text||``}),d&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__badge`,children:d}),!d&&m&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__red-dot`})]},`${s}-${o}`)})})}function y(e){return e?e.replace(/^\/+/,``):``}function b(e,t,n){if(!e)return null;let r=e.trim();if(!r)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(r))return r;if(!t)return null;let i=r.replace(/^\/+/,``).replace(/^\.\//,``);return i.startsWith(`${n}/`)?x(t,i):x(t,`${n}/main/${i}`)}function x(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t.replace(/^\/+/,``)}`}var S=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M23.1221%2013.3855C23.1221%2018.5302%2018.2862%2022.7007%2012.321%2022.7007C10.9486%2022.7007%209.63581%2022.48%208.42807%2022.0774C7.60996%2022.48%204.89408%2023.8264%204.89408%2023.8264C4.89408%2023.8264%205.25692%2022.0774%205.51715%2020.6206C3.07834%2018.9126%201.52002%2016.306%201.52002%2013.3855C1.52002%208.241%206.35572%204.07031%2012.321%204.07031C18.2862%204.07031%2023.1221%208.241%2023.1221%2013.3855Z'%20fill='url(%23paint0_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.2446%2019.4912C12.2446%2023.6844%2016.326%2027.0838%2021.3605%2027.0838C22.5189%2027.0838%2023.6267%2026.9038%2024.646%2026.5756C25.4567%2026.9038%2027.6286%2028.0012%2027.6286%2028.0012C27.6286%2028.0012%2027.3134%2026.3862%2027.103%2025.3882C29.1612%2023.9961%2030.4764%2021.8715%2030.4764%2019.4912C30.4764%2015.2977%2026.3951%2011.8984%2021.3605%2011.8984C16.326%2011.8984%2012.2446%2015.2977%2012.2446%2019.4912Z'%20fill='url(%23paint1_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.45121%208.49023C9.2684%208.49023%209.93086%209.14537%209.93086%209.95365C9.93086%2010.7618%209.2684%2011.4171%208.45121%2011.4171C7.63403%2011.4171%206.97168%2010.7618%206.97168%209.95365C6.97168%209.14537%207.63403%208.49023%208.45121%208.49023Z'%20fill='url(%23paint2_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.2077%208.49023C17.0247%208.49023%2017.6872%209.14537%2017.6872%209.95365C17.6872%2010.7618%2017.0247%2011.4171%2016.2077%2011.4171C15.3905%2011.4171%2014.728%2010.7618%2014.728%209.95365C14.728%209.14537%2015.3905%208.49023%2016.2077%208.49023Z'%20fill='url(%23paint3_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.402%2016.9363C19.402%2017.6636%2018.8059%2018.2533%2018.0704%2018.2533C17.3349%2018.2533%2016.7388%2017.6636%2016.7388%2016.9363C16.7388%2016.2089%2017.3349%2015.6191%2018.0704%2015.6191C18.8059%2015.6191%2019.402%2016.2089%2019.402%2016.9363Z'%20fill='url(%23paint4_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M24.6296%2015.6191C25.3649%2015.6191%2025.9611%2016.2089%2025.9611%2016.9363C25.9611%2017.6636%2025.3649%2018.2533%2024.6296%2018.2533C23.8942%2018.2533%2023.2979%2017.6636%2023.2979%2016.9363C23.2979%2016.2089%2023.8942%2015.6191%2024.6296%2015.6191Z'%20fill='url(%23paint5_linear_87227_8743)'/%3e%3cdefs%3e%3cradialGradient%20id='paint0_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(12.321%204.07031)%20rotate(90)%20scale(25.1081%2027.4541)'%3e%3cstop%20stop-color='%2395FF00'/%3e%3cstop%20offset='1'%20stop-color='%2369CC15'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(21.3441%2011.8984)%20rotate(90)%20scale(15.2975%2017.2945)'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23DFEAEB'/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint2_linear_87227_8743'%20x1='6.97168'%20y1='8.49023'%20x2='6.97168'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint3_linear_87227_8743'%20x1='14.728'%20y1='8.49023'%20x2='14.728'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint4_linear_87227_8743'%20x1='16.7388'%20y1='15.6191'%20x2='16.7388'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%235C7564'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint5_linear_87227_8743'%20x1='23.2979'%20y1='15.6191'%20x2='23.2979'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23607B68'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,C=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16%203C23.1797%203%2029%208.82027%2029%2016C29%2023.1796%2023.1797%2029%2016%2029C8.82027%2029%203%2023.1796%203%2016C3%208.82027%208.82027%203%2016%203ZM16.1243%2011.9418C18.3423%2011.9418%2020.1402%2013.7398%2020.1402%2015.9578C20.1402%2018.1756%2018.3423%2019.9737%2016.1243%2019.9737C13.9064%2019.9737%2012.1084%2018.1756%2012.1084%2015.9578C12.1084%2013.7398%2013.9064%2011.9418%2016.1243%2011.9418Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27.2082%2011.9995L19%2019.9898L27.3144%2019.9995C27.3144%2019.9995%2028.9256%2016.3089%2027.2082%2011.9995Z'%20fill='%235E9FF1'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27%2020.9995H15L21.0382%2026.9995C21.0382%2026.9995%2025.0194%2025.4292%2027%2020.9995Z'%20fill='%2367E4EE'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20%2027.1955L12.0097%2018.9995L12%2027.349C12%2027.349%2015.6906%2028.9102%2020%2027.1955Z'%20fill='%236DEE63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11%2026.9995V14.9995L5%2021.1662C5%2021.1662%206.63005%2025.0188%2011%2026.9995Z'%20fill='%23BEEE65'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M4.81275%2019.9995L13%2012.0092L4.62657%2011.9995C4.62657%2011.9995%203.09985%2015.6901%204.81275%2019.9995Z'%20fill='%23F0DC63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5%2010.9995H17L10.7953%204.99951C10.7953%204.99951%206.98064%206.62957%205%2010.9995Z'%20fill='%23EDB262'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%204.80358L19.9903%2012.9995L20%204.65008C20%204.65008%2016.3094%203.08878%2012%204.80358Z'%20fill='%23F1775B'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M21%204.99951V16.9995L27%2010.9995C27%2010.9995%2025.4298%206.9801%2021%204.99951Z'%20fill='%236961EC'/%3e%3c/svg%3e`,w=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.3485%202.17401C19.7864%200.611917%2017.2537%200.611917%2015.6916%202.17401L11.2336%206.63201L12.6478%208.04622L17.1058%203.58823C17.8869%202.80718%2019.1532%202.80718%2019.9343%203.58823L20.412%204.06598C21.1931%204.84703%2021.1931%206.11336%2020.412%206.89441L14.4202%2012.8863C13.6391%2013.6673%2012.3728%2013.6673%2011.5917%2012.8863L10.7628%2012.0573L9.3486%2013.4715L10.1775%2014.3005C11.7396%2015.8626%2014.2723%2015.8626%2015.8344%2014.3005L21.8262%208.30862C23.3883%206.74652%2023.3883%204.21386%2021.8262%202.65177L21.3485%202.17401ZM2.77902%2021.8258C4.34112%2023.3879%206.87378%2023.3879%208.43588%2021.8258L12.8913%2017.3704L11.4771%2015.9562L7.02166%2020.4116C6.24062%2021.1926%204.97429%2021.1926%204.19324%2020.4116L3.58798%2019.8063C2.80694%2019.0253%202.80694%2017.759%203.58798%2016.9779L9.57583%2010.9901C10.3569%2010.209%2011.6232%2010.209%2012.4043%2010.9901L13.3129%2011.8987L14.7271%2010.4845L13.8185%209.57586C12.2564%208.01376%209.72372%208.01376%208.16162%209.57586L2.17377%2015.5637C0.611673%2017.1258%200.611673%2019.6585%202.17377%2021.2206L2.77902%2021.8258Z'%20fill='%232B263B'/%3e%3c/svg%3e`,T=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%201H11V2V14.5858L5.70719%209.2929L4.29297%2010.7071L11.2223%2017.6365C11.6518%2018.066%2012.3483%2018.066%2012.7779%2017.6365L19.7072%2010.7071L18.293%209.2929L13%2014.5859V2V1H12ZM3.5%2020.5001V16.7501H1.5V20.5001C1.5%2021.6047%202.39543%2022.5001%203.5%2022.5001H20.5C21.6046%2022.5001%2022.5%2021.6047%2022.5%2020.5001V16.7501H20.5V20.5001H3.5Z'%20fill='%232B263B'/%3e%3c/svg%3e`,E=50,D=3e3;function O({dialog:e}){let[t,n]=(0,i.useState)(``),[r,a]=(0,i.useState)(``),[o,s]=(0,i.useState)(!0),c=r.trim().length>0;return(0,u.jsxs)(`div`,{className:`dmui-publish`,children:[(0,u.jsxs)(`div`,{className:`dmui-publish__nav`,children:[(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__back`,onClick:()=>e.onResult(!1),children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,children:(0,u.jsx)(`path`,{d:`M15 19l-7-7 7-7`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,u.jsxs)(`div`,{className:`dmui-publish__island-chip`,children:[e.islandImage?(0,u.jsx)(`img`,{className:`dmui-publish__chip-avatar`,src:e.islandImage,alt:``}):(0,u.jsx)(`div`,{className:`dmui-publish__chip-avatar dmui-publish__chip-avatar--placeholder`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-name`,children:e.islandName||`未命名岛`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-tag`,children:`岛`})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__submit${c?``:` dmui-publish__submit--disabled`}`,disabled:!c,onClick:()=>e.onResult(!0),children:`发布`})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__body`,children:[(0,u.jsx)(`div`,{className:`dmui-publish__images`,children:(0,u.jsx)(`div`,{className:`dmui-publish__image-add`,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,children:(0,u.jsx)(`path`,{d:`M12 5v14M5 12h14`,fill:`none`,stroke:`#999`,strokeWidth:`2`,strokeLinecap:`round`})})})}),(0,u.jsx)(`input`,{className:`dmui-publish__title`,placeholder:`标题 (50字以内)`,value:t,maxLength:E,onChange:e=>n(e.target.value)}),(0,u.jsx)(`textarea`,{className:`dmui-publish__content`,placeholder:`写下你的想法...`,value:r,maxLength:D,onChange:e=>a(e.target.value)})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__toolbar`,children:[(0,u.jsxs)(`span`,{className:`dmui-publish__count`,children:[r.length,`/`,D]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__privacy`,onClick:()=>s(!o),children:o?`公开`:`私密`})]})]})}function ee(){let[{toast:e,dialog:n},r]=(0,i.useState)(()=>t.getState());return(0,i.useEffect)(()=>t.subscribe(r),[]),(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)(k,{toast:e}),n?.kind===`modal`&&(0,u.jsx)(j,{dialog:n}),n?.kind===`actionSheet`&&(0,u.jsx)(M,{dialog:n}),n?.kind===`halfSheet`&&(0,u.jsx)(N,{dialog:n}),n?.kind===`capsuleMenu`&&(0,u.jsx)(te,{dialog:n}),n?.kind===`share`&&(0,u.jsx)(ne,{dialog:n}),n?.kind===`openPost`&&(0,u.jsx)(O,{dialog:n})]})}function k({toast:e}){(0,i.useEffect)(()=>{if(!Number.isFinite(e.duration))return;let n=window.setTimeout(()=>t.dismissToast(e),e.duration);return()=>window.clearTimeout(n)},[e]);let n=e.icon!==`none`||!!e.image;return(0,u.jsxs)(`div`,{className:`dmui-overlay`,"aria-live":`polite`,children:[e.mask&&(0,u.jsx)(`div`,{className:`dmui-mask dmui-mask--transparent`}),(0,u.jsxs)(`div`,{className:`dmui-toast${n?``:` dmui-toast--text`}`,role:`alert`,children:[e.image?(0,u.jsx)(`img`,{className:`dmui-toast__image`,src:e.image,alt:``}):(0,u.jsx)(A,{icon:e.icon}),e.title&&(0,u.jsx)(`div`,{className:`dmui-toast__title`,children:e.title})]})]})}function A({icon:e}){return e===`success`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M5 13l4 4L19 7`})}):e===`error`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})}):e===`loading`?(0,u.jsx)(`span`,{className:`dmui-toast__spinner`,"aria-hidden":`true`}):null}function j({dialog:e}){let[t,n]=(0,i.useState)(``),r=(0,i.useRef)(null);return(0,i.useEffect)(()=>{e.editable&&r.current?.focus()},[e.editable]),(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`}),(0,u.jsxs)(`div`,{className:`dmui-modal`,role:`dialog`,"aria-modal":`true`,children:[e.title&&(0,u.jsx)(`div`,{className:`dmui-modal__title`,children:e.title}),e.editable?(0,u.jsx)(`input`,{ref:r,className:`dmui-modal__input`,value:t,placeholder:e.placeholderText,onChange:e=>n(e.target.value)}):e.content&&(0,u.jsx)(`div`,{className:`dmui-modal__content`,children:e.content}),(0,u.jsxs)(`div`,{className:`dmui-modal__actions`,children:[e.showCancel&&(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.cancelColor},onClick:()=>e.onResult(!1),children:e.cancelText}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.confirmColor},onClick:()=>e.onResult(!0,t),children:e.confirmText})]})]})]})}function M({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-action-sheet`,role:`menu`,children:[(0,u.jsx)(`div`,{className:`dmui-action-sheet__items`,children:e.itemList.map((t,n)=>(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__item`,style:{color:e.itemColor},onClick:()=>e.onSelect(n),children:t},n))}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function N({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onResult(!1)}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__title`,children:`加入岛即可发布讨论`}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__row`,children:[e.islandAvatar&&(0,u.jsx)(`img`,{className:`dmui-half-sheet__avatar`,src:e.islandAvatar,alt:``}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__info`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__name`,children:e.islandName}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__members`,children:[e.memberCount,`人加入`]})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__join`,onClick:()=>e.onResult(!0),children:`加入`})]}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__cancel`,onClick:()=>e.onResult(!1),children:`取消`})]})]})}function te({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__header`,children:[e.appAvatar?(0,u.jsx)(`img`,{className:`dmui-capsule-menu__avatar`,src:e.appAvatar,alt:``}):(0,u.jsx)(`div`,{className:`dmui-capsule-menu__avatar dmui-capsule-menu__avatar--placeholder`}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-info`,children:[(0,u.jsx)(`div`,{className:`dmui-capsule-menu__app-name`,children:e.appName}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-version`,children:[`V`,e.appVersion]})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__grid`,children:e.items.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:t.icon}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n))}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}var P=[{label:`微信`,icon:S},{label:`朋友圈`,icon:C}];function ne({dialog:e}){let t=e.type===`image`?{label:`保存图片`,icon:T}:{label:`复制链接`,icon:w};return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__title`,children:`分享到`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet__grid`,children:[P.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n)),(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(P.length),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function F(e,n){let r={kind:`capsuleMenu`,appName:n||`小程序`,appAvatar:``,appVersion:`1.0.0`,items:[{label:`复制链接`,icon:`🔗`}],onSelect(n){n===0&&navigator.clipboard.writeText(`https://qiandao.com/miniapp?appId=${e}`),t.hideDialog()}};t.showDialog(r)}function I(e){if(!e)return{config:null,visible:!1,badges:[],redDots:[]};let t=e.list.length;return{config:L(e),visible:!0,badges:Array.from({length:t},()=>``),redDots:Array.from({length:t},()=>!1)}}function L(e){return{...e,list:e.list.map(e=>({...e}))}}function R(e,t){switch(t.kind){case`reset`:return{state:I(t.config),ok:!0,errMsg:`reset:ok`};case`visibility`:return{state:{...e,visible:t.visible},ok:!0,errMsg:t.visible?`showTabBar:ok`:`hideTabBar:ok`};case`apply`:return z(e,t.name,t.params)}}function z(e,t,n){if(!e.config)return{state:e,ok:!1,errMsg:`${t}:fail tabBar not configured`};switch(t){case`setTabBarStyle`:return B(e,n);case`setTabBarItem`:return V(e,n);case`showTabBar`:return{state:{...e,visible:!0},ok:!0,errMsg:`showTabBar:ok`};case`hideTabBar`:return{state:{...e,visible:!1},ok:!0,errMsg:`hideTabBar:ok`};case`setTabBarBadge`:return H(e,n);case`removeTabBarBadge`:return U(e,n);case`showTabBarRedDot`:return W(e,n,!0);case`hideTabBarRedDot`:return W(e,n,!1)}}function B(e,t){if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarStyle:fail tabBar not configured`};let n={...e.config},r=(e,t)=>{let r=K(t);r&&(n[e]=r)};return r(`color`,t.color),r(`selectedColor`,t.selectedColor),r(`backgroundColor`,t.backgroundColor),(t.borderStyle===`black`||t.borderStyle===`white`)&&(n.borderStyle=t.borderStyle),{state:{...e,config:n},ok:!0,errMsg:`setTabBarStyle:ok`}}function V(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarItem:fail ${n.err}`};if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarItem:fail tabBar not configured`};let r=e.config.list[n.index],i={...r,text:typeof t.text==`string`?t.text:r.text,iconPath:typeof t.iconPath==`string`?t.iconPath:r.iconPath,selectedIconPath:typeof t.selectedIconPath==`string`?t.selectedIconPath:r.selectedIconPath},a=[...e.config.list];return a[n.index]=i,{state:{...e,config:{...e.config,list:a}},ok:!0,errMsg:`setTabBarItem:ok`}}function H(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarBadge:fail ${n.err}`};let r=[...e.badges];r[n.index]=String(t.text??``);let i=[...e.redDots];return i[n.index]=!1,{state:{...e,badges:r,redDots:i},ok:!0,errMsg:`setTabBarBadge:ok`}}function U(e,t){let n=G(e,t);if(n.err)return{state:e,ok:!1,errMsg:`removeTabBarBadge:fail ${n.err}`};let r=[...e.badges];return r[n.index]=``,{state:{...e,badges:r},ok:!0,errMsg:`removeTabBarBadge:ok`}}function W(e,t,n){let r=G(e,t);if(r.err)return{state:e,ok:!1,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:fail ${r.err}`};let i=[...e.redDots];i[r.index]=n;let a=[...e.badges];return n&&(a[r.index]=``),{state:{...e,redDots:i,badges:a},ok:!0,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:ok`}}function G(e,t){let n=e.config?.list??[],r=t.index,i=Number(r);return n.length?r==null||!Number.isInteger(i)||i<0||i>=n.length?{index:-1,err:`invalid index ${r}`}:{index:i,err:null}:{index:-1,err:`tabBar not configured`}}function K(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>64?null:/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:null:t}function q(e){return e?e.replace(/^\/+/,``):``}function J(e){if(!e)return null;let t=e.indexOf(`=`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``;return n?[decodeURIComponent(n),decodeURIComponent(r)]:null}function Y(e){let t={};for(let n of e.split(`&`)){let e=J(n);e&&(t[e[0]]=e[1])}return t}function X(e){let[t,n]=(typeof e==`string`?e:``).split(`?`);return{pagePath:q(t),query:n?Y(n):{}}}function re(e){let t={};return e.isTab&&(t[e.pagePath]=[e]),{stack:[e],tabStacks:t,currentTabPath:e.isTab?e.pagePath:null}}function ie(e){return e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:[...e.stack]}:e.tabStacks}function ae(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack,t];return{next:{...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},effects:n?[{kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageHide`}]:[]}}function oe(e,t){if(e.stack.length<=1)return{error:`no page to back`};let n=Math.min(Math.max(1,Number.isFinite(t)?t:1),e.stack.length-1),r=e.stack.slice(e.stack.length-n),i=e.stack.slice(0,e.stack.length-n),a=i[i.length-1],o={...e,stack:i,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:i}:e.tabStacks,currentTabPath:a.isTab?a.pagePath:e.currentTabPath},s=[];for(let e of r)s.push({kind:`lifecycle`,bridgeId:e.bridgeId,event:`pageUnload`}),s.push({kind:`closePage`,bridgeId:e.bridgeId});return s.push({kind:`lifecycle`,bridgeId:a.bridgeId,event:`pageShow`}),{next:o,effects:s}}function se(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack.slice(0,e.stack.length-1),t],i={...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},a=[];return n&&(a.push({kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:n.bridgeId})),{next:i,effects:a}}function ce(e,t){let n=new Set;for(let t of e.stack)n.add(t.bridgeId);for(let t of Object.values(e.tabStacks))for(let e of t)n.add(e.bridgeId);n.delete(t.bridgeId);let r=t.isTab?{[t.pagePath]:[t]}:{},i={stack:[t],tabStacks:r,currentTabPath:t.isTab?t.pagePath:null},a=[];for(let e of n)a.push({kind:`lifecycle`,bridgeId:e,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:e});return{next:i,effects:a}}function le(e,t,n){let r=e.stack[e.stack.length-1],i=ie(e),a,o=i[t];if(o&&o.length>0)a=o;else if(n)a=[n];else throw Error(`[page-stack] switchTab to ${t} requires either a cached substack or a freshly-opened entry`);let s={...e,stack:a,tabStacks:{...i,[t]:a},currentTabPath:t},c=a[a.length-1],l=[];return r&&r.bridgeId!==c.bridgeId&&l.push({kind:`lifecycle`,bridgeId:r.bridgeId,event:`pageHide`}),n||l.push({kind:`lifecycle`,bridgeId:c.bridgeId,event:`pageShow`}),{next:s,effects:l}}function ue(e){let t=new Map,n=e.stack[e.stack.length-1]?.bridgeId,r=e=>{t.has(e.bridgeId)||t.set(e.bridgeId,{entry:e,visible:e.bridgeId===n})};for(let t of Object.values(e.tabStacks))for(let e of t)r(e);for(let t of e.stack)r(t);return Array.from(t.values())}function Z(e){return e.backgroundColor??`#ffffff`}function Q(e,t){let n=e.navigationBarBackgroundColor??`#ffffff`,r=e.navigationBarTextStyle??`black`,i=e.navigationStyle??`default`;return h({title:e.navigationBarTitleText??t,backgroundColor:n,textStyle:r,style:i,homeButtonVisible:e.homeButton===!0})}function de(e,t,n){switch(t){case`setNavigationBarTitle`:return{...e,title:typeof n.title==`string`?n.title:e.title};case`setNavigationBarColor`:return pe(e,n);case`showNavigationBarLoading`:return{...e,loading:!0};case`hideNavigationBarLoading`:return{...e,loading:!1};case`hideHomeButton`:return{...e,homeButtonVisible:!1};default:return e}}var fe=[`linear`,`easeIn`,`easeOut`,`easeInOut`];function pe(e,t){let n=typeof t.frontColor==`string`?t.frontColor.toLowerCase():void 0,r=n===`#ffffff`?`white`:n===`#000000`?`black`:e.textStyle,i=typeof t.backgroundColor==`string`?t.backgroundColor:e.backgroundColor,a=(()=>{let e=t.animation;if(!e||typeof e!=`object`)return;let n=e,r=typeof n.duration==`number`&&Number.isFinite(n.duration)?Math.max(0,n.duration):0,i=typeof n.timingFunc==`string`?n.timingFunc:`linear`;return{durationMs:r,timingFunc:fe.includes(i)?i:`linear`}})();return{...e,textStyle:r,backgroundColor:i,colorAnimation:a}}function me(e,t,n){let r=e=>e.bridgeId===t?{...e,navBar:n(e.navBar)}:e,i=e.stack.map(r),a={};for(let[t,n]of Object.entries(e.tabStacks))a[t]=n.map(r);return{...e,stack:i,tabStacks:a}}var he=44,ge=24,$=44;function _e({miniApp:e,bridgeId:t,platform:n=`ios`}){let[a,o]=(0,i.useState)(()=>e.getInitialDevice());(0,i.useEffect)(()=>e.onSimulatorEvent(r.DEVICE_CHANGE,o),[e]);let c=a?.safeAreaInsets.top??(n===`ios`?he:ge),l=a?.safeAreaInsets.bottom??0,d=a?.notchType??`none`,f=(0,i.useMemo)(()=>e.getRenderPreloadUrl(),[e]),p=(0,i.useMemo)(()=>e.getTabBarConfig(),[e]),h=(0,i.useMemo)(()=>({bridgeId:t,pagePath:q(e.pagePath),query:{...e.query},isTab:!!e.getTabBarConfig()?.list.some(t=>q(t.pagePath)===q(e.pagePath)),windowConfig:e.rootWindowConfig??{},navBar:Q(e.rootWindowConfig??{},e.appId)}),[e,t]),[{shell:g,tabBar:y},b]=(0,i.useState)(()=>({shell:re(h),tabBar:I(p)})),x=(0,i.useRef)({shell:g,tabBar:y});(0,i.useEffect)(()=>{x.current={shell:g,tabBar:y}},[g,y]);let S=(0,i.useCallback)(t=>{for(let n of t)n.kind===`lifecycle`?e.notifyLifecycle(n.bridgeId,n.event):n.kind===`closePage`&&e.closePage(n.bridgeId)},[e]);(0,i.useEffect)(()=>e.onSimulatorEvent(r.NAV_BAR,e=>{b(t=>({...t,shell:me(t.shell,e.bridgeId,t=>de(t,e.name,e.params))}))}),[e]),(0,i.useEffect)(()=>e.onSessionEvent(r.TAB_ACTION,t=>{let n=R(x.current.tabBar,{kind:`apply`,name:t.name,params:t.params});b(e=>({...e,tabBar:n.state})),e.notifyNavCallback({ok:n.ok,errMsg:n.errMsg,callbacks:t.callbacks})}),[e]);let C=(0,i.useCallback)(async t=>{let n=(n,r)=>e.notifyNavCallback({ok:n,errMsg:r,callbacks:t.callbacks});try{switch(t.name){case`navigateTo`:await ve(e,x,b,S,t,n);break;case`navigateBack`:ye(x,b,S,t,n);break;case`redirectTo`:await be(e,x,b,S,t,n);break;case`reLaunch`:await xe(e,x,b,S,t,n);break;case`switchTab`:await Se(e,x,b,S,t,n);break}}catch(e){n(!1,`${t.name}:fail ${e instanceof Error?e.message:String(e)}`)}},[e,S]);(0,i.useEffect)(()=>e.onSessionEvent(r.NAV_ACTION,e=>{C(e)}),[C,e]),(0,i.useEffect)(()=>e.onSessionEvent(r.API_CALL,t=>{s(e,t.name,t.params,n=>{e.notifyApiResponse({requestId:t.requestId,ok:n.ok,result:n.result,errMsg:n.errMsg,keep:n.keep})})}),[e]);let w=(0,i.useCallback)(()=>{if(x.current.shell.stack.length<=1)return;let t=x.current.shell.stack;C({appSessionId:e.appSessionId??``,bridgeId:t[t.length-1].bridgeId,name:`navigateBack`,params:{delta:1},callbacks:{}})},[e,C]),T=(0,i.useCallback)(t=>{let n=x.current.shell;t===n.currentTabPath&&n.stack.length===1||C({appSessionId:e.appSessionId??``,bridgeId:n.stack[n.stack.length-1].bridgeId,name:`switchTab`,params:{url:`/${t}`},callbacks:{}})},[e,C]),E=(0,i.useCallback)(()=>{let t=x.current.shell.stack;F(e.appId,t[t.length-1].navBar.title)},[e]),D=g.stack[g.stack.length-1],O=ue(g);return(0,i.useEffect)(()=>{e.notifyActivePage(D.bridgeId)},[e,D.bridgeId]),(0,i.useEffect)(()=>{e.notifyPageStack(g.stack.map(e=>({pagePath:e.pagePath,query:e.query})))},[e,g.stack]),(0,u.jsx)(`main`,{className:`device-shell-root`,children:(0,u.jsxs)(`section`,{className:`device-shell`,"aria-label":`Dimina simulator`,style:a?{width:a.screenWidth,height:a.screenHeight}:void 0,children:[(0,u.jsx)(_,{height:c,notchType:d,textStyle:D.navBar.textStyle}),(0,u.jsx)(m,{state:D.navBar,stackDepth:g.stack.length,platform:n,statusBarHeight:c,navBarHeight:$,onBack:w,onMoreClick:E}),(0,u.jsx)(`div`,{className:`device-shell__viewport`,children:O.map(({entry:t,visible:n})=>(0,u.jsx)(`webview`,{className:`device-shell__webview`,src:e.createRenderHostUrl(t.bridgeId,t.pagePath,t.isTab,Z(t.windowConfig)),preload:f,allowpopups:`true`,style:{display:n?`flex`:`none`,zIndex:n?100:1,backgroundColor:Z(t.windowConfig)}},t.bridgeId))}),D.isTab&&(0,u.jsx)(v,{state:y,currentPath:g.currentTabPath,resourceBaseUrl:e.resourceBaseUrl,appId:e.appId,onSwitch:T,bottomInset:l}),(0,u.jsx)(ee,{}),l>0&&(0,u.jsx)(`div`,{className:`device-shell__home-indicator`,style:{height:l},"aria-hidden":`true`})]})})}async function ve(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`navigateTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`navigateTo:fail can not navigateTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=ae(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`navigateTo:ok`)}function ye(e,t,n,r,i){let a=r.params.delta,o=Number.isFinite(Number(a))?Number(a):1,s=oe(e.current.shell,o);if(`error`in s){i(!1,`navigateBack:fail ${s.error}`);return}t(e=>({...e,shell:s.next})),n(s.effects),i(!0,`navigateBack:ok`)}async function be(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`redirectTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`redirectTo:fail can not redirectTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=se(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`redirectTo:ok`)}async function xe(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`reLaunch:fail invalid url`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:Q(c.windowConfig,e.appId)},{next:u,effects:d}=ce(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`reLaunch:ok`)}async function Se(e,t,n,r,i,a){let{pagePath:o}=X(i.params.url);if(!o){a(!1,`switchTab:fail invalid url`);return}if(!e.getTabBarConfig()?.list.some(e=>q(e.pagePath)===o)){a(!1,`switchTab:fail not a tabBar page: ${o}`);return}let s=t.current.shell.tabStacks[o],c=null;if(!s||s.length===0){let t=await e.openPage(o,{});c={bridgeId:t.bridgeId,pagePath:t.pagePath,query:{},isTab:!0,windowConfig:t.windowConfig,navBar:Q(t.windowConfig,e.appId)}}let{next:l,effects:u}=le(t.current.shell,o,c);n(e=>({...e,shell:l})),r(u),a(!0,`switchTab:ok`)}export{_e as DeviceShell};
|
|
2
|
+
//# sourceMappingURL=device-shell-Sbkjw8Nb.js.map
|