shinkom 1.0.3 → 1.1.1

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.
Files changed (90) hide show
  1. package/README.md +3 -2
  2. package/dist/bundles/_virtual/_rolldown/runtime.js +14 -14
  3. package/dist/bundles/core/constants.d.ts +15 -15
  4. package/dist/bundles/core/constants.js +23 -20
  5. package/dist/bundles/core/elements/compat-view-element.d.ts +100 -0
  6. package/dist/bundles/core/elements/compat-view-element.js +440 -0
  7. package/dist/bundles/core/elements/control-panel-element.d.ts +45 -0
  8. package/dist/bundles/core/elements/control-panel-element.js +99 -0
  9. package/dist/bundles/core/elements/index.d.ts +13 -0
  10. package/dist/bundles/core/elements/index.js +13 -0
  11. package/dist/bundles/core/elements/inspector-element.d.ts +27 -0
  12. package/dist/bundles/core/elements/inspector-element.js +58 -0
  13. package/dist/bundles/core/elements/recent-result-item.js +46 -0
  14. package/dist/bundles/core/elements/results-history-item.js +46 -0
  15. package/dist/bundles/core/elements/templates/compat-view.templates.js +462 -0
  16. package/dist/bundles/core/elements/templates/control-panel.templates.js +335 -0
  17. package/dist/bundles/core/elements/templates/root-styles.template.js +40 -0
  18. package/dist/bundles/core/event-bus.d.ts +46 -32
  19. package/dist/bundles/core/event-bus.js +49 -36
  20. package/dist/bundles/core/helpers.js +47 -25
  21. package/dist/bundles/core/index.d.ts +15 -12
  22. package/dist/bundles/core/index.js +16 -12
  23. package/dist/bundles/core/state-service.d.ts +56 -36
  24. package/dist/bundles/core/state-service.js +80 -60
  25. package/dist/bundles/core/ui-component.d.ts +63 -44
  26. package/dist/bundles/core/ui-component.js +71 -52
  27. package/dist/bundles/engine/engine.d.ts +108 -60
  28. package/dist/bundles/engine/engine.js +238 -154
  29. package/dist/bundles/engine/index.js +8 -8
  30. package/dist/bundles/gen/browser-data.js +96 -96
  31. package/dist/bundles/gen/browser-usage-data.js +671 -671
  32. package/dist/bundles/gen/index.js +14 -14
  33. package/dist/bundles/index.d.ts +20 -16
  34. package/dist/bundles/index.js +23 -17
  35. package/dist/bundles/pkg/shinkore.d.ts +50 -50
  36. package/dist/bundles/pkg/shinkore.js +465 -465
  37. package/dist/bundles/pkg/shinkore_bg.wasm +0 -0
  38. package/dist/bundles/shinkom.d.ts +41 -33
  39. package/dist/bundles/shinkom.js +80 -55
  40. package/dist/bundles/types/public.d.ts +13 -29
  41. package/dist/bundles/types/types.d.ts +99 -0
  42. package/dist/bundles/ui/compat-ui/compat-ui.d.ts +43 -33
  43. package/dist/bundles/ui/compat-ui/compat-ui.js +59 -49
  44. package/dist/bundles/ui/compat-ui/index.js +8 -0
  45. package/dist/bundles/ui/compatibility-view/compatibility-view.d.ts +42 -0
  46. package/dist/bundles/ui/compatibility-view/compatibility-view.js +229 -0
  47. package/dist/bundles/ui/compatibility-view/index.js +8 -0
  48. package/dist/bundles/ui/control-panel/control-panel.d.ts +52 -38
  49. package/dist/bundles/ui/control-panel/control-panel.js +320 -409
  50. package/dist/bundles/ui/control-panel/index.js +8 -0
  51. package/dist/bundles/ui/index.d.ts +12 -11
  52. package/dist/bundles/ui/index.js +16 -11
  53. package/dist/bundles/ui/inspector/index.js +8 -0
  54. package/dist/bundles/ui/inspector/inspector.d.ts +97 -43
  55. package/dist/bundles/ui/inspector/inspector.js +394 -314
  56. package/dist/modules/core/constants.cjs +17 -1
  57. package/dist/modules/core/elements/compat-view-element.cjs +434 -0
  58. package/dist/modules/core/elements/control-panel-element.cjs +93 -0
  59. package/dist/modules/core/elements/index.cjs +11 -0
  60. package/dist/modules/core/elements/inspector-element.cjs +52 -0
  61. package/dist/modules/core/elements/recent-result-item.cjs +39 -0
  62. package/dist/modules/core/elements/results-history-item.cjs +39 -0
  63. package/dist/modules/core/elements/templates/compat-view.templates.cjs +458 -0
  64. package/dist/modules/core/elements/templates/control-panel.templates.cjs +332 -0
  65. package/dist/modules/core/elements/templates/root-styles.template.cjs +33 -0
  66. package/dist/modules/core/event-bus.cjs +43 -1
  67. package/dist/modules/core/helpers.cjs +41 -1
  68. package/dist/modules/core/index.cjs +16 -1
  69. package/dist/modules/core/state-service.cjs +74 -1
  70. package/dist/modules/core/ui-component.cjs +65 -1
  71. package/dist/modules/engine/engine.cjs +232 -1
  72. package/dist/modules/gen/browser-data.cjs +100 -1
  73. package/dist/modules/gen/browser-usage-data.cjs +675 -1
  74. package/dist/modules/gen/compat-data.cjs +31015 -1
  75. package/dist/modules/gen/index.cjs +7 -1
  76. package/dist/modules/index.cjs +27 -1
  77. package/dist/modules/pkg/shinkore.cjs +459 -1
  78. package/dist/modules/pkg/shinkore_bg.wasm +0 -0
  79. package/dist/modules/shinkom.cjs +73 -1
  80. package/dist/modules/ui/compat-ui/compat-ui.cjs +53 -1
  81. package/dist/modules/ui/compat-ui/index.cjs +1 -0
  82. package/dist/modules/ui/compatibility-view/compatibility-view.cjs +223 -0
  83. package/dist/modules/ui/compatibility-view/index.cjs +1 -0
  84. package/dist/modules/ui/control-panel/control-panel.cjs +314 -182
  85. package/dist/modules/ui/control-panel/index.cjs +1 -0
  86. package/dist/modules/ui/index.cjs +13 -1
  87. package/dist/modules/ui/inspector/index.cjs +1 -0
  88. package/dist/modules/ui/inspector/inspector.cjs +388 -1
  89. package/package.json +13 -6
  90. package/dist/bundles/node_modules/@mdn/browser-compat-data/types.d.ts +0 -78
