@open-pioneer/runtime 4.7.1-dev-test-snapshot-123.20260821142246 → 4.8.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +178 -174
  2. package/CustomElement.js.map +1 -1
  3. package/DeclaredService.js.map +1 -1
  4. package/Service.js.map +1 -1
  5. package/_virtual/source-info.js.map +1 -1
  6. package/app/AppInstance.js.map +1 -1
  7. package/app/gatherConfig.js.map +1 -1
  8. package/app/logErrors.js.map +1 -1
  9. package/builtin-services/ApiServiceImpl.js.map +1 -1
  10. package/builtin-services/ApplicationContextImpl.js.map +1 -1
  11. package/builtin-services/ApplicationLifecycleEventService.js.map +1 -1
  12. package/builtin-services/LocaleServiceImpl.js.map +1 -1
  13. package/builtin-services/NumberParserServiceImpl.js.map +1 -1
  14. package/builtin-services/ThemeServiceImpl.js.map +1 -1
  15. package/builtin-services/index.js.map +1 -1
  16. package/dom/index.js.map +1 -1
  17. package/errors.js.map +1 -1
  18. package/i18n/AppIntl.js.map +1 -1
  19. package/i18n/PackageIntl.js.map +1 -1
  20. package/i18n/intl-locale.js.map +1 -1
  21. package/i18n/pick.js.map +1 -1
  22. package/metadata/ObservableBox.js.map +1 -1
  23. package/package.json +9 -9
  24. package/react-integration/ChakraProvider.js.map +1 -1
  25. package/react-integration/ErrorScreen.js.map +1 -1
  26. package/react-integration/PackageContext.js.map +1 -1
  27. package/react-integration/ReactIntegration.js.map +1 -1
  28. package/react-integration/hooks.js.map +1 -1
  29. package/service-layer/InterfaceSpec.js.map +1 -1
  30. package/service-layer/PackageRepr.js.map +1 -1
  31. package/service-layer/ServiceLayer.js.map +1 -1
  32. package/service-layer/ServiceLookup.js.map +1 -1
  33. package/service-layer/ServiceRepr.js.map +1 -1
  34. package/service-layer/verifyDependencies.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
- ## 4.7.1-dev-test-snapshot-123.20260821142246
3
+ ## 4.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a38e934: Update Chakra to 3.37.0
4
8
 
5
9
  ### Patch Changes
6
10
 
@@ -15,12 +19,12 @@
15
19
  - e433296: Update Chakra UI to 3.36.1
16
20
  - 278515d: Add `runtime.LocaleService` and opt-in reactive locale switching.
17
21
 
18
- You can opt-in by configuring the property `advanced.enableLiveLocaleChanges` when calling `createCustomElement`.
19
- Once enabled, locale switches can be done without restarting the application.
20
- Use `LocaleService.changeLocale` to update the application's locale.
22
+ You can opt-in by configuring the property `advanced.enableLiveLocaleChanges` when calling `createCustomElement`.
23
+ Once enabled, locale switches can be done without restarting the application.
24
+ Use `LocaleService.changeLocale` to update the application's locale.
21
25
 
22
- Also export `parseLocale` and `tryParseLocale` algorithms.
23
- These can be used to construct a (cleaned up) `Intl.Locale` object from a string.
26
+ Also export `parseLocale` and `tryParseLocale` algorithms.
27
+ These can be used to construct a (cleaned up) `Intl.Locale` object from a string.
24
28
 
25
29
  ### Patch Changes
26
30
 
@@ -39,15 +43,15 @@
39
43
  - 05425c6: runtime - Introduce support for ServiceFactories, to provide constructor indirection during service creation
40
44
  - 63db133: Support for hot reloading of i18n messages (requires updated vite plugin).
41
45
  When i18n messages are updated:
42
- - React components rerender automatically with new `intl` object returned by `useIntl()`.
43
- - Services that use the new `serviceOptions.currentIntl` interface also receive a new `intl` object (if they are watching for changes).
44
- - Services that that still use the deprecated `serviceOptions.intl` interface cause the application to reload instead.
46
+ - React components rerender automatically with new `intl` object returned by `useIntl()`.
47
+ - Services that use the new `serviceOptions.currentIntl` interface also receive a new `intl` object (if they are watching for changes).
48
+ - Services that that still use the deprecated `serviceOptions.intl` interface cause the application to reload instead.
45
49
 
46
50
  ### Patch Changes
47
51
 
48
52
  - e6db101: Update to Chakra UI 3.35.0
49
- - update to Chakra UI @ 3.35.0, Ark UI @ 5.36.2, Zag JS @ 1.40.0
50
- - use TooltipProviderProps to override `openDelay` globally (instead of Tooltip snippet)
53
+ - update to Chakra UI @ 3.35.0, Ark UI @ 5.36.2, Zag JS @ 1.40.0
54
+ - use TooltipProviderProps to override `openDelay` globally (instead of Tooltip snippet)
51
55
 
52
56
  - b092b75: Declare css property `color-scheme` on the application root. This can be used by the browser to render builtin controls differently.
53
57
 
@@ -56,9 +60,9 @@
56
60
  ### Minor Changes
57
61
 
58
62
  - 89d743b: Provide `runtime.ThemeService`:
