relu-trace 0.1.0 → 0.1.1

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.
@@ -3,22 +3,31 @@ export const inspectorCSS = `
3
3
  display: block;
4
4
  min-width: 0;
5
5
  container-type: inline-size;
6
- --relu-bg: #131815;
7
- --relu-surface: #1b221e;
8
- --relu-panel: #191f1b;
9
- --relu-ink: #eaece6;
10
- --relu-muted: #a4afa7;
11
- --relu-accent: #c6f57b;
12
- --relu-rule: #303632;
13
- --relu-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
14
- --relu-font: 15px/1.45 system-ui, sans-serif;
15
- color: var(--relu-ink);
6
+ /* Each public --relu-* token is read with a fallback, so a value set on the host or inherited from any ancestor applies. */
7
+ --_bg: var(--relu-bg, #131815);
8
+ --_surface: var(--relu-surface, #1b221e);
9
+ --_panel: var(--relu-panel, #191f1b);
10
+ --_ink: var(--relu-ink, #eaece6);
11
+ --_muted: var(--relu-muted, #a4afa7);
12
+ --_accent: var(--relu-accent, #c6f57b);
13
+ --_rule: var(--relu-rule, #303632);
14
+ --_mono: var(--relu-mono, ui-monospace, SFMono-Regular, Consolas, monospace);
15
+ --_font: var(--relu-font, 15px/1.45 system-ui, sans-serif);
16
+ --_control-font: var(--relu-control-font, 600 13px/1.2 system-ui, sans-serif);
17
+ --_heading-font: var(--relu-heading-font, 700 15px/1.45 system-ui, sans-serif);
18
+ --_radius: var(--relu-radius, 12px);
19
+ /* Control fills are mixed from ink and background, so a theme only sets the tokens above. */
20
+ --_control: color-mix(in srgb, var(--_ink) 8%, var(--_bg));
21
+ --_control-rule: color-mix(in srgb, var(--_ink) 26%, var(--_bg));
22
+ --_control-hover: color-mix(in srgb, var(--_ink) 17%, var(--_bg));
23
+ --_control-hover-rule: color-mix(in srgb, var(--_ink) 55%, var(--_bg));
24
+ color: var(--_ink);
16
25
  }
17
26
  .inspector {
18
- font: var(--relu-font);
19
- background: var(--relu-bg);
20
- border: 1px solid var(--relu-rule);
21
- border-radius: 12px;
27
+ font: var(--_font);
28
+ background: var(--_bg);
29
+ border: 1px solid var(--_rule);
30
+ border-radius: var(--_radius);
22
31
  overflow: hidden;
23
32
  text-align: left;
24
33
  }
@@ -26,52 +35,54 @@ export const inspectorCSS = `
26
35
  .toolbar, .comparison, .panel-head, .panel-body, .panel-foot, .state { padding: 12px 16px; }
