shinkom 1.0.3 → 1.1.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/README.md +3 -2
- package/dist/bundles/_virtual/_rolldown/runtime.js +1 -1
- package/dist/bundles/core/constants.d.ts +1 -1
- package/dist/bundles/core/constants.js +5 -2
- package/dist/bundles/core/elements/compat-view-element.d.ts +100 -0
- package/dist/bundles/core/elements/compat-view-element.js +440 -0
- package/dist/bundles/core/elements/control-panel-element.d.ts +45 -0
- package/dist/bundles/core/elements/control-panel-element.js +99 -0
- package/dist/bundles/core/elements/index.d.ts +13 -0
- package/dist/bundles/core/elements/index.js +13 -0
- package/dist/bundles/core/elements/inspector-element.d.ts +27 -0
- package/dist/bundles/core/elements/inspector-element.js +58 -0
- package/dist/bundles/core/elements/recent-result-item.js +46 -0
- package/dist/bundles/core/elements/results-history-item.js +46 -0
- package/dist/bundles/core/elements/templates/compat-view.templates.js +462 -0
- package/dist/bundles/core/elements/templates/control-panel.templates.js +335 -0
- package/dist/bundles/core/elements/templates/root-styles.template.js +40 -0
- package/dist/bundles/core/event-bus.d.ts +19 -5
- package/dist/bundles/core/event-bus.js +21 -8
- package/dist/bundles/core/helpers.js +24 -2
- package/dist/bundles/core/index.d.ts +5 -2
- package/dist/bundles/core/index.js +6 -2
- package/dist/bundles/core/state-service.d.ts +24 -4
- package/dist/bundles/core/state-service.js +25 -5
- package/dist/bundles/core/ui-component.d.ts +25 -6
- package/dist/bundles/core/ui-component.js +31 -12
- package/dist/bundles/engine/engine.d.ts +57 -9
- package/dist/bundles/engine/engine.js +115 -31
- package/dist/bundles/engine/index.js +1 -1
- package/dist/bundles/gen/browser-data.js +96 -96
- package/dist/bundles/gen/browser-usage-data.js +671 -671
- package/dist/bundles/gen/index.js +1 -1
- package/dist/bundles/index.d.ts +6 -2
- package/dist/bundles/index.js +8 -2
- package/dist/bundles/pkg/shinkore.d.ts +1 -1
- package/dist/bundles/pkg/shinkore.js +1 -1
- package/dist/bundles/shinkom.d.ts +9 -1
- package/dist/bundles/shinkom.js +31 -6
- package/dist/bundles/types/public.d.ts +13 -29
- package/dist/bundles/types/types.d.ts +99 -0
- package/dist/bundles/ui/compat-ui/compat-ui.d.ts +12 -2
- package/dist/bundles/ui/compat-ui/compat-ui.js +12 -2
- package/dist/bundles/ui/compat-ui/index.js +8 -0
- package/dist/bundles/ui/compatibility-view/compatibility-view.d.ts +42 -0
- package/dist/bundles/ui/compatibility-view/compatibility-view.js +229 -0
- package/dist/bundles/ui/compatibility-view/index.js +8 -0
- package/dist/bundles/ui/control-panel/control-panel.d.ts +30 -16
- package/dist/bundles/ui/control-panel/control-panel.js +188 -277
- package/dist/bundles/ui/control-panel/index.js +8 -0
- package/dist/bundles/ui/index.d.ts +3 -2
- package/dist/bundles/ui/index.js +7 -2
- package/dist/bundles/ui/inspector/index.js +8 -0
- package/dist/bundles/ui/inspector/inspector.d.ts +60 -6
- package/dist/bundles/ui/inspector/inspector.js +149 -69
- package/dist/modules/core/constants.cjs +17 -1
- package/dist/modules/core/elements/compat-view-element.cjs +434 -0
- package/dist/modules/core/elements/control-panel-element.cjs +93 -0
- package/dist/modules/core/elements/index.cjs +11 -0
- package/dist/modules/core/elements/inspector-element.cjs +52 -0
- package/dist/modules/core/elements/recent-result-item.cjs +39 -0
- package/dist/modules/core/elements/results-history-item.cjs +39 -0
- package/dist/modules/core/elements/templates/compat-view.templates.cjs +458 -0
- package/dist/modules/core/elements/templates/control-panel.templates.cjs +332 -0
- package/dist/modules/core/elements/templates/root-styles.template.cjs +33 -0
- package/dist/modules/core/event-bus.cjs +43 -1
- package/dist/modules/core/helpers.cjs +41 -1
- package/dist/modules/core/index.cjs +16 -1
- package/dist/modules/core/state-service.cjs +74 -1
- package/dist/modules/core/ui-component.cjs +65 -1
- package/dist/modules/engine/engine.cjs +232 -1
- package/dist/modules/gen/browser-data.cjs +100 -1
- package/dist/modules/gen/browser-usage-data.cjs +675 -1
- package/dist/modules/gen/compat-data.cjs +31015 -1
- package/dist/modules/gen/index.cjs +7 -1
- package/dist/modules/index.cjs +27 -1
- package/dist/modules/pkg/shinkore.cjs +459 -1
- package/dist/modules/shinkom.cjs +73 -1
- package/dist/modules/ui/compat-ui/compat-ui.cjs +53 -1
- package/dist/modules/ui/compat-ui/index.cjs +1 -0
- package/dist/modules/ui/compatibility-view/compatibility-view.cjs +223 -0
- package/dist/modules/ui/compatibility-view/index.cjs +1 -0
- package/dist/modules/ui/control-panel/control-panel.cjs +314 -182
- package/dist/modules/ui/control-panel/index.cjs +1 -0
- package/dist/modules/ui/index.cjs +13 -1
- package/dist/modules/ui/inspector/index.cjs +1 -0
- package/dist/modules/ui/inspector/inspector.cjs +388 -1
- package/package.json +13 -6
- package/dist/bundles/node_modules/@mdn/browser-compat-data/types.d.ts +0 -78
|
@@ -1 +1,388 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_ui_component = require("../../core/ui-component.cjs");
|
|
3
|
+
const require_core_elements_inspector_element = require("../../core/elements/inspector-element.cjs");
|
|
4
|
+
require("../../core/elements/index.cjs");
|
|
5
|
+
require("../../core/index.cjs");
|
|
6
|
+
//#region src/ui/inspector/inspector.js
|
|
7
|
+
/**@typedef {import('../../types/public').UISharedState} UISharedState */
|
|
8
|
+
/**@typedef {import('../../types/public').InspectorConfig} InspectorConfig */
|
|
9
|
+
/**@typedef {import('../../types/public').UISharedStateProps} UISharedStateProps */
|
|
10
|
+
/**
|
|
11
|
+
* CompatInspector manages the interactive compatibility inspector overlay.
|
|
12
|
+
*
|
|
13
|
+
* It mounts the custom element `<sk-compat-inspector>`, synchronizes
|
|
14
|
+
* the overlay state with the shared UI state, and emits inspection
|
|
15
|
+
* requests through the Shinkom event bus.
|
|
16
|
+
*
|
|
17
|
+
* The inspector supports pointer tracking, element freezing, optional
|
|
18
|
+
* keyboard shortcuts, and soft mount/unmount flows that preserve or
|
|
19
|
+
* skip event bus bindings.
|
|
20
|
+
*
|
|
21
|
+
* @extends {UIComponent}
|
|
22
|
+
*/
|
|
23
|
+
var CompatInspector = class CompatInspector extends require_core_ui_component.UIComponent {
|
|
24
|
+
/**@type {UISharedState | null} */
|
|
25
|
+
#stateBind = null;
|
|
26
|
+
#freezeInspector = false;
|
|
27
|
+
/**@type {AbortController | null} */
|
|
28
|
+
#inspectorController = null;
|
|
29
|
+
/**
|
|
30
|
+
* Initializes the compatibility inspector.
|
|
31
|
+
*
|
|
32
|
+
* It requires an instance of the `ShinkomBus` and `ShinkomState` to listen
|
|
33
|
+
* for event bus emits and state service notifications.
|
|
34
|
+
*
|
|
35
|
+
* It also registers the `<sk-compat-inspector>` custom element.
|
|
36
|
+
*
|
|
37
|
+
* It has an optional configuration object for disabling the inspector
|
|
38
|
+
* and toggling keyboard shortcuts.
|
|
39
|
+
*
|
|
40
|
+
* ### Keyboard Shortcuts
|
|
41
|
+
*
|
|
42
|
+
* - Create inspector: Ctrl + Alt + c
|
|
43
|
+
* - Reset inspector: Ctrl + Shift + |
|
|
44
|
+
* - Destroy inspector: Ctrl + Alt + \
|
|
45
|
+
* - Toggle element switching: Ctrl + \
|
|
46
|
+
*
|
|
47
|
+
* @param {ShinkomBus} bus
|
|
48
|
+
* @param {ShinkomState} stateService
|
|
49
|
+
* @param {InspectorConfig | undefined} config
|
|
50
|
+
*/
|
|
51
|
+
constructor(bus, stateService, config = void 0) {
|
|
52
|
+
super(bus, stateService);
|
|
53
|
+
CompatInspector.register();
|
|
54
|
+
/**@type {InspectorConfig | undefined} */
|
|
55
|
+
this.config = config;
|
|
56
|
+
/**@type {boolean} */
|
|
57
|
+
this.enableSwitching = false;
|
|
58
|
+
/**@type {CompatInspectorElement | null} */
|
|
59
|
+
this.inspectorEl = null;
|
|
60
|
+
/**@type {HTMLElement | null} */
|
|
61
|
+
this.frozenTarget = null;
|
|
62
|
+
/**@type {(() => void)[]} */
|
|
63
|
+
this.unsubEvents = [];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Register custom elements to the CustomElementRegistry.
|
|
67
|
+
*/
|
|
68
|
+
static register() {
|
|
69
|
+
if ("customElements" in globalThis && !globalThis.customElements.get("sk-compat-inspector")) globalThis.customElements.define("sk-compat-inspector", require_core_elements_inspector_element.CompatInspectorElement);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Registers event bus listeners for the inspector.
|
|
73
|
+
*/
|
|
74
|
+
#setupEventBusListeners() {
|
|
75
|
+
this.unsubEvents = [
|
|
76
|
+
this.bus.on("ci:toggle", () => {
|
|
77
|
+
if (this.#stateBind?.inspectorActive) this.#removeGlobalListeners();
|
|
78
|
+
else this.#setupGlobalListeners();
|
|
79
|
+
}),
|
|
80
|
+
this.bus.on("ci:create", () => {
|
|
81
|
+
this.mountSoft();
|
|
82
|
+
}),
|
|
83
|
+
this.bus.on("ci:reset", () => {
|
|
84
|
+
this.resetSoft();
|
|
85
|
+
}),
|
|
86
|
+
this.bus.on("ci:destroy", () => {
|
|
87
|
+
this.unmountSoft();
|
|
88
|
+
})
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Removes event bus listeners for the inspector.
|
|
93
|
+
*/
|
|
94
|
+
#cleanupEventBusListeners() {
|
|
95
|
+
this.unsubEvents.forEach((cleanup) => cleanup());
|
|
96
|
+
this.unsubEvents = [];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Handler responds to keyboard shortcuts.
|
|
100
|
+
* @param {KeyboardEvent} e
|
|
101
|
+
*/
|
|
102
|
+
#handleKeyboard = (e) => {
|
|
103
|
+
const ctrlDown = e.ctrlKey;
|
|
104
|
+
const shiftDown = e.shiftKey;
|
|
105
|
+
const altDown = e.altKey;
|
|
106
|
+
if (!this.inspectorEl && ctrlDown && altDown && e.key === "c") {
|
|
107
|
+
this.mountSoft();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (this.inspectorEl && ctrlDown && shiftDown && e.key === "|") {
|
|
111
|
+
this.resetSoft();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (this.inspectorEl && ctrlDown && altDown && e.key === "\\") {
|
|
115
|
+
this.unmountSoft();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (ctrlDown && e.key === "\\") {
|
|
119
|
+
this.enableSwitching = !this.enableSwitching;
|
|
120
|
+
if (this.#stateBind) this.#stateBind.inspectorSwitching = this.enableSwitching;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Handler toggles inspector freezing on elements.
|
|
125
|
+
* @param {PointerEvent} e
|
|
126
|
+
*/
|
|
127
|
+
#handleToggleFreeze = (e) => {
|
|
128
|
+
if (e.composedPath().includes(this.#stateBind?.ignorePanelEl) || e.composedPath().includes(this.#stateBind?.ignoreCompatViewEl)) return;
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
if (!this.#freezeInspector) {
|
|
132
|
+
this.#freeze(e.target);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (this.#freezeInspector && e.target === this.frozenTarget) {
|
|
136
|
+
this.#unfreeze();
|
|
137
|
+
return;
|
|
138
|
+
} else this.#switch(e.target);
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Freezes inspector on selected target.
|
|
142
|
+
* @param {HTMLElement} target
|
|
143
|
+
*/
|
|
144
|
+
#freeze(target) {
|
|
145
|
+
if (!this.inspectorEl) return;
|
|
146
|
+
const { width, height, top, left } = target.getBoundingClientRect();
|
|
147
|
+
const scrollTop = window.scrollY;
|
|
148
|
+
const scrollLeft = window.scrollX;
|
|
149
|
+
this.#freezeInspector = true;
|
|
150
|
+
this.frozenTarget = target;
|
|
151
|
+
this.#inspect(this.frozenTarget.outerHTML);
|
|
152
|
+
Object.assign(this.inspectorEl.shadowHost.style, {
|
|
153
|
+
width: `${width}px`,
|
|
154
|
+
height: `${height}px`,
|
|
155
|
+
transform: `translateX(${left + scrollLeft}px) translateY(${top + scrollTop}px)`,
|
|
156
|
+
backgroundColor: "rgba(255,0,0,.3)",
|
|
157
|
+
outlineColor: "rgb(255,0,0)"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**@param {string} frozenTarget */
|
|
161
|
+
#inspect(frozenTarget) {
|
|
162
|
+
if (this.#stateBind) this.bus.emit("engine:inspect", { detail: {
|
|
163
|
+
elem: frozenTarget,
|
|
164
|
+
multiElements: this.#stateBind.multiElements,
|
|
165
|
+
depthLevel: this.#stateBind.depthLevel
|
|
166
|
+
} });
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Unfreezes inspector from selected element.
|
|
170
|
+
*/
|
|
171
|
+
#unfreeze() {
|
|
172
|
+
if (!this.inspectorEl) return;
|
|
173
|
+
this.#freezeInspector = false;
|
|
174
|
+
this.frozenTarget = null;
|
|
175
|
+
Object.assign(this.inspectorEl.shadowHost.style, {
|
|
176
|
+
backgroundColor: "rgba(0,255,0,.3)",
|
|
177
|
+
outlineColor: "rgb(0,255,0)"
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handler updates inspector to wrap target element.
|
|
182
|
+
* @param {PointerEvent} e
|
|
183
|
+
*/
|
|
184
|
+
#handlePointerOver = (e) => {
|
|
185
|
+
if (this.#freezeInspector) return;
|
|
186
|
+
try {
|
|
187
|
+
this.#update(e.target);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error(`Inspector pointerOver error: ${error}`);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Switches inspector to target a different element.
|
|
194
|
+
* @param {HTMLElement} target
|
|
195
|
+
*/
|
|
196
|
+
#switch(target) {
|
|
197
|
+
if (this.enableSwitching) {
|
|
198
|
+
this.#freezeInspector = true;
|
|
199
|
+
this.frozenTarget = target;
|
|
200
|
+
this.#inspect(this.frozenTarget.outerHTML);
|
|
201
|
+
try {
|
|
202
|
+
this.#update(target);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error(`Inspector switch error: ${error}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Updates the position of the inspector when moving to a different element.
|
|
210
|
+
* @param {HTMLElement} target
|
|
211
|
+
*/
|
|
212
|
+
#update(target) {
|
|
213
|
+
if (!this.inspectorEl) throw new Error("Failed to update inspector position and size as it does not exist.");
|
|
214
|
+
const { width, height, top, left } = target.getBoundingClientRect();
|
|
215
|
+
const scrollTop = window.scrollY;
|
|
216
|
+
const scrollLeft = window.scrollX;
|
|
217
|
+
Object.assign(this.inspectorEl.shadowHost.style, {
|
|
218
|
+
width: `${width}px`,
|
|
219
|
+
height: `${height}px`,
|
|
220
|
+
transform: `translateX(${left + scrollLeft}px) translateY(${top + scrollTop}px)`
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @param {UISharedState} state
|
|
225
|
+
*/
|
|
226
|
+
bindState(state) {
|
|
227
|
+
if (!this.#stateBind) this.#stateBind = state;
|
|
228
|
+
this.#stateBind.inspectorActive = this.inspectorEl !== null;
|
|
229
|
+
this.#stateBind.inspectorExists = this.inspectorEl !== null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @param {UISharedStateProps} prop
|
|
233
|
+
* @param {any} val
|
|
234
|
+
*/
|
|
235
|
+
onStateChange(prop, val) {
|
|
236
|
+
switch (prop) {
|
|
237
|
+
case "inspectorSwitching":
|
|
238
|
+
this.enableSwitching = val;
|
|
239
|
+
break;
|
|
240
|
+
default: break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
mount() {
|
|
244
|
+
if (this.inspectorEl || this.config?.disabled || document.querySelector("sk-compat-inspector")) {
|
|
245
|
+
console.warn("Inspector is either disabled or already exists");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
console.log("Creating inspector");
|
|
249
|
+
this.inspectorEl = document.createElement("sk-compat-inspector");
|
|
250
|
+
document.body.appendChild(this.inspectorEl);
|
|
251
|
+
this.#setupGlobalListeners();
|
|
252
|
+
this.#setupEventBusListeners();
|
|
253
|
+
if (this.#stateBind) {
|
|
254
|
+
this.#stateBind.inspectorActive = this.inspectorEl !== null;
|
|
255
|
+
this.#stateBind.inspectorExists = this.inspectorEl !== null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Mounts the inspector without setting up event bus listeners or state listeners.
|
|
260
|
+
*
|
|
261
|
+
* This is useful when the inspector should be rendered and tracked visually,
|
|
262
|
+
* but the surrounding application already manages bus events separately.
|
|
263
|
+
*
|
|
264
|
+
* **Only use this if you do not need to setup listeners.**
|
|
265
|
+
*/
|
|
266
|
+
mountSoft() {
|
|
267
|
+
if (this.inspectorEl || this.config?.disabled || document.querySelector("sk-compat-inspector")) {
|
|
268
|
+
console.warn("Inspector is either disabled or already exists");
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
console.log("Soft creating inspector");
|
|
272
|
+
this.inspectorEl = document.createElement("sk-compat-inspector");
|
|
273
|
+
document.body.appendChild(this.inspectorEl);
|
|
274
|
+
this.#setupGlobalListeners();
|
|
275
|
+
if (this.#stateBind) {
|
|
276
|
+
this.#stateBind.inspectorActive = this.inspectorEl !== null;
|
|
277
|
+
this.#stateBind.inspectorExists = this.inspectorEl !== null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Setup event listeners on `window` object.
|
|
282
|
+
*/
|
|
283
|
+
#setupGlobalListeners() {
|
|
284
|
+
if (!this.inspectorEl) {
|
|
285
|
+
console.warn("Cannot activate inspector as it does not exist.");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
this.#inspectorController = new AbortController();
|
|
289
|
+
const { signal } = this.#inspectorController;
|
|
290
|
+
window.addEventListener("pointerover", this.#handlePointerOver, { signal });
|
|
291
|
+
window.addEventListener("click", this.#handleToggleFreeze, {
|
|
292
|
+
signal,
|
|
293
|
+
capture: true
|
|
294
|
+
});
|
|
295
|
+
if (this.config?.keyboardShortcuts) window.addEventListener("keydown", this.#handleKeyboard);
|
|
296
|
+
if (this.#stateBind) this.#stateBind.inspectorActive = true;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Remove event listeners on `window` object.
|
|
300
|
+
*/
|
|
301
|
+
#removeGlobalListeners() {
|
|
302
|
+
if (!this.inspectorEl) {
|
|
303
|
+
console.warn("Cannot deactivate inspector as it does not exist.");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (this.#inspectorController) this.#inspectorController.abort();
|
|
307
|
+
this.#inspectorController = null;
|
|
308
|
+
if (this.#stateBind) this.#stateBind.inspectorActive = false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Resets the inspector.
|
|
312
|
+
*/
|
|
313
|
+
reset() {
|
|
314
|
+
if (!this.inspectorEl || document.querySelector("sk-compat-inspector")) {
|
|
315
|
+
console.warn("Cannot reset inspector as it does not exist.");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
console.log("Resetting inspector");
|
|
319
|
+
this.unmount();
|
|
320
|
+
this.mount();
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Resets the inspector using soft operations.
|
|
324
|
+
*/
|
|
325
|
+
resetSoft() {
|
|
326
|
+
if (!this.inspectorEl) {
|
|
327
|
+
console.warn("Cannot reset inspector as it does not exist.");
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
console.log("Soft resetting inspector");
|
|
331
|
+
this.unmountSoft();
|
|
332
|
+
this.mountSoft();
|
|
333
|
+
}
|
|
334
|
+
unmount() {
|
|
335
|
+
try {
|
|
336
|
+
if (!this.inspectorEl && this.unsubEvents.length === 0) {
|
|
337
|
+
console.warn("Cannot destroy inspector as it does not exist.");
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
console.log("Destroying inspector");
|
|
341
|
+
this.#resetInternalState();
|
|
342
|
+
this.inspectorEl?.remove();
|
|
343
|
+
this.inspectorEl = null;
|
|
344
|
+
this.#cleanupEventBusListeners();
|
|
345
|
+
} catch (error) {
|
|
346
|
+
console.error(`Inspector destroy error: ${error}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Unmounts the inspector without cleaning up event bus listeners or state listeners.
|
|
351
|
+
*
|
|
352
|
+
* This preserves any active bus subscriptions when the visual overlay is
|
|
353
|
+
* temporarily removed.
|
|
354
|
+
*
|
|
355
|
+
* **Only use this if you still need the listeners after unmounting.**
|
|
356
|
+
*/
|
|
357
|
+
unmountSoft() {
|
|
358
|
+
try {
|
|
359
|
+
if (!this.inspectorEl) {
|
|
360
|
+
console.warn("Cannot destroy inspector as it does not exist.");
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
console.log("Soft destroying inspector");
|
|
364
|
+
this.#resetInternalState();
|
|
365
|
+
this.inspectorEl.remove();
|
|
366
|
+
this.inspectorEl = null;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
console.error(`Inspector destroy error: ${error}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Reset internal state of the instance and any related state
|
|
373
|
+
* in the `stateBind`.
|
|
374
|
+
*/
|
|
375
|
+
#resetInternalState() {
|
|
376
|
+
this.#removeGlobalListeners();
|
|
377
|
+
this.#freezeInspector = false;
|
|
378
|
+
this.enableSwitching = false;
|
|
379
|
+
this.frozenTarget = null;
|
|
380
|
+
if (this.#stateBind) {
|
|
381
|
+
this.#stateBind.inspectorActive = false;
|
|
382
|
+
this.#stateBind.inspectorExists = false;
|
|
383
|
+
this.#stateBind.inspectorSwitching = false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
//#endregion
|
|
388
|
+
exports.CompatInspector = CompatInspector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinkom",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A cross-browser compatibility library for developers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "OneilNvM <oneil324@outlook.com>",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"require": "./dist/modules/index.cjs"
|
|
37
37
|
},
|
|
38
38
|
"./shinkom": {
|
|
39
|
-
"types": "./dist/bundles/shinkom
|
|
40
|
-
"import": "./dist/bundles/shinkom
|
|
41
|
-
"require": "./dist/modules/shinkom
|
|
39
|
+
"types": "./dist/bundles/shinkom.d.ts",
|
|
40
|
+
"import": "./dist/bundles/shinkom.js",
|
|
41
|
+
"require": "./dist/modules/shinkom.cjs"
|
|
42
42
|
},
|
|
43
43
|
"./engine": {
|
|
44
44
|
"types": "./dist/bundles/engine/engine.d.ts",
|
|
@@ -60,6 +60,11 @@
|
|
|
60
60
|
"import": "./dist/bundles/ui/control-panel/control-panel.js",
|
|
61
61
|
"require": "./dist/modules/ui/control-panel/control-panel.cjs"
|
|
62
62
|
},
|
|
63
|
+
"./ui/compatibility-view": {
|
|
64
|
+
"types": "./dist/bundles/ui/compatibility-view/compatibility-view.d.ts",
|
|
65
|
+
"import": "./dist/bundles/ui/compatibility-view/compatibility-view.js",
|
|
66
|
+
"require": "./dist/modules/ui/compatibility-view/compatibility-view.cjs"
|
|
67
|
+
},
|
|
63
68
|
"./ui/compat-ui": {
|
|
64
69
|
"types": "./dist/bundles/ui/compat-ui/compat-ui.d.ts",
|
|
65
70
|
"import": "./dist/bundles/ui/compat-ui/compat-ui.js",
|
|
@@ -72,7 +77,7 @@
|
|
|
72
77
|
"dev:nobuild": "vite",
|
|
73
78
|
"dev": "npm run build:wasm && vite",
|
|
74
79
|
"build": "npm run build:wasm && npm run build:js",
|
|
75
|
-
"build:js": "tsdown --config-loader unrun && cp src/types/public.d.ts dist/bundles/types/public.d.ts",
|
|
80
|
+
"build:js": "tsdown --config-loader unrun && cp src/types/public.d.ts dist/bundles/types/public.d.ts && cp src/types/types.d.ts dist/bundles/types/types.d.ts",
|
|
76
81
|
"build:wasm": "wasm-pack build shinkore --target web --out-dir ../pkg --release",
|
|
77
82
|
"test": "vitest",
|
|
78
83
|
"type:check": "tsc --project tsconfig.json",
|
|
@@ -82,12 +87,14 @@
|
|
|
82
87
|
"@mdn/browser-compat-data": "7.3.16",
|
|
83
88
|
"@types/node": "^25.6.0",
|
|
84
89
|
"caniuse-db": "^1.0.30001793",
|
|
90
|
+
"construct-style-sheets-polyfill": "^3.1.0",
|
|
85
91
|
"jsdom": "^28.1.0",
|
|
86
92
|
"node": "^25.9.0",
|
|
87
93
|
"tsdown": "^0.21.2",
|
|
88
94
|
"tsx": "^4.21.0",
|
|
89
95
|
"typescript": "^5.9.3",
|
|
90
96
|
"vite": "^7.3.1",
|
|
91
|
-
"vitest": "^4.0.18"
|
|
97
|
+
"vitest": "^4.0.18",
|
|
98
|
+
"vitest-localstorage-mock": "^0.1.2"
|
|
92
99
|
}
|
|
93
100
|
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - browser-compat-data
|
|
3
|
-
* @version 1.0.3
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
//#region node_modules/@mdn/browser-compat-data/types.d.ts
|
|
9
|
-
type VersionValue = string | false;
|
|
10
|
-
/**
|
|
11
|
-
* This interface was referenced by `CompatDataFile`'s JSON-Schema
|
|
12
|
-
* via the `definition` "support_statement".
|
|
13
|
-
*/
|
|
14
|
-
type SupportStatement = SimpleSupportStatement | [SimpleSupportStatement, SimpleSupportStatement, ...SimpleSupportStatement[]];
|
|
15
|
-
/**
|
|
16
|
-
* This interface was referenced by `CompatDataFile`'s JSON-Schema
|
|
17
|
-
* via the `definition` "simple_support_statement".
|
|
18
|
-
*/
|
|
19
|
-
interface SimpleSupportStatement {
|
|
20
|
-
/**
|
|
21
|
-
* A string (indicating which browser version added this feature), or the value false (indicating the feature is not supported).
|
|
22
|
-
*/
|
|
23
|
-
version_added: VersionValue;
|
|
24
|
-
/**
|
|
25
|
-
* A string, indicating which browser version removed this feature.
|
|
26
|
-
*/
|
|
27
|
-
version_removed?: string;
|
|
28
|
-
/**
|
|
29
|
-
* A string, indicating the last browser version that supported this feature. This is automatically generated.
|
|
30
|
-
*/
|
|
31
|
-
version_last?: string;
|
|
32
|
-
/**
|
|
33
|
-
* A prefix to add to the sub-feature name (defaults to empty string). If applicable, leading and trailing '-' must be included.
|
|
34
|
-
*/
|
|
35
|
-
prefix?: string;
|
|
36
|
-
/**
|
|
37
|
-
* An alternative name for the feature, for cases where a feature is implemented under an entirely different name and not just prefixed.
|
|
38
|
-
*/
|
|
39
|
-
alternative_name?: string;
|
|
40
|
-
/**
|
|
41
|
-
* An optional array of objects describing flags that must be configured for this browser to support this feature.
|
|
42
|
-
*
|
|
43
|
-
* @minItems 1
|
|
44
|
-
*/
|
|
45
|
-
flags?: [FlagStatement, ...FlagStatement[]];
|
|
46
|
-
/**
|
|
47
|
-
* An optional changeset/commit URL for the revision which implemented the feature in the source code, or the URL to the bug tracking the implementation, for the associated browser.
|
|
48
|
-
*/
|
|
49
|
-
impl_url?: string | [string, string, ...string[]];
|
|
50
|
-
/**
|
|
51
|
-
* A boolean value indicating whether or not the implementation of the sub-feature deviates from the specification in a way that may cause compatibility problems. It defaults to false (no interoperability problems expected). If set to true, it is recommended that you add a note explaining how it diverges from the standard (such as that it implements an old version of the standard, for example).
|
|
52
|
-
*/
|
|
53
|
-
partial_implementation?: true;
|
|
54
|
-
/**
|
|
55
|
-
* A string or array of strings containing additional information.
|
|
56
|
-
*/
|
|
57
|
-
notes?: string | [string, string, ...string[]];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* This interface was referenced by `CompatDataFile`'s JSON-Schema
|
|
61
|
-
* via the `definition` "flag_statement".
|
|
62
|
-
*/
|
|
63
|
-
interface FlagStatement {
|
|
64
|
-
/**
|
|
65
|
-
* An enum that indicates the flag type.
|
|
66
|
-
*/
|
|
67
|
-
type: "preference" | "runtime_flag";
|
|
68
|
-
/**
|
|
69
|
-
* A string giving the name of the flag or preference that must be configured.
|
|
70
|
-
*/
|
|
71
|
-
name: string;
|
|
72
|
-
/**
|
|
73
|
-
* A string giving the value which the specified flag must be set to for this feature to work.
|
|
74
|
-
*/
|
|
75
|
-
value_to_set?: string;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
export { SupportStatement };
|