empty-piral 0.15.0-beta.4816

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/app/index.d.ts ADDED
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Defines the API accessible from pilets.
3
+ */
4
+ export interface PiletApi extends EventEmitter {
5
+ /**
6
+ * Gets the metadata of the current pilet.
7
+ */
8
+ meta: PiletMetadata;
9
+ }
10
+
11
+ /**
12
+ * The emitter for Piral app shell events.
13
+ */
14
+ export interface EventEmitter {
15
+ /**
16
+ * Attaches a new event listener.
17
+ * @param type The type of the event to listen for.
18
+ * @param callback The callback to trigger.
19
+ */
20
+ on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
21
+ /**
22
+ * Detaches an existing event listener.
23
+ * @param type The type of the event to listen for.
24
+ * @param callback The callback to trigger.
25
+ */
26
+ off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
27
+ /**
28
+ * Emits a new event with the given type.
29
+ * @param type The type of the event to emit.
30
+ * @param arg The payload of the event.
31
+ */
32
+ emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
33
+ }
34
+
35
+ /**
36
+ * Describes the metadata of a pilet available in its API.
37
+ */
38
+ export interface PiletMetadata {
39
+ /**
40
+ * The name of the pilet, i.e., the package id.
41
+ */
42
+ name: string;
43
+ /**
44
+ * The version of the pilet. Should be semantically versioned.
45
+ */
46
+ version: string;
47
+ /**
48
+ * Provides the version of the specification for this pilet.
49
+ */
50
+ spec: string;
51
+ /**
52
+ * Provides some custom metadata for the pilet.
53
+ */
54
+ custom?: any;
55
+ /**
56
+ * Optionally indicates the global require reference, if any.
57
+ */
58
+ requireRef?: string;
59
+ /**
60
+ * Additional shared dependencies from the pilet.
61
+ */
62
+ dependencies: Record<string, string>;
63
+ /**
64
+ * Provides some configuration to be used in the pilet.
65
+ */
66
+ config: Record<string, any>;
67
+ /**
68
+ * The URL of the main script of the pilet.
69
+ */
70
+ link: string;
71
+ /**
72
+ * The base path to the pilet. Can be used to make resource requests
73
+ * and override the public path.
74
+ */
75
+ basePath: string;
76
+ }
77
+
78
+ /**
79
+ * Listener for Piral app shell events.
80
+ */
81
+ export interface Listener<T> {
82
+ /**
83
+ * Receives an event of type T.
84
+ */
85
+ (arg: T): void;
86
+ }
87
+
88
+ /**
89
+ * The map of known Piral app shell events.
90
+ */
91
+ export interface PiralEventMap {
92
+ "unload-pilet": PiralUnloadPiletEvent;
93
+ [custom: string]: any;
94
+ }
95
+
96
+ /**
97
+ * Gets fired when a pilet gets unloaded.
98
+ */
99
+ export interface PiralUnloadPiletEvent {
100
+ /**
101
+ * The name of the pilet to be unloaded.
102
+ */
103
+ name: string;
104
+ }