59
- - Supports switching between color modes `light` and `dark`.
60
- - Supports changing the chakra theme ("systemConfig") at runtime.
61
- - Supports reactive access to the preferred (system) color mode.
63
+ - Supports switching between color modes `light` and `dark`.
64
+ - Supports changing the chakra theme ("systemConfig") at runtime.
65
+ - Supports reactive access to the preferred (system) color mode.
62
66
 
63
67
  - 89d743b: Support for color modes (light and dark).
64
68
  The default color mode remains `light` for backwards compatibility.
@@ -107,7 +111,7 @@
107
111
 
108
112
  - b7a854d: Update dependencies
109
113
  - 3881d08: - Update Chakra UI from 3.22.0 to 3.24.2
110
- - Update to latest Chakra snippets
114
+ - Update to latest Chakra snippets
111
115
  - adf277b: Update dependencies
112
116
 
113
117
  ## 4.0.0
@@ -117,41 +121,41 @@
117
121
  - 9f074d8: Update to Chakra 3.x
118
122
  - 53c92ba: Introduce an advanced option to disable the shadow root.
119
123
 
120
- By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.
124
+ By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.
121
125
 
122
- Applications that use the entire browser viewport may not need this feature, since there may be no "other" parts that may conflict with the app. In this case, you can disable the shadow root by setting this property to `false`.
123
- - New option `advanced.enableShadowRoot`:
126
+ Applications that use the entire browser viewport may not need this feature, since there may be no "other" parts that may conflict with the app. In this case, you can disable the shadow root by setting this property to `false`.
127
+ - New option `advanced.enableShadowRoot`:
124
128
 
125
- ```ts
126
- import { createCustomElement } from "@open-pioneer/runtime";
127
- import * as appMetadata from "open-pioneer:app";
128
- import { AppUI } from "./AppUI";
129
-
130
- const element = createCustomElement({
131
- component: AppUI,
132
- appMetadata,
133
- advanced: {
134
- enableShadowRoot: false,
135
- },
136
- });
137
-
138
- customElements.define("no-shadowroot-sample", element);
139
- ```
129
+ ```ts
130
+ import { createCustomElement } from "@open-pioneer/runtime";
131
+ import * as appMetadata from "open-pioneer:app";
132
+ import { AppUI } from "./AppUI";
140
133
 
141
- - **Breaking:** As a consequence, the `ApplicationContext`'s `getShadowRoot()` method will now return `undefined` if the shadow root is disabled (previous: always a `ShadowRoot`):
134
+ const element = createCustomElement({
135
+ component: AppUI,
136
+ appMetadata,
137
+ advanced: {
138
+ enableShadowRoot: false
139
+ }
140
+ });
142
141
 
143
- ```ts
144
- const ctx: ApplicationContext = ...; // injected
145
- const shadowRoot = ctx.getShadowRoot(); // ShadowRoot | undefined
146
- ```
142
+ customElements.define("no-shadowroot-sample", element);
143
+ ```
147
144
 
148
- - New method on the `ApplicationContext` that returns _either_ the `ShadowRoot` _or_ the `Document` (if the shadow root is disabled):
145
+ - **Breaking:** As a consequence, the `ApplicationContext`'s `getShadowRoot()` method will now return `undefined` if the shadow root is disabled (previous: always a `ShadowRoot`):
149
146
 
150
- ```ts
151
- const ctx: ApplicationContext = ...; // injected
152
- const root = ctx.getRoot(); // Document | ShadowRoot
153
- root.getElementById("...") // always works
154
- ```
147
+ ```ts
148
+ const ctx: ApplicationContext = ...; // injected
149
+ const shadowRoot = ctx.getShadowRoot(); // ShadowRoot | undefined
150
+ ```
151
+
152
+ - New method on the `ApplicationContext` that returns _either_ the `ShadowRoot` _or_ the `Document` (if the shadow root is disabled):
153
+
154
+ ```ts
155
+ const ctx: ApplicationContext = ...; // injected
156
+ const root = ctx.getRoot(); // Document | ShadowRoot
157
+ root.getElementById("...") // always works
158
+ ```
155
159
 
156
160
  - 9f074d8: **Breaking:** Rename `theme` option of `createCustomElement()` to `chakraSystemConfig`.
157
161
 
@@ -167,54 +171,54 @@
167
171
  In addition to primitive values, rich text formatting supports react values and custom react tags.
168
172
  It always returns a react node, so can only be used in combination with react components.
169
173
 
