@novasamatech/host-api 0.6.6-1 → 0.6.6
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 +1 -1
- package/dist/logger.js +7 -5
- package/dist/protocol/v1/jsonRpc.d.ts +1 -1
- package/dist/protocol/v1/notification.d.ts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/transport.js +3 -3
- package/dist/types.d.ts +3 -1
- package/package.json +4 -3
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/
|
|
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/
|
|
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">>>;
|
package/dist/provider.d.ts
CHANGED
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
|
|
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:
|
|
166
|
+
unsubscribe: unsubscribeListener,
|
|
167
167
|
};
|
|
168
168
|
const publicSubscription = {
|
|
169
|
-
unsubscribe:
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.6
|
|
4
|
+
"version": "0.6.6",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -12,6 +12,7 @@
|
|
|
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
|
|
25
|
+
"@novasamatech/scale": "0.6.6",
|
|
25
26
|
"@polkadot-api/utils": "^0.2.0",
|
|
26
27
|
"nanoevents": "9.1.0",
|
|
27
|
-
"nanoid": "5.1.
|
|
28
|
+
"nanoid": "5.1.7",
|
|
28
29
|
"neverthrow": "^8.2.0",
|
|
29
30
|
"scale-ts": "1.6.1"
|
|
30
31
|
},
|