@returningai/widget-sdk 1.8.3 → 1.8.5

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.
@@ -6,7 +6,24 @@ export interface BundleMountUnmountHandle {
6
6
  unmount: () => void;
7
7
  }
8
8
  export type BundleMountReadiness = "deep-ready" | "first-paint";
9
- export declare function resolveBundleMountResult(mountResult: unknown, timeoutMs?: number): Promise<unknown>;
9
+ export type BundleReadinessPhase = "mount" | "deep-ready";
10
+ export interface BundleReadinessEnvironment {
11
+ isHidden: () => boolean;
12
+ now: () => number;
13
+ setTimeout: (callback: () => void, delayMs: number) => unknown;
14
+ clearTimeout: (timerId: unknown) => void;
15
+ addVisibilityChangeListener: (listener: () => void) => void;
16
+ removeVisibilityChangeListener: (listener: () => void) => void;
17
+ addPageShowListener: (listener: () => void) => void;
18
+ removePageShowListener: (listener: () => void) => void;
19
+ }
20
+ export declare class BundleReadinessTimeoutError extends Error {
21
+ readonly phase: BundleReadinessPhase;
22
+ constructor(phase: BundleReadinessPhase, message: string);
23
+ }
24
+ export declare function isBundleReadinessTimeoutError(error: unknown): error is BundleReadinessTimeoutError;
25
+ export declare function scheduleForegroundRecovery(recover: () => void, environment?: BundleReadinessEnvironment): () => void;
26
+ export declare function resolveBundleMountResult(mountResult: unknown, timeoutMs?: number, environment?: BundleReadinessEnvironment): Promise<unknown>;
10
27
  export declare function createBundleMountCleanup(mountResult: unknown): (() => void) | undefined;
11
28
  /**
12
29
  * Wait for the strongest readiness signal a bundle provides.
@@ -17,4 +34,4 @@ export declare function createBundleMountCleanup(mountResult: unknown): (() => v
17
34
  * to an object with a `ready` promise. Legacy bundles keep the first-paint
18
35
  * behavior unchanged.
19
36
  */
20
- export declare function waitForBundleMountReadiness(mountResult: unknown, firstPaint: PromiseLike<void>, timeoutMs?: number): Promise<BundleMountReadiness>;
37
+ export declare function waitForBundleMountReadiness(mountResult: unknown, firstPaint: PromiseLike<void>, timeoutMs?: number, environment?: BundleReadinessEnvironment): Promise<BundleMountReadiness>;
@@ -0,0 +1,15 @@
1
+ import type { WidgetState } from "../types";
2
+ export type WidgetFailureKind = "authentication" | "bundle";
3
+ export interface WidgetErrorPresentationInput {
4
+ failureKind: WidgetFailureKind;
5
+ customMessage?: string | null;
6
+ lastAuthError: WidgetState["lastAuthError"];
7
+ }
8
+ export interface WidgetErrorPresentation {
9
+ useCustomMessage: boolean;
10
+ displayMessage: string;
11
+ emittedMessage: string;
12
+ hint?: string;
13
+ status?: number;
14
+ }
15
+ export declare function selectWidgetErrorPresentation({ failureKind, customMessage, lastAuthError, }: WidgetErrorPresentationInput): WidgetErrorPresentation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@returningai/widget-sdk",
3
- "version": "1.8.3",
3
+ "version": "1.8.5",
4
4
  "description": "Shadow DOM isolated widget SDK for ReturningAI",
5
5
  "main": "dist/rai-widget.iife.js",
6
6
  "module": "dist/rai-widget.js",
@@ -25,7 +25,7 @@
25
25
  "build:all": "npm run build && npm run build:banner",
26
26
  "build:all:min": "npm run build:min && npm run build:banner:min",
27
27
  "types": "tsc --emitDeclarationOnly --outDir dist/types && cp src/jsx.d.ts dist/types/jsx.d.ts",
28
- "test": "npm run test:host-callback && npm run test:bundle-readiness && npm run test:bundle-runtime-cache && npm run test:bundle-token-sync && npm run test:auth-bootstrap && npm run test:auth-error-reporting && npm run test:auth-refresh-state && npm run test:startup-performance && npm run test:jsx-types",
28
+ "test": "npm run test:host-callback && npm run test:bundle-readiness && npm run test:bundle-runtime-cache && npm run test:bundle-token-sync && npm run test:auth-bootstrap && npm run test:auth-error-reporting && npm run test:auth-refresh-state && npm run test:auth-session-coordinator && npm run test:startup-performance && npm run test:widget-error-presentation && npm run test:jsx-types",
29
29
  "test:host-callback": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/postmessage-host-callback.test.js",
30
30
  "test:bundle-readiness": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-readiness.test.js",
31
31
  "test:bundle-runtime-cache": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-runtime-cache.test.js",
@@ -33,7 +33,9 @@
33
33
  "test:auth-bootstrap": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-bootstrap.test.js",
34
34
  "test:auth-error-reporting": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-error-reporting.test.js",
35
35
  "test:auth-refresh-state": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-refresh-state.test.js",
36
+ "test:auth-session-coordinator": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-session-coordinator.test.js",
36
37
  "test:startup-performance": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/startup-performance.test.js",
38
+ "test:widget-error-presentation": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/widget-error-presentation.test.js",
37
39
  "test:jsx-types": "tsc --noEmit --strict --lib ES2020,DOM --skipLibCheck false src/jsx.d.ts",
38
40
  "coverage:repowise": "rm -rf coverage && npm run coverage:host-callback && npm run coverage:bundle-readiness && npm run test:jsx-types",
39
41
  "coverage:host-callback": "rm -rf test/.tmp && tsc -p test/tsconfig.json && c8 --reporter=lcov --reports-dir=coverage/host-callback --exclude-after-remap --exclude='**/*.test.ts' node test/.tmp/test/postmessage-host-callback.test.js && node scripts/name-lcov-test.mjs coverage/host-callback/lcov.info test/postmessage-host-callback.test.ts",