@novasamatech/host-api 0.6.6-1 → 0.6.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/logger.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Logger } from './types.js';
2
- export declare function createDefaultLogger(): Logger;
2
+ export declare function createDefaultLogger(msgPrefix?: string): Logger;
package/dist/logger.js CHANGED
@@ -1,8 +1,10 @@
1
- export function createDefaultLogger() {
1
+ export function createDefaultLogger(msgPrefix) {
2
+ const prefix = msgPrefix ? `[${msgPrefix}]` : '';
2
3
  return {
3
- info: (...args) => console.info(...args),
4
- error: (...args) => console.error(...args),
5
- warn: (...args) => console.warn(...args),
6
- log: (...args) => console.log(...args),
4
+ info: (...args) => console.info(prefix, ...args),
5
+ error: (...args) => console.error(prefix, ...args),
6
+ warn: (...args) => console.warn(prefix, ...args),
7
+ log: (...args) => console.log(prefix, ...args),
8
+ withPrefix: (newPrefix) => createDefaultLogger(newPrefix),
7
9
  };
8
10
  }
@@ -1,5 +1,5 @@
1
1
  export declare const JsonRpcMessageSendV1_request: import("scale-ts").Codec<[`0x${string}`, string]>;
2
- export declare const JsonRpcMessageSendV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("packages/scale/dist/err.js").CodecError<{
2
+ export declare const JsonRpcMessageSendV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("packages/scale/src/err.js").CodecError<{
3
3
  reason: string;
4
4
  }, "GenericError">>>;
5
5
  export declare const JsonRpcMessageSubscribeV1_start: import("scale-ts").Codec<`0x${string}`>;
@@ -6,6 +6,6 @@ export declare const PushNotificationV1_request: import("scale-ts").Codec<{
6
6
  text: string;
7
7
  deeplink: string | undefined;
8
8
  }>;
9
- export declare const PushNotificationV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("packages/scale/dist/err.js").CodecError<{
9
+ export declare const PushNotificationV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("packages/scale/src/err.js").CodecError<{
10
10
  reason: string;
11
11
  }, "GenericError">>>;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from './types.js';
2
2
  export type Provider = {
3
- logger: Logger;
3
+ readonly logger: Logger;
4
4
  isCorrectEnvironment(): boolean;
5
5
  postMessage(message: Uint8Array): void;
6
6
  subscribe(callback: (message: Uint8Array) => void): () => void;
package/dist/transport.js CHANGED
@@ -148,7 +148,7 @@ export function createTransport(provider) {
148
148
  const startPayload = enumValue(startAction, payload);
149
149
  const subscriptionKey = getSubscriptionKey(method, startPayload);
150
150
  let subscription = activeSubscriptions.get(subscriptionKey);
151
- function unsub() {
151
+ function unsubscribeListener() {
152
152
  const subscription = activeSubscriptions.get(subscriptionKey);
153
153
  if (subscription) {
154
154
  const newListeners = subscription.listeners.filter(listener => listener.call !== callback);
@@ -163,10 +163,10 @@ export function createTransport(provider) {
163
163
  }
164
164
  const listener = {
165
165
  call: callback,
166
- unsubscribe: unsub,
166
+ unsubscribe: unsubscribeListener,
167
167
  };
168
168
  const publicSubscription = {
169
- unsubscribe: unsub,
169
+ unsubscribe: unsubscribeListener,
170
170
  onInterrupt(callback) {
171
171
  return events.on('interrupt', callback);
172
172
  },
package/dist/types.d.ts CHANGED
@@ -2,7 +2,9 @@ import type { HostApiProtocol } from './protocol/impl.js';
2
2
  import type { ComposeMessageAction, MessageAction, MessagePayloadSchema, PickMessagePayload, PickMessagePayloadValue } from './protocol/messageCodec.js';
3
3
  import type { Provider } from './provider.js';
4
4
  export type HostApiMethod = keyof HostApiProtocol;
5
- export type Logger = Record<'info' | 'warn' | 'error' | 'log', (...args: unknown[]) => void>;
5
+ export type Logger = Record<'info' | 'warn' | 'error' | 'log', (...args: unknown[]) => void> & {
6
+ withPrefix(prefix: string): Logger;
7
+ };
6
8
  export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected';
7
9
  export type RequestHandler<Method extends string> = (message: PickMessagePayloadValue<ComposeMessageAction<Method, 'request'>>) => PromiseLike<PickMessagePayloadValue<ComposeMessageAction<Method, 'response'>>>;
8
10
  export type SubscriptionHandler<Method extends string> = (params: PickMessagePayloadValue<ComposeMessageAction<Method, 'start'>>, send: (value: PickMessagePayloadValue<ComposeMessageAction<Method, 'receive'>>) => void, interrupt: () => void) => VoidFunction;
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@novasamatech/host-api",
3
3
  "type": "module",
4
- "version": "0.6.6-1",
4
+ "version": "0.6.7",
5
5
  "description": "Host API: transport implementation for host - product integration.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/Polkadot-Community-Foundation/triangle-js-sdks.git"
9
+ "url": "git+https://github.com/paritytech/triangle-js-sdks.git"
10
10
  },
11
11
  "main": "dist/index.js",
12
12
  "exports": {
13
13
  "./package.json": "./package.json",
14
14
  ".": {
15
+ "#/source": "./src/index.ts",
15
16
  "types": "./dist/index.d.ts",
16
17
  "default": "./dist/index.js"
17
18
  }
@@ -21,10 +22,10 @@
21
22
  "README.md"
22
23
  ],
23
24
  "dependencies": {
24
- "@novasamatech/scale": "0.6.6-1",
25
+ "@novasamatech/scale": "0.6.7",
25
26
  "@polkadot-api/utils": "^0.2.0",
26
27
  "nanoevents": "9.1.0",
27
- "nanoid": "5.1.6",
28
+ "nanoid": "5.1.7",
28
29
  "neverthrow": "^8.2.0",
29
30
  "scale-ts": "1.6.1"
30
31
  },