shinkom 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +399 -0
  3. package/dist/bundles/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/bundles/core/constants.d.ts +16 -0
  5. package/dist/bundles/core/constants.js +20 -0
  6. package/dist/bundles/core/event-bus.d.ts +33 -0
  7. package/dist/bundles/core/event-bus.js +36 -0
  8. package/dist/bundles/core/helpers.js +25 -0
  9. package/dist/bundles/core/index.d.ts +12 -0
  10. package/dist/bundles/core/index.js +12 -0
  11. package/dist/bundles/core/state-service.d.ts +37 -0
  12. package/dist/bundles/core/state-service.js +60 -0
  13. package/dist/bundles/core/ui-component.d.ts +45 -0
  14. package/dist/bundles/core/ui-component.js +52 -0
  15. package/dist/bundles/engine/engine.d.ts +61 -0
  16. package/dist/bundles/engine/engine.js +154 -0
  17. package/dist/bundles/engine/index.js +8 -0
  18. package/dist/bundles/gen/browser-data.js +96 -0
  19. package/dist/bundles/gen/browser-usage-data.js +669 -0
  20. package/dist/bundles/gen/compat-data.js +1 -0
  21. package/dist/bundles/gen/index.js +14 -0
  22. package/dist/bundles/index.d.ts +16 -0
  23. package/dist/bundles/index.js +17 -0
  24. package/dist/bundles/node_modules/@mdn/browser-compat-data/types.d.ts +78 -0
  25. package/dist/bundles/pkg/shinkore.d.ts +51 -0
  26. package/dist/bundles/pkg/shinkore.js +462 -0
  27. package/dist/bundles/pkg/shinkore_bg.wasm +0 -0
  28. package/dist/bundles/shinkom.d.ts +34 -0
  29. package/dist/bundles/shinkom.js +55 -0
  30. package/dist/bundles/types/public.d.ts +73 -0
  31. package/dist/bundles/ui/compat-ui/compat-ui.d.ts +33 -0
  32. package/dist/bundles/ui/compat-ui/compat-ui.js +49 -0
  33. package/dist/bundles/ui/control-panel/control-panel.d.ts +39 -0
  34. package/dist/bundles/ui/control-panel/control-panel.js +409 -0
  35. package/dist/bundles/ui/index.d.ts +11 -0
  36. package/dist/bundles/ui/index.js +11 -0
  37. package/dist/bundles/ui/inspector/inspector.d.ts +44 -0
  38. package/dist/bundles/ui/inspector/inspector.js +314 -0
  39. package/dist/modules/core/constants.cjs +1 -0
  40. package/dist/modules/core/event-bus.cjs +1 -0
  41. package/dist/modules/core/helpers.cjs +1 -0
  42. package/dist/modules/core/index.cjs +1 -0
  43. package/dist/modules/core/state-service.cjs +1 -0
  44. package/dist/modules/core/ui-component.cjs +1 -0
  45. package/dist/modules/engine/engine.cjs +1 -0
  46. package/dist/modules/gen/browser-data.cjs +1 -0
  47. package/dist/modules/gen/browser-usage-data.cjs +1 -0
  48. package/dist/modules/gen/compat-data.cjs +1 -0
  49. package/dist/modules/gen/index.cjs +1 -0
  50. package/dist/modules/index.cjs +1 -0
  51. package/dist/modules/pkg/shinkore.cjs +1 -0
  52. package/dist/modules/pkg/shinkore_bg.wasm +0 -0
  53. package/dist/modules/shinkom.cjs +1 -0
  54. package/dist/modules/ui/compat-ui/compat-ui.cjs +1 -0
  55. package/dist/modules/ui/control-panel/control-panel.cjs +182 -0
  56. package/dist/modules/ui/index.cjs +1 -0
  57. package/dist/modules/ui/inspector/inspector.cjs +1 -0
  58. package/package.json +89 -0
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 OneilNvM
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,399 @@
1
+ <h1 align="center">Shinkom</h1>
2
+
3
+ <p align="center">
4
+ <strong><em><span style="font-style:italic;">Shinkom</span></em>, the high-speed rail for real-time cross-browser compatibility analysis for websites.<br>
5
+ A JavaScript library powered by a Rust/WASM engine, providing native speed cross-browser compatibility data processing and analysis.<br>
6
+ </strong>
7
+ </p>
8
+
9
+ ## Introduction
10
+
11
+ **Shinkom** is a JavaScript library for real-time website cross-browser compatibility analysis.
12
+
13
+ It is *compatible* with many popular libraries and frameworks such as **React, Vue, NextJs, Nuxt** and Vanilla JS.
14
+ It is also accessible in **Node.Js**, [see more on Node.Js usage here](#nodejs).
15
+
16
+ ---
17
+
18
+ ## Purpose
19
+
20
+ The web has evolved a lot and so have browsers. Among the most popular browsers such as **Chrome, Firefox, Edge, Safari, Opera** and the like,
21
+ there are always new browsers being developed aiming to push the boundaries of what is capable of existing browser technology.
22
+ However, this causes a discrepency in the feature-set between modern browsers since they may use differing technology and architecture
23
+ when developing new browsers.
24
+ Web technology and languages such as **HTML, CSS and JavaScript** are constantly evolving which aids in the problem of features
25
+ either being widely supported or having limited support between browsers.
26
+
27
+ This makes cross-browser compatibility all the more important for a web developer to consider as neglecting this could lead
28
+ to users on other browsers having a poor experience visiting a website due to broken layouts, styling or functionality.
29
+ However, testing for compatibility on different browsers can often become tedious due to the volume of different browsers
30
+ and the many versions of each single one.
31
+
32
+ This is where **Shinkom** connects the rails!
33
+
34
+ The purpose of this library is to provide web developers an intuitive library for analysing the compatibility of a website in real-time during development.
35
+ This project depends heavily on the [@mdn/browser-compat-data](https://github.com/mdn/browser-compat-data/tree/main) project by MDN, which stores a large amount of compatibility data about
36
+ browsers and web features.
37
+
38
+ Most online browser compatibility websites usually require payment for the use of their services and don't often allow for
39
+ finer control of what specifically to test within the website.
40
+ Shinkom aims to provide that fine level of control, to allow web developers to discover the compatibility of their components
41
+ across many browsers during development.
42
+
43
+ This library can also make it easier to identify which specific browsers to test immediately without having to sift through documentation
44
+ to check if a feature works on a particular browser or test the website on every browser to discover potential issues.
45
+
46
+ **Shinkom conducts the analysis of the website content and browser compatibility data and delivers the compatibility result as fast as a bullet train.**
47
+
48
+ ---
49
+
50
+ ## IMPORTANT
51
+
52
+ ### WebAssembly
53
+
54
+ It is important to mention that this project is made with **WebAssembly** through [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen).
55
+ Therefore, the engine will need to be initialized asynchronously and your server will need to accept the `application/wasm` MIME type.
56
+ It is recommended to read relevant documentation in whichever framework or bundler you are using to apply the correct configuration to accept
57
+ WASM files on your server or visit the [examples](/examples) directory, if your framework or bundler of choice is listed there for a working example.
58
+
59
+ ### Server-side Rendering Applications
60
+
61
+ The core engine of Shinkom can be run in Node.js environments, but this is not true for the UI components and the Shinkom entry-point as they are browser-only.
62
+ If using a framework that uses SSR, make sure to initialize the library in hooks that perform side-effects (i.e. `useEffect` or `onMounted`) to prevent
63
+ `window is undefined` errors during SSR pre-rendering.
64
+
65
+ ---
66
+
67
+ ## Getting Started
68
+
69
+ Shinkom can be installed from npm via the `shinkom` package
70
+
71
+ ```bash
72
+ npm install -D shinkom
73
+ ```
74
+
75
+ Once installed, you can then import the Shinkom package in JavaScript.
76
+ Shinkom can be used in frontend frameworks, bundlers and vanilla JS.
77
+
78
+ ### Vanilla JS
79
+
80
+ ```javascript
81
+ import { Shinkom } from 'shinkom'
82
+
83
+ const shinkom = new Shinkom()
84
+
85
+ shinkom.init()
86
+ ```
87
+
88
+ ### React
89
+
90
+ ```javascript
91
+ import React, { useEffect } from 'react'
92
+ import { Shinkom } from 'shinkom'
93
+
94
+ export default function App() {
95
+ useEffect(() => {
96
+ const shinkom = new Shinkom()
97
+
98
+ shinkom.init()
99
+
100
+ return () => shinkom.destroy()
101
+ }, [])
102
+ }
103
+ ```
104
+
105
+ ### Vue
106
+
107
+ ```javascript
108
+ <script setup lang="ts">
109
+ import { onMounted, onUnmounted } from 'vue'
110
+ import { Shinkom } from 'shinkom'
111
+ import wasm from 'shinkom/wasm?url'
112
+
113
+ const shinkom = new Shinkom({
114
+ engine: {
115
+ wasmURL: wasm
116
+ }
117
+ })
118
+
119
+ onMounted(() => {
120
+ shinkom.init()
121
+ })
122
+
123
+ onUnmounted(() => {
124
+ shinkom.destroy()
125
+ })
126
+ </script>
127
+ ```
128
+
129
+ You can also use Shinkom through the `require` statement in commonJS.
130
+
131
+ ```javascript
132
+ const Shinkom = require('shinkom').Shinkom
133
+
134
+ const shinkom = new Shinkom()
135
+
136
+ shinkom.init()
137
+ ```
138
+
139
+ If there are other frameworks or bundlers not listed here as being supported that you would like to use Shinkom with,
140
+ then consider contributing by creating a **pull request** on the **dev** branch to support it and make sure to **create an example for others!**
141
+
142
+ ---
143
+
144
+ ## Usage
145
+
146
+ ### Basic
147
+
148
+ https://github.com/user-attachments/assets/fc0dda8d-1f1b-44cf-bcbe-db7a5f4c76c9
149
+
150
+ The simplest and **recommended** way to utilize Shinkom is through the main entry-point.
151
+
152
+ ```javascript
153
+ import { Shinkom } from 'shinkom'
154
+
155
+ const shinkom = new Shinkom()
156
+
157
+ shinkom.init()
158
+ ```
159
+
160
+ This enables the use of the **interactive UI and Rust/WASM engine** in order to inspect elements on a page.
161
+
162
+ ### Modular
163
+
164
+ Shinkom was made to be **modular**, meaning you can also choose to use individual modules that you would
165
+ like to make use of for finer control.
166
+
167
+ ```javascript
168
+ import { ShinkomBus, ShinkomState, SKEngine, CompatInspector, CompatUI } from 'shinkom'
169
+
170
+ const bus = new ShinkomBus()
171
+ const state = new ShinkomState()
172
+ const engine = new SKEngine(bus)
173
+ const inspector = new CompatInspector(bus, state)
174
+ const ui = new CompatUI(bus, state, [inspector])
175
+
176
+ ui.init()
177
+ engine.initEngine()
178
+ ```
179
+
180
+ ### Engine
181
+
182
+ The **Rust/WASM engine** can be used separately from the UI components in cases where you may want to automate
183
+ compatibility inspection without manually having to interact with a page.
184
+
185
+ ```javascript
186
+ import { SKEngine } from 'shinkom/engine'
187
+
188
+ const engine = new SKEngine()
189
+
190
+ const run = async () => {
191
+ await engine.initEngine()
192
+ }
193
+
194
+ await run()
195
+ ```
196
+
197
+ If needed, you can also **preload** the WASM file for **lazy initialization** of the engine,
198
+ this can be particularly useful when using the engine in **SSR applications** to eliminate
199
+ constant cold starts.
200
+
201
+ ```javascript
202
+ import { SKEngine } from 'shinkom/engine'
203
+
204
+ const engine = new SKEngine()
205
+
206
+ const preLoad = async () => {
207
+ await engine.loadWasm()
208
+ }
209
+
210
+ await preLoad()
211
+
212
+ // other operations //
213
+
214
+ await engine.initEngine()
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Compatibility Checks
220
+
221
+ ### Schema
222
+
223
+ In order to discover potential compatibility issues, Shinkom implements a score metric for the result of the compatibility check.
224
+
225
+ The general schema that an average compatibility check will follow goes like this:
226
+
227
+ ```javascript
228
+ {
229
+ "lookup_results": [
230
+ // results for each web feature
231
+ {
232
+ "name": "fake-element", // name of the web feature
233
+ "mdn_url": "https://developer.mozilla.org/docs/web/HTML/Reference/Elements/fake-element", // link that leads to MDN documentation of the web feature
234
+ "compat_score": "100.00", // score based on the sum of the browser_score and status_score over the max compat score
235
+ "browser_score": "100.00", // score based on the sum of weighted scores in each browser
236
+ "status_score": "100.00", // score based on the status object in compatibility data
237
+ "browsers": [
238
+ // results for each checked browser
239
+ {
240
+ "browser_name": "edge", // name of the browser
241
+ "score": {
242
+ "raw_score": "100.00", // score based on the safety of feature in browser
243
+ "weighted_score": "5.74", // score based on the usage of edge over the total market share between checked browsers
244
+ },
245
+ "versions": {
246
+ "version_added": "34" // feature added in edge engine version 34
247
+ }
248
+ }
249
+ ]
250
+ }
251
+ ],
252
+ // the overall score of the compatibility check
253
+ "overall_score": 100
254
+ }
255
+ ```
256
+
257
+ This object consists of the following:
258
+
259
+ - The `overall_score` property is a number that represents the final score of the compatibility check. It is a sum of each `compat_score` a
260
+ web feature has been given.
261
+ - The `lookup_results` property is an array of objects that contains each web feature's individual compatibility results.
262
+ - The `name` property is a string representing the name of the web feature.
263
+ - The `mdn_url` property is a string containing a link to the MDN Web Docs documentation for the web feature.
264
+ - The `compat_score` property is a string representing the calculated score for the web feature. It is calculated by summing the `browser_score` and `status_score`
265
+ and then dividing that sum by the total compatibility score a feature can get (currently 200).
266
+ - The `browser_score` property is a string representing the sum of the `weighted_score`'s between each browser for the web feature.
267
+ - The `status_score` property is a string representing the calculated score based on the current status of this web feature (standard_track, experimental, or deprecated).
268
+ - The `browsers` property is an array of objects that contains each browsers individual compatibility results.
269
+ - The `browser_name` property is a string representing the name of the checked browser.
270
+ - The `score` property is an object containing the `raw_score` and `weighted_score` for the web feature in a particular browser.
271
+ - `raw_score` is the calculated score before weighting is applied, which can be interpreted as the *safety* of a web feature.
272
+ - `weighted_score` is the raw score but with a weighting multiplier calculated as such: **total_browser_usage / market_share**.
273
+ - The `versions` property can be either an object or an array of objects depending on whether the web feature has been added, removed or partially implemented
274
+ in many different versions or just one version.
275
+
276
+ ### Scoring
277
+
278
+ The scoring for the compatibility check is an important feature to make sure that it gives fair and understandable results that won't leave you
279
+ guessing why a check resulted in a particular score.
280
+
281
+ The table below lists the score types and their respective formulas:
282
+
283
+ | Score Type | Formula |
284
+ |----------------|:-------------------------------------------------------------------------------------------:|
285
+ | overall_score | (compat_score~1~ + compat_score~2~ + ... compat_score~n~) / N |
286
+ | compat_score | ((browser_score + status_score) / MAX_COMPAT_SCORE) * 100 |
287
+ | browser_score | ((weighted_score~1~ + weighted_score~2~ + ... weighted_score~n~) / MAX_BROWSER_SCORE) * 100 |
288
+ | status_score | (status_score / MAX_STATUS_SCORE) * 100 |
289
+ | raw_score | Raw score calculation explained below |
290
+ | weighted_score | raw_score * (total_usage / market_share) |
291
+
292
+ Here are a few things to clarify about these formulas:
293
+
294
+ - In `overall_score`, *N* represents the number of lookup results returned.
295
+ - `MAX_COMPAT_SCORE` has a value of 200, whereas `MAX_BROWSER_SCORE` and `MAX_STATUS_SCORE` have a value of 100.
296
+ - The `raw_score` is calculated based on many different factors.
297
+ - If the current version of the browser is greater than the `version_added` value, the score is 100. This is
298
+ also the case if `version_added` is set to `true`.
299
+ - If the `version_removed` value is greater than the `version_added` value, the score is 0 since it is a removed feature.
300
+ - If the `partial_implementation` value is set to true, the score is 80.
301
+ - `total_usage` is the usage of a browser across all of its versions, and the `market_share` is the sum of `total_usage`
302
+ between every browser.
303
+ - The `browser_score` is the sum of the weighted scores from each browser divided by the `MAX_BROWSER_SCORE`.
304
+
305
+ ---
306
+
307
+ ## Node.js
308
+
309
+ Shinkom can be utilised in Node environments through its Engine module.
310
+ The UI components are strictly for browser environments, however the engine itself can be used independently in both environments.
311
+
312
+ ### ESM Bundles
313
+
314
+ ```javascript
315
+ import { SKEngine } from 'shinkom/engine'
316
+
317
+ const skEngine = new SKEngine()
318
+
319
+ await skEngine.initEngine()
320
+
321
+ skEngine.checkElement(`<div id="test-div" class="test-classes">Test Div</div>`)
322
+ ```
323
+
324
+ ### CommonJS Modules
325
+
326
+ ```javascript
327
+ const SKEngine = require('shinkom/engine').SKEngine
328
+
329
+ const skEngine = new SKEngine()
330
+
331
+ const run = async () => {
332
+ await skEngine.initEngine()
333
+
334
+ skEngine.checkElement(`<div id="test-div" class="test-classes">Test Div</div>`)
335
+ }
336
+
337
+ run()
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Contributing
343
+
344
+ In order to contribute to this project, there are a few prerequisites before doing so:
345
+
346
+ - Install the latest stable version of Rust on the [official Rust website](https://rust-lang.org/learn/get-started/)
347
+ - Install `wasm-pack` via this command:
348
+
349
+ ```bash
350
+ cargo install wasm-pack
351
+ ```
352
+
353
+ After that, make sure to run `npm i` to install project dependencies, create a branch **from the dev branch**, add your code,
354
+ and **create a pull request to the dev branch**.
355
+
356
+ After review and approval of the pull request, we can introduce your changes to the dev branch and eventually to the main branch.
357
+
358
+ ---
359
+
360
+ ## Development Scripts
361
+
362
+ When cloning or forking this library, refer to this table in regards to the NPM scripts:
363
+
364
+ | Scripts | Actions |
365
+ |-------------|:---------------------------------------------------------------------------------------------------:|
366
+ | dev:nobuild | Runs Vite dev server without running `build:wasm` |
367
+ | dev | Runs Vite dev server and builds a new WASM files through `build:wasm`. |
368
+ | build | Builds the WASM and JS through `build:wasm` and `build:js` and outputs files to `dist` folder. |
369
+ | build:js | Builds the ESM bundles and CJS modules for the Javascript library. |
370
+ | build:wasm | Builds the WASM files through `wasm-pack` and outputs files to a `pkg` directory. |
371
+ | test | Runs tests through Vitest. |
372
+ | type:check | Runs `tsc` to check types in the `src` directory. |
373
+ | gen:data | Generates JSON files for compatibility data and usage data and outputs them to the `gen` directory. |
374
+
375
+ ---
376
+
377
+ ## Credits
378
+
379
+ This project wouldn't be possible without amazing projects providing the data necessary to perform these compatibility checks.
380
+
381
+ The [browser-compat-data](https://github.com/mdn/browser-compat-data) project by [MDN](https://github.com/mdn) is the single reason why this project was made possible. Make sure to check out their project as it compiles a large majority of modern
382
+ web features across multiple different browser environments.
383
+
384
+ The [caniuse-db](https://github.com/Fyrd/caniuse) package also plays a big role in keeping up-to-date with the global usage data of browsers and their market share.
385
+
386
+ Make sure to check out both of these great projects!
387
+
388
+ ---
389
+
390
+ ## Package Features Checklist
391
+
392
+ - [x] Cross-browser compatibility based on MDN's browser-compat-data package
393
+ - [x] Configurable cross-browser compatibility DOM inspection
394
+ - [x] Full page cross-browser compatibility scan
395
+ - [x] HTML parsing and compatibility checks via Rust and WASM engine module
396
+ - [ ] Interactive side panel for viewing results of compatibility checks
397
+ - [ ] Hints for improving cross-browser compatibility based on checks
398
+ - [ ] Optional accessibility evaluation and hints based on WCAG guidelines
399
+ - [ ] CSS and Javascript file parsing and cross-browser compatibility checks
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shinkom - _rolldown
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ //#region \0rolldown/runtime.js
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
12
+ });
13
+ //#endregion
14
+ export { __require };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { UISharedState as UISharedState$1 } from "../types/public.js";
9
+
10
+ //#region src/core/constants.d.ts
11
+ /**@typedef {import('../types/public').UISharedState} UISharedState */
12
+ /**@type {UISharedState} */
13
+ declare const DEFAULT_STATE: UISharedState;
14
+ type UISharedState = UISharedState$1;
15
+ //#endregion
16
+ export { DEFAULT_STATE, UISharedState };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ //#region src/core/constants.js
9
+ /**@typedef {import('../types/public').UISharedState} UISharedState */
10
+ /**@type {UISharedState} */
11
+ const DEFAULT_STATE = {
12
+ inspectorExists: false,
13
+ inspectorActive: false,
14
+ inspectorSwitching: false,
15
+ ignorePanelEl: null,
16
+ multiElements: false,
17
+ depthLevel: 0
18
+ };
19
+ //#endregion
20
+ export { DEFAULT_STATE };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { ShinkomEventListener as ShinkomEventListener$1, ShinkomEventMap as ShinkomEventMap$1, ShinkomEventTarget as ShinkomEventTarget$1 } from "../types/public.js";
9
+
10
+ //#region src/core/event-bus.d.ts
11
+ /**@typedef {import("../types/public").ShinkomEventTarget} ShinkomEventTarget */
12
+ /**@typedef {import("../types/public").ShinkomEventMap} ShinkomEventMap */
13
+ /**@typedef {import("../types/public").ShinkomEventListener<keyof ShinkomEventMap>} ShinkomEventListener */
14
+ declare class ShinkomBus {
15
+ /**
16
+ * Emits an event to the event bus.
17
+ * @param {string} event
18
+ * @param {object | undefined} detail
19
+ */
20
+ emit(event: string, detail?: object | undefined): void;
21
+ /**
22
+ * Registers a listener on the event bus.
23
+ * @param {keyof ShinkomEventMap} eventName
24
+ * @param {Function} cb
25
+ */
26
+ on(eventName: keyof ShinkomEventMap, cb: Function): () => void;
27
+ #private;
28
+ }
29
+ type ShinkomEventTarget = ShinkomEventTarget$1;
30
+ type ShinkomEventMap = ShinkomEventMap$1;
31
+ type ShinkomEventListener = ShinkomEventListener$1<keyof ShinkomEventMap>;
32
+ //#endregion
33
+ export { ShinkomBus, ShinkomEventListener, ShinkomEventMap, ShinkomEventTarget };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ //#region src/core/event-bus.js
9
+ /**@typedef {import("../types/public").ShinkomEventTarget} ShinkomEventTarget */
10
+ /**@typedef {import("../types/public").ShinkomEventMap} ShinkomEventMap */
11
+ /**@typedef {import("../types/public").ShinkomEventListener<keyof ShinkomEventMap>} ShinkomEventListener */
12
+ var ShinkomBus = class {
13
+ /**@type {ShinkomEventTarget} */
14
+ #customEventTarget = new EventTarget();
15
+ /**
16
+ * Emits an event to the event bus.
17
+ * @param {string} event
18
+ * @param {object | undefined} detail
19
+ */
20
+ emit(event, detail = void 0) {
21
+ this.#customEventTarget.dispatchEvent(new CustomEvent(event, detail));
22
+ }
23
+ /**
24
+ * Registers a listener on the event bus.
25
+ * @param {keyof ShinkomEventMap} eventName
26
+ * @param {Function} cb
27
+ */
28
+ on(eventName, cb) {
29
+ /**@type {ShinkomEventListener} */
30
+ const wrapper = (e) => cb(e.detail);
31
+ this.#customEventTarget.addEventListener(eventName, wrapper);
32
+ return () => this.#customEventTarget.removeEventListener(eventName, wrapper);
33
+ }
34
+ };
35
+ //#endregion
36
+ export { ShinkomBus };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shinkom - core\helpers
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { __require } from "../_virtual/_rolldown/runtime.js";
9
+ //#region src/core/helpers.js
10
+ /**
11
+ * Get the resolved module path as a string or URL.
12
+ * @param {string} modulePath
13
+ * @returns {Promise<string | URL>} module path
14
+ */
15
+ const getModulePath = async (modulePath) => {
16
+ const path = await import("node:url");
17
+ const module = await import("node:module");
18
+ try {
19
+ return module.createRequire(import.meta.url).resolve(modulePath);
20
+ } catch (_error) {
21
+ return path.pathToFileURL(__require.resolve(modulePath));
22
+ }
23
+ };
24
+ //#endregion
25
+ export { getModulePath };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { ShinkomBus } from "./event-bus.js";
9
+ import { DEFAULT_STATE } from "./constants.js";
10
+ import { ShinkomState } from "./state-service.js";
11
+ import { UIComponent } from "./ui-component.js";
12
+ export { DEFAULT_STATE, ShinkomBus, ShinkomState, UIComponent };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { ShinkomBus } from "./event-bus.js";
9
+ import { DEFAULT_STATE } from "./constants.js";
10
+ import { ShinkomState } from "./state-service.js";
11
+ import { UIComponent } from "./ui-component.js";
12
+ export { DEFAULT_STATE, ShinkomBus, ShinkomState, UIComponent };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { UISharedState as UISharedState$1, UISharedStateProps as UISharedStateProps$1 } from "../types/public.js";
9
+
10
+ //#region src/core/state-service.d.ts
11
+ declare class ShinkomState {
12
+ /**
13
+ * @param {UISharedState} initalState
14
+ */
15
+ constructor(initalState?: UISharedState);
16
+ /**
17
+ * @callback Listener
18
+ * @param {UISharedStateProps} prop
19
+ * @param {any} val
20
+ */
21
+ /**
22
+ * Used to subscribe listener to the state service to listen for changes
23
+ * to the state.
24
+ * @param {Listener} callback
25
+ */
26
+ subscribe(callback: (prop: UISharedStateProps, val: any) => any): () => void;
27
+ /**
28
+ * Gets the state.
29
+ * @returns {UISharedState}
30
+ */
31
+ getState: () => UISharedState;
32
+ #private;
33
+ }
34
+ type UISharedState = UISharedState$1;
35
+ type UISharedStateProps = UISharedStateProps$1;
36
+ //#endregion
37
+ export { ShinkomState, UISharedState, UISharedStateProps };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Shinkom - core
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2026 - OneilNvM
6
+ */
7
+
8
+ import { DEFAULT_STATE } from "./constants.js";
9
+ //#region src/core/state-service.js
10
+ /**@typedef {import('../types/public').UISharedState} UISharedState */
11
+ /**@typedef {import('../types/public').UISharedStateProps} UISharedStateProps */
12
+ var ShinkomState = class {
13
+ /**@type {UISharedState}*/
14
+ #state;
15
+ /**@type {function[]} */
16
+ #listeners = [];
17
+ /**
18
+ * @param {UISharedState} initalState
19
+ */
20
+ constructor(initalState = DEFAULT_STATE) {
21
+ const notify = (prop, val) => {
22
+ this.#listeners.forEach((fn) => fn(prop, val));
23
+ };
24
+ this.#state = new Proxy(initalState, {
25
+ get(obj, prop) {
26
+ return obj[prop];
27
+ },
28
+ set(obj, prop, val) {
29
+ if (obj[prop] === val) return true;
30
+ notify(prop, val);
31
+ /**@type {any} */ obj[prop] = val;
32
+ console.log(`Setting ${prop} -> ${val}`);
33
+ return true;
34
+ }
35
+ });
36
+ }
37
+ /**
38
+ * @callback Listener
39
+ * @param {UISharedStateProps} prop
40
+ * @param {any} val
41
+ */
42
+ /**
43
+ * Used to subscribe listener to the state service to listen for changes
44
+ * to the state.
45
+ * @param {Listener} callback
46
+ */
47
+ subscribe(callback) {
48
+ this.#listeners.push(callback);
49
+ return () => {
50
+ this.#listeners = this.#listeners.filter((fn) => fn !== callback);
51
+ };
52
+ }
53
+ /**
54
+ * Gets the state.
55
+ * @returns {UISharedState}
56
+ */
57
+ getState = () => this.#state;
58
+ };
59
+ //#endregion
60
+ export { ShinkomState };