bun-dev-server 1.0.2 → 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/index.js +1395 -706
- package/dist/index.js.map +29 -0
- package/package.json +9 -5
package/dist/index.js
CHANGED
|
@@ -4,18 +4,33 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __require = import.meta.require;
|
|
19
34
|
|
|
20
35
|
// node_modules/picocolors/picocolors.js
|
|
21
36
|
var require_picocolors = __commonJS((exports, module) => {
|
|
@@ -87,523 +102,390 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
87
102
|
module.exports.createColors = createColors;
|
|
88
103
|
});
|
|
89
104
|
|
|
90
|
-
// node_modules/ejs/
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
exports.escapeRegExpChars = function(string) {
|
|
98
|
-
if (!string) {
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
return String(string).replace(regExpChars, "\\$&");
|
|
102
|
-
};
|
|
103
|
-
var _ENCODE_HTML_RULES = {
|
|
104
|
-
"&": "&",
|
|
105
|
-
"<": "<",
|
|
106
|
-
">": ">",
|
|
107
|
-
'"': """,
|
|
108
|
-
"'": "'"
|
|
109
|
-
};
|
|
110
|
-
var _MATCH_HTML = /[&<>'"]/g;
|
|
111
|
-
function encode_char(c) {
|
|
112
|
-
return _ENCODE_HTML_RULES[c] || c;
|
|
113
|
-
}
|
|
114
|
-
var escapeFuncStr = `var _ENCODE_HTML_RULES = {
|
|
115
|
-
` + ` "&": "&"
|
|
116
|
-
` + ` , "<": "<"
|
|
117
|
-
` + ` , ">": ">"
|
|
118
|
-
` + ` , '"': """
|
|
119
|
-
` + ` , "'": "'"
|
|
120
|
-
` + ` }
|
|
121
|
-
` + ` , _MATCH_HTML = /[&<>'"]/g;
|
|
122
|
-
` + `function encode_char(c) {
|
|
123
|
-
` + ` return _ENCODE_HTML_RULES[c] || c;
|
|
124
|
-
` + `};
|
|
125
|
-
`;
|
|
126
|
-
exports.escapeXML = function(markup) {
|
|
127
|
-
return markup == undefined ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
128
|
-
};
|
|
129
|
-
function escapeXMLToString() {
|
|
130
|
-
return Function.prototype.toString.call(this) + `;
|
|
131
|
-
` + escapeFuncStr;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
if (typeof Object.defineProperty === "function") {
|
|
135
|
-
Object.defineProperty(exports.escapeXML, "toString", { value: escapeXMLToString });
|
|
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);
|
|
136
112
|
} else {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (!hasOwn(from, p)) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (p === "__proto__" || p === "constructor") {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
to[p] = from[p];
|
|
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;
|
|
153
122
|
}
|
|
123
|
+
g.ejs = f();
|
|
154
124
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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);
|
|
169
145
|
}
|
|
170
|
-
|
|
146
|
+
return n[i2].exports;
|
|
171
147
|
}
|
|
148
|
+
for (var u = __require, i = 0;i < t.length; i++)
|
|
149
|
+
o(t[i]);
|
|
150
|
+
return o;
|
|
172
151
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
_data: {},
|
|
178
|
-
set: function(key, val) {
|
|
179
|
-
this._data[key] = val;
|
|
180
|
-
},
|
|
181
|
-
get: function(key) {
|
|
182
|
-
return this._data[key];
|
|
183
|
-
},
|
|
184
|
-
remove: function(key) {
|
|
185
|
-
delete this._data[key];
|
|
186
|
-
},
|
|
187
|
-
reset: function() {
|
|
188
|
-
this._data = {};
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
exports.hyphenToCamel = function(str) {
|
|
192
|
-
return str.replace(/-[a-z]/g, function(match) {
|
|
193
|
-
return match[1].toUpperCase();
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
exports.createNullProtoObjWherePossible = function() {
|
|
197
|
-
if (typeof Object.create == "function") {
|
|
198
|
-
return function() {
|
|
199
|
-
return Object.create(null);
|
|
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 };
|
|
200
156
|
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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;
|
|
205
197
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
for (var p in obj) {
|
|
214
|
-
if (hasOwn(obj, p)) {
|
|
215
|
-
o[p] = obj[p];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return o;
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// node_modules/ejs/package.json
|
|
223
|
-
var require_package = __commonJS((exports, module) => {
|
|
224
|
-
module.exports = {
|
|
225
|
-
name: "ejs",
|
|
226
|
-
description: "Embedded JavaScript templates",
|
|
227
|
-
keywords: [
|
|
228
|
-
"template",
|
|
229
|
-
"engine",
|
|
230
|
-
"ejs"
|
|
231
|
-
],
|
|
232
|
-
version: "3.1.10",
|
|
233
|
-
author: "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
|
234
|
-
license: "Apache-2.0",
|
|
235
|
-
bin: {
|
|
236
|
-
ejs: "./bin/cli.js"
|
|
237
|
-
},
|
|
238
|
-
main: "./lib/ejs.js",
|
|
239
|
-
jsdelivr: "ejs.min.js",
|
|
240
|
-
unpkg: "ejs.min.js",
|
|
241
|
-
repository: {
|
|
242
|
-
type: "git",
|
|
243
|
-
url: "git://github.com/mde/ejs.git"
|
|
244
|
-
},
|
|
245
|
-
bugs: "https://github.com/mde/ejs/issues",
|
|
246
|
-
homepage: "https://github.com/mde/ejs",
|
|
247
|
-
dependencies: {
|
|
248
|
-
jake: "^10.8.5"
|
|
249
|
-
},
|
|
250
|
-
devDependencies: {
|
|
251
|
-
browserify: "^16.5.1",
|
|
252
|
-
eslint: "^6.8.0",
|
|
253
|
-
"git-directory-deploy": "^1.5.1",
|
|
254
|
-
jsdoc: "^4.0.2",
|
|
255
|
-
"lru-cache": "^4.0.1",
|
|
256
|
-
mocha: "^10.2.0",
|
|
257
|
-
"uglify-js": "^3.3.16"
|
|
258
|
-
},
|
|
259
|
-
engines: {
|
|
260
|
-
node: ">=0.10.0"
|
|
261
|
-
},
|
|
262
|
-
scripts: {
|
|
263
|
-
test: "npx jake test"
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
// node_modules/ejs/lib/ejs.js
|
|
269
|
-
var require_ejs = __commonJS((exports) => {
|
|
270
|
-
var fs = import.meta.require("fs");
|
|
271
|
-
var path = import.meta.require("path");
|
|
272
|
-
var utils = require_utils();
|
|
273
|
-
var scopeOptionWarned = false;
|
|
274
|
-
var _VERSION_STRING = require_package().version;
|
|
275
|
-
var _DEFAULT_OPEN_DELIMITER = "<";
|
|
276
|
-
var _DEFAULT_CLOSE_DELIMITER = ">";
|
|
277
|
-
var _DEFAULT_DELIMITER = "%";
|
|
278
|
-
var _DEFAULT_LOCALS_NAME = "locals";
|
|
279
|
-
var _NAME = "ejs";
|
|
280
|
-
var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
281
|
-
var _OPTS_PASSABLE_WITH_DATA = [
|
|
282
|
-
"delimiter",
|
|
283
|
-
"scope",
|
|
284
|
-
"context",
|
|
285
|
-
"debug",
|
|
286
|
-
"compileDebug",
|
|
287
|
-
"client",
|
|
288
|
-
"_with",
|
|
289
|
-
"rmWhitespace",
|
|
290
|
-
"strict",
|
|
291
|
-
"filename",
|
|
292
|
-
"async"
|
|
293
|
-
];
|
|
294
|
-
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
295
|
-
var _BOM = /^\uFEFF/;
|
|
296
|
-
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
297
|
-
exports.cache = utils.cache;
|
|
298
|
-
exports.fileLoader = fs.readFileSync;
|
|
299
|
-
exports.localsName = _DEFAULT_LOCALS_NAME;
|
|
300
|
-
exports.promiseImpl = new Function("return this;")().Promise;
|
|
301
|
-
exports.resolveInclude = function(name, filename, isDir) {
|
|
302
|
-
var dirname = path.dirname;
|
|
303
|
-
var extname = path.extname;
|
|
304
|
-
var resolve = path.resolve;
|
|
305
|
-
var includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
306
|
-
var ext = extname(name);
|
|
307
|
-
if (!ext) {
|
|
308
|
-
includePath += ".ejs";
|
|
309
|
-
}
|
|
310
|
-
return includePath;
|
|
311
|
-
};
|
|
312
|
-
function resolvePaths(name, paths) {
|
|
313
|
-
var filePath;
|
|
314
|
-
if (paths.some(function(v) {
|
|
315
|
-
filePath = exports.resolveInclude(name, v, true);
|
|
316
|
-
return fs.existsSync(filePath);
|
|
317
|
-
})) {
|
|
318
|
-
return filePath;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
function getIncludePath(path2, options) {
|
|
322
|
-
var includePath;
|
|
323
|
-
var filePath;
|
|
324
|
-
var views = options.views;
|
|
325
|
-
var match = /^[A-Za-z]+:\\|^\//.exec(path2);
|
|
326
|
-
if (match && match.length) {
|
|
327
|
-
path2 = path2.replace(/^\/*/, "");
|
|
328
|
-
if (Array.isArray(options.root)) {
|
|
329
|
-
includePath = resolvePaths(path2, options.root);
|
|
330
|
-
} else {
|
|
331
|
-
includePath = exports.resolveInclude(path2, options.root || "/", true);
|
|
332
|
-
}
|
|
333
|
-
} else {
|
|
334
|
-
if (options.filename) {
|
|
335
|
-
filePath = exports.resolveInclude(path2, options.filename);
|
|
336
|
-
if (fs.existsSync(filePath)) {
|
|
337
|
-
includePath = filePath;
|
|
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;
|
|
338
205
|
}
|
|
339
206
|
}
|
|
340
|
-
|
|
341
|
-
includePath
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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;
|
|
356
234
|
}
|
|
357
|
-
|
|
358
|
-
|
|
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
|
+
}
|
|
359
260
|
return func;
|
|
360
261
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
var result;
|
|
378
|
-
if (!cb) {
|
|
379
|
-
if (typeof exports.promiseImpl == "function") {
|
|
380
|
-
return new exports.promiseImpl(function(resolve, reject) {
|
|
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 {
|
|
381
278
|
try {
|
|
382
279
|
result = handleCache(options)(data);
|
|
383
|
-
resolve(result);
|
|
384
280
|
} catch (err) {
|
|
385
|
-
|
|
281
|
+
return cb(err);
|
|
386
282
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
throw new Error("Please provide a callback function");
|
|
283
|
+
cb(null, result);
|
|
284
|
+
}
|
|
390
285
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
result = handleCache(options)(data);
|
|
394
|
-
} catch (err) {
|
|
395
|
-
return cb(err);
|
|
286
|
+
function fileLoader(filePath) {
|
|
287
|
+
return ejs.fileLoader(filePath);
|
|
396
288
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
opts.filename = includerResult.filename;
|
|
411
|
-
}
|
|
412
|
-
if (includerResult.template) {
|
|
413
|
-
return handleCache(opts, includerResult.template);
|
|
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
|
+
}
|
|
414
302
|
}
|
|
303
|
+
return handleCache(opts);
|
|
415
304
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
function rethrow(err, str, flnm, lineno, esc) {
|
|
420
|
-
var lines = str.split(`
|
|
305
|
+
function rethrow(err, str, flnm, lineno, esc) {
|
|
306
|
+
var lines = str.split(`
|
|
421
307
|
`);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
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(`
|
|
429
315
|
`);
|
|
430
|
-
|
|
431
|
-
|
|
316
|
+
err.path = filename;
|
|
317
|
+
err.message = (filename || "ejs") + ":" + lineno + `
|
|
432
318
|
` + context + `
|
|
433
319
|
|
|
434
320
|
` + err.message;
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
function stripSemi(str) {
|
|
438
|
-
return str.replace(/;(\s*$)/, "$1");
|
|
439
|
-
}
|
|
440
|
-
exports.compile = function compile(template, opts) {
|
|
441
|
-
var templ;
|
|
442
|
-
if (opts && opts.scope) {
|
|
443
|
-
if (!scopeOptionWarned) {
|
|
444
|
-
console.warn("`scope` option is deprecated and will be removed in EJS 3");
|
|
445
|
-
scopeOptionWarned = true;
|
|
321
|
+
throw err;
|
|
446
322
|
}
|
|
447
|
-
|
|
448
|
-
|
|
323
|
+
function stripSemi(str) {
|
|
324
|
+
return str.replace(/;(\s*$)/, "$1");
|
|
449
325
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
var data = d || utils.createNullProtoObjWherePossible();
|
|
457
|
-
var opts = o || utils.createNullProtoObjWherePossible();
|
|
458
|
-
if (arguments.length == 2) {
|
|
459
|
-
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
460
|
-
}
|
|
461
|
-
return handleCache(opts, template)(data);
|
|
462
|
-
};
|
|
463
|
-
exports.renderFile = function() {
|
|
464
|
-
var args = Array.prototype.slice.call(arguments);
|
|
465
|
-
var filename = args.shift();
|
|
466
|
-
var cb;
|
|
467
|
-
var opts = { filename };
|
|
468
|
-
var data;
|
|
469
|
-
var viewOpts;
|
|
470
|
-
if (typeof arguments[arguments.length - 1] == "function") {
|
|
471
|
-
cb = args.pop();
|
|
472
|
-
}
|
|
473
|
-
if (args.length) {
|
|
474
|
-
data = args.shift();
|
|
475
|
-
if (args.length) {
|
|
476
|
-
utils.shallowCopy(opts, args.pop());
|
|
477
|
-
} else {
|
|
478
|
-
if (data.settings) {
|
|
479
|
-
if (data.settings.views) {
|
|
480
|
-
opts.views = data.settings.views;
|
|
481
|
-
}
|
|
482
|
-
if (data.settings["view cache"]) {
|
|
483
|
-
opts.cache = true;
|
|
484
|
-
}
|
|
485
|
-
viewOpts = data.settings["view options"];
|
|
486
|
-
if (viewOpts) {
|
|
487
|
-
utils.shallowCopy(opts, viewOpts);
|
|
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;
|
|
488
332
|
}
|
|
333
|
+
delete opts.scope;
|
|
489
334
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
530
|
-
if (options.strict) {
|
|
531
|
-
options._with = false;
|
|
532
|
-
} else {
|
|
533
|
-
options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
534
|
-
}
|
|
535
|
-
this.opts = options;
|
|
536
|
-
this.regex = this.createRegex();
|
|
537
|
-
}
|
|
538
|
-
Template.modes = {
|
|
539
|
-
EVAL: "eval",
|
|
540
|
-
ESCAPED: "escaped",
|
|
541
|
-
RAW: "raw",
|
|
542
|
-
COMMENT: "comment",
|
|
543
|
-
LITERAL: "literal"
|
|
544
|
-
};
|
|
545
|
-
Template.prototype = {
|
|
546
|
-
createRegex: function() {
|
|
547
|
-
var str = _REGEX_STRING;
|
|
548
|
-
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
549
|
-
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
550
|
-
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
551
|
-
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
552
|
-
return new RegExp(str);
|
|
553
|
-
},
|
|
554
|
-
compile: function() {
|
|
555
|
-
var src;
|
|
556
|
-
var fn;
|
|
557
|
-
var opts = this.opts;
|
|
558
|
-
var prepended = "";
|
|
559
|
-
var appended = "";
|
|
560
|
-
var escapeFn = opts.escapeFunction;
|
|
561
|
-
var ctor;
|
|
562
|
-
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
563
|
-
if (!this.source) {
|
|
564
|
-
this.generateSource();
|
|
565
|
-
prepended += ` var __output = "";
|
|
566
|
-
` + ` function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
567
|
-
`;
|
|
568
|
-
if (opts.outputFunctionName) {
|
|
569
|
-
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
|
|
570
|
-
throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
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);
|
|
571
374
|
}
|
|
572
|
-
|
|
573
|
-
|
|
375
|
+
opts.filename = filename;
|
|
376
|
+
} else {
|
|
377
|
+
data = utils_js_1.default.createNullProtoObjWherePossible();
|
|
574
378
|
}
|
|
575
|
-
|
|
576
|
-
|
|
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;
|
|
577
416
|
}
|
|
578
|
-
|
|
579
|
-
|
|
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;" + `
|
|
580
455
|
`;
|
|
581
|
-
for (var i = 0;i < opts.destructuredLocals.length; i++) {
|
|
582
|
-
var name = opts.destructuredLocals[i];
|
|
583
|
-
if (!_JS_IDENTIFIER.test(name)) {
|
|
584
|
-
throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
585
456
|
}
|
|
586
|
-
if (
|
|
587
|
-
|
|
588
|
-
`;
|
|
457
|
+
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
|
|
458
|
+
throw new Error("localsName is not a valid JS identifier.");
|
|
589
459
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
prepended += destructuring + `;
|
|
460
|
+
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
461
|
+
var destructuring = " ".concat(DECLARATION_KEYWORD, " __locals = (") + opts.localsName + ` || {}),
|
|
593
462
|
`;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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 + " || {}) {" + `
|
|
597
479
|
`;
|
|
598
|
-
|
|
480
|
+
appended += " }" + `
|
|
599
481
|
`;
|
|
600
|
-
|
|
601
|
-
|
|
482
|
+
}
|
|
483
|
+
appended += " return __output;" + `
|
|
602
484
|
`;
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
485
|
+
this.source = prepended + this.source + appended;
|
|
486
|
+
}
|
|
487
|
+
if (opts.compileDebug) {
|
|
488
|
+
src = "".concat(DECLARATION_KEYWORD, " __line = 1") + `
|
|
607
489
|
` + " , __lines = " + JSON.stringify(this.templateText) + `
|
|
608
490
|
` + " , __filename = " + sanitizedFilename + ";" + `
|
|
609
491
|
` + "try {" + `
|
|
@@ -611,247 +493,956 @@ var require_ejs = __commonJS((exports) => {
|
|
|
611
493
|
` + " rethrow(e, __lines, __filename, __line, escapeFn);" + `
|
|
612
494
|
` + "}" + `
|
|
613
495
|
`;
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
` + src;
|
|
620
|
-
if (opts.compileDebug) {
|
|
621
|
-
src = "rethrow = rethrow || " + rethrow.toString() + ";" + `
|
|
622
|
-
` + src;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (opts.strict) {
|
|
626
|
-
src = `"use strict";
|
|
496
|
+
} else {
|
|
497
|
+
src = this.source;
|
|
498
|
+
}
|
|
499
|
+
if (opts.strict) {
|
|
500
|
+
src = `"use strict";
|
|
627
501
|
` + src;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
502
|
+
}
|
|
503
|
+
if (opts.debug) {
|
|
504
|
+
console.log(src);
|
|
505
|
+
}
|
|
506
|
+
if (opts.compileDebug && opts.filename) {
|
|
507
|
+
src = src + `
|
|
634
508
|
` + "//# sourceURL=" + sanitizedFilename + `
|
|
635
509
|
`;
|
|
636
|
-
|
|
637
|
-
try {
|
|
638
|
-
if (opts.async) {
|
|
510
|
+
}
|
|
639
511
|
try {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
+
}
|
|
644
522
|
} else {
|
|
645
|
-
|
|
523
|
+
ctor = Function;
|
|
646
524
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (opts.filename) {
|
|
655
|
-
e.message += " in " + opts.filename;
|
|
656
|
-
}
|
|
657
|
-
e.message += ` while compiling ejs
|
|
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
|
|
658
532
|
|
|
659
533
|
`;
|
|
660
|
-
|
|
534
|
+
e.message += `If the above error is not helpful, you may want to try EJS-Lint:
|
|
661
535
|
`;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
536
|
+
e.message += "https://github.com/RyanZim/EJS-Lint";
|
|
537
|
+
if (!opts.async) {
|
|
538
|
+
e.message += `
|
|
665
539
|
`;
|
|
666
|
-
|
|
540
|
+
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
throw e;
|
|
667
544
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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) {}
|
|
676
566
|
}
|
|
677
|
-
return
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
var basename = path.basename(filename, path.extname(filename));
|
|
684
|
-
try {
|
|
685
|
-
Object.defineProperty(returnedFn, "name", {
|
|
686
|
-
value: basename,
|
|
687
|
-
writable: false,
|
|
688
|
-
enumerable: false,
|
|
689
|
-
configurable: true
|
|
690
|
-
});
|
|
691
|
-
} catch (e) {
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return returnedFn;
|
|
695
|
-
},
|
|
696
|
-
generateSource: function() {
|
|
697
|
-
var opts = this.opts;
|
|
698
|
-
if (opts.rmWhitespace) {
|
|
699
|
-
this.templateText = this.templateText.replace(/[\r\n]+/g, `
|
|
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, `
|
|
700
573
|
`).replace(/^\s+|\s+$/gm, "");
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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);
|
|
715
609
|
}
|
|
610
|
+
arr.push(result[0]);
|
|
611
|
+
str = str.slice(result[0].length);
|
|
612
|
+
result = pat.exec(str);
|
|
716
613
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
result = pat.exec(str);
|
|
736
|
-
}
|
|
737
|
-
if (str) {
|
|
738
|
-
arr.push(str);
|
|
739
|
-
}
|
|
740
|
-
return arr;
|
|
741
|
-
},
|
|
742
|
-
_addOutput: function(line) {
|
|
743
|
-
if (this.truncate) {
|
|
744
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
745
|
-
this.truncate = false;
|
|
746
|
-
}
|
|
747
|
-
if (!line) {
|
|
748
|
-
return line;
|
|
749
|
-
}
|
|
750
|
-
line = line.replace(/\\/g, "\\\\");
|
|
751
|
-
line = line.replace(/\n/g, "\\n");
|
|
752
|
-
line = line.replace(/\r/g, "\\r");
|
|
753
|
-
line = line.replace(/"/g, "\\\"");
|
|
754
|
-
this.source += ' ; __append("' + line + '")' + `
|
|
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 + '")' + `
|
|
755
632
|
`;
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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(`
|
|
764
641
|
`).length - 1;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
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) + '")' + `
|
|
782
659
|
`;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
660
|
+
break;
|
|
661
|
+
case d + d + c:
|
|
662
|
+
this.mode = Template.modes.LITERAL;
|
|
663
|
+
this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + `
|
|
787
664
|
`;
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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(`
|
|
805
682
|
`)) {
|
|
806
|
-
|
|
683
|
+
line += `
|
|
807
684
|
`;
|
|
685
|
+
}
|
|
808
686
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
this.source += " ; " + line + `
|
|
687
|
+
switch (this.mode) {
|
|
688
|
+
case Template.modes.EVAL:
|
|
689
|
+
this.source += " ; " + line + `
|
|
813
690
|
`;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
691
|
+
break;
|
|
692
|
+
case Template.modes.ESCAPED:
|
|
693
|
+
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))" + `
|
|
817
694
|
`;
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
695
|
+
break;
|
|
696
|
+
case Template.modes.RAW:
|
|
697
|
+
this.source += " ; __append(" + stripSemi(line) + ")" + `
|
|
821
698
|
`;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
699
|
+
break;
|
|
700
|
+
case Template.modes.COMMENT:
|
|
701
|
+
break;
|
|
702
|
+
case Template.modes.LITERAL:
|
|
703
|
+
this._addOutput(line);
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
} else {
|
|
826
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)
|
|
827
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;
|
|
828
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;
|
|
829
1295
|
} else {
|
|
830
|
-
|
|
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);
|
|
831
1326
|
}
|
|
1327
|
+
}
|
|
832
1328
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
+
}
|
|
837
1346
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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
|
+
});
|
|
847
1439
|
});
|
|
848
1440
|
|
|
849
1441
|
// node_modules/eventemitter3/index.js
|
|
850
1442
|
var require_eventemitter3 = __commonJS((exports, module) => {
|
|
851
1443
|
var has = Object.prototype.hasOwnProperty;
|
|
852
1444
|
var prefix = "~";
|
|
853
|
-
function Events() {
|
|
854
|
-
}
|
|
1445
|
+
function Events() {}
|
|
855
1446
|
if (Object.create) {
|
|
856
1447
|
Events.prototype = Object.create(null);
|
|
857
1448
|
if (!new Events().__proto__)
|
|
@@ -1155,7 +1746,7 @@ async function handleDirectoryRequest(fsPath, requestPath, req, finalConfig) {
|
|
|
1155
1746
|
};
|
|
1156
1747
|
});
|
|
1157
1748
|
const templatePath = requestPath === "/" ? "" : requestPath;
|
|
1158
|
-
const rnd = import_ejs.render(finalConfig.serveOutputEjs, {
|
|
1749
|
+
const rnd = import_ejs.default.render(finalConfig.serveOutputEjs, {
|
|
1159
1750
|
dirs,
|
|
1160
1751
|
files,
|
|
1161
1752
|
requestPath: templatePath
|
|
@@ -1346,6 +1937,9 @@ class PQueue extends import__.default {
|
|
|
1346
1937
|
#lastExecutionTime = 0;
|
|
1347
1938
|
#intervalId;
|
|
1348
1939
|
#timeoutId;
|
|
1940
|
+
#strict;
|
|
1941
|
+
#strictTicks = [];
|
|
1942
|
+
#strictTicksStartIndex = 0;
|
|
1349
1943
|
#queue;
|
|
1350
1944
|
#queueClass;
|
|
1351
1945
|
#pending = 0;
|
|
@@ -1363,6 +1957,7 @@ class PQueue extends import__.default {
|
|
|
1363
1957
|
concurrency: Number.POSITIVE_INFINITY,
|
|
1364
1958
|
autoStart: true,
|
|
1365
1959
|
queueClass: PriorityQueue,
|
|
1960
|
+
strict: false,
|
|
1366
1961
|
...options
|
|
1367
1962
|
};
|
|
1368
1963
|
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
|
|
@@ -1371,10 +1966,17 @@ class PQueue extends import__.default {
|
|
|
1371
1966
|
if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {
|
|
1372
1967
|
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
|
|
1373
1968
|
}
|
|
1969
|
+
if (options.strict && options.interval === 0) {
|
|
1970
|
+
throw new TypeError("The `strict` option requires a non-zero `interval`");
|
|
1971
|
+
}
|
|
1972
|
+
if (options.strict && options.intervalCap === Number.POSITIVE_INFINITY) {
|
|
1973
|
+
throw new TypeError("The `strict` option requires a finite `intervalCap`");
|
|
1974
|
+
}
|
|
1374
1975
|
this.#carryoverIntervalCount = options.carryoverIntervalCount ?? options.carryoverConcurrencyCount ?? false;
|
|
1375
1976
|
this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
|
|
1376
1977
|
this.#intervalCap = options.intervalCap;
|
|
1377
1978
|
this.#interval = options.interval;
|
|
1979
|
+
this.#strict = options.strict;
|
|
1378
1980
|
this.#queue = new options.queueClass;
|
|
1379
1981
|
this.#queueClass = options.queueClass;
|
|
1380
1982
|
this.concurrency = options.concurrency;
|
|
@@ -1385,8 +1987,48 @@ class PQueue extends import__.default {
|
|
|
1385
1987
|
this.#isPaused = options.autoStart === false;
|
|
1386
1988
|
this.#setupRateLimitTracking();
|
|
1387
1989
|
}
|
|
1990
|
+
#cleanupStrictTicks(now) {
|
|
1991
|
+
while (this.#strictTicksStartIndex < this.#strictTicks.length) {
|
|
1992
|
+
const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
|
|
1993
|
+
if (oldestTick !== undefined && now - oldestTick >= this.#interval) {
|
|
1994
|
+
this.#strictTicksStartIndex++;
|
|
1995
|
+
} else {
|
|
1996
|
+
break;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const shouldCompact = this.#strictTicksStartIndex > 100 && this.#strictTicksStartIndex > this.#strictTicks.length / 2 || this.#strictTicksStartIndex === this.#strictTicks.length;
|
|
2000
|
+
if (shouldCompact) {
|
|
2001
|
+
this.#strictTicks = this.#strictTicks.slice(this.#strictTicksStartIndex);
|
|
2002
|
+
this.#strictTicksStartIndex = 0;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
#consumeIntervalSlot(now) {
|
|
2006
|
+
if (this.#strict) {
|
|
2007
|
+
this.#strictTicks.push(now);
|
|
2008
|
+
} else {
|
|
2009
|
+
this.#intervalCount++;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
#rollbackIntervalSlot() {
|
|
2013
|
+
if (this.#strict) {
|
|
2014
|
+
if (this.#strictTicks.length > this.#strictTicksStartIndex) {
|
|
2015
|
+
this.#strictTicks.pop();
|
|
2016
|
+
}
|
|
2017
|
+
} else if (this.#intervalCount > 0) {
|
|
2018
|
+
this.#intervalCount--;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
#getActiveTicksCount() {
|
|
2022
|
+
return this.#strictTicks.length - this.#strictTicksStartIndex;
|
|
2023
|
+
}
|
|
1388
2024
|
get #doesIntervalAllowAnother() {
|
|
1389
|
-
|
|
2025
|
+
if (this.#isIntervalIgnored) {
|
|
2026
|
+
return true;
|
|
2027
|
+
}
|
|
2028
|
+
if (this.#strict) {
|
|
2029
|
+
return this.#getActiveTicksCount() < this.#intervalCap;
|
|
2030
|
+
}
|
|
2031
|
+
return this.#intervalCount < this.#intervalCap;
|
|
1390
2032
|
}
|
|
1391
2033
|
get #doesConcurrentAllowAnother() {
|
|
1392
2034
|
return this.#pending < this.#concurrency;
|
|
@@ -1400,12 +2042,22 @@ class PQueue extends import__.default {
|
|
|
1400
2042
|
this.emit("next");
|
|
1401
2043
|
}
|
|
1402
2044
|
#onResumeInterval() {
|
|
2045
|
+
this.#timeoutId = undefined;
|
|
1403
2046
|
this.#onInterval();
|
|
1404
2047
|
this.#initializeIntervalIfNeeded();
|
|
1405
|
-
this.#timeoutId = undefined;
|
|
1406
2048
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
2049
|
+
#isIntervalPausedAt(now) {
|
|
2050
|
+
if (this.#strict) {
|
|
2051
|
+
this.#cleanupStrictTicks(now);
|
|
2052
|
+
const activeTicksCount = this.#getActiveTicksCount();
|
|
2053
|
+
if (activeTicksCount >= this.#intervalCap) {
|
|
2054
|
+
const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
|
|
2055
|
+
const delay = this.#interval - (now - oldestTick);
|
|
2056
|
+
this.#createIntervalTimeout(delay);
|
|
2057
|
+
return true;
|
|
2058
|
+
}
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
1409
2061
|
if (this.#intervalId === undefined) {
|
|
1410
2062
|
const delay = this.#intervalEnd - now;
|
|
1411
2063
|
if (delay < 0) {
|
|
@@ -1450,21 +2102,25 @@ class PQueue extends import__.default {
|
|
|
1450
2102
|
this.emit("empty");
|
|
1451
2103
|
if (this.#pending === 0) {
|
|
1452
2104
|
this.#clearTimeoutTimer();
|
|
2105
|
+
if (this.#strict && this.#strictTicksStartIndex > 0) {
|
|
2106
|
+
const now = Date.now();
|
|
2107
|
+
this.#cleanupStrictTicks(now);
|
|
2108
|
+
}
|
|
1453
2109
|
this.emit("idle");
|
|
1454
2110
|
}
|
|
1455
2111
|
return false;
|
|
1456
2112
|
}
|
|
1457
2113
|
let taskStarted = false;
|
|
1458
2114
|
if (!this.#isPaused) {
|
|
1459
|
-
const
|
|
2115
|
+
const now = Date.now();
|
|
2116
|
+
const canInitializeInterval = !this.#isIntervalPausedAt(now);
|
|
1460
2117
|
if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
|
|
1461
2118
|
const job = this.#queue.dequeue();
|
|
1462
2119
|
if (!this.#isIntervalIgnored) {
|
|
1463
|
-
this.#
|
|
2120
|
+
this.#consumeIntervalSlot(now);
|
|
1464
2121
|
this.#scheduleRateLimitUpdate();
|
|
1465
2122
|
}
|
|
1466
2123
|
this.emit("active");
|
|
1467
|
-
this.#lastExecutionTime = Date.now();
|
|
1468
2124
|
job();
|
|
1469
2125
|
if (canInitializeInterval) {
|
|
1470
2126
|
this.#initializeIntervalIfNeeded();
|
|
@@ -1478,22 +2134,26 @@ class PQueue extends import__.default {
|
|
|
1478
2134
|
if (this.#isIntervalIgnored || this.#intervalId !== undefined) {
|
|
1479
2135
|
return;
|
|
1480
2136
|
}
|
|
2137
|
+
if (this.#strict) {
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
1481
2140
|
this.#intervalId = setInterval(() => {
|
|
1482
2141
|
this.#onInterval();
|
|
1483
2142
|
}, this.#interval);
|
|
1484
2143
|
this.#intervalEnd = Date.now() + this.#interval;
|
|
1485
2144
|
}
|
|
1486
2145
|
#onInterval() {
|
|
1487
|
-
if (this.#
|
|
1488
|
-
this.#
|
|
2146
|
+
if (!this.#strict) {
|
|
2147
|
+
if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
|
|
2148
|
+
this.#clearIntervalTimer();
|
|
2149
|
+
}
|
|
2150
|
+
this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
|
|
1489
2151
|
}
|
|
1490
|
-
this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
|
|
1491
2152
|
this.#processQueue();
|
|
1492
2153
|
this.#scheduleRateLimitUpdate();
|
|
1493
2154
|
}
|
|
1494
2155
|
#processQueue() {
|
|
1495
|
-
while (this.#tryToStartAnother()) {
|
|
1496
|
-
}
|
|
2156
|
+
while (this.#tryToStartAnother()) {}
|
|
1497
2157
|
}
|
|
1498
2158
|
get concurrency() {
|
|
1499
2159
|
return this.#concurrency;
|
|
@@ -1512,10 +2172,10 @@ class PQueue extends import__.default {
|
|
|
1512
2172
|
this.#queue.setPriority(id, priority);
|
|
1513
2173
|
}
|
|
1514
2174
|
async add(function_, options = {}) {
|
|
1515
|
-
options.id ??= (this.#idAssigner++).toString();
|
|
1516
2175
|
options = {
|
|
1517
2176
|
timeout: this.timeout,
|
|
1518
|
-
...options
|
|
2177
|
+
...options,
|
|
2178
|
+
id: options.id ?? (this.#idAssigner++).toString()
|
|
1519
2179
|
};
|
|
1520
2180
|
return new Promise((resolve2, reject) => {
|
|
1521
2181
|
const taskSymbol = Symbol(`task-${options.id}`);
|
|
@@ -1532,12 +2192,11 @@ class PQueue extends import__.default {
|
|
|
1532
2192
|
try {
|
|
1533
2193
|
options.signal?.throwIfAborted();
|
|
1534
2194
|
} catch (error) {
|
|
1535
|
-
|
|
1536
|
-
this.#intervalCount--;
|
|
1537
|
-
}
|
|
2195
|
+
this.#rollbackIntervalConsumption();
|
|
1538
2196
|
this.#runningTasks.delete(taskSymbol);
|
|
1539
2197
|
throw error;
|
|
1540
2198
|
}
|
|
2199
|
+
this.#lastExecutionTime = Date.now();
|
|
1541
2200
|
let operation = function_({ signal: options.signal });
|
|
1542
2201
|
if (options.timeout) {
|
|
1543
2202
|
operation = pTimeout(Promise.resolve(operation), {
|
|
@@ -1590,7 +2249,14 @@ class PQueue extends import__.default {
|
|
|
1590
2249
|
}
|
|
1591
2250
|
clear() {
|
|
1592
2251
|
this.#queue = new this.#queueClass;
|
|
2252
|
+
this.#clearIntervalTimer();
|
|
1593
2253
|
this.#updateRateLimitState();
|
|
2254
|
+
this.emit("empty");
|
|
2255
|
+
if (this.#pending === 0) {
|
|
2256
|
+
this.#clearTimeoutTimer();
|
|
2257
|
+
this.emit("idle");
|
|
2258
|
+
}
|
|
2259
|
+
this.emit("next");
|
|
1594
2260
|
}
|
|
1595
2261
|
async onEmpty() {
|
|
1596
2262
|
if (this.#queue.size === 0) {
|
|
@@ -1628,7 +2294,7 @@ class PQueue extends import__.default {
|
|
|
1628
2294
|
}
|
|
1629
2295
|
await this.#onEvent("rateLimitCleared");
|
|
1630
2296
|
}
|
|
1631
|
-
|
|
2297
|
+
onError() {
|
|
1632
2298
|
return new Promise((_resolve, reject) => {
|
|
1633
2299
|
const handleError = (error) => {
|
|
1634
2300
|
this.off("error", handleError);
|
|
@@ -1684,9 +2350,31 @@ class PQueue extends import__.default {
|
|
|
1684
2350
|
this.#updateRateLimitState();
|
|
1685
2351
|
});
|
|
1686
2352
|
}
|
|
2353
|
+
#rollbackIntervalConsumption() {
|
|
2354
|
+
if (this.#isIntervalIgnored) {
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
this.#rollbackIntervalSlot();
|
|
2358
|
+
this.#scheduleRateLimitUpdate();
|
|
2359
|
+
}
|
|
1687
2360
|
#updateRateLimitState() {
|
|
1688
2361
|
const previous = this.#rateLimitedInInterval;
|
|
1689
|
-
|
|
2362
|
+
if (this.#isIntervalIgnored || this.#queue.size === 0) {
|
|
2363
|
+
if (previous) {
|
|
2364
|
+
this.#rateLimitedInInterval = false;
|
|
2365
|
+
this.emit("rateLimitCleared");
|
|
2366
|
+
}
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
let count;
|
|
2370
|
+
if (this.#strict) {
|
|
2371
|
+
const now = Date.now();
|
|
2372
|
+
this.#cleanupStrictTicks(now);
|
|
2373
|
+
count = this.#getActiveTicksCount();
|
|
2374
|
+
} else {
|
|
2375
|
+
count = this.#intervalCount;
|
|
2376
|
+
}
|
|
2377
|
+
const shouldBeRateLimited = count >= this.#intervalCap;
|
|
1690
2378
|
if (shouldBeRateLimited !== previous) {
|
|
1691
2379
|
this.#rateLimitedInInterval = shouldBeRateLimited;
|
|
1692
2380
|
this.emit(shouldBeRateLimited ? "rateLimit" : "rateLimitCleared");
|
|
@@ -1839,7 +2527,7 @@ function publishIndexHTML(paths, template, output, _event) {
|
|
|
1839
2527
|
const hashedCss = `${cssUrl.href.replace(`${basePathUrl.href}/`, "./")}?${cssFile.hash}`;
|
|
1840
2528
|
cssFiles.push(hashedCss);
|
|
1841
2529
|
}
|
|
1842
|
-
Bun.write(paths.buildDestination + "/index.html", import_ejs2.render(template, { hashedImports, cssFiles }));
|
|
2530
|
+
Bun.write(paths.buildDestination + "/index.html", import_ejs2.default.render(template, { hashedImports, cssFiles }));
|
|
1843
2531
|
}
|
|
1844
2532
|
function printPrettyBuildOutput(outTable) {
|
|
1845
2533
|
if (outTable.length === 0)
|
|
@@ -1920,8 +2608,7 @@ function hotReload() {
|
|
|
1920
2608
|
let parsed = msg.data;
|
|
1921
2609
|
try {
|
|
1922
2610
|
parsed = JSON.parse(msg.data);
|
|
1923
|
-
} catch (e) {
|
|
1924
|
-
}
|
|
2611
|
+
} catch (e) {}
|
|
1925
2612
|
if (parsed?.type === "message") {
|
|
1926
2613
|
console.log(devServer, parsed.message);
|
|
1927
2614
|
return;
|
|
@@ -2146,8 +2833,7 @@ async function startBunDevServer(serverConfig, importMeta) {
|
|
|
2146
2833
|
open(ws) {
|
|
2147
2834
|
ws.subscribe("message");
|
|
2148
2835
|
},
|
|
2149
|
-
message(ws, message) {
|
|
2150
|
-
},
|
|
2836
|
+
message(ws, message) {},
|
|
2151
2837
|
sendPings: true
|
|
2152
2838
|
}
|
|
2153
2839
|
});
|
|
@@ -2166,3 +2852,6 @@ export {
|
|
|
2166
2852
|
getBunHMRFooter,
|
|
2167
2853
|
bunHotReloadPlugin
|
|
2168
2854
|
};
|
|
2855
|
+
|
|
2856
|
+
//# debugId=CBC8475BE6C83F4364756E2164756E21
|
|
2857
|
+
//# sourceMappingURL=index.js.map
|