@open-pioneer/runtime 4.8.0 → 4.9.0-dev.20261002130116

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 (55) hide show
  1. package/CHANGELOG.md +189 -173
  2. package/CustomElement.d.ts +5 -5
  3. package/CustomElement.js +1 -3
  4. package/CustomElement.js.map +1 -1
  5. package/README.md +14 -6
  6. package/Service.d.ts +2 -2
  7. package/Service.js.map +1 -1
  8. package/_virtual/source-info.js +7 -5
  9. package/_virtual/source-info.js.map +1 -1
  10. package/api.d.ts +7 -8
  11. package/app/AppInstance.js +10 -6
  12. package/app/AppInstance.js.map +1 -1
  13. package/app/gatherConfig.d.ts +13 -4
  14. package/app/gatherConfig.js +23 -12
  15. package/app/gatherConfig.js.map +1 -1
  16. package/app/logErrors.js +1 -1
  17. package/builtin-services/ApplicationContextImpl.js +7 -1
  18. package/builtin-services/ApplicationContextImpl.js.map +1 -1
  19. package/builtin-services/{ApplicationLifecycleEventService.d.ts → ApplicationLifecycleEventServiceImpl.d.ts} +1 -1
  20. package/builtin-services/{ApplicationLifecycleEventService.js → ApplicationLifecycleEventServiceImpl.js} +4 -4
  21. package/builtin-services/ApplicationLifecycleEventServiceImpl.js.map +1 -0
  22. package/builtin-services/NumberParserServiceImpl.d.ts +1 -1
  23. package/builtin-services/NumberParserServiceImpl.js +3 -3
  24. package/builtin-services/NumberParserServiceImpl.js.map +1 -1
  25. package/builtin-services/index.js +2 -2
  26. package/builtin-services/index.js.map +1 -1
  27. package/dom/index.d.ts +0 -1
  28. package/dom/index.js +1 -1
  29. package/dom/index.js.map +1 -1
  30. package/i18n/AppIntl.d.ts +1 -1
  31. package/i18n/AppIntl.js +5 -10
  32. package/i18n/AppIntl.js.map +1 -1
  33. package/i18n/PackageIntl.js +2 -5
  34. package/i18n/PackageIntl.js.map +1 -1
  35. package/metadata/ObservableBox.d.ts +1 -1
  36. package/metadata/ObservableBox.js.map +1 -1
  37. package/package.json +6 -6
  38. package/react-integration/PackageContext.d.ts +1 -1
  39. package/react-integration/PackageContext.js.map +1 -1
  40. package/react-integration/hooks.d.ts +4 -4
  41. package/react-integration/hooks.js +6 -7
  42. package/react-integration/hooks.js.map +1 -1
  43. package/service-layer/PackageRepr.d.ts +1 -1
  44. package/service-layer/PackageRepr.js +1 -1
  45. package/service-layer/PackageRepr.js.map +1 -1
  46. package/service-layer/ServiceLayer.d.ts +3 -2
  47. package/service-layer/ServiceLayer.js +4 -3
  48. package/service-layer/ServiceLayer.js.map +1 -1
  49. package/service-layer/ServiceLookup.d.ts +4 -3
  50. package/service-layer/ServiceLookup.js +3 -3
  51. package/service-layer/ServiceLookup.js.map +1 -1
  52. package/service-layer/ServiceRepr.d.ts +2 -2
  53. package/service-layer/ServiceRepr.js +7 -5
  54. package/service-layer/ServiceRepr.js.map +1 -1
  55. package/builtin-services/ApplicationLifecycleEventService.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
