@lowdefy/server-dev 4.5.2 → 4.7.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/{manager/utils/createLogger.mjs → lib/build/app.js} +4 -18
- package/lib/build/auth.js +19 -0
- package/lib/build/config.js +19 -0
- package/lib/build/logger.js +19 -0
- package/lib/client/App.js +25 -21
- package/lib/client/BuildErrorPage.js +91 -0
- package/lib/client/BuildingPage.js +74 -0
- package/lib/client/InstallingPluginsPage.js +50 -0
- package/lib/client/Page.js +20 -2
- package/lib/client/Reload.js +1 -1
- package/lib/client/RestartingPage.js +3 -1
- package/lib/client/auth/Auth.js +2 -2
- package/lib/client/auth/AuthConfigured.js +2 -2
- package/lib/client/auth/AuthNotConfigured.js +1 -1
- package/lib/client/setPageId.js +1 -1
- package/lib/client/utils/request.js +2 -5
- package/lib/client/utils/useMutateCache.js +16 -3
- package/lib/client/utils/usePageConfig.js +51 -5
- package/lib/client/utils/useRootConfig.js +1 -1
- package/lib/client/utils/waitForRestartedServer.js +1 -1
- package/lib/server/apiWrapper.js +48 -8
- package/lib/server/auth/getAuthOptions.js +2 -2
- package/lib/server/auth/getMockSession.js +67 -0
- package/lib/server/auth/getServerSession.js +10 -3
- package/lib/server/fileCache.js +1 -1
- package/lib/server/jitPageBuilder.js +168 -0
- package/lib/server/log/createHandleError.js +47 -0
- package/lib/server/log/createLogger.js +4 -4
- package/lib/server/log/logRequest.js +1 -1
- package/lib/server/pageCache.mjs +61 -0
- package/lib/server/pageCache.test.mjs +80 -0
- package/manager/getContext.mjs +26 -4
- package/manager/processes/checkMockUserWarning.mjs +42 -0
- package/manager/processes/initialBuild.mjs +2 -1
- package/manager/processes/installPlugins.mjs +3 -3
- package/manager/processes/lowdefyBuild.mjs +16 -5
- package/manager/processes/nextBuild.mjs +27 -8
- package/manager/processes/readDotEnv.mjs +1 -1
- package/manager/processes/reloadClients.mjs +1 -1
- package/manager/processes/restartServer.mjs +3 -3
- package/manager/processes/shutdownServer.mjs +2 -2
- package/manager/processes/startServer.mjs +32 -15
- package/manager/processes/startWatchers.mjs +1 -1
- package/manager/run.mjs +2 -12
- package/manager/utils/BatchChanges.mjs +1 -1
- package/manager/utils/createCustomPluginTypesMap.mjs +1 -1
- package/manager/utils/getLowdefyVersion.mjs +8 -7
- package/manager/utils/getNextBin.mjs +1 -1
- package/manager/utils/setupWatcher.mjs +1 -1
- package/manager/watchers/envWatcher.mjs +1 -1
- package/manager/watchers/lowdefyBuildWatcher.mjs +26 -5
- package/manager/watchers/nextBuildWatcher.mjs +12 -2
- package/next.config.js +3 -2
- package/package.json +33 -29
- package/package.original.json +32 -28
- package/pages/404.js +1 -1
- package/pages/[pageId].js +1 -1
- package/pages/_app.js +17 -4
- package/pages/_document.js +3 -3
- package/pages/api/auth/[...nextauth].js +13 -2
- package/pages/api/client-error.js +45 -0
- package/pages/api/dev-tools.js +1 -1
- package/pages/api/endpoints/[endpointId].js +1 -1
- package/pages/api/js/[env].js +42 -0
- package/pages/api/page/[pageId].js +40 -2
- package/pages/api/ping.js +1 -1
- package/pages/api/reload.js +6 -3
- package/pages/api/request/[pageId]/[requestId].js +6 -3
- package/pages/api/root.js +1 -1
- package/pages/index.js +1 -1
- package/lib/server/log/logError.js +0 -40
- package/manager/utils/createStdOutLineHandler.mjs +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,21 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/app.json';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
const logger = pino({
|
|
20
|
-
name: 'lowdefy build',
|
|
21
|
-
level,
|
|
22
|
-
base: { pid: undefined, hostname: undefined },
|
|
23
|
-
mixin: (context, level) => {
|
|
24
|
-
return {
|
|
25
|
-
...context,
|
|
26
|
-
print: context.print ?? logger.levels.labels[level],
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
return logger;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default createLogger;
|
|
19
|
+
export default serializer.deserialize(raw);
|
|
@@ -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/auth.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
|
@@ -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/config.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
|
@@ -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/logger.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
package/lib/client/App.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,23 +14,25 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React from 'react';
|
|
17
|
+
import React, { Suspense } from 'react';
|
|
18
18
|
|
|
19
19
|
import { useRouter } from 'next/router';
|
|
20
20
|
|
|
21
21
|
import Head from 'next/head';
|
|
22
22
|
import Link from 'next/link';
|
|
23
23
|
|
|
24
|
+
import BuildingPage from './BuildingPage.js';
|
|
24
25
|
import Reload from './Reload.js';
|
|
25
26
|
import Page from './Page.js';
|
|
26
27
|
import setPageId from './setPageId.js';
|
|
28
|
+
import { getReloadVersion } from './utils/useMutateCache.js';
|
|
27
29
|
import useRootConfig from './utils/useRootConfig.js';
|
|
28
30
|
|
|
29
31
|
import actions from '../../build/plugins/actions.js';
|
|
30
32
|
import blocks from '../../build/plugins/blocks.js';
|
|
31
33
|
import icons from '../../build/plugins/icons.js';
|
|
32
34
|
import operators from '../../build/plugins/operators/client.js';
|
|
33
|
-
import
|
|
35
|
+
import staticJsMap from '../../build/plugins/operators/clientJsMap.js';
|
|
34
36
|
|
|
35
37
|
const App = ({ auth, lowdefy }) => {
|
|
36
38
|
const router = useRouter();
|
|
@@ -44,24 +46,26 @@ const App = ({ auth, lowdefy }) => {
|
|
|
44
46
|
return (
|
|
45
47
|
<Reload basePath={router.basePath} lowdefy={lowdefy}>
|
|
46
48
|
{(resetContext) => (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
<Suspense key={`${pageId}_${getReloadVersion()}`} fallback={<BuildingPage />}>
|
|
50
|
+
<Page
|
|
51
|
+
auth={auth}
|
|
52
|
+
Components={{ Head, Link }}
|
|
53
|
+
config={{
|
|
54
|
+
rootConfig,
|
|
55
|
+
}}
|
|
56
|
+
jsMap={staticJsMap}
|
|
57
|
+
lowdefy={lowdefy}
|
|
58
|
+
pageId={pageId}
|
|
59
|
+
resetContext={resetContext}
|
|
60
|
+
router={router}
|
|
61
|
+
types={{
|
|
62
|
+
actions,
|
|
63
|
+
blocks,
|
|
64
|
+
icons,
|
|
65
|
+
operators,
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
</Suspense>
|
|
65
69
|
)}
|
|
66
70
|
</Reload>
|
|
67
71
|
);
|
|
@@ -0,0 +1,91 @@
|
|
|
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 React from 'react';
|
|
18
|
+
|
|
19
|
+
const typeColors = {
|
|
20
|
+
ConfigError: '#cf1322',
|
|
21
|
+
ConfigWarning: '#d48806',
|
|
22
|
+
PluginError: '#531dab',
|
|
23
|
+
ServiceError: '#096dd9',
|
|
24
|
+
LowdefyInternalError: '#cf1322',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function getTypeColor(type) {
|
|
28
|
+
return typeColors[type] ?? '#595959';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ErrorItem = ({ type, message, source }) => {
|
|
32
|
+
const color = getTypeColor(type);
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
style={{
|
|
36
|
+
borderLeft: `3px solid ${color}`,
|
|
37
|
+
paddingLeft: 12,
|
|
38
|
+
marginBottom: 16,
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<span
|
|
42
|
+
style={{
|
|
43
|
+
fontSize: 11,
|
|
44
|
+
fontWeight: 600,
|
|
45
|
+
color,
|
|
46
|
+
textTransform: 'uppercase',
|
|
47
|
+
letterSpacing: '0.05em',
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{type}
|
|
51
|
+
</span>
|
|
52
|
+
<p style={{ fontSize: 14, margin: '4px 0', fontFamily: 'monospace' }}>{message}</p>
|
|
53
|
+
{source && <p style={{ fontSize: 13, color: '#8c8c8c', margin: 0 }}>{source}</p>}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const BuildErrorPage = ({ errors, message, source }) => {
|
|
59
|
+
// Support both new errors array and legacy single message/source props
|
|
60
|
+
const errorList = errors ?? (message ? [{ type: 'Error', message, source }] : []);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
style={{
|
|
65
|
+
height: '100vh',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
flexDirection: 'column',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
justifyContent: 'center',
|
|
70
|
+
fontFamily:
|
|
71
|
+
"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
72
|
+
padding: '0 24px',
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<div style={{ maxWidth: 720, width: '100%' }}>
|
|
76
|
+
<h2 style={{ color: '#cf1322', marginBottom: 16 }}>
|
|
77
|
+
{errorList.length > 1 ? `Build Errors (${errorList.length})` : 'Build Error'}
|
|
78
|
+
</h2>
|
|
79
|
+
{errorList.map((err, i) => (
|
|
80
|
+
<ErrorItem key={i} type={err.type} message={err.message} source={err.source} />
|
|
81
|
+
))}
|
|
82
|
+
<p style={{ fontSize: 13, color: '#8c8c8c', marginTop: 24 }}>
|
|
83
|
+
Fix the error{errorList.length > 1 ? 's' : ''} in your config and the page will rebuild
|
|
84
|
+
automatically.
|
|
85
|
+
</p>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default BuildErrorPage;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 React from 'react';
|
|
18
|
+
|
|
19
|
+
const BuildingPage = () => {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
style={{
|
|
23
|
+
height: '100vh',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
fontFamily:
|
|
30
|
+
"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<style>
|
|
34
|
+
{`
|
|
35
|
+
@keyframes building-progress {
|
|
36
|
+
0% { transform: translateX(-100%); }
|
|
37
|
+
100% { transform: translateX(100%); }
|
|
38
|
+
}
|
|
39
|
+
`}
|
|
40
|
+
</style>
|
|
41
|
+
<div
|
|
42
|
+
style={{
|
|
43
|
+
position: 'fixed',
|
|
44
|
+
top: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: 3,
|
|
48
|
+
backgroundColor: '#f0f0f0',
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
width: '40%',
|
|
55
|
+
height: '100%',
|
|
56
|
+
backgroundColor: '#1890ff',
|
|
57
|
+
animation: 'building-progress 1.5s ease-in-out infinite',
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
style={{
|
|
63
|
+
verticalAlign: 'middle',
|
|
64
|
+
display: 'inline-block',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<h3>Building page...</h3>
|
|
68
|
+
<p>The page will appear when the build completes.</p>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default BuildingPage;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 React from 'react';
|
|
18
|
+
|
|
19
|
+
const InstallingPluginsPage = ({ packages }) => {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
style={{
|
|
23
|
+
height: '100vh',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
fontFamily:
|
|
30
|
+
"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<div
|
|
34
|
+
style={{
|
|
35
|
+
verticalAlign: 'middle',
|
|
36
|
+
display: 'inline-block',
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<h3>Installing Plugin Packages</h3>
|
|
40
|
+
<p>
|
|
41
|
+
This page requires packages that are not yet installed:{' '}
|
|
42
|
+
<strong>{(packages ?? []).join(', ')}</strong>.
|
|
43
|
+
</p>
|
|
44
|
+
<p>The server will restart automatically. The page will reload when ready.</p>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default InstallingPluginsPage;
|
package/lib/client/Page.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import Client from '@lowdefy/client';
|
|
19
19
|
|
|
20
|
+
import BuildErrorPage from './BuildErrorPage.js';
|
|
21
|
+
import InstallingPluginsPage from './InstallingPluginsPage.js';
|
|
20
22
|
import RestartingPage from './RestartingPage.js';
|
|
21
23
|
import usePageConfig from './utils/usePageConfig.js';
|
|
22
24
|
|
|
@@ -37,9 +39,25 @@ const Page = ({
|
|
|
37
39
|
router.replace(`/404`);
|
|
38
40
|
return '';
|
|
39
41
|
}
|
|
42
|
+
if (pageConfig.buildError) {
|
|
43
|
+
return (
|
|
44
|
+
<BuildErrorPage
|
|
45
|
+
errors={pageConfig.errors}
|
|
46
|
+
message={pageConfig.message}
|
|
47
|
+
source={pageConfig.source}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (pageConfig.installing) {
|
|
52
|
+
return <InstallingPluginsPage packages={pageConfig.packages} />;
|
|
53
|
+
}
|
|
40
54
|
if (resetContext.restarting) {
|
|
41
55
|
return <RestartingPage />;
|
|
42
56
|
}
|
|
57
|
+
|
|
58
|
+
// Merge dynamic JS entries fetched after JIT build with the static jsMap
|
|
59
|
+
const mergedJsMap = pageConfig._jsEntries ? { ...jsMap, ...pageConfig._jsEntries } : jsMap;
|
|
60
|
+
|
|
43
61
|
return (
|
|
44
62
|
<Client
|
|
45
63
|
auth={auth}
|
|
@@ -48,7 +66,7 @@ const Page = ({
|
|
|
48
66
|
...config,
|
|
49
67
|
pageConfig,
|
|
50
68
|
}}
|
|
51
|
-
jsMap={
|
|
69
|
+
jsMap={mergedJsMap}
|
|
52
70
|
lowdefy={lowdefy}
|
|
53
71
|
resetContext={resetContext}
|
|
54
72
|
router={router}
|
package/lib/client/Reload.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -26,6 +26,8 @@ const RestartingPage = () => {
|
|
|
26
26
|
flexDirection: 'column',
|
|
27
27
|
alignItems: 'center',
|
|
28
28
|
justifyContent: 'center',
|
|
29
|
+
fontFamily:
|
|
30
|
+
"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
29
31
|
}}
|
|
30
32
|
>
|
|
31
33
|
<div
|
package/lib/client/auth/Auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -19,7 +19,7 @@ import React from 'react';
|
|
|
19
19
|
import AuthConfigured from './AuthConfigured.js';
|
|
20
20
|
import AuthNotConfigured from './AuthNotConfigured.js';
|
|
21
21
|
|
|
22
|
-
import authConfig from '
|
|
22
|
+
import authConfig from '../../build/auth.js';
|
|
23
23
|
|
|
24
24
|
function Auth({ children, session }) {
|
|
25
25
|
if (authConfig.configured === true) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import React, { useEffect, useRef } from 'react';
|
|
19
19
|
import { getSession, SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
|
|
20
20
|
|
|
21
|
-
import lowdefyConfig from '
|
|
21
|
+
import lowdefyConfig from '../../build/config.js';
|
|
22
22
|
|
|
23
23
|
function Session({ children }) {
|
|
24
24
|
const wasAuthenticated = useRef(false);
|
package/lib/client/setPageId.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -26,11 +26,8 @@ async function request({ url, method = 'GET', body }) {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
if (!res.ok) {
|
|
29
|
-
// TODO: check
|
|
30
29
|
const body = await res.json();
|
|
31
|
-
|
|
32
|
-
console.log(body);
|
|
33
|
-
throw new Error(body.message || 'Request error');
|
|
30
|
+
throw new Error(body?.['~e']?.message ?? body?.message ?? 'Request error');
|
|
34
31
|
}
|
|
35
32
|
return res.json();
|
|
36
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,10 +16,23 @@
|
|
|
16
16
|
|
|
17
17
|
import { useSWRConfig } from 'swr';
|
|
18
18
|
|
|
19
|
+
let reloadVersion = 0;
|
|
20
|
+
|
|
21
|
+
function getReloadVersion() {
|
|
22
|
+
return reloadVersion;
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
function useMutateCache(basePath) {
|
|
20
26
|
const { mutate } = useSWRConfig();
|
|
21
|
-
return () =>
|
|
22
|
-
|
|
27
|
+
return () => {
|
|
28
|
+
// Increment the reload version so that usePageConfig SWR keys change.
|
|
29
|
+
// Old cached page entries become orphaned (different key), forcing fresh
|
|
30
|
+
// fetches when navigating to any page after a reload.
|
|
31
|
+
reloadVersion += 1;
|
|
32
|
+
// Revalidate root config in the background (stale-while-revalidate, no suspend).
|
|
33
|
+
return mutate((key) => key === `${basePath}/api/root`);
|
|
34
|
+
};
|
|
23
35
|
}
|
|
24
36
|
|
|
37
|
+
export { getReloadVersion };
|
|
25
38
|
export default useMutateCache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License.
|
|
5
5
|
You may obtain a copy of the License at
|
|
@@ -13,14 +13,60 @@
|
|
|
13
13
|
|
|
14
14
|
import useSWR from 'swr';
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import { getReloadVersion } from './useMutateCache.js';
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
|
|
18
|
+
function parseJsModule(text) {
|
|
19
|
+
const fn = new Function('exports', text.replace('export default', 'exports.default ='));
|
|
20
|
+
const mod = {};
|
|
21
|
+
fn(mod);
|
|
22
|
+
return mod.default ?? {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function fetchJsEntries(basePath) {
|
|
26
|
+
try {
|
|
27
|
+
const res = await fetch(`${basePath}/api/js/client`);
|
|
28
|
+
if (!res.ok) return {};
|
|
29
|
+
return parseJsModule(await res.text());
|
|
30
|
+
} catch {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function fetchPageConfig(url) {
|
|
36
|
+
const res = await fetch(url, {
|
|
37
|
+
headers: { 'Content-Type': 'application/json' },
|
|
38
|
+
});
|
|
39
|
+
if (res.status === 404) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const data = await res.json();
|
|
43
|
+
if (data?.buildError) {
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
if (data?.installing) {
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
throw new Error(data.message || 'Request error');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Fetch jsMap after page build completes (JIT build may have added new entries).
|
|
54
|
+
// Extract basePath from the URL to construct the jsMap endpoint.
|
|
55
|
+
const basePath = url.replace(/\/api\/page\/.*$/, '');
|
|
56
|
+
const jsEntries = await fetchJsEntries(basePath);
|
|
57
|
+
data._jsEntries = jsEntries;
|
|
58
|
+
|
|
59
|
+
return data;
|
|
20
60
|
}
|
|
21
61
|
|
|
22
62
|
function usePageConfig(pageId, basePath) {
|
|
23
|
-
const
|
|
63
|
+
const url = `${basePath}/api/page/${pageId}`;
|
|
64
|
+
// Include reloadVersion in the SWR key so that after a config reload,
|
|
65
|
+
// previously cached page data is not reused. The fetcher receives
|
|
66
|
+
// [url, version] but only uses url — the version just busts the cache.
|
|
67
|
+
const { data } = useSWR([url, getReloadVersion()], ([fetchUrl]) => fetchPageConfig(fetchUrl), {
|
|
68
|
+
suspense: true,
|
|
69
|
+
});
|
|
24
70
|
return { data };
|
|
25
71
|
}
|
|
26
72
|
|