shinkom 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -18
- package/dist/bundles/_virtual/_rolldown/runtime.js +14 -14
- package/dist/bundles/core/constants.d.ts +15 -15
- package/dist/bundles/core/constants.js +23 -23
- package/dist/bundles/core/elements/compat-view-element.d.ts +99 -99
- package/dist/bundles/core/elements/compat-view-element.js +440 -440
- package/dist/bundles/core/elements/control-panel-element.d.ts +44 -44
- package/dist/bundles/core/elements/control-panel-element.js +99 -99
- package/dist/bundles/core/elements/index.d.ts +12 -12
- package/dist/bundles/core/elements/index.js +13 -13
- package/dist/bundles/core/elements/inspector-element.d.ts +26 -26
- package/dist/bundles/core/elements/inspector-element.js +58 -58
- package/dist/bundles/core/elements/recent-result-item.js +46 -46
- package/dist/bundles/core/elements/results-history-item.js +46 -46
- package/dist/bundles/core/elements/templates/compat-view.templates.js +462 -462
- package/dist/bundles/core/elements/templates/control-panel.templates.js +335 -335
- package/dist/bundles/core/elements/templates/root-styles.template.js +40 -40
- package/dist/bundles/core/event-bus.d.ts +46 -46
- package/dist/bundles/core/event-bus.js +49 -49
- package/dist/bundles/core/helpers.js +47 -47
- package/dist/bundles/core/index.d.ts +14 -14
- package/dist/bundles/core/index.js +16 -16
- package/dist/bundles/core/state-service.d.ts +56 -56
- package/dist/bundles/core/state-service.js +91 -80
- package/dist/bundles/core/ui-component.d.ts +63 -63
- package/dist/bundles/core/ui-component.js +71 -71
- package/dist/bundles/engine/engine.d.ts +108 -108
- package/dist/bundles/engine/engine.js +238 -238
- package/dist/bundles/engine/index.js +8 -8
- package/dist/bundles/gen/index.js +14 -14
- package/dist/bundles/index.d.ts +19 -19
- package/dist/bundles/index.js +23 -23
- package/dist/bundles/pkg/shinkore.d.ts +40 -50
- package/dist/bundles/pkg/shinkore.js +465 -465
- package/dist/bundles/pkg/shinkore_bg.wasm +0 -0
- package/dist/bundles/shinkom.d.ts +41 -41
- package/dist/bundles/shinkom.js +80 -80
- package/dist/bundles/ui/compat-ui/compat-ui.d.ts +42 -42
- package/dist/bundles/ui/compat-ui/compat-ui.js +59 -59
- package/dist/bundles/ui/compat-ui/index.js +8 -8
- package/dist/bundles/ui/compatibility-view/compatibility-view.d.ts +41 -41
- package/dist/bundles/ui/compatibility-view/compatibility-view.js +229 -229
- package/dist/bundles/ui/compatibility-view/index.js +8 -8
- package/dist/bundles/ui/control-panel/control-panel.d.ts +52 -52
- package/dist/bundles/ui/control-panel/control-panel.js +320 -320
- package/dist/bundles/ui/control-panel/index.js +8 -8
- package/dist/bundles/ui/index.d.ts +11 -11
- package/dist/bundles/ui/index.js +16 -16
- package/dist/bundles/ui/inspector/index.js +8 -8
- package/dist/bundles/ui/inspector/inspector.d.ts +97 -97
- package/dist/bundles/ui/inspector/inspector.js +394 -394
- package/dist/modules/core/constants.cjs +17 -17
- package/dist/modules/core/elements/compat-view-element.cjs +434 -434
- package/dist/modules/core/elements/control-panel-element.cjs +93 -93
- package/dist/modules/core/elements/index.cjs +11 -11
- package/dist/modules/core/elements/inspector-element.cjs +52 -52
- package/dist/modules/core/elements/recent-result-item.cjs +39 -39
- package/dist/modules/core/elements/results-history-item.cjs +39 -39
- package/dist/modules/core/elements/templates/compat-view.templates.cjs +458 -458
- package/dist/modules/core/elements/templates/control-panel.templates.cjs +332 -332
- package/dist/modules/core/elements/templates/root-styles.template.cjs +33 -33
- package/dist/modules/core/event-bus.cjs +43 -43
- package/dist/modules/core/helpers.cjs +41 -41
- package/dist/modules/core/index.cjs +16 -16
- package/dist/modules/core/state-service.cjs +85 -74
- package/dist/modules/core/ui-component.cjs +65 -65
- package/dist/modules/engine/engine.cjs +232 -232
- package/dist/modules/gen/browser-data.cjs +100 -100
- package/dist/modules/gen/browser-usage-data.cjs +675 -675
- package/dist/modules/gen/compat-data.cjs +31015 -31015
- package/dist/modules/gen/index.cjs +7 -7
- package/dist/modules/index.cjs +27 -27
- package/dist/modules/pkg/shinkore.cjs +459 -459
- package/dist/modules/pkg/shinkore_bg.wasm +0 -0
- package/dist/modules/shinkom.cjs +73 -73
- package/dist/modules/ui/compat-ui/compat-ui.cjs +53 -53
- package/dist/modules/ui/compat-ui/index.cjs +1 -1
- package/dist/modules/ui/compatibility-view/compatibility-view.cjs +223 -223
- package/dist/modules/ui/compatibility-view/index.cjs +1 -1
- package/dist/modules/ui/control-panel/control-panel.cjs +314 -314
- package/dist/modules/ui/control-panel/index.cjs +1 -1
- package/dist/modules/ui/index.cjs +13 -13
- package/dist/modules/ui/inspector/index.cjs +1 -1
- package/dist/modules/ui/inspector/inspector.cjs +388 -388
- package/package.json +100 -100
|
@@ -1,320 +1,320 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - control-panel
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { UIComponent } from "../../core/ui-component.js";
|
|
9
|
-
import { CompatControlPanelElement } from "../../core/elements/control-panel-element.js";
|
|
10
|
-
import "../../core/elements/index.js";
|
|
11
|
-
import "../../core/index.js";
|
|
12
|
-
//#region src/ui/control-panel/control-panel.js
|
|
13
|
-
/**@typedef {import('../../types/public').UISharedState} UISharedState */
|
|
14
|
-
/**@typedef {import('../../types/public').UISharedStateProps} UISharedStateProps */
|
|
15
|
-
/**
|
|
16
|
-
* CompatControlPanel manages the visibility, tabs, and input controls of
|
|
17
|
-
* the compatibility control panel overlay.
|
|
18
|
-
*
|
|
19
|
-
* It mounts the `<sk-control-panel>` custom element, binds control values
|
|
20
|
-
* to shared UI state, and dispatches user-driven commands over the Shinkom
|
|
21
|
-
* event bus.
|
|
22
|
-
*
|
|
23
|
-
* The panel supports inspector controls, compatibility view settings,
|
|
24
|
-
* tab switching, and display transitions with or without view transition
|
|
25
|
-
* support.
|
|
26
|
-
*
|
|
27
|
-
* @extends {UIComponent}
|
|
28
|
-
*/
|
|
29
|
-
var CompatControlPanel = class CompatControlPanel extends UIComponent {
|
|
30
|
-
/**@type {UISharedState | null} */
|
|
31
|
-
#stateBind = null;
|
|
32
|
-
/**@type {AbortController | null} */
|
|
33
|
-
#panelController = null;
|
|
34
|
-
/**
|
|
35
|
-
* Initializes the compatibility control panel.
|
|
36
|
-
*
|
|
37
|
-
* It requires an instance of the `ShinkomBus` and `ShinkomState` to listen
|
|
38
|
-
* for event bus emits and state service notifications.
|
|
39
|
-
*
|
|
40
|
-
* It also registers the `<sk-control-panel>` custom element.
|
|
41
|
-
*
|
|
42
|
-
* @param {ShinkomBus} bus
|
|
43
|
-
* @param {ShinkomState} stateService
|
|
44
|
-
*/
|
|
45
|
-
constructor(bus, stateService) {
|
|
46
|
-
super(bus, stateService);
|
|
47
|
-
CompatControlPanel.register();
|
|
48
|
-
/**@type {CompatControlPanelElement | null} */
|
|
49
|
-
this.controlPanelEl = null;
|
|
50
|
-
/**@type {HTMLInputElement | null} */
|
|
51
|
-
this.depthLevelInput = null;
|
|
52
|
-
/**@type {HTMLInputElement | null} */
|
|
53
|
-
this.maxResultsHistoryInput = null;
|
|
54
|
-
/**@type {number} */
|
|
55
|
-
this.maxResultsHistory = 10;
|
|
56
|
-
/**@type {number} */
|
|
57
|
-
this.depthLevel = 0;
|
|
58
|
-
/**@type {boolean} */
|
|
59
|
-
this.multiElements = false;
|
|
60
|
-
/**@type {"inspector" | "compatView"} */
|
|
61
|
-
this.currentTab = "inspector";
|
|
62
|
-
/**@type {() => void} */
|
|
63
|
-
this.unsubState = () => {};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Register custom elements to the CustomElementRegistry.
|
|
67
|
-
*/
|
|
68
|
-
static register() {
|
|
69
|
-
if (typeof window !== "undefined" && "customElements" in globalThis && !globalThis.customElements.get("sk-control-panel")) globalThis.customElements.define("sk-control-panel", CompatControlPanelElement);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Subscribes to shared UI state changes from the Shinkom state service.
|
|
73
|
-
*
|
|
74
|
-
* When the state service emits updates, the control panel updates the
|
|
75
|
-
* relevant button labels and input state accordingly.
|
|
76
|
-
*/
|
|
77
|
-
#setupStateServiceListener() {
|
|
78
|
-
this.unsubState = this.stateService.subscribe((prop, val) => {
|
|
79
|
-
this.onStateChange(prop, val);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Unsubscribes from the shared UI state service.
|
|
84
|
-
*/
|
|
85
|
-
#cleanupStateServiceListener() {
|
|
86
|
-
this.unsubState();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @param {UISharedState} state
|
|
90
|
-
*/
|
|
91
|
-
bindState(state) {
|
|
92
|
-
if (!this.#stateBind) this.#stateBind = state;
|
|
93
|
-
this.#stateBind.ignorePanelEl = this.controlPanelEl;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @param {UISharedStateProps} prop
|
|
97
|
-
* @param {any} val
|
|
98
|
-
*/
|
|
99
|
-
onStateChange(prop, val) {
|
|
100
|
-
switch (prop) {
|
|
101
|
-
case "inspectorSwitching":
|
|
102
|
-
if (this.controlPanelEl) {
|
|
103
|
-
const toggleSwitchingButton = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-switching");
|
|
104
|
-
if (toggleSwitchingButton) toggleSwitchingButton.textContent = val ? "Enabled" : "Disabled";
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case "inspectorActive":
|
|
108
|
-
if (this.controlPanelEl) {
|
|
109
|
-
const toggleInspectorButton = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-inspector");
|
|
110
|
-
if (toggleInspectorButton) toggleInspectorButton.textContent = val ? "Enabled" : "Disabled";
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
default: break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
mount() {
|
|
117
|
-
if (this.controlPanelEl || document.querySelector("sk-control-panel")) return;
|
|
118
|
-
this.controlPanelEl = document.createElement("sk-control-panel");
|
|
119
|
-
document.body.appendChild(this.controlPanelEl);
|
|
120
|
-
this.#setupShadowListeners();
|
|
121
|
-
this.#setupStateServiceListener();
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Sets up event listeners within the `ShadowDOM`.
|
|
125
|
-
*/
|
|
126
|
-
#setupShadowListeners() {
|
|
127
|
-
if (!this.controlPanelEl) return;
|
|
128
|
-
this.#panelController = new AbortController();
|
|
129
|
-
const { signal } = this.#panelController;
|
|
130
|
-
const depthLevelInput = this.controlPanelEl.shadowRootRef.getElementById("sk-depth-level");
|
|
131
|
-
this.controlPanelEl.shadowHost.addEventListener("click", this.#handleToggleClick, { signal });
|
|
132
|
-
depthLevelInput?.addEventListener("change", this.#handleDepthLevelValue, { signal });
|
|
133
|
-
if (depthLevelInput) {
|
|
134
|
-
this.depthLevelInput = depthLevelInput;
|
|
135
|
-
this.depthLevelInput.disabled = !this.#stateBind?.multiElements;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
unmount() {
|
|
139
|
-
try {
|
|
140
|
-
if (!this.controlPanelEl) return;
|
|
141
|
-
this.controlPanelEl.remove();
|
|
142
|
-
this.controlPanelEl = null;
|
|
143
|
-
this.#resetInternalState();
|
|
144
|
-
this.#cleanupStateServiceListener();
|
|
145
|
-
} catch (error) {
|
|
146
|
-
console.error(`Control panel destroy error: ${error}`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Resets any internal state and event listeners.
|
|
151
|
-
*/
|
|
152
|
-
#resetInternalState() {
|
|
153
|
-
if (this.#panelController) this.#panelController.abort();
|
|
154
|
-
this.#panelController = null;
|
|
155
|
-
this.depthLevelInput = null;
|
|
156
|
-
this.depthLevel = 0;
|
|
157
|
-
this.multiElements = false;
|
|
158
|
-
if (this.#stateBind) {
|
|
159
|
-
this.#stateBind.depthLevel = 0;
|
|
160
|
-
this.#stateBind.multiElements = false;
|
|
161
|
-
this.#stateBind.ignorePanelEl = null;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Handles click events within the control panel.
|
|
166
|
-
* @param {PointerEvent} e
|
|
167
|
-
*/
|
|
168
|
-
#handleToggleClick = (e) => {
|
|
169
|
-
switch (e.target.id) {
|
|
170
|
-
case "sk-show-panel":
|
|
171
|
-
if (!this.controlPanelEl) return;
|
|
172
|
-
if (!document.startViewTransition) this.controlPanelEl.renderDisplayTransition("show");
|
|
173
|
-
else this.#handleDisplayTransition("show");
|
|
174
|
-
break;
|
|
175
|
-
case "sk-close-panel":
|
|
176
|
-
if (!this.controlPanelEl) return;
|
|
177
|
-
if (!document.startViewTransition) this.controlPanelEl.renderDisplayTransition("hide");
|
|
178
|
-
else this.#handleDisplayTransition("hide");
|
|
179
|
-
break;
|
|
180
|
-
case "sk-inspector-tab":
|
|
181
|
-
if (!this.controlPanelEl || this.currentTab === "inspector") return;
|
|
182
|
-
if (!document.startViewTransition) {
|
|
183
|
-
this.controlPanelEl.renderTabContent("inspector");
|
|
184
|
-
this.#handleInspectorTabState();
|
|
185
|
-
this.currentTab = "inspector";
|
|
186
|
-
} else this.#handleTabChange("inspector");
|
|
187
|
-
break;
|
|
188
|
-
case "sk-compat-view-tab":
|
|
189
|
-
if (!this.controlPanelEl || this.currentTab === "compatView") return;
|
|
190
|
-
if (!document.startViewTransition) {
|
|
191
|
-
this.controlPanelEl.renderTabContent("compatView");
|
|
192
|
-
this.#handleCompatViewTabState();
|
|
193
|
-
this.currentTab = "compatView";
|
|
194
|
-
} else this.#handleTabChange("compatView");
|
|
195
|
-
break;
|
|
196
|
-
case "sk-toggle-inspector":
|
|
197
|
-
this.bus.emit("ci:toggle");
|
|
198
|
-
break;
|
|
199
|
-
case "sk-toggle-elements":
|
|
200
|
-
this.multiElements = !this.multiElements;
|
|
201
|
-
if (this.depthLevelInput) if (this.multiElements) this.depthLevelInput.disabled = false;
|
|
202
|
-
else this.depthLevelInput.disabled = true;
|
|
203
|
-
if (this.#stateBind) this.#stateBind.multiElements = this.multiElements;
|
|
204
|
-
break;
|
|
205
|
-
case "sk-toggle-switching":
|
|
206
|
-
if (this.#stateBind) this.#stateBind.inspectorSwitching = !this.#stateBind.inspectorSwitching;
|
|
207
|
-
break;
|
|
208
|
-
case "sk-create-inspector":
|
|
209
|
-
this.bus.emit("ci:create");
|
|
210
|
-
break;
|
|
211
|
-
case "sk-reset-inspector":
|
|
212
|
-
this.bus.emit("ci:reset");
|
|
213
|
-
break;
|
|
214
|
-
case "sk-destroy-inspector":
|
|
215
|
-
this.bus.emit("ci:destroy");
|
|
216
|
-
break;
|
|
217
|
-
case "sk-clear-history":
|
|
218
|
-
this.bus.emit("clear:history");
|
|
219
|
-
break;
|
|
220
|
-
default: break;
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Handles the transition between tab changes.
|
|
225
|
-
* @param {"inspector" | "compatView"} tab
|
|
226
|
-
*/
|
|
227
|
-
async #handleTabChange(tab) {
|
|
228
|
-
if (!this.controlPanelEl) return;
|
|
229
|
-
if (this.controlPanelEl.shadowRootRef.getElementById("sk-control-panel-main")) {
|
|
230
|
-
const transition = document.startViewTransition(() => {
|
|
231
|
-
this.controlPanelEl?.renderTabContent(tab);
|
|
232
|
-
});
|
|
233
|
-
this.currentTab = tab;
|
|
234
|
-
await transition.finished;
|
|
235
|
-
if (this.currentTab === "inspector") this.#handleInspectorTabState();
|
|
236
|
-
else if (this.currentTab === "compatView") this.#handleCompatViewTabState();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
#handleInspectorTabState() {
|
|
240
|
-
if (!this.controlPanelEl) return;
|
|
241
|
-
const depthLevel = this.controlPanelEl.shadowRootRef.getElementById("sk-depth-level");
|
|
242
|
-
if (depthLevel) {
|
|
243
|
-
this.depthLevelInput = depthLevel;
|
|
244
|
-
this.depthLevelInput.addEventListener("change", this.#handleDepthLevelValue, { signal: this.#panelController?.signal });
|
|
245
|
-
if (this.#stateBind) {
|
|
246
|
-
if (this.#stateBind.multiElements) {
|
|
247
|
-
const checkbox = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-elements");
|
|
248
|
-
checkbox.checked = true;
|
|
249
|
-
} else this.depthLevelInput.disabled = true;
|
|
250
|
-
if (this.#stateBind.depthLevel > 0) this.depthLevelInput.value = `${this.#stateBind.depthLevel}`;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (this.#stateBind) {
|
|
254
|
-
const switchingToggle = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-switching");
|
|
255
|
-
const inspectorToggle = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-inspector");
|
|
256
|
-
if (inspectorToggle) if (this.#stateBind.inspectorActive) inspectorToggle.textContent = "Enabled";
|
|
257
|
-
else inspectorToggle.textContent = "Disabled";
|
|
258
|
-
if (switchingToggle) if (this.#stateBind.inspectorSwitching) switchingToggle.textContent = "Enabled";
|
|
259
|
-
else switchingToggle.textContent = "Disabled";
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
#handleCompatViewTabState() {
|
|
263
|
-
if (!this.controlPanelEl) return;
|
|
264
|
-
const maxHistory = this.controlPanelEl.shadowRootRef.getElementById("sk-max-history");
|
|
265
|
-
if (maxHistory && maxHistory instanceof HTMLInputElement) {
|
|
266
|
-
this.maxResultsHistoryInput = maxHistory;
|
|
267
|
-
this.maxResultsHistoryInput.addEventListener("change", this.#handleMaxHistoryValue, { signal: this.#panelController?.signal });
|
|
268
|
-
if (this.#stateBind) {
|
|
269
|
-
if (this.#stateBind.maxResultsHistory >= 0 && this.#stateBind.maxResultsHistory != 10) this.maxResultsHistoryInput.value = `${this.#stateBind.maxResultsHistory}`;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Handles the transition when toggling the display.
|
|
275
|
-
* @param {"show" | "hide"} display
|
|
276
|
-
*/
|
|
277
|
-
async #handleDisplayTransition(display) {
|
|
278
|
-
if (!this.controlPanelEl) return;
|
|
279
|
-
const controlPanel = this.controlPanelEl.shadowRootRef.getElementById("sk-control-panel");
|
|
280
|
-
if (controlPanel) {
|
|
281
|
-
controlPanel.part.value = "control-panel";
|
|
282
|
-
const transition = document.startViewTransition(() => {
|
|
283
|
-
this.controlPanelEl?.renderDisplayTransition(display);
|
|
284
|
-
});
|
|
285
|
-
try {
|
|
286
|
-
await transition.finished;
|
|
287
|
-
} finally {
|
|
288
|
-
controlPanel.removeAttribute("part");
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Handles the change event for the `maxResultsHistory` input.
|
|
294
|
-
* @param {Event} e
|
|
295
|
-
*/
|
|
296
|
-
#handleMaxHistoryValue = (e) => {
|
|
297
|
-
const value = parseInt(
|
|
298
|
-
/**@type {HTMLInputElement} */
|
|
299
|
-
e.target.value,
|
|
300
|
-
10
|
|
301
|
-
);
|
|
302
|
-
this.maxResultsHistory = value;
|
|
303
|
-
if (this.#stateBind) this.#stateBind.maxResultsHistory = value;
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* Handles the change event for the `depth_level` input.
|
|
307
|
-
* @param {Event} e
|
|
308
|
-
*/
|
|
309
|
-
#handleDepthLevelValue = (e) => {
|
|
310
|
-
const level = parseInt(
|
|
311
|
-
/**@type {HTMLInputElement}*/
|
|
312
|
-
e.target.value,
|
|
313
|
-
10
|
|
314
|
-
);
|
|
315
|
-
this.depthLevel = level;
|
|
316
|
-
if (this.#stateBind) this.#stateBind.depthLevel = level;
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
|
-
//#endregion
|
|
320
|
-
export { CompatControlPanel };
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - control-panel
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { UIComponent } from "../../core/ui-component.js";
|
|
9
|
+
import { CompatControlPanelElement } from "../../core/elements/control-panel-element.js";
|
|
10
|
+
import "../../core/elements/index.js";
|
|
11
|
+
import "../../core/index.js";
|
|
12
|
+
//#region src/ui/control-panel/control-panel.js
|
|
13
|
+
/**@typedef {import('../../types/public').UISharedState} UISharedState */
|
|
14
|
+
/**@typedef {import('../../types/public').UISharedStateProps} UISharedStateProps */
|
|
15
|
+
/**
|
|
16
|
+
* CompatControlPanel manages the visibility, tabs, and input controls of
|
|
17
|
+
* the compatibility control panel overlay.
|
|
18
|
+
*
|
|
19
|
+
* It mounts the `<sk-control-panel>` custom element, binds control values
|
|
20
|
+
* to shared UI state, and dispatches user-driven commands over the Shinkom
|
|
21
|
+
* event bus.
|
|
22
|
+
*
|
|
23
|
+
* The panel supports inspector controls, compatibility view settings,
|
|
24
|
+
* tab switching, and display transitions with or without view transition
|
|
25
|
+
* support.
|
|
26
|
+
*
|
|
27
|
+
* @extends {UIComponent}
|
|
28
|
+
*/
|
|
29
|
+
var CompatControlPanel = class CompatControlPanel extends UIComponent {
|
|
30
|
+
/**@type {UISharedState | null} */
|
|
31
|
+
#stateBind = null;
|
|
32
|
+
/**@type {AbortController | null} */
|
|
33
|
+
#panelController = null;
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the compatibility control panel.
|
|
36
|
+
*
|
|
37
|
+
* It requires an instance of the `ShinkomBus` and `ShinkomState` to listen
|
|
38
|
+
* for event bus emits and state service notifications.
|
|
39
|
+
*
|
|
40
|
+
* It also registers the `<sk-control-panel>` custom element.
|
|
41
|
+
*
|
|
42
|
+
* @param {ShinkomBus} bus
|
|
43
|
+
* @param {ShinkomState} stateService
|
|
44
|
+
*/
|
|
45
|
+
constructor(bus, stateService) {
|
|
46
|
+
super(bus, stateService);
|
|
47
|
+
CompatControlPanel.register();
|
|
48
|
+
/**@type {CompatControlPanelElement | null} */
|
|
49
|
+
this.controlPanelEl = null;
|
|
50
|
+
/**@type {HTMLInputElement | null} */
|
|
51
|
+
this.depthLevelInput = null;
|
|
52
|
+
/**@type {HTMLInputElement | null} */
|
|
53
|
+
this.maxResultsHistoryInput = null;
|
|
54
|
+
/**@type {number} */
|
|
55
|
+
this.maxResultsHistory = 10;
|
|
56
|
+
/**@type {number} */
|
|
57
|
+
this.depthLevel = 0;
|
|
58
|
+
/**@type {boolean} */
|
|
59
|
+
this.multiElements = false;
|
|
60
|
+
/**@type {"inspector" | "compatView"} */
|
|
61
|
+
this.currentTab = "inspector";
|
|
62
|
+
/**@type {() => void} */
|
|
63
|
+
this.unsubState = () => {};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Register custom elements to the CustomElementRegistry.
|
|
67
|
+
*/
|
|
68
|
+
static register() {
|
|
69
|
+
if (typeof window !== "undefined" && "customElements" in globalThis && !globalThis.customElements.get("sk-control-panel")) globalThis.customElements.define("sk-control-panel", CompatControlPanelElement);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Subscribes to shared UI state changes from the Shinkom state service.
|
|
73
|
+
*
|
|
74
|
+
* When the state service emits updates, the control panel updates the
|
|
75
|
+
* relevant button labels and input state accordingly.
|
|
76
|
+
*/
|
|
77
|
+
#setupStateServiceListener() {
|
|
78
|
+
this.unsubState = this.stateService.subscribe((prop, val) => {
|
|
79
|
+
this.onStateChange(prop, val);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Unsubscribes from the shared UI state service.
|
|
84
|
+
*/
|
|
85
|
+
#cleanupStateServiceListener() {
|
|
86
|
+
this.unsubState();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @param {UISharedState} state
|
|
90
|
+
*/
|
|
91
|
+
bindState(state) {
|
|
92
|
+
if (!this.#stateBind) this.#stateBind = state;
|
|
93
|
+
this.#stateBind.ignorePanelEl = this.controlPanelEl;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @param {UISharedStateProps} prop
|
|
97
|
+
* @param {any} val
|
|
98
|
+
*/
|
|
99
|
+
onStateChange(prop, val) {
|
|
100
|
+
switch (prop) {
|
|
101
|
+
case "inspectorSwitching":
|
|
102
|
+
if (this.controlPanelEl) {
|
|
103
|
+
const toggleSwitchingButton = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-switching");
|
|
104
|
+
if (toggleSwitchingButton) toggleSwitchingButton.textContent = val ? "Enabled" : "Disabled";
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "inspectorActive":
|
|
108
|
+
if (this.controlPanelEl) {
|
|
109
|
+
const toggleInspectorButton = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-inspector");
|
|
110
|
+
if (toggleInspectorButton) toggleInspectorButton.textContent = val ? "Enabled" : "Disabled";
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
default: break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
mount() {
|
|
117
|
+
if (this.controlPanelEl || document.querySelector("sk-control-panel")) return;
|
|
118
|
+
this.controlPanelEl = document.createElement("sk-control-panel");
|
|
119
|
+
document.body.appendChild(this.controlPanelEl);
|
|
120
|
+
this.#setupShadowListeners();
|
|
121
|
+
this.#setupStateServiceListener();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sets up event listeners within the `ShadowDOM`.
|
|
125
|
+
*/
|
|
126
|
+
#setupShadowListeners() {
|
|
127
|
+
if (!this.controlPanelEl) return;
|
|
128
|
+
this.#panelController = new AbortController();
|
|
129
|
+
const { signal } = this.#panelController;
|
|
130
|
+
const depthLevelInput = this.controlPanelEl.shadowRootRef.getElementById("sk-depth-level");
|
|
131
|
+
this.controlPanelEl.shadowHost.addEventListener("click", this.#handleToggleClick, { signal });
|
|
132
|
+
depthLevelInput?.addEventListener("change", this.#handleDepthLevelValue, { signal });
|
|
133
|
+
if (depthLevelInput) {
|
|
134
|
+
this.depthLevelInput = depthLevelInput;
|
|
135
|
+
this.depthLevelInput.disabled = !this.#stateBind?.multiElements;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
unmount() {
|
|
139
|
+
try {
|
|
140
|
+
if (!this.controlPanelEl) return;
|
|
141
|
+
this.controlPanelEl.remove();
|
|
142
|
+
this.controlPanelEl = null;
|
|
143
|
+
this.#resetInternalState();
|
|
144
|
+
this.#cleanupStateServiceListener();
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error(`Control panel destroy error: ${error}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Resets any internal state and event listeners.
|
|
151
|
+
*/
|
|
152
|
+
#resetInternalState() {
|
|
153
|
+
if (this.#panelController) this.#panelController.abort();
|
|
154
|
+
this.#panelController = null;
|
|
155
|
+
this.depthLevelInput = null;
|
|
156
|
+
this.depthLevel = 0;
|
|
157
|
+
this.multiElements = false;
|
|
158
|
+
if (this.#stateBind) {
|
|
159
|
+
this.#stateBind.depthLevel = 0;
|
|
160
|
+
this.#stateBind.multiElements = false;
|
|
161
|
+
this.#stateBind.ignorePanelEl = null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Handles click events within the control panel.
|
|
166
|
+
* @param {PointerEvent} e
|
|
167
|
+
*/
|
|
168
|
+
#handleToggleClick = (e) => {
|
|
169
|
+
switch (e.target.id) {
|
|
170
|
+
case "sk-show-panel":
|
|
171
|
+
if (!this.controlPanelEl) return;
|
|
172
|
+
if (!document.startViewTransition) this.controlPanelEl.renderDisplayTransition("show");
|
|
173
|
+
else this.#handleDisplayTransition("show");
|
|
174
|
+
break;
|
|
175
|
+
case "sk-close-panel":
|
|
176
|
+
if (!this.controlPanelEl) return;
|
|
177
|
+
if (!document.startViewTransition) this.controlPanelEl.renderDisplayTransition("hide");
|
|
178
|
+
else this.#handleDisplayTransition("hide");
|
|
179
|
+
break;
|
|
180
|
+
case "sk-inspector-tab":
|
|
181
|
+
if (!this.controlPanelEl || this.currentTab === "inspector") return;
|
|
182
|
+
if (!document.startViewTransition) {
|
|
183
|
+
this.controlPanelEl.renderTabContent("inspector");
|
|
184
|
+
this.#handleInspectorTabState();
|
|
185
|
+
this.currentTab = "inspector";
|
|
186
|
+
} else this.#handleTabChange("inspector");
|
|
187
|
+
break;
|
|
188
|
+
case "sk-compat-view-tab":
|
|
189
|
+
if (!this.controlPanelEl || this.currentTab === "compatView") return;
|
|
190
|
+
if (!document.startViewTransition) {
|
|
191
|
+
this.controlPanelEl.renderTabContent("compatView");
|
|
192
|
+
this.#handleCompatViewTabState();
|
|
193
|
+
this.currentTab = "compatView";
|
|
194
|
+
} else this.#handleTabChange("compatView");
|
|
195
|
+
break;
|
|
196
|
+
case "sk-toggle-inspector":
|
|
197
|
+
this.bus.emit("ci:toggle");
|
|
198
|
+
break;
|
|
199
|
+
case "sk-toggle-elements":
|
|
200
|
+
this.multiElements = !this.multiElements;
|
|
201
|
+
if (this.depthLevelInput) if (this.multiElements) this.depthLevelInput.disabled = false;
|
|
202
|
+
else this.depthLevelInput.disabled = true;
|
|
203
|
+
if (this.#stateBind) this.#stateBind.multiElements = this.multiElements;
|
|
204
|
+
break;
|
|
205
|
+
case "sk-toggle-switching":
|
|
206
|
+
if (this.#stateBind) this.#stateBind.inspectorSwitching = !this.#stateBind.inspectorSwitching;
|
|
207
|
+
break;
|
|
208
|
+
case "sk-create-inspector":
|
|
209
|
+
this.bus.emit("ci:create");
|
|
210
|
+
break;
|
|
211
|
+
case "sk-reset-inspector":
|
|
212
|
+
this.bus.emit("ci:reset");
|
|
213
|
+
break;
|
|
214
|
+
case "sk-destroy-inspector":
|
|
215
|
+
this.bus.emit("ci:destroy");
|
|
216
|
+
break;
|
|
217
|
+
case "sk-clear-history":
|
|
218
|
+
this.bus.emit("clear:history");
|
|
219
|
+
break;
|
|
220
|
+
default: break;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Handles the transition between tab changes.
|
|
225
|
+
* @param {"inspector" | "compatView"} tab
|
|
226
|
+
*/
|
|
227
|
+
async #handleTabChange(tab) {
|
|
228
|
+
if (!this.controlPanelEl) return;
|
|
229
|
+
if (this.controlPanelEl.shadowRootRef.getElementById("sk-control-panel-main")) {
|
|
230
|
+
const transition = document.startViewTransition(() => {
|
|
231
|
+
this.controlPanelEl?.renderTabContent(tab);
|
|
232
|
+
});
|
|
233
|
+
this.currentTab = tab;
|
|
234
|
+
await transition.finished;
|
|
235
|
+
if (this.currentTab === "inspector") this.#handleInspectorTabState();
|
|
236
|
+
else if (this.currentTab === "compatView") this.#handleCompatViewTabState();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
#handleInspectorTabState() {
|
|
240
|
+
if (!this.controlPanelEl) return;
|
|
241
|
+
const depthLevel = this.controlPanelEl.shadowRootRef.getElementById("sk-depth-level");
|
|
242
|
+
if (depthLevel) {
|
|
243
|
+
this.depthLevelInput = depthLevel;
|
|
244
|
+
this.depthLevelInput.addEventListener("change", this.#handleDepthLevelValue, { signal: this.#panelController?.signal });
|
|
245
|
+
if (this.#stateBind) {
|
|
246
|
+
if (this.#stateBind.multiElements) {
|
|
247
|
+
const checkbox = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-elements");
|
|
248
|
+
checkbox.checked = true;
|
|
249
|
+
} else this.depthLevelInput.disabled = true;
|
|
250
|
+
if (this.#stateBind.depthLevel > 0) this.depthLevelInput.value = `${this.#stateBind.depthLevel}`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (this.#stateBind) {
|
|
254
|
+
const switchingToggle = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-switching");
|
|
255
|
+
const inspectorToggle = this.controlPanelEl.shadowRootRef.getElementById("sk-toggle-inspector");
|
|
256
|
+
if (inspectorToggle) if (this.#stateBind.inspectorActive) inspectorToggle.textContent = "Enabled";
|
|
257
|
+
else inspectorToggle.textContent = "Disabled";
|
|
258
|
+
if (switchingToggle) if (this.#stateBind.inspectorSwitching) switchingToggle.textContent = "Enabled";
|
|
259
|
+
else switchingToggle.textContent = "Disabled";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
#handleCompatViewTabState() {
|
|
263
|
+
if (!this.controlPanelEl) return;
|
|
264
|
+
const maxHistory = this.controlPanelEl.shadowRootRef.getElementById("sk-max-history");
|
|
265
|
+
if (maxHistory && maxHistory instanceof HTMLInputElement) {
|
|
266
|
+
this.maxResultsHistoryInput = maxHistory;
|
|
267
|
+
this.maxResultsHistoryInput.addEventListener("change", this.#handleMaxHistoryValue, { signal: this.#panelController?.signal });
|
|
268
|
+
if (this.#stateBind) {
|
|
269
|
+
if (this.#stateBind.maxResultsHistory >= 0 && this.#stateBind.maxResultsHistory != 10) this.maxResultsHistoryInput.value = `${this.#stateBind.maxResultsHistory}`;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Handles the transition when toggling the display.
|
|
275
|
+
* @param {"show" | "hide"} display
|
|
276
|
+
*/
|
|
277
|
+
async #handleDisplayTransition(display) {
|
|
278
|
+
if (!this.controlPanelEl) return;
|
|
279
|
+
const controlPanel = this.controlPanelEl.shadowRootRef.getElementById("sk-control-panel");
|
|
280
|
+
if (controlPanel) {
|
|
281
|
+
controlPanel.part.value = "control-panel";
|
|
282
|
+
const transition = document.startViewTransition(() => {
|
|
283
|
+
this.controlPanelEl?.renderDisplayTransition(display);
|
|
284
|
+
});
|
|
285
|
+
try {
|
|
286
|
+
await transition.finished;
|
|
287
|
+
} finally {
|
|
288
|
+
controlPanel.removeAttribute("part");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Handles the change event for the `maxResultsHistory` input.
|
|
294
|
+
* @param {Event} e
|
|
295
|
+
*/
|
|
296
|
+
#handleMaxHistoryValue = (e) => {
|
|
297
|
+
const value = parseInt(
|
|
298
|
+
/**@type {HTMLInputElement} */
|
|
299
|
+
e.target.value,
|
|
300
|
+
10
|
|
301
|
+
);
|
|
302
|
+
this.maxResultsHistory = value;
|
|
303
|
+
if (this.#stateBind) this.#stateBind.maxResultsHistory = value;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Handles the change event for the `depth_level` input.
|
|
307
|
+
* @param {Event} e
|
|
308
|
+
*/
|
|
309
|
+
#handleDepthLevelValue = (e) => {
|
|
310
|
+
const level = parseInt(
|
|
311
|
+
/**@type {HTMLInputElement}*/
|
|
312
|
+
e.target.value,
|
|
313
|
+
10
|
|
314
|
+
);
|
|
315
|
+
this.depthLevel = level;
|
|
316
|
+
if (this.#stateBind) this.#stateBind.depthLevel = level;
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
export { CompatControlPanel };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - ui\control-panel\index
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import "./control-panel.js";
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - ui\control-panel\index
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import "./control-panel.js";
|