bun-dev-server 1.0.2 → 1.0.3
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/dist/index.css +164 -0
- package/dist/index.js +862 -792
- package/package.json +8 -4
- package/dist/assets/serveOutputStyles.css +0 -166
package/dist/index.js
CHANGED
|
@@ -4,18 +4,45 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name, newValue) {
|
|
35
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, {
|
|
40
|
+
get: all[name],
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
set: __exportSetter.bind(all, name)
|
|
44
|
+
});
|
|
45
|
+
};
|
|
19
46
|
|
|
20
47
|
// node_modules/picocolors/picocolors.js
|
|
21
48
|
var require_picocolors = __commonJS((exports, module) => {
|
|
@@ -87,771 +114,11 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
87
114
|
module.exports.createColors = createColors;
|
|
88
115
|
});
|
|
89
116
|
|
|
90
|
-
// node_modules/ejs/lib/utils.js
|
|
91
|
-
var require_utils = __commonJS((exports) => {
|
|
92
|
-
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
93
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
94
|
-
var hasOwn = function(obj, key) {
|
|
95
|
-
return hasOwnProperty.apply(obj, [key]);
|
|
96
|
-
};
|
|
97
|
-
exports.escapeRegExpChars = function(string) {
|
|
98
|
-
if (!string) {
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
return String(string).replace(regExpChars, "\\$&");
|
|
102
|
-
};
|
|
103
|
-
var _ENCODE_HTML_RULES = {
|
|
104
|
-
"&": "&",
|
|
105
|
-
"<": "<",
|
|
106
|
-
">": ">",
|
|
107
|
-
'"': """,
|
|
108
|
-
"'": "'"
|
|
109
|
-
};
|
|
110
|
-
var _MATCH_HTML = /[&<>'"]/g;
|
|
111
|
-
function encode_char(c) {
|
|
112
|
-
return _ENCODE_HTML_RULES[c] || c;
|
|
113
|
-
}
|
|
114
|
-
var escapeFuncStr = `var _ENCODE_HTML_RULES = {
|
|
115
|
-
` + ` "&": "&"
|
|
116
|
-
` + ` , "<": "<"
|
|
117
|
-
` + ` , ">": ">"
|
|
118
|
-
` + ` , '"': """
|
|
119
|
-
` + ` , "'": "'"
|
|
120
|
-
` + ` }
|
|
121
|
-
` + ` , _MATCH_HTML = /[&<>'"]/g;
|
|
122
|
-
` + `function encode_char(c) {
|
|
123
|
-
` + ` return _ENCODE_HTML_RULES[c] || c;
|
|
124
|
-
` + `};
|
|
125
|
-
`;
|
|
126
|
-
exports.escapeXML = function(markup) {
|
|
127
|
-
return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
128
|
-
};
|
|
129
|
-
function escapeXMLToString() {
|
|
130
|
-
return Function.prototype.toString.call(this) + `;
|
|
131
|
-
` + escapeFuncStr;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
if (typeof Object.defineProperty === "function") {
|
|
135
|
-
Object.defineProperty(exports.escapeXML, "toString", { value: escapeXMLToString });
|
|
136
|
-
} else {
|
|
137
|
-
exports.escapeXML.toString = escapeXMLToString;
|
|
138
|
-
}
|
|
139
|
-
} catch (err) {
|
|
140
|
-
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
141
|
-
}
|
|
142
|
-
exports.shallowCopy = function(to, from) {
|
|
143
|
-
from = from || {};
|
|
144
|
-
if (to !== null && to !== undefined) {
|
|
145
|
-
for (var p in from) {
|
|
146
|
-
if (!hasOwn(from, p)) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (p === "__proto__" || p === "constructor") {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
to[p] = from[p];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return to;
|
|
156
|
-
};
|
|
157
|
-
exports.shallowCopyFromList = function(to, from, list) {
|
|
158
|
-
list = list || [];
|
|
159
|
-
from = from || {};
|
|
160
|
-
if (to !== null && to !== undefined) {
|
|
161
|
-
for (var i = 0;i < list.length; i++) {
|
|
162
|
-
var p = list[i];
|
|
163
|
-
if (typeof from[p] != "undefined") {
|
|
164
|
-
if (!hasOwn(from, p)) {
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (p === "__proto__" || p === "constructor") {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
to[p] = from[p];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return to;
|
|
175
|
-
};
|
|
176
|
-
exports.cache = {
|
|
177
|
-
_data: {},
|
|
178
|
-
set: function(key, val) {
|
|
179
|
-
this._data[key] = val;
|
|
180
|
-
},
|
|
181
|
-
get: function(key) {
|
|
182
|
-
return this._data[key];
|
|
183
|
-
},
|
|
184
|
-
remove: function(key) {
|
|
185
|
-
delete this._data[key];
|
|
186
|
-
},
|
|
187
|
-
reset: function() {
|
|
188
|
-
this._data = {};
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
exports.hyphenToCamel = function(str) {
|
|
192
|
-
return str.replace(/-[a-z]/g, function(match) {
|
|
193
|
-
return match[1].toUpperCase();
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
exports.createNullProtoObjWherePossible = function() {
|
|
197
|
-
if (typeof Object.create == "function") {
|
|
198
|
-
return function() {
|
|
199
|
-
return Object.create(null);
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
if (!({ __proto__: null } instanceof Object)) {
|
|
203
|
-
return function() {
|
|
204
|
-
return { __proto__: null };
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
return function() {
|
|
208
|
-
return {};
|
|
209
|
-
};
|
|
210
|
-
}();
|
|
211
|
-
exports.hasOwnOnlyObject = function(obj) {
|
|
212
|
-
var o = exports.createNullProtoObjWherePossible();
|
|
213
|
-
for (var p in obj) {
|
|
214
|
-
if (hasOwn(obj, p)) {
|
|
215
|
-
o[p] = obj[p];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return o;
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// node_modules/ejs/package.json
|
|
223
|
-
var require_package = __commonJS((exports, module) => {
|
|
224
|
-
module.exports = {
|
|
225
|
-
name: "ejs",
|
|
226
|
-
description: "Embedded JavaScript templates",
|
|
227
|
-
keywords: [
|
|
228
|
-
"template",
|
|
229
|
-
"engine",
|
|
230
|
-
"ejs"
|
|
231
|
-
],
|
|
232
|
-
version: "3.1.10",
|
|
233
|
-
author: "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
|
234
|
-
license: "Apache-2.0",
|
|
235
|
-
bin: {
|
|
236
|
-
ejs: "./bin/cli.js"
|
|
237
|
-
},
|
|
238
|
-
main: "./lib/ejs.js",
|
|
239
|
-
jsdelivr: "ejs.min.js",
|
|
240
|
-
unpkg: "ejs.min.js",
|
|
241
|
-
repository: {
|
|
242
|
-
type: "git",
|
|
243
|
-
url: "git://github.com/mde/ejs.git"
|
|
244
|
-
},
|
|
245
|
-
bugs: "https://github.com/mde/ejs/issues",
|
|
246
|
-
homepage: "https://github.com/mde/ejs",
|
|
247
|
-
dependencies: {
|
|
248
|
-
jake: "^10.8.5"
|
|
249
|
-
},
|
|
250
|
-
devDependencies: {
|
|
251
|
-
browserify: "^16.5.1",
|
|
252
|
-
eslint: "^6.8.0",
|
|
253
|
-
"git-directory-deploy": "^1.5.1",
|
|
254
|
-
jsdoc: "^4.0.2",
|
|
255
|
-
"lru-cache": "^4.0.1",
|
|
256
|
-
mocha: "^10.2.0",
|
|
257
|
-
"uglify-js": "^3.3.16"
|
|
258
|
-
},
|
|
259
|
-
engines: {
|
|
260
|
-
node: ">=0.10.0"
|
|
261
|
-
},
|
|
262
|
-
scripts: {
|
|
263
|
-
test: "npx jake test"
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
// node_modules/ejs/lib/ejs.js
|
|
269
|
-
var require_ejs = __commonJS((exports) => {
|
|
270
|
-
var fs = import.meta.require("fs");
|
|
271
|
-
var path = import.meta.require("path");
|
|
272
|
-
var utils = require_utils();
|
|
273
|
-
var scopeOptionWarned = false;
|
|
274
|
-
var _VERSION_STRING = require_package().version;
|
|
275
|
-
var _DEFAULT_OPEN_DELIMITER = "<";
|
|
276
|
-
var _DEFAULT_CLOSE_DELIMITER = ">";
|
|
277
|
-
var _DEFAULT_DELIMITER = "%";
|
|
278
|
-
var _DEFAULT_LOCALS_NAME = "locals";
|
|
279
|
-
var _NAME = "ejs";
|
|
280
|
-
var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
281
|
-
var _OPTS_PASSABLE_WITH_DATA = [
|
|
282
|
-
"delimiter",
|
|
283
|
-
"scope",
|
|
284
|
-
"context",
|
|
285
|
-
"debug",
|
|
286
|
-
"compileDebug",
|
|
287
|
-
"client",
|
|
288
|
-
"_with",
|
|
289
|
-
"rmWhitespace",
|
|
290
|
-
"strict",
|
|
291
|
-
"filename",
|
|
292
|
-
"async"
|
|
293
|
-
];
|
|
294
|
-
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
295
|
-
var _BOM = /^\uFEFF/;
|
|
296
|
-
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
297
|
-
exports.cache = utils.cache;
|
|
298
|
-
exports.fileLoader = fs.readFileSync;
|
|
299
|
-
exports.localsName = _DEFAULT_LOCALS_NAME;
|
|
300
|
-
exports.promiseImpl = new Function("return this;")().Promise;
|
|
301
|
-
exports.resolveInclude = function(name, filename, isDir) {
|
|
302
|
-
var dirname = path.dirname;
|
|
303
|
-
var extname = path.extname;
|
|
304
|
-
var resolve = path.resolve;
|
|
305
|
-
var includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
306
|
-
var ext = extname(name);
|
|
307
|
-
if (!ext) {
|
|
308
|
-
includePath += ".ejs";
|
|
309
|
-
}
|
|
310
|
-
return includePath;
|
|
311
|
-
};
|
|
312
|
-
function resolvePaths(name, paths) {
|
|
313
|
-
var filePath;
|
|
314
|
-
if (paths.some(function(v) {
|
|
315
|
-
filePath = exports.resolveInclude(name, v, true);
|
|
316
|
-
return fs.existsSync(filePath);
|
|
317
|
-
})) {
|
|
318
|
-
return filePath;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
function getIncludePath(path2, options) {
|
|
322
|
-
var includePath;
|
|
323
|
-
var filePath;
|
|
324
|
-
var views = options.views;
|
|
325
|
-
var match = /^[A-Za-z]+:\\|^\//.exec(path2);
|
|
326
|
-
if (match && match.length) {
|
|
327
|
-
path2 = path2.replace(/^\/*/, "");
|
|
328
|
-
if (Array.isArray(options.root)) {
|
|
329
|
-
includePath = resolvePaths(path2, options.root);
|
|
330
|
-
} else {
|
|
331
|
-
includePath = exports.resolveInclude(path2, options.root || "/", true);
|
|
332
|
-
}
|
|
333
|
-
} else {
|
|
334
|
-
if (options.filename) {
|
|
335
|
-
filePath = exports.resolveInclude(path2, options.filename);
|
|
336
|
-
if (fs.existsSync(filePath)) {
|
|
337
|
-
includePath = filePath;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (!includePath && Array.isArray(views)) {
|
|
341
|
-
includePath = resolvePaths(path2, views);
|
|
342
|
-
}
|
|
343
|
-
if (!includePath && typeof options.includer !== "function") {
|
|
344
|
-
throw new Error('Could not find the include file "' + options.escapeFunction(path2) + '"');
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return includePath;
|
|
348
|
-
}
|
|
349
|
-
function handleCache(options, template) {
|
|
350
|
-
var func;
|
|
351
|
-
var filename = options.filename;
|
|
352
|
-
var hasTemplate = arguments.length > 1;
|
|
353
|
-
if (options.cache) {
|
|
354
|
-
if (!filename) {
|
|
355
|
-
throw new Error("cache option requires a filename");
|
|
356
|
-
}
|
|
357
|
-
func = exports.cache.get(filename);
|
|
358
|
-
if (func) {
|
|
359
|
-
return func;
|
|
360
|
-
}
|
|
361
|
-
if (!hasTemplate) {
|
|
362
|
-
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
363
|
-
}
|
|
364
|
-
} else if (!hasTemplate) {
|
|
365
|
-
if (!filename) {
|
|
366
|
-
throw new Error("Internal EJS error: no file name or template " + "provided");
|
|
367
|
-
}
|
|
368
|
-
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
369
|
-
}
|
|
370
|
-
func = exports.compile(template, options);
|
|
371
|
-
if (options.cache) {
|
|
372
|
-
exports.cache.set(filename, func);
|
|
373
|
-
}
|
|
374
|
-
return func;
|
|
375
|
-
}
|
|
376
|
-
function tryHandleCache(options, data, cb) {
|
|
377
|
-
var result;
|
|
378
|
-
if (!cb) {
|
|
379
|
-
if (typeof exports.promiseImpl == "function") {
|
|
380
|
-
return new exports.promiseImpl(function(resolve, reject) {
|
|
381
|
-
try {
|
|
382
|
-
result = handleCache(options)(data);
|
|
383
|
-
resolve(result);
|
|
384
|
-
} catch (err) {
|
|
385
|
-
reject(err);
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
} else {
|
|
389
|
-
throw new Error("Please provide a callback function");
|
|
390
|
-
}
|
|
391
|
-
} else {
|
|
392
|
-
try {
|
|
393
|
-
result = handleCache(options)(data);
|
|
394
|
-
} catch (err) {
|
|
395
|
-
return cb(err);
|
|
396
|
-
}
|
|
397
|
-
cb(null, result);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
function fileLoader(filePath) {
|
|
401
|
-
return exports.fileLoader(filePath);
|
|
402
|
-
}
|
|
403
|
-
function includeFile(path2, options) {
|
|
404
|
-
var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
|
|
405
|
-
opts.filename = getIncludePath(path2, opts);
|
|
406
|
-
if (typeof options.includer === "function") {
|
|
407
|
-
var includerResult = options.includer(path2, opts.filename);
|
|
408
|
-
if (includerResult) {
|
|
409
|
-
if (includerResult.filename) {
|
|
410
|
-
opts.filename = includerResult.filename;
|
|
411
|
-
}
|
|
412
|
-
if (includerResult.template) {
|
|
413
|
-
return handleCache(opts, includerResult.template);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return handleCache(opts);
|
|
418
|
-
}
|
|
419
|
-
function rethrow(err, str, flnm, lineno, esc) {
|
|
420
|
-
var lines = str.split(`
|
|
421
|
-
`);
|
|
422
|
-
var start = Math.max(lineno - 3, 0);
|
|
423
|
-
var end = Math.min(lines.length, lineno + 3);
|
|
424
|
-
var filename = esc(flnm);
|
|
425
|
-
var context = lines.slice(start, end).map(function(line, i) {
|
|
426
|
-
var curr = i + start + 1;
|
|
427
|
-
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
428
|
-
}).join(`
|
|
429
|
-
`);
|
|
430
|
-
err.path = filename;
|
|
431
|
-
err.message = (filename || "ejs") + ":" + lineno + `
|
|
432
|
-
` + context + `
|
|
433
|
-
|
|
434
|
-
` + err.message;
|
|
435
|
-
throw err;
|
|
436
|
-
}
|
|
437
|
-
function stripSemi(str) {
|
|
438
|
-
return str.replace(/;(\s*$)/, "$1");
|
|
439
|
-
}
|
|
440
|
-
exports.compile = function compile(template, opts) {
|
|
441
|
-
var templ;
|
|
442
|
-
if (opts && opts.scope) {
|
|
443
|
-
if (!scopeOptionWarned) {
|
|
444
|
-
console.warn("`scope` option is deprecated and will be removed in EJS 3");
|
|
445
|
-
scopeOptionWarned = true;
|
|
446
|
-
}
|
|
447
|
-
if (!opts.context) {
|
|
448
|
-
opts.context = opts.scope;
|
|
449
|
-
}
|
|
450
|
-
delete opts.scope;
|
|
451
|
-
}
|
|
452
|
-
templ = new Template(template, opts);
|
|
453
|
-
return templ.compile();
|
|
454
|
-
};
|
|
455
|
-
exports.render = function(template, d, o) {
|
|
456
|
-
var data = d || utils.createNullProtoObjWherePossible();
|
|
457
|
-
var opts = o || utils.createNullProtoObjWherePossible();
|
|
458
|
-
if (arguments.length == 2) {
|
|
459
|
-
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
460
|
-
}
|
|
461
|
-
return handleCache(opts, template)(data);
|
|
462
|
-
};
|
|
463
|
-
exports.renderFile = function() {
|
|
464
|
-
var args = Array.prototype.slice.call(arguments);
|
|
465
|
-
var filename = args.shift();
|
|
466
|
-
var cb;
|
|
467
|
-
var opts = { filename };
|
|
468
|
-
var data;
|
|
469
|
-
var viewOpts;
|
|
470
|
-
if (typeof arguments[arguments.length - 1] == "function") {
|
|
471
|
-
cb = args.pop();
|
|
472
|
-
}
|
|
473
|
-
if (args.length) {
|
|
474
|
-
data = args.shift();
|
|
475
|
-
if (args.length) {
|
|
476
|
-
utils.shallowCopy(opts, args.pop());
|
|
477
|
-
} else {
|
|
478
|
-
if (data.settings) {
|
|
479
|
-
if (data.settings.views) {
|
|
480
|
-
opts.views = data.settings.views;
|
|
481
|
-
}
|
|
482
|
-
if (data.settings["view cache"]) {
|
|
483
|
-
opts.cache = true;
|
|
484
|
-
}
|
|
485
|
-
viewOpts = data.settings["view options"];
|
|
486
|
-
if (viewOpts) {
|
|
487
|
-
utils.shallowCopy(opts, viewOpts);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
491
|
-
}
|
|
492
|
-
opts.filename = filename;
|
|
493
|
-
} else {
|
|
494
|
-
data = utils.createNullProtoObjWherePossible();
|
|
495
|
-
}
|
|
496
|
-
return tryHandleCache(opts, data, cb);
|
|
497
|
-
};
|
|
498
|
-
exports.Template = Template;
|
|
499
|
-
exports.clearCache = function() {
|
|
500
|
-
exports.cache.reset();
|
|
501
|
-
};
|
|
502
|
-
function Template(text, optsParam) {
|
|
503
|
-
var opts = utils.hasOwnOnlyObject(optsParam);
|
|
504
|
-
var options = utils.createNullProtoObjWherePossible();
|
|
505
|
-
this.templateText = text;
|
|
506
|
-
this.mode = null;
|
|
507
|
-
this.truncate = false;
|
|
508
|
-
this.currentLine = 1;
|
|
509
|
-
this.source = "";
|
|
510
|
-
options.client = opts.client || false;
|
|
511
|
-
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
512
|
-
options.compileDebug = opts.compileDebug !== false;
|
|
513
|
-
options.debug = !!opts.debug;
|
|
514
|
-
options.filename = opts.filename;
|
|
515
|
-
options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
516
|
-
options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
517
|
-
options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
|
|
518
|
-
options.strict = opts.strict || false;
|
|
519
|
-
options.context = opts.context;
|
|
520
|
-
options.cache = opts.cache || false;
|
|
521
|
-
options.rmWhitespace = opts.rmWhitespace;
|
|
522
|
-
options.root = opts.root;
|
|
523
|
-
options.includer = opts.includer;
|
|
524
|
-
options.outputFunctionName = opts.outputFunctionName;
|
|
525
|
-
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
|
526
|
-
options.views = opts.views;
|
|
527
|
-
options.async = opts.async;
|
|
528
|
-
options.destructuredLocals = opts.destructuredLocals;
|
|
529
|
-
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
530
|
-
if (options.strict) {
|
|
531
|
-
options._with = false;
|
|
532
|
-
} else {
|
|
533
|
-
options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
534
|
-
}
|
|
535
|
-
this.opts = options;
|
|
536
|
-
this.regex = this.createRegex();
|
|
537
|
-
}
|
|
538
|
-
Template.modes = {
|
|
539
|
-
EVAL: "eval",
|
|
540
|
-
ESCAPED: "escaped",
|
|
541
|
-
RAW: "raw",
|
|
542
|
-
COMMENT: "comment",
|
|
543
|
-
LITERAL: "literal"
|
|
544
|
-
};
|
|
545
|
-
Template.prototype = {
|
|
546
|
-
createRegex: function() {
|
|
547
|
-
var str = _REGEX_STRING;
|
|
548
|
-
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
549
|
-
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
550
|
-
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
551
|
-
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
552
|
-
return new RegExp(str);
|
|
553
|
-
},
|
|
554
|
-
compile: function() {
|
|
555
|
-
var src;
|
|
556
|
-
var fn;
|
|
557
|
-
var opts = this.opts;
|
|
558
|
-
var prepended = "";
|
|
559
|
-
var appended = "";
|
|
560
|
-
var escapeFn = opts.escapeFunction;
|
|
561
|
-
var ctor;
|
|
562
|
-
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
563
|
-
if (!this.source) {
|
|
564
|
-
this.generateSource();
|
|
565
|
-
prepended += ` var __output = "";
|
|
566
|
-
` + ` function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
567
|
-
`;
|
|
568
|
-
if (opts.outputFunctionName) {
|
|
569
|
-
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
|
|
570
|
-
throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
571
|
-
}
|
|
572
|
-
prepended += " var " + opts.outputFunctionName + " = __append;" + `
|
|
573
|
-
`;
|
|
574
|
-
}
|
|
575
|
-
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
|
|
576
|
-
throw new Error("localsName is not a valid JS identifier.");
|
|
577
|
-
}
|
|
578
|
-
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
579
|
-
var destructuring = " var __locals = (" + opts.localsName + ` || {}),
|
|
580
|
-
`;
|
|
581
|
-
for (var i = 0;i < opts.destructuredLocals.length; i++) {
|
|
582
|
-
var name = opts.destructuredLocals[i];
|
|
583
|
-
if (!_JS_IDENTIFIER.test(name)) {
|
|
584
|
-
throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
585
|
-
}
|
|
586
|
-
if (i > 0) {
|
|
587
|
-
destructuring += `,
|
|
588
|
-
`;
|
|
589
|
-
}
|
|
590
|
-
destructuring += name + " = __locals." + name;
|
|
591
|
-
}
|
|
592
|
-
prepended += destructuring + `;
|
|
593
|
-
`;
|
|
594
|
-
}
|
|
595
|
-
if (opts._with !== false) {
|
|
596
|
-
prepended += " with (" + opts.localsName + " || {}) {" + `
|
|
597
|
-
`;
|
|
598
|
-
appended += " }" + `
|
|
599
|
-
`;
|
|
600
|
-
}
|
|
601
|
-
appended += " return __output;" + `
|
|
602
|
-
`;
|
|
603
|
-
this.source = prepended + this.source + appended;
|
|
604
|
-
}
|
|
605
|
-
if (opts.compileDebug) {
|
|
606
|
-
src = "var __line = 1" + `
|
|
607
|
-
` + " , __lines = " + JSON.stringify(this.templateText) + `
|
|
608
|
-
` + " , __filename = " + sanitizedFilename + ";" + `
|
|
609
|
-
` + "try {" + `
|
|
610
|
-
` + this.source + "} catch (e) {" + `
|
|
611
|
-
` + " rethrow(e, __lines, __filename, __line, escapeFn);" + `
|
|
612
|
-
` + "}" + `
|
|
613
|
-
`;
|
|
614
|
-
} else {
|
|
615
|
-
src = this.source;
|
|
616
|
-
}
|
|
617
|
-
if (opts.client) {
|
|
618
|
-
src = "escapeFn = escapeFn || " + escapeFn.toString() + ";" + `
|
|
619
|
-
` + src;
|
|
620
|
-
if (opts.compileDebug) {
|
|
621
|
-
src = "rethrow = rethrow || " + rethrow.toString() + ";" + `
|
|
622
|
-
` + src;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (opts.strict) {
|
|
626
|
-
src = `"use strict";
|
|
627
|
-
` + src;
|
|
628
|
-
}
|
|
629
|
-
if (opts.debug) {
|
|
630
|
-
console.log(src);
|
|
631
|
-
}
|
|
632
|
-
if (opts.compileDebug && opts.filename) {
|
|
633
|
-
src = src + `
|
|
634
|
-
` + "//# sourceURL=" + sanitizedFilename + `
|
|
635
|
-
`;
|
|
636
|
-
}
|
|
637
|
-
try {
|
|
638
|
-
if (opts.async) {
|
|
639
|
-
try {
|
|
640
|
-
ctor = new Function("return (async function(){}).constructor;")();
|
|
641
|
-
} catch (e) {
|
|
642
|
-
if (e instanceof SyntaxError) {
|
|
643
|
-
throw new Error("This environment does not support async/await");
|
|
644
|
-
} else {
|
|
645
|
-
throw e;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
} else {
|
|
649
|
-
ctor = Function;
|
|
650
|
-
}
|
|
651
|
-
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
|
|
652
|
-
} catch (e) {
|
|
653
|
-
if (e instanceof SyntaxError) {
|
|
654
|
-
if (opts.filename) {
|
|
655
|
-
e.message += " in " + opts.filename;
|
|
656
|
-
}
|
|
657
|
-
e.message += ` while compiling ejs
|
|
658
|
-
|
|
659
|
-
`;
|
|
660
|
-
e.message += `If the above error is not helpful, you may want to try EJS-Lint:
|
|
661
|
-
`;
|
|
662
|
-
e.message += "https://github.com/RyanZim/EJS-Lint";
|
|
663
|
-
if (!opts.async) {
|
|
664
|
-
e.message += `
|
|
665
|
-
`;
|
|
666
|
-
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
throw e;
|
|
670
|
-
}
|
|
671
|
-
var returnedFn = opts.client ? fn : function anonymous(data) {
|
|
672
|
-
var include = function(path2, includeData) {
|
|
673
|
-
var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
|
|
674
|
-
if (includeData) {
|
|
675
|
-
d = utils.shallowCopy(d, includeData);
|
|
676
|
-
}
|
|
677
|
-
return includeFile(path2, opts)(d);
|
|
678
|
-
};
|
|
679
|
-
return fn.apply(opts.context, [data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
|
|
680
|
-
};
|
|
681
|
-
if (opts.filename && typeof Object.defineProperty === "function") {
|
|
682
|
-
var filename = opts.filename;
|
|
683
|
-
var basename = path.basename(filename, path.extname(filename));
|
|
684
|
-
try {
|
|
685
|
-
Object.defineProperty(returnedFn, "name", {
|
|
686
|
-
value: basename,
|
|
687
|
-
writable: false,
|
|
688
|
-
enumerable: false,
|
|
689
|
-
configurable: true
|
|
690
|
-
});
|
|
691
|
-
} catch (e) {
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return returnedFn;
|
|
695
|
-
},
|
|
696
|
-
generateSource: function() {
|
|
697
|
-
var opts = this.opts;
|
|
698
|
-
if (opts.rmWhitespace) {
|
|
699
|
-
this.templateText = this.templateText.replace(/[\r\n]+/g, `
|
|
700
|
-
`).replace(/^\s+|\s+$/gm, "");
|
|
701
|
-
}
|
|
702
|
-
this.templateText = this.templateText.replace(/[ \t]*<%_/gm, "<%_").replace(/_%>[ \t]*/gm, "_%>");
|
|
703
|
-
var self = this;
|
|
704
|
-
var matches = this.parseTemplateText();
|
|
705
|
-
var d = this.opts.delimiter;
|
|
706
|
-
var o = this.opts.openDelimiter;
|
|
707
|
-
var c = this.opts.closeDelimiter;
|
|
708
|
-
if (matches && matches.length) {
|
|
709
|
-
matches.forEach(function(line, index) {
|
|
710
|
-
var closing;
|
|
711
|
-
if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
|
|
712
|
-
closing = matches[index + 2];
|
|
713
|
-
if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
|
|
714
|
-
throw new Error('Could not find matching close tag for "' + line + '".');
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
self.scanLine(line);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
parseTemplateText: function() {
|
|
722
|
-
var str = this.templateText;
|
|
723
|
-
var pat = this.regex;
|
|
724
|
-
var result = pat.exec(str);
|
|
725
|
-
var arr = [];
|
|
726
|
-
var firstPos;
|
|
727
|
-
while (result) {
|
|
728
|
-
firstPos = result.index;
|
|
729
|
-
if (firstPos !== 0) {
|
|
730
|
-
arr.push(str.substring(0, firstPos));
|
|
731
|
-
str = str.slice(firstPos);
|
|
732
|
-
}
|
|
733
|
-
arr.push(result[0]);
|
|
734
|
-
str = str.slice(result[0].length);
|
|
735
|
-
result = pat.exec(str);
|
|
736
|
-
}
|
|
737
|
-
if (str) {
|
|
738
|
-
arr.push(str);
|
|
739
|
-
}
|
|
740
|
-
return arr;
|
|
741
|
-
},
|
|
742
|
-
_addOutput: function(line) {
|
|
743
|
-
if (this.truncate) {
|
|
744
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
745
|
-
this.truncate = false;
|
|
746
|
-
}
|
|
747
|
-
if (!line) {
|
|
748
|
-
return line;
|
|
749
|
-
}
|
|
750
|
-
line = line.replace(/\\/g, "\\\\");
|
|
751
|
-
line = line.replace(/\n/g, "\\n");
|
|
752
|
-
line = line.replace(/\r/g, "\\r");
|
|
753
|
-
line = line.replace(/"/g, "\\\"");
|
|
754
|
-
this.source += ' ; __append("' + line + '")' + `
|
|
755
|
-
`;
|
|
756
|
-
},
|
|
757
|
-
scanLine: function(line) {
|
|
758
|
-
var self = this;
|
|
759
|
-
var d = this.opts.delimiter;
|
|
760
|
-
var o = this.opts.openDelimiter;
|
|
761
|
-
var c = this.opts.closeDelimiter;
|
|
762
|
-
var newLineCount = 0;
|
|
763
|
-
newLineCount = line.split(`
|
|
764
|
-
`).length - 1;
|
|
765
|
-
switch (line) {
|
|
766
|
-
case o + d:
|
|
767
|
-
case o + d + "_":
|
|
768
|
-
this.mode = Template.modes.EVAL;
|
|
769
|
-
break;
|
|
770
|
-
case o + d + "=":
|
|
771
|
-
this.mode = Template.modes.ESCAPED;
|
|
772
|
-
break;
|
|
773
|
-
case o + d + "-":
|
|
774
|
-
this.mode = Template.modes.RAW;
|
|
775
|
-
break;
|
|
776
|
-
case o + d + "#":
|
|
777
|
-
this.mode = Template.modes.COMMENT;
|
|
778
|
-
break;
|
|
779
|
-
case o + d + d:
|
|
780
|
-
this.mode = Template.modes.LITERAL;
|
|
781
|
-
this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + `
|
|
782
|
-
`;
|
|
783
|
-
break;
|
|
784
|
-
case d + d + c:
|
|
785
|
-
this.mode = Template.modes.LITERAL;
|
|
786
|
-
this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + `
|
|
787
|
-
`;
|
|
788
|
-
break;
|
|
789
|
-
case d + c:
|
|
790
|
-
case "-" + d + c:
|
|
791
|
-
case "_" + d + c:
|
|
792
|
-
if (this.mode == Template.modes.LITERAL) {
|
|
793
|
-
this._addOutput(line);
|
|
794
|
-
}
|
|
795
|
-
this.mode = null;
|
|
796
|
-
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
797
|
-
break;
|
|
798
|
-
default:
|
|
799
|
-
if (this.mode) {
|
|
800
|
-
switch (this.mode) {
|
|
801
|
-
case Template.modes.EVAL:
|
|
802
|
-
case Template.modes.ESCAPED:
|
|
803
|
-
case Template.modes.RAW:
|
|
804
|
-
if (line.lastIndexOf("//") > line.lastIndexOf(`
|
|
805
|
-
`)) {
|
|
806
|
-
line += `
|
|
807
|
-
`;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
switch (this.mode) {
|
|
811
|
-
case Template.modes.EVAL:
|
|
812
|
-
this.source += " ; " + line + `
|
|
813
|
-
`;
|
|
814
|
-
break;
|
|
815
|
-
case Template.modes.ESCAPED:
|
|
816
|
-
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))" + `
|
|
817
|
-
`;
|
|
818
|
-
break;
|
|
819
|
-
case Template.modes.RAW:
|
|
820
|
-
this.source += " ; __append(" + stripSemi(line) + ")" + `
|
|
821
|
-
`;
|
|
822
|
-
break;
|
|
823
|
-
case Template.modes.COMMENT:
|
|
824
|
-
break;
|
|
825
|
-
case Template.modes.LITERAL:
|
|
826
|
-
this._addOutput(line);
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
} else {
|
|
830
|
-
this._addOutput(line);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
if (self.opts.compileDebug && newLineCount) {
|
|
834
|
-
this.currentLine += newLineCount;
|
|
835
|
-
this.source += " ; __line = " + this.currentLine + `
|
|
836
|
-
`;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
exports.escapeXML = utils.escapeXML;
|
|
841
|
-
exports.__express = exports.renderFile;
|
|
842
|
-
exports.VERSION = _VERSION_STRING;
|
|
843
|
-
exports.name = _NAME;
|
|
844
|
-
if (typeof window != "undefined") {
|
|
845
|
-
window.ejs = exports;
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
|
|
849
117
|
// node_modules/eventemitter3/index.js
|
|
850
118
|
var require_eventemitter3 = __commonJS((exports, module) => {
|
|
851
119
|
var has = Object.prototype.hasOwnProperty;
|
|
852
120
|
var prefix = "~";
|
|
853
|
-
function Events() {
|
|
854
|
-
}
|
|
121
|
+
function Events() {}
|
|
855
122
|
if (Object.create) {
|
|
856
123
|
Events.prototype = Object.create(null);
|
|
857
124
|
if (!new Events().__proto__)
|
|
@@ -1028,8 +295,717 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
1028
295
|
// src/server.ts
|
|
1029
296
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
1030
297
|
|
|
298
|
+
// node_modules/ejs/lib/esm/ejs.js
|
|
299
|
+
import fs from "fs";
|
|
300
|
+
import path from "path";
|
|
301
|
+
|
|
302
|
+
// node_modules/ejs/lib/esm/utils.js
|
|
303
|
+
var exports_utils = {};
|
|
304
|
+
__export(exports_utils, {
|
|
305
|
+
default: () => utils_default
|
|
306
|
+
});
|
|
307
|
+
var utils = {};
|
|
308
|
+
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
309
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
310
|
+
var hasOwn = function(obj, key) {
|
|
311
|
+
return hasOwnProperty.apply(obj, [key]);
|
|
312
|
+
};
|
|
313
|
+
utils.escapeRegExpChars = function(string) {
|
|
314
|
+
if (!string) {
|
|
315
|
+
return "";
|
|
316
|
+
}
|
|
317
|
+
return String(string).replace(regExpChars, "\\$&");
|
|
318
|
+
};
|
|
319
|
+
var _ENCODE_HTML_RULES = {
|
|
320
|
+
"&": "&",
|
|
321
|
+
"<": "<",
|
|
322
|
+
">": ">",
|
|
323
|
+
'"': """,
|
|
324
|
+
"'": "'"
|
|
325
|
+
};
|
|
326
|
+
var _MATCH_HTML = /[&<>'"]/g;
|
|
327
|
+
function encode_char(c) {
|
|
328
|
+
return _ENCODE_HTML_RULES[c] || c;
|
|
329
|
+
}
|
|
330
|
+
var escapeFuncStr = `var _ENCODE_HTML_RULES = {
|
|
331
|
+
` + ` "&": "&"
|
|
332
|
+
` + ` , "<": "<"
|
|
333
|
+
` + ` , ">": ">"
|
|
334
|
+
` + ` , '"': """
|
|
335
|
+
` + ` , "'": "'"
|
|
336
|
+
` + ` }
|
|
337
|
+
` + ` , _MATCH_HTML = /[&<>'"]/g;
|
|
338
|
+
` + `function encode_char(c) {
|
|
339
|
+
` + ` return _ENCODE_HTML_RULES[c] || c;
|
|
340
|
+
` + `};
|
|
341
|
+
`;
|
|
342
|
+
utils.escapeXML = function(markup) {
|
|
343
|
+
return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
344
|
+
};
|
|
345
|
+
function escapeXMLToString() {
|
|
346
|
+
return Function.prototype.toString.call(this) + `;
|
|
347
|
+
` + escapeFuncStr;
|
|
348
|
+
}
|
|
349
|
+
try {
|
|
350
|
+
if (typeof Object.defineProperty === "function") {
|
|
351
|
+
Object.defineProperty(utils.escapeXML, "toString", { value: escapeXMLToString });
|
|
352
|
+
} else {
|
|
353
|
+
utils.escapeXML.toString = escapeXMLToString;
|
|
354
|
+
}
|
|
355
|
+
} catch (err) {
|
|
356
|
+
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
357
|
+
}
|
|
358
|
+
utils.shallowCopy = function(to, from) {
|
|
359
|
+
from = from || {};
|
|
360
|
+
if (to !== null && to !== undefined) {
|
|
361
|
+
for (var p in from) {
|
|
362
|
+
if (!hasOwn(from, p)) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (p === "__proto__" || p === "constructor") {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
to[p] = from[p];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return to;
|
|
372
|
+
};
|
|
373
|
+
utils.shallowCopyFromList = function(to, from, list) {
|
|
374
|
+
list = list || [];
|
|
375
|
+
from = from || {};
|
|
376
|
+
if (to !== null && to !== undefined) {
|
|
377
|
+
for (var i = 0;i < list.length; i++) {
|
|
378
|
+
var p = list[i];
|
|
379
|
+
if (typeof from[p] != "undefined") {
|
|
380
|
+
if (!hasOwn(from, p)) {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (p === "__proto__" || p === "constructor") {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
to[p] = from[p];
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return to;
|
|
391
|
+
};
|
|
392
|
+
utils.cache = {
|
|
393
|
+
_data: {},
|
|
394
|
+
set: function(key, val) {
|
|
395
|
+
this._data[key] = val;
|
|
396
|
+
},
|
|
397
|
+
get: function(key) {
|
|
398
|
+
return this._data[key];
|
|
399
|
+
},
|
|
400
|
+
remove: function(key) {
|
|
401
|
+
delete this._data[key];
|
|
402
|
+
},
|
|
403
|
+
reset: function() {
|
|
404
|
+
this._data = {};
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
utils.hyphenToCamel = function(str) {
|
|
408
|
+
return str.replace(/-[a-z]/g, function(match) {
|
|
409
|
+
return match[1].toUpperCase();
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
utils.createNullProtoObjWherePossible = function() {
|
|
413
|
+
if (typeof Object.create == "function") {
|
|
414
|
+
return function() {
|
|
415
|
+
return Object.create(null);
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
if (!({ __proto__: null } instanceof Object)) {
|
|
419
|
+
return function() {
|
|
420
|
+
return { __proto__: null };
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return function() {
|
|
424
|
+
return {};
|
|
425
|
+
};
|
|
426
|
+
}();
|
|
427
|
+
utils.hasOwnOnlyObject = function(obj) {
|
|
428
|
+
var o = utils.createNullProtoObjWherePossible();
|
|
429
|
+
for (var p in obj) {
|
|
430
|
+
if (hasOwn(obj, p)) {
|
|
431
|
+
o[p] = obj[p];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return o;
|
|
435
|
+
};
|
|
436
|
+
if (typeof exports_utils != "undefined") {
|
|
437
|
+
module_utils.exports = utils;
|
|
438
|
+
}
|
|
439
|
+
var utils_default = utils;
|
|
440
|
+
|
|
441
|
+
// node_modules/ejs/lib/esm/ejs.js
|
|
442
|
+
var DECLARATION_KEYWORD = "let";
|
|
443
|
+
var ejs = {};
|
|
444
|
+
var _DEFAULT_OPEN_DELIMITER = "<";
|
|
445
|
+
var _DEFAULT_CLOSE_DELIMITER = ">";
|
|
446
|
+
var _DEFAULT_DELIMITER = "%";
|
|
447
|
+
var _DEFAULT_LOCALS_NAME = "locals";
|
|
448
|
+
var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
449
|
+
var _OPTS_PASSABLE_WITH_DATA = [
|
|
450
|
+
"delimiter",
|
|
451
|
+
"scope",
|
|
452
|
+
"context",
|
|
453
|
+
"debug",
|
|
454
|
+
"compileDebug",
|
|
455
|
+
"_with",
|
|
456
|
+
"rmWhitespace",
|
|
457
|
+
"strict",
|
|
458
|
+
"filename",
|
|
459
|
+
"async"
|
|
460
|
+
];
|
|
461
|
+
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
462
|
+
var _BOM = /^\uFEFF/;
|
|
463
|
+
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
464
|
+
ejs.cache = utils_default.cache;
|
|
465
|
+
ejs.fileLoader = fs.readFileSync;
|
|
466
|
+
ejs.localsName = _DEFAULT_LOCALS_NAME;
|
|
467
|
+
ejs.promiseImpl = new Function("return this;")().Promise;
|
|
468
|
+
ejs.resolveInclude = function(name, filename, isDir) {
|
|
469
|
+
let dirname = path.dirname;
|
|
470
|
+
let extname = path.extname;
|
|
471
|
+
let resolve = path.resolve;
|
|
472
|
+
let includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
473
|
+
let ext = extname(name);
|
|
474
|
+
if (!ext) {
|
|
475
|
+
includePath += ".ejs";
|
|
476
|
+
}
|
|
477
|
+
return includePath;
|
|
478
|
+
};
|
|
479
|
+
function resolvePaths(name, paths) {
|
|
480
|
+
let filePath;
|
|
481
|
+
if (paths.some(function(v) {
|
|
482
|
+
filePath = ejs.resolveInclude(name, v, true);
|
|
483
|
+
return fs.existsSync(filePath);
|
|
484
|
+
})) {
|
|
485
|
+
return filePath;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function getIncludePath(path2, options) {
|
|
489
|
+
let includePath;
|
|
490
|
+
let filePath;
|
|
491
|
+
let views = options.views;
|
|
492
|
+
let match = /^[A-Za-z]+:\\|^\//.exec(path2);
|
|
493
|
+
if (match && match.length) {
|
|
494
|
+
path2 = path2.replace(/^\/*/, "");
|
|
495
|
+
if (Array.isArray(options.root)) {
|
|
496
|
+
includePath = resolvePaths(path2, options.root);
|
|
497
|
+
} else {
|
|
498
|
+
includePath = ejs.resolveInclude(path2, options.root || "/", true);
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
if (options.filename) {
|
|
502
|
+
filePath = ejs.resolveInclude(path2, options.filename);
|
|
503
|
+
if (fs.existsSync(filePath)) {
|
|
504
|
+
includePath = filePath;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (!includePath && Array.isArray(views)) {
|
|
508
|
+
includePath = resolvePaths(path2, views);
|
|
509
|
+
}
|
|
510
|
+
if (!includePath && typeof options.includer !== "function") {
|
|
511
|
+
throw new Error('Could not find the include file "' + options.escapeFunction(path2) + '"');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return includePath;
|
|
515
|
+
}
|
|
516
|
+
function handleCache(options, template) {
|
|
517
|
+
let func;
|
|
518
|
+
let filename = options.filename;
|
|
519
|
+
let hasTemplate = arguments.length > 1;
|
|
520
|
+
if (options.cache) {
|
|
521
|
+
if (!filename) {
|
|
522
|
+
throw new Error("cache option requires a filename");
|
|
523
|
+
}
|
|
524
|
+
func = ejs.cache.get(filename);
|
|
525
|
+
if (func) {
|
|
526
|
+
return func;
|
|
527
|
+
}
|
|
528
|
+
if (!hasTemplate) {
|
|
529
|
+
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
530
|
+
}
|
|
531
|
+
} else if (!hasTemplate) {
|
|
532
|
+
if (!filename) {
|
|
533
|
+
throw new Error("Internal EJS error: no file name or template " + "provided");
|
|
534
|
+
}
|
|
535
|
+
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
536
|
+
}
|
|
537
|
+
func = ejs.compile(template, options);
|
|
538
|
+
if (options.cache) {
|
|
539
|
+
ejs.cache.set(filename, func);
|
|
540
|
+
}
|
|
541
|
+
return func;
|
|
542
|
+
}
|
|
543
|
+
function tryHandleCache(options, data, cb) {
|
|
544
|
+
let result;
|
|
545
|
+
if (!cb) {
|
|
546
|
+
if (typeof ejs.promiseImpl == "function") {
|
|
547
|
+
return new ejs.promiseImpl(function(resolve, reject) {
|
|
548
|
+
try {
|
|
549
|
+
result = handleCache(options)(data);
|
|
550
|
+
resolve(result);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
reject(err);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
} else {
|
|
556
|
+
throw new Error("Please provide a callback function");
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
try {
|
|
560
|
+
result = handleCache(options)(data);
|
|
561
|
+
} catch (err) {
|
|
562
|
+
return cb(err);
|
|
563
|
+
}
|
|
564
|
+
cb(null, result);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function fileLoader(filePath) {
|
|
568
|
+
return ejs.fileLoader(filePath);
|
|
569
|
+
}
|
|
570
|
+
function includeFile(path2, options) {
|
|
571
|
+
let opts = utils_default.shallowCopy(utils_default.createNullProtoObjWherePossible(), options);
|
|
572
|
+
opts.filename = getIncludePath(path2, opts);
|
|
573
|
+
if (typeof options.includer === "function") {
|
|
574
|
+
let includerResult = options.includer(path2, opts.filename);
|
|
575
|
+
if (includerResult) {
|
|
576
|
+
if (includerResult.filename) {
|
|
577
|
+
opts.filename = includerResult.filename;
|
|
578
|
+
}
|
|
579
|
+
if (includerResult.template) {
|
|
580
|
+
return handleCache(opts, includerResult.template);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return handleCache(opts);
|
|
585
|
+
}
|
|
586
|
+
function rethrow(err, str, flnm, lineno, esc) {
|
|
587
|
+
let lines = str.split(`
|
|
588
|
+
`);
|
|
589
|
+
let start = Math.max(lineno - 3, 0);
|
|
590
|
+
let end = Math.min(lines.length, lineno + 3);
|
|
591
|
+
let filename = esc(flnm);
|
|
592
|
+
let context = lines.slice(start, end).map(function(line, i) {
|
|
593
|
+
let curr = i + start + 1;
|
|
594
|
+
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
595
|
+
}).join(`
|
|
596
|
+
`);
|
|
597
|
+
err.path = filename;
|
|
598
|
+
err.message = (filename || "ejs") + ":" + lineno + `
|
|
599
|
+
` + context + `
|
|
600
|
+
|
|
601
|
+
` + err.message;
|
|
602
|
+
throw err;
|
|
603
|
+
}
|
|
604
|
+
function stripSemi(str) {
|
|
605
|
+
return str.replace(/;(\s*$)/, "$1");
|
|
606
|
+
}
|
|
607
|
+
ejs.compile = function compile(template, opts) {
|
|
608
|
+
let templ;
|
|
609
|
+
if (opts && opts.scope) {
|
|
610
|
+
console.warn("`scope` option is deprecated and will be removed in future EJS");
|
|
611
|
+
if (!opts.context) {
|
|
612
|
+
opts.context = opts.scope;
|
|
613
|
+
}
|
|
614
|
+
delete opts.scope;
|
|
615
|
+
}
|
|
616
|
+
templ = new Template(template, opts);
|
|
617
|
+
return templ.compile();
|
|
618
|
+
};
|
|
619
|
+
ejs.render = function(template, d, o) {
|
|
620
|
+
let data = d || utils_default.createNullProtoObjWherePossible();
|
|
621
|
+
let opts = o || utils_default.createNullProtoObjWherePossible();
|
|
622
|
+
if (arguments.length == 2) {
|
|
623
|
+
utils_default.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
624
|
+
}
|
|
625
|
+
return handleCache(opts, template)(data);
|
|
626
|
+
};
|
|
627
|
+
ejs.renderFile = function() {
|
|
628
|
+
let args = Array.prototype.slice.call(arguments);
|
|
629
|
+
let filename = args.shift();
|
|
630
|
+
let cb;
|
|
631
|
+
let opts = { filename };
|
|
632
|
+
let data;
|
|
633
|
+
let viewOpts;
|
|
634
|
+
if (typeof arguments[arguments.length - 1] == "function") {
|
|
635
|
+
cb = args.pop();
|
|
636
|
+
}
|
|
637
|
+
if (args.length) {
|
|
638
|
+
data = args.shift();
|
|
639
|
+
if (args.length) {
|
|
640
|
+
utils_default.shallowCopy(opts, args.pop());
|
|
641
|
+
} else {
|
|
642
|
+
if (data.settings) {
|
|
643
|
+
if (data.settings.views) {
|
|
644
|
+
opts.views = data.settings.views;
|
|
645
|
+
}
|
|
646
|
+
if (data.settings["view cache"]) {
|
|
647
|
+
opts.cache = true;
|
|
648
|
+
}
|
|
649
|
+
viewOpts = data.settings["view options"];
|
|
650
|
+
if (viewOpts) {
|
|
651
|
+
utils_default.shallowCopy(opts, viewOpts);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
utils_default.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
655
|
+
}
|
|
656
|
+
opts.filename = filename;
|
|
657
|
+
} else {
|
|
658
|
+
data = utils_default.createNullProtoObjWherePossible();
|
|
659
|
+
}
|
|
660
|
+
return tryHandleCache(opts, data, cb);
|
|
661
|
+
};
|
|
662
|
+
ejs.Template = Template;
|
|
663
|
+
ejs.clearCache = function() {
|
|
664
|
+
ejs.cache.reset();
|
|
665
|
+
};
|
|
666
|
+
function Template(text, optsParam) {
|
|
667
|
+
let opts = utils_default.hasOwnOnlyObject(optsParam);
|
|
668
|
+
let options = utils_default.createNullProtoObjWherePossible();
|
|
669
|
+
this.templateText = text;
|
|
670
|
+
this.mode = null;
|
|
671
|
+
this.truncate = false;
|
|
672
|
+
this.currentLine = 1;
|
|
673
|
+
this.source = "";
|
|
674
|
+
options.escapeFunction = opts.escape || opts.escapeFunction || utils_default.escapeXML;
|
|
675
|
+
options.compileDebug = opts.compileDebug !== false;
|
|
676
|
+
options.debug = !!opts.debug;
|
|
677
|
+
options.filename = opts.filename;
|
|
678
|
+
options.openDelimiter = opts.openDelimiter || ejs.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
679
|
+
options.closeDelimiter = opts.closeDelimiter || ejs.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
680
|
+
options.delimiter = opts.delimiter || ejs.delimiter || _DEFAULT_DELIMITER;
|
|
681
|
+
options.strict = opts.strict || false;
|
|
682
|
+
options.context = opts.context;
|
|
683
|
+
options.cache = opts.cache || false;
|
|
684
|
+
options.rmWhitespace = opts.rmWhitespace;
|
|
685
|
+
options.root = opts.root;
|
|
686
|
+
options.includer = opts.includer;
|
|
687
|
+
options.outputFunctionName = opts.outputFunctionName;
|
|
688
|
+
options.localsName = opts.localsName || ejs.localsName || _DEFAULT_LOCALS_NAME;
|
|
689
|
+
options.views = opts.views;
|
|
690
|
+
options.async = opts.async;
|
|
691
|
+
options.destructuredLocals = opts.destructuredLocals;
|
|
692
|
+
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
693
|
+
if (options.strict) {
|
|
694
|
+
options._with = false;
|
|
695
|
+
} else {
|
|
696
|
+
options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
697
|
+
}
|
|
698
|
+
this.opts = options;
|
|
699
|
+
this.regex = this.createRegex();
|
|
700
|
+
}
|
|
701
|
+
Template.modes = {
|
|
702
|
+
EVAL: "eval",
|
|
703
|
+
ESCAPED: "escaped",
|
|
704
|
+
RAW: "raw",
|
|
705
|
+
COMMENT: "comment",
|
|
706
|
+
LITERAL: "literal"
|
|
707
|
+
};
|
|
708
|
+
Template.prototype = {
|
|
709
|
+
createRegex: function() {
|
|
710
|
+
let str = _REGEX_STRING;
|
|
711
|
+
let delim = utils_default.escapeRegExpChars(this.opts.delimiter);
|
|
712
|
+
let open = utils_default.escapeRegExpChars(this.opts.openDelimiter);
|
|
713
|
+
let close = utils_default.escapeRegExpChars(this.opts.closeDelimiter);
|
|
714
|
+
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
715
|
+
return new RegExp(str);
|
|
716
|
+
},
|
|
717
|
+
compile: function() {
|
|
718
|
+
let src;
|
|
719
|
+
let fn;
|
|
720
|
+
let opts = this.opts;
|
|
721
|
+
let prepended = "";
|
|
722
|
+
let appended = "";
|
|
723
|
+
let escapeFn = opts.escapeFunction;
|
|
724
|
+
let ctor;
|
|
725
|
+
let sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
726
|
+
if (!this.source) {
|
|
727
|
+
this.generateSource();
|
|
728
|
+
prepended += ` ${DECLARATION_KEYWORD} __output = "";
|
|
729
|
+
` + ` function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
730
|
+
`;
|
|
731
|
+
if (opts.outputFunctionName) {
|
|
732
|
+
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
|
|
733
|
+
throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
734
|
+
}
|
|
735
|
+
prepended += ` ${DECLARATION_KEYWORD} ` + opts.outputFunctionName + " = __append;" + `
|
|
736
|
+
`;
|
|
737
|
+
}
|
|
738
|
+
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
|
|
739
|
+
throw new Error("localsName is not a valid JS identifier.");
|
|
740
|
+
}
|
|
741
|
+
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
742
|
+
let destructuring = ` ${DECLARATION_KEYWORD} __locals = (` + opts.localsName + ` || {}),
|
|
743
|
+
`;
|
|
744
|
+
for (let i = 0;i < opts.destructuredLocals.length; i++) {
|
|
745
|
+
let name = opts.destructuredLocals[i];
|
|
746
|
+
if (!_JS_IDENTIFIER.test(name)) {
|
|
747
|
+
throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
748
|
+
}
|
|
749
|
+
if (i > 0) {
|
|
750
|
+
destructuring += `,
|
|
751
|
+
`;
|
|
752
|
+
}
|
|
753
|
+
destructuring += name + " = __locals." + name;
|
|
754
|
+
}
|
|
755
|
+
prepended += destructuring + `;
|
|
756
|
+
`;
|
|
757
|
+
}
|
|
758
|
+
if (opts._with !== false) {
|
|
759
|
+
prepended += " with (" + opts.localsName + " || {}) {" + `
|
|
760
|
+
`;
|
|
761
|
+
appended += " }" + `
|
|
762
|
+
`;
|
|
763
|
+
}
|
|
764
|
+
appended += " return __output;" + `
|
|
765
|
+
`;
|
|
766
|
+
this.source = prepended + this.source + appended;
|
|
767
|
+
}
|
|
768
|
+
if (opts.compileDebug) {
|
|
769
|
+
src = `${DECLARATION_KEYWORD} __line = 1` + `
|
|
770
|
+
` + " , __lines = " + JSON.stringify(this.templateText) + `
|
|
771
|
+
` + " , __filename = " + sanitizedFilename + ";" + `
|
|
772
|
+
` + "try {" + `
|
|
773
|
+
` + this.source + "} catch (e) {" + `
|
|
774
|
+
` + " rethrow(e, __lines, __filename, __line, escapeFn);" + `
|
|
775
|
+
` + "}" + `
|
|
776
|
+
`;
|
|
777
|
+
} else {
|
|
778
|
+
src = this.source;
|
|
779
|
+
}
|
|
780
|
+
if (opts.strict) {
|
|
781
|
+
src = `"use strict";
|
|
782
|
+
` + src;
|
|
783
|
+
}
|
|
784
|
+
if (opts.debug) {
|
|
785
|
+
console.log(src);
|
|
786
|
+
}
|
|
787
|
+
if (opts.compileDebug && opts.filename) {
|
|
788
|
+
src = src + `
|
|
789
|
+
` + "//# sourceURL=" + sanitizedFilename + `
|
|
790
|
+
`;
|
|
791
|
+
}
|
|
792
|
+
try {
|
|
793
|
+
if (opts.async) {
|
|
794
|
+
try {
|
|
795
|
+
ctor = new Function("return (async function(){}).constructor;")();
|
|
796
|
+
} catch (e) {
|
|
797
|
+
if (e instanceof SyntaxError) {
|
|
798
|
+
throw new Error("This environment does not support async/await");
|
|
799
|
+
} else {
|
|
800
|
+
throw e;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
} else {
|
|
804
|
+
ctor = Function;
|
|
805
|
+
}
|
|
806
|
+
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
|
|
807
|
+
} catch (e) {
|
|
808
|
+
if (e instanceof SyntaxError) {
|
|
809
|
+
if (opts.filename) {
|
|
810
|
+
e.message += " in " + opts.filename;
|
|
811
|
+
}
|
|
812
|
+
e.message += ` while compiling ejs
|
|
813
|
+
|
|
814
|
+
`;
|
|
815
|
+
e.message += `If the above error is not helpful, you may want to try EJS-Lint:
|
|
816
|
+
`;
|
|
817
|
+
e.message += "https://github.com/RyanZim/EJS-Lint";
|
|
818
|
+
if (!opts.async) {
|
|
819
|
+
e.message += `
|
|
820
|
+
`;
|
|
821
|
+
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
throw e;
|
|
825
|
+
}
|
|
826
|
+
let returnedFn = function anonymous(data) {
|
|
827
|
+
let include = function(path2, includeData) {
|
|
828
|
+
let d = utils_default.shallowCopy(utils_default.createNullProtoObjWherePossible(), data);
|
|
829
|
+
if (includeData) {
|
|
830
|
+
d = utils_default.shallowCopy(d, includeData);
|
|
831
|
+
}
|
|
832
|
+
return includeFile(path2, opts)(d);
|
|
833
|
+
};
|
|
834
|
+
return fn.apply(opts.context, [data || utils_default.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
|
|
835
|
+
};
|
|
836
|
+
if (opts.filename && typeof Object.defineProperty === "function") {
|
|
837
|
+
let filename = opts.filename;
|
|
838
|
+
let basename = path.basename(filename, path.extname(filename));
|
|
839
|
+
try {
|
|
840
|
+
Object.defineProperty(returnedFn, "name", {
|
|
841
|
+
value: basename,
|
|
842
|
+
writable: false,
|
|
843
|
+
enumerable: false,
|
|
844
|
+
configurable: true
|
|
845
|
+
});
|
|
846
|
+
} catch (e) {}
|
|
847
|
+
}
|
|
848
|
+
return returnedFn;
|
|
849
|
+
},
|
|
850
|
+
generateSource: function() {
|
|
851
|
+
let opts = this.opts;
|
|
852
|
+
if (opts.rmWhitespace) {
|
|
853
|
+
this.templateText = this.templateText.replace(/[\r\n]+/g, `
|
|
854
|
+
`).replace(/^\s+|\s+$/gm, "");
|
|
855
|
+
}
|
|
856
|
+
let self = this;
|
|
857
|
+
let d = this.opts.delimiter;
|
|
858
|
+
let o = this.opts.openDelimiter;
|
|
859
|
+
let c = this.opts.closeDelimiter;
|
|
860
|
+
let openWhitespaceSlurpTag = utils_default.escapeRegExpChars(o + d + "_");
|
|
861
|
+
let closeWhitespaceSlurpTag = utils_default.escapeRegExpChars("_" + d + c);
|
|
862
|
+
let openWhitespaceSlurpReplacement = o + d + "_";
|
|
863
|
+
let closeWhitespaceSlurpReplacement = "_" + d + c;
|
|
864
|
+
this.templateText = this.templateText.replace(new RegExp("[ \\t]*" + openWhitespaceSlurpTag, "gm"), openWhitespaceSlurpReplacement).replace(new RegExp(closeWhitespaceSlurpTag + "[ \\t]*", "gm"), closeWhitespaceSlurpReplacement);
|
|
865
|
+
let matches = this.parseTemplateText();
|
|
866
|
+
if (matches && matches.length) {
|
|
867
|
+
matches.forEach(function(line, index) {
|
|
868
|
+
let closing;
|
|
869
|
+
if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
|
|
870
|
+
closing = matches[index + 2];
|
|
871
|
+
if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
|
|
872
|
+
throw new Error('Could not find matching close tag for "' + line + '".');
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
self.scanLine(line);
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
parseTemplateText: function() {
|
|
880
|
+
let str = this.templateText;
|
|
881
|
+
let pat = this.regex;
|
|
882
|
+
let result = pat.exec(str);
|
|
883
|
+
let arr = [];
|
|
884
|
+
let firstPos;
|
|
885
|
+
while (result) {
|
|
886
|
+
firstPos = result.index;
|
|
887
|
+
if (firstPos !== 0) {
|
|
888
|
+
arr.push(str.substring(0, firstPos));
|
|
889
|
+
str = str.slice(firstPos);
|
|
890
|
+
}
|
|
891
|
+
arr.push(result[0]);
|
|
892
|
+
str = str.slice(result[0].length);
|
|
893
|
+
result = pat.exec(str);
|
|
894
|
+
}
|
|
895
|
+
if (str) {
|
|
896
|
+
arr.push(str);
|
|
897
|
+
}
|
|
898
|
+
return arr;
|
|
899
|
+
},
|
|
900
|
+
_addOutput: function(line) {
|
|
901
|
+
if (this.truncate) {
|
|
902
|
+
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
903
|
+
this.truncate = false;
|
|
904
|
+
}
|
|
905
|
+
if (!line) {
|
|
906
|
+
return line;
|
|
907
|
+
}
|
|
908
|
+
line = line.replace(/\\/g, "\\\\");
|
|
909
|
+
line = line.replace(/\n/g, "\\n");
|
|
910
|
+
line = line.replace(/\r/g, "\\r");
|
|
911
|
+
line = line.replace(/"/g, "\\\"");
|
|
912
|
+
this.source += ' ; __append("' + line + '")' + `
|
|
913
|
+
`;
|
|
914
|
+
},
|
|
915
|
+
scanLine: function(line) {
|
|
916
|
+
let self = this;
|
|
917
|
+
let d = this.opts.delimiter;
|
|
918
|
+
let o = this.opts.openDelimiter;
|
|
919
|
+
let c = this.opts.closeDelimiter;
|
|
920
|
+
let newLineCount = 0;
|
|
921
|
+
newLineCount = line.split(`
|
|
922
|
+
`).length - 1;
|
|
923
|
+
switch (line) {
|
|
924
|
+
case o + d:
|
|
925
|
+
case o + d + "_":
|
|
926
|
+
this.mode = Template.modes.EVAL;
|
|
927
|
+
break;
|
|
928
|
+
case o + d + "=":
|
|
929
|
+
this.mode = Template.modes.ESCAPED;
|
|
930
|
+
break;
|
|
931
|
+
case o + d + "-":
|
|
932
|
+
this.mode = Template.modes.RAW;
|
|
933
|
+
break;
|
|
934
|
+
case o + d + "#":
|
|
935
|
+
this.mode = Template.modes.COMMENT;
|
|
936
|
+
break;
|
|
937
|
+
case o + d + d:
|
|
938
|
+
this.mode = Template.modes.LITERAL;
|
|
939
|
+
this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + `
|
|
940
|
+
`;
|
|
941
|
+
break;
|
|
942
|
+
case d + d + c:
|
|
943
|
+
this.mode = Template.modes.LITERAL;
|
|
944
|
+
this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + `
|
|
945
|
+
`;
|
|
946
|
+
break;
|
|
947
|
+
case d + c:
|
|
948
|
+
case "-" + d + c:
|
|
949
|
+
case "_" + d + c:
|
|
950
|
+
if (this.mode == Template.modes.LITERAL) {
|
|
951
|
+
this._addOutput(line);
|
|
952
|
+
}
|
|
953
|
+
this.mode = null;
|
|
954
|
+
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
955
|
+
break;
|
|
956
|
+
default:
|
|
957
|
+
if (this.mode) {
|
|
958
|
+
switch (this.mode) {
|
|
959
|
+
case Template.modes.EVAL:
|
|
960
|
+
case Template.modes.ESCAPED:
|
|
961
|
+
case Template.modes.RAW:
|
|
962
|
+
if (line.lastIndexOf("//") > line.lastIndexOf(`
|
|
963
|
+
`)) {
|
|
964
|
+
line += `
|
|
965
|
+
`;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
switch (this.mode) {
|
|
969
|
+
case Template.modes.EVAL:
|
|
970
|
+
this.source += " ; " + line + `
|
|
971
|
+
`;
|
|
972
|
+
break;
|
|
973
|
+
case Template.modes.ESCAPED:
|
|
974
|
+
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))" + `
|
|
975
|
+
`;
|
|
976
|
+
break;
|
|
977
|
+
case Template.modes.RAW:
|
|
978
|
+
this.source += " ; __append(" + stripSemi(line) + ")" + `
|
|
979
|
+
`;
|
|
980
|
+
break;
|
|
981
|
+
case Template.modes.COMMENT:
|
|
982
|
+
break;
|
|
983
|
+
case Template.modes.LITERAL:
|
|
984
|
+
this._addOutput(line);
|
|
985
|
+
break;
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
this._addOutput(line);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (self.opts.compileDebug && newLineCount) {
|
|
992
|
+
this.currentLine += newLineCount;
|
|
993
|
+
this.source += " ; __line = " + this.currentLine + `
|
|
994
|
+
`;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
ejs.escapeXML = utils_default.escapeXML;
|
|
999
|
+
ejs.__express = ejs.renderFile;
|
|
1000
|
+
if (typeof window != "undefined") {
|
|
1001
|
+
window.ejs = ejs;
|
|
1002
|
+
}
|
|
1003
|
+
if (typeof module_ejs != "undefined") {
|
|
1004
|
+
module_ejs.exports = ejs;
|
|
1005
|
+
}
|
|
1006
|
+
var ejs_default = ejs;
|
|
1007
|
+
|
|
1031
1008
|
// src/httpHandler.ts
|
|
1032
|
-
var import_ejs = __toESM(require_ejs(), 1);
|
|
1033
1009
|
import { readFile, readdir } from "fs/promises";
|
|
1034
1010
|
|
|
1035
1011
|
// src/utils/cors.ts
|
|
@@ -1155,7 +1131,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
|
|
|
1155
1131
|
};
|
|
1156
1132
|
});
|
|
1157
1133
|
const templatePath = requestPath === "/" ? "" : requestPath;
|
|
1158
|
-
const rnd =
|
|
1134
|
+
const rnd = ejs_default.render(finalConfig.serveOutputEjs, {
|
|
1159
1135
|
dirs,
|
|
1160
1136
|
files,
|
|
1161
1137
|
requestPath: templatePath
|
|
@@ -1171,7 +1147,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
|
|
|
1171
1147
|
import { resolve } from "path";
|
|
1172
1148
|
|
|
1173
1149
|
// src/static/serveOutputStyles.css
|
|
1174
|
-
var serveOutputStyles_default =
|
|
1150
|
+
var serveOutputStyles_default = {};
|
|
1175
1151
|
|
|
1176
1152
|
// src/static/file.svg
|
|
1177
1153
|
var file_default = "./assets/file.svg";
|
|
@@ -1200,7 +1176,6 @@ var staticAssetRoutes = {
|
|
|
1200
1176
|
import { watch } from "fs/promises";
|
|
1201
1177
|
|
|
1202
1178
|
// src/buildManager.ts
|
|
1203
|
-
var import_ejs2 = __toESM(require_ejs(), 1);
|
|
1204
1179
|
var {build } = globalThis.Bun;
|
|
1205
1180
|
|
|
1206
1181
|
// node_modules/eventemitter3/index.mjs
|
|
@@ -1346,6 +1321,9 @@ class PQueue extends import__.default {
|
|
|
1346
1321
|
#lastExecutionTime = 0;
|
|
1347
1322
|
#intervalId;
|
|
1348
1323
|
#timeoutId;
|
|
1324
|
+
#strict;
|
|
1325
|
+
#strictTicks = [];
|
|
1326
|
+
#strictTicksStartIndex = 0;
|
|
1349
1327
|
#queue;
|
|
1350
1328
|
#queueClass;
|
|
1351
1329
|
#pending = 0;
|
|
@@ -1363,6 +1341,7 @@ class PQueue extends import__.default {
|
|
|
1363
1341
|
concurrency: Number.POSITIVE_INFINITY,
|
|
1364
1342
|
autoStart: true,
|
|
1365
1343
|
queueClass: PriorityQueue,
|
|
1344
|
+
strict: false,
|
|
1366
1345
|
...options
|
|
1367
1346
|
};
|
|
1368
1347
|
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
|
|
@@ -1371,10 +1350,17 @@ class PQueue extends import__.default {
|
|
|
1371
1350
|
if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {
|
|
1372
1351
|
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
|
|
1373
1352
|
}
|
|
1353
|
+
if (options.strict && options.interval === 0) {
|
|
1354
|
+
throw new TypeError("The `strict` option requires a non-zero `interval`");
|
|
1355
|
+
}
|
|
1356
|
+
if (options.strict && options.intervalCap === Number.POSITIVE_INFINITY) {
|
|
1357
|
+
throw new TypeError("The `strict` option requires a finite `intervalCap`");
|
|
1358
|
+
}
|
|
1374
1359
|
this.#carryoverIntervalCount = options.carryoverIntervalCount ?? options.carryoverConcurrencyCount ?? false;
|
|
1375
1360
|
this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
|
|
1376
1361
|
this.#intervalCap = options.intervalCap;
|
|
1377
1362
|
this.#interval = options.interval;
|
|
1363
|
+
this.#strict = options.strict;
|
|
1378
1364
|
this.#queue = new options.queueClass;
|
|
1379
1365
|
this.#queueClass = options.queueClass;
|
|
1380
1366
|
this.concurrency = options.concurrency;
|
|
@@ -1385,8 +1371,48 @@ class PQueue extends import__.default {
|
|
|
1385
1371
|
this.#isPaused = options.autoStart === false;
|
|
1386
1372
|
this.#setupRateLimitTracking();
|
|
1387
1373
|
}
|
|
1374
|
+
#cleanupStrictTicks(now) {
|
|
1375
|
+
while (this.#strictTicksStartIndex < this.#strictTicks.length) {
|
|
1376
|
+
const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
|
|
1377
|
+
if (oldestTick !== undefined && now - oldestTick >= this.#interval) {
|
|
1378
|
+
this.#strictTicksStartIndex++;
|
|
1379
|
+
} else {
|
|
1380
|
+
break;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
const shouldCompact = this.#strictTicksStartIndex > 100 && this.#strictTicksStartIndex > this.#strictTicks.length / 2 || this.#strictTicksStartIndex === this.#strictTicks.length;
|
|
1384
|
+
if (shouldCompact) {
|
|
1385
|
+
this.#strictTicks = this.#strictTicks.slice(this.#strictTicksStartIndex);
|
|
1386
|
+
this.#strictTicksStartIndex = 0;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
#consumeIntervalSlot(now) {
|
|
1390
|
+
if (this.#strict) {
|
|
1391
|
+
this.#strictTicks.push(now);
|
|
1392
|
+
} else {
|
|
1393
|
+
this.#intervalCount++;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
#rollbackIntervalSlot() {
|
|
1397
|
+
if (this.#strict) {
|
|
1398
|
+
if (this.#strictTicks.length > this.#strictTicksStartIndex) {
|
|
1399
|
+
this.#strictTicks.pop();
|
|
1400
|
+
}
|
|
1401
|
+
} else if (this.#intervalCount > 0) {
|
|
1402
|
+
this.#intervalCount--;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
#getActiveTicksCount() {
|
|
1406
|
+
return this.#strictTicks.length - this.#strictTicksStartIndex;
|
|
1407
|
+
}
|
|
1388
1408
|
get #doesIntervalAllowAnother() {
|
|
1389
|
-
|
|
1409
|
+
if (this.#isIntervalIgnored) {
|
|
1410
|
+
return true;
|
|
1411
|
+
}
|
|
1412
|
+
if (this.#strict) {
|
|
1413
|
+
return this.#getActiveTicksCount() < this.#intervalCap;
|
|
1414
|
+
}
|
|
1415
|
+
return this.#intervalCount < this.#intervalCap;
|
|
1390
1416
|
}
|
|
1391
1417
|
get #doesConcurrentAllowAnother() {
|
|
1392
1418
|
return this.#pending < this.#concurrency;
|
|
@@ -1400,12 +1426,22 @@ class PQueue extends import__.default {
|
|
|
1400
1426
|
this.emit("next");
|
|
1401
1427
|
}
|
|
1402
1428
|
#onResumeInterval() {
|
|
1429
|
+
this.#timeoutId = undefined;
|
|
1403
1430
|
this.#onInterval();
|
|
1404
1431
|
this.#initializeIntervalIfNeeded();
|
|
1405
|
-
this.#timeoutId = undefined;
|
|
1406
1432
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1433
|
+
#isIntervalPausedAt(now) {
|
|
1434
|
+
if (this.#strict) {
|
|
1435
|
+
this.#cleanupStrictTicks(now);
|
|
1436
|
+
const activeTicksCount = this.#getActiveTicksCount();
|
|
1437
|
+
if (activeTicksCount >= this.#intervalCap) {
|
|
1438
|
+
const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
|
|
1439
|
+
const delay = this.#interval - (now - oldestTick);
|
|
1440
|
+
this.#createIntervalTimeout(delay);
|
|
1441
|
+
return true;
|
|
1442
|
+
}
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1409
1445
|
if (this.#intervalId === undefined) {
|
|
1410
1446
|
const delay = this.#intervalEnd - now;
|
|
1411
1447
|
if (delay < 0) {
|
|
@@ -1450,21 +1486,25 @@ class PQueue extends import__.default {
|
|
|
1450
1486
|
this.emit("empty");
|
|
1451
1487
|
if (this.#pending === 0) {
|
|
1452
1488
|
this.#clearTimeoutTimer();
|
|
1489
|
+
if (this.#strict && this.#strictTicksStartIndex > 0) {
|
|
1490
|
+
const now = Date.now();
|
|
1491
|
+
this.#cleanupStrictTicks(now);
|
|
1492
|
+
}
|
|
1453
1493
|
this.emit("idle");
|
|
1454
1494
|
}
|
|
1455
1495
|
return false;
|
|
1456
1496
|
}
|
|
1457
1497
|
let taskStarted = false;
|
|
1458
1498
|
if (!this.#isPaused) {
|
|
1459
|
-
const
|
|
1499
|
+
const now = Date.now();
|
|
1500
|
+
const canInitializeInterval = !this.#isIntervalPausedAt(now);
|
|
1460
1501
|
if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
|
|
1461
1502
|
const job = this.#queue.dequeue();
|
|
1462
1503
|
if (!this.#isIntervalIgnored) {
|
|
1463
|
-
this.#
|
|
1504
|
+
this.#consumeIntervalSlot(now);
|
|
1464
1505
|
this.#scheduleRateLimitUpdate();
|
|
1465
1506
|
}
|
|
1466
1507
|
this.emit("active");
|
|
1467
|
-
this.#lastExecutionTime = Date.now();
|
|
1468
1508
|
job();
|
|
1469
1509
|
if (canInitializeInterval) {
|
|
1470
1510
|
this.#initializeIntervalIfNeeded();
|
|
@@ -1478,22 +1518,26 @@ class PQueue extends import__.default {
|
|
|
1478
1518
|
if (this.#isIntervalIgnored || this.#intervalId !== undefined) {
|
|
1479
1519
|
return;
|
|
1480
1520
|
}
|
|
1521
|
+
if (this.#strict) {
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1481
1524
|
this.#intervalId = setInterval(() => {
|
|
1482
1525
|
this.#onInterval();
|
|
1483
1526
|
}, this.#interval);
|
|
1484
1527
|
this.#intervalEnd = Date.now() + this.#interval;
|
|
1485
1528
|
}
|
|
1486
1529
|
#onInterval() {
|
|
1487
|
-
if (this.#
|
|
1488
|
-
this.#
|
|
1530
|
+
if (!this.#strict) {
|
|
1531
|
+
if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
|
|
1532
|
+
this.#clearIntervalTimer();
|
|
1533
|
+
}
|
|
1534
|
+
this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
|
|
1489
1535
|
}
|
|
1490
|
-
this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
|
|
1491
1536
|
this.#processQueue();
|
|
1492
1537
|
this.#scheduleRateLimitUpdate();
|
|
1493
1538
|
}
|
|
1494
1539
|
#processQueue() {
|
|
1495
|
-
while (this.#tryToStartAnother()) {
|
|
1496
|
-
}
|
|
1540
|
+
while (this.#tryToStartAnother()) {}
|
|
1497
1541
|
}
|
|
1498
1542
|
get concurrency() {
|
|
1499
1543
|
return this.#concurrency;
|
|
@@ -1512,10 +1556,10 @@ class PQueue extends import__.default {
|
|
|
1512
1556
|
this.#queue.setPriority(id, priority);
|
|
1513
1557
|
}
|
|
1514
1558
|
async add(function_, options = {}) {
|
|
1515
|
-
options.id ??= (this.#idAssigner++).toString();
|
|
1516
1559
|
options = {
|
|
1517
1560
|
timeout: this.timeout,
|
|
1518
|
-
...options
|
|
1561
|
+
...options,
|
|
1562
|
+
id: options.id ?? (this.#idAssigner++).toString()
|
|
1519
1563
|
};
|
|
1520
1564
|
return new Promise((resolve2, reject) => {
|
|
1521
1565
|
const taskSymbol = Symbol(`task-${options.id}`);
|
|
@@ -1532,12 +1576,11 @@ class PQueue extends import__.default {
|
|
|
1532
1576
|
try {
|
|
1533
1577
|
options.signal?.throwIfAborted();
|
|
1534
1578
|
} catch (error) {
|
|
1535
|
-
|
|
1536
|
-
this.#intervalCount--;
|
|
1537
|
-
}
|
|
1579
|
+
this.#rollbackIntervalConsumption();
|
|
1538
1580
|
this.#runningTasks.delete(taskSymbol);
|
|
1539
1581
|
throw error;
|
|
1540
1582
|
}
|
|
1583
|
+
this.#lastExecutionTime = Date.now();
|
|
1541
1584
|
let operation = function_({ signal: options.signal });
|
|
1542
1585
|
if (options.timeout) {
|
|
1543
1586
|
operation = pTimeout(Promise.resolve(operation), {
|
|
@@ -1590,7 +1633,14 @@ class PQueue extends import__.default {
|
|
|
1590
1633
|
}
|
|
1591
1634
|
clear() {
|
|
1592
1635
|
this.#queue = new this.#queueClass;
|
|
1636
|
+
this.#clearIntervalTimer();
|
|
1593
1637
|
this.#updateRateLimitState();
|
|
1638
|
+
this.emit("empty");
|
|
1639
|
+
if (this.#pending === 0) {
|
|
1640
|
+
this.#clearTimeoutTimer();
|
|
1641
|
+
this.emit("idle");
|
|
1642
|
+
}
|
|
1643
|
+
this.emit("next");
|
|
1594
1644
|
}
|
|
1595
1645
|
async onEmpty() {
|
|
1596
1646
|
if (this.#queue.size === 0) {
|
|
@@ -1628,7 +1678,7 @@ class PQueue extends import__.default {
|
|
|
1628
1678
|
}
|
|
1629
1679
|
await this.#onEvent("rateLimitCleared");
|
|
1630
1680
|
}
|
|
1631
|
-
|
|
1681
|
+
onError() {
|
|
1632
1682
|
return new Promise((_resolve, reject) => {
|
|
1633
1683
|
const handleError = (error) => {
|
|
1634
1684
|
this.off("error", handleError);
|
|
@@ -1684,9 +1734,31 @@ class PQueue extends import__.default {
|
|
|
1684
1734
|
this.#updateRateLimitState();
|
|
1685
1735
|
});
|
|
1686
1736
|
}
|
|
1737
|
+
#rollbackIntervalConsumption() {
|
|
1738
|
+
if (this.#isIntervalIgnored) {
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
this.#rollbackIntervalSlot();
|
|
1742
|
+
this.#scheduleRateLimitUpdate();
|
|
1743
|
+
}
|
|
1687
1744
|
#updateRateLimitState() {
|
|
1688
1745
|
const previous = this.#rateLimitedInInterval;
|
|
1689
|
-
|
|
1746
|
+
if (this.#isIntervalIgnored || this.#queue.size === 0) {
|
|
1747
|
+
if (previous) {
|
|
1748
|
+
this.#rateLimitedInInterval = false;
|
|
1749
|
+
this.emit("rateLimitCleared");
|
|
1750
|
+
}
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
let count;
|
|
1754
|
+
if (this.#strict) {
|
|
1755
|
+
const now = Date.now();
|
|
1756
|
+
this.#cleanupStrictTicks(now);
|
|
1757
|
+
count = this.#getActiveTicksCount();
|
|
1758
|
+
} else {
|
|
1759
|
+
count = this.#intervalCount;
|
|
1760
|
+
}
|
|
1761
|
+
const shouldBeRateLimited = count >= this.#intervalCap;
|
|
1690
1762
|
if (shouldBeRateLimited !== previous) {
|
|
1691
1763
|
this.#rateLimitedInInterval = shouldBeRateLimited;
|
|
1692
1764
|
this.emit(shouldBeRateLimited ? "rateLimit" : "rateLimitCleared");
|
|
@@ -1839,7 +1911,7 @@ function publishIndexHTML(paths, template, output, _event) {
|
|
|
1839
1911
|
const hashedCss = `${cssUrl.href.replace(`${basePathUrl.href}/`, "./")}?${cssFile.hash}`;
|
|
1840
1912
|
cssFiles.push(hashedCss);
|
|
1841
1913
|
}
|
|
1842
|
-
Bun.write(paths.buildDestination + "/index.html",
|
|
1914
|
+
Bun.write(paths.buildDestination + "/index.html", ejs_default.render(template, { hashedImports, cssFiles }));
|
|
1843
1915
|
}
|
|
1844
1916
|
function printPrettyBuildOutput(outTable) {
|
|
1845
1917
|
if (outTable.length === 0)
|
|
@@ -1920,8 +1992,7 @@ function hotReload() {
|
|
|
1920
1992
|
let parsed = msg.data;
|
|
1921
1993
|
try {
|
|
1922
1994
|
parsed = JSON.parse(msg.data);
|
|
1923
|
-
} catch (e) {
|
|
1924
|
-
}
|
|
1995
|
+
} catch (e) {}
|
|
1925
1996
|
if (parsed?.type === "message") {
|
|
1926
1997
|
console.log(devServer, parsed.message);
|
|
1927
1998
|
return;
|
|
@@ -1977,8 +2048,8 @@ var DEFAULT_HMR_PATH = "/hmr-ws";
|
|
|
1977
2048
|
function bunHotReload(bunServerConfig) {
|
|
1978
2049
|
const socketPath = bunServerConfig.websocketPath || DEFAULT_HMR_PATH;
|
|
1979
2050
|
const endPath = socketPath.startsWith("/") ? socketPath : `/${socketPath}`;
|
|
1980
|
-
const
|
|
1981
|
-
return hotReload.toString().replace("[REPLACE_ENDPOINT]",
|
|
2051
|
+
const path2 = `${bunServerConfig.secure ? "wss" : "ws"}://localhost:${bunServerConfig.port}${endPath}`;
|
|
2052
|
+
return hotReload.toString().replace("[REPLACE_ENDPOINT]", path2);
|
|
1982
2053
|
}
|
|
1983
2054
|
|
|
1984
2055
|
// src/bunHmrPlugin.ts
|
|
@@ -2146,8 +2217,7 @@ async function startBunDevServer(serverConfig, importMeta) {
|
|
|
2146
2217
|
open(ws) {
|
|
2147
2218
|
ws.subscribe("message");
|
|
2148
2219
|
},
|
|
2149
|
-
message(ws, message) {
|
|
2150
|
-
},
|
|
2220
|
+
message(ws, message) {},
|
|
2151
2221
|
sendPings: true
|
|
2152
2222
|
}
|
|
2153
2223
|
});
|