@novasamatech/host-container 0.5.5 → 0.6.1

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/README.md CHANGED
@@ -133,6 +133,16 @@ container.handleLocalStorageClear(async (key, { ok, err }) => {
133
133
  });
134
134
  ```
135
135
 
136
+ ### handleAccountConnectionStatusSubscribe
137
+
138
+ ```ts
139
+ container.handleAccountConnectionStatusSubscribe((_, send, interrupt) => {
140
+ const listener = (status) => send(status);
141
+ accountService.on('connectionStatusChange', listener);
142
+ return () => accountService.off('connectionStatusChange', listener);
143
+ });
144
+ ```
145
+
136
146
  ### handleAccountGet
137
147
 
138
148
  ```ts
@@ -278,6 +288,18 @@ container.handleChatActionSubscribe((_, send, interrupt) => {
278
288
  });
279
289
  ```
280
290
 
291
+ ### renderChatCustomMessage
292
+
293
+ ```ts
294
+ const subscription = container.renderChatCustomMessage('my-custom-type', payload, (node) => {
295
+ // node is a CustomRendererNode tree describing the UI to render
296
+ console.log('Render custom message:', node);
297
+ });
298
+
299
+ // Unsubscribe when done
300
+ subscription.unsubscribe();
301
+ ```
302
+
281
303
  ### handleStatementStoreSubscribe
282
304
 
283
305
  ```ts
@@ -113,6 +113,18 @@ export function createContainer(provider) {
113
113
  .unwrapOr(enumValue(version, resultErr(error)));
114
114
  });
115
115
  },
116
+ handleAccountConnectionStatusSubscribe(handler) {
117
+ init();
118
+ return transport.handleSubscription('host_account_connection_status_subscribe', (params, send, interrupt) => {
119
+ const version = 'v1';
120
+ return guardVersion(params, version, null)
121
+ .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
122
+ .orTee(interrupt)
123
+ .unwrapOr(() => {
124
+ /* empty */
125
+ });
126
+ });
127
+ },
116
128
  handleAccountGet(handler) {
117
129
  init();
118
130
  return transport.handleRequest('host_account_get', async (params) => {
@@ -269,6 +281,14 @@ export function createContainer(provider) {
269
281
  });
270
282
  });
271
283
  },
284
+ renderChatCustomMessage(messageType, payload, callback) {
285
+ init();
286
+ return transport.subscribe('product_chat_custom_message_render_subscribe', enumValue('v1', { messageType, payload }), value => {
287
+ if (value.tag === 'v1') {
288
+ callback(value.value);
289
+ }
290
+ });
291
+ },
272
292
  handleStatementStoreSubscribe(handler) {
273
293
  init();
274
294
  return transport.handleSubscription('remote_statement_store_subscribe', (params, send, interrupt) => {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { Codec, CodecType, ConnectionStatus, HexString, HostApiProtocol, VersionedProtocolRequest, VersionedProtocolSubscription } from '@novasamatech/host-api';
1
+ import type { Codec, CodecType, ConnectionStatus, HexString, HostApiProtocol, Subscription, VersionedProtocolRequest, VersionedProtocolSubscription } from '@novasamatech/host-api';
2
+ import { CustomRendererNode } from '@novasamatech/host-api';
2
3
  import type { JsonRpcProvider } from '@polkadot-api/json-rpc-provider';
3
4
  import type { ResultAsync, errAsync } from 'neverthrow';
4
5
  import { okAsync } from 'neverthrow';
@@ -58,6 +59,7 @@ export type Container = {
58
59
  handleLocalStorageRead: InferHandler<'v1', HostApiProtocol['host_local_storage_read']>;
59
60
  handleLocalStorageWrite: InferHandler<'v1', HostApiProtocol['host_local_storage_write']>;
60
61
  handleLocalStorageClear: InferHandler<'v1', HostApiProtocol['host_local_storage_clear']>;
62
+ handleAccountConnectionStatusSubscribe: InferHandler<'v1', HostApiProtocol['host_account_connection_status_subscribe']>;
61
63
  handleAccountGet: InferHandler<'v1', HostApiProtocol['host_account_get']>;
62
64
  handleAccountGetAlias: InferHandler<'v1', HostApiProtocol['host_account_get_alias']>;
63
65
  handleAccountCreateProof: InferHandler<'v1', HostApiProtocol['host_account_create_proof']>;
@@ -71,6 +73,7 @@ export type Container = {
71
73
  handleChatListSubscribe: InferHandler<'v1', HostApiProtocol['host_chat_list_subscribe']>;
72
74
  handleChatPostMessage: InferHandler<'v1', HostApiProtocol['host_chat_post_message']>;
73
75
  handleChatActionSubscribe: InferHandler<'v1', HostApiProtocol['host_chat_action_subscribe']>;
76
+ renderChatCustomMessage(messageType: string, payload: Uint8Array, callback: (node: CodecType<typeof CustomRendererNode>) => void): Subscription;
74
77
  handleStatementStoreSubscribe: InferHandler<'v1', HostApiProtocol['remote_statement_store_subscribe']>;
75
78
  handleStatementStoreCreateProof: InferHandler<'v1', HostApiProtocol['remote_statement_store_create_proof']>;
76
79
  handleStatementStoreSubmit: InferHandler<'v1', HostApiProtocol['remote_statement_store_submit']>;
package/dist/types.js CHANGED
@@ -1 +1,2 @@
1
+ import { CustomRendererNode } from '@novasamatech/host-api';
1
2
  import { okAsync } from 'neverthrow';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.5.5",
4
+ "version": "0.6.1",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@polkadot-api/utils": "^0.2.0",
30
30
  "@polkadot-api/json-rpc-provider": "^0.0.4",
31
- "@novasamatech/host-api": "0.5.5",
31
+ "@novasamatech/host-api": "0.6.1",
32
32
  "nanoid": "5.1.6"
33
33
  },
34
34
  "devDependencies": {