@novasamatech/product-sdk 0.6.14 → 0.6.16
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/deriveEntropy.d.ts +3 -0
- package/dist/deriveEntropy.js +8 -0
- package/dist/permission.d.ts +24 -0
- package/dist/permission.js +28 -0
- package/dist/theme.d.ts +9 -0
- package/dist/theme.js +17 -0
- package/package.json +2 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DevicePermission, RemotePermission } from '@novasamatech/host-api';
|
|
2
|
+
import type { CodecType } from 'scale-ts';
|
|
3
|
+
export type DevicePermissionKind = CodecType<typeof DevicePermission>;
|
|
4
|
+
export type RemotePermissionItem = CodecType<typeof RemotePermission>;
|
|
5
|
+
/**
|
|
6
|
+
* Request a single device permission from the host.
|
|
7
|
+
* Returns ResultAsync<boolean, GenericError>:
|
|
8
|
+
* - ok(true) — permission granted
|
|
9
|
+
* - ok(false) — permission denied by the user
|
|
10
|
+
* - err(...) — transport or encoding error
|
|
11
|
+
*/
|
|
12
|
+
export declare function requestDevicePermission(permission: DevicePermissionKind): import("neverthrow").ResultAsync<boolean, import("packages/scale/src/err.js").CodecError<{
|
|
13
|
+
reason: string;
|
|
14
|
+
}, "GenericError">>;
|
|
15
|
+
/**
|
|
16
|
+
* Request one or more remote permissions from the host in a single batch.
|
|
17
|
+
* Returns ResultAsync<boolean, GenericError>:
|
|
18
|
+
* - ok(true) — all permissions granted
|
|
19
|
+
* - ok(false) — at least one permission denied
|
|
20
|
+
* - err(...) — transport or encoding error
|
|
21
|
+
*/
|
|
22
|
+
export declare function requestPermission(permissions: RemotePermissionItem[]): import("neverthrow").ResultAsync<boolean, import("packages/scale/src/err.js").CodecError<{
|
|
23
|
+
reason: string;
|
|
24
|
+
}, "GenericError">>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DevicePermission, RemotePermission, enumValue } from '@novasamatech/host-api';
|
|
2
|
+
import { hostApi } from './hostApi.js';
|
|
3
|
+
/**
|
|
4
|
+
* Request a single device permission from the host.
|
|
5
|
+
* Returns ResultAsync<boolean, GenericError>:
|
|
6
|
+
* - ok(true) — permission granted
|
|
7
|
+
* - ok(false) — permission denied by the user
|
|
8
|
+
* - err(...) — transport or encoding error
|
|
9
|
+
*/
|
|
10
|
+
export function requestDevicePermission(permission) {
|
|
11
|
+
return hostApi
|
|
12
|
+
.devicePermission(enumValue('v1', permission))
|
|
13
|
+
.map(r => r.value)
|
|
14
|
+
.mapErr(e => e.value);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Request one or more remote permissions from the host in a single batch.
|
|
18
|
+
* Returns ResultAsync<boolean, GenericError>:
|
|
19
|
+
* - ok(true) — all permissions granted
|
|
20
|
+
* - ok(false) — at least one permission denied
|
|
21
|
+
* - err(...) — transport or encoding error
|
|
22
|
+
*/
|
|
23
|
+
export function requestPermission(permissions) {
|
|
24
|
+
return hostApi
|
|
25
|
+
.permission(enumValue('v1', permissions))
|
|
26
|
+
.map(r => r.value)
|
|
27
|
+
.mapErr(e => e.value);
|
|
28
|
+
}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CodecType, Transport } from '@novasamatech/host-api';
|
|
2
|
+
import { Theme } from '@novasamatech/host-api';
|
|
3
|
+
export type ThemeMode = CodecType<typeof Theme>;
|
|
4
|
+
export type ThemeSubscription = {
|
|
5
|
+
unsubscribe: VoidFunction;
|
|
6
|
+
};
|
|
7
|
+
export declare function createThemeProvider(transport?: Transport): {
|
|
8
|
+
subscribeTheme(callback: (theme: ThemeMode) => void): ThemeSubscription;
|
|
9
|
+
};
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Theme, createHostApi, enumValue } from '@novasamatech/host-api';
|
|
2
|
+
import { sandboxTransport } from './sandboxTransport.js';
|
|
3
|
+
export function createThemeProvider(transport = sandboxTransport) {
|
|
4
|
+
const hostApi = createHostApi(transport);
|
|
5
|
+
return {
|
|
6
|
+
subscribeTheme(callback) {
|
|
7
|
+
const subscription = hostApi.themeSubscribe(enumValue('v1', undefined), value => {
|
|
8
|
+
if (value.tag === 'v1') {
|
|
9
|
+
callback(value.value);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
unsubscribe: subscription.unsubscribe,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/product-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.16",
|
|
5
5
|
"description": "Polkadot product SDK: integrate and run your product inside Polkadot browser.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@polkadot-api/substrate-bindings": "^0.17.0",
|
|
30
30
|
"@polkadot-api/json-rpc-provider": "^0.0.4",
|
|
31
31
|
"@polkadot-api/json-rpc-provider-proxy": "^0.2.7",
|
|
32
|
-
"@novasamatech/host-api": "0.6.
|
|
32
|
+
"@novasamatech/host-api": "0.6.16"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|