@signageos/cli 2.3.1 → 2.4.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.
Files changed (146) hide show
  1. package/README.md +54 -19
  2. package/dist/Applet/Build/appletBuildCommand.js +28 -72
  3. package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
  4. package/dist/Applet/Generate/Templates/README.md.template +3 -0
  5. package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
  6. package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
  7. package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
  8. package/dist/Applet/Start/appletStartCommand.js +70 -132
  9. package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
  10. package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
  11. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
  12. package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
  13. package/dist/Applet/Test/appletTestCommand.js +6 -36
  14. package/dist/Applet/Upload/appletUploadCommand.js +199 -305
  15. package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
  16. package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
  17. package/dist/Applet/Upload/appletUploadFacade.js +184 -265
  18. package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
  19. package/dist/Applet/appletCommand.d.ts +25 -157
  20. package/dist/Applet/appletCommand.js +9 -39
  21. package/dist/Applet/appletErrors.js +5 -24
  22. package/dist/Applet/appletFacade.js +122 -147
  23. package/dist/Applet/appletServerHelper.js +18 -55
  24. package/dist/Auth/loginCommand.d.ts +2 -2
  25. package/dist/Auth/loginCommand.js +105 -136
  26. package/dist/Cache/tmpCache.js +47 -16
  27. package/dist/Cli/helper.js +3 -5
  28. package/dist/Cli/packageVersion.js +99 -131
  29. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
  30. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
  31. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
  32. package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
  33. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
  34. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
  35. package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
  36. package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
  37. package/dist/Command/autoComplete.d.ts +4 -0
  38. package/dist/Command/autoComplete.js +184 -0
  39. package/dist/Command/commandDefinition.d.ts +9 -9
  40. package/dist/Command/commandDefinition.js +1 -3
  41. package/dist/Command/commandProcessor.js +41 -131
  42. package/dist/Command/globalArgs.js +9 -8
  43. package/dist/CommandLine/IProgressBar.js +0 -1
  44. package/dist/CommandLine/progressBarFactory.d.ts +1 -1
  45. package/dist/CommandLine/progressBarFactory.js +42 -13
  46. package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
  47. package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
  48. package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
  49. package/dist/CustomScript/customScriptCommand.d.ts +1 -9
  50. package/dist/CustomScript/customScriptCommand.js +6 -36
  51. package/dist/CustomScript/customScriptFacade.d.ts +2 -2
  52. package/dist/CustomScript/customScriptFacade.js +187 -297
  53. package/dist/Device/Connect/connectCommand.js +73 -137
  54. package/dist/Device/Content/setContentCommand.js +33 -78
  55. package/dist/Device/PowerAction/powerActionCommand.js +22 -65
  56. package/dist/Device/deviceCommand.js +7 -37
  57. package/dist/Device/deviceFacade.js +71 -127
  58. package/dist/Emulator/IEmulator.js +0 -1
  59. package/dist/Emulator/createDomain.d.ts +0 -1
  60. package/dist/Emulator/createDomain.js +44 -14
  61. package/dist/Emulator/emulatorFacade.js +75 -133
  62. package/dist/Emulator/emulatorFactory.js +123 -126
  63. package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
  64. package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
  65. package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
  66. package/dist/Firmware/firmwareCommand.js +5 -35
  67. package/dist/Lib/archive.js +56 -62
  68. package/dist/Lib/childProcess.js +37 -5
  69. package/dist/Lib/fileSystem.js +76 -87
  70. package/dist/Lib/git.d.ts +1 -1
  71. package/dist/Lib/git.js +58 -87
  72. package/dist/Organization/Get/organizationGetCommand.js +14 -50
  73. package/dist/Organization/List/organizationListCommand.js +12 -46
  74. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
  75. package/dist/Organization/organizationCommand.js +7 -37
  76. package/dist/Organization/organizationFacade.js +102 -177
  77. package/dist/RunControl/runControlHelper.js +14 -64
  78. package/dist/Timer/wait.js +2 -3
  79. package/dist/Timing/List/timingListCommand.js +20 -62
  80. package/dist/Timing/timingCommand.js +5 -35
  81. package/dist/generalCommand.js +1 -2
  82. package/dist/helper.d.ts +4 -4
  83. package/dist/helper.js +61 -122
  84. package/dist/index.js +19 -46
  85. package/dist/parameters.js +17 -40
  86. package/package.json +52 -57
  87. package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
  88. package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
  89. package/dist/Applet/Start/appletStartCommand.js.map +0 -1
  90. package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
  91. package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
  92. package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
  93. package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
  94. package/dist/Applet/Test/appletTestCommand.js.map +0 -1
  95. package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
  96. package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
  97. package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
  98. package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
  99. package/dist/Applet/appletCommand.js.map +0 -1
  100. package/dist/Applet/appletErrors.js.map +0 -1
  101. package/dist/Applet/appletFacade.js.map +0 -1
  102. package/dist/Applet/appletServerHelper.js.map +0 -1
  103. package/dist/Auth/loginCommand.js.map +0 -1
  104. package/dist/Cache/tmpCache.js.map +0 -1
  105. package/dist/Cli/helper.js.map +0 -1
  106. package/dist/Cli/packageVersion.js.map +0 -1
  107. package/dist/Command/commandDefinition.js.map +0 -1
  108. package/dist/Command/commandProcessor.js.map +0 -1
  109. package/dist/Command/globalArgs.js.map +0 -1
  110. package/dist/CommandLine/IProgressBar.js.map +0 -1
  111. package/dist/CommandLine/progressBarFactory.js.map +0 -1
  112. package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
  113. package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
  114. package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
  115. package/dist/CustomScript/customScriptCommand.js.map +0 -1
  116. package/dist/CustomScript/customScriptFacade.js.map +0 -1
  117. package/dist/Device/Connect/connectCommand.js.map +0 -1
  118. package/dist/Device/Content/setContentCommand.js.map +0 -1
  119. package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
  120. package/dist/Device/deviceCommand.js.map +0 -1
  121. package/dist/Device/deviceFacade.js.map +0 -1
  122. package/dist/Emulator/IEmulator.js.map +0 -1
  123. package/dist/Emulator/createDomain.js.map +0 -1
  124. package/dist/Emulator/emulatorFacade.js.map +0 -1
  125. package/dist/Emulator/emulatorFactory.js.map +0 -1
  126. package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
  127. package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
  128. package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
  129. package/dist/Firmware/firmwareCommand.js.map +0 -1
  130. package/dist/Lib/archive.js.map +0 -1
  131. package/dist/Lib/childProcess.js.map +0 -1
  132. package/dist/Lib/fileSystem.js.map +0 -1
  133. package/dist/Lib/git.js.map +0 -1
  134. package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
  135. package/dist/Organization/List/organizationListCommand.js.map +0 -1
  136. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
  137. package/dist/Organization/organizationCommand.js.map +0 -1
  138. package/dist/Organization/organizationFacade.js.map +0 -1
  139. package/dist/RunControl/runControlHelper.js.map +0 -1
  140. package/dist/Timer/wait.js.map +0 -1
  141. package/dist/Timing/List/timingListCommand.js.map +0 -1
  142. package/dist/Timing/timingCommand.js.map +0 -1
  143. package/dist/generalCommand.js.map +0 -1
  144. package/dist/helper.js.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/parameters.js.map +0 -1
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,137 +41,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
42
  });