+ ## 4.9.0-dev.20261002130116
4
+
5
+ ### Minor Changes
6
+
7
+ - 6145961: Update `@formatjs/intl` to version 6.
8
+
9
+ ### Patch Changes
10
+
11
+ - 6b160f3: Fix a set of smaller issues:
12
+ - `element.when()` rejects with an abort error when the app failed to start, also when it is called after the failure. Previously such a call returned a promise that never settled.
13
+ - The deprecated `ApplicationContext.setLocale()` throws `runtime:unsupported-locale` again for a string that is not a valid BCP 47 tag, instead of silently switching to automatic locale selection.
14
+ - `useService()` no longer repeats the service lookup on every render when an options object is passed inline.
15
+ - The development-only intl watch of a service is released when the service constructor throws, and the `AppIntl` instance is released when the app is destroyed during startup.
16
+
17
+ - 7053566: An `undefined` value returned from `resolveConfig()` (for example `locale`) no longer overrides the default value of `config`.
18
+
3
19
  ## 4.8.0
4
20
 
5
21
  ### Minor Changes
@@ -19,12 +35,12 @@
19
35
  - e433296: Update Chakra UI to 3.36.1
20
36
  - 278515d: Add `runtime.LocaleService` and opt-in reactive locale switching.
21
37
 
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.
38
+ You can opt-in by configuring the property `advanced.enableLiveLocaleChanges` when calling `createCustomElement`.
39
+ Once enabled, locale switches can be done without restarting the application.
40
+ Use `LocaleService.changeLocale` to update the application's locale.
25
41
 
26
- Also export `parseLocale` and `tryParseLocale` algorithms.
27
- These can be used to construct a (cleaned up) `Intl.Locale` object from a string.
42
+ Also export `parseLocale` and `tryParseLocale` algorithms.
43
+ These can be used to construct a (cleaned up) `Intl.Locale` object from a string.
28
44
 
29
45
  ### Patch Changes
30
46
 
@@ -43,15 +59,15 @@
43
59
  - 05425c6: runtime - Introduce support for ServiceFactories, to provide constructor indirection during service creation
44
60
  - 63db133: Support for hot reloading of i18n messages (requires updated vite plugin).
45
61
  When i18n messages are updated:
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.
62
+ - React components rerender automatically with new `intl` object returned by `useIntl()`.
63
+ - Services that use the new `serviceOptions.currentIntl` interface also receive a new `intl` object (if they are watching for changes).
64
+ - Services that that still use the deprecated `serviceOptions.intl` interface cause the application to reload instead.
49
65
 
50
66
  ### Patch Changes
51
67
 
52
68
  - e6db101: Update to Chakra UI 3.35.0
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)
69
+ - update to Chakra UI @ 3.35.0, Ark UI @ 5.36.2, Zag JS @ 1.40.0
70
+ - use TooltipProviderProps to override `openDelay` globally (instead of Tooltip snippet)
55
71
 
56
72
  - b092b75: Declare css property `color-scheme` on the application root. This can be used by the browser to render builtin controls differently.
57
73
 
@@ -60,9 +76,9 @@
60
76
  ### Minor Changes
61
77
 
62
78
  - 89d743b: Provide `runtime.ThemeService`:
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.
79
+ - Supports switching between color modes `light` and `dark`.
80
+ - Supports changing the chakra theme ("systemConfig") at runtime.
81
+ - Supports reactive access to the preferred (system) color mode.
66
82
 
67
83
  - 89d743b: Support for color modes (light and dark).
68
84
  The default color mode remains `light` for backwards compatibility.
@@ -111,7 +127,7 @@
111
127
 
112
128
  - b7a854d: Update dependencies
113
129
  - 3881d08: - Update Chakra UI from 3.22.0 to 3.24.2
114
- - Update to latest Chakra snippets
130
+ - Update to latest Chakra snippets
115
131
  - adf277b: Update dependencies
116
132
 
117
133
  ## 4.0.0
@@ -121,41 +137,41 @@
121
137
  - 9f074d8: Update to Chakra 3.x
122
138
  - 53c92ba: Introduce an advanced option to disable the shadow root.
