@2112-lab/central-plant 0.3.57 → 0.3.59

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 (29) hide show
  1. package/dist/bundle/index.js +1696 -34
  2. package/dist/cjs/src/core/centralPlant.js +80 -11
  3. package/dist/cjs/src/core/centralPlantInternals.js +4 -0
  4. package/dist/cjs/src/core/centralPlantValidator.js +10 -6
  5. package/dist/cjs/src/core/stateEngine.js +733 -0
  6. package/dist/cjs/src/core/stateEngineScene.js +97 -0
  7. package/dist/cjs/src/index.js +10 -0
  8. package/dist/cjs/src/managers/controls/transformControlsManager.js +61 -2
  9. package/dist/cjs/src/managers/pathfinding/PathFlowManager.js +94 -13
  10. package/dist/cjs/src/managers/pathfinding/PathRenderingManager.js +15 -0
  11. package/dist/cjs/src/managers/scene/componentTooltipManager.js +7 -1
  12. package/dist/cjs/src/managers/scene/controlPanelManager.js +377 -0
  13. package/dist/cjs/src/managers/scene/sceneExportManager.js +10 -1
  14. package/dist/cjs/src/managers/state/EffectiveVisualManager.js +270 -0
  15. package/dist/esm/src/core/centralPlant.js +80 -11
  16. package/dist/esm/src/core/centralPlantInternals.js +4 -0
  17. package/dist/esm/src/core/centralPlantValidator.js +10 -6
  18. package/dist/esm/src/core/stateEngine.js +725 -0
  19. package/dist/esm/src/core/stateEngineScene.js +90 -0
  20. package/dist/esm/src/index.js +2 -0
  21. package/dist/esm/src/managers/controls/transformControlsManager.js +61 -2
  22. package/dist/esm/src/managers/pathfinding/PathFlowManager.js +94 -13
  23. package/dist/esm/src/managers/pathfinding/PathRenderingManager.js +15 -0
  24. package/dist/esm/src/managers/scene/componentTooltipManager.js +7 -1
  25. package/dist/esm/src/managers/scene/controlPanelManager.js +352 -0
  26. package/dist/esm/src/managers/scene/sceneExportManager.js +10 -1
  27. package/dist/esm/src/managers/state/EffectiveVisualManager.js +266 -0
  28. package/dist/index.d.ts +85 -0
  29. package/package.json +5 -2
package/dist/index.d.ts CHANGED
@@ -5,6 +5,91 @@
5
5
  * organized by their functional categories.
6
6
  */
7
7
 
8
+ // ─── State Engine ─────────────────────────────────────────────────────────────
9
+
10
+ export function makeAddress(scope: string, attribute: string): string
11
+ export function valuesEqual(a: unknown, b: unknown): boolean
12
+ export function offValue(desired: unknown): unknown
13
+
14
+ export interface StateChange {
15
+ address: string
16
+ desired: unknown
17
+ effective: unknown
18
+ }
19
+
20
+ /** One endpoint of a declared chain (scope + attribute). */
21
+ export interface ChainEndpoint {
22
+ /** Object/scope id, e.g. "pump-001" or "pump-001::start-switch". */
23
+ address: string
24
+ /** Attribute name, e.g. "power", "mode", "flow". */
25
+ attribute: string
26
+ }
27
+
28
+ /** The chain trigger; `source` selects which layer of the trigger to read. */
29
+ export interface ChainWhen extends ChainEndpoint {
30
+ /** Read the trigger's desired (default) or effective value. */
31
+ source?: 'desired' | 'effective'
32
+ }
33
+
34
+ /** A declared chain: when the trigger changes, copy its value to the target. */
35
+ export interface Chain {
36
+ /** Unique id within the scene. */
37
+ id?: string
38
+ /** Only 'copy' is supported today. */
39
+ action?: 'copy'
40
+ when: ChainWhen
41
+ set: ChainEndpoint
42
+ }
43
+
44
+ export interface StateEngineOptions {
45
+ /** Ripple hop limit per initiating change (Framework §11.2). Default 8. */
46
+ maxChainDepth?: number
47
+ /** Operational attributes gated to a safe-off value when power is off (§6/§10). */
48
+ gatedOperationalAttributes?: string[]
49
+ }
50
+
51
+ export declare class StateEngine {
52
+ constructor(options?: StateEngineOptions)
53
+ maxChainDepth: number
54
+ load(declaration?: Record<string, unknown>): void
55
+ reset(): void
56
+ getDesired(address: string): unknown
57
+ getEffective(address: string): unknown
58
+ getGroupsForObject(objectId: string): string[]
59
+ setDesired(address: string, value: unknown): boolean
60
+ /** Register a pipe/path so its `<pipeId>::flow` state exists (tied to lifecycle). */
61
+ registerPipe(pipeId: string, options?: { defaultFlow?: boolean }): string
62
+ /** Remove a pipe and all of its registry keys; returns the number removed. */
63
+ unregisterPipe(pipeId: string): number
64
+ subscribe(listener: (change: StateChange) => void): () => void
65
+ toRegistry(): Record<string, unknown>
66
+ /** Reconstruct the §17 scene declaration (round-trips with load). */
67
+ toDeclaration(): {
68
+ version: string
69
+ plant: Record<string, unknown>
70
+ groups: Record<string, unknown>
71
+ chains: Chain[]
72
+ stateRegistry: Record<string, unknown>
73
+ }
74
+ }
75
+
76
+ // ─── State Engine ⇄ scene glue (stateEngineScene.js) ────────────────────────
77
+
78
+ export function ioAddress(attachmentId: string, stateId: string, parentUuid?: string): string
79
+ export function parseIoAddress(
80
+ address: string
81
+ ): { parentUuid: string; attachmentId: string; stateId: string; scopedKey: string } | null
82
+ export function extractDeclaration(sceneData?: Record<string, unknown>): {
83
+ plant: Record<string, unknown>
84
+ groups: Record<string, unknown>
85
+ chains: Chain[]
86
+ stateRegistry: Record<string, unknown>
87
+ }
88
+ export function applyDeclarationToExport<T extends Record<string, unknown>>(
89
+ exportData: T,
90
+ engine: { toDeclaration: () => Record<string, unknown> }
91
+ ): T
92
+
8
93
  // ─── Connector flow types ─────────────────────────────────────────────────────
9
94
 
10
95
  /** The flow direction of a connector port. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2112-lab/central-plant",
3
- "version": "0.3.57",
3
+ "version": "0.3.59",
4
4
  "description": "Utility modules for the Central Plant Application",
5
5
  "main": "dist/bundle/index.js",
6
6
  "module": "dist/esm/src/index.js",
@@ -18,6 +18,8 @@
18
18
  "build": "rollup -c && npm run build:types",
19
19
  "build:types": "node -e \"require('fs').copyFileSync('src/index.d.ts', 'dist/index.d.ts')\"",
20
20
  "dev": "rollup -c -w",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest",
21
23
  "prepublishOnly": "npm run build",
22
24
  "docs": "jsdoc -c jsdoc.json",
23
25
  "release": "npm install @2112-lab/pathfinder@latest && npm version patch && npm publish"
@@ -46,6 +48,7 @@
46
48
  "regenerator-runtime": "^0.14.1",
47
49
  "rollup": "^2.79.1",
48
50
  "rollup-plugin-copy": "^3.5.0",
49
- "rollup-plugin-terser": "^7.0.2"
51
+ "rollup-plugin-terser": "^7.0.2",
52
+ "vitest": "^2.1.9"
50
53
  }
51
54
  }