@botonic/webviews 2.27.0 → 2.29.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.
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ export * from './botonic-context-webviews';
2
+ export * from './factory';
@@ -1,3 +1,4 @@
1
+ import { BotonicContextWebviews } from '../context';
1
2
  export declare const useBotonicContextWebviews: () => {
2
- botonicContextWebviews: any;
3
+ botonicContextWebviews: BotonicContextWebviews | undefined;
3
4
  };
@@ -1,4 +1,4 @@
1
- import { BotonicContextWebviews } from '../../../../shared/src/index.ts';
1
+ import { BotonicContextWebviews } from '../context';
2
2
  export interface CloseWebviewOptions {
3
3
  payload?: any;
4
4
  path?: string;
@@ -1,4 +1,4 @@
1
- import { BotonicContextWebviews } from '../../../../../shared/src/index.ts';
1
+ import { BotonicContextWebviews } from '../../context';
2
2
  import { MapContentsType, UseWebviewContents } from './types';
3
3
  export interface UseWebviewContentsProps<T extends MapContentsType> {
4
4
  /** Undefined until `useBotonicContextWebviews` finishes loading the GET webviews session. */
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './components';
2
+ export * from './context';
2
3
  export * from './hooks/use-botonic-context-webviews';
3
4
  export * from './hooks/use-webview-close';
4
5
  export * from './hooks/use-webview-contents';
@@ -1,5 +1,5 @@
1
- import { BotonicContextWebviews } from '../../../shared/src/index.ts';
2
1
  import { ConfirmCloseOption } from '../../../webchat-core/src/index.ts';
2
+ import { BotonicContextWebviews } from './context';
3
3
  import { CloseWebviewOptions } from './hooks/use-webview-close';
4
4
  import { WebviewDefinition } from './webviews';
5
5
  export interface WebviewContextType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/webviews",
3
- "version": "2.27.0",
3
+ "version": "2.29.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/shared": "2.27.0",
16
- "@botonic/webchat-core": "2.27.0",
17
- "@lilara/foundations": ">=0.6.0",
15
+ "@botonic/core": "2.29.0",
16
+ "@botonic/shared": "2.29.0",
17
+ "@botonic/webchat-core": "2.29.0",
18
+ "@lilara/foundations": ">=0.8.0",
18
19
  "class-variance-authority": "^0.7.0",
19
20
  "react": "18.3.1"
20
21
  },