dns-worker 1.2.2 → 1.2.3-alpha.766ee05
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/serverfull.mjs +194 -98
- package/dist/serverfull.mjs.map +3 -3
- package/migrations/0068_add_isp_hourly_rollups.sql +34 -0
- package/migrations/0069_drop_redundant_logs_indexes.sql +7 -0
- package/package.json +7 -7
- package/static/assets/{AccountView-CKn8YPlP.js → AccountView-BwhP5Vyg.js} +3 -3
- package/static/assets/{AnalyticsView-DtwAFAS2.js → AnalyticsView-BWZ4DRZZ.js} +2 -2
- package/static/assets/DestinationMap-dSnmpJUa.js +1 -0
- package/static/assets/{FilteringView-C3o6cUlv.js → FilteringView-ClKcN1xl.js} +1 -1
- package/static/assets/{LogsView-CB5qSS6F.js → LogsView-CMrLMBqC.js} +3 -3
- package/static/assets/{RulesView-Br-TGI0S.js → RulesView-Cf5VfP9Y.js} +1 -1
- package/static/assets/{SettingsView-DfNd-8A4.js → SettingsView-CCIqvC6k.js} +1 -1
- package/static/assets/{SetupView-CWmyacJn.js → SetupView-BvuDu_-w.js} +1 -1
- package/static/assets/{SystemView-C-AbCiPA.js → SystemView-Ck5_5ItK.js} +1 -1
- package/static/assets/{TrendChart-CTcw6KTh.js → TrendChart-f1u-kUeB.js} +1 -1
- package/static/assets/date-QJg19jj0.js +1 -0
- package/static/assets/{index-DAjmisEt.js → index-DMN6dW1Y.js} +4 -4
- package/static/assets/{services-OOd28yfV.js → services-bT9mifA7.js} +1 -1
- package/static/assets/{sqlite.worker-DfuIqYyd.js → sqlite.worker-D8vG3D1o.js} +7 -3
- package/static/assets/{useLogsE2ee-BG2dwwV0.js → useLogsE2ee-CyrFWCkS.js} +1 -1
- package/static/index.html +1 -1
- package/static/assets/DestinationMap-BQ-SJwVY.js +0 -1
- package/static/assets/date-CsFxSeKu.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-utils-Bab4qB3W.js";import{$ as e,$t as t,A as ee,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,It as v,J as y,Jt as b,K as x,Kt as S,L as C,Lt as w,M as T,Mt as E,N as D,Nt as O,O as k,Ot as A,P as j,Pt as M,Q as N,Qt as P,R as F,Rt as I,S as L,St as R,T as z,Tt as B,U as V,Ut as H,V as U,Vt as W,W as G,Wt as K,X as q,Xt as J,Y,Yt as X,Z,Zt as Q,_t as te,an as ne,at as re,b as ie,bt as ae,cn as oe,ct as se,dn as ce,dt as $,en as le,et as ue,fn as de,ft as fe,gt as pe,hn as me,ht as he,it as ge,j as _e,jt as ve,k as ye,kt as be,ln as xe,lt as Se,mn as Ce,mt as we,nt as Te,on as Ee,ot as De,pn as Oe,pt as ke,q as Ae,qt as je,rt as Me,sn as Ne,st as Pe,tn as Fe,tt as Ie,un as Le,ut as Re,v as ze,vt as Be,w as Ve,wt as He,x as Ue,xt as We,y as Ge,yt as Ke,z as qe,zt as Je}from"./index-
|
|
1
|
+
import"./vendor-utils-Bab4qB3W.js";import{$ as e,$t as t,A as ee,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,It as v,J as y,Jt as b,K as x,Kt as S,L as C,Lt as w,M as T,Mt as E,N as D,Nt as O,O as k,Ot as A,P as j,Pt as M,Q as N,Qt as P,R as F,Rt as I,S as L,St as R,T as z,Tt as B,U as V,Ut as H,V as U,Vt as W,W as G,Wt as K,X as q,Xt as J,Y,Yt as X,Z,Zt as Q,_t as te,an as ne,at as re,b as ie,bt as ae,cn as oe,ct as se,dn as ce,dt as $,en as le,et as ue,fn as de,ft as fe,gt as pe,hn as me,ht as he,it as ge,j as _e,jt as ve,k as ye,kt as be,ln as xe,lt as Se,mn as Ce,mt as we,nt as Te,on as Ee,ot as De,pn as Oe,pt as ke,q as Ae,qt as je,rt as Me,sn as Ne,st as Pe,tn as Fe,tt as Ie,un as Le,ut as Re,v as ze,vt as Be,w as Ve,wt as He,x as Ue,xt as We,y as Ge,yt as Ke,z as qe,zt as Je}from"./index-DMN6dW1Y.js";export{$ as exportProfileLogs};
|
|
@@ -172,14 +172,18 @@ importDb(e,n){if(n instanceof ArrayBuffer)n=new Uint8Array(n);else if(n instance
|
|
|
172
172
|
ORDER BY count DESC
|
|
173
173
|
LIMIT 250;
|
|
174
174
|
`);try{for(S.bind(l);S.step();){let e=S.get({});e&&e.country_code&&x.push(e)}}finally{S.finalize()}return{summary:u,trend:f,top_allowed:m,top_blocked:g,clients:y,destinations:x}}function g(e){let t=o(),{profileId:n,countryCode:r,since:i,until:a,accessPointId:s,limit:c=250}=e,l=`profile_id = ? AND timestamp BETWEEN ? AND ?`,u=[n,i,a];s&&(l+=` AND access_point_id = ?`,u.push(s)),r&&(l+=` AND (
|
|
175
|
-
UPPER(COALESCE(dest_country_code, json_extract(dest_geoip, '$.country_code'))) = ?
|
|
175
|
+
UPPER(COALESCE(NULLIF(dest_country_code, ''), json_extract(dest_geoip, '$.country_code'))) = ?
|
|
176
176
|
)`,u.push(r.toUpperCase())),l+=` AND (
|
|
177
177
|
(dest_isp IS NOT NULL AND dest_isp != '')
|
|
178
178
|
OR
|
|
179
|
-
(dest_geoip IS NOT NULL AND
|
|
179
|
+
(dest_geoip IS NOT NULL AND (
|
|
180
|
+
(json_extract(dest_geoip, '$.isp') IS NOT NULL AND json_extract(dest_geoip, '$.isp') != '')
|
|
181
|
+
OR
|
|
182
|
+
(json_extract(dest_geoip, '$.org') IS NOT NULL AND json_extract(dest_geoip, '$.org') != '')
|
|
183
|
+
))
|
|
180
184
|
)`;let d=[],f=t.prepare(`
|
|
181
185
|
SELECT
|
|
182
|
-
COALESCE(dest_isp, json_extract(dest_geoip, '$.isp'), 'Unknown') as name,
|
|
186
|
+
COALESCE(NULLIF(dest_isp, ''), NULLIF(json_extract(dest_geoip, '$.isp'), ''), NULLIF(json_extract(dest_geoip, '$.org'), ''), 'Unknown') as name,
|
|
183
187
|
count(*) as count
|
|
184
188
|
FROM local_logs
|
|
185
189
|
WHERE ${l}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{bt as t,ft as n,j as r,nn as i,tt as a}from"./vendor-react-DYK5a2J9.js";import{S as o,b as s}from"./vendor-icons-other-BTYC6Wvz.js";import{B as c,C as l,H as u,P as d,R as f,f as p,k as m,p as h,z as g}from"./vendor-ui-core-CodM8CpF.js";import{_t as _}from"./vendor-utils-Bab4qB3W.js";import{A as v,Kt as y,w as b}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{bt as t,ft as n,j as r,nn as i,tt as a}from"./vendor-react-DYK5a2J9.js";import{S as o,b as s}from"./vendor-icons-other-BTYC6Wvz.js";import{B as c,C as l,H as u,P as d,R as f,f as p,k as m,p as h,z as g}from"./vendor-ui-core-CodM8CpF.js";import{_t as _}from"./vendor-utils-Bab4qB3W.js";import{A as v,Kt as y,w as b}from"./index-DMN6dW1Y.js";var x=e(o(),1),S=e(s(),1);const C=({isMobile:e,unlocking:t,onUnlockPasskey:n,onOpenRecoveryDialog:r})=>{let{t:o}=i();return(0,S.jsx)(`div`,{className:_(`mb-2 shrink-0`,e?`px-2`:`px-4`),children:(0,S.jsx)(l,{intent:u.PRIMARY,icon:`lock`,title:o(`settings.e2eeTitle`,`端到端加密日志`),children:(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 mt-1`,children:[(0,S.jsx)(`p`,{className:`text-xs opacity-80 m-0`,children:o(`settings.e2eeUnlockPrompt`,`日志已通过端到端加密保护。请验证已授权的硬件 Passkey 或输入紧急恢复密钥以在本地解密。`)}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap shrink-0`,children:[(0,S.jsx)(d,{intent:u.PRIMARY,icon:`key`,small:!0,loading:t,onClick:n,className:`font-medium`,children:o(`settings.e2eeUnlockNow`,`验证 Passkey 解锁`)}),(0,S.jsx)(d,{intent:u.NONE,icon:(0,S.jsx)(a,{size:14}),small:!0,disabled:t,onClick:r,className:`font-medium`,children:o(`settings.e2eeUnlockRecovery`,`使用恢复密钥解锁`)})]})]})})})},w=({isOpen:e,onClose:t,recoveryKeyInput:n,setRecoveryKeyInput:r,recoveryError:a,unlocking:o,onSubmit:s})=>{let{t:_}=i();return(0,S.jsx)(m,{isOpen:e,onClose:t,title:_(`account.e2ee.unlockWithRecoveryTitle`,`使用恢复密钥解锁`),icon:`key`,className:`dark:bg-gray-900`,children:(0,S.jsxs)(`form`,{onSubmit:s,autoComplete:`off`,children:[(0,S.jsxs)(`div`,{className:f,children:[(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:_(`account.e2ee.unlockWithRecoveryDesc`,`请输入 30 位紧急恢复密钥。注意:根据单次使用规则,恢复密钥验证成功后将立即自动轮换。`)}),a&&(0,S.jsx)(l,{intent:u.DANGER,className:`mb-3 text-xs`,children:a}),(0,S.jsx)(h,{label:_(`account.e2ee.recoveryKeyInputLabel`,`恢复密钥`),labelFor:`recovery-key-input-logs`,children:(0,S.jsx)(p,{id:`recovery-key-input-logs`,name:`recovery_key_input_logs`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-bwignore":`true`,placeholder:`123456-789012-345678-901234-567890`,value:n,onChange:e=>r(e.target.value),leftIcon:`key`,className:`font-mono text-xs`,autoFocus:!0})})]}),(0,S.jsx)(`div`,{className:g,children:(0,S.jsxs)(`div`,{className:c,children:[(0,S.jsx)(d,{onClick:t,text:_(`common.cancel`,`取消`)}),(0,S.jsx)(d,{type:`submit`,intent:u.PRIMARY,loading:o,disabled:!n.trim(),text:_(`account.e2ee.unlockConfirm`,`解锁日志`)})]})})]})})},T=({rotatedKey:e,onClose:a,copiedKey:o,onCopyKey:s})=>{let{t:p}=i();return(0,S.jsxs)(m,{isOpen:!!e,onClose:a,title:p(`account.recoveryKey.autoRotatedTitle`,`恢复密钥已自动轮换`),icon:`warning-sign`,isCloseButtonShown:!1,canOutsideClickClose:!1,className:`dark:bg-gray-900`,children:[(0,S.jsxs)(`div`,{className:f,children:[(0,S.jsx)(l,{intent:u.WARNING,icon:null,className:`mb-4 text-xs`,children:(0,S.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,S.jsx)(r,{className:`w-4 h-4 shrink-0 mt-0.5`}),(0,S.jsx)(`span`,{children:p(`account.recoveryKey.autoRotatedNotice`,`根据恢复密钥单次使用规则,您的原恢复密钥已失效,系统已为您生成全新 30 位紧急恢复密钥。请务必立即复制并妥善离线保存,关闭后将无法再次查看!`)})]})}),e&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsx)(`div`,{className:`p-3 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 font-mono text-center text-lg font-bold tracking-widest select-all text-gray-900 dark:text-gray-100`,children:e}),(0,S.jsx)(`div`,{className:`flex justify-center`,children:(0,S.jsx)(d,{intent:u.PRIMARY,icon:o?(0,S.jsx)(t,{size:14,className:`text-green-400`}):(0,S.jsx)(n,{size:14}),text:o?p(`common.copied`,`已复制`):p(`common.copyKey`,`复制新恢复密钥`),onClick:()=>s(e)})})]})]}),(0,S.jsx)(`div`,{className:g,children:(0,S.jsx)(`div`,{className:c,children:(0,S.jsx)(d,{intent:u.SUCCESS,onClick:a,text:p(`account.recoveryKey.savedAndClose`,`我已妥善保存并继续`)})})})]})};function E({profileId:e,range:t,fetchLogs:n,onUnlocked:r,toasterRef:a}){let{t:o}=i(),[s,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(``),[S,C]=(0,x.useState)(``),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(!1),O=(0,x.useRef)(!1),k=(0,x.useRef)(e);k.current!==e&&(k.current=e,O.current=!1);let A=(0,x.useCallback)(async()=>{r?await r():n&&t&&await n(t,!0)},[r,n,t]),j=(0,x.useCallback)(async()=>{try{let t=await v.getStatus(e),n=!!(t.enabled||t.hasKeys);c(n);let r=v.isProfileUnlocked(e);if(d(r),n&&!r&&t.wrappedPasskeys&&t.wrappedPasskeys.length>0&&!O.current){O.current=!0;try{await v.unlockProfile(e)&&(d(!0),await b.reDecryptLocalLogs(e),await A())}catch(e){console.debug(`[useLogsE2ee] Silent auto-unlock skipped or cancelled:`,e)}}}catch{c(!1)}},[e,A]);return(0,x.useEffect)(()=>{j()},[j]),{isE2eeEnabled:s,isE2eeUnlocked:l,unlocking:f,recoveryDialogOpen:m,setRecoveryDialogOpen:h,recoveryKeyInput:g,setRecoveryKeyInput:_,recoveryError:S,setRecoveryError:C,rotatedKey:w,setRotatedKey:T,copiedKey:E,handleCopyRotatedKey:e=>{navigator.clipboard.writeText(e),D(!0),setTimeout(()=>D(!1),2e3)},handleUnlockPasskey:async()=>{try{p(!0),await v.unlockProfile(e)&&(d(!0),await b.reDecryptLocalLogs(e),a?.current?.show({message:o(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:u.SUCCESS}),await A())}catch(e){console.error(`Failed to unlock E2EE via Passkey:`,e),a?.current?.show({message:e.message||o(`settings.e2eeUnlockError`,`验证 Passkey 解锁失败`),intent:u.DANGER})}finally{p(!1)}},handleUnlockRecoveryKey:async t=>{t.preventDefault();let n=g.trim();if(n){p(!0),C(``);try{await v.unlockWithRecoveryKey(n);try{let e=await y({recoveryKey:n});await v.wrapCurrentKeyForRecovery(e.recovery_key),T(e.recovery_key)}catch(e){console.warn(`[useLogsE2ee] Recovery key auto-rotation failed:`,e)}d(!0),h(!1),_(``),await b.reDecryptLocalLogs(e),a?.current?.show({message:o(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:u.SUCCESS}),await A()}catch(e){console.error(`Failed to unlock E2EE via recovery key:`,e),C(e.message||o(`account.e2ee.recoveryUnlockFailed`,`恢复密钥无效或解析失败`))}finally{p(!1)}}}}}export{C as i,T as n,w as r,E as t};
|
package/static/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="shortcut icon" href="/favicon.ico">
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
10
|
<title>DNS Worker</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DMN6dW1Y.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C4Xdq4VV.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-icons-16-BgwRBCeU.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/vendor-icons-20-X5NPN60g.js">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{_ as t,d as n,f as r,g as i,i as a,m as o,nn as s,p as c,r as l,u,y as d,z as f}from"./vendor-react-DYK5a2J9.js";import{S as p,b as m}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import"./vendor-utils-Bab4qB3W.js";import{W as h,pt as g,w as _}from"./index-DAjmisEt.js";import{n as v,t as y}from"./formatCountryName-C6cFVUu2.js";import{t as b}from"./getFlagEmoji-Cd2A891A.js";var x=e(p(),1);function S(e){let[t,n]=(0,x.useState)(null);(0,x.useEffect)(()=>{h().then(e=>{if(e&&e.objects){let t={};e.objects.countries&&(t.countries=e.objects.countries),e.objects.land&&(t.land=e.objects.land),e.objects=t}e&&e.objects&&e.objects.countries&&Array.isArray(e.objects.countries.geometries)&&e.objects.countries.geometries.forEach(e=>{e.id!==void 0&&e.id!==null&&(e.id=String(e.id).padStart(3,`0`))}),n(e)}).catch(e=>console.error(`Failed to load map topology`,e))},[]);let r=(0,x.useMemo)(()=>e.reduce((e,t)=>e+(Number(t.count)||0),0),[e]),i=(0,x.useMemo)(()=>{if(r<=0)return{maxThreshold:10,step:1};if(r<=1e3)return{maxThreshold:100,step:10};let e=10**Math.floor(Math.log10(r));return{maxThreshold:e,step:e/10}},[r]);return{geographyData:t,destinationMap:(0,x.useMemo)(()=>{let t={};return e.forEach(e=>{if(e.country_code){let n=e.country_code.toUpperCase(),r=Number(e.count)||0;t[n]?(t[n].count+=r,(!t[n].name||t[n].name===`Unknown`)&&e.country&&e.country!==`Unknown`&&(t[n].name=e.country)):t[n]={count:r,name:e.country,countryCode:n}}}),t},[e]),scaleConfig:i,getLevel:e=>!e||e<=0?0:Math.min(10,Math.floor(e/i.step)+1),formatNumber:e=>{if(e>=1e6){let t=e/1e6;return Number.isInteger(t)?`${t}M`:`${t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return Number.isInteger(t)?`${t}K`:`${t.toFixed(1)}K`}return e.toString()}}}var C=e(m(),1);const w=({onZoomIn:e,onZoomOut:n,onReset:r})=>(0,C.jsxs)(`div`,{className:`absolute top-3 right-3 flex flex-col gap-1.5 bg-white/80 dark:bg-slate-950/80 backdrop-blur-md p-1.5 rounded-lg border border-gray-200/50 dark:border-slate-800/50 shadow-sm z-10`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:e,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Zoom In`,children:(0,C.jsx)(t,{size:16})}),(0,C.jsx)(`button`,{type:`button`,onClick:n,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Zoom Out`,children:(0,C.jsx)(i,{size:16})}),(0,C.jsx)(`button`,{type:`button`,onClick:r,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Reset Zoom`,children:(0,C.jsx)(f,{size:16})})]}),T=({maxThreshold:e,formatNumber:t})=>{let{t:n}=s();return(0,C.jsxs)(`div`,{className:`sm:absolute sm:bottom-3 sm:left-3 relative m-3 sm:m-0 flex flex-col shrink-0 gap-1.5 bg-white/80 dark:bg-slate-950/80 backdrop-blur-md p-2 rounded-lg border border-gray-200/50 dark:border-slate-800/50 shadow-sm z-10 max-w-70`,children:[(0,C.jsx)(`span`,{className:`text-[9px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:n(`analytics.queries`)}),(0,C.jsx)(`div`,{className:`flex items-center gap-0.5`,children:Array.from({length:11}).map((e,t)=>(0,C.jsx)(`div`,{className:`w-4 h-2.5 rounded-sm border border-black/5 dark:border-white/5`,style:{backgroundColor:`var(--map-color-${t})`}},t))}),(0,C.jsxs)(`div`,{className:`flex justify-between text-[9px] text-gray-500 dark:text-gray-400 font-semibold px-0.5`,children:[(0,C.jsx)(`span`,{children:`0`}),(0,C.jsx)(`span`,{children:t(e/2)}),(0,C.jsxs)(`span`,{children:[t(e),`+`]})]})]})},E=({name:e,count:t,flag:n,x:r,y:i,countryCode:a,profileId:o,range:c,customRange:l,accessPointId:u,ispCache:f,onCacheIsp:p,isPinned:m,onClose:h})=>{let{t:v}=s(),y=(0,x.useRef)(null),[b,S]=(0,x.useState)({left:r,top:i-10,alignBottom:!1}),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(!1),O=(0,x.useRef)(f);O.current=f;let k=(0,x.useRef)(p);return k.current=p,(0,x.useEffect)(()=>{if(!a||!o)return;if(t<=0){T([]),D(!1);return}let e=O.current[a];if(e){T(e),D(!1);return}D(!0);let n=Math.floor(Date.now()/1e3),r,i=n,s=`?country_code=${a}&range=${c}`;if(c===`custom`&&l.start&&l.end)r=Math.floor(new Date(l.start).getTime()/1e3),i=Math.floor(new Date(l.end).getTime()/1e3),s+=`&start=${r}&end=${i}`;else switch(c){case`10m`:r=n-600;break;case`1h`:r=n-3600;break;case`24h`:r=n-86400;break;case`7d`:r=n-604800;break;case`30d`:r=n-2592e3;break;default:r=n-3600;break}u&&(s+=`&access_point_id=${u}`);let d=!0,f=setTimeout(async()=>{try{let e=await g(o,`isps`,s),t=Array.isArray(e)?e:[];if(t.length>0){k.current(a,t),d&&(T(t),D(!1));return}}catch(e){console.debug(`[MapTooltip] Server ISP fetch failed, trying local DB fallback:`,e)}try{let e=await _.queryISPs({profileId:o,countryCode:a,since:r,until:i,accessPointId:u||void 0});e&&e.length>0&&(k.current(a,e),d&&T(e))}catch(e){console.warn(`[MapTooltip] Local SQLite ISP query failed:`,e)}finally{d&&D(!1)}},150);return()=>{d=!1,clearTimeout(f)}},[a,o,c,l,u,t]),(0,x.useEffect)(()=>{if(!m)return;let e=e=>{if(y.current&&!y.current.contains(e.target)){let t=e.target,n=t.classList.contains(`rsm-geography`)||t.closest(`.rsm-geography`),r=t.classList.contains(`map-marker-circle`)||t.closest(`.map-marker-circle`);!n&&!r&&h()}},t=setTimeout(()=>{document.addEventListener(`click`,e,!0)},0);return()=>{clearTimeout(t),document.removeEventListener(`click`,e,!0)}},[m,h]),(0,x.useLayoutEffect)(()=>{if(!y.current)return;let e=y.current.getBoundingClientRect(),t=y.current.parentElement;if(!t)return;let n=t.getBoundingClientRect(),a=r,o=e.width/2;r-o<4?a=o+4:r+o>n.width-4&&(a=n.width-o-4);let s=i-10,c=!1;i-e.height-15<4&&(s=i+15,c=!0),S({left:a,top:s,alignBottom:c})},[r,i,w]),(0,C.jsxs)(`div`,{ref:y,onMouseLeave:m?h:void 0,className:`absolute bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm px-3 py-2 rounded-lg shadow-xl border border-gray-200/50 dark:border-slate-800/50 text-xs z-50 flex flex-col gap-1 transition-all duration-75 text-gray-900 dark:text-gray-100 ${m?`pointer-events-auto cursor-default`:`pointer-events-none`}`,style:{left:`${b.left}px`,top:`${b.top}px`,transform:b.alignBottom?`translate(-50%, 0)`:`translate(-50%, -100%)`},children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold whitespace-nowrap`,children:[(0,C.jsx)(`span`,{className:`text-sm`,children:n}),(0,C.jsx)(`span`,{children:e})]}),(0,C.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400 whitespace-nowrap`,children:[t.toLocaleString(),` `,v(`analytics.queries`)]})]}),m&&(0,C.jsx)(`button`,{onClick:e=>{e.stopPropagation(),h()},className:`flex items-center justify-center p-2 rounded-lg border border-gray-200 dark:border-slate-800 text-gray-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-950/20 hover:border-red-200 dark:hover:border-red-900/50 transition-colors cursor-pointer self-stretch aspect-square`,title:v(`common.close`,`Close`),children:(0,C.jsx)(d,{size:18})})]}),E?(0,C.jsxs)(`div`,{className:`mt-1.5 pt-1.5 border-t border-gray-150 dark:border-slate-850 flex flex-col gap-1 min-w-36`,children:[(0,C.jsx)(`div`,{className:`text-[10px] uppercase font-bold text-gray-400 dark:text-gray-500 tracking-wider`,children:v(`analytics.topIsps`,`Top ISPs`)}),(0,C.jsx)(`div`,{className:`text-[11px] text-gray-400 dark:text-gray-500 italic`,children:v(`analytics.loading`,`Loading...`)})]}):w.length>0&&(0,C.jsxs)(`div`,{className:`mt-1.5 pt-1.5 border-t border-gray-150 dark:border-slate-800 flex flex-col gap-1`,children:[(0,C.jsx)(`div`,{className:`text-[10px] uppercase font-bold text-gray-400 dark:text-gray-500 tracking-wider`,children:v(`analytics.topIsps`,`Top ISPs`)}),(0,C.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-36 max-w-48 ${m?`max-h-36 overflow-y-auto pr-1`:``}`,children:[(m?w:w.slice(0,5)).map(e=>(0,C.jsxs)(`div`,{className:`flex justify-between gap-3 text-[11px] text-gray-600 dark:text-gray-300`,children:[(0,C.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,C.jsx)(`span`,{className:`font-mono text-gray-400 dark:text-gray-500`,children:e.count.toLocaleString()})]},e.name)),!m&&w.length>5&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`text-center text-gray-400 dark:text-gray-500 leading-none py-0.5 font-bold`,children:`...`}),(0,C.jsx)(`div`,{className:`text-[10px] text-center text-blue-500 dark:text-blue-400 font-medium whitespace-nowrap mt-0.5`,children:v(`analytics.pressToShowMore`,`Click to show more`)})]})]})]})]})},D=({geographyData:e,destinationMap:t,getLevel:r,containerRef:i,hoveredCountry:a,setHoveredCountry:o})=>{let{i18n:c}=s();return e?(0,C.jsx)(n,{geography:e,children:({geographies:e})=>e.map(e=>{let n=e.id==null?void 0:v[String(e.id)],s=n?t[n]:null,l=s?.count||0,d=r(l);return(0,C.jsx)(u,{geography:e,onMouseEnter:e=>{if(!n||a?.isPinned)return;let t=y(n,c.language)||s?.name||n,r=b(n),u=i.current?.getBoundingClientRect();o({name:t,code:n,count:l,flag:r,x:e.clientX-(u?.left||0),y:e.clientY-(u?.top||0)-15})},onMouseMove:e=>{o(t=>{if(t?.isPinned)return t;let n=i.current?.getBoundingClientRect(),r=e.clientX-(n?.left||0),a=e.clientY-(n?.top||0)-15;return t?{...t,x:r,y:a}:null})},onMouseLeave:()=>{o(e=>e?.isPinned?e:null)},onClick:e=>{if(e.stopPropagation(),!n)return;let t=y(n,c.language)||s?.name||n,r=b(n),a=i.current?.getBoundingClientRect(),u=e.clientX-(a?.left||0),d=e.clientY-(a?.top||0)-15;o(e=>e?.code===n&&e?.isPinned?null:{name:t,code:n,count:l,flag:r,x:u,y:d,isPinned:!0})},style:{default:{fill:`var(--map-color-${d})`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`,transition:`fill 250ms, stroke 250ms`},hover:{fill:`var(--map-hover)`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`,cursor:`pointer`},pressed:{fill:`var(--map-hover)`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`}}},e.rsmKey)})}):null},O={SG:{name:`Singapore`,coordinates:[103.8198,1.3521]},HK:{name:`Hong Kong`,coordinates:[114.1694,22.3193]},MO:{name:`Macau`,coordinates:[113.5439,22.1987]},VA:{name:`Vatican City`,coordinates:[12.4534,41.9029]},MC:{name:`Monaco`,coordinates:[7.4246,43.7384]},SM:{name:`San Marino`,coordinates:[12.4578,43.9424]},LI:{name:`Liechtenstein`,coordinates:[9.5209,47.141]},AD:{name:`Andorra`,coordinates:[1.5218,42.5063]},MT:{name:`Malta`,coordinates:[14.3754,35.9375]},GI:{name:`Gibraltar`,coordinates:[-5.3536,36.1408]},BM:{name:`Bermuda`,coordinates:[-64.7505,32.3078]},MV:{name:`Maldives`,coordinates:[73.5089,4.1755]},MU:{name:`Mauritius`,coordinates:[57.5522,-20.3484]}},k=({destinationMap:e,getLevel:t,containerRef:n,hoveredCountry:r,setHoveredCountry:i})=>{let{i18n:a}=s();return(0,C.jsx)(C.Fragment,{children:Object.entries(O).map(([s,c])=>{let u=e[s],d=u?.count||0,f=t(d),p=d>0,m=p?4:1.5;return(0,C.jsx)(l,{coordinates:o(c.coordinates[0],c.coordinates[1]),onMouseEnter:e=>{if(r?.isPinned)return;let t=y(s,a.language)||u?.name||s,o=b(s),c=n.current?.getBoundingClientRect();i({name:t,code:s,count:d,flag:o,x:e.clientX-(c?.left||0),y:e.clientY-(c?.top||0)-15})},onMouseMove:e=>{i(t=>{if(t?.isPinned)return t;let r=n.current?.getBoundingClientRect(),i=e.clientX-(r?.left||0),a=e.clientY-(r?.top||0)-15;return t?{...t,x:i,y:a}:null})},onMouseLeave:()=>{i(e=>e?.isPinned?e:null)},onClick:e=>{e.stopPropagation();let t=y(s,a.language)||u?.name||s,r=b(s),o=n.current?.getBoundingClientRect(),c=e.clientX-(o?.left||0),l=e.clientY-(o?.top||0)-15;i(e=>e?.code===s&&e?.isPinned?null:{name:t,code:s,count:d,flag:r,x:c,y:l,isPinned:!0})},children:p?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`circle`,{r:m+3,fill:`var(--map-color-${f})`,opacity:.4,className:`animate-ping map-marker-circle`}),(0,C.jsx)(`circle`,{r:m,fill:`var(--map-color-${f})`,stroke:`var(--map-stroke)`,strokeWidth:.75,style:{cursor:`pointer`},className:`map-marker-circle`})]}):(0,C.jsx)(`circle`,{r:m,fill:`var(--text-color)`,opacity:.25,style:{pointerEvents:`none`}})},s)})})},A=({destinations:e,profileId:t,range:n,customRange:i,accessPointId:s})=>{let{geographyData:l,destinationMap:u,scaleConfig:d,getLevel:f,formatNumber:p}=S(e),[m,h]=(0,x.useState)({coordinates:o(0,0),zoom:1.2}),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),[b,O]=(0,x.useState)({}),A=(0,x.useRef)(null);A.current=g,(0,x.useEffect)(()=>{if(!g){y(null);return}if(g.isPinned){y(g);return}if(v&&v.code===g.code)return;let e=setTimeout(()=>{A.current&&A.current.code===g.code&&y(A.current)},100);return()=>clearTimeout(e)},[g?.code,g?.isPinned,v?.code]),(0,x.useEffect)(()=>{g&&v&&g.code===v.code&&(g.x!==v.x||g.y!==v.y||g.isPinned!==v.isPinned)&&y(g)},[g?.x,g?.y,g?.isPinned,v]);let j=(0,x.useRef)(null);x.useEffect(()=>{O({})},[t,n,i,s]);let M=x.useCallback((e,t)=>{O(n=>({...n,[e]:t}))},[]),N=x.useMemo(()=>c(o(-100,-50),o(900,600)),[]);return(0,C.jsxs)(`div`,{className:`relative w-full min-h-85 max-h-120 aspect-800/566 bg-gray-50 dark:bg-slate-950 rounded-xl overflow-hidden border border-gray-100 dark:border-slate-800 flex flex-col justify-between shadow-sm`,children:[(0,C.jsxs)(`div`,{ref:j,className:`relative w-full flex-1 min-h-0 overflow-hidden select-none cursor-grab active:cursor-grabbing`,onClick:e=>{(e.target===e.currentTarget||e.target.tagName===`svg`)&&_(null)},children:[(0,C.jsx)(r,{projection:`geoEqualEarth`,width:800,height:566,style:{width:`100%`,height:`100%`},children:(0,C.jsxs)(a,{zoom:m.zoom,center:m.coordinates,onMoveEnd:e=>h({coordinates:o(e.coordinates[0],e.coordinates[1]),zoom:e.zoom}),maxZoom:8,minZoom:1,enablePan:!0,translateExtent:N,children:[(0,C.jsx)(D,{geographyData:l,destinationMap:u,getLevel:f,containerRef:j,hoveredCountry:g,setHoveredCountry:_}),(0,C.jsx)(k,{destinationMap:u,getLevel:f,containerRef:j,hoveredCountry:g,setHoveredCountry:_})]})}),v&&(0,C.jsx)(E,{name:v.name,count:v.count,flag:v.flag,x:v.x,y:v.y,countryCode:v.code,profileId:t,range:n,customRange:i,accessPointId:s,ispCache:b,onCacheIsp:M,isPinned:v.isPinned||!1,onClose:()=>_(null)})]}),(0,C.jsx)(w,{onZoomIn:()=>{m.zoom>=8||h(e=>({...e,zoom:e.zoom*1.5}))},onZoomOut:()=>{m.zoom<=1||h(e=>({...e,zoom:e.zoom/1.5}))},onReset:()=>{h({coordinates:o(0,0),zoom:1.2})}}),(0,C.jsx)(T,{maxThreshold:d.maxThreshold,formatNumber:p})]})};export{A as DestinationMap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,g as t,h as n}from"./index-DAjmisEt.js";export{t as setSystemLocale,e as setSystemTimeZone};
|