iframe-coordinator-cli 5.5.3 → 5.5.8

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.
@@ -1,40 +1,40 @@
1
- module.exports = function(frameRouter) {
1
+ module.exports = function (frameRouter) {
2
2
  let hostname = window.location.hostname;
3
3
 
4
4
  frameRouter.clientConfig = {
5
5
  clients: {
6
6
  application1: {
7
7
  url: `http://${hostname}:8080/client-app-1/#/`,
8
- assignedRoute: '/app1'
8
+ assignedRoute: "/app1",
9
9
  },
10
10
  application2: {
11
11
  // We are removing the built-in proxy route example for now, as there are conflicts with vite and
12
12
  // we will be adding improvements to the proxy behavior in the near future
13
13
  url: `http://${hostname}:8080/client-app-2/#/`,
14
- assignedRoute: '/app2',
15
- allow: 'camera http://localhost:8080;', // optional
16
- sandbox: 'allow-presentation allow-modals', // optional
17
- defaultTitle: 'iframe Application 2 Example' // optional, but needed for accessibility
18
- }
14
+ assignedRoute: "/app2",
15
+ allow: "camera http://localhost:8080;", // optional
16
+ sandbox: "allow-presentation allow-modals", // optional
17
+ defaultTitle: "iframe Application 2 Example", // optional, but needed for accessibility
18
+ },
19
19
  },
20
20
  envData: {
21
- locale: 'en-US',
22
- hostRootUrl: window.location.origin + '/#/',
21
+ locale: "en-US",
22
+ hostRootUrl: window.location.origin + "/#/",
23
23
  registeredKeys: [
24
- { key: 'a', ctrlKey: true },
25
- { key: 'b', altKey: true },
26
- { key: 'a', ctrlKey: true, shiftKey: true }
24
+ { key: "a", ctrlKey: true },
25
+ { key: "b", altKey: true },
26
+ { key: "a", ctrlKey: true, shiftKey: true },
27
27
  ],
28
- custom: getCustomClientData()
29
- }
28
+ custom: getCustomClientData(),
29
+ },
30
30
  };
31
31
  return {
32
32
  // These are the topics that the host app should display payloads for when
33
33
  // the client publishes on them.
34
- publishTopics: ['publish.topic']
34
+ publishTopics: ["publish.topic"],
35
35
  };
36
36
  };
37
37
 
38
38
  function getCustomClientData() {
39
- return { test: 'This is only a test' };
39
+ return { test: "This is only a test" };
40
40
  }
package/ifc-cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const commander = require('commander');
4
- const program = new commander.Command();
5
- const fs = require('fs');
6
- const path = require('path');
7
- const findRoot = require('find-root');
8
- const express = require('express');
9
- const cheerio = require('cheerio');
10
- const https = require('https');
11
- const devCertAuthority = require('dev-cert-authority');
12
- const { createProxyMiddleware } = require('http-proxy-middleware');
13
-
14
- const appPath = path.join(__dirname, './dist/');
3
+ const { Command } = require("commander");
4
+ const program = new Command();
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const findRoot = require("find-root");
8
+ const express = require("express");
9
+ const cheerio = require("cheerio");
10
+ const https = require("https");
11
+ const devCertAuthority = require("dev-cert-authority");
12
+ const { createProxyMiddleware } = require("http-proxy-middleware");
13
+
14
+ const appPath = path.join(__dirname, "./dist/");
15
15
 
16
16
  main();
17
17
 
@@ -23,17 +23,17 @@ function main() {
23
23
  app = express();
24
24
  app.use(/^\/$/, serveIndex(indexContent));
25
25
  app.use(
26
- '/proxy',
26
+ "/proxy",
27
27
  createProxyMiddleware({
28
28
  router: extractTargetHost,
29
29
  pathRewrite: rewritePath,
30
30
  onError: (err, req, res) => {
31
- console.log('ERROR', err);
32
- res.writeHead(500, { 'Content-Type': 'text/plain' });
31
+ console.log("ERROR", err);
32
+ res.writeHead(500, { "Content-Type": "text/plain" });
33
33
  res.end(err.message);
34
34
  },
35
- target: `http://localhost:${opts.port}` //Required by middleware, but should be always overriden by the previous options
36
- })
35
+ target: `http://localhost:${opts.port}`, //Required by middleware, but should be always overriden by the previous options
36
+ }),
37
37
  );
