@snack-kit/lib 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chunk-YOWLTZM5.cjs +868 -0
- package/dist/cjs/chunk-YOWLTZM5.cjs.map +1 -0
- package/dist/cjs/debugger.cjs +2 -2
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/chunk-4DLFIN3C.js +866 -0
- package/dist/es/chunk-4DLFIN3C.js.map +1 -0
- package/dist/es/debugger.js +1 -1
- package/dist/es/index.js +2 -2
- package/dist/es/index.js.map +1 -1
- package/dist/types/debugger.d.ts +22 -18
- package/dist/types/index.d.ts +1 -1
- package/dist/umd/debugger.global.js +662 -157
- package/dist/umd/debugger.global.js.map +1 -1
- package/dist/umd/index.global.js +663 -158
- package/dist/umd/index.global.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/chunk-JBJEXFQC.cjs +0 -363
- package/dist/cjs/chunk-JBJEXFQC.cjs.map +0 -1
- package/dist/es/chunk-QBBEQHXG.js +0 -361
- package/dist/es/chunk-QBBEQHXG.js.map +0 -1
package/dist/umd/index.global.js
CHANGED
|
@@ -11625,7 +11625,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
11625
11625
|
});
|
|
11626
11626
|
|
|
11627
11627
|
// package.json
|
|
11628
|
-
var version = "0.
|
|
11628
|
+
var version = "0.2.0";
|
|
11629
11629
|
|
|
11630
11630
|
// node_modules/axios/lib/helpers/bind.js
|
|
11631
11631
|
function bind(fn, thisArg) {
|
|
@@ -15574,95 +15574,530 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
15574
15574
|
var KEY_GATEWAY = `${STORAGE_PREFIX}gateway`;
|
|
15575
15575
|
var KEY_TYPE = `${STORAGE_PREFIX}type`;
|
|
15576
15576
|
var KEY_SERVER = `${STORAGE_PREFIX}server`;
|
|
15577
|
+
function isChinese() {
|
|
15578
|
+
return /^zh/i.test(navigator.language ?? "");
|
|
15579
|
+
}
|
|
15580
|
+
var T = {
|
|
15581
|
+
gateway: () => isChinese() ? "\u7F51\u5173" : "Gateway",
|
|
15582
|
+
tag: () => isChinese() ? "\u6807\u7B7E" : "Tag",
|
|
15583
|
+
server: () => isChinese() ? "\u670D\u52A1" : "Server",
|
|
15584
|
+
ctx: () => isChinese() ? "\u4E0A\u4E0B\u6587" : "Ctx",
|
|
15585
|
+
ctxLabel: () => isChinese() ? "\u4E0A\u4E0B\u6587 \u2014 \u70B9\u51FB\u884C\u590D\u5236 key" : "Ctx \u2014 click row to copy key",
|
|
15586
|
+
search: () => isChinese() ? "\u641C\u7D22..." : "Search...",
|
|
15587
|
+
noMatch: () => isChinese() ? "\u65E0\u5339\u914D\u9879" : "No results",
|
|
15588
|
+
allTags: () => isChinese() ? "\u5168\u90E8\u6807\u7B7E" : "All tags",
|
|
15589
|
+
selectGateway: () => isChinese() ? "\u9009\u62E9\u7F51\u5173" : "Select gateway",
|
|
15590
|
+
selectServer: () => isChinese() ? "\u9009\u62E9\u670D\u52A1" : "Select server",
|
|
15591
|
+
filterCtx: () => isChinese() ? "\u8FC7\u6EE4\u8DEF\u7531..." : "Filter routes...",
|
|
15592
|
+
selectFirst: () => isChinese() ? "\u2190 \u8BF7\u5148\u9009\u62E9\u670D\u52A1" : "\u2190 Select a server first",
|
|
15593
|
+
loading: () => isChinese() ? "\u52A0\u8F7D\u670D\u52A1\u5217\u8868..." : "Loading...",
|
|
15594
|
+
loadFailed: (m) => isChinese() ? `\u52A0\u8F7D\u5931\u8D25: ${m}` : `Failed: ${m}`,
|
|
15595
|
+
loaded: (n) => isChinese() ? `\u5DF2\u52A0\u8F7D ${n} \u4E2A\u670D\u52A1` : `${n} servers loaded`,
|
|
15596
|
+
switching: () => isChinese() ? "\u5207\u6362\u670D\u52A1\u4E2D..." : "Switching...",
|
|
15597
|
+
switchFailed: (m) => isChinese() ? `\u5207\u6362\u5931\u8D25: ${m}` : `Failed: ${m}`,
|
|
15598
|
+
routes: (name, n) => isChinese() ? `${name} \xB7 ${n} \u6761\u8DEF\u7531` : `${name} \xB7 ${n} routes`,
|
|
15599
|
+
copied: (k) => isChinese() ? `\u5DF2\u590D\u5236: ${k}` : `Copied: ${k}`,
|
|
15600
|
+
copyAll: () => isChinese() ? "\u590D\u5236\u5168\u90E8 JSON" : "Copy all JSON",
|
|
15601
|
+
copyAllDone: () => isChinese() ? "\u5DF2\u590D\u5236\u4E3A JSON" : "Copied as JSON"
|
|
15602
|
+
};
|
|
15577
15603
|
var PANEL_STYLE = `
|
|
15578
15604
|
#__snackkit_debugger__ {
|
|
15579
15605
|
position: fixed;
|
|
15580
|
-
bottom:
|
|
15581
|
-
right:
|
|
15606
|
+
bottom: 20px;
|
|
15607
|
+
right: 20px;
|
|
15582
15608
|
z-index: 99999;
|
|
15583
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
15609
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
|
|
15584
15610
|
font-size: 13px;
|
|
15585
|
-
color: #
|
|
15611
|
+
color: #b8ccec;
|
|
15612
|
+
user-select: none;
|
|
15586
15613
|
}
|
|
15614
|
+
|
|
15615
|
+
/* \u2500\u2500 \u6D6E\u52A8\u6309\u94AE \u2500\u2500 */
|
|
15587
15616
|
#__snackkit_debugger__ .dbg-toggle {
|
|
15588
|
-
width:
|
|
15589
|
-
height:
|
|
15617
|
+
width: 42px;
|
|
15618
|
+
height: 42px;
|
|
15590
15619
|
border-radius: 50%;
|
|
15591
|
-
background: #
|
|
15620
|
+
background: linear-gradient(135deg, #4f8ef7, #6d6ff5);
|
|
15592
15621
|
border: none;
|
|
15593
15622
|
cursor: pointer;
|
|
15594
15623
|
display: flex;
|
|
15595
15624
|
align-items: center;
|
|
15596
15625
|
justify-content: center;
|
|
15597
|
-
box-shadow: 0
|
|
15626
|
+
box-shadow: 0 4px 14px rgba(79,142,247,0.45);
|
|
15598
15627
|
margin-left: auto;
|
|
15599
|
-
|
|
15600
|
-
|
|
15628
|
+
font-size: 20px;
|
|
15629
|
+
transition: transform 0.15s, box-shadow 0.15s;
|
|
15601
15630
|
}
|
|
15631
|
+
#__snackkit_debugger__ .dbg-toggle:hover {
|
|
15632
|
+
transform: scale(1.08);
|
|
15633
|
+
box-shadow: 0 6px 20px rgba(79,142,247,0.55);
|
|
15634
|
+
}
|
|
15635
|
+
#__snackkit_debugger__ .dbg-toggle:active { transform: scale(0.94); }
|
|
15636
|
+
|
|
15637
|
+
/* \u2500\u2500 \u9762\u677F\u4E3B\u4F53 \u2500\u2500 */
|
|
15602
15638
|
#__snackkit_debugger__ .dbg-panel {
|
|
15603
|
-
background: #
|
|
15604
|
-
border: 1px solid #
|
|
15605
|
-
border-radius:
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15639
|
+
background: #1e2638;
|
|
15640
|
+
border: 1px solid #2d3a55;
|
|
15641
|
+
border-radius: 12px;
|
|
15642
|
+
width: 440px;
|
|
15643
|
+
margin-bottom: 10px;
|
|
15644
|
+
box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.05);
|
|
15645
|
+
overflow: visible;
|
|
15646
|
+
opacity: 0;
|
|
15647
|
+
transform: translateY(8px) scale(0.98);
|
|
15648
|
+
pointer-events: none;
|
|
15649
|
+
transition: opacity 0.18s ease, transform 0.18s ease;
|
|
15650
|
+
}
|
|
15651
|
+
#__snackkit_debugger__ .dbg-panel.open {
|
|
15652
|
+
opacity: 1;
|
|
15653
|
+
transform: translateY(0) scale(1);
|
|
15654
|
+
pointer-events: auto;
|
|
15611
15655
|
}
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15656
|
+
|
|
15657
|
+
/* \u2500\u2500 \u9762\u677F Header \u2500\u2500 */
|
|
15658
|
+
#__snackkit_debugger__ .dbg-header {
|
|
15615
15659
|
display: flex;
|
|
15616
|
-
|
|
15617
|
-
|
|
15660
|
+
align-items: center;
|
|
15661
|
+
justify-content: space-between;
|
|
15662
|
+
padding: 10px 14px;
|
|
15663
|
+
background: #171e2e;
|
|
15664
|
+
border-bottom: 1px solid #2d3a55;
|
|
15665
|
+
border-radius: 12px 12px 0 0;
|
|
15666
|
+
}
|
|
15667
|
+
#__snackkit_debugger__ .dbg-header-left {
|
|
15668
|
+
display: flex;
|
|
15669
|
+
align-items: center;
|
|
15670
|
+
gap: 7px;
|
|
15671
|
+
}
|
|
15672
|
+
#__snackkit_debugger__ .dbg-header-dot {
|
|
15673
|
+
width: 7px;
|
|
15674
|
+
height: 7px;
|
|
15675
|
+
border-radius: 50%;
|
|
15676
|
+
background: #34d399;
|
|
15677
|
+
box-shadow: 0 0 6px rgba(52,211,153,0.6);
|
|
15618
15678
|
}
|
|
15619
|
-
#__snackkit_debugger__
|
|
15679
|
+
#__snackkit_debugger__ .dbg-header-dot.loading {
|
|
15680
|
+
background: #fbbf24;
|
|
15681
|
+
box-shadow: 0 0 6px rgba(251,191,36,0.6);
|
|
15682
|
+
animation: dbg-pulse 1s ease-in-out infinite;
|
|
15683
|
+
}
|
|
15684
|
+
#__snackkit_debugger__ .dbg-header-dot.err {
|
|
15685
|
+
background: #f87171;
|
|
15686
|
+
box-shadow: 0 0 6px rgba(248,113,113,0.6);
|
|
15687
|
+
}
|
|
15688
|
+
#__snackkit_debugger__ .dbg-header-title {
|
|
15689
|
+
font-size: 12px;
|
|
15690
|
+
font-weight: 600;
|
|
15691
|
+
color: #dce8fa;
|
|
15692
|
+
letter-spacing: 0.03em;
|
|
15693
|
+
}
|
|
15694
|
+
#__snackkit_debugger__ .dbg-header-meta {
|
|
15620
15695
|
font-size: 11px;
|
|
15621
|
-
color: #
|
|
15696
|
+
color: #4d6080;
|
|
15697
|
+
}
|
|
15698
|
+
|
|
15699
|
+
/* \u2500\u2500 \u9762\u677F\u5185\u5BB9\u533A \u2500\u2500 */
|
|
15700
|
+
#__snackkit_debugger__ .dbg-body {
|
|
15701
|
+
padding: 12px 14px;
|
|
15702
|
+
display: flex;
|
|
15703
|
+
flex-direction: column;
|
|
15704
|
+
gap: 10px;
|
|
15705
|
+
height: 420px;
|
|
15706
|
+
overflow: visible;
|
|
15707
|
+
}
|
|
15708
|
+
|
|
15709
|
+
/* \u2500\u2500 \u5B57\u6BB5\u884C \u2500\u2500 */
|
|
15710
|
+
#__snackkit_debugger__ .dbg-field {
|
|
15711
|
+
display: flex;
|
|
15712
|
+
flex-direction: column;
|
|
15713
|
+
gap: 5px;
|
|
15714
|
+
}
|
|
15715
|
+
#__snackkit_debugger__ .dbg-field-header {
|
|
15716
|
+
display: flex;
|
|
15717
|
+
align-items: center;
|
|
15718
|
+
justify-content: space-between;
|
|
15719
|
+
}
|
|
15720
|
+
#__snackkit_debugger__ .dbg-label {
|
|
15721
|
+
font-size: 10px;
|
|
15722
|
+
font-weight: 600;
|
|
15723
|
+
color: #5e72a0;
|
|
15622
15724
|
text-transform: uppercase;
|
|
15623
|
-
letter-spacing: 0.
|
|
15725
|
+
letter-spacing: 0.07em;
|
|
15624
15726
|
}
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15727
|
+
|
|
15728
|
+
/* \u2500\u2500 \u4E00\u952E\u590D\u5236\u5168\u90E8 JSON \u6309\u94AE \u2500\u2500 */
|
|
15729
|
+
#__snackkit_debugger__ .dbg-copy-all {
|
|
15730
|
+
display: flex;
|
|
15731
|
+
align-items: center;
|
|
15732
|
+
gap: 4px;
|
|
15733
|
+
background: transparent;
|
|
15734
|
+
border: 1px solid #2d3a55;
|
|
15628
15735
|
border-radius: 4px;
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
font-size:
|
|
15632
|
-
|
|
15736
|
+
padding: 2px 7px;
|
|
15737
|
+
color: #5e72a0;
|
|
15738
|
+
font-size: 10px;
|
|
15739
|
+
font-family: inherit;
|
|
15633
15740
|
cursor: pointer;
|
|
15741
|
+
transition: border-color 0.15s, color 0.15s, background 0.15s;
|
|
15634
15742
|
}
|
|
15635
|
-
#__snackkit_debugger__ .dbg-
|
|
15743
|
+
#__snackkit_debugger__ .dbg-copy-all:hover {
|
|
15744
|
+
border-color: #4f8ef7;
|
|
15745
|
+
color: #7aacfa;
|
|
15746
|
+
background: rgba(79,142,247,0.08);
|
|
15747
|
+
}
|
|
15748
|
+
#__snackkit_debugger__ .dbg-copy-all.done {
|
|
15749
|
+
border-color: #34d399;
|
|
15750
|
+
color: #34d399;
|
|
15751
|
+
}
|
|
15752
|
+
|
|
15753
|
+
/* \u2500\u2500 \u81EA\u5B9A\u4E49\u4E0B\u62C9 \u2500\u2500 */
|
|
15754
|
+
#__snackkit_debugger__ .dbg-select {
|
|
15755
|
+
position: relative;
|
|
15756
|
+
}
|
|
15757
|
+
#__snackkit_debugger__ .dbg-select-trigger {
|
|
15758
|
+
display: flex;
|
|
15759
|
+
align-items: center;
|
|
15760
|
+
justify-content: space-between;
|
|
15761
|
+
gap: 6px;
|
|
15762
|
+
background: #252f45;
|
|
15763
|
+
border: 1px solid #2d3a55;
|
|
15764
|
+
border-radius: 6px;
|
|
15765
|
+
padding: 6px 10px;
|
|
15766
|
+
cursor: pointer;
|
|
15767
|
+
transition: border-color 0.15s, background 0.15s;
|
|
15768
|
+
min-height: 32px;
|
|
15769
|
+
}
|
|
15770
|
+
#__snackkit_debugger__ .dbg-select-trigger:hover { border-color: #3d5070; background: #2d3a55; }
|
|
15771
|
+
#__snackkit_debugger__ .dbg-select.open .dbg-select-trigger {
|
|
15772
|
+
border-color: #4f8ef7;
|
|
15773
|
+
background: #2d3a55;
|
|
15774
|
+
}
|
|
15775
|
+
#__snackkit_debugger__ .dbg-select-val {
|
|
15776
|
+
flex: 1;
|
|
15777
|
+
overflow: hidden;
|
|
15778
|
+
text-overflow: ellipsis;
|
|
15779
|
+
white-space: nowrap;
|
|
15780
|
+
font-size: 12px;
|
|
15781
|
+
color: #b8ccec;
|
|
15782
|
+
}
|
|
15783
|
+
#__snackkit_debugger__ .dbg-select-val.placeholder { color: #3d5070; }
|
|
15784
|
+
#__snackkit_debugger__ .dbg-select-arrow {
|
|
15785
|
+
color: #3d5070;
|
|
15786
|
+
font-size: 10px;
|
|
15787
|
+
flex-shrink: 0;
|
|
15788
|
+
transition: transform 0.15s, color 0.15s;
|
|
15789
|
+
}
|
|
15790
|
+
#__snackkit_debugger__ .dbg-select.open .dbg-select-arrow {
|
|
15791
|
+
transform: rotate(180deg);
|
|
15792
|
+
color: #4f8ef7;
|
|
15793
|
+
}
|
|
15794
|
+
#__snackkit_debugger__ .dbg-select-dropdown {
|
|
15795
|
+
position: absolute;
|
|
15796
|
+
bottom: calc(100% + 4px);
|
|
15797
|
+
left: 0;
|
|
15798
|
+
right: 0;
|
|
15799
|
+
background: #1e2638;
|
|
15800
|
+
border: 1px solid #2d3a55;
|
|
15801
|
+
border-radius: 8px;
|
|
15802
|
+
box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
|
|
15803
|
+
overflow: hidden;
|
|
15804
|
+
opacity: 0;
|
|
15805
|
+
transform: translateY(4px);
|
|
15806
|
+
pointer-events: none;
|
|
15807
|
+
transition: opacity 0.14s, transform 0.14s;
|
|
15808
|
+
z-index: 100000;
|
|
15809
|
+
}
|
|
15810
|
+
#__snackkit_debugger__ .dbg-select.open .dbg-select-dropdown {
|
|
15811
|
+
opacity: 1;
|
|
15812
|
+
transform: translateY(0);
|
|
15813
|
+
pointer-events: auto;
|
|
15814
|
+
}
|
|
15815
|
+
#__snackkit_debugger__ .dbg-select-search {
|
|
15816
|
+
display: flex;
|
|
15817
|
+
align-items: center;
|
|
15818
|
+
gap: 6px;
|
|
15819
|
+
padding: 7px 10px;
|
|
15820
|
+
border-bottom: 1px solid #2d3a55;
|
|
15821
|
+
}
|
|
15822
|
+
#__snackkit_debugger__ .dbg-select-search-icon { color: #3d5070; font-size: 11px; flex-shrink: 0; }
|
|
15823
|
+
#__snackkit_debugger__ .dbg-select-search input {
|
|
15824
|
+
flex: 1;
|
|
15825
|
+
background: transparent;
|
|
15826
|
+
border: none;
|
|
15827
|
+
outline: none;
|
|
15828
|
+
color: #b8ccec;
|
|
15829
|
+
font-size: 12px;
|
|
15830
|
+
font-family: inherit;
|
|
15831
|
+
}
|
|
15832
|
+
#__snackkit_debugger__ .dbg-select-search input::placeholder { color: #3d5070; }
|
|
15833
|
+
#__snackkit_debugger__ .dbg-select-list {
|
|
15636
15834
|
max-height: 160px;
|
|
15637
15835
|
overflow-y: auto;
|
|
15638
|
-
border: 1px solid #334155;
|
|
15639
|
-
border-radius: 4px;
|
|
15640
|
-
background: #0f172a;
|
|
15641
15836
|
}
|
|
15642
|
-
#__snackkit_debugger__ .dbg-
|
|
15643
|
-
|
|
15644
|
-
|
|
15837
|
+
#__snackkit_debugger__ .dbg-select-list::-webkit-scrollbar { width: 3px; }
|
|
15838
|
+
#__snackkit_debugger__ .dbg-select-list::-webkit-scrollbar-track { background: transparent; }
|
|
15839
|
+
#__snackkit_debugger__ .dbg-select-list::-webkit-scrollbar-thumb { background: #2d3a55; border-radius: 2px; }
|
|
15840
|
+
#__snackkit_debugger__ .dbg-select-option {
|
|
15841
|
+
padding: 7px 10px;
|
|
15645
15842
|
cursor: pointer;
|
|
15843
|
+
font-size: 12px;
|
|
15844
|
+
color: #8aa4c8;
|
|
15845
|
+
transition: background 0.1s, color 0.1s;
|
|
15846
|
+
overflow: hidden;
|
|
15847
|
+
text-overflow: ellipsis;
|
|
15848
|
+
white-space: nowrap;
|
|
15849
|
+
}
|
|
15850
|
+
#__snackkit_debugger__ .dbg-select-option:hover { background: #2d3a55; color: #dce8fa; }
|
|
15851
|
+
#__snackkit_debugger__ .dbg-select-option.active { color: #7aacfa; background: #1e3060; }
|
|
15852
|
+
#__snackkit_debugger__ .dbg-select-option.hidden { display: none; }
|
|
15853
|
+
#__snackkit_debugger__ .dbg-select-empty {
|
|
15854
|
+
padding: 12px 10px;
|
|
15855
|
+
font-size: 12px;
|
|
15856
|
+
color: #3d5070;
|
|
15857
|
+
text-align: center;
|
|
15858
|
+
}
|
|
15859
|
+
|
|
15860
|
+
/* \u2500\u2500 \u8DEF\u7531\u5217\u8868 \u2500\u2500 */
|
|
15861
|
+
#__snackkit_debugger__ .dbg-ctx-field {
|
|
15862
|
+
flex: 1;
|
|
15863
|
+
min-height: 0;
|
|
15864
|
+
display: flex;
|
|
15865
|
+
flex-direction: column;
|
|
15866
|
+
gap: 5px;
|
|
15867
|
+
}
|
|
15868
|
+
#__snackkit_debugger__ .dbg-ctx-wrap {
|
|
15869
|
+
flex: 1;
|
|
15870
|
+
min-height: 0;
|
|
15871
|
+
border: 1px solid #2d3a55;
|
|
15872
|
+
border-radius: 6px;
|
|
15873
|
+
overflow: hidden;
|
|
15874
|
+
background: #252f45;
|
|
15875
|
+
display: flex;
|
|
15876
|
+
flex-direction: column;
|
|
15877
|
+
}
|
|
15878
|
+
#__snackkit_debugger__ .dbg-ctx-search {
|
|
15646
15879
|
display: flex;
|
|
15647
|
-
justify-content: space-between;
|
|
15648
15880
|
align-items: center;
|
|
15881
|
+
gap: 6px;
|
|
15882
|
+
padding: 6px 10px;
|
|
15883
|
+
border-bottom: 1px solid #2d3a55;
|
|
15884
|
+
background: #1e2638;
|
|
15885
|
+
}
|
|
15886
|
+
#__snackkit_debugger__ .dbg-ctx-search input {
|
|
15887
|
+
flex: 1;
|
|
15888
|
+
background: transparent;
|
|
15889
|
+
border: none;
|
|
15890
|
+
outline: none;
|
|
15891
|
+
color: #b8ccec;
|
|
15892
|
+
font-size: 12px;
|
|
15893
|
+
font-family: inherit;
|
|
15894
|
+
}
|
|
15895
|
+
#__snackkit_debugger__ .dbg-ctx-search input::placeholder { color: #3d5070; }
|
|
15896
|
+
#__snackkit_debugger__ .dbg-ctx-list {
|
|
15897
|
+
flex: 1;
|
|
15898
|
+
min-height: 0;
|
|
15899
|
+
overflow-y: auto;
|
|
15900
|
+
}
|
|
15901
|
+
#__snackkit_debugger__ .dbg-ctx-list::-webkit-scrollbar { width: 3px; }
|
|
15902
|
+
#__snackkit_debugger__ .dbg-ctx-list::-webkit-scrollbar-track { background: transparent; }
|
|
15903
|
+
#__snackkit_debugger__ .dbg-ctx-list::-webkit-scrollbar-thumb { background: #2d3a55; border-radius: 2px; }
|
|
15904
|
+
#__snackkit_debugger__ .dbg-ctx-item {
|
|
15905
|
+
padding: 5px 10px;
|
|
15906
|
+
cursor: pointer;
|
|
15907
|
+
display: grid;
|
|
15908
|
+
grid-template-columns: minmax(80px, 148px) 1fr auto;
|
|
15909
|
+
gap: 8px;
|
|
15910
|
+
align-items: center;
|
|
15911
|
+
border-bottom: 1px solid #1e2638;
|
|
15912
|
+
transition: background 0.1s;
|
|
15649
15913
|
}
|
|
15650
15914
|
#__snackkit_debugger__ .dbg-ctx-item:last-child { border-bottom: none; }
|
|
15651
|
-
#__snackkit_debugger__ .dbg-ctx-item:hover { background: #
|
|
15652
|
-
#__snackkit_debugger__ .dbg-ctx-
|
|
15653
|
-
#__snackkit_debugger__ .dbg-ctx-
|
|
15654
|
-
|
|
15915
|
+
#__snackkit_debugger__ .dbg-ctx-item:hover { background: #2d3a55; }
|
|
15916
|
+
#__snackkit_debugger__ .dbg-ctx-item.hidden { display: none; }
|
|
15917
|
+
#__snackkit_debugger__ .dbg-ctx-key {
|
|
15918
|
+
font-size: 12px;
|
|
15919
|
+
color: #7aacfa;
|
|
15920
|
+
overflow: hidden;
|
|
15921
|
+
text-overflow: ellipsis;
|
|
15922
|
+
white-space: nowrap;
|
|
15923
|
+
}
|
|
15924
|
+
#__snackkit_debugger__ .dbg-ctx-val {
|
|
15925
|
+
font-size: 11px;
|
|
15926
|
+
color: #4d6080;
|
|
15927
|
+
overflow: hidden;
|
|
15928
|
+
text-overflow: ellipsis;
|
|
15929
|
+
white-space: nowrap;
|
|
15930
|
+
transition: color 0.1s;
|
|
15931
|
+
}
|
|
15932
|
+
#__snackkit_debugger__ .dbg-ctx-item:hover .dbg-ctx-val { color: #7a90b0; }
|
|
15933
|
+
#__snackkit_debugger__ .dbg-ctx-copy {
|
|
15934
|
+
font-size: 11px;
|
|
15935
|
+
color: #3d5070;
|
|
15936
|
+
opacity: 0;
|
|
15937
|
+
flex-shrink: 0;
|
|
15938
|
+
transition: opacity 0.1s, color 0.1s;
|
|
15939
|
+
}
|
|
15940
|
+
#__snackkit_debugger__ .dbg-ctx-item:hover .dbg-ctx-copy { opacity: 1; color: #5e72a0; }
|
|
15941
|
+
#__snackkit_debugger__ .dbg-ctx-item.copied .dbg-ctx-copy { color: #34d399; opacity: 1; }
|
|
15942
|
+
#__snackkit_debugger__ .dbg-ctx-empty {
|
|
15943
|
+
padding: 16px 10px;
|
|
15944
|
+
font-size: 12px;
|
|
15945
|
+
color: #3d5070;
|
|
15946
|
+
text-align: center;
|
|
15947
|
+
}
|
|
15948
|
+
|
|
15949
|
+
/* \u2500\u2500 \u5E95\u90E8\u72B6\u6001\u680F \u2500\u2500 */
|
|
15950
|
+
#__snackkit_debugger__ .dbg-footer {
|
|
15951
|
+
display: flex;
|
|
15952
|
+
align-items: center;
|
|
15953
|
+
gap: 6px;
|
|
15954
|
+
padding: 7px 14px;
|
|
15955
|
+
background: #171e2e;
|
|
15956
|
+
border-top: 1px solid #2d3a55;
|
|
15957
|
+
border-radius: 0 0 12px 12px;
|
|
15655
15958
|
font-size: 11px;
|
|
15656
|
-
color: #
|
|
15657
|
-
|
|
15658
|
-
|
|
15959
|
+
color: #4d6080;
|
|
15960
|
+
min-height: 30px;
|
|
15961
|
+
}
|
|
15962
|
+
#__snackkit_debugger__ .dbg-footer.ok { color: #34d399; }
|
|
15963
|
+
#__snackkit_debugger__ .dbg-footer.err { color: #f87171; }
|
|
15964
|
+
#__snackkit_debugger__ .dbg-footer-dot {
|
|
15965
|
+
width: 4px;
|
|
15966
|
+
height: 4px;
|
|
15967
|
+
border-radius: 50%;
|
|
15968
|
+
background: currentColor;
|
|
15969
|
+
flex-shrink: 0;
|
|
15970
|
+
}
|
|
15971
|
+
|
|
15972
|
+
@keyframes dbg-pulse {
|
|
15973
|
+
0%, 100% { opacity: 1; }
|
|
15974
|
+
50% { opacity: 0.35; }
|
|
15659
15975
|
}
|
|
15660
|
-
#__snackkit_debugger__ .dbg-status.ok { color: #22c55e; }
|
|
15661
|
-
#__snackkit_debugger__ .dbg-status.err { color: #ef4444; }
|
|
15662
15976
|
`;
|
|
15977
|
+
var SearchSelect = class {
|
|
15978
|
+
constructor(onChange) {
|
|
15979
|
+
this.options = [];
|
|
15980
|
+
this.selected = "";
|
|
15981
|
+
this.onChange = onChange;
|
|
15982
|
+
this.el = document.createElement("div");
|
|
15983
|
+
this.el.className = "dbg-select";
|
|
15984
|
+
this.trigger = document.createElement("div");
|
|
15985
|
+
this.trigger.className = "dbg-select-trigger";
|
|
15986
|
+
this.valEl = document.createElement("span");
|
|
15987
|
+
this.valEl.className = "dbg-select-val placeholder";
|
|
15988
|
+
const arrow = document.createElement("span");
|
|
15989
|
+
arrow.className = "dbg-select-arrow";
|
|
15990
|
+
arrow.textContent = "\u25BE";
|
|
15991
|
+
this.trigger.appendChild(this.valEl);
|
|
15992
|
+
this.trigger.appendChild(arrow);
|
|
15993
|
+
this.dropdown = document.createElement("div");
|
|
15994
|
+
this.dropdown.className = "dbg-select-dropdown";
|
|
15995
|
+
const searchWrap = document.createElement("div");
|
|
15996
|
+
searchWrap.className = "dbg-select-search";
|
|
15997
|
+
const searchIcon = document.createElement("span");
|
|
15998
|
+
searchIcon.className = "dbg-select-search-icon";
|
|
15999
|
+
searchIcon.textContent = "\u2315";
|
|
16000
|
+
this.searchInput = document.createElement("input");
|
|
16001
|
+
this.searchInput.type = "text";
|
|
16002
|
+
this.searchInput.placeholder = T.search();
|
|
16003
|
+
searchWrap.appendChild(searchIcon);
|
|
16004
|
+
searchWrap.appendChild(this.searchInput);
|
|
16005
|
+
this.listEl = document.createElement("div");
|
|
16006
|
+
this.listEl.className = "dbg-select-list";
|
|
16007
|
+
this.dropdown.appendChild(searchWrap);
|
|
16008
|
+
this.dropdown.appendChild(this.listEl);
|
|
16009
|
+
this.el.appendChild(this.trigger);
|
|
16010
|
+
this.el.appendChild(this.dropdown);
|
|
16011
|
+
this.bindEvents();
|
|
16012
|
+
}
|
|
16013
|
+
bindEvents() {
|
|
16014
|
+
this.trigger.addEventListener("click", (e) => {
|
|
16015
|
+
e.stopPropagation();
|
|
16016
|
+
const isOpen = this.el.classList.contains("open");
|
|
16017
|
+
document.querySelectorAll("#__snackkit_debugger__ .dbg-select.open").forEach((el) => {
|
|
16018
|
+
if (el !== this.el) el.classList.remove("open");
|
|
16019
|
+
});
|
|
16020
|
+
this.el.classList.toggle("open", !isOpen);
|
|
16021
|
+
if (!isOpen) {
|
|
16022
|
+
this.searchInput.value = "";
|
|
16023
|
+
this.filterOptions("");
|
|
16024
|
+
setTimeout(() => this.searchInput.focus(), 50);
|
|
16025
|
+
}
|
|
16026
|
+
});
|
|
16027
|
+
this.searchInput.addEventListener("input", () => {
|
|
16028
|
+
this.filterOptions(this.searchInput.value);
|
|
16029
|
+
});
|
|
16030
|
+
this.searchInput.addEventListener("click", (e) => e.stopPropagation());
|
|
16031
|
+
document.addEventListener("click", () => {
|
|
16032
|
+
this.el.classList.remove("open");
|
|
16033
|
+
});
|
|
16034
|
+
}
|
|
16035
|
+
filterOptions(query) {
|
|
16036
|
+
const q = query.toLowerCase();
|
|
16037
|
+
let visibleCount = 0;
|
|
16038
|
+
this.listEl.querySelectorAll(".dbg-select-option").forEach((opt) => {
|
|
16039
|
+
const match = !q || opt.textContent.toLowerCase().includes(q);
|
|
16040
|
+
opt.classList.toggle("hidden", !match);
|
|
16041
|
+
if (match) visibleCount++;
|
|
16042
|
+
});
|
|
16043
|
+
let emptyEl = this.listEl.querySelector(".dbg-select-empty");
|
|
16044
|
+
if (visibleCount === 0) {
|
|
16045
|
+
if (!emptyEl) {
|
|
16046
|
+
emptyEl = document.createElement("div");
|
|
16047
|
+
emptyEl.className = "dbg-select-empty";
|
|
16048
|
+
emptyEl.textContent = T.noMatch();
|
|
16049
|
+
this.listEl.appendChild(emptyEl);
|
|
16050
|
+
}
|
|
16051
|
+
} else {
|
|
16052
|
+
emptyEl?.remove();
|
|
16053
|
+
}
|
|
16054
|
+
}
|
|
16055
|
+
/** 更新选项列表 */
|
|
16056
|
+
setOptions(options, placeholder) {
|
|
16057
|
+
this.options = options;
|
|
16058
|
+
this.listEl.innerHTML = "";
|
|
16059
|
+
this.valEl.textContent = placeholder;
|
|
16060
|
+
this.valEl.className = "dbg-select-val placeholder";
|
|
16061
|
+
this.selected = "";
|
|
16062
|
+
options.forEach(({ value, label }) => {
|
|
16063
|
+
const opt = document.createElement("div");
|
|
16064
|
+
opt.className = "dbg-select-option";
|
|
16065
|
+
opt.dataset["value"] = value;
|
|
16066
|
+
opt.textContent = label;
|
|
16067
|
+
opt.setAttribute("title", label);
|
|
16068
|
+
opt.addEventListener("click", (e) => {
|
|
16069
|
+
e.stopPropagation();
|
|
16070
|
+
this.select(value, label);
|
|
16071
|
+
this.el.classList.remove("open");
|
|
16072
|
+
});
|
|
16073
|
+
this.listEl.appendChild(opt);
|
|
16074
|
+
});
|
|
16075
|
+
}
|
|
16076
|
+
/** 选中某个值(不触发 onChange) */
|
|
16077
|
+
setValue(value) {
|
|
16078
|
+
const opt = this.options.find((o) => o.value === value);
|
|
16079
|
+
if (opt) this.select(opt.value, opt.label, false);
|
|
16080
|
+
}
|
|
16081
|
+
select(value, label, emit = true) {
|
|
16082
|
+
this.selected = value;
|
|
16083
|
+
this.valEl.textContent = label;
|
|
16084
|
+
this.valEl.className = "dbg-select-val";
|
|
16085
|
+
this.listEl.querySelectorAll(".dbg-select-option").forEach((el) => {
|
|
16086
|
+
el.classList.toggle("active", el.dataset["value"] === value);
|
|
16087
|
+
});
|
|
16088
|
+
if (emit) this.onChange(value);
|
|
16089
|
+
}
|
|
16090
|
+
getValue() {
|
|
16091
|
+
return this.selected;
|
|
16092
|
+
}
|
|
16093
|
+
getElement() {
|
|
16094
|
+
return this.el;
|
|
16095
|
+
}
|
|
16096
|
+
};
|
|
15663
16097
|
var Debugger = class _Debugger {
|
|
15664
16098
|
constructor(options) {
|
|
15665
16099
|
this.servers = [];
|
|
16100
|
+
this.currentCtxMap = {};
|
|
15666
16101
|
this.options = options;
|
|
15667
16102
|
this.gateways = Array.isArray(options.gateways) ? options.gateways : [options.gateways];
|
|
15668
16103
|
}
|
|
@@ -15725,146 +16160,167 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
15725
16160
|
const panel = document.createElement("div");
|
|
15726
16161
|
panel.className = "dbg-panel";
|
|
15727
16162
|
this.panelEl = panel;
|
|
15728
|
-
const
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
16163
|
+
const header = document.createElement("div");
|
|
16164
|
+
header.className = "dbg-header";
|
|
16165
|
+
const headerLeft = document.createElement("div");
|
|
16166
|
+
headerLeft.className = "dbg-header-left";
|
|
16167
|
+
this.headerDot = document.createElement("span");
|
|
16168
|
+
this.headerDot.className = "dbg-header-dot loading";
|
|
16169
|
+
const headerTitle = document.createElement("span");
|
|
16170
|
+
headerTitle.className = "dbg-header-title";
|
|
16171
|
+
headerTitle.textContent = "Snack Kit Debugger";
|
|
16172
|
+
headerLeft.appendChild(this.headerDot);
|
|
16173
|
+
headerLeft.appendChild(headerTitle);
|
|
16174
|
+
header.appendChild(headerLeft);
|
|
16175
|
+
panel.appendChild(header);
|
|
16176
|
+
const body = document.createElement("div");
|
|
16177
|
+
body.className = "dbg-body";
|
|
16178
|
+
this.gwVersion = document.createElement("span");
|
|
16179
|
+
this.gwVersion.className = "dbg-header-meta";
|
|
16180
|
+
this.gwSelect = new SearchSelect((val) => this.onGatewayChange(val));
|
|
16181
|
+
this.gwSelect.setOptions(this.gateways.map((g) => ({ value: g, label: g })), T.selectGateway());
|
|
16182
|
+
body.appendChild(this.createFieldWithAction(T.gateway(), this.gwVersion, this.gwSelect.getElement()));
|
|
16183
|
+
this.typeSelect = new SearchSelect((val) => this.onTypeChange(val));
|
|
16184
|
+
body.appendChild(this.createField(T.tag(), this.typeSelect.getElement()));
|
|
16185
|
+
this.serverSelect = new SearchSelect((val) => this.onServerChange(val));
|
|
16186
|
+
body.appendChild(this.createField(T.server(), this.serverSelect.getElement()));
|
|
16187
|
+
const ctxWrap = document.createElement("div");
|
|
16188
|
+
ctxWrap.className = "dbg-ctx-wrap";
|
|
16189
|
+
const ctxSearch = document.createElement("div");
|
|
16190
|
+
ctxSearch.className = "dbg-ctx-search";
|
|
16191
|
+
const ctxSearchIcon = document.createElement("span");
|
|
16192
|
+
ctxSearchIcon.className = "dbg-select-search-icon";
|
|
16193
|
+
ctxSearchIcon.textContent = "\u2315";
|
|
16194
|
+
this.ctxSearchInput = document.createElement("input");
|
|
16195
|
+
this.ctxSearchInput.type = "text";
|
|
16196
|
+
this.ctxSearchInput.placeholder = T.filterCtx();
|
|
16197
|
+
this.ctxSearchInput.addEventListener("input", () => this.filterCtx(this.ctxSearchInput.value));
|
|
16198
|
+
ctxSearch.appendChild(ctxSearchIcon);
|
|
16199
|
+
ctxSearch.appendChild(this.ctxSearchInput);
|
|
16200
|
+
this.ctxList = document.createElement("div");
|
|
16201
|
+
this.ctxList.className = "dbg-ctx-list";
|
|
16202
|
+
ctxWrap.appendChild(ctxSearch);
|
|
16203
|
+
ctxWrap.appendChild(this.ctxList);
|
|
16204
|
+
this.copyAllBtn = document.createElement("button");
|
|
16205
|
+
this.copyAllBtn.className = "dbg-copy-all";
|
|
16206
|
+
this.copyAllBtn.textContent = T.copyAll();
|
|
16207
|
+
this.copyAllBtn.setAttribute("title", isChinese() ? "\u5C06\u5168\u90E8\u4E0A\u4E0B\u6587\u590D\u5236\u4E3A JSON\uFF0C\u53EF\u4F5C\u4E3A Context.load({...}) \u7684\u53C2\u6570" : "Copy all ctx entries as JSON for Context.load({...})");
|
|
16208
|
+
this.copyAllBtn.addEventListener("click", (e) => {
|
|
16209
|
+
e.stopPropagation();
|
|
16210
|
+
this.copyAllCtx();
|
|
15735
16211
|
});
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
panel.appendChild(
|
|
15740
|
-
const
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
this.typeSelect = typeSelect;
|
|
15745
|
-
panel.appendChild(typeRow);
|
|
15746
|
-
const serverRow = this.createRow("\u670D\u52A1 (Server)");
|
|
15747
|
-
const serverSelect = document.createElement("select");
|
|
15748
|
-
serverSelect.addEventListener("change", () => this.onServerChange());
|
|
15749
|
-
serverRow.appendChild(serverSelect);
|
|
15750
|
-
this.serverSelect = serverSelect;
|
|
15751
|
-
panel.appendChild(serverRow);
|
|
15752
|
-
const ctxRow = this.createRow("\u8DEF\u7531 (Ctx) - \u70B9\u51FB\u590D\u5236");
|
|
15753
|
-
const ctxList = document.createElement("div");
|
|
15754
|
-
ctxList.className = "dbg-ctx-list";
|
|
15755
|
-
ctxRow.appendChild(ctxList);
|
|
15756
|
-
this.ctxList = ctxList;
|
|
15757
|
-
panel.appendChild(ctxRow);
|
|
15758
|
-
const status = document.createElement("div");
|
|
15759
|
-
status.className = "dbg-status";
|
|
15760
|
-
this.statusEl = status;
|
|
15761
|
-
panel.appendChild(status);
|
|
16212
|
+
const ctxField = this.createFieldWithAction(T.ctxLabel(), this.copyAllBtn, ctxWrap);
|
|
16213
|
+
ctxField.classList.add("dbg-ctx-field");
|
|
16214
|
+
body.appendChild(ctxField);
|
|
16215
|
+
panel.appendChild(body);
|
|
16216
|
+
const footer = document.createElement("div");
|
|
16217
|
+
footer.className = "dbg-footer";
|
|
16218
|
+
this.footerEl = footer;
|
|
16219
|
+
panel.appendChild(footer);
|
|
15762
16220
|
const toggle = document.createElement("button");
|
|
15763
16221
|
toggle.className = "dbg-toggle";
|
|
15764
16222
|
toggle.textContent = "\u{1F41B}";
|
|
15765
16223
|
toggle.setAttribute("title", "Snack Debugger");
|
|
15766
|
-
toggle.addEventListener("click", () =>
|
|
16224
|
+
toggle.addEventListener("click", (e) => {
|
|
16225
|
+
e.stopPropagation();
|
|
16226
|
+
panel.classList.toggle("open");
|
|
16227
|
+
});
|
|
15767
16228
|
root.appendChild(panel);
|
|
15768
16229
|
root.appendChild(toggle);
|
|
15769
16230
|
document.body.appendChild(root);
|
|
15770
16231
|
}
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
16232
|
+
/** 创建普通字段行(label + content) */
|
|
16233
|
+
createField(label, content) {
|
|
16234
|
+
const field = document.createElement("div");
|
|
16235
|
+
field.className = "dbg-field";
|
|
16236
|
+
const lbl = document.createElement("div");
|
|
16237
|
+
lbl.className = "dbg-label";
|
|
16238
|
+
lbl.textContent = label;
|
|
16239
|
+
field.appendChild(lbl);
|
|
16240
|
+
field.appendChild(content);
|
|
16241
|
+
return field;
|
|
16242
|
+
}
|
|
16243
|
+
/** 创建带操作按钮的字段行(label + action button + content) */
|
|
16244
|
+
createFieldWithAction(label, action, content) {
|
|
16245
|
+
const field = document.createElement("div");
|
|
16246
|
+
field.className = "dbg-field";
|
|
16247
|
+
const fieldHeader = document.createElement("div");
|
|
16248
|
+
fieldHeader.className = "dbg-field-header";
|
|
16249
|
+
const lbl = document.createElement("div");
|
|
16250
|
+
lbl.className = "dbg-label";
|
|
15775
16251
|
lbl.textContent = label;
|
|
15776
|
-
|
|
15777
|
-
|
|
16252
|
+
fieldHeader.appendChild(lbl);
|
|
16253
|
+
fieldHeader.appendChild(action);
|
|
16254
|
+
field.appendChild(fieldHeader);
|
|
16255
|
+
field.appendChild(content);
|
|
16256
|
+
return field;
|
|
15778
16257
|
}
|
|
15779
16258
|
/** 恢复上次持久化的状态 */
|
|
15780
16259
|
async restoreState() {
|
|
15781
16260
|
const savedGw = localStorage.getItem(KEY_GATEWAY);
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
await this.loadServers(this.gwSelect.value);
|
|
16261
|
+
const gw = savedGw && this.gateways.includes(savedGw) ? savedGw : this.gateways[0];
|
|
16262
|
+
this.gwSelect.setValue(gw);
|
|
16263
|
+
await this.loadServers(gw);
|
|
15786
16264
|
const savedType = localStorage.getItem(KEY_TYPE);
|
|
15787
16265
|
if (savedType) {
|
|
15788
|
-
this.typeSelect.
|
|
16266
|
+
this.typeSelect.setValue(savedType);
|
|
15789
16267
|
this.renderServerOptions(savedType);
|
|
15790
16268
|
}
|
|
15791
16269
|
const savedServer = localStorage.getItem(KEY_SERVER);
|
|
15792
|
-
if (savedServer && this.
|
|
15793
|
-
this.serverSelect.
|
|
16270
|
+
if (savedServer && this.servers.find((s) => s.key === savedServer)) {
|
|
16271
|
+
this.serverSelect.setValue(savedServer);
|
|
15794
16272
|
await this.applyServer(savedServer);
|
|
15795
16273
|
}
|
|
15796
16274
|
}
|
|
15797
|
-
|
|
15798
|
-
async onGatewayChange() {
|
|
15799
|
-
const gw = this.gwSelect.value;
|
|
16275
|
+
async onGatewayChange(gw) {
|
|
15800
16276
|
localStorage.setItem(KEY_GATEWAY, gw);
|
|
16277
|
+
this.gwVersion.textContent = "";
|
|
15801
16278
|
await this.loadServers(gw);
|
|
15802
16279
|
}
|
|
15803
|
-
|
|
15804
|
-
onTypeChange() {
|
|
15805
|
-
const type = this.typeSelect.value;
|
|
16280
|
+
onTypeChange(type) {
|
|
15806
16281
|
localStorage.setItem(KEY_TYPE, type);
|
|
15807
16282
|
this.renderServerOptions(type);
|
|
15808
16283
|
}
|
|
15809
|
-
|
|
15810
|
-
async onServerChange() {
|
|
15811
|
-
const key = this.serverSelect.value;
|
|
16284
|
+
async onServerChange(key) {
|
|
15812
16285
|
localStorage.setItem(KEY_SERVER, key);
|
|
15813
16286
|
await this.applyServer(key);
|
|
15814
16287
|
}
|
|
15815
|
-
/**
|
|
15816
|
-
* 从网关加载服务列表
|
|
15817
|
-
* @param gwUrl 网关 URL
|
|
15818
|
-
*/
|
|
16288
|
+
/** 从网关加载服务列表 */
|
|
15819
16289
|
async loadServers(gwUrl) {
|
|
15820
|
-
this.
|
|
16290
|
+
this.setHeader("loading");
|
|
16291
|
+
this.setFooter(T.loading(), "");
|
|
15821
16292
|
const result = await Get(`${gwUrl}/web-debug/host/list`, {
|
|
15822
16293
|
cache: true,
|
|
15823
16294
|
timeout: this.options.timeout
|
|
15824
16295
|
});
|
|
15825
16296
|
if (result.error) {
|
|
15826
|
-
this.
|
|
16297
|
+
this.setHeader("err");
|
|
16298
|
+
this.setFooter(T.loadFailed(result.error.message), "err");
|
|
15827
16299
|
return;
|
|
15828
16300
|
}
|
|
15829
16301
|
this.servers = result.data ?? [];
|
|
15830
16302
|
this.renderTypeOptions();
|
|
15831
|
-
this.
|
|
16303
|
+
this.setHeader("ok");
|
|
16304
|
+
this.setFooter(T.loaded(this.servers.length), "ok");
|
|
15832
16305
|
}
|
|
15833
|
-
/**
|
|
16306
|
+
/** 渲染标签选项 */
|
|
15834
16307
|
renderTypeOptions() {
|
|
15835
|
-
const types = [...new Set(this.servers.map((s) => s.type))];
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
this.typeSelect.appendChild(allOpt);
|
|
15841
|
-
types.forEach((t) => {
|
|
15842
|
-
const opt = document.createElement("option");
|
|
15843
|
-
opt.value = t;
|
|
15844
|
-
opt.textContent = t;
|
|
15845
|
-
this.typeSelect.appendChild(opt);
|
|
15846
|
-
});
|
|
15847
|
-
this.renderServerOptions(this.typeSelect.value);
|
|
16308
|
+
const types = [...new Set(this.servers.map((s) => s.type).filter(Boolean))];
|
|
16309
|
+
const opts = [{ value: "", label: T.allTags() }, ...types.map((t) => ({ value: t, label: t }))];
|
|
16310
|
+
this.typeSelect.setOptions(opts, T.allTags());
|
|
16311
|
+
this.typeSelect.setValue("");
|
|
16312
|
+
this.renderServerOptions("");
|
|
15848
16313
|
}
|
|
15849
|
-
/**
|
|
16314
|
+
/** 根据标签渲染服务选项 */
|
|
15850
16315
|
renderServerOptions(type) {
|
|
15851
16316
|
const filtered = type ? this.servers.filter((s) => s.type === type) : this.servers;
|
|
15852
|
-
this.serverSelect.
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
this.
|
|
15857
|
-
filtered.forEach((s) => {
|
|
15858
|
-
const opt = document.createElement("option");
|
|
15859
|
-
opt.value = s.key;
|
|
15860
|
-
opt.textContent = `${s.name} (${s.key})`;
|
|
15861
|
-
this.serverSelect.appendChild(opt);
|
|
15862
|
-
});
|
|
16317
|
+
this.serverSelect.setOptions(
|
|
16318
|
+
filtered.map((s) => ({ value: s.key, label: `${s.name} (${s.key})` })),
|
|
16319
|
+
T.selectServer()
|
|
16320
|
+
);
|
|
16321
|
+
this.renderCtxList({});
|
|
15863
16322
|
}
|
|
15864
|
-
/**
|
|
15865
|
-
* 切换目标服务,重新加载 Context 路由映射
|
|
15866
|
-
* @param key 服务 key
|
|
15867
|
-
*/
|
|
16323
|
+
/** 切换目标服务,重新加载 Context 路由映射 */
|
|
15868
16324
|
async applyServer(key) {
|
|
15869
16325
|
if (!key) {
|
|
15870
16326
|
this.renderCtxList({});
|
|
@@ -15872,56 +16328,105 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
15872
16328
|
}
|
|
15873
16329
|
const server = this.servers.find((s) => s.key === key);
|
|
15874
16330
|
if (!server) return;
|
|
15875
|
-
this.
|
|
16331
|
+
this.setFooter(T.switching(), "");
|
|
15876
16332
|
try {
|
|
15877
16333
|
await Context.load(server.origin, this.options.timeout);
|
|
15878
|
-
const ctxMap = {};
|
|
15879
16334
|
const res = await fetch(`${server.origin}/ngw/context`);
|
|
15880
16335
|
const raw = res.ok ? await res.json() : {};
|
|
16336
|
+
const ctxMap = {};
|
|
15881
16337
|
for (const [k, v] of Object.entries(raw)) {
|
|
15882
16338
|
if (k !== "$info" && typeof v === "string") ctxMap[k] = v;
|
|
15883
16339
|
}
|
|
16340
|
+
const info = Context.info;
|
|
16341
|
+
if (info) this.gwVersion.textContent = `v${info.version}`;
|
|
15884
16342
|
this.renderCtxList(ctxMap);
|
|
15885
|
-
|
|
16343
|
+
const count = Object.keys(ctxMap).length;
|
|
16344
|
+
this.setFooter(T.routes(server.name, count), "ok");
|
|
15886
16345
|
} catch (err) {
|
|
15887
16346
|
const msg = err instanceof Error ? err.message : String(err);
|
|
15888
|
-
this.
|
|
16347
|
+
this.setFooter(T.switchFailed(msg), "err");
|
|
15889
16348
|
}
|
|
15890
16349
|
}
|
|
15891
16350
|
/** 渲染路由列表 */
|
|
15892
16351
|
renderCtxList(ctxMap) {
|
|
16352
|
+
this.currentCtxMap = ctxMap;
|
|
15893
16353
|
this.ctxList.innerHTML = "";
|
|
16354
|
+
this.ctxSearchInput.value = "";
|
|
15894
16355
|
const entries = Object.entries(ctxMap);
|
|
15895
16356
|
if (entries.length === 0) {
|
|
15896
|
-
|
|
16357
|
+
const empty = document.createElement("div");
|
|
16358
|
+
empty.className = "dbg-ctx-empty";
|
|
16359
|
+
empty.textContent = T.selectFirst();
|
|
16360
|
+
this.ctxList.appendChild(empty);
|
|
15897
16361
|
return;
|
|
15898
16362
|
}
|
|
15899
16363
|
entries.forEach(([k, v]) => {
|
|
15900
16364
|
const item = document.createElement("div");
|
|
15901
16365
|
item.className = "dbg-ctx-item";
|
|
16366
|
+
item.dataset["key"] = k;
|
|
15902
16367
|
const keySpan = document.createElement("span");
|
|
15903
16368
|
keySpan.className = "dbg-ctx-key";
|
|
15904
16369
|
keySpan.textContent = k;
|
|
16370
|
+
keySpan.setAttribute("title", k);
|
|
15905
16371
|
const valSpan = document.createElement("span");
|
|
15906
16372
|
valSpan.className = "dbg-ctx-val";
|
|
15907
16373
|
valSpan.textContent = v;
|
|
15908
|
-
valSpan.setAttribute("title", v);
|
|
16374
|
+
valSpan.setAttribute("title", `${k} \u2192 ${v}`);
|
|
16375
|
+
const copyIcon = document.createElement("span");
|
|
16376
|
+
copyIcon.className = "dbg-ctx-copy";
|
|
16377
|
+
copyIcon.textContent = "\u2398";
|
|
15909
16378
|
item.appendChild(keySpan);
|
|
15910
16379
|
item.appendChild(valSpan);
|
|
15911
|
-
item.
|
|
16380
|
+
item.appendChild(copyIcon);
|
|
16381
|
+
item.addEventListener("click", () => this.copyCtxItem(item, k));
|
|
15912
16382
|
this.ctxList.appendChild(item);
|
|
15913
16383
|
});
|
|
15914
16384
|
}
|
|
15915
|
-
/**
|
|
15916
|
-
|
|
16385
|
+
/** 过滤路由列表 */
|
|
16386
|
+
filterCtx(query) {
|
|
16387
|
+
const q = query.toLowerCase();
|
|
16388
|
+
this.ctxList.querySelectorAll(".dbg-ctx-item").forEach((item) => {
|
|
16389
|
+
const key = item.dataset["key"] ?? "";
|
|
16390
|
+
item.classList.toggle("hidden", !!q && !key.toLowerCase().includes(q));
|
|
16391
|
+
});
|
|
16392
|
+
}
|
|
16393
|
+
/** 复制单个 ctx key */
|
|
16394
|
+
copyCtxItem(item, text) {
|
|
15917
16395
|
navigator.clipboard.writeText(text).then(() => {
|
|
15918
|
-
|
|
15919
|
-
|
|
16396
|
+
item.classList.add("copied");
|
|
16397
|
+
const icon = item.querySelector(".dbg-ctx-copy");
|
|
16398
|
+
if (icon) icon.textContent = "\u2713";
|
|
16399
|
+
setTimeout(() => {
|
|
16400
|
+
item.classList.remove("copied");
|
|
16401
|
+
const ic = item.querySelector(".dbg-ctx-copy");
|
|
16402
|
+
if (ic) ic.textContent = "\u2398";
|
|
16403
|
+
}, 1500);
|
|
16404
|
+
this.setFooter(T.copied(text), "ok");
|
|
16405
|
+
setTimeout(() => this.setFooter("", ""), 2e3);
|
|
16406
|
+
});
|
|
16407
|
+
}
|
|
16408
|
+
/** 一键复制全部上下文为 JSON */
|
|
16409
|
+
copyAllCtx() {
|
|
16410
|
+
const entries = Object.keys(this.currentCtxMap);
|
|
16411
|
+
if (entries.length === 0) return;
|
|
16412
|
+
const json = JSON.stringify(this.currentCtxMap, null, 2);
|
|
16413
|
+
navigator.clipboard.writeText(json).then(() => {
|
|
16414
|
+
this.copyAllBtn.textContent = "\u2713 " + T.copyAllDone();
|
|
16415
|
+
this.copyAllBtn.classList.add("done");
|
|
16416
|
+
setTimeout(() => {
|
|
16417
|
+
this.copyAllBtn.textContent = T.copyAll();
|
|
16418
|
+
this.copyAllBtn.classList.remove("done");
|
|
16419
|
+
}, 2e3);
|
|
16420
|
+
this.setFooter(T.copyAllDone(), "ok");
|
|
16421
|
+
setTimeout(() => this.setFooter("", ""), 2500);
|
|
15920
16422
|
});
|
|
15921
16423
|
}
|
|
15922
|
-
|
|
15923
|
-
this.
|
|
15924
|
-
|
|
16424
|
+
setHeader(state) {
|
|
16425
|
+
this.headerDot.className = `dbg-header-dot${state !== "ok" ? ` ${state}` : ""}`;
|
|
16426
|
+
}
|
|
16427
|
+
setFooter(msg, cls) {
|
|
16428
|
+
this.footerEl.innerHTML = msg ? `<span class="dbg-footer-dot"></span>${msg}` : "";
|
|
16429
|
+
this.footerEl.className = `dbg-footer${cls ? ` ${cls}` : ""}`;
|
|
15925
16430
|
}
|
|
15926
16431
|
};
|
|
15927
16432
|
/*! Bundled license information:
|