@asgard-js/react 0.0.13 → 0.0.15

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.
@@ -1,2 +1,3 @@
1
1
  export * from './chatbot/chatbot';
2
+ export * from './templates';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
@@ -2,6 +2,7 @@ import { AsgardServiceClient, Conversation, ConversationMessage, FetchSsePayload
2
2
 
3
3
  interface UseChannelProps {
4
4
  defaultIsOpen?: boolean;
5
+ resetPayload?: Pick<FetchSsePayload, 'text' | 'payload'>;
5
6
  client: AsgardServiceClient | null;
6
7
  customChannelId: string;
7
8
  customMessageId?: string;
@@ -13,7 +14,7 @@ export interface UseChannelReturn {
13
14
  isConnecting: boolean;
14
15
  conversation: Conversation | null;
15
16
  sendMessage?: (payload: Pick<FetchSsePayload, 'text' | 'payload'>) => void;
16
- resetChannel?: () => void;
17
+ resetChannel?: (payload: Pick<FetchSsePayload, 'text' | 'payload'>) => void;
17
18
  closeChannel?: () => void;
18
19
  }
19
20
  export declare function useChannel(props: UseChannelProps): UseChannelReturn;
@@ -1 +1 @@
1
- {"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB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AAI,CAAC;IAC3E,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC;IAC5E,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CA8GnE"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
+ export * from './context';
2
3
  export * from './hooks';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -74,67 +74,72 @@ function T7(e) {
74
74
  const {
75
75
  client: t,
76
76
  defaultIsOpen: n,
77
- customChannelId: i,
78
- customMessageId: r,
79
- initMessages: o
77
+ resetPayload: i,
78
+ customChannelId: r,
79
+ customMessageId: o,
80
+ initMessages: s
80
81
  } = e;
81
82
  if (!t)
82
83
  throw new Error("Client instance is required");
83
- if (!i)
84
+ if (!r)
84
85
  throw new Error("Custom channel id is required");
85
- const [s, a] = Cn(null), [u, l] = Cn(n ?? !0), [c, f] = Cn(!1), [d, h] = Cn(!1), [p, g] = Cn(null), m = xt(async () => {
86
- const x = new k7({
87
- messages: new Map(
88
- o == null ? void 0 : o.map((v) => [v.messageId, v])
89
- )
90
- });
91
- f(!0), h(!0), g(x);
92
- const _ = await A7.reset(
93
- {
94
- client: t,
95
- customChannelId: i,
96
- customMessageId: r,
97
- conversation: x,
98
- statesObserver: (v) => {
99
- h(v.isConnecting), g(v.conversation);
100
- }
101
- },
102
- {
103
- onSseCompleted() {
104
- f(!1);
86
+ const [a, u] = Cn(null), [l, c] = Cn(n ?? !0), [f, d] = Cn(!1), [h, p] = Cn(!1), [g, m] = Cn(null), y = xt(
87
+ async (_) => {
88
+ const v = new k7({
89
+ messages: new Map(
90
+ s == null ? void 0 : s.map((w) => [w.messageId, w])
91
+ )
92
+ });
93
+ d(!0), p(!0), m(v);
94
+ const E = await A7.reset(
95
+ {
96
+ client: t,
97
+ customChannelId: r,
98
+ customMessageId: o,
99
+ conversation: v,
100
+ statesObserver: (w) => {
101
+ p(w.isConnecting), m(w.conversation);
102
+ }
105
103
  },
106
- onSseError() {
107
- f(!1);
104
+ _,
105
+ {
106
+ onSseCompleted() {
107
+ d(!1);
108
+ },
109
+ onSseError() {
110
+ d(!1);
111
+ }
108
112
  }
109
- }
110
- );
111
- a(_);
112
- }, [t, i, r, o]), y = xt(() => {
113
- a((x) => (x == null || x.close(), null)), l(!1), f(!1), h(!1), g(null);
114
- }, []), b = xt(
115
- (x) => s == null ? void 0 : s.sendMessage(x),
116
- [s]
113
+ );
114
+ c(!0), u(E);
115
+ },
116
+ [t, r, o, s]
117
+ ), b = xt(() => {
118
+ u((_) => (_ == null || _.close(), null)), c(!1), d(!1), p(!1), m(null);
119
+ }, []), x = xt(
120
+ (_) => a == null ? void 0 : a.sendMessage(_),
121
+ [a]
117
122
  );
118
123
  return Nt(() => {
119
- !s && u && m();
120
- }, [s, u, m]), Nt(() => () => y(), [y]), jt(
124
+ !a && l && y(i);
125
+ }, [a, l, y, i]), Nt(() => () => b(), [b]), jt(
121
126
  () => ({
122
- isOpen: u,
123
- isResetting: c,
124
- isConnecting: d,
125
- conversation: p,
126
- sendMessage: b,
127
- resetChannel: m,
128
- closeChannel: y
127
+ isOpen: l,
128
+ isResetting: f,
129
+ isConnecting: h,
130
+ conversation: g,
131
+ sendMessage: x,
132
+ resetChannel: y,
133
+ closeChannel: b
129
134
  }),
130
135
  [
131
- u,
132
- c,
133
- d,
134
- p,
135
- b,
136
- m,
137
- y
136
+ l,
137
+ f,
138
+ h,
139
+ g,
140
+ x,
141
+ y,
142
+ b
138
143
  ]
139
144
  );
140
145
  }
@@ -43449,8 +43454,29 @@ function Kxe(e) {
43449
43454
  ) });
43450
43455
  }
43451
43456
  export {
43457
+ aF as AsgardServiceContext,
43458
+ Yz as AsgardServiceContextProvider,
43459
+ uF as AsgardTemplateContext,
43460
+ Xz as AsgardTemplateContextProvider,
43461
+ jM as AsgardThemeContext,
43462
+ $7 as AsgardThemeContextProvider,
43463
+ dF as BotTypingBox,
43464
+ EB as BotTypingPlaceholder,
43465
+ wB as ButtonTemplate,
43466
+ AB as CarouselTemplate,
43467
+ Lbe as ChartTemplate,
43452
43468
  Kxe as Chatbot,
43469
+ WA as HintTemplate,
43470
+ Wbe as ImageTemplate,
43471
+ dB as QuickReplies,
43472
+ Ia as TemplateBox,
43473
+ Yl as TemplateBoxContent,
43474
+ jA as TextTemplate,
43475
+ UM as defaultAsgardThemeContextValue,
43476
+ Ii as useAsgardContext,
43453
43477
  C7 as useAsgardServiceClient,
43478
+ Zz as useAsgardTemplateContext,
43479
+ au as useAsgardThemeContext,
43454
43480
  T7 as useChannel,
43455
43481
  R7 as useDebounce,
43456
43482
  O7 as useIsOnScreenKeyboardOpen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },