@widgetic/ui-sdk 0.0.0-stage → 0.1.1
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 +718 -2
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2525 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2559 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk/core/component.d.ts +47 -0
- package/dist/sdk/core/component.d.ts.map +1 -0
- package/dist/sdk/core/events.d.ts +26 -0
- package/dist/sdk/core/events.d.ts.map +1 -0
- package/dist/sdk/core/index.d.ts +33 -0
- package/dist/sdk/core/index.d.ts.map +1 -0
- package/dist/sdk/core/lifecycle.d.ts +97 -0
- package/dist/sdk/core/lifecycle.d.ts.map +1 -0
- package/dist/sdk/core/local-events.d.ts +25 -0
- package/dist/sdk/core/local-events.d.ts.map +1 -0
- package/dist/sdk/core/messaging.d.ts +58 -0
- package/dist/sdk/core/messaging.d.ts.map +1 -0
- package/dist/sdk/core/state.d.ts +58 -0
- package/dist/sdk/core/state.d.ts.map +1 -0
- package/dist/sdk/core/theme-mode.d.ts +44 -0
- package/dist/sdk/core/theme-mode.d.ts.map +1 -0
- package/dist/sdk/core/theme.d.ts +58 -0
- package/dist/sdk/core/theme.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/integration/host.d.ts +54 -0
- package/dist/sdk/integration/host.d.ts.map +1 -0
- package/dist/sdk/integration/index.d.ts +19 -0
- package/dist/sdk/integration/index.d.ts.map +1 -0
- package/dist/sdk/layers/index.d.ts +36 -0
- package/dist/sdk/layers/index.d.ts.map +1 -0
- package/dist/sdk/loader/ui.d.ts +165 -0
- package/dist/sdk/loader/ui.d.ts.map +1 -0
- package/dist/sdk/modules/index.d.ts +9 -0
- package/dist/sdk/modules/index.d.ts.map +1 -0
- package/dist/sdk/modules/loader.d.ts +84 -0
- package/dist/sdk/modules/loader.d.ts.map +1 -0
- package/dist/sdk/types/component.d.ts +177 -0
- package/dist/sdk/types/component.d.ts.map +1 -0
- package/dist/sdk/types/events.d.ts +112 -0
- package/dist/sdk/types/events.d.ts.map +1 -0
- package/dist/sdk/types/index.d.ts +42 -0
- package/dist/sdk/types/index.d.ts.map +1 -0
- package/dist/sdk/types/messaging.d.ts +41 -0
- package/dist/sdk/types/messaging.d.ts.map +1 -0
- package/dist/sdk/types/module-language.d.ts +45 -0
- package/dist/sdk/types/module-language.d.ts.map +1 -0
- package/dist/sdk/types/module-theme.d.ts +93 -0
- package/dist/sdk/types/module-theme.d.ts.map +1 -0
- package/dist/sdk/types/state.d.ts +38 -0
- package/dist/sdk/types/state.d.ts.map +1 -0
- package/dist/sdk/types/theme.d.ts +76 -0
- package/dist/sdk/types/theme.d.ts.map +1 -0
- package/dist/sdk/utils/config.d.ts +70 -0
- package/dist/sdk/utils/config.d.ts.map +1 -0
- package/dist/sdk/utils/errors.d.ts +56 -0
- package/dist/sdk/utils/errors.d.ts.map +1 -0
- package/dist/sdk/utils/http.d.ts +21 -0
- package/dist/sdk/utils/http.d.ts.map +1 -0
- package/dist/sdk/utils/security.d.ts +95 -0
- package/dist/sdk/utils/security.d.ts.map +1 -0
- package/dist/sdk/utils/validation.d.ts +64 -0
- package/dist/sdk/utils/validation.d.ts.map +1 -0
- package/dist/sdk/version.d.ts +8 -0
- package/dist/sdk/version.d.ts.map +1 -0
- package/dist/services/dataService.d.ts +10 -0
- package/dist/services/dataService.d.ts.map +1 -0
- package/dist/umd/ui-sdk.js +2 -0
- package/dist/umd/ui-sdk.js.map +1 -0
- package/dist/utils/caseConversion.d.ts +3 -0
- package/dist/utils/caseConversion.d.ts.map +1 -0
- package/package.json +91 -4
|
@@ -0,0 +1,112 @@
|
|
|
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 {};
|
|
112
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +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;IACtD,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CAC7D;AAED;;;GAGG;AACH,UAAU,SAAS;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,CAE7B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GACp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E,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CACxD,CAAC;AAEF;;GAEG;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,42 @@
|
|
|
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';
|
|
9
|
+
export * from './events';
|
|
10
|
+
export * from './theme';
|
|
11
|
+
export * from './module-theme';
|
|
12
|
+
export * from './module-language';
|
|
13
|
+
export type { StateConfig, StateSnapshot } from './state';
|
|
14
|
+
/**
|
|
15
|
+
* Error Event Structure
|
|
16
|
+
* Standard format for error events in messaging system
|
|
17
|
+
*/
|
|
18
|
+
export interface MessagingErrorEvent {
|
|
19
|
+
type: 'messaging:error';
|
|
20
|
+
error: SDKError;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* SDK Error Structure
|
|
25
|
+
* Standardized error format across the SDK
|
|
26
|
+
*/
|
|
27
|
+
export interface SDKError {
|
|
28
|
+
message: string;
|
|
29
|
+
code: string;
|
|
30
|
+
name: string;
|
|
31
|
+
stack?: string;
|
|
32
|
+
details?: unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* HTTP Types
|
|
36
|
+
* Types for HTTP client configuration and responses
|
|
37
|
+
*/
|
|
38
|
+
export type ResponseType = 'json' | 'text' | 'blob';
|
|
39
|
+
export interface RequestConfig extends RequestInit {
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAGrB,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D;;;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,41 @@
|
|
|
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
|
+
}
|
|
41
|
+
//# sourceMappingURL=messaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/messaging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a partner can say about the language of a UI module: the `locale` and `messages` options of a mount call, and
|
|
3
|
+
* `setLanguage(...)` of a mounted module.
|
|
4
|
+
*
|
|
5
|
+
* const fileBrowser = await ui.mount('file-browser', {
|
|
6
|
+
* container,
|
|
7
|
+
* locale: 'de', // plural rules, numbers, file sizes, dates
|
|
8
|
+
* messages: { 'action.cancel': 'Abbrechen', 'upload.clear': 'Leeren' }, // the words; any key left out stays English
|
|
9
|
+
* });
|
|
10
|
+
* fileBrowser.setLanguage({ locale: 'fr', messages: frenchMessages }); // while it is on screen
|
|
11
|
+
*
|
|
12
|
+
* The composition editor takes the same options with ONE `messages` object for everything it shows (its own words, its
|
|
13
|
+
* file picker's and its rich text editor's); the editor splits it between them. The widget creator does the same for
|
|
14
|
+
* the whole creator (its own words, the chat's, the canvas's, the starting-point picker's, and the composition editor's
|
|
15
|
+
* with the file picker and the rich text editor inside it).
|
|
16
|
+
*
|
|
17
|
+
* Only the words the visitor reads are covered: what the module tells the page's code (`error` events, thrown errors,
|
|
18
|
+
* the console) stays English.
|
|
19
|
+
*
|
|
20
|
+
* This file is the single source of these types: the modules (`modules/src/shared/languageTypes.ts`) re-export it, so what
|
|
21
|
+
* the loader accepts and what a module accepts cannot drift apart. It holds types only.
|
|
22
|
+
*/
|
|
23
|
+
/** The language of a module: how numbers, dates and file sizes are written, and the words itself. */
|
|
24
|
+
export interface ModuleLanguage {
|
|
25
|
+
/**
|
|
26
|
+
* A BCP 47 language tag such as `de` or `pt-BR`. It sets the plural rules ("1 file", "2 files", and the extra forms
|
|
27
|
+
* of Polish or Arabic) and how numbers, dates and file sizes are written. It does not translate anything by itself:
|
|
28
|
+
* the words come from `messages`. A tag this browser has no data for is reported in the console and English is used.
|
|
29
|
+
*
|
|
30
|
+
* It is also the `lang` of the module's elements, so a screen reader says the words in that language. The File
|
|
31
|
+
* Browser is read the way the language is written: a language written right to left (Arabic, Hebrew, Persian, Urdu
|
|
32
|
+
* ...) turns the whole screen around, and `setLanguage` turns it around or back while it is on screen. The page's own
|
|
33
|
+
* direction does not decide. The composition editor and the widget creator keep a left to right layout in every
|
|
34
|
+
* language for now.
|
|
35
|
+
*/
|
|
36
|
+
locale?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The words of the module in your language: a message key and its text, like `{ 'action.cancel': 'Abbrechen' }`.
|
|
39
|
+
* `{name}` puts a value in; `{count, plural, one {# file} other {# files}}` picks a form for a number. A key left
|
|
40
|
+
* out keeps its English text. A module lists its keys: the File Browser's are in its README, "Languages", and every
|
|
41
|
+
* module that has words offers them as `defaultMessages`.
|
|
42
|
+
*/
|
|
43
|
+
messages?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=module-language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-language.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/module-language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC3B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a partner can say about the look of a UI module: the `theme` of a mount call, of `new WidgeticUI({ theme })`
|
|
3
|
+
* and of `updateTheme(...)`, and the `theme` option every module takes when it is built without the loader.
|
|
4
|
+
*
|
|
5
|
+
* await ui.mount('file-browser', { container, theme: 'dark' }); // just light or dark
|
|
6
|
+
* await ui.mount('file-browser', { container, theme: { preset: 'ocean' } }); // one of the built-in themes
|
|
7
|
+
* await ui.mount('composition-editor', {
|
|
8
|
+
* container,
|
|
9
|
+
* theme: {
|
|
10
|
+
* preset: 'graphite', // start from a built-in theme ...
|
|
11
|
+
* colors: { primary: '#e0541b', background: '#fffaf5' }, // ... and change what is yours
|
|
12
|
+
* radius: 'large',
|
|
13
|
+
* font: { family: '"Poppins", sans-serif', stylesheetUrl: 'https://fonts.googleapis.com/css2?family=Poppins' },
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* Each module takes its own `theme`, so the modules on one page can look different.
|
|
18
|
+
*
|
|
19
|
+
* This file is the single source of these types: the modules (`modules/src/shared/theme/themeTypes.ts`) re-export it, so
|
|
20
|
+
* what the loader accepts and what a module accepts cannot drift apart. It holds types only.
|
|
21
|
+
*/
|
|
22
|
+
import type { ThemeMode } from './theme';
|
|
23
|
+
/** Light or dark. */
|
|
24
|
+
export type ModuleThemeMode = 'light' | 'dark';
|
|
25
|
+
/** The built-in themes. `widgetic` is the look the modules have when nothing is asked. */
|
|
26
|
+
export type ModuleThemePresetName = 'widgetic' | 'graphite' | 'ocean' | 'violet' | 'sunset';
|
|
27
|
+
/**
|
|
28
|
+
* Colours of a theme. Any CSS colour that is written out (`#0b6bcb`, `rgb(11 107 203)`, `hsl(210 90% 41%)`, `rebeccapurple`,
|
|
29
|
+
* `oklch(0.6 0.15 250)`); `var(--x)` and `currentColor` are not understood. A colour is used opaque: a transparency in it is ignored.
|
|
30
|
+
* Leave a colour out and it follows from the others (a theme with only a `primary` still has readable text on it).
|
|
31
|
+
*/
|
|
32
|
+
export interface ModuleThemeColors {
|
|
33
|
+
/** The brand colour: buttons, selected items, links, the focus ring. */
|
|
34
|
+
primary?: string;
|
|
35
|
+
/** Text and icons on `primary`. Default: white or near-black, whichever reads better. */
|
|
36
|
+
primaryForeground?: string;
|
|
37
|
+
/** The module's own background (its panels, menus and dialogs). */
|
|
38
|
+
background?: string;
|
|
39
|
+
/** Main text and icons. */
|
|
40
|
+
foreground?: string;
|
|
41
|
+
/** Quiet surfaces: a search box, a hovered row, a tab strip. Default: a little of `foreground` over `background`. */
|
|
42
|
+
muted?: string;
|
|
43
|
+
/** Secondary text: captions, placeholders, file sizes. Default: `foreground` over `background`, softened. */
|
|
44
|
+
mutedForeground?: string;
|
|
45
|
+
/** Lines around cards and inputs, and between sections. Default: a little of `foreground` over `background`. */
|
|
46
|
+
border?: string;
|
|
47
|
+
/** A soft highlight: the selected file, a hovered menu entry. Default: a light tint of `primary`. */
|
|
48
|
+
accent?: string;
|
|
49
|
+
/** Errors, warnings about data loss, and delete buttons. */
|
|
50
|
+
destructive?: string;
|
|
51
|
+
}
|
|
52
|
+
/** The typeface of a module. The widgets the visitor builds keep their own fonts. */
|
|
53
|
+
export interface ModuleThemeFont {
|
|
54
|
+
/**
|
|
55
|
+
* A CSS font-family list, like `'"Poppins", system-ui, sans-serif'`. A single name (`'Poppins'`) gets a safe list of
|
|
56
|
+
* fallbacks added behind it. The font has to be available on the page: already loaded by the page, or through `stylesheetUrl`.
|
|
57
|
+
*/
|
|
58
|
+
family: string;
|
|
59
|
+
/**
|
|
60
|
+
* A stylesheet that defines the font, such as a Google Fonts address. The module adds it to the page's `<head>`
|
|
61
|
+
* once (a font can only be defined there, not inside the module). Needs `https:`; your Content-Security-Policy has
|
|
62
|
+
* to allow it. Not needed for a font your page loads itself.
|
|
63
|
+
*/
|
|
64
|
+
stylesheetUrl?: string;
|
|
65
|
+
}
|
|
66
|
+
/** How round the corners are: a word, or the radius in pixels of a normal control. `medium` (8px) is how the modules look by default. */
|
|
67
|
+
export type ModuleThemeRadius = 'none' | 'small' | 'medium' | 'large' | number;
|
|
68
|
+
/** Everything about a look. All of it is optional. */
|
|
69
|
+
export interface ModuleThemeSettings {
|
|
70
|
+
/** The built-in theme to start from. Default `widgetic`. */
|
|
71
|
+
preset?: ModuleThemePresetName;
|
|
72
|
+
/** Light or dark. Default `light`. */
|
|
73
|
+
mode?: ModuleThemeMode;
|
|
74
|
+
/** Your colours, on top of the preset's. */
|
|
75
|
+
colors?: ModuleThemeColors;
|
|
76
|
+
/** Roundness of buttons, cards and inputs. */
|
|
77
|
+
radius?: ModuleThemeRadius;
|
|
78
|
+
/** Your typeface. */
|
|
79
|
+
font?: ModuleThemeFont;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What a module takes as its `theme`: `'light'`, `'dark'`, or the settings. As the argument of a module's `setTheme`, a
|
|
83
|
+
* bare `'light'` or `'dark'` changes only the mode and keeps the rest; settings replace the whole theme.
|
|
84
|
+
*/
|
|
85
|
+
export type ModuleTheme = ModuleThemeMode | ModuleThemeSettings;
|
|
86
|
+
/**
|
|
87
|
+
* What a page may write wherever the loader takes a theme (`new WidgeticUI({ theme })`, `updateTheme`, the `theme` of a
|
|
88
|
+
* mount call): the modules' theme, where the mode may also be `'system'` to follow the visitor's operating system.
|
|
89
|
+
*/
|
|
90
|
+
export type ThemeOption = ThemeMode | (Omit<ModuleThemeSettings, 'mode'> & {
|
|
91
|
+
mode?: ThemeMode;
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=module-theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-theme.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/module-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAqB;AACrB,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAA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AAG,mBAAmB,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Management Types
|
|
3
|
+
* Contains type definitions for component and system state management.
|
|
4
|
+
* Used for tracking component status, errors, and configuration.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Component state configuration
|
|
8
|
+
* Defines state manager settings
|
|
9
|
+
*/
|
|
10
|
+
export interface StateConfig {
|
|
11
|
+
maxSnapshots?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Component state snapshot
|
|
15
|
+
* Point-in-time capture of component state
|
|
16
|
+
*/
|
|
17
|
+
export interface StateSnapshot {
|
|
18
|
+
timestamp: number;
|
|
19
|
+
state: Map<string, any>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Component state interface
|
|
23
|
+
* Current state of a UI component
|
|
24
|
+
*/
|
|
25
|
+
export interface ComponentState {
|
|
26
|
+
status: 'initializing' | 'ready' | 'error';
|
|
27
|
+
error: Error | null;
|
|
28
|
+
data?: Record<string, any>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* State update configuration
|
|
32
|
+
* Options for state updates
|
|
33
|
+
*/
|
|
34
|
+
export interface StateUpdateOptions {
|
|
35
|
+
silent?: boolean;
|
|
36
|
+
snapshot?: boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC;IAC3C,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Type Definitions
|
|
3
|
+
* Contains types for theme configuration and customization.
|
|
4
|
+
* Used for consistent styling across components.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Theme mode options
|
|
8
|
+
* Defines available color schemes
|
|
9
|
+
*/
|
|
10
|
+
export type ThemeMode = 'light' | 'dark' | 'system';
|
|
11
|
+
/**
|
|
12
|
+
* Color scheme configuration
|
|
13
|
+
* Defines customizable colors for components
|
|
14
|
+
*/
|
|
15
|
+
export interface ColorScheme {
|
|
16
|
+
primary: string;
|
|
17
|
+
secondary: string;
|
|
18
|
+
background: string;
|
|
19
|
+
surface: string;
|
|
20
|
+
text: string;
|
|
21
|
+
border: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Spacing configuration
|
|
25
|
+
* Defines consistent spacing units
|
|
26
|
+
*/
|
|
27
|
+
export interface SpacingConfig {
|
|
28
|
+
unit: number;
|
|
29
|
+
scale: number[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Typography configuration
|
|
33
|
+
* Defines font settings and scale
|
|
34
|
+
*/
|
|
35
|
+
export interface TypographyConfig {
|
|
36
|
+
fontFamily: string;
|
|
37
|
+
scale: number[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Complete theme configuration
|
|
41
|
+
* Combines all theme settings
|
|
42
|
+
*/
|
|
43
|
+
export interface ThemeConfig {
|
|
44
|
+
mode: ThemeMode;
|
|
45
|
+
colors: ColorScheme;
|
|
46
|
+
spacing: SpacingConfig;
|
|
47
|
+
typography: TypographyConfig;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Partial theme updates
|
|
51
|
+
* Allows updating specific theme properties
|
|
52
|
+
*/
|
|
53
|
+
export type PartialThemeConfig = Partial<ThemeConfig>;
|
|
54
|
+
/**
|
|
55
|
+
* Partner theme overrides
|
|
56
|
+
* Allows partners to customize specific theme aspects
|
|
57
|
+
*/
|
|
58
|
+
export interface PartnerTheme {
|
|
59
|
+
mode?: ThemeMode;
|
|
60
|
+
colors?: Partial<ColorScheme>;
|
|
61
|
+
spacing?: Partial<SpacingConfig>;
|
|
62
|
+
typography?: Partial<TypographyConfig>;
|
|
63
|
+
}
|
|
64
|
+
export type ThemePreset = {
|
|
65
|
+
readonly mode: ThemeMode;
|
|
66
|
+
readonly colors: Readonly<ColorScheme>;
|
|
67
|
+
readonly spacing: {
|
|
68
|
+
readonly unit: number;
|
|
69
|
+
readonly scale: readonly number[];
|
|
70
|
+
};
|
|
71
|
+
readonly typography: {
|
|
72
|
+
readonly fontFamily: string;
|
|
73
|
+
readonly scale: readonly number[];
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,WAAW;IACx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,CAAC;QAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;KACrC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration Management
|
|
3
|
+
*
|
|
4
|
+
* Holds the SDK's default addresses and the few switches the legacy security helpers read.
|
|
5
|
+
*
|
|
6
|
+
* Nothing in here handles credentials. The SDK never sees an API key: a partner's server mints a short-lived editor
|
|
7
|
+
* session token and the partner's `getToken` function hands it to the SDK (see `WidgeticUI`).
|
|
8
|
+
*/
|
|
9
|
+
/** The Widgetic API every module talks to unless the partner points it somewhere else (staging, local gateway). */
|
|
10
|
+
export declare const DEFAULT_API_URL = "https://api.widgetic.com";
|
|
11
|
+
/** Where the UI modules are served from. Each module lives in a folder named after it: `<base>/<name>/…`. */
|
|
12
|
+
export declare const DEFAULT_MODULE_BASE_URL = "https://cdn.widgetic.com/modules";
|
|
13
|
+
export interface Config {
|
|
14
|
+
CDN_URL: string;
|
|
15
|
+
NODE_ENV: string;
|
|
16
|
+
API_URL: string;
|
|
17
|
+
API_VERSION: string;
|
|
18
|
+
CLIENT_URL: string;
|
|
19
|
+
PRODUCTION_URL: string;
|
|
20
|
+
EMBED_SDK_URL: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Default configuration values.
|
|
24
|
+
*
|
|
25
|
+
* `NODE_ENV` defaults to production: the origin checks in the security helpers are only relaxed when a developer
|
|
26
|
+
* asks for development mode explicitly, never because nobody configured anything.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_CONFIG: Config;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration Manager
|
|
31
|
+
* Singleton class that handles the SDK's configuration values.
|
|
32
|
+
*/
|
|
33
|
+
export declare class ConfigManager {
|
|
34
|
+
private static instance;
|
|
35
|
+
private config;
|
|
36
|
+
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Get singleton instance
|
|
39
|
+
* Creates instance if it doesn't exist
|
|
40
|
+
*/
|
|
41
|
+
static getInstance(): ConfigManager;
|
|
42
|
+
/**
|
|
43
|
+
* Initialize configuration with custom values
|
|
44
|
+
* Merges provided config with defaults
|
|
45
|
+
* @param config - Partial configuration to apply
|
|
46
|
+
*/
|
|
47
|
+
initialize(config: Partial<Config>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get API base URL
|
|
50
|
+
* @returns Configured API URL
|
|
51
|
+
*/
|
|
52
|
+
getApiUrl(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Get CDN base URL
|
|
55
|
+
* @returns Configured CDN URL
|
|
56
|
+
*/
|
|
57
|
+
getCdnUrl(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Check if running in production mode
|
|
60
|
+
*/
|
|
61
|
+
get isProduction(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Validate required configuration
|
|
64
|
+
* Ensures all required values are present
|
|
65
|
+
* @throws Error if required config is missing
|
|
66
|
+
*/
|
|
67
|
+
validateConfig(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare const config: ConfigManager;
|
|
70
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mHAAmH;AACnH,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAE1E,MAAM,WAAW,MAAM;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,MAQ5B,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgB;IACvC,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,WAAW,IAAI,aAAa;IAOnC;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI;IAOzC;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED;;;;OAIG;IACH,cAAc,IAAI,IAAI;CAazB;AAGD,eAAO,MAAM,MAAM,eAA8B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Handling System
|
|
3
|
+
* Provides centralized error handling and standardization.
|
|
4
|
+
* Creates consistent error objects with proper typing and context.
|
|
5
|
+
*/
|
|
6
|
+
import type { SDKError } from '../types';
|
|
7
|
+
export declare class SDKErrorHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Create standardized error object
|
|
10
|
+
* Formats error with message and code for consistent handling
|
|
11
|
+
* @param message - Human readable error message
|
|
12
|
+
* @param code - Error code for programmatic handling
|
|
13
|
+
* @returns Formatted error object
|
|
14
|
+
*/
|
|
15
|
+
static createError(message: string, code: string): Error;
|
|
16
|
+
/**
|
|
17
|
+
* Handle and transform errors
|
|
18
|
+
* Converts various error types to standardized SDK errors
|
|
19
|
+
* @param error - Original error object
|
|
20
|
+
* @param context - Error context for tracking
|
|
21
|
+
* @returns Standardized error object
|
|
22
|
+
*/
|
|
23
|
+
static handleError(error: unknown, context: string): Error;
|
|
24
|
+
/**
|
|
25
|
+
* Convert error to SDK error format
|
|
26
|
+
* Ensures error object matches SDK error interface
|
|
27
|
+
* @param error - Error to convert
|
|
28
|
+
* @returns SDK formatted error
|
|
29
|
+
*/
|
|
30
|
+
static toSDKError(error: Error): SDKError;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validation Error
|
|
34
|
+
* Thrown when input validation fails
|
|
35
|
+
*/
|
|
36
|
+
export declare class ValidationError extends Error {
|
|
37
|
+
field?: string | undefined;
|
|
38
|
+
constructor(message: string, field?: string | undefined);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Security Error
|
|
42
|
+
* Thrown when security checks fail
|
|
43
|
+
*/
|
|
44
|
+
export declare class SecurityError extends Error {
|
|
45
|
+
code?: string | undefined;
|
|
46
|
+
constructor(message: string, code?: string | undefined);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Component Error
|
|
50
|
+
* Thrown when component operations fail
|
|
51
|
+
*/
|
|
52
|
+
export declare class ComponentError extends Error {
|
|
53
|
+
componentId?: string | undefined;
|
|
54
|
+
constructor(message: string, componentId?: string | undefined);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,qBAAa,eAAe;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK;IAMxD;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK;IAqB1D;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ;CAS5C;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACF,KAAK,CAAC,EAAE,MAAM;gBAAtC,OAAO,EAAE,MAAM,EAAS,KAAK,CAAC,EAAE,MAAM,YAAA;CAIrD;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACA,IAAI,CAAC,EAAE,MAAM;gBAArC,OAAO,EAAE,MAAM,EAAS,IAAI,CAAC,EAAE,MAAM,YAAA;CAIpD;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACD,WAAW,CAAC,EAAE,MAAM;gBAA5C,OAAO,EAAE,MAAM,EAAS,WAAW,CAAC,EAAE,MAAM,YAAA;CAI3D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP helpers
|
|
3
|
+
*
|
|
4
|
+
* Small request/response helpers. The SDK itself makes no authenticated API calls: the UI modules talk to the
|
|
5
|
+
* Widgetic API with the editor session token the partner's `getToken` returns. A browser-side HTTP client that
|
|
6
|
+
* attached an API key to requests used to live here; it was removed so an API key can never end up in a browser.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a secure HTTP request
|
|
10
|
+
* @param url - Request URL
|
|
11
|
+
* @param options - Request options
|
|
12
|
+
* @returns Configured request
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSecureRequest(url: string, options?: RequestInit): Request;
|
|
15
|
+
/**
|
|
16
|
+
* Validate HTTP response
|
|
17
|
+
* @param response - Response to validate
|
|
18
|
+
* @returns True if response is valid
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateResponse(response: Response): boolean;
|
|
21
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/http.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAWnF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAa5D"}
|