Major Changes
-
ce9e060: Remove support for closed shadow roots.
Shadow roots used by trails applications are now always"open"
.
See #19. -
6f954e3: Breaking Change: change how services integrate into TypeScript (fixes #22).
The old TypeScript integration had unexpected edge cases, see the linked issue.NOTE: The changes below have no impact on runtime behavior, but they may trigger TypeScript errors in your code.
-
To register a service's type with TypeScript, one previously used a block such as this:
// OLD! Can be removed import "@open-pioneer/runtime"; declare module "@open-pioneer/runtime" { interface ServiceRegistry { "http.HttpService": HttpService; } }
The new method requires the developer to change the service's declaration.
Simply addextends DeclaredService<"SERVICE_ID">
to your service interface, whereSERVICE_ID
should match the service's interface name ("provides"
inbuild.config.mjs
).+ import { DeclaredService } from "@open-pioneer/runtime"; - export interface HttpService { + export interface HttpService extends DeclaredService<"http.HttpService"> { - import "@open-pioneer/runtime"; - declare module "@open-pioneer/runtime" { - interface ServiceRegistry { - "http.HttpService": HttpService; - } - }
-
To use a service from React code (i.e.
useService
anduseServices
), you must now use the explicit service type in the hook's generic parameter list. Otherwise the hook will simply returnunknown
:+ import { HttpService } from "@open-pioneer/http"; - const httpService = useService("http.HttpService"); + const httpService = useService<HttpService>("http.HttpService");
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.
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. -
The types
InterfaceName
andServiceType<I>
have been removed. Use explicit service interfaces instead. -
The interfaces
ServiceRegistry
andPropertiesRegistry
have been removed as global registration is no longer possible. -
The type
RawApplicationProperties
has been removed. UseApplicationProperties
instead.
-
Patch Changes
- f5c0e31: Bump @formatjs/intl version
- Updated dependencies [f5c0e31]
- Updated dependencies [6f954e3]
- @open-pioneer/[email protected]
- @open-pioneer/[email protected]
- @open-pioneer/[email protected]