@lowdefy/server-dev 0.0.0-experimental-20260204101132 → 0.0.0-experimental-20260204101136

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/client/App.js CHANGED
@@ -30,7 +30,7 @@ import actions from '../../build/plugins/actions.js';
30
30
  import blocks from '../../build/plugins/blocks.js';
31
31
  import icons from '../../build/plugins/icons.js';
32
32
  import operators from '../../build/plugins/operators/client.js';
33
- import staticJsMap from '../../build/plugins/operators/clientJsMap.js';
33
+ import jsMap from '../../build/plugins/operators/clientJsMap.js';
34
34
 
35
35
  const App = ({ auth, lowdefy }) => {
36
36
  const router = useRouter();
@@ -50,7 +50,7 @@ const App = ({ auth, lowdefy }) => {
50
50
  config={{
51
51
  rootConfig,
52
52
  }}
53
- jsMap={staticJsMap}
53
+ jsMap={jsMap}
54
54
  lowdefy={lowdefy}
55
55
  pageId={pageId}
56
56
  resetContext={resetContext}
@@ -17,7 +17,6 @@
17
17
  import React from 'react';
18
18
  import Client from '@lowdefy/client';
19
19
 
20
- import BuildErrorPage from './BuildErrorPage.js';
21
20
  import RestartingPage from './RestartingPage.js';
22
21
  import usePageConfig from './utils/usePageConfig.js';
23
22
 
@@ -38,24 +37,9 @@ const Page = ({
38
37
  router.replace(`/404`);
39
38
  return '';
40
39
  }
41
- if (pageConfig.buildError) {
42
- return (
43
- <BuildErrorPage
44
- errors={pageConfig.errors}
45
- message={pageConfig.message}
46
- source={pageConfig.source}
47
- />
48
- );
49
- }
50
40
  if (resetContext.restarting) {
51
41
  return <RestartingPage />;
52
42
  }
53
-
54
- // Merge dynamic JS entries fetched after JIT build with the static jsMap
55
- const mergedJsMap = pageConfig._jsEntries
56
- ? { ...jsMap, ...pageConfig._jsEntries }
57
- : jsMap;
58
-
59
43
  return (
60
44
  <Client
61
45
  auth={auth}
@@ -64,7 +48,7 @@ const Page = ({
64
48
  ...config,
65
49
  pageConfig,
66
50
  }}
67
- jsMap={mergedJsMap}
51
+ jsMap={jsMap}
68
52
  lowdefy={lowdefy}
69
53
  resetContext={resetContext}
70
54
  router={router}
@@ -16,23 +16,10 @@
16
16
 
17
17
  import { useSWRConfig } from 'swr';
18
18
 
19
- let reloadVersion = 0;
20
-
21
- function getReloadVersion() {
22
- return reloadVersion;
23
- }
24
-
25
19
  function useMutateCache(basePath) {
26
20
  const { mutate } = useSWRConfig();
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
- };
21
+ return () =>
22
+ mutate((key) => key.startsWith(`${basePath}/api/page`) || key === `${basePath}/api/root`);
35
23
  }
36
24
 
37
- export { getReloadVersion };
38
25
  export default useMutateCache;
@@ -13,59 +13,14 @@
13
13
 
14
14
  import useSWR from 'swr';
15
15
 
16
- import { getReloadVersion } from './useMutateCache.js';
16
+ import request from './request.js';
17
17
 
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 (!res.ok) {
47
- throw new Error(data.message || 'Request error');
48
- }
49
-
50
- // Fetch jsMap after page build completes (JIT build may have added new entries).
51
- // Extract basePath from the URL to construct the jsMap endpoint.
52
- const basePath = url.replace(/\/api\/page\/.*$/, '');
53
- const jsEntries = await fetchJsEntries(basePath);
54
- data._jsEntries = jsEntries;
55
-
56
- return data;
18
+ function fetchPageConfig(url) {
19
+ return request({ url });
57
20
  }
58
21
 
59
22
  function usePageConfig(pageId, basePath) {
60
- const url = `${basePath}/api/page/${pageId}`;
61
- // Include reloadVersion in the SWR key so that after a config reload,
62
- // previously cached page data is not reused. The fetcher receives
63
- // [url, version] but only uses url — the version just busts the cache.
64
- const { data } = useSWR(
65
- [url, getReloadVersion()],
66
- ([fetchUrl]) => fetchPageConfig(fetchUrl),
67
- { suspense: true }
68
- );
23
+ const { data } = useSWR(`${basePath}/api/page/${pageId}`, fetchPageConfig, { suspense: true });
69
24
  return { data };
70
25
  }
71
26
 
@@ -13,7 +13,6 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */
16
- import fs from 'fs';
17
16
  import path from 'path';
18
17
  import { createApiContext } from '@lowdefy/api';
19
18
  import { getSecretsFromEnv } from '@lowdefy/node-utils';
@@ -27,7 +26,7 @@ import getServerSession from './auth/getServerSession.js';
27
26
  import logError from './log/logError.js';
28
27
  import logRequest from './log/logRequest.js';
29
28
  import operators from '../../build/plugins/operators/server.js';
30
- import staticJsMap from '../../build/plugins/operators/serverJsMap.js';
29
+ import jsMap from '../../build/plugins/operators/serverJsMap.js';
31
30
  import getAuthOptions from './auth/getAuthOptions.js';
32
31
  import setSentryUser from './sentry/setSentryUser.js';
33
32
 
@@ -40,39 +39,12 @@ try {
40
39
 
41
40
  const secrets = getSecretsFromEnv();
42
41
 
43
- // Dynamic JS map loading for JIT-built pages
44
- let cachedJsMapMtime = null;
45
- let cachedJsMap = staticJsMap;
46
-
47
- function loadDynamicJsMap(buildDirectory) {
48
- const jsMapPath = path.join(buildDirectory, 'plugins', 'operators', 'serverJsMap.js');
49
- try {
50
- const stat = fs.statSync(jsMapPath);
51
- if (cachedJsMapMtime && stat.mtimeMs === cachedJsMapMtime) {
52
- return cachedJsMap;
53
- }
54
- cachedJsMapMtime = stat.mtimeMs;
55
- // For server-side, we can read and eval the JS file
56
- const content = fs.readFileSync(jsMapPath, 'utf8');
57
- const fn = new Function('exports', content.replace('export default', 'exports.default ='));
58
- const exports = {};
59
- fn(exports);
60
- cachedJsMap = { ...staticJsMap, ...(exports.default ?? {}) };
61
- return cachedJsMap;
62
- } catch {
63
- return cachedJsMap;
64
- }
65
- }
66
-
67
42
  function apiWrapper(handler) {
68
43
  return async function wrappedHandler(req, res) {
69
- const buildDirectory = path.join(process.cwd(), 'build');
70
- const jsMap = loadDynamicJsMap(buildDirectory);
71
-
72
44
  const context = {
73
45
  // Important to give absolute path so Next can trace build files
74
46
  rid: uuid(),
75
- buildDirectory,
47
+ buildDirectory: path.join(process.cwd(), 'build'),
76
48
  configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
77
49
  config,
78
50
  connections,
@@ -32,7 +32,6 @@ import shutdownServer from './processes/shutdownServer.mjs';
32
32
  import startWatchers from './processes/startWatchers.mjs';
33
33
 
34
34
  import getNextBin from './utils/getNextBin.mjs';
35
- import PageCache from '../lib/server/pageCache.mjs';
36
35
 
37
36
  const argv = yargs(hideBin(process.argv)).array('watch').array('watchIgnore').argv;
38
37
 
@@ -60,30 +59,13 @@ async function getContext() {
60
59
  : [],
61
60
  },
62
61
  version: env.npm_package_version,
63
-
64
- // JIT build state
65
- pageCache: new PageCache(),
66
- pageRegistry: null,
67
- fileDependencyMap: null,
68
- buildContext: null,
69
62
  };
70
63
 
71
64
  context.packageManagerCmd = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
72
65
  context.checkMockUserWarning = checkMockUserWarning(context);
73
66
  context.initialBuild = initialBuild(context);
74
67
  context.installPlugins = installPlugins(context);
75
-
76
- // Wrap lowdefyBuild to capture and store the shallow build result
77
- const buildFn = lowdefyBuild(context);
78
- context.lowdefyBuild = async () => {
79
- const result = await buildFn();
80
- if (result) {
81
- context.pageRegistry = result.pageRegistry;
82
- context.fileDependencyMap = result.fileDependencyMap;
83
- context.buildContext = result.context;
84
- }
85
- };
86
-
68
+ context.lowdefyBuild = lowdefyBuild(context);
87
69
  context.nextBuild = nextBuild(context);
88
70
  context.readDotEnv = readDotEnv(context);
89
71
  context.reloadClients = reloadClients(context);
@@ -14,35 +14,21 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import { shallowBuild } from '@lowdefy/build/dev';
17
+ import build from '@lowdefy/build';
18
18
  import createCustomPluginTypesMap from '../utils/createCustomPluginTypesMap.mjs';
19
19
 
20
- function lowdefyBuild({ directories, logger, options, pageCache }) {
20
+ function lowdefyBuild({ directories, logger, options }) {
21
21
  return async () => {
22
22
  logger.ui.spin('Building config...');
23
23
  const customTypesMap = await createCustomPluginTypesMap({ directories, logger });
24
-
25
- if (pageCache) {
26
- await pageCache.acquireSkeletonLock();
27
- }
28
- try {
29
- const result = await shallowBuild({
30
- customTypesMap,
31
- directories,
32
- logger,
33
- refResolver: options.refResolver,
34
- stage: 'dev',
35
- });
36
-
37
- // Return result so getContext can store registries
38
- logger.ui.log('Built config.');
39
- return result;
40
- } finally {
41
- if (pageCache) {
42
- pageCache.invalidateAll();
43
- pageCache.releaseSkeletonLock();
44
- }
45
- }
24
+ await build({
25
+ customTypesMap,
26
+ directories,
27
+ logger,
28
+ refResolver: options.refResolver,
29
+ stage: 'dev',
30
+ });
31
+ logger.ui.log('Built config.');
46
32
  };
47
33
  }
48
34
 
@@ -19,26 +19,11 @@ import { spawnProcess } from '@lowdefy/node-utils';
19
19
  function nextBuild({ bin, logger }) {
20
20
  return async () => {
21
21
  logger.ui.spin('Building app...');
22
- const errorLines = [];
23
- try {
24
- await spawnProcess({
25
- command: 'node',
26
- args: [bin.next, 'build'],
27
- stdOutLineHandler: (line) => logger.debug(line),
28
- stdErrLineHandler: (line) => {
29
- logger.debug(line);
30
- errorLines.push(line);
31
- },
32
- });
33
- } catch (err) {
34
- if (errorLines.length > 0) {
35
- errorLines.forEach((line) => logger.error(line));
36
- }
37
- const error = new Error('Next.js build failed. See above for details.');
38
- error.isFormatted = true;
39
- error.hideStack = true;
40
- throw error;
41
- }
22
+ await spawnProcess({
23
+ command: 'node',
24
+ args: [bin.next, 'build'],
25
+ stdOutLineHandler: (line) => logger.debug(line),
26
+ });
42
27
  logger.ui.log('Built app.');
43
28
  };
44
29
  }
@@ -16,19 +16,6 @@
16
16
 
17
17
  import { spawn } from 'child_process';
18
18
 
19
- function createStdErrLineHandler({ context }) {
20
- const port = context.options.port;
21
- return function stdErrLineHandler(line) {
22
- if (line.includes('EADDRINUSE')) {
23
- context.logger.error(
24
- `Port ${port} is already in use. Stop the other process or use a different port with --port.`
25
- );
26
- return;
27
- }
28
- context.logger.error(line);
29
- };
30
- }
31
-
32
19
  function startServer(context) {
33
20
  context.shutdownServer();
34
21
 
@@ -41,13 +28,12 @@ function startServer(context) {
41
28
  },
42
29
  });
43
30
 
44
- const stdErrLineHandler = createStdErrLineHandler({ context });
45
31
  nextServer.stderr.on('data', (data) => {
46
32
  data
47
33
  .toString('utf8')
48
34
  .split('\n')
49
35
  .forEach((line) => {
50
- if (line) stdErrLineHandler(line);
36
+ if (line) context.logger.error(line);
51
37
  });
52
38
  });
53
39
 
package/manager/run.mjs CHANGED
@@ -19,7 +19,6 @@ import { wait } from '@lowdefy/helpers';
19
19
  import opener from 'opener';
20
20
  import getContext from './getContext.mjs';
21
21
  import startServer from './processes/startServer.mjs';
22
- import checkPortAvailable from './utils/checkPortAvailable.mjs';
23
22
 
24
23
  /*
25
24
  The run script does the following:
@@ -86,7 +85,6 @@ try {
86
85
  // because chokidar sometimes doesn't fire this event, and it seems like there isn't an issue with not waiting.
87
86
  context.startWatchers();
88
87
 
89
- await checkPortAvailable(context.options.port);
90
88
  startServer(context);
91
89
  await wait(800);
92
90
  if (process.env.LOWDEFY_SERVER_DEV_OPEN_BROWSER === 'true') {
@@ -95,7 +93,13 @@ try {
95
93
  }
96
94
  await new Promise(() => {});
97
95
  } catch (error) {
98
- context.logger.error(error);
96
+ // If error is already formatted (from error collection), just show the message
97
+ if (error.isFormatted || error.hideStack) {
98
+ context.logger.error(error.message);
99
+ } else {
100
+ // Otherwise, show full error with stack trace
101
+ context.logger.error(error);
102
+ }
99
103
  context.shutdownServer();
100
104
  process.exit();
101
105
  }
@@ -14,7 +14,6 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import fs from 'fs';
18
17
  import path from 'path';
19
18
  import getLowdefyVersion from '../utils/getLowdefyVersion.mjs';
20
19
  import setupWatcher from '../utils/setupWatcher.mjs';
@@ -24,13 +23,9 @@ function lowdefyBuildWatcher(context) {
24
23
  path.isAbsolute(item) ? item : path.resolve(context.directories.config, item);
25
24
 
26
25
  const callback = async (filePaths) => {
27
- const changedFiles = filePaths
26
+ const lowdefyYamlModified = filePaths
28
27
  .flat()
29
- .map((filePath) => path.relative(context.directories.config, filePath));
30
-
31
- const lowdefyYamlModified = changedFiles.some(
32
- (filePath) => filePath === 'lowdefy.yaml' || filePath === 'lowdefy.yml'
33
- );
28
+ .some((filePath) => filePath.includes('lowdefy.yaml') || filePath.includes('lowdefy.yml'));
34
29
  if (lowdefyYamlModified) {
35
30
  const lowdefyVersion = await getLowdefyVersion(context);
36
31
  if (lowdefyVersion !== context.version && lowdefyVersion !== 'local') {
@@ -41,41 +36,17 @@ function lowdefyBuildWatcher(context) {
41
36
  }
42
37
 
43
38
  try {
44
- // Check if only page-level files changed (targeted invalidation)
45
- const isSkeletonChange =
46
- lowdefyYamlModified ||
47
- changedFiles.some(
48
- (f) =>
49
- !context.fileDependencyMap?.has(f) &&
50
- !f.startsWith('pages/') &&
51
- !f.startsWith('./')
52
- );
53
-
54
- if (isSkeletonChange || !context.pageCache) {
55
- // Full skeleton rebuild
56
- await context.lowdefyBuild();
57
- } else {
58
- // Targeted invalidation: only clear affected pages
59
- const affectedPages = context.pageCache.invalidateByFiles(
60
- changedFiles,
61
- context.fileDependencyMap
62
- );
63
- if (affectedPages.size > 0) {
64
- // Write invalidated page IDs to a file so the Next.js server process
65
- // (which has its own PageCache) knows which pages to rebuild.
66
- const invalidationPath = path.join(context.directories.build, 'invalidatePages.json');
67
- fs.writeFileSync(invalidationPath, JSON.stringify([...affectedPages]));
68
- context.logger.ui.log(
69
- `Invalidated ${affectedPages.size} page(s): ${[...affectedPages].join(', ')}`
70
- );
71
- } else {
72
- // Unknown file changed - do full rebuild to be safe
73
- await context.lowdefyBuild();
74
- }
75
- }
39
+ await context.lowdefyBuild();
76
40
  context.reloadClients();
77
41
  } catch (error) {
78
- context.logger.error(error);
42
+ // If error is already formatted (from error collection), just show the message
43
+ if (error.isFormatted || error.hideStack) {
44
+ context.logger.error(error.message);
45
+ } else {
46
+ // Otherwise, show full error with stack trace
47
+ context.logger.error(error);
48
+ }
49
+ // Don't crash the watcher - keep it running so user can fix errors and rebuild
79
50
  }
80
51
  };
81
52
  return setupWatcher({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "0.0.0-experimental-20260204101132",
3
+ "version": "0.0.0-experimental-20260204101136",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,36 +36,36 @@
36
36
  ".npmrc"
37
37
  ],
38
38
  "dependencies": {
39
- "@lowdefy/actions-core": "0.0.0-experimental-20260204101132",
40
- "@lowdefy/api": "0.0.0-experimental-20260204101132",
41
- "@lowdefy/block-utils": "0.0.0-experimental-20260204101132",
42
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260204101132",
43
- "@lowdefy/blocks-antd": "0.0.0-experimental-20260204101132",
44
- "@lowdefy/blocks-basic": "0.0.0-experimental-20260204101132",
45
- "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260204101132",
46
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20260204101132",
47
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20260204101132",
48
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20260204101132",
49
- "@lowdefy/blocks-qr": "0.0.0-experimental-20260204101132",
50
- "@lowdefy/build": "0.0.0-experimental-20260204101132",
51
- "@lowdefy/client": "0.0.0-experimental-20260204101132",
52
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20260204101132",
53
- "@lowdefy/connection-test": "0.0.0-experimental-20260204101132",
54
- "@lowdefy/engine": "0.0.0-experimental-20260204101132",
55
- "@lowdefy/errors": "0.0.0-experimental-20260204101132",
56
- "@lowdefy/helpers": "0.0.0-experimental-20260204101132",
57
- "@lowdefy/layout": "0.0.0-experimental-20260204101132",
58
- "@lowdefy/logger": "0.0.0-experimental-20260204101132",
59
- "@lowdefy/node-utils": "0.0.0-experimental-20260204101132",
60
- "@lowdefy/operators-change-case": "0.0.0-experimental-20260204101132",
61
- "@lowdefy/operators-diff": "0.0.0-experimental-20260204101132",
62
- "@lowdefy/operators-js": "0.0.0-experimental-20260204101132",
63
- "@lowdefy/operators-moment": "0.0.0-experimental-20260204101132",
64
- "@lowdefy/operators-mql": "0.0.0-experimental-20260204101132",
65
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260204101132",
66
- "@lowdefy/operators-uuid": "0.0.0-experimental-20260204101132",
67
- "@lowdefy/operators-yaml": "0.0.0-experimental-20260204101132",
68
- "@lowdefy/plugin-next-auth": "0.0.0-experimental-20260204101132",
39
+ "@lowdefy/actions-core": "0.0.0-experimental-20260204101136",
40
+ "@lowdefy/api": "0.0.0-experimental-20260204101136",
41
+ "@lowdefy/block-utils": "0.0.0-experimental-20260204101136",
42
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260204101136",
43
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20260204101136",
44
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20260204101136",
45
+ "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260204101136",
46
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20260204101136",
47
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20260204101136",
48
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20260204101136",
49
+ "@lowdefy/blocks-qr": "0.0.0-experimental-20260204101136",
50
+ "@lowdefy/build": "0.0.0-experimental-20260204101136",
51
+ "@lowdefy/client": "0.0.0-experimental-20260204101136",
52
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20260204101136",
53
+ "@lowdefy/connection-test": "0.0.0-experimental-20260204101136",
54
+ "@lowdefy/engine": "0.0.0-experimental-20260204101136",
55
+ "@lowdefy/errors": "0.0.0-experimental-20260204101136",
56
+ "@lowdefy/helpers": "0.0.0-experimental-20260204101136",
57
+ "@lowdefy/layout": "0.0.0-experimental-20260204101136",
58
+ "@lowdefy/logger": "0.0.0-experimental-20260204101136",
59
+ "@lowdefy/node-utils": "0.0.0-experimental-20260204101136",
60
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20260204101136",
61
+ "@lowdefy/operators-diff": "0.0.0-experimental-20260204101136",
62
+ "@lowdefy/operators-js": "0.0.0-experimental-20260204101136",
63
+ "@lowdefy/operators-moment": "0.0.0-experimental-20260204101136",
64
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260204101136",
65
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260204101136",
66
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20260204101136",
67
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20260204101136",
68
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20260204101136",
69
69
  "@sentry/nextjs": "8.53.0",
70
70
  "chokidar": "3.5.3",
71
71
  "dotenv": "16.3.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "0.0.0-experimental-20260204101132",
3
+ "version": "0.0.0-experimental-20260204101136",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,36 +43,36 @@
43
43
  "prepublishOnly": "pnpm build"
44
44
  },
45
45
  "dependencies": {
46
- "@lowdefy/actions-core": "0.0.0-experimental-20260204101132",
47
- "@lowdefy/api": "0.0.0-experimental-20260204101132",
48
- "@lowdefy/block-utils": "0.0.0-experimental-20260204101132",
49
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260204101132",
50
- "@lowdefy/blocks-antd": "0.0.0-experimental-20260204101132",
51
- "@lowdefy/blocks-basic": "0.0.0-experimental-20260204101132",
52
- "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260204101132",
53
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20260204101132",
54
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20260204101132",
55
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20260204101132",
56
- "@lowdefy/blocks-qr": "0.0.0-experimental-20260204101132",
57
- "@lowdefy/build": "0.0.0-experimental-20260204101132",
58
- "@lowdefy/client": "0.0.0-experimental-20260204101132",
59
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20260204101132",
60
- "@lowdefy/connection-test": "0.0.0-experimental-20260204101132",
61
- "@lowdefy/engine": "0.0.0-experimental-20260204101132",
62
- "@lowdefy/errors": "0.0.0-experimental-20260204101132",
63
- "@lowdefy/helpers": "0.0.0-experimental-20260204101132",
64
- "@lowdefy/layout": "0.0.0-experimental-20260204101132",
65
- "@lowdefy/logger": "0.0.0-experimental-20260204101132",
66
- "@lowdefy/node-utils": "0.0.0-experimental-20260204101132",
67
- "@lowdefy/operators-change-case": "0.0.0-experimental-20260204101132",
68
- "@lowdefy/operators-diff": "0.0.0-experimental-20260204101132",
69
- "@lowdefy/operators-js": "0.0.0-experimental-20260204101132",
70
- "@lowdefy/operators-moment": "0.0.0-experimental-20260204101132",
71
- "@lowdefy/operators-mql": "0.0.0-experimental-20260204101132",
72
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260204101132",
73
- "@lowdefy/operators-uuid": "0.0.0-experimental-20260204101132",
74
- "@lowdefy/operators-yaml": "0.0.0-experimental-20260204101132",
75
- "@lowdefy/plugin-next-auth": "0.0.0-experimental-20260204101132",
46
+ "@lowdefy/actions-core": "0.0.0-experimental-20260204101136",
47
+ "@lowdefy/api": "0.0.0-experimental-20260204101136",
48
+ "@lowdefy/block-utils": "0.0.0-experimental-20260204101136",
49
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260204101136",
50
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20260204101136",
51
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20260204101136",
52
+ "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260204101136",
53
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20260204101136",
54
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20260204101136",
55
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20260204101136",
56
+ "@lowdefy/blocks-qr": "0.0.0-experimental-20260204101136",
57
+ "@lowdefy/build": "0.0.0-experimental-20260204101136",
58
+ "@lowdefy/client": "0.0.0-experimental-20260204101136",
59
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20260204101136",
60
+ "@lowdefy/connection-test": "0.0.0-experimental-20260204101136",
61
+ "@lowdefy/engine": "0.0.0-experimental-20260204101136",
62
+ "@lowdefy/errors": "0.0.0-experimental-20260204101136",
63
+ "@lowdefy/helpers": "0.0.0-experimental-20260204101136",
64
+ "@lowdefy/layout": "0.0.0-experimental-20260204101136",
65
+ "@lowdefy/logger": "0.0.0-experimental-20260204101136",
66
+ "@lowdefy/node-utils": "0.0.0-experimental-20260204101136",
67
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20260204101136",
68
+ "@lowdefy/operators-diff": "0.0.0-experimental-20260204101136",
69
+ "@lowdefy/operators-js": "0.0.0-experimental-20260204101136",
70
+ "@lowdefy/operators-moment": "0.0.0-experimental-20260204101136",
71
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260204101136",
72
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260204101136",
73
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20260204101136",
74
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20260204101136",
75
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20260204101136",
76
76
  "@sentry/nextjs": "8.53.0",
77
77
  "chokidar": "3.5.3",
78
78
  "dotenv": "16.3.1",
@@ -17,41 +17,11 @@
17
17
  import { getPageConfig } from '@lowdefy/api';
18
18
 
19
19
  import apiWrapper from '../../../lib/server/apiWrapper.js';
20
- import buildPageIfNeeded from '../../../lib/server/jitPageBuilder.js';
21
- import logError from '../../../lib/server/log/logError.js';
22
20
 
23
21
  async function handler({ context, req, res }) {
24
22
  const { pageId } = req.query;
25
-
26
- // Attempt JIT build if page not yet compiled
27
- try {
28
- await buildPageIfNeeded({
29
- pageId,
30
- buildDirectory: context.buildDirectory,
31
- configDirectory: context.configDirectory,
32
- });
33
- } catch (error) {
34
- const rawErrors = error.buildErrors ?? [error];
35
- const errors = [];
36
- for (const err of rawErrors) {
37
- await logError({ context, error: err });
38
- errors.push({
39
- type: err.name ?? 'Error',
40
- message: err.message,
41
- source: err.source ?? null,
42
- });
43
- }
44
- res.status(500).json({
45
- buildError: true,
46
- errors,
47
- // Keep top-level message/source for backward compatibility
48
- message: error.message,
49
- source: error.source ?? null,
50
- });
51
- return;
52
- }
53
-
54
23
  const pageConfig = await getPageConfig(context, { pageId });
24
+ // TODO: Do we log here?
55
25
  if (pageConfig === null) {
56
26
  res.status(404).send('Page not found.');
57
27
  } else {
@@ -1,99 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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
- LowdefyError: '#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' }}>{message}</p>
53
- {source && (
54
- <p style={{ fontSize: 13, color: '#8c8c8c', margin: 0 }}>{source}</p>
55
- )}
56
- </div>
57
- );
58
- };
59
-
60
- const BuildErrorPage = ({ errors, message, source }) => {
61
- // Support both new errors array and legacy single message/source props
62
- const errorList = errors ?? (message ? [{ type: 'Error', message, source }] : []);
63
-
64
- return (
65
- <div
66
- style={{
67
- height: '100vh',
68
- display: 'flex',
69
- flexDirection: 'column',
70
- alignItems: 'center',
71
- justifyContent: 'center',
72
- fontFamily: 'monospace',
73
- padding: '0 24px',
74
- }}
75
- >
76
- <div style={{ maxWidth: 720, width: '100%' }}>
77
- <h2 style={{ color: '#cf1322', marginBottom: 16 }}>
78
- {errorList.length > 1
79
- ? `Build Errors (${errorList.length})`
80
- : 'Build Error'}
81
- </h2>
82
- {errorList.map((err, i) => (
83
- <ErrorItem
84
- key={i}
85
- type={err.type}
86
- message={err.message}
87
- source={err.source}
88
- />
89
- ))}
90
- <p style={{ fontSize: 13, color: '#8c8c8c', marginTop: 24 }}>
91
- Fix the error{errorList.length > 1 ? 's' : ''} in your config and the page will rebuild
92
- automatically.
93
- </p>
94
- </div>
95
- </div>
96
- );
97
- };
98
-
99
- export default BuildErrorPage;
@@ -1,143 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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 fs from 'fs';
18
- import path from 'path';
19
- import { serializer } from '@lowdefy/helpers';
20
- import { buildPageJit, createContext } from '@lowdefy/build/dev';
21
-
22
- import createLogger from './log/createLogger.js';
23
- import PageCache from './pageCache.mjs';
24
-
25
- const jitLogger = createLogger({ component: 'jit-build' });
26
-
27
- const pageCache = new PageCache();
28
- let cachedRegistryMtime = null;
29
- let cachedRegistry = null;
30
- let cachedBuildContext = null;
31
- let lastInvalidationMtime = null;
32
-
33
- function readJsonFile(filePath) {
34
- try {
35
- const content = fs.readFileSync(filePath, 'utf8');
36
- return serializer.deserialize(JSON.parse(content));
37
- } catch {
38
- return null;
39
- }
40
- }
41
-
42
- function checkPageInvalidations(buildDirectory) {
43
- const invalidationPath = path.join(buildDirectory, 'invalidatePages.json');
44
- try {
45
- const stat = fs.statSync(invalidationPath);
46
- if (lastInvalidationMtime && stat.mtimeMs === lastInvalidationMtime) {
47
- return;
48
- }
49
- lastInvalidationMtime = stat.mtimeMs;
50
- const content = fs.readFileSync(invalidationPath, 'utf8');
51
- const pageIds = JSON.parse(content);
52
- if (Array.isArray(pageIds) && pageIds.length > 0) {
53
- pageCache.invalidatePages(pageIds);
54
- cachedBuildContext = null;
55
- }
56
- } catch {
57
- // File doesn't exist yet or read error — nothing to invalidate
58
- }
59
- }
60
-
61
- function loadPageRegistry(buildDirectory) {
62
- const registryPath = path.join(buildDirectory, 'pageRegistry.json');
63
- try {
64
- const stat = fs.statSync(registryPath);
65
- // Only reload if file has changed
66
- if (cachedRegistryMtime && stat.mtimeMs === cachedRegistryMtime) {
67
- return cachedRegistry;
68
- }
69
- cachedRegistryMtime = stat.mtimeMs;
70
- cachedRegistry = readJsonFile(registryPath);
71
- // Invalidate all pages when registry changes (skeleton rebuild happened)
72
- pageCache.invalidateAll();
73
- cachedBuildContext = null;
74
- return cachedRegistry;
75
- } catch {
76
- return null;
77
- }
78
- }
79
-
80
- function getBuildContext(buildDirectory, configDirectory) {
81
- if (cachedBuildContext) return cachedBuildContext;
82
-
83
- const refMap = readJsonFile(path.join(buildDirectory, 'refMap.json')) ?? {};
84
- const keyMap = readJsonFile(path.join(buildDirectory, 'keyMap.json')) ?? {};
85
- const jsMap = readJsonFile(path.join(buildDirectory, 'jsMap.json')) ?? { client: {}, server: {} };
86
- const connectionIds = readJsonFile(path.join(buildDirectory, 'connectionIds.json')) ?? [];
87
-
88
- cachedBuildContext = createContext({
89
- directories: {
90
- build: buildDirectory,
91
- config: configDirectory,
92
- },
93
- logger: jitLogger,
94
- stage: 'dev',
95
- });
96
-
97
- // Restore refMap, keyMap, jsMap, and connectionIds from skeleton build
98
- Object.assign(cachedBuildContext.refMap, refMap);
99
- Object.assign(cachedBuildContext.keyMap, keyMap);
100
- cachedBuildContext.jsMap.client = jsMap.client ?? {};
101
- cachedBuildContext.jsMap.server = jsMap.server ?? {};
102
- for (const id of connectionIds) {
103
- cachedBuildContext.connectionIds.add(id);
104
- }
105
-
106
- return cachedBuildContext;
107
- }
108
-
109
- async function buildPageIfNeeded({ pageId, buildDirectory, configDirectory }) {
110
- checkPageInvalidations(buildDirectory);
111
- const registry = loadPageRegistry(buildDirectory);
112
- if (!registry || !registry[pageId]) {
113
- return false;
114
- }
115
-
116
- if (pageCache.isCompiled(pageId)) {
117
- return true;
118
- }
119
-
120
- const shouldBuild = await pageCache.acquireBuildLock(pageId);
121
- if (!shouldBuild) {
122
- // Another request completed the build
123
- return true;
124
- }
125
-
126
- try {
127
- const context = getBuildContext(buildDirectory, configDirectory);
128
- const startTime = Date.now();
129
- await buildPageJit({
130
- pageId,
131
- pageRegistry: registry,
132
- context,
133
- });
134
- pageCache.markCompiled(pageId);
135
- jitLogger.info(`Built page "${pageId}" in ${Date.now() - startTime}ms.`);
136
- return true;
137
- } finally {
138
- pageCache.releaseBuildLock(pageId);
139
- }
140
- }
141
-
142
- export default buildPageIfNeeded;
143
- export { pageCache };
@@ -1,104 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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
- class PageCache {
18
- constructor() {
19
- this.compiledPages = new Set();
20
- this.buildLocks = new Map();
21
- this.skeletonLock = null;
22
- }
23
-
24
- isCompiled(pageId) {
25
- return this.compiledPages.has(pageId);
26
- }
27
-
28
- markCompiled(pageId) {
29
- this.compiledPages.add(pageId);
30
- }
31
-
32
- async acquireBuildLock(pageId) {
33
- // Wait for any skeleton rebuild first
34
- if (this.skeletonLock) {
35
- await this.skeletonLock;
36
- }
37
-
38
- // If page build already in progress, wait for it
39
- if (this.buildLocks.has(pageId)) {
40
- await this.buildLocks.get(pageId);
41
- return false;
42
- }
43
-
44
- // Create new lock
45
- let resolve;
46
- const promise = new Promise((r) => {
47
- resolve = r;
48
- });
49
- promise.resolve = resolve;
50
- this.buildLocks.set(pageId, promise);
51
- return true;
52
- }
53
-
54
- releaseBuildLock(pageId) {
55
- const lock = this.buildLocks.get(pageId);
56
- if (lock) {
57
- lock.resolve();
58
- this.buildLocks.delete(pageId);
59
- }
60
- }
61
-
62
- async acquireSkeletonLock() {
63
- // Wait for all in-progress page builds to complete
64
- await Promise.all(this.buildLocks.values());
65
- let resolve;
66
- this.skeletonLock = new Promise((r) => {
67
- resolve = r;
68
- });
69
- this.skeletonLock.resolve = resolve;
70
- }
71
-
72
- releaseSkeletonLock() {
73
- if (this.skeletonLock) {
74
- this.skeletonLock.resolve();
75
- this.skeletonLock = null;
76
- }
77
- }
78
-
79
- invalidateAll() {
80
- this.compiledPages.clear();
81
- }
82
-
83
- invalidatePages(pageIds) {
84
- for (const pageId of pageIds) {
85
- this.compiledPages.delete(pageId);
86
- }
87
- }
88
-
89
- invalidateByFiles(changedFiles, fileDependencyMap) {
90
- const affectedPages = new Set();
91
- for (const filePath of changedFiles) {
92
- const pageIds = fileDependencyMap.get(filePath);
93
- if (pageIds) {
94
- for (const pageId of pageIds) {
95
- affectedPages.add(pageId);
96
- }
97
- }
98
- }
99
- this.invalidatePages(affectedPages);
100
- return affectedPages;
101
- }
102
- }
103
-
104
- export default PageCache;
@@ -1,182 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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 PageCache from './pageCache.mjs';
18
-
19
- test('isCompiled returns false for uncompiled page', () => {
20
- const cache = new PageCache();
21
- expect(cache.isCompiled('home')).toBe(false);
22
- });
23
-
24
- test('isCompiled returns true after markCompiled', () => {
25
- const cache = new PageCache();
26
- cache.markCompiled('home');
27
- expect(cache.isCompiled('home')).toBe(true);
28
- });
29
-
30
- test('invalidateAll clears all compiled pages', () => {
31
- const cache = new PageCache();
32
- cache.markCompiled('home');
33
- cache.markCompiled('dashboard');
34
- cache.invalidateAll();
35
- expect(cache.isCompiled('home')).toBe(false);
36
- expect(cache.isCompiled('dashboard')).toBe(false);
37
- });
38
-
39
- test('invalidatePages removes specific pages', () => {
40
- const cache = new PageCache();
41
- cache.markCompiled('home');
42
- cache.markCompiled('dashboard');
43
- cache.markCompiled('settings');
44
- cache.invalidatePages(['home', 'settings']);
45
- expect(cache.isCompiled('home')).toBe(false);
46
- expect(cache.isCompiled('dashboard')).toBe(true);
47
- expect(cache.isCompiled('settings')).toBe(false);
48
- });
49
-
50
- test('invalidateByFiles returns affected pages and invalidates them', () => {
51
- const cache = new PageCache();
52
- cache.markCompiled('home');
53
- cache.markCompiled('dashboard');
54
-
55
- const fileDependencyMap = new Map([
56
- ['pages/home/blocks.yaml', new Set(['home'])],
57
- ['shared/layout.yaml', new Set(['home', 'dashboard'])],
58
- ]);
59
-
60
- const affected = cache.invalidateByFiles(['pages/home/blocks.yaml'], fileDependencyMap);
61
- expect(affected).toEqual(new Set(['home']));
62
- expect(cache.isCompiled('home')).toBe(false);
63
- expect(cache.isCompiled('dashboard')).toBe(true);
64
- });
65
-
66
- test('invalidateByFiles handles shared files affecting multiple pages', () => {
67
- const cache = new PageCache();
68
- cache.markCompiled('home');
69
- cache.markCompiled('dashboard');
70
-
71
- const fileDependencyMap = new Map([
72
- ['shared/layout.yaml', new Set(['home', 'dashboard'])],
73
- ]);
74
-
75
- const affected = cache.invalidateByFiles(['shared/layout.yaml'], fileDependencyMap);
76
- expect(affected).toEqual(new Set(['home', 'dashboard']));
77
- expect(cache.isCompiled('home')).toBe(false);
78
- expect(cache.isCompiled('dashboard')).toBe(false);
79
- });
80
-
81
- test('invalidateByFiles returns empty set for unknown files', () => {
82
- const cache = new PageCache();
83
- cache.markCompiled('home');
84
-
85
- const fileDependencyMap = new Map();
86
- const affected = cache.invalidateByFiles(['unknown.yaml'], fileDependencyMap);
87
- expect(affected).toEqual(new Set());
88
- expect(cache.isCompiled('home')).toBe(true);
89
- });
90
-
91
- test('acquireBuildLock returns true for first request', async () => {
92
- const cache = new PageCache();
93
- const shouldBuild = await cache.acquireBuildLock('home');
94
- expect(shouldBuild).toBe(true);
95
- cache.releaseBuildLock('home');
96
- });
97
-
98
- test('acquireBuildLock returns false for concurrent request (waits for first)', async () => {
99
- const cache = new PageCache();
100
-
101
- // First request acquires lock
102
- const shouldBuild1 = await cache.acquireBuildLock('home');
103
- expect(shouldBuild1).toBe(true);
104
-
105
- // Second request waits for lock and returns false
106
- const promise2 = cache.acquireBuildLock('home');
107
-
108
- // Release first lock
109
- cache.releaseBuildLock('home');
110
-
111
- const shouldBuild2 = await promise2;
112
- expect(shouldBuild2).toBe(false);
113
- });
114
-
115
- test('acquireBuildLock for different pages does not block', async () => {
116
- const cache = new PageCache();
117
-
118
- const shouldBuild1 = await cache.acquireBuildLock('home');
119
- const shouldBuild2 = await cache.acquireBuildLock('dashboard');
120
-
121
- expect(shouldBuild1).toBe(true);
122
- expect(shouldBuild2).toBe(true);
123
-
124
- cache.releaseBuildLock('home');
125
- cache.releaseBuildLock('dashboard');
126
- });
127
-
128
- test('releaseBuildLock does nothing for non-existent lock', () => {
129
- const cache = new PageCache();
130
- // Should not throw
131
- cache.releaseBuildLock('nonexistent');
132
- });
133
-
134
- test('acquireSkeletonLock waits for page builds', async () => {
135
- const cache = new PageCache();
136
- const buildOrder = [];
137
-
138
- // Start a page build
139
- await cache.acquireBuildLock('home');
140
-
141
- // Start skeleton lock acquisition (should wait)
142
- const skeletonPromise = cache.acquireSkeletonLock().then(() => {
143
- buildOrder.push('skeleton-acquired');
144
- });
145
-
146
- // Release page build
147
- buildOrder.push('page-released');
148
- cache.releaseBuildLock('home');
149
-
150
- await skeletonPromise;
151
- expect(buildOrder).toEqual(['page-released', 'skeleton-acquired']);
152
- cache.releaseSkeletonLock();
153
- });
154
-
155
- test('acquireBuildLock waits for skeleton lock', async () => {
156
- const cache = new PageCache();
157
- const buildOrder = [];
158
-
159
- // Acquire skeleton lock
160
- await cache.acquireSkeletonLock();
161
-
162
- // Start page build (should wait for skeleton)
163
- const pagePromise = cache.acquireBuildLock('home').then((result) => {
164
- buildOrder.push('page-acquired');
165
- return result;
166
- });
167
-
168
- // Release skeleton
169
- buildOrder.push('skeleton-released');
170
- cache.releaseSkeletonLock();
171
-
172
- const shouldBuild = await pagePromise;
173
- expect(shouldBuild).toBe(true);
174
- expect(buildOrder).toEqual(['skeleton-released', 'page-acquired']);
175
- cache.releaseBuildLock('home');
176
- });
177
-
178
- test('releaseSkeletonLock does nothing when no lock exists', () => {
179
- const cache = new PageCache();
180
- // Should not throw
181
- cache.releaseSkeletonLock();
182
- });
@@ -1,40 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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 net from 'net';
18
-
19
- function checkPortAvailable(port) {
20
- return new Promise((resolve, reject) => {
21
- const server = net.createServer();
22
- server.once('error', (err) => {
23
- if (err.code === 'EADDRINUSE') {
24
- const error = new Error(
25
- `Port ${port} is already in use. Stop the other process or use a different port with --port.`
26
- );
27
- error.isFormatted = true;
28
- reject(error);
29
- } else {
30
- reject(err);
31
- }
32
- });
33
- server.once('listening', () => {
34
- server.close(() => resolve());
35
- });
36
- server.listen(port);
37
- });
38
- }
39
-
40
- export default checkPortAvailable;
@@ -1,42 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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 fs from 'fs';
18
- import path from 'path';
19
-
20
- async function handler(req, res) {
21
- const { env } = req.query;
22
-
23
- if (env !== 'client' && env !== 'server') {
24
- res.status(400).send('Invalid env parameter. Use "client" or "server".');
25
- return;
26
- }
27
-
28
- const fileName = env === 'client' ? 'clientJsMap.js' : 'serverJsMap.js';
29
- const filePath = path.join(process.cwd(), 'build', 'plugins', 'operators', fileName);
30
-
31
- try {
32
- const content = fs.readFileSync(filePath, 'utf8');
33
- res.setHeader('Content-Type', 'application/javascript');
34
- res.status(200).send(content);
35
- } catch {
36
- // Return empty default export if file doesn't exist yet
37
- res.setHeader('Content-Type', 'application/javascript');
38
- res.status(200).send('export default {};');
39
- }
40
- }
41
-
42
- export default handler;