@kosatyi/ejs 0.0.49 → 0.0.50
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/cjs/index.js +79 -72
- package/dist/esm/index.js +20 -23
- package/dist/umd/index.js +79 -70
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -4
package/dist/cjs/index.js
CHANGED
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var chokidar = require('chokidar');
|
|
8
7
|
|
|
9
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
9
|
|
|
11
10
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
12
11
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
13
|
-
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
14
12
|
|
|
15
13
|
var defaults = {};
|
|
16
14
|
defaults["export"] = 'ejsPrecompiled';
|
|
@@ -36,6 +34,66 @@ defaults.token = {
|
|
|
36
34
|
regex: '([\\s\\S]+?)'
|
|
37
35
|
};
|
|
38
36
|
|
|
37
|
+
function _typeof(obj) {
|
|
38
|
+
"@babel/helpers - typeof";
|
|
39
|
+
|
|
40
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
41
|
+
return typeof obj;
|
|
42
|
+
} : function (obj) {
|
|
43
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
44
|
+
}, _typeof(obj);
|
|
45
|
+
}
|
|
46
|
+
function _classCallCheck(instance, Constructor) {
|
|
47
|
+
if (!(instance instanceof Constructor)) {
|
|
48
|
+
throw new TypeError("Cannot call a class as a function");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function _defineProperties(target, props) {
|
|
52
|
+
for (var i = 0; i < props.length; i++) {
|
|
53
|
+
var descriptor = props[i];
|
|
54
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
55
|
+
descriptor.configurable = true;
|
|
56
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
57
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
61
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
62
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
63
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
64
|
+
writable: false
|
|
65
|
+
});
|
|
66
|
+
return Constructor;
|
|
67
|
+
}
|
|
68
|
+
function _defineProperty(obj, key, value) {
|
|
69
|
+
key = _toPropertyKey(key);
|
|
70
|
+
if (key in obj) {
|
|
71
|
+
Object.defineProperty(obj, key, {
|
|
72
|
+
value: value,
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
obj[key] = value;
|
|
79
|
+
}
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
function _toPrimitive(input, hint) {
|
|
83
|
+
if (typeof input !== "object" || input === null) return input;
|
|
84
|
+
var prim = input[Symbol.toPrimitive];
|
|
85
|
+
if (prim !== undefined) {
|
|
86
|
+
var res = prim.call(input, hint || "default");
|
|
87
|
+
if (typeof res !== "object") return res;
|
|
88
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
89
|
+
}
|
|
90
|
+
return (hint === "string" ? String : Number)(input);
|
|
91
|
+
}
|
|
92
|
+
function _toPropertyKey(arg) {
|
|
93
|
+
var key = _toPrimitive(arg, "string");
|
|
94
|
+
return typeof key === "symbol" ? key : String(key);
|
|
95
|
+
}
|
|
96
|
+
|
|
39
97
|
var typeProp = function typeProp() {
|
|
40
98
|
var args = [].slice.call(arguments);
|
|
41
99
|
var callback = args.shift();
|
|
@@ -50,6 +108,9 @@ var isString = function isString(v) {
|
|
|
50
108
|
var isBoolean = function isBoolean(v) {
|
|
51
109
|
return typeof v === 'boolean';
|
|
52
110
|
};
|
|
111
|
+
var isObject = function isObject(v) {
|
|
112
|
+
return _typeof(v) === 'object';
|
|
113
|
+
};
|
|
53
114
|
var isUndefined = function isUndefined(v) {
|
|
54
115
|
return typeof v === 'undefined';
|
|
55
116
|
};
|
|
@@ -193,57 +254,6 @@ var element = function element(tag, attrs, content) {
|
|
|
193
254
|
return result.join('');
|
|
194
255
|
};
|
|
195
256
|
|
|
196
|
-
function _classCallCheck(instance, Constructor) {
|
|
197
|
-
if (!(instance instanceof Constructor)) {
|
|
198
|
-
throw new TypeError("Cannot call a class as a function");
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function _defineProperties(target, props) {
|
|
202
|
-
for (var i = 0; i < props.length; i++) {
|
|
203
|
-
var descriptor = props[i];
|
|
204
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
205
|
-
descriptor.configurable = true;
|
|
206
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
207
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
211
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
212
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
213
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
214
|
-
writable: false
|
|
215
|
-
});
|
|
216
|
-
return Constructor;
|
|
217
|
-
}
|
|
218
|
-
function _defineProperty(obj, key, value) {
|
|
219
|
-
key = _toPropertyKey(key);
|
|
220
|
-
if (key in obj) {
|
|
221
|
-
Object.defineProperty(obj, key, {
|
|
222
|
-
value: value,
|
|
223
|
-
enumerable: true,
|
|
224
|
-
configurable: true,
|
|
225
|
-
writable: true
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
obj[key] = value;
|
|
229
|
-
}
|
|
230
|
-
return obj;
|
|
231
|
-
}
|
|
232
|
-
function _toPrimitive(input, hint) {
|
|
233
|
-
if (typeof input !== "object" || input === null) return input;
|
|
234
|
-
var prim = input[Symbol.toPrimitive];
|
|
235
|
-
if (prim !== undefined) {
|
|
236
|
-
var res = prim.call(input, hint || "default");
|
|
237
|
-
if (typeof res !== "object") return res;
|
|
238
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
239
|
-
}
|
|
240
|
-
return (hint === "string" ? String : Number)(input);
|
|
241
|
-
}
|
|
242
|
-
function _toPropertyKey(arg) {
|
|
243
|
-
var key = _toPrimitive(arg, "string");
|
|
244
|
-
return typeof key === "symbol" ? key : String(key);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
257
|
var tagList = [{
|
|
248
258
|
symbol: '-',
|
|
249
259
|
format: function format(value) {
|
|
@@ -374,20 +384,6 @@ var fileSystem = function fileSystem(path, template) {
|
|
|
374
384
|
});
|
|
375
385
|
});
|
|
376
386
|
};
|
|
377
|
-
var disableWatcher = function disableWatcher(watcher) {
|
|
378
|
-
if (watcher) {
|
|
379
|
-
watcher.unwatch('.');
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
var enableWatcher = function enableWatcher(path, cache) {
|
|
383
|
-
return chokidar__default["default"].watch('.', {
|
|
384
|
-
cwd: path
|
|
385
|
-
}).on('change', function (name) {
|
|
386
|
-
cache.remove(name);
|
|
387
|
-
}).on('error', function (error) {
|
|
388
|
-
console.log('watcher error: ' + error);
|
|
389
|
-
});
|
|
390
|
-
};
|
|
391
387
|
var Template = /*#__PURE__*/function () {
|
|
392
388
|
function Template(config, cache, compiler) {
|
|
393
389
|
_classCallCheck(this, Template);
|
|
@@ -399,11 +395,21 @@ var Template = /*#__PURE__*/function () {
|
|
|
399
395
|
_createClass(Template, [{
|
|
400
396
|
key: "configure",
|
|
401
397
|
value: function configure(config) {
|
|
398
|
+
var _this = this;
|
|
402
399
|
this.path = config.path;
|
|
400
|
+
this.chokidar = config.chokidar;
|
|
403
401
|
this.resolver = isFunction(config.resolver) ? config.resolver : isNode() ? fileSystem : httpRequest;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
402
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
403
|
+
if (this.watcher) {
|
|
404
|
+
this.watcher.unwatch('.');
|
|
405
|
+
}
|
|
406
|
+
this.watcher = this.chokidar.watch('.', {
|
|
407
|
+
cwd: this.path
|
|
408
|
+
}).on('change', function (name) {
|
|
409
|
+
_this.cache.remove(name);
|
|
410
|
+
}).on('error', function (error) {
|
|
411
|
+
console.log('watcher error: ' + error);
|
|
412
|
+
});
|
|
407
413
|
}
|
|
408
414
|
}
|
|
409
415
|
}, {
|
|
@@ -429,12 +435,12 @@ var Template = /*#__PURE__*/function () {
|
|
|
429
435
|
}, {
|
|
430
436
|
key: "get",
|
|
431
437
|
value: function get(template) {
|
|
432
|
-
var
|
|
438
|
+
var _this2 = this;
|
|
433
439
|
if (this.cache.exist(template)) {
|
|
434
440
|
return this.cache.resolve(template);
|
|
435
441
|
}
|
|
436
442
|
var content = this.resolve(template).then(function (content) {
|
|
437
|
-
return
|
|
443
|
+
return _this2.result(template, _this2.compile(content, template));
|
|
438
444
|
});
|
|
439
445
|
return this.result(template, content);
|
|
440
446
|
}
|
|
@@ -743,6 +749,7 @@ var configSchema = function configSchema(config, options) {
|
|
|
743
749
|
withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
|
|
744
750
|
rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
745
751
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
752
|
+
chokidar: typeProp(isObject, defaults["export"], config["export"], options["export"]),
|
|
746
753
|
token: extend({}, defaults.token, config.token, options.token),
|
|
747
754
|
vars: extend({}, defaults.vars, config.vars, options.vars)
|
|
748
755
|
});
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import chokidar from 'chokidar';
|
|
4
3
|
|
|
5
4
|
const defaults = {};
|
|
6
5
|
|
|
@@ -43,6 +42,7 @@ const typeProp = function () {
|
|
|
43
42
|
const isFunction = (v) => typeof v === 'function';
|
|
44
43
|
const isString = (v) => typeof v === 'string';
|
|
45
44
|
const isBoolean = (v) => typeof v === 'boolean';
|
|
45
|
+
const isObject = (v) => typeof v === 'object';
|
|
46
46
|
const isUndefined = (v) => typeof v === 'undefined';
|
|
47
47
|
|
|
48
48
|
const isNodeEnv =
|
|
@@ -367,25 +367,6 @@ const fileSystem = (path, template) => {
|
|
|
367
367
|
})
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
-
const disableWatcher = (watcher) => {
|
|
371
|
-
if (watcher) {
|
|
372
|
-
watcher.unwatch('.');
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const enableWatcher = (path, cache) => {
|
|
377
|
-
return chokidar
|
|
378
|
-
.watch('.', {
|
|
379
|
-
cwd: path,
|
|
380
|
-
})
|
|
381
|
-
.on('change', (name) => {
|
|
382
|
-
cache.remove(name);
|
|
383
|
-
})
|
|
384
|
-
.on('error', (error) => {
|
|
385
|
-
console.log('watcher error: ' + error);
|
|
386
|
-
})
|
|
387
|
-
};
|
|
388
|
-
|
|
389
370
|
class Template {
|
|
390
371
|
constructor(config, cache, compiler) {
|
|
391
372
|
this.cache = cache;
|
|
@@ -395,14 +376,24 @@ class Template {
|
|
|
395
376
|
}
|
|
396
377
|
configure(config) {
|
|
397
378
|
this.path = config.path;
|
|
379
|
+
this.chokidar = config.chokidar;
|
|
398
380
|
this.resolver = isFunction(config.resolver)
|
|
399
381
|
? config.resolver
|
|
400
382
|
: isNode()
|
|
401
383
|
? fileSystem
|
|
402
384
|
: httpRequest;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
386
|
+
if (this.watcher) {
|
|
387
|
+
this.watcher.unwatch('.');
|
|
388
|
+
}
|
|
389
|
+
this.watcher = this.chokidar
|
|
390
|
+
.watch('.', { cwd: this.path })
|
|
391
|
+
.on('change', (name) => {
|
|
392
|
+
this.cache.remove(name);
|
|
393
|
+
})
|
|
394
|
+
.on('error', (error) => {
|
|
395
|
+
console.log('watcher error: ' + error);
|
|
396
|
+
});
|
|
406
397
|
}
|
|
407
398
|
}
|
|
408
399
|
resolve(template) {
|
|
@@ -778,6 +769,12 @@ const configSchema = (config, options) => {
|
|
|
778
769
|
options.rmWhitespace
|
|
779
770
|
),
|
|
780
771
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
772
|
+
chokidar: typeProp(
|
|
773
|
+
isObject,
|
|
774
|
+
defaults.export,
|
|
775
|
+
config.export,
|
|
776
|
+
options.export
|
|
777
|
+
),
|
|
781
778
|
token: extend({}, defaults.token, config.token, options.token),
|
|
782
779
|
vars: extend({}, defaults.vars, config.vars, options.vars),
|
|
783
780
|
});
|
package/dist/umd/index.js
CHANGED
|
@@ -30,6 +30,66 @@
|
|
|
30
30
|
regex: '([\\s\\S]+?)'
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
function _typeof(obj) {
|
|
34
|
+
"@babel/helpers - typeof";
|
|
35
|
+
|
|
36
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
37
|
+
return typeof obj;
|
|
38
|
+
} : function (obj) {
|
|
39
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
40
|
+
}, _typeof(obj);
|
|
41
|
+
}
|
|
42
|
+
function _classCallCheck(instance, Constructor) {
|
|
43
|
+
if (!(instance instanceof Constructor)) {
|
|
44
|
+
throw new TypeError("Cannot call a class as a function");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function _defineProperties(target, props) {
|
|
48
|
+
for (var i = 0; i < props.length; i++) {
|
|
49
|
+
var descriptor = props[i];
|
|
50
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
+
descriptor.configurable = true;
|
|
52
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
57
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
58
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
59
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
60
|
+
writable: false
|
|
61
|
+
});
|
|
62
|
+
return Constructor;
|
|
63
|
+
}
|
|
64
|
+
function _defineProperty(obj, key, value) {
|
|
65
|
+
key = _toPropertyKey(key);
|
|
66
|
+
if (key in obj) {
|
|
67
|
+
Object.defineProperty(obj, key, {
|
|
68
|
+
value: value,
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
obj[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
function _toPrimitive(input, hint) {
|
|
79
|
+
if (typeof input !== "object" || input === null) return input;
|
|
80
|
+
var prim = input[Symbol.toPrimitive];
|
|
81
|
+
if (prim !== undefined) {
|
|
82
|
+
var res = prim.call(input, hint || "default");
|
|
83
|
+
if (typeof res !== "object") return res;
|
|
84
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
85
|
+
}
|
|
86
|
+
return (hint === "string" ? String : Number)(input);
|
|
87
|
+
}
|
|
88
|
+
function _toPropertyKey(arg) {
|
|
89
|
+
var key = _toPrimitive(arg, "string");
|
|
90
|
+
return typeof key === "symbol" ? key : String(key);
|
|
91
|
+
}
|
|
92
|
+
|
|
33
93
|
var typeProp = function typeProp() {
|
|
34
94
|
var args = [].slice.call(arguments);
|
|
35
95
|
var callback = args.shift();
|
|
@@ -44,6 +104,9 @@
|
|
|
44
104
|
var isBoolean = function isBoolean(v) {
|
|
45
105
|
return typeof v === 'boolean';
|
|
46
106
|
};
|
|
107
|
+
var isObject = function isObject(v) {
|
|
108
|
+
return _typeof(v) === 'object';
|
|
109
|
+
};
|
|
47
110
|
var isUndefined = function isUndefined(v) {
|
|
48
111
|
return typeof v === 'undefined';
|
|
49
112
|
};
|
|
@@ -187,57 +250,6 @@
|
|
|
187
250
|
return result.join('');
|
|
188
251
|
};
|
|
189
252
|
|
|
190
|
-
function _classCallCheck(instance, Constructor) {
|
|
191
|
-
if (!(instance instanceof Constructor)) {
|
|
192
|
-
throw new TypeError("Cannot call a class as a function");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function _defineProperties(target, props) {
|
|
196
|
-
for (var i = 0; i < props.length; i++) {
|
|
197
|
-
var descriptor = props[i];
|
|
198
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
199
|
-
descriptor.configurable = true;
|
|
200
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
201
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
205
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
206
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
207
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
208
|
-
writable: false
|
|
209
|
-
});
|
|
210
|
-
return Constructor;
|
|
211
|
-
}
|
|
212
|
-
function _defineProperty(obj, key, value) {
|
|
213
|
-
key = _toPropertyKey(key);
|
|
214
|
-
if (key in obj) {
|
|
215
|
-
Object.defineProperty(obj, key, {
|
|
216
|
-
value: value,
|
|
217
|
-
enumerable: true,
|
|
218
|
-
configurable: true,
|
|
219
|
-
writable: true
|
|
220
|
-
});
|
|
221
|
-
} else {
|
|
222
|
-
obj[key] = value;
|
|
223
|
-
}
|
|
224
|
-
return obj;
|
|
225
|
-
}
|
|
226
|
-
function _toPrimitive(input, hint) {
|
|
227
|
-
if (typeof input !== "object" || input === null) return input;
|
|
228
|
-
var prim = input[Symbol.toPrimitive];
|
|
229
|
-
if (prim !== undefined) {
|
|
230
|
-
var res = prim.call(input, hint || "default");
|
|
231
|
-
if (typeof res !== "object") return res;
|
|
232
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
233
|
-
}
|
|
234
|
-
return (hint === "string" ? String : Number)(input);
|
|
235
|
-
}
|
|
236
|
-
function _toPropertyKey(arg) {
|
|
237
|
-
var key = _toPrimitive(arg, "string");
|
|
238
|
-
return typeof key === "symbol" ? key : String(key);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
253
|
var tagList = [{
|
|
242
254
|
symbol: '-',
|
|
243
255
|
format: function format(value) {
|
|
@@ -368,20 +380,6 @@
|
|
|
368
380
|
});
|
|
369
381
|
});
|
|
370
382
|
};
|
|
371
|
-
var disableWatcher = function disableWatcher(watcher) {
|
|
372
|
-
if (watcher) {
|
|
373
|
-
watcher.unwatch('.');
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
var enableWatcher = function enableWatcher(path$1, cache) {
|
|
377
|
-
return path.watch('.', {
|
|
378
|
-
cwd: path$1
|
|
379
|
-
}).on('change', function (name) {
|
|
380
|
-
cache.remove(name);
|
|
381
|
-
}).on('error', function (error) {
|
|
382
|
-
console.log('watcher error: ' + error);
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
383
|
var Template = /*#__PURE__*/function () {
|
|
386
384
|
function Template(config, cache, compiler) {
|
|
387
385
|
_classCallCheck(this, Template);
|
|
@@ -393,11 +391,21 @@
|
|
|
393
391
|
_createClass(Template, [{
|
|
394
392
|
key: "configure",
|
|
395
393
|
value: function configure(config) {
|
|
394
|
+
var _this = this;
|
|
396
395
|
this.path = config.path;
|
|
396
|
+
this.chokidar = config.chokidar;
|
|
397
397
|
this.resolver = isFunction(config.resolver) ? config.resolver : isNode() ? fileSystem : httpRequest;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
399
|
+
if (this.watcher) {
|
|
400
|
+
this.watcher.unwatch('.');
|
|
401
|
+
}
|
|
402
|
+
this.watcher = this.chokidar.watch('.', {
|
|
403
|
+
cwd: this.path
|
|
404
|
+
}).on('change', function (name) {
|
|
405
|
+
_this.cache.remove(name);
|
|
406
|
+
}).on('error', function (error) {
|
|
407
|
+
console.log('watcher error: ' + error);
|
|
408
|
+
});
|
|
401
409
|
}
|
|
402
410
|
}
|
|
403
411
|
}, {
|
|
@@ -423,12 +431,12 @@
|
|
|
423
431
|
}, {
|
|
424
432
|
key: "get",
|
|
425
433
|
value: function get(template) {
|
|
426
|
-
var
|
|
434
|
+
var _this2 = this;
|
|
427
435
|
if (this.cache.exist(template)) {
|
|
428
436
|
return this.cache.resolve(template);
|
|
429
437
|
}
|
|
430
438
|
var content = this.resolve(template).then(function (content) {
|
|
431
|
-
return
|
|
439
|
+
return _this2.result(template, _this2.compile(content, template));
|
|
432
440
|
});
|
|
433
441
|
return this.result(template, content);
|
|
434
442
|
}
|
|
@@ -737,6 +745,7 @@
|
|
|
737
745
|
withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
|
|
738
746
|
rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
739
747
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
748
|
+
chokidar: typeProp(isObject, defaults["export"], config["export"], options["export"]),
|
|
740
749
|
token: extend({}, defaults.token, config.token, options.token),
|
|
741
750
|
vars: extend({}, defaults.vars, config.vars, options.vars)
|
|
742
751
|
});
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var e={},n={export:"ejsPrecompiled",watch:!1,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof t},u=function(t){return void 0===t},s="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return s},h={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},p=l(f),v=l(h),d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(p,(function(t){return f[t]}))},m=function(t,e,n){return null==(n=t)?"":e?d(n):n},g=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},y=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},b=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},w=function(){},x=function(t,e){var n;for(n in t)E(t,n)&&e(t[n],n,t)},j=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return x(t,(function(t,n,o){var c=e(t,n,o);!1===u(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},k=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},E=function(t,e){return t&&t.hasOwnProperty(e)},O=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",B='"',P="/",R="<",S=">",$=function(t,e,n){var r=[],i=-1===O.indexOf(t),o=function(t,e,n){var r=[];return x(t,(function(t,n,i){var o=e(t,n,i);!1===u(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[d(e),[B,d(t),B].join("")].join("=")})).join(F);return r.push([R,t,F,o,S].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([R,P,t,S].join("")),r.join("")};function M(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,U(r.key),r)}}function C(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function U(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var A=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],_=function(){function t(e){M(this,t),this.configure(e)}return C(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},A.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,f,l="".concat(c,"('");s=this.regex,a=function(e,r,i){l+=(""+t.slice(r,i)).replace(v,(function(t){return"\\"+h[t]})),e.forEach((function(t,e){t&&(l+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,f,e),f=e+n.length,n})),l="try{".concat(l+="');","}catch(e){console.info(e)}"),this.withObject&&(l="with(".concat(i,"){").concat(l,"}")),l="".concat(c,".start();").concat(l,"return ").concat(c,".end();"),l+="\n//# sourceURL=".concat(e);var p=null;try{(p=new Function(i,u,c,o,l)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(l,"\n})")}catch(t){throw t.filename=e,t.source=l,t}return p}}]),t}(),L=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},N=function(t,e){return fetch(L(t,e)).then((function(t){return t.text()}))},W=function(t,n){return new Promise((function(r,i){e.readFile(L(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){M(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return C(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:a()?W:N,(n=this.watcher)&&n.unwatch("."),t.watch&&a()&&(this.watcher=(r=this.path,o=this.cache,e.watch(".",{cwd:r}).on("change",(function(t){o.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return i(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){M(this,t),this.configure(e)}return C(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,c=n.LAYOUT,u=n.BLOCKS,s=n.BUFFER,a=n.MACRO,h=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),b(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){b(f.prototype,t)},f.prototype=b({},e||{}),f.define=f.method=function(t,e,n,r,i){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},f.define(s,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),D(n)},n.error=function(t){throw t},n.end=function(){return D(e)},n}()),f.define(u,{},!0),f.define(a,{},!0),f.define(c,!1,!0),f.define(r,!1,!0),f.method("initBlocks",(function(){this[u]={}})),f.method("initMacro",(function(){this[a]={}})),f.method("getMacro",(function(){return this[a]})),f.method("getBuffer",(function(){return this[s]})),f.method("getComponent",(function(){var t=this;return h in t?function(){return t[h].apply(t,arguments)}:function(){console.log("%s function not defined",h)}})),f.method("getBlocks",(function(){return this[u]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[c]=t})),f.method("getLayout",(function(){return this[c]})),f.method("clone",(function(t){var e=[c,r,s];return!0===t&&e.push(u),j(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),i(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return E(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&E(r,i)?r[i]:r[i]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(i(n))return n.apply(n,r)})),f.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:w}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=b(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(k(n,(function(t){var n=this.getMacro();x(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(k(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return $(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(k(n,(function(n){return $(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),x(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;M(this,t),n=this,i={},(r=U(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===a()&&this.load(X[this.namespace])}return C(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return b(this.list,t),this}},{key:"exist",value:function(t){return E(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),V=function(t,e){b(t,{path:r(o,n.path,t.path,e.path),export:r(o,n.export,t.export,e.export),resolver:r(i,n.resolver,t.resolver,e.resolver),extension:r(o,n.extension,t.extension,e.extension),withObject:r(c,n.withObject,t.withObject,e.withObject),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:r(c,n.watch,t.watch,e.watch),token:b({},n.token,t.token,e.token),vars:b({},n.vars,t.vars,e.vars)})},z=function t(u){var s={},a={};V(s,u||{});var h=new K(s),f=new _(s),l=new Y(s),p=new q(s,l,f),v=function(t){return V(s,t),h.configure(s,a),f.configure(s),l.configure(s),p.configure(s),s},d=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),m)}))},g=function(t,e){var n=y(t,s.extension),r=h.create(e);return d(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return g(e,n)}return t}))},w=function(t){h.helpers(b(a,t||{}))};return w({require:function(t){return function(t){var e=y(t,s.extension),n=h.create({});return d(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return g(t,e)}}),{render:g,helpers:w,configure:v,compile:function(t,e){return f.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},context:h,__express:function(t,u,s){i(u)&&(s=u,u={});var a=b({},(u=u||{}).settings),h=r(o,n.path,a.views),f=r(c,n.cache,a["view cache"]),l=b({},a["view options"]),p=e.relative(h,t);return l.path=h,l.cache=f,v(l),g(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),G=z.context,H=z.render,I=z.helpers,J=z.configure,Q=z.compile,Z=z.create,tt=z.preload,et=z.__express;t.__express=et,t.compile=Q,t.configure=J,t.context=G,t.create=Z,t.element=$,t.helpers=I,t.preload=tt,t.render=H,t.safeValue=m,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var e={},n={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,u(r.key),r)}}function c(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}n.export="ejsPrecompiled",n.watch=!1,n.path="views",n.resolver=null,n.extension="ejs",n.rmWhitespace=!0,n.withObject=!0,n.vars={SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},n.token={start:"<%",end:"%>",regex:"([\\s\\S]+?)"};var s=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},a=function(t){return"function"==typeof t},h=function(t){return"string"==typeof t},f=function(t){return"boolean"==typeof t},l=function(t){return"object"===r(t)},p=function(t){return void 0===t},v="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return v},d={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},g={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},b=y(g),w=y(d),x=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(b,(function(t){return g[t]}))},k=function(t,e,n){return null==(n=t)?"":e?x(n):n},j=function(t,e){var n=t,r=e.split("."),o=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,o]},E=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},O=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},F=function(){},S=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},B=function(t,e){return function(t,e,n){var r=t instanceof Array,o=r?[]:{};return S(t,(function(t,n,i){var c=e(t,n,i);!1===p(c)&&(r?o.push(c):o[n]=c)})),o}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},P=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],M=" ",T='"',C="/",U="<",A=">",_=function(t,e,n){var r=[],o=-1===$.indexOf(t),i=function(t,e,n){var r=[];return S(t,(function(t,n,o){var i=e(t,n,o);!1===p(i)&&r.push(i)})),r}(e,(function(t,e){if(null!=t)return[x(e),[T,x(t),T].join("")].join("=")})).join(M);return r.push([U,t,M,i,A].join("")),n&&r.push(n instanceof Array?n.join(""):n),o&&r.push([U,C,t,A].join("")),r.join("")},L=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],N=function(){function t(e){o(this,t),this.configure(e)}return c(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},L.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,h,f="".concat(c,"('");s=this.regex,a=function(e,r,o){f+=(""+t.slice(r,o)).replace(w,(function(t){return"\\"+d[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,h,e),h=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(o,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(o,u,c,i,f)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),W=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},q=function(t,e){return fetch(W(t,e)).then((function(t){return t.text()}))},D=function(t,n){return new Promise((function(r,o){e.readFile(W(t,n),(function(t,e){t?o(t):r(e.toString())}))}))},K=function(){function t(e,n,r){o(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return c(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=a(t.resolver)?t.resolver:m()?D:q,t.watch&&t.chokidar&&m()&&(this.watcher&&this.watcher.unwatch("."),this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)})))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return a(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),X=function(t){return Promise.all(t).then((function(t){return t.join("")}))},Y=function(){function t(e){o(this,t),this.configure(e)}return c(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,o=n.LAYOUT,i=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),O(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){O(f.prototype,t)},f.prototype=O({},e||{}),f.define=f.method=function(t,e,n,r,o){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:o||!1})},f.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),X(n)},n.error=function(t){throw t},n.end=function(){return X(e)},n}()),f.define(i,{},!0),f.define(u,{},!0),f.define(o,!1,!0),f.define(r,!1,!0),f.method("initBlocks",(function(){this[i]={}})),f.method("initMacro",(function(){this[u]={}})),f.method("getMacro",(function(){return this[u]})),f.method("getBuffer",(function(){return this[c]})),f.method("getComponent",(function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}})),f.method("getBlocks",(function(){return this[i]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[o]=t})),f.method("getLayout",(function(){return this[o]})),f.method("clone",(function(t){var e=[o,r,c];return!0===t&&e.push(i),B(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),a(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return R(r,o)?r[o]:e})),f.method("set",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return this.getExtend()&&R(r,o)?r[o]:r[o]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),o=this;n[t]=function(){return o.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(a(n))return n.apply(n,r)})),f.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var e=i();return e?function(){n.echo(e(t()))}:F}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),o=O(r,e||{}),i=this.render(t,o);this.echo(i)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(P(n,(function(t){var n=this.getMacro();S(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(P(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return _(t,e,n)})),f.method("el",(function(t,e,n){a(n)&&(n=this.fn(n)()),this.echo(P(n,(function(n){return _(t,e,n)}),this))})),f.method("each",(function(t,e){h(t)&&(t=this.get(t,[])),S(t,e)}))}}]),t}(),V="undefined"!=typeof globalThis?globalThis:window||self,z=function(){function t(e){var n,r,i;o(this,t),n=this,i={},(r=u(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===m()&&this.load(V[this.namespace])}return c(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return O(this.list,t),this}},{key:"exist",value:function(t){return R(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),G=function(t,e){O(t,{path:s(h,n.path,t.path,e.path),export:s(h,n.export,t.export,e.export),resolver:s(a,n.resolver,t.resolver,e.resolver),extension:s(h,n.extension,t.extension,e.extension),withObject:s(f,n.withObject,t.withObject,e.withObject),rmWhitespace:s(f,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:s(f,n.watch,t.watch,e.watch),chokidar:s(l,n.export,t.export,e.export),token:O({},n.token,t.token,e.token),vars:O({},n.vars,t.vars,e.vars)})},H=function t(r){var o={},i={};G(o,r||{});var c=new Y(o),u=new N(o),l=new z(o),p=new K(o,l,u),v=function(t){return G(o,t),c.configure(o,i),u.configure(o),l.configure(o),p.configure(o),o},m=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),k)}))},d=function(t,e){var n=E(t,o.extension),r=c.create(e);return m(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return d(e,n)}return t}))},g=function(t){c.helpers(O(i,t||{}))};return g({require:function(t){return function(t){var e=E(t,o.extension),n=c.create({});return m(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return d(t,e)}}),{render:d,helpers:g,configure:v,compile:function(t,e){return u.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},context:c,__express:function(t,r,o){a(r)&&(o=r,r={});var i=O({},(r=r||{}).settings),c=s(h,n.path,i.views),u=s(f,n.cache,i["view cache"]),l=O({},i["view options"]),p=e.relative(c,t);return l.path=c,l.cache=u,v(l),d(p,r).then((function(t){o(null,t)})).catch((function(t){o(t)}))}}}({}),I=H.context,J=H.render,Q=H.helpers,Z=H.configure,tt=H.compile,et=H.create,nt=H.preload,rt=H.__express;t.__express=rt,t.compile=tt,t.configure=Z,t.context=I,t.create=et,t.element=_,t.helpers=Q,t.preload=nt,t.render=J,t.safeValue=k,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
"description": "EJS Templates",
|
|
4
4
|
"homepage": "https://github.com/kosatyi/ejs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.50",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/index.js",
|
|
10
10
|
"minified": "dist/umd/index.min.js",
|
|
11
11
|
"author": "Stepan Kosatyi (https://kosatyi.com)",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"chokidar": "^3.5.3"
|
|
14
|
-
},
|
|
15
12
|
"exports": {
|
|
16
13
|
".": {
|
|
17
14
|
"types": "./index.d.ts",
|