Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@appsemble/preact

Package Overview
Dependencies
Maintainers
4
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appsemble/preact - npm Package Compare versions

Comparing version 0.13.12 to 0.13.13

22

dist/index.d.ts
import { BootstrapParams } from '@appsemble/sdk';
import { IntlMessageFormat } from 'intl-messageformat';
import { ComponentType, VNode } from 'preact';
import { ComponentType } from 'preact';
export interface BlockProps extends BootstrapParams {

@@ -9,5 +8,2 @@ /**

ready: () => void;
messages: {
[id: string]: IntlMessageFormat;
};
}

@@ -18,12 +14,7 @@ /**

* @param Component - The Preact component to mount.
* @param messages - Translatable messages to serve (deprecated).
*
* @returns A promise which gets resolved if the component calls `ready()`.
*/
export declare function mount(Component: ComponentType<BlockProps>, messages?: {
[id: string]: string;
}): (params: BootstrapParams) => Promise<void>;
export declare function bootstrap(Component: ComponentType<BlockProps>, messages?: {
[id: string]: string;
}): void;
export declare function mount(Component: ComponentType<BlockProps>): (params: BootstrapParams) => Promise<void>;
export declare function bootstrap(Component: ComponentType<BlockProps>): void;
/**

@@ -40,8 +31,1 @@ * A HOC which passes the Appsemble block values to he wrapped Preact component.

export declare function useBlock(): BlockProps;
export interface FormattedMessageProps {
id: string;
values?: {
[key: string]: number | string | ((str: string) => VNode);
};
}
export declare function FormattedMessage({ id, values }: FormattedMessageProps): VNode;
import { bootstrap as sdkBootstrap } from '@appsemble/sdk';
import { IntlMessageFormat } from 'intl-messageformat';
import { createContext, Fragment, h, render } from 'preact';
import { createContext, h, render } from 'preact';
import { useContext } from 'preact/hooks';

@@ -10,7 +9,6 @@ const Context = createContext(null);

* @param Component - The Preact component to mount.
* @param messages - Translatable messages to serve (deprecated).
*
* @returns A promise which gets resolved if the component calls `ready()`.
*/
export function mount(Component, messages) {
export function mount(Component) {
return (params) => new Promise((ready) => {

@@ -20,8 +18,2 @@ const props = {

ready,
messages: messages
? Object.entries(messages).reduce((acc, [key, message]) => {
acc[key] = new IntlMessageFormat(message);
return acc;
}, {})
: {},
};

@@ -34,4 +26,4 @@ const component = (h(Context.Provider, { value: props },

}
export function bootstrap(Component, messages) {
sdkBootstrap(mount(Component, messages));
export function bootstrap(Component) {
sdkBootstrap(mount(Component));
}

@@ -53,13 +45,2 @@ /**

}
export function FormattedMessage({ id, values }) {
const { messages } = useBlock();
if (!Object.hasOwnProperty.call(messages, id)) {
return h(Fragment, null,
"Untranslated message ID: ",
id);
}
const formattedMessage = messages[id].format(values);
// eslint-disable-next-line react/jsx-no-useless-fragment
return h(Fragment, null, formattedMessage);
}
//# sourceMappingURL=index.js.map

7

package.json
{
"name": "@appsemble/preact",
"version": "0.13.12",
"version": "0.13.13",
"description": "Build your own blocks using Preact",

@@ -36,9 +36,6 @@ "keywords": [

},
"dependencies": {
"intl-messageformat": "^9.3.6"
},
"peerDependencies": {
"@appsemble/sdk": "0.13.12",
"@appsemble/sdk": "0.13.13",
"preact": "^10.0.4"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc