energy-visualization-sankey 1.0.27 → 1.2.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.
- package/README.md +125 -0
- package/babel.config.cjs +18 -21
- package/dist/.tsbuildinfo +1 -0
- package/dist/sankey.esm.js +490 -160
- package/dist/sankey.esm.js.map +1 -1
- package/dist/sankey.umd.js +490 -160
- package/dist/sankey.umd.js.map +1 -1
- package/dist/types/core/Sankey.d.ts +60 -46
- package/dist/types/core/Sankey.d.ts.map +1 -1
- package/dist/types/core/types/public-events.d.ts +159 -0
- package/dist/types/core/types/public-events.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/services/AnimationService.d.ts.map +1 -1
- package/dist/types/services/InteractionService.d.ts.map +1 -1
- package/dist/types/services/data/DataValidationService.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +40 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/header.d.ts +54 -0
- package/dist/types/utils/header.d.ts.map +1 -0
- package/jest.config.cjs +22 -7
- package/package.json +3 -2
- package/src/core/Sankey.ts +291 -61
- package/src/core/types/public-events.ts +189 -0
- package/src/index.ts +23 -0
- package/src/services/AnimationService.ts +34 -19
- package/src/services/InteractionService.ts +49 -31
- package/src/services/data/DataValidationService.ts +8 -5
- package/src/types/index.ts +47 -0
- package/src/utils/header.ts +238 -0
- package/tests/event-bus.test.ts +137 -0
- package/tests/header.test.ts +198 -0
- package/tests/sankey-events.test.ts +289 -0
- package/tests/setup.js +13 -48
|
@@ -1,50 +1,5 @@
|
|
|
1
|
+
import type { SankeyEventListener, SankeyPublicEvent, SankeyPublicEventType, SankeyUnsubscribe } from './types/public-events';
|
|
1
2
|
import type { SankeyOptions } from '../index';
|
|
2
|
-
/**
|
|
3
|
-
* Main Sankey Visualization Class - Event-Driven Architecture Orchestrator
|
|
4
|
-
*
|
|
5
|
-
* ARCHITECTURE PATTERN: Service Orchestration with Event-Driven Communication
|
|
6
|
-
*
|
|
7
|
-
* This class implements the Orchestrator pattern from Clean Architecture,
|
|
8
|
-
* coordinating between focused, single-responsibility services through
|
|
9
|
-
* a type-safe event bus. It acts as the application boundary, managing
|
|
10
|
-
* the complete lifecycle from initialization to destruction.
|
|
11
|
-
*
|
|
12
|
-
* SERVICE COMPOSITION ARCHITECTURE:
|
|
13
|
-
* 1. Infrastructure Layer: ConfigurationService (mathematical constants)
|
|
14
|
-
* 2. Data Layer: DataService, ValidationService, TransformService
|
|
15
|
-
* 3. Calculation Layer: SummaryService, GraphService, PositionService
|
|
16
|
-
* 4. Presentation Layer: RenderingService, AnimationService
|
|
17
|
-
* 5. Interaction Layer: InteractionService, TooltipService
|
|
18
|
-
*
|
|
19
|
-
* DEPENDENCY INJECTION PATTERN:
|
|
20
|
-
* - Constructor Injection: Services receive dependencies via constructor
|
|
21
|
-
* - Service Locator: Services are registered in central container
|
|
22
|
-
* - Event Bus Mediation: Services communicate without direct coupling
|
|
23
|
-
* - Lifecycle Management: Services created in dependency order
|
|
24
|
-
*
|
|
25
|
-
* EVENT-DRIVEN COMMUNICATION BENEFITS:
|
|
26
|
-
* - Loose Coupling: Services don't hold references to each other
|
|
27
|
-
* - Testability: Services can be mocked and tested in isolation
|
|
28
|
-
* - Maintainability: Changes to one service don't affect others
|
|
29
|
-
* - Performance: Async event dispatch prevents blocking operations
|
|
30
|
-
*
|
|
31
|
-
* PUBLIC API COMPATIBILITY:
|
|
32
|
-
* Maintains complete API compatibility with previous versions while
|
|
33
|
-
* providing enhanced functionality including configurable animation
|
|
34
|
-
* looping, improved error handling, and comprehensive performance monitoring.
|
|
35
|
-
*
|
|
36
|
-
* Usage Example:
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const sankey = new SankeyVisualization('container', {
|
|
39
|
-
* data: energyData,
|
|
40
|
-
* includeControls: true,
|
|
41
|
-
* loopAnimation: false
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* // Chain-able API maintained for compatibility
|
|
45
|
-
* sankey.play().setSpeed(100).setYear(2020);
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
3
|
export default class Sankey {
|
|
49
4
|
private readonly eventBus;
|
|
50
5
|
private services;
|
|
@@ -57,6 +12,10 @@ export default class Sankey {
|
|
|
57
12
|
private wasteHeatVisible;
|
|
58
13
|
private readonly logger;
|
|
59
14
|
private subscriptions;
|
|
15
|
+
private publicListeners;
|
|
16
|
+
private readonly readyPromise;
|
|
17
|
+
private resolveReady;
|
|
18
|
+
private rejectReady;
|
|
60
19
|
constructor(containerId: string | HTMLElement, options: SankeyOptions);
|
|
61
20
|
/**
|
|
62
21
|
* Initialize the visualization system with layered service creation
|
|
@@ -216,6 +175,22 @@ export default class Sankey {
|
|
|
216
175
|
* Setup system-level event listeners
|
|
217
176
|
*/
|
|
218
177
|
private setupSystemEventListeners;
|
|
178
|
+
/**
|
|
179
|
+
* Register handlers supplied through the `events` constructor option.
|
|
180
|
+
* Runs before initialize() so that no lifecycle event is dropped.
|
|
181
|
+
*/
|
|
182
|
+
private registerConfiguredEventHandlers;
|
|
183
|
+
/**
|
|
184
|
+
* Shared registration path for on(), once() and the `events` option.
|
|
185
|
+
*
|
|
186
|
+
* @param identity what off() matches on - the handler the caller passed
|
|
187
|
+
* @param invoke what actually runs, which differs from identity for once()
|
|
188
|
+
*/
|
|
189
|
+
private addListener;
|
|
190
|
+
/**
|
|
191
|
+
* Remove a single public subscription and its bus registration
|
|
192
|
+
*/
|
|
193
|
+
private removeListener;
|
|
219
194
|
/**
|
|
220
195
|
* Handle initialization errors
|
|
221
196
|
*/
|
|
@@ -261,6 +236,45 @@ export default class Sankey {
|
|
|
261
236
|
* @returns True if initialization is complete and visualization is ready
|
|
262
237
|
*/
|
|
263
238
|
isInitialized(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Subscribe to a visualization event
|
|
241
|
+
*
|
|
242
|
+
* Handlers run asynchronously, one microtask after the event is produced,
|
|
243
|
+
* and are error-isolated: a throwing handler cannot break the visualization
|
|
244
|
+
* or prevent other handlers from running.
|
|
245
|
+
*
|
|
246
|
+
* LIFECYCLE TIMING: `system.ready` and `system.error` are produced during the
|
|
247
|
+
* asynchronous initialization the constructor starts. Subscribing in the same
|
|
248
|
+
* synchronous tick as `new Sankey(...)` is soon enough; subscribing later (for
|
|
249
|
+
* example after `await nextTick()`) is not. For those, use the `events`
|
|
250
|
+
* constructor option or {@link whenReady}.
|
|
251
|
+
*
|
|
252
|
+
* Registering the same function twice registers it twice and it is called
|
|
253
|
+
* twice; each call returns its own unsubscribe.
|
|
254
|
+
*
|
|
255
|
+
* @returns an unsubscribe function, safe to call more than once
|
|
256
|
+
*/
|
|
257
|
+
on<K extends SankeyPublicEventType>(type: K, handler: SankeyEventListener<K>): SankeyUnsubscribe;
|
|
258
|
+
/**
|
|
259
|
+
* Subscribe until the first delivery, then unsubscribe automatically
|
|
260
|
+
*
|
|
261
|
+
* Cancellable either with the returned function or with `off(type, handler)`.
|
|
262
|
+
*/
|
|
263
|
+
once<K extends SankeyPublicEventType>(type: K, handler: SankeyEventListener<K>): SankeyUnsubscribe;
|
|
264
|
+
/**
|
|
265
|
+
* Remove every registration of `handler` for `type`, including a pending once()
|
|
266
|
+
*
|
|
267
|
+
* Removes all matching registrations rather than one, so teardown code
|
|
268
|
+
* reliably stops delivery. No-op if the handler was never registered.
|
|
269
|
+
*/
|
|
270
|
+
off<K extends SankeyPublicEventType>(type: K, handler: SankeyEventListener<K>): this;
|
|
271
|
+
/**
|
|
272
|
+
* Resolve when initialization completes, or reject if it failed
|
|
273
|
+
*
|
|
274
|
+
* Unlike `on('system.ready', ...)` this is a latch: it resolves even when
|
|
275
|
+
* called long after the event was emitted. Safe to call any number of times.
|
|
276
|
+
*/
|
|
277
|
+
whenReady(): Promise<SankeyPublicEvent<'system.ready'>>;
|
|
264
278
|
/**
|
|
265
279
|
* Get array of available years in dataset
|
|
266
280
|
* @returns Readonly array of years available for visualization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sankey.d.ts","sourceRoot":"","sources":["../../../src/core/Sankey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sankey.d.ts","sourceRoot":"","sources":["../../../src/core/Sankey.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACR,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EAErB,iBAAiB,EACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAA6D,aAAa,EAAC,MAAM,SAAS,CAAC;AAyEvG,MAAM,CAAC,OAAO,OAAO,MAAM;IAIvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IAKpC,OAAO,CAAC,QAAQ,CAoBT;IAMP,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,GAAG,CAA+B;IAC1C,OAAO,CAAC,OAAO,CAA+B;IAM9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAKhC,OAAO,CAAC,aAAa,CAA2B;IAKhD,OAAO,CAAC,eAAe,CAA8B;IAIrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6C;IAC1E,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,WAAW,CAA0B;gBAEjC,WAAW,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,EAAE,aAAa;IAuCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;YACW,UAAU;IA4JxB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;YACW,0BAA0B;IAcxC;;;;;;;;;;;;;OAaG;YACW,kBAAkB;IAqBhC;;;;;;;;;;;;;;;;OAgBG;YACW,yBAAyB;IAmB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,CAAC,CAAC,GAChC,IAAI;IASP;;;;;OAKG;IACI,SAAS,IAAI,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAI9D;;;OAGG;IACI,QAAQ,IAAI,SAAS,MAAM,EAAE;IAIpC;;;OAGG;IACI,cAAc,IAAI,GAAG;IAI5B;;;OAGG;IACI,eAAe,IAAI,IAAI;IAwB9B;;;OAGG;IACI,kBAAkB,IAAI,OAAO;IAIpC;;;OAGG;IACI,OAAO,IAAI,IAAI;IAmDtB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,wBAAwB;CAYnC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public Event Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* The curated, consumer-facing subset of the internal event system. Everything
|
|
5
|
+
* declared here is part of the published API surface and is covered by semver.
|
|
6
|
+
* The internal union in ./events.ts is NOT: it carries service-coordination
|
|
7
|
+
* channels and several declared-but-never-emitted types.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately excluded from the public map:
|
|
10
|
+
* - 'system.initialized' Three unrelated payloads from three sources
|
|
11
|
+
* (Sankey, ConfigurationService, InteractionService), two
|
|
12
|
+
* of which fire synchronously inside the constructor. The
|
|
13
|
+
* Sankey payload is {services: [], initTime: 0} - both
|
|
14
|
+
* fields are permanently dead. Use 'system.ready'.
|
|
15
|
+
* - 'data.loaded' Payload embeds a full copy of the dataset. Handing that
|
|
16
|
+
* to an analytics layer invites someone serializing it.
|
|
17
|
+
* - 'data.validated' Internal; 'system.ready' carries the same metadata.
|
|
18
|
+
* - 'rendering.completed' Fires exactly once per instance, immediately before
|
|
19
|
+
* 'system.ready', which carries strictly better data.
|
|
20
|
+
* - 'calculation.completed', 'year.changing', 'timeline.updated',
|
|
21
|
+
* 'rendering.started', 'dimensions.changed'
|
|
22
|
+
* Declared in SankeyEventType but never emitted anywhere.
|
|
23
|
+
* Publishing a typed key for an event that never fires is
|
|
24
|
+
* a promise the library does not keep.
|
|
25
|
+
*
|
|
26
|
+
* Adding a key to SankeyEventMap later is purely additive, so this map starts
|
|
27
|
+
* narrow on purpose.
|
|
28
|
+
*/
|
|
29
|
+
/** Classification of the SVG element under the pointer. */
|
|
30
|
+
export type SankeyElementType = 'flow' | 'box';
|
|
31
|
+
/** Viewport coordinates of a pointer interaction. */
|
|
32
|
+
export interface SankeyMousePosition {
|
|
33
|
+
readonly x: number;
|
|
34
|
+
readonly y: number;
|
|
35
|
+
}
|
|
36
|
+
/** Payload of `system.ready`. Emitted once, after the first frame is rendered. */
|
|
37
|
+
export interface SankeyReadyEventData {
|
|
38
|
+
/** Wall-clock milliseconds from construction to first rendered frame. */
|
|
39
|
+
readonly totalInitTime: number;
|
|
40
|
+
readonly dataPointCount: number;
|
|
41
|
+
/** Earliest and latest year present in the dataset. */
|
|
42
|
+
readonly yearRange: readonly [number, number];
|
|
43
|
+
}
|
|
44
|
+
/** Payload of `system.error`. */
|
|
45
|
+
export interface SankeyErrorEventData {
|
|
46
|
+
readonly error: Error;
|
|
47
|
+
readonly context: 'initialization' | 'data_validation';
|
|
48
|
+
readonly recoverable: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Payload of `year.changed`.
|
|
52
|
+
*
|
|
53
|
+
* `isAnimating` distinguishes a user scrubbing the timeline from the animation
|
|
54
|
+
* advancing on its own. A full playthrough emits one event per year in the
|
|
55
|
+
* dataset, so analytics consumers should filter on this flag rather than
|
|
56
|
+
* forwarding every occurrence.
|
|
57
|
+
*/
|
|
58
|
+
export interface SankeyYearChangedEventData {
|
|
59
|
+
readonly year: number;
|
|
60
|
+
readonly previousYear: number;
|
|
61
|
+
readonly yearIndex: number;
|
|
62
|
+
readonly isAnimating: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Payload of `animation.started` and `animation.stopped`. */
|
|
65
|
+
export interface SankeyAnimationEventData {
|
|
66
|
+
readonly isPlaying: boolean;
|
|
67
|
+
readonly currentYear: number;
|
|
68
|
+
/** Milliseconds per year. */
|
|
69
|
+
readonly speed: number;
|
|
70
|
+
}
|
|
71
|
+
/** Payload of `speed.changed`. */
|
|
72
|
+
export interface SankeySpeedChangedEventData {
|
|
73
|
+
readonly speed: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Payload of `interaction.hover` and `interaction.click`.
|
|
77
|
+
*
|
|
78
|
+
* `fuel` and `sector` are read from the `data-fuel` / `data-sector` attributes
|
|
79
|
+
* and are genuinely null for elements that do not carry them.
|
|
80
|
+
*/
|
|
81
|
+
export interface SankeyElementInteractionEventData {
|
|
82
|
+
readonly elementType: SankeyElementType;
|
|
83
|
+
readonly fuel: string | null;
|
|
84
|
+
readonly sector: string | null;
|
|
85
|
+
readonly mousePosition: SankeyMousePosition;
|
|
86
|
+
}
|
|
87
|
+
/** Payload of `interaction.keypress`. */
|
|
88
|
+
export interface SankeyKeypressEventData {
|
|
89
|
+
readonly key: string;
|
|
90
|
+
readonly ctrlKey: boolean;
|
|
91
|
+
readonly shiftKey: boolean;
|
|
92
|
+
readonly altKey: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** Payload of `interaction.slider`. */
|
|
95
|
+
export interface SankeySliderEventData {
|
|
96
|
+
readonly year: number;
|
|
97
|
+
/** Duplicate of `year`, retained for backwards compatibility. */
|
|
98
|
+
readonly value: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Payload of `interaction.button`. Discriminated on `action`, which is a literal
|
|
102
|
+
* at both emit sites.
|
|
103
|
+
*/
|
|
104
|
+
export type SankeyButtonEventData = {
|
|
105
|
+
readonly buttonId: 'evs-play-button';
|
|
106
|
+
readonly action: 'play' | 'pause';
|
|
107
|
+
/** Never present for play/pause. Declared so `data.speed` reads without narrowing. */
|
|
108
|
+
readonly speed?: undefined;
|
|
109
|
+
} | {
|
|
110
|
+
readonly buttonId: string;
|
|
111
|
+
readonly action: 'speed-change';
|
|
112
|
+
readonly speed: number;
|
|
113
|
+
};
|
|
114
|
+
/** Maps every public event type to its payload. */
|
|
115
|
+
export interface SankeyEventMap {
|
|
116
|
+
'system.ready': SankeyReadyEventData;
|
|
117
|
+
'system.error': SankeyErrorEventData;
|
|
118
|
+
'year.changed': SankeyYearChangedEventData;
|
|
119
|
+
'animation.started': SankeyAnimationEventData;
|
|
120
|
+
'animation.stopped': SankeyAnimationEventData;
|
|
121
|
+
'speed.changed': SankeySpeedChangedEventData;
|
|
122
|
+
/** High frequency: fires on every mouseover. Debounce or sample before forwarding. */
|
|
123
|
+
'interaction.hover': SankeyElementInteractionEventData;
|
|
124
|
+
'interaction.click': SankeyElementInteractionEventData;
|
|
125
|
+
'interaction.keypress': SankeyKeypressEventData;
|
|
126
|
+
'interaction.slider': SankeySliderEventData;
|
|
127
|
+
'interaction.button': SankeyButtonEventData;
|
|
128
|
+
}
|
|
129
|
+
/** Name of a public event. */
|
|
130
|
+
export type SankeyPublicEventType = keyof SankeyEventMap;
|
|
131
|
+
/**
|
|
132
|
+
* Event envelope.
|
|
133
|
+
*
|
|
134
|
+
* Distributive on purpose: the defaulted `SankeyPublicEvent` is a discriminated
|
|
135
|
+
* union, so a generic forwarder can `switch (event.type)` and narrow
|
|
136
|
+
* `event.data`. A plain generic interface would collapse to
|
|
137
|
+
* `{type: <every key>, data: <union of every payload>}`, which cannot narrow.
|
|
138
|
+
*/
|
|
139
|
+
export type SankeyPublicEvent<K extends SankeyPublicEventType = SankeyPublicEventType> = K extends SankeyPublicEventType ? {
|
|
140
|
+
readonly type: K;
|
|
141
|
+
readonly timestamp: number;
|
|
142
|
+
/** Emitting component, e.g. 'InteractionService'. Diagnostic only; not stable. */
|
|
143
|
+
readonly source: string;
|
|
144
|
+
readonly data: SankeyEventMap[K];
|
|
145
|
+
} : never;
|
|
146
|
+
/**
|
|
147
|
+
* Handler for a single public event type.
|
|
148
|
+
*
|
|
149
|
+
* Handlers are error-isolated: a throw cannot break the visualization or stop
|
|
150
|
+
* other handlers. A returned promise's rejection is caught and logged.
|
|
151
|
+
*/
|
|
152
|
+
export type SankeyEventListener<K extends SankeyPublicEventType = SankeyPublicEventType> = (event: SankeyPublicEvent<K>) => void | Promise<void>;
|
|
153
|
+
/** Returned by `on()` and `once()`. Idempotent. */
|
|
154
|
+
export type SankeyUnsubscribe = () => void;
|
|
155
|
+
/** Shape of the `events` constructor option. */
|
|
156
|
+
export type SankeyEventHandlers = {
|
|
157
|
+
readonly [K in SankeyPublicEventType]?: SankeyEventListener<K>;
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=public-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-events.d.ts","sourceRoot":"","sources":["../../../../src/core/types/public-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,KAAK,CAAC;AAE/C,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,oBAAoB;IACjC,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD;AAED,iCAAiC;AACjC,MAAM,WAAW,oBAAoB;IACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B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AAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1D,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAE3C,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,EAAE,CAAC,IAAI,qBAAqB,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC;CACjE,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @author Research Computing Center (RCC), University of Chicago
|
|
15
15
|
*/
|
|
16
|
-
export type { SankeyOptions, EnergyDataPoint, SummaryData, GraphData, YearTotals, BoxMaxes, BoxTops } from './types/index';
|
|
16
|
+
export type { SankeyOptions, SankeyHeaderOptions, SankeyHeaderLogo, EnergyDataPoint, SummaryData, GraphData, YearTotals, BoxMaxes, BoxTops } from './types/index';
|
|
17
17
|
export { SankeyError, DataValidationError } from './types/index';
|
|
18
|
+
export type { SankeyEventMap, SankeyPublicEventType, SankeyPublicEvent, SankeyEventListener, SankeyEventHandlers, SankeyUnsubscribe, SankeyElementType, SankeyMousePosition, SankeyReadyEventData, SankeyErrorEventData, SankeyYearChangedEventData, SankeyAnimationEventData, SankeySpeedChangedEventData, SankeyElementInteractionEventData, SankeyKeypressEventData, SankeySliderEventData, SankeyButtonEventData } from './core/types/public-events';
|
|
18
19
|
export { default as default } from './core/Sankey';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,YAAY,EACR,aAAa,EACb,eAAe,EACf,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,OAAO,EACV,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,WAAW,EACX,mBAAmB,EACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,YAAY,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,OAAO,EACV,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,WAAW,EACX,mBAAmB,EACtB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACR,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationService.d.ts","sourceRoot":"","sources":["../../../src/services/AnimationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnimationService.d.ts","sourceRoot":"","sources":["../../../src/services/AnimationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAMhD,OAAO,EAAC,cAAc,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ACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA8BpC;;OAEG;IACI,SAAS,IAAI,OAAO;IAI3B;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,QAAQ,IAAI,IAAI;IAOvB;;OAEG;IACI,YAAY,IAAI,IAAI;IAO3B;;OAEG;IACI,OAAO,IAAI,IAAI;CAazB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionService.d.ts","sourceRoot":"","sources":["../../../src/services/InteractionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"InteractionService.d.ts","sourceRoot":"","sources":["../../../src/services/InteractionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAOhD,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAItC,KAAK,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AAC7E,KAAK,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AAE9E,UAAU,gBAAgB;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;CACrC;AAED,UAAU,mBAAmB;IACzB,cAAc,CAAC,EA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0BG;IACH,OAAO,CAAC,uBAAuB;IAoE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,0BAA0B;IA4ClC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,kBAAkB;IAqC1B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;OAEG;IACI,sBAAsB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAKlE;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,OAAO,IAAI,IAAI;IAkCtB;;OAEG;IACI,mBAAmB,IAAI,QAAQ,CAAC,gBAAgB,CAAC;IAIxD;;OAEG;IACI,oBAAoB,IAAI,OAAO;IAItC;;OAEG;IACI,mBAAmB,IAAI;QAC1B,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,OAAO,CAAC;QACzB,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C;IASD;;OAEG;IACI,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAWlD;;OAEG;IACI,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAUrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataValidationService.d.ts","sourceRoot":"","sources":["../../../../src/services/data/DataValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DataValidationService.d.ts","sourceRoot":"","sources":["../../../../src/services/data/DataValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,qBAAqB;IAClB,OAAO,CAAC,oBAAoB;IAAwB,OAAO,CAAC,QAAQ;IAAY,OAAO,CAAC,MAAM;gBAAtF,oBAAoB,EAAE,oBAAoB,EAAU,QAAQ,EAAE,QAAQ,EAAU,MAAM,EAAE,MAAM;IAGlH;;;;;OAKG;IACI,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI;CA8GrD"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* - Generic types for flexible service composition
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
+
import type { SankeyEventHandlers } from '../core/types/public-events';
|
|
21
22
|
export declare class SankeyError extends Error {
|
|
22
23
|
code?: string | undefined;
|
|
23
24
|
constructor(message: string, code?: string | undefined);
|
|
@@ -51,6 +52,34 @@ export interface EnergyDataPoint {
|
|
|
51
52
|
readonly petro: EnergySectorBreakdown;
|
|
52
53
|
readonly heat: EnergySectorBreakdown;
|
|
53
54
|
}
|
|
55
|
+
/** Logo shown at the left of the header. `src` and `href` must be https:// URLs. */
|
|
56
|
+
export interface SankeyHeaderLogo {
|
|
57
|
+
readonly src: string;
|
|
58
|
+
readonly href?: string;
|
|
59
|
+
readonly alt?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Text and logo of the header above the chart.
|
|
63
|
+
*
|
|
64
|
+
* For every field: leave it out to keep the default, set it to `null` to hide
|
|
65
|
+
* that element. Text fields and affiliation lines may use the placeholders
|
|
66
|
+
* `{country}`, `{firstYear}` and `{lastYear}`. All values are rendered as text,
|
|
67
|
+
* never as HTML.
|
|
68
|
+
*
|
|
69
|
+
* The animated W/capita total and year are always shown, whatever is hidden.
|
|
70
|
+
*/
|
|
71
|
+
export interface SankeyHeaderOptions {
|
|
72
|
+
/** Default: `"{country} energy usage"` */
|
|
73
|
+
readonly title?: string | null;
|
|
74
|
+
/** Default: `"Energy Transitions in {country} History, {firstYear}-{lastYear}"` */
|
|
75
|
+
readonly subtitle?: string | null;
|
|
76
|
+
/** Default: `"Suits, Matteson, and Moyer (2020)"` */
|
|
77
|
+
readonly attribution?: string | null;
|
|
78
|
+
/** One entry per line. Default: the two RDCEP affiliation lines. */
|
|
79
|
+
readonly affiliation?: readonly string[] | null;
|
|
80
|
+
/** Default: the RDCEP logo linking to https://www.rdcep.org/ */
|
|
81
|
+
readonly logo?: SankeyHeaderLogo | null;
|
|
82
|
+
}
|
|
54
83
|
export interface SankeyOptions {
|
|
55
84
|
readonly data: EnergyDataPoint[];
|
|
56
85
|
readonly country: string;
|
|
@@ -71,6 +100,17 @@ export interface SankeyOptions {
|
|
|
71
100
|
readonly heatBoxY?: number;
|
|
72
101
|
readonly loopAnimation?: boolean;
|
|
73
102
|
readonly debugLogging?: boolean;
|
|
103
|
+
readonly header?: SankeyHeaderOptions;
|
|
104
|
+
/**
|
|
105
|
+
* Event handlers registered before asynchronous initialization begins.
|
|
106
|
+
*
|
|
107
|
+
* Prefer this over `.on()` for lifecycle events. `system.ready` and
|
|
108
|
+
* `system.error` are produced during the initialization the constructor
|
|
109
|
+
* starts, and the event bus drops events that have no subscriber at emit
|
|
110
|
+
* time, so a subscription added later can miss them entirely. Interaction
|
|
111
|
+
* events can be attached either way.
|
|
112
|
+
*/
|
|
113
|
+
readonly events?: SankeyEventHandlers;
|
|
74
114
|
}
|
|
75
115
|
export interface GraphPoint {
|
|
76
116
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version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AM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAGD,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACpF,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header configuration: defaults, validation, placeholder substitution and
|
|
3
|
+
* HTML rendering for the title block above the chart.
|
|
4
|
+
*
|
|
5
|
+
* Every value that reaches the markup goes through escapeHtml(). Header text and
|
|
6
|
+
* `country` come from host configuration that, in the Energy Visualization
|
|
7
|
+
* Platform, is user-entered and rendered on public share pages, so they must
|
|
8
|
+
* never be interpreted as HTML.
|
|
9
|
+
*/
|
|
10
|
+
import type { SankeyHeaderOptions } from '../index';
|
|
11
|
+
export interface HeaderContext {
|
|
12
|
+
readonly country: string;
|
|
13
|
+
readonly firstYear: number;
|
|
14
|
+
readonly lastYear: number;
|
|
15
|
+
}
|
|
16
|
+
/** Fully resolved header: `null` means the element is not rendered. */
|
|
17
|
+
export interface ResolvedHeader {
|
|
18
|
+
readonly title: string | null;
|
|
19
|
+
readonly subtitle: string | null;
|
|
20
|
+
readonly attribution: string | null;
|
|
21
|
+
readonly affiliation: readonly string[] | null;
|
|
22
|
+
readonly logo: {
|
|
23
|
+
readonly src: string;
|
|
24
|
+
readonly href: string | null;
|
|
25
|
+
readonly alt: string;
|
|
26
|
+
} | null;
|
|
27
|
+
}
|
|
28
|
+
/** The header shown when no `header` option is given (unchanged from earlier releases). */
|
|
29
|
+
export declare const DEFAULT_HEADER: {
|
|
30
|
+
readonly title: "{country} energy usage";
|
|
31
|
+
readonly subtitle: "Energy Transitions in {country} History, {firstYear}-{lastYear}";
|
|
32
|
+
readonly attribution: "Suits, Matteson, and Moyer (2020)";
|
|
33
|
+
readonly affiliation: readonly ["Center for Robust Decision-making on", "Climate and Energy Policy, UChicago"];
|
|
34
|
+
readonly logo: {
|
|
35
|
+
readonly src: "https://images.squarespace-cdn.com/content/v1/54dcfad0e4b0eaff5e0068bf/1446137765478-FX9WM00VV1LWAFUJRZBI/rdcep+sig2.png";
|
|
36
|
+
readonly href: "https://www.rdcep.org/";
|
|
37
|
+
readonly alt: "The Center for Robust Decision-making on Climate and Energy Policy (RDCEP)";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare function escapeHtml(value: string): string;
|
|
41
|
+
export declare function isHttpsUrl(value: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Validate the shape of the `header` option. Throws SankeyError so a bad
|
|
44
|
+
* configuration fails at construction time, like the existing data checks.
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateHeaderOptions(header: unknown): void;
|
|
47
|
+
export declare function resolveHeader(header: SankeyHeaderOptions | undefined, context: HeaderContext): ResolvedHeader;
|
|
48
|
+
/**
|
|
49
|
+
* Render the header block. The `.evs-energy-usage-overlay` and
|
|
50
|
+
* `.evs-year-overlay` containers are always emitted: RenderingService mounts the
|
|
51
|
+
* animated W/capita total and year into them, whatever text is hidden.
|
|
52
|
+
*/
|
|
53
|
+
export declare function renderHeaderHtml(header: ResolvedHeader): string;
|
|
54
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/utils/header.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAmB,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC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js|jsx)$': 'babel-jest',
|
|
5
|
+
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
|
6
6
|
},
|
|
7
7
|
testMatch: [
|
|
8
|
-
'<rootDir>/tests/**/*.test.js'
|
|
8
|
+
'<rootDir>/tests/**/*.test.js',
|
|
9
|
+
'<rootDir>/tests/**/*.test.ts'
|
|
10
|
+
],
|
|
11
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
|
12
|
+
moduleNameMapper: {
|
|
13
|
+
// d3 v7 is ESM-only ("type": "module", exports.default -> ./src/index.js)
|
|
14
|
+
// and pulls in roughly 30 ESM subpackages (d3-array, d3-selection,
|
|
15
|
+
// delaunator, ...). Resolving to the prebuilt UMD bundle is far cheaper
|
|
16
|
+
// and more robust than babel-transforming all of node_modules.
|
|
17
|
+
'^d3$': '<rootDir>/node_modules/d3/dist/d3.js',
|
|
18
|
+
// Mirrors the tsconfig "paths" entries. The exact '@/types' mapping MUST
|
|
19
|
+
// come before the wildcard: moduleNameMapper is evaluated in key order.
|
|
20
|
+
'^@/types$': '<rootDir>/src/types/index.ts',
|
|
21
|
+
'^@/(.*)$': '<rootDir>/src/$1'
|
|
22
|
+
},
|
|
23
|
+
// Back to the Jest default now that d3 resolves to a UMD file.
|
|
24
|
+
transformIgnorePatterns: [
|
|
25
|
+
'/node_modules/'
|
|
9
26
|
],
|
|
10
|
-
moduleFileExtensions: ['js', 'json'],
|
|
11
27
|
collectCoverageFrom: [
|
|
12
28
|
'src/**/*.{ts,js}',
|
|
13
29
|
'!src/**/*.d.ts',
|
|
14
30
|
'!src/types/**/*'
|
|
15
|
-
],
|
|
16
|
-
// Allow importing the standalone ESM build in tests
|
|
17
|
-
transformIgnorePatterns: [
|
|
18
|
-
'node_modules/(?!(d3|internmap)/)'
|
|
19
31
|
]
|
|
32
|
+
// NOTE: never add a test that imports from dist/. `prepublishOnly` runs
|
|
33
|
+
// `clean` (which deletes dist/) BEFORE `test:ci`, so such a test would break
|
|
34
|
+
// publishing. Tests import from src/ through the aliases above.
|
|
20
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "energy-visualization-sankey",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A modern TypeScript library for creating interactive Sankey diagrams that visualize energy flows from sources to consumption sectors.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sankey",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"validate:quick": "npm run test:numerical",
|
|
49
49
|
"validate:full": "npm run test:numerical && npm run build && npm run serve & sleep 3 && npm run test:visual && npm run test:performance && kill %1",
|
|
50
50
|
"validate": "npm run validate:full",
|
|
51
|
-
"prepublishOnly": "npm run clean && npm run test:ci && npm run build"
|
|
51
|
+
"prepublishOnly": "npm run clean && npm run type-check && npm run test:ci && npm run build"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"d3": "^7.8.5"
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/core": "^7.23.0",
|
|
58
58
|
"@babel/preset-env": "^7.23.0",
|
|
59
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
59
60
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
60
61
|
"@rollup/plugin-terser": "^0.4.4",
|
|
61
62
|
"@rollup/plugin-typescript": "^11.1.5",
|