@open-pioneer/runtime 4.5.0-dev.20260303103629 → 4.5.0-dev.20260325074159
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/CHANGELOG.md +3 -167
- package/api.d.ts +1 -1
- package/builtin-services/ThemeServiceImpl.d.ts +1 -1
- package/builtin-services/ThemeServiceImpl.js +3 -5
- package/builtin-services/ThemeServiceImpl.js.map +1 -1
- package/package.json +6 -6
- package/service-layer/ServiceLayer.js +7 -7
- package/service-layer/ServiceLayer.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @open-pioneer/runtime
|
|
2
2
|
|
|
3
|
-
## 4.5.0-dev.
|
|
3
|
+
## 4.5.0-dev.20260325074159
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -12,17 +12,13 @@
|
|
|
12
12
|
- 89d743b: Support for color modes (light and dark).
|
|
13
13
|
The default color mode remains `light` for backwards compatibility.
|
|
14
14
|
- 94b0cca: API initialization does no longer block rendering of the user interface.
|
|
15
|
-
- 4e76893: Update Chakra UI to 3.
|
|
15
|
+
- 4e76893: Update Chakra UI to 3.34.0
|
|
16
16
|
- c866e13: createCustomElement: Add support for configuration of `chakraSystemConfig` in `config` and `resolveConfig`.
|
|
17
17
|
This is needed when the specific application theme depends on asynchronous data.
|
|
18
18
|
|
|
19
19
|
### Patch Changes
|
|
20
20
|
|
|
21
|
-
-
|
|
22
|
-
- Updated dependencies [4e76893]
|
|
23
|
-
- @open-pioneer/base-theme@4.5.0-dev.20260303103629
|
|
24
|
-
- @open-pioneer/core@4.5.0-dev.20260303103629
|
|
25
|
-
- @open-pioneer/reactivity@4.5.0-dev.20260303103629
|
|
21
|
+
- befae99: Fix wrong order of destruction for some services. It was possible for service dependencies to be destroyed before the service.
|
|
26
22
|
|
|
27
23
|
## 4.4.0
|
|
28
24
|
|
|
@@ -37,12 +33,6 @@
|
|
|
37
33
|
- f9aaf46: Bump various dependencies
|
|
38
34
|
- 554d58e: Use `workspace:*` instead of `workspace:^` for local package references as default. This ensures that trails packages from this repository are always referenced with their exact version to avoid potential issues with version mismatches. If a project specifically wants to use other versions for some trails packages, a pnpm override can be used to force other versions.
|
|
39
35
|
- 84068f2: Hide emotion warnings for certain css selectors (see [Issue](https://github.com/open-pioneer/trails-core-packages/issues/169)).
|
|
40
|
-
- Updated dependencies [f9aaf46]
|
|
41
|
-
- Updated dependencies [b28d6bc]
|
|
42
|
-
- Updated dependencies [554d58e]
|
|
43
|
-
- @open-pioneer/base-theme@4.4.0
|
|
44
|
-
- @open-pioneer/core@4.4.0
|
|
45
|
-
- @open-pioneer/reactivity@4.4.0
|
|
46
36
|
|
|
47
37
|
## 4.3.0
|
|
48
38
|
|
|
@@ -50,14 +40,6 @@
|
|
|
50
40
|
|
|
51
41
|
- eb54023: Update chakra to 3.29.0
|
|
52
42
|
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- Updated dependencies [eb54023]
|
|
56
|
-
- Updated dependencies [eb54023]
|
|
57
|
-
- @open-pioneer/base-theme@4.3.0
|
|
58
|
-
- @open-pioneer/core@4.3.0
|
|
59
|
-
- @open-pioneer/reactivity@4.3.0
|
|
60
|
-
|
|
61
43
|
## 4.2.0
|
|
62
44
|
|
|
63
45
|
### Minor Changes
|
|
@@ -67,13 +49,6 @@
|
|
|
67
49
|
### Patch Changes
|
|
68
50
|
|
|
69
51
|
- 81308c0: Update to eslint 9
|
|
70
|
-
- Updated dependencies [81308c0]
|
|
71
|
-
- Updated dependencies [ed3d452]
|
|
72
|
-
- Updated dependencies [0bcda89]
|
|
73
|
-
- Updated dependencies [1b95a62]
|
|
74
|
-
- @open-pioneer/reactivity@4.2.0
|
|
75
|
-
- @open-pioneer/core@4.2.0
|
|
76
|
-
- @open-pioneer/base-theme@4.2.0
|
|
77
52
|
|
|
78
53
|
## 4.1.0
|
|
79
54
|
|
|
@@ -83,12 +58,6 @@
|
|
|
83
58
|
- 3881d08: - Update Chakra UI from 3.22.0 to 3.24.2
|
|
84
59
|
- Update to latest Chakra snippets
|
|
85
60
|
- adf277b: Update dependencies
|
|
86
|
-
- Updated dependencies [b7a854d]
|
|
87
|
-
- Updated dependencies [2da02e7]
|
|
88
|
-
- Updated dependencies [adf277b]
|
|
89
|
-
- @open-pioneer/base-theme@4.1.0
|
|
90
|
-
- @open-pioneer/core@4.1.0
|
|
91
|
-
- @open-pioneer/reactivity@4.1.0
|
|
92
61
|
|
|
93
62
|
## 4.0.0
|
|
94
63
|
|
|
@@ -138,14 +107,6 @@
|
|
|
138
107
|
### Patch Changes
|
|
139
108
|
|
|
140
109
|
- 434bd04: Bump dependencies.
|
|
141
|
-
- Updated dependencies [9f074d8]
|
|
142
|
-
- Updated dependencies [b5f25d8]
|
|
143
|
-
- Updated dependencies [434bd04]
|
|
144
|
-
- Updated dependencies [9f074d8]
|
|
145
|
-
- Updated dependencies [1f4fa84]
|
|
146
|
-
- @open-pioneer/base-theme@4.0.0
|
|
147
|
-
- @open-pioneer/core@4.0.0
|
|
148
|
-
- @open-pioneer/reactivity@4.0.0
|
|
149
110
|
|
|
150
111
|
## 3.1.0
|
|
151
112
|
|
|
@@ -207,11 +168,6 @@
|
|
|
207
168
|
### Patch Changes
|
|
208
169
|
|
|
209
170
|
- 1c1ede8: Bump dependencies.
|
|
210
|
-
- Updated dependencies [1c1ede8]
|
|
211
|
-
- @open-pioneer/base-theme@3.1.0
|
|
212
|
-
- @open-pioneer/chakra-integration@3.1.0
|
|
213
|
-
- @open-pioneer/core@3.1.0
|
|
214
|
-
- @open-pioneer/runtime-react-support@3.1.0
|
|
215
171
|
|
|
216
172
|
## 3.0.0
|
|
217
173
|
|
|
@@ -226,14 +182,6 @@
|
|
|
226
182
|
|
|
227
183
|
For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
|
|
228
184
|
|
|
229
|
-
### Patch Changes
|
|
230
|
-
|
|
231
|
-
- Updated dependencies [9477e54]
|
|
232
|
-
- @open-pioneer/base-theme@3.0.0
|
|
233
|
-
- @open-pioneer/chakra-integration@3.0.0
|
|
234
|
-
- @open-pioneer/core@3.0.0
|
|
235
|
-
- @open-pioneer/runtime-react-support@3.0.0
|
|
236
|
-
|
|
237
185
|
## 2.4.0
|
|
238
186
|
|
|
239
187
|
### Minor Changes
|
|
@@ -244,12 +192,6 @@
|
|
|
244
192
|
### Patch Changes
|
|
245
193
|
|
|
246
194
|
- 1b63ebe: Update dependencies
|
|
247
|
-
- Updated dependencies [1b63ebe]
|
|
248
|
-
- Updated dependencies [e3802fb]
|
|
249
|
-
- @open-pioneer/chakra-integration@2.4.0
|
|
250
|
-
- @open-pioneer/base-theme@2.4.0
|
|
251
|
-
- @open-pioneer/core@2.4.0
|
|
252
|
-
- @open-pioneer/runtime-react-support@2.4.0
|
|
253
195
|
|
|
254
196
|
## 2.3.0
|
|
255
197
|
|
|
@@ -257,25 +199,12 @@
|
|
|
257
199
|
|
|
258
200
|
- 2fbaaa0: Use normal `dependencies` instead of `peerDependencies`. Peer dependencies have some usability issues (and bugs) when used at scale.
|
|
259
201
|
|
|
260
|
-
### Patch Changes
|
|
261
|
-
|
|
262
|
-
- Updated dependencies [2fbaaa0]
|
|
263
|
-
- @open-pioneer/runtime-react-support@2.3.0
|
|
264
|
-
- @open-pioneer/chakra-integration@2.3.0
|
|
265
|
-
- @open-pioneer/base-theme@2.3.0
|
|
266
|
-
- @open-pioneer/core@2.3.0
|
|
267
|
-
|
|
268
202
|
## 2.2.0
|
|
269
203
|
|
|
270
204
|
### Patch Changes
|
|
271
205
|
|
|
272
206
|
- 39dad46: Switch to a new versioning strategy.
|
|
273
207
|
From now on, packages released by this repository share a common version number.
|
|
274
|
-
- Updated dependencies [39dad46]
|
|
275
|
-
- @open-pioneer/base-theme@2.2.0
|
|
276
|
-
- @open-pioneer/chakra-integration@2.2.0
|
|
277
|
-
- @open-pioneer/core@2.2.0
|
|
278
|
-
- @open-pioneer/runtime-react-support@2.2.0
|
|
279
208
|
|
|
280
209
|
## 2.1.7
|
|
281
210
|
|
|
@@ -286,13 +215,6 @@
|
|
|
286
215
|
The `type` keyword can now be omitted.
|
|
287
216
|
- e0b2fae: Update dependencies
|
|
288
217
|
- 6cc7fcd: Allow synchronous `getApiMethods()` when implementing an `ApiExtension`.
|
|
289
|
-
- Updated dependencies [5c62522]
|
|
290
|
-
- Updated dependencies [50550d3]
|
|
291
|
-
- Updated dependencies [e0b2fae]
|
|
292
|
-
- @open-pioneer/chakra-integration@1.1.4
|
|
293
|
-
- @open-pioneer/core@1.3.0
|
|
294
|
-
- @open-pioneer/base-theme@0.3.3
|
|
295
|
-
- @open-pioneer/runtime-react-support@1.0.2
|
|
296
218
|
|
|
297
219
|
## 2.1.6
|
|
298
220
|
|
|
@@ -327,35 +249,15 @@
|
|
|
327
249
|
|
|
328
250
|
- 64645aa: Update to react 18.3
|
|
329
251
|
- b3c60f2: Harmonize naming of Open Pioneer Trails in READMEs and package.json files.
|
|
330
|
-
- Updated dependencies [5d3aafd]
|
|
331
|
-
- Updated dependencies [64645aa]
|
|
332
|
-
- Updated dependencies [64645aa]
|
|
333
|
-
- Updated dependencies [b3c60f2]
|
|
334
|
-
- @open-pioneer/core@1.2.3
|
|
335
|
-
- @open-pioneer/runtime-react-support@1.0.2
|
|
336
|
-
- @open-pioneer/chakra-integration@1.1.3
|
|
337
|
-
- @open-pioneer/base-theme@0.3.2
|
|
338
252
|
|
|
339
253
|
## 2.1.3
|
|
340
254
|
|
|
341
255
|
### Patch Changes
|
|
342
256
|
|
|
343
257
|
- 5ff8f30: Update package.json metadata.
|
|
344
|
-
- Updated dependencies [be236af]
|
|
345
|
-
- Updated dependencies [5ff8f30]
|
|
346
|
-
- @open-pioneer/base-theme@0.3.1
|
|
347
|
-
- @open-pioneer/runtime-react-support@1.0.1
|
|
348
|
-
- @open-pioneer/chakra-integration@1.1.2
|
|
349
|
-
- @open-pioneer/core@1.2.2
|
|
350
258
|
|
|
351
259
|
## 2.1.2
|
|
352
260
|
|
|
353
|
-
### Patch Changes
|
|
354
|
-
|
|
355
|
-
- Updated dependencies [6380aa4]
|
|
356
|
-
- @open-pioneer/base-theme@0.3.0
|
|
357
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
358
|
-
|
|
359
261
|
## 2.1.1
|
|
360
262
|
|
|
361
263
|
### Patch Changes
|
|
@@ -416,20 +318,8 @@
|
|
|
416
318
|
|
|
417
319
|
## 2.0.2
|
|
418
320
|
|
|
419
|
-
### Patch Changes
|
|
420
|
-
|
|
421
|
-
- Updated dependencies [11b1428]
|
|
422
|
-
- @open-pioneer/core@1.2.1
|
|
423
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
424
|
-
|
|
425
321
|
## 2.0.1
|
|
426
322
|
|
|
427
|
-
### Patch Changes
|
|
428
|
-
|
|
429
|
-
- Updated dependencies [a18d227]
|
|
430
|
-
- @open-pioneer/core@1.2.0
|
|
431
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
432
|
-
|
|
433
323
|
## 2.0.0
|
|
434
324
|
|
|
435
325
|
### Major Changes
|
|
@@ -489,11 +379,6 @@
|
|
|
489
379
|
### Patch Changes
|
|
490
380
|
|
|
491
381
|
- f5c0e31: Bump @formatjs/intl version
|
|
492
|
-
- Updated dependencies [f5c0e31]
|
|
493
|
-
- Updated dependencies [6f954e3]
|
|
494
|
-
- @open-pioneer/chakra-integration@1.1.1
|
|
495
|
-
- @open-pioneer/base-theme@0.2.0
|
|
496
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
497
382
|
|
|
498
383
|
## 1.1.0
|
|
499
384
|
|
|
@@ -502,52 +387,21 @@
|
|
|
502
387
|
- 6632892: Implement support for custom chakra themes via the `theme` parameter in `createCustomElement()`.
|
|
503
388
|
`theme` from `@open-pioneer/base-theme` is used as default when no other theme is configured.
|
|
504
389
|
|
|
505
|
-
### Patch Changes
|
|
506
|
-
|
|
507
|
-
- Updated dependencies [6632892]
|
|
508
|
-
- Updated dependencies [6632892]
|
|
509
|
-
- @open-pioneer/base-theme@0.1.0
|
|
510
|
-
- @open-pioneer/chakra-integration@1.1.0
|
|
511
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
512
|
-
|
|
513
390
|
## 1.0.2
|
|
514
391
|
|
|
515
|
-
### Patch Changes
|
|
516
|
-
|
|
517
|
-
- Updated dependencies [69c0fcd]
|
|
518
|
-
- @open-pioneer/core@1.1.0
|
|
519
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
520
|
-
|
|
521
392
|
## 1.0.1
|
|
522
393
|
|
|
523
|
-
### Patch Changes
|
|
524
|
-
|
|
525
|
-
- Updated dependencies [88fd710]
|
|
526
|
-
- @open-pioneer/core@1.0.1
|
|
527
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
528
|
-
|
|
529
394
|
## 1.0.0
|
|
530
395
|
|
|
531
396
|
### Major Changes
|
|
532
397
|
|
|
533
398
|
- 22ff68a: Initial release
|
|
534
399
|
|
|
535
|
-
### Patch Changes
|
|
536
|
-
|
|
537
|
-
- Updated dependencies [22ff68a]
|
|
538
|
-
- @open-pioneer/chakra-integration@1.0.0
|
|
539
|
-
- @open-pioneer/core@1.0.0
|
|
540
|
-
- @open-pioneer/runtime-react-support@1.0.0
|
|
541
|
-
|
|
542
400
|
## 0.1.5
|
|
543
401
|
|
|
544
402
|
### Patch Changes
|
|
545
403
|
|
|
546
404
|
- 9eac5c9: Use peer dependencies for (most) dependencies
|
|
547
|
-
- Updated dependencies [9eac5c9]
|
|
548
|
-
- @open-pioneer/runtime-react-support@0.1.2
|
|
549
|
-
- @open-pioneer/chakra-integration@0.1.4
|
|
550
|
-
- @open-pioneer/core@0.1.4
|
|
551
405
|
|
|
552
406
|
## 0.1.4
|
|
553
407
|
|
|
@@ -555,45 +409,27 @@
|
|
|
555
409
|
|
|
556
410
|
- 234b3be: Fix registrations in ServiceRegistry
|
|
557
411
|
- 49ba4e1: Use build-package CLI to build.
|
|
558
|
-
- Updated dependencies [49ba4e1]
|
|
559
|
-
- @open-pioneer/chakra-integration@0.1.3
|
|
560
|
-
- @open-pioneer/core@0.1.3
|
|
561
|
-
- @open-pioneer/runtime-react-support@0.1.1
|
|
562
412
|
|
|
563
413
|
## 0.1.3
|
|
564
414
|
|
|
565
415
|
### Patch Changes
|
|
566
416
|
|
|
567
417
|
- e752d49: Use new runtime-react-support package
|
|
568
|
-
- Updated dependencies [e752d49]
|
|
569
|
-
- @open-pioneer/runtime-react-support@0.1.0
|
|
570
418
|
|
|
571
419
|
## 0.1.2
|
|
572
420
|
|
|
573
421
|
### Patch Changes
|
|
574
422
|
|
|
575
423
|
- a40f12d: Update build-package tool. TypeScript declaration files should now be available.
|
|
576
|
-
- Updated dependencies [a40f12d]
|
|
577
|
-
- @open-pioneer/chakra-integration@0.1.2
|
|
578
|
-
- @open-pioneer/core@0.1.2
|
|
579
424
|
|
|
580
425
|
## 0.1.1
|
|
581
426
|
|
|
582
427
|
### Patch Changes
|
|
583
428
|
|
|
584
429
|
- e1c7295: Compiled with build-package 0.5.2
|
|
585
|
-
- Updated dependencies [e1c7295]
|
|
586
|
-
- @open-pioneer/chakra-integration@0.1.1
|
|
587
|
-
- @open-pioneer/core@0.1.1
|
|
588
430
|
|
|
589
431
|
## 0.1.0
|
|
590
432
|
|
|
591
433
|
### Minor Changes
|
|
592
434
|
|
|
593
435
|
- 77f7d5c: Initial test release
|
|
594
|
-
|
|
595
|
-
### Patch Changes
|
|
596
|
-
|
|
597
|
-
- Updated dependencies [77f7d5c]
|
|
598
|
-
- @open-pioneer/chakra-integration@0.1.0
|
|
599
|
-
- @open-pioneer/core@0.1.0
|
package/api.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export interface ThemeService extends DeclaredService<"runtime.ThemeService"> {
|
|
|
153
153
|
* Can be called with a direct value or a function that returns a value.
|
|
154
154
|
* The function form allows the use of reactive values, which will automatically trigger a color mode update.
|
|
155
155
|
*/
|
|
156
|
-
setColorMode(value: ColorModeValue | ColorModeValueSupplier): void;
|
|
156
|
+
setColorMode(value: ColorModeValue | "system" | ColorModeValueSupplier): void;
|
|
157
157
|
/**
|
|
158
158
|
* The currently active system config.
|
|
159
159
|
*/
|
|
@@ -10,7 +10,7 @@ export declare class ThemeServiceImpl implements ThemeService {
|
|
|
10
10
|
constructor({ initialSystemConfig, initialColorMode }: ThemeServiceProperties);
|
|
11
11
|
get systemColorMode(): ColorModeValue;
|
|
12
12
|
get colorMode(): ColorModeValue;
|
|
13
|
-
setColorMode(value: ColorModeValue | ColorModeValueSupplier): void;
|
|
13
|
+
setColorMode(value: ColorModeValue | "system" | ColorModeValueSupplier): void;
|
|
14
14
|
get systemConfig(): ChakraSystemConfig | undefined;
|
|
15
15
|
setSystemConfig(value: ChakraSystemConfig | ChakraSystemConfigSupplier | undefined): void;
|
|
16
16
|
}
|
|
@@ -12,11 +12,7 @@ class ThemeServiceImpl {
|
|
|
12
12
|
() => this.#systemConfigSource.value() ?? void 0
|
|
13
13
|
);
|
|
14
14
|
constructor({ initialSystemConfig, initialColorMode }) {
|
|
15
|
-
|
|
16
|
-
this.setColorMode(() => this.#systemColorMode.value);
|
|
17
|
-
} else {
|
|
18
|
-
this.setColorMode(initialColorMode ?? DEFAULT_INITIAL_COLOR_MODE);
|
|
19
|
-
}
|
|
15
|
+
this.setColorMode(initialColorMode ?? DEFAULT_INITIAL_COLOR_MODE);
|
|
20
16
|
if (initialSystemConfig) {
|
|
21
17
|
this.setSystemConfig(initialSystemConfig);
|
|
22
18
|
}
|
|
@@ -30,6 +26,8 @@ class ThemeServiceImpl {
|
|
|
30
26
|
setColorMode(value) {
|
|
31
27
|
if (typeof value === "function") {
|
|
32
28
|
this.#colorModeSource.value = value;
|
|
29
|
+
} else if (value === "system") {
|
|
30
|
+
this.#colorModeSource.value = () => this.#systemColorMode.value;
|
|
33
31
|
} else {
|
|
34
32
|
this.#colorModeSource.value = () => value;
|
|
35
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeServiceImpl.js","sources":["ThemeServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { type SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { computed, reactive, ReadonlyReactive, synchronized } from \"@conterra/reactivity-core\";\nimport {\n type ChakraSystemConfigSupplier,\n type ColorModeValue,\n type ColorModeValueSupplier,\n type ThemeService\n} from \"../api\";\n\nexport const DEFAULT_INITIAL_COLOR_MODE: ColorModeValue = \"light\";\n\nexport interface ThemeServiceProperties {\n initialColorMode?: ColorModeValue | \"system\";\n initialSystemConfig?: ChakraSystemConfig;\n}\n\nexport class ThemeServiceImpl implements ThemeService {\n #systemColorMode = reactiveSystemColorMode();\n\n #colorModeSource = reactive<ColorModeValueSupplier>(() => DEFAULT_INITIAL_COLOR_MODE);\n #colorMode = computed<ColorModeValue>(\n () => this.#colorModeSource.value() ?? DEFAULT_INITIAL_COLOR_MODE\n );\n\n #systemConfigSource = reactive<ChakraSystemConfigSupplier>(() => undefined);\n #systemConfig = computed<ChakraSystemConfig | undefined>(\n () => this.#systemConfigSource.value() ?? undefined\n );\n\n constructor({ initialSystemConfig, initialColorMode }: ThemeServiceProperties) {\n
|
|
1
|
+
{"version":3,"file":"ThemeServiceImpl.js","sources":["ThemeServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { type SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { computed, reactive, ReadonlyReactive, synchronized } from \"@conterra/reactivity-core\";\nimport {\n type ChakraSystemConfigSupplier,\n type ColorModeValue,\n type ColorModeValueSupplier,\n type ThemeService\n} from \"../api\";\n\nexport const DEFAULT_INITIAL_COLOR_MODE: ColorModeValue = \"light\";\n\nexport interface ThemeServiceProperties {\n initialColorMode?: ColorModeValue | \"system\";\n initialSystemConfig?: ChakraSystemConfig;\n}\n\nexport class ThemeServiceImpl implements ThemeService {\n #systemColorMode = reactiveSystemColorMode();\n\n #colorModeSource = reactive<ColorModeValueSupplier>(() => DEFAULT_INITIAL_COLOR_MODE);\n #colorMode = computed<ColorModeValue>(\n () => this.#colorModeSource.value() ?? DEFAULT_INITIAL_COLOR_MODE\n );\n\n #systemConfigSource = reactive<ChakraSystemConfigSupplier>(() => undefined);\n #systemConfig = computed<ChakraSystemConfig | undefined>(\n () => this.#systemConfigSource.value() ?? undefined\n );\n\n constructor({ initialSystemConfig, initialColorMode }: ThemeServiceProperties) {\n this.setColorMode(initialColorMode ?? DEFAULT_INITIAL_COLOR_MODE);\n if (initialSystemConfig) {\n this.setSystemConfig(initialSystemConfig);\n }\n }\n\n get systemColorMode(): ColorModeValue {\n return this.#systemColorMode.value;\n }\n\n get colorMode(): ColorModeValue {\n return this.#colorMode.value;\n }\n\n setColorMode(value: ColorModeValue | \"system\" | ColorModeValueSupplier): void {\n if (typeof value === \"function\") {\n this.#colorModeSource.value = value;\n } else if (value === \"system\") {\n this.#colorModeSource.value = () => this.#systemColorMode.value;\n } else {\n this.#colorModeSource.value = () => value;\n }\n }\n\n get systemConfig(): ChakraSystemConfig | undefined {\n return this.#systemConfig.value;\n }\n\n setSystemConfig(value: ChakraSystemConfig | ChakraSystemConfigSupplier | undefined): void {\n if (typeof value === \"function\") {\n this.#systemConfigSource.value = value;\n } else {\n this.#systemConfigSource.value = () => value;\n }\n }\n}\n\nfunction reactiveSystemColorMode(): ReadonlyReactive<ColorModeValue> {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return reactive(\"light\");\n }\n\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n return synchronized(\n () => (query.matches ? \"dark\" : \"light\"),\n (onChange) => {\n const listener = () => onChange();\n query.addEventListener(\"change\", listener);\n return () => query.removeEventListener(\"change\", listener);\n }\n );\n}\n"],"names":[],"mappings":";;AAWO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C,IAAA,OAAO,KAAK,aAAA,CAAc,KAAA;AAAA,EAC9B;AAAA,EAEA,gBAAgB,KAAA,EAA0E;AACtF,IAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAC7B,MAAA,IAAA,CAAK,oBAAoB,KAAA,GAAQ,KAAA;AAAA,IACrC,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,mBAAA,CAAoB,QAAQ,MAAM,KAAA;AAAA,IAC3C;AAAA,EACJ;AACJ;AAEA,SAAS,uBAAA,GAA4D;AACjE,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,MAAA,CAAO,eAAe,UAAA,EAAY;AAC1E,IAAA,OAAO,SAAS,OAAO,CAAA;AAAA,EAC3B;AAEA,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,UAAA,CAAW,8BAA8B,CAAA;AAC9D,EAAA,OAAO,YAAA;AAAA,IACH,MAAO,KAAA,CAAM,OAAA,GAAU,MAAA,GAAS,OAAA;AAAA,IAChC,CAAC,QAAA,KAAa;AACV,MAAA,MAAM,QAAA,GAAW,MAAM,QAAA,EAAS;AAChC,MAAA,KAAA,CAAM,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AACzC,MAAA,OAAO,MAAM,KAAA,CAAM,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AAAA,IAC7D;AAAA,GACJ;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/runtime",
|
|
4
|
-
"version": "4.5.0-dev.
|
|
4
|
+
"version": "4.5.0-dev.20260325074159",
|
|
5
5
|
"description": "Implements the runtime environment for Open Pioneer Trails apps.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@conterra/reactivity-core": "^0.8.1",
|
|
18
|
-
"@formatjs/intl": "^4.1.
|
|
19
|
-
"@chakra-ui/react": "^3.
|
|
18
|
+
"@formatjs/intl": "^4.1.4",
|
|
19
|
+
"@chakra-ui/react": "^3.34.0",
|
|
20
20
|
"@emotion/cache": "^11.14.0",
|
|
21
21
|
"@emotion/react": "^11.14.0",
|
|
22
22
|
"react": "^19.2.4",
|
|
23
23
|
"react-dom": "^19.2.4",
|
|
24
|
-
"@open-pioneer/base-theme": "4.5.0-dev.
|
|
25
|
-
"@open-pioneer/core": "4.5.0-dev.
|
|
26
|
-
"@open-pioneer/reactivity": "4.5.0-dev.
|
|
24
|
+
"@open-pioneer/base-theme": "4.5.0-dev.20260325074159",
|
|
25
|
+
"@open-pioneer/core": "4.5.0-dev.20260325074159",
|
|
26
|
+
"@open-pioneer/reactivity": "4.5.0-dev.20260325074159"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
"./package.json": "./package.json",
|
|
@@ -159,14 +159,14 @@ class ServiceLayer {
|
|
|
159
159
|
if (service.removeRef() <= 0) {
|
|
160
160
|
LOG.debug(`Destroying service '${service.id}'`);
|
|
161
161
|
service.destroy();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
for (const serviceDeps of Object.values(this.getServiceDeps(service))) {
|
|
163
|
+
if (Array.isArray(serviceDeps)) {
|
|
164
|
+
for (const dep of serviceDeps) {
|
|
165
|
+
this.destroyService(dep);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
this.destroyService(serviceDeps);
|
|
167
169
|
}
|
|
168
|
-
} else {
|
|
169
|
-
this.destroyService(serviceDeps);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceLayer.js","sources":["ServiceLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReferenceMeta } from \"../Service\";\nimport { RUNTIME_PACKAGE_NAME } from \"../builtin-services\";\nimport { ErrorId } from \"../errors\";\nimport {\n InterfaceSpec,\n isAllImplementationsSpec,\n isSingleImplementationSpec,\n ReferenceSpec,\n renderInterfaceSpec\n} from \"./InterfaceSpec\";\nimport { PackageRepr } from \"./PackageRepr\";\nimport { ReadonlyServiceLookup, ServiceLookupResult, ServicesLookupResult } from \"./ServiceLookup\";\nimport { ServiceRepr } from \"./ServiceRepr\";\nimport {\n ComputedServiceDependencies,\n FrameworkDependency,\n UIDependency,\n verifyDependencies\n} from \"./verifyDependencies\";\n\nconst LOG = createLogger(sourceId);\n\nexport type DynamicLookupResult = ServiceLookupResult | UndeclaredDependency;\n\n/**\n * Returned when a dependency is not declared in the package's metadata.\n */\nexport interface UndeclaredDependency {\n type: \"undeclared\";\n}\n\n/**\n * Returned when a package is not found in the application's metadata.\n */\nexport interface UnknownPackage {\n type: \"unknown-package\";\n}\n\nconst UNDECLARED_DEPENDENCY = { type: \"undeclared\" } satisfies UndeclaredDependency;\nconst UNKNOWN_PACKAGE = { type: \"unknown-package\" } satisfies UnknownPackage;\n\ninterface DependencyDeclarations {\n all: boolean;\n unqualified: boolean;\n qualifiers: Set<string>;\n}\n\nexport class ServiceLayer {\n // All services in the application.\n private allServices: ServiceRepr[];\n\n // Set of required services. These services and their dependencies will be started.\n private requiredServices: Set<ServiceRepr>;\n\n private serviceLookup: ReadonlyServiceLookup;\n\n // Service id --> Service dependencies\n private serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n // Package name --> Interface name --> Declarations\n private declaredDependencies;\n private state: \"not-started\" | \"started\" | \"destroyed\" = \"not-started\";\n\n /**\n * Constructs a new service layer instance.\n * Requires the application's set of packages (from which services are taken)\n * and an optional set of forced references (interfaces whose implementing services will be started unconditionally).\n *\n * In its current form, the service layer will start only forced references and references needed by the UI (and their dependencies).\n */\n constructor(packages: readonly PackageRepr[], forcedReferences: ReferenceSpec[] = []) {\n const allServices = packages.map((pkg) => pkg.services).flat();\n const uiDependencies = packages\n .map((pkg) =>\n pkg.uiReferences.map<UIDependency>((dep) => {\n return {\n type: \"ui\",\n packageName: pkg.name,\n ...dep\n };\n })\n )\n .flat();\n const requiredReferences = [\n ...forcedReferences.map<FrameworkDependency>((r) => ({\n type: \"framework\",\n ...r\n })),\n ...uiDependencies\n ];\n const { serviceLookup, serviceDependencies } = verifyDependencies({\n services: allServices,\n requiredReferences: requiredReferences\n });\n\n this.allServices = allServices;\n this.requiredServices = getRequiredServices(requiredReferences, serviceLookup);\n this.serviceLookup = serviceLookup;\n this.serviceDependencies = serviceDependencies;\n this.declaredDependencies = buildDependencyIndex(packages);\n }\n\n destroy() {\n for (const service of this.requiredServices) {\n this.destroyService(service);\n }\n this.state = \"destroyed\";\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer was already started.\");\n }\n\n for (const service of this.requiredServices) {\n this.createService(service);\n }\n this.state = \"started\";\n\n // Give warnings for unneeded services during development.\n if (import.meta.env.DEV) {\n const unneededServices = this.allServices\n .filter(\n (service) =>\n service.packageName !== RUNTIME_PACKAGE_NAME &&\n service.state === \"not-constructed\"\n )\n .map((service) => `'${service.id}'`);\n if (unneededServices.length) {\n const services = unneededServices.join(\", \");\n LOG.warn(\n `The following services are contained in the application but were not started: ${services}.`\n );\n }\n }\n }\n\n /**\n * Returns a service implementing the given interface.\n * Checks that the given package actually declared a dependency on that interface\n * to enforce coding guidelines.\n *\n * @param packageName the name of the package requesting the import\n * @param spec the interface specifier\n * @param options advanced options to customize lookup\n * @throws if the service layer is not in 'started' state or if no service implements the interface.\n */\n getService(\n packageName: string,\n spec: InterfaceSpec,\n options?: { ignoreDeclarationCheck?: boolean }\n ): ServiceLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n if (!options?.ignoreDeclarationCheck) {\n const checkError = this.checkDependency(packageName, spec);\n if (checkError) {\n return checkError;\n }\n }\n\n return this.serviceLookup.lookupOne(spec);\n }\n\n /**\n * Returns all services implementing the given interface.\n * Requires that the dependency on all implementations has been declared in the package.\n *\n * @param packageName the name of the package requesting the import\n * @param interfaceName the interface name\n *\n * @throws if the service layer is not in 'started'.\n */\n getServices(\n packageName: string,\n interfaceName: string\n ): ServicesLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n const checkError = this.checkDependency(packageName, { interfaceName, all: true });\n if (checkError) {\n return checkError;\n }\n return this.serviceLookup.lookupAll(interfaceName);\n }\n\n /**\n * Initializes the given service and its dependencies.\n * Dependencies are initialized before the service that requires them.\n */\n private createService(service: ServiceRepr) {\n if (service.state === \"constructed\") {\n const instance = service.getInstanceOrThrow();\n service.addRef();\n return instance;\n }\n if (service.state === \"constructing\") {\n throw new Error(ErrorId.INTERNAL, \"Cycle during service construction.\");\n }\n if (service.state !== \"not-constructed\") {\n throw new Error(ErrorId.INTERNAL, \"Invalid service state.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const references: Record<string, any> = {};\n const referencesMeta: Record<string, ReferenceMeta | ReferenceMeta[]> = {};\n\n // Sets state to 'constructing' to detect cycles\n service.beforeCreate();\n\n // Initialize dependencies recursively before creating the current service.\n for (const [referenceName, serviceDeps] of Object.entries(this.getServiceDeps(service))) {\n const [referenceValue, referenceMeta] = this.getReference(serviceDeps);\n references[referenceName] = referenceValue;\n referencesMeta[referenceName] = referenceMeta;\n }\n\n // Sets state to 'constructed' to finish the state transition, useCount is 1.\n LOG.debug(`Creating service '${service.id}'.`);\n return service.create({ references, referencesMeta });\n }\n\n /**\n * Destroys the given service and its dependencies.\n * The dependencies are destroyed after the service.\n */\n private destroyService(service: ServiceRepr) {\n if (service.state === \"destroyed\") {\n return;\n }\n\n // Destroy the service before its dependencies (reverse order\n // compared to construction).\n if (service.removeRef() <= 0) {\n LOG.debug(`Destroying service '${service.id}'`);\n service.destroy();\n }\n\n for (const serviceDeps of Object.values(this.getServiceDeps(service))) {\n if (Array.isArray(serviceDeps)) {\n for (const dep of serviceDeps) {\n this.destroyService(dep);\n }\n } else {\n this.destroyService(serviceDeps);\n }\n }\n }\n\n /** Undefined -> everything is okay */\n private checkDependency(\n packageName: string,\n spec: ReferenceSpec\n ): UnknownPackage | UndeclaredDependency | undefined {\n const packageEntry = this.declaredDependencies.get(packageName);\n if (!packageEntry) {\n return UNKNOWN_PACKAGE;\n }\n\n const interfaceEntry = packageEntry.get(spec.interfaceName);\n if (!interfaceEntry) {\n return UNDECLARED_DEPENDENCY;\n }\n\n if (isSingleImplementationSpec(spec)) {\n if (spec.qualifier == null) {\n return interfaceEntry.unqualified ? undefined : UNDECLARED_DEPENDENCY;\n }\n return interfaceEntry.qualifiers.has(spec.qualifier)\n ? undefined\n : UNDECLARED_DEPENDENCY;\n } else {\n return interfaceEntry.all ? undefined : UNDECLARED_DEPENDENCY;\n }\n }\n\n private getReference(ref: ServiceRepr): [unknown, ReferenceMeta];\n private getReference(ref: ServiceRepr[]): [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]] {\n if (Array.isArray(ref)) {\n const referenceValues: unknown[] = [];\n const referenceMeta: ReferenceMeta[] = [];\n for (const d of ref) {\n const [value, meta] = this.getReference(d);\n referenceValues.push(value);\n referenceMeta.push(meta);\n }\n return [referenceValues, referenceMeta];\n }\n\n const referenceValue = this.createService(ref);\n const referenceMeta: ReferenceMeta = {\n serviceId: ref.id\n };\n return [referenceValue, referenceMeta];\n }\n\n private getServiceDeps(service: ServiceRepr) {\n const dependencies = this.serviceDependencies.get(service.id);\n if (!dependencies) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find precomputed service dependencies for '${service.id}'.`\n );\n }\n return dependencies;\n }\n}\n\nfunction getRequiredServices(\n requiredReferences: readonly ReferenceSpec[],\n serviceLookup: ReadonlyServiceLookup\n): Set<ServiceRepr> {\n const requiredServices = new Set<ServiceRepr>();\n for (const referenceSpec of requiredReferences) {\n const result = serviceLookup.lookup(referenceSpec);\n if (result.type !== \"found\") {\n // Should be caught by verifier\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find required reference to ${renderInterfaceSpec(referenceSpec)}.`\n );\n }\n if (Array.isArray(result.value)) {\n for (const service of result.value) {\n requiredServices.add(service);\n }\n } else {\n requiredServices.add(result.value);\n }\n }\n return requiredServices;\n}\n\nfunction buildDependencyIndex(packages: readonly PackageRepr[]) {\n // Register declared UI dependencies.\n // This is needed as a lookup structure to that dynamic service lookups\n // can be validated at runtime.\n const index = new Map<string, Map<string, DependencyDeclarations>>();\n for (const pkg of packages) {\n const packageName = pkg.name;\n const packageEntry = new Map<string, DependencyDeclarations>();\n for (const uiReference of pkg.uiReferences) {\n let interfaceEntry = packageEntry.get(uiReference.interfaceName);\n if (!interfaceEntry) {\n interfaceEntry = {\n all: false,\n unqualified: false,\n qualifiers: new Set<string>()\n };\n packageEntry.set(uiReference.interfaceName, interfaceEntry);\n }\n\n if (isAllImplementationsSpec(uiReference)) {\n interfaceEntry.all = true;\n } else if (isSingleImplementationSpec(uiReference)) {\n if (uiReference.qualifier == null) {\n interfaceEntry.unqualified = true;\n } else {\n interfaceEntry.qualifiers.add(uiReference.qualifier);\n }\n } else {\n throw new Error(ErrorId.INTERNAL, `Unexpected implementation spec.`);\n }\n }\n index.set(packageName, packageEntry);\n }\n return index;\n}\n"],"names":["referenceMeta"],"mappings":";;;;;;;AAwBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAkBjC,MAAM,qBAAA,GAAwB,EAAE,I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AA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,EAAU,CAAA,+BAAA,CAAiC,CAAA;AAAA,MACvE;AAAA,IACJ;AACA,IAAA,KAAA,CAAM,GAAA,CAAI,aAAa,YAAY,CAAA;AAAA,EACvC;AACA,EAAA,OAAO,KAAA;AACX;;;;"}
|
|
1
|
+
{"version":3,"file":"ServiceLayer.js","sources":["ServiceLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReferenceMeta } from \"../Service\";\nimport { RUNTIME_PACKAGE_NAME } from \"../builtin-services\";\nimport { ErrorId } from \"../errors\";\nimport {\n InterfaceSpec,\n isAllImplementationsSpec,\n isSingleImplementationSpec,\n ReferenceSpec,\n renderInterfaceSpec\n} from \"./InterfaceSpec\";\nimport { PackageRepr } from \"./PackageRepr\";\nimport { ReadonlyServiceLookup, ServiceLookupResult, ServicesLookupResult } from \"./ServiceLookup\";\nimport { ServiceRepr } from \"./ServiceRepr\";\nimport {\n ComputedServiceDependencies,\n FrameworkDependency,\n UIDependency,\n verifyDependencies\n} from \"./verifyDependencies\";\n\nconst LOG = createLogger(sourceId);\n\nexport type DynamicLookupResult = ServiceLookupResult | UndeclaredDependency;\n\n/**\n * Returned when a dependency is not declared in the package's metadata.\n */\nexport interface UndeclaredDependency {\n type: \"undeclared\";\n}\n\n/**\n * Returned when a package is not found in the application's metadata.\n */\nexport interface UnknownPackage {\n type: \"unknown-package\";\n}\n\nconst UNDECLARED_DEPENDENCY = { type: \"undeclared\" } satisfies UndeclaredDependency;\nconst UNKNOWN_PACKAGE = { type: \"unknown-package\" } satisfies UnknownPackage;\n\ninterface DependencyDeclarations {\n all: boolean;\n unqualified: boolean;\n qualifiers: Set<string>;\n}\n\nexport class ServiceLayer {\n // All services in the application.\n private allServices: ServiceRepr[];\n\n // Set of required services. These services and their dependencies will be started.\n private requiredServices: Set<ServiceRepr>;\n\n private serviceLookup: ReadonlyServiceLookup;\n\n // Service id --> Service dependencies\n private serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n // Package name --> Interface name --> Declarations\n private declaredDependencies;\n private state: \"not-started\" | \"started\" | \"destroyed\" = \"not-started\";\n\n /**\n * Constructs a new service layer instance.\n * Requires the application's set of packages (from which services are taken)\n * and an optional set of forced references (interfaces whose implementing services will be started unconditionally).\n *\n * In its current form, the service layer will start only forced references and references needed by the UI (and their dependencies).\n */\n constructor(packages: readonly PackageRepr[], forcedReferences: ReferenceSpec[] = []) {\n const allServices = packages.map((pkg) => pkg.services).flat();\n const uiDependencies = packages\n .map((pkg) =>\n pkg.uiReferences.map<UIDependency>((dep) => {\n return {\n type: \"ui\",\n packageName: pkg.name,\n ...dep\n };\n })\n )\n .flat();\n const requiredReferences = [\n ...forcedReferences.map<FrameworkDependency>((r) => ({\n type: \"framework\",\n ...r\n })),\n ...uiDependencies\n ];\n const { serviceLookup, serviceDependencies } = verifyDependencies({\n services: allServices,\n requiredReferences: requiredReferences\n });\n\n this.allServices = allServices;\n this.requiredServices = getRequiredServices(requiredReferences, serviceLookup);\n this.serviceLookup = serviceLookup;\n this.serviceDependencies = serviceDependencies;\n this.declaredDependencies = buildDependencyIndex(packages);\n }\n\n destroy() {\n for (const service of this.requiredServices) {\n this.destroyService(service);\n }\n this.state = \"destroyed\";\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer was already started.\");\n }\n\n for (const service of this.requiredServices) {\n this.createService(service);\n }\n this.state = \"started\";\n\n // Give warnings for unneeded services during development.\n if (import.meta.env.DEV) {\n const unneededServices = this.allServices\n .filter(\n (service) =>\n service.packageName !== RUNTIME_PACKAGE_NAME &&\n service.state === \"not-constructed\"\n )\n .map((service) => `'${service.id}'`);\n if (unneededServices.length) {\n const services = unneededServices.join(\", \");\n LOG.warn(\n `The following services are contained in the application but were not started: ${services}.`\n );\n }\n }\n }\n\n /**\n * Returns a service implementing the given interface.\n * Checks that the given package actually declared a dependency on that interface\n * to enforce coding guidelines.\n *\n * @param packageName the name of the package requesting the import\n * @param spec the interface specifier\n * @param options advanced options to customize lookup\n * @throws if the service layer is not in 'started' state or if no service implements the interface.\n */\n getService(\n packageName: string,\n spec: InterfaceSpec,\n options?: { ignoreDeclarationCheck?: boolean }\n ): ServiceLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n if (!options?.ignoreDeclarationCheck) {\n const checkError = this.checkDependency(packageName, spec);\n if (checkError) {\n return checkError;\n }\n }\n\n return this.serviceLookup.lookupOne(spec);\n }\n\n /**\n * Returns all services implementing the given interface.\n * Requires that the dependency on all implementations has been declared in the package.\n *\n * @param packageName the name of the package requesting the import\n * @param interfaceName the interface name\n *\n * @throws if the service layer is not in 'started'.\n */\n getServices(\n packageName: string,\n interfaceName: string\n ): ServicesLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n const checkError = this.checkDependency(packageName, { interfaceName, all: true });\n if (checkError) {\n return checkError;\n }\n return this.serviceLookup.lookupAll(interfaceName);\n }\n\n /**\n * Initializes the given service and its dependencies.\n * Dependencies are initialized before the service that requires them.\n */\n private createService(service: ServiceRepr) {\n if (service.state === \"constructed\") {\n const instance = service.getInstanceOrThrow();\n service.addRef();\n return instance;\n }\n if (service.state === \"constructing\") {\n throw new Error(ErrorId.INTERNAL, \"Cycle during service construction.\");\n }\n if (service.state !== \"not-constructed\") {\n throw new Error(ErrorId.INTERNAL, \"Invalid service state.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const references: Record<string, any> = {};\n const referencesMeta: Record<string, ReferenceMeta | ReferenceMeta[]> = {};\n\n // Sets state to 'constructing' to detect cycles\n service.beforeCreate();\n\n // Initialize dependencies recursively before creating the current service.\n for (const [referenceName, serviceDeps] of Object.entries(this.getServiceDeps(service))) {\n const [referenceValue, referenceMeta] = this.getReference(serviceDeps);\n references[referenceName] = referenceValue;\n referencesMeta[referenceName] = referenceMeta;\n }\n\n // Sets state to 'constructed' to finish the state transition, useCount is 1.\n LOG.debug(`Creating service '${service.id}'.`);\n return service.create({ references, referencesMeta });\n }\n\n /**\n * Destroys the given service and its dependencies.\n * The dependencies are destroyed after the service.\n */\n private destroyService(service: ServiceRepr) {\n if (service.state === \"destroyed\") {\n return;\n }\n\n // Destroy the service before its dependencies (reverse order\n // compared to construction).\n if (service.removeRef() <= 0) {\n LOG.debug(`Destroying service '${service.id}'`);\n service.destroy();\n\n for (const serviceDeps of Object.values(this.getServiceDeps(service))) {\n if (Array.isArray(serviceDeps)) {\n for (const dep of serviceDeps) {\n this.destroyService(dep);\n }\n } else {\n this.destroyService(serviceDeps);\n }\n }\n }\n }\n\n /** Undefined -> everything is okay */\n private checkDependency(\n packageName: string,\n spec: ReferenceSpec\n ): UnknownPackage | UndeclaredDependency | undefined {\n const packageEntry = this.declaredDependencies.get(packageName);\n if (!packageEntry) {\n return UNKNOWN_PACKAGE;\n }\n\n const interfaceEntry = packageEntry.get(spec.interfaceName);\n if (!interfaceEntry) {\n return UNDECLARED_DEPENDENCY;\n }\n\n if (isSingleImplementationSpec(spec)) {\n if (spec.qualifier == null) {\n return interfaceEntry.unqualified ? undefined : UNDECLARED_DEPENDENCY;\n }\n return interfaceEntry.qualifiers.has(spec.qualifier)\n ? undefined\n : UNDECLARED_DEPENDENCY;\n } else {\n return interfaceEntry.all ? undefined : UNDECLARED_DEPENDENCY;\n }\n }\n\n private getReference(ref: ServiceRepr): [unknown, ReferenceMeta];\n private getReference(ref: ServiceRepr[]): [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]] {\n if (Array.isArray(ref)) {\n const referenceValues: unknown[] = [];\n const referenceMeta: ReferenceMeta[] = [];\n for (const d of ref) {\n const [value, meta] = this.getReference(d);\n referenceValues.push(value);\n referenceMeta.push(meta);\n }\n return [referenceValues, referenceMeta];\n }\n\n const referenceValue = this.createService(ref);\n const referenceMeta: ReferenceMeta = {\n serviceId: ref.id\n };\n return [referenceValue, referenceMeta];\n }\n\n private getServiceDeps(service: ServiceRepr) {\n const dependencies = this.serviceDependencies.get(service.id);\n if (!dependencies) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find precomputed service dependencies for '${service.id}'.`\n );\n }\n return dependencies;\n }\n}\n\nfunction getRequiredServices(\n requiredReferences: readonly ReferenceSpec[],\n serviceLookup: ReadonlyServiceLookup\n): Set<ServiceRepr> {\n const requiredServices = new Set<ServiceRepr>();\n for (const referenceSpec of requiredReferences) {\n const result = serviceLookup.lookup(referenceSpec);\n if (result.type !== \"found\") {\n // Should be caught by verifier\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find required reference to ${renderInterfaceSpec(referenceSpec)}.`\n );\n }\n if (Array.isArray(result.value)) {\n for (const service of result.value) {\n requiredServices.add(service);\n }\n } else {\n requiredServices.add(result.value);\n }\n }\n return requiredServices;\n}\n\nfunction buildDependencyIndex(packages: readonly PackageRepr[]) {\n // Register declared UI dependencies.\n // This is needed as a lookup structure to that dynamic service lookups\n // can be validated at runtime.\n const index = new Map<string, Map<string, DependencyDeclarations>>();\n for (const pkg of packages) {\n const packageName = pkg.name;\n const packageEntry = new Map<string, DependencyDeclarations>();\n for (const uiReference of pkg.uiReferences) {\n let interfaceEntry = packageEntry.get(uiReference.interfaceName);\n if (!interfaceEntry) {\n interfaceEntry = {\n all: false,\n unqualified: false,\n qualifiers: new Set<string>()\n };\n packageEntry.set(uiReference.interfaceName, interfaceEntry);\n }\n\n if (isAllImplementationsSpec(uiReference)) {\n interfaceEntry.all = true;\n } else if (isSingleImplementationSpec(uiReference)) {\n if (uiReference.qualifier == null) {\n interfaceEntry.unqualified = true;\n } else {\n interfaceEntry.qualifiers.add(uiReference.qualifier);\n }\n } else {\n throw new Error(ErrorId.INTERNAL, `Unexpected implementation spec.`);\n }\n }\n index.set(packageName, packageEntry);\n }\n return index;\n}\n"],"names":["referenceMeta"],"mappings":";;;;;;;AAwBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAkBjC,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,YAAA,EAAa;AACnD,MAAM,eAAA,GAAkB,EAAE,IAAA,EAAM,iBAAA,EAAkB;AAQ3C,MAAM,YAAA,CAAa;AAAA;AAAA,EAEd,WAAA;AAAA;AAAA,EAGA,gBAAA;AAAA,EAEA,aAAA;AAAA;AAAA,EAGA,mBAAA;AAAA;AAAA,EAGA,oBAAA;AAAA,EACA,KAAA,GAAiD,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzD,WAAA,CAAY,QAAA,EAAkC,gBAAA,GAAoC,EAAC,EAAG;AAClF,IAAA,MAAM,WAAA,GAAc,SAAS,GAAA,CAAI,CAAC,QAAQ,GAAA,CAAI,QAAQ,EAAE,IAAA,EAAK;AAC7D,IAAA,MAAM,iBAAiB,QAAA,CAClB,GAAA;AAAA,MAAI,CAAC,GAAA,KACF,GAAA,CAAI,YAAA,CAAa,GAAA,CAAkB,CAAC,GAAA,KAAQ;AACxC,QAAA,OAAO;AAAA,UACH,IAAA,EAAM,IAAA;AAAA,UACN,aAAa,GAAA,CAAI,IAAA;AAAA,UACjB,GAAG;AAAA,SACP;AAAA,MACJ,CAAC;AAAA,MAEJ,IAAA,EAAK;AACV,IAAA,MAAM,kBAAA,GAAqB;AAAA,MACvB,GAAG,gBAAA,CAAiB,GAAA,CAAyB,CAAC,CAAA,MAAO;AAAA,QACjD,IAAA,EAAM,WAAA;AAAA,QACN,GAAG;AAAA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