@novasamatech/host-api 0.10.1 → 0.10.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-api",
3
3
  "type": "module",
4
- "version": "0.10.1",
4
+ "version": "0.10.2",
5
5
  "description": "Host API: transport implementation for host - product integration.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@novasamatech/scale": "0.10.1",
25
+ "@novasamatech/scale": "0.10.2",
26
26
  "nanoevents": "10.0.0",
27
27
  "nanoid": "6.0.1",
28
28
  "neverthrow": "^8.2.0",
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { hostApiProtocol } from './impl.js';
3
- import { MessagePayload } from './messageCodec.js';
4
- describe('MessagePayload ABI', () => {
5
- it('declares an explicit base index per method matching contiguous serialization order', () => {
6
- let next = 0;
7
- for (const payload of Object.values(hostApiProtocol)) {
8
- expect(payload.index).toBe(next);
9
- // requests expand to 2 actions (request/response),
10
- // subscriptions to 4 (start/stop/interrupt/receive)
11
- next += payload.method === 'subscribe' ? 4 : 2;
12
- }
13
- });
14
- it('encodes the first action with leading index byte 0', () => {
15
- const bytes = MessagePayload.enc({ tag: 'host_handshake_request', value: { tag: 'v1', value: 1 } });
16
- expect(bytes[0]).toBe(0);
17
- });
18
- it('encodes the last action with its explicit index byte', () => {
19
- const bytes = MessagePayload.enc({
20
- tag: 'host_push_notification_cancel_response',
21
- value: { tag: 'v1', value: { success: true, value: undefined } },
22
- });
23
- expect(bytes[0]).toBe(129);
24
- });
25
- it('round-trips an action through its explicit index', () => {
26
- const value = { tag: 'host_handshake_request', value: { tag: 'v1', value: 7 } };
27
- expect(MessagePayload.dec(MessagePayload.enc(value))).toEqual(value);
28
- });
29
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { Theme, ThemeName, ThemeVariant } from './theme.js';
3
- describe('ThemeName', () => {
4
- it('encodes/decodes the Custom variant with its string payload', () => {
5
- const value = { tag: 'Custom', value: 'midnight' };
6
- expect(ThemeName.dec(ThemeName.enc(value))).toEqual(value);
7
- });
8
- it('encodes/decodes the Default variant', () => {
9
- const value = { tag: 'Default', value: undefined };
10
- expect(ThemeName.dec(ThemeName.enc(value))).toEqual(value);
11
- });
12
- it('pins the wire indexes: Custom=0, Default=1', () => {
13
- // Custom('x'): tag byte 0, then SCALE compact-prefixed string "x"
14
- expect(ThemeName.enc({ tag: 'Custom', value: 'x' })).toEqual(new Uint8Array([0, 4, 120]));
15
- expect(ThemeName.enc({ tag: 'Default', value: undefined })).toEqual(new Uint8Array([1]));
16
- });
17
- });
18
- describe('ThemeVariant', () => {
19
- it('encodes/decodes Light and Dark', () => {
20
- expect(ThemeVariant.enc('Light')).toEqual(new Uint8Array([0]));
21
- expect(ThemeVariant.enc('Dark')).toEqual(new Uint8Array([1]));
22
- expect(ThemeVariant.dec(new Uint8Array([0]))).toEqual('Light');
23
- expect(ThemeVariant.dec(new Uint8Array([1]))).toEqual('Dark');
24
- });
25
- });
26
- describe('Theme', () => {
27
- it('round-trips a Default/Light theme', () => {
28
- const value = { name: { tag: 'Default', value: undefined }, variant: 'Light' };
29
- expect(Theme.dec(Theme.enc(value))).toEqual(value);
30
- });
31
- it('round-trips a Custom/Dark theme and pins its byte layout', () => {
32
- const value = { name: { tag: 'Custom', value: 'dark' }, variant: 'Dark' };
33
- // name: Custom(0) + compact(4)=0x10 + "dark"; variant: Dark(1)
34
- expect(Theme.enc(value)).toEqual(new Uint8Array([0, 16, 100, 97, 114, 107, 1]));
35
- expect(Theme.dec(Theme.enc(value))).toEqual(value);
36
- });
37
- });