@widgetic/ui-sdk 0.1.5 → 0.1.7
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 +63 -10
- package/dist/{index.js → index.cjs} +13 -23
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +52 -0
- package/dist/index.esm.js +12 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk/core/component.d.cts +46 -0
- package/dist/sdk/core/component.d.ts +1 -1
- package/dist/sdk/core/component.d.ts.map +1 -1
- package/dist/sdk/core/events.d.cts +25 -0
- package/dist/sdk/core/events.d.ts +1 -1
- package/dist/sdk/core/events.d.ts.map +1 -1
- package/dist/sdk/core/index.d.cts +32 -0
- package/dist/sdk/core/index.d.ts +6 -6
- package/dist/sdk/core/index.d.ts.map +1 -1
- package/dist/sdk/core/lifecycle.d.cts +96 -0
- package/dist/sdk/core/lifecycle.d.ts +3 -3
- package/dist/sdk/core/lifecycle.d.ts.map +1 -1
- package/dist/sdk/core/local-events.d.cts +24 -0
- package/dist/sdk/core/local-events.d.ts +1 -1
- package/dist/sdk/core/local-events.d.ts.map +1 -1
- package/dist/sdk/core/messaging.d.cts +57 -0
- package/dist/sdk/core/messaging.d.ts +2 -2
- package/dist/sdk/core/messaging.d.ts.map +1 -1
- package/dist/sdk/core/state.d.cts +64 -0
- package/dist/sdk/core/state.d.ts +10 -3
- package/dist/sdk/core/state.d.ts.map +1 -1
- package/dist/sdk/core/theme-mode.d.cts +43 -0
- package/dist/sdk/core/theme-mode.d.ts +1 -1
- package/dist/sdk/core/theme-mode.d.ts.map +1 -1
- package/dist/sdk/core/theme.d.cts +57 -0
- package/dist/sdk/core/theme.d.ts +2 -2
- package/dist/sdk/core/theme.d.ts.map +1 -1
- package/dist/sdk/index.d.cts +3 -0
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/integration/host.d.cts +53 -0
- package/dist/sdk/integration/host.d.ts +2 -2
- package/dist/sdk/integration/host.d.ts.map +1 -1
- package/dist/sdk/integration/index.d.cts +18 -0
- package/dist/sdk/integration/index.d.ts +1 -1
- package/dist/sdk/integration/index.d.ts.map +1 -1
- package/dist/sdk/layers/index.d.cts +35 -0
- package/dist/sdk/loader/ui.d.cts +207 -0
- package/dist/sdk/loader/ui.d.ts +49 -6
- package/dist/sdk/loader/ui.d.ts.map +1 -1
- package/dist/sdk/modules/index.d.cts +8 -0
- package/dist/sdk/modules/index.d.ts +1 -1
- package/dist/sdk/modules/index.d.ts.map +1 -1
- package/dist/sdk/modules/loader.d.cts +83 -0
- package/dist/sdk/modules/loader.d.ts +1 -1
- package/dist/sdk/modules/loader.d.ts.map +1 -1
- package/dist/sdk/types/component.d.cts +214 -0
- package/dist/sdk/types/component.d.ts +27 -12
- package/dist/sdk/types/component.d.ts.map +1 -1
- package/dist/sdk/types/events.d.cts +111 -0
- package/dist/sdk/types/events.d.ts.map +1 -1
- package/dist/sdk/types/index.d.cts +43 -0
- package/dist/sdk/types/index.d.ts +8 -7
- package/dist/sdk/types/index.d.ts.map +1 -1
- package/dist/sdk/types/messaging.d.cts +40 -0
- package/dist/sdk/types/module-events.d.cts +212 -0
- package/dist/sdk/types/module-events.d.ts +213 -0
- package/dist/sdk/types/module-events.d.ts.map +1 -0
- package/dist/sdk/types/module-language.d.cts +46 -0
- package/dist/sdk/types/module-media-library.d.cts +143 -0
- package/dist/sdk/types/module-theme.d.cts +96 -0
- package/dist/sdk/types/module-theme.d.ts +1 -1
- package/dist/sdk/types/module-theme.d.ts.map +1 -1
- package/dist/sdk/types/state.d.cts +37 -0
- package/dist/sdk/types/state.d.ts.map +1 -1
- package/dist/sdk/types/theme.d.cts +75 -0
- package/dist/sdk/utils/config.d.cts +69 -0
- package/dist/sdk/utils/config.d.ts.map +1 -1
- package/dist/sdk/utils/errors.d.cts +55 -0
- package/dist/sdk/utils/errors.d.ts +1 -1
- package/dist/sdk/utils/errors.d.ts.map +1 -1
- package/dist/sdk/utils/http.d.cts +20 -0
- package/dist/sdk/utils/security.d.cts +94 -0
- package/dist/sdk/utils/validation.d.cts +63 -0
- package/dist/sdk/utils/validation.d.ts +1 -1
- package/dist/sdk/utils/validation.d.ts.map +1 -1
- package/dist/sdk/version.d.cts +10 -0
- package/dist/sdk/version.d.ts +1 -1
- package/dist/services/dataService.d.cts +9 -0
- package/dist/services/dataService.d.ts +4 -4
- package/dist/services/dataService.d.ts.map +1 -1
- package/dist/umd/ui-sdk.js +1 -1
- package/dist/umd/ui-sdk.js.map +1 -1
- package/dist/utils/caseConversion.d.cts +2 -0
- package/dist/utils/caseConversion.d.ts +2 -2
- package/dist/utils/caseConversion.d.ts.map +1 -1
- package/modules/README.md +62 -35
- package/package.json +21 -9
- package/dist/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-events.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/local-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"local-events.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/local-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7F,qBAAa,iBAAkB,YAAW,aAAa;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmD;IAE5E,uEAAuE;IACvE,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,IAAI;IAO1D,yEAAyE;IACzE,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IASrD,2FAA2F;IAC3F,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI;IAcnG,8BAA8B;IAC9B,OAAO,IAAI,IAAI;CAGlB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging System
|
|
3
|
+
* Handles secure communication between components and host application.
|
|
4
|
+
* Implements event validation and message routing.
|
|
5
|
+
*/
|
|
6
|
+
import type { SDKEvent, EventHandler, IEventEmitter, SDKEventType } from '../types/index.cjs';
|
|
7
|
+
import { SecurityManager } from '../utils/security.cjs';
|
|
8
|
+
export declare class MessagingSystem implements IEventEmitter {
|
|
9
|
+
private config;
|
|
10
|
+
private handlers;
|
|
11
|
+
private hostHandlers;
|
|
12
|
+
private bridge;
|
|
13
|
+
private security;
|
|
14
|
+
private messageListener;
|
|
15
|
+
constructor(config: {
|
|
16
|
+
origin: string;
|
|
17
|
+
security: SecurityManager;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Set up message event listener based on bridge type
|
|
21
|
+
* Handles both MessagePort and Window message events
|
|
22
|
+
*/
|
|
23
|
+
private setupMessageListener;
|
|
24
|
+
/**
|
|
25
|
+
* Validate incoming messages for security and structure
|
|
26
|
+
* Checks origin, message format, and source
|
|
27
|
+
*/
|
|
28
|
+
private validateMessage;
|
|
29
|
+
/**
|
|
30
|
+
* Subscribe to events with automatic cleanup
|
|
31
|
+
*/
|
|
32
|
+
on(event: SDKEventType, handler: EventHandler): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Remove event subscription
|
|
35
|
+
*/
|
|
36
|
+
off(event: SDKEventType, handler: EventHandler): void;
|
|
37
|
+
/**
|
|
38
|
+
* Emit events with type-safe payload
|
|
39
|
+
* Handles both local events and host communication
|
|
40
|
+
*/
|
|
41
|
+
emit<T extends SDKEvent['type']>(type: T, data: Omit<Extract<SDKEvent, {
|
|
42
|
+
type: T;
|
|
43
|
+
}>, 'type'>): void;
|
|
44
|
+
/**
|
|
45
|
+
* Send message to host application
|
|
46
|
+
* Handles different bridge types appropriately
|
|
47
|
+
*/
|
|
48
|
+
private sendToHost;
|
|
49
|
+
/**
|
|
50
|
+
* Handle and emit error events
|
|
51
|
+
*/
|
|
52
|
+
private emitError;
|
|
53
|
+
/**
|
|
54
|
+
* Clean up resources and event listeners
|
|
55
|
+
*/
|
|
56
|
+
destroy(): void;
|
|
57
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Handles secure communication between components and host application.
|
|
4
4
|
* Implements event validation and message routing.
|
|
5
5
|
*/
|
|
6
|
-
import type { SDKEvent, EventHandler, IEventEmitter, SDKEventType } from '../types';
|
|
7
|
-
import { SecurityManager } from '../utils/security';
|
|
6
|
+
import type { SDKEvent, EventHandler, IEventEmitter, SDKEventType } from '../types/index.js';
|
|
7
|
+
import { SecurityManager } from '../utils/security.js';
|
|
8
8
|
export declare class MessagingSystem implements IEventEmitter {
|
|
9
9
|
private config;
|
|
10
10
|
private handlers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/messaging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,YAAY,EAEf,MAAM,
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/messaging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,YAAY,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,qBAAa,eAAgB,YAAW,aAAa;IAY7C,OAAO,CAAC,MAAM;IAVlB,OAAO,CAAC,QAAQ,CAA6C;IAE7D,OAAO,CAAC,YAAY,CAA6C;IAEjE,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAkB;IAElC,OAAO,CAAC,eAAe,CAAgD;gBAG3D,MAAM,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,eAAe,CAAC;KAC7B;IAcL;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAmC5B;;;OAGG;IACH,OAAO,CAAC,eAAe;IA0BvB;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,IAAI;IAS1D;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAIrD;;;OAGG;IACH,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,EAC3B,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,EAAE,MAAM,CAAC,GACnD,IAAI;IAoCP;;;OAGG;IACH,OAAO,CAAC,UAAU;IAalB;;OAEG;IACH,OAAO,CAAC,SAAS;IAuBjB;;OAEG;IACH,OAAO,IAAI,IAAI;CAUlB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Management System
|
|
3
|
+
* Handles component state tracking, updates, and snapshots for undo/redo functionality.
|
|
4
|
+
* Provides a centralized way to manage and persist component states across the SDK.
|
|
5
|
+
*/
|
|
6
|
+
import type { StateConfig } from '../types/index.cjs';
|
|
7
|
+
/**
|
|
8
|
+
* A state change listener: any function. It is called with one `{ componentId, key, newValue, oldValue }` object.
|
|
9
|
+
* `never[]` takes a listener whatever it declares for that object, as the type `Function` did, without the unsafe call
|
|
10
|
+
* that `Function` allows.
|
|
11
|
+
*/
|
|
12
|
+
type StateChangeListener = (...args: never[]) => unknown;
|
|
13
|
+
export declare class StateManager {
|
|
14
|
+
private state;
|
|
15
|
+
private listeners;
|
|
16
|
+
private snapshots;
|
|
17
|
+
private maxSnapshots;
|
|
18
|
+
constructor(config?: StateConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Update component state with optional snapshot creation and silent updates
|
|
21
|
+
* @param componentId - Unique identifier for the component
|
|
22
|
+
* @param key - State property to update
|
|
23
|
+
* @param value - New value for the state property
|
|
24
|
+
* @param options - Configuration for state update behavior
|
|
25
|
+
*/
|
|
26
|
+
setState(componentId: string, key: string, value: unknown, options?: {
|
|
27
|
+
silent?: boolean;
|
|
28
|
+
snapshot?: boolean;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve specific state value for a component
|
|
32
|
+
*/
|
|
33
|
+
getState(componentId: string, key: string): any;
|
|
34
|
+
/**
|
|
35
|
+
* Get entire state map for a component
|
|
36
|
+
*/
|
|
37
|
+
getComponentState(componentId: string): Map<string, any> | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to state changes with automatic cleanup
|
|
40
|
+
*/
|
|
41
|
+
subscribe(componentId: string, callback: StateChangeListener): () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Remove state change subscription
|
|
44
|
+
*/
|
|
45
|
+
private unsubscribe;
|
|
46
|
+
/**
|
|
47
|
+
* Create a point-in-time snapshot of component state
|
|
48
|
+
*/
|
|
49
|
+
private createSnapshot;
|
|
50
|
+
/**
|
|
51
|
+
* Restore component state from a snapshot
|
|
52
|
+
* @param index - Optional index of snapshot to restore, defaults to latest
|
|
53
|
+
*/
|
|
54
|
+
restoreSnapshot(componentId: string, index?: number): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Notify all listeners of state changes
|
|
57
|
+
*/
|
|
58
|
+
private notifyStateChange;
|
|
59
|
+
/**
|
|
60
|
+
* Clean up resources for specific component or entire system
|
|
61
|
+
*/
|
|
62
|
+
cleanup(componentId?: string): void;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
package/dist/sdk/core/state.d.ts
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* Handles component state tracking, updates, and snapshots for undo/redo functionality.
|
|
4
4
|
* Provides a centralized way to manage and persist component states across the SDK.
|
|
5
5
|
*/
|
|
6
|
-
import type { StateConfig } from '../types';
|
|
6
|
+
import type { StateConfig } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* A state change listener: any function. It is called with one `{ componentId, key, newValue, oldValue }` object.
|
|
9
|
+
* `never[]` takes a listener whatever it declares for that object, as the type `Function` did, without the unsafe call
|
|
10
|
+
* that `Function` allows.
|
|
11
|
+
*/
|
|
12
|
+
type StateChangeListener = (...args: never[]) => unknown;
|
|
7
13
|
export declare class StateManager {
|
|
8
14
|
private state;
|
|
9
15
|
private listeners;
|
|
@@ -17,7 +23,7 @@ export declare class StateManager {
|
|
|
17
23
|
* @param value - New value for the state property
|
|
18
24
|
* @param options - Configuration for state update behavior
|
|
19
25
|
*/
|
|
20
|
-
setState(componentId: string, key: string, value:
|
|
26
|
+
setState(componentId: string, key: string, value: unknown, options?: {
|
|
21
27
|
silent?: boolean;
|
|
22
28
|
snapshot?: boolean;
|
|
23
29
|
}): void;
|
|
@@ -32,7 +38,7 @@ export declare class StateManager {
|
|
|
32
38
|
/**
|
|
33
39
|
* Subscribe to state changes with automatic cleanup
|
|
34
40
|
*/
|
|
35
|
-
subscribe(componentId: string, callback:
|
|
41
|
+
subscribe(componentId: string, callback: StateChangeListener): () => void;
|
|
36
42
|
/**
|
|
37
43
|
* Remove state change subscription
|
|
38
44
|
*/
|
|
@@ -55,4 +61,5 @@ export declare class StateManager {
|
|
|
55
61
|
*/
|
|
56
62
|
cleanup(componentId?: string): void;
|
|
57
63
|
}
|
|
64
|
+
export {};
|
|
58
65
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/state.ts"],"names":[],"mappings":"AA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MAAM,GAAG,IAAI;CAWtC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme helpers
|
|
3
|
+
*
|
|
4
|
+
* A theme a page gives the SDK is a mode (`light`, `dark`, or `system` to follow the visitor's operating system), settings
|
|
5
|
+
* (`preset`, `colors`, `radius`, `font`), or both. The SDK resolves `system` into `light` or `dark` here and hands the
|
|
6
|
+
* settings to the modules untouched: each module checks them itself and says what is wrong (error code `INVALID_THEME`).
|
|
7
|
+
*/
|
|
8
|
+
import type { ModuleTheme, ModuleThemeSettings, ThemeOption } from '../types/index.cjs';
|
|
9
|
+
export type { ThemeOption };
|
|
10
|
+
/** What a theme sets besides its mode. */
|
|
11
|
+
export type ThemeSettings = Omit<ModuleThemeSettings, 'mode'>;
|
|
12
|
+
/** The keys the SDK recognises in an object theme. */
|
|
13
|
+
export declare const THEME_KEYS: readonly ["mode", "preset", "colors", "radius", "font"];
|
|
14
|
+
/** True when the visitor's system asks for dark colours. False where that cannot be known (server, old browser). */
|
|
15
|
+
export declare function systemPrefersDark(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* True for something `updateTheme` can use: `'light'`, `'dark'`, `'system'`, or an object with at least one of `mode`,
|
|
18
|
+
* `preset`, `colors`, `radius`, `font` and nothing else. Only the shape is checked here; the modules check the values.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isThemeOption(value: unknown): value is ThemeOption;
|
|
21
|
+
/** The mode a theme option asks for, or `undefined` when it asks for none. */
|
|
22
|
+
export declare function modeOfThemeOption(theme: ThemeOption | undefined): 'light' | 'dark' | 'system' | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* What an object theme sets besides its mode, or `undefined` for a bare mode, for nothing, and for an object with a mode
|
|
25
|
+
* only. A key the SDK does not know is kept, so that the module it reaches can say it is a mistake.
|
|
26
|
+
*/
|
|
27
|
+
export declare function settingsOfThemeOption(theme: ThemeOption | undefined): ThemeSettings | undefined;
|
|
28
|
+
/** `light` or `dark`, with `system` turned into whichever one the visitor's system prefers right now. */
|
|
29
|
+
export declare function resolveMode(mode: 'light' | 'dark' | 'system'): 'light' | 'dark';
|
|
30
|
+
/**
|
|
31
|
+
* The `theme` a module is built with: the settings of the mount call where it brought some, the page-wide settings where
|
|
32
|
+
* it did not; the mode of the mount call where it brought one, the page-wide mode where it did not.
|
|
33
|
+
* With no settings at all this is just `'light'` or `'dark'`, which is what modules have always been given.
|
|
34
|
+
*/
|
|
35
|
+
export declare function themeForModule(own: ThemeOption | undefined, pageWide: {
|
|
36
|
+
mode: 'light' | 'dark';
|
|
37
|
+
settings?: ThemeSettings;
|
|
38
|
+
}): ModuleTheme;
|
|
39
|
+
/**
|
|
40
|
+
* Calls `onChange` whenever the visitor's system switches between light and dark.
|
|
41
|
+
* Returns a function that stops listening. Does nothing where the browser cannot tell.
|
|
42
|
+
*/
|
|
43
|
+
export declare function watchSystemTheme(onChange: (mode: 'light' | 'dark') => void): () => void;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (`preset`, `colors`, `radius`, `font`), or both. The SDK resolves `system` into `light` or `dark` here and hands the
|
|
6
6
|
* settings to the modules untouched: each module checks them itself and says what is wrong (error code `INVALID_THEME`).
|
|
7
7
|
*/
|
|
8
|
-
import type { ModuleTheme, ModuleThemeSettings, ThemeOption } from '../types';
|
|
8
|
+
import type { ModuleTheme, ModuleThemeSettings, ThemeOption } from '../types/index.js';
|
|
9
9
|
export type { ThemeOption };
|
|
10
10
|
/** What a theme sets besides its mode. */
|
|
11
11
|
export type ThemeSettings = Omit<ModuleThemeSettings, 'mode'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-mode.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/theme-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"theme-mode.d.ts","sourceRoot":"","sources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, and system-wide theme synchronization.
|
|
4
|
+
* Supports light/dark modes, custom colors, spacing, and typography settings.
|
|
5
|
+
*/
|
|
6
|
+
import type { ThemeConfig, ThemeMode, PartialThemeConfig } from '../types/index.cjs';
|
|
7
|
+
import { EventSystem } from './events.cjs';
|
|
8
|
+
export declare class ThemeManager {
|
|
9
|
+
private events;
|
|
10
|
+
private currentTheme;
|
|
11
|
+
private activePreset;
|
|
12
|
+
constructor(events: EventSystem, initialTheme?: PartialThemeConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Get current theme configuration
|
|
15
|
+
*/
|
|
16
|
+
getCurrentTheme(): ThemeConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Update theme with partial configuration
|
|
19
|
+
*/
|
|
20
|
+
updateTheme(updates: PartialThemeConfig): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set theme mode (light/dark/system)
|
|
23
|
+
*/
|
|
24
|
+
setMode(mode: ThemeMode): void;
|
|
25
|
+
/**
|
|
26
|
+
* Listen for system theme changes
|
|
27
|
+
*/
|
|
28
|
+
private setupSystemThemeListener;
|
|
29
|
+
/**
|
|
30
|
+
* Create default theme instance
|
|
31
|
+
*/
|
|
32
|
+
private createDefaultTheme;
|
|
33
|
+
/**
|
|
34
|
+
* Merge base theme with updates
|
|
35
|
+
*/
|
|
36
|
+
private mergeThemes;
|
|
37
|
+
/**
|
|
38
|
+
* Validate theme configuration
|
|
39
|
+
*/
|
|
40
|
+
private validateTheme;
|
|
41
|
+
/**
|
|
42
|
+
* Validate color format
|
|
43
|
+
*/
|
|
44
|
+
private isValidColor;
|
|
45
|
+
/**
|
|
46
|
+
* Apply color scheme based on mode
|
|
47
|
+
*/
|
|
48
|
+
private applyColorScheme;
|
|
49
|
+
/**
|
|
50
|
+
* Apply theme to document root
|
|
51
|
+
*/
|
|
52
|
+
private applyTheme;
|
|
53
|
+
/**
|
|
54
|
+
* Notify listeners of theme updates
|
|
55
|
+
*/
|
|
56
|
+
private notifyThemeUpdate;
|
|
57
|
+
}
|
package/dist/sdk/core/theme.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Handles theme configuration, updates, and system-wide theme synchronization.
|
|
4
4
|
* Supports light/dark modes, custom colors, spacing, and typography settings.
|
|
5
5
|
*/
|
|
6
|
-
import type { ThemeConfig, ThemeMode, PartialThemeConfig } from '../types';
|
|
7
|
-
import { EventSystem } from './events';
|
|
6
|
+
import type { ThemeConfig, ThemeMode, PartialThemeConfig } from '../types/index.js';
|
|
7
|
+
import { EventSystem } from './events.js';
|
|
8
8
|
export declare class ThemeManager {
|
|
9
9
|
private events;
|
|
10
10
|
private currentTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,kBAAkB,EACrB,MAAM,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,kBAAkB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAsC1C,qBAAa,YAAY;IAKjB,OAAO,CAAC,MAAM;IAJlB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,YAAY,CAAqB;gBAG7B,MAAM,EAAE,WAAW,EAC3B,YAAY,CAAC,EAAE,kBAAkB;IAUrC;;OAEG;IACH,eAAe,IAAI,WAAW;IAI9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAgB9C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAK9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;IACH,OAAO,CAAC,WAAW;IASnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAmBrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,UAAU;IAqBlB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAK5B"}
|
package/dist/sdk/index.d.ts
CHANGED
package/dist/sdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK7D,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host Communication Module
|
|
3
|
+
* Handles secure communication between the SDK and the host application.
|
|
4
|
+
* Implements message validation, secure channel creation, and event routing.
|
|
5
|
+
*/
|
|
6
|
+
import type { IEventEmitter } from '../types/index.cjs';
|
|
7
|
+
import { SecurityManager } from '../utils/security.cjs';
|
|
8
|
+
export declare class HostCommunication {
|
|
9
|
+
private origin;
|
|
10
|
+
private events;
|
|
11
|
+
private security;
|
|
12
|
+
private channel?;
|
|
13
|
+
private boundHandleMessage;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize host communication system
|
|
16
|
+
* @param origin - Allowed origin for message validation
|
|
17
|
+
* @param events - Event emitter for SDK-wide communication
|
|
18
|
+
* @param security - Security manager instance
|
|
19
|
+
*/
|
|
20
|
+
constructor(origin: string, events: IEventEmitter, security: SecurityManager);
|
|
21
|
+
/**
|
|
22
|
+
* Set up message event listener for host communication
|
|
23
|
+
* Binds message handler to window events
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private setupMessageHandling;
|
|
27
|
+
/**
|
|
28
|
+
* Handle incoming messages from host application
|
|
29
|
+
* Validates messages and routes events to appropriate handlers
|
|
30
|
+
* @param event - Message event from host
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
private handleMessage;
|
|
34
|
+
/**
|
|
35
|
+
* Validate incoming messages for security
|
|
36
|
+
* Checks origin and message structure
|
|
37
|
+
* @param event - Message event to validate
|
|
38
|
+
* @returns boolean indicating message validity
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private validateMessage;
|
|
42
|
+
/**
|
|
43
|
+
* Create secure communication channel with host
|
|
44
|
+
* Uses MessageChannel API for secure bi-directional communication
|
|
45
|
+
* @returns Promise that resolves when channel is established
|
|
46
|
+
*/
|
|
47
|
+
createSecureChannel(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Clean up resources and event listeners
|
|
50
|
+
* Called when host communication is no longer needed
|
|
51
|
+
*/
|
|
52
|
+
destroy(): void;
|
|
53
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Handles secure communication between the SDK and the host application.
|
|
4
4
|
* Implements message validation, secure channel creation, and event routing.
|
|
5
5
|
*/
|
|
6
|
-
import type { IEventEmitter } from '../types';
|
|
7
|
-
import { SecurityManager } from '../utils/security';
|
|
6
|
+
import type { IEventEmitter } from '../types/index.js';
|
|
7
|
+
import { SecurityManager } from '../utils/security.js';
|
|
8
8
|
export declare class HostCommunication {
|
|
9
9
|
private origin;
|
|
10
10
|
private events;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/sdk/integration/host.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/sdk/integration/host.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,qBAAa,iBAAiB;IAiBtB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAhBlB,OAAO,CAAC,QAAQ,CAAkB;IAElC,OAAO,CAAC,OAAO,CAAC,CAAc;IAE9B,OAAO,CAAC,kBAAkB,CAExB;IAEF;;;;;OAKG;gBAES,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EAC7B,QAAQ,EAAE,eAAe;IAO7B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAmBrB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAcvB;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAc1C;;;OAGG;IACH,OAAO,IAAI,IAAI;CAMlB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Module Index
|
|
3
|
+
* Exports components that handle integration with external systems
|
|
4
|
+
* and the host platform. These components form the bridge between
|
|
5
|
+
* the SDK and its hosting environment.
|
|
6
|
+
*/
|
|
7
|
+
export { HostCommunication } from './host.cjs';
|
|
8
|
+
/**
|
|
9
|
+
* Integration Component Architecture:
|
|
10
|
+
*
|
|
11
|
+
* - HostCommunication:
|
|
12
|
+
* - Secure messaging
|
|
13
|
+
* - Cross-origin communication
|
|
14
|
+
* - Event synchronization
|
|
15
|
+
*
|
|
16
|
+
* The platform and SDK-integration classes that used to live here validated an API key in the browser and probed
|
|
17
|
+
* the API with it. They were removed: the SDK holds no credentials (see `WidgeticUI` and its `getToken` option).
|
|
18
|
+
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-Level UI API for UI SDK
|
|
3
|
+
*
|
|
4
|
+
* The shortest way to put a Widgetic module on a page: configure once, then mount by name.
|
|
5
|
+
* Perfect for: Quick integration, HTML-first approaches, minimal JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* For anything more (several instances, events, different tokens per module) use `WidgeticUI` or `mountModule`
|
|
8
|
+
* directly. The mid-level and low-level APIs that used to sit beside this one handed out the SDK's internals,
|
|
9
|
+
* including an HTTP client that sent an API key from the browser; they were removed.
|
|
10
|
+
*/
|
|
11
|
+
import { WidgeticUI, type WidgeticUIOptions } from '../loader/ui.cjs';
|
|
12
|
+
import type { ModuleName, MountConfig } from '../types/index.cjs';
|
|
13
|
+
/**
|
|
14
|
+
* High-Level UI API - Declarative & Auto-magical
|
|
15
|
+
*
|
|
16
|
+
* Characteristics: one-call initialization, convention over configuration.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HighLevelUIAPI: {
|
|
19
|
+
readonly WidgeticUI: typeof WidgeticUI;
|
|
20
|
+
/**
|
|
21
|
+
* Configure the shared SDK instance. Calling it again replaces the instance and unmounts what the old one mounted.
|
|
22
|
+
*/
|
|
23
|
+
readonly initialize: (options: WidgeticUIOptions) => Promise<WidgeticUI>;
|
|
24
|
+
/**
|
|
25
|
+
* Mount a module into a container, given as an element or a CSS selector.
|
|
26
|
+
* @returns The instance ID to hand to `unmountComponent`
|
|
27
|
+
*/
|
|
28
|
+
readonly mountComponent: (type: ModuleName, container: HTMLElement | string, options?: Omit<MountConfig, "container">) => Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Take a mounted module down.
|
|
31
|
+
* @param instanceId - What `mountComponent` returned
|
|
32
|
+
*/
|
|
33
|
+
readonly unmountComponent: (instanceId: string) => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export type HighLevelUIAPIType = typeof HighLevelUIAPI;
|