170
- _Example with react node as value:_
171
-
172
- ```tsx
173
- function Example() {
174
- const intl = useIntl();
175
- // Given i18n message "Hello, {name}!"
176
- // replaces 'name' with the given react node:
177
- const message = intl.formatRichMessage(
178
- { id: "foo" },
179
- {
180
- name: <FancyUserName />,
181
- },
182
- );
183
- return <Box>{message}</Box>;
184
- }
185
- ```
186
-
187
- _Example with basic formatting:_
188
-
189
- ```tsx
190
- function Example() {
191
- const intl = useIntl();
192
- // Given i18n message "Hello, <strong>{name}</strong>!"
193
- // renders with actual <strong> html node:
194
- return <Box>{intl.formatRichMessage({ id: "foo" }, { name: "User" })}</Box>;
195
- }
196
- ```
197
-
198
- Note that only a few basic formatting tags are predefined ("b", "strong", "i", "em", "code", "br").
199
- If you need more advanced tags, you can define your own, see below.
200
- _Example with custom tag:_
201
-
202
- ```tsx
203
- function Example() {
204
- const intl = useIntl();
205
- // Given i18n message "Open <foo>the door</foo>!",
206
- // renders 'foo' using the formatter function below:
207
- const message = intl.formatRichMessage(
208
- { id: "foo" },
209
- {
210
- foo: (parts) => <FancyTag>{parts}</FancyTag>,
211
- },
212
- );
213
- return <Box>{message}</Box>;
214
- }
215
- ```
216
-
217
- The TypeScript signature for the `intl.formatMessage()` function has been made a little bit stricter compared with FormatJS: only primitive values are allowed for the `values` argument (this should not affect users in practice).
174
+ _Example with react node as value:_
175
+
176
+ ```tsx
177
+ function Example() {
178
+ const intl = useIntl();
179
+ // Given i18n message "Hello, {name}!"
180
+ // replaces 'name' with the given react node:
181
+ const message = intl.formatRichMessage(
182
+ { id: "foo" },
183
+ {
184
+ name: <FancyUserName />
185
+ }
186
+ );
187
+ return <Box>{message}</Box>;
188
+ }
189
+ ```
190
+
191
+ _Example with basic formatting:_
192
+
193
+ ```tsx
194
+ function Example() {
195
+ const intl = useIntl();
196
+ // Given i18n message "Hello, <strong>{name}</strong>!"
197
+ // renders with actual <strong> html node:
198
+ return <Box>{intl.formatRichMessage({ id: "foo" }, { name: "User" })}</Box>;
199
+ }
200
+ ```
201
+
202
+ Note that only a few basic formatting tags are predefined ("b", "strong", "i", "em", "code", "br").
203
+ If you need more advanced tags, you can define your own, see below.
204
+ _Example with custom tag:_
205
+
206
+ ```tsx
207
+ function Example() {
208
+ const intl = useIntl();
209
+ // Given i18n message "Open <foo>the door</foo>!",
210
+ // renders 'foo' using the formatter function below:
211
+ const message = intl.formatRichMessage(
212
+ { id: "foo" },
213
+ {
214
+ foo: (parts) => <FancyTag>{parts}</FancyTag>
215
+ }
216
+ );
217
+ return <Box>{message}</Box>;
218
+ }
219
+ ```
220
+
221
+ The TypeScript signature for the `intl.formatMessage()` function has been made a little bit stricter compared with FormatJS: only primitive values are allowed for the `values` argument (this should not affect users in practice).
218
222
 
219
223
  ### Patch Changes
220
224
 
@@ -225,13 +229,13 @@
225
229
  ### Major Changes
226
230
 
227
231
  - 9477e54: Update dependencies
228
- - React 19
229
- - Vite 6
230
- - FormatJS 3
231
- - Open Pioneer Build Tools
232
- - ...
232
+ - React 19
233
+ - Vite 6
234
+ - FormatJS 3
235
+ - Open Pioneer Build Tools
236
+ - ...
233
237
 
234
- For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
238
+ For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
235
239
 
236
240
  ## 2.4.0
237
241
 
@@ -272,7 +276,7 @@
272
276
  ### Patch Changes
273
277
 
274
278
  - e945264: Improve error message when metadata is missing (#55)
275
- - @open-pioneer/runtime-react-support@1.0.2
279
+ - @open-pioneer/runtime-react-support@1.0.2
276
280
 
277
281
  ## 2.1.5
278
282
 
@@ -283,16 +287,16 @@
283
287
  Note that with the current implementation, the application will simply restart with the new locale.
284
288
  The application's state will be lost.
285
289
 
286
- Example:
290
+ Example:
287
291
 
288
- ```ts
289
- import { ApplicationContext } from "@open-pioneer/runtime";
292
+ ```ts
293
+ import { ApplicationContext } from "@open-pioneer/runtime";
290
294
 
291
- const appCtx: ApplicationContext = ...; // injected
292
- appCtx.setLocale("en-US");
293
- ```
295
+ const appCtx: ApplicationContext = ...; // injected
296
+ appCtx.setLocale("en-US");
297
+ ```
294
298
 
295
- - @open-pioneer/runtime-react-support@1.0.2
299
+ - @open-pioneer/runtime-react-support@1.0.2
296
300
 
297
301
  ## 2.1.4
298
302
 
@@ -314,7 +318,7 @@
314
318
  ### Patch Changes
315
319
 
316
320
  - f749d96: Add a hint that `DECLARE_SERVICE_INTERFACE` should be imported via `import type`.
317
- - @open-pioneer/runtime-react-support@1.0.0
321
+ - @open-pioneer/runtime-react-support@1.0.0
318
322
 
319
323
  ## 2.1.0
320
324
 
@@ -322,46 +326,46 @@
322
326
 
323
327
  - 80cd62d: Improve TypeScript integration for service classes.
324
328
 
325
- Add a way for a service class to specify its interface name directly.
326
- Usually services used across package boundaries split their public interface and their implementation such as this:
327
-
328
- ```ts
329
- // Exported from package
330
- interface MyService extends DeclaredService<"my-package.SomeInterface"> {
331
- method(): void;
332
- }
329
+ Add a way for a service class to specify its interface name directly.
330
+ Usually services used across package boundaries split their public interface and their implementation such as this:
333
331
 
334
- // In an implementation file, usually private.
335
- class MyServiceImpl implements MyService {
336
- method(): void {
337
- // ...
332
+ ```ts
333
+ // Exported from package
334
+ interface MyService extends DeclaredService<"my-package.SomeInterface"> {
335
+ method(): void;
338
336
  }
339
- }
340
- ```
341
337
 
342
- Until now, there was no way for a service class to declare its interface directly.
343
- This could be convenient within a package, or with a group of tightly coupled packages:
338
+ // In an implementation file, usually private.
339
+ class MyServiceImpl implements MyService {
340
+ method(): void {
341
+ // ...
342
+ }
343
+ }
344
+ ```
344
345
 
