@widgetic/ui-sdk 0.1.3 → 0.1.6
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 +161 -10
- package/dist/{index.js → index.cjs} +17 -24
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +52 -0
- package/dist/index.esm.js +16 -23
- 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 +49 -11
- 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 -6
- 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-media-library.d.ts +144 -0
- package/dist/sdk/types/module-media-library.d.ts.map +1 -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 +5 -2
- package/dist/sdk/version.d.ts.map +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 +79 -43
- package/package.json +24 -10
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Lifecycle Manager
|
|
3
|
+
* Mounts and unmounts UI modules and keeps track of the ones that are on screen.
|
|
4
|
+
*
|
|
5
|
+
* It owns the part between "the partner asked for a module" and "the module is running":
|
|
6
|
+
* 1. check the container,
|
|
7
|
+
* 2. show a loading placeholder inside it,
|
|
8
|
+
* 3. have the `ModuleLoader` fetch the module (the only way modules are loaded),
|
|
9
|
+
* 4. build it as `new Module(container, config)` with the partner's `getToken`, `apiUrl` and the theme,
|
|
10
|
+
* 5. connect the events the partner asked for, then `mount()`.
|
|
11
|
+
*
|
|
12
|
+
* It never writes to the container beyond adding (and later removing) its own placeholder, so whatever the partner
|
|
13
|
+
* put there stays where it was.
|
|
14
|
+
*/
|
|
15
|
+
import type { GetToken, IEventEmitter, ModuleName, MountConfig, MountedModule } from '../types/index.cjs';
|
|
16
|
+
import type { ModuleLoader } from '../modules/loader.cjs';
|
|
17
|
+
import { type ThemeSettings } from './theme-mode.cjs';
|
|
18
|
+
export interface LifecycleOptions {
|
|
19
|
+
/** Finds and imports modules. */
|
|
20
|
+
loader: ModuleLoader;
|
|
21
|
+
/** Handed to every module unless the mount call brings its own. */
|
|
22
|
+
moduleDefaults: {
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
/** Absent when the page gave none; a module that needs a token then says so itself. */
|
|
25
|
+
getToken?: GetToken;
|
|
26
|
+
locale?: string;
|
|
27
|
+
};
|
|
28
|
+
/** The look modules should have right now (`system` already resolved). */
|
|
29
|
+
getThemeMode: () => 'light' | 'dark';
|
|
30
|
+
/**
|
|
31
|
+
* What the page-wide theme sets besides the mode (preset, colours, radius, font), or nothing. A module whose mount call
|
|
32
|
+
* brought no settings of its own is built with these.
|
|
33
|
+
*/
|
|
34
|
+
getThemeSettings?: () => ThemeSettings | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The module started loading but could not be built or mounted. `cause` has the module's own error. */
|
|
37
|
+
export declare class ModuleMountError extends Error {
|
|
38
|
+
readonly code = "MOUNT_FAILED";
|
|
39
|
+
readonly moduleName: string;
|
|
40
|
+
readonly cause?: unknown;
|
|
41
|
+
constructor(moduleName: string, cause: unknown);
|
|
42
|
+
}
|
|
43
|
+
export declare class LifecycleManager {
|
|
44
|
+
private readonly events;
|
|
45
|
+
private readonly options;
|
|
46
|
+
private readonly active;
|
|
47
|
+
constructor(events: IEventEmitter, options: LifecycleOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Mount a module into a container.
|
|
50
|
+
* @param type - Which module, like `file-browser`.
|
|
51
|
+
* @param mountConfig - The container, SDK-level options and whatever the module itself takes.
|
|
52
|
+
* @returns The mounted module. `unmount()` on it takes it down again.
|
|
53
|
+
*/
|
|
54
|
+
mount(type: ModuleName, mountConfig: MountConfig): Promise<MountedModule>;
|
|
55
|
+
/** Take one mounted module down. */
|
|
56
|
+
unmount(instanceId: string): Promise<void>;
|
|
57
|
+
/** A module that is currently mounted, or `undefined`. */
|
|
58
|
+
get(instanceId: string): MountedModule | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Tells every mounted module to switch to the light or the dark look. A module keeps the rest of its theme (its preset,
|
|
61
|
+
* colours, radius and font): a bare mode only changes the mode.
|
|
62
|
+
*/
|
|
63
|
+
setThemeMode(mode: 'light' | 'dark'): void;
|
|
64
|
+
/**
|
|
65
|
+
* Gives the page's new settings to every module that has none of its own, in the mode given. A module with settings
|
|
66
|
+
* of its own keeps them, and is told the mode only when the call that brought the settings also chose a mode
|
|
67
|
+
* (`modeChanged`): a page that changes a preset does not turn a module that was mounted dark back to light.
|
|
68
|
+
*/
|
|
69
|
+
setDefaultTheme(settings: ThemeSettings, mode: 'light' | 'dark', modeChanged?: boolean): void;
|
|
70
|
+
/** Hands a theme to one module. One that refuses it does not stop the others from getting theirs. */
|
|
71
|
+
private tellModule;
|
|
72
|
+
/** Take every mounted module down. One that fails to unmount does not stop the others. */
|
|
73
|
+
cleanup(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Subscribes to the module's events: the partner's handlers first (so they see `ready`), then the SDK's own
|
|
76
|
+
* bookkeeping. Returns the functions that stop every subscription.
|
|
77
|
+
*/
|
|
78
|
+
private connectEvents;
|
|
79
|
+
private createMountedModule;
|
|
80
|
+
/** Takes a half-started module down without letting its own errors hide the real one. */
|
|
81
|
+
private unmountQuietly;
|
|
82
|
+
/**
|
|
83
|
+
* Shows a spinner inside the container while the module downloads, so the page does not jump when it appears.
|
|
84
|
+
* It is one element, added after whatever the container already holds, and removed again by `mount`.
|
|
85
|
+
* A screen reader says `loadingLabel` for it ("Loading" unless the page gave its own words).
|
|
86
|
+
*/
|
|
87
|
+
private showPlaceholder;
|
|
88
|
+
/**
|
|
89
|
+
* Get recommended minimum height for component type to prevent CLS
|
|
90
|
+
*/
|
|
91
|
+
private getComponentMinHeight;
|
|
92
|
+
/**
|
|
93
|
+
* Generate unique instance ID
|
|
94
|
+
*/
|
|
95
|
+
private generateInstanceId;
|
|
96
|
+
}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* It never writes to the container beyond adding (and later removing) its own placeholder, so whatever the partner
|
|
13
13
|
* put there stays where it was.
|
|
14
14
|
*/
|
|
15
|
-
import type { GetToken, IEventEmitter, ModuleName, MountConfig, MountedModule } from '../types';
|
|
16
|
-
import type { ModuleLoader } from '../modules/loader';
|
|
17
|
-
import { type ThemeSettings } from './theme-mode';
|
|
15
|
+
import type { GetToken, IEventEmitter, ModuleName, MountConfig, MountedModule } from '../types/index.js';
|
|
16
|
+
import type { ModuleLoader } from '../modules/loader.js';
|
|
17
|
+
import { type ThemeSettings } from './theme-mode.js';
|
|
18
18
|
export interface LifecycleOptions {
|
|
19
19
|
/** Finds and imports modules. */
|
|
20
20
|
loader: ModuleLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAe,WAAW,EAAE,aAAa,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAe,WAAW,EAAE,aAAa,EAAY,MAAM,mBAAmB,CAAC;AAGhI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5F,MAAM,WAAW,gBAAgB;IAC7B,iCAAiC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,mEAAmE;IACnE,cAAc,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,uFAAuF;QACvF,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,0EAA0E;IAC1E,YAAY,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC;IACrC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,aAAa,GAAG,SAAS,CAAC;CACtD;AAED,wGAAwG;AACxG,qBAAa,gBAAiB,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEb,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAOjD;AAYD,qBAAa,gBAAgB;IAIrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAG1C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB;IAG9C;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAwD/E,oCAAoC;IAC9B,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBhD,0DAA0D;IAC1D,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIlD;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAM1C;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,WAAW,UAAO,GAAG,IAAI;IAU1F,qGAAqG;IACrG,OAAO,CAAC,UAAU;IAQlB,0FAA0F;IACpF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,mBAAmB;IA6C3B,yFAAyF;YAC3E,cAAc;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAa7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAG7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Event Emitter
|
|
3
|
+
*
|
|
4
|
+
* The SDK's own events (`ready`, `error`, ...) delivered to handlers on the same page and nowhere else.
|
|
5
|
+
*
|
|
6
|
+
* `EventSystem` also posts every event to `window.parent` and listens to every `message` on the window, because it
|
|
7
|
+
* was designed for components living in an iframe. UI modules mount straight into the partner's page, so nothing
|
|
8
|
+
* has to cross a frame boundary; using `EventSystem` here would broadcast the SDK's events to the partner page's
|
|
9
|
+
* own `message` listeners, which is noise at best.
|
|
10
|
+
*/
|
|
11
|
+
import type { EventHandler, IEventEmitter, SDKEvent, SDKEventType } from '../types/index.cjs';
|
|
12
|
+
export declare class LocalEventEmitter implements IEventEmitter {
|
|
13
|
+
private readonly handlers;
|
|
14
|
+
/** Starts listening. Returns a function that stops listening again. */
|
|
15
|
+
on(event: SDKEventType, handler: EventHandler): () => void;
|
|
16
|
+
/** Stops listening. Does nothing when the handler was not registered. */
|
|
17
|
+
off(event: SDKEventType, handler: EventHandler): void;
|
|
18
|
+
/** Tells every listener. A listener that throws is logged and does not stop the others. */
|
|
19
|
+
emit<T extends SDKEvent['type']>(type: T, data: Omit<Extract<SDKEvent, {
|
|
20
|
+
type: T;
|
|
21
|
+
}>, 'type'>): void;
|
|
22
|
+
/** Forgets every listener. */
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* has to cross a frame boundary; using `EventSystem` here would broadcast the SDK's events to the partner page's
|
|
9
9
|
* own `message` listeners, which is noise at best.
|
|
10
10
|
*/
|
|
11
|
-
import type { EventHandler, IEventEmitter, SDKEvent, SDKEventType } from '../types';
|
|
11
|
+
import type { EventHandler, IEventEmitter, SDKEvent, SDKEventType } from '../types/index.js';
|
|
12
12
|
export declare class LocalEventEmitter implements IEventEmitter {
|
|
13
13
|
private readonly handlers;
|
|
14
14
|
/** Starts listening. Returns a function that stops listening again. */
|
|
@@ -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":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/sdk/core/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAEpE;;;;GAIG;AACH,KAAK,mBAAmB,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAUzD,qBAAa,YAAY;IAErB,OAAO,CAAC,KAAK,CAAoC;IAEjD,OAAO,CAAC,SAAS,CAAwC;IAEzD,OAAO,CAAC,SAAS,CAA+B;IAEhD,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,GAAE,WAAgB;IAQpC;;;;;;OAMG;IACH,QAAQ,CACJ,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACjB,GACP,IAAI;IA4BP;;OAEG;IAEH,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG;IAI/C;;OAEG;IAEH,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS;IAIpE;;OAEG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IASzE;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,cAAc;IAmBtB;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO;IAoBjE;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;OAEG;IACH,OAAO,CAAC,WAAW,CAAC,EAAE,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":["../../../src/sdk/core/theme-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvF,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,0CAA0C;AAC1C,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAE9D,sDAAsD;AACtD,eAAO,MAAM,UAAU,yDAA0D,CAAC;AASlF,oHAAoH;AACpH,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAgBlE;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAGzG;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAM/F;AAED,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAK/E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,QAAQ,EAAE;IAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,aAAa,CAAA;CAAE,GAC/D,WAAW,CAKb;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAQvF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Management System
|
|
3
|
+
* Handles theme configuration, updates, 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"}
|