bun-dev-server 1.0.3 → 1.0.4
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/assets/serveOutputStyles.css +166 -0
- package/dist/index.js +1347 -728
- package/dist/index.js.map +29 -0
- package/package.json +2 -2
- package/dist/index.css +0 -164
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
|
|
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,1342 @@ 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 (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.escapeRegExpChars = function(string) {
|
|
735
|
+
if (!string) {
|
|
736
|
+
return "";
|
|
737
|
+
}
|
|
738
|
+
return String(string).replace(regExpChars, "\\$&");
|
|
739
|
+
};
|
|
740
|
+
var _ENCODE_HTML_RULES = {
|
|
741
|
+
"&": "&",
|
|
742
|
+
"<": "<",
|
|
743
|
+
">": ">",
|
|
744
|
+
'"': """,
|
|
745
|
+
"'": "'"
|
|
746
|
+
};
|
|
747
|
+
var _MATCH_HTML = /[&<>'"]/g;
|
|
748
|
+
function encode_char(c) {
|
|
749
|
+
return _ENCODE_HTML_RULES[c] || c;
|
|
750
|
+
}
|
|
751
|
+
var escapeFuncStr = `var _ENCODE_HTML_RULES = {
|
|
752
|
+
` + ` "&": "&"
|
|
753
|
+
` + ` , "<": "<"
|
|
754
|
+
` + ` , ">": ">"
|
|
755
|
+
` + ` , '"': """
|
|
756
|
+
` + ` , "'": "'"
|
|
757
|
+
` + ` }
|
|
758
|
+
` + ` , _MATCH_HTML = /[&<>'"]/g;
|
|
759
|
+
` + `function encode_char(c) {
|
|
760
|
+
` + ` return _ENCODE_HTML_RULES[c] || c;
|
|
761
|
+
` + `};
|
|
762
|
+
`;
|
|
763
|
+
utils.escapeXML = function(markup) {
|
|
764
|
+
return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
765
|
+
};
|
|
766
|
+
function escapeXMLToString() {
|
|
767
|
+
return Function.prototype.toString.call(this) + `;
|
|
768
|
+
` + escapeFuncStr;
|
|
769
|
+
}
|
|
770
|
+
try {
|
|
771
|
+
if (typeof Object.defineProperty === "function") {
|
|
772
|
+
Object.defineProperty(utils.escapeXML, "toString", { value: escapeXMLToString });
|
|
773
|
+
} else {
|
|
774
|
+
utils.escapeXML.toString = escapeXMLToString;
|
|
775
|
+
}
|
|
776
|
+
} catch (err) {
|
|
777
|
+
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
778
|
+
}
|
|
779
|
+
utils.shallowCopy = function(to, from) {
|
|
780
|
+
from = from || {};
|
|
781
|
+
if (to !== null && to !== undefined) {
|
|
782
|
+
for (var p in from) {
|
|
783
|
+
if (!hasOwn(from, p)) {
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (p === "__proto__" || p === "constructor") {
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
to[p] = from[p];
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return to;
|
|
793
|
+
};
|
|
794
|
+
utils.shallowCopyFromList = function(to, from, list) {
|
|
795
|
+
list = list || [];
|
|
796
|
+
from = from || {};
|
|
797
|
+
if (to !== null && to !== undefined) {
|
|
798
|
+
for (var i = 0;i < list.length; i++) {
|
|
799
|
+
var p = list[i];
|
|
800
|
+
if (typeof from[p] != "undefined") {
|
|
801
|
+
if (!hasOwn(from, p)) {
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (p === "__proto__" || p === "constructor") {
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
to[p] = from[p];
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return to;
|
|
812
|
+
};
|
|
813
|
+
utils.cache = {
|
|
814
|
+
_data: {},
|
|
815
|
+
set: function(key, val) {
|
|
816
|
+
this._data[key] = val;
|
|
817
|
+
},
|
|
818
|
+
get: function(key) {
|
|
819
|
+
return this._data[key];
|
|
820
|
+
},
|
|
821
|
+
remove: function(key) {
|
|
822
|
+
delete this._data[key];
|
|
823
|
+
},
|
|
824
|
+
reset: function() {
|
|
825
|
+
this._data = {};
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
utils.hyphenToCamel = function(str) {
|
|
829
|
+
return str.replace(/-[a-z]/g, function(match) {
|
|
830
|
+
return match[1].toUpperCase();
|
|
831
|
+
});
|
|
832
|
+
};
|
|
833
|
+
utils.createNullProtoObjWherePossible = function() {
|
|
834
|
+
if (typeof Object.create == "function") {
|
|
835
|
+
return function() {
|
|
836
|
+
return Object.create(null);
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
if (!({ __proto__: null } instanceof Object)) {
|
|
840
|
+
return function() {
|
|
841
|
+
return { __proto__: null };
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
return function() {
|
|
845
|
+
return {};
|
|
846
|
+
};
|
|
847
|
+
}();
|
|
848
|
+
utils.hasOwnOnlyObject = function(obj) {
|
|
849
|
+
var o = utils.createNullProtoObjWherePossible();
|
|
850
|
+
for (var p in obj) {
|
|
851
|
+
if (hasOwn(obj, p)) {
|
|
852
|
+
o[p] = obj[p];
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return o;
|
|
856
|
+
};
|
|
857
|
+
if (typeof exports3 != "undefined") {
|
|
858
|
+
module3.exports = utils;
|
|
859
|
+
}
|
|
860
|
+
exports3.default = utils;
|
|
861
|
+
}, {}], 3: [function(require2, module3, exports3) {}, {}], 4: [function(require2, module3, exports3) {
|
|
862
|
+
(function(process2) {
|
|
863
|
+
(function() {
|
|
864
|
+
function assertPath(path) {
|
|
865
|
+
if (typeof path !== "string") {
|
|
866
|
+
throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
870
|
+
var res = "";
|
|
871
|
+
var lastSegmentLength = 0;
|
|
872
|
+
var lastSlash = -1;
|
|
873
|
+
var dots = 0;
|
|
874
|
+
var code;
|
|
875
|
+
for (var i = 0;i <= path.length; ++i) {
|
|
876
|
+
if (i < path.length)
|
|
877
|
+
code = path.charCodeAt(i);
|
|
878
|
+
else if (code === 47)
|
|
879
|
+
break;
|
|
880
|
+
else
|
|
881
|
+
code = 47;
|
|
882
|
+
if (code === 47) {
|
|
883
|
+
if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
|
|
884
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
885
|
+
if (res.length > 2) {
|
|
886
|
+
var lastSlashIndex = res.lastIndexOf("/");
|
|
887
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
888
|
+
if (lastSlashIndex === -1) {
|
|
889
|
+
res = "";
|
|
890
|
+
lastSegmentLength = 0;
|
|
891
|
+
} else {
|
|
892
|
+
res = res.slice(0, lastSlashIndex);
|
|
893
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
894
|
+
}
|
|
895
|
+
lastSlash = i;
|
|
896
|
+
dots = 0;
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
900
|
+
res = "";
|
|
901
|
+
lastSegmentLength = 0;
|
|
902
|
+
lastSlash = i;
|
|
903
|
+
dots = 0;
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (allowAboveRoot) {
|
|
908
|
+
if (res.length > 0)
|
|
909
|
+
res += "/..";
|
|
910
|
+
else
|
|
911
|
+
res = "..";
|
|
912
|
+
lastSegmentLength = 2;
|
|
913
|
+
}
|
|
914
|
+
} else {
|
|
915
|
+
if (res.length > 0)
|
|
916
|
+
res += "/" + path.slice(lastSlash + 1, i);
|
|
917
|
+
else
|
|
918
|
+
res = path.slice(lastSlash + 1, i);
|
|
919
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
920
|
+
}
|
|
921
|
+
lastSlash = i;
|
|
922
|
+
dots = 0;
|
|
923
|
+
} else if (code === 46 && dots !== -1) {
|
|
924
|
+
++dots;
|
|
925
|
+
} else {
|
|
926
|
+
dots = -1;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return res;
|
|
930
|
+
}
|
|
931
|
+
function _format(sep, pathObject) {
|
|
932
|
+
var dir = pathObject.dir || pathObject.root;
|
|
933
|
+
var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
934
|
+
if (!dir) {
|
|
935
|
+
return base;
|
|
936
|
+
}
|
|
937
|
+
if (dir === pathObject.root) {
|
|
938
|
+
return dir + base;
|
|
939
|
+
}
|
|
940
|
+
return dir + sep + base;
|
|
941
|
+
}
|
|
942
|
+
var posix = {
|
|
943
|
+
resolve: function resolve() {
|
|
944
|
+
var resolvedPath = "";
|
|
945
|
+
var resolvedAbsolute = false;
|
|
946
|
+
var cwd;
|
|
947
|
+
for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
|
948
|
+
var path;
|
|
949
|
+
if (i >= 0)
|
|
950
|
+
path = arguments[i];
|
|
951
|
+
else {
|
|
952
|
+
if (cwd === undefined)
|
|
953
|
+
cwd = process2.cwd();
|
|
954
|
+
path = cwd;
|
|
955
|
+
}
|
|
956
|
+
assertPath(path);
|
|
957
|
+
if (path.length === 0) {
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
resolvedPath = path + "/" + resolvedPath;
|
|
961
|
+
resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
962
|
+
}
|
|
963
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
964
|
+
if (resolvedAbsolute) {
|
|
965
|
+
if (resolvedPath.length > 0)
|
|
966
|
+
return "/" + resolvedPath;
|
|
967
|
+
else
|
|
968
|
+
return "/";
|
|
969
|
+
} else if (resolvedPath.length > 0) {
|
|
970
|
+
return resolvedPath;
|
|
971
|
+
} else {
|
|
972
|
+
return ".";
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
normalize: function normalize(path) {
|
|
976
|
+
assertPath(path);
|
|
977
|
+
if (path.length === 0)
|
|
978
|
+
return ".";
|
|
979
|
+
var isAbsolute = path.charCodeAt(0) === 47;
|
|
980
|
+
var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
|
981
|
+
path = normalizeStringPosix(path, !isAbsolute);
|
|
982
|
+
if (path.length === 0 && !isAbsolute)
|
|
983
|
+
path = ".";
|
|
984
|
+
if (path.length > 0 && trailingSeparator)
|
|
985
|
+
path += "/";
|
|
986
|
+
if (isAbsolute)
|
|
987
|
+
return "/" + path;
|
|
988
|
+
return path;
|
|
989
|
+
},
|
|
990
|
+
isAbsolute: function isAbsolute(path) {
|
|
991
|
+
assertPath(path);
|
|
992
|
+
return path.length > 0 && path.charCodeAt(0) === 47;
|
|
993
|
+
},
|
|
994
|
+
join: function join() {
|
|
995
|
+
if (arguments.length === 0)
|
|
996
|
+
return ".";
|
|
997
|
+
var joined;
|
|
998
|
+
for (var i = 0;i < arguments.length; ++i) {
|
|
999
|
+
var arg = arguments[i];
|
|
1000
|
+
assertPath(arg);
|
|
1001
|
+
if (arg.length > 0) {
|
|
1002
|
+
if (joined === undefined)
|
|
1003
|
+
joined = arg;
|
|
1004
|
+
else
|
|
1005
|
+
joined += "/" + arg;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (joined === undefined)
|
|
1009
|
+
return ".";
|
|
1010
|
+
return posix.normalize(joined);
|
|
1011
|
+
},
|
|
1012
|
+
relative: function relative(from, to) {
|
|
1013
|
+
assertPath(from);
|
|
1014
|
+
assertPath(to);
|
|
1015
|
+
if (from === to)
|
|
1016
|
+
return "";
|
|
1017
|
+
from = posix.resolve(from);
|
|
1018
|
+
to = posix.resolve(to);
|
|
1019
|
+
if (from === to)
|
|
1020
|
+
return "";
|
|
1021
|
+
var fromStart = 1;
|
|
1022
|
+
for (;fromStart < from.length; ++fromStart) {
|
|
1023
|
+
if (from.charCodeAt(fromStart) !== 47)
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
var fromEnd = from.length;
|
|
1027
|
+
var fromLen = fromEnd - fromStart;
|
|
1028
|
+
var toStart = 1;
|
|
1029
|
+
for (;toStart < to.length; ++toStart) {
|
|
1030
|
+
if (to.charCodeAt(toStart) !== 47)
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
var toEnd = to.length;
|
|
1034
|
+
var toLen = toEnd - toStart;
|
|
1035
|
+
var length = fromLen < toLen ? fromLen : toLen;
|
|
1036
|
+
var lastCommonSep = -1;
|
|
1037
|
+
var i = 0;
|
|
1038
|
+
for (;i <= length; ++i) {
|
|
1039
|
+
if (i === length) {
|
|
1040
|
+
if (toLen > length) {
|
|
1041
|
+
if (to.charCodeAt(toStart + i) === 47) {
|
|
1042
|
+
return to.slice(toStart + i + 1);
|
|
1043
|
+
} else if (i === 0) {
|
|
1044
|
+
return to.slice(toStart + i);
|
|
1045
|
+
}
|
|
1046
|
+
} else if (fromLen > length) {
|
|
1047
|
+
if (from.charCodeAt(fromStart + i) === 47) {
|
|
1048
|
+
lastCommonSep = i;
|
|
1049
|
+
} else if (i === 0) {
|
|
1050
|
+
lastCommonSep = 0;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
var fromCode = from.charCodeAt(fromStart + i);
|
|
1056
|
+
var toCode = to.charCodeAt(toStart + i);
|
|
1057
|
+
if (fromCode !== toCode)
|
|
1058
|
+
break;
|
|
1059
|
+
else if (fromCode === 47)
|
|
1060
|
+
lastCommonSep = i;
|
|
1061
|
+
}
|
|
1062
|
+
var out = "";
|
|
1063
|
+
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i) {
|
|
1064
|
+
if (i === fromEnd || from.charCodeAt(i) === 47) {
|
|
1065
|
+
if (out.length === 0)
|
|
1066
|
+
out += "..";
|
|
1067
|
+
else
|
|
1068
|
+
out += "/..";
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
if (out.length > 0)
|
|
1072
|
+
return out + to.slice(toStart + lastCommonSep);
|
|
1073
|
+
else {
|
|
1074
|
+
toStart += lastCommonSep;
|
|
1075
|
+
if (to.charCodeAt(toStart) === 47)
|
|
1076
|
+
++toStart;
|
|
1077
|
+
return to.slice(toStart);
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
_makeLong: function _makeLong(path) {
|
|
1081
|
+
return path;
|
|
1082
|
+
},
|
|
1083
|
+
dirname: function dirname(path) {
|
|
1084
|
+
assertPath(path);
|
|
1085
|
+
if (path.length === 0)
|
|
1086
|
+
return ".";
|
|
1087
|
+
var code = path.charCodeAt(0);
|
|
1088
|
+
var hasRoot = code === 47;
|
|
1089
|
+
var end = -1;
|
|
1090
|
+
var matchedSlash = true;
|
|
1091
|
+
for (var i = path.length - 1;i >= 1; --i) {
|
|
1092
|
+
code = path.charCodeAt(i);
|
|
1093
|
+
if (code === 47) {
|
|
1094
|
+
if (!matchedSlash) {
|
|
1095
|
+
end = i;
|
|
1096
|
+
break;
|
|
1097
|
+
}
|
|
1098
|
+
} else {
|
|
1099
|
+
matchedSlash = false;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (end === -1)
|
|
1103
|
+
return hasRoot ? "/" : ".";
|
|
1104
|
+
if (hasRoot && end === 1)
|
|
1105
|
+
return "//";
|
|
1106
|
+
return path.slice(0, end);
|
|
1107
|
+
},
|
|
1108
|
+
basename: function basename(path, ext) {
|
|
1109
|
+
if (ext !== undefined && typeof ext !== "string")
|
|
1110
|
+
throw new TypeError('"ext" argument must be a string');
|
|
1111
|
+
assertPath(path);
|
|
1112
|
+
var start = 0;
|
|
1113
|
+
var end = -1;
|
|
1114
|
+
var matchedSlash = true;
|
|
1115
|
+
var i;
|
|
1116
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
1117
|
+
if (ext.length === path.length && ext === path)
|
|
1118
|
+
return "";
|
|
1119
|
+
var extIdx = ext.length - 1;
|
|
1120
|
+
var firstNonSlashEnd = -1;
|
|
1121
|
+
for (i = path.length - 1;i >= 0; --i) {
|
|
1122
|
+
var code = path.charCodeAt(i);
|
|
1123
|
+
if (code === 47) {
|
|
1124
|
+
if (!matchedSlash) {
|
|
1125
|
+
start = i + 1;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
} else {
|
|
1129
|
+
if (firstNonSlashEnd === -1) {
|
|
1130
|
+
matchedSlash = false;
|
|
1131
|
+
firstNonSlashEnd = i + 1;
|
|
1132
|
+
}
|
|
1133
|
+
if (extIdx >= 0) {
|
|
1134
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
1135
|
+
if (--extIdx === -1) {
|
|
1136
|
+
end = i;
|
|
1137
|
+
}
|
|
1138
|
+
} else {
|
|
1139
|
+
extIdx = -1;
|
|
1140
|
+
end = firstNonSlashEnd;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (start === end)
|
|
1146
|
+
end = firstNonSlashEnd;
|
|
1147
|
+
else if (end === -1)
|
|
1148
|
+
end = path.length;
|
|
1149
|
+
return path.slice(start, end);
|
|
1150
|
+
} else {
|
|
1151
|
+
for (i = path.length - 1;i >= 0; --i) {
|
|
1152
|
+
if (path.charCodeAt(i) === 47) {
|
|
1153
|
+
if (!matchedSlash) {
|
|
1154
|
+
start = i + 1;
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1157
|
+
} else if (end === -1) {
|
|
1158
|
+
matchedSlash = false;
|
|
1159
|
+
end = i + 1;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (end === -1)
|
|
1163
|
+
return "";
|
|
1164
|
+
return path.slice(start, end);
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
extname: function extname(path) {
|
|
1168
|
+
assertPath(path);
|
|
1169
|
+
var startDot = -1;
|
|
1170
|
+
var startPart = 0;
|
|
1171
|
+
var end = -1;
|
|
1172
|
+
var matchedSlash = true;
|
|
1173
|
+
var preDotState = 0;
|
|
1174
|
+
for (var i = path.length - 1;i >= 0; --i) {
|
|
1175
|
+
var code = path.charCodeAt(i);
|
|
1176
|
+
if (code === 47) {
|
|
1177
|
+
if (!matchedSlash) {
|
|
1178
|
+
startPart = i + 1;
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (end === -1) {
|
|
1184
|
+
matchedSlash = false;
|
|
1185
|
+
end = i + 1;
|
|
1186
|
+
}
|
|
1187
|
+
if (code === 46) {
|
|
1188
|
+
if (startDot === -1)
|
|
1189
|
+
startDot = i;
|
|
1190
|
+
else if (preDotState !== 1)
|
|
1191
|
+
preDotState = 1;
|
|
1192
|
+
} else if (startDot !== -1) {
|
|
1193
|
+
preDotState = -1;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
1197
|
+
return "";
|
|
1198
|
+
}
|
|
1199
|
+
return path.slice(startDot, end);
|
|
1200
|
+
},
|
|
1201
|
+
format: function format(pathObject) {
|
|
1202
|
+
if (pathObject === null || typeof pathObject !== "object") {
|
|
1203
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
1204
|
+
}
|
|
1205
|
+
return _format("/", pathObject);
|
|
1206
|
+
},
|
|
1207
|
+
parse: function parse(path) {
|
|
1208
|
+
assertPath(path);
|
|
1209
|
+
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
1210
|
+
if (path.length === 0)
|
|
1211
|
+
return ret;
|
|
1212
|
+
var code = path.charCodeAt(0);
|
|
1213
|
+
var isAbsolute = code === 47;
|
|
1214
|
+
var start;
|
|
1215
|
+
if (isAbsolute) {
|
|
1216
|
+
ret.root = "/";
|
|
1217
|
+
start = 1;
|
|
1218
|
+
} else {
|
|
1219
|
+
start = 0;
|
|
1220
|
+
}
|
|
1221
|
+
var startDot = -1;
|
|
1222
|
+
var startPart = 0;
|
|
1223
|
+
var end = -1;
|
|
1224
|
+
var matchedSlash = true;
|
|
1225
|
+
var i = path.length - 1;
|
|
1226
|
+
var preDotState = 0;
|
|
1227
|
+
for (;i >= start; --i) {
|
|
1228
|
+
code = path.charCodeAt(i);
|
|
1229
|
+
if (code === 47) {
|
|
1230
|
+
if (!matchedSlash) {
|
|
1231
|
+
startPart = i + 1;
|
|
1232
|
+
break;
|
|
1233
|
+
}
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
1236
|
+
if (end === -1) {
|
|
1237
|
+
matchedSlash = false;
|
|
1238
|
+
end = i + 1;
|
|
1239
|
+
}
|
|
1240
|
+
if (code === 46) {
|
|
1241
|
+
if (startDot === -1)
|
|
1242
|
+
startDot = i;
|
|
1243
|
+
else if (preDotState !== 1)
|
|
1244
|
+
preDotState = 1;
|
|
1245
|
+
} else if (startDot !== -1) {
|
|
1246
|
+
preDotState = -1;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
1250
|
+
if (end !== -1) {
|
|
1251
|
+
if (startPart === 0 && isAbsolute)
|
|
1252
|
+
ret.base = ret.name = path.slice(1, end);
|
|
1253
|
+
else
|
|
1254
|
+
ret.base = ret.name = path.slice(startPart, end);
|
|
1255
|
+
}
|
|
1256
|
+
} else {
|
|
1257
|
+
if (startPart === 0 && isAbsolute) {
|
|
1258
|
+
ret.name = path.slice(1, startDot);
|
|
1259
|
+
ret.base = path.slice(1, end);
|
|
1260
|
+
} else {
|
|
1261
|
+
ret.name = path.slice(startPart, startDot);
|
|
1262
|
+
ret.base = path.slice(startPart, end);
|
|
1263
|
+
}
|
|
1264
|
+
ret.ext = path.slice(startDot, end);
|
|
1265
|
+
}
|
|
1266
|
+
if (startPart > 0)
|
|
1267
|
+
ret.dir = path.slice(0, startPart - 1);
|
|
1268
|
+
else if (isAbsolute)
|
|
1269
|
+
ret.dir = "/";
|
|
1270
|
+
return ret;
|
|
1271
|
+
},
|
|
1272
|
+
sep: "/",
|
|
1273
|
+
delimiter: ":",
|
|
1274
|
+
win32: null,
|
|
1275
|
+
posix: null
|
|
1276
|
+
};
|
|
1277
|
+
posix.posix = posix;
|
|
1278
|
+
module3.exports = posix;
|
|
1279
|
+
}).call(this);
|
|
1280
|
+
}).call(this, require2("_process"));
|
|
1281
|
+
}, { _process: 5 }], 5: [function(require2, module3, exports3) {
|
|
1282
|
+
var process2 = module3.exports = {};
|
|
1283
|
+
var cachedSetTimeout;
|
|
1284
|
+
var cachedClearTimeout;
|
|
1285
|
+
function defaultSetTimout() {
|
|
1286
|
+
throw new Error("setTimeout has not been defined");
|
|
1287
|
+
}
|
|
1288
|
+
function defaultClearTimeout() {
|
|
1289
|
+
throw new Error("clearTimeout has not been defined");
|
|
1290
|
+
}
|
|
1291
|
+
(function() {
|
|
1292
|
+
try {
|
|
1293
|
+
if (typeof setTimeout === "function") {
|
|
1294
|
+
cachedSetTimeout = setTimeout;
|
|
1295
|
+
} else {
|
|
1296
|
+
cachedSetTimeout = defaultSetTimout;
|
|
1297
|
+
}
|
|
1298
|
+
} catch (e) {
|
|
1299
|
+
cachedSetTimeout = defaultSetTimout;
|
|
1300
|
+
}
|
|
1301
|
+
try {
|
|
1302
|
+
if (typeof clearTimeout === "function") {
|
|
1303
|
+
cachedClearTimeout = clearTimeout;
|
|
1304
|
+
} else {
|
|
1305
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
1306
|
+
}
|
|
1307
|
+
} catch (e) {
|
|
1308
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
1309
|
+
}
|
|
1310
|
+
})();
|
|
1311
|
+
function runTimeout(fun) {
|
|
1312
|
+
if (cachedSetTimeout === setTimeout) {
|
|
1313
|
+
return setTimeout(fun, 0);
|
|
1314
|
+
}
|
|
1315
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
1316
|
+
cachedSetTimeout = setTimeout;
|
|
1317
|
+
return setTimeout(fun, 0);
|
|
1318
|
+
}
|
|
1319
|
+
try {
|
|
1320
|
+
return cachedSetTimeout(fun, 0);
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
try {
|
|
1323
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
1324
|
+
} catch (e2) {
|
|
1325
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
function runClearTimeout(marker) {
|
|
1330
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
1331
|
+
return clearTimeout(marker);
|
|
1332
|
+
}
|
|
1333
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
1334
|
+
cachedClearTimeout = clearTimeout;
|
|
1335
|
+
return clearTimeout(marker);
|
|
1336
|
+
}
|
|
1337
|
+
try {
|
|
1338
|
+
return cachedClearTimeout(marker);
|
|
1339
|
+
} catch (e) {
|
|
1340
|
+
try {
|
|
1341
|
+
return cachedClearTimeout.call(null, marker);
|
|
1342
|
+
} catch (e2) {
|
|
1343
|
+
return cachedClearTimeout.call(this, marker);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
var queue = [];
|
|
1348
|
+
var draining = false;
|
|
1349
|
+
var currentQueue;
|
|
1350
|
+
var queueIndex = -1;
|
|
1351
|
+
function cleanUpNextTick() {
|
|
1352
|
+
if (!draining || !currentQueue) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
draining = false;
|
|
1356
|
+
if (currentQueue.length) {
|
|
1357
|
+
queue = currentQueue.concat(queue);
|
|
1358
|
+
} else {
|
|
1359
|
+
queueIndex = -1;
|
|
1360
|
+
}
|
|
1361
|
+
if (queue.length) {
|
|
1362
|
+
drainQueue();
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function drainQueue() {
|
|
1366
|
+
if (draining) {
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
1370
|
+
draining = true;
|
|
1371
|
+
var len = queue.length;
|
|
1372
|
+
while (len) {
|
|
1373
|
+
currentQueue = queue;
|
|
1374
|
+
queue = [];
|
|
1375
|
+
while (++queueIndex < len) {
|
|
1376
|
+
if (currentQueue) {
|
|
1377
|
+
currentQueue[queueIndex].run();
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
queueIndex = -1;
|
|
1381
|
+
len = queue.length;
|
|
1382
|
+
}
|
|
1383
|
+
currentQueue = null;
|
|
1384
|
+
draining = false;
|
|
1385
|
+
runClearTimeout(timeout);
|
|
1386
|
+
}
|
|
1387
|
+
process2.nextTick = function(fun) {
|
|
1388
|
+
var args = new Array(arguments.length - 1);
|
|
1389
|
+
if (arguments.length > 1) {
|
|
1390
|
+
for (var i = 1;i < arguments.length; i++) {
|
|
1391
|
+
args[i - 1] = arguments[i];
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
queue.push(new Item(fun, args));
|
|
1395
|
+
if (queue.length === 1 && !draining) {
|
|
1396
|
+
runTimeout(drainQueue);
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
function Item(fun, array) {
|
|
1400
|
+
this.fun = fun;
|
|
1401
|
+
this.array = array;
|
|
1402
|
+
}
|
|
1403
|
+
Item.prototype.run = function() {
|
|
1404
|
+
this.fun.apply(null, this.array);
|
|
1405
|
+
};
|
|
1406
|
+
process2.title = "browser";
|
|
1407
|
+
process2.browser = true;
|
|
1408
|
+
process2.env = {};
|
|
1409
|
+
process2.argv = [];
|
|
1410
|
+
process2.version = "";
|
|
1411
|
+
process2.versions = {};
|
|
1412
|
+
function noop() {}
|
|
1413
|
+
process2.on = noop;
|
|
1414
|
+
process2.addListener = noop;
|
|
1415
|
+
process2.once = noop;
|
|
1416
|
+
process2.off = noop;
|
|
1417
|
+
process2.removeListener = noop;
|
|
1418
|
+
process2.removeAllListeners = noop;
|
|
1419
|
+
process2.emit = noop;
|
|
1420
|
+
process2.prependListener = noop;
|
|
1421
|
+
process2.prependOnceListener = noop;
|
|
1422
|
+
process2.listeners = function(name) {
|
|
1423
|
+
return [];
|
|
1424
|
+
};
|
|
1425
|
+
process2.binding = function(name) {
|
|
1426
|
+
throw new Error("process.binding is not supported");
|
|
1427
|
+
};
|
|
1428
|
+
process2.cwd = function() {
|
|
1429
|
+
return "/";
|
|
1430
|
+
};
|
|
1431
|
+
process2.chdir = function(dir) {
|
|
1432
|
+
throw new Error("process.chdir is not supported");
|
|
1433
|
+
};
|
|
1434
|
+
process2.umask = function() {
|
|
1435
|
+
return 0;
|
|
1436
|
+
};
|
|
1437
|
+
}, {}] }, {}, [1])(1);
|
|
1438
|
+
});
|
|
1439
|
+
});
|
|
1440
|
+
|
|
117
1441
|
// node_modules/eventemitter3/index.js
|
|
118
1442
|
var require_eventemitter3 = __commonJS((exports, module) => {
|
|
119
1443
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -295,717 +1619,8 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
295
1619
|
// src/server.ts
|
|
296
1620
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
297
1621
|
|
|
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
|
-
|
|
1008
1622
|
// src/httpHandler.ts
|
|
1623
|
+
var import_ejs = __toESM(require_ejs(), 1);
|
|
1009
1624
|
import { readFile, readdir } from "fs/promises";
|
|
1010
1625
|
|
|
1011
1626
|
// src/utils/cors.ts
|
|
@@ -1131,7 +1746,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
|
|
|
1131
1746
|
};
|
|
1132
1747
|
});
|
|
1133
1748
|
const templatePath = requestPath === "/" ? "" : requestPath;
|
|
1134
|
-
const rnd =
|
|
1749
|
+
const rnd = import_ejs.default.render(finalConfig.serveOutputEjs, {
|
|
1135
1750
|
dirs,
|
|
1136
1751
|
files,
|
|
1137
1752
|
requestPath: templatePath
|
|
@@ -1147,7 +1762,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
|
|
|
1147
1762
|
import { resolve } from "path";
|
|
1148
1763
|
|
|
1149
1764
|
// src/static/serveOutputStyles.css
|
|
1150
|
-
var serveOutputStyles_default =
|
|
1765
|
+
var serveOutputStyles_default = "./assets/serveOutputStyles.css";
|
|
1151
1766
|
|
|
1152
1767
|
// src/static/file.svg
|
|
1153
1768
|
var file_default = "./assets/file.svg";
|
|
@@ -1176,6 +1791,7 @@ var staticAssetRoutes = {
|
|
|
1176
1791
|
import { watch } from "fs/promises";
|
|
1177
1792
|
|
|
1178
1793
|
// src/buildManager.ts
|
|
1794
|
+
var import_ejs2 = __toESM(require_ejs(), 1);
|
|
1179
1795
|
var {build } = globalThis.Bun;
|
|
1180
1796
|
|
|
1181
1797
|
// node_modules/eventemitter3/index.mjs
|
|
@@ -1911,7 +2527,7 @@ function publishIndexHTML(paths, template, output, _event) {
|
|
|
1911
2527
|
const hashedCss = `${cssUrl.href.replace(`${basePathUrl.href}/`, "./")}?${cssFile.hash}`;
|
|
1912
2528
|
cssFiles.push(hashedCss);
|
|
1913
2529
|
}
|
|
1914
|
-
Bun.write(paths.buildDestination + "/index.html",
|
|
2530
|
+
Bun.write(paths.buildDestination + "/index.html", import_ejs2.default.render(template, { hashedImports, cssFiles }));
|
|
1915
2531
|
}
|
|
1916
2532
|
function printPrettyBuildOutput(outTable) {
|
|
1917
2533
|
if (outTable.length === 0)
|
|
@@ -2048,8 +2664,8 @@ var DEFAULT_HMR_PATH = "/hmr-ws";
|
|
|
2048
2664
|
function bunHotReload(bunServerConfig) {
|
|
2049
2665
|
const socketPath = bunServerConfig.websocketPath || DEFAULT_HMR_PATH;
|
|
2050
2666
|
const endPath = socketPath.startsWith("/") ? socketPath : `/${socketPath}`;
|
|
2051
|
-
const
|
|
2052
|
-
return hotReload.toString().replace("[REPLACE_ENDPOINT]",
|
|
2667
|
+
const path = `${bunServerConfig.secure ? "wss" : "ws"}://localhost:${bunServerConfig.port}${endPath}`;
|
|
2668
|
+
return hotReload.toString().replace("[REPLACE_ENDPOINT]", path);
|
|
2053
2669
|
}
|
|
2054
2670
|
|
|
2055
2671
|
// src/bunHmrPlugin.ts
|
|
@@ -2236,3 +2852,6 @@ export {
|
|
|
2236
2852
|
getBunHMRFooter,
|
|
2237
2853
|
bunHotReloadPlugin
|
|
2238
2854
|
};
|
|
2855
|
+
|
|
2856
|
+
//# debugId=CBC8475BE6C83F4364756E2164756E21
|
|
2857
|
+
//# sourceMappingURL=index.js.map
|