-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgossipstack.d.ts
More file actions
273 lines (240 loc) · 8.05 KB
/
Copy pathgossipstack.d.ts
File metadata and controls
273 lines (240 loc) · 8.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*!
*
* gossipstack.d.ts
* GossipStack
*
* version 1.0.4
*
* Created by Honmono Studio SAS on 16-07-2026
* Copyright © 2026 Honmono Studio SAS. All rights reserved.
*
* https://gossipstack.com
*
* This software and its source code (including any obfuscated, minified,
* or compiled form) are the proprietary property of
* Honmono Studio SAS.
*
* Use of this software is governed by the GossipStack Terms of Service
* available at https://gossipstack.com/terms.
*
* Unauthorized copying, modification, reverse engineering, decompilation,
* disassembly, redistribution, sublicensing, or commercial use of this
* software, in whole or in part, by any means and in any form, is strictly
* prohibited without the prior express written permission of Honmono Studio SAS.
*
* The publication of this software at a publicly accessible URL for the
* purpose of distribution to authorized licensees does not constitute a
* waiver of any intellectual property rights, nor does it grant any license
* or right of use beyond those expressly set forth in the agreements
* referenced above.
*/
/**
* Attributes available on the <gossipstack-app> custom element.
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#full-page-example Web SDK guide} for details.
*
* @example
* <gossipstack-app
* app-id="__APP_ID__"
* project-id="__PROJECT_ID__"
* page-id="__PAGE_ID__"
* theme="auto"
* language="en"
* sso-user="__BASE64_USER_DATA__"
* sso-hash="__HMAC_SIGNATURE__">
* </gossipstack-app>
*/
export interface GossipStackAppElement extends HTMLElement {
/** Your GossipStack application identifier */
'app-id': string;
/** The project identifier (required when not using initialize()) */
'project-id'?: string;
/** Unique identifier scoping this comment section to a page or resource */
'page-id': string;
/** UI color theme */
'theme'?: 'light' | 'dark' | 'auto';
/** BCP 47 language code (e.g. 'en', 'fr', 'de') */
'language'?: string;
/** Logging verbosity */
'log-level'?: 'debug' | 'info' | 'warn' | 'error';
/** Toolbar features to enable */
'toolbar'?: string;
/** Base64-encoded SSO user payload (server-generated) */
'sso-user'?: string;
/** HMAC signature of the SSO user payload (server-generated) */
'sso-hash'?: string;
}
declare global {
interface HTMLElementTagNameMap {
'gossipstack-app': GossipStackAppElement;
}
}
// ---------------------------------------------------------------------------
// initialize() config
// ---------------------------------------------------------------------------
export interface GossipStackConfig {
/**
* Your GossipStack project identifier
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#initialization-options Web SDK guide} for details.
* */
project_id: string;
/**
* UI color theme. Defaults to 'auto'
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#initialization-options Web SDK guide} for details.
* */
theme?: 'light' | 'dark' | 'auto';
/**
* BCP 47 language code (e.g. 'en', 'fr', 'de'). Defaults to 'en'
*
* See the {@link https://docs.gossipstack.com/echo-localization Web SDK guide} for details.
* */
language?: string;
/**
* Toolbar features to enable
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#initialization-options Web SDK guide} for details.
* */
toolbar?: Array<'media' | 'mention' | 'hashtag'>;
/**
* When true, toast notifications are suppressed and forwarded to your
* own handler via the toastEvent hook instead.
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#handling-toast-notifications Web SDK guide} for details.
*/
handle_toasts_manually?: boolean;
/**
* Logging verbosity. Defaults to 'warn'
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#logging-values Web SDK guide} for details.
* */
logLevel?: 'debug' | 'info' | 'warn' | 'error';
/**
* Base64-encoded SSO user payload — must be generated server-side
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#adding-sso-authentication Web SDK guide} for details.
* */
sso_user?: string;
/**
* HMAC signature of the SSO payload — must be generated server-side
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#adding-sso-authentication Web SDK guide} for details.
* */
sso_hash?: string;
}
// ---------------------------------------------------------------------------
// Hook payloads
// ---------------------------------------------------------------------------
export interface MentionSuggestion {
id: number;
/** Value inserted into the editor on selection */
value: string;
username: string;
avatar?: string;
email?: string;
}
export interface HashtagSuggestion {
id: number;
/** Value inserted into the editor on selection (without #) */
value: string;
/** Display label including the # symbol */
hashtag: string;
/** Human-readable reach count e.g. '2.3M' */
reach?: string;
}
export interface ToastEvent {
type: 'success' | 'error' | 'info' | 'warning';
message: string;
[key: string]: unknown;
}
export interface AvatarClickEvent {
userId: number;
username: string;
[key: string]: unknown;
}
export interface TextClickEvent {
type: 'mention' | 'hashtag' | 'link';
value: string;
[key: string]: unknown;
}
export interface CssLoadedEvent {
[key: string]: unknown;
}
export interface UnauthenticatedActionEvent {
action: string;
[key: string]: unknown;
}
// ---------------------------------------------------------------------------
// Hook registry
// ---------------------------------------------------------------------------
export type HookName =
| 'mention-suggestions'
| 'hashtag-suggestions'
| 'toast-event'
| 'on-avatar-click-event'
| 'text-click-event'
| 'on-css-loaded'
| 'on-unauthenticated-action';
export type HookFunction<T = unknown, R = unknown> = (payload: T) => R | Promise<R>;
// ---------------------------------------------------------------------------
// Action types
// ---------------------------------------------------------------------------
export type ObjectType = 'comment' | 'thread' | 'user';
export type ActionType = 'like' | 'dislike' | 'share' | string;
// ---------------------------------------------------------------------------
// GossipStackSDK
// ---------------------------------------------------------------------------
/**
* GossipStack SDK — Drop-in social feature SDKs for web and mobile apps.
*
* Singleton class. Do not instantiate directly.
* Use the static methods as your public API.
*
* See the {@link https://docs.gossipstack.com/echo-installation-web#adding-sso-authentication Web SDK guide} for details.
*
* @example
*
* GossipStackSDK.initialize({
* project_id: '__PROJECT_ID__',
* theme: 'light',
* language: 'en',
* sso_hash: "__HMAC_SIGNATURE__",
* sso_user: "__BASE64_USER_DATA__"
* })
*/
declare class GossipStackSDK {
/** Current SDK version */
static readonly version: string;
/**
* Initialize the SDK. Must be called once before any other interaction
* when using the programmatic integration pattern.
*
* @param config - SDK configuration object
*/
static initialize(config: GossipStackConfig): Promise<void>;
/**
* Returns true when the SDK is fully initialized and ready.
*/
static isReady(): boolean;
/**
* Register a hook function for a given lifecycle event.
*
* @param hookName - The event to hook into
* @param func - Your handler function
* @param pluginName - Optional label to identify your hook in logs
*
* See {@link https://docs.gossipstack.com/echo-installation-web#sdk-hook-events} for all available options.
*/
static addHook<T = unknown, R = unknown>(
hookName: HookName,
func: HookFunction<T, R>,
pluginName?: string
): void;
}
export default GossipStackSDK;
declare global {
interface Window {
GossipStackSDK: typeof GossipStackSDK;
}
}