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