345
- ```ts
346
- // Error: Type 'MyServiceImpl' has no properties in common with type 'DeclaredService<"my-package.InterfaceName">'.
347
- class MyServiceImpl implements DeclaredService<"my-package.InterfaceName"> {
348
- method() {}
349
- }
350
- ```
346
+ Until now, there was no way for a service class to declare its interface directly.
347
+ This could be convenient within a package, or with a group of tightly coupled packages:
351
348
 
352
- From now on, you can write this instead:
349
+ ```ts
350
+ // Error: Type 'MyServiceImpl' has no properties in common with type 'DeclaredService<"my-package.InterfaceName">'.
351
+ class MyServiceImpl implements DeclaredService<"my-package.InterfaceName"> {
352
+ method() {}
353
+ }
354
+ ```
353
355
 
354
- ```ts
355
- class MyServiceImpl {
356
- // Tells TypeScript which interface name must be used.
357
- // See documentation of `DECLARE_SERVICE_INTERFACE` for more details.
358
- declare [DECLARE_SERVICE_INTERFACE]: "my-package.InterfaceName";
356
+ From now on, you can write this instead:
359
357
 
360
- method(): void {
361
- // ...
358
+ ```ts
359
+ class MyServiceImpl {
360
+ // Tells TypeScript which interface name must be used.
361
+ // See documentation of `DECLARE_SERVICE_INTERFACE` for more details.
362
+ declare [DECLARE_SERVICE_INTERFACE]: "my-package.InterfaceName";
363
+
364
+ method(): void {
365
+ // ...
366
+ }
362
367
  }
363
- }
364
- ```
368
+ ```
365
369
 
366
370
  ### Patch Changes
367
371
 
