@lowdefy/server 5.0.0 → 5.2.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/lib/build/theme.js +19 -0
- package/package.json +18 -17
- package/package.original.json +23 -17
- package/pages/{[pageId].js → [[...pageId]].js} +35 -1
- package/pages/_app.js +13 -3
- package/pages/_document.js +41 -0
- package/pages/api/endpoints/{[endpointId].js → [...endpointId].js} +1 -1
- package/pages/api/request/{[pageId]/[requestId].js → [...path].js} +8 -2
- package/pages/index.js +0 -57
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/theme.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,23 +38,23 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@ant-design/cssinjs": "2.1.2",
|
|
41
|
-
"@lowdefy/actions-core": "5.
|
|
42
|
-
"@lowdefy/api": "5.
|
|
43
|
-
"@lowdefy/block-utils": "5.
|
|
44
|
-
"@lowdefy/blocks-antd": "5.
|
|
45
|
-
"@lowdefy/blocks-basic": "5.
|
|
46
|
-
"@lowdefy/blocks-loaders": "5.
|
|
47
|
-
"@lowdefy/
|
|
48
|
-
"@lowdefy/
|
|
49
|
-
"@lowdefy/
|
|
50
|
-
"@lowdefy/
|
|
51
|
-
"@lowdefy/
|
|
52
|
-
"@lowdefy/
|
|
53
|
-
"@lowdefy/
|
|
54
|
-
"@lowdefy/
|
|
41
|
+
"@lowdefy/actions-core": "5.2.0",
|
|
42
|
+
"@lowdefy/api": "5.2.0",
|
|
43
|
+
"@lowdefy/block-utils": "5.2.0",
|
|
44
|
+
"@lowdefy/blocks-antd": "5.2.0",
|
|
45
|
+
"@lowdefy/blocks-basic": "5.2.0",
|
|
46
|
+
"@lowdefy/blocks-loaders": "5.2.0",
|
|
47
|
+
"@lowdefy/blocks-tiptap": "5.2.0",
|
|
48
|
+
"@lowdefy/client": "5.2.0",
|
|
49
|
+
"@lowdefy/errors": "5.2.0",
|
|
50
|
+
"@lowdefy/helpers": "5.2.0",
|
|
51
|
+
"@lowdefy/layout": "5.2.0",
|
|
52
|
+
"@lowdefy/logger": "5.2.0",
|
|
53
|
+
"@lowdefy/node-utils": "5.2.0",
|
|
54
|
+
"@lowdefy/operators-js": "5.2.0",
|
|
55
|
+
"@lowdefy/plugin-next-auth": "5.2.0",
|
|
55
56
|
"@sentry/nextjs": "8.53.0",
|
|
56
57
|
"@tailwindcss/postcss": "4.2.1",
|
|
57
|
-
"tailwindcss": "4.2.1",
|
|
58
58
|
"antd": "6.3.1",
|
|
59
59
|
"dayjs": "1.11.19",
|
|
60
60
|
"next": "16.1.6",
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
"react": "18.2.0",
|
|
64
64
|
"react-dom": "18.2.0",
|
|
65
65
|
"react-icons": "5.6.0",
|
|
66
|
+
"tailwindcss": "4.2.1",
|
|
66
67
|
"uuid": "13.0.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@lowdefy/build": "5.
|
|
70
|
+
"@lowdefy/build": "5.2.0",
|
|
70
71
|
"@next/eslint-plugin-next": "16.1.6",
|
|
71
72
|
"@tailwindcss/postcss": "4.2.1",
|
|
72
73
|
"tailwindcss": "4.2.1",
|
package/package.original.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -48,23 +48,23 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ant-design/cssinjs": "2.1.2",
|
|
51
|
-
"@lowdefy/actions-core": "5.
|
|
52
|
-
"@lowdefy/api": "5.
|
|
53
|
-
"@lowdefy/block-utils": "5.
|
|
54
|
-
"@lowdefy/blocks-antd": "5.
|
|
55
|
-
"@lowdefy/blocks-basic": "5.
|
|
56
|
-
"@lowdefy/blocks-loaders": "5.
|
|
57
|
-
"@lowdefy/
|
|
58
|
-
"@lowdefy/
|
|
59
|
-
"@lowdefy/
|
|
60
|
-
"@lowdefy/
|
|
61
|
-
"@lowdefy/
|
|
62
|
-
"@lowdefy/
|
|
63
|
-
"@lowdefy/
|
|
64
|
-
"@lowdefy/
|
|
51
|
+
"@lowdefy/actions-core": "5.2.0",
|
|
52
|
+
"@lowdefy/api": "5.2.0",
|
|
53
|
+
"@lowdefy/block-utils": "5.2.0",
|
|
54
|
+
"@lowdefy/blocks-antd": "5.2.0",
|
|
55
|
+
"@lowdefy/blocks-basic": "5.2.0",
|
|
56
|
+
"@lowdefy/blocks-loaders": "5.2.0",
|
|
57
|
+
"@lowdefy/blocks-tiptap": "5.2.0",
|
|
58
|
+
"@lowdefy/client": "5.2.0",
|
|
59
|
+
"@lowdefy/errors": "5.2.0",
|
|
60
|
+
"@lowdefy/helpers": "5.2.0",
|
|
61
|
+
"@lowdefy/layout": "5.2.0",
|
|
62
|
+
"@lowdefy/logger": "5.2.0",
|
|
63
|
+
"@lowdefy/node-utils": "5.2.0",
|
|
64
|
+
"@lowdefy/operators-js": "5.2.0",
|
|
65
|
+
"@lowdefy/plugin-next-auth": "5.2.0",
|
|
65
66
|
"@sentry/nextjs": "8.53.0",
|
|
66
67
|
"@tailwindcss/postcss": "4.2.1",
|
|
67
|
-
"tailwindcss": "4.2.1",
|
|
68
68
|
"antd": "6.3.1",
|
|
69
69
|
"dayjs": "1.11.19",
|
|
70
70
|
"next": "16.1.6",
|
|
@@ -73,10 +73,11 @@
|
|
|
73
73
|
"react": "18.2.0",
|
|
74
74
|
"react-dom": "18.2.0",
|
|
75
75
|
"react-icons": "5.6.0",
|
|
76
|
+
"tailwindcss": "4.2.1",
|
|
76
77
|
"uuid": "13.0.0"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
|
-
"@lowdefy/build": "5.
|
|
80
|
+
"@lowdefy/build": "5.2.0",
|
|
80
81
|
"@next/eslint-plugin-next": "16.1.6",
|
|
81
82
|
"@tailwindcss/postcss": "4.2.1",
|
|
82
83
|
"tailwindcss": "4.2.1",
|
|
@@ -87,6 +88,11 @@
|
|
|
87
88
|
"engines": {
|
|
88
89
|
"node": ">=18"
|
|
89
90
|
},
|
|
91
|
+
"pnpm": {
|
|
92
|
+
"onlyBuiltDependencies": [
|
|
93
|
+
"better-sqlite3"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
90
96
|
"publishConfig": {
|
|
91
97
|
"access": "public"
|
|
92
98
|
}
|
|
@@ -20,8 +20,42 @@ import serverSidePropsWrapper from '../lib/server/serverSidePropsWrapper.js';
|
|
|
20
20
|
import Page from '../lib/client/Page.js';
|
|
21
21
|
|
|
22
22
|
async function getServerSidePropsHandler({ context, nextContext }) {
|
|
23
|
-
const
|
|
23
|
+
const segments = nextContext.params.pageId ?? [];
|
|
24
|
+
const pageId = segments.join('/');
|
|
24
25
|
const { logger, session } = context;
|
|
26
|
+
|
|
27
|
+
if (!pageId) {
|
|
28
|
+
const rootConfig = await getRootConfig(context);
|
|
29
|
+
const { home } = rootConfig;
|
|
30
|
+
if (home.configured === false) {
|
|
31
|
+
logger.info({ event: 'redirect_to_homepage', pageId: home.pageId });
|
|
32
|
+
return {
|
|
33
|
+
redirect: {
|
|
34
|
+
destination: `/${home.pageId}`,
|
|
35
|
+
permanent: false,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const pageConfig = await getPageConfig(context, { pageId: home.pageId });
|
|
40
|
+
if (!pageConfig) {
|
|
41
|
+
logger.info({ event: 'redirect_page_not_found', pageId: home.pageId });
|
|
42
|
+
return {
|
|
43
|
+
redirect: {
|
|
44
|
+
destination: '/404',
|
|
45
|
+
permanent: false,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
logger.info({ event: 'page_view', pageId: home.pageId });
|
|
50
|
+
return {
|
|
51
|
+
props: {
|
|
52
|
+
pageConfig,
|
|
53
|
+
rootConfig,
|
|
54
|
+
session,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
25
59
|
const [rootConfig, pageConfig] = await Promise.all([
|
|
26
60
|
getRootConfig(context),
|
|
27
61
|
getPageConfig(context, { pageId }),
|
package/pages/_app.js
CHANGED
|
@@ -58,11 +58,19 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
58
58
|
lowdefyRef.current.theme = rootConfig.theme;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const algorithm = useDarkMode({
|
|
62
|
-
|
|
61
|
+
const { algorithm, token, components } = useDarkMode({
|
|
62
|
+
antd: lowdefyRef.current.theme?.antd,
|
|
63
63
|
configDarkMode: lowdefyRef.current.theme?.darkMode,
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
const {
|
|
67
|
+
lightToken: _lightToken,
|
|
68
|
+
darkToken: _darkToken,
|
|
69
|
+
lightComponents: _lightComponents,
|
|
70
|
+
darkComponents: _darkComponents,
|
|
71
|
+
...antdConfig
|
|
72
|
+
} = lowdefyRef.current.theme?.antd ?? {};
|
|
73
|
+
|
|
66
74
|
const handleError = useCallback((error) => {
|
|
67
75
|
if (lowdefyRef.current?._internal?.handleError) {
|
|
68
76
|
lowdefyRef.current._internal.handleError(error);
|
|
@@ -75,7 +83,9 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
75
83
|
<StyleProvider layer>
|
|
76
84
|
<ConfigProvider
|
|
77
85
|
theme={{
|
|
78
|
-
...
|
|
86
|
+
...antdConfig,
|
|
87
|
+
token,
|
|
88
|
+
components,
|
|
79
89
|
cssVar: { key: 'lowdefy' },
|
|
80
90
|
hashed: false,
|
|
81
91
|
algorithm,
|
package/pages/_document.js
CHANGED
|
@@ -19,8 +19,34 @@ import Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
|
19
19
|
|
|
20
20
|
import appJson from '../lib/build/app.js';
|
|
21
21
|
import lowdefyConfig from '../lib/build/config.js';
|
|
22
|
+
import themeConfig from '../lib/build/theme.js';
|
|
22
23
|
|
|
23
24
|
const basePath = lowdefyConfig.basePath ?? '';
|
|
25
|
+
const VALID_COLOR_MODES = ['system', 'light', 'dark'];
|
|
26
|
+
const configColorMode = VALID_COLOR_MODES.includes(themeConfig.darkMode)
|
|
27
|
+
? themeConfig.darkMode
|
|
28
|
+
: 'system';
|
|
29
|
+
const darkBg = themeConfig?.antd?.darkToken?.colorBgLayout ?? '#000';
|
|
30
|
+
const lightBg = themeConfig?.antd?.lightToken?.colorBgLayout ?? '';
|
|
31
|
+
|
|
32
|
+
// Escape characters that could break out of the enclosing <script> tag or
|
|
33
|
+
// terminate a JS string literal. Used to defuse the js/bad-code-sanitization
|
|
34
|
+
// class of injection for values embedded into the pre-hydration inline script.
|
|
35
|
+
const SCRIPT_ESCAPES = {
|
|
36
|
+
'<': '\\u003C',
|
|
37
|
+
'>': '\\u003E',
|
|
38
|
+
'\b': '\\b',
|
|
39
|
+
'\f': '\\f',
|
|
40
|
+
'\n': '\\n',
|
|
41
|
+
'\r': '\\r',
|
|
42
|
+
'\t': '\\t',
|
|
43
|
+
'\0': '\\0',
|
|
44
|
+
'\u2028': '\\u2028',
|
|
45
|
+
'\u2029': '\\u2029',
|
|
46
|
+
};
|
|
47
|
+
function safeScriptJson(value) {
|
|
48
|
+
return JSON.stringify(value).replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, (c) => SCRIPT_ESCAPES[c]);
|
|
49
|
+
}
|
|
24
50
|
|
|
25
51
|
class LowdefyDocument extends Document {
|
|
26
52
|
render() {
|
|
@@ -38,6 +64,21 @@ class LowdefyDocument extends Document {
|
|
|
38
64
|
__html: `(function(){var s=document.createElement("style");s.id="__lf-layer-order";s.textContent="@layer theme, base, antd, components, utilities;";document.head.prepend(s);new MutationObserver(function(){if(document.head.firstChild!==s)document.head.prepend(s)}).observe(document.head,{childList:true})})();`,
|
|
39
65
|
}}
|
|
40
66
|
/>
|
|
67
|
+
{/* Synchronous pre-hydration background script — prevents mode-mismatch
|
|
68
|
+
flash on page navigation. Mirrors useDarkMode.js resolution order:
|
|
69
|
+
configDarkMode → localStorage → prefers-color-scheme. Uses the user's
|
|
70
|
+
configured colorBgLayout tokens when present (theme.antd.darkToken and
|
|
71
|
+
theme.antd.lightToken), falling back to #000 in dark and no inline style
|
|
72
|
+
in light so default behavior is unchanged. */}
|
|
73
|
+
<script
|
|
74
|
+
dangerouslySetInnerHTML={{
|
|
75
|
+
__html: `(function(){var c=${safeScriptJson(configColorMode)};var db=${safeScriptJson(
|
|
76
|
+
darkBg
|
|
77
|
+
)};var lb=${safeScriptJson(
|
|
78
|
+
lightBg
|
|
79
|
+
)};var d;if(c==="dark")d=true;else if(c==="light")d=false;else{try{var p=localStorage.getItem("lowdefy_darkMode");if(p==="dark")d=true;else if(p==="light")d=false;else d=window.matchMedia("(prefers-color-scheme:dark)").matches}catch(e){d=window.matchMedia("(prefers-color-scheme:dark)").matches}}var bg=d?db:lb;if(bg)document.documentElement.style.backgroundColor=bg})();`,
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
41
82
|
<link rel="manifest" href={`${basePath}/manifest.webmanifest`} />
|
|
42
83
|
<link rel="icon" type="image/svg+xml" href={`${basePath}/icon.svg`} />
|
|
43
84
|
<link rel="apple-touch-icon" href={`${basePath}/apple-touch-icon.png`} />
|
|
@@ -22,7 +22,7 @@ async function handler({ context, req, res }) {
|
|
|
22
22
|
if (req.method !== 'POST') {
|
|
23
23
|
throw new Error('Only POST requests are supported.');
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const endpointId = req.query.endpointId.join('/');
|
|
26
26
|
const { blockId, payload, pageId } = req.body;
|
|
27
27
|
context.logger.info({ event: 'call_api_endpoint', blockId, endpointId, pageId });
|
|
28
28
|
const response = await callEndpoint(context, { blockId, endpointId, pageId, payload });
|
|
@@ -16,13 +16,19 @@
|
|
|
16
16
|
|
|
17
17
|
import { callRequest } from '@lowdefy/api';
|
|
18
18
|
|
|
19
|
-
import apiWrapper from '
|
|
19
|
+
import apiWrapper from '../../../lib/server/apiWrapper.js';
|
|
20
20
|
|
|
21
21
|
async function handler({ context, req, res }) {
|
|
22
22
|
if (req.method !== 'POST') {
|
|
23
23
|
throw new Error('Only POST requests are supported.');
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const segments = req.query.path;
|
|
26
|
+
if (!Array.isArray(segments) || segments.length < 2) {
|
|
27
|
+
res.status(400).json({ error: 'Invalid request path' });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const requestId = segments[segments.length - 1];
|
|
31
|
+
const pageId = segments.slice(0, -1).join('/');
|
|
26
32
|
const { actionId, blockId, payload } = req.body;
|
|
27
33
|
context.logger.info({ event: 'call_request', pageId, requestId, blockId, actionId });
|
|
28
34
|
const response = await callRequest(context, { blockId, pageId, payload, requestId });
|
package/pages/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
-
|
|
19
|
-
import serverSidePropsWrapper from '../lib/server/serverSidePropsWrapper.js';
|
|
20
|
-
import Page from '../lib/client/Page.js';
|
|
21
|
-
|
|
22
|
-
async function getServerSidePropsHandler({ context }) {
|
|
23
|
-
const rootConfig = await getRootConfig(context);
|
|
24
|
-
const { home } = rootConfig;
|
|
25
|
-
const { logger, session } = context;
|
|
26
|
-
if (home.configured === false) {
|
|
27
|
-
logger.info({ event: 'redirect_to_homepage', pageId: home.pageId });
|
|
28
|
-
return {
|
|
29
|
-
redirect: {
|
|
30
|
-
destination: `/${home.pageId}`,
|
|
31
|
-
permanent: false,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const pageConfig = await getPageConfig(context, { pageId: home.pageId });
|
|
36
|
-
if (!pageConfig) {
|
|
37
|
-
logger.info({ event: 'redirect_page_not_found', pageId: home.pageId });
|
|
38
|
-
return {
|
|
39
|
-
redirect: {
|
|
40
|
-
destination: '/404',
|
|
41
|
-
permanent: false,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
logger.info({ event: 'page_view', pageId: home.pageId });
|
|
46
|
-
return {
|
|
47
|
-
props: {
|
|
48
|
-
pageConfig,
|
|
49
|
-
rootConfig,
|
|
50
|
-
session,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const getServerSideProps = serverSidePropsWrapper(getServerSidePropsHandler);
|
|
56
|
-
|
|
57
|
-
export default Page;
|