hotstaq 0.8.17 → 0.8.19
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/build/src/Hot.js +227 -343
- package/build/src/Hot.js.map +1 -1
- package/build/src/HotAPI.js +104 -185
- package/build/src/HotAPI.js.map +1 -1
- package/build/src/HotAgentAPI.js +17 -67
- package/build/src/HotAgentAPI.js.map +1 -1
- package/build/src/HotAgentRoute.js +22 -70
- package/build/src/HotAgentRoute.js.map +1 -1
- package/build/src/HotAsset.js +19 -21
- package/build/src/HotAsset.js.map +1 -1
- package/build/src/HotBuilder.js +426 -715
- package/build/src/HotBuilder.js.map +1 -1
- package/build/src/HotCLI.js +1189 -1536
- package/build/src/HotCLI.js.map +1 -1
- package/build/src/HotClient.js +4 -5
- package/build/src/HotClient.js.map +1 -1
- package/build/src/HotComponent.js +6 -8
- package/build/src/HotComponent.js.map +1 -1
- package/build/src/HotCreator.js +328 -428
- package/build/src/HotCreator.js.map +1 -1
- package/build/src/HotDB.js +3 -7
- package/build/src/HotDB.js.map +1 -1
- package/build/src/HotFile.d.ts.map +1 -1
- package/build/src/HotFile.js +250 -252
- package/build/src/HotFile.js.map +1 -1
- package/build/src/HotGenerator.js +626 -502
- package/build/src/HotGenerator.js.map +1 -1
- package/build/src/HotHTTPServer.d.ts.map +1 -1
- package/build/src/HotHTTPServer.js +580 -839
- package/build/src/HotHTTPServer.js.map +1 -1
- package/build/src/HotHTTPServerProcessRequest.js +112 -182
- package/build/src/HotHTTPServerProcessRequest.js.map +1 -1
- package/build/src/HotHTTPServerThread.js +6 -41
- package/build/src/HotHTTPServerThread.js.map +1 -1
- package/build/src/HotIO.js +131 -218
- package/build/src/HotIO.js.map +1 -1
- package/build/src/HotLog.js +17 -19
- package/build/src/HotLog.js.map +1 -1
- package/build/src/HotModule.js +47 -96
- package/build/src/HotModule.js.map +1 -1
- package/build/src/HotPage.js +41 -103
- package/build/src/HotPage.js.map +1 -1
- package/build/src/HotRoute.js +13 -18
- package/build/src/HotRoute.js.map +1 -1
- package/build/src/HotRouteMethod.js +38 -49
- package/build/src/HotRouteMethod.js.map +1 -1
- package/build/src/HotServer.js +11 -40
- package/build/src/HotServer.js.map +1 -1
- package/build/src/HotSetAsWeb.js +1 -1
- package/build/src/HotSetAsWeb.js.map +1 -1
- package/build/src/HotStaq.js +889 -1079
- package/build/src/HotStaq.js.map +1 -1
- package/build/src/HotStaqRegisterComponent.js +115 -140
- package/build/src/HotStaqRegisterComponent.js.map +1 -1
- package/build/src/HotStaqWebStart.js +207 -242
- package/build/src/HotStaqWebStart.js.map +1 -1
- package/build/src/HotTestDestination.js +3 -6
- package/build/src/HotTestDestination.js.map +1 -1
- package/build/src/HotTestDriver.js +32 -83
- package/build/src/HotTestDriver.js.map +1 -1
- package/build/src/HotTestElement.js +6 -11
- package/build/src/HotTestElement.js.map +1 -1
- package/build/src/HotTestMap.js +8 -12
- package/build/src/HotTestMap.js.map +1 -1
- package/build/src/HotTestSeleniumDriver.js +279 -438
- package/build/src/HotTestSeleniumDriver.js.map +1 -1
- package/build/src/HotTestUIDriver.js +5 -23
- package/build/src/HotTestUIDriver.js.map +1 -1
- package/build/src/HotTester.js +321 -555
- package/build/src/HotTester.js.map +1 -1
- package/build/src/HotTesterAPI.js +80 -145
- package/build/src/HotTesterAPI.js.map +1 -1
- package/build/src/HotTesterMocha.js +104 -212
- package/build/src/HotTesterMocha.js.map +1 -1
- package/build/src/HotTesterMochaSelenium.js +124 -235
- package/build/src/HotTesterMochaSelenium.js.map +1 -1
- package/build/src/HotTesterServer.js +295 -472
- package/build/src/HotTesterServer.js.map +1 -1
- package/build/src/HotWebSocketClient.js +14 -17
- package/build/src/HotWebSocketClient.js.map +1 -1
- package/build/src/HotWebSocketServer.js +143 -242
- package/build/src/HotWebSocketServer.js.map +1 -1
- package/build/src/api-web.js +19 -19
- package/build/src/api-web.js.map +1 -1
- package/build/src/api.js +33 -33
- package/build/src/api.js.map +1 -1
- package/build/src/index.js +5 -39
- package/build/src/index.js.map +1 -1
- package/build/src/schemas/HotDBInflux.js +104 -178
- package/build/src/schemas/HotDBInflux.js.map +1 -1
- package/build/src/schemas/HotDBMigration.js +3 -5
- package/build/src/schemas/HotDBMigration.js.map +1 -1
- package/build/src/schemas/HotDBMySQL.js +154 -278
- package/build/src/schemas/HotDBMySQL.js.map +1 -1
- package/build/src/schemas/HotDBSchema.js +3 -4
- package/build/src/schemas/HotDBSchema.js.map +1 -1
- package/build/src/schemas/influx/InfluxSchema.js +6 -24
- package/build/src/schemas/influx/InfluxSchema.js.map +1 -1
- package/build/src/schemas/mysql/MySQLSchema.js +33 -108
- package/build/src/schemas/mysql/MySQLSchema.js.map +1 -1
- package/build/src/schemas/mysql/MySQLSchemaField.js +73 -117
- package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -1
- package/build/src/schemas/mysql/MySQLSchemaTable.js +184 -244
- package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -1
- package/build-web/HotStaq.js +2 -2
- package/build-web/HotStaq.min.js +6 -6
- package/builder/docker/dockerignore +1 -2
- package/creator/project/npmignore +2 -0
- package/creator/ts/tsconfig-web.json +1 -1
- package/creator/ts/tsconfig.json +1 -1
- package/package.json +1 -1
- package/src/HotFile.ts +6 -2
- package/src/HotHTTPServer.ts +6 -0
- package/src/HotStaq.ts +1 -1
- package/tsconfig.json +1 -1
package/build/src/Hot.js
CHANGED
|
@@ -8,44 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.Hot = exports.DeveloperMode = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
16
|
+
const HotFile_1 = require("./HotFile");
|
|
17
|
+
const HotStaq_1 = require("./HotStaq");
|
|
18
|
+
const HotTestElement_1 = require("./HotTestElement");
|
|
19
|
+
const js_cookie_1 = __importDefault(require("js-cookie"));
|
|
20
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
21
|
+
const HotRouteMethod_1 = require("./HotRouteMethod");
|
|
49
22
|
/**
|
|
50
23
|
* The available developer modes.
|
|
51
24
|
*/
|
|
@@ -65,191 +38,125 @@ var DeveloperMode;
|
|
|
65
38
|
/**
|
|
66
39
|
* The api used during processing.
|
|
67
40
|
*/
|
|
68
|
-
|
|
69
|
-
function Hot() {
|
|
70
|
-
}
|
|
41
|
+
class Hot {
|
|
71
42
|
/**
|
|
72
43
|
* Retrieve a file and echo out it's contents.
|
|
73
44
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// will ensure the server sends only the file content.
|
|
86
|
-
if (lowerFile.indexOf(".hott") > -1) {
|
|
87
|
-
if (lowerFile.indexOf("nahfam") < 0)
|
|
88
|
-
file += "?hstqserve=nahfam";
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
_b = (_a = Hot).echo;
|
|
93
|
-
return [4 /*yield*/, Hot.getFile(file, args)];
|
|
94
|
-
case 1:
|
|
95
|
-
_b.apply(_a, [_c.sent()]);
|
|
96
|
-
return [2 /*return*/];
|
|
45
|
+
static include(file, args = null) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (HotStaq_1.HotStaq.isWeb === true) {
|
|
48
|
+
if (typeof (file) === "string") {
|
|
49
|
+
const lowerFile = file.toLowerCase();
|
|
50
|
+
// If the file to be included does not have a nahfam, add it. This
|
|
51
|
+
// will ensure the server sends only the file content.
|
|
52
|
+
if (lowerFile.indexOf(".hott") > -1) {
|
|
53
|
+
if (lowerFile.indexOf("nahfam") < 0)
|
|
54
|
+
file += "?hstqserve=nahfam";
|
|
55
|
+
}
|
|
97
56
|
}
|
|
98
|
-
}
|
|
57
|
+
}
|
|
58
|
+
Hot.echo(yield Hot.getFile(file, args));
|
|
99
59
|
});
|
|
100
|
-
}
|
|
60
|
+
}
|
|
101
61
|
/**
|
|
102
62
|
* Include and execute JavaScript for use when running the preprocessor.
|
|
103
63
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
parentObject = window;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (parentObject == null)
|
|
120
|
-
parentObject = global;
|
|
121
|
-
}
|
|
122
|
-
return [2 /*return*/, (eval.apply(parentObject, [output]))];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
64
|
+
static includeJS(file, args = null, parentObject = null) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const output = yield Hot.getFile(file, args);
|
|
67
|
+
if (HotStaq_1.HotStaq.isWeb === true) {
|
|
68
|
+
if (parentObject == null)
|
|
69
|
+
parentObject = window;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (parentObject == null)
|
|
73
|
+
parentObject = global;
|
|
74
|
+
}
|
|
75
|
+
return (eval.apply(parentObject, [output]));
|
|
125
76
|
});
|
|
126
|
-
}
|
|
77
|
+
}
|
|
127
78
|
/**
|
|
128
79
|
* Retrieve a file and echo out it's contents.
|
|
129
80
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (parentObject == null)
|
|
151
|
-
parentObject = global;
|
|
152
|
-
}
|
|
153
|
-
newModule = new Function(output).apply(parentObject);
|
|
154
|
-
if (!(newModule.loadHTML != null)) return [3 /*break*/, 3];
|
|
155
|
-
return [4 /*yield*/, newModule.loadHTML()];
|
|
156
|
-
case 2:
|
|
157
|
-
_a.sent();
|
|
158
|
-
_a.label = 3;
|
|
159
|
-
case 3:
|
|
160
|
-
Hot.CurrentPage.processor.addModule(moduleName, newModule);
|
|
161
|
-
return [2 /*return*/, (newModule)];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
81
|
+
static import(moduleName, args = null, parentObject = null) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
let foundModule = Hot.CurrentPage.processor.getModule(moduleName);
|
|
84
|
+
if (foundModule != null)
|
|
85
|
+
return (foundModule);
|
|
86
|
+
const file = `./hotstaq_modules/${moduleName}/index.js`;
|
|
87
|
+
const output = yield Hot.getFile(file, args);
|
|
88
|
+
if (HotStaq_1.HotStaq.isWeb === true) {
|
|
89
|
+
if (parentObject == null)
|
|
90
|
+
parentObject = window;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (parentObject == null)
|
|
94
|
+
parentObject = global;
|
|
95
|
+
}
|
|
96
|
+
let newModule = new Function(output).apply(parentObject);
|
|
97
|
+
if (newModule.loadHTML != null)
|
|
98
|
+
yield newModule.loadHTML();
|
|
99
|
+
Hot.CurrentPage.processor.addModule(moduleName, newModule);
|
|
100
|
+
return (newModule);
|
|
164
101
|
});
|
|
165
|
-
}
|
|
102
|
+
}
|
|
166
103
|
/**
|
|
167
104
|
* Run an already loaded file and echo out it's contents.
|
|
168
105
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
tempFile.page = this.CurrentPage;
|
|
179
|
-
return [4 /*yield*/, tempFile.process(args)];
|
|
180
|
-
case 1:
|
|
181
|
-
content = _a.sent();
|
|
182
|
-
Hot.echo(content);
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
106
|
+
static runFile(fileName, args = null) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
let file = Hot.CurrentPage.processor.getFile(fileName);
|
|
109
|
+
/// @fixme Does the file need to be deep cloned first?
|
|
110
|
+
//let clonedFile: HotFile = new HotFile (Object.assign ({}, file));
|
|
111
|
+
let tempFile = file;
|
|
112
|
+
tempFile.page = this.CurrentPage;
|
|
113
|
+
let content = yield tempFile.process(args);
|
|
114
|
+
Hot.echo(content);
|
|
186
115
|
});
|
|
187
|
-
}
|
|
116
|
+
}
|
|
188
117
|
/**
|
|
189
118
|
* Get the content of a file.
|
|
190
119
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
tempFile = checkFile;
|
|
212
|
-
return [4 /*yield*/, tempFile.load()];
|
|
213
|
-
case 1:
|
|
214
|
-
_a.sent();
|
|
215
|
-
tempFile.page = this.CurrentPage;
|
|
216
|
-
return [4 /*yield*/, tempFile.process(args)];
|
|
217
|
-
case 2:
|
|
218
|
-
content = _a.sent();
|
|
219
|
-
return [2 /*return*/, (content)];
|
|
220
|
-
}
|
|
221
|
-
});
|
|
120
|
+
static getFile(path, args = null) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
let tempFile = null;
|
|
123
|
+
if (typeof (path) === "string") {
|
|
124
|
+
tempFile = new HotFile_1.HotFile();
|
|
125
|
+
tempFile.name = path;
|
|
126
|
+
if (HotStaq_1.HotStaq.isWeb === true)
|
|
127
|
+
tempFile.url = path;
|
|
128
|
+
else
|
|
129
|
+
tempFile.localFile = path;
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
tempFile = path;
|
|
133
|
+
let checkFile = Hot.CurrentPage.processor.getFile(tempFile.name, false);
|
|
134
|
+
if (checkFile != null)
|
|
135
|
+
tempFile = checkFile;
|
|
136
|
+
yield tempFile.load();
|
|
137
|
+
tempFile.page = this.CurrentPage;
|
|
138
|
+
let content = yield tempFile.process(args);
|
|
139
|
+
return (content);
|
|
222
140
|
});
|
|
223
|
-
}
|
|
141
|
+
}
|
|
224
142
|
/**
|
|
225
143
|
* Make an api call.
|
|
226
144
|
*/
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
throw new Error("Current page's processor is null!");
|
|
241
|
-
if (Hot.CurrentPage.processor.api == null)
|
|
242
|
-
throw new Error("Current page's processor api is null! Did you forget to set the API name or URL?");
|
|
243
|
-
if (!(Hot.CurrentPage.processor.api != null)) return [3 /*break*/, 2];
|
|
244
|
-
return [4 /*yield*/, Hot.CurrentPage.processor.api.makeCall(route, data, httpMethod, files)];
|
|
245
|
-
case 1:
|
|
246
|
-
result = _a.sent();
|
|
247
|
-
_a.label = 2;
|
|
248
|
-
case 2: return [2 /*return*/, (result)];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
145
|
+
static apiCall(route, data = null, httpMethod = HotRouteMethod_1.HotEventMethod.POST, files = {}) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
let result = null;
|
|
148
|
+
if (Hot.CurrentPage == null)
|
|
149
|
+
throw new Error("Current page is null!");
|
|
150
|
+
if (Hot.CurrentPage.processor == null)
|
|
151
|
+
throw new Error("Current page's processor is null!");
|
|
152
|
+
if (Hot.CurrentPage.processor.api == null)
|
|
153
|
+
throw new Error("Current page's processor api is null! Did you forget to set the API name or URL?");
|
|
154
|
+
if (Hot.CurrentPage.processor.api != null) {
|
|
155
|
+
result = yield Hot.CurrentPage.processor.api.makeCall(route, data, httpMethod, files);
|
|
156
|
+
}
|
|
157
|
+
return (result);
|
|
251
158
|
});
|
|
252
|
-
}
|
|
159
|
+
}
|
|
253
160
|
/**
|
|
254
161
|
* Get a HTTP JSON file or request.
|
|
255
162
|
*
|
|
@@ -257,13 +164,11 @@ var Hot = /** @class */ (function () {
|
|
|
257
164
|
*
|
|
258
165
|
* @returns The parsed JSON object.
|
|
259
166
|
*/
|
|
260
|
-
|
|
261
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
-
return
|
|
263
|
-
return [2 /*return*/, (Hot.jsonRequest(url, null, HotRouteMethod_1.HotEventMethod.GET))];
|
|
264
|
-
});
|
|
167
|
+
static getJSON(url) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
return (Hot.jsonRequest(url, null, HotRouteMethod_1.HotEventMethod.GET));
|
|
265
170
|
});
|
|
266
|
-
}
|
|
171
|
+
}
|
|
267
172
|
/**
|
|
268
173
|
* Make a HTTP JSON request.
|
|
269
174
|
*
|
|
@@ -273,43 +178,31 @@ var Hot = /** @class */ (function () {
|
|
|
273
178
|
*
|
|
274
179
|
* @returns The parsed JSON object.
|
|
275
180
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
"Content-Type": "application/json"
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
if (httpMethod === HotRouteMethod_1.HotEventMethod.POST) {
|
|
293
|
-
/// @ts-ignore
|
|
294
|
-
fetchObj["body"] = JSON.stringify(data);
|
|
295
|
-
}
|
|
296
|
-
return [4 /*yield*/, (0, node_fetch_1.default)(url, fetchObj)];
|
|
297
|
-
case 1:
|
|
298
|
-
res = _a.sent();
|
|
299
|
-
if (res.ok === false)
|
|
300
|
-
throw new Error("".concat(res.status, ": ").concat(res.statusText));
|
|
301
|
-
return [4 /*yield*/, res.json()];
|
|
302
|
-
case 2:
|
|
303
|
-
result = _a.sent();
|
|
304
|
-
return [2 /*return*/, (result)];
|
|
305
|
-
case 3:
|
|
306
|
-
ex_1 = _a.sent();
|
|
307
|
-
return [2 /*return*/, (JSON.stringify({ "error": "".concat(ex_1.message, " - Could not fetch ").concat(url) }))];
|
|
308
|
-
case 4: return [2 /*return*/];
|
|
181
|
+
static jsonRequest(url, data = null, httpMethod = HotRouteMethod_1.HotEventMethod.POST) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
try {
|
|
184
|
+
let fetchObj = {
|
|
185
|
+
"method": httpMethod,
|
|
186
|
+
"headers": {
|
|
187
|
+
"Accept": "application/json",
|
|
188
|
+
"Content-Type": "application/json"
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
if (httpMethod === HotRouteMethod_1.HotEventMethod.POST) {
|
|
192
|
+
/// @ts-ignore
|
|
193
|
+
fetchObj["body"] = JSON.stringify(data);
|
|
309
194
|
}
|
|
310
|
-
|
|
195
|
+
let res = yield (0, node_fetch_1.default)(url, fetchObj);
|
|
196
|
+
if (res.ok === false)
|
|
197
|
+
throw new Error(`${res.status}: ${res.statusText}`);
|
|
198
|
+
let result = yield res.json();
|
|
199
|
+
return (result);
|
|
200
|
+
}
|
|
201
|
+
catch (ex) {
|
|
202
|
+
return (JSON.stringify({ "error": `${ex.message} - Could not fetch ${url}` }));
|
|
203
|
+
}
|
|
311
204
|
});
|
|
312
|
-
}
|
|
205
|
+
}
|
|
313
206
|
/**
|
|
314
207
|
* Make a HTTP request. This is basically just a wrapper for fetch.
|
|
315
208
|
*
|
|
@@ -318,137 +211,128 @@ var Hot = /** @class */ (function () {
|
|
|
318
211
|
*
|
|
319
212
|
* @returns The HTTP response.
|
|
320
213
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return __generator(this, function (_a) {
|
|
326
|
-
switch (_a.label) {
|
|
327
|
-
case 0: return [4 /*yield*/, (0, node_fetch_1.default)(url, requestInit)];
|
|
328
|
-
case 1:
|
|
329
|
-
res = _a.sent();
|
|
330
|
-
return [2 /*return*/, (res)];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
214
|
+
static httpRequest(url, requestInit = undefined) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
let res = yield (0, node_fetch_1.default)(url, requestInit);
|
|
217
|
+
return (res);
|
|
333
218
|
});
|
|
334
|
-
}
|
|
219
|
+
}
|
|
335
220
|
/**
|
|
336
221
|
* Echo out some output.
|
|
337
222
|
*/
|
|
338
|
-
|
|
223
|
+
static echo(message) {
|
|
339
224
|
Hot.Output += message;
|
|
340
|
-
}
|
|
225
|
+
}
|
|
341
226
|
/**
|
|
342
227
|
* Echo out the CSS for the current page being generated.
|
|
343
228
|
*/
|
|
344
|
-
|
|
345
|
-
for (
|
|
346
|
-
|
|
347
|
-
|
|
229
|
+
static displayCSS() {
|
|
230
|
+
for (let iIdx = 0; iIdx < Hot.CSS.length; iIdx++) {
|
|
231
|
+
let cssFile = Hot.CSS[iIdx];
|
|
232
|
+
let cssOut = Hot.cssStr;
|
|
348
233
|
cssOut = cssOut.replace(/\%CSS_FILE\%/g, cssFile);
|
|
349
234
|
Hot.echo(cssOut);
|
|
350
235
|
}
|
|
351
|
-
}
|
|
236
|
+
}
|
|
352
237
|
/**
|
|
353
238
|
* Echo out the JS files for the current page being generated.
|
|
354
239
|
*/
|
|
355
|
-
|
|
356
|
-
for (
|
|
357
|
-
|
|
358
|
-
|
|
240
|
+
static displayJSFiles() {
|
|
241
|
+
for (let iIdx = 0; iIdx < Hot.JSFiles.length; iIdx++) {
|
|
242
|
+
let jsFile = Hot.JSFiles[iIdx];
|
|
243
|
+
let jsFileOut = Hot.jsFileStr;
|
|
359
244
|
jsFileOut = jsFileOut.replace(/\%JS_FILE\%/g, jsFile);
|
|
360
245
|
Hot.echo(jsFileOut);
|
|
361
246
|
}
|
|
362
|
-
}
|
|
247
|
+
}
|
|
363
248
|
/**
|
|
364
249
|
* Echo out the JS scripts for the current page being generated.
|
|
365
250
|
*/
|
|
366
|
-
|
|
367
|
-
for (
|
|
368
|
-
|
|
369
|
-
|
|
251
|
+
static displayJSScripts() {
|
|
252
|
+
for (let iIdx = 0; iIdx < Hot.JSScripts.length; iIdx++) {
|
|
253
|
+
let jsScript = Hot.JSScripts[iIdx];
|
|
254
|
+
let jsScriptOut = Hot.jsScriptsStr;
|
|
370
255
|
jsScriptOut = jsScriptOut.replace(/\%JS_CODE\%/g, jsScript);
|
|
371
256
|
Hot.echo(jsScriptOut);
|
|
372
257
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
* The currently generated page being displayed. This is cleared between every file processed.
|
|
376
|
-
*/
|
|
377
|
-
Hot.CurrentPage = null;
|
|
378
|
-
/**
|
|
379
|
-
* The arguments passed.
|
|
380
|
-
*/
|
|
381
|
-
Hot.Arguments = null;
|
|
382
|
-
/**
|
|
383
|
-
* The mode in which this application is running. If it's set to development mode, all testing
|
|
384
|
-
* related data will be collected, parsed, and executed if necessary.
|
|
385
|
-
*/
|
|
386
|
-
Hot.DeveloperMode = DeveloperMode;
|
|
387
|
-
/**
|
|
388
|
-
* The mode in which this application is running. If it's set to development mode, all testing
|
|
389
|
-
* related data will be collected, parsed, and executed if necessary.
|
|
390
|
-
*/
|
|
391
|
-
Hot.HotTestElement = HotTestElement_1.HotTestElement;
|
|
392
|
-
/**
|
|
393
|
-
* The mode in which this application is running. If it's set to development mode, all testing
|
|
394
|
-
* related data will be collected, parsed, and executed if necessary.
|
|
395
|
-
*/
|
|
396
|
-
Hot.Mode = DeveloperMode.Production;
|
|
397
|
-
/**
|
|
398
|
-
*The current API used on this page. This is cleared between every file processed.
|
|
399
|
-
*/
|
|
400
|
-
Hot.API = null;
|
|
401
|
-
/**
|
|
402
|
-
* The API being used by the tester.
|
|
403
|
-
*/
|
|
404
|
-
Hot.TesterAPI = null;
|
|
405
|
-
/**
|
|
406
|
-
* Contains the buffer to output. This is cleared between every file processed.
|
|
407
|
-
*/
|
|
408
|
-
Hot.Output = "";
|
|
409
|
-
/**
|
|
410
|
-
* The data to share across all the different files and pages. This data will be public.
|
|
411
|
-
*/
|
|
412
|
-
Hot.Data = {};
|
|
413
|
-
/**
|
|
414
|
-
* The cookies to use between pages.
|
|
415
|
-
*/
|
|
416
|
-
Hot.Cookies = js_cookie_1.default;
|
|
417
|
-
/**
|
|
418
|
-
* Any public keys that need to be shown. These can be passed from HotSite.json.
|
|
419
|
-
*/
|
|
420
|
-
Hot.PublicKeys = {};
|
|
421
|
-
/**
|
|
422
|
-
* The CSS string to use when echoing out the CSS files.
|
|
423
|
-
*/
|
|
424
|
-
Hot.cssStr = "<link rel = \"stylesheet\" href = \"%CSS_FILE%\" />";
|
|
425
|
-
/**
|
|
426
|
-
* The CSS files to use in the current page being generated.
|
|
427
|
-
*
|
|
428
|
-
* @todo Make this a "string | CSSObject" data type so it can also include
|
|
429
|
-
* the integrity hashes as well.
|
|
430
|
-
*/
|
|
431
|
-
Hot.CSS = [];
|
|
432
|
-
/**
|
|
433
|
-
* The JavaScript files to use in the current page being generated.
|
|
434
|
-
*
|
|
435
|
-
* @todo Make this a "string | JSFileObject" data type so it can also include
|
|
436
|
-
* the integrity hashes as well.
|
|
437
|
-
*/
|
|
438
|
-
Hot.JSFiles = [];
|
|
439
|
-
/**
|
|
440
|
-
* The JavaScript inline code to use in the current page being generated.
|
|
441
|
-
*/
|
|
442
|
-
Hot.JSScripts = [];
|
|
443
|
-
/**
|
|
444
|
-
* The JavaScript string to use when echoing out the Scripts files.
|
|
445
|
-
*/
|
|
446
|
-
Hot.jsFileStr = "<script type = \"text/javascript\" src = \"%JS_FILE%\"></script>";
|
|
447
|
-
/**
|
|
448
|
-
* The JavaScript string to use when echoing out the Scripts files.
|
|
449
|
-
*/
|
|
450
|
-
Hot.jsScriptsStr = "<script type = \"text/javascript\">%JS_CODE%</script>";
|
|
451
|
-
return Hot;
|
|
452
|
-
}());
|
|
258
|
+
}
|
|
259
|
+
}
|
|
453
260
|
exports.Hot = Hot;
|
|
261
|
+
/**
|
|
262
|
+
* The currently generated page being displayed. This is cleared between every file processed.
|
|
263
|
+
*/
|
|
264
|
+
Hot.CurrentPage = null;
|
|
265
|
+
/**
|
|
266
|
+
* The arguments passed.
|
|
267
|
+
*/
|
|
268
|
+
Hot.Arguments = null;
|
|
269
|
+
/**
|
|
270
|
+
* The mode in which this application is running. If it's set to development mode, all testing
|
|
271
|
+
* related data will be collected, parsed, and executed if necessary.
|
|
272
|
+
*/
|
|
273
|
+
Hot.DeveloperMode = DeveloperMode;
|
|
274
|
+
/**
|
|
275
|
+
* The mode in which this application is running. If it's set to development mode, all testing
|
|
276
|
+
* related data will be collected, parsed, and executed if necessary.
|
|
277
|
+
*/
|
|
278
|
+
Hot.HotTestElement = HotTestElement_1.HotTestElement;
|
|
279
|
+
/**
|
|
280
|
+
* The mode in which this application is running. If it's set to development mode, all testing
|
|
281
|
+
* related data will be collected, parsed, and executed if necessary.
|
|
282
|
+
*/
|
|
283
|
+
Hot.Mode = DeveloperMode.Production;
|
|
284
|
+
/**
|
|
285
|
+
*The current API used on this page. This is cleared between every file processed.
|
|
286
|
+
*/
|
|
287
|
+
Hot.API = null;
|
|
288
|
+
/**
|
|
289
|
+
* The API being used by the tester.
|
|
290
|
+
*/
|
|
291
|
+
Hot.TesterAPI = null;
|
|
292
|
+
/**
|
|
293
|
+
* Contains the buffer to output. This is cleared between every file processed.
|
|
294
|
+
*/
|
|
295
|
+
Hot.Output = "";
|
|
296
|
+
/**
|
|
297
|
+
* The data to share across all the different files and pages. This data will be public.
|
|
298
|
+
*/
|
|
299
|
+
Hot.Data = {};
|
|
300
|
+
/**
|
|
301
|
+
* The cookies to use between pages.
|
|
302
|
+
*/
|
|
303
|
+
Hot.Cookies = js_cookie_1.default;
|
|
304
|
+
/**
|
|
305
|
+
* Any public keys that need to be shown. These can be passed from HotSite.json.
|
|
306
|
+
*/
|
|
307
|
+
Hot.PublicKeys = {};
|
|
308
|
+
/**
|
|
309
|
+
* The CSS string to use when echoing out the CSS files.
|
|
310
|
+
*/
|
|
311
|
+
Hot.cssStr = `<link rel = "stylesheet" href = "%CSS_FILE%" />`;
|
|
312
|
+
/**
|
|
313
|
+
* The CSS files to use in the current page being generated.
|
|
314
|
+
*
|
|
315
|
+
* @todo Make this a "string | CSSObject" data type so it can also include
|
|
316
|
+
* the integrity hashes as well.
|
|
317
|
+
*/
|
|
318
|
+
Hot.CSS = [];
|
|
319
|
+
/**
|
|
320
|
+
* The JavaScript files to use in the current page being generated.
|
|
321
|
+
*
|
|
322
|
+
* @todo Make this a "string | JSFileObject" data type so it can also include
|
|
323
|
+
* the integrity hashes as well.
|
|
324
|
+
*/
|
|
325
|
+
Hot.JSFiles = [];
|
|
326
|
+
/**
|
|
327
|
+
* The JavaScript inline code to use in the current page being generated.
|
|
328
|
+
*/
|
|
329
|
+
Hot.JSScripts = [];
|
|
330
|
+
/**
|
|
331
|
+
* The JavaScript string to use when echoing out the Scripts files.
|
|
332
|
+
*/
|
|
333
|
+
Hot.jsFileStr = `<script type = "text/javascript" src = "%JS_FILE%"></script>`;
|
|
334
|
+
/**
|
|
335
|
+
* The JavaScript string to use when echoing out the Scripts files.
|
|
336
|
+
*/
|
|
337
|
+
Hot.jsScriptsStr = `<script type = "text/javascript">%JS_CODE%</script>`;
|
|
454
338
|
//# sourceMappingURL=Hot.js.map
|