simple-circuit-engine 0.0.12 → 0.0.14

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 (99) hide show
  1. package/AGENTS.md +9 -6
  2. package/CLAUDE.md +2 -0
  3. package/README.md +8 -8
  4. package/dist/core/index.js +109 -74
  5. package/dist/core/setup.d.ts +18 -0
  6. package/dist/core/simulation/behaviors/arithmetic/AdderBehavior.d.ts +28 -0
  7. package/dist/core/simulation/behaviors/arithmetic/ArithmeticBehaviorMixin.d.ts +63 -0
  8. package/dist/core/simulation/behaviors/arithmetic/EightBitAdderBehavior.d.ts +51 -0
  9. package/dist/core/simulation/behaviors/arithmetic/EightBitOnesComplementBehavior.d.ts +29 -0
  10. package/dist/core/simulation/behaviors/arithmetic/HalfAdderBehavior.d.ts +22 -0
  11. package/dist/core/simulation/behaviors/arithmetic/index.d.ts +7 -0
  12. package/dist/core/simulation/behaviors/index.d.ts +14 -0
  13. package/dist/core/simulation/behaviors/interface/EightInputBehavior.d.ts +9 -0
  14. package/dist/core/simulation/behaviors/interface/EightLightBehavior.d.ts +9 -0
  15. package/dist/core/simulation/behaviors/interface/FourInputBehavior.d.ts +9 -0
  16. package/dist/core/simulation/behaviors/interface/FourLightBehavior.d.ts +9 -0
  17. package/dist/core/simulation/behaviors/interface/InputBehaviorMixin.d.ts +37 -0
  18. package/dist/core/simulation/behaviors/interface/LightBehaviorMixin.d.ts +60 -0
  19. package/dist/core/simulation/behaviors/interface/OneInputBehavior.d.ts +9 -0
  20. package/dist/core/simulation/behaviors/interface/OneLightBehavior.d.ts +9 -0
  21. package/dist/core/simulation/behaviors/interface/TwoInputBehavior.d.ts +9 -0
  22. package/dist/core/simulation/behaviors/interface/TwoLightBehavior.d.ts +9 -0
  23. package/dist/core/simulation/behaviors/interface/index.d.ts +0 -0
  24. package/dist/core/simulation/states/arithmetic/AdderState.d.ts +16 -0
  25. package/dist/core/simulation/states/arithmetic/ArithmeticState.d.ts +53 -0
  26. package/dist/core/simulation/states/arithmetic/EightBitAdderState.d.ts +25 -0
  27. package/dist/core/simulation/states/arithmetic/EightBitOnesComplementState.d.ts +18 -0
  28. package/dist/core/simulation/states/arithmetic/HalfAdderState.d.ts +16 -0
  29. package/dist/core/simulation/states/arithmetic/index.d.ts +7 -0
  30. package/dist/core/simulation/states/index.d.ts +15 -0
  31. package/dist/core/simulation/states/interface/EightInputState.d.ts +6 -0
  32. package/dist/core/simulation/states/interface/EightLightState.d.ts +6 -0
  33. package/dist/core/simulation/states/interface/FourInputState.d.ts +6 -0
  34. package/dist/core/simulation/states/interface/FourLightState.d.ts +6 -0
  35. package/dist/core/simulation/states/interface/InputState.d.ts +45 -0
  36. package/dist/core/simulation/states/interface/LightState.d.ts +54 -0
  37. package/dist/core/simulation/states/interface/OneInputState.d.ts +6 -0
  38. package/dist/core/simulation/states/interface/OneLightState.d.ts +6 -0
  39. package/dist/core/simulation/states/interface/TwoInputState.d.ts +6 -0
  40. package/dist/core/simulation/states/interface/TwoLightState.d.ts +6 -0
  41. package/dist/core/simulation/types.d.ts +10 -2
  42. package/dist/core/topology/Component.d.ts +6 -1
  43. package/dist/core/topology/ENode.d.ts +7 -2
  44. package/dist/core/topology/index.d.ts +2 -0
  45. package/dist/core/topology/networkTraversal.d.ts +50 -0
  46. package/dist/core/topology/types.d.ts +31 -6
  47. package/dist/core-HH6iRWtB.js +4671 -0
  48. package/dist/core-HH6iRWtB.js.map +1 -0
  49. package/dist/i18n/index.d.ts +1158 -0
  50. package/dist/i18n/locales/en.json.d.ts +366 -0
  51. package/dist/i18n/locales/fr.json.d.ts +366 -0
  52. package/dist/index.d.ts +1 -0
  53. package/dist/index.js +172 -118
  54. package/dist/scene/CircuitEngine.d.ts +49 -4
  55. package/dist/scene/index.d.ts +6 -2
  56. package/dist/scene/index.js +62 -45
  57. package/dist/scene/setup.d.ts +18 -0
  58. package/dist/scene/shared/AbstractCircuitController.d.ts +11 -3
  59. package/dist/scene/shared/HoverManager.d.ts +15 -0
  60. package/dist/scene/shared/components/arithmetic/AdderVisualFactory.d.ts +54 -0
  61. package/dist/scene/shared/components/arithmetic/EightBitAdderVisualFactory.d.ts +45 -0
  62. package/dist/scene/shared/components/arithmetic/EightBitOnesComplementVisualFactory.d.ts +63 -0
  63. package/dist/scene/shared/components/arithmetic/HalfAdderVisualFactory.d.ts +55 -0
  64. package/dist/scene/shared/components/arithmetic/index.d.ts +4 -0
  65. package/dist/scene/shared/components/index.d.ts +14 -0
  66. package/dist/scene/shared/components/interface/EightInputVisualFactory.d.ts +15 -0
  67. package/dist/scene/shared/components/interface/EightLightVisualFactory.d.ts +15 -0
  68. package/dist/scene/shared/components/interface/FourInputVisualFactory.d.ts +15 -0
  69. package/dist/scene/shared/components/interface/FourLightVisualFactory.d.ts +15 -0
  70. package/dist/scene/shared/components/interface/InputVisualFactoryBase.d.ts +50 -0
  71. package/dist/scene/shared/components/interface/LightVisualFactoryBase.d.ts +46 -0
  72. package/dist/scene/shared/components/interface/OneInputVisualFactory.d.ts +15 -0
  73. package/dist/scene/shared/components/interface/OneLightVisualFactory.d.ts +15 -0
  74. package/dist/scene/shared/components/interface/TwoInputVisualFactory.d.ts +15 -0
  75. package/dist/scene/shared/components/interface/TwoLightVisualFactory.d.ts +15 -0
  76. package/dist/scene/shared/types.d.ts +34 -4
  77. package/dist/scene/shared/utils/ControlsUtils.d.ts +1 -1
  78. package/dist/scene/shared/utils/GeometryUtils.d.ts +111 -0
  79. package/dist/scene/static/CircuitController.d.ts +13 -1
  80. package/dist/scene/static/tools/BuildTool.d.ts +81 -0
  81. package/dist/scene/static/tools/ComponentPickerWidget.d.ts +7 -0
  82. package/dist/scene/static/tools/ConfigPanelWidget.d.ts +14 -0
  83. package/dist/scene/static/tools/MultiWiringPlacement.d.ts +40 -0
  84. package/dist/scene/widgets/HelpWidget.d.ts +13 -0
  85. package/dist/scene/widgets/ModeWidget.d.ts +16 -0
  86. package/dist/scene/widgets/MultiWiringWidget.d.ts +21 -0
  87. package/dist/scene/{static → widgets}/PinTooltipWidget.d.ts +7 -1
  88. package/dist/scene/widgets/SimulationPlayerWidget.d.ts +62 -0
  89. package/dist/scene/widgets/ToolsWidget.d.ts +18 -0
  90. package/dist/scene/widgets/WidgetsManager.d.ts +65 -0
  91. package/dist/scene/widgets/assets/icons.d.ts +20 -0
  92. package/dist/scene/widgets/index.d.ts +9 -0
  93. package/dist/scene/widgets/styles.d.ts +33 -0
  94. package/dist/{scene-CVsDdySt.js → scene-C1xhdw_B.js} +3993 -772
  95. package/dist/scene-C1xhdw_B.js.map +1 -0
  96. package/package.json +14 -9
  97. package/dist/core-Bjta9Y7_.js +0 -2707
  98. package/dist/core-Bjta9Y7_.js.map +0 -1
  99. package/dist/scene-CVsDdySt.js.map +0 -1
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Multi-Wiring Widget
3
+ * @module scene/widgets/MultiWiringWidget
4
+ *
5
+ * Single toggle button (verr-maj style) that flips the engine's multi-wiring
6
+ * flag. Visible only in edit mode.
7
+ */
8
+ export declare class MultiWiringWidget {
9
+ private readonly _button;
10
+ private readonly _onToggle;
11
+ private _active;
12
+ constructor(initialActive: boolean, onToggle: () => void);
13
+ mount(parent: HTMLElement): void;
14
+ setVisible(visible: boolean): void;
15
+ setActive(active: boolean): void;
16
+ setLanguage(_lng: string): void;
17
+ dispose(): void;
18
+ /** Test/debug accessor. */
19
+ get element(): HTMLButtonElement;
20
+ private _render;
21
+ }
@@ -1,4 +1,5 @@
1
1
  import { ComponentType } from '../../core/index.ts';
