slicejs-web-framework 3.2.3 → 3.3.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/.opencode/opencode.json +13 -13
- package/LICENSE +21 -21
- package/README.md +97 -174
- package/Slice/Components/Structural/ContextManager/ContextManager.js +369 -369
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +420 -297
- package/Slice/Components/Structural/Controller/Controller.js +1131 -1131
- package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
- package/Slice/Components/Structural/Debugger/Debugger.js +1497 -1547
- package/Slice/Components/Structural/EventManager/EventManager.js +338 -338
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +476 -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 +752 -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/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 +40 -38
- package/sliceConfig.schema.json +109 -109
- package/src/App/index.html +16 -22
- package/src/App/index.js +20 -23
- package/src/App/style.css +11 -40
- package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -0
- package/src/Components/AppComponents/AppShell/AppShell.css +10 -0
- package/src/Components/AppComponents/AppShell/AppShell.html +4 -0
- package/src/Components/AppComponents/AppShell/AppShell.js +36 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -0
- 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 +100 -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 +15 -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 +9 -15
- package/src/sliceConfig.json +74 -73
- package/types/index.d.ts +207 -207
- package/Slice/Components/Structural/Debugger/Debugger.css +0 -620
- package/src/Components/AppComponents/HomePage/HomePage.css +0 -201
- package/src/Components/AppComponents/HomePage/HomePage.html +0 -37
- package/src/Components/AppComponents/HomePage/HomePage.js +0 -210
- package/src/Components/AppComponents/Playground/Playground.css +0 -12
- package/src/Components/AppComponents/Playground/Playground.html +0 -0
- package/src/Components/AppComponents/Playground/Playground.js +0 -111
- package/src/images/Slice.js-logo.png +0 -0
- package/src/images/im2/Slice.js-logo.png +0 -0
- package/src/testing.js +0 -888
|
@@ -1,297 +1,420 @@
|
|
|
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-
|
|
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="
|
|
159
|
-
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
</div>
|
|
168
|
-
<div class="context-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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-row-head">
|
|
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="brand">
|
|
159
|
+
<span class="status-dot"></span>
|
|
160
|
+
<span class="glyph">◈</span>
|
|
161
|
+
<span class="title">CONTEXT</span>
|
|
162
|
+
</div>
|
|
163
|
+
<div class="actions">
|
|
164
|
+
<button id="context-refresh" class="btn" title="Refresh" aria-label="Refresh">⟳</button>
|
|
165
|
+
<button id="context-close" class="btn" title="Close" aria-label="Close">✕</button>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="context-toolbar">
|
|
169
|
+
<input id="context-filter" type="text" placeholder="filter contexts…" autocomplete="off" spellcheck="false" />
|
|
170
|
+
<div class="count"><span id="context-count">0</span></div>
|
|
171
|
+
</div>
|
|
172
|
+
<div class="context-list" id="context-list"></div>
|
|
173
|
+
</div>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
renderStyles() {
|
|
178
|
+
return `
|
|
179
|
+
/* Slice Instruments — context store. All selectors scoped to the
|
|
180
|
+
<slice-contextmanager-debugger> tag so nothing clashes with app styles. */
|
|
181
|
+
slice-contextmanager-debugger {
|
|
182
|
+
--si-accent: var(--primary-color, #6ee7ff);
|
|
183
|
+
--si-accent-rgb: var(--primary-color-rgb, 110, 231, 255);
|
|
184
|
+
--si-surface: rgba(17, 19, 28, 0.86);
|
|
185
|
+
--si-raised: rgba(255, 255, 255, 0.035);
|
|
186
|
+
--si-raised-2: rgba(255, 255, 255, 0.06);
|
|
187
|
+
--si-border: rgba(255, 255, 255, 0.09);
|
|
188
|
+
--si-text: #e8eaf2;
|
|
189
|
+
--si-dim: #888fa6;
|
|
190
|
+
--si-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
slice-contextmanager-debugger #context-debugger {
|
|
194
|
+
position: fixed;
|
|
195
|
+
bottom: 20px;
|
|
196
|
+
left: 20px;
|
|
197
|
+
width: min(400px, calc(100vw - 40px));
|
|
198
|
+
max-height: 64vh;
|
|
199
|
+
background: var(--si-surface);
|
|
200
|
+
border: 1px solid var(--si-border);
|
|
201
|
+
border-radius: 14px;
|
|
202
|
+
box-shadow:
|
|
203
|
+
0 24px 60px -12px rgba(0, 0, 0, 0.55),
|
|
204
|
+
0 0 0 1px rgba(0, 0, 0, 0.2),
|
|
205
|
+
0 0 38px -18px rgba(var(--si-accent-rgb), 0.55);
|
|
206
|
+
-webkit-backdrop-filter: blur(22px) saturate(1.3);
|
|
207
|
+
backdrop-filter: blur(22px) saturate(1.3);
|
|
208
|
+
display: none;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
z-index: 10001;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
color: var(--si-text);
|
|
213
|
+
font-family: var(--si-mono);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
slice-contextmanager-debugger #context-debugger.active {
|
|
217
|
+
display: flex;
|
|
218
|
+
animation: si-context-in 0.26s cubic-bezier(0.16, 1, 0.3, 1);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@keyframes si-context-in {
|
|
222
|
+
from { opacity: 0; transform: translateY(10px) scale(0.985); }
|
|
223
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
slice-contextmanager-debugger #context-debugger * { box-sizing: border-box; }
|
|
227
|
+
|
|
228
|
+
slice-contextmanager-debugger #context-debugger::before {
|
|
229
|
+
content: '';
|
|
230
|
+
position: absolute;
|
|
231
|
+
left: 0; top: 0; bottom: 0;
|
|
232
|
+
width: 2px;
|
|
233
|
+
background: linear-gradient(180deg, var(--si-accent), transparent 70%);
|
|
234
|
+
opacity: 0.85;
|
|
235
|
+
pointer-events: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
slice-contextmanager-debugger #context-debugger > .context-header {
|
|
239
|
+
display: flex;
|
|
240
|
+
justify-content: space-between;
|
|
241
|
+
align-items: center;
|
|
242
|
+
padding: 12px 14px;
|
|
243
|
+
background:
|
|
244
|
+
radial-gradient(120% 140% at 0% 0%, rgba(var(--si-accent-rgb), 0.10), transparent 60%),
|
|
245
|
+
var(--si-raised);
|
|
246
|
+
border-bottom: 1px solid var(--si-border);
|
|
247
|
+
user-select: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
slice-contextmanager-debugger .brand { display: flex; align-items: center; gap: 9px; }
|
|
251
|
+
|
|
252
|
+
slice-contextmanager-debugger .status-dot {
|
|
253
|
+
width: 7px; height: 7px;
|
|
254
|
+
border-radius: 50%;
|
|
255
|
+
background: var(--si-accent);
|
|
256
|
+
animation: si-pulse-ctx 2.4s ease-out infinite;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@keyframes si-pulse-ctx {
|
|
260
|
+
0% { box-shadow: 0 0 0 0 rgba(var(--si-accent-rgb), 0.55); }
|
|
261
|
+
70% { box-shadow: 0 0 0 7px rgba(var(--si-accent-rgb), 0); }
|
|
262
|
+
100% { box-shadow: 0 0 0 0 rgba(var(--si-accent-rgb), 0); }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
slice-contextmanager-debugger .glyph { color: var(--si-accent); font-size: 12px; opacity: 0.9; }
|
|
266
|
+
|
|
267
|
+
slice-contextmanager-debugger .title {
|
|
268
|
+
font-weight: 600;
|
|
269
|
+
font-size: 11px;
|
|
270
|
+
letter-spacing: 0.18em;
|
|
271
|
+
color: var(--si-text);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
slice-contextmanager-debugger .actions { display: flex; gap: 6px; }
|
|
275
|
+
|
|
276
|
+
slice-contextmanager-debugger .btn {
|
|
277
|
+
width: 26px; height: 26px;
|
|
278
|
+
display: flex; align-items: center; justify-content: center;
|
|
279
|
+
border-radius: 7px;
|
|
280
|
+
border: 1px solid var(--si-border);
|
|
281
|
+
background: var(--si-raised);
|
|
282
|
+
color: var(--si-dim);
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
font-size: 13px;
|
|
285
|
+
line-height: 1;
|
|
286
|
+
transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
|
|
287
|
+
}
|
|
288
|
+
slice-contextmanager-debugger .btn:hover {
|
|
289
|
+
color: var(--si-text);
|
|
290
|
+
background: var(--si-raised-2);
|
|
291
|
+
border-color: rgba(var(--si-accent-rgb), 0.5);
|
|
292
|
+
}
|
|
293
|
+
slice-contextmanager-debugger .btn:active { transform: scale(0.92); }
|
|
294
|
+
slice-contextmanager-debugger #context-refresh:hover { color: var(--si-accent); }
|
|
295
|
+
|
|
296
|
+
slice-contextmanager-debugger .context-toolbar {
|
|
297
|
+
display: flex;
|
|
298
|
+
gap: 10px;
|
|
299
|
+
align-items: center;
|
|
300
|
+
padding: 10px 12px;
|
|
301
|
+
border-bottom: 1px solid var(--si-border);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
slice-contextmanager-debugger .context-toolbar input {
|
|
305
|
+
flex: 1;
|
|
306
|
+
min-width: 0;
|
|
307
|
+
padding: 7px 10px 7px 30px;
|
|
308
|
+
border-radius: 8px;
|
|
309
|
+
border: 1px solid var(--si-border);
|
|
310
|
+
background:
|
|
311
|
+
var(--si-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23888fa6' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center;
|
|
312
|
+
color: var(--si-text);
|
|
313
|
+
font-family: var(--si-mono);
|
|
314
|
+
font-size: 12px;
|
|
315
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
316
|
+
}
|
|
317
|
+
slice-contextmanager-debugger .context-toolbar input::placeholder { color: var(--si-dim); }
|
|
318
|
+
slice-contextmanager-debugger .context-toolbar input:focus {
|
|
319
|
+
outline: none;
|
|
320
|
+
border-color: rgba(var(--si-accent-rgb), 0.6);
|
|
321
|
+
box-shadow: 0 0 0 3px rgba(var(--si-accent-rgb), 0.12);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
slice-contextmanager-debugger .context-toolbar .count { font-size: 11px; color: var(--si-dim); min-width: 22px; text-align: center; }
|
|
325
|
+
slice-contextmanager-debugger .context-toolbar .count span { color: var(--si-accent); font-weight: 600; }
|
|
326
|
+
|
|
327
|
+
slice-contextmanager-debugger .context-list {
|
|
328
|
+
padding: 10px 12px 12px;
|
|
329
|
+
overflow: auto;
|
|
330
|
+
display: flex;
|
|
331
|
+
flex-direction: column;
|
|
332
|
+
gap: 9px;
|
|
333
|
+
}
|
|
334
|
+
slice-contextmanager-debugger .context-list::-webkit-scrollbar { width: 8px; }
|
|
335
|
+
slice-contextmanager-debugger .context-list::-webkit-scrollbar-thumb {
|
|
336
|
+
background: var(--si-raised-2);
|
|
337
|
+
border-radius: 8px;
|
|
338
|
+
border: 2px solid transparent;
|
|
339
|
+
background-clip: padding-box;
|
|
340
|
+
}
|
|
341
|
+
slice-contextmanager-debugger .context-list::-webkit-scrollbar-thumb:hover { background: rgba(var(--si-accent-rgb), 0.4); background-clip: padding-box; }
|
|
342
|
+
|
|
343
|
+
slice-contextmanager-debugger .context-row {
|
|
344
|
+
border: 1px solid var(--si-border);
|
|
345
|
+
border-left: 2px solid transparent;
|
|
346
|
+
border-radius: 10px;
|
|
347
|
+
background: var(--si-raised);
|
|
348
|
+
padding: 10px 11px;
|
|
349
|
+
display: flex;
|
|
350
|
+
flex-direction: column;
|
|
351
|
+
gap: 8px;
|
|
352
|
+
transition: border-color 0.18s ease, background 0.18s ease;
|
|
353
|
+
}
|
|
354
|
+
slice-contextmanager-debugger .context-row:hover { background: var(--si-raised-2); border-left-color: var(--si-accent); }
|
|
355
|
+
|
|
356
|
+
slice-contextmanager-debugger .context-row-head {
|
|
357
|
+
display: flex;
|
|
358
|
+
align-items: center;
|
|
359
|
+
justify-content: space-between;
|
|
360
|
+
gap: 10px;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
slice-contextmanager-debugger .context-name {
|
|
364
|
+
font-weight: 600;
|
|
365
|
+
font-size: 12.5px;
|
|
366
|
+
color: var(--si-text);
|
|
367
|
+
font-family: var(--si-mono);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
slice-contextmanager-debugger .context-keys {
|
|
371
|
+
font-size: 10px;
|
|
372
|
+
letter-spacing: 0.04em;
|
|
373
|
+
text-transform: uppercase;
|
|
374
|
+
color: var(--si-accent);
|
|
375
|
+
background: rgba(var(--si-accent-rgb), 0.12);
|
|
376
|
+
border: 1px solid rgba(var(--si-accent-rgb), 0.25);
|
|
377
|
+
padding: 1px 8px;
|
|
378
|
+
border-radius: 999px;
|
|
379
|
+
white-space: nowrap;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
slice-contextmanager-debugger .context-preview {
|
|
383
|
+
background: rgba(0, 0, 0, 0.3);
|
|
384
|
+
border-radius: 8px;
|
|
385
|
+
padding: 10px;
|
|
386
|
+
border: 1px solid var(--si-border);
|
|
387
|
+
max-height: 200px;
|
|
388
|
+
overflow: auto;
|
|
389
|
+
font-size: 11px;
|
|
390
|
+
line-height: 1.55;
|
|
391
|
+
font-family: var(--si-mono);
|
|
392
|
+
color: #c5cad8;
|
|
393
|
+
white-space: pre;
|
|
394
|
+
margin: 0;
|
|
395
|
+
}
|
|
396
|
+
slice-contextmanager-debugger .context-preview::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
397
|
+
slice-contextmanager-debugger .context-preview::-webkit-scrollbar-thumb {
|
|
398
|
+
background: var(--si-raised-2);
|
|
399
|
+
border-radius: 8px;
|
|
400
|
+
border: 2px solid transparent;
|
|
401
|
+
background-clip: padding-box;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
slice-contextmanager-debugger .empty {
|
|
405
|
+
color: var(--si-dim);
|
|
406
|
+
font-size: 11px;
|
|
407
|
+
letter-spacing: 0.04em;
|
|
408
|
+
text-align: center;
|
|
409
|
+
padding: 22px 0;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@media (prefers-reduced-motion: reduce) {
|
|
413
|
+
slice-contextmanager-debugger #context-debugger.active { animation: none; }
|
|
414
|
+
slice-contextmanager-debugger .status-dot { animation: none; }
|
|
415
|
+
}
|
|
416
|
+
`;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
customElements.define('slice-contextmanager-debugger', ContextManagerDebugger);
|