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