mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-04-06 15:30:30 +08:00
Merge branch 'develop' into fix-selectors
This commit is contained in:
commit
55d620cf55
@ -57,9 +57,16 @@ async function getExpress({ context, gqlServer }) {
|
||||
// serve webpack files
|
||||
app.use(express.static(path.resolve(__dirname, 'shell')));
|
||||
|
||||
// serve version for renderer module federation
|
||||
app.use('/api/dev/version', (req, res) => {
|
||||
res.json(context.lowdefyVersion);
|
||||
// Serve rendererRemoteEntryUrl for renderer module federation
|
||||
app.use('/api/dev/rendererRemoteEntryUrl', (req, res) => {
|
||||
let rendererRemoteEntryUrl;
|
||||
|
||||
if (context.options.blocksServerUrl) {
|
||||
rendererRemoteEntryUrl = `${context.options.blocksServerUrl}/renderer/remoteEntry.js`;
|
||||
} else {
|
||||
rendererRemoteEntryUrl = `https://blocks-cdn.lowdefy.com/v${context.lowdefyVersion}/renderer/remoteEntry.js`;
|
||||
}
|
||||
res.json(rendererRemoteEntryUrl);
|
||||
});
|
||||
|
||||
// Redirect all 404 to index.html with status 200
|
||||
|
15
packages/cli/src/commands/dev/shell/bootstrap.js
vendored
15
packages/cli/src/commands/dev/shell/bootstrap.js
vendored
@ -18,9 +18,9 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Loading, loadWebpackFederatedModule, useDynamicScript } from '@lowdefy/block-tools';
|
||||
|
||||
function Shell({ version }) {
|
||||
function Shell({ rendererRemoteEntryUrl }) {
|
||||
const { ready, failed } = useDynamicScript({
|
||||
src: `https://blocks-cdn.lowdefy.com/v${version}/renderer/remoteEntry.js`,
|
||||
src: rendererRemoteEntryUrl,
|
||||
});
|
||||
|
||||
if (!ready) {
|
||||
@ -40,10 +40,13 @@ function Shell({ version }) {
|
||||
);
|
||||
}
|
||||
|
||||
const getVersion = async () => {
|
||||
return (await fetch(`/api/dev/version`)).json();
|
||||
const getRendererRemoteEntryUrl = async () => {
|
||||
return (await fetch(`/api/dev/rendererRemoteEntryUrl`)).json();
|
||||
};
|
||||
|
||||
getVersion().then((version) => {
|
||||
ReactDOM.render(<Shell version={version} />, document.getElementById('root'));
|
||||
getRendererRemoteEntryUrl().then((rendererRemoteEntryUrl) => {
|
||||
ReactDOM.render(
|
||||
<Shell rendererRemoteEntryUrl={rendererRemoteEntryUrl} />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
});
|
||||
|
@ -162,6 +162,8 @@ _ref:
|
||||
- `@lowdefy/blocks-markdown` to be hosted at `{BLOCK_SERVER_URL}/blocks-markdown/`.
|
||||
- `@lowdefy/blocks-echarts` to be hosted at `{BLOCK_SERVER_URL}/blocks-echarts/`.
|
||||
|
||||
If you wish to run the CLI dev server, the `@lowdefy/renderer` package build artifacts (located in the `dist` directory) should also be served from `{BLOCK_SERVER_URL}/renderer/`.
|
||||
|
||||
- _ref:
|
||||
path: templates/navigation_buttons.yaml
|
||||
vars:
|
||||
|
@ -24,7 +24,7 @@ _ref:
|
||||
type: MarkdownWithCode
|
||||
properties:
|
||||
content: |
|
||||
The `AxiosHTTP` connection is used to connect to APIs and web servers using HTTP or HTTPS.
|
||||
The `AxiosHttp` connection is used to connect to APIs and web servers using HTTP or HTTPS.
|
||||
|
||||
It uses the [axios](https://github.com/axios/axios) library.
|
||||
|
||||
@ -35,14 +35,14 @@ _ref:
|
||||
## Connections
|
||||
|
||||
Connection types:
|
||||
- AxiosHTTP
|
||||
- AxiosHttp
|
||||
|
||||
## Requests
|
||||
|
||||
Request types:
|
||||
- AxiosHTTP
|
||||
- AxiosHttp
|
||||
|
||||
### AxiosHTTP
|
||||
### AxiosHttp
|
||||
|
||||
#### Properties
|
||||
|
||||
|
@ -198,6 +198,54 @@ _ref:
|
||||
```
|
||||
description: |
|
||||
The `_array.reduce` method [executes a reducer function on each element of the array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce), resulting in single output value.
|
||||
examples: |
|
||||
The simplest example would probably be adding all the elements in an array:
|
||||
```yaml
|
||||
sum:
|
||||
_array.reduce:
|
||||
on: [1, 2, 3, 4]
|
||||
callback:
|
||||
_function:
|
||||
__sum:
|
||||
- __args: 0
|
||||
- __args: 1
|
||||
```
|
||||
This will return `sum: 10`
|
||||
|
||||
You can start off by counting from 10 by specifying an `initialValue` for the reducer:
|
||||
```yaml
|
||||
sum:
|
||||
_array.reduce:
|
||||
on: [1, 2, 3, 4]
|
||||
callback:
|
||||
_function:
|
||||
__sum:
|
||||
- __args: 0
|
||||
- __args: 1
|
||||
initialValue: 10
|
||||
```
|
||||
This will return `sum: 20`
|
||||
|
||||
You can use the index of the array element to add some logic to your `callback`. For instance, when you reach index 2 of your array (the 3rd entry), add 100 instead of the current element value:
|
||||
```yaml
|
||||
sum:
|
||||
_array.reduce:
|
||||
on: [1, 2, 3, 4]
|
||||
callback:
|
||||
_function:
|
||||
__sum:
|
||||
- __args: 0
|
||||
- __if:
|
||||
test:
|
||||
__eq:
|
||||
- __args: 2
|
||||
- 2
|
||||
then: 100
|
||||
else:
|
||||
__args: 1
|
||||
```
|
||||
This will return `sum: 107`
|
||||
|
||||
- name: reduceRight
|
||||
types: |
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user