10
43
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
46
  };
38
47
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.createEmulator = void 0;
40
- var path = require("path");
41
- var http = require("http");
42
- var url = require("url");
43
- var express = require("express");
44
- var cors = require("cors");
45
- var serveStatic = require("serve-static");
46
- var mime = require("mime");
47
- var fsExtra = require("fs-extra");
48
- var chalk_1 = require("chalk");
49
- var log_1 = require("@signageos/sdk/dist/Console/log");
50
- var fileSystem_1 = require("../Lib/fileSystem");
51
- var DUMMY_CHECKSUM = '0000000000ffffffffff';
52
- var APPLET_DIRECTORY_PATH = '/applet';
48
+ exports.createEmulator = createEmulator;
49
+ const path = __importStar(require("path"));
50
+ const http = __importStar(require("http"));
51
+ const url = __importStar(require("url"));
52
+ const express_1 = __importDefault(require("express"));
53
+ const cors_1 = __importDefault(require("cors"));
54
+ const serve_static_1 = __importDefault(require("serve-static"));
55
+ const mime_1 = __importDefault(require("mime"));
56
+ const fsExtra = __importStar(require("fs-extra"));
57
+ const chalk_1 = __importDefault(require("chalk"));
58
+ const log_1 = require("@signageos/sdk/dist/Console/log");
59
+ const fileSystem_1 = require("../Lib/fileSystem");
60
+ const DUMMY_CHECKSUM = '0000000000ffffffffff';
61
+ const APPLET_DIRECTORY_PATH = '/applet';
53
62
  function createEmulator(params, organizationUid, dev) {
54
- return __awaiter(this, void 0, void 0, function () {
55
- var appletUid, appletVersion, emulatorServerPort, appletPath, entryFileRelativePath, entryFileAbsolutePath, frontDisplayPath, frontDisplayDistPath, envVars, app, server;
56
- var _this = this;
57
- return __generator(this, function (_a) {
58
- appletUid = params.appletUid, appletVersion = params.appletVersion, emulatorServerPort = params.emulatorServerPort, appletPath = params.appletPath, entryFileRelativePath = params.entryFileRelativePath;
59
- entryFileAbsolutePath = path.join(appletPath, entryFileRelativePath);
60
- frontDisplayPath = path.dirname(require.resolve('@signageos/front-display/package.json', { paths: [appletPath] }));
61
- frontDisplayDistPath = path.join(frontDisplayPath, 'dist');
62
- if (!organizationUid) {
63
- throw new Error("No default organization selected. Use ".concat(chalk_1.default.green('sos organization set-default'), " first."));
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const { appletUid, appletVersion, emulatorServerPort, appletPath, entryFileRelativePath } = params;
65
+ const entryFileAbsolutePath = path.join(appletPath, entryFileRelativePath);
66
+ const frontDisplayPath = path.dirname(require.resolve('@signageos/front-display/package.json', { paths: [appletPath] }));
67
+ const frontDisplayDistPath = path.join(frontDisplayPath, 'dist');
68
+ if (!organizationUid) {
69
+ throw new Error(`No default organization selected. Use ${chalk_1.default.green('sos organization set-default')} first.`);
70
+ }
71
+ const envVars = {
72
+ uid: appletUid || '__default_timing__',
73
+ version: appletVersion || '0.0.0',
74
+ organizationUid,
75
+ binaryFilePath: `${APPLET_DIRECTORY_PATH}/${entryFileRelativePath}`,
76
+ checksum: DUMMY_CHECKSUM,
77
+ frontAppletVersion: '', // has bundled front applet
78
+ frontAppletBinaryFile: '', // has bundled front applet
79
+ };
80
+ const app = (0, express_1.default)();
81
+ app.use((0, cors_1.default)());
82
+ app.get('/', (req, res) => {
83
+ if (!req.query.duid) {
84
+ res.redirect(`${req.originalUrl}${req.originalUrl.includes('?') ? '&' : '?'}duid=${params.emulatorUid}`);
64
85
  }
65
- envVars = {
66
- uid: appletUid || '__default_timing__',
67
- version: appletVersion || '0.0.0',
68
- organizationUid: organizationUid,
69
- binaryFilePath: "".concat(APPLET_DIRECTORY_PATH, "/").concat(entryFileRelativePath),
70
- checksum: DUMMY_CHECKSUM,
71
- frontAppletVersion: '',
72
- frontAppletBinaryFile: '', // has bundled front applet
73
- };
74
- app = express();
75
- app.use(cors());
76
- app.get('/', function (req, res) {
77
- if (!req.query.duid) {
78
- res.redirect("".concat(req.originalUrl).concat(req.originalUrl.includes('?') ? '&' : '?', "duid=").concat(params.emulatorUid));
79
- }
80
- else {
81
- var page = fsExtra.readFileSync(path.join(frontDisplayDistPath, 'index.html')).toString();
82
- var script = "\n<script>\n\twindow.__SOS_BUNDLED_APPLET = {};\n\twindow.__SOS_BUNDLED_APPLET.binaryFile = location.origin + ".concat(JSON.stringify(envVars.binaryFilePath), ";\n\twindow.__SOS_BUNDLED_APPLET.uid = ").concat(JSON.stringify(envVars.uid), ";\n\twindow.__SOS_BUNDLED_APPLET.version = ").concat(JSON.stringify(envVars.version), ";\n\twindow.__SOS_BUNDLED_APPLET.checksum = ").concat(JSON.stringify(envVars.checksum), ";\n\twindow.__SOS_BUNDLED_APPLET.frontAppletVersion = ").concat(JSON.stringify(envVars.frontAppletVersion), ";\n\twindow.__SOS_BUNDLED_APPLET.frontAppletBinaryFile = ").concat(JSON.stringify(envVars.frontAppletBinaryFile), ";\n\twindow.__SOS_AUTO_VERIFICATION = {};\n\twindow.__SOS_AUTO_VERIFICATION.organizationUid = ").concat(JSON.stringify(envVars.organizationUid), ";\n</script>");
83
- res.send(page.replace('</head>', "".concat(script, "</head>")));
84
- }
85
- });
86
- app.use(serveStatic(frontDisplayDistPath));
87
- server = http.createServer(app);
88
- server.listen(emulatorServerPort, function () {
89
- var emulatorUrl = "http://localhost:".concat(emulatorServerPort);
90
- (0, log_1.log)('info', "Emulator is running at ".concat(chalk_1.default.blue(chalk_1.default.bold(emulatorUrl))));
86
+ else {
87
+ const page = fsExtra.readFileSync(path.join(frontDisplayDistPath, 'index.html')).toString();
88
+ const script = `
89
+ <script>
90
+ window.__SOS_BUNDLED_APPLET = {};
91
+ window.__SOS_BUNDLED_APPLET.binaryFile = location.origin + ${JSON.stringify(envVars.binaryFilePath)};
92
+ window.__SOS_BUNDLED_APPLET.uid = ${JSON.stringify(envVars.uid)};
93
+ window.__SOS_BUNDLED_APPLET.version = ${JSON.stringify(envVars.version)};
94
+ window.__SOS_BUNDLED_APPLET.checksum = ${JSON.stringify(envVars.checksum)};
95
+ window.__SOS_BUNDLED_APPLET.frontAppletVersion = ${JSON.stringify(envVars.frontAppletVersion)};
96
+ window.__SOS_BUNDLED_APPLET.frontAppletBinaryFile = ${JSON.stringify(envVars.frontAppletBinaryFile)};
97
+ window.__SOS_AUTO_VERIFICATION = {};
98
+ window.__SOS_AUTO_VERIFICATION.organizationUid = ${JSON.stringify(envVars.organizationUid)};
99
+ </script>`;
100
+ res.send(page.replace('</head>', `${script}</head>`));
101
+ }
102
+ });
103
+ app.use((0, serve_static_1.default)(frontDisplayDistPath));
104
+ const server = http.createServer(app);
105
+ server.listen(emulatorServerPort, () => {
106
+ const emulatorUrl = `http://localhost:${emulatorServerPort}`;
107
+ (0, log_1.log)('info', `Emulator is running at ${chalk_1.default.blue(chalk_1.default.bold(emulatorUrl))}`);
108
+ });
109
+ app.use(APPLET_DIRECTORY_PATH, (req, res) => __awaiter(this, void 0, void 0, function* () {
110
+ const fileUrl = url.parse(req.url);
111
+ const relativeFilePath = fileUrl.pathname ? fileUrl.pathname.substring(1) : '';
112
+ const absoluteFilePath = path.join(appletPath, relativeFilePath);
113
+ const appletFilePaths = yield dev.applet.files.listAppletFiles({
114
+ appletPath,
91
115
  });
92
- app.use(APPLET_DIRECTORY_PATH, function (req, res) { return __awaiter(_this, void 0, void 0, function () {
93
- var fileUrl, relativeFilePath, absoluteFilePath, appletFilePaths, prependFileContent, page, contentType, readStream;
94
- return __generator(this, function (_a) {
95
- switch (_a.label) {
96
- case 0:
97
- fileUrl = url.parse(req.url);
98
- relativeFilePath = fileUrl.pathname ? fileUrl.pathname.substring(1) : '';
99
- absoluteFilePath = path.join(appletPath, relativeFilePath);
100
- return [4 /*yield*/, dev.applet.files.listAppletFiles({
101
- appletPath: appletPath,
102
- })];
103
- case 1:
104
- appletFilePaths = _a.sent();
105
- if (!(0, fileSystem_1.isPathIncluded)(appletFilePaths, absoluteFilePath)) {
106
- res.status(404).send("File \"".concat(relativeFilePath, "\" was not found"));
107
- return [2 /*return*/];
108
- }
109
- if (!(relativeFilePath === entryFileRelativePath)) return [3 /*break*/, 3];
110
- prependFileContent = '<script>window.onbeforeunload = function () { window.parent.postMessage({ type: "hug.applet_refresh" }, "*") }</script>';
111
- res.setHeader('Content-Type', 'text/html');
112
- return [4 /*yield*/, fsExtra.readFile(entryFileAbsolutePath, 'utf8')];
113
- case 2:
114
- page = _a.sent();
115
- res.send(page.replace('</head>', "".concat(prependFileContent, "</head>")));
116
- return [2 /*return*/];
117
- case 3:
118
- contentType = mime.getType(absoluteFilePath) || 'application/octet-stream';
119
- res.setHeader('Content-Type', contentType);
120
- readStream = fsExtra.createReadStream(absoluteFilePath);
121
- readStream.pipe(res);
122
- return [2 /*return*/];
123
- }
116
+ if (!(0, fileSystem_1.isPathIncluded)(appletFilePaths, absoluteFilePath)) {
117
+ res.status(404).send(`File "${relativeFilePath}" was not found`);
118
+ return;
119
+ }
120
+ if (relativeFilePath === entryFileRelativePath) {
121
+ // Propagate Hot reload of whole emulator
122
+ const prependFileContent = '<script>window.onbeforeunload = function () { window.parent.postMessage({ type: "hug.applet_refresh" }, "*") }</script>';
123
+ res.setHeader('Content-Type', 'text/html');
124
+ const page = yield fsExtra.readFile(entryFileAbsolutePath, 'utf8');
125
+ res.send(page.replace('</head>', `${prependFileContent}</head>`));
126
+ return;
127
+ }
128
+ const contentType = mime_1.default.getType(absoluteFilePath) || 'application/octet-stream';
129
+ res.setHeader('Content-Type', contentType);
130
+ const readStream = fsExtra.createReadStream(absoluteFilePath);
131
+ readStream.pipe(res);
132
+ }));
133
+ return {
134
+ stop() {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ yield new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())));
124
137
  });
125
- }); });
126
- return [2 /*return*/, {
127
- stop: function () {
128
- return __awaiter(this, void 0, void 0, function () {
129
- return __generator(this, function (_a) {
130
- switch (_a.label) {
131
- case 0: return [4 /*yield*/, new Promise(function (resolve, reject) { return server.close(function (error) { return (error ? reject(error) : resolve()); }); })];
132
- case 1:
133
- _a.sent();
134
- return [2 /*return*/];
135
- }
136
- });
137
- });
138
- },
139
- }];
140
- });
138
+ },
139
+ };
141
140
  });
142
141
  }
143
- exports.createEmulator = createEmulator;
144
- //# sourceMappingURL=emulatorFactory.js.map