27
36
  .toolbar, .actions, .meter, .panel-head, .panel-foot, .comparison { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
28
37
  .toolbar, .panel-head { justify-content: space-between; }
29
- .toolbar { background: var(--relu-surface); }
30
- button, select { font: 600 13px/1.2 system-ui, sans-serif; border: 1px solid #48554c; border-radius: 5px; padding: 8px 12px; background: #222b25; color: var(--relu-ink); min-height: 34px; }
38
+ .toolbar { background: var(--_surface); }
39
+ button, select { font: var(--_control-font); border: 1px solid var(--_control-rule); border-radius: min(5px, var(--_radius)); padding: 8px 12px; background: var(--_control); color: var(--_ink); min-height: 34px; }
31
40
  button:not(:disabled) { cursor: pointer; }
32
- button:hover:not(:disabled), select:hover:not(:disabled) { background: #344438; border-color: #899e8c; }
33
- button:focus-visible, select:focus-visible { outline: 2px solid var(--relu-accent); outline-offset: 2px; }
34
- button:disabled, select:disabled { color: #858f86; border-color: #373f39; background: transparent; }
35
- button.primary:not(:disabled) { color: #151e12; background: var(--relu-accent); border-color: var(--relu-accent); }
36
- button.primary:hover:not(:disabled) { background: #dcffa7; }
41
+ button:hover:not(:disabled), select:hover:not(:disabled) { background: var(--_control-hover); border-color: var(--_control-hover-rule); }
42
+ button:focus-visible, select:focus-visible { outline: 2px solid var(--_accent); outline-offset: 2px; }
43
+ button:disabled, select:disabled { color: color-mix(in srgb, var(--_ink) 53%, var(--_bg)); border-color: var(--_control-hover); background: transparent; }
44
+ button.primary:not(:disabled) { color: var(--_bg); background: var(--_accent); border-color: var(--_accent); }
45
+ button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--_accent) 70%, white); }
37
46
  button[hidden] { display: none; }
38
- .meter { font: 13px/1.2 var(--relu-mono); color: var(--relu-muted); }
39
- #status { font: 700 12px/1.2 system-ui, sans-serif; padding: 5px 8px; border-radius: 4px; background: #303e32; color: var(--relu-accent); }
47
+ .meter { font: 13px/1.2 var(--_mono); color: var(--_muted); }
48
+ #status { font: var(--_control-font); font-weight: 700; font-size: 12px; padding: 5px 8px; border-radius: min(4px, var(--_radius)); background: color-mix(in srgb, var(--_accent) 18%, var(--_bg)); color: var(--_accent); }
40
49
  #status[data-kind="halt"] { color: #b6ead9; background: #233d35; }
41
50
  #status[data-kind="budget"], .comparison[data-kind="diff"] strong { color: #ffcf8e; }
42
51
  #status[data-kind="invalid"], .comparison[data-kind="error"] strong, .error { color: #ffb0a2; }
43
- .comparison { background: #18221a; border-top: 1px solid var(--relu-rule); font-size: 13px; column-gap: 12px; overflow-wrap: anywhere; }
52
+ .comparison { background: color-mix(in srgb, var(--_accent) 4%, var(--_bg)); border-top: 1px solid var(--_rule); font-size: 13px; column-gap: 12px; overflow-wrap: anywhere; }
44
53
  .comparison[hidden] { display: none; }
45
- .comparison strong { font: 600 11px/1.2 var(--relu-mono); letter-spacing: .08em; color: var(--relu-accent); }
54
+ .comparison strong { font: 600 11px/1.2 var(--_mono); letter-spacing: .08em; color: var(--_accent); }
46
55
  .comparison[data-kind="diff"] { background: #292216; }
47
56
  .comparison[data-kind="error"] { background: #2c1a19; }
48
- .panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--relu-rule); }
57
+ .panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--_rule); }
49
58
  .panel { display: flex; flex-direction: column; }
50
- .panel + .panel { border-left: 1px solid var(--relu-rule); }
51
- .panel-head { background: var(--relu-panel); min-height: 58px; border-bottom: 1px solid var(--relu-rule); }
59
+ .panel + .panel { border-left: 1px solid var(--_rule); }
60
+ .panel-head { background: var(--_panel); min-height: 58px; border-bottom: 1px solid var(--_rule); }
52
61
  .panel-body { flex: 1; overflow-wrap: anywhere; }
53
62
  .panel-body:has(> .muted:only-child) { min-height: 112px; }
54
- .panel-foot { border-top: 1px solid var(--relu-rule); }
55
- .state { border-top: 1px solid var(--relu-rule); background: var(--relu-panel); overflow-wrap: anywhere; }
56
- .state h3 span { font-size: 12px; font-weight: 400; color: var(--relu-muted); margin-left: 4px; }
63
+ .panel-foot { border-top: 1px solid var(--_rule); }
64
+ .state { border-top: 1px solid var(--_rule); background: var(--_panel); overflow-wrap: anywhere; }
65
+ .state h3 span { display: inline-block; font-size: .8em; font-weight: 400; color: var(--_muted); margin-left: 4px; }
57
66
  .state dl { grid-template-columns: max-content 1fr; }
58
67
  .bank-value { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
59
68
  .bank-toggle { padding: 3px 8px; min-height: 26px; font-size: 11px; }
60
- h3 { font-size: 15px; margin: 0; }
61
- h4 { margin: 12px 0 5px; color: var(--relu-muted); font: 600 11px/1.4 var(--relu-mono); text-transform: uppercase; letter-spacing: .08em; }
69
+ h3 { font: var(--_heading-font); margin: 0; }
70
+ h4 { margin: 12px 0 5px; color: var(--_muted); font: 600 11px/1.4 var(--_mono); text-transform: uppercase; letter-spacing: .08em; }
62
71
  p { margin: 0; }
63
- label { display: flex; align-items: center; gap: 6px; color: var(--relu-muted); font-size: 12px; min-width: 0; }
72
+ label { display: flex; align-items: center; gap: 6px; color: var(--_muted); font-size: 12px; min-width: 0; }
64
73
  select { max-width: min(32ch, 63cqw); color-scheme: dark; }
65
- .muted { color: var(--relu-muted); }
74
+ .muted { color: var(--_muted); }
66
75
  .small { font-size: 13px; }
67
- .equation { font: 600 16px/1.4 var(--relu-mono); color: var(--relu-accent); margin-bottom: 5px; }
68
- dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; margin: 0; font: 13px/1.4 var(--relu-mono); }
69
- dt { color: #b7c7ba; } dd { margin: 0; }
70
- table { width: 100%; border-collapse: collapse; text-align: left; margin-top: 12px; font: 13px/1.4 var(--relu-mono); }
71
- th, td { border-bottom: 1px solid var(--relu-rule); padding: 6px 8px 6px 0; }
72
- th { color: var(--relu-muted); font-weight: 500; font-size: 11px; }
76
+ .equation { font: 600 16px/1.4 var(--_mono); color: var(--_accent); margin-bottom: 5px; }
77
+ dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; margin: 0; font: 13px/1.4 var(--_mono); }
78
+ dt { color: color-mix(in srgb, var(--_ink) 50%, var(--_muted)); } dd { margin: 0; }
79
+ table { width: 100%; border-collapse: collapse; text-align: left; margin-top: 12px; font: 13px/1.4 var(--_mono); }
80
+ th, td { border-bottom: 1px solid var(--_rule); padding: 6px 8px 6px 0; }
81
+ th { color: var(--_muted); font-weight: 500; font-size: 11px; }
82
+ /* Headings and numbers stay whole; a long signal name is the cell that wraps. */
83
+ th, td:not(:first-child) { white-space: nowrap; }
73
84
  @container (max-width: 700px) {
74
85
  .panels { grid-template-columns: minmax(0, 1fr); }
75
- .panel + .panel { border-left: none; border-top: 1px solid var(--relu-rule); }
86
+ .panel + .panel { border-left: none; border-top: 1px solid var(--_rule); }
76
87
  }
77
88
  `;
package/docs/integrate.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Integrate: use the same machine in Node and the browser
2
2
 
3
- From a source checkout, `npm ci` then `npm pack`. In a separate Node 22+ ESM project, install the tarball with `npm install /path/to/relu-trace-0.1.0.tgz`. The code below uses TypeScript; JavaScript consumers can use the same exports without the type-only import and annotations.
3
+ In a Node 22+ ESM project, run `npm install relu-trace`. The code below uses TypeScript; JavaScript consumers can use the same exports without the type-only import and annotations.
4
4
 
5
5
  Save the shared definition as `machine.ts`. The first ReLU increments a counter; the host commits that value and halts because `next` is `null`.
6
6
 
@@ -43,7 +43,7 @@ if (!target) throw new Error('Missing debugger element');
43
43
  export const unmount = mountInspector(target, { machine, initial, limit: 4 });
44
44
  ```
45
45
 
46
- The inspector shows `count = 2` before you start and `count = 3` after one step. Call `unmount()` on route or component cleanup (active playback timers also stop automatically if the host element is removed from the DOM). Optional `onTick(trace, snapshot)` and `onStatusChange(status, snapshot)` callbacks let host apps observe execution without touching internal state. For an app that already runs a machine, pass a copy from your session's `snapshot()` at the point you want to investigate; your live app's clocks and memory are not touched. Mount behind a development route when snapshots contain application data. The inspector builds its Shadow DOM without `innerHTML` and applies styles via `adoptedStyleSheets` (with a `<style>` fallback), making it compatible with Trusted Types and strict-CSP hosts. Host pages can theme it by setting `--relu-bg`, `--relu-surface`, `--relu-panel`, `--relu-ink`, `--relu-muted`, `--relu-accent`, `--relu-rule`, `--relu-mono`, or `--relu-font` on the mounted container.
46
+ The inspector shows `count = 2` before you start and `count = 3` after one step. Call `unmount()` on route or component cleanup (active playback timers also stop automatically if the host element is removed from the DOM). Optional `onTick(trace, snapshot)` and `onStatusChange(status, snapshot)` callbacks let host apps observe execution without touching internal state. For an app that already runs a machine, pass a copy from your session's `snapshot()` at the point you want to investigate; your live app's clocks and memory are not touched. Mount behind a development route when snapshots contain application data. The inspector builds its Shadow DOM without `innerHTML` and applies styles via `adoptedStyleSheets` (with a `<style>` fallback), making it compatible with Trusted Types and strict-CSP hosts. Host pages can theme it by setting `--relu-bg`, `--relu-surface`, `--relu-panel`, `--relu-ink`, `--relu-muted`, `--relu-accent`, `--relu-rule`, `--relu-mono`, `--relu-font`, `--relu-control-font`, `--relu-heading-font`, or `--relu-radius` on the mounted container or any ancestor.
47
47
 
48
48
  ## Bring your own definition
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relu-trace",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A browser debugger for hand-built ReLU state machines",
5
5
  "license": "MIT",
6
6
  "author": "Daniel Rodríguez",