slicejs-web-framework 3.2.1 → 3.2.3
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/.opencode/opencode.json +14 -0
- package/LICENSE +21 -21
- package/README.md +174 -174
- package/Slice/Components/Structural/ContextManager/ContextManager.js +369 -369
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +297 -297
- package/Slice/Components/Structural/Controller/Controller.js +1138 -1129
- package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -0
- package/Slice/Components/Structural/Debugger/Debugger.css +619 -619
- package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
- package/Slice/Components/Structural/Debugger/Debugger.js +1547 -1547
- package/Slice/Components/Structural/EventManager/EventManager.js +338 -338
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +361 -361
- package/Slice/Components/Structural/Logger/Log.js +10 -10
- package/Slice/Components/Structural/Logger/Logger.js +146 -146
- package/Slice/Components/Structural/Router/Router.js +721 -721
- package/Slice/Components/Structural/StylesManager/StylesManager.js +78 -78
- package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +84 -84
- package/Slice/Slice.js +542 -542
- package/Slice/tests/build-bundled-component-without-category.test.js +103 -103
- package/Slice/tests/build-js-only-visual-components.test.js +144 -144
- package/Slice/tests/bundle-v2-runtime-contract.test.js +728 -728
- package/Slice/tests/props-allowed-values-validation.test.js +119 -0
- package/Slice/tests/public-env-runtime-accessors.test.js +44 -44
- package/Slice/tests/router-loading-finally.test.js +68 -68
- package/api/index.js +286 -286
- package/api/middleware/securityMiddleware.js +252 -252
- package/api/tests/public-env-resolver.test.js +193 -193
- package/api/utils/publicEnvResolver.js +117 -117
- package/package.json +38 -37
- package/sliceConfig.schema.json +109 -109
- package/src/App/index.html +22 -22
- package/src/App/index.js +23 -23
- package/src/App/style.css +40 -40
- package/src/Components/AppComponents/HomePage/HomePage.css +201 -201
- package/src/Components/AppComponents/HomePage/HomePage.html +37 -37
- package/src/Components/AppComponents/HomePage/HomePage.js +210 -210
- package/src/Components/AppComponents/Playground/Playground.css +11 -11
- package/src/Components/AppComponents/Playground/Playground.js +111 -111
- package/src/Components/Service/FetchManager/FetchManager.js +133 -133
- package/src/Components/Service/IndexedDbManager/IndexedDbManager.js +141 -141
- package/src/Components/Service/LocalStorageManager/LocalStorageManager.js +45 -45
- package/src/Components/Visual/Button/Button.css +47 -47
- package/src/Components/Visual/Button/Button.html +5 -5
- package/src/Components/Visual/Button/Button.js +92 -92
- package/src/Components/Visual/Card/Card.css +68 -68
- package/src/Components/Visual/Card/Card.html +7 -7
- package/src/Components/Visual/Card/Card.js +107 -107
- package/src/Components/Visual/Checkbox/Checkbox.css +87 -87
- package/src/Components/Visual/Checkbox/Checkbox.html +8 -8
- package/src/Components/Visual/Checkbox/Checkbox.js +86 -86
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.css +129 -129
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.html +3 -3
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.js +262 -262
- package/src/Components/Visual/Details/Details.css +70 -70
- package/src/Components/Visual/Details/Details.html +9 -9
- package/src/Components/Visual/Details/Details.js +76 -76
- package/src/Components/Visual/DropDown/DropDown.css +60 -60
- package/src/Components/Visual/DropDown/DropDown.html +5 -5
- package/src/Components/Visual/DropDown/DropDown.js +63 -63
- package/src/Components/Visual/Grid/Grid.css +7 -7
- package/src/Components/Visual/Grid/Grid.html +1 -1
- package/src/Components/Visual/Grid/Grid.js +57 -57
- package/src/Components/Visual/Icon/Icon.css +510 -510
- package/src/Components/Visual/Icon/Icon.js +89 -89
- package/src/Components/Visual/Icon/slc.json +554 -554
- package/src/Components/Visual/Icon/slc.styl +507 -507
- package/src/Components/Visual/Icon/slc.svg +1485 -1485
- package/src/Components/Visual/Icon/slc.symbol.svg +1058 -1058
- package/src/Components/Visual/Input/Input.css +91 -91
- package/src/Components/Visual/Input/Input.html +4 -4
- package/src/Components/Visual/Input/Input.js +215 -215
- package/src/Components/Visual/Layout/Layout.js +49 -49
- package/src/Components/Visual/Link/Link.css +8 -8
- package/src/Components/Visual/Link/Link.html +1 -1
- package/src/Components/Visual/Link/Link.js +63 -63
- package/src/Components/Visual/Loading/Loading.css +56 -56
- package/src/Components/Visual/Loading/Loading.html +83 -83
- package/src/Components/Visual/Loading/Loading.js +38 -38
- package/src/Components/Visual/MultiRoute/MultiRoute.js +93 -93
- package/src/Components/Visual/Navbar/Navbar.css +115 -115
- package/src/Components/Visual/Navbar/Navbar.html +44 -44
- package/src/Components/Visual/Navbar/Navbar.js +141 -141
- package/src/Components/Visual/NotFound/NotFound.css +116 -116
- package/src/Components/Visual/NotFound/NotFound.html +23 -23
- package/src/Components/Visual/NotFound/NotFound.js +16 -16
- package/src/Components/Visual/Route/Route.js +93 -93
- package/src/Components/Visual/Select/Select.css +84 -84
- package/src/Components/Visual/Select/Select.html +8 -8
- package/src/Components/Visual/Select/Select.js +195 -195
- package/src/Components/Visual/Switch/Switch.css +76 -76
- package/src/Components/Visual/Switch/Switch.html +8 -8
- package/src/Components/Visual/Switch/Switch.js +102 -102
- package/src/Components/Visual/TreeItem/TreeItem.css +36 -36
- package/src/Components/Visual/TreeItem/TreeItem.html +1 -1
- package/src/Components/Visual/TreeItem/TreeItem.js +126 -126
- package/src/Components/Visual/TreeView/TreeView.css +8 -8
- package/src/Components/Visual/TreeView/TreeView.html +1 -1
- package/src/Components/Visual/TreeView/TreeView.js +48 -48
- package/src/Components/components.js +27 -27
- package/src/Styles/sliceStyles.css +34 -34
- package/src/Themes/Dark.css +42 -42
- package/src/Themes/Light.css +31 -31
- package/src/Themes/Slice.css +47 -47
- package/src/routes.js +15 -15
- package/src/sliceConfig.json +73 -73
- package/src/testing.js +887 -887
- package/types/index.d.ts +207 -0
|
@@ -1,297 +1,297 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContextManager debug panel.
|
|
3
|
-
*/
|
|
4
|
-
export default class ContextManagerDebugger extends HTMLElement {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.isOpen = false;
|
|
8
|
-
this.filterText = '';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Initialize panel UI.
|
|
13
|
-
* @returns {Promise<void>}
|
|
14
|
-
*/
|
|
15
|
-
async init() {
|
|
16
|
-
this.innerHTML = this.renderTemplate();
|
|
17
|
-
slice.stylesManager.registerComponentStyles('ContextManagerDebugger', this.renderStyles());
|
|
18
|
-
this.cacheElements();
|
|
19
|
-
this.bindEvents();
|
|
20
|
-
this.makeDraggable();
|
|
21
|
-
this.renderList();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Toggle panel visibility.
|
|
26
|
-
* @returns {void}
|
|
27
|
-
*/
|
|
28
|
-
toggle() {
|
|
29
|
-
this.isOpen = !this.isOpen;
|
|
30
|
-
this.container.classList.toggle('active', this.isOpen);
|
|
31
|
-
if (this.isOpen) {
|
|
32
|
-
this.renderList();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Show panel.
|
|
38
|
-
* @returns {void}
|
|
39
|
-
*/
|
|
40
|
-
open() {
|
|
41
|
-
this.isOpen = true;
|
|
42
|
-
this.container.classList.add('active');
|
|
43
|
-
this.renderList();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Hide panel.
|
|
48
|
-
* @returns {void}
|
|
49
|
-
*/
|
|
50
|
-
close() {
|
|
51
|
-
this.isOpen = false;
|
|
52
|
-
this.container.classList.remove('active');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
cacheElements() {
|
|
56
|
-
this.container = this.querySelector('#context-debugger');
|
|
57
|
-
this.header = this.querySelector('.context-header');
|
|
58
|
-
this.list = this.querySelector('#context-list');
|
|
59
|
-
this.filterInput = this.querySelector('#context-filter');
|
|
60
|
-
this.countLabel = this.querySelector('#context-count');
|
|
61
|
-
this.refreshButton = this.querySelector('#context-refresh');
|
|
62
|
-
this.closeButton = this.querySelector('#context-close');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
bindEvents() {
|
|
66
|
-
this.refreshButton.addEventListener('click', () => this.renderList());
|
|
67
|
-
this.closeButton.addEventListener('click', () => this.close());
|
|
68
|
-
this.filterInput.addEventListener('input', (event) => {
|
|
69
|
-
this.filterText = event.target.value.trim().toLowerCase();
|
|
70
|
-
this.renderList();
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
makeDraggable() {
|
|
75
|
-
if (!this.header || !this.container) return;
|
|
76
|
-
|
|
77
|
-
let offset = { x: 0, y: 0 };
|
|
78
|
-
let isDragging = false;
|
|
79
|
-
|
|
80
|
-
this.header.style.cursor = 'grab';
|
|
81
|
-
|
|
82
|
-
this.header.addEventListener('mousedown', (event) => {
|
|
83
|
-
if (event.target.closest('.btn')) return;
|
|
84
|
-
isDragging = true;
|
|
85
|
-
offset.x = event.clientX - this.container.getBoundingClientRect().left;
|
|
86
|
-
offset.y = event.clientY - this.container.getBoundingClientRect().top;
|
|
87
|
-
this.header.style.cursor = 'grabbing';
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
document.addEventListener('mousemove', (event) => {
|
|
91
|
-
if (!isDragging) return;
|
|
92
|
-
const rect = this.container.getBoundingClientRect();
|
|
93
|
-
const maxX = window.innerWidth - rect.width;
|
|
94
|
-
const maxY = window.innerHeight - rect.height;
|
|
95
|
-
const x = Math.min(Math.max(event.clientX - offset.x, 0), maxX);
|
|
96
|
-
const y = Math.min(Math.max(event.clientY - offset.y, 0), maxY);
|
|
97
|
-
this.container.style.left = `${x}px`;
|
|
98
|
-
this.container.style.top = `${y}px`;
|
|
99
|
-
this.container.style.right = 'auto';
|
|
100
|
-
this.container.style.bottom = 'auto';
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
document.addEventListener('mouseup', () => {
|
|
104
|
-
if (!isDragging) return;
|
|
105
|
-
isDragging = false;
|
|
106
|
-
this.header.style.cursor = 'grab';
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
renderList() {
|
|
111
|
-
if (!slice?.context?.contexts) {
|
|
112
|
-
this.list.textContent = 'ContextManager not available.';
|
|
113
|
-
this.countLabel.textContent = '0';
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const items = [];
|
|
118
|
-
slice.context.contexts.forEach((value, name) => {
|
|
119
|
-
if (this.filterText && !name.toLowerCase().includes(this.filterText)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const keys = value?.state ? Object.keys(value.state).length : 0;
|
|
123
|
-
items.push({ name, keys, state: value?.state || {} });
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
items.sort((a, b) => a.name.localeCompare(b.name));
|
|
127
|
-
|
|
128
|
-
this.countLabel.textContent = String(items.length);
|
|
129
|
-
this.list.innerHTML = items.length
|
|
130
|
-
? items.map((item) => {
|
|
131
|
-
const preview = JSON.stringify(item.state, null, 2);
|
|
132
|
-
return `
|
|
133
|
-
<div class="context-row">
|
|
134
|
-
<div class="context-header">
|
|
135
|
-
<div class="context-name">${item.name}</div>
|
|
136
|
-
<div class="context-keys">${item.keys} keys</div>
|
|
137
|
-
</div>
|
|
138
|
-
<pre class="context-preview">${this.escapeHtml(preview)}</pre>
|
|
139
|
-
</div>
|
|
140
|
-
`;
|
|
141
|
-
}).join('')
|
|
142
|
-
: '<div class="empty">No contexts</div>';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
escapeHtml(value) {
|
|
146
|
-
return value
|
|
147
|
-
.replace(/&/g, '&')
|
|
148
|
-
.replace(/</g, '<')
|
|
149
|
-
.replace(/>/g, '>')
|
|
150
|
-
.replace(/"/g, '"')
|
|
151
|
-
.replace(/'/g, ''');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
renderTemplate() {
|
|
155
|
-
return `
|
|
156
|
-
<div id="context-debugger">
|
|
157
|
-
<div class="context-header">
|
|
158
|
-
<div class="title">Contexts</div>
|
|
159
|
-
<div class="actions">
|
|
160
|
-
<button id="context-refresh" class="btn">Refresh</button>
|
|
161
|
-
<button id="context-close" class="btn">Close</button>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
<div class="context-toolbar">
|
|
165
|
-
<input id="context-filter" type="text" placeholder="Filter contexts" />
|
|
166
|
-
<div class="count">Total: <span id="context-count">0</span></div>
|
|
167
|
-
</div>
|
|
168
|
-
<div class="context-list" id="context-list"></div>
|
|
169
|
-
</div>
|
|
170
|
-
`;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
renderStyles() {
|
|
174
|
-
return `
|
|
175
|
-
#context-debugger {
|
|
176
|
-
position: fixed;
|
|
177
|
-
bottom: 20px;
|
|
178
|
-
left: 20px;
|
|
179
|
-
width: min(380px, calc(100vw - 40px));
|
|
180
|
-
max-height: 60vh;
|
|
181
|
-
background: var(--primary-background-color);
|
|
182
|
-
border: 1px solid var(--medium-color);
|
|
183
|
-
border-radius: 12px;
|
|
184
|
-
box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
|
|
185
|
-
display: none;
|
|
186
|
-
flex-direction: column;
|
|
187
|
-
z-index: 10001;
|
|
188
|
-
overflow: hidden;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
#context-debugger.active {
|
|
192
|
-
display: flex;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
#context-debugger * {
|
|
196
|
-
box-sizing: border-box;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.context-header {
|
|
200
|
-
display: flex;
|
|
201
|
-
justify-content: space-between;
|
|
202
|
-
align-items: center;
|
|
203
|
-
padding: 12px 14px;
|
|
204
|
-
background: var(--tertiary-background-color);
|
|
205
|
-
border-bottom: 1px solid var(--medium-color);
|
|
206
|
-
user-select: none;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.context-header .title {
|
|
210
|
-
font-weight: 600;
|
|
211
|
-
color: var(--font-primary-color);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.context-header .actions {
|
|
215
|
-
display: flex;
|
|
216
|
-
gap: 8px;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.context-header .btn {
|
|
220
|
-
padding: 6px 10px;
|
|
221
|
-
border-radius: 6px;
|
|
222
|
-
border: 1px solid var(--medium-color);
|
|
223
|
-
background: var(--primary-background-color);
|
|
224
|
-
color: var(--font-primary-color);
|
|
225
|
-
cursor: pointer;
|
|
226
|
-
font-size: 12px;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.context-toolbar {
|
|
230
|
-
display: flex;
|
|
231
|
-
gap: 10px;
|
|
232
|
-
align-items: center;
|
|
233
|
-
padding: 10px 12px;
|
|
234
|
-
border-bottom: 1px solid var(--medium-color);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.context-toolbar input {
|
|
238
|
-
flex: 1;
|
|
239
|
-
min-width: 0;
|
|
240
|
-
padding: 6px 8px;
|
|
241
|
-
border-radius: 6px;
|
|
242
|
-
border: 1px solid var(--medium-color);
|
|
243
|
-
background: var(--primary-background-color);
|
|
244
|
-
color: var(--font-primary-color);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.context-list {
|
|
248
|
-
padding: 10px 12px;
|
|
249
|
-
overflow: auto;
|
|
250
|
-
display: flex;
|
|
251
|
-
flex-direction: column;
|
|
252
|
-
gap: 10px;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.context-row {
|
|
256
|
-
border: 1px solid var(--medium-color);
|
|
257
|
-
border-radius: 8px;
|
|
258
|
-
background: var(--tertiary-background-color);
|
|
259
|
-
padding: 10px;
|
|
260
|
-
display: flex;
|
|
261
|
-
flex-direction: column;
|
|
262
|
-
gap: 6px;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.context-name {
|
|
266
|
-
font-weight: 600;
|
|
267
|
-
color: var(--font-primary-color);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.context-keys {
|
|
271
|
-
font-size: 12px;
|
|
272
|
-
color: var(--font-secondary-color);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.context-preview {
|
|
276
|
-
background: var(--primary-background-color);
|
|
277
|
-
border-radius: 6px;
|
|
278
|
-
padding: 8px;
|
|
279
|
-
border: 1px solid var(--medium-color);
|
|
280
|
-
max-height: 180px;
|
|
281
|
-
overflow: auto;
|
|
282
|
-
font-size: 11px;
|
|
283
|
-
font-family: monospace;
|
|
284
|
-
color: var(--font-primary-color);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.empty {
|
|
288
|
-
color: var(--font-secondary-color);
|
|
289
|
-
font-size: 12px;
|
|
290
|
-
text-align: center;
|
|
291
|
-
padding: 12px 0;
|
|
292
|
-
}
|
|
293
|
-
`;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
customElements.define('slice-contextmanager-debugger', ContextManagerDebugger);
|
|
1
|
+
/**
|
|
2
|
+
* ContextManager debug panel.
|
|
3
|
+
*/
|
|
4
|
+
export default class ContextManagerDebugger extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.isOpen = false;
|
|
8
|
+
this.filterText = '';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initialize panel UI.
|
|
13
|
+
* @returns {Promise<void>}
|
|
14
|
+
*/
|
|
15
|
+
async init() {
|
|
16
|
+
this.innerHTML = this.renderTemplate();
|
|
17
|
+
slice.stylesManager.registerComponentStyles('ContextManagerDebugger', this.renderStyles());
|
|
18
|
+
this.cacheElements();
|
|
19
|
+
this.bindEvents();
|
|
20
|
+
this.makeDraggable();
|
|
21
|
+
this.renderList();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Toggle panel visibility.
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
toggle() {
|
|
29
|
+
this.isOpen = !this.isOpen;
|
|
30
|
+
this.container.classList.toggle('active', this.isOpen);
|
|
31
|
+
if (this.isOpen) {
|
|
32
|
+
this.renderList();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Show panel.
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
open() {
|
|
41
|
+
this.isOpen = true;
|
|
42
|
+
this.container.classList.add('active');
|
|
43
|
+
this.renderList();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Hide panel.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
close() {
|
|
51
|
+
this.isOpen = false;
|
|
52
|
+
this.container.classList.remove('active');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cacheElements() {
|
|
56
|
+
this.container = this.querySelector('#context-debugger');
|
|
57
|
+
this.header = this.querySelector('.context-header');
|
|
58
|
+
this.list = this.querySelector('#context-list');
|
|
59
|
+
this.filterInput = this.querySelector('#context-filter');
|
|
60
|
+
this.countLabel = this.querySelector('#context-count');
|
|
61
|
+
this.refreshButton = this.querySelector('#context-refresh');
|
|
62
|
+
this.closeButton = this.querySelector('#context-close');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bindEvents() {
|
|
66
|
+
this.refreshButton.addEventListener('click', () => this.renderList());
|
|
67
|
+
this.closeButton.addEventListener('click', () => this.close());
|
|
68
|
+
this.filterInput.addEventListener('input', (event) => {
|
|
69
|
+
this.filterText = event.target.value.trim().toLowerCase();
|
|
70
|
+
this.renderList();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
makeDraggable() {
|
|
75
|
+
if (!this.header || !this.container) return;
|
|
76
|
+
|
|
77
|
+
let offset = { x: 0, y: 0 };
|
|
78
|
+
let isDragging = false;
|
|
79
|
+
|
|
80
|
+
this.header.style.cursor = 'grab';
|
|
81
|
+
|
|
82
|
+
this.header.addEventListener('mousedown', (event) => {
|
|
83
|
+
if (event.target.closest('.btn')) return;
|
|
84
|
+
isDragging = true;
|
|
85
|
+
offset.x = event.clientX - this.container.getBoundingClientRect().left;
|
|
86
|
+
offset.y = event.clientY - this.container.getBoundingClientRect().top;
|
|
87
|
+
this.header.style.cursor = 'grabbing';
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
document.addEventListener('mousemove', (event) => {
|
|
91
|
+
if (!isDragging) return;
|
|
92
|
+
const rect = this.container.getBoundingClientRect();
|
|
93
|
+
const maxX = window.innerWidth - rect.width;
|
|
94
|
+
const maxY = window.innerHeight - rect.height;
|
|
95
|
+
const x = Math.min(Math.max(event.clientX - offset.x, 0), maxX);
|
|
96
|
+
const y = Math.min(Math.max(event.clientY - offset.y, 0), maxY);
|
|
97
|
+
this.container.style.left = `${x}px`;
|
|
98
|
+
this.container.style.top = `${y}px`;
|
|
99
|
+
this.container.style.right = 'auto';
|
|
100
|
+
this.container.style.bottom = 'auto';
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
document.addEventListener('mouseup', () => {
|
|
104
|
+
if (!isDragging) return;
|
|
105
|
+
isDragging = false;
|
|
106
|
+
this.header.style.cursor = 'grab';
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
renderList() {
|
|
111
|
+
if (!slice?.context?.contexts) {
|
|
112
|
+
this.list.textContent = 'ContextManager not available.';
|
|
113
|
+
this.countLabel.textContent = '0';
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const items = [];
|
|
118
|
+
slice.context.contexts.forEach((value, name) => {
|
|
119
|
+
if (this.filterText && !name.toLowerCase().includes(this.filterText)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const keys = value?.state ? Object.keys(value.state).length : 0;
|
|
123
|
+
items.push({ name, keys, state: value?.state || {} });
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
items.sort((a, b) => a.name.localeCompare(b.name));
|
|
127
|
+
|
|
128
|
+
this.countLabel.textContent = String(items.length);
|
|
129
|
+
this.list.innerHTML = items.length
|
|
130
|
+
? items.map((item) => {
|
|
131
|
+
const preview = JSON.stringify(item.state, null, 2);
|
|
132
|
+
return `
|
|
133
|
+
<div class="context-row">
|
|
134
|
+
<div class="context-header">
|
|
135
|
+
<div class="context-name">${item.name}</div>
|
|
136
|
+
<div class="context-keys">${item.keys} keys</div>
|
|
137
|
+
</div>
|
|
138
|
+
<pre class="context-preview">${this.escapeHtml(preview)}</pre>
|
|
139
|
+
</div>
|
|
140
|
+
`;
|
|
141
|
+
}).join('')
|
|
142
|
+
: '<div class="empty">No contexts</div>';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
escapeHtml(value) {
|
|
146
|
+
return value
|
|
147
|
+
.replace(/&/g, '&')
|
|
148
|
+
.replace(/</g, '<')
|
|
149
|
+
.replace(/>/g, '>')
|
|
150
|
+
.replace(/"/g, '"')
|
|
151
|
+
.replace(/'/g, ''');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
renderTemplate() {
|
|
155
|
+
return `
|
|
156
|
+
<div id="context-debugger">
|
|
157
|
+
<div class="context-header">
|
|
158
|
+
<div class="title">Contexts</div>
|
|
159
|
+
<div class="actions">
|
|
160
|
+
<button id="context-refresh" class="btn">Refresh</button>
|
|
161
|
+
<button id="context-close" class="btn">Close</button>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
<div class="context-toolbar">
|
|
165
|
+
<input id="context-filter" type="text" placeholder="Filter contexts" />
|
|
166
|
+
<div class="count">Total: <span id="context-count">0</span></div>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="context-list" id="context-list"></div>
|
|
169
|
+
</div>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
renderStyles() {
|
|
174
|
+
return `
|
|
175
|
+
#context-debugger {
|
|
176
|
+
position: fixed;
|
|
177
|
+
bottom: 20px;
|
|
178
|
+
left: 20px;
|
|
179
|
+
width: min(380px, calc(100vw - 40px));
|
|
180
|
+
max-height: 60vh;
|
|
181
|
+
background: var(--primary-background-color);
|
|
182
|
+
border: 1px solid var(--medium-color);
|
|
183
|
+
border-radius: 12px;
|
|
184
|
+
box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
|
|
185
|
+
display: none;
|
|
186
|
+
flex-direction: column;
|
|
187
|
+
z-index: 10001;
|
|
188
|
+
overflow: hidden;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#context-debugger.active {
|
|
192
|
+
display: flex;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#context-debugger * {
|
|
196
|
+
box-sizing: border-box;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.context-header {
|
|
200
|
+
display: flex;
|
|
201
|
+
justify-content: space-between;
|
|
202
|
+
align-items: center;
|
|
203
|
+
padding: 12px 14px;
|
|
204
|
+
background: var(--tertiary-background-color);
|
|
205
|
+
border-bottom: 1px solid var(--medium-color);
|
|
206
|
+
user-select: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.context-header .title {
|
|
210
|
+
font-weight: 600;
|
|
211
|
+
color: var(--font-primary-color);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.context-header .actions {
|
|
215
|
+
display: flex;
|
|
216
|
+
gap: 8px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.context-header .btn {
|
|
220
|
+
padding: 6px 10px;
|
|
221
|
+
border-radius: 6px;
|
|
222
|
+
border: 1px solid var(--medium-color);
|
|
223
|
+
background: var(--primary-background-color);
|
|
224
|
+
color: var(--font-primary-color);
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
font-size: 12px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.context-toolbar {
|
|
230
|
+
display: flex;
|
|
231
|
+
gap: 10px;
|
|
232
|
+
align-items: center;
|
|
233
|
+
padding: 10px 12px;
|
|
234
|
+
border-bottom: 1px solid var(--medium-color);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.context-toolbar input {
|
|
238
|
+
flex: 1;
|
|
239
|
+
min-width: 0;
|
|
240
|
+
padding: 6px 8px;
|
|
241
|
+
border-radius: 6px;
|
|
242
|
+
border: 1px solid var(--medium-color);
|
|
243
|
+
background: var(--primary-background-color);
|
|
244
|
+
color: var(--font-primary-color);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.context-list {
|
|
248
|
+
padding: 10px 12px;
|
|
249
|
+
overflow: auto;
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
gap: 10px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.context-row {
|
|
256
|
+
border: 1px solid var(--medium-color);
|
|
257
|
+
border-radius: 8px;
|
|
258
|
+
background: var(--tertiary-background-color);
|
|
259
|
+
padding: 10px;
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-direction: column;
|
|
262
|
+
gap: 6px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.context-name {
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
color: var(--font-primary-color);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.context-keys {
|
|
271
|
+
font-size: 12px;
|
|
272
|
+
color: var(--font-secondary-color);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.context-preview {
|
|
276
|
+
background: var(--primary-background-color);
|
|
277
|
+
border-radius: 6px;
|
|
278
|
+
padding: 8px;
|
|
279
|
+
border: 1px solid var(--medium-color);
|
|
280
|
+
max-height: 180px;
|
|
281
|
+
overflow: auto;
|
|
282
|
+
font-size: 11px;
|
|
283
|
+
font-family: monospace;
|
|
284
|
+
color: var(--font-primary-color);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.empty {
|
|
288
|
+
color: var(--font-secondary-color);
|
|
289
|
+
font-size: 12px;
|
|
290
|
+
text-align: center;
|
|
291
|
+
padding: 12px 0;
|
|
292
|
+
}
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
customElements.define('slice-contextmanager-debugger', ContextManagerDebugger);
|