@useknest/widget-core 0.1.0-beta.6 → 0.1.0-beta.7
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/dist/config.d.ts +10 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +532 -482
- package/dist/sentry.d.ts +3 -0
- package/dist/sentry.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -6,9 +6,18 @@ export interface ConfigResult {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Fetches widget configuration from the API.
|
|
9
|
+
* Uses localStorage caching to speed up subsequent loads.
|
|
10
|
+
*
|
|
11
|
+
* Caching strategy:
|
|
12
|
+
* - On first load: fetches from API, caches result
|
|
13
|
+
* - On subsequent loads (within TTL): returns cached config immediately,
|
|
14
|
+
* then refreshes in background to pick up any config changes
|
|
15
|
+
* - Cache includes updatedAt timestamp for staleness detection
|
|
16
|
+
*
|
|
9
17
|
* @param publishableApiKey - The API key for authentication
|
|
10
18
|
* @param baseUrl - Base URL for the API. Defaults to https://useknest.com. Pass empty string for relative paths.
|
|
19
|
+
* @param onConfigUpdate - Optional callback when config is updated in background
|
|
11
20
|
* @returns ConfigResult with config data or error type
|
|
12
21
|
*/
|
|
13
|
-
export declare function fetchWidgetConfig(publishableApiKey: string, baseUrl?: string): Promise<ConfigResult>;
|
|
22
|
+
export declare function fetchWidgetConfig(publishableApiKey: string, baseUrl?: string, onConfigUpdate?: (config: WidgetConfig) => void): Promise<ConfigResult>;
|
|
14
23
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAExD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,eAAe,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAExD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,eAAe,CAAC;CACvB;AAgGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACtC,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAC7C,OAAO,CAAC,YAAY,CAAC,CAkBvB"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const DEFAULT_BASE_URL = "https://useknest.com";
|
|
2
2
|
export declare const API_PATH = "/api/v1";
|
|
3
|
+
export declare const PUBLIC_SUPABASE_URL = "https://lghrsugmhzpccpriqhrx.supabase.co";
|
|
4
|
+
export declare const PUBLIC_SUPABASE_ANON_KEY = "sb_publishable_-KUwilDA78QM849gk662FA_kEzMezNS";
|
|
3
5
|
/** Builds the chat messages API URL from a base URL. */
|
|
4
6
|
export declare function getChatApiUrl(baseUrl?: string): string;
|
|
5
7
|
/** Builds the widget config API URL from a base URL. */
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,QAAQ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,QAAQ,YAAY,CAAC;AAIlC,eAAO,MAAM,mBAAmB,6CAA6C,CAAC;AAC9E,eAAO,MAAM,wBAAwB,mDAAmD,CAAC;AAEzF,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAExE;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAE1E;AAED,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,iGACgE,CAAC;AAChG,eAAO,MAAM,kBAAkB,4CAA4C,CAAC;AAC5E,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,uBAAuB,mHAC6E,CAAC;AAClH,eAAO,MAAM,yBAAyB,UAIrC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { WidgetMode, MessageRole, Source, Message, ChatMessageRequest, ChatMessageResponse, ChatApiError, WidgetConfig, SSEEvent } from './types';
|
|
2
|
-
export { DEFAULT_BASE_URL, API_PATH, getChatApiUrl, getConfigApiUrl, FALLBACK_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, AUTH_ERROR_MESSAGE, DEFAULT_AVATAR_URL, DEFAULT_BRAND_COLOR, DEFAULT_WELCOME_MESSAGE, DEFAULT_EXAMPLE_QUESTIONS } from './constants';
|
|
2
|
+
export { DEFAULT_BASE_URL, API_PATH, getChatApiUrl, getConfigApiUrl, FALLBACK_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, AUTH_ERROR_MESSAGE, DEFAULT_AVATAR_URL, DEFAULT_BRAND_COLOR, DEFAULT_WELCOME_MESSAGE, DEFAULT_EXAMPLE_QUESTIONS, PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from './constants';
|
|
3
3
|
export { fetchWidgetConfig } from './config';
|
|
4
4
|
export type { ConfigResult, ConfigErrorType } from './config';
|
|
5
5
|
export { streamChatMessage } from './streaming';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,UAAU,EACV,WAAW,EACX,MAAM,EACN,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAG5F,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.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