@open-pioneer/integration 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @open-pioneer/integration
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a40f12d: Update build-package tool. TypeScript declaration files should now be available.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ import { ApplicationContext, Service, ServiceOptions } from "@open-pioneer/runtime";
2
+ import { ExternalEventService } from "./api";
3
+ interface References {
4
+ ctx: ApplicationContext;
5
+ }
6
+ export declare class ExternalEventServiceImpl implements Service<ExternalEventService> {
7
+ #private;
8
+ constructor({ references }: ServiceOptions<References>);
9
+ emitEvent(name: string, detail?: unknown): void;
10
+ emitEvent(event: Event): void;
11
+ }
12
+ export {};
package/api.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ import { type ApiExtension, type ApiMethods, type ApiMethod } from "@open-pioneer/runtime";
2
+ /**
3
+ * Emits events to users of the current web component.
4
+ *
5
+ * Use the interface `"integration.ExternalEventService"` to obtain an instance of this service.
6
+ */
7
+ export interface ExternalEventService {
8
+ /**
9
+ * Emits an event to the host site as a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent).
10
+ *
11
+ * The `detail` value (if any) will be used as the custom event's `detail`.
12
+ *
13
+ * @example
14
+ *
15
+ * ```js
16
+ * // In the application, e.g. in a service
17
+ * eventService.emitEvent("my-event", { message: "Hello World" });
18
+ *
19
+ * // In the host site (node is the application's web component node)
20
+ * node.addEventLister("my-event", (event) => {
21
+ * console.log(event.detail);
22
+ * })
23
+ * ```
24
+ */
25
+ emitEvent(name: string, detail?: unknown): void;
26
+ /**
27
+ * Emits a prepared [DOM event](https://developer.mozilla.org/en-US/docs/Web/API/Event) to the host site.
28
+ *
29
+ * The event will be dispatched on the web component's dom node without being altered by this service.
30
+ *
31
+ * You must take care to set the appropriate event options for your use case if you're using this overload (e.g. `bubbles`).
32
+ *
33
+ * @example
34
+ *
35
+ * ```js
36
+ * // You can use the CustomEvent class or your own subclass of Event
37
+ * eventService.emitEvent(new CustomEvent("my-event", {
38
+ * detail: "detail-value"
39
+ * }));
40
+ * ```
41
+ */
42
+ emitEvent(event: Event): void;
43
+ }
44
+ export { ApiExtension, ApiMethod, ApiMethods };
45
+ declare module "@open-pioneer/runtime" {
46
+ interface ServiceRegistry {
47
+ "integration.ApiExtension": ApiExtension;
48
+ "integration.ExternalEventService": ExternalEventService;
49
+ }
50
+ }
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./api";
2
+ export default undefined;
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/integration",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
8
8
  ".": {
9
- "import": "./index.js"
9
+ "import": "./index.js",
10
+ "types": "./index.d.ts"
10
11
  },
11
12
  "./services": {
12
- "import": "./services.js"
13
+ "import": "./services.js",
14
+ "types": "./services.d.ts"
13
15
  }
14
16
  },
15
17
  "openPioneerFramework": {
package/services.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { ExternalEventServiceImpl } from "./ExternalEventServiceImpl";