@tellegen/svelte 0.4.3 → 0.4.5

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 (115) hide show
  1. package/README.md +45 -0
  2. package/dist/TellegenMap.svelte +63 -22
  3. package/dist/TellegenProvider.svelte +7 -4
  4. package/dist/TellegenShell.svelte +12 -1
  5. package/dist/TellegenViewer.svelte +2 -0
  6. package/dist/basemap.d.ts +14 -0
  7. package/dist/basemap.js +27 -0
  8. package/dist/colors.d.ts +6 -1
  9. package/dist/colors.js +11 -4
  10. package/dist/components/DiagnosticLogView.svelte +176 -0
  11. package/dist/components/DiagnosticLogView.svelte.d.ts +11 -0
  12. package/dist/components/FormulationSelector.svelte +1 -1
  13. package/dist/components/LocalCaseDetails.svelte +18 -3
  14. package/dist/components/LogEntryView.svelte +188 -0
  15. package/dist/components/LogEntryView.svelte.d.ts +11 -0
  16. package/dist/components/LogPanel.svelte +25 -0
  17. package/dist/components/LogPanel.svelte.d.ts +3 -0
  18. package/dist/components/McResults.svelte +18 -3
  19. package/dist/components/McWorkbench.svelte +688 -0
  20. package/dist/components/McWorkbench.svelte.d.ts +38 -0
  21. package/dist/components/MultiWire.svelte +136 -0
  22. package/dist/components/MultiWire.svelte.d.ts +7 -0
  23. package/dist/components/MulticonductorDetails.svelte +7 -0
  24. package/dist/components/NotificationCenter.svelte +37 -6
  25. package/dist/components/OmniSearch.svelte +163 -0
  26. package/dist/components/OmniSearch.svelte.d.ts +14 -0
  27. package/dist/components/ResultsTable.svelte +259 -0
  28. package/dist/components/ResultsTable.svelte.d.ts +13 -0
  29. package/dist/components/SchematicCanvas.svelte +1896 -0
  30. package/dist/components/SchematicCanvas.svelte.d.ts +13 -0
  31. package/dist/components/SolveCard.svelte +6 -0
  32. package/dist/components/schematic/PickCard.svelte +126 -0
  33. package/dist/components/schematic/PickCard.svelte.d.ts +56 -0
  34. package/dist/components/schematic/export.d.ts +21 -0
  35. package/dist/components/schematic/export.js +110 -0
  36. package/dist/components/schematic/layers.d.ts +161 -0
  37. package/dist/components/schematic/layers.js +756 -0
  38. package/dist/components/schematic/paint.d.ts +28 -0
  39. package/dist/components/schematic/paint.js +69 -0
  40. package/dist/components/schematic/palette.d.ts +34 -0
  41. package/dist/components/schematic/palette.js +54 -0
  42. package/dist/components/schematic/text.d.ts +83 -0
  43. package/dist/components/schematic/text.js +190 -0
  44. package/dist/components/schematic/view-prefs.svelte.d.ts +30 -0
  45. package/dist/components/schematic/view-prefs.svelte.js +77 -0
  46. package/dist/components.d.ts +4 -0
  47. package/dist/components.js +4 -0
  48. package/dist/context.svelte.d.ts +2 -0
  49. package/dist/context.svelte.js +2 -0
  50. package/dist/controller.svelte.d.ts +40 -5
  51. package/dist/controller.svelte.js +230 -25
  52. package/dist/diagram/basemap.d.ts +28 -0
  53. package/dist/diagram/basemap.js +39 -0
  54. package/dist/diagram/bus-stacks.d.ts +19 -0
  55. package/dist/diagram/bus-stacks.js +99 -0
  56. package/dist/diagram/colour-modes.d.ts +18 -0
  57. package/dist/diagram/colour-modes.js +33 -0
  58. package/dist/diagram/connections.d.ts +30 -0
  59. package/dist/diagram/connections.js +129 -0
  60. package/dist/diagram/display-tree.d.ts +21 -0
  61. package/dist/diagram/display-tree.js +65 -0
  62. package/dist/diagram/energisation.d.ts +10 -0
  63. package/dist/diagram/energisation.js +31 -0
  64. package/dist/diagram/feeders.d.ts +30 -0
  65. package/dist/diagram/feeders.js +57 -0
  66. package/dist/diagram/galvanic-zones.d.ts +60 -0
  67. package/dist/diagram/galvanic-zones.js +210 -0
  68. package/dist/diagram/graph-inputs.d.ts +18 -0
  69. package/dist/diagram/graph-inputs.js +103 -0
  70. package/dist/diagram/index.d.ts +28 -0
  71. package/dist/diagram/index.js +28 -0
  72. package/dist/diagram/landmarks.d.ts +50 -0
  73. package/dist/diagram/landmarks.js +153 -0
  74. package/dist/diagram/layout-morph.d.ts +15 -0
  75. package/dist/diagram/layout-morph.js +32 -0
  76. package/dist/diagram/multi-wire.d.ts +44 -0
  77. package/dist/diagram/multi-wire.js +65 -0
  78. package/dist/diagram/phase-bars.d.ts +35 -0
  79. package/dist/diagram/phase-bars.js +44 -0
  80. package/dist/diagram/results-table.d.ts +47 -0
  81. package/dist/diagram/results-table.js +173 -0
  82. package/dist/diagram/schematic-equipment.d.ts +133 -0
  83. package/dist/diagram/schematic-equipment.js +645 -0
  84. package/dist/diagram/schematic-layout.d.ts +51 -0
  85. package/dist/diagram/schematic-layout.js +240 -0
  86. package/dist/diagram/search.d.ts +36 -0
  87. package/dist/diagram/search.js +48 -0
  88. package/dist/diagram/shared-routes.d.ts +21 -0
  89. package/dist/diagram/shared-routes.js +40 -0
  90. package/dist/diagram/short-names.d.ts +11 -0
  91. package/dist/diagram/short-names.js +54 -0
  92. package/dist/diagram/snapshot.d.ts +115 -0
  93. package/dist/diagram/snapshot.js +242 -0
  94. package/dist/diagram/summary.d.ts +65 -0
  95. package/dist/diagram/summary.js +144 -0
  96. package/dist/diagram/svg-export.d.ts +80 -0
  97. package/dist/diagram/svg-export.js +108 -0
  98. package/dist/diagram/tree-walk.d.ts +13 -0
  99. package/dist/diagram/tree-walk.js +83 -0
  100. package/dist/diagram/value-labels.d.ts +24 -0
  101. package/dist/diagram/value-labels.js +69 -0
  102. package/dist/diagram/view-state.d.ts +12 -0
  103. package/dist/diagram/view-state.js +22 -0
  104. package/dist/diagram/voltage-levels.d.ts +14 -0
  105. package/dist/diagram/voltage-levels.js +20 -0
  106. package/dist/index.d.ts +3 -0
  107. package/dist/index.js +2 -0
  108. package/dist/log.svelte.d.ts +77 -0
  109. package/dist/log.svelte.js +149 -0
  110. package/dist/notices.svelte.d.ts +3 -0
  111. package/dist/state.svelte.d.ts +42 -5
  112. package/dist/state.svelte.js +56 -4
  113. package/dist/transformer-icon.d.ts +22 -13
  114. package/dist/transformer-icon.js +23 -13
  115. package/package.json +2 -2
