@pritzlaff/nano-ui 0.0.0-stage → 0.5.0

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -2
  3. package/explorer-details.d.ts +44 -0
  4. package/explorer-nodes.d.ts +9 -0
  5. package/explorer.d.ts +52 -0
  6. package/filter/filter.d.ts +40 -0
  7. package/filter/model.d.ts +25 -0
  8. package/index.d.ts +33 -0
  9. package/index.js +2556 -0
  10. package/index.js.map +54 -0
  11. package/interfaces.d.ts +239 -0
  12. package/layout.d.ts +23 -0
  13. package/observe/bar.d.ts +46 -0
  14. package/observe/clock-driver.d.ts +16 -0
  15. package/observe/entry.d.ts +66 -0
  16. package/observe/fold.d.ts +14 -0
  17. package/observe/in-flight.d.ts +10 -0
  18. package/observe/memory-store.d.ts +5 -0
  19. package/observe/record.d.ts +15 -0
  20. package/observe/replay.d.ts +56 -0
  21. package/observe/restart-order.d.ts +3 -0
  22. package/observe/ring-view.d.ts +86 -0
  23. package/observe/ring.d.ts +38 -0
  24. package/observe/shadow.d.ts +18 -0
  25. package/observe/time-machine.d.ts +55 -0
  26. package/package.json +29 -4
  27. package/pods/clock.d.ts +3 -0
  28. package/pods/debounce.d.ts +6 -0
  29. package/pods/input.d.ts +5 -0
  30. package/pods/log.d.ts +3 -0
  31. package/pods/map.d.ts +3 -0
  32. package/pods/random.d.ts +5 -0
  33. package/pods/sim-clock.d.ts +3 -0
  34. package/provider.d.ts +1 -0
  35. package/views/debounce-model.d.ts +72 -0
  36. package/views/debounce-parts.d.ts +12 -0
  37. package/views/debounce.d.ts +36 -0
  38. package/views/define.d.ts +3 -0
  39. package/views/faces.d.ts +16 -0
  40. package/views/input.d.ts +9 -0
  41. package/views/pod-view.d.ts +10 -0
  42. package/views/view.d.ts +61 -0
  43. package/wiring/constants.d.ts +15 -0
  44. package/wiring/layout.d.ts +49 -0
  45. package/wiring/model.d.ts +3 -0
  46. package/wiring/render-drawer.d.ts +16 -0
  47. package/wiring/render-pills.d.ts +2 -0
  48. package/wiring/render-stage.d.ts +2 -0
  49. package/wiring/styles.d.ts +1 -0
  50. package/wiring/types.d.ts +68 -0
  51. package/wiring/wiring.d.ts +69 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The time machine: a cursor (a time, in the recording's `at` ms) over a recording, emitting a frame of what's in flight
3
+ * there on every change. Live follows the newest entry; playing moves at speed × real time, skipping idle gaps; paused
4
+ * stays put while recording goes on.
5
+ *
6
+ * const tm = await timeMachine({ store, listen }) // listen: from record()
7
+ * tm.subscribe(f => draw(f.inFlight)); tm.seek(t); tm.play()
8
+ */
9
+ import type { Entry, Message, MessageStore } from './entry.js';
10
+ export type Frame = {
11
+ t: number;
12
+ inFlight: {
13
+ message: Message;
14
+ progress: number;
15
+ }[];
16
+ recent: Message[];
17
+ at?: Message;
18
+ };
19
+ /** `frame(fn)` runs `fn` once, at the next frame, and returns its cancel. */
20
+ export type Ticker = {
21
+ now(): number;
22
+ frame(fn: () => void): () => void;
23
+ };
24
+ export interface TimeMachine {
25
+ readonly cursor: number;
26
+ readonly mode: 'live' | 'paused' | 'playing';
27
+ readonly speed: number;
28
+ readonly span: {
29
+ from: number;
30
+ to: number;
31
+ };
32
+ seek(t: number): void;
33
+ step(dir: 1 | -1): void;
34
+ play(): void;
35
+ pause(): void;
36
+ live(): void;
37
+ setSpeed(s: number): void;
38
+ subscribe(fn: (f: Frame) => void): () => void;
39
+ close(): void;
40
+ }
41
+ export declare const SPEEDS: number[];
42
+ /**
43
+ * Catches up with `store.range()` and then hears `listen`, missing nothing. A message's window is
44
+ * `[at, at + travelMs]` (`travelMs` 600) at any speed: speed scales only how fast the cursor moves. Live, while
45
+ * anything is in flight, a frame is emitted each ticker frame with `t = now()`. `recent` keeps the last `recent` (200) messages with `at ≤ t`.
46
+ * Messages are ordered by `at`, ties by seq; a step moves to the next or previous one.
47
+ */
48
+ export declare function timeMachine(source: {
49
+ store: MessageStore;
50
+ listen: (fn: (e: Entry) => void) => () => void;
51
+ }, opts?: {
52
+ ticker?: Ticker;
53
+ recent?: number;
54
+ travelMs?: number;
55
+ }): Promise<TimeMachine>;
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@pritzlaff/nano-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.0",
4
+ "description": "The nano.ui provider: input, debounce, map and log pods, and the HostUI interface.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/aaronp/nano.git",
10
+ "directory": "packages/ui"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./index.d.ts",
15
+ "import": "./index.js"
16
+ }
17
+ },
18
+ "types": "./index.d.ts",
19
+ "module": "./index.js",
20
+ "sideEffects": false,
21
+ "dependencies": {},
22
+ "peerDependencies": {
23
+ "@pritzlaff/nano-core": "^0.5.0",
24
+ "@pritzlaff/nano-elements": "^0.5.0",
25
+ "lit": "^3.0.0",
26
+ "typebox": "^1.4.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** The real clock: `now` is Date.now, `after` is setTimeout, and `fired` is published when the timer is due. */
3
+ export declare const clock: Implementation;
@@ -0,0 +1,6 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /**
3
+ * `push` returns at once and queues its value. After `quietMs` without a push, or at the latest `maxWaitMs` after the
4
+ * first push of a batch (when set), the queue flushes: the newest value as `flushed`, all of it, oldest first, as `batch`.
5
+ */
6
+ export declare const debounce: Implementation;
@@ -0,0 +1,5 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** What its view shows: a line of text, a text area, a number or a checkbox. The pod itself only returns its input. */
3
+ export declare const KINDS: readonly ['text', 'textarea', 'number', 'boolean'];
4
+ export type InputKind = typeof KINDS[number];
5
+ export declare const input: Implementation;
package/pods/log.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** Keeps the newest `max` entries (default 100). */
3
+ export declare const log: Implementation;
package/pods/map.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** `code` is a function body over `x`. A body that does not parse makes `make` throw, so each call fails with `threw`. */
3
+ export declare const map: Implementation;
@@ -0,0 +1,5 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** The real random: `next` is Math.random. */
3
+ export declare const random: Implementation;
4
+ /** A seeded random (mulberry32): the same seed gives the same sequence, and a restart begins it again. */
5
+ export declare const seededRandom: Implementation;
@@ -0,0 +1,3 @@
1
+ import { Implementation } from '@pritzlaff/nano-core';
2
+ /** A clock that moves only by `advance` and `set`, firing due timers in due order (ties in start order), one at a time. */
3
+ export declare const simClock: Implementation;
package/provider.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const uiProvider: import("@pritzlaff/nano-core").Provider;
@@ -0,0 +1,72 @@
1
+ /** A queued value and when it arrived (ms since the epoch). */
2
+ export type Queued = {
3
+ value: unknown;
4
+ at: number;
5
+ };
6
+ /** Stage geometry and motion (px, slots, ms). Slot 0 sits on the hatch; higher slots run back along the switchback. */
7
+ export declare const G: {
8
+ readonly rows: 3;
9
+ readonly perRow: 18;
10
+ readonly sp: 54;
11
+ readonly xEnd: 1110;
12
+ readonly xStart: 192;
13
+ readonly rowY: readonly [176, 106, 36];
14
+ readonly maxPos: 53;
15
+ readonly hidePos: -2.3;
16
+ readonly bucketTop: 290;
17
+ readonly bucketH: 270;
18
+ readonly pitch: 122;
19
+ readonly history: 8;
20
+ readonly enterSpeed: 0.07;
21
+ readonly flushSpeed: 0.06;
22
+ readonly hatchLeadMs: 180;
23
+ readonly settleMs: 260;
24
+ readonly slideMs: 480;
25
+ };
26
+ export type Reason = 'quiet' | 'max wait';
27
+ /** A batch dropping through the hatch: its values (with when each arrived), and when it lands. */
28
+ export type Flushing = {
29
+ events: Queued[];
30
+ at: number;
31
+ doneAt: number;
32
+ reason: Reason;
33
+ };
34
+ export type Batch = {
35
+ id: number;
36
+ events: Queued[];
37
+ reason: Reason;
38
+ };
39
+ /** Why a queue flushed (or will): whichever deadline comes first. */
40
+ export declare const reasonFor: (q: Queued[], quiet: number, maxWait?: number) => Reason;
41
+ /** When a queue flushes: whichever deadline comes first (no max wait: only quiet). */
42
+ export declare const dueAt: (q: Queued[], quiet: number, maxWait?: number) => number;
43
+ /** Where a queued value is: it slides in from the back of the queue to its slot. */
44
+ export declare const arrivalPos: (slot: number, at: number, now: number) => number;
45
+ /** How far a dropping batch has travelled towards the hatch. */
46
+ export declare const flushTravel: (f: Flushing, now: number) => number;
47
+ /** A batch starts dropping now; it lands once its farthest value has passed the hatch. */
48
+ export declare function startFlush(events: Queued[], now: number, reason: Reason): Flushing;
49
+ /** A (fractional) queue position as stage coordinates along the switchback. */
50
+ export declare function slotXY(pos: number): {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ /** A value's colour, by its JSON type (the prototype coloured by event type): a series token. */
55
+ export declare function colorOf(v: unknown): "var(--nano-s1, #4C8DFF)" | "var(--nano-s2, #FF9F1C)" | "var(--nano-s3, #2EC4A6)" | "var(--nano-s5, #B48CFF)";
56
+ /** A colour (a token) at an opacity. */
57
+ export declare const tint: (color: string, a: number) => string;
58
+ export declare const label: (v: unknown, n: number) => string;
59
+ export declare const clamp01: (v: number) => number;
60
+ /** A bucket's contents: cells stacked from the bottom, thinner the fuller it is. */
61
+ export declare function bucketView(events: Queued[]): {
62
+ n: number;
63
+ gap: number;
64
+ solid: boolean;
65
+ countTop: number;
66
+ cells: {
67
+ color: string;
68
+ bg: string;
69
+ h: number;
70
+ text: string;
71
+ }[];
72
+ };
@@ -0,0 +1,12 @@
1
+ import { bucketView } from './debounce-model.js';
2
+ export declare const MONO = "'JetBrains Mono', ui-monospace, monospace";
3
+ /** A setting's slider: the value (shown while dragging), how much of it has elapsed, and `set` on release. */
4
+ export declare const slider: (name: string, aria: string, min: number, max: number, step: number, value: number, elapsed: number, color: string, drag: (v: number) => void, set: (v: number) => void, off?: {
5
+ on: boolean;
6
+ toggle: (on: boolean) => void;
7
+ }) => import("lit").TemplateResult<1>;
8
+ /** The switchback track the queue runs along, from the entry at the top-left down to the hatch. */
9
+ export declare const track: () => import("lit").TemplateResult<1>;
10
+ /** A batch bucket: its count, its cells stacked from the bottom, and its id and reason underneath. The live one is
11
+ * the bucket under the hatch. */
12
+ export declare function bucket(v: ReturnType<typeof bucketView>, left: number, opacity: number, id: string, reason: string, reasonColor: string, live: boolean, border?: string): import("lit").TemplateResult<1>;
@@ -0,0 +1,36 @@
1
+ import { type AppEvent } from '@pritzlaff/nano-core';
2
+ import { type Batch, type Flushing, type Queued } from './debounce-model.js';
3
+ import { ViewElement, type ViewTarget } from './view.js';
4
+ export declare class NanoDebounce extends ViewElement {
5
+ static styles: import("lit").CSSResult[];
6
+ pending: Queued[];
7
+ flushing: Flushing | null;
8
+ batches: Batch[];
9
+ batchSeq: number;
10
+ committed: number;
11
+ lastCommitAt: number;
12
+ /** A slider's value while it is dragged, before the config is applied. */
13
+ private dragged;
14
+ private valued;
15
+ private unsub?;
16
+ private raf;
17
+ private fit;
18
+ private ro?;
19
+ private config;
20
+ private quiet;
21
+ private maxWait;
22
+ /** Values come from `subscribe(push)` when this runtime has one debounce; else arrivals are counted from `sent`. */
23
+ protected started(tg: ViewTarget): void;
24
+ protected hear(e: AppEvent, tg: ViewTarget): void;
25
+ private arrive;
26
+ private flush;
27
+ private commit;
28
+ /** Applies the pod's config with `c` merged in (the pod restarts with it). */
29
+ private set;
30
+ firstUpdated(): void;
31
+ connectedCallback(): void;
32
+ disconnectedCallback(): void;
33
+ willUpdate(changed: Map<string, unknown>): void;
34
+ updated(): void;
35
+ protected face(tg: ViewTarget): import("lit").TemplateResult<1>;
36
+ }
@@ -0,0 +1,3 @@
1
+ import type { ViewMap } from './view.js';
2
+ export declare const views: ViewMap;
3
+ export declare function defineViews(): void;
@@ -0,0 +1,16 @@
1
+ import { type AppEvent } from '@pritzlaff/nano-core';
2
+ import { ViewElement, type ViewTarget } from './view.js';
3
+ export declare class NanoMap extends ViewElement {
4
+ private mine;
5
+ private output?;
6
+ protected hear(e: AppEvent, tg: ViewTarget): void;
7
+ protected face(tg: ViewTarget): import("lit").TemplateResult<1>;
8
+ }
9
+ export declare class NanoLog extends ViewElement {
10
+ private entries;
11
+ private logs;
12
+ protected started(tg: ViewTarget): void;
13
+ private read;
14
+ protected hear(e: AppEvent, tg: ViewTarget): void;
15
+ protected face(): import("lit").TemplateResult<1>;
16
+ }
@@ -0,0 +1,9 @@
1
+ import { ViewElement, type ViewTarget } from './view.js';
2
+ export declare class NanoInput extends ViewElement {
3
+ private value;
4
+ private kind;
5
+ private edit;
6
+ private send;
7
+ private setKind;
8
+ protected face(tg: ViewTarget): import("lit").TemplateResult<1>;
9
+ }
@@ -0,0 +1,10 @@
1
+ import type { AppEvent } from '@pritzlaff/nano-core';
2
+ import { ViewElement, type ViewTarget } from './view.js';
3
+ export declare class NanoPodView extends ViewElement {
4
+ static styles: import("lit").CSSResult[];
5
+ private ports;
6
+ private stats;
7
+ protected started(): void;
8
+ protected hear(e: AppEvent, tg: ViewTarget): void;
9
+ protected face(tg: ViewTarget): import("lit").TemplateResult<1>;
10
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The view contract: a view is a custom element over one pod, with a `target: ViewTarget` property. It reaches its pod
3
+ * only through `target.app.call(target.runtime, target.pod)` and `target.app.listen`. `viewFor` picks the tag.
4
+ *
5
+ * viewFor('up', app.deployment(), defaults, overrides) // the pod's override, else the default, else 'nano-pod-view'
6
+ */
7
+ import { LitElement } from 'lit';
8
+ import type { AppDeployment, AppEvent, Application, Registry } from '@pritzlaff/nano-core';
9
+ export type ViewTarget = {
10
+ app: Application;
11
+ registry: Registry;
12
+ runtime: string;
13
+ pod: string;
14
+ };
15
+ /** An implementation coordinate → a custom-element tag. */
16
+ export type ViewMap = Record<string, string>;
17
+ /** `overrides`: pod → tag (a host's, e.g. the host document's `host.views`). */
18
+ export declare function viewFor(pod: string, deployment: AppDeployment, defaults: ViewMap, overrides?: Record<string, string>): string;
19
+ /**
20
+ * What every view here shares: listening while connected and its pod is placed; "removed" once an `applied` removes it.
21
+ * Not exported from the package: a view is any element with `target`, this is only how these ones are made.
22
+ */
23
+ export declare class ViewElement extends LitElement {
24
+ static properties: {
25
+ target: {
26
+ attribute: boolean;
27
+ };
28
+ removed: {
29
+ state: boolean;
30
+ };
31
+ };
32
+ static styles: import("lit").CSSResult[];
33
+ target?: ViewTarget;
34
+ removed: boolean;
35
+ private off?;
36
+ private watching?;
37
+ constructor();
38
+ connectedCallback(): void;
39
+ disconnectedCallback(): void;
40
+ willUpdate(changed: Map<string, unknown>): void;
41
+ private watch;
42
+ private stop;
43
+ /** The pod's client. */
44
+ protected pod(t: ViewTarget): {
45
+ [x: string]: (input: unknown) => Promise<import("@pritzlaff/nano-core").NanoResult<unknown>>;
46
+ };
47
+ /** Called once listening starts. */
48
+ protected started(_t: ViewTarget): void;
49
+ /** Every event while listening. */
50
+ protected hear(_e: AppEvent, _t: ViewTarget): void;
51
+ protected face(_t: ViewTarget): unknown;
52
+ render(): unknown;
53
+ }
54
+ /** A result's value, shown. */
55
+ export declare const shown: (r: {
56
+ ok: boolean;
57
+ value?: unknown;
58
+ fail?: {
59
+ reason: string;
60
+ };
61
+ } | undefined) => string;
@@ -0,0 +1,15 @@
1
+ import type { PadType } from './types.js';
2
+ export declare const TYPE_COLOR: Record<PadType, string>;
3
+ export declare const TYPE_GLYPH: Record<PadType, string>;
4
+ export declare const TYPE_NAME: Record<PadType, string>;
5
+ /** A page, in world px; page i sits at x = i·XSTEP, so the stack fans out to the right. */
6
+ export declare const PW = 720, PH = 440, XSTEP = 140;
7
+ /** How far back a layer sits per page of distance from the focus. */
8
+ export declare const ZGAP = 160;
9
+ export declare const TILT = "rotateX(32deg) rotateY(-14deg)";
10
+ export declare const FADE_MIN = 0.15, FADE_STEP = 0.35, DIM_CABLE = 0.18;
11
+ export declare const fade: (d: number) => number;
12
+ export declare const PAD = 24, PAD_STEP = 30, HEAD = 34;
13
+ export declare const SIDE_W = 280, SIDE_GAP = 140, BLOCK_HEAD = 30, BLOCK_GAP = 28, ITEM_GAP = 12;
14
+ export declare const ZOOM_MIN = 0.3, ZOOM_MAX = 2.5;
15
+ export declare const MARGIN = 60;
@@ -0,0 +1,49 @@
1
+ import type { Circuit, Footprint, Layer, Pad, SideItem, SystemBlock } from './types.js';
2
+ export type Rect = {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ };
8
+ export type Pt = {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ export type PlacedPad = {
13
+ pad: Pad;
14
+ x: number;
15
+ y: number;
16
+ };
17
+ /** One box: a footprint or a side item. Positions are local to its frame. */
18
+ export type PlacedBox = {
19
+ item: Footprint | SideItem;
20
+ rect: Rect;
21
+ pads: PlacedPad[];
22
+ };
23
+ export type Frame = {
24
+ id: string;
25
+ origin: Pt;
26
+ rect: Rect;
27
+ boxes: PlacedBox[];
28
+ };
29
+ export type LayerFrame = Frame & {
30
+ layer: Layer;
31
+ index: number;
32
+ };
33
+ export type BlockFrame = Frame & {
34
+ block: SystemBlock;
35
+ };
36
+ export type Layout = {
37
+ layers: LayerFrame[];
38
+ blocks: BlockFrame[];
39
+ pos: Map<string, Pt>;
40
+ bounds: Rect;
41
+ pageRect(i: number): Rect;
42
+ };
43
+ export declare const frameId: (at: {
44
+ layer: string;
45
+ } | {
46
+ side: string;
47
+ }) => string;
48
+ export declare const posKey: (frame: string, pad: string) => string;
49
+ export declare function layout(c: Circuit): Layout;
@@ -0,0 +1,3 @@
1
+ import type { AppDeployment, Registry } from '@pritzlaff/nano-core';
2
+ import { type Circuit } from './types.js';
3
+ export declare function circuitOf(deployment: AppDeployment, registry: Registry): Circuit;
@@ -0,0 +1,16 @@
1
+ import type { NanoWiring } from './wiring.js';
2
+ import type { PadType } from './types.js';
3
+ type View = {
4
+ kicker: string;
5
+ title: string;
6
+ sub: string;
7
+ types: PadType[];
8
+ rows: [string, string][];
9
+ schemaLabel?: string;
10
+ schema?: unknown;
11
+ follow: boolean;
12
+ };
13
+ /** Resolves the selection (`pad:`, `cable:` or `fp:`) to what the drawer shows. */
14
+ export declare function describe(el: NanoWiring): View | null;
15
+ export declare function renderDrawer(el: NanoWiring): import("lit").TemplateResult<1>;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { NanoWiring } from './wiring.js';
2
+ export declare function renderPills(el: NanoWiring): import("lit").TemplateResult<1>;
@@ -0,0 +1,2 @@
1
+ import type { NanoWiring } from './wiring.js';
2
+ export declare function renderStage(el: NanoWiring): import("lit").TemplateResult<1>;
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult[];
@@ -0,0 +1,68 @@
1
+ import type { TSchema } from 'typebox';
2
+ export type PadType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'signal' | 'any' | 'call';
3
+ /** A pad's data type, from its schema's type: none (or Void) is a signal; unions, Unknown and the rest are any. */
4
+ export declare function padTypeOf(schema: TSchema | undefined): PadType;
5
+ /** An event is round, an action a rounded square; an input is hollow, an output filled. */
6
+ export type Pad = {
7
+ key: string;
8
+ instance: string;
9
+ op: string;
10
+ label: string;
11
+ dir: 'in' | 'out';
12
+ kind: 'event' | 'call';
13
+ type: PadType;
14
+ description?: string;
15
+ schema?: TSchema;
16
+ };
17
+ export type Box = {
18
+ x: number;
19
+ y: number;
20
+ w: number;
21
+ h: number;
22
+ };
23
+ export type Footprint = {
24
+ system: string;
25
+ instance: string;
26
+ title: string;
27
+ box: Box;
28
+ shared: boolean;
29
+ pads: Pad[];
30
+ };
31
+ export type Layer = {
32
+ screen: string;
33
+ title: string;
34
+ system: string;
35
+ footprints: Footprint[];
36
+ };
37
+ export type SideItem = {
38
+ system: string;
39
+ instance: string;
40
+ title: string;
41
+ pads: Pad[];
42
+ };
43
+ export type SystemBlock = {
44
+ system: string;
45
+ items: SideItem[];
46
+ };
47
+ /** Where a cable end sits: on a runtime's layer, or in the side area (the block's system id). */
48
+ export type CableEnd = {
49
+ pad: string;
50
+ at: {
51
+ layer: string;
52
+ } | {
53
+ side: string;
54
+ };
55
+ };
56
+ /** `id` is `runtime|from|to|port|source` for a pipe, `runtime|from|to|call|` for a call edge. */
57
+ export type Cable = {
58
+ id: string;
59
+ system: string;
60
+ from: CableEnd;
61
+ to: CableEnd;
62
+ type: PadType;
63
+ };
64
+ export type Circuit = {
65
+ layers: Layer[];
66
+ side: SystemBlock[];
67
+ cables: Cable[];
68
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `<nano-wiring>`: the app as a tilted stack of runtime layers (their pods, pads and cables) and a side area for pods
3
+ * placed in more than one runtime. Read-only. It rebuilds on `applied` and lights a cable for 600ms when it carries a message.
4
+ */
5
+ import { LitElement } from 'lit';
6
+ import type { Application, Registry } from '@pritzlaff/nano-core';
7
+ import { type Layout, type Rect } from './layout.js';
8
+ import type { Circuit } from './types.js';
9
+ type Target = {
10
+ app: Application;
11
+ registry: Registry;
12
+ };
13
+ /** The view: focused layer, zoom, pan, and what is selected (`pad:`, `cable:` or `fp:` + id). */
14
+ export interface State {
15
+ focus: string | null;
16
+ zoom: number;
17
+ panX: number;
18
+ panY: number;
19
+ sel: string | null;
20
+ }
21
+ export declare class NanoWiring extends LitElement {
22
+ static properties: {
23
+ target: {
24
+ attribute: boolean;
25
+ };
26
+ };
27
+ static styles: import("lit").CSSResult[];
28
+ target?: Target;
29
+ s: State;
30
+ model: Circuit;
31
+ geo: Layout;
32
+ dragging: boolean;
33
+ private off?;
34
+ private watching?;
35
+ private fitted;
36
+ private drag;
37
+ private lit;
38
+ constructor();
39
+ connectedCallback(): void;
40
+ disconnectedCallback(): void;
41
+ willUpdate(changed: Map<string, unknown>): void;
42
+ render(): import("lit").TemplateResult<1>[];
43
+ private watch;
44
+ private stop;
45
+ private load;
46
+ /** A cable is lit by prefix: its id starts with `runtime|from|to|port|` (a pipe's target port) or `...|call|`. */
47
+ private light;
48
+ isLit(id: string): boolean;
49
+ reduced(): boolean;
50
+ stageSize(): {
51
+ w: number;
52
+ h: number;
53
+ };
54
+ fitRect(r: Rect): void;
55
+ fitPage(id: string): void;
56
+ fitAll(): void;
57
+ go(id: string): void;
58
+ move(by: number): void;
59
+ key(e: KeyboardEvent): void;
60
+ refocus(): void;
61
+ select(sel: string | null): void;
62
+ /** Pans to the other end of the selected pad's (or cable's) cable, focusing its layer if it has one. */
63
+ follow(): void;
64
+ wheel(e: WheelEvent): void;
65
+ dragStart(e: PointerEvent): void;
66
+ /** Centres the view on the world point clicked in the minimap. */
67
+ panFromMinimap(e: MouseEvent): void;
68
+ }
69
+ export {};