@appsemble/sdk 0.23.5 → 0.23.7
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/README.md +3 -3
- package/index.d.ts +31 -9
- package/index.js +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble SDK
|
|
2
2
|
|
|
3
3
|
> Build your own blocks
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/sdk)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.23.7)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -153,5 +153,5 @@ declare module '@appsemble/sdk' {
|
|
|
153
153
|
|
|
154
154
|
## License
|
|
155
155
|
|
|
156
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.23.
|
|
156
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.23.7/LICENSE.md) ©
|
|
157
157
|
[Appsemble](https://appsemble.com)
|
package/index.d.ts
CHANGED
|
@@ -144,6 +144,8 @@ export interface Utils {
|
|
|
144
144
|
* @returns The result of the remapped data.
|
|
145
145
|
*/
|
|
146
146
|
remap: (remapper: Remapper | undefined, data: unknown, context?: Record<string, unknown>) => unknown;
|
|
147
|
+
}
|
|
148
|
+
export interface BlockUtils extends Utils {
|
|
147
149
|
/**
|
|
148
150
|
* Show a bulma style message.
|
|
149
151
|
*/
|
|
@@ -204,20 +206,13 @@ export interface Events {
|
|
|
204
206
|
[K in keyof EventListeners]: <T>(callback: (data: T, error?: string) => void) => boolean;
|
|
205
207
|
};
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
* The parameters that get passed to the bootstrap function.
|
|
209
|
-
*/
|
|
210
|
-
export interface BootstrapParams {
|
|
209
|
+
export interface EventParams {
|
|
211
210
|
/**
|
|
212
211
|
* The actions that may be dispatched by the block.
|
|
213
212
|
*/
|
|
214
213
|
actions: {
|
|
215
214
|
[K in keyof Actions]: Action;
|
|
216
215
|
};
|
|
217
|
-
/**
|
|
218
|
-
* The parameters as they are defined in the app definition.
|
|
219
|
-
*/
|
|
220
|
-
parameters: Parameters;
|
|
221
216
|
/**
|
|
222
217
|
* Any kind of data that has been passed in by some context.
|
|
223
218
|
*/
|
|
@@ -226,6 +221,15 @@ export interface BootstrapParams {
|
|
|
226
221
|
* Event related functions and constants.
|
|
227
222
|
*/
|
|
228
223
|
events: Events;
|
|
224
|
+
/**
|
|
225
|
+
* Some utility functions provided by the Appsemble app framework.
|
|
226
|
+
*/
|
|
227
|
+
utils: Utils;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The parameters that get passed to the bootstrap function.
|
|
231
|
+
*/
|
|
232
|
+
export interface BootstrapParams extends EventParams {
|
|
229
233
|
/**
|
|
230
234
|
* URL parameters of the current route.
|
|
231
235
|
*
|
|
@@ -254,7 +258,11 @@ export interface BootstrapParams {
|
|
|
254
258
|
/**
|
|
255
259
|
* Some utility functions provided by the Appsemble app framework.
|
|
256
260
|
*/
|
|
257
|
-
utils:
|
|
261
|
+
utils: BlockUtils;
|
|
262
|
+
/**
|
|
263
|
+
* The parameters as they are defined in the app definition.
|
|
264
|
+
*/
|
|
265
|
+
parameters: Parameters;
|
|
258
266
|
}
|
|
259
267
|
export type BootstrapFunction = (params: BootstrapParams) => Promisable<Element | void>;
|
|
260
268
|
export interface AppsembleBootstrapEvent extends CustomEvent {
|
|
@@ -271,3 +279,17 @@ export interface AppsembleBootstrapEvent extends CustomEvent {
|
|
|
271
279
|
* If the function returns an element, it’s appended to the shadow root.
|
|
272
280
|
*/
|
|
273
281
|
export declare function bootstrap(fn: BootstrapFunction): void;
|
|
282
|
+
export type HandlerFunction = (...params: any[]) => Promisable<unknown>;
|
|
283
|
+
export type ControllerFunction = (params: EventParams) => Promisable<Record<keyof Actions, HandlerFunction>>;
|
|
284
|
+
export interface AppsembleControllerEvent extends CustomEvent {
|
|
285
|
+
detail: {
|
|
286
|
+
fn: ControllerFunction;
|
|
287
|
+
document: Document;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Register a controller function.
|
|
292
|
+
*
|
|
293
|
+
* @param fn The controller function to register
|
|
294
|
+
*/
|
|
295
|
+
export declare function controller(fn: ControllerFunction): void;
|
package/index.js
CHANGED
|
@@ -16,4 +16,20 @@ export function bootstrap(fn) {
|
|
|
16
16
|
document.currentScript.dispatchEvent(event);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a controller function.
|
|
21
|
+
*
|
|
22
|
+
* @param fn The controller function to register
|
|
23
|
+
*/
|
|
24
|
+
export function controller(fn) {
|
|
25
|
+
const event = new CustomEvent('AppsembleController', {
|
|
26
|
+
detail: {
|
|
27
|
+
fn,
|
|
28
|
+
document,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (document.currentScript) {
|
|
32
|
+
document.currentScript.dispatchEvent(event);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/sdk",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.7",
|
|
4
4
|
"description": "Build your own blocks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test": "vitest"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@appsemble/types": "0.23.
|
|
44
|
+
"@appsemble/types": "0.23.7",
|
|
45
45
|
"@fortawesome/fontawesome-common-types": "^6.0.0",
|
|
46
46
|
"type-fest": "^4.0.0"
|
|
47
47
|
},
|