@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,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Type Definitions
|
|
3
|
+
* Core types for UI component system including:
|
|
4
|
+
* - Component configuration
|
|
5
|
+
* - Component lifecycle
|
|
6
|
+
* - Component interfaces
|
|
7
|
+
*/
|
|
8
|
+
import type { ThemeConfig } from './theme.cjs';
|
|
9
|
+
import type { ModuleTheme, ThemeOption } from './module-theme.cjs';
|
|
10
|
+
import type { ModuleLanguage } from './module-language.cjs';
|
|
11
|
+
import type { PartnerMediaLibrary, PickFileFn } from './module-media-library.cjs';
|
|
12
|
+
import type { ModuleEventHandlers, ModuleEventName, ModuleEventPayload } from './module-events.cjs';
|
|
13
|
+
import type { IEventEmitter } from './events.cjs';
|
|
14
|
+
/**
|
|
15
|
+
* Why a module is asking the partner for a token.
|
|
16
|
+
* - `initial`: the module is starting and has no token yet.
|
|
17
|
+
* - `expiring`: the current token is about to expire and the module wants its replacement.
|
|
18
|
+
* - `expired`: the current token has already expired (the page was asleep, or an earlier refresh failed).
|
|
19
|
+
*/
|
|
20
|
+
export interface TokenRequestContext {
|
|
21
|
+
reason: 'initial' | 'expiring' | 'expired';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* What the partner's `getToken` resolves with: the bare editor session token, or the token together with the moment
|
|
25
|
+
* it stops working (an ISO 8601 string, epoch milliseconds or a Date). With `expiresAt` the module asks for a
|
|
26
|
+
* replacement shortly before then, so the visitor is never interrupted.
|
|
27
|
+
*/
|
|
28
|
+
export type TokenResult = string | {
|
|
29
|
+
token: string;
|
|
30
|
+
expiresAt?: string | number | Date;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Asks the partner's server for an editor session token.
|
|
34
|
+
* The partner's server mints it (`POST /v1/managed-users/{id}/editor-sessions` with its API key), so the API key
|
|
35
|
+
* never reaches the browser.
|
|
36
|
+
*/
|
|
37
|
+
export type GetToken = (context: TokenRequestContext) => Promise<TokenResult> | TokenResult;
|
|
38
|
+
/**
|
|
39
|
+
* UI Module Interface
|
|
40
|
+
* What the SDK needs from every UI module (File Browser, editors ...). Modules are plain classes built as
|
|
41
|
+
* `new Module(container, config)`; only `mount` is required.
|
|
42
|
+
*/
|
|
43
|
+
export interface UIModule {
|
|
44
|
+
mount(): Promise<void> | void;
|
|
45
|
+
unmount?(): Promise<void> | void;
|
|
46
|
+
/**
|
|
47
|
+
* Change the look: `'light'` or `'dark'` switch the mode and keep the rest of the theme; settings
|
|
48
|
+
* (`{ preset, colors, radius, font }`) replace the whole theme. Throws for a theme that cannot be used.
|
|
49
|
+
*/
|
|
50
|
+
setTheme?(theme: ModuleTheme): void;
|
|
51
|
+
/**
|
|
52
|
+
* Change the language while the module is on screen: `locale` for numbers, dates and plural rules, `messages` for the
|
|
53
|
+
* words. A key of `locale` or `messages` that the call leaves out keeps its current value; a `messages` object
|
|
54
|
+
* replaces all the module's current messages. Throws for a value that cannot be used, and then changes nothing.
|
|
55
|
+
*/
|
|
56
|
+
setLanguage?(language: ModuleLanguage): void;
|
|
57
|
+
on?(eventName: string, handler: (payload: any) => void): () => void;
|
|
58
|
+
off?(eventName: string, handler: (payload: any) => void): void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Component Status Type
|
|
62
|
+
* All possible component lifecycle states
|
|
63
|
+
*/
|
|
64
|
+
export type ComponentStatus = 'initializing' | 'ready' | 'error' | 'destroyed';
|
|
65
|
+
/**
|
|
66
|
+
* Component State Interface
|
|
67
|
+
* Tracks component status and data
|
|
68
|
+
*/
|
|
69
|
+
export interface ComponentState {
|
|
70
|
+
status: ComponentStatus;
|
|
71
|
+
error: Error | null;
|
|
72
|
+
data?: Record<string, any>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Base mount configuration
|
|
76
|
+
* Settings for mounting any module. Everything that is not listed here is handed to the module itself
|
|
77
|
+
* (the File Browser takes `maxSelections`, `initialFilter`, `selectLabel`, `locale`, `messages` ...).
|
|
78
|
+
*
|
|
79
|
+
* `Name` is the name of the module being mounted. `mountModule` and `ui.mount` fill it in from the name you pass, which is
|
|
80
|
+
* how `on` knows the events of the File Browser, the composition editor and the widget creator. Left out, `on` takes any
|
|
81
|
+
* event name.
|
|
82
|
+
*/
|
|
83
|
+
export interface MountConfig<Name extends ModuleName = ModuleName> {
|
|
84
|
+
container: string | HTMLElement;
|
|
85
|
+
/** Pin an exact module version such as "1.2.0". Default: the newest published version. */
|
|
86
|
+
version?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The look of this module: `'light'`, `'dark'`, `'system'`, or settings (`{ preset, mode, colors, radius, font }`).
|
|
89
|
+
* Default: the SDK's current theme. A module with settings of its own keeps them when the page later calls
|
|
90
|
+
* `ui.updateTheme(...)` with settings; it follows a change of mode.
|
|
91
|
+
*/
|
|
92
|
+
theme?: ThemeOption;
|
|
93
|
+
/** Show a loading placeholder while the module downloads. Default: true. */
|
|
94
|
+
placeholder?: boolean;
|
|
95
|
+
/** The words a screen reader says for that placeholder, in your language. Default: "Loading". */
|
|
96
|
+
loadingLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Cancels the mount. When the signal aborts before the module is running, the download is abandoned, nothing is
|
|
99
|
+
* left in the container and the mount rejects with an `AbortError` (code `MOUNT_ABORTED`). When it aborts
|
|
100
|
+
* while the module is starting, the module is taken down again. Made for components that can be removed before
|
|
101
|
+
* the module has finished loading (React effects, route changes).
|
|
102
|
+
*/
|
|
103
|
+
signal?: AbortSignal;
|
|
104
|
+
/**
|
|
105
|
+
* Listen to module events from the very start, so `ready` is not missed. For the File Browser, the composition editor
|
|
106
|
+
* and the widget creator the event names and what each one carries are typed (`FileBrowserEvents`,
|
|
107
|
+
* `CompositionEditorEvents`, `WidgetCreatorEvents`); any other module takes any name, with a payload of `any`.
|
|
108
|
+
*/
|
|
109
|
+
on?: ModuleEventHandlers<Name>;
|
|
110
|
+
callbacks?: {
|
|
111
|
+
onReady?: () => void;
|
|
112
|
+
onError?: (error: Error) => void;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Every module. When `true`, the module reads its colours and corner radius once, as it starts, from the CSS custom
|
|
116
|
+
* properties of the container it is mounted in (`--primary`, `--background`, `--radius` ...), and follows them
|
|
117
|
+
* when the container's `style` or `class` changes. What you give in `theme` wins. Default: `false`.
|
|
118
|
+
*/
|
|
119
|
+
themeFromHost?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The File Browser, the composition editor and the widget creator: your own media library, so that their pickers
|
|
122
|
+
* show your files and not the user's Widgetic uploads. Only `list` is required; `urlResolver` turns a listed
|
|
123
|
+
* address into the one that is saved.
|
|
124
|
+
*/
|
|
125
|
+
mediaLibrary?: PartnerMediaLibrary;
|
|
126
|
+
/**
|
|
127
|
+
* The composition editor and the widget creator: your own picker for file fields, instead of the File Browser.
|
|
128
|
+
* Resolve the files chosen, or `[]` when the visitor cancelled.
|
|
129
|
+
*/
|
|
130
|
+
pickFile?: PickFileFn;
|
|
131
|
+
/**
|
|
132
|
+
* The composition editor: when `true`, resizing the preview changes how it looks in the editor but does not update
|
|
133
|
+
* the widget's `embedSettings.width` and `embedSettings.height` when it is saved. Default: `false`.
|
|
134
|
+
*/
|
|
135
|
+
lockPreviewSize?: boolean;
|
|
136
|
+
[moduleOption: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Component configuration
|
|
140
|
+
* Full configuration for component initialization
|
|
141
|
+
* @deprecated Part of the legacy component base class (`WidgeticComponent`); UI modules do not use it.
|
|
142
|
+
*/
|
|
143
|
+
export interface ComponentConfig {
|
|
144
|
+
id: string;
|
|
145
|
+
container: HTMLElement;
|
|
146
|
+
events: IEventEmitter;
|
|
147
|
+
theme?: ThemeConfig;
|
|
148
|
+
widgetId?: string;
|
|
149
|
+
compositionId?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Component instance information
|
|
153
|
+
* Runtime data for mounted components
|
|
154
|
+
*/
|
|
155
|
+
export interface ComponentInstance {
|
|
156
|
+
id: string;
|
|
157
|
+
type: ComponentType;
|
|
158
|
+
container: HTMLElement;
|
|
159
|
+
unmount: () => Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A mounted UI module
|
|
163
|
+
* What `mount()` resolves with: the module itself plus the controls a page needs.
|
|
164
|
+
*
|
|
165
|
+
* `Name` is the name the module was mounted with. For the File Browser, the composition editor and the widget creator it
|
|
166
|
+
* gives `on` and `off` the names of that module's events and the payload of each (`ModuleEventMap`); for any other name
|
|
167
|
+
* they take any event name, with a payload of `any`.
|
|
168
|
+
*/
|
|
169
|
+
export interface MountedModule<Module extends UIModule = UIModule, Name extends ModuleName = ModuleName> {
|
|
170
|
+
id: string;
|
|
171
|
+
type: Name;
|
|
172
|
+
version: string;
|
|
173
|
+
container: HTMLElement;
|
|
174
|
+
module: Module;
|
|
175
|
+
/** Listen to a module event. Returns the function that stops listening. */
|
|
176
|
+
on: <Event extends ModuleEventName<Name>>(eventName: Event, handler: (payload: ModuleEventPayload<Name, Event>) => void) => () => void;
|
|
177
|
+
/** Stop listening with the handler given to `on`. */
|
|
178
|
+
off: <Event extends ModuleEventName<Name>>(eventName: Event, handler: (payload: ModuleEventPayload<Name, Event>) => void) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Change the look of this module alone: `'light'` or `'dark'` switch the mode and keep the rest of its theme; settings
|
|
181
|
+
* replace its theme, and from then on the module keeps them when the page calls `ui.updateTheme(...)` with settings.
|
|
182
|
+
* Throws for a theme that cannot be used, and then changes nothing.
|
|
183
|
+
*/
|
|
184
|
+
setTheme: (theme: ModuleTheme) => void;
|
|
185
|
+
/**
|
|
186
|
+
* Change the language of this module while it is on screen (`locale`, `messages`). A key the call leaves out keeps its
|
|
187
|
+
* current value; `messages` replaces all of the module's current messages, so a page switching from German to French
|
|
188
|
+
* passes the French ones only. Throws for a value the module cannot use, and then changes nothing. A module that has
|
|
189
|
+
* no words to translate (yet) says so in the console and does nothing.
|
|
190
|
+
*/
|
|
191
|
+
setLanguage: (language: ModuleLanguage) => void;
|
|
192
|
+
unmount: () => Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Available component types
|
|
196
|
+
* Union of all supported UI components
|
|
197
|
+
*/
|
|
198
|
+
export type ComponentType = 'widget-creator' | 'composition-editor' | 'embed-editor' | 'file-browser';
|
|
199
|
+
/**
|
|
200
|
+
* Any module name. The known modules autocomplete; a module published after this SDK release still works because
|
|
201
|
+
* modules are found through the CDN, not through this list.
|
|
202
|
+
*/
|
|
203
|
+
export type ModuleName = ComponentType | (string & {});
|
|
204
|
+
/**
|
|
205
|
+
* Module manifest
|
|
206
|
+
* A small JSON file next to every module (`<base>/<name>/manifest.json`) that names the newest version.
|
|
207
|
+
*/
|
|
208
|
+
export interface ModuleManifest {
|
|
209
|
+
name: string;
|
|
210
|
+
version: string;
|
|
211
|
+
entry: string;
|
|
212
|
+
}
|
|
213
|
+
/** @deprecated Use `ModuleManifest`. */
|
|
214
|
+
export type ComponentManifest = ModuleManifest;
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* - Component lifecycle
|
|
6
6
|
* - Component interfaces
|
|
7
7
|
*/
|
|
8
|
-
import type { ThemeConfig } from './theme';
|
|
9
|
-
import type { ModuleTheme, ThemeOption } from './module-theme';
|
|
10
|
-
import type { ModuleLanguage } from './module-language';
|
|
11
|
-
import type {
|
|
8
|
+
import type { ThemeConfig } from './theme.js';
|
|
9
|
+
import type { ModuleTheme, ThemeOption } from './module-theme.js';
|
|
10
|
+
import type { ModuleLanguage } from './module-language.js';
|
|
11
|
+
import type { PartnerMediaLibrary, PickFileFn } from './module-media-library.js';
|
|
12
|
+
import type { ModuleEventHandlers, ModuleEventName, ModuleEventPayload } from './module-events.js';
|
|
13
|
+
import type { IEventEmitter } from './events.js';
|
|
12
14
|
/**
|
|
13
15
|
* Why a module is asking the partner for a token.
|
|
14
16
|
* - `initial`: the module is starting and has no token yet.
|
|
@@ -73,8 +75,12 @@ export interface ComponentState {
|
|
|
73
75
|
* Base mount configuration
|
|
74
76
|
* Settings for mounting any module. Everything that is not listed here is handed to the module itself
|
|
75
77
|
* (the File Browser takes `maxSelections`, `initialFilter`, `selectLabel`, `locale`, `messages` ...).
|
|
78
|
+
*
|
|
79
|
+
* `Name` is the name of the module being mounted. `mountModule` and `ui.mount` fill it in from the name you pass, which is
|
|
80
|
+
* how `on` knows the events of the File Browser, the composition editor and the widget creator. Left out, `on` takes any
|
|
81
|
+
* event name.
|
|
76
82
|
*/
|
|
77
|
-
export interface MountConfig {
|
|
83
|
+
export interface MountConfig<Name extends ModuleName = ModuleName> {
|
|
78
84
|
container: string | HTMLElement;
|
|
79
85
|
/** Pin an exact module version such as "1.2.0". Default: the newest published version. */
|
|
80
86
|
version?: string;
|
|
@@ -95,12 +101,38 @@ export interface MountConfig {
|
|
|
95
101
|
* the module has finished loading (React effects, route changes).
|
|
96
102
|
*/
|
|
97
103
|
signal?: AbortSignal;
|
|
98
|
-
/**
|
|
99
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Listen to module events from the very start, so `ready` is not missed. For the File Browser, the composition editor
|
|
106
|
+
* and the widget creator the event names and what each one carries are typed (`FileBrowserEvents`,
|
|
107
|
+
* `CompositionEditorEvents`, `WidgetCreatorEvents`); any other module takes any name, with a payload of `any`.
|
|
108
|
+
*/
|
|
109
|
+
on?: ModuleEventHandlers<Name>;
|
|
100
110
|
callbacks?: {
|
|
101
111
|
onReady?: () => void;
|
|
102
112
|
onError?: (error: Error) => void;
|
|
103
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Every module. When `true`, the module reads its colours and corner radius once, as it starts, from the CSS custom
|
|
116
|
+
* properties of the container it is mounted in (`--primary`, `--background`, `--radius` ...), and follows them
|
|
117
|
+
* when the container's `style` or `class` changes. What you give in `theme` wins. Default: `false`.
|
|
118
|
+
*/
|
|
119
|
+
themeFromHost?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The File Browser, the composition editor and the widget creator: your own media library, so that their pickers
|
|
122
|
+
* show your files and not the user's Widgetic uploads. Only `list` is required; `urlResolver` turns a listed
|
|
123
|
+
* address into the one that is saved.
|
|
124
|
+
*/
|
|
125
|
+
mediaLibrary?: PartnerMediaLibrary;
|
|
126
|
+
/**
|
|
127
|
+
* The composition editor and the widget creator: your own picker for file fields, instead of the File Browser.
|
|
128
|
+
* Resolve the files chosen, or `[]` when the visitor cancelled.
|
|
129
|
+
*/
|
|
130
|
+
pickFile?: PickFileFn;
|
|
131
|
+
/**
|
|
132
|
+
* The composition editor: when `true`, resizing the preview changes how it looks in the editor but does not update
|
|
133
|
+
* the widget's `embedSettings.width` and `embedSettings.height` when it is saved. Default: `false`.
|
|
134
|
+
*/
|
|
135
|
+
lockPreviewSize?: boolean;
|
|
104
136
|
[moduleOption: string]: unknown;
|
|
105
137
|
}
|
|
106
138
|
/**
|
|
@@ -129,15 +161,21 @@ export interface ComponentInstance {
|
|
|
129
161
|
/**
|
|
130
162
|
* A mounted UI module
|
|
131
163
|
* What `mount()` resolves with: the module itself plus the controls a page needs.
|
|
164
|
+
*
|
|
165
|
+
* `Name` is the name the module was mounted with. For the File Browser, the composition editor and the widget creator it
|
|
166
|
+
* gives `on` and `off` the names of that module's events and the payload of each (`ModuleEventMap`); for any other name
|
|
167
|
+
* they take any event name, with a payload of `any`.
|
|
132
168
|
*/
|
|
133
|
-
export interface MountedModule<Module extends UIModule = UIModule> {
|
|
169
|
+
export interface MountedModule<Module extends UIModule = UIModule, Name extends ModuleName = ModuleName> {
|
|
134
170
|
id: string;
|
|
135
|
-
type:
|
|
171
|
+
type: Name;
|
|
136
172
|
version: string;
|
|
137
173
|
container: HTMLElement;
|
|
138
174
|
module: Module;
|
|
139
|
-
|
|
140
|
-
|
|
175
|
+
/** Listen to a module event. Returns the function that stops listening. */
|
|
176
|
+
on: <Event extends ModuleEventName<Name>>(eventName: Event, handler: (payload: ModuleEventPayload<Name, Event>) => void) => () => void;
|
|
177
|
+
/** Stop listening with the handler given to `on`. */
|
|
178
|
+
off: <Event extends ModuleEventName<Name>>(eventName: Event, handler: (payload: ModuleEventPayload<Name, Event>) => void) => void;
|
|
141
179
|
/**
|
|
142
180
|
* Change the look of this module alone: `'light'` or `'dark'` switch the mode and keep the rest of its theme; settings
|
|
143
181
|
* replace its theme, and from then on the module keeps them when the page calls `ui.updateTheme(...)` with settings.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE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AAc,GACd,cAAc,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wCAAwC;AACxC,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module defines the type system for the SDK's event handling.
|
|
5
|
+
* It provides type-safe event emission and handling across all components.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* All SDK Event Types
|
|
9
|
+
* Union of all possible event type strings
|
|
10
|
+
*/
|
|
11
|
+
export type SDKEventType = 'ready' | 'error' | 'state:update' | 'theme:update' | 'widget:create:start' | 'widget:create:complete' | 'composition:edit:start' | 'composition:save' | 'embed:configure' | 'embed:complete' | 'messaging:error' | 'cache:loaded' | 'cache:saved' | 'cache:hit' | 'cache:miss' | 'cache:updated' | 'cache:expired' | 'cache:cleared' | 'cache:error' | 'cache:update-available';
|
|
12
|
+
/**
|
|
13
|
+
* Event Handler Function
|
|
14
|
+
* Generic handler for all SDK events
|
|
15
|
+
*/
|
|
16
|
+
export type EventHandler = (event: SDKEvent) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Event Emitter Interface
|
|
19
|
+
* Core interface for event management
|
|
20
|
+
*/
|
|
21
|
+
export interface IEventEmitter {
|
|
22
|
+
on(event: SDKEventType, handler: EventHandler): () => void;
|
|
23
|
+
off(event: SDKEventType, handler: EventHandler): void;
|
|
24
|
+
emit(type: SDKEventType, data: Record<string, any>): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SDK Event Base Type
|
|
28
|
+
* Common properties for all events
|
|
29
|
+
*/
|
|
30
|
+
interface BaseEvent {
|
|
31
|
+
type: SDKEventType;
|
|
32
|
+
timestamp?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* SDK Event Union
|
|
36
|
+
* Combines all possible events and their payloads
|
|
37
|
+
*/
|
|
38
|
+
export type SDKEvent = BaseEvent & ({
|
|
39
|
+
type: 'ready';
|
|
40
|
+
componentId: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'error';
|
|
43
|
+
componentId: string;
|
|
44
|
+
error: Error;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'state:update';
|
|
47
|
+
componentId: string;
|
|
48
|
+
state: any;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'theme:update';
|
|
51
|
+
theme: any;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'messaging:error';
|
|
54
|
+
error: SDKError;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'widget:create:start';
|
|
57
|
+
partnerId: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'widget:create:complete';
|
|
60
|
+
widgetId: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'composition:edit:start';
|
|
63
|
+
widgetId: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'composition:save';
|
|
66
|
+
compositionId: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'embed:configure';
|
|
69
|
+
compositionId: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'embed:complete';
|
|
72
|
+
embedCode: string;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'cache:loaded';
|
|
75
|
+
cacheId: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'cache:saved';
|
|
78
|
+
cacheId: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'cache:hit';
|
|
81
|
+
cacheId: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: 'cache:miss';
|
|
84
|
+
cacheId: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'cache:updated';
|
|
87
|
+
cacheId: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: 'cache:expired';
|
|
90
|
+
cacheId: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'cache:cleared';
|
|
93
|
+
cacheId: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'cache:error';
|
|
96
|
+
cacheId: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'cache:update-available';
|
|
99
|
+
cacheId: string;
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* SDK Error Structure
|
|
103
|
+
*/
|
|
104
|
+
export interface SDKError {
|
|
105
|
+
message: string;
|
|
106
|
+
code: string;
|
|
107
|
+
name: string;
|
|
108
|
+
stack?: string;
|
|
109
|
+
details?: unknown;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAClB,OAAO,GACP,OAAO,GACP,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,wBAAwB,GACxB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,eAAe,GACf,eAAe,GACf,eAAe,GACf,aAAa,GACb,wBAAwB,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,IAAI,CAAC;IAC3D,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../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;AACH,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widgetic UI SDK Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module serves as the central type system for the UI SDK.
|
|
5
|
+
* It exports all type definitions used across the SDK components
|
|
6
|
+
* and provides type safety for the entire system.
|
|
7
|
+
*/
|
|
8
|
+
export type { UIModule, ComponentStatus, ComponentState, ComponentType, ModuleName, ModuleManifest, ComponentManifest, MountConfig, MountedModule, ComponentConfig, ComponentInstance, GetToken, TokenRequestContext, TokenResult } from './component.cjs';
|
|
9
|
+
export * from './events.cjs';
|
|
10
|
+
export * from './theme.cjs';
|
|
11
|
+
export * from './module-theme.cjs';
|
|
12
|
+
export * from './module-language.cjs';
|
|
13
|
+
export * from './module-media-library.cjs';
|
|
14
|
+
export * from './module-events.cjs';
|
|
15
|
+
export type { StateConfig, StateSnapshot } from './state.cjs';
|
|
16
|
+
/**
|
|
17
|
+
* Error Event Structure
|
|
18
|
+
* Standard format for error events in messaging system
|
|
19
|
+
*/
|
|
20
|
+
export interface MessagingErrorEvent {
|
|
21
|
+
type: 'messaging:error';
|
|
22
|
+
error: SDKError;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* SDK Error Structure
|
|
27
|
+
* Standardized error format across the SDK
|
|
28
|
+
*/
|
|
29
|
+
export interface SDKError {
|
|
30
|
+
message: string;
|
|
31
|
+
code: string;
|
|
32
|
+
name: string;
|
|
33
|
+
stack?: string;
|
|
34
|
+
details?: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* HTTP Types
|
|
38
|
+
* Types for HTTP client configuration and responses
|
|
39
|
+
*/
|
|
40
|
+
export type ResponseType = 'json' | 'text' | 'blob';
|
|
41
|
+
export interface RequestConfig extends RequestInit {
|
|
42
|
+
headers?: Record<string, string>;
|
|
43
|
+
}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* It exports all type definitions used across the SDK components
|
|
6
6
|
* and provides type safety for the entire system.
|
|
7
7
|
*/
|
|
8
|
-
export type { UIModule, ComponentStatus, ComponentState, ComponentType, ModuleName, ModuleManifest, ComponentManifest, MountConfig, MountedModule, ComponentConfig, ComponentInstance, GetToken, TokenRequestContext, TokenResult } from './component';
|
|
9
|
-
export * from './events';
|
|
10
|
-
export * from './theme';
|
|
11
|
-
export * from './module-theme';
|
|
12
|
-
export * from './module-language';
|
|
13
|
-
export
|
|
8
|
+
export type { UIModule, ComponentStatus, ComponentState, ComponentType, ModuleName, ModuleManifest, ComponentManifest, MountConfig, MountedModule, ComponentConfig, ComponentInstance, GetToken, TokenRequestContext, TokenResult } from './component.js';
|
|
9
|
+
export * from './events.js';
|
|
10
|
+
export * from './theme.js';
|
|
11
|
+
export * from './module-theme.js';
|
|
12
|
+
export * from './module-language.js';
|
|
13
|
+
export * from './module-media-library.js';
|
|
14
|
+
export * from './module-events.js';
|
|
15
|
+
export type { StateConfig, StateSnapshot } from './state.js';
|
|
14
16
|
/**
|
|
15
17
|
* Error Event Structure
|
|
16
18
|
* Standard format for error events in messaging system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACR,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACd,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACR,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACd,MAAM,gBAAgB,CAAC;AAGxB,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,oBAAoB,CAAC;AAGnC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,aAAc,SAAQ,WAAW;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging System Types
|
|
3
|
+
* Contains types for cross-origin communication and message handling.
|
|
4
|
+
* Used for secure communication between SDK and host application.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Message origin configuration
|
|
8
|
+
* Defines allowed message sources
|
|
9
|
+
*/
|
|
10
|
+
export interface MessageConfig {
|
|
11
|
+
allowedOrigins: string[];
|
|
12
|
+
targetOrigin: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Message payload structure
|
|
16
|
+
* Standard format for all messages
|
|
17
|
+
*/
|
|
18
|
+
export interface MessagePayload<T = unknown> {
|
|
19
|
+
type: string;
|
|
20
|
+
data: T;
|
|
21
|
+
source: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Message channel configuration
|
|
26
|
+
* Settings for secure channel setup
|
|
27
|
+
*/
|
|
28
|
+
export interface ChannelConfig {
|
|
29
|
+
secure: boolean;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
retries?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Message validation result
|
|
35
|
+
* Result of message security checks
|
|
36
|
+
*/
|
|
37
|
+
export interface ValidationResult {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|