@@ -1,4 +1,8 @@
1
1
  import { DEFAULT_FORMULATION } from '@tellegen/engine';
2
+ import { DiagnosticLog, errorEntry } from './log.svelte.js';
3
+ import { graphInputs } from './diagram/graph-inputs.js';
4
+ import { buildSearchIndex } from './diagram/search.js';
5
+ import { snapshotFromMcPf } from './diagram/snapshot.js';
2
6
  /** A case is perturbed when any committed demand or rating delta is nonzero. Shared
3
7
  * by both solvable case classes so the "perturbed" rule stays single-sourced. */
4
8
  const hasPerturbation = (edits) => Object.values(edits).some((mw) => mw !== 0);
@@ -40,6 +44,8 @@ export class LocalCase {
40
44
  solving = $state(false);
41
45
  solveMs = $state(null);
42
46
  solveBackend = $state(null);
47
+ /** Short solver-specific diagnostic shown beside the elapsed time. */
48
+ solveDetail = $state(null);
43
49
  solveFallbackReason = $state(null);
44
50
  /** Monotone token: only the latest solve may write this case. */
45
51
  solveSeq = 0;
@@ -92,6 +98,8 @@ export class CaseState {
92
98
  solving = $state(false);
93
99
  solveMs = $state(null);
94
100
  solveBackend = $state(null);
101
+ /** Short solver-specific diagnostic shown beside the elapsed time. */
102
+ solveDetail = $state(null);
95
103
  solveFallbackReason = $state(null);
96
104
  /** Monotone token: only the latest solve may write this case. */
97
105
  solveSeq = 0;
@@ -158,6 +166,31 @@ export class MulticonductorCase {
158
166
  /** The selected edge id, whose conductor pairing expands in the panel;
159
167
  * mutually exclusive with selectedBusId. */
160
168
  selectedEdgeId = $state(null);
169
+ /** What the pointer is over in any linked view (schematic, profile, tables); highlighted in
170
+ * the others. Transient: never saved or put in links. */
171
+ hovered = $state(null);
172
+ /** Bumped to ask the views to bring the current selection into view again (an issue clicked
173
+ * that is already selected). */
174
+ revealSeq = $state(0);
175
+ /** The full operating point read for whole-network views (overview, schematic); null until read,
176
+ * and cleared when a large case's operating point changes. */
177
+ overviewResult = $state.raw(null);
178
+ overviewLoading = $state(false);
179
+ /** The graph's buses and branches as the overview and the diagram read them: rebuilt when the
180
+ * graph is replaced, never after a solve. Both views read this one copy. */
181
+ overviewInputs = $derived(this.graph ? graphInputs(this.graph) : null);
182
+ /** Search over the graph's buses and branches, rebuilt with `overviewInputs`. */
183
+ overviewSearch = $derived(this.overviewInputs ? buildSearchIndex(this.overviewInputs.entities) : null);
184
+ /** `overviewResult` projected onto the graph, built once per operating point and shared by the
185
+ * overview and the diagram; null while there is none. */
186
+ overviewSnapshot = $derived(this.overviewResult && this.overviewInputs
187
+ ? snapshotFromMcPf(this.overviewResult, this.overviewInputs.buses, this.overviewInputs.branches)
188
+ : null);
189
+ /** Show this case as a schematic instead of the map. */
190
+ schematic = $state(false);
191
+ /** The diagram's last geographic view as a map camera, for the map to continue from when the
192
+ * diagram closes. Plain, not reactive: it is read once, on close. */
193
+ lastGeoView = null;
161
194
  constructor(init) {
162
195
  this.id = init.id;
163
196
  this.label = init.label;
@@ -200,6 +233,9 @@ export class MulticonductorCase {
200
233
  }
201
234
  export class AppState {
202
235
  camera = $state.raw(null);
236
+ /** Set when a view hands its camera to the map it returns to (the diagram closing from
237
+ * geographic positions): the re-created map starts at `camera` instead of framing the case. */
238
+ cameraHandoff = false;
203
239
  cameraRequest = $state.raw(null);
204
240
  cameraSeq = $state(0);
205
241
  diagramCamera = $state.raw(null);
@@ -213,7 +249,11 @@ export class AppState {
213
249
  throw new Error('Invalid saved drawing view');
214
250
  }
215
251
  this.settleFrame();
216
- this.diagramCameraRequest = { caseId, center: [...snapshot.center], scale: snapshot.scale };
252
+ this.diagramCameraRequest = {
253
+ caseId,
254
+ center: [...snapshot.center],
255
+ scale: snapshot.scale
256
+ };
217
257
  this.diagramCameraSeq++;
218
258
  }
219
259
  requestCamera(snapshot) {
@@ -262,16 +302,28 @@ export class AppState {
262
302
  /** Technical detail behind the current `error`, when the message itself is
263
303
  * written for people; notices keep it in their disclosure. Every write to
264
304
  * `error` clears it, as it clears `errorRetry`. */
265
- errorDetail = $state(null);
305
+ #errorDetail = $state(null);
306
+ /** Every error and engine finding of this session, structured; see `DiagnosticLog`. */
307
+ log = new DiagnosticLog();
266
308
  get error() {
267
309
  return this.#error;
268
310
  }
269
311
  set error(message) {
270
312
  this.#error = message;
271
- if (message)
313
+ if (message) {
272
314
  this.errorRevision++;
315
+ this.log.record(errorEntry(message));
316
+ }
273
317
  this.errorRetry = null;
274
- this.errorDetail = null;
318
+ this.#errorDetail = null;
319
+ }
320
+ get errorDetail() {
321
+ return this.#errorDetail;
322
+ }
323
+ set errorDetail(detail) {
324
+ this.#errorDetail = detail;
325
+ if (detail && this.#error)
326
+ this.log.record(errorEntry(this.#error, detail), { repeat: false });
275
327
  }
276
328
  /** Case files parsed in the browser via the powerio wasm module. */
277
329
  localCases = $state.raw([]);
@@ -1,15 +1,24 @@
1
- /** The IEC two-winding transformer symbol as a deck.gl icon: two overlapping
2
- * circles, rasterized once to a data URL. Drawn white on transparent with
3
- * `mask: true`, so the layer's getColor tints it. */
4
- export interface TransformerIcon {
5
- url: string;
6
- width: number;
7
- height: number;
8
- anchorX: number;
9
- anchorY: number;
10
- mask: true;
11
- }
1
+ /** The IEC two-winding transformer symbol as a prepacked deck.gl icon atlas:
2
+ * two overlapping circles on a canvas that deck.gl uploads as a texture.
3
+ * Nothing is fetched, so the symbol needs no `data:` in a CSP's connect-src.
4
+ * Drawn white on transparent with `mask: true`, so the layer's getColor tints
5
+ * it. */
6
+ /** The icon name for the layer's getIcon. */
7
+ export declare const TRANSFORMER_ICON = "transformer";
8
+ /** The atlas holds the one symbol, anchored at its center. */
9
+ export declare const transformerIconMapping: {
10
+ transformer: {
11
+ x: number;
12
+ y: number;
13
+ width: number;
14
+ height: number;
15
+ anchorX: number;
16
+ anchorY: number;
17
+ mask: boolean;
18
+ };
19
+ };
12
20
  /** Rasterize the glyph lazily; layers only build client-side, after the map
13
21
  * modules load, so document is always available here. The 128 px backing keeps
14
- * a ~16 px on-screen symbol crisp on 2x/3x displays. */
15
- export declare function transformerIcon(): TransformerIcon;
22
+ * a ~16 px on-screen symbol crisp on 2x/3x displays. Every call returns the
23
+ * same canvas, so deck.gl's prop diff keeps the texture it made from it. */
24
+ export declare function transformerIconAtlas(): HTMLCanvasElement;
@@ -1,15 +1,32 @@
1
- /** The IEC two-winding transformer symbol as a deck.gl icon: two overlapping
2
- * circles, rasterized once to a data URL. Drawn white on transparent with
3
- * `mask: true`, so the layer's getColor tints it. */
1
+ /** The IEC two-winding transformer symbol as a prepacked deck.gl icon atlas:
2
+ * two overlapping circles on a canvas that deck.gl uploads as a texture.
3
+ * Nothing is fetched, so the symbol needs no `data:` in a CSP's connect-src.
4
+ * Drawn white on transparent with `mask: true`, so the layer's getColor tints
5
+ * it. */
4
6
  const SIZE = 128;
5
7
  const RADIUS = 34;
6
8
  const OFFSET = 17;
7
9
  const STROKE = 9;
10
+ /** The icon name for the layer's getIcon. */
11
+ export const TRANSFORMER_ICON = 'transformer';
12
+ /** The atlas holds the one symbol, anchored at its center. */
13
+ export const transformerIconMapping = {
14
+ [TRANSFORMER_ICON]: {
15
+ x: 0,
16
+ y: 0,
17
+ width: SIZE,
18
+ height: SIZE,
19
+ anchorX: SIZE / 2,
20
+ anchorY: SIZE / 2,
21
+ mask: true
22
+ }
23
+ };
8
24
  let cached = null;
9
25
  /** Rasterize the glyph lazily; layers only build client-side, after the map
10
26
  * modules load, so document is always available here. The 128 px backing keeps
11
- * a ~16 px on-screen symbol crisp on 2x/3x displays. */
12
- export function transformerIcon() {
27
+ * a ~16 px on-screen symbol crisp on 2x/3x displays. Every call returns the
28
+ * same canvas, so deck.gl's prop diff keeps the texture it made from it. */
29
+ export function transformerIconAtlas() {
13
30
  if (cached)
14
31
  return cached;
15
32
  const canvas = document.createElement('canvas');
@@ -23,13 +40,6 @@ export function transformerIcon() {
23
40
  ctx.arc(SIZE / 2 + dx, SIZE / 2, RADIUS, 0, 2 * Math.PI);
24
41
  ctx.stroke();
25
42
  }
26
- cached = {
27
- url: canvas.toDataURL(),
28
- width: SIZE,
29
- height: SIZE,
30
- anchorX: SIZE / 2,
31
- anchorY: SIZE / 2,
32
- mask: true
33
- };
43
+ cached = canvas;
34
44
  return cached;
35
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellegen/svelte",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Svelte components for tellegen power system maps, local case files, and browser solves.",
5
5
  "keywords": [
6
6
  "svelte",
@@ -67,7 +67,7 @@
67
67
  "pack:dry-run": "npm pack --dry-run --cache ../../node_modules/.cache/npm-pack"
68
68
  },
69
69
  "dependencies": {
70
- "@tellegen/engine": "^0.4.1"
70
+ "@tellegen/engine": "^0.4.6"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@deck.gl/core": "^9.4.0",