2
+ import { ILogicPinMetadata } from '../../core/topology/types';
2
3
  /**
3
4
  * Manages a transient HTML tooltip displayed when hovering a component pin.
4
5
  *
@@ -15,12 +16,17 @@ export declare class PinTooltipWidget {
15
16
  * Show tooltip at the given client coordinates for the specified pin.
16
17
  * If already showing for the same component type, only repositions.
17
18
  */
18
- show(pinLabel: string, componentType: ComponentType, clientX: number, clientY: number): void;
19
+ show(pinLabel: string, componentType: ComponentType, logicMetadata: ILogicPinMetadata | null, clientX: number, clientY: number): void;
19
20
  /** Hide and remove the tooltip element */
20
21
  hide(): void;
21
22
  /** Update cursor position without recreating the tooltip */
22
23
  updatePosition(clientX: number, clientY: number): void;
23
24
  get isVisible(): boolean;
25
+ /**
26
+ * Signal a language change — hides any open tooltip so the next hover
27
+ * recreates it with updated translations.
28
+ */
29
+ setLanguage(_lng: string): void;
24
30
  dispose(): void;
25
31
  private _position;
26
32
  }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Simulation Player Widget
3
+ * @module scene/widgets/SimulationPlayerWidget
4
+ *
5
+ * Horizontal control strip: stop | (spacer) | play/pause | speed slider |
6
+ * TPS indicator | step. Visible only in simulation mode.
7
+ *
8
+ * Play/pause button icon reflects current state: `pauseIcon` while playing,
9
+ * `playIcon` while paused. The step button relies on the engine pausing
10
+ * automatically when stepping while playing.
11
+ */
12
+ export interface SimulationPlayerCallbacks {
13
+ onTogglePlay: () => void;
14
+ onSpeedChange: (tps: number) => void;
15
+ onStep: () => void;
16
+ onStopReset: () => void;
17
+ }
18
+ export declare class SimulationPlayerWidget {
19
+ private readonly _root;
20
+ private readonly _stopBtn;
21
+ private readonly _playPauseBtn;
22
+ private readonly _stepBtn;
23
+ private readonly _slider;
24
+ private readonly _speedLabel;
25
+ private readonly _callbacks;
26
+ private _isPlaying;
27
+ private _currentTick;
28
+ constructor(minSpeed: number, maxSpeed: number, initialSpeed: number, initialPlaying: boolean, callbacks: SimulationPlayerCallbacks);
29
+ mount(parent: HTMLElement): void;
30
+ setVisible(visible: boolean): void;
31
+ setPosition(top: number, left: number): void;
32
+ setSpeed(tps: number): void;
33
+ setTick(tick: number): void;
34
+ setPlaying(playing: boolean): void;
35
+ setLanguage(_lng: string): void;
36
+ dispose(): void;
37
+ /** Test/debug accessor. */
38
+ get element(): HTMLDivElement;
39
+ /** Test/debug accessor. */
40
+ get sliderElement(): HTMLInputElement;
41
+ /** Test/debug accessor. */
42
+ get stopButton(): HTMLButtonElement;
43
+ /** Test/debug accessor. */
44
+ get playPauseButton(): HTMLButtonElement;
45
+ /** Test/debug accessor. */
46
+ get stepButton(): HTMLButtonElement;
47
+ private _makeStopButton;
48
+ private _makePlayPauseButton;
49
+ private _makeStepButton;
50
+ private _makeSlider;
51
+ private _makeSpeedLabel;
52
+ private _renderLabel;
53
+ private _renderPlayPauseIcon;
54
+ private _playPauseTitle;
55
+ private _renderThumbColor;
56
+ /**
57
+ * Inject a one-shot stylesheet for the slider thumb so it visually matches
58
+ * `slider.png` (orange round thumb on a grey track) on browsers that ignore
59
+ * `accent-color`. Idempotent across multiple widget instances.
60
+ */
61
+ private _injectThumbStyles;
62
+ }
@@ -0,0 +1,18 @@
1
+ import { ToolType } from '../shared/types';
2
+ export declare class ToolsWidget {
3
+ private readonly _root;
4
+ private readonly _buildBtn;
5
+ private readonly _multiSelectBtn;
6
+ private readonly _onSelect;
7
+ private _activeTool;
8
+ constructor(initialTool: ToolType | null, onSelect: (tool: ToolType) => void);
9
+ mount(parent: HTMLElement): void;
10
+ setVisible(visible: boolean): void;
11
+ setActiveTool(tool: ToolType | null): void;
12
+ setLanguage(_lng: string): void;
13
+ dispose(): void;
14
+ /** Test/debug accessor. */
15
+ get element(): HTMLDivElement;
16
+ private _makeButton;
17
+ private _render;
18
+ }
@@ -0,0 +1,65 @@
1
+ import { EngineMode, ToolType } from '../shared/types';
2
+ import { HelpWidget } from './HelpWidget';
3
+ import { SimulationPlayerWidget } from './SimulationPlayerWidget';
4
+ /**
5
+ * Minimal slice of CircuitEngine the manager depends on. Defined as an
6
+ * interface (rather than importing `CircuitEngine` directly) to keep widgets
7
+ * unit-testable with a small mock.
8
+ */
9
+ export interface IEngineForWidgets {
10
+ readonly mode: EngineMode;
11
+ readonly multiWiring: boolean;
12
+ readonly simulationSpeed: number;
13
+ readonly minSimulationSpeed: number;
14
+ readonly maxSimulationSpeed: number;
15
+ readonly isPlaying: boolean;
16
+ setMode(mode: EngineMode): void;
17
+ setActiveTool(toolType: ToolType): void;
18
+ getActiveTool(): ToolType | null;
19
+ setEditModeEnabled(enabled: boolean): void;
20
+ setMultiWiring(value: boolean): void;
21
+ play(): void;
22
+ pause(): void;
23
+ step(): void;
24
+ stop(): void;
25
+ requestHelp(): void;
26
+ on(event: any, callback: (payload: any) => void): void;
27
+ off(event: any, callback: (payload: any) => void): void;
28
+ }
29
+ export declare class WidgetsManager {
30
+ private readonly _engine;
31
+ private readonly _container;
32
+ private readonly _root;
33
+ private readonly _modeWidget;
34
+ private readonly _toolsWidget;
35
+ private readonly _multiWiringWidget;
36
+ private readonly _playerWidget;
37
+ private readonly _helpWidget;
38
+ private readonly _subscriptions;
39
+ private _disposed;
40
+ private _resizeObserver;
41
+ constructor(engine: IEngineForWidgets, container: HTMLElement);
42
+ /**
43
+ * Re-render translated labels after the consumer changed i18next language.
44
+ */
45
+ setLanguage(lng: string): void;
46
+ dispose(): void;
47
+ /** Test/debug accessor. */
48
+ get root(): HTMLDivElement;
49
+ /** Test/debug accessor. */
50
+ get container(): HTMLElement;
51
+ /** Test/debug accessor. */
52
+ get helpWidget(): HelpWidget;
53
+ /** Test/debug accessor. */
54
+ get playerWidget(): SimulationPlayerWidget;
55
+ private _subscribeToEngine;
56
+ private _listen;
57
+ private _applyModeVisibility;
58
+ private _handleModeToggle;
59
+ private _handleToolSelect;
60
+ private _handleMultiWiringToggle;
61
+ private _handleHelpRequested;
62
+ private _applyResponsivePlayerLayout;
63
+ private _observeContainerResize;
64
+ private _safeCall;
65
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Embedded heroicon SVGs (24x24 outline) used by the integrated widgets.
3
+ *
4
+ * Sources: https://heroicons.com/ (MIT). Inlined as raw markup so the library
5
+ * ships no external icon dependency and CSS `currentColor` drives the stroke.
6
+ */
7
+ export declare const wrenchScrewdriverIcon: string;
8
+ export declare const cubeTransparentIcon: string;
9
+ export declare const barsArrowDownIcon: string;
10
+ export declare const playIcon: string;
11
+ export declare const pauseIcon: string;
12
+ export declare const stepIcon: string;
13
+ export declare const stopIcon: string;
14
+ export declare const questionMarkIcon: string;
15
+ /**
16
+ * Wrap an inline SVG string into a `<span>` so it can be appended to any
17
+ * widget DOM. The SVG inherits `color` from the parent button so styling stays
18
+ * declarative.
19
+ */
20
+ export declare function iconElement(svg: string, sizePx?: number): HTMLElement;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Integrated overlay widgets shipped with the scene module.
3
+ *
4
+ * Public surface kept minimal: only `WidgetsManager` is exported so consumers
5
+ * who opt out of the bundled wiring can still mount it manually. Individual
6
+ * widgets are implementation detail.
7
+ */
8
+ export { WidgetsManager } from './WidgetsManager';
9
+ export type { IEngineForWidgets } from './WidgetsManager';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared inline-style helpers for the integrated widgets.
3
+ *
4
+ * Library convention is to avoid bundling a stylesheet — every widget styles
5
+ * its DOM via `Object.assign(el.style, ...)`. These helpers centralise the
6
+ * shared tokens (button base, active state, container) so the four widgets
7
+ * stay visually consistent without an external CSS file.
8
+ */
9
+ export declare const WIDGET_Z_INDEX = 1500;
10
+ /** Base background and border for square icon buttons (inactive state). */
11
+ export declare function applyIconButtonBase(button: HTMLButtonElement): void;
12
+ /** Toggle the active visual variant on an icon button. */
13
+ export declare function setIconButtonActive(button: HTMLButtonElement, active: boolean): void;
14
+ /** Position a widget root absolutely inside the engine container. */
15
+ export declare function applyWidgetRoot(el: HTMLElement, top: number, left: number): void;
16
+ /** Vertical layout offsets (px) for the left-edge widget stack. */
17
+ export declare const LAYOUT: {
18
+ readonly GUTTER: 12;
19
+ readonly BUTTON: 36;
20
+ readonly MODE_TOP: 12;
21
+ readonly TOOLS_TOP: 60;
22
+ readonly MULTI_WIRING_TOP: 60;
23
+ readonly MULTI_WIRING_LEFT: 53;
24
+ readonly PLAYER_TOP: 8;
25
+ readonly PLAYER_LEFT: 170;
26
+ readonly PLAYER_RESPONSIVE_TOP: 60;
27
+ readonly PLAYER_RESPONSIVE_LEFT: 12;
28
+ readonly HELP_TOP_EDIT: 10;
29
+ readonly HELP_LEFT_EDIT: 100;
30
+ readonly HELP_TOP_SIM: 10;
31
+ readonly HELP_LEFT_SIM: 130;
32
+ readonly LEFT: 12;
33
+ };