38
38
  app.use(express.static(appPath));
39
39
 
@@ -45,7 +45,7 @@ function main() {
45
45
  }
46
46
 
47
47
  const localhostUrl =
48
- (opts.ssl ? 'https' : 'http') + '://localhost:' + opts.port + '/';
48
+ (opts.ssl ? "https" : "http") + "://localhost:" + opts.port + "/";
49
49
  console.log(`Listening on port ${opts.port}...`);
50
50
  console.log(`Visit host app at: ${localhostUrl}`);
51
51
  }
@@ -54,33 +54,35 @@ function main() {
54
54
 
55
55
  function parseProgramOptions() {
56
56
  const projRoot = findRoot(process.cwd());
57
- const defaultJsConfig = path.join(projRoot, 'ifc-cli.config.js');
57
+ const defaultJsConfig = path.join(projRoot, "ifc-cli.config.js");
58
58
 
59
59
  program
60
60
  .option(
61
- '-f, --config-file <file>',
62
- 'iframe client configuration file',
63
- defaultJsConfig
61
+ "-f, --config-file <file>",
62
+ "iframe client configuration file",
63
+ defaultJsConfig,
64
64
  )
65
- .option('-p, --port <port_num>', 'port number to host on', 3000)
66
- .option('-s, --ssl', 'serve over https')
67
- .option('--ssl-cert <cert_path>', 'certificate file to use for https')
68
- .option('--ssl-key <key_path>', 'key file to use for https');
69
- program.on('--help', showHelpText);
65
+ .option("-p, --port <port_num>", "port number to host on", 3000)
66
+ .option("-s, --ssl", "serve over https")
67
+ .option("--ssl-cert <cert_path>", "certificate file to use for https")
68
+ .option("--ssl-key <key_path>", "key file to use for https");
69
+ program.on("--help", showHelpText);
70
70
 
71
71
  program.parse(process.argv);
72
72
 
73
+ const options = program.opts();
74
+
73
75
  return {
74
- clientConfigFile: findConfigFile(program.configFile),
75
- port: program.port,
76
- ssl: program.ssl,
77
- sslCert: program.sslCert,
78
- sslKey: program.sslKey
76
+ clientConfigFile: findConfigFile(options.configFile),
77
+ port: options.port,
78
+ ssl: options.ssl,
79
+ sslCert: options.sslCert,
80
+ sslKey: options.sslKey,
79
81
  };
80
82
  }
81
83
 
82
84
  function showHelpText() {
83
- const configExample = path.join(__dirname, 'example-ifc.config.js');
85
+ const configExample = path.join(__dirname, "example-ifc.config.js");
84
86
  console.log(`
85
87
  This program will start a server for a basic iframe-coordinator host app. In
86
88
  order to configure the frame-router element and any other custom logic needed
@@ -90,10 +92,10 @@ function showHelpText() {
90
92
  object with the following fields:
91
93
 
92
94
  - publishTopics: A list of messaging topics the client publishes on
93
-
95
+
94
96
  Keep in mind that the config file is not a true commonJS module, and
95
97
  will be evaluated directly inside the browser in an immediately invoked
96
- function expression.
98
+ function expression.
97
99
 
98
100
  Here is an example config file:
99
101
  `);
@@ -101,17 +103,17 @@ function showHelpText() {
101
103
  }
102
104
 
103
105
  function serveIndex(indexContent) {
104
- return function(req, res) {
106
+ return function (req, res) {
105
107
  res.send(indexContent);
106
108
  };
107
109
  }
108
110
 
109
111
  function generateIndex(appPath, clientConfigFile) {
110
112
  const baseIndex = fs
111
- .readFileSync(path.join(appPath, 'index.html'))
113
+ .readFileSync(path.join(appPath, "index.html"))
112
114
  .toString();
113
115
  const $ = cheerio.load(baseIndex);
114
- $('head').append(configScript(clientConfigFile));
116
+ $("head").append(configScript(clientConfigFile));
115
117
  return $.html();
116
118
  }
117
119
 
@@ -142,12 +144,12 @@ function findConfigFile(cliPath) {
142
144
 
143
145
  function getSslOpts(certPath, keyPath) {
144
146
  if (!certPath || !keyPath) {
145
- return devCertAuthority('localhost');
147
+ return devCertAuthority("localhost");
146
148
  }
147
149
  if (fs.existsSync(certPath) && fs.existsSync(keyPath)) {
148
150
  return {
149
151
  cert: fs.readFileSync(certPath),
150
- key: fs.readFileSync(keyPath)
152
+ key: fs.readFileSync(keyPath),
151
153
  };
152
154
  } else {
153
155
  console.log(`Certificate files not found @ ${certPath}, and ${keyPath}`);
@@ -158,8 +160,8 @@ function getSslOpts(certPath, keyPath) {
158
160
  // Make sure a path isn't interpreted as a module when required.
159
161
  function relativizePath(inPath) {
160
162
  let outPath = path.relative(process.cwd(), inPath);
161
- if (!outPath.startsWith('.')) {
162
- outPath = './' + outPath;
163
+ if (!outPath.startsWith(".")) {
164
+ outPath = "./" + outPath;
163
165
  }
164
166
  return outPath;
165
167
  }
@@ -173,7 +175,7 @@ function rewritePath(path) {
173
175
  }
174
176
 
175
177
  function extractProxyUrl(path) {
176
- const proxyPath = path.replace(/^\/proxy\//, '');
178
+ const proxyPath = path.replace(/^\/proxy\//, "");
177
179
  let newUrl;
178
180
  try {
179
181
  newUrl = new URL(decodeURIComponent(proxyPath));
package/package.json CHANGED
@@ -1,27 +1,29 @@
1
1
  {
2
2
  "name": "iframe-coordinator-cli",
3
- "version": "5.5.3",
3
+ "version": "5.5.8",
4
4
  "description": "CLI for local iframe-coordinator development",
5
5
  "dependencies": {
6
6
  "cheerio": "^1.0.0-rc.10",
7
- "commander": "^2.20.3",
7
+ "commander": "^11.1.0",
8
8
  "custom-event-polyfill": "^1.0.7",
9
9
  "dev-cert-authority": "^1.1.1",
10
- "express": "^4.17.3",
10
+ "express": "^4.18.2",
11
11
  "find-root": "^1.1.0",
12
- "http-proxy-middleware": "^1.3.1",
13
- "iframe-coordinator": "file:../iframe-coordinator",
14
- "vue": "^2.7.10",
15
- "vue-class-component": "^7.0.2",
16
- "vue-notification": "^1.3.16",
17
- "vue-property-decorator": "^8.1.0",
18
- "vue-router": "^3.0.3",
19
- "vuex": "^3.0.1"
12
+ "http-proxy-middleware": "^2.0.6",
13
+ "iframe-coordinator": "5.5.8",
14
+ "vue": "^2.7.16",
15
+ "vue-class-component": "^7.2.6",
16
+ "vue-notification": "^1.3.20",
17
+ "vue-property-decorator": "^8.5.1",
18
+ "vue-router": "^3.6.5",
19
+ "vuex": "^3.6.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@vitejs/plugin-vue2": "^2.0.0",
23
- "typescript": "^4.8.3",
24
- "vite": "^3.1.3"
22
+ "@vitejs/plugin-vue2": "^2.3.1",
23
+ "jsdom": "^23.2.0",
24
+ "karma-jsdom-launcher": "^16.0.0",
25
+ "typescript": "^4.9.5",
26
+ "vite": "^5.0.11"
25
27
  },
26
28
  "files": [
27
29
  "dist",