123
139
 
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.
125
-
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`:
140
+ 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.
128
141
 
129
- ```ts
130
- import { createCustomElement } from "@open-pioneer/runtime";
131
- import * as appMetadata from "open-pioneer:app";
132
- import { AppUI } from "./AppUI";
142
+ 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`.
143
+ - New option `advanced.enableShadowRoot`:
133
144
 
134
- const element = createCustomElement({
135
- component: AppUI,
136
- appMetadata,
137
- advanced: {
138
- enableShadowRoot: false
139
- }
140
- });
141
-
142
- customElements.define("no-shadowroot-sample", element);
143
- ```
145
+ ```ts
146
+ import { createCustomElement } from "@open-pioneer/runtime";
147
+ import * as appMetadata from "open-pioneer:app";
148
+ import { AppUI } from "./AppUI";
149
+
150
+ const element = createCustomElement({
151
+ component: AppUI,
152
+ appMetadata,
153
+ advanced: {
154
+ enableShadowRoot: false,
155
+ },
156
+ });
157
+
158
+ customElements.define("no-shadowroot-sample", element);
159
+ ```
144
160
 
145
- - **Breaking:** As a consequence, the `ApplicationContext`'s `getShadowRoot()` method will now return `undefined` if the shadow root is disabled (previous: always a `ShadowRoot`):
161
+ - **Breaking:** As a consequence, the `ApplicationContext`'s `getShadowRoot()` method will now return `undefined` if the shadow root is disabled (previous: always a `ShadowRoot`):
146
162
 
147
- ```ts
148
- const ctx: ApplicationContext = ...; // injected
149
- const shadowRoot = ctx.getShadowRoot(); // ShadowRoot | undefined
150
- ```
163
+ ```ts
164
+ const ctx: ApplicationContext = ...; // injected
165
+ const shadowRoot = ctx.getShadowRoot(); // ShadowRoot | undefined
166
+ ```
151
167
 
152
- - New method on the `ApplicationContext` that returns _either_ the `ShadowRoot` _or_ the `Document` (if the shadow root is disabled):
168
+ - New method on the `ApplicationContext` that returns _either_ the `ShadowRoot` _or_ the `Document` (if the shadow root is disabled):
153
169
 
154
- ```ts
155
- const ctx: ApplicationContext = ...; // injected
156
- const root = ctx.getRoot(); // Document | ShadowRoot
157
- root.getElementById("...") // always works
158
- ```
170
+ ```ts
171
+ const ctx: ApplicationContext = ...; // injected
172
+ const root = ctx.getRoot(); // Document | ShadowRoot
173
+ root.getElementById("...") // always works
174
+ ```
159
175
 
160
176
  - 9f074d8: **Breaking:** Rename `theme` option of `createCustomElement()` to `chakraSystemConfig`.
161
177
 
@@ -171,54 +187,54 @@
171
187
  In addition to primitive values, rich text formatting supports react values and custom react tags.
172
188
  It always returns a react node, so can only be used in combination with react components.
173
189
 
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).
190
+ _Example with react node as value:_
191
+
192
+ ```tsx
193
+ function Example() {
194
+ const intl = useIntl();
195
+ // Given i18n message "Hello, {name}!"
196
+ // replaces 'name' with the given react node:
197
+ const message = intl.formatRichMessage(
198
+ { id: "foo" },
199
+ {
200
+ name: <FancyUserName />,
201
+ },
202
+ );
203
+ return <Box>{message}</Box>;
204
+ }
205
+ ```
206
+
207
+ _Example with basic formatting:_
208
+
209
+ ```tsx
210
+ function Example() {
211
+ const intl = useIntl();
212
+ // Given i18n message "Hello, <strong>{name}</strong>!"
213
+ // renders with actual <strong> html node:
214
+ return <Box>{intl.formatRichMessage({ id: "foo" }, { name: "User" })}</Box>;
215
+ }
216
+ ```
217
+
218
+ Note that only a few basic formatting tags are predefined ("b", "strong", "i", "em", "code", "br").
219
+ If you need more advanced tags, you can define your own, see below.
220
+ _Example with custom tag:_
221
+
222
+ ```tsx
223
+ function Example() {
224
+ const intl = useIntl();
225
+ // Given i18n message "Open <foo>the door</foo>!",
226
+ // renders 'foo' using the formatter function below:
227
+ const message = intl.formatRichMessage(
228
+ { id: "foo" },
229
+ {
230
+ foo: (parts) => <FancyTag>{parts}</FancyTag>,
231
+ },
232
+ );
233
+ return <Box>{message}</Box>;
234
+ }
235
+ ```
236
+
237
+ 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).
222
238
 
