webssh2_client 0.2.31-alpha.0 → 0.2.31-alpha.2

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 (3) hide show
  1. package/client/index.js +11 -3
  2. package/index.js +19 -10
  3. package/package.json +1 -1
package/client/index.js CHANGED
@@ -1,8 +1,16 @@
1
1
  // client
2
2
  // client/index.js
3
- const path = require('path');
3
+ import path from 'path';
4
+ import { readFileSync } from 'fs';
5
+ import { fileURLToPath } from 'url';
4
6
 
5
- module.exports = {
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ // Read package.json synchronously for version
11
+ const packageJson = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
12
+
13
+ export default {
6
14
  getPublicPath: () => path.join(__dirname, 'public'),
7
- version: require('../package.json').version
15
+ version: packageJson.version
8
16
  };
package/index.js CHANGED
@@ -1,21 +1,29 @@
1
1
  // client
2
2
  // index.js
3
3
 
4
- if (require.main === module) {
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ // Check if this file is being run directly
11
+ const isMainModule = import.meta.url === `file://${process.argv[1]}`;
12
+
13
+ if (isMainModule) {
5
14
  // Run the development server
6
- const path = require("path");
7
- const express = require("express");
8
- const app = express();
15
+ const express = await import("express");
16
+ const app = express.default();
9
17
 
10
18
  // Security headers middleware
11
- const { securityHeadersMiddleware } = require('./client/src/js/csp-config.js');
19
+ const { securityHeadersMiddleware } = await import('./client/src/js/csp-config.js');
12
20
 
13
21
  const port = 3000;
14
22
 
15
23
  // Apply security headers to all responses
16
24
  app.use(securityHeadersMiddleware);
17
25
 
18
- app.use(express.static(path.join(__dirname, "client/public")));
26
+ app.use(express.default.static(path.join(__dirname, "client/public")));
19
27
 
20
28
  app.get("/", (req, res) => {
21
29
  res.sendFile(path.join(__dirname, "client/public", "client.htm"));
@@ -25,7 +33,8 @@ if (require.main === module) {
25
33
  console.log(`Client server listening at http://localhost:${port}`);
26
34
  console.log('Security headers including CSP are enabled');
27
35
  });
28
- } else {
29
- // We're called as a module
30
- module.exports = require('./client');
31
- }
36
+ }
37
+
38
+ // Always export the client module as default
39
+ const clientModule = await import('./client/index.js');
40
+ export default clientModule.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webssh2_client",
3
- "version": "0.2.31-alpha.0",
3
+ "version": "0.2.31-alpha.2",
4
4
  "ignore": [
5
5
  ".gitignore"
6
6
  ],