@momentco-ai/moment-sdk 0.9.0-dev.48 → 0.9.0-dev.49
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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/dist/moment-sdk.js +4 -4
- package/dist/moment-sdk.mjs +350 -218
- package/dist/types/sdk/__tests__/feedback-layer.test.d.ts +1 -0
- package/dist/types/sdk/feedback-layer.d.ts +21 -0
- package/dist/types/sdk/moment-sdk.d.ts +4 -0
- package/dist/types/sdk/types.d.ts +30 -4
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confetti and toasts the embed asks for (`moment.embed.celebrate`, `moment.embed.toast`), drawn
|
|
3
|
+
* over the host page instead of clipped inside the iframe. They sit on one click-through layer in
|
|
4
|
+
* the overlay, after the sheet: inside it, the frame's `overflow: hidden` would clip them.
|
|
5
|
+
*/
|
|
6
|
+
import type { MomentToastVariant } from './types';
|
|
7
|
+
/** What the SDK can draw over the page while the sheet is open. */
|
|
8
|
+
export interface FeedbackLayer {
|
|
9
|
+
/** A confetti burst up from the sheet's top edge once it settles; none under reduced motion. */
|
|
10
|
+
celebrate(): void;
|
|
11
|
+
/** Show a toast for 4 s, replacing the current one. `text` is drawn as text, never HTML. */
|
|
12
|
+
toast(text: string, variant?: MomentToastVariant): void;
|
|
13
|
+
/** Remove the layer, its announcer and any pending toast or confetti timer. */
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Add the feedback layer to the overlay, after `wrapper` (the sheet). Toasts are announced by a
|
|
18
|
+
* status region inside the sheet's dialog, since an `aria-modal` dialog hides the rest of the page,
|
|
19
|
+
* this layer included, from screen readers.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createFeedbackLayer(overlay: HTMLElement, wrapper: HTMLElement): FeedbackLayer;
|
|
@@ -33,6 +33,10 @@ export declare class MomentSdk {
|
|
|
33
33
|
private footer;
|
|
34
34
|
private hairline;
|
|
35
35
|
private viewportResizeHandler;
|
|
36
|
+
/** Confetti and toasts over the page, for the open sheet. */
|
|
37
|
+
private feedback;
|
|
38
|
+
/** Set by a `keepOpen` (not `schedule`) result, which reports the close, so the sheet's close doesn't. */
|
|
39
|
+
private closeReported;
|
|
36
40
|
constructor(options: MomentSdkInitOptions);
|
|
37
41
|
/**
|
|
38
42
|
* Programmatically open the sync modal.
|
|
@@ -30,7 +30,9 @@ export interface MomentSdkInitOptions {
|
|
|
30
30
|
onError?: (payload: MomentResultPayload) => void;
|
|
31
31
|
/**
|
|
32
32
|
* Called when a sync finishes (success, partial or error) and when the modal is dismissed
|
|
33
|
-
* (`cancelled`). For `schedule`
|
|
33
|
+
* (`cancelled`). For a `schedule` result both happen, in that order. Any other `keepOpen` result
|
|
34
|
+
* reports the close itself, so dismissing its sheet afterwards doesn't call this again (0.9.0+;
|
|
35
|
+
* 0.8.0 called it again with `cancelled`).
|
|
34
36
|
*/
|
|
35
37
|
onClose?: (payload: MomentResultPayload) => void;
|
|
36
38
|
/** Optional analytics callback for tracking embed events. */
|
|
@@ -167,8 +169,10 @@ export interface MomentResultPayload {
|
|
|
167
169
|
message?: string;
|
|
168
170
|
/**
|
|
169
171
|
* Set by an embed that shows its own confirmation. The SDK fires the callbacks as usual but
|
|
170
|
-
* skips the auto-close
|
|
171
|
-
* 0.8.0
|
|
172
|
+
* skips the auto-close: the sheet stays open until the fan closes it (`moment.embed.close` or a
|
|
173
|
+
* dismiss). That close fires no second `onClose` or `embed.close` (0.9.0+; 0.8.0 fired `onClose`
|
|
174
|
+
* again with `cancelled`), except after a `schedule` result, which still reports the dismissal.
|
|
175
|
+
* SDKs before 0.8.0 ignore it.
|
|
172
176
|
*/
|
|
173
177
|
keepOpen?: boolean;
|
|
174
178
|
}
|
|
@@ -230,6 +234,28 @@ export interface MomentThemePayload {
|
|
|
230
234
|
*/
|
|
231
235
|
design?: 'v1' | 'v2';
|
|
232
236
|
}
|
|
237
|
+
/** A toast's look. `success` is Roman's default toast; an absent or unknown variant gets it too. */
|
|
238
|
+
export type MomentToastVariant = 'success' | 'info' | 'warning' | 'error';
|
|
239
|
+
/**
|
|
240
|
+
* Iframe → Parent (0.9.0+): one confetti burst over the page, launched up from the sheet's top
|
|
241
|
+
* edge and faded out before the top of the screen. Skipped when the visitor prefers reduced
|
|
242
|
+
* motion. Older SDKs ignore it, so the embed draws its own for them.
|
|
243
|
+
*/
|
|
244
|
+
export interface MomentCelebratePayload {
|
|
245
|
+
source: 'moment-live-embed';
|
|
246
|
+
type: 'moment.embed.celebrate';
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Iframe → Parent (0.9.0+): a toast 56px below the top of the page for 4 s, replacing any current
|
|
250
|
+
* one, and announced inside the dialog. `text` is drawn as text, never HTML; a toast without text
|
|
251
|
+
* is ignored. Older SDKs ignore it, so the embed shows its own for them.
|
|
252
|
+
*/
|
|
253
|
+
export interface MomentToastPayload {
|
|
254
|
+
source: 'moment-live-embed';
|
|
255
|
+
type: 'moment.embed.toast';
|
|
256
|
+
variant?: MomentToastVariant;
|
|
257
|
+
text: string;
|
|
258
|
+
}
|
|
233
259
|
export type MomentAnalyticsEventName = 'embed.init' | 'embed.trigger.click' | 'embed.open' | 'oauth.start' | 'oauth.popup.blocked' | 'oauth.popup.closed' | 'open.url.blocked' | 'subscribe.success' | 'subscribe.error' | 'embed.close';
|
|
234
260
|
export interface MomentAnalyticsEvent {
|
|
235
261
|
event: MomentAnalyticsEventName;
|
|
@@ -241,4 +267,4 @@ export interface MomentAnalyticsEvent {
|
|
|
241
267
|
triggerSource?: 'url';
|
|
242
268
|
timestamp: number;
|
|
243
269
|
}
|
|
244
|
-
export type MomentPostMessage = MomentOAuthStartPayload | MomentOAuthStatusPayload | MomentResultPayload | MomentOpenUrlPayload | MomentOpenUrlStatusPayload | MomentClosePayload | MomentThemePayload;
|
|
270
|
+
export type MomentPostMessage = MomentOAuthStartPayload | MomentOAuthStatusPayload | MomentResultPayload | MomentOpenUrlPayload | MomentOpenUrlStatusPayload | MomentClosePayload | MomentThemePayload | MomentCelebratePayload | MomentToastPayload;
|
package/package.json
CHANGED