@signageos/webpack-plugin 0.0.4 → 0.1.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.
- package/CHANGELOG.md +12 -0
- package/config/parameters.d.ts +4 -0
- package/config/parameters.js +3 -0
- package/dist/ConnectControl/apiHelper.d.ts +3 -0
- package/dist/ConnectControl/apiHelper.js +89 -0
- package/dist/ConnectControl/apiHelper.js.map +1 -0
- package/dist/ConnectControl/helper.d.ts +11 -0
- package/dist/ConnectControl/helper.js +244 -0
- package/dist/ConnectControl/helper.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +69 -37
- package/dist/index.js.map +1 -0
- package/package-lock.json +7759 -0
- package/package.json +18 -7
- package/tools/prepare-npm-public.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.1.2] - 2022-01-18
|
|
8
|
+
### Fixed
|
|
9
|
+
- Compatibility with peer dependency for front-display version 9.13.0+ (because of changed API)
|
|
10
|
+
|
|
11
|
+
## [0.1.1] - 2021-02-22
|
|
12
|
+
### Fixed
|
|
13
|
+
- `localhost:8090` based development of applet works now
|
|
14
|
+
|
|
15
|
+
## [0.1.0] - 2021-01-29
|
|
16
|
+
### Added
|
|
17
|
+
- Reloading connected devices after build.
|
|
18
|
+
|
|
7
19
|
## [0.0.4] - 2020-10-13
|
|
8
20
|
### Fixed
|
|
9
21
|
- Remove unnecessary dependencies to keep plugin small
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var RestApi_1 = require("@signageos/sdk/dist/RestApi/RestApi");
|
|
51
|
+
var sosControlHelper_1 = require("@signageos/sdk/dist/SosHelper/sosControlHelper");
|
|
52
|
+
var parameters = require("../../config/parameters");
|
|
53
|
+
exports.API_URL = parameters.apiUrl;
|
|
54
|
+
function createOrganizationRestApi() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var config, accountAuth, accountOptions, organization, organizationAuth, organizationOptions;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, sosControlHelper_1.loadConfig()];
|
|
60
|
+
case 1:
|
|
61
|
+
config = _a.sent();
|
|
62
|
+
accountAuth = {
|
|
63
|
+
url: exports.API_URL,
|
|
64
|
+
auth: {
|
|
65
|
+
clientId: config.identification,
|
|
66
|
+
secret: config.apiSecurityToken,
|
|
67
|
+
},
|
|
68
|
+
version: 'v1',
|
|
69
|
+
};
|
|
70
|
+
accountOptions = __assign({}, accountAuth);
|
|
71
|
+
return [4 /*yield*/, new RestApi_1.default(accountAuth, accountOptions).organization.get(config.defaultOrganizationUid)];
|
|
72
|
+
case 2:
|
|
73
|
+
organization = _a.sent();
|
|
74
|
+
organizationAuth = {
|
|
75
|
+
url: exports.API_URL,
|
|
76
|
+
auth: {
|
|
77
|
+
clientId: organization.oauthClientId,
|
|
78
|
+
secret: organization.oauthClientSecret,
|
|
79
|
+
},
|
|
80
|
+
version: 'v1',
|
|
81
|
+
};
|
|
82
|
+
organizationOptions = __assign({}, organizationAuth);
|
|
83
|
+
return [2 /*return*/, new RestApi_1.default(organizationAuth, organizationOptions)];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.createOrganizationRestApi = createOrganizationRestApi;
|
|
89
|
+
//# sourceMappingURL=apiHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiHelper.js","sourceRoot":"","sources":["../../src/ConnectControl/apiHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+DAA0D;AAC1D,mFAA4E;AAC5E,oDAAsD;AAEzC,QAAA,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;AAEzC,SAAsB,yBAAyB;;;;;wBAE/B,qBAAM,6BAAU,EAAE,EAAA;;oBAA3B,MAAM,GAAG,SAAkB;oBAC3B,WAAW,GAAoB;wBACpC,GAAG,EAAE,eAAO;wBACZ,IAAI,EAAE;4BACL,QAAQ,EAAE,MAAM,CAAC,cAAe;4BAChC,MAAM,EAAE,MAAM,CAAC,gBAAiB;yBAChC;wBACD,OAAO,EAAE,IAAY;qBACrB,CAAC;oBACI,cAAc,gBAChB,WAAW,CACd,CAAC;oBACmB,qBAAM,IAAI,iBAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,sBAAuB,CAAC,EAAA;;oBAA9G,YAAY,GAAG,SAA+F;oBAC9G,gBAAgB,GAAoB;wBACzC,GAAG,EAAE,eAAO;wBACZ,IAAI,EAAE;4BACL,QAAQ,EAAE,YAAY,CAAC,aAAc;4BACrC,MAAM,EAAE,YAAY,CAAC,iBAAkB;yBACvC;wBACD,OAAO,EAAE,IAAY;qBACrB,CAAC;oBACI,mBAAmB,gBACrB,gBAAgB,CACnB,CAAC;oBACF,sBAAO,IAAI,iBAAO,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,EAAC;;;;CAC1D;AA3BD,8DA2BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as nativeFs from "fs";
|
|
3
|
+
declare type FileSystem = typeof nativeFs;
|
|
4
|
+
export declare const ignoredFiles: string[];
|
|
5
|
+
export declare function reloadConnectedDevices(): Promise<void>;
|
|
6
|
+
export declare function loadConnectedDeviceUids(): Promise<string[]>;
|
|
7
|
+
export declare function createAllAppletZips(outputFileSystem: FileSystem): Promise<string[]>;
|
|
8
|
+
export declare function createAppletZip(deviceUid: string, outputFileSystem: FileSystem): Promise<string>;
|
|
9
|
+
export declare function getAllFiles(directory: string, outputFileSystem: FileSystem): Promise<string[]>;
|
|
10
|
+
export declare function getAppletFileRelativePath(fileAbsolutePath: string, directoryAbsolutePath: string): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
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
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
var os = require("os");
|
|
47
|
+
var _ = require("lodash");
|
|
48
|
+
var fsExtra = require("fs-extra");
|
|
49
|
+
var nativeFs = require("fs");
|
|
50
|
+
var path = require("path");
|
|
51
|
+
var IPowerAction_1 = require("@signageos/sdk/dist/RestApi/Device/PowerAction/IPowerAction");
|
|
52
|
+
var apiHelper_1 = require("./apiHelper");
|
|
53
|
+
var archiver = require("archiver");
|
|
54
|
+
var CONNECT_DIRECTORY = 'signageos';
|
|
55
|
+
var connectRuntimeDirPath = path.join(os.tmpdir(), CONNECT_DIRECTORY);
|
|
56
|
+
exports.ignoredFiles = ["node_modules", "package-lock.json", "src", "public", ".gitignore", "README.md"];
|
|
57
|
+
function reloadConnectedDevices() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var connectedDeviceUids, resApi_1;
|
|
60
|
+
var _this = this;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, loadConnectedDeviceUids()];
|
|
64
|
+
case 1:
|
|
65
|
+
connectedDeviceUids = _a.sent();
|
|
66
|
+
if (!(connectedDeviceUids.length >= 1)) return [3 /*break*/, 4];
|
|
67
|
+
return [4 /*yield*/, apiHelper_1.createOrganizationRestApi()];
|
|
68
|
+
case 2:
|
|
69
|
+
resApi_1 = _a.sent();
|
|
70
|
+
return [4 /*yield*/, Promise.all(connectedDeviceUids.map(function (deviceUid) { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
+
var error_1;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
_a.trys.push([0, 2, , 3]);
|
|
76
|
+
return [4 /*yield*/, resApi_1.device.powerAction.set(deviceUid, {
|
|
77
|
+
devicePowerAction: IPowerAction_1.DevicePowerAction.AppletReload,
|
|
78
|
+
})];
|
|
79
|
+
case 1:
|
|
80
|
+
_a.sent();
|
|
81
|
+
console.log("Successfully reloaded device " + deviceUid + " ");
|
|
82
|
+
return [3 /*break*/, 3];
|
|
83
|
+
case 2:
|
|
84
|
+
error_1 = _a.sent();
|
|
85
|
+
console.log("Reload Failed", error_1);
|
|
86
|
+
return [3 /*break*/, 3];
|
|
87
|
+
case 3: return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); }))];
|
|
91
|
+
case 3:
|
|
92
|
+
_a.sent();
|
|
93
|
+
_a.label = 4;
|
|
94
|
+
case 4: return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.reloadConnectedDevices = reloadConnectedDevices;
|
|
100
|
+
function loadConnectedDeviceUids() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var connectFileContent, connectedDeviceUids, _i, connectFileContent_1, file;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, fsExtra.pathExists(connectRuntimeDirPath)];
|
|
106
|
+
case 1:
|
|
107
|
+
if (!(_a.sent())) {
|
|
108
|
+
return [2 /*return*/, []];
|
|
109
|
+
}
|
|
110
|
+
return [4 /*yield*/, fsExtra.readdir(connectRuntimeDirPath)];
|
|
111
|
+
case 2:
|
|
112
|
+
connectFileContent = _a.sent();
|
|
113
|
+
connectedDeviceUids = [];
|
|
114
|
+
if (!(connectFileContent.length >= 1)) return [3 /*break*/, 6];
|
|
115
|
+
_i = 0, connectFileContent_1 = connectFileContent;
|
|
116
|
+
_a.label = 3;
|
|
117
|
+
case 3:
|
|
118
|
+
if (!(_i < connectFileContent_1.length)) return [3 /*break*/, 6];
|
|
119
|
+
file = connectFileContent_1[_i];
|
|
120
|
+
return [4 /*yield*/, fsExtra.stat(path.join(connectRuntimeDirPath, file))];
|
|
121
|
+
case 4:
|
|
122
|
+
if ((_a.sent()).isDirectory()) {
|
|
123
|
+
connectedDeviceUids.push(file);
|
|
124
|
+
}
|
|
125
|
+
_a.label = 5;
|
|
126
|
+
case 5:
|
|
127
|
+
_i++;
|
|
128
|
+
return [3 /*break*/, 3];
|
|
129
|
+
case 6: return [2 /*return*/, connectedDeviceUids];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
exports.loadConnectedDeviceUids = loadConnectedDeviceUids;
|
|
135
|
+
function createAllAppletZips(outputFileSystem) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
var connectedDeviceUids, packageZipPaths;
|
|
138
|
+
var _this = this;
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0: return [4 /*yield*/, loadConnectedDeviceUids()];
|
|
142
|
+
case 1:
|
|
143
|
+
connectedDeviceUids = _a.sent();
|
|
144
|
+
return [4 /*yield*/, Promise.all(connectedDeviceUids.map(function (deviceUid) { return __awaiter(_this, void 0, void 0, function () {
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0: return [4 /*yield*/, createAppletZip(deviceUid, outputFileSystem)];
|
|
148
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}); }))];
|
|
152
|
+
case 2:
|
|
153
|
+
packageZipPaths = _a.sent();
|
|
154
|
+
return [2 /*return*/, packageZipPaths];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
exports.createAllAppletZips = createAllAppletZips;
|
|
160
|
+
function createAppletZip(deviceUid, outputFileSystem) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
var archive, deviceConnectDir, packageZipPath, output, actualDirectory, outputFiles, realFiles, oldRealFiles, _i, oldRealFiles_1, fileAbsolutePath, fileRelativePath, _a, outputFiles_1, fileAbsolutePath, fileRelativePath, promise;
|
|
163
|
+
return __generator(this, function (_b) {
|
|
164
|
+
switch (_b.label) {
|
|
165
|
+
case 0:
|
|
166
|
+
archive = archiver('zip');
|
|
167
|
+
deviceConnectDir = path.join(connectRuntimeDirPath, deviceUid);
|
|
168
|
+
packageZipPath = path.join(deviceConnectDir, "package.zip" + ("" + deviceUid));
|
|
169
|
+
output = fsExtra.createWriteStream(packageZipPath);
|
|
170
|
+
archive.pipe(output);
|
|
171
|
+
actualDirectory = process.cwd();
|
|
172
|
+
return [4 /*yield*/, getAllFiles(actualDirectory, outputFileSystem)];
|
|
173
|
+
case 1:
|
|
174
|
+
outputFiles = _b.sent();
|
|
175
|
+
return [4 /*yield*/, getAllFiles(actualDirectory, nativeFs)];
|
|
176
|
+
case 2:
|
|
177
|
+
realFiles = _b.sent();
|
|
178
|
+
oldRealFiles = _.difference(realFiles, outputFiles);
|
|
179
|
+
// First put all old real files from general file system to zip
|
|
180
|
+
for (_i = 0, oldRealFiles_1 = oldRealFiles; _i < oldRealFiles_1.length; _i++) {
|
|
181
|
+
fileAbsolutePath = oldRealFiles_1[_i];
|
|
182
|
+
fileRelativePath = getAppletFileRelativePath(fileAbsolutePath, actualDirectory);
|
|
183
|
+
archive.append(nativeFs.createReadStream(fileAbsolutePath), { name: fileRelativePath });
|
|
184
|
+
}
|
|
185
|
+
// Then extend zip with files from output file system (which is usually in memory FS from webpack in memory compilation)
|
|
186
|
+
for (_a = 0, outputFiles_1 = outputFiles; _a < outputFiles_1.length; _a++) {
|
|
187
|
+
fileAbsolutePath = outputFiles_1[_a];
|
|
188
|
+
fileRelativePath = getAppletFileRelativePath(fileAbsolutePath, actualDirectory);
|
|
189
|
+
archive.append(outputFileSystem.createReadStream(fileAbsolutePath), { name: fileRelativePath });
|
|
190
|
+
}
|
|
191
|
+
promise = new Promise(function (resolve, reject) {
|
|
192
|
+
archive.on('end', function () { return resolve(); });
|
|
193
|
+
archive.on('error', function (error) { return reject(error); });
|
|
194
|
+
});
|
|
195
|
+
archive.finalize();
|
|
196
|
+
return [4 /*yield*/, promise];
|
|
197
|
+
case 3:
|
|
198
|
+
_b.sent();
|
|
199
|
+
return [2 /*return*/, packageZipPath];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
exports.createAppletZip = createAppletZip;
|
|
205
|
+
function getAllFiles(directory, outputFileSystem) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
+
var fileList, files, _i, files_1, file, p, _a;
|
|
208
|
+
return __generator(this, function (_b) {
|
|
209
|
+
switch (_b.label) {
|
|
210
|
+
case 0:
|
|
211
|
+
fileList = [];
|
|
212
|
+
files = outputFileSystem.readdirSync(directory);
|
|
213
|
+
_i = 0, files_1 = files;
|
|
214
|
+
_b.label = 1;
|
|
215
|
+
case 1:
|
|
216
|
+
if (!(_i < files_1.length)) return [3 /*break*/, 5];
|
|
217
|
+
file = files_1[_i];
|
|
218
|
+
if (!!exports.ignoredFiles.includes(file)) return [3 /*break*/, 4];
|
|
219
|
+
p = path.join(directory, file);
|
|
220
|
+
if (!outputFileSystem.statSync(p).isDirectory()) return [3 /*break*/, 3];
|
|
221
|
+
_a = [fileList];
|
|
222
|
+
return [4 /*yield*/, getAllFiles(p, outputFileSystem)];
|
|
223
|
+
case 2:
|
|
224
|
+
fileList = __spreadArrays.apply(void 0, _a.concat([(_b.sent())]));
|
|
225
|
+
return [3 /*break*/, 4];
|
|
226
|
+
case 3:
|
|
227
|
+
fileList.push(p);
|
|
228
|
+
_b.label = 4;
|
|
229
|
+
case 4:
|
|
230
|
+
_i++;
|
|
231
|
+
return [3 /*break*/, 1];
|
|
232
|
+
case 5: return [2 /*return*/, fileList];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
exports.getAllFiles = getAllFiles;
|
|
238
|
+
function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
|
|
239
|
+
var directoryAbsolutePathNormalized = path.normalize(directoryAbsolutePath);
|
|
240
|
+
var fileAbsolutePathNormalized = path.normalize(fileAbsolutePath);
|
|
241
|
+
return fileAbsolutePathNormalized.substring(directoryAbsolutePathNormalized.length + 1);
|
|
242
|
+
}
|
|
243
|
+
exports.getAppletFileRelativePath = getAppletFileRelativePath;
|
|
244
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/ConnectControl/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB;AACzB,0BAA4B;AAC5B,kCAAoC;AACpC,6BAA+B;AAC/B,2BAA6B;AAC7B,4FAAgG;AAChG,yCAAwD;AACxD,mCAAqC;AAIrC,IAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,IAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAC3D,QAAA,YAAY,GAAa,CAAC,cAAc,EAAE,mBAAmB,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAExH,SAAsB,sBAAsB;;;;;;wBACf,qBAAM,uBAAuB,EAAE,EAAA;;oBAArD,mBAAmB,GAAG,SAA+B;yBACvD,CA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AAS,EAAE,IAAI,CAAC,CAAC;yBACjC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAA1C,wBAA0C;0BAC9B,QAAQ;oBAAM,qBAAM,WAAW,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAA;;oBAAnE,QAAQ,2CAAoB,CAAC,SAAsC,CAAC,GAAC,CAAC;;;oBAEtE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;oBAND,IAAK,CAAA;;wBAWxB,sBAAO,QAAQ,EAAC;;;;CAChB;AAhBD,kCAgBC;AAED,SAAgB,yBAAyB,CAAC,gBAAwB,EAAE,qBAA6B;IAChG,IAAM,+BAA+B,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC9E,IAAM,0BAA0B,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEpE,OAAO,0BAA0B,CAAC,SAAS,CAAC,+BAA+B,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACzF,CAAC;AALD,8DAKC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as webpack from 'webpack';
|
|
2
|
+
export interface IWebpackOptions {
|
|
3
|
+
https?: boolean;
|
|
4
|
+
port?: number;
|
|
5
|
+
public?: string;
|
|
6
|
+
useLocalIp?: boolean;
|
|
7
|
+
host?: string;
|
|
8
|
+
}
|
|
9
|
+
export default class Plugin {
|
|
10
|
+
private options;
|
|
11
|
+
constructor(options?: IWebpackOptions);
|
|
12
|
+
apply(compiler: webpack.Compiler): void;
|
|
13
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -53,13 +53,28 @@ var http = require("http");
|
|
|
53
53
|
var url = require("url");
|
|
54
54
|
var cors = require("cors");
|
|
55
55
|
var mime = require("mime");
|
|
56
|
-
var
|
|
56
|
+
var fsExtra = require("fs-extra");
|
|
57
|
+
var nativeFs = require("fs");
|
|
57
58
|
var serveStatic = require("serve-static");
|
|
58
59
|
var chalk = require("chalk");
|
|
59
60
|
var debug_1 = require("debug");
|
|
60
|
-
var
|
|
61
|
+
var sosControlHelper_1 = require("@signageos/sdk/dist/SosHelper/sosControlHelper");
|
|
62
|
+
var helper_1 = require("./ConnectControl/helper");
|
|
61
63
|
var createDomain = require('webpack-dev-server/lib/utils/createDomain');
|
|
62
64
|
var debug = debug_1.default('@signageos/webpack-plugin:index');
|
|
65
|
+
function getCompilationFileSystem(possibleFs) {
|
|
66
|
+
var fileSystem = possibleFs;
|
|
67
|
+
if (!('createReadStream' in fileSystem)) {
|
|
68
|
+
// TODO uncomment this warning when webpack-dev-server is fixed for device connected builds (currently webpack --watch is supported)
|
|
69
|
+
/*console.warn(
|
|
70
|
+
'The environment is running in not standard mode. '
|
|
71
|
+
+ 'Try to use `npm start` or `webpack-dev-server` instead. '
|
|
72
|
+
+ 'The real FS will be used as failover.',
|
|
73
|
+
);*/
|
|
74
|
+
fileSystem = nativeFs;
|
|
75
|
+
}
|
|
76
|
+
return fileSystem;
|
|
77
|
+
}
|
|
63
78
|
var Plugin = /** @class */ (function () {
|
|
64
79
|
function Plugin(options) {
|
|
65
80
|
if (options === void 0) { options = {}; }
|
|
@@ -94,11 +109,21 @@ var Plugin = /** @class */ (function () {
|
|
|
94
109
|
return [2 /*return*/];
|
|
95
110
|
});
|
|
96
111
|
}); });
|
|
97
|
-
compiler.plugin('done', function (stats) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
compiler.plugin('done', function (stats) { return __awaiter(_this, void 0, void 0, function () {
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
if (!emulator) return [3 /*break*/, 2];
|
|
117
|
+
emulator.notifyDone(stats);
|
|
118
|
+
return [4 /*yield*/, helper_1.createAllAppletZips(getCompilationFileSystem(stats.compilation.compiler.outputFileSystem))];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
helper_1.reloadConnectedDevices();
|
|
122
|
+
_a.label = 2;
|
|
123
|
+
case 2: return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); });
|
|
102
127
|
process.on('exit', function () {
|
|
103
128
|
if (emulator) {
|
|
104
129
|
emulator.stop();
|
|
@@ -111,19 +136,40 @@ var Plugin = /** @class */ (function () {
|
|
|
111
136
|
exports.default = Plugin;
|
|
112
137
|
module.exports = Plugin;
|
|
113
138
|
module.exports.default = Plugin;
|
|
139
|
+
var APPLET_DIRECTORY_PATH = '/applet';
|
|
114
140
|
function createEmulator(options) {
|
|
141
|
+
var _a;
|
|
115
142
|
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var projectPath, defaultPort, frontDisplayPath, frontDisplayDistPath_1,
|
|
117
|
-
return __generator(this, function (
|
|
118
|
-
switch (
|
|
143
|
+
var projectPath, defaultPort, frontDisplayPath, frontDisplayDistPath_1, packagePath, packageConfig, sosGlobalConfig, organizationUid, currentCompilation_1, lastCompilationAssets_1, envVars_1, app, server_1, error_1;
|
|
144
|
+
return __generator(this, function (_b) {
|
|
145
|
+
switch (_b.label) {
|
|
119
146
|
case 0:
|
|
120
|
-
|
|
147
|
+
_b.trys.push([0, 2, , 3]);
|
|
121
148
|
projectPath = process.cwd();
|
|
122
149
|
defaultPort = options.port;
|
|
123
150
|
frontDisplayPath = path.dirname(require.resolve('@signageos/front-display/package.json', { paths: [projectPath] }));
|
|
124
151
|
frontDisplayDistPath_1 = path.join(frontDisplayPath, 'dist');
|
|
152
|
+
packagePath = path.join(projectPath, 'package.json');
|
|
153
|
+
packageConfig = fsExtra.pathExistsSync(packagePath)
|
|
154
|
+
? JSON.parse(fsExtra.readFileSync(packagePath).toString())
|
|
155
|
+
: { version: '0.0.0' };
|
|
156
|
+
return [4 /*yield*/, sosControlHelper_1.loadConfig()];
|
|
157
|
+
case 1:
|
|
158
|
+
sosGlobalConfig = _b.sent();
|
|
159
|
+
organizationUid = sosGlobalConfig.defaultOrganizationUid;
|
|
160
|
+
if (!organizationUid) {
|
|
161
|
+
throw new Error("No default organization selected. Use " + chalk.green('sos organization set-default') + " first.");
|
|
162
|
+
}
|
|
125
163
|
lastCompilationAssets_1 = {};
|
|
126
|
-
envVars_1 = {
|
|
164
|
+
envVars_1 = {
|
|
165
|
+
uid: ((_a = packageConfig.sos) === null || _a === void 0 ? void 0 : _a.appletUid) || '__default_timing__',
|
|
166
|
+
version: packageConfig.version,
|
|
167
|
+
organizationUid: organizationUid,
|
|
168
|
+
binaryFilePath: APPLET_DIRECTORY_PATH + "/index.html",
|
|
169
|
+
checksum: '',
|
|
170
|
+
frontAppletVersion: '',
|
|
171
|
+
frontAppletBinaryFile: '',
|
|
172
|
+
};
|
|
127
173
|
app = express();
|
|
128
174
|
app.use(cors());
|
|
129
175
|
app.get('/display.appcache', function (_req, res) {
|
|
@@ -133,21 +179,22 @@ function createEmulator(options) {
|
|
|
133
179
|
res.send("CACHE MANIFEST\n# v1 - " + currentDate.toISOString() + "\n/tmp\nNETWORK:\n*\n");
|
|
134
180
|
});
|
|
135
181
|
app.get('/', function (_req, res) {
|
|
136
|
-
res.send("<script
|
|
137
|
-
+ (
|
|
138
|
-
+ fs.readFileSync(path.join(frontDisplayDistPath_1, 'index.html')).toString());
|
|
182
|
+
res.send("<script>\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET = {};\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.binaryFile = location.origin + " + JSON.stringify(envVars_1.binaryFilePath) + ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.uid = " + JSON.stringify(envVars_1.uid) + ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.version = " + JSON.stringify(envVars_1.version) + ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.checksum = " + JSON.stringify(envVars_1.checksum) + ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.frontAppletVersion = " + JSON.stringify(envVars_1.frontAppletVersion) + ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.frontAppletBinaryFile = " + JSON.stringify(envVars_1.frontAppletBinaryFile) + ";\n\t\t\t\t\twindow.__SOS_AUTO_VERIFICATION = {};\n\t\t\t\t\twindow.__SOS_AUTO_VERIFICATION.organizationUid = " + JSON.stringify(envVars_1.organizationUid) + ";\n\t\t\t\t</script>"
|
|
183
|
+
+ fsExtra.readFileSync(path.join(frontDisplayDistPath_1, 'index.html')).toString());
|
|
139
184
|
});
|
|
140
185
|
app.use(serveStatic(frontDisplayDistPath_1));
|
|
141
186
|
server_1 = http.createServer(app);
|
|
142
187
|
server_1.listen(defaultPort, function () {
|
|
143
188
|
console.log("Emulator is running at " + chalk.blue(chalk.bold(createDomain(options, server_1))));
|
|
144
189
|
});
|
|
145
|
-
|
|
146
|
-
appletDirectoryPath = '/applet';
|
|
147
|
-
appletBinaryFileUrl = "" + defaultUrl + appletDirectoryPath + "/index.html";
|
|
148
|
-
app.use(appletDirectoryPath, function (req, res, next) {
|
|
190
|
+
app.use(APPLET_DIRECTORY_PATH, function (req, res, next) {
|
|
149
191
|
var fileUrl = url.parse(req.url);
|
|
150
192
|
var relativeFilePath = fileUrl.pathname ? fileUrl.pathname.substr(1) : '';
|
|
193
|
+
if (!currentCompilation_1) {
|
|
194
|
+
res.status(502).send('<span style="background-color: darkred;">Webpack is starting up. Please wait a second & try it again.</span>');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
var fileSystem = getCompilationFileSystem(currentCompilation_1.compiler.outputFileSystem);
|
|
151
198
|
if (relativeFilePath === 'index.html') {
|
|
152
199
|
if (typeof lastCompilationAssets_1[relativeFilePath] === 'undefined') {
|
|
153
200
|
res.status(404).send();
|
|
@@ -163,33 +210,18 @@ function createEmulator(options) {
|
|
|
163
210
|
var compiledFilePath = lastCompilationAssets_1[relativeFilePath].existsAt;
|
|
164
211
|
var contentType = mime.getType(relativeFilePath) || 'application/octet-stream';
|
|
165
212
|
res.setHeader('Content-Type', contentType);
|
|
166
|
-
var readStream =
|
|
213
|
+
var readStream = fileSystem.createReadStream(compiledFilePath);
|
|
167
214
|
readStream.pipe(res);
|
|
168
215
|
}
|
|
169
216
|
else {
|
|
170
217
|
next();
|
|
171
218
|
}
|
|
172
219
|
});
|
|
173
|
-
packageConfig = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json')).toString());
|
|
174
|
-
return [4 /*yield*/, runControlHelper_1.loadConfig()];
|
|
175
|
-
case 1:
|
|
176
|
-
sosGlobalConfig = _a.sent();
|
|
177
|
-
organizationUid = sosGlobalConfig.defaultOrganizationUid;
|
|
178
|
-
if (!organizationUid) {
|
|
179
|
-
throw new Error("No default organization selected. Use " + chalk.green('sos organization set-default') + " first.");
|
|
180
|
-
}
|
|
181
|
-
envVars_1 = {
|
|
182
|
-
version: packageConfig.version,
|
|
183
|
-
binaryFile: appletBinaryFileUrl,
|
|
184
|
-
frontAppletVersion: '',
|
|
185
|
-
frontAppletBinaryFile: '',
|
|
186
|
-
organizationUid: organizationUid,
|
|
187
|
-
};
|
|
188
220
|
return [2 /*return*/, {
|
|
189
221
|
notifyDone: function (stats) {
|
|
190
222
|
try {
|
|
191
223
|
console.log('SOS Applet compilation done');
|
|
192
|
-
envVars_1 =
|
|
224
|
+
envVars_1.checksum = stats.compilation.hash;
|
|
193
225
|
debug('process.env', envVars_1);
|
|
194
226
|
if (typeof stats.compilation.assets['index.html'] === 'undefined') {
|
|
195
227
|
console.warn("Applet has to have " + chalk.green('index.html') + " in output files.");
|
|
@@ -208,7 +240,7 @@ function createEmulator(options) {
|
|
|
208
240
|
},
|
|
209
241
|
}];
|
|
210
242
|
case 2:
|
|
211
|
-
error_1 =
|
|
243
|
+
error_1 = _b.sent();
|
|
212
244
|
console.error(error_1);
|
|
213
245
|
process.exit(1);
|
|
214
246
|
return [3 /*break*/, 3];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRo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