@@ -1 +1,388 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../core/ui-component.cjs`);var t=class extends e.UIComponent{#e=null;#t=!1;#n=null;#r=null;constructor(e,t,n=void 0){super(e,t),this.config=n,this.enableSwitching=!1,this.inspectorEl=null,this.frozenTarget=null,this.bus.on(`ci:toggle`,()=>{this.#e?.inspectorActive?this.#m():this.#p()}),this.bus.on(`ci:create`,()=>{this.mount()}),this.bus.on(`ci:reset`,()=>{this.reset()}),this.bus.on(`ci:destroy`,()=>{this.unmount()})}#i=e=>{let t=e.ctrlKey,n=e.shiftKey,r=e.altKey;if(!this.inspectorEl&&t&&r&&e.key===`c`){this.mount();return}if(this.inspectorEl&&t&&n&&e.key===`|`){this.reset();return}if(this.inspectorEl&&t&&r&&e.key===`\\`){this.unmount();return}t&&e.key===`\\`&&(this.enableSwitching=!this.enableSwitching,console.log(`Switching is ${this.enableSwitching?`enabled`:`disabled`}`),this.#e&&(this.#e.inspectorSwitching=this.enableSwitching))};#a=e=>{if(!e.composedPath().includes(this.#r)){if(e.preventDefault(),e.stopPropagation(),!this.#t){this.#o(e.target);return}if(this.#t&&e.target===this.frozenTarget){this.#c();return}else this.#u(e.target)}};#o(e){this.inspectorEl&&(this.#t=!0,this.frozenTarget=e,this.#s(this.frozenTarget.outerHTML),Object.assign(this.inspectorEl.style,{backgroundColor:`rgba(255,0,0,.3)`,outlineColor:`rgb(255,0,0)`}))}#s(e){this.#e&&this.bus.emit(`engine:inspect`,{detail:{elem:e,multiElements:this.#e.multiElements,depthLevel:this.#e.depthLevel}})}#c(){this.inspectorEl&&(this.#t=!1,this.frozenTarget=null,Object.assign(this.inspectorEl.style,{backgroundColor:`rgba(0,255,0,.3)`,outlineColor:`rgb(0,255,0)`}))}#l=e=>{if(!this.#t)try{this.#d(e.target)}catch(e){console.error(`Inspector pointerOver error: ${e}`)}};#u(e){if(this.enableSwitching){this.#t=!0,this.frozenTarget=e,this.#s(this.frozenTarget.outerHTML);try{this.#d(e)}catch(e){console.error(`Inspector switch error: ${e}`)}}}#d(e){if(!this.inspectorEl)throw Error(`Failed to update inspector position and size as it does not exist.`);let{width:t,height:n,top:r,left:i}=e.getBoundingClientRect(),a=window.scrollY,o=window.scrollX;Object.assign(this.inspectorEl.style,{width:`${t}px`,height:`${n}px`,transform:`translateX(${i+o}px) translateY(${r+a}px)`})}createInspector(){if(this.inspectorEl){console.warn(`Inspector element already exists.`);return}this.inspectorEl=document.createElement(`div`),this.inspectorEl.id=`compat-inspector`,Object.assign(this.inspectorEl.style,{position:`absolute`,top:`0`,backgroundColor:`rgba(0, 255, 0, .3)`,outlineWidth:`1px`,outlineStyle:`dashed`,outlineColor:`rgb(0, 255, 0)`,outlineOffset:`4px`,zIndex:`9998`,transitionProperty:`width, height, transform`,transitionDuration:`300ms`,transitionTimingFunction:`ease-out`,willChange:`width, height, transform`,pointerEvents:`none`}),document.body.appendChild(this.inspectorEl)}#f(e){if(!(e instanceof HTMLDivElement)&&e!==null)throw Error(`el must be of type HTMLDivElement or null`);this.#r=e}bindState(e){this.#e||=e,this.#e.inspectorActive=this.inspectorEl!==null,this.#e.inspectorExists=this.inspectorEl!==null}onStateChange(e,t){switch(e){case`inspectorSwitching`:this.enableSwitching=t;break;case`ignorePanelEl`:this.#f(t);break;default:break}}mount(){if(this.inspectorEl||this.config?.disabled){console.warn(`Inspector is either disabled or already exists`);return}this.createInspector(),this.#p(),this.#e&&(this.#e.inspectorActive=this.inspectorEl!==null,this.#e.inspectorExists=this.inspectorEl!==null)}#p(){if(!this.inspectorEl){console.warn(`Cannot activate inspector as it does not exist.`);return}this.#n=new AbortController;let{signal:e}=this.#n;window.addEventListener(`pointerover`,this.#l,{signal:e}),window.addEventListener(`click`,this.#a,{signal:e,capture:!0}),this.config?.keyboardShortcuts&&window.addEventListener(`keydown`,this.#i),this.#e&&(this.#e.inspectorActive=!0)}#m(){if(!this.inspectorEl){console.warn(`Cannot deactivate inspector as it does not exist.`);return}this.#n&&this.#n.abort(),this.#n=null,this.#e&&(this.#e.inspectorActive=!1)}reset(){if(!this.inspectorEl){console.warn(`Cannot reset inspector as it does not exist.`);return}console.log(`Resetting inspector`),this.unmount(),this.mount()}unmount(){try{if(!this.inspectorEl){console.warn(`Cannot destroy inspector as it does not exist.`);return}console.log(`Destroying inspector`),this.#h(),this.inspectorEl.remove(),this.inspectorEl=null}catch(e){console.error(`Inspector destroy error: ${e}`)}}#h(){this.#m(),this.#t=!1,this.enableSwitching=!1,this.frozenTarget=null,this.#e&&(this.#e.inspectorActive=!1,this.#e.inspectorExists=!1,this.#e.inspectorSwitching=!1)}};exports.CompatInspector=t;
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",
3
+ "version": "1.1.1",
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/shinkom.d.ts",
40
- "import": "./dist/bundles/shinkom/shinkom.js",
41
- "require": "./dist/modules/shinkom/shinkom.cjs"
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 };