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,33 +1,33 @@
|
|
|
1
|
-
//#region src/core/elements/templates/root-styles.template.js
|
|
2
|
-
const hostStyles = `
|
|
3
|
-
:host {
|
|
4
|
-
--sk-primary: #050021;
|
|
5
|
-
--sk-secondary: #1E0074;
|
|
6
|
-
--sk-accent: #C9D1FF;
|
|
7
|
-
--sk-hover-color: #03001a;
|
|
8
|
-
--sk-background-variant-1: #191B1C;
|
|
9
|
-
--sk-background-variant-2: #1E1E1E;
|
|
10
|
-
--sk-background-variant-3: #0c0c0c;
|
|
11
|
-
|
|
12
|
-
--sk-text-grey: #5f5f5f;
|
|
13
|
-
--sk-results-blue-foreground: #3172ff;
|
|
14
|
-
--sk-results-yellow-foreground: #ffe600;
|
|
15
|
-
--sk-results-green-foreground: #40ff2f;
|
|
16
|
-
--sk-results-red-foreground: #ff2b2b;
|
|
17
|
-
--sk-indicator-green: #36ff46;
|
|
18
|
-
--sk-indicator-yellow: #fafe09;
|
|
19
|
-
--sk-indicator-red: #de291f;
|
|
20
|
-
--sk-indicator-blue: #1b72e4;
|
|
21
|
-
|
|
22
|
-
--sk-text-xs: 0.75rem;
|
|
23
|
-
--sk-text-sm: 0.875rem;
|
|
24
|
-
--sk-text-base: 1rem;
|
|
25
|
-
--sk-text-md: 1.075rem;
|
|
26
|
-
--sk-text-lg: 1.125rem;
|
|
27
|
-
--sk-text-xl: 1.25rem;
|
|
28
|
-
--sk-text-2xl: 1.5rem;
|
|
29
|
-
--sk-text-3xl: 2rem;
|
|
30
|
-
--sk-text-4xl: 3rem;
|
|
31
|
-
}`;
|
|
32
|
-
//#endregion
|
|
33
|
-
exports.hostStyles = hostStyles;
|
|
1
|
+
//#region src/core/elements/templates/root-styles.template.js
|
|
2
|
+
const hostStyles = `
|
|
3
|
+
:host {
|
|
4
|
+
--sk-primary: #050021;
|
|
5
|
+
--sk-secondary: #1E0074;
|
|
6
|
+
--sk-accent: #C9D1FF;
|
|
7
|
+
--sk-hover-color: #03001a;
|
|
8
|
+
--sk-background-variant-1: #191B1C;
|
|
9
|
+
--sk-background-variant-2: #1E1E1E;
|
|
10
|
+
--sk-background-variant-3: #0c0c0c;
|
|
11
|
+
|
|
12
|
+
--sk-text-grey: #5f5f5f;
|
|
13
|
+
--sk-results-blue-foreground: #3172ff;
|
|
14
|
+
--sk-results-yellow-foreground: #ffe600;
|
|
15
|
+
--sk-results-green-foreground: #40ff2f;
|
|
16
|
+
--sk-results-red-foreground: #ff2b2b;
|
|
17
|
+
--sk-indicator-green: #36ff46;
|
|
18
|
+
--sk-indicator-yellow: #fafe09;
|
|
19
|
+
--sk-indicator-red: #de291f;
|
|
20
|
+
--sk-indicator-blue: #1b72e4;
|
|
21
|
+
|
|
22
|
+
--sk-text-xs: 0.75rem;
|
|
23
|
+
--sk-text-sm: 0.875rem;
|
|
24
|
+
--sk-text-base: 1rem;
|
|
25
|
+
--sk-text-md: 1.075rem;
|
|
26
|
+
--sk-text-lg: 1.125rem;
|
|
27
|
+
--sk-text-xl: 1.25rem;
|
|
28
|
+
--sk-text-2xl: 1.5rem;
|
|
29
|
+
--sk-text-3xl: 2rem;
|
|
30
|
+
--sk-text-4xl: 3rem;
|
|
31
|
+
}`;
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.hostStyles = hostStyles;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/core/event-bus.js
|
|
3
|
-
/**@typedef {import("../types/types").ShinkomEventTarget} ShinkomEventTarget */
|
|
4
|
-
/**@typedef {import("../types/types").ShinkomEventMap} ShinkomEventMap */
|
|
5
|
-
/**@typedef {import("../types/types").ShinkomEventListener<keyof ShinkomEventMap>} ShinkomEventListener */
|
|
6
|
-
/**
|
|
7
|
-
* ShinkomBus is the application event bus used to coordinate cross-cutting
|
|
8
|
-
* actions across Shinkom UI components and the engine.
|
|
9
|
-
*
|
|
10
|
-
* It wraps a standard `EventTarget` and exposes a small typed API for
|
|
11
|
-
* emitting custom events and subscribing to them with cleanup support.
|
|
12
|
-
*/
|
|
13
|
-
var ShinkomBus = class {
|
|
14
|
-
#customEventTarget = new EventTarget();
|
|
15
|
-
/**
|
|
16
|
-
* Emits an event to the event bus.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} event
|
|
19
|
-
* @param {object | undefined} detail
|
|
20
|
-
*/
|
|
21
|
-
emit(event, detail = void 0) {
|
|
22
|
-
this.#customEventTarget.dispatchEvent(new CustomEvent(event, detail));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Registers a listener on the event bus.
|
|
26
|
-
*
|
|
27
|
-
* The returned cleanup function removes the listener so callers can stop
|
|
28
|
-
* receiving events and avoid leaking handlers when the listener is no
|
|
29
|
-
* longer needed.
|
|
30
|
-
*
|
|
31
|
-
* @param {keyof ShinkomEventMap} eventName
|
|
32
|
-
* @param {Function} cb
|
|
33
|
-
* @returns {() => void} cleanup function
|
|
34
|
-
*/
|
|
35
|
-
on(eventName, cb) {
|
|
36
|
-
/**@type {ShinkomEventListener} */
|
|
37
|
-
const wrapper = (e) => cb(e.detail);
|
|
38
|
-
this.#customEventTarget.addEventListener(eventName, wrapper);
|
|
39
|
-
return () => this.#customEventTarget.removeEventListener(eventName, wrapper);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
exports.ShinkomBus = ShinkomBus;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/core/event-bus.js
|
|
3
|
+
/**@typedef {import("../types/types").ShinkomEventTarget} ShinkomEventTarget */
|
|
4
|
+
/**@typedef {import("../types/types").ShinkomEventMap} ShinkomEventMap */
|
|
5
|
+
/**@typedef {import("../types/types").ShinkomEventListener<keyof ShinkomEventMap>} ShinkomEventListener */
|
|
6
|
+
/**
|
|
7
|
+
* ShinkomBus is the application event bus used to coordinate cross-cutting
|
|
8
|
+
* actions across Shinkom UI components and the engine.
|
|
9
|
+
*
|
|
10
|
+
* It wraps a standard `EventTarget` and exposes a small typed API for
|
|
11
|
+
* emitting custom events and subscribing to them with cleanup support.
|
|
12
|
+
*/
|
|
13
|
+
var ShinkomBus = class {
|
|
14
|
+
#customEventTarget = new EventTarget();
|
|
15
|
+
/**
|
|
16
|
+
* Emits an event to the event bus.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} event
|
|
19
|
+
* @param {object | undefined} detail
|
|
20
|
+
*/
|
|
21
|
+
emit(event, detail = void 0) {
|
|
22
|
+
this.#customEventTarget.dispatchEvent(new CustomEvent(event, detail));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Registers a listener on the event bus.
|
|
26
|
+
*
|
|
27
|
+
* The returned cleanup function removes the listener so callers can stop
|
|
28
|
+
* receiving events and avoid leaking handlers when the listener is no
|
|
29
|
+
* longer needed.
|
|
30
|
+
*
|
|
31
|
+
* @param {keyof ShinkomEventMap} eventName
|
|
32
|
+
* @param {Function} cb
|
|
33
|
+
* @returns {() => void} cleanup function
|
|
34
|
+
*/
|
|
35
|
+
on(eventName, cb) {
|
|
36
|
+
/**@type {ShinkomEventListener} */
|
|
37
|
+
const wrapper = (e) => cb(e.detail);
|
|
38
|
+
this.#customEventTarget.addEventListener(eventName, wrapper);
|
|
39
|
+
return () => this.#customEventTarget.removeEventListener(eventName, wrapper);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.ShinkomBus = ShinkomBus;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
//#region src/core/helpers.js
|
|
2
|
-
/**
|
|
3
|
-
* Get the resolved module path as a string or URL.
|
|
4
|
-
* @param {string} modulePath
|
|
5
|
-
* @returns {Promise<string | URL>} module path
|
|
6
|
-
*/
|
|
7
|
-
const getModulePath = async (modulePath) => {
|
|
8
|
-
const path = await import("node:url");
|
|
9
|
-
const module = await import("node:module");
|
|
10
|
-
try {
|
|
11
|
-
return module.createRequire({}.url).resolve(modulePath);
|
|
12
|
-
} catch (_error) {
|
|
13
|
-
return path.pathToFileURL(require.resolve(modulePath));
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Splits a version string into parts.
|
|
18
|
-
* @param {string} version
|
|
19
|
-
* @returns {number[]} version number in parts
|
|
20
|
-
*/
|
|
21
|
-
function versionToParts(version) {
|
|
22
|
-
return version.replace(/^v/, "").split(".").map(Number);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates a CSSStyleSheet and applies styles to it.
|
|
26
|
-
* @param {CSSStyleSheet | null} cache
|
|
27
|
-
* @param {string} styles
|
|
28
|
-
* @returns {CSSStyleSheet | null} A CSS stylesheet
|
|
29
|
-
*/
|
|
30
|
-
function getStyleSheet(cache, styles) {
|
|
31
|
-
if (typeof window === "undefined") return null;
|
|
32
|
-
if (!cache) {
|
|
33
|
-
cache = new CSSStyleSheet();
|
|
34
|
-
cache.replaceSync(styles);
|
|
35
|
-
}
|
|
36
|
-
return cache;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
exports.getModulePath = getModulePath;
|
|
40
|
-
exports.getStyleSheet = getStyleSheet;
|
|
41
|
-
exports.versionToParts = versionToParts;
|
|
1
|
+
//#region src/core/helpers.js
|
|
2
|
+
/**
|
|
3
|
+
* Get the resolved module path as a string or URL.
|
|
4
|
+
* @param {string} modulePath
|
|
5
|
+
* @returns {Promise<string | URL>} module path
|
|
6
|
+
*/
|
|
7
|
+
const getModulePath = async (modulePath) => {
|
|
8
|
+
const path = await import("node:url");
|
|
9
|
+
const module = await import("node:module");
|
|
10
|
+
try {
|
|
11
|
+
return module.createRequire({}.url).resolve(modulePath);
|
|
12
|
+
} catch (_error) {
|
|
13
|
+
return path.pathToFileURL(require.resolve(modulePath));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Splits a version string into parts.
|
|
18
|
+
* @param {string} version
|
|
19
|
+
* @returns {number[]} version number in parts
|
|
20
|
+
*/
|
|
21
|
+
function versionToParts(version) {
|
|
22
|
+
return version.replace(/^v/, "").split(".").map(Number);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a CSSStyleSheet and applies styles to it.
|
|
26
|
+
* @param {CSSStyleSheet | null} cache
|
|
27
|
+
* @param {string} styles
|
|
28
|
+
* @returns {CSSStyleSheet | null} A CSS stylesheet
|
|
29
|
+
*/
|
|
30
|
+
function getStyleSheet(cache, styles) {
|
|
31
|
+
if (typeof window === "undefined") return null;
|
|
32
|
+
if (!cache) {
|
|
33
|
+
cache = new CSSStyleSheet();
|
|
34
|
+
cache.replaceSync(styles);
|
|
35
|
+
}
|
|
36
|
+
return cache;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.getModulePath = getModulePath;
|
|
40
|
+
exports.getStyleSheet = getStyleSheet;
|
|
41
|
+
exports.versionToParts = versionToParts;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_core_event_bus = require("./event-bus.cjs");
|
|
3
|
-
const require_core_constants = require("./constants.cjs");
|
|
4
|
-
const require_core_state_service = require("./state-service.cjs");
|
|
5
|
-
const require_core_ui_component = require("./ui-component.cjs");
|
|
6
|
-
const require_core_elements_compat_view_element = require("./elements/compat-view-element.cjs");
|
|
7
|
-
const require_core_elements_control_panel_element = require("./elements/control-panel-element.cjs");
|
|
8
|
-
const require_core_elements_inspector_element = require("./elements/inspector-element.cjs");
|
|
9
|
-
require("./elements/index.cjs");
|
|
10
|
-
exports.CompatControlPanelElement = require_core_elements_control_panel_element.CompatControlPanelElement;
|
|
11
|
-
exports.CompatInspectorElement = require_core_elements_inspector_element.CompatInspectorElement;
|
|
12
|
-
exports.CompatViewElement = require_core_elements_compat_view_element.CompatViewElement;
|
|
13
|
-
exports.DEFAULT_STATE = require_core_constants.DEFAULT_STATE;
|
|
14
|
-
exports.ShinkomBus = require_core_event_bus.ShinkomBus;
|
|
15
|
-
exports.ShinkomState = require_core_state_service.ShinkomState;
|
|
16
|
-
exports.UIComponent = require_core_ui_component.UIComponent;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_event_bus = require("./event-bus.cjs");
|
|
3
|
+
const require_core_constants = require("./constants.cjs");
|
|
4
|
+
const require_core_state_service = require("./state-service.cjs");
|
|
5
|
+
const require_core_ui_component = require("./ui-component.cjs");
|
|
6
|
+
const require_core_elements_compat_view_element = require("./elements/compat-view-element.cjs");
|
|
7
|
+
const require_core_elements_control_panel_element = require("./elements/control-panel-element.cjs");
|
|
8
|
+
const require_core_elements_inspector_element = require("./elements/inspector-element.cjs");
|
|
9
|
+
require("./elements/index.cjs");
|
|
10
|
+
exports.CompatControlPanelElement = require_core_elements_control_panel_element.CompatControlPanelElement;
|
|
11
|
+
exports.CompatInspectorElement = require_core_elements_inspector_element.CompatInspectorElement;
|
|
12
|
+
exports.CompatViewElement = require_core_elements_compat_view_element.CompatViewElement;
|
|
13
|
+
exports.DEFAULT_STATE = require_core_constants.DEFAULT_STATE;
|
|
14
|
+
exports.ShinkomBus = require_core_event_bus.ShinkomBus;
|
|
15
|
+
exports.ShinkomState = require_core_state_service.ShinkomState;
|
|
16
|
+
exports.UIComponent = require_core_ui_component.UIComponent;
|
|
@@ -1,74 +1,85 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_core_constants = require("./constants.cjs");
|
|
3
|
-
//#region src/core/state-service.js
|
|
4
|
-
/**@typedef {import('../types/public').UISharedState} UISharedState */
|
|
5
|
-
/**@typedef {import('../types/public').UISharedStateProps} UISharedStateProps */
|
|
6
|
-
/**
|
|
7
|
-
* ShinkomState provides shared UI state management for the application.
|
|
8
|
-
*
|
|
9
|
-
* It wraps a proxied state object and notifies subscribed listeners whenever
|
|
10
|
-
* a state property changes. Components can subscribe to update events and
|
|
11
|
-
* access the reactive state through `getState()`.
|
|
12
|
-
*/
|
|
13
|
-
var ShinkomState = class {
|
|
14
|
-
/**@type {UISharedState}*/
|
|
15
|
-
#state;
|
|
16
|
-
/**@type {function[]} */
|
|
17
|
-
#listeners = [];
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the shared state service.
|
|
20
|
-
*
|
|
21
|
-
* The returned state object is proxied so that property assignments
|
|
22
|
-
* automatically notify listeners when values change.
|
|
23
|
-
*
|
|
24
|
-
* @param {UISharedState} initalState
|
|
25
|
-
*/
|
|
26
|
-
constructor(initalState = require_core_constants.DEFAULT_STATE) {
|
|
27
|
-
const notify = (prop, val) => {
|
|
28
|
-
this.#listeners.forEach((fn) => fn(prop, val));
|
|
29
|
-
};
|
|
30
|
-
this.#state = new Proxy(initalState, {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* @
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_constants = require("./constants.cjs");
|
|
3
|
+
//#region src/core/state-service.js
|
|
4
|
+
/**@typedef {import('../types/public').UISharedState} UISharedState */
|
|
5
|
+
/**@typedef {import('../types/public').UISharedStateProps} UISharedStateProps */
|
|
6
|
+
/**
|
|
7
|
+
* ShinkomState provides shared UI state management for the application.
|
|
8
|
+
*
|
|
9
|
+
* It wraps a proxied state object and notifies subscribed listeners whenever
|
|
10
|
+
* a state property changes. Components can subscribe to update events and
|
|
11
|
+
* access the reactive state through `getState()`.
|
|
12
|
+
*/
|
|
13
|
+
var ShinkomState = class {
|
|
14
|
+
/**@type {UISharedState}*/
|
|
15
|
+
#state;
|
|
16
|
+
/**@type {function[]} */
|
|
17
|
+
#listeners = [];
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the shared state service.
|
|
20
|
+
*
|
|
21
|
+
* The returned state object is proxied so that property assignments
|
|
22
|
+
* automatically notify listeners when values change.
|
|
23
|
+
*
|
|
24
|
+
* @param {UISharedState} initalState
|
|
25
|
+
*/
|
|
26
|
+
constructor(initalState = require_core_constants.DEFAULT_STATE) {
|
|
27
|
+
const notify = (prop, val) => {
|
|
28
|
+
this.#listeners.forEach((fn) => fn(prop, val));
|
|
29
|
+
};
|
|
30
|
+
this.#state = new Proxy(initalState, {
|
|
31
|
+
/**
|
|
32
|
+
* @param {UISharedState} obj
|
|
33
|
+
* @param {UISharedStateProps} prop
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
get(obj, prop) {
|
|
37
|
+
return obj[prop];
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* @param {UISharedState} obj
|
|
41
|
+
* @param {UISharedStateProps} prop
|
|
42
|
+
* @param {any} val
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
set(obj, prop, val) {
|
|
46
|
+
if (obj[prop] === val) return true;
|
|
47
|
+
notify(prop, val);
|
|
48
|
+
/**@type {any} */ obj[prop] = val;
|
|
49
|
+
console.log(`Setting ${prop} -> ${val}`);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @callback Listener
|
|
56
|
+
* @param {UISharedStateProps} prop
|
|
57
|
+
* @param {any} val
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Subscribes a listener to state change notifications.
|
|
61
|
+
*
|
|
62
|
+
* When any property on the shared state changes, the callback receives the
|
|
63
|
+
* changed property and its new value.
|
|
64
|
+
*
|
|
65
|
+
* @param {Listener} callback
|
|
66
|
+
* @returns {() => void} cleanup function
|
|
67
|
+
*/
|
|
68
|
+
subscribe(callback) {
|
|
69
|
+
this.#listeners.push(callback);
|
|
70
|
+
return () => {
|
|
71
|
+
this.#listeners = this.#listeners.filter((fn) => fn !== callback);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the proxied shared state object.
|
|
76
|
+
*
|
|
77
|
+
* Callers can read and write state properties directly, and writes will
|
|
78
|
+
* trigger listener notifications when values change.
|
|
79
|
+
*
|
|
80
|
+
* @returns {UISharedState}
|
|
81
|
+
*/
|
|
82
|
+
getState = () => this.#state;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.ShinkomState = ShinkomState;
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/core/ui-component.js
|
|
3
|
-
/**
|
|
4
|
-
* Base UI component class for Shinkom UI modules.
|
|
5
|
-
*
|
|
6
|
-
* UIComponent is abstract and provides shared integration with the Shinkom
|
|
7
|
-
* event bus and shared state service. Subclasses must implement lifecycle
|
|
8
|
-
* methods for mounting, unmounting, binding state, and responding to state
|
|
9
|
-
* changes.
|
|
10
|
-
*/
|
|
11
|
-
var UIComponent = class UIComponent {
|
|
12
|
-
/**
|
|
13
|
-
* @param {ShinkomBus} bus
|
|
14
|
-
* @param {ShinkomState} stateService
|
|
15
|
-
*/
|
|
16
|
-
constructor(bus, stateService) {
|
|
17
|
-
if (this.constructor === UIComponent) throw new Error("UIComponent is an abstract class and cannot be instantiated.");
|
|
18
|
-
this.bus = bus;
|
|
19
|
-
this.stateService = stateService;
|
|
20
|
-
stateService.subscribe((prop, val) => {
|
|
21
|
-
this.onStateChange(prop, val);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Mounts the component into the DOM.
|
|
26
|
-
*
|
|
27
|
-
* Subclasses must implement this method to create and attach their UI.
|
|
28
|
-
*/
|
|
29
|
-
mount() {
|
|
30
|
-
throw new Error("mount() method must be implemented.");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Unmounts the component from the DOM.
|
|
34
|
-
*
|
|
35
|
-
* Subclasses must implement this method to remove their UI and cleanup.
|
|
36
|
-
*/
|
|
37
|
-
unmount() {
|
|
38
|
-
throw new Error("unmount() method must be implemented.");
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Binds shared UI state to the component instance.
|
|
42
|
-
*
|
|
43
|
-
* Implementations should store the bound state reference and apply any
|
|
44
|
-
* initial state values needed by the component.
|
|
45
|
-
*
|
|
46
|
-
* @param {UISharedState} _state
|
|
47
|
-
*/
|
|
48
|
-
bindState(_state) {
|
|
49
|
-
throw new Error("bindState() method must be implemented.");
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Called when a shared state property changes.
|
|
53
|
-
*
|
|
54
|
-
* Components should override this to react to updates from the shared state
|
|
55
|
-
* service.
|
|
56
|
-
*
|
|
57
|
-
* @param {UISharedStateProps} _prop
|
|
58
|
-
* @param {any} _val
|
|
59
|
-
*/
|
|
60
|
-
onStateChange(_prop, _val) {
|
|
61
|
-
throw new Error("onStateChange() method must be implemented.");
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
//#endregion
|
|
65
|
-
exports.UIComponent = UIComponent;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/core/ui-component.js
|
|
3
|
+
/**
|
|
4
|
+
* Base UI component class for Shinkom UI modules.
|
|
5
|
+
*
|
|
6
|
+
* UIComponent is abstract and provides shared integration with the Shinkom
|
|
7
|
+
* event bus and shared state service. Subclasses must implement lifecycle
|
|
8
|
+
* methods for mounting, unmounting, binding state, and responding to state
|
|
9
|
+
* changes.
|
|
10
|
+
*/
|
|
11
|
+
var UIComponent = class UIComponent {
|
|
12
|
+
/**
|
|
13
|
+
* @param {ShinkomBus} bus
|
|
14
|
+
* @param {ShinkomState} stateService
|
|
15
|
+
*/
|
|
16
|
+
constructor(bus, stateService) {
|
|
17
|
+
if (this.constructor === UIComponent) throw new Error("UIComponent is an abstract class and cannot be instantiated.");
|
|
18
|
+
this.bus = bus;
|
|
19
|
+
this.stateService = stateService;
|
|
20
|
+
stateService.subscribe((prop, val) => {
|
|
21
|
+
this.onStateChange(prop, val);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Mounts the component into the DOM.
|
|
26
|
+
*
|
|
27
|
+
* Subclasses must implement this method to create and attach their UI.
|
|
28
|
+
*/
|
|
29
|
+
mount() {
|
|
30
|
+
throw new Error("mount() method must be implemented.");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Unmounts the component from the DOM.
|
|
34
|
+
*
|
|
35
|
+
* Subclasses must implement this method to remove their UI and cleanup.
|
|
36
|
+
*/
|
|
37
|
+
unmount() {
|
|
38
|
+
throw new Error("unmount() method must be implemented.");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Binds shared UI state to the component instance.
|
|
42
|
+
*
|
|
43
|
+
* Implementations should store the bound state reference and apply any
|
|
44
|
+
* initial state values needed by the component.
|
|
45
|
+
*
|
|
46
|
+
* @param {UISharedState} _state
|
|
47
|
+
*/
|
|
48
|
+
bindState(_state) {
|
|
49
|
+
throw new Error("bindState() method must be implemented.");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Called when a shared state property changes.
|
|
53
|
+
*
|
|
54
|
+
* Components should override this to react to updates from the shared state
|
|
55
|
+
* service.
|
|
56
|
+
*
|
|
57
|
+
* @param {UISharedStateProps} _prop
|
|
58
|
+
* @param {any} _val
|
|
59
|
+
*/
|
|
60
|
+
onStateChange(_prop, _val) {
|
|
61
|
+
throw new Error("onStateChange() method must be implemented.");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.UIComponent = UIComponent;
|