@botonic/webviews 2.26.0 → 2.28.0
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 +23 -0
- package/index.css +1 -1
- package/index.js +16931 -5859
- package/lib/context/botonic-context-webviews.d.ts +70 -0
- package/lib/context/factory.d.ts +17 -0
- package/lib/context/index.d.ts +2 -0
- package/lib/hooks/use-botonic-context-webviews.d.ts +4 -0
- package/lib/hooks/use-webview-close.d.ts +2 -1
- package/lib/hooks/use-webview-contents/hook.d.ts +4 -2
- package/lib/index.d.ts +2 -1
- package/lib/webview-context.d.ts +2 -1
- package/package.json +5 -4
- package/lib/hooks/use-bot-session.d.ts +0 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { MessagingChannel, BotonicWebviewsSessionChannel, BotonicWebviewsSessionUser } from '../../../../shared/src/index.ts';
|
|
2
|
+
export declare class BotonicContextWebviewsChannel {
|
|
3
|
+
private readonly channel;
|
|
4
|
+
constructor(channel: BotonicWebviewsSessionChannel);
|
|
5
|
+
get provider(): MessagingChannel;
|
|
6
|
+
get impId(): string;
|
|
7
|
+
get unformattedPhoneNumber(): string;
|
|
8
|
+
}
|
|
9
|
+
export declare class BotonicContextWebviewsUser {
|
|
10
|
+
private readonly user;
|
|
11
|
+
constructor(user: {
|
|
12
|
+
id: string;
|
|
13
|
+
locale: string;
|
|
14
|
+
country: string;
|
|
15
|
+
system_locale: string;
|
|
16
|
+
});
|
|
17
|
+
get id(): string;
|
|
18
|
+
get locale(): string;
|
|
19
|
+
get country(): string;
|
|
20
|
+
get systemLocale(): string;
|
|
21
|
+
}
|
|
22
|
+
export declare class BotonicContextWebviewsSettings {
|
|
23
|
+
private readonly settings;
|
|
24
|
+
constructor(settings: {
|
|
25
|
+
HUBTYPE_API_URL: string;
|
|
26
|
+
});
|
|
27
|
+
get hubtypeApiUrl(): string;
|
|
28
|
+
}
|
|
29
|
+
export declare class BotonicContextWebviewsBot {
|
|
30
|
+
private readonly bot;
|
|
31
|
+
constructor(bot: {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
});
|
|
35
|
+
get id(): string;
|
|
36
|
+
get name(): string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Nested session slice with channel/user wrappers (same idea as {@link BotonicContextSession} on the server).
|
|
40
|
+
*/
|
|
41
|
+
export declare class BotonicContextWebviewsSession {
|
|
42
|
+
private readonly sessionPayload;
|
|
43
|
+
constructor(sessionPayload: {
|
|
44
|
+
channel: BotonicWebviewsSessionChannel;
|
|
45
|
+
user: BotonicWebviewsSessionUser;
|
|
46
|
+
});
|
|
47
|
+
get channel(): BotonicContextWebviewsChannel;
|
|
48
|
+
get user(): BotonicContextWebviewsUser;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Normalized webviews context: `session` groups API `channel` + `user` (set by the factory).
|
|
52
|
+
* Optional `settings` is not returned by GET webviews — pass when building from app config / URL (e.g. hubtype API URL).
|
|
53
|
+
*/
|
|
54
|
+
export interface BotonicContextWebviewsType {
|
|
55
|
+
custom: Record<string, any>;
|
|
56
|
+
bot: BotonicContextWebviewsBot;
|
|
57
|
+
session: BotonicContextWebviewsSession;
|
|
58
|
+
settings?: BotonicContextWebviewsSettings;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Hydrated webviews context (like {@link BotonicContext}): factory output plus optional injected settings.
|
|
62
|
+
*/
|
|
63
|
+
export declare class BotonicContextWebviews implements BotonicContextWebviewsType {
|
|
64
|
+
readonly custom: Record<string, any>;
|
|
65
|
+
readonly bot: BotonicContextWebviewsBot;
|
|
66
|
+
readonly session: BotonicContextWebviewsSession;
|
|
67
|
+
readonly settings?: BotonicContextWebviewsSettings;
|
|
68
|
+
constructor(base: BotonicContextWebviewsType);
|
|
69
|
+
get hubtypeApiUrl(): string;
|
|
70
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BotonicWebviewsSessionBot, BotonicWebviewsSessionChannel, BotonicWebviewsSessionUser } from '../../../../shared/src/index.ts';
|
|
2
|
+
import { BotonicContextWebviews } from './botonic-context-webviews';
|
|
3
|
+
interface BotonicContextWebviewsFactoryParams {
|
|
4
|
+
custom: Record<string, unknown>;
|
|
5
|
+
channel: BotonicWebviewsSessionChannel;
|
|
6
|
+
user: BotonicWebviewsSessionUser;
|
|
7
|
+
bot: BotonicWebviewsSessionBot;
|
|
8
|
+
hubtypeApiUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class BotonicContextWebviewsFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Maps flat GET webviews JSON (`custom`, `channel`, `user`) into a context shape where
|
|
13
|
+
* `channel` and `user` are grouped under `session` (see {@link BotonicContextFactory.from}).
|
|
14
|
+
*/
|
|
15
|
+
static from(params: BotonicContextWebviewsFactoryParams): BotonicContextWebviews;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { BotonicContextWebviews } from '../context';
|
|
1
2
|
export interface CloseWebviewOptions {
|
|
2
3
|
payload?: any;
|
|
3
4
|
path?: string;
|
|
4
5
|
params?: Record<string, string>;
|
|
5
6
|
}
|
|
6
|
-
export declare function useWebviewClose(
|
|
7
|
+
export declare function useWebviewClose(botonicContextWebviews?: BotonicContextWebviews): (options?: CloseWebviewOptions) => Promise<void>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { BotonicContextWebviews } from '../../context';
|
|
1
2
|
import { MapContentsType, UseWebviewContents } from './types';
|
|
2
3
|
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
3
|
-
|
|
4
|
+
/** Undefined until `useBotonicContextWebviews` finishes loading the GET webviews session. */
|
|
5
|
+
botonicContextWebviews?: BotonicContextWebviews;
|
|
4
6
|
params: Record<string, string>;
|
|
5
7
|
version?: 'draft' | 'latest' | string;
|
|
6
8
|
mapContents: Record<keyof T, string>;
|
|
7
9
|
}
|
|
8
|
-
export declare function useWebviewContents<T extends MapContentsType>({
|
|
10
|
+
export declare function useWebviewContents<T extends MapContentsType>({ botonicContextWebviews, params, version, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export * from './context';
|
|
1
2
|
export * from './components';
|
|
2
|
-
export * from './hooks/use-
|
|
3
|
+
export * from './hooks/use-botonic-context-webviews';
|
|
3
4
|
export * from './hooks/use-webview-close';
|
|
4
5
|
export * from './hooks/use-webview-contents';
|
|
5
6
|
export * from './webview-context';
|
package/lib/webview-context.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { BotonicContextWebviews } from './context';
|
|
1
2
|
import { ConfirmCloseOption } from '../../../webchat-core/src/index.ts';
|
|
2
3
|
import { CloseWebviewOptions } from './hooks/use-webview-close';
|
|
3
4
|
import { WebviewDefinition } from './webviews';
|
|
4
5
|
export interface WebviewContextType {
|
|
5
|
-
|
|
6
|
+
botonicContextWebviews?: BotonicContextWebviews;
|
|
6
7
|
params: Record<string, string>;
|
|
7
8
|
closeWebview: (options?: CloseWebviewOptions) => Promise<void>;
|
|
8
9
|
setWebviewTitle: (title: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/webviews",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@botonic/core": "2.
|
|
16
|
-
"@botonic/
|
|
17
|
-
"@
|
|
15
|
+
"@botonic/core": "2.28.0",
|
|
16
|
+
"@botonic/shared": "2.28.0",
|
|
17
|
+
"@botonic/webchat-core": "2.28.0",
|
|
18
|
+
"@lilara/foundations": ">=0.7.0",
|
|
18
19
|
"class-variance-authority": "^0.7.0",
|
|
19
20
|
"react": "18.3.1"
|
|
20
21
|
},
|