@@ -381,51 +385,51 @@
381
385
  - 6f954e3: **Breaking Change**: change how services integrate into TypeScript (fixes #22).
382
386
  The old TypeScript integration had unexpected edge cases, see the linked issue.
383
387
 
384
- NOTE: The changes below have no impact on runtime behavior, but they may trigger TypeScript errors in your code.
385
- - To register a service's type with TypeScript, one previously used a block such as this:
388
+ NOTE: The changes below have no impact on runtime behavior, but they may trigger TypeScript errors in your code.
389
+ - To register a service's type with TypeScript, one previously used a block such as this:
386
390
 
387
- ```ts
388
- // OLD! Can be removed
389
- import "@open-pioneer/runtime";
390
- declare module "@open-pioneer/runtime" {
391
- interface ServiceRegistry {
392
- "http.HttpService": HttpService;
393
- }
394
- }
395
- ```
391
+ ```ts
392
+ // OLD! Can be removed
393
+ import "@open-pioneer/runtime";
394
+ declare module "@open-pioneer/runtime" {
395
+ interface ServiceRegistry {
396
+ "http.HttpService": HttpService;
397
+ }
398
+ }
399
+ ```
396
400
 
397
- The new method requires the developer to change the service's declaration.
398
- Simply add `extends DeclaredService<"SERVICE_ID">` to your service interface, where `SERVICE_ID` should match the service's interface name (`"provides"` in `build.config.mjs`).
401
+ The new method requires the developer to change the service's declaration.
402
+ Simply add `extends DeclaredService<"SERVICE_ID">` to your service interface, where `SERVICE_ID` should match the service's interface name (`"provides"` in `build.config.mjs`).
399
403
 
400
- ```diff
401
- + import { DeclaredService } from "@open-pioneer/runtime";
404
+ ```diff
405
+ + import { DeclaredService } from "@open-pioneer/runtime";
402
406
 
403
- - export interface HttpService {
404
- + export interface HttpService extends DeclaredService<"http.HttpService"> {
407
+ - export interface HttpService {
408
+ + export interface HttpService extends DeclaredService<"http.HttpService"> {
405
409
 
406
- - import "@open-pioneer/runtime";
407
- - declare module "@open-pioneer/runtime" {
408
- - interface ServiceRegistry {
409
- - "http.HttpService": HttpService;
410
- - }
411
- - }
412
- ```
410
+ - import "@open-pioneer/runtime";
411
+ - declare module "@open-pioneer/runtime" {
412
+ - interface ServiceRegistry {
413
+ - "http.HttpService": HttpService;
414
+ - }
415
+ - }
416
+ ```
413
417
 
414
- - To use a service from React code (i.e. `useService` and `useServices`), you must now use the explicit service type in the hook's generic parameter list. Otherwise the hook will simply return `unknown`:
418
+ - To use a service from React code (i.e. `useService` and `useServices`), you must now use the explicit service type in the hook's generic parameter list. Otherwise the hook will simply return `unknown`:
415
419
 
416
- ```diff
417
- + import { HttpService } from "@open-pioneer/http";
418
- - const httpService = useService("http.HttpService");
419
- + const httpService = useService<HttpService>("http.HttpService");
420
- ```
420
+ ```diff
421
+ + import { HttpService } from "@open-pioneer/http";
422
+ - const httpService = useService("http.HttpService");
423
+ + const httpService = useService<HttpService>("http.HttpService");
424
+ ```
421
425
 
422
- This change was necessary to fix an issue where the global registration of the service interface (and its association with the string constant) was not available.
426
+ This change was necessary to fix an issue where the global registration of the service interface (and its association with the string constant) was not available.
423
427
 
424
- The system will still check that the provided string matches the string constant used in the service's declaration (`DeclaredService<...>`), so type safety is preserved.
428
+ The system will still check that the provided string matches the string constant used in the service's declaration (`DeclaredService<...>`), so type safety is preserved.
425
429
 
426
- - The types `InterfaceName` and `ServiceType<I>` have been removed. Use explicit service interfaces instead.
427
- - The interfaces `ServiceRegistry` and `PropertiesRegistry` have been removed as global registration is no longer possible.
428
- - The type `RawApplicationProperties` has been removed. Use `ApplicationProperties` instead.
430
+ - The types `InterfaceName` and `ServiceType<I>` have been removed. Use explicit service interfaces instead.
431
+ - The interfaces `ServiceRegistry` and `PropertiesRegistry` have been removed as global registration is no longer possible.
432
+ - The type `RawApplicationProperties` has been removed. Use `ApplicationProperties` instead.
429
433
 
430
434
  ### Patch Changes
431
435
 
@@ -1 +1 @@
1
- {"version":3,"file":"CustomElement.js","sources":["CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ComponentType } from \"react\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type ApiMethods, type ColorModeValue, type ApiExtension } from \"./api\";\nimport { AppInstance } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { ServiceOptions } from \"./Service\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n *\n * This option can be used to override default properties of the application's packages.\n *\n * All instances of the web component will share this static configuration.\n */\n config?: ApplicationConfig;\n\n /**\n * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n\n /**\n * Advanced configuration that alters the behavior of the custom element.\n */\n advanced?: AdvancedCustomElementOptions;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application instance basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * The application's host element.\n */\n hostElement: HTMLElement;\n\n /**\n * Defined when the application forcefully restarts with new options.\n */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Application overrides are defined when the is explicitly being restarted with new options.\n *\n * Options set through overrides cannot be overwritten by the `resolveConfig` hook.\n */\nexport interface ApplicationOverrides {\n /**\n * The new application locale.\n */\n locale?: string;\n\n /**\n * The new color mode.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * The new used chakra system config.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale (BCP-47 string, e.g. `\"en\"`) to set the default message locale of the application.\n *\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * This locale should match one of the supported message locales defined by the application's package.\n */\n locale?: string | undefined;\n\n /**\n * The list of locales supported by the application.\n *\n * This allows a further restriction of the locales supported by the application, compared to the ones defined by the application's package.\n * It is not possible to extend the supported locales defined by the package, only to restrict them.\n *\n * If this property is not set, then the application supports all locales defined by the application's package.\n * If the values are not a valid subset of the application package supported locales, then the application will throw an error at startup.\n *\n * An empty array will disable loading of any message bundle.\n */\n supportedLocales?: string[] | undefined;\n\n /**\n * Configures the application's initial color mode.\n *\n * Use `system` to use the user's preferred color mode, derived from the browser or operating system.\n *\n * Default: `light`.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n\n /**\n * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n *\n * NOTE: This setting has priority over {@link CustomElementOptions.chakraSystemConfig}.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport interface ApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /**\n * Resolves to the element's API when the application has started.\n *\n * The API exposed by an application can be defined by implementing an {@link ApiExtension}.\n * For more details, open the documentation of the `@open-pioneer/integration` package.\n */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * Advanced configuration that alters the behavior of the custom element.\n *\n * See {@link createCustomElement}.\n */\nexport interface AdvancedCustomElementOptions {\n /**\n * Enables or disables the [shadow root](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot) inside the application's web component.\n *\n * Default: `true`.\n *\n * By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.\n *\n * Applications that use the entire browser viewport may not need this feature, since there may be no \"other\" parts that may conflict with the app.\n * In this case, you can disable the shadow root by setting this property to `false`.\n * In general, UI components used by the app (e.g. from Chakra UI) should work just as well when disabling the shadow root.\n * If you notice any problems, please file an issue.\n *\n * If you are developing UI components that are meant to be used in other applications, you should always use a shadow root to\n * ensure that your components work in that setting.\n */\n enableShadowRoot?: boolean;\n\n /**\n * Opts into live locale changes within the running application, without performing a full application restart.\n *\n * Default: `false`.\n *\n * Live locale changes preserve the application's state when the user changes the language.\n * It requires that react components and services in the application handle intl changes correctly (see, for example, {@link ServiceOptions.currentIntl}).\n *\n * Note that this option will become the new default in the next major release,\n * at which point this option will be removed.\n */\n enableLiveLocaleChanges?: boolean;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot | undefined;\n #instance: AppInstance | undefined;\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n #deferredRestart: any; // A Timer\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n const enableShadowRoot = options.advanced?.enableShadowRoot ?? true;\n if (enableShadowRoot) {\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n } else {\n LOG.debug(\"Creating component instance without shadow root\");\n }\n\n if (import.meta.env.DEV) {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#instance;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#instance) {\n this.#instance.destroy();\n }\n\n this.#instance = this.#createApplicationInstance();\n this.#instance.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#instance?.destroy();\n this.#instance = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#instance) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#instance.whenAPI();\n }\n\n #triggerReload(overrides?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new AppInstance({\n rootNode: this.#shadowRoot ?? document,\n hostElement: this,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"CustomElement.js","sources":["CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ComponentType } from \"react\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type ApiMethods, type ColorModeValue, type ApiExtension } from \"./api\";\nimport { AppInstance } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { ServiceOptions } from \"./Service\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n *\n * This option can be used to override default properties of the application's packages.\n *\n * All instances of the web component will share this static configuration.\n */\n config?: ApplicationConfig;\n\n /**\n * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n\n /**\n * Advanced configuration that alters the behavior of the custom element.\n */\n advanced?: AdvancedCustomElementOptions;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application instance basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * The application's host element.\n */\n hostElement: HTMLElement;\n\n /**\n * Defined when the application forcefully restarts with new options.\n */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Application overrides are defined when the is explicitly being restarted with new options.\n *\n * Options set through overrides cannot be overwritten by the `resolveConfig` hook.\n */\nexport interface ApplicationOverrides {\n /**\n * The new application locale.\n */\n locale?: string;\n\n /**\n * The new color mode.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * The new used chakra system config.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale (BCP-47 string, e.g. `\"en\"`) to set the default message locale of the application.\n *\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * This locale should match one of the supported message locales defined by the application's package.\n */\n locale?: string | undefined;\n\n /**\n * The list of locales supported by the application.\n *\n * This allows a further restriction of the locales supported by the application, compared to the ones defined by the application's package.\n * It is not possible to extend the supported locales defined by the package, only to restrict them.\n *\n * If this property is not set, then the application supports all locales defined by the application's package.\n * If the values are not a valid subset of the application package supported locales, then the application will throw an error at startup.\n *\n * An empty array will disable loading of any message bundle.\n */\n supportedLocales?: string[] | undefined;\n\n /**\n * Configures the application's initial color mode.\n *\n * Use `system` to use the user's preferred color mode, derived from the browser or operating system.\n *\n * Default: `light`.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n\n /**\n * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n *\n * NOTE: This setting has priority over {@link CustomElementOptions.chakraSystemConfig}.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport interface ApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /**\n * Resolves to the element's API when the application has started.\n *\n * The API exposed by an application can be defined by implementing an {@link ApiExtension}.\n * For more details, open the documentation of the `@open-pioneer/integration` package.\n */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * Advanced configuration that alters the behavior of the custom element.\n *\n * See {@link createCustomElement}.\n */\nexport interface AdvancedCustomElementOptions {\n /**\n * Enables or disables the [shadow root](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot) inside the application's web component.\n *\n * Default: `true`.\n *\n * By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.\n *\n * Applications that use the entire browser viewport may not need this feature, since there may be no \"other\" parts that may conflict with the app.\n * In this case, you can disable the shadow root by setting this property to `false`.\n * In general, UI components used by the app (e.g. from Chakra UI) should work just as well when disabling the shadow root.\n * If you notice any problems, please file an issue.\n *\n * If you are developing UI components that are meant to be used in other applications, you should always use a shadow root to\n * ensure that your components work in that setting.\n */\n enableShadowRoot?: boolean;\n\n /**\n * Opts into live locale changes within the running application, without performing a full application restart.\n *\n * Default: `false`.\n *\n * Live locale changes preserve the application's state when the user changes the language.\n * It requires that react components and services in the application handle intl changes correctly (see, for example, {@link ServiceOptions.currentIntl}).\n *\n * Note that this option will become the new default in the next major release,\n * at which point this option will be removed.\n */\n enableLiveLocaleChanges?: boolean;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot | undefined;\n #instance: AppInstance | undefined;\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n #deferredRestart: any; // A Timer\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n const enableShadowRoot = options.advanced?.enableShadowRoot ?? true;\n if (enableShadowRoot) {\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n } else {\n LOG.debug(\"Creating component instance without shadow root\");\n }\n\n if (import.meta.env.DEV) {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#instance;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#instance) {\n this.#instance.destroy();\n }\n\n this.#instance = this.#createApplicationInstance();\n this.#instance.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#instance?.destroy();\n this.#instance = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#instance) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#instance.whenAPI();\n }\n\n #triggerReload(overrides?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new AppInstance({\n rootNode: this.#shadowRoot ?? document,\n hostElement: this,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & (infer InterfaceName) }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"AA+DA,MAAM,yBAAA,0BAAmC,mCAAmC;;;;"}
1
+ {"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & (infer InterfaceName) }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"AA+DA,MAAM,yBAAA,0BAAmC,mCAAmC;;"}
package/Service.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Service.js","sources":["Service.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { PackageIntl } from \"./i18n\";\n\n/** Lifecycle hooks supported by the service interface. */\nexport interface ServiceLifecycleHooks {\n /**\n * Destroys the component.\n * Should clean up all resources used by the component.\n */\n destroy?(): void;\n\n /*\n * Just used so that this interface is not empty.\n * TypeScript would otherwise throw an 'no common properties' error\n * if one tries to implement this interface without providing any\n * lifecycle hooks.\n */\n toString(): string;\n}\n\nexport type Service<Interface extends {} = {}> = ServiceLifecycleHooks & Interface;\n\n/**\n * Represents metadata for an injected reference.\n */\nexport interface ReferenceMeta {\n /**\n * The unique service id of the injected service.\n */\n serviceId: string;\n}\n\n/**\n * Contains metadata about injected references.\n * The key for the reference metadata is the reference's name.\n */\nexport type ReferencesMeta<References extends {}> = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]: References[referenceName] extends any[]\n ? ReferenceMeta[]\n : ReferenceMeta;\n};\n\n/**\n * Options passed to a service's constructor.\n */\nexport type ServiceOptions<References extends {} = {}> = {\n /**\n * References to other services.\n * These are injected by the runtime and match the declared references of the service.\n */\n references: References;\n\n /**\n * Metadata about the injected references.\n * The object contains one entry for every reference injected via `references` (under the same key).\n *\n * If a single service has been injected, `referencesMeta[key]` will be of type {@link ReferenceMeta}.\n * If multiple services have been injected, an array of {@link ReferenceMeta} will be provided instead,\n * where the indices match the order in the injected references array.\n */\n referencesMeta: ReferencesMeta<References>;\n\n /**\n * Configuration properties.\n *\n * Default values are taken from the package's configuration, but these can be overridden\n * by the application.\n */\n properties: Record<string, unknown>;\n\n /**\n * A constant reference to the shared i18n object of the current package.\n *\n * @deprecated use `currentIntl` instead, which is a signal that returns the current i18n object and updates when it changes at runtime. Be aware to implement a watch for yourself\n */\n intl: PackageIntl;\n\n /**\n * A signal that returns the current i18n object of the service's package.\n *\n * The i18n object may change at runtime (for example to implement hot reloading during development,\n * or to implement language changes while the application is running).\n */\n currentIntl: ReadonlyReactive<PackageIntl>;\n};\n\n/**\n * A service constructor returns a service instance when calling `new`.\n */\nexport type ServiceConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): Service<Interface>;\n};\n\n/**\n * A service factory is an object that has a method to create a service instance.\n * The service factory itself can also implement lifecycle hooks, which will be called by the runtime\n * when the factory is destroyed.\n */\nexport type ServiceFactory<Interface extends {} = {}> = {\n /**\n * Method to create a service instance.\n * It is directly called by the runtime after constructing the factory.\n * NOTE: the service.destroy lifecycle hook is not called by the runtime.\n */\n createService(): Interface;\n /**\n * Optional method to destroy a service instance created by this factory.\n * If provided, this method will be called by the runtime when the service instance is destroyed.\n * A factory instance exists per service, this method invocation means that the factory is no longer used by the runtime.\n */\n destroyService?(service: Interface): void;\n};\n\n/**\n * A constructor type for a service factory.\n * The service factory is an object that has a method to create a service instance,\n * this allows for more flexibility in service construction.\n */\nexport type ServiceFactoryConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): ServiceFactory<Interface>;\n};\n\n/**\n * Symbol used to detect if a constructor function is a service factory constructor.\n */\nconst IS_SERVICE_FACTORY = Symbol(\"runtime.IS_SERVICE_FACTORY\");\nexport { IS_SERVICE_FACTORY };\n\n/**\n * A service factory constructor must be marked\n * with the `IS_SERVICE_FACTORY` symbol to be recognized by the runtime as such.\n */\nexport type MarkedServiceFactoryConstructor<\n References extends {} = {},\n Interface extends {} = {}\n> = ServiceFactoryConstructor<References, Interface> & {\n [IS_SERVICE_FACTORY]: true;\n};\n\n/**\n * Utility function to mark a constructor as a service factory constructor.\n * @param ctr normal constructor function for a service factory.\n * @returns the same constructor function, but marked with the `IS_SERVICE_FACTORY` symbol so that the runtime recognizes it as a service factory constructor.\n */\nexport function defineServiceFactory(\n ctr: ServiceFactoryConstructor\n): MarkedServiceFactoryConstructor {\n const markedCtr = ctr as MarkedServiceFactoryConstructor;\n markedCtr[IS_SERVICE_FACTORY] = true;\n return markedCtr;\n}\n"],"names":[],"mappings":"AAiIA,MAAM,kBAAA,0BAA4B,4BAA4B;AAmBvD,SAAS,qBACZ,GAAA,EAC+B;AAC/B,EAAA,MAAM,SAAA,GAAY,GAAA;AAClB,EAAA,SAAA,CAAU,kBAAkB,CAAA,GAAI,IAAA;AAChC,EAAA,OAAO,SAAA;AACX;;;;"}
1
+ {"version":3,"file":"Service.js","sources":["Service.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { PackageIntl } from \"./i18n\";\n\n/** Lifecycle hooks supported by the service interface. */\nexport interface ServiceLifecycleHooks {\n /**\n * Destroys the component.\n * Should clean up all resources used by the component.\n */\n destroy?(): void;\n\n /*\n * Just used so that this interface is not empty.\n * TypeScript would otherwise throw an 'no common properties' error\n * if one tries to implement this interface without providing any\n * lifecycle hooks.\n */\n toString(): string;\n}\n\nexport type Service<Interface extends {} = {}> = ServiceLifecycleHooks & Interface;\n\n/**\n * Represents metadata for an injected reference.\n */\nexport interface ReferenceMeta {\n /**\n * The unique service id of the injected service.\n */\n serviceId: string;\n}\n\n/**\n * Contains metadata about injected references.\n * The key for the reference metadata is the reference's name.\n */\nexport type ReferencesMeta<References extends {}> = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]: References[referenceName] extends any[]\n ? ReferenceMeta[]\n : ReferenceMeta;\n};\n\n/**\n * Options passed to a service's constructor.\n */\nexport type ServiceOptions<References extends {} = {}> = {\n /**\n * References to other services.\n * These are injected by the runtime and match the declared references of the service.\n */\n references: References;\n\n /**\n * Metadata about the injected references.\n * The object contains one entry for every reference injected via `references` (under the same key).\n *\n * If a single service has been injected, `referencesMeta[key]` will be of type {@link ReferenceMeta}.\n * If multiple services have been injected, an array of {@link ReferenceMeta} will be provided instead,\n * where the indices match the order in the injected references array.\n */\n referencesMeta: ReferencesMeta<References>;\n\n /**\n * Configuration properties.\n *\n * Default values are taken from the package's configuration, but these can be overridden\n * by the application.\n */\n properties: Record<string, unknown>;\n\n /**\n * A constant reference to the shared i18n object of the current package.\n *\n * @deprecated use `currentIntl` instead, which is a signal that returns the current i18n object and updates when it changes at runtime. Be aware to implement a watch for yourself\n */\n intl: PackageIntl;\n\n /**\n * A signal that returns the current i18n object of the service's package.\n *\n * The i18n object may change at runtime (for example to implement hot reloading during development,\n * or to implement language changes while the application is running).\n */\n currentIntl: ReadonlyReactive<PackageIntl>;\n};\n\n/**\n * A service constructor returns a service instance when calling `new`.\n */\nexport type ServiceConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): Service<Interface>;\n};\n\n/**\n * A service factory is an object that has a method to create a service instance.\n * The service factory itself can also implement lifecycle hooks, which will be called by the runtime\n * when the factory is destroyed.\n */\nexport type ServiceFactory<Interface extends {} = {}> = {\n /**\n * Method to create a service instance.\n * It is directly called by the runtime after constructing the factory.\n * NOTE: the service.destroy lifecycle hook is not called by the runtime.\n */\n createService(): Interface;\n /**\n * Optional method to destroy a service instance created by this factory.\n * If provided, this method will be called by the runtime when the service instance is destroyed.\n * A factory instance exists per service, this method invocation means that the factory is no longer used by the runtime.\n */\n destroyService?(service: Interface): void;\n};\n\n/**\n * A constructor type for a service factory.\n * The service factory is an object that has a method to create a service instance,\n * this allows for more flexibility in service construction.\n */\nexport type ServiceFactoryConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): ServiceFactory<Interface>;\n};\n\n/**\n * Symbol used to detect if a constructor function is a service factory constructor.\n */\nconst IS_SERVICE_FACTORY = Symbol(\"runtime.IS_SERVICE_FACTORY\");\nexport { IS_SERVICE_FACTORY };\n\n/**\n * A service factory constructor must be marked\n * with the `IS_SERVICE_FACTORY` symbol to be recognized by the runtime as such.\n */\nexport type MarkedServiceFactoryConstructor<\n References extends {} = {},\n Interface extends {} = {}\n> = ServiceFactoryConstructor<References, Interface> & {\n [IS_SERVICE_FACTORY]: true;\n};\n\n/**\n * Utility function to mark a constructor as a service factory constructor.\n * @param ctr normal constructor function for a service factory.\n * @returns the same constructor function, but marked with the `IS_SERVICE_FACTORY` symbol so that the runtime recognizes it as a service factory constructor.\n */\nexport function defineServiceFactory(\n ctr: ServiceFactoryConstructor\n): MarkedServiceFactoryConstructor {\n const markedCtr = ctr as MarkedServiceFactoryConstructor;\n markedCtr[IS_SERVICE_FACTORY] = true;\n return markedCtr;\n}\n"],"names":[],"mappings":"AAiIA,MAAM,kBAAA,0BAA4B,4BAA4B;AAmBvD,SAAS,qBACZ,GAAA,EAC+B;AAC/B,EAAA,MAAM,SAAA,GAAY,GAAA;AAClB,EAAA,SAAA,CAAU,kBAAkB,CAAA,GAAI,IAAA;AAChC,EAAA,OAAO,SAAA;AACX;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}