@appsemble/preact 0.20.28 → 0.20.30
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 +4 -4
- package/package.json +2 -2
- package/.eslintrc.yaml +0 -4
- package/changed/added/.gitkeep +0 -0
- package/changed/changed/.gitkeep +0 -0
- package/changed/deprecated/.gitkeep +0 -0
- package/changed/fixed/.gitkeep +0 -0
- package/changed/removed/.gitkeep +0 -0
- package/changed/security/.gitkeep +0 -0
- package/index.js.map +0 -1
- package/index.tsx +0 -93
- package/jest.config.js +0 -3
- package/tsconfig.json +0 -8
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#  Appsemble Preact SDK
|
|
2
2
|
|
|
3
3
|
> Build your own blocks using Preact
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/preact)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.20.30)
|
|
7
|
+
[](https://codecov.io/gl/appsemble/appsemble)
|
|
8
8
|
[](https://prettier.io)
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
@@ -89,5 +89,5 @@ export function MyButton({ name }: MyButtonProps): VNode {
|
|
|
89
89
|
|
|
90
90
|
## License
|
|
91
91
|
|
|
92
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.20.
|
|
92
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.20.30/LICENSE.md) ©
|
|
93
93
|
[Appsemble](https://appsemble.com)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/preact",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.30",
|
|
4
4
|
"description": "Build your own blocks using Preact",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@appsemble/sdk": "0.20.
|
|
38
|
+
"@appsemble/sdk": "0.20.30",
|
|
39
39
|
"preact": "^10"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/.eslintrc.yaml
DELETED
package/changed/added/.gitkeep
DELETED
|
File without changes
|
package/changed/changed/.gitkeep
DELETED
|
File without changes
|
|
File without changes
|
package/changed/fixed/.gitkeep
DELETED
|
File without changes
|
package/changed/removed/.gitkeep
DELETED
|
File without changes
|
|
File without changes
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6B,SAAS,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAiC,aAAa,EAAE,MAAM,EAAS,MAAM,QAAQ,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C,MAAM,OAAO,GAAG,aAAa,CAAa,IAAI,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CACnB,SAAoC;IAEpC,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,MAAM,KAAK,GAAG;YACZ,GAAG,MAAM;YACT,KAAK;SACN,CAAC;QACF,MAAM,SAAS,GAAG,CAChB,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC5B,KAAC,SAAS,OAAK,KAAK,GAAI,GACP,CACpB,CAAC;QACF,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,SAAoC;IAC5D,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,SAAuD;IAEvD,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,CACnB,KAAC,OAAO,CAAC,QAAQ,cAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAC,SAAS,OAAK,KAAK,KAAM,MAAM,GAAI,GAAoB,CACxF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAqBD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAEsC;IAEtC,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,mFAAmF;IACnF,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAA4B,CAAC;AAChF,CAAC"}
|
package/index.tsx
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { BootstrapParams, Messages, bootstrap as sdkBootstrap } from '@appsemble/sdk';
|
|
2
|
-
import { ComponentChild, ComponentType, createContext, render, VNode } from 'preact';
|
|
3
|
-
import { useContext } from 'preact/hooks';
|
|
4
|
-
|
|
5
|
-
export interface BlockProps extends BootstrapParams {
|
|
6
|
-
/**
|
|
7
|
-
* A function that must be called to indicate the block is ready to be rendered.
|
|
8
|
-
*/
|
|
9
|
-
ready: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const Context = createContext<BlockProps>(null);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Mount a Preact component returned by a bootstrap function in the shadow DOM of a block.
|
|
16
|
-
*
|
|
17
|
-
* @param Component The Preact component to mount.
|
|
18
|
-
* @returns A promise which gets resolved if the component calls `ready()`.
|
|
19
|
-
*/
|
|
20
|
-
export function mount(
|
|
21
|
-
Component: ComponentType<BlockProps>,
|
|
22
|
-
): (params: BootstrapParams) => Promise<void> {
|
|
23
|
-
return (params) =>
|
|
24
|
-
new Promise((ready) => {
|
|
25
|
-
const props = {
|
|
26
|
-
...params,
|
|
27
|
-
ready,
|
|
28
|
-
};
|
|
29
|
-
const component = (
|
|
30
|
-
<Context.Provider value={props}>
|
|
31
|
-
<Component {...props} />
|
|
32
|
-
</Context.Provider>
|
|
33
|
-
);
|
|
34
|
-
render(component, params.shadowRoot);
|
|
35
|
-
params.utils.addCleanup(() => render(null, params.shadowRoot));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function bootstrap(Component: ComponentType<BlockProps>): void {
|
|
40
|
-
sdkBootstrap(mount(Component));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A HOC which passes the Appsemble block values to he wrapped Preact component.
|
|
45
|
-
*
|
|
46
|
-
* @param Component The Preact component to wrap.
|
|
47
|
-
* @returns The wrapper component.
|
|
48
|
-
* @deprecated Use `useBlock()` instead.
|
|
49
|
-
*/
|
|
50
|
-
export function withBlock<P extends {}>(
|
|
51
|
-
Component: ComponentType<Omit<BlockProps, keyof P> & P>,
|
|
52
|
-
): ComponentType<P> {
|
|
53
|
-
return (props: P) => (
|
|
54
|
-
<Context.Consumer>{(values) => <Component {...props} {...values} />}</Context.Consumer>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function useBlock(): BlockProps {
|
|
59
|
-
return useContext(Context);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface FormattedMessagePropsWithoutValues<M extends keyof Messages> {
|
|
63
|
-
/**
|
|
64
|
-
* The ID of the message to render.
|
|
65
|
-
*/
|
|
66
|
-
id: M;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface FormattedMessagePropsWithValues<M extends keyof Messages> {
|
|
70
|
-
/**
|
|
71
|
-
* The ID of the message to render.
|
|
72
|
-
*/
|
|
73
|
-
id: M;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Values to pass to the formatted message.
|
|
77
|
-
*/
|
|
78
|
-
values: Messages[M] extends never ? undefined : Messages[M];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Render an Appsemble message.
|
|
83
|
-
*/
|
|
84
|
-
export function FormattedMessage<M extends keyof Messages>(
|
|
85
|
-
props: Messages[M] extends never
|
|
86
|
-
? FormattedMessagePropsWithoutValues<M>
|
|
87
|
-
: FormattedMessagePropsWithValues<M>,
|
|
88
|
-
): VNode {
|
|
89
|
-
const { utils } = useBlock();
|
|
90
|
-
|
|
91
|
-
// @ts-expect-error The messages interface isn’t implemented within the Preact SDK.
|
|
92
|
-
return utils.formatMessage(props.id, props.values) as ComponentChild as VNode;
|
|
93
|
-
}
|
package/jest.config.js
DELETED