bun-dev-server 1.0.3 → 1.0.5

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.js CHANGED
@@ -30,19 +30,7 @@ var __toESM = (mod, isNodeMode, target) => {
30
30
  return to;
31
31
  };
32
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
- };
33
+ var __require = import.meta.require;
46
34
 
47
35
  // node_modules/picocolors/picocolors.js
48
36
  var require_picocolors = __commonJS((exports, module) => {
@@ -114,6 +102,1343 @@ var require_picocolors = __commonJS((exports, module) => {
114
102
  module.exports.createColors = createColors;
115
103
  });
116
104
 
105
+ // node_modules/ejs/ejs.js
106
+ var require_ejs = __commonJS((exports, module) => {
107
+ (function(f) {
108
+ if (typeof exports === "object" && typeof module !== "undefined") {
109
+ module.exports = f();
110
+ } else if (typeof define === "function" && define.amd) {
111
+ define([], f);
112
+ } else {
113
+ var g;
114
+ if (typeof window !== "undefined") {
115
+ g = window;
116
+ } else if (typeof global !== "undefined") {
117
+ g = global;
118
+ } else if (typeof self !== "undefined") {
119
+ g = self;
120
+ } else {
121
+ g = this;
122
+ }
123
+ g.ejs = f();
124
+ }
125
+ })(function() {
126
+ var define2, module2, exports2;
127
+ return function() {
128
+ function r(e, n, t) {
129
+ function o(i2, f) {
130
+ if (!n[i2]) {
131
+ if (!e[i2]) {
132
+ var c = __require;
133
+ if (!f && c)
134
+ return c(i2, true);
135
+ if (u)
136
+ return u(i2, true);
137
+ var a = new Error("Cannot find module '" + i2 + "'");
138
+ throw a.code = "MODULE_NOT_FOUND", a;
139
+ }
140
+ var p = n[i2] = { exports: {} };
141
+ e[i2][0].call(p.exports, function(r2) {
142
+ var n2 = e[i2][1][r2];
143
+ return o(n2 || r2);
144
+ }, p, p.exports, r, e, n, t);
145
+ }
146
+ return n[i2].exports;
147
+ }
148
+ for (var u = __require, i = 0;i < t.length; i++)
149
+ o(t[i]);
150
+ return o;
151
+ }
152
+ return r;
153
+ }()({ 1: [function(require2, module3, exports3) {
154
+ var __importDefault = this && this.__importDefault || function(mod) {
155
+ return mod && mod.__esModule ? mod : { default: mod };
156
+ };
157
+ Object.defineProperty(exports3, "__esModule", { value: true });
158
+ var fs_1 = __importDefault(require2("fs"));
159
+ var path_1 = __importDefault(require2("path"));
160
+ var utils_js_1 = __importDefault(require2("./utils.js"));
161
+ var DECLARATION_KEYWORD = "var";
162
+ var ejs = {};
163
+ var _DEFAULT_OPEN_DELIMITER = "<";
164
+ var _DEFAULT_CLOSE_DELIMITER = ">";
165
+ var _DEFAULT_DELIMITER = "%";
166
+ var _DEFAULT_LOCALS_NAME = "locals";
167
+ var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
168
+ var _OPTS_PASSABLE_WITH_DATA = [
169
+ "delimiter",
170
+ "scope",
171
+ "context",
172
+ "debug",
173
+ "compileDebug",
174
+ "_with",
175
+ "rmWhitespace",
176
+ "strict",
177
+ "filename",
178
+ "async"
179
+ ];
180
+ var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
181
+ var _BOM = /^\uFEFF/;
182
+ var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
183
+ ejs.cache = utils_js_1.default.cache;
184
+ ejs.fileLoader = fs_1.default.readFileSync;
185
+ ejs.localsName = _DEFAULT_LOCALS_NAME;
186
+ ejs.promiseImpl = new Function("return this;")().Promise;
187
+ ejs.resolveInclude = function(name, filename, isDir) {
188
+ var dirname = path_1.default.dirname;
189
+ var extname = path_1.default.extname;
190
+ var resolve = path_1.default.resolve;
191
+ var includePath = resolve(isDir ? filename : dirname(filename), name);
192
+ var ext = extname(name);
193
+ if (!ext) {
194
+ includePath += ".ejs";
195
+ }
196
+ return includePath;
197
+ };
198
+ function resolvePaths(name, paths) {
199
+ var filePath;
200
+ if (paths.some(function(v) {
201
+ filePath = ejs.resolveInclude(name, v, true);
202
+ return fs_1.default.existsSync(filePath);
203
+ })) {
204
+ return filePath;
205
+ }
206
+ }
207
+ function getIncludePath(path, options) {
208
+ var includePath;
209
+ var filePath;
210
+ var views = options.views;
211
+ var match = /^[A-Za-z]+:\\|^\//.exec(path);
212
+ if (match && match.length) {
213
+ path = path.replace(/^\/*/, "");
214
+ if (Array.isArray(options.root)) {
215
+ includePath = resolvePaths(path, options.root);
216
+ } else {
217
+ includePath = ejs.resolveInclude(path, options.root || "/", true);
218
+ }
219
+ } else {
220
+ if (options.filename) {
221
+ filePath = ejs.resolveInclude(path, options.filename);
222
+ if (fs_1.default.existsSync(filePath)) {
223
+ includePath = filePath;
224
+ }
225
+ }
226
+ if (!includePath && Array.isArray(views)) {
227
+ includePath = resolvePaths(path, views);
228
+ }
229
+ if (!includePath && typeof options.includer !== "function") {
230
+ throw new Error('Could not find the include file "' + options.escapeFunction(path) + '"');
231
+ }
232
+ }
233
+ return includePath;
234
+ }
235
+ function handleCache(options, template) {
236
+ var func;
237
+ var filename = options.filename;
238
+ var hasTemplate = arguments.length > 1;
239
+ if (options.cache) {
240
+ if (!filename) {
241
+ throw new Error("cache option requires a filename");
242
+ }
243
+ func = ejs.cache.get(filename);
244
+ if (func) {
245
+ return func;
246
+ }
247
+ if (!hasTemplate) {
248
+ template = fileLoader(filename).toString().replace(_BOM, "");
249
+ }
250
+ } else if (!hasTemplate) {
251
+ if (!filename) {
252
+ throw new Error("Internal EJS error: no file name or template " + "provided");
253
+ }
254
+ template = fileLoader(filename).toString().replace(_BOM, "");
255
+ }
256
+ func = ejs.compile(template, options);
257
+ if (options.cache) {
258
+ ejs.cache.set(filename, func);
259
+ }
260
+ return func;
261
+ }
262
+ function tryHandleCache(options, data, cb) {
263
+ var result;
264
+ if (!cb) {
265
+ if (typeof ejs.promiseImpl == "function") {
266
+ return new ejs.promiseImpl(function(resolve, reject) {
267
+ try {
268
+ result = handleCache(options)(data);
269
+ resolve(result);
270
+ } catch (err) {
271
+ reject(err);
272
+ }
273
+ });
274
+ } else {
275
+ throw new Error("Please provide a callback function");
276
+ }
277
+ } else {
278
+ try {
279
+ result = handleCache(options)(data);
280
+ } catch (err) {
281
+ return cb(err);
282
+ }
283
+ cb(null, result);
284
+ }
285
+ }
286
+ function fileLoader(filePath) {
287
+ return ejs.fileLoader(filePath);
288
+ }
289
+ function includeFile(path, options) {
290
+ var opts = utils_js_1.default.shallowCopy(utils_js_1.default.createNullProtoObjWherePossible(), options);
291
+ opts.filename = getIncludePath(path, opts);
292
+ if (typeof options.includer === "function") {
293
+ var includerResult = options.includer(path, opts.filename);
294
+ if (includerResult) {
295
+ if (includerResult.filename) {
296
+ opts.filename = includerResult.filename;
297
+ }
298
+ if (includerResult.template) {
299
+ return handleCache(opts, includerResult.template);
300
+ }
301
+ }
302
+ }
303
+ return handleCache(opts);
304
+ }
305
+ function rethrow(err, str, flnm, lineno, esc) {
306
+ var lines = str.split(`
307
+ `);
308
+ var start = Math.max(lineno - 3, 0);
309
+ var end = Math.min(lines.length, lineno + 3);
310
+ var filename = esc(flnm);
311
+ var context = lines.slice(start, end).map(function(line, i) {
312
+ var curr = i + start + 1;
313
+ return (curr == lineno ? " >> " : " ") + curr + "| " + line;
314
+ }).join(`
315
+ `);
316
+ err.path = filename;
317
+ err.message = (filename || "ejs") + ":" + lineno + `
318
+ ` + context + `
319
+
320
+ ` + err.message;
321
+ throw err;
322
+ }
323
+ function stripSemi(str) {
324
+ return str.replace(/;(\s*$)/, "$1");
325
+ }
326
+ ejs.compile = function compile(template, opts) {
327
+ var templ;
328
+ if (opts && opts.scope) {
329
+ console.warn("`scope` option is deprecated and will be removed in future EJS");
330
+ if (!opts.context) {
331
+ opts.context = opts.scope;
332
+ }
333
+ delete opts.scope;
334
+ }
335
+ templ = new Template(template, opts);
336
+ return templ.compile();
337
+ };
338
+ ejs.render = function(template, d, o) {
339
+ var data = d || utils_js_1.default.createNullProtoObjWherePossible();
340
+ var opts = o || utils_js_1.default.createNullProtoObjWherePossible();
341
+ if (arguments.length == 2) {
342
+ utils_js_1.default.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
343
+ }
344
+ return handleCache(opts, template)(data);
345
+ };
346
+ ejs.renderFile = function() {
347
+ var args = Array.prototype.slice.call(arguments);
348
+ var filename = args.shift();
349
+ var cb;
350
+ var opts = { filename };
351
+ var data;
352
+ var viewOpts;
353
+ if (typeof arguments[arguments.length - 1] == "function") {
354
+ cb = args.pop();
355
+ }
356
+ if (args.length) {
357
+ data = args.shift();
358
+ if (args.length) {
359
+ utils_js_1.default.shallowCopy(opts, args.pop());
360
+ } else {
361
+ if (utils_js_1.default.hasOwn(data, "settings") && data.settings) {
362
+ if (data.settings.views) {
363
+ opts.views = data.settings.views;
364
+ }
365
+ if (data.settings["view cache"]) {
366
+ opts.cache = true;
367
+ }
368
+ viewOpts = data.settings["view options"];
369
+ if (viewOpts) {
370
+ utils_js_1.default.shallowCopy(opts, viewOpts);
371
+ }
372
+ }
373
+ utils_js_1.default.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
374
+ }
375
+ opts.filename = filename;
376
+ } else {
377
+ data = utils_js_1.default.createNullProtoObjWherePossible();
378
+ }
379
+ return tryHandleCache(opts, data, cb);
380
+ };
381
+ ejs.Template = Template;
382
+ ejs.clearCache = function() {
383
+ ejs.cache.reset();
384
+ };
385
+ function Template(text, optsParam) {
386
+ var opts = utils_js_1.default.hasOwnOnlyObject(optsParam);
387
+ var options = utils_js_1.default.createNullProtoObjWherePossible();
388
+ this.templateText = text;
389
+ this.mode = null;
390
+ this.truncate = false;
391
+ this.currentLine = 1;
392
+ this.source = "";
393
+ options.escapeFunction = opts.escape || opts.escapeFunction || utils_js_1.default.escapeXML;
394
+ options.compileDebug = opts.compileDebug !== false;
395
+ options.debug = !!opts.debug;
396
+ options.filename = opts.filename;
397
+ options.openDelimiter = opts.openDelimiter || ejs.openDelimiter || _DEFAULT_OPEN_DELIMITER;
398
+ options.closeDelimiter = opts.closeDelimiter || ejs.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
399
+ options.delimiter = opts.delimiter || ejs.delimiter || _DEFAULT_DELIMITER;
400
+ options.strict = opts.strict || false;
401
+ options.context = opts.context;
402
+ options.cache = opts.cache || false;
403
+ options.rmWhitespace = opts.rmWhitespace;
404
+ options.root = opts.root;
405
+ options.includer = opts.includer;
406
+ options.outputFunctionName = opts.outputFunctionName;
407
+ options.localsName = opts.localsName || ejs.localsName || _DEFAULT_LOCALS_NAME;
408
+ options.views = opts.views;
409
+ options.async = opts.async;
410
+ options.destructuredLocals = opts.destructuredLocals;
411
+ options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
412
+ if (options.strict) {
413
+ options._with = false;
414
+ } else {
415
+ options._with = typeof opts._with != "undefined" ? opts._with : true;
416
+ }
417
+ this.opts = options;
418
+ this.regex = this.createRegex();
419
+ }
420
+ Template.modes = {
421
+ EVAL: "eval",
422
+ ESCAPED: "escaped",
423
+ RAW: "raw",
424
+ COMMENT: "comment",
425
+ LITERAL: "literal"
426
+ };
427
+ Template.prototype = {
428
+ createRegex: function() {
429
+ var str = _REGEX_STRING;
430
+ var delim = utils_js_1.default.escapeRegExpChars(this.opts.delimiter);
431
+ var open = utils_js_1.default.escapeRegExpChars(this.opts.openDelimiter);
432
+ var close = utils_js_1.default.escapeRegExpChars(this.opts.closeDelimiter);
433
+ str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
434
+ return new RegExp(str);
435
+ },
436
+ compile: function() {
437
+ var src;
438
+ var fn;
439
+ var opts = this.opts;
440
+ var prepended = "";
441
+ var appended = "";
442
+ var escapeFn = opts.escapeFunction;
443
+ var ctor;
444
+ var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
445
+ if (!this.source) {
446
+ this.generateSource();
447
+ prepended += " ".concat(DECLARATION_KEYWORD, ` __output = "";
448
+ `) + ` function __append(s) { if (s !== undefined && s !== null) __output += s }
449
+ `;
450
+ if (opts.outputFunctionName) {
451
+ if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
452
+ throw new Error("outputFunctionName is not a valid JS identifier.");
453
+ }
454
+ prepended += " ".concat(DECLARATION_KEYWORD, " ") + opts.outputFunctionName + " = __append;" + `
455
+ `;
456
+ }
457
+ if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
458
+ throw new Error("localsName is not a valid JS identifier.");
459
+ }
460
+ if (opts.destructuredLocals && opts.destructuredLocals.length) {
461
+ var destructuring = " ".concat(DECLARATION_KEYWORD, " __locals = (") + opts.localsName + ` || {}),
462
+ `;
463
+ for (var i = 0;i < opts.destructuredLocals.length; i++) {
464
+ var name_1 = opts.destructuredLocals[i];
465
+ if (!_JS_IDENTIFIER.test(name_1)) {
466
+ throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
467
+ }
468
+ if (i > 0) {
469
+ destructuring += `,
470
+ `;
471
+ }
472
+ destructuring += name_1 + " = __locals." + name_1;
473
+ }
474
+ prepended += destructuring + `;
475
+ `;
476
+ }
477
+ if (opts._with !== false) {
478
+ prepended += " with (" + opts.localsName + " || {}) {" + `
479
+ `;
480
+ appended += " }" + `
481
+ `;
482
+ }
483
+ appended += " return __output;" + `
484
+ `;
485
+ this.source = prepended + this.source + appended;
486
+ }
487
+ if (opts.compileDebug) {
488
+ src = "".concat(DECLARATION_KEYWORD, " __line = 1") + `
489
+ ` + " , __lines = " + JSON.stringify(this.templateText) + `
490
+ ` + " , __filename = " + sanitizedFilename + ";" + `
491
+ ` + "try {" + `
492
+ ` + this.source + "} catch (e) {" + `
493
+ ` + " rethrow(e, __lines, __filename, __line, escapeFn);" + `
494
+ ` + "}" + `
495
+ `;
496
+ } else {
497
+ src = this.source;
498
+ }
499
+ if (opts.strict) {
500
+ src = `"use strict";
501
+ ` + src;
502
+ }
503
+ if (opts.debug) {
504
+ console.log(src);
505
+ }
506
+ if (opts.compileDebug && opts.filename) {
507
+ src = src + `
508
+ ` + "//# sourceURL=" + sanitizedFilename + `
509
+ `;
510
+ }
511
+ try {
512
+ if (opts.async) {
513
+ try {
514
+ ctor = new Function("return (async function(){}).constructor;")();
515
+ } catch (e) {
516
+ if (e instanceof SyntaxError) {
517
+ throw new Error("This environment does not support async/await");
518
+ } else {
519
+ throw e;
520
+ }
521
+ }
522
+ } else {
523
+ ctor = Function;
524
+ }
525
+ fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
526
+ } catch (e) {
527
+ if (e instanceof SyntaxError) {
528
+ if (opts.filename) {
529
+ e.message += " in " + opts.filename;
530
+ }
531
+ e.message += ` while compiling ejs
532
+
533
+ `;
534
+ e.message += `If the above error is not helpful, you may want to try EJS-Lint:
535
+ `;
536
+ e.message += "https://github.com/RyanZim/EJS-Lint";
537
+ if (!opts.async) {
538
+ e.message += `
539
+ `;
540
+ e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
541
+ }
542
+ }
543
+ throw e;
544
+ }
545
+ var returnedFn = function anonymous(data) {
546
+ var include = function(path, includeData) {
547
+ var d = utils_js_1.default.shallowCopy(utils_js_1.default.createNullProtoObjWherePossible(), data);
548
+ if (includeData) {
549
+ d = utils_js_1.default.shallowCopy(d, includeData);
550
+ }
551
+ return includeFile(path, opts)(d);
552
+ };
553
+ return fn.apply(opts.context, [data || utils_js_1.default.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
554
+ };
555
+ if (opts.filename && typeof Object.defineProperty === "function") {
556
+ var filename = opts.filename;
557
+ var basename = path_1.default.basename(filename, path_1.default.extname(filename));
558
+ try {
559
+ Object.defineProperty(returnedFn, "name", {
560
+ value: basename,
561
+ writable: false,
562
+ enumerable: false,
563
+ configurable: true
564
+ });
565
+ } catch (e) {}
566
+ }
567
+ return returnedFn;
568
+ },
569
+ generateSource: function() {
570
+ var opts = this.opts;
571
+ if (opts.rmWhitespace) {
572
+ this.templateText = this.templateText.replace(/[\r\n]+/g, `
573
+ `).replace(/^\s+|\s+$/gm, "");
574
+ }
575
+ var self2 = this;
576
+ var d = this.opts.delimiter;
577
+ var o = this.opts.openDelimiter;
578
+ var c = this.opts.closeDelimiter;
579
+ var openWhitespaceSlurpTag = utils_js_1.default.escapeRegExpChars(o + d + "_");
580
+ var closeWhitespaceSlurpTag = utils_js_1.default.escapeRegExpChars("_" + d + c);
581
+ var openWhitespaceSlurpReplacement = o + d + "_";
582
+ var closeWhitespaceSlurpReplacement = "_" + d + c;
583
+ this.templateText = this.templateText.replace(new RegExp("[ \\t]*" + openWhitespaceSlurpTag, "gm"), openWhitespaceSlurpReplacement).replace(new RegExp(closeWhitespaceSlurpTag + "[ \\t]*", "gm"), closeWhitespaceSlurpReplacement);
584
+ var matches = this.parseTemplateText();
585
+ if (matches && matches.length) {
586
+ matches.forEach(function(line, index) {
587
+ var closing;
588
+ if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
589
+ closing = matches[index + 2];
590
+ if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
591
+ throw new Error('Could not find matching close tag for "' + line + '".');
592
+ }
593
+ }
594
+ self2.scanLine(line);
595
+ });
596
+ }
597
+ },
598
+ parseTemplateText: function() {
599
+ var str = this.templateText;
600
+ var pat = this.regex;
601
+ var result = pat.exec(str);
602
+ var arr = [];
603
+ var firstPos;
604
+ while (result) {
605
+ firstPos = result.index;
606
+ if (firstPos !== 0) {
607
+ arr.push(str.substring(0, firstPos));
608
+ str = str.slice(firstPos);
609
+ }
610
+ arr.push(result[0]);
611
+ str = str.slice(result[0].length);
612
+ result = pat.exec(str);
613
+ }
614
+ if (str) {
615
+ arr.push(str);
616
+ }
617
+ return arr;
618
+ },
619
+ _addOutput: function(line) {
620
+ if (this.truncate) {
621
+ line = line.replace(/^(?:\r\n|\r|\n)/, "");
622
+ this.truncate = false;
623
+ }
624
+ if (!line) {
625
+ return line;
626
+ }
627
+ line = line.replace(/\\/g, "\\\\");
628
+ line = line.replace(/\n/g, "\\n");
629
+ line = line.replace(/\r/g, "\\r");
630
+ line = line.replace(/"/g, "\\\"");
631
+ this.source += ' ; __append("' + line + '")' + `
632
+ `;
633
+ },
634
+ scanLine: function(line) {
635
+ var self2 = this;
636
+ var d = this.opts.delimiter;
637
+ var o = this.opts.openDelimiter;
638
+ var c = this.opts.closeDelimiter;
639
+ var newLineCount = 0;
640
+ newLineCount = line.split(`
641
+ `).length - 1;
642
+ switch (line) {
643
+ case o + d:
644
+ case o + d + "_":
645
+ this.mode = Template.modes.EVAL;
646
+ break;
647
+ case o + d + "=":
648
+ this.mode = Template.modes.ESCAPED;
649
+ break;
650
+ case o + d + "-":
651
+ this.mode = Template.modes.RAW;
652
+ break;
653
+ case o + d + "#":
654
+ this.mode = Template.modes.COMMENT;
655
+ break;
656
+ case o + d + d:
657
+ this.mode = Template.modes.LITERAL;
658
+ this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + `
659
+ `;
660
+ break;
661
+ case d + d + c:
662
+ this.mode = Template.modes.LITERAL;
663
+ this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + `
664
+ `;
665
+ break;
666
+ case d + c:
667
+ case "-" + d + c:
668
+ case "_" + d + c:
669
+ if (this.mode == Template.modes.LITERAL) {
670
+ this._addOutput(line);
671
+ }
672
+ this.mode = null;
673
+ this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
674
+ break;
675
+ default:
676
+ if (this.mode) {
677
+ switch (this.mode) {
678
+ case Template.modes.EVAL:
679
+ case Template.modes.ESCAPED:
680
+ case Template.modes.RAW:
681
+ if (line.lastIndexOf("//") > line.lastIndexOf(`
682
+ `)) {
683
+ line += `
684
+ `;
685
+ }
686
+ }
687
+ switch (this.mode) {
688
+ case Template.modes.EVAL:
689
+ this.source += " ; " + line + `
690
+ `;
691
+ break;
692
+ case Template.modes.ESCAPED:
693
+ this.source += " ; __append(escapeFn(" + stripSemi(line) + "))" + `
694
+ `;
695
+ break;
696
+ case Template.modes.RAW:
697
+ this.source += " ; __append(" + stripSemi(line) + ")" + `
698
+ `;
699
+ break;
700
+ case Template.modes.COMMENT:
701
+ break;
702
+ case Template.modes.LITERAL:
703
+ this._addOutput(line);
704
+ break;
705
+ }
706
+ } else {
707
+ this._addOutput(line);
708
+ }
709
+ }
710
+ if (self2.opts.compileDebug && newLineCount) {
711
+ this.currentLine += newLineCount;
712
+ this.source += " ; __line = " + this.currentLine + `
713
+ `;
714
+ }
715
+ }
716
+ };
717
+ ejs.escapeXML = utils_js_1.default.escapeXML;
718
+ ejs.__express = ejs.renderFile;
719
+ if (typeof window != "undefined") {
720
+ window.ejs = ejs;
721
+ }
722
+ if (typeof module3 != "undefined") {
723
+ module3.exports = ejs;
724
+ }
725
+ exports3.default = ejs;
726
+ }, { "./utils.js": 2, fs: 3, path: 4 }], 2: [function(require2, module3, exports3) {
727
+ Object.defineProperty(exports3, "__esModule", { value: true });
728
+ var utils = {};
729
+ var regExpChars = /[|\\{}()[\]^$+*?.]/g;
730
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
731
+ var hasOwn = function(obj, key) {
732
+ return hasOwnProperty.apply(obj, [key]);
733
+ };
734
+ utils.hasOwn = hasOwn;
735
+ utils.escapeRegExpChars = function(string) {
736
+ if (!string) {
737
+ return "";
738
+ }
739
+ return String(string).replace(regExpChars, "\\$&");
740
+ };
741
+ var _ENCODE_HTML_RULES = {
742
+ "&": "&amp;",
743
+ "<": "&lt;",
744
+ ">": "&gt;",
745
+ '"': "&#34;",
746
+ "'": "&#39;"
747
+ };
748
+ var _MATCH_HTML = /[&<>'"]/g;
749
+ function encode_char(c) {
750
+ return _ENCODE_HTML_RULES[c] || c;
751
+ }
752
+ var escapeFuncStr = `var _ENCODE_HTML_RULES = {
753
+ ` + ` "&": "&amp;"
754
+ ` + ` , "<": "&lt;"
755
+ ` + ` , ">": "&gt;"
756
+ ` + ` , '"': "&#34;"
757
+ ` + ` , "'": "&#39;"
758
+ ` + ` }
759
+ ` + ` , _MATCH_HTML = /[&<>'"]/g;
760
+ ` + `function encode_char(c) {
761
+ ` + ` return _ENCODE_HTML_RULES[c] || c;
762
+ ` + `};
763
+ `;
764
+ utils.escapeXML = function(markup) {
765
+ return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
766
+ };
767
+ function escapeXMLToString() {
768
+ return Function.prototype.toString.call(this) + `;
769
+ ` + escapeFuncStr;
770
+ }
771
+ try {
772
+ if (typeof Object.defineProperty === "function") {
773
+ Object.defineProperty(utils.escapeXML, "toString", { value: escapeXMLToString });
774
+ } else {
775
+ utils.escapeXML.toString = escapeXMLToString;
776
+ }
777
+ } catch (err) {
778
+ console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
779
+ }
780
+ utils.shallowCopy = function(to, from) {
781
+ from = from || {};
782
+ if (to !== null && to !== undefined) {
783
+ for (var p in from) {
784
+ if (!hasOwn(from, p)) {
785
+ continue;
786
+ }
787
+ if (p === "__proto__" || p === "constructor") {
788
+ continue;
789
+ }
790
+ to[p] = from[p];
791
+ }
792
+ }
793
+ return to;
794
+ };
795
+ utils.shallowCopyFromList = function(to, from, list) {
796
+ list = list || [];
797
+ from = from || {};
798
+ if (to !== null && to !== undefined) {
799
+ for (var i = 0;i < list.length; i++) {
800
+ var p = list[i];
801
+ if (typeof from[p] != "undefined") {
802
+ if (!hasOwn(from, p)) {
803
+ continue;
804
+ }
805
+ if (p === "__proto__" || p === "constructor") {
806
+ continue;
807
+ }
808
+ to[p] = from[p];
809
+ }
810
+ }
811
+ }
812
+ return to;
813
+ };
814
+ utils.cache = {
815
+ _data: {},
816
+ set: function(key, val) {
817
+ this._data[key] = val;
818
+ },
819
+ get: function(key) {
820
+ return this._data[key];
821
+ },
822
+ remove: function(key) {
823
+ delete this._data[key];
824
+ },
825
+ reset: function() {
826
+ this._data = {};
827
+ }
828
+ };
829
+ utils.hyphenToCamel = function(str) {
830
+ return str.replace(/-[a-z]/g, function(match) {
831
+ return match[1].toUpperCase();
832
+ });
833
+ };
834
+ utils.createNullProtoObjWherePossible = function() {
835
+ if (typeof Object.create == "function") {
836
+ return function() {
837
+ return Object.create(null);
838
+ };
839
+ }
840
+ if (!({ __proto__: null } instanceof Object)) {
841
+ return function() {
842
+ return { __proto__: null };
843
+ };
844
+ }
845
+ return function() {
846
+ return {};
847
+ };
848
+ }();
849
+ utils.hasOwnOnlyObject = function(obj) {
850
+ var o = utils.createNullProtoObjWherePossible();
851
+ for (var p in obj) {
852
+ if (hasOwn(obj, p)) {
853
+ o[p] = obj[p];
854
+ }
855
+ }
856
+ return o;
857
+ };
858
+ if (typeof exports3 != "undefined") {
859
+ module3.exports = utils;
860
+ }
861
+ exports3.default = utils;
862
+ }, {}], 3: [function(require2, module3, exports3) {}, {}], 4: [function(require2, module3, exports3) {
863
+ (function(process2) {
864
+ (function() {
865
+ function assertPath(path) {
866
+ if (typeof path !== "string") {
867
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
868
+ }
869
+ }
870
+ function normalizeStringPosix(path, allowAboveRoot) {
871
+ var res = "";
872
+ var lastSegmentLength = 0;
873
+ var lastSlash = -1;
874
+ var dots = 0;
875
+ var code;
876
+ for (var i = 0;i <= path.length; ++i) {
877
+ if (i < path.length)
878
+ code = path.charCodeAt(i);
879
+ else if (code === 47)
880
+ break;
881
+ else
882
+ code = 47;
883
+ if (code === 47) {
884
+ if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
885
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
886
+ if (res.length > 2) {
887
+ var lastSlashIndex = res.lastIndexOf("/");
888
+ if (lastSlashIndex !== res.length - 1) {
889
+ if (lastSlashIndex === -1) {
890
+ res = "";
891
+ lastSegmentLength = 0;
892
+ } else {
893
+ res = res.slice(0, lastSlashIndex);
894
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
895
+ }
896
+ lastSlash = i;
897
+ dots = 0;
898
+ continue;
899
+ }
900
+ } else if (res.length === 2 || res.length === 1) {
901
+ res = "";
902
+ lastSegmentLength = 0;
903
+ lastSlash = i;
904
+ dots = 0;
905
+ continue;
906
+ }
907
+ }
908
+ if (allowAboveRoot) {
909
+ if (res.length > 0)
910
+ res += "/..";
911
+ else
912
+ res = "..";
913
+ lastSegmentLength = 2;
914
+ }
915
+ } else {
916
+ if (res.length > 0)
917
+ res += "/" + path.slice(lastSlash + 1, i);
918
+ else
919
+ res = path.slice(lastSlash + 1, i);
920
+ lastSegmentLength = i - lastSlash - 1;
921
+ }
922
+ lastSlash = i;
923
+ dots = 0;
924
+ } else if (code === 46 && dots !== -1) {
925
+ ++dots;
926
+ } else {
927
+ dots = -1;
928
+ }
929
+ }
930
+ return res;
931
+ }
932
+ function _format(sep, pathObject) {
933
+ var dir = pathObject.dir || pathObject.root;
934
+ var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
935
+ if (!dir) {
936
+ return base;
937
+ }
938
+ if (dir === pathObject.root) {
939
+ return dir + base;
940
+ }
941
+ return dir + sep + base;
942
+ }
943
+ var posix = {
944
+ resolve: function resolve() {
945
+ var resolvedPath = "";
946
+ var resolvedAbsolute = false;
947
+ var cwd;
948
+ for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
949
+ var path;
950
+ if (i >= 0)
951
+ path = arguments[i];
952
+ else {
953
+ if (cwd === undefined)
954
+ cwd = process2.cwd();
955
+ path = cwd;
956
+ }
957
+ assertPath(path);
958
+ if (path.length === 0) {
959
+ continue;
960
+ }
961
+ resolvedPath = path + "/" + resolvedPath;
962
+ resolvedAbsolute = path.charCodeAt(0) === 47;
963
+ }
964
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
965
+ if (resolvedAbsolute) {
966
+ if (resolvedPath.length > 0)
967
+ return "/" + resolvedPath;
968
+ else
969
+ return "/";
970
+ } else if (resolvedPath.length > 0) {
971
+ return resolvedPath;
972
+ } else {
973
+ return ".";
974
+ }
975
+ },
976
+ normalize: function normalize(path) {
977
+ assertPath(path);
978
+ if (path.length === 0)
979
+ return ".";
980
+ var isAbsolute = path.charCodeAt(0) === 47;
981
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
982
+ path = normalizeStringPosix(path, !isAbsolute);
983
+ if (path.length === 0 && !isAbsolute)
984
+ path = ".";
985
+ if (path.length > 0 && trailingSeparator)
986
+ path += "/";
987
+ if (isAbsolute)
988
+ return "/" + path;
989
+ return path;
990
+ },
991
+ isAbsolute: function isAbsolute(path) {
992
+ assertPath(path);
993
+ return path.length > 0 && path.charCodeAt(0) === 47;
994
+ },
995
+ join: function join() {
996
+ if (arguments.length === 0)
997
+ return ".";
998
+ var joined;
999
+ for (var i = 0;i < arguments.length; ++i) {
1000
+ var arg = arguments[i];
1001
+ assertPath(arg);
1002
+ if (arg.length > 0) {
1003
+ if (joined === undefined)
1004
+ joined = arg;
1005
+ else
1006
+ joined += "/" + arg;
1007
+ }
1008
+ }
1009
+ if (joined === undefined)
1010
+ return ".";
1011
+ return posix.normalize(joined);
1012
+ },
1013
+ relative: function relative(from, to) {
1014
+ assertPath(from);
1015
+ assertPath(to);
1016
+ if (from === to)
1017
+ return "";
1018
+ from = posix.resolve(from);
1019
+ to = posix.resolve(to);
1020
+ if (from === to)
1021
+ return "";
1022
+ var fromStart = 1;
1023
+ for (;fromStart < from.length; ++fromStart) {
1024
+ if (from.charCodeAt(fromStart) !== 47)
1025
+ break;
1026
+ }
1027
+ var fromEnd = from.length;
1028
+ var fromLen = fromEnd - fromStart;
1029
+ var toStart = 1;
1030
+ for (;toStart < to.length; ++toStart) {
1031
+ if (to.charCodeAt(toStart) !== 47)
1032
+ break;
1033
+ }
1034
+ var toEnd = to.length;
1035
+ var toLen = toEnd - toStart;
1036
+ var length = fromLen < toLen ? fromLen : toLen;
1037
+ var lastCommonSep = -1;
1038
+ var i = 0;
1039
+ for (;i <= length; ++i) {
1040
+ if (i === length) {
1041
+ if (toLen > length) {
1042
+ if (to.charCodeAt(toStart + i) === 47) {
1043
+ return to.slice(toStart + i + 1);
1044
+ } else if (i === 0) {
1045
+ return to.slice(toStart + i);
1046
+ }
1047
+ } else if (fromLen > length) {
1048
+ if (from.charCodeAt(fromStart + i) === 47) {
1049
+ lastCommonSep = i;
1050
+ } else if (i === 0) {
1051
+ lastCommonSep = 0;
1052
+ }
1053
+ }
1054
+ break;
1055
+ }
1056
+ var fromCode = from.charCodeAt(fromStart + i);
1057
+ var toCode = to.charCodeAt(toStart + i);
1058
+ if (fromCode !== toCode)
1059
+ break;
1060
+ else if (fromCode === 47)
1061
+ lastCommonSep = i;
1062
+ }
1063
+ var out = "";
1064
+ for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i) {
1065
+ if (i === fromEnd || from.charCodeAt(i) === 47) {
1066
+ if (out.length === 0)
1067
+ out += "..";
1068
+ else
1069
+ out += "/..";
1070
+ }
1071
+ }
1072
+ if (out.length > 0)
1073
+ return out + to.slice(toStart + lastCommonSep);
1074
+ else {
1075
+ toStart += lastCommonSep;
1076
+ if (to.charCodeAt(toStart) === 47)
1077
+ ++toStart;
1078
+ return to.slice(toStart);
1079
+ }
1080
+ },
1081
+ _makeLong: function _makeLong(path) {
1082
+ return path;
1083
+ },
1084
+ dirname: function dirname(path) {
1085
+ assertPath(path);
1086
+ if (path.length === 0)
1087
+ return ".";
1088
+ var code = path.charCodeAt(0);
1089
+ var hasRoot = code === 47;
1090
+ var end = -1;
1091
+ var matchedSlash = true;
1092
+ for (var i = path.length - 1;i >= 1; --i) {
1093
+ code = path.charCodeAt(i);
1094
+ if (code === 47) {
1095
+ if (!matchedSlash) {
1096
+ end = i;
1097
+ break;
1098
+ }
1099
+ } else {
1100
+ matchedSlash = false;
1101
+ }
1102
+ }
1103
+ if (end === -1)
1104
+ return hasRoot ? "/" : ".";
1105
+ if (hasRoot && end === 1)
1106
+ return "//";
1107
+ return path.slice(0, end);
1108
+ },
1109
+ basename: function basename(path, ext) {
1110
+ if (ext !== undefined && typeof ext !== "string")
1111
+ throw new TypeError('"ext" argument must be a string');
1112
+ assertPath(path);
1113
+ var start = 0;
1114
+ var end = -1;
1115
+ var matchedSlash = true;
1116
+ var i;
1117
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
1118
+ if (ext.length === path.length && ext === path)
1119
+ return "";
1120
+ var extIdx = ext.length - 1;
1121
+ var firstNonSlashEnd = -1;
1122
+ for (i = path.length - 1;i >= 0; --i) {
1123
+ var code = path.charCodeAt(i);
1124
+ if (code === 47) {
1125
+ if (!matchedSlash) {
1126
+ start = i + 1;
1127
+ break;
1128
+ }
1129
+ } else {
1130
+ if (firstNonSlashEnd === -1) {
1131
+ matchedSlash = false;
1132
+ firstNonSlashEnd = i + 1;
1133
+ }
1134
+ if (extIdx >= 0) {
1135
+ if (code === ext.charCodeAt(extIdx)) {
1136
+ if (--extIdx === -1) {
1137
+ end = i;
1138
+ }
1139
+ } else {
1140
+ extIdx = -1;
1141
+ end = firstNonSlashEnd;
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ if (start === end)
1147
+ end = firstNonSlashEnd;
1148
+ else if (end === -1)
1149
+ end = path.length;
1150
+ return path.slice(start, end);
1151
+ } else {
1152
+ for (i = path.length - 1;i >= 0; --i) {
1153
+ if (path.charCodeAt(i) === 47) {
1154
+ if (!matchedSlash) {
1155
+ start = i + 1;
1156
+ break;
1157
+ }
1158
+ } else if (end === -1) {
1159
+ matchedSlash = false;
1160
+ end = i + 1;
1161
+ }
1162
+ }
1163
+ if (end === -1)
1164
+ return "";
1165
+ return path.slice(start, end);
1166
+ }
1167
+ },
1168
+ extname: function extname(path) {
1169
+ assertPath(path);
1170
+ var startDot = -1;
1171
+ var startPart = 0;
1172
+ var end = -1;
1173
+ var matchedSlash = true;
1174
+ var preDotState = 0;
1175
+ for (var i = path.length - 1;i >= 0; --i) {
1176
+ var code = path.charCodeAt(i);
1177
+ if (code === 47) {
1178
+ if (!matchedSlash) {
1179
+ startPart = i + 1;
1180
+ break;
1181
+ }
1182
+ continue;
1183
+ }
1184
+ if (end === -1) {
1185
+ matchedSlash = false;
1186
+ end = i + 1;
1187
+ }
1188
+ if (code === 46) {
1189
+ if (startDot === -1)
1190
+ startDot = i;
1191
+ else if (preDotState !== 1)
1192
+ preDotState = 1;
1193
+ } else if (startDot !== -1) {
1194
+ preDotState = -1;
1195
+ }
1196
+ }
1197
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1198
+ return "";
1199
+ }
1200
+ return path.slice(startDot, end);
1201
+ },
1202
+ format: function format(pathObject) {
1203
+ if (pathObject === null || typeof pathObject !== "object") {
1204
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
1205
+ }
1206
+ return _format("/", pathObject);
1207
+ },
1208
+ parse: function parse(path) {
1209
+ assertPath(path);
1210
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
1211
+ if (path.length === 0)
1212
+ return ret;
1213
+ var code = path.charCodeAt(0);
1214
+ var isAbsolute = code === 47;
1215
+ var start;
1216
+ if (isAbsolute) {
1217
+ ret.root = "/";
1218
+ start = 1;
1219
+ } else {
1220
+ start = 0;
1221
+ }
1222
+ var startDot = -1;
1223
+ var startPart = 0;
1224
+ var end = -1;
1225
+ var matchedSlash = true;
1226
+ var i = path.length - 1;
1227
+ var preDotState = 0;
1228
+ for (;i >= start; --i) {
1229
+ code = path.charCodeAt(i);
1230
+ if (code === 47) {
1231
+ if (!matchedSlash) {
1232
+ startPart = i + 1;
1233
+ break;
1234
+ }
1235
+ continue;
1236
+ }
1237
+ if (end === -1) {
1238
+ matchedSlash = false;
1239
+ end = i + 1;
1240
+ }
1241
+ if (code === 46) {
1242
+ if (startDot === -1)
1243
+ startDot = i;
1244
+ else if (preDotState !== 1)
1245
+ preDotState = 1;
1246
+ } else if (startDot !== -1) {
1247
+ preDotState = -1;
1248
+ }
1249
+ }
1250
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1251
+ if (end !== -1) {
1252
+ if (startPart === 0 && isAbsolute)
1253
+ ret.base = ret.name = path.slice(1, end);
1254
+ else
1255
+ ret.base = ret.name = path.slice(startPart, end);
1256
+ }
1257
+ } else {
1258
+ if (startPart === 0 && isAbsolute) {
1259
+ ret.name = path.slice(1, startDot);
1260
+ ret.base = path.slice(1, end);
1261
+ } else {
1262
+ ret.name = path.slice(startPart, startDot);
1263
+ ret.base = path.slice(startPart, end);
1264
+ }
1265
+ ret.ext = path.slice(startDot, end);
1266
+ }
1267
+ if (startPart > 0)
1268
+ ret.dir = path.slice(0, startPart - 1);
1269
+ else if (isAbsolute)
1270
+ ret.dir = "/";
1271
+ return ret;
1272
+ },
1273
+ sep: "/",
1274
+ delimiter: ":",
1275
+ win32: null,
1276
+ posix: null
1277
+ };
1278
+ posix.posix = posix;
1279
+ module3.exports = posix;
1280
+ }).call(this);
1281
+ }).call(this, require2("_process"));
1282
+ }, { _process: 5 }], 5: [function(require2, module3, exports3) {
1283
+ var process2 = module3.exports = {};
1284
+ var cachedSetTimeout;
1285
+ var cachedClearTimeout;
1286
+ function defaultSetTimout() {
1287
+ throw new Error("setTimeout has not been defined");
1288
+ }
1289
+ function defaultClearTimeout() {
1290
+ throw new Error("clearTimeout has not been defined");
1291
+ }
1292
+ (function() {
1293
+ try {
1294
+ if (typeof setTimeout === "function") {
1295
+ cachedSetTimeout = setTimeout;
1296
+ } else {
1297
+ cachedSetTimeout = defaultSetTimout;
1298
+ }
1299
+ } catch (e) {
1300
+ cachedSetTimeout = defaultSetTimout;
1301
+ }
1302
+ try {
1303
+ if (typeof clearTimeout === "function") {
1304
+ cachedClearTimeout = clearTimeout;
1305
+ } else {
1306
+ cachedClearTimeout = defaultClearTimeout;
1307
+ }
1308
+ } catch (e) {
1309
+ cachedClearTimeout = defaultClearTimeout;
1310
+ }
1311
+ })();
1312
+ function runTimeout(fun) {
1313
+ if (cachedSetTimeout === setTimeout) {
1314
+ return setTimeout(fun, 0);
1315
+ }
1316
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1317
+ cachedSetTimeout = setTimeout;
1318
+ return setTimeout(fun, 0);
1319
+ }
1320
+ try {
1321
+ return cachedSetTimeout(fun, 0);
1322
+ } catch (e) {
1323
+ try {
1324
+ return cachedSetTimeout.call(null, fun, 0);
1325
+ } catch (e2) {
1326
+ return cachedSetTimeout.call(this, fun, 0);
1327
+ }
1328
+ }
1329
+ }
1330
+ function runClearTimeout(marker) {
1331
+ if (cachedClearTimeout === clearTimeout) {
1332
+ return clearTimeout(marker);
1333
+ }
1334
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1335
+ cachedClearTimeout = clearTimeout;
1336
+ return clearTimeout(marker);
1337
+ }
1338
+ try {
1339
+ return cachedClearTimeout(marker);
1340
+ } catch (e) {
1341
+ try {
1342
+ return cachedClearTimeout.call(null, marker);
1343
+ } catch (e2) {
1344
+ return cachedClearTimeout.call(this, marker);
1345
+ }
1346
+ }
1347
+ }
1348
+ var queue = [];
1349
+ var draining = false;
1350
+ var currentQueue;
1351
+ var queueIndex = -1;
1352
+ function cleanUpNextTick() {
1353
+ if (!draining || !currentQueue) {
1354
+ return;
1355
+ }
1356
+ draining = false;
1357
+ if (currentQueue.length) {
1358
+ queue = currentQueue.concat(queue);
1359
+ } else {
1360
+ queueIndex = -1;
1361
+ }
1362
+ if (queue.length) {
1363
+ drainQueue();
1364
+ }
1365
+ }
1366
+ function drainQueue() {
1367
+ if (draining) {
1368
+ return;
1369
+ }
1370
+ var timeout = runTimeout(cleanUpNextTick);
1371
+ draining = true;
1372
+ var len = queue.length;
1373
+ while (len) {
1374
+ currentQueue = queue;
1375
+ queue = [];
1376
+ while (++queueIndex < len) {
1377
+ if (currentQueue) {
1378
+ currentQueue[queueIndex].run();
1379
+ }
1380
+ }
1381
+ queueIndex = -1;
1382
+ len = queue.length;
1383
+ }
1384
+ currentQueue = null;
1385
+ draining = false;
1386
+ runClearTimeout(timeout);
1387
+ }
1388
+ process2.nextTick = function(fun) {
1389
+ var args = new Array(arguments.length - 1);
1390
+ if (arguments.length > 1) {
1391
+ for (var i = 1;i < arguments.length; i++) {
1392
+ args[i - 1] = arguments[i];
1393
+ }
1394
+ }
1395
+ queue.push(new Item(fun, args));
1396
+ if (queue.length === 1 && !draining) {
1397
+ runTimeout(drainQueue);
1398
+ }
1399
+ };
1400
+ function Item(fun, array) {
1401
+ this.fun = fun;
1402
+ this.array = array;
1403
+ }
1404
+ Item.prototype.run = function() {
1405
+ this.fun.apply(null, this.array);
1406
+ };
1407
+ process2.title = "browser";
1408
+ process2.browser = true;
1409
+ process2.env = {};
1410
+ process2.argv = [];
1411
+ process2.version = "";
1412
+ process2.versions = {};
1413
+ function noop() {}
1414
+ process2.on = noop;
1415
+ process2.addListener = noop;
1416
+ process2.once = noop;
1417
+ process2.off = noop;
1418
+ process2.removeListener = noop;
1419
+ process2.removeAllListeners = noop;
1420
+ process2.emit = noop;
1421
+ process2.prependListener = noop;
1422
+ process2.prependOnceListener = noop;
1423
+ process2.listeners = function(name) {
1424
+ return [];
1425
+ };
1426
+ process2.binding = function(name) {
1427
+ throw new Error("process.binding is not supported");
1428
+ };
1429
+ process2.cwd = function() {
1430
+ return "/";
1431
+ };
1432
+ process2.chdir = function(dir) {
1433
+ throw new Error("process.chdir is not supported");
1434
+ };
1435
+ process2.umask = function() {
1436
+ return 0;
1437
+ };
1438
+ }, {}] }, {}, [1])(1);
1439
+ });
1440
+ });
1441
+
117
1442
  // node_modules/eventemitter3/index.js
118
1443
  var require_eventemitter3 = __commonJS((exports, module) => {
119
1444
  var has = Object.prototype.hasOwnProperty;
@@ -295,717 +1620,8 @@ var require_eventemitter3 = __commonJS((exports, module) => {
295
1620
  // src/server.ts
296
1621
  var import_picocolors3 = __toESM(require_picocolors(), 1);
297
1622
 
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
- "&": "&amp;",
321
- "<": "&lt;",
322
- ">": "&gt;",
323
- '"': "&#34;",
324
- "'": "&#39;"
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
- ` + ` "&": "&amp;"
332
- ` + ` , "<": "&lt;"
333
- ` + ` , ">": "&gt;"
334
- ` + ` , '"': "&#34;"
335
- ` + ` , "'": "&#39;"
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
-
1008
1623
  // src/httpHandler.ts
1624
+ var import_ejs = __toESM(require_ejs(), 1);
1009
1625
  import { readFile, readdir } from "fs/promises";
1010
1626
 
1011
1627
  // src/utils/cors.ts
@@ -1131,7 +1747,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
1131
1747
  };
1132
1748
  });
1133
1749
  const templatePath = requestPath === "/" ? "" : requestPath;
1134
- const rnd = ejs_default.render(finalConfig.serveOutputEjs, {
1750
+ const rnd = import_ejs.default.render(finalConfig.serveOutputEjs, {
1135
1751
  dirs,
1136
1752
  files,
1137
1753
  requestPath: templatePath
@@ -1147,7 +1763,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
1147
1763
  import { resolve } from "path";
1148
1764
 
1149
1765
  // src/static/serveOutputStyles.css
1150
- var serveOutputStyles_default = {};
1766
+ var serveOutputStyles_default = "./assets/serveOutputStyles.css";
1151
1767
 
1152
1768
  // src/static/file.svg
1153
1769
  var file_default = "./assets/file.svg";
@@ -1176,6 +1792,7 @@ var staticAssetRoutes = {
1176
1792
  import { watch } from "fs/promises";
1177
1793
 
1178
1794
  // src/buildManager.ts
1795
+ var import_ejs2 = __toESM(require_ejs(), 1);
1179
1796
  var {build } = globalThis.Bun;
1180
1797
 
1181
1798
  // node_modules/eventemitter3/index.mjs
@@ -1272,39 +1889,88 @@ function lowerBound(array, value, comparator) {
1272
1889
  }
1273
1890
 
1274
1891
  // node_modules/p-queue/dist/priority-queue.js
1892
+ var compactionThreshold = 100;
1893
+
1275
1894
  class PriorityQueue {
1276
1895
  #queue = [];
1896
+ #head = 0;
1277
1897
  enqueue(run, options) {
1278
1898
  const { priority = 0, id } = options ?? {};
1899
+ const { size } = this;
1279
1900
  const element = {
1280
1901
  priority,
1281
1902
  id,
1282
1903
  run
1283
1904
  };
1284
- if (this.size === 0 || this.#queue[this.size - 1].priority >= priority) {
1905
+ if (size === 0) {
1906
+ this.#queue.length = 0;
1907
+ this.#head = 0;
1285
1908
  this.#queue.push(element);
1286
1909
  return;
1287
1910
  }
1911
+ if (this.#queue.at(-1).priority >= priority) {
1912
+ this.#queue.push(element);
1913
+ return;
1914
+ }
1915
+ this.#compact();
1288
1916
  const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);
1289
1917
  this.#queue.splice(index, 0, element);
1290
1918
  }
1291
1919
  setPriority(id, priority) {
1292
- const index = this.#queue.findIndex((element) => element.id === id);
1920
+ const index = this.#queue.findIndex((element, index2) => index2 >= this.#head && element.id === id);
1293
1921
  if (index === -1) {
1294
1922
  throw new ReferenceError(`No promise function with the id "${id}" exists in the queue.`);
1295
1923
  }
1296
1924
  const [item] = this.#queue.splice(index, 1);
1297
1925
  this.enqueue(item.run, { priority, id });
1298
1926
  }
1927
+ remove(idOrRun) {
1928
+ const index = this.#queue.findIndex((element, index2) => {
1929
+ if (index2 < this.#head) {
1930
+ return false;
1931
+ }
1932
+ if (typeof idOrRun === "string") {
1933
+ return element.id === idOrRun;
1934
+ }
1935
+ return element.run === idOrRun;
1936
+ });
1937
+ if (index !== -1) {
1938
+ this.#queue.splice(index, 1);
1939
+ }
1940
+ }
1299
1941
  dequeue() {
1300
- const item = this.#queue.shift();
1942
+ if (this.#head === this.#queue.length) {
1943
+ return;
1944
+ }
1945
+ const item = this.#queue[this.#head];
1946
+ this.#head++;
1947
+ if (this.#head === this.#queue.length) {
1948
+ this.#queue.length = 0;
1949
+ this.#head = 0;
1950
+ } else if (this.#head > compactionThreshold && this.#head > this.#queue.length / 2) {
1951
+ this.#compact();
1952
+ }
1301
1953
  return item?.run;
1302
1954
  }
1303
1955
  filter(options) {
1304
- return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
1956
+ const result = [];
1957
+ for (let index = this.#head;index < this.#queue.length; index++) {
1958
+ const element = this.#queue[index];
1959
+ if (element.priority === options.priority) {
1960
+ result.push(element.run);
1961
+ }
1962
+ }
1963
+ return result;
1305
1964
  }
1306
1965
  get size() {
1307
- return this.#queue.length;
1966
+ return this.#queue.length - this.#head;
1967
+ }
1968
+ #compact() {
1969
+ if (this.#head === 0) {
1970
+ return;
1971
+ }
1972
+ this.#queue.splice(0, this.#head);
1973
+ this.#head = 0;
1308
1974
  }
1309
1975
  }
1310
1976
 
@@ -1331,6 +1997,7 @@ class PQueue extends import__.default {
1331
1997
  #isPaused;
1332
1998
  #idAssigner = 1n;
1333
1999
  #runningTasks = new Map;
2000
+ #queueAbortListenerCleanupFunctions = new Set;
1334
2001
  timeout;
1335
2002
  constructor(options) {
1336
2003
  super();
@@ -1563,7 +2230,11 @@ class PQueue extends import__.default {
1563
2230
  };
1564
2231
  return new Promise((resolve2, reject) => {
1565
2232
  const taskSymbol = Symbol(`task-${options.id}`);
1566
- this.#queue.enqueue(async () => {
2233
+ let cleanupQueueAbortHandler = () => {
2234
+ return;
2235
+ };
2236
+ const run = async () => {
2237
+ cleanupQueueAbortHandler();
1567
2238
  this.#pending++;
1568
2239
  this.#runningTasks.set(taskSymbol, {
1569
2240
  id: options.id,
@@ -1612,7 +2283,35 @@ class PQueue extends import__.default {
1612
2283
  this.#next();
1613
2284
  });
1614
2285
  }
1615
- }, options);
2286
+ };
2287
+ this.#queue.enqueue(run, options);
2288
+ const removeQueuedTask = () => {
2289
+ if (this.#queue instanceof PriorityQueue) {
2290
+ this.#queue.remove(run);
2291
+ return;
2292
+ }
2293
+ this.#queue.remove?.(options.id);
2294
+ };
2295
+ if (options.signal) {
2296
+ const { signal } = options;
2297
+ const queueAbortHandler = () => {
2298
+ cleanupQueueAbortHandler();
2299
+ removeQueuedTask();
2300
+ reject(signal.reason);
2301
+ this.#tryToStartAnother();
2302
+ this.emit("next");
2303
+ };
2304
+ cleanupQueueAbortHandler = () => {
2305
+ signal.removeEventListener("abort", queueAbortHandler);
2306
+ this.#queueAbortListenerCleanupFunctions.delete(cleanupQueueAbortHandler);
2307
+ };
2308
+ if (signal.aborted) {
2309
+ queueAbortHandler();
2310
+ return;
2311
+ }
2312
+ signal.addEventListener("abort", queueAbortHandler, { once: true });
2313
+ this.#queueAbortListenerCleanupFunctions.add(cleanupQueueAbortHandler);
2314
+ }
1616
2315
  this.emit("add");
1617
2316
  this.#tryToStartAnother();
1618
2317
  });
@@ -1632,6 +2331,9 @@ class PQueue extends import__.default {
1632
2331
  this.#isPaused = true;
1633
2332
  }
1634
2333
  clear() {
2334
+ for (const cleanupQueueAbortHandler of this.#queueAbortListenerCleanupFunctions) {
2335
+ cleanupQueueAbortHandler();
2336
+ }
1635
2337
  this.#queue = new this.#queueClass;
1636
2338
  this.#clearIntervalTimer();
1637
2339
  this.#updateRateLimitState();
@@ -1771,7 +2473,10 @@ class PQueue extends import__.default {
1771
2473
  return this.#pending === this.#concurrency && this.#queue.size > 0 || this.isRateLimited && this.#queue.size > 0;
1772
2474
  }
1773
2475
  get runningTasks() {
1774
- return [...this.#runningTasks.values()].map((task) => ({ ...task }));
2476
+ return [...this.#runningTasks.values()].map((task) => ({
2477
+ ...task,
2478
+ timeoutRemaining: task.timeout ? Math.max(0, task.startTime + task.timeout - Date.now()) : undefined
2479
+ }));
1775
2480
  }
1776
2481
  }
1777
2482
 
@@ -1911,7 +2616,7 @@ function publishIndexHTML(paths, template, output, _event) {
1911
2616
  const hashedCss = `${cssUrl.href.replace(`${basePathUrl.href}/`, "./")}?${cssFile.hash}`;
1912
2617
  cssFiles.push(hashedCss);
1913
2618
  }
1914
- Bun.write(paths.buildDestination + "/index.html", ejs_default.render(template, { hashedImports, cssFiles }));
2619
+ Bun.write(paths.buildDestination + "/index.html", import_ejs2.default.render(template, { hashedImports, cssFiles }));
1915
2620
  }
1916
2621
  function printPrettyBuildOutput(outTable) {
1917
2622
  if (outTable.length === 0)
@@ -2048,8 +2753,8 @@ var DEFAULT_HMR_PATH = "/hmr-ws";
2048
2753
  function bunHotReload(bunServerConfig) {
2049
2754
  const socketPath = bunServerConfig.websocketPath || DEFAULT_HMR_PATH;
2050
2755
  const endPath = socketPath.startsWith("/") ? socketPath : `/${socketPath}`;
2051
- const path2 = `${bunServerConfig.secure ? "wss" : "ws"}://localhost:${bunServerConfig.port}${endPath}`;
2052
- return hotReload.toString().replace("[REPLACE_ENDPOINT]", path2);
2756
+ const path = `${bunServerConfig.secure ? "wss" : "ws"}://localhost:${bunServerConfig.port}${endPath}`;
2757
+ return hotReload.toString().replace("[REPLACE_ENDPOINT]", path);
2053
2758
  }
2054
2759
 
2055
2760
  // src/bunHmrPlugin.ts
@@ -2236,3 +2941,6 @@ export {
2236
2941
  getBunHMRFooter,
2237
2942
  bunHotReloadPlugin
2238
2943
  };
2944
+
2945
+ //# debugId=148C2DD0CFF66E3C64756E2164756E21
2946
+ //# sourceMappingURL=index.js.map