@whoz-oss/coday-web 0.0.0-workstream-forge.5 → 0.0.0-workstream-forge.9

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.
Files changed (2) hide show
  1. package/index.js +45 -25
  2. package/package.json +4 -3
package/index.js CHANGED
@@ -27,46 +27,56 @@ const require = createRequire(import.meta.url);
27
27
  * 2. Workspace protocol resolution (development)
28
28
  * 3. Relative path fallback (monorepo development)
29
29
  */
30
- function resolveClientPath() {
30
+ function resolveStaticPackagePath(packageName, developmentPath, displayName) {
31
+ const developmentBrowserPath = resolve(__dirname, developmentPath);
32
+
31
33
  try {
32
- // Try to resolve the client package using Node's module resolution
33
- const clientPackagePath = require.resolve('@whoz-oss/coday-client/package.json');
34
- const clientPath = dirname(clientPackagePath);
35
-
36
- // Check if browser directory exists
37
- const browserPath = resolve(clientPath, 'browser');
34
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
35
+ const packagePath = dirname(packageJsonPath);
36
+ const browserPath = resolve(packagePath, 'browser');
37
+
38
38
  if (existsSync(browserPath)) {
39
39
  return browserPath;
40
40
  }
41
-
42
- // Fallback: browser might be at package root for published package
43
- if (existsSync(resolve(clientPath, 'index.html'))) {
44
- return clientPath;
41
+
42
+ // Keep compatibility with packages exposing their browser build at the root.
43
+ if (existsSync(resolve(packagePath, 'index.html'))) {
44
+ return packagePath;
45
+ }
46
+
47
+ if (existsSync(developmentBrowserPath)) {
48
+ console.log(`Using development ${displayName.toLowerCase()} build from monorepo`);
49
+ return developmentBrowserPath;
45
50
  }
46
-
47
- console.error('Client package found but browser directory is missing.');
48
- console.error(`Checked paths: ${browserPath}, ${clientPath}`);
51
+
52
+ console.error(`${displayName} package found but browser directory is missing.`);
53
+ console.error(`Checked paths: ${browserPath}, ${packagePath}, ${developmentBrowserPath}`);
49
54
  process.exit(1);
50
55
  } catch (error) {
51
- // Fallback for monorepo development
52
- const devClientPath = resolve(__dirname, '../../client/dist/browser');
53
- if (existsSync(devClientPath)) {
54
- console.log('Using development client build from monorepo');
55
- return devClientPath;
56
+ if (existsSync(developmentBrowserPath)) {
57
+ console.log(`Using development ${displayName.toLowerCase()} build from monorepo`);
58
+ return developmentBrowserPath;
56
59
  }
57
-
58
- console.error('Could not resolve @whoz-oss/coday-client package.');
59
- console.error('Please ensure dependencies are installed: pnpm install');
60
+
61
+ console.error(`Could not resolve ${packageName} package.`);
62
+ console.error('Please ensure dependencies are installed and the application is built.');
60
63
  console.error('Error:', error.message);
61
64
  process.exit(1);
62
65
  }
63
66
  }
64
67
 
65
- // Resolve and set the client path
66
- const clientPath = resolveClientPath();
68
+ // Resolve and expose static application paths to the server.
69
+ const clientPath = resolveStaticPackagePath('@whoz-oss/coday-client', '../client/dist/browser', 'Client');
70
+ const factoryCockpitPath = resolveStaticPackagePath(
71
+ '@whoz-oss/coday-factory-cockpit',
72
+ '../factory-cockpit/dist/browser',
73
+ 'Factory cockpit'
74
+ );
67
75
  process.env.CODAY_CLIENT_PATH = clientPath;
76
+ process.env.CODAY_FACTORY_COCKPIT_PATH = factoryCockpitPath;
68
77
 
69
78
  console.log(`Coday Web: Using client files from ${clientPath}`);
79
+ console.log(`Coday Web: Using factory cockpit files from ${factoryCockpitPath}`);
70
80
 
71
81
  // Import and run the server
72
82
  // The server package exports its main module which starts the server
@@ -74,7 +84,17 @@ try {
74
84
  // Try to resolve the server package
75
85
  const serverPackagePath = require.resolve('@whoz-oss/coday-server/package.json');
76
86
  const serverDir = dirname(serverPackagePath);
77
- const serverMainPath = resolve(serverDir, 'server.js');
87
+ const packagedServerMainPath = resolve(serverDir, 'server.js');
88
+ const developmentServerMainPath = resolve(__dirname, '../server/dist/server.js');
89
+ const serverMainPath = existsSync(packagedServerMainPath)
90
+ ? packagedServerMainPath
91
+ : developmentServerMainPath;
92
+
93
+ if (!existsSync(serverMainPath)) {
94
+ throw new Error(
95
+ `Server entry point is missing. Checked paths: ${packagedServerMainPath}, ${developmentServerMainPath}`
96
+ );
97
+ }
78
98
 
79
99
  // Import the server module
80
100
  // Convert Windows absolute path to file:// URL for ESM import
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whoz-oss/coday-web",
3
- "version": "0.0.0-workstream-forge.5",
3
+ "version": "0.0.0-workstream-forge.9",
4
4
  "repository": "https://github.com/whoz-oss/coday",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,8 +11,9 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
- "@whoz-oss/coday-client": "0.0.0-workstream-forge.5",
15
- "@whoz-oss/coday-server": "0.0.0-workstream-forge.5"
14
+ "@whoz-oss/coday-client": "0.0.0-workstream-forge.9",
15
+ "@whoz-oss/coday-factory-cockpit": "3.28.0",
16
+ "@whoz-oss/coday-server": "0.0.0-workstream-forge.9"
16
17
  },
17
18
  "publishConfig": {
18
19
  "access": "public"