@yam8d/m8-sdk 0.5.1 → 0.5.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@yam8d/m8-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Client SDK for apps that read and drive a Dirtywave M8, inside a yam8d External Apps iframe or standalone over Web Serial, WebUSB or Web MIDI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,15 +1,16 @@
1
1
  export type Direction = 'up' | 'down' | 'left' | 'right';
2
2
  export type Edge = {
3
3
  to: string;
4
- dir: Direction;
4
+ dir?: Direction;
5
5
  weight?: number;
6
6
  };
7
- export type Graph = Map<string, Edge[]>;
7
+ export type Graph<E extends Edge = Edge> = Map<string, E[]>;
8
8
  export type Heuristic = (a: string, b: string) => number;
9
- export type EdgeCostFn = (from: string, to: string, dir: Direction) => number;
10
- export interface PathResult {
9
+ export type EdgeCostFn = (from: string, to: string, dir?: Direction) => number;
10
+ export interface PathResult<E extends Edge = Edge> {
11
11
  pages: string[];
12
- directions: Direction[];
12
+ directions: (Direction | undefined)[];
13
+ edges: E[];
13
14
  cost: number;
14
15
  }
15
- export declare function aStar(graph: Graph, start: string, goal: string, heuristic?: Heuristic, edgeCost?: EdgeCostFn): PathResult | null;
16
+ export declare function aStar<E extends Edge = Edge>(graph: Graph<E>, start: string, goal: string, heuristic?: Heuristic, edgeCost?: EdgeCostFn): PathResult<E> | null;
@@ -19,7 +19,8 @@ export interface M8Engine {
19
19
  readonly macro: MacroRunner;
20
20
  /** Moves the cursor towards a point in M8 pixel coordinates. */
21
21
  navigateTo(point: Point): Promise<void>;
22
- navigateToView(viewName: string): Promise<void>;
22
+ /** Resolves true when the view is reached. */
23
+ navigateToView(viewName: string): Promise<boolean>;
23
24
  getState(): M8State;
24
25
  getScreenLines(): string[];
25
26
  getScreenCellColors(): ScreenCellColors;
@@ -7,7 +7,7 @@ export type HostMethodsDeps = {
7
7
  editors: ReturnType<typeof createValueEditors>;
8
8
  setValueFloat: (targetFloat: number) => Promise<boolean>;
9
9
  browseFile: (targetText: string, exact: boolean) => Promise<boolean>;
10
- navigateToView: (viewName: string) => Promise<void>;
10
+ navigateToView: (viewName: string) => Promise<boolean>;
11
11
  navigateTo: (point: {
12
12
  x: number;
13
13
  y: number;
@@ -1,6 +1,22 @@
1
- import type { Graph } from './astar';
1
+ import type { Edge, Graph } from './astar';
2
+ export type NavEdgeKind = 'shift' | 'button' | 'exit';
3
+ export interface NavEdge extends Edge {
4
+ from: string;
5
+ kind: NavEdgeKind;
6
+ /** Key frames to play (after the cursor move, for buttons). Empty: Shift+dir. */
7
+ keys: number[];
8
+ /** Button cell, in text grid coordinates. */
9
+ cursor?: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ /** Button text, used to find the button where the layout differs from `cursor`. */
14
+ label?: string;
15
+ /** Where this key goes when the M8 came from `to` (it goes back). */
16
+ back?: boolean;
17
+ }
2
18
  export interface M8ViewGraph {
3
- graph: Graph;
19
+ graph: Graph<NavEdge>;
4
20
  /** Explicit key frame sequences per edge: from -> to -> frames. */
5
21
  edgeKeys: Map<string, Map<string, number[]>>;
6
22
  }
@@ -6,11 +6,16 @@ export declare const toKeyMasks: (directions: Direction[], opts?: {
6
6
  shift?: boolean;
7
7
  }) => number[];
8
8
  export interface ViewNavigation {
9
- /** Resolves when the view is reached, no path is found, or the step limit is hit. */
10
- navigateToView(viewName: string): Promise<void>;
9
+ /** Resolves true when the view is reached; false when no path is left, the step limit is hit or another navigation starts. */
10
+ navigateToView(viewName: string): Promise<boolean>;
11
11
  dispose(): void;
12
12
  }
13
- export declare const createViewNavigation: ({ store, runner }: {
13
+ export interface ViewNavigationDeps {
14
14
  store: M8Store;
15
15
  runner: MacroRunner;
16
- }) => ViewNavigation;
16
+ /** The 24 text rows of the screen, to find buttons by their label. */
17
+ getScreenLines?: () => string[];
18
+ /** Moves the cursor to a text grid cell. Without it, button edges are not used. */
19
+ moveCursor?: (x: number, y: number) => Promise<void>;
20
+ }
21
+ export declare const createViewNavigation: ({ store, runner, getScreenLines, moveCursor }: ViewNavigationDeps) => ViewNavigation;
@@ -71,8 +71,10 @@ export declare function formatFxValue(cmd: string, value: number): string;
71
71
  export interface FxValueContext {
72
72
  /** Note on the same step (used by ARP to spell out the notes). */
73
73
  note?: string | null;
74
- /** Table view: HOP and CHA mean something different there. */
74
+ /** Table view: HOP, CHA, DEL, TIC, REP, RTO and MTT mean something different there. */
75
75
  inTable?: boolean;
76
+ /** Row (phrase step or table row) the command is on: a HOP onto its own row, MTT on the first step. */
77
+ row?: number | null;
76
78
  }
77
79
  /**
78
80
  * Short explanation of what `value` does for `cmd` (phrase view), or null when
@@ -34,6 +34,14 @@ interface ZoneDef {
34
34
  width: number;
35
35
  }
36
36
  type VocabEntry = Pick<ColumnDef, 'type' | 'format' | 'label' | 'description' | 'parts' | 'options' | 'unit'>;
37
+ /** Rows with one value per operator (FM): the columns of the values. */
38
+ interface OperatorsDef {
39
+ instrument: string;
40
+ x: number;
41
+ step: number;
42
+ width: number;
43
+ letters: string[];
44
+ }
37
45
  interface LayoutDef {
38
46
  extends?: string;
39
47
  /** Pattern of the heading label that names the block a cell belongs to ('MOD\\d'): read upward in the cell's zone. */
@@ -45,6 +53,7 @@ interface LayoutDef {
45
53
  sections?: string[];
46
54
  rows?: RowDef[];
47
55
  zones?: ZoneDef[];
56
+ operators?: OperatorsDef;
48
57
  vocabulary?: Record<string, VocabEntry>;
49
58
  vocabularyFrom?: 'instrumentTypes';
50
59
  }