create-appsemble 0.21.3 → 0.22.0
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 -14
- package/index.js +2 -5
- package/package.json +5 -4
- package/commands/block.d.ts +0 -11
- package/commands/block.js +0 -60
- package/templates/mini-jsx/.appsemblerc.yaml +0 -1
- package/templates/mini-jsx/README.md +0 -11
- package/templates/mini-jsx/block.ts +0 -48
- package/templates/mini-jsx/i18n/en.json +0 -3
- package/templates/mini-jsx/package.json +0 -8
- package/templates/mini-jsx/src/index.module.css +0 -19
- package/templates/mini-jsx/src/index.tsx +0 -61
- package/templates/mini-jsx/tsconfig.json +0 -9
- package/templates/preact/.appsemblerc.yaml +0 -1
- package/templates/preact/README.md +0 -11
- package/templates/preact/block.ts +0 -37
- package/templates/preact/i18n/en.json +0 -5
- package/templates/preact/package.json +0 -9
- package/templates/preact/src/index.tsx +0 -99
- package/templates/preact/tsconfig.json +0 -9
- package/templates/vanilla/.appsemblerc.yaml +0 -1
- package/templates/vanilla/README.md +0 -10
- package/templates/vanilla/block.ts +0 -20
- package/templates/vanilla/i18n/en.json +0 -3
- package/templates/vanilla/package.json +0 -7
- package/templates/vanilla/src/index.ts +0 -25
- package/templates/vanilla/tsconfig.json +0 -7
- package/vitest.config.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
#  Appsemble Create
|
|
2
2
|
|
|
3
|
-
> Bootstrap an Appsemble
|
|
3
|
+
> Bootstrap an Appsemble project
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-appsemble)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.22.0)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
|
11
11
|
- [Usage](#usage)
|
|
12
|
-
- [Blocks](#blocks)
|
|
13
12
|
- [License](#license)
|
|
14
13
|
|
|
15
14
|
## Usage
|
|
@@ -25,16 +24,7 @@ npm init appsemble
|
|
|
25
24
|
yarn create appsemble
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
### Blocks
|
|
29
|
-
|
|
30
|
-
This package allows you to bootstrap an Appsemble block in a standard Appsemble project layout. The
|
|
31
|
-
initial command will be followed by a number questions interactively.
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
npm init appsemble block
|
|
35
|
-
```
|
|
36
|
-
|
|
37
27
|
## License
|
|
38
28
|
|
|
39
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.22.0/LICENSE.md) ©
|
|
40
30
|
[Appsemble](https://appsemble.com)
|
package/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { configureLogger, handleError } from '@appsemble/node-utils';
|
|
2
|
+
import { configureLogger, handleError, version } from '@appsemble/node-utils';
|
|
3
3
|
import yargs from 'yargs';
|
|
4
|
-
import * as block from './commands/block.js';
|
|
5
|
-
import pkg from './package.json' assert { type: 'json' };
|
|
6
4
|
yargs()
|
|
7
|
-
.version(
|
|
5
|
+
.version(version)
|
|
8
6
|
.option('verbose', {
|
|
9
7
|
alias: 'v',
|
|
10
8
|
describe: 'Increase verbosity',
|
|
@@ -16,7 +14,6 @@ yargs()
|
|
|
16
14
|
type: 'count',
|
|
17
15
|
})
|
|
18
16
|
.middleware([configureLogger])
|
|
19
|
-
.command(block)
|
|
20
17
|
.demandCommand(1)
|
|
21
18
|
.fail(handleError)
|
|
22
19
|
.help()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-appsemble",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Bootstrap an Appsemble project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -32,17 +32,18 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"**/*.d.ts",
|
|
34
34
|
"**/*.js",
|
|
35
|
-
"!*.config.js"
|
|
36
|
-
"templates"
|
|
35
|
+
"!*.config.js"
|
|
37
36
|
],
|
|
38
37
|
"scripts": {
|
|
39
38
|
"prepack": "tsc --noEmit false",
|
|
40
39
|
"test": "vitest"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@appsemble/node-utils": "0.
|
|
42
|
+
"@appsemble/node-utils": "0.22.0",
|
|
43
|
+
"@appsemble/types": "0.22.0",
|
|
44
44
|
"inquirer": "^9.0.0",
|
|
45
45
|
"type-fest": "^4.0.0",
|
|
46
|
+
"yaml": "^2.0.0",
|
|
46
47
|
"yargs": "^17.0.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
package/commands/block.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Argv } from 'yargs';
|
|
2
|
-
export declare const command = "block";
|
|
3
|
-
export declare const description = "Bootstrap a new Appsemble block.";
|
|
4
|
-
interface BlockArgs {
|
|
5
|
-
organization?: string;
|
|
6
|
-
name?: string;
|
|
7
|
-
template?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function builder(yargs: Argv): Promise<Argv<any>>;
|
|
10
|
-
export declare function handler(args: BlockArgs): Promise<void>;
|
|
11
|
-
export {};
|
package/commands/block.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { cp, readdir } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { logger, readData, writeData } from '@appsemble/node-utils';
|
|
4
|
-
import inquirer from 'inquirer';
|
|
5
|
-
import pkg from '../package.json' assert { type: 'json' };
|
|
6
|
-
const templateDir = new URL('../templates/', import.meta.url);
|
|
7
|
-
export const command = 'block';
|
|
8
|
-
export const description = 'Bootstrap a new Appsemble block.';
|
|
9
|
-
export async function builder(yargs) {
|
|
10
|
-
const choices = await readdir(templateDir);
|
|
11
|
-
return yargs
|
|
12
|
-
.option('organization', {
|
|
13
|
-
describe: 'The ID the block should be created for.',
|
|
14
|
-
})
|
|
15
|
-
.option('name', {
|
|
16
|
-
describe: 'The name of the block',
|
|
17
|
-
})
|
|
18
|
-
.option('template', {
|
|
19
|
-
describe: 'The template to use.',
|
|
20
|
-
choices,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export async function handler(args) {
|
|
24
|
-
const choices = await readdir(templateDir);
|
|
25
|
-
const answers = await inquirer.prompt([
|
|
26
|
-
!args.organization && {
|
|
27
|
-
name: 'organization',
|
|
28
|
-
message: 'For which organization is the block?',
|
|
29
|
-
},
|
|
30
|
-
!args.name && { name: 'name', message: 'What should be the name of the block?' },
|
|
31
|
-
!args.template && {
|
|
32
|
-
name: 'template',
|
|
33
|
-
type: 'list',
|
|
34
|
-
choices,
|
|
35
|
-
message: 'What kind of block project should be bootstrapped?',
|
|
36
|
-
},
|
|
37
|
-
].filter(Boolean));
|
|
38
|
-
const organization = answers.organization || args.organization;
|
|
39
|
-
const name = answers.name || args.name;
|
|
40
|
-
const template = answers.template || args.template;
|
|
41
|
-
const { version } = pkg;
|
|
42
|
-
const outputPath = join(process.cwd(), 'blocks', name);
|
|
43
|
-
const inputPath = new URL(`${template}/`, templateDir);
|
|
44
|
-
const pkgPath = new URL('package.json', inputPath);
|
|
45
|
-
const [inputPkg] = await readData(pkgPath);
|
|
46
|
-
const outputPkg = {
|
|
47
|
-
name: `@${organization}/${name}`,
|
|
48
|
-
version,
|
|
49
|
-
...inputPkg,
|
|
50
|
-
};
|
|
51
|
-
await cp(inputPath, outputPath, {
|
|
52
|
-
errorOnExist: true,
|
|
53
|
-
filter: (src) => !src.endsWith('package.json'),
|
|
54
|
-
force: false,
|
|
55
|
-
recursive: true,
|
|
56
|
-
});
|
|
57
|
-
await writeData(join(outputPath, 'package.json'), outputPkg);
|
|
58
|
-
logger.info(`Successfully created @${organization}/${name}/${version} at ${outputPath}`);
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=block.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
output: dist
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
This block was bootstrapped using the following command:
|
|
2
|
-
|
|
3
|
-
```sh
|
|
4
|
-
npm init appsemble block
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
This block renders a single data entity that is emitted through an Appsemble block event. It uses
|
|
8
|
-
[`mini-jsx`](https://gitlab.com/appsemble/mini-jsx) to define raw DOM nodes using JSX syntax.
|
|
9
|
-
|
|
10
|
-
This readme will be rendered on <https://appsemble.app> when the block is published. Replace the
|
|
11
|
-
contents of this document with a useful block description.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// Blocks can actions, parameters, messages, and event listeners and emitters. These can be defined
|
|
2
|
-
// by augmenting the @appsemble/sdk module. Typically this happens in a file named block.ts. When a
|
|
3
|
-
// block is published, the CLI will process the augmented interfaces and validate the app definition
|
|
4
|
-
// complies with them. The JSDoc will be used to render documentation.
|
|
5
|
-
import { type IconName, type Remapper } from '@appsemble/sdk';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A field to display.
|
|
9
|
-
*/
|
|
10
|
-
export interface Field {
|
|
11
|
-
/**
|
|
12
|
-
* The value of the property to render.
|
|
13
|
-
*/
|
|
14
|
-
value: Remapper;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The fontawesome icon to render.
|
|
18
|
-
*/
|
|
19
|
-
icon: IconName;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The label to render.
|
|
23
|
-
*/
|
|
24
|
-
label?: Remapper;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '@appsemble/sdk' {
|
|
28
|
-
interface EventListeners {
|
|
29
|
-
/**
|
|
30
|
-
* The event to listen on for data to display.
|
|
31
|
-
*/
|
|
32
|
-
data: never;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface Messages {
|
|
36
|
-
/**
|
|
37
|
-
* This message is displayed when there was an error loading data.
|
|
38
|
-
*/
|
|
39
|
-
error: never;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface Parameters {
|
|
43
|
-
/**
|
|
44
|
-
* The fields to display.
|
|
45
|
-
*/
|
|
46
|
-
fields: Field[];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// `src/index.tsx` is the initial entry point of the block source code run. For small blocks this
|
|
2
|
-
// often contains the entire logic of the block. Bigger blocks are often split into smaller modules.
|
|
3
|
-
import { bootstrap } from '@appsemble/sdk';
|
|
4
|
-
|
|
5
|
-
import styles from './index.module.css';
|
|
6
|
-
|
|
7
|
-
// The bootstrap function injects various properties that can be destructured. You can use your
|
|
8
|
-
// editor’s autocomplete to see which variables are available.
|
|
9
|
-
bootstrap(({ events, parameters: { fields }, utils: { fa, formatMessage, remap } }) => {
|
|
10
|
-
/**
|
|
11
|
-
* The wrapper element is used to assign data to when it has loaded asynchronously.
|
|
12
|
-
*/
|
|
13
|
-
const wrapper = (
|
|
14
|
-
// In this template the JSX is handled by mini-jsx (https://gitlab.com/appsemble/mini-jsx).
|
|
15
|
-
// This is a small library that turns JSX into plain DOM nodes. Unlike React or Preact, no
|
|
16
|
-
// virtual DOM or state management is involved.
|
|
17
|
-
<div className={styles.wrapper}>
|
|
18
|
-
<div className={styles.loader} />
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// The preferred way to listen for handling data is using event listeners. At first it may seem
|
|
23
|
-
// simpler to use actions, but event handlers give users the ability to do additional processing
|
|
24
|
-
// in another block, or to render the same data in different blocks. Typically user data is loaded
|
|
25
|
-
// using the data-loader block.
|
|
26
|
-
events.on.data((data, error) => {
|
|
27
|
-
while (wrapper.lastChild) {
|
|
28
|
-
wrapper.lastChild.remove();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (error) {
|
|
32
|
-
// It’s always important to handle errors. Events may emit errors for various reasons that are
|
|
33
|
-
// out of control for this block.
|
|
34
|
-
wrapper.append(formatMessage('error'));
|
|
35
|
-
} else {
|
|
36
|
-
wrapper.append(
|
|
37
|
-
...fields.map(({ icon, label, value }) => {
|
|
38
|
-
// The remap utility is a powerful tool to transform user data. A full reference is found
|
|
39
|
-
// on https://appsemble.app/docs/reference/remapper. However, for the block all that
|
|
40
|
-
// matters is we can pass in a user defined remapper and a value, and get the value the
|
|
41
|
-
// user wants to use.
|
|
42
|
-
const remappedLabel = remap(label, data) as string;
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div className={styles.field}>
|
|
46
|
-
<i className={`${fa(icon)} ${styles.icon}`} />
|
|
47
|
-
{/* Bulma classes are supported. See https://bulma.io/documentation */}
|
|
48
|
-
<div className={`has-text-weight-bold ${styles.value}`}>
|
|
49
|
-
{remap(value, data) as string}
|
|
50
|
-
</div>
|
|
51
|
-
{remappedLabel ? <div>{remappedLabel}</div> : null}
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// If a DOM node is returned by the bootstrap function, it will be rendered in the shadow root.
|
|
60
|
-
return <div>{wrapper}</div>;
|
|
61
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
output: dist
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
This block was bootstrapped using the following command:
|
|
2
|
-
|
|
3
|
-
```sh
|
|
4
|
-
npm init appsemble block
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
This block renders a list of data entities that is emitted through an Appsemble block event. It uses
|
|
8
|
-
[`preact`](https://preactjs.com) to define a block.
|
|
9
|
-
|
|
10
|
-
This readme will be rendered on <https://appsemble.app> when the block is published. Replace the
|
|
11
|
-
contents of this document with a useful block description.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Blocks can actions, parameters, messages, and event listeners and emitters. These can be defined
|
|
2
|
-
// by augmenting the @appsemble/sdk module. Typically this happens in a file named block.ts. When a
|
|
3
|
-
// block is published, the CLI will process the augmented interfaces and validate the app definition
|
|
4
|
-
// complies with them. The JSDoc will be used to render documentation.
|
|
5
|
-
|
|
6
|
-
declare module '@appsemble/sdk' {
|
|
7
|
-
interface EventListeners {
|
|
8
|
-
/**
|
|
9
|
-
* This event can be used to receive incoming data to display.
|
|
10
|
-
*/
|
|
11
|
-
data: never;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface Messages {
|
|
15
|
-
/**
|
|
16
|
-
* This message is displayed if the data is empty.
|
|
17
|
-
*/
|
|
18
|
-
empty: never;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This message is displayed if there was a problem loading the data.
|
|
22
|
-
*/
|
|
23
|
-
error: never;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* This message is displayed if no data has been loaded yet.
|
|
27
|
-
*/
|
|
28
|
-
loading: never;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface Parameters {
|
|
32
|
-
/**
|
|
33
|
-
* A list of fields to render out in a table.
|
|
34
|
-
*/
|
|
35
|
-
fields: string[];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// `src/index.tsx` is the initial entry point of the block source code run. For small blocks this
|
|
2
|
-
// often contains the entire logic of the block. Bigger blocks are often split into smaller modules.
|
|
3
|
-
|
|
4
|
-
// Normally bootstrap is imported from @appsemble/sdk. When using preact, it must be imported from
|
|
5
|
-
// @appsemble/preact instead.
|
|
6
|
-
import { bootstrap, FormattedMessage } from '@appsemble/preact';
|
|
7
|
-
import { useEffect, useState } from 'preact/hooks';
|
|
8
|
-
|
|
9
|
-
// The bootstrap function injects various properties that can be destructured. You can use your
|
|
10
|
-
// editor’s autocomplete to see which variables are available. These properties can also be accessed
|
|
11
|
-
// from anywhere in a preact component using the useBlock() hook.
|
|
12
|
-
bootstrap(({ events, parameters: { fields }, ready }) => {
|
|
13
|
-
// The @appsemble/preact bootstrap function renders a component. This means preact hooks such as
|
|
14
|
-
// useState and useEffect can be used.
|
|
15
|
-
const [data, setData] = useState<any[]>();
|
|
16
|
-
const [error, setError] = useState(false);
|
|
17
|
-
|
|
18
|
-
// The block needs to call ready() once when it’s ready. Appsemble waits for all blocks to be
|
|
19
|
-
// ready before it dispatches any actions or events.
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
ready();
|
|
22
|
-
}, [ready]);
|
|
23
|
-
|
|
24
|
-
// The preferred way to listen for handling data is using event listeners. At first it may seem
|
|
25
|
-
// simpler to use actions, but event handlers give users the ability to do additional processing
|
|
26
|
-
// in another block, or to render the same data in different blocks. Typically user data is loaded
|
|
27
|
-
// using the data-loader block.
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const onData = (newData: unknown[], newError: unknown): void => {
|
|
30
|
-
if (newError) {
|
|
31
|
-
setError(true);
|
|
32
|
-
// @ts-expect-error this is valid.
|
|
33
|
-
setData();
|
|
34
|
-
} else {
|
|
35
|
-
setData(newData);
|
|
36
|
-
setError(false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
events.on.data(onData);
|
|
41
|
-
|
|
42
|
-
return () => {
|
|
43
|
-
events.off.data(onData);
|
|
44
|
-
};
|
|
45
|
-
}, [events]);
|
|
46
|
-
|
|
47
|
-
// It’s always important to handle errors. Events may emit errors for various reasons that are
|
|
48
|
-
// out of control for this block.
|
|
49
|
-
if (error) {
|
|
50
|
-
return (
|
|
51
|
-
<p>
|
|
52
|
-
<FormattedMessage id="error" />
|
|
53
|
-
</p>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// It’s always important to handle the loading state.
|
|
58
|
-
if (!data) {
|
|
59
|
-
return (
|
|
60
|
-
<p>
|
|
61
|
-
<FormattedMessage id="loading" />
|
|
62
|
-
</p>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// It’s always important to handle an empty state
|
|
67
|
-
if (!data.length) {
|
|
68
|
-
return (
|
|
69
|
-
<p>
|
|
70
|
-
<FormattedMessage id="empty" />
|
|
71
|
-
</p>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
// Bulma classes are supported in Appsemble blocks. See https://bulma.io/documentation
|
|
77
|
-
<table className="table">
|
|
78
|
-
<thead>
|
|
79
|
-
<tr>
|
|
80
|
-
{fields.map((field) => (
|
|
81
|
-
<th key={field}>{field}</th>
|
|
82
|
-
))}
|
|
83
|
-
</tr>
|
|
84
|
-
</thead>
|
|
85
|
-
<tbody>
|
|
86
|
-
{data.map((item, dataIndex) => (
|
|
87
|
-
// Because any data may be emitted, it’s often hard to determine the correct key to use.
|
|
88
|
-
// Often an id property is known, at least this handles the use case of Appsemble
|
|
89
|
-
// resources.
|
|
90
|
-
<tr key={item.id || dataIndex}>
|
|
91
|
-
{fields.map((field) => (
|
|
92
|
-
<td key={field}>{item[field]}</td>
|
|
93
|
-
))}
|
|
94
|
-
</tr>
|
|
95
|
-
))}
|
|
96
|
-
</tbody>
|
|
97
|
-
</table>
|
|
98
|
-
);
|
|
99
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
output: dist
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
This block was bootstrapped using the following command:
|
|
2
|
-
|
|
3
|
-
```sh
|
|
4
|
-
npm init appsemble block
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
This block displays a button that dispatches an action when clicked.
|
|
8
|
-
|
|
9
|
-
This readme will be rendered on <https://appsemble.app> when the block is published. Replace the
|
|
10
|
-
contents of this document with a useful block description.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Blocks can actions, parameters, messages, and event listeners and emitters. These can be defined
|
|
2
|
-
// by augmenting the @appsemble/sdk module. Typically this happens in a file named block.ts. When a
|
|
3
|
-
// block is published, the CLI will process the augmented interfaces and validate the app definition
|
|
4
|
-
// complies with them. The JSDoc will be used to render documentation.
|
|
5
|
-
|
|
6
|
-
declare module '@appsemble/sdk' {
|
|
7
|
-
interface Actions {
|
|
8
|
-
/**
|
|
9
|
-
* What happens if the button is clicked.
|
|
10
|
-
*/
|
|
11
|
-
onClick: never;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface Messages {
|
|
15
|
-
/**
|
|
16
|
-
* The button label.
|
|
17
|
-
*/
|
|
18
|
-
label: never;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// `src/index.ts` is the initial entry point of the block source code run. For small blocks this
|
|
2
|
-
// often contains the entire logic of the block. Bigger blocks are often split into smaller modules.
|
|
3
|
-
import { bootstrap } from '@appsemble/sdk';
|
|
4
|
-
|
|
5
|
-
// The bootstrap function injects various properties that can be destructured. You can use your
|
|
6
|
-
// editor’s autocomplete to see which variables are available.
|
|
7
|
-
bootstrap(({ actions, utils }) => {
|
|
8
|
-
const button = document.createElement('button');
|
|
9
|
-
button.type = 'button';
|
|
10
|
-
|
|
11
|
-
// Using utils.formatMessage we can provide internationalized messages.
|
|
12
|
-
button.textContent = utils.formatMessage('label');
|
|
13
|
-
|
|
14
|
-
// Bulma classes are supported. See https://bulma.io/documentation
|
|
15
|
-
button.classList.add('button');
|
|
16
|
-
|
|
17
|
-
button.addEventListener('click', (event) => {
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
// This dispatches a user defined action.
|
|
20
|
-
actions.onClick();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// If a DOM node is returned by the bootstrap function, it will be rendered in the shadow root.
|
|
24
|
-
return button;
|
|
25
|
-
});
|
package/vitest.config.d.ts
DELETED