223
239
  ### Patch Changes
224
240
 
@@ -229,13 +245,13 @@
229
245
  ### Major Changes
230
246
 
231
247
  - 9477e54: Update dependencies
232
- - React 19
233
- - Vite 6
234
- - FormatJS 3
235
- - Open Pioneer Build Tools
236
- - ...
248
+ - React 19
249
+ - Vite 6
250
+ - FormatJS 3
251
+ - Open Pioneer Build Tools
252
+ - ...
237
253
 
238
- For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
254
+ For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
239
255
 
240
256
  ## 2.4.0
241
257
 
@@ -276,7 +292,7 @@
276
292
  ### Patch Changes
277
293
 
278
294
  - e945264: Improve error message when metadata is missing (#55)
279
- - @open-pioneer/runtime-react-support@1.0.2
295
+ - @open-pioneer/runtime-react-support@1.0.2
280
296
 
281
297
  ## 2.1.5
282
298
 
@@ -287,16 +303,16 @@
287
303
  Note that with the current implementation, the application will simply restart with the new locale.
288
304
  The application's state will be lost.
289
305
 
290
- Example:
306
+ Example:
291
307
 
292
- ```ts
293
- import { ApplicationContext } from "@open-pioneer/runtime";
308
+ ```ts
309
+ import { ApplicationContext } from "@open-pioneer/runtime";
294
310
 
295
- const appCtx: ApplicationContext = ...; // injected
296
- appCtx.setLocale("en-US");
297
- ```
311
+ const appCtx: ApplicationContext = ...; // injected
312
+ appCtx.setLocale("en-US");
313
+ ```
298
314
 
299
- - @open-pioneer/runtime-react-support@1.0.2
315
+ - @open-pioneer/runtime-react-support@1.0.2
300
316
 
301
317
  ## 2.1.4
302
318
 
@@ -318,7 +334,7 @@
318
334
  ### Patch Changes
319
335
 
320
336
  - f749d96: Add a hint that `DECLARE_SERVICE_INTERFACE` should be imported via `import type`.
321
- - @open-pioneer/runtime-react-support@1.0.0
337
+ - @open-pioneer/runtime-react-support@1.0.0
322
338
 
323
339
  ## 2.1.0
324
340
 
@@ -326,46 +342,46 @@
326
342
 
327
343
  - 80cd62d: Improve TypeScript integration for service classes.
328
344
 
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:
345
+ Add a way for a service class to specify its interface name directly.
346
+ Usually services used across package boundaries split their public interface and their implementation such as this:
331
347
 
332
- ```ts
333
- // Exported from package
334
- interface MyService extends DeclaredService<"my-package.SomeInterface"> {
335
- method(): void;
336
- }
348
+ ```ts
349
+ // Exported from package
350
+ interface MyService extends DeclaredService<"my-package.SomeInterface"> {
351
+ method(): void;
352
+ }
337
353
 
338
- // In an implementation file, usually private.
339
- class MyServiceImpl implements MyService {
340
- method(): void {
341
- // ...
342
- }
354
+ // In an implementation file, usually private.
355
+ class MyServiceImpl implements MyService {
356
+ method(): void {
357
+ // ...
343
358
  }
344
- ```
359
+ }
360
+ ```
345
361
 
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:
362
+ Until now, there was no way for a service class to declare its interface directly.
363
+ This could be convenient within a package, or with a group of tightly coupled packages:
348
364
 
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
- ```
365
+ ```ts
366
+ // Error: Type 'MyServiceImpl' has no properties in common with type 'DeclaredService<"my-package.InterfaceName">'.
367
+ class MyServiceImpl implements DeclaredService<"my-package.InterfaceName"> {
368
+ method() {}
369
+ }
370
+ ```
355
371
 
356
- From now on, you can write this instead:
372
+ From now on, you can write this instead:
357
373
 
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
- }
374
+ ```ts
375
+ class MyServiceImpl {
376
+ // Tells TypeScript which interface name must be used.
377
+ // See documentation of `DECLARE_SERVICE_INTERFACE` for more details.
378
+ declare [DECLARE_SERVICE_INTERFACE]: "my-package.InterfaceName";
379
+
380
+ method(): void {
381
+ // ...
367
382
  }
368
- ```
383
+ }
384
+ ```
369
385
 
370
386
  ### Patch Changes
371
387
 
@@ -385,51 +401,51 @@
385
401
  - 6f954e3: **Breaking Change**: change how services integrate into TypeScript (fixes #22).
386
402
  The old TypeScript integration had unexpected edge cases, see the linked issue.
387
403
 
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:
404
+ NOTE: The changes below have no impact on runtime behavior, but they may trigger TypeScript errors in your code.
405
+ - To register a service's type with TypeScript, one previously used a block such as this:
390
406
 
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
- ```
407
+ ```ts
408
+ // OLD! Can be removed
409
+ import "@open-pioneer/runtime";
410
+ declare module "@open-pioneer/runtime" {
411
+ interface ServiceRegistry {
412
+ "http.HttpService": HttpService;
413
+ }
414
+ }
415
+ ```
400
416
 
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`).
417
+ The new method requires the developer to change the service's declaration.
418
+ 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`).
403
419
 
404
- ```diff
405
- + import { DeclaredService } from "@open-pioneer/runtime";
420
+ ```diff
421
+ + import { DeclaredService } from "@open-pioneer/runtime";
406
422
 
407
- - export interface HttpService {
408
- + export interface HttpService extends DeclaredService<"http.HttpService"> {
423
+ - export interface HttpService {
424
+ + export interface HttpService extends DeclaredService<"http.HttpService"> {
409
425
 
410
- - import "@open-pioneer/runtime";
411
- - declare module "@open-pioneer/runtime" {
412
- - interface ServiceRegistry {
413
- - "http.HttpService": HttpService;
414
- - }
415
- - }
416
- ```
426
+ - import "@open-pioneer/runtime";
427
+ - declare module "@open-pioneer/runtime" {
428
+ - interface ServiceRegistry {
429
+ - "http.HttpService": HttpService;
430
+ - }
431
+ - }
432
+ ```
417
433
 
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`:
434
+ - 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`:
419
435
 
420
- ```diff
421
- + import { HttpService } from "@open-pioneer/http";
422
- - const httpService = useService("http.HttpService");
423
- + const httpService = useService<HttpService>("http.HttpService");
424
- ```
436
+ ```diff
437
+ + import { HttpService } from "@open-pioneer/http";
438
+ - const httpService = useService("http.HttpService");
439
+ + const httpService = useService<HttpService>("http.HttpService");
440
+ ```
425
441
 
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.
442
+ 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.
427
443
 
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.
444
+ 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.
429
445
 
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.
446
+ - The types `InterfaceName` and `ServiceType<I>` have been removed. Use explicit service interfaces instead.
447
+ - The interfaces `ServiceRegistry` and `PropertiesRegistry` have been removed as global registration is no longer possible.
448
+ - The type `RawApplicationProperties` has been removed. Use `ApplicationProperties` instead.
433
449
 
434
450
  ### Patch Changes
435
451
 
@@ -44,7 +44,7 @@ export interface CustomElementOptions {
44
44
  resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;
45
45
  }
46
46
  /**
47
- * A context object that is passed to the `resolveProperties` function.
47
+ * A context object that is passed to the `resolveConfig` function.
48
48
  */
49
49
  export interface ConfigContext {
50
50
  /**
@@ -56,12 +56,12 @@ export interface ConfigContext {
56
56
  */
57
57
  overrides: ApplicationOverrides | undefined;
58
58
  /**
59
- * Returns an attribute from the application's root node.
59
+ * Returns an attribute of the application's host element.
60
60
  */
61
61
  getAttribute(name: string): string | undefined;
62
62
  }
63
63
  /**
64
- * Application overrides are defined when the is explicitly being restarted with new options.
64
+ * Application overrides are defined when the application is explicitly restarted with new options.
65
65
  *
66
66
  * Options set through overrides cannot be overwritten by the `resolveConfig` hook.
67
67
  */
@@ -196,11 +196,11 @@ export interface ApplicationElementConstructor {
196
196
  * Creates a new custom element class (web component) that can be registered within a DOM.
197
197
  *
198
198
  * @example
199
- * ```ts
199
+ * ```tsx
200
200
  * import * as appMetadata from "open-pioneer:app";
201
201
  *
202
202
  * const CustomElementClazz = createCustomElement({
203
- * component: <div>Hello World!</div>,
203
+ * component: () => <div>Hello World!</div>,
204
204
  * appMetadata
205
205
  * });
206
206
  * customElements.define("sample-element", CustomElementClazz);
package/CustomElement.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId$7 as sourceId } from './_virtual/source-info.js';
2
+ import { sourceId$8 as sourceId } from './_virtual/source-info.js';
3
3
  import { AppInstance } from './app/AppInstance.js';
4
4
  import { ErrorId } from './errors.js';
5
5
 
@@ -8,9 +8,7 @@ function createCustomElement(options) {
8
8
  class PioneerApplication extends HTMLElement {
9
9
  #shadowRoot;
10
10
  #instance;
11
- // oxlint-disable-next-line @typescript-eslint/no-explicit-any
12
11
  #deferredRestart;
13
- // A Timer
14
12
  static get observedAttributes() {
15
13
  return [];
16
14
  }
@@ -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":";;;;;AAeA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAoO1B,SAAS,oBAAoB,OAAA,EAA8D;AAAA,EAC9F,MAAM,2BAA2B,WAAA,CAA0C;AAAA,IACvE,WAAA;AAAA,IACA,SAAA;AAAA;AAAA,IAGA,gBAAA;AAAA;AAAA,IAEA,WAAW,kBAAA,GAA+B;AACtC,MAAA,OAAO,EAAC;AAAA,IACZ;AAAA,IAEA,WAAA,GAAc;AACV,MAAA,KAAA,EAAM;AAEN,MAAA,MAAM,gBAAA,GAAmB,OAAA,CAAQ,QAAA,EAAU,gBAAA,IAAoB,IAAA;AAC/D,MAAA,IAAI,gBAAA,EAAkB;AAClB,QAAA,IAAA,CAAK,WAAA,GAAc,KAAK,YAAA,CAAa;AAAA,UACjC,IAAA,EAAM;AAAA,SACT,CAAA;AAAA,MACL,CAAA,MAAO;AACH,QAAA,GAAA,CAAI,MAAM,iDAAiD,CAAA;AAAA,MAC/D;AAEA,MAAA,IAAI,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AAErB,QAAC,IAAA,CAAa,oBAAA,GAAuB,MAAM,IAAA,CAAK,SAAA;AAAA,MACpD;AAAA,IACJ;AAAA,IAEA,iBAAA,GAAoB;AAChB,MAAA,GAAA,CAAI,MAAM,uBAAuB,CAAA;AAEjC,MAAA,IAAI,KAAK,SAAA,EAAW;AAChB,QAAA,IAAA,CAAK,UAAU,OAAA,EAAQ;AAAA,MAC3B;AAEA,MAAA,IAAA,CAAK,SAAA,GAAY,KAAK,0BAAA,EAA2B;AACjD,MAAA,IAAA,CAAK,UAAU,KAAA,EAAM;AAAA,IACzB;AAAA,IAEA,oBAAA,GAAuB;AACnB,MAAA,GAAA,CAAI,MAAM,2BAA2B,CAAA;AAErC,MAAA,IAAI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CAAK,IAAI;AAAA,OACzC,CAAA;AAAA,IACL;AAAA;AAEJ,EAAA,OAAO,kBAAA;AACX;;"}
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 `resolveConfig` 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 of the application's host element.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Application overrides are defined when the application is explicitly 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 * ```tsx\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 #deferredRestart: ReturnType<typeof setTimeout> | undefined;\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 over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