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,238 +1,238 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - engine
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { getModulePath } from "../core/helpers.js";
|
|
9
|
-
import { CompatEngine, __wbg_init } from "../pkg/shinkore.js";
|
|
10
|
-
import browser_data_default from "../gen/browser-data.js";
|
|
11
|
-
import browser_usage_data_default from "../gen/browser-usage-data.js";
|
|
12
|
-
import gen_default from "../gen/index.js";
|
|
13
|
-
//#region src/engine/engine.js
|
|
14
|
-
/**@typedef {import('../types/types').CustomEventEngineDetail} CustomEventEngineDetail */
|
|
15
|
-
/**@typedef {import('../types/public').CompatResult} CompatResult */
|
|
16
|
-
/**@type {SKEngine | null} */
|
|
17
|
-
let instance = null;
|
|
18
|
-
/**
|
|
19
|
-
* SKEngine wraps the Shinkom compatibility analysis engine.
|
|
20
|
-
*
|
|
21
|
-
* It manages WASM loading, engine initialization, and compatibility checks
|
|
22
|
-
* for single elements, element subtrees, and full pages. When a `ShinkomBus`
|
|
23
|
-
* instance is provided, SKEngine also emits result events and responds to
|
|
24
|
-
* engine commands from the UI.
|
|
25
|
-
*/
|
|
26
|
-
var SKEngine = class SKEngine {
|
|
27
|
-
/**@type {Promise<void> | null} */
|
|
28
|
-
#wasmLoaded = null;
|
|
29
|
-
/**
|
|
30
|
-
* Initializes the compatibility engine.
|
|
31
|
-
*
|
|
32
|
-
* The engine optionally accepts an event bus to listen for
|
|
33
|
-
* `engine:inspect` and `engine:full` events from UI
|
|
34
|
-
* components.
|
|
35
|
-
*
|
|
36
|
-
* @param {ShinkomBus | null} bus
|
|
37
|
-
*/
|
|
38
|
-
constructor(bus = null) {
|
|
39
|
-
if (instance) return instance;
|
|
40
|
-
this.initialized = false;
|
|
41
|
-
/**@type {CompatEngine | null} */
|
|
42
|
-
this.compatEngine = null;
|
|
43
|
-
/**@type {ShinkomBus | null} */
|
|
44
|
-
this.bus = bus;
|
|
45
|
-
/**@type {(() => void)[]} */
|
|
46
|
-
this.unsubEvents = [];
|
|
47
|
-
instance = this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets the instance of the engine.
|
|
51
|
-
* @returns {SKEngine} the instance
|
|
52
|
-
*/
|
|
53
|
-
getInstance() {
|
|
54
|
-
if (!instance) instance = this;
|
|
55
|
-
return instance;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Clears the instance from memory.
|
|
59
|
-
*/
|
|
60
|
-
static clearInstance() {
|
|
61
|
-
instance = null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Subscribes the engine to UI-driven bus commands.
|
|
65
|
-
*
|
|
66
|
-
* The engine listens for `engine:inspect` and `engine:full` events and
|
|
67
|
-
* translates them into compatibility checks.
|
|
68
|
-
*/
|
|
69
|
-
#setupEventBusListeners() {
|
|
70
|
-
if (this.bus) this.unsubEvents.push(this.bus.on("engine:inspect", (e) => {
|
|
71
|
-
if (typeof e === "object") if (e.multiElements) this.checkElements(e.elem, e.depthLevel);
|
|
72
|
-
else this.checkElement(e.elem);
|
|
73
|
-
}), this.bus.on("engine:full", () => {
|
|
74
|
-
this.fullInspect();
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Unsubscribes from any registered bus listeners.
|
|
79
|
-
*
|
|
80
|
-
* This is called when the engine is destroyed so that no stale callbacks
|
|
81
|
-
* remain attached to the shared event bus.
|
|
82
|
-
*/
|
|
83
|
-
#cleanupEventBusListeners() {
|
|
84
|
-
if (this.unsubEvents.length > 0) {
|
|
85
|
-
this.unsubEvents.forEach((cleanup) => cleanup());
|
|
86
|
-
this.unsubEvents = [];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Loads the WASM runtime and initializes the native Shinkom engine.
|
|
91
|
-
*
|
|
92
|
-
* In Node.js this resolves the module path and loads the WASM binary from
|
|
93
|
-
* the local filesystem. In browser environments it optionally accepts a
|
|
94
|
-
* WASM URL or falls back to the default packaged module loader.
|
|
95
|
-
*
|
|
96
|
-
* @param {string | undefined} wasmURL
|
|
97
|
-
*/
|
|
98
|
-
async loadWasm(wasmURL = void 0) {
|
|
99
|
-
if (this.#wasmLoaded) return this.#wasmLoaded;
|
|
100
|
-
const isNode = typeof window === "undefined";
|
|
101
|
-
try {
|
|
102
|
-
if (isNode) {
|
|
103
|
-
const path = await import("node:path");
|
|
104
|
-
const fs = await import("node:fs");
|
|
105
|
-
let wasmPath = await getModulePath("shinkom/wasm");
|
|
106
|
-
let wasmBuffer;
|
|
107
|
-
if (wasmPath.toString().endsWith("shinkore_bg.wasm")) {
|
|
108
|
-
if (fs.existsSync(wasmPath)) wasmBuffer = fs.readFileSync(wasmPath);
|
|
109
|
-
else {
|
|
110
|
-
wasmPath = path.resolve(__dirname, "../../pkg/shinkore_bg.wasm");
|
|
111
|
-
wasmBuffer = fs.readFileSync(wasmPath);
|
|
112
|
-
}
|
|
113
|
-
this.#wasmLoaded = (async () => {
|
|
114
|
-
await __wbg_init({ module_or_path: wasmBuffer });
|
|
115
|
-
})();
|
|
116
|
-
} else throw new Error("Path does not lead to WASM file.");
|
|
117
|
-
} else if (wasmURL) this.#wasmLoaded = (async () => {
|
|
118
|
-
await __wbg_init({ module_or_path: wasmURL });
|
|
119
|
-
})();
|
|
120
|
-
else this.#wasmLoaded = (async () => {
|
|
121
|
-
await __wbg_init();
|
|
122
|
-
})();
|
|
123
|
-
console.log("loaded WASM");
|
|
124
|
-
return this.#wasmLoaded;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw error;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Initializes the Rust-based compatibility engine.
|
|
131
|
-
*
|
|
132
|
-
* The engine is created after the WASM runtime has been loaded and is
|
|
133
|
-
* configured with the bundled compatibility data.
|
|
134
|
-
*
|
|
135
|
-
* @param {string | undefined} wasmURL
|
|
136
|
-
*/
|
|
137
|
-
async initEngine(wasmURL = void 0) {
|
|
138
|
-
if (this.initialized) {
|
|
139
|
-
console.warn("SKEngine is already initialized.");
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (this.unsubEvents.length === 0) this.#setupEventBusListeners();
|
|
143
|
-
try {
|
|
144
|
-
if (!this.compatEngine) {
|
|
145
|
-
if (!this.#wasmLoaded) if (wasmURL) await this.loadWasm(wasmURL);
|
|
146
|
-
else await this.loadWasm();
|
|
147
|
-
this.compatEngine = new CompatEngine(gen_default.html, gen_default.svg, browser_data_default, browser_usage_data_default);
|
|
148
|
-
this.initialized = true;
|
|
149
|
-
this.getInstance();
|
|
150
|
-
console.log("initialized engine");
|
|
151
|
-
}
|
|
152
|
-
} catch (error) {
|
|
153
|
-
console.error(`Engine initialization error: ${error}`);
|
|
154
|
-
SKEngine.clearInstance();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Checks compatibility for a single element HTML string.
|
|
159
|
-
*
|
|
160
|
-
* If a bus was provided at construction, the resulting compatibility data
|
|
161
|
-
* is emitted on `results:ready`.
|
|
162
|
-
*
|
|
163
|
-
* @param {string} element
|
|
164
|
-
* @returns {CompatResult | null}
|
|
165
|
-
*/
|
|
166
|
-
checkElement(element) {
|
|
167
|
-
try {
|
|
168
|
-
/**@type {CompatResult} */
|
|
169
|
-
const result = this.compatEngine?.check_element(element);
|
|
170
|
-
console.dir(result);
|
|
171
|
-
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
172
|
-
return result;
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error(error);
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Checks compatibility for a subtree of HTML elements.
|
|
180
|
-
*
|
|
181
|
-
* The `depthLevel` controls how deeply nested elements are inspected.
|
|
182
|
-
*
|
|
183
|
-
* @param {string} html
|
|
184
|
-
* @param {number} depthLevel
|
|
185
|
-
* @returns {CompatResult | null}
|
|
186
|
-
*/
|
|
187
|
-
checkElements(html, depthLevel) {
|
|
188
|
-
try {
|
|
189
|
-
const result = this.compatEngine?.check_elements(html, depthLevel);
|
|
190
|
-
console.dir(result);
|
|
191
|
-
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
192
|
-
return result;
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.error(error);
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Checks compatibility for the current full document page.
|
|
200
|
-
*
|
|
201
|
-
* This method is browser-only because it depends on `document` and
|
|
202
|
-
* inspects the serialized page HTML.
|
|
203
|
-
*
|
|
204
|
-
* @returns {CompatResult | null}
|
|
205
|
-
*/
|
|
206
|
-
fullInspect() {
|
|
207
|
-
try {
|
|
208
|
-
const result = this.compatEngine?.full_inspect(document.documentElement.outerHTML.replace(/<sk-[\w-]+><\/sk-[\w-]+>/g, ""));
|
|
209
|
-
console.dir(result);
|
|
210
|
-
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
211
|
-
return result;
|
|
212
|
-
} catch (error) {
|
|
213
|
-
if (error instanceof ReferenceError) console.error("fullInspect is only available in browser environments");
|
|
214
|
-
else console.error(`fullInspect error: ${error}`);
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Releases WASM resources and destroys the engine instance.
|
|
220
|
-
*
|
|
221
|
-
* After calling this method, the engine must be reinitialized before
|
|
222
|
-
* further compatibility checks can be performed.
|
|
223
|
-
*/
|
|
224
|
-
destroy() {
|
|
225
|
-
if (!this.initialized) {
|
|
226
|
-
console.warn("SKEngine has not been initialized.");
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
this.compatEngine?.free();
|
|
230
|
-
this.#cleanupEventBusListeners();
|
|
231
|
-
this.#wasmLoaded = null;
|
|
232
|
-
this.compatEngine = null;
|
|
233
|
-
this.initialized = false;
|
|
234
|
-
SKEngine.clearInstance();
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
//#endregion
|
|
238
|
-
export { SKEngine };
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - engine
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getModulePath } from "../core/helpers.js";
|
|
9
|
+
import { CompatEngine, __wbg_init } from "../pkg/shinkore.js";
|
|
10
|
+
import browser_data_default from "../gen/browser-data.js";
|
|
11
|
+
import browser_usage_data_default from "../gen/browser-usage-data.js";
|
|
12
|
+
import gen_default from "../gen/index.js";
|
|
13
|
+
//#region src/engine/engine.js
|
|
14
|
+
/**@typedef {import('../types/types').CustomEventEngineDetail} CustomEventEngineDetail */
|
|
15
|
+
/**@typedef {import('../types/public').CompatResult} CompatResult */
|
|
16
|
+
/**@type {SKEngine | null} */
|
|
17
|
+
let instance = null;
|
|
18
|
+
/**
|
|
19
|
+
* SKEngine wraps the Shinkom compatibility analysis engine.
|
|
20
|
+
*
|
|
21
|
+
* It manages WASM loading, engine initialization, and compatibility checks
|
|
22
|
+
* for single elements, element subtrees, and full pages. When a `ShinkomBus`
|
|
23
|
+
* instance is provided, SKEngine also emits result events and responds to
|
|
24
|
+
* engine commands from the UI.
|
|
25
|
+
*/
|
|
26
|
+
var SKEngine = class SKEngine {
|
|
27
|
+
/**@type {Promise<void> | null} */
|
|
28
|
+
#wasmLoaded = null;
|
|
29
|
+
/**
|
|
30
|
+
* Initializes the compatibility engine.
|
|
31
|
+
*
|
|
32
|
+
* The engine optionally accepts an event bus to listen for
|
|
33
|
+
* `engine:inspect` and `engine:full` events from UI
|
|
34
|
+
* components.
|
|
35
|
+
*
|
|
36
|
+
* @param {ShinkomBus | null} bus
|
|
37
|
+
*/
|
|
38
|
+
constructor(bus = null) {
|
|
39
|
+
if (instance) return instance;
|
|
40
|
+
this.initialized = false;
|
|
41
|
+
/**@type {CompatEngine | null} */
|
|
42
|
+
this.compatEngine = null;
|
|
43
|
+
/**@type {ShinkomBus | null} */
|
|
44
|
+
this.bus = bus;
|
|
45
|
+
/**@type {(() => void)[]} */
|
|
46
|
+
this.unsubEvents = [];
|
|
47
|
+
instance = this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the instance of the engine.
|
|
51
|
+
* @returns {SKEngine} the instance
|
|
52
|
+
*/
|
|
53
|
+
getInstance() {
|
|
54
|
+
if (!instance) instance = this;
|
|
55
|
+
return instance;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Clears the instance from memory.
|
|
59
|
+
*/
|
|
60
|
+
static clearInstance() {
|
|
61
|
+
instance = null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Subscribes the engine to UI-driven bus commands.
|
|
65
|
+
*
|
|
66
|
+
* The engine listens for `engine:inspect` and `engine:full` events and
|
|
67
|
+
* translates them into compatibility checks.
|
|
68
|
+
*/
|
|
69
|
+
#setupEventBusListeners() {
|
|
70
|
+
if (this.bus) this.unsubEvents.push(this.bus.on("engine:inspect", (e) => {
|
|
71
|
+
if (typeof e === "object") if (e.multiElements) this.checkElements(e.elem, e.depthLevel);
|
|
72
|
+
else this.checkElement(e.elem);
|
|
73
|
+
}), this.bus.on("engine:full", () => {
|
|
74
|
+
this.fullInspect();
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Unsubscribes from any registered bus listeners.
|
|
79
|
+
*
|
|
80
|
+
* This is called when the engine is destroyed so that no stale callbacks
|
|
81
|
+
* remain attached to the shared event bus.
|
|
82
|
+
*/
|
|
83
|
+
#cleanupEventBusListeners() {
|
|
84
|
+
if (this.unsubEvents.length > 0) {
|
|
85
|
+
this.unsubEvents.forEach((cleanup) => cleanup());
|
|
86
|
+
this.unsubEvents = [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Loads the WASM runtime and initializes the native Shinkom engine.
|
|
91
|
+
*
|
|
92
|
+
* In Node.js this resolves the module path and loads the WASM binary from
|
|
93
|
+
* the local filesystem. In browser environments it optionally accepts a
|
|
94
|
+
* WASM URL or falls back to the default packaged module loader.
|
|
95
|
+
*
|
|
96
|
+
* @param {string | undefined} wasmURL
|
|
97
|
+
*/
|
|
98
|
+
async loadWasm(wasmURL = void 0) {
|
|
99
|
+
if (this.#wasmLoaded) return this.#wasmLoaded;
|
|
100
|
+
const isNode = typeof window === "undefined";
|
|
101
|
+
try {
|
|
102
|
+
if (isNode) {
|
|
103
|
+
const path = await import("node:path");
|
|
104
|
+
const fs = await import("node:fs");
|
|
105
|
+
let wasmPath = await getModulePath("shinkom/wasm");
|
|
106
|
+
let wasmBuffer;
|
|
107
|
+
if (wasmPath.toString().endsWith("shinkore_bg.wasm")) {
|
|
108
|
+
if (fs.existsSync(wasmPath)) wasmBuffer = fs.readFileSync(wasmPath);
|
|
109
|
+
else {
|
|
110
|
+
wasmPath = path.resolve(__dirname, "../../pkg/shinkore_bg.wasm");
|
|
111
|
+
wasmBuffer = fs.readFileSync(wasmPath);
|
|
112
|
+
}
|
|
113
|
+
this.#wasmLoaded = (async () => {
|
|
114
|
+
await __wbg_init({ module_or_path: wasmBuffer });
|
|
115
|
+
})();
|
|
116
|
+
} else throw new Error("Path does not lead to WASM file.");
|
|
117
|
+
} else if (wasmURL) this.#wasmLoaded = (async () => {
|
|
118
|
+
await __wbg_init({ module_or_path: wasmURL });
|
|
119
|
+
})();
|
|
120
|
+
else this.#wasmLoaded = (async () => {
|
|
121
|
+
await __wbg_init();
|
|
122
|
+
})();
|
|
123
|
+
console.log("loaded WASM");
|
|
124
|
+
return this.#wasmLoaded;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Initializes the Rust-based compatibility engine.
|
|
131
|
+
*
|
|
132
|
+
* The engine is created after the WASM runtime has been loaded and is
|
|
133
|
+
* configured with the bundled compatibility data.
|
|
134
|
+
*
|
|
135
|
+
* @param {string | undefined} wasmURL
|
|
136
|
+
*/
|
|
137
|
+
async initEngine(wasmURL = void 0) {
|
|
138
|
+
if (this.initialized) {
|
|
139
|
+
console.warn("SKEngine is already initialized.");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (this.unsubEvents.length === 0) this.#setupEventBusListeners();
|
|
143
|
+
try {
|
|
144
|
+
if (!this.compatEngine) {
|
|
145
|
+
if (!this.#wasmLoaded) if (wasmURL) await this.loadWasm(wasmURL);
|
|
146
|
+
else await this.loadWasm();
|
|
147
|
+
this.compatEngine = new CompatEngine(gen_default.html, gen_default.svg, browser_data_default, browser_usage_data_default);
|
|
148
|
+
this.initialized = true;
|
|
149
|
+
this.getInstance();
|
|
150
|
+
console.log("initialized engine");
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(`Engine initialization error: ${error}`);
|
|
154
|
+
SKEngine.clearInstance();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Checks compatibility for a single element HTML string.
|
|
159
|
+
*
|
|
160
|
+
* If a bus was provided at construction, the resulting compatibility data
|
|
161
|
+
* is emitted on `results:ready`.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} element
|
|
164
|
+
* @returns {CompatResult | null}
|
|
165
|
+
*/
|
|
166
|
+
checkElement(element) {
|
|
167
|
+
try {
|
|
168
|
+
/**@type {CompatResult} */
|
|
169
|
+
const result = this.compatEngine?.check_element(element);
|
|
170
|
+
console.dir(result);
|
|
171
|
+
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
172
|
+
return result;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error(error);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Checks compatibility for a subtree of HTML elements.
|
|
180
|
+
*
|
|
181
|
+
* The `depthLevel` controls how deeply nested elements are inspected.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} html
|
|
184
|
+
* @param {number} depthLevel
|
|
185
|
+
* @returns {CompatResult | null}
|
|
186
|
+
*/
|
|
187
|
+
checkElements(html, depthLevel) {
|
|
188
|
+
try {
|
|
189
|
+
const result = this.compatEngine?.check_elements(html, depthLevel);
|
|
190
|
+
console.dir(result);
|
|
191
|
+
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
192
|
+
return result;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error(error);
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Checks compatibility for the current full document page.
|
|
200
|
+
*
|
|
201
|
+
* This method is browser-only because it depends on `document` and
|
|
202
|
+
* inspects the serialized page HTML.
|
|
203
|
+
*
|
|
204
|
+
* @returns {CompatResult | null}
|
|
205
|
+
*/
|
|
206
|
+
fullInspect() {
|
|
207
|
+
try {
|
|
208
|
+
const result = this.compatEngine?.full_inspect(document.documentElement.outerHTML.replace(/<sk-[\w-]+><\/sk-[\w-]+>/g, ""));
|
|
209
|
+
console.dir(result);
|
|
210
|
+
if (this.bus) this.bus.emit("results:ready", { detail: result });
|
|
211
|
+
return result;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
if (error instanceof ReferenceError) console.error("fullInspect is only available in browser environments");
|
|
214
|
+
else console.error(`fullInspect error: ${error}`);
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Releases WASM resources and destroys the engine instance.
|
|
220
|
+
*
|
|
221
|
+
* After calling this method, the engine must be reinitialized before
|
|
222
|
+
* further compatibility checks can be performed.
|
|
223
|
+
*/
|
|
224
|
+
destroy() {
|
|
225
|
+
if (!this.initialized) {
|
|
226
|
+
console.warn("SKEngine has not been initialized.");
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
this.compatEngine?.free();
|
|
230
|
+
this.#cleanupEventBusListeners();
|
|
231
|
+
this.#wasmLoaded = null;
|
|
232
|
+
this.compatEngine = null;
|
|
233
|
+
this.initialized = false;
|
|
234
|
+
SKEngine.clearInstance();
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
//#endregion
|
|
238
|
+
export { SKEngine };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - engine\index
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import "./engine.js";
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - engine\index
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import "./engine.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - gen
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import compat_data_default from "./compat-data.js";
|
|
9
|
-
import "./browser-data.js";
|
|
10
|
-
import "./browser-usage-data.js";
|
|
11
|
-
//#region gen/index.js
|
|
12
|
-
var gen_default = compat_data_default;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { gen_default as default };
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - gen
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import compat_data_default from "./compat-data.js";
|
|
9
|
+
import "./browser-data.js";
|
|
10
|
+
import "./browser-usage-data.js";
|
|
11
|
+
//#region gen/index.js
|
|
12
|
+
var gen_default = compat_data_default;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { gen_default as default };
|
package/dist/bundles/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - index
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { ShinkomBus } from "./core/event-bus.js";
|
|
9
|
-
import { ShinkomState } from "./core/state-service.js";
|
|
10
|
-
import { UIComponent } from "./core/ui-component.js";
|
|
11
|
-
import { CompatViewElement } from "./core/elements/compat-view-element.js";
|
|
12
|
-
import { CompatControlPanelElement } from "./core/elements/control-panel-element.js";
|
|
13
|
-
import { CompatInspectorElement } from "./core/elements/inspector-element.js";
|
|
14
|
-
import { CompatInspector } from "./ui/inspector/inspector.js";
|
|
15
|
-
import { CompatControlPanel } from "./ui/control-panel/control-panel.js";
|
|
16
|
-
import { CompatView } from "./ui/compatibility-view/compatibility-view.js";
|
|
17
|
-
import { CompatUI } from "./ui/compat-ui/compat-ui.js";
|
|
18
|
-
import { SKEngine } from "./engine/engine.js";
|
|
19
|
-
import { Shinkom } from "./shinkom.js";
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - index
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ShinkomBus } from "./core/event-bus.js";
|
|
9
|
+
import { ShinkomState } from "./core/state-service.js";
|
|
10
|
+
import { UIComponent } from "./core/ui-component.js";
|
|
11
|
+
import { CompatViewElement } from "./core/elements/compat-view-element.js";
|
|
12
|
+
import { CompatControlPanelElement } from "./core/elements/control-panel-element.js";
|
|
13
|
+
import { CompatInspectorElement } from "./core/elements/inspector-element.js";
|
|
14
|
+
import { CompatInspector } from "./ui/inspector/inspector.js";
|
|
15
|
+
import { CompatControlPanel } from "./ui/control-panel/control-panel.js";
|
|
16
|
+
import { CompatView } from "./ui/compatibility-view/compatibility-view.js";
|
|
17
|
+
import { CompatUI } from "./ui/compat-ui/compat-ui.js";
|
|
18
|
+
import { SKEngine } from "./engine/engine.js";
|
|
19
|
+
import { Shinkom } from "./shinkom.js";
|
|
20
20
|
export { CompatControlPanel, CompatControlPanelElement, CompatInspector, CompatInspectorElement, CompatUI, CompatView, CompatViewElement, SKEngine, Shinkom, ShinkomBus, ShinkomState, UIComponent };
|
package/dist/bundles/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shinkom - index
|
|
3
|
-
* @version 1.1.
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2026 - OneilNvM
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { ShinkomBus } from "./core/event-bus.js";
|
|
9
|
-
import { ShinkomState } from "./core/state-service.js";
|
|
10
|
-
import { UIComponent } from "./core/ui-component.js";
|
|
11
|
-
import { CompatViewElement } from "./core/elements/compat-view-element.js";
|
|
12
|
-
import { CompatControlPanelElement } from "./core/elements/control-panel-element.js";
|
|
13
|
-
import { CompatInspectorElement } from "./core/elements/inspector-element.js";
|
|
14
|
-
import "./core/index.js";
|
|
15
|
-
import { CompatInspector } from "./ui/inspector/inspector.js";
|
|
16
|
-
import { CompatControlPanel } from "./ui/control-panel/control-panel.js";
|
|
17
|
-
import { CompatView } from "./ui/compatibility-view/compatibility-view.js";
|
|
18
|
-
import { CompatUI } from "./ui/compat-ui/compat-ui.js";
|
|
19
|
-
import "./ui/index.js";
|
|
20
|
-
import { SKEngine } from "./engine/engine.js";
|
|
21
|
-
import "./engine/index.js";
|
|
22
|
-
import { Shinkom } from "./shinkom.js";
|
|
23
|
-
export { CompatControlPanel, CompatControlPanelElement, CompatInspector, CompatInspectorElement, CompatUI, CompatView, CompatViewElement, SKEngine, Shinkom, ShinkomBus, ShinkomState, UIComponent };
|
|
1
|
+
/**
|
|
2
|
+
* Shinkom - index
|
|
3
|
+
* @version 1.1.2
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - OneilNvM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ShinkomBus } from "./core/event-bus.js";
|
|
9
|
+
import { ShinkomState } from "./core/state-service.js";
|
|
10
|
+
import { UIComponent } from "./core/ui-component.js";
|
|
11
|
+
import { CompatViewElement } from "./core/elements/compat-view-element.js";
|
|
12
|
+
import { CompatControlPanelElement } from "./core/elements/control-panel-element.js";
|
|
13
|
+
import { CompatInspectorElement } from "./core/elements/inspector-element.js";
|
|
14
|
+
import "./core/index.js";
|
|
15
|
+
import { CompatInspector } from "./ui/inspector/inspector.js";
|
|
16
|
+
import { CompatControlPanel } from "./ui/control-panel/control-panel.js";
|
|
17
|
+
import { CompatView } from "./ui/compatibility-view/compatibility-view.js";
|
|
18
|
+
import { CompatUI } from "./ui/compat-ui/compat-ui.js";
|
|
19
|
+
import "./ui/index.js";
|
|
20
|
+
import { SKEngine } from "./engine/engine.js";
|
|
21
|
+
import "./engine/index.js";
|
|
22
|
+
import { Shinkom } from "./shinkom.js";
|
|
23
|
+
export { CompatControlPanel, CompatControlPanelElement, CompatInspector, CompatInspectorElement, CompatUI, CompatView, CompatViewElement, SKEngine, Shinkom, ShinkomBus, ShinkomState, UIComponent };
|