mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-01-06 13:15:24 +08:00
Merge branch 'main' into develop
This commit is contained in:
commit
54e947f92f
1
.pnp.js
generated
1
.pnp.js
generated
@ -3892,6 +3892,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||||||
["@apollo/link-retry", "npm:2.0.0-beta.3"],
|
["@apollo/link-retry", "npm:2.0.0-beta.3"],
|
||||||
["@babel/core", "npm:7.11.6"],
|
["@babel/core", "npm:7.11.6"],
|
||||||
["@babel/preset-react", "virtual:22157ea722f8d6428f1fcf0a6f7f6c7d6b902d9c785256c60a65fe6cd0db76ebccc7c1457ee047df0ba6909ff018e300c4f4957a60f5b670089810dfc417af9b#npm:7.10.4"],
|
["@babel/preset-react", "virtual:22157ea722f8d6428f1fcf0a6f7f6c7d6b902d9c785256c60a65fe6cd0db76ebccc7c1457ee047df0ba6909ff018e300c4f4957a60f5b670089810dfc417af9b#npm:7.10.4"],
|
||||||
|
["@lowdefy/block-tools", "workspace:packages/blockTools"],
|
||||||
["babel-loader", "virtual:e7dd2bdbec1b3ec399e5f3318d0a58728583b58181f43cb8f4f372a1b2b9707e2ffcf76bd80aad3c5c64a731754028a8070020628ca4fa0a02fe260c179762ae#npm:8.1.0"],
|
["babel-loader", "virtual:e7dd2bdbec1b3ec399e5f3318d0a58728583b58181f43cb8f4f372a1b2b9707e2ffcf76bd80aad3c5c64a731754028a8070020628ca4fa0a02fe260c179762ae#npm:8.1.0"],
|
||||||
["bundle-loader", "npm:0.5.6"],
|
["bundle-loader", "npm:0.5.6"],
|
||||||
["graphql", "npm:15.3.0"],
|
["graphql", "npm:15.3.0"],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lowdefy/block-tools",
|
"name": "@lowdefy/block-tools",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1-experimental.1",
|
||||||
"licence": "Apache-2.0",
|
"licence": "Apache-2.0",
|
||||||
"description": "Lowdefy Block Tools",
|
"description": "Lowdefy Block Tools",
|
||||||
"homepage": "https://lowdefy.com",
|
"homepage": "https://lowdefy.com",
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import makeCssClass from './makeCssClass';
|
||||||
|
|
||||||
const defaultMethods = (methods) => ({
|
const defaultMethods = (methods) => ({
|
||||||
|
makeCssClass,
|
||||||
callAction: methods.callAction || (() => undefined),
|
callAction: methods.callAction || (() => undefined),
|
||||||
makeCss: methods.makeCss || (() => undefined),
|
|
||||||
registerAction: methods.registerAction || (() => undefined),
|
registerAction: methods.registerAction || (() => undefined),
|
||||||
registerMethod: methods.registerMethod || (() => undefined),
|
registerMethod: methods.registerMethod || (() => undefined),
|
||||||
...methods,
|
...methods,
|
||||||
|
@ -17,16 +17,16 @@
|
|||||||
import createEmotion from 'create-emotion';
|
import createEmotion from 'create-emotion';
|
||||||
|
|
||||||
const windowContext = window || {};
|
const windowContext = window || {};
|
||||||
let emotion;
|
|
||||||
|
|
||||||
// memoize emotion
|
const initEmotion = () => {
|
||||||
if (!windowContext.emotion) {
|
|
||||||
const { css, injectGlobal } = createEmotion({
|
const { css, injectGlobal } = createEmotion({
|
||||||
container: document.getElementById('emotion'),
|
container: document.getElementById('emotion'),
|
||||||
});
|
});
|
||||||
emotion = { css, injectGlobal };
|
windowContext.emotion = { css, injectGlobal };
|
||||||
} else {
|
};
|
||||||
emotion = windowContext.emotion;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default emotion;
|
const getEmotionCss = () => {
|
||||||
|
return windowContext.emotion.css;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { initEmotion, getEmotionCss };
|
||||||
|
@ -15,10 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import connectBlock from './connectBlock';
|
import connectBlock from './connectBlock';
|
||||||
import emotion from './emotion';
|
import { getEmotionCss, initEmotion } from './emotion';
|
||||||
import ErrorBoundary from './ErrorBoundary';
|
import ErrorBoundary from './ErrorBoundary';
|
||||||
import makeCssClass from './makeCssClass.js';
|
import makeCssClass from './makeCssClass.js';
|
||||||
import mediaToCssObject from './mediaToCssObject.js';
|
import mediaToCssObject from './mediaToCssObject.js';
|
||||||
import useRunAfterUpdate from './useRunAfterUpdate';
|
import useRunAfterUpdate from './useRunAfterUpdate';
|
||||||
|
|
||||||
export { connectBlock, emotion, ErrorBoundary, makeCssClass, mediaToCssObject, useRunAfterUpdate };
|
export {
|
||||||
|
connectBlock,
|
||||||
|
ErrorBoundary,
|
||||||
|
getEmotionCss,
|
||||||
|
initEmotion,
|
||||||
|
makeCssClass,
|
||||||
|
mediaToCssObject,
|
||||||
|
useRunAfterUpdate,
|
||||||
|
};
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
import { mergeObjects } from '@lowdefy/helpers';
|
import { mergeObjects } from '@lowdefy/helpers';
|
||||||
import mediaToCssObject from './mediaToCssObject';
|
import mediaToCssObject from './mediaToCssObject';
|
||||||
import emotion from './emotion';
|
import { getEmotionCss } from './emotion';
|
||||||
|
|
||||||
const makeCssClass = (styles, options = {}) =>
|
const makeCssClass = (styles, options = {}) => {
|
||||||
options.styleObjectOnly
|
const css = getEmotionCss();
|
||||||
|
return options.styleObjectOnly
|
||||||
? mediaToCssObject(mergeObjects(styles), options)
|
? mediaToCssObject(mergeObjects(styles), options)
|
||||||
: emotion.css(mediaToCssObject(mergeObjects(styles), options));
|
: css(mediaToCssObject(mergeObjects(styles), options));
|
||||||
|
};
|
||||||
|
|
||||||
export default makeCssClass;
|
export default makeCssClass;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import makeCssClass from '../src/makeCssClass';
|
import makeCssClass from '../src/makeCssClass';
|
||||||
|
import { initEmotion } from '../src/emotion';
|
||||||
|
|
||||||
const mockCss = jest.fn();
|
const mockCss = jest.fn();
|
||||||
const mockCssImp = (obj) => ({
|
const mockCssImp = (obj) => ({
|
||||||
@ -28,6 +29,7 @@ jest.mock('create-emotion', () => () => ({
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockCss.mockReset();
|
mockCss.mockReset();
|
||||||
mockCss.mockImplementation(mockCssImp);
|
mockCss.mockImplementation(mockCssImp);
|
||||||
|
initEmotion();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('object with no media', () => {
|
test('object with no media', () => {
|
||||||
|
@ -37,4 +37,4 @@ const app = express();
|
|||||||
|
|
||||||
server.applyMiddleware({ app });
|
server.applyMiddleware({ app });
|
||||||
app.use(express.static('shell/dist'));
|
app.use(express.static('shell/dist'));
|
||||||
app.listen({ port: 4000 }, () => console.log(`🚀 Server ready at http://localhost:4000`));
|
app.listen({ port: 3000 }, () => console.log(`🚀 Server ready at http://localhost:3000`));
|
||||||
|
@ -20,7 +20,7 @@ import useDynamicScript from './utils/useDynamicScript';
|
|||||||
|
|
||||||
function Engine() {
|
function Engine() {
|
||||||
const { ready, failed } = useDynamicScript({
|
const { ready, failed } = useDynamicScript({
|
||||||
url: 'https://unpkg.com/nxjdkxbp/dist/remoteEntry.js',
|
url: 'http://localhost:3001/remoteEntry.js',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
@ -31,7 +31,7 @@ function Engine() {
|
|||||||
return <h2>Failed to load dynamic script</h2>;
|
return <h2>Failed to load dynamic script</h2>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Component = React.lazy(loadComponent('nxjdkxbp', 'Engine'));
|
const Component = React.lazy(loadComponent('lowdefy_renderer', 'Engine'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Suspense fallback="Loading Engine">
|
<React.Suspense fallback="Loading Engine">
|
||||||
|
@ -69,5 +69,5 @@ test('momentHumanizeDuration', () => {
|
|||||||
withSuffix: true,
|
withSuffix: true,
|
||||||
thresholds: { d: 7, w: 4 },
|
thresholds: { d: 7, w: 4 },
|
||||||
});
|
});
|
||||||
expect(formatter(604800000)).toEqual('dans a week');
|
expect(formatter(604800000)).toEqual('dans une semaine');
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"@babel/core": "7.11.6",
|
"@babel/core": "7.11.6",
|
||||||
"@babel/preset-env": "7.11.5",
|
"@babel/preset-env": "7.11.5",
|
||||||
"@babel/preset-react": "7.10.4",
|
"@babel/preset-react": "7.10.4",
|
||||||
"@lowdefy/block-tools": "1.0.0",
|
"@lowdefy/block-tools": "1.0.1-experimental.1",
|
||||||
"babel-jest": "26.5.2",
|
"babel-jest": "26.5.2",
|
||||||
"babel-loader": "8.1.0",
|
"babel-loader": "8.1.0",
|
||||||
"babel-plugin-import": "1.13.0",
|
"babel-plugin-import": "1.13.0",
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
"@apollo/link-context": "2.0.0-beta.3",
|
"@apollo/link-context": "2.0.0-beta.3",
|
||||||
"@apollo/link-error": "2.0.0-beta.3",
|
"@apollo/link-error": "2.0.0-beta.3",
|
||||||
"@apollo/link-retry": "2.0.0-beta.3",
|
"@apollo/link-retry": "2.0.0-beta.3",
|
||||||
|
"@lowdefy/block-tools": "1.0.1-experimental.1",
|
||||||
"graphql": "15.3.0",
|
"graphql": "15.3.0",
|
||||||
"react": "17.0.0-rc.3",
|
"react": "17.0.0-rc.3",
|
||||||
"react-dom": "17.0.0-rc.3"
|
"react-dom": "17.0.0-rc.3"
|
||||||
|
@ -15,9 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { connectBlock } from '@lowdefy/block-tools';
|
||||||
import useDynamicScript from './utils/useDynamicScript';
|
import useDynamicScript from './utils/useDynamicScript';
|
||||||
import loadComponent from './utils/loadComponent';
|
import loadComponent from './utils/loadComponent';
|
||||||
|
|
||||||
|
const Comp = ({ bl }) => {
|
||||||
|
const CBlock = connectBlock(bl);
|
||||||
|
return <CBlock />;
|
||||||
|
};
|
||||||
|
|
||||||
function Block({ meta }) {
|
function Block({ meta }) {
|
||||||
const { ready, failed } = useDynamicScript({
|
const { ready, failed } = useDynamicScript({
|
||||||
url: meta && meta.url,
|
url: meta && meta.url,
|
||||||
@ -39,7 +45,7 @@ function Block({ meta }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Suspense fallback="Loading Block">
|
<React.Suspense fallback="Loading Block">
|
||||||
<Component />
|
<Comp bl={Component} />
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,14 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ApolloProvider } from '@apollo/client';
|
import { ApolloProvider } from '@apollo/client';
|
||||||
|
import { initEmotion } from '@lowdefy/block-tools';
|
||||||
import useGqlClient from './utils/useGqlClient';
|
import useGqlClient from './utils/useGqlClient';
|
||||||
import Page from './Page';
|
import Page from './Page';
|
||||||
|
|
||||||
// const RemoteButton = React.lazy(() => import('block/Button'));
|
// const RemoteButton = React.lazy(() => import('block/Button'));
|
||||||
|
|
||||||
const Engine = () => {
|
const Engine = () => {
|
||||||
|
initEmotion();
|
||||||
const client = useGqlClient();
|
const client = useGqlClient();
|
||||||
return (
|
return (
|
||||||
<ApolloProvider client={client}>
|
<ApolloProvider client={client}>
|
||||||
|
@ -24,7 +24,7 @@ import { RetryLink } from '@apollo/link-retry';
|
|||||||
const cache = new InMemoryCache();
|
const cache = new InMemoryCache();
|
||||||
const retryLink = new RetryLink();
|
const retryLink = new RetryLink();
|
||||||
const httpLink = new HttpLink({
|
const httpLink = new HttpLink({
|
||||||
uri: 'http://localhost:4000/graphql',
|
uri: '/graphql',
|
||||||
});
|
});
|
||||||
const errorHandler = ({ graphQLErrors, networkError }) => {
|
const errorHandler = ({ graphQLErrors, networkError }) => {
|
||||||
console.log('graphQLErrors', graphQLErrors);
|
console.log('graphQLErrors', graphQLErrors);
|
||||||
|
@ -2789,7 +2789,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@lowdefy/block-tools@1.0.0, @lowdefy/block-tools@workspace:packages/blockTools":
|
"@lowdefy/block-tools@1.0.1-experimental.1, @lowdefy/block-tools@workspace:packages/blockTools":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@lowdefy/block-tools@workspace:packages/blockTools"
|
resolution: "@lowdefy/block-tools@workspace:packages/blockTools"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2971,7 +2971,7 @@ __metadata:
|
|||||||
"@babel/core": 7.11.6
|
"@babel/core": 7.11.6
|
||||||
"@babel/preset-env": 7.11.5
|
"@babel/preset-env": 7.11.5
|
||||||
"@babel/preset-react": 7.10.4
|
"@babel/preset-react": 7.10.4
|
||||||
"@lowdefy/block-tools": 1.0.0
|
"@lowdefy/block-tools": 1.0.1-experimental.1
|
||||||
"@lowdefy/type": 1.0.1
|
"@lowdefy/type": 1.0.1
|
||||||
antd: 4.4.2
|
antd: 4.4.2
|
||||||
babel-jest: 26.5.2
|
babel-jest: 26.5.2
|
||||||
@ -3062,6 +3062,7 @@ __metadata:
|
|||||||
"@apollo/link-retry": 2.0.0-beta.3
|
"@apollo/link-retry": 2.0.0-beta.3
|
||||||
"@babel/core": 7.11.6
|
"@babel/core": 7.11.6
|
||||||
"@babel/preset-react": 7.10.4
|
"@babel/preset-react": 7.10.4
|
||||||
|
"@lowdefy/block-tools": 1.0.1-experimental.1
|
||||||
babel-loader: 8.1.0
|
babel-loader: 8.1.0
|
||||||
bundle-loader: 0.5.6
|
bundle-loader: 0.5.6
|
||||||
graphql: 15.3.0
|
graphql: 15.3.0
|
||||||
|
Loading…
Reference in New Issue
Block a user