@kosatyi/ejs 0.0.97 → 0.0.99
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/browser.js +778 -645
- package/dist/cjs/bundler.js +28 -22
- package/dist/cjs/element.js +7 -0
- package/dist/cjs/index.js +787 -653
- package/dist/cjs/worker.js +774 -643
- package/dist/esm/browser.js +557 -616
- package/dist/esm/bundler.js +21 -15
- package/dist/esm/element.js +11 -1
- package/dist/esm/index.js +566 -625
- package/dist/esm/worker.js +573 -633
- package/dist/umd/browser.js +996 -863
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +7 -0
- package/dist/umd/index.js +1030 -896
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +774 -643
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/ejs.d.ts +26 -26
- package/types/global.d.ts +4 -0
package/dist/umd/index.js
CHANGED
|
@@ -1,337 +1,519 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ejs = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
7
|
+
function _assertClassBrand(e, t, n) {
|
|
8
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
9
|
+
throw new TypeError("Private element is not present on this object");
|
|
10
|
+
}
|
|
11
|
+
function _assertThisInitialized(e) {
|
|
12
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
return e;
|
|
14
|
+
}
|
|
15
|
+
function _callSuper(t, o, e) {
|
|
16
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
17
|
+
}
|
|
18
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
19
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
20
|
+
}
|
|
21
|
+
function _classCallCheck(a, n) {
|
|
22
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
23
|
+
}
|
|
24
|
+
function _classPrivateFieldGet2(s, a) {
|
|
25
|
+
return s.get(_assertClassBrand(s, a));
|
|
26
|
+
}
|
|
27
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
28
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
29
|
+
}
|
|
30
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
31
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
32
|
+
}
|
|
33
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
34
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
35
|
+
}
|
|
36
|
+
function _construct(t, e, r) {
|
|
37
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
38
|
+
var o = [null];
|
|
39
|
+
o.push.apply(o, e);
|
|
40
|
+
var p = new (t.bind.apply(t, o))();
|
|
41
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
42
|
+
}
|
|
43
|
+
function _defineProperties(e, r) {
|
|
44
|
+
for (var t = 0; t < r.length; t++) {
|
|
45
|
+
var o = r[t];
|
|
46
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function _createClass(e, r, t) {
|
|
50
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
51
|
+
writable: !1
|
|
52
|
+
}), e;
|
|
53
|
+
}
|
|
54
|
+
function _defineProperty(e, r, t) {
|
|
55
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
56
|
+
value: t,
|
|
57
|
+
enumerable: !0,
|
|
58
|
+
configurable: !0,
|
|
59
|
+
writable: !0
|
|
60
|
+
}) : e[r] = t, e;
|
|
61
|
+
}
|
|
62
|
+
function _getPrototypeOf(t) {
|
|
63
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
64
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
65
|
+
}, _getPrototypeOf(t);
|
|
66
|
+
}
|
|
67
|
+
function _inherits(t, e) {
|
|
68
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
69
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
70
|
+
constructor: {
|
|
71
|
+
value: t,
|
|
72
|
+
writable: !0,
|
|
73
|
+
configurable: !0
|
|
74
|
+
}
|
|
75
|
+
}), Object.defineProperty(t, "prototype", {
|
|
76
|
+
writable: !1
|
|
77
|
+
}), e && _setPrototypeOf(t, e);
|
|
78
|
+
}
|
|
79
|
+
function _isNativeFunction(t) {
|
|
80
|
+
try {
|
|
81
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
82
|
+
} catch (n) {
|
|
83
|
+
return "function" == typeof t;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function _isNativeReflectConstruct() {
|
|
87
|
+
try {
|
|
88
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
89
|
+
} catch (t) {}
|
|
90
|
+
return (_isNativeReflectConstruct = function () {
|
|
91
|
+
return !!t;
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
function _possibleConstructorReturn(t, e) {
|
|
95
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
96
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
97
|
+
return _assertThisInitialized(t);
|
|
98
|
+
}
|
|
99
|
+
function _setPrototypeOf(t, e) {
|
|
100
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
101
|
+
return t.__proto__ = e, t;
|
|
102
|
+
}, _setPrototypeOf(t, e);
|
|
103
|
+
}
|
|
104
|
+
function _toPrimitive(t, r) {
|
|
105
|
+
if ("object" != typeof t || !t) return t;
|
|
106
|
+
var e = t[Symbol.toPrimitive];
|
|
107
|
+
if (void 0 !== e) {
|
|
108
|
+
var i = e.call(t, r);
|
|
109
|
+
if ("object" != typeof i) return i;
|
|
110
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
111
|
+
}
|
|
112
|
+
return (String )(t);
|
|
113
|
+
}
|
|
114
|
+
function _toPropertyKey(t) {
|
|
115
|
+
var i = _toPrimitive(t, "string");
|
|
116
|
+
return "symbol" == typeof i ? i : i + "";
|
|
117
|
+
}
|
|
118
|
+
function _wrapNativeSuper(t) {
|
|
119
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
120
|
+
return _wrapNativeSuper = function (t) {
|
|
121
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
122
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
123
|
+
if (void 0 !== r) {
|
|
124
|
+
if (r.has(t)) return r.get(t);
|
|
125
|
+
r.set(t, Wrapper);
|
|
126
|
+
}
|
|
127
|
+
function Wrapper() {
|
|
128
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
85
129
|
}
|
|
130
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
131
|
+
constructor: {
|
|
132
|
+
value: Wrapper,
|
|
133
|
+
enumerable: !1,
|
|
134
|
+
writable: !0,
|
|
135
|
+
configurable: !0
|
|
136
|
+
}
|
|
137
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
138
|
+
}, _wrapNativeSuper(t);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var typeProp = function typeProp() {
|
|
142
|
+
var args = [].slice.call(arguments);
|
|
143
|
+
var callback = args.shift();
|
|
144
|
+
return args.filter(callback).pop();
|
|
145
|
+
};
|
|
146
|
+
var isArray = function isArray(v) {
|
|
147
|
+
return Array.isArray(v);
|
|
148
|
+
};
|
|
149
|
+
var isFunction = function isFunction(v) {
|
|
150
|
+
return typeof v === 'function';
|
|
151
|
+
};
|
|
152
|
+
var isString = function isString(v) {
|
|
153
|
+
return typeof v === 'string';
|
|
154
|
+
};
|
|
155
|
+
var isBoolean = function isBoolean(v) {
|
|
156
|
+
return typeof v === 'boolean';
|
|
157
|
+
};
|
|
158
|
+
var isUndefined = function isUndefined(v) {
|
|
159
|
+
return typeof v === 'undefined';
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var isNodeEnv = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
163
|
+
var isNode = function isNode() {
|
|
164
|
+
return isNodeEnv;
|
|
165
|
+
};
|
|
166
|
+
var symbolEntities = {
|
|
167
|
+
"'": "'",
|
|
168
|
+
'\\': '\\',
|
|
169
|
+
'\r': 'r',
|
|
170
|
+
'\n': 'n',
|
|
171
|
+
'\t': 't',
|
|
172
|
+
"\u2028": 'u2028',
|
|
173
|
+
"\u2029": 'u2029'
|
|
174
|
+
};
|
|
175
|
+
var htmlEntities = {
|
|
176
|
+
'&': '&',
|
|
177
|
+
'<': '<',
|
|
178
|
+
'>': '>',
|
|
179
|
+
'"': '"',
|
|
180
|
+
"'": '''
|
|
181
|
+
};
|
|
182
|
+
var regexKeys = function regexKeys(obj) {
|
|
183
|
+
return new RegExp(['[', Object.keys(obj).join(''), ']'].join(''), 'g');
|
|
184
|
+
};
|
|
185
|
+
var htmlEntitiesMatch = regexKeys(htmlEntities);
|
|
186
|
+
var symbolEntitiesMatch = regexKeys(symbolEntities);
|
|
187
|
+
var entities = function entities() {
|
|
188
|
+
var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
189
|
+
return ('' + string).replace(htmlEntitiesMatch, function (match) {
|
|
190
|
+
return htmlEntities[match];
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
var symbols = function symbols(string) {
|
|
194
|
+
return ('' + string).replace(symbolEntitiesMatch, function (match) {
|
|
195
|
+
return '\\' + symbolEntities[match];
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
var safeValue = function safeValue(value, escape) {
|
|
199
|
+
var check = value;
|
|
200
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
201
|
+
};
|
|
202
|
+
var instanceOf = function instanceOf(object, instance) {
|
|
203
|
+
return Boolean(object instanceof instance);
|
|
204
|
+
};
|
|
205
|
+
var assertInstanceOf = function assertInstanceOf(object, instance) {
|
|
206
|
+
if (instanceOf(object, instance) === false) throw new TypeError("".concat(object, " in not instance of ").concat(instance));
|
|
207
|
+
};
|
|
208
|
+
var getPath = function getPath(context, name, strict) {
|
|
209
|
+
var data = context;
|
|
210
|
+
var chunks = String(name).split('.');
|
|
211
|
+
var prop = chunks.pop();
|
|
212
|
+
for (var i = 0; i < chunks.length; i++) {
|
|
213
|
+
var part = chunks[i];
|
|
86
214
|
if (isFunction(data['toJSON'])) {
|
|
87
215
|
data = data.toJSON();
|
|
88
216
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var ext = path.split('.').pop();
|
|
93
|
-
if (ext !== defaults) {
|
|
94
|
-
path = [path, defaults].join('.');
|
|
217
|
+
if (strict && data.hasOwnProperty(part) === false) {
|
|
218
|
+
data = {};
|
|
219
|
+
break;
|
|
95
220
|
}
|
|
96
|
-
|
|
97
|
-
}
|
|
221
|
+
data = data[part] = data[part] || {};
|
|
222
|
+
}
|
|
223
|
+
if (isFunction(data['toJSON'])) {
|
|
224
|
+
data = data.toJSON();
|
|
225
|
+
}
|
|
226
|
+
return [data, prop];
|
|
227
|
+
};
|
|
228
|
+
var bindContext = function bindContext(object) {
|
|
229
|
+
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
230
|
+
methods.forEach(function (name) {
|
|
231
|
+
if (name in object) {
|
|
232
|
+
object[name] = object[name].bind(object);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
var ext = function ext(path, defaults) {
|
|
237
|
+
var ext = path.split('.').pop();
|
|
238
|
+
if (ext !== defaults) {
|
|
239
|
+
path = [path, defaults].join('.');
|
|
240
|
+
}
|
|
241
|
+
return path;
|
|
242
|
+
};
|
|
98
243
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
244
|
+
/**
|
|
245
|
+
* @type {<T extends {}, U, V, W,Y>(T,U,V,W,Y)=> T & U & V & W & Y}
|
|
246
|
+
*/
|
|
247
|
+
var extend = function extend(target) {
|
|
248
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
249
|
+
args[_key - 1] = arguments[_key];
|
|
250
|
+
}
|
|
251
|
+
return args.filter(function (source) {
|
|
252
|
+
return source;
|
|
253
|
+
}).reduce(function (target, source) {
|
|
254
|
+
return Object.assign(target, source);
|
|
255
|
+
}, target);
|
|
256
|
+
};
|
|
257
|
+
var noop = function noop() {};
|
|
258
|
+
var each = function each(object, callback) {
|
|
259
|
+
var prop;
|
|
260
|
+
for (prop in object) {
|
|
261
|
+
if (hasProp(object, prop)) {
|
|
262
|
+
callback(object[prop], prop, object);
|
|
119
263
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
var map = function map(object, callback, context) {
|
|
267
|
+
var result = [];
|
|
268
|
+
each(object, function (value, key, object) {
|
|
269
|
+
var item = callback(value, key, object);
|
|
270
|
+
if (isUndefined(item) === false) {
|
|
271
|
+
result.push(item);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return result;
|
|
275
|
+
};
|
|
276
|
+
var filter = function filter(object, callback, context) {
|
|
277
|
+
var isArray = object instanceof Array;
|
|
278
|
+
var result = isArray ? [] : {};
|
|
279
|
+
each(object, function (value, key, object) {
|
|
280
|
+
var item = callback(value, key, object);
|
|
281
|
+
if (isUndefined(item) === false) {
|
|
282
|
+
if (isArray) {
|
|
126
283
|
result.push(item);
|
|
284
|
+
} else {
|
|
285
|
+
result[key] = item;
|
|
127
286
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} else {
|
|
140
|
-
result[key] = item;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
};
|
|
146
|
-
var omit = function omit(object, list) {
|
|
147
|
-
return filter(object, function (value, key) {
|
|
148
|
-
if (list.indexOf(key) === -1) {
|
|
149
|
-
return value;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
var hasProp = function hasProp(object, prop) {
|
|
154
|
-
return object && object.hasOwnProperty(prop);
|
|
155
|
-
};
|
|
156
|
-
var joinPath = function joinPath(path, template) {
|
|
157
|
-
template = [path, template].join('/');
|
|
158
|
-
template = template.replace(/\/\//g, '/');
|
|
159
|
-
return template;
|
|
160
|
-
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
return result;
|
|
290
|
+
};
|
|
291
|
+
var omit = function omit(object, list) {
|
|
292
|
+
return filter(object, function (value, key) {
|
|
293
|
+
if (list.indexOf(key) === -1) {
|
|
294
|
+
return value;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
};
|
|
161
298
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
regex: '([\\s\\S]+?)'
|
|
188
|
-
};
|
|
299
|
+
/**
|
|
300
|
+
*
|
|
301
|
+
* @param object
|
|
302
|
+
* @param prop
|
|
303
|
+
* @return {boolean}
|
|
304
|
+
*/
|
|
305
|
+
var hasProp = function hasProp(object, prop) {
|
|
306
|
+
return object && object.hasOwnProperty(prop);
|
|
307
|
+
};
|
|
308
|
+
var joinPath = function joinPath(path, template) {
|
|
309
|
+
template = [path, template].join('/');
|
|
310
|
+
template = template.replace(/\/\//g, '/');
|
|
311
|
+
return template;
|
|
312
|
+
};
|
|
313
|
+
var matchTokens = function matchTokens(regex, text, callback) {
|
|
314
|
+
var index = 0;
|
|
315
|
+
text.replace(regex, function () {
|
|
316
|
+
var params = [].slice.call(arguments, 0, -1);
|
|
317
|
+
var offset = params.pop();
|
|
318
|
+
var match = params.shift();
|
|
319
|
+
callback(params, index, offset);
|
|
320
|
+
index = offset + match.length;
|
|
321
|
+
return match;
|
|
322
|
+
});
|
|
323
|
+
};
|
|
189
324
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
325
|
+
var defaults = {};
|
|
326
|
+
defaults["export"] = 'ejsPrecompiled';
|
|
327
|
+
defaults.cache = true;
|
|
328
|
+
defaults.chokidar = null;
|
|
329
|
+
defaults.path = 'views';
|
|
330
|
+
defaults.resolver = function (path, template) {
|
|
331
|
+
return Promise.resolve(['resolver is not defined', path, template].join(' '));
|
|
332
|
+
};
|
|
333
|
+
defaults.extension = 'ejs';
|
|
334
|
+
defaults.rmWhitespace = true;
|
|
335
|
+
defaults.withObject = true;
|
|
336
|
+
defaults.globalHelpers = [];
|
|
337
|
+
defaults.vars = {
|
|
338
|
+
SCOPE: 'ejs',
|
|
339
|
+
COMPONENT: 'ui',
|
|
340
|
+
ELEMENT: 'el',
|
|
341
|
+
EXTEND: '$$e',
|
|
342
|
+
BUFFER: '$$a',
|
|
343
|
+
LAYOUT: '$$l',
|
|
344
|
+
BLOCKS: '$$b',
|
|
345
|
+
MACRO: '$$m',
|
|
346
|
+
SAFE: '$$v'
|
|
347
|
+
};
|
|
348
|
+
defaults.token = {
|
|
349
|
+
start: '<%',
|
|
350
|
+
end: '%>',
|
|
351
|
+
regex: '([\\s\\S]+?)'
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
var configSchema = function configSchema(config, options) {
|
|
355
|
+
extend(config, {
|
|
356
|
+
path: typeProp(isString, defaults.path, config.path, options.path),
|
|
357
|
+
"export": typeProp(isString, defaults["export"], config["export"], options["export"]),
|
|
358
|
+
resolver: typeProp(isFunction, defaults.resolver, config.resolver, options.resolver),
|
|
359
|
+
extension: typeProp(isString, defaults.extension, config.extension, options.extension),
|
|
360
|
+
withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
|
|
361
|
+
rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
362
|
+
cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
|
|
363
|
+
token: extend({}, defaults.token, config.token, options.token),
|
|
364
|
+
vars: extend({}, defaults.vars, config.vars, options.vars),
|
|
365
|
+
globalHelpers: typeProp(isArray, defaults.globalHelpers, config.globalHelpers, options.globalHelpers)
|
|
366
|
+
});
|
|
367
|
+
};
|
|
204
368
|
|
|
205
|
-
|
|
369
|
+
var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
|
|
370
|
+
var _enabled = /*#__PURE__*/new WeakMap();
|
|
371
|
+
var _list = /*#__PURE__*/new WeakMap();
|
|
372
|
+
var Cache = /*#__PURE__*/function () {
|
|
206
373
|
function Cache(config) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
this.clear = function () {
|
|
219
|
-
cache.list = {};
|
|
220
|
-
};
|
|
221
|
-
this.load = function (data) {
|
|
222
|
-
if (cache.enabled) {
|
|
223
|
-
extend(cache.list, data || {});
|
|
374
|
+
_classCallCheck(this, Cache);
|
|
375
|
+
_classPrivateFieldInitSpec(this, _enabled, true);
|
|
376
|
+
_classPrivateFieldInitSpec(this, _list, {});
|
|
377
|
+
this.configure(config);
|
|
378
|
+
}
|
|
379
|
+
return _createClass(Cache, [{
|
|
380
|
+
key: "load",
|
|
381
|
+
value: function load(data) {
|
|
382
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
383
|
+
extend(_classPrivateFieldGet2(_list, this), data || {});
|
|
224
384
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
385
|
+
}
|
|
386
|
+
}, {
|
|
387
|
+
key: "get",
|
|
388
|
+
value: function get(key) {
|
|
389
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
390
|
+
return _classPrivateFieldGet2(_list, this)[key];
|
|
230
391
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "set",
|
|
395
|
+
value: function set(key, value) {
|
|
396
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
397
|
+
_classPrivateFieldGet2(_list, this)[key] = value;
|
|
235
398
|
}
|
|
236
|
-
return this;
|
|
237
|
-
};
|
|
238
|
-
this.resolve = function (key) {
|
|
239
|
-
return Promise.resolve(this.get(key));
|
|
240
|
-
};
|
|
241
|
-
this.remove = function (key) {
|
|
242
|
-
delete cache.list[key];
|
|
243
|
-
};
|
|
244
|
-
this.exist = function (key) {
|
|
245
|
-
return hasProp(cache.list, key);
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var tagList = [{
|
|
250
|
-
symbol: '-',
|
|
251
|
-
format: function format(value) {
|
|
252
|
-
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
253
399
|
}
|
|
254
400
|
}, {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return
|
|
401
|
+
key: "exist",
|
|
402
|
+
value: function exist(key) {
|
|
403
|
+
return hasProp(_classPrivateFieldGet2(_list, this), key);
|
|
258
404
|
}
|
|
259
405
|
}, {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
406
|
+
key: "clear",
|
|
407
|
+
value: function clear() {
|
|
408
|
+
_classPrivateFieldSet2(_list, this, {});
|
|
263
409
|
}
|
|
264
410
|
}, {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
411
|
+
key: "remove",
|
|
412
|
+
value: function remove(key) {
|
|
413
|
+
delete _classPrivateFieldGet2(_list, this)[key];
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "resolve",
|
|
417
|
+
value: function resolve(key) {
|
|
418
|
+
return Promise.resolve(this.get(key));
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
key: "configure",
|
|
422
|
+
value: function configure(config) {
|
|
423
|
+
_classPrivateFieldSet2(_enabled, this, config.cache);
|
|
424
|
+
if (isNode() === false) {
|
|
425
|
+
this.load(global[config["export"]]);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}]);
|
|
429
|
+
}();
|
|
430
|
+
|
|
431
|
+
var _config$1 = /*#__PURE__*/new WeakMap();
|
|
432
|
+
var _symbols = /*#__PURE__*/new WeakMap();
|
|
433
|
+
var Compiler = /*#__PURE__*/function () {
|
|
281
434
|
function Compiler(config) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
435
|
+
_classCallCheck(this, Compiler);
|
|
436
|
+
_classPrivateFieldInitSpec(this, _config$1, {});
|
|
437
|
+
_classPrivateFieldInitSpec(this, _symbols, [{
|
|
438
|
+
symbol: '-',
|
|
439
|
+
format: function format(value) {
|
|
440
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
441
|
+
}
|
|
442
|
+
}, {
|
|
443
|
+
symbol: '=',
|
|
444
|
+
format: function format(value) {
|
|
445
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
|
|
446
|
+
}
|
|
447
|
+
}, {
|
|
448
|
+
symbol: '#',
|
|
449
|
+
format: function format(value) {
|
|
450
|
+
return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
|
|
451
|
+
}
|
|
452
|
+
}, {
|
|
453
|
+
symbol: '',
|
|
454
|
+
format: function format(value) {
|
|
455
|
+
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
456
|
+
}
|
|
457
|
+
}]);
|
|
458
|
+
this.configure(config);
|
|
459
|
+
}
|
|
460
|
+
return _createClass(Compiler, [{
|
|
461
|
+
key: "configure",
|
|
462
|
+
value: function configure(config) {
|
|
463
|
+
var _this = this;
|
|
464
|
+
_classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
|
|
465
|
+
_classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
|
|
466
|
+
_classPrivateFieldGet2(_config$1, this).token = config.token;
|
|
467
|
+
_classPrivateFieldGet2(_config$1, this).vars = config.vars;
|
|
468
|
+
_classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
|
|
469
|
+
_classPrivateFieldGet2(_config$1, this).matches = [];
|
|
470
|
+
_classPrivateFieldGet2(_config$1, this).formats = [];
|
|
471
|
+
_classPrivateFieldGet2(_config$1, this).slurp = {
|
|
472
|
+
match: '[s\t\n]*',
|
|
473
|
+
start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
|
|
474
|
+
end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
|
|
296
475
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
476
|
+
_classPrivateFieldGet2(_symbols, this).forEach(function (item) {
|
|
477
|
+
_classPrivateFieldGet2(_config$1, _this).matches.push(_classPrivateFieldGet2(_config$1, _this).token.start.concat(item.symbol).concat(_classPrivateFieldGet2(_config$1, _this).token.regex).concat(_classPrivateFieldGet2(_config$1, _this).token.end));
|
|
478
|
+
_classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
|
|
300
479
|
});
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
480
|
+
_classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
|
|
481
|
+
_classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
|
|
482
|
+
_classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
|
|
483
|
+
}
|
|
484
|
+
}, {
|
|
485
|
+
key: "compile",
|
|
486
|
+
value: function compile(content, path) {
|
|
487
|
+
var _this2 = this;
|
|
488
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
|
|
489
|
+
SCOPE = _classPrivateFieldGet2$1.SCOPE,
|
|
490
|
+
SAFE = _classPrivateFieldGet2$1.SAFE,
|
|
491
|
+
BUFFER = _classPrivateFieldGet2$1.BUFFER,
|
|
492
|
+
COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
|
|
493
|
+
ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
|
|
494
|
+
var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
|
|
495
|
+
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
496
|
+
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
315
497
|
}
|
|
316
|
-
content = content.replace(
|
|
498
|
+
content = String(content).replace(_classPrivateFieldGet2(_config$1, this).slurpStart, _classPrivateFieldGet2(_config$1, this).token.start).replace(_classPrivateFieldGet2(_config$1, this).slurpEnd, _classPrivateFieldGet2(_config$1, this).token.end);
|
|
317
499
|
var source = "".concat(BUFFER, "('");
|
|
318
|
-
matchTokens(
|
|
500
|
+
matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
|
|
319
501
|
source += symbols(content.slice(index, offset));
|
|
320
502
|
params.forEach(function (value, index) {
|
|
321
503
|
if (value) {
|
|
322
|
-
source +=
|
|
504
|
+
source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
|
|
323
505
|
}
|
|
324
506
|
});
|
|
325
507
|
});
|
|
326
508
|
source += "');";
|
|
327
509
|
source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
|
|
328
|
-
if (
|
|
510
|
+
if (_classPrivateFieldGet2(_config$1, this).withObject) {
|
|
329
511
|
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
330
512
|
}
|
|
331
513
|
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
332
514
|
source += "\n//# sourceURL=".concat(path);
|
|
333
515
|
var result = null;
|
|
334
|
-
var params = [SCOPE,
|
|
516
|
+
var params = [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT].concat(GLOBALS);
|
|
335
517
|
try {
|
|
336
518
|
result = Function.apply(null, params.concat(source));
|
|
337
519
|
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
@@ -341,656 +523,608 @@
|
|
|
341
523
|
throw e;
|
|
342
524
|
}
|
|
343
525
|
return result;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
526
|
+
}
|
|
527
|
+
}]);
|
|
528
|
+
}();
|
|
347
529
|
|
|
530
|
+
var _path = /*#__PURE__*/new WeakMap();
|
|
531
|
+
var _cache$1 = /*#__PURE__*/new WeakMap();
|
|
532
|
+
var _compiler$1 = /*#__PURE__*/new WeakMap();
|
|
533
|
+
var _resolver = /*#__PURE__*/new WeakMap();
|
|
534
|
+
var _Template_brand = /*#__PURE__*/new WeakSet();
|
|
535
|
+
var Template = /*#__PURE__*/function () {
|
|
348
536
|
function Template(config, cache, compiler) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
this.configure = function (config) {
|
|
368
|
-
template.path = config.path;
|
|
369
|
-
template.cache = config.cache;
|
|
537
|
+
_classCallCheck(this, Template);
|
|
538
|
+
_classPrivateMethodInitSpec(this, _Template_brand);
|
|
539
|
+
_classPrivateFieldInitSpec(this, _path, void 0);
|
|
540
|
+
_classPrivateFieldInitSpec(this, _cache$1, void 0);
|
|
541
|
+
_classPrivateFieldInitSpec(this, _compiler$1, void 0);
|
|
542
|
+
_classPrivateFieldInitSpec(this, _resolver, void 0);
|
|
543
|
+
assertInstanceOf(cache, Cache);
|
|
544
|
+
assertInstanceOf(compiler, Compiler);
|
|
545
|
+
_classPrivateFieldSet2(_cache$1, this, cache);
|
|
546
|
+
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
547
|
+
this.configure(config);
|
|
548
|
+
}
|
|
549
|
+
return _createClass(Template, [{
|
|
550
|
+
key: "configure",
|
|
551
|
+
value: function configure(config) {
|
|
552
|
+
_classPrivateFieldSet2(_path, this, config.path);
|
|
370
553
|
if (isFunction(config.resolver)) {
|
|
371
|
-
|
|
554
|
+
_classPrivateFieldSet2(_resolver, this, config.resolver);
|
|
372
555
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
556
|
+
}
|
|
557
|
+
}, {
|
|
558
|
+
key: "get",
|
|
559
|
+
value: function get(template) {
|
|
560
|
+
var _this = this;
|
|
561
|
+
if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
|
|
562
|
+
return _classPrivateFieldGet2(_cache$1, this).resolve(template);
|
|
377
563
|
}
|
|
378
|
-
return
|
|
379
|
-
return
|
|
564
|
+
return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
|
|
565
|
+
return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
|
|
380
566
|
});
|
|
381
|
-
}
|
|
382
|
-
|
|
567
|
+
}
|
|
568
|
+
}]);
|
|
569
|
+
}();
|
|
570
|
+
function _resolve(path) {
|
|
571
|
+
return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
|
|
572
|
+
}
|
|
573
|
+
function _result(template, content) {
|
|
574
|
+
_classPrivateFieldGet2(_cache$1, this).set(template, content);
|
|
575
|
+
return content;
|
|
576
|
+
}
|
|
577
|
+
function _compile(content, template) {
|
|
578
|
+
if (isFunction(content)) {
|
|
579
|
+
return content;
|
|
580
|
+
} else {
|
|
581
|
+
return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
|
|
383
582
|
}
|
|
583
|
+
}
|
|
384
584
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
585
|
+
var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
586
|
+
var space = ' ';
|
|
587
|
+
var quote = '"';
|
|
588
|
+
var equal = '=';
|
|
589
|
+
var slash = '/';
|
|
590
|
+
var lt = '<';
|
|
591
|
+
var gt = '>';
|
|
592
|
+
var element = function element(tag, attrs, content) {
|
|
593
|
+
var result = [];
|
|
594
|
+
var hasClosedTag = selfClosed.indexOf(tag) === -1;
|
|
595
|
+
var attributes = map(attrs, function (value, key) {
|
|
596
|
+
if (value !== null && value !== undefined) {
|
|
597
|
+
return [entities(key), [quote, entities(value), quote].join('')].join(equal);
|
|
598
|
+
}
|
|
599
|
+
}).join(space);
|
|
600
|
+
result.push([lt, tag, space, attributes, gt].join(''));
|
|
601
|
+
if (content && hasClosedTag) {
|
|
602
|
+
result.push(content instanceof Array ? content.join('') : content);
|
|
402
603
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return "symbol" == typeof i ? i : i + "";
|
|
604
|
+
if (hasClosedTag) {
|
|
605
|
+
result.push([lt, slash, tag, gt].join(''));
|
|
406
606
|
}
|
|
607
|
+
return result.join('');
|
|
608
|
+
};
|
|
407
609
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}).join(space);
|
|
423
|
-
result.push([lt, tag, space, attributes, gt].join(''));
|
|
424
|
-
if (content && hasClosedTag) {
|
|
425
|
-
result.push(content instanceof Array ? content.join('') : content);
|
|
610
|
+
var TemplateError = /*#__PURE__*/function (_Error) {
|
|
611
|
+
function TemplateError(message) {
|
|
612
|
+
var _this;
|
|
613
|
+
_classCallCheck(this, TemplateError);
|
|
614
|
+
_this = _callSuper(this, TemplateError);
|
|
615
|
+
_defineProperty(_this, "code", 0);
|
|
616
|
+
_this.message = message;
|
|
617
|
+
return _this;
|
|
618
|
+
}
|
|
619
|
+
_inherits(TemplateError, _Error);
|
|
620
|
+
return _createClass(TemplateError, [{
|
|
621
|
+
key: "getCode",
|
|
622
|
+
value: function getCode() {
|
|
623
|
+
return this.code;
|
|
426
624
|
}
|
|
427
|
-
|
|
428
|
-
|
|
625
|
+
}, {
|
|
626
|
+
key: "getMessage",
|
|
627
|
+
value: function getMessage() {
|
|
628
|
+
return this.message;
|
|
429
629
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
this
|
|
441
|
-
|
|
442
|
-
|
|
630
|
+
}, {
|
|
631
|
+
key: "toString",
|
|
632
|
+
value: function toString() {
|
|
633
|
+
return this.getMessage();
|
|
634
|
+
}
|
|
635
|
+
}]);
|
|
636
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
637
|
+
var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
|
|
638
|
+
function TemplateNotFound() {
|
|
639
|
+
var _this2;
|
|
640
|
+
_classCallCheck(this, TemplateNotFound);
|
|
641
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
642
|
+
args[_key] = arguments[_key];
|
|
643
|
+
}
|
|
644
|
+
_this2 = _callSuper(this, TemplateNotFound, [].concat(args));
|
|
645
|
+
_defineProperty(_this2, "code", 404);
|
|
646
|
+
return _this2;
|
|
443
647
|
}
|
|
648
|
+
_inherits(TemplateNotFound, _TemplateError2);
|
|
649
|
+
return _createClass(TemplateNotFound);
|
|
650
|
+
}(TemplateError);
|
|
651
|
+
var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
|
|
652
|
+
function TemplateSyntaxError() {
|
|
653
|
+
var _this3;
|
|
654
|
+
_classCallCheck(this, TemplateSyntaxError);
|
|
655
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
656
|
+
args[_key2] = arguments[_key2];
|
|
657
|
+
}
|
|
658
|
+
_this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
|
|
659
|
+
_defineProperty(_this3, "code", 500);
|
|
660
|
+
return _this3;
|
|
661
|
+
}
|
|
662
|
+
_inherits(TemplateSyntaxError, _TemplateError3);
|
|
663
|
+
return _createClass(TemplateSyntaxError);
|
|
664
|
+
}(TemplateError);
|
|
444
665
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
code: 1
|
|
666
|
+
function resolve(list) {
|
|
667
|
+
return Promise.all(list || []).then(function (list) {
|
|
668
|
+
return list.join('');
|
|
669
|
+
})["catch"](function (e) {
|
|
670
|
+
return e;
|
|
451
671
|
});
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
672
|
+
}
|
|
673
|
+
function reject(error) {
|
|
674
|
+
return Promise.reject(new TemplateSyntaxError(error.message));
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
*
|
|
679
|
+
* @return {buffer}
|
|
680
|
+
*/
|
|
681
|
+
function createBuffer() {
|
|
682
|
+
var store = [],
|
|
683
|
+
array = [];
|
|
684
|
+
var buffer = function buffer(value) {
|
|
685
|
+
array.push(value);
|
|
458
686
|
};
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
* @return {string}
|
|
462
|
-
*/
|
|
463
|
-
TemplateError.prototype.getMessage = function () {
|
|
464
|
-
return this.message;
|
|
687
|
+
buffer.start = function () {
|
|
688
|
+
array = [];
|
|
465
689
|
};
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
TemplateError.prototype.toString = function () {
|
|
470
|
-
return this.getMessage();
|
|
690
|
+
buffer.backup = function () {
|
|
691
|
+
store.push(array.concat());
|
|
692
|
+
array = [];
|
|
471
693
|
};
|
|
694
|
+
buffer.restore = function () {
|
|
695
|
+
var result = array.concat();
|
|
696
|
+
array = store.pop();
|
|
697
|
+
return resolve(result);
|
|
698
|
+
};
|
|
699
|
+
buffer.error = function (e) {
|
|
700
|
+
return reject(e);
|
|
701
|
+
};
|
|
702
|
+
buffer.end = function () {
|
|
703
|
+
return resolve(array);
|
|
704
|
+
};
|
|
705
|
+
return buffer;
|
|
706
|
+
}
|
|
472
707
|
|
|
708
|
+
var createContextScope = function createContextScope(config, methods) {
|
|
709
|
+
var _Object$definePropert;
|
|
710
|
+
var _config$vars = config.vars,
|
|
711
|
+
BLOCKS = _config$vars.BLOCKS,
|
|
712
|
+
MACRO = _config$vars.MACRO,
|
|
713
|
+
EXTEND = _config$vars.EXTEND,
|
|
714
|
+
LAYOUT = _config$vars.LAYOUT,
|
|
715
|
+
BUFFER = _config$vars.BUFFER,
|
|
716
|
+
SAFE = _config$vars.SAFE,
|
|
717
|
+
SCOPE = _config$vars.SCOPE,
|
|
718
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
719
|
+
ELEMENT = _config$vars.ELEMENT;
|
|
473
720
|
/**
|
|
474
|
-
* @
|
|
475
|
-
* @param
|
|
476
|
-
* @constructor
|
|
477
|
-
*/
|
|
478
|
-
function TemplateNotFound(message) {
|
|
479
|
-
TemplateError.call(this);
|
|
480
|
-
this.name = 'TemplateNotFound';
|
|
481
|
-
this.message = message;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
*
|
|
486
|
-
*/
|
|
487
|
-
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
488
|
-
Object.assign(TemplateNotFound.prototype, {
|
|
489
|
-
code: 404
|
|
490
|
-
});
|
|
491
|
-
/**
|
|
492
|
-
* @extends TemplateError
|
|
493
|
-
* @param {string} message
|
|
721
|
+
* @name ContextScope
|
|
722
|
+
* @param data
|
|
494
723
|
* @constructor
|
|
495
724
|
*/
|
|
496
|
-
function
|
|
497
|
-
|
|
498
|
-
this
|
|
499
|
-
this
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
*
|
|
504
|
-
*/
|
|
505
|
-
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
506
|
-
Object.assign(TemplateSyntaxError.prototype, {
|
|
507
|
-
code: 500
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
function resolve(list) {
|
|
511
|
-
return Promise.all(list || []).then(function (list) {
|
|
512
|
-
return list.join('');
|
|
513
|
-
})["catch"](function (e) {
|
|
514
|
-
return e;
|
|
515
|
-
});
|
|
725
|
+
function ContextScope(data) {
|
|
726
|
+
this[BLOCKS] = {};
|
|
727
|
+
this[MACRO] = {};
|
|
728
|
+
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
516
729
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
this
|
|
559
|
-
|
|
730
|
+
Object.assign(ContextScope.prototype, methods);
|
|
731
|
+
Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
|
|
732
|
+
value: createBuffer()
|
|
733
|
+
}), BLOCKS, {
|
|
734
|
+
value: {},
|
|
735
|
+
writable: true
|
|
736
|
+
}), MACRO, {
|
|
737
|
+
value: {},
|
|
738
|
+
writable: true
|
|
739
|
+
}), LAYOUT, {
|
|
740
|
+
value: false,
|
|
741
|
+
writable: true
|
|
742
|
+
}), EXTEND, {
|
|
743
|
+
value: false,
|
|
744
|
+
writable: true
|
|
745
|
+
}), "useSafeValue", {
|
|
746
|
+
get: function get() {
|
|
747
|
+
return safeValue;
|
|
748
|
+
}
|
|
749
|
+
}), "useComponent", {
|
|
750
|
+
get: function get() {
|
|
751
|
+
if (isFunction(this[COMPONENT])) {
|
|
752
|
+
return this[COMPONENT].bind(this);
|
|
753
|
+
} else {
|
|
754
|
+
return function () {
|
|
755
|
+
throw new Error("".concat(COMPONENT, " must be a function"));
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}), "useElement", {
|
|
760
|
+
get: function get() {
|
|
761
|
+
if (isFunction(this[ELEMENT])) {
|
|
762
|
+
return this[ELEMENT].bind(this);
|
|
763
|
+
} else {
|
|
764
|
+
return function () {
|
|
765
|
+
throw new Error("".concat(ELEMENT, " must be a function"));
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}), "getMacro", {
|
|
770
|
+
value: function value() {
|
|
771
|
+
return this[MACRO];
|
|
772
|
+
}
|
|
773
|
+
}), "getBuffer", {
|
|
774
|
+
value: function value() {
|
|
775
|
+
return this[BUFFER];
|
|
776
|
+
}
|
|
777
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
|
|
778
|
+
value: function value() {
|
|
779
|
+
return this[BLOCKS];
|
|
780
|
+
}
|
|
781
|
+
}), "setExtend", {
|
|
782
|
+
value: function value(_value) {
|
|
783
|
+
this[EXTEND] = _value;
|
|
784
|
+
}
|
|
785
|
+
}), "getExtend", {
|
|
786
|
+
value: function value() {
|
|
787
|
+
return this[EXTEND];
|
|
788
|
+
}
|
|
789
|
+
}), "setLayout", {
|
|
790
|
+
value: function value(layout) {
|
|
791
|
+
this[LAYOUT] = layout;
|
|
792
|
+
}
|
|
793
|
+
}), "getLayout", {
|
|
794
|
+
value: function value() {
|
|
795
|
+
return this[LAYOUT];
|
|
796
|
+
}
|
|
797
|
+
}), "clone", {
|
|
798
|
+
value: function value(exclude_blocks) {
|
|
799
|
+
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
800
|
+
if (exclude_blocks === true) {
|
|
801
|
+
filter.push(BLOCKS);
|
|
802
|
+
}
|
|
803
|
+
return omit(this, filter);
|
|
804
|
+
}
|
|
805
|
+
}), "extend", {
|
|
806
|
+
value: function value(layout) {
|
|
807
|
+
this.setExtend(true);
|
|
808
|
+
this.setLayout(layout);
|
|
809
|
+
}
|
|
810
|
+
}), "echo", {
|
|
811
|
+
value: function value(layout) {
|
|
812
|
+
var buffer = this.getBuffer();
|
|
813
|
+
var params = [].slice.call(arguments);
|
|
814
|
+
params.forEach(buffer);
|
|
815
|
+
}
|
|
816
|
+
}), "fn", {
|
|
817
|
+
value: function value(callback) {
|
|
818
|
+
var buffer = this.getBuffer();
|
|
819
|
+
var context = this;
|
|
820
|
+
return function () {
|
|
821
|
+
if (isFunction(callback)) {
|
|
822
|
+
buffer.backup();
|
|
823
|
+
buffer(callback.apply(context, arguments));
|
|
824
|
+
return buffer.restore();
|
|
825
|
+
}
|
|
560
826
|
};
|
|
561
|
-
|
|
562
|
-
|
|
827
|
+
}
|
|
828
|
+
}), "macro", {
|
|
829
|
+
value: function value(name, callback) {
|
|
830
|
+
var list = this.getMacro();
|
|
831
|
+
var macro = this.fn(callback);
|
|
832
|
+
var context = this;
|
|
833
|
+
list[name] = function () {
|
|
834
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
563
835
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
extend(this, data || {});
|
|
836
|
+
}
|
|
837
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
838
|
+
value: function value(name) {
|
|
839
|
+
var list = this.getMacro();
|
|
840
|
+
var macro = list[name];
|
|
841
|
+
var params = [].slice.call(arguments, 1);
|
|
842
|
+
if (isFunction(macro)) {
|
|
843
|
+
return macro.apply(macro, params);
|
|
573
844
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
enumerable: false
|
|
590
|
-
}), LAYOUT, {
|
|
591
|
-
value: false,
|
|
592
|
-
writable: true,
|
|
593
|
-
configurable: false,
|
|
594
|
-
enumerable: false
|
|
595
|
-
}), EXTEND, {
|
|
596
|
-
value: false,
|
|
597
|
-
writable: true,
|
|
598
|
-
configurable: false,
|
|
599
|
-
enumerable: false
|
|
600
|
-
}), "getMacro", {
|
|
601
|
-
value: function value() {
|
|
602
|
-
return this[MACRO];
|
|
603
|
-
},
|
|
604
|
-
writable: false,
|
|
605
|
-
configurable: false,
|
|
606
|
-
enumerable: false
|
|
607
|
-
}), "getBuffer", {
|
|
608
|
-
value: function value() {
|
|
609
|
-
return this[BUFFER];
|
|
610
|
-
},
|
|
611
|
-
writable: false,
|
|
612
|
-
configurable: false,
|
|
613
|
-
enumerable: false
|
|
614
|
-
}), "getComponent", {
|
|
615
|
-
value: function value() {
|
|
616
|
-
var context = this;
|
|
617
|
-
if (COMPONENT in context) {
|
|
618
|
-
return function () {
|
|
619
|
-
return context[COMPONENT].apply(context, arguments);
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
return function () {
|
|
623
|
-
console.log('%s function not defined', COMPONENT);
|
|
624
|
-
};
|
|
625
|
-
},
|
|
626
|
-
writable: false,
|
|
627
|
-
configurable: false,
|
|
628
|
-
enumerable: false
|
|
629
|
-
}), "getBlocks", {
|
|
630
|
-
value: function value() {
|
|
631
|
-
return this[BLOCKS];
|
|
632
|
-
},
|
|
633
|
-
writable: false,
|
|
634
|
-
configurable: false,
|
|
635
|
-
enumerable: false
|
|
636
|
-
}), "setExtend", {
|
|
637
|
-
value: function value(_value) {
|
|
638
|
-
this[EXTEND] = _value;
|
|
639
|
-
},
|
|
640
|
-
writable: false,
|
|
641
|
-
configurable: false,
|
|
642
|
-
enumerable: false
|
|
643
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getExtend", {
|
|
644
|
-
value: function value() {
|
|
645
|
-
return this[EXTEND];
|
|
646
|
-
},
|
|
647
|
-
writable: false,
|
|
648
|
-
configurable: false,
|
|
649
|
-
enumerable: false
|
|
650
|
-
}), "setLayout", {
|
|
651
|
-
value: function value(layout) {
|
|
652
|
-
this[LAYOUT] = layout;
|
|
653
|
-
},
|
|
654
|
-
writable: false,
|
|
655
|
-
configurable: false,
|
|
656
|
-
enumerable: false
|
|
657
|
-
}), "getLayout", {
|
|
658
|
-
value: function value() {
|
|
659
|
-
return this[LAYOUT];
|
|
660
|
-
},
|
|
661
|
-
writable: false,
|
|
662
|
-
configurable: false,
|
|
663
|
-
enumerable: false
|
|
664
|
-
}), "clone", {
|
|
665
|
-
value: function value(exclude_blocks) {
|
|
666
|
-
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
667
|
-
if (exclude_blocks === true) {
|
|
668
|
-
filter.push(BLOCKS);
|
|
669
|
-
}
|
|
670
|
-
return omit(this, filter);
|
|
671
|
-
},
|
|
672
|
-
writable: false,
|
|
673
|
-
configurable: false,
|
|
674
|
-
enumerable: false
|
|
675
|
-
}), "extend", {
|
|
676
|
-
value: function value(layout) {
|
|
677
|
-
this.setExtend(true);
|
|
678
|
-
this.setLayout(layout);
|
|
679
|
-
},
|
|
680
|
-
writable: false,
|
|
681
|
-
configurable: false,
|
|
682
|
-
enumerable: false
|
|
683
|
-
}), "echo", {
|
|
684
|
-
value: function value(layout) {
|
|
685
|
-
var buffer = this.getBuffer();
|
|
686
|
-
var params = [].slice.call(arguments);
|
|
687
|
-
params.forEach(buffer);
|
|
688
|
-
},
|
|
689
|
-
writable: false,
|
|
690
|
-
configurable: false,
|
|
691
|
-
enumerable: false
|
|
692
|
-
}), "fn", {
|
|
693
|
-
value: function value(callback) {
|
|
694
|
-
var buffer = this.getBuffer();
|
|
695
|
-
var context = this;
|
|
845
|
+
}
|
|
846
|
+
}), "block", {
|
|
847
|
+
value: function value(name, callback) {
|
|
848
|
+
var _this = this;
|
|
849
|
+
var blocks = this.getBlocks();
|
|
850
|
+
blocks[name] = blocks[name] || [];
|
|
851
|
+
blocks[name].push(this.fn(callback));
|
|
852
|
+
if (this.getExtend()) return;
|
|
853
|
+
var list = Object.assign([], blocks[name]);
|
|
854
|
+
var current = function current() {
|
|
855
|
+
return list.shift();
|
|
856
|
+
};
|
|
857
|
+
var _next = function next() {
|
|
858
|
+
var parent = current();
|
|
859
|
+
if (parent) {
|
|
696
860
|
return function () {
|
|
697
|
-
|
|
698
|
-
if (isFunction(callback)) {
|
|
699
|
-
callback.apply(context, arguments);
|
|
700
|
-
}
|
|
701
|
-
return buffer.restore();
|
|
702
|
-
};
|
|
703
|
-
},
|
|
704
|
-
writable: false,
|
|
705
|
-
configurable: false,
|
|
706
|
-
enumerable: false
|
|
707
|
-
}), "get", {
|
|
708
|
-
value: function value(name, defaults) {
|
|
709
|
-
var path = getPath(this, name, true);
|
|
710
|
-
var result = path.shift();
|
|
711
|
-
var prop = path.pop();
|
|
712
|
-
return hasProp(result, prop) ? result[prop] : defaults;
|
|
713
|
-
},
|
|
714
|
-
writable: true,
|
|
715
|
-
configurable: true,
|
|
716
|
-
enumerable: false
|
|
717
|
-
}), "set", {
|
|
718
|
-
value: function value(name, _value2) {
|
|
719
|
-
var path = getPath(this, name, false);
|
|
720
|
-
var result = path.shift();
|
|
721
|
-
var prop = path.pop();
|
|
722
|
-
if (this.getExtend() && hasProp(result, prop)) {
|
|
723
|
-
return result[prop];
|
|
724
|
-
}
|
|
725
|
-
return result[prop] = _value2;
|
|
726
|
-
},
|
|
727
|
-
writable: false,
|
|
728
|
-
configurable: false,
|
|
729
|
-
enumerable: false
|
|
730
|
-
}), "macro", {
|
|
731
|
-
value: function value(name, callback) {
|
|
732
|
-
var list = this.getMacro();
|
|
733
|
-
var macro = this.fn(callback);
|
|
734
|
-
var context = this;
|
|
735
|
-
list[name] = function () {
|
|
736
|
-
return context.echo(macro.apply(undefined, arguments));
|
|
861
|
+
_this.echo(parent(_next()));
|
|
737
862
|
};
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
configurable: false,
|
|
815
|
-
enumerable: false
|
|
816
|
-
}), "async", {
|
|
817
|
-
value: function value(promise, callback) {
|
|
818
|
-
this.echo(this.promiseResolve(promise, function (data) {
|
|
819
|
-
return this.fn(callback)(data);
|
|
820
|
-
}));
|
|
821
|
-
},
|
|
822
|
-
writable: false,
|
|
823
|
-
configurable: false,
|
|
824
|
-
enumerable: false
|
|
825
|
-
}), "each", {
|
|
826
|
-
value: function value(object, callback) {
|
|
827
|
-
if (isString(object)) {
|
|
828
|
-
object = this.get(object, []);
|
|
829
|
-
}
|
|
830
|
-
each(object, callback);
|
|
831
|
-
},
|
|
832
|
-
writable: false,
|
|
833
|
-
configurable: false,
|
|
834
|
-
enumerable: false
|
|
835
|
-
}), "element", {
|
|
836
|
-
value: function value(tag, attr, content) {
|
|
837
|
-
return element(tag, attr, content);
|
|
838
|
-
},
|
|
839
|
-
writable: false,
|
|
840
|
-
configurable: false,
|
|
841
|
-
enumerable: false
|
|
842
|
-
}), "el", {
|
|
843
|
-
value: function value(tag, attr, content) {
|
|
844
|
-
this.echo(this.promiseResolve(content, function (content) {
|
|
845
|
-
return this.element(tag, attr, content);
|
|
846
|
-
}));
|
|
847
|
-
},
|
|
848
|
-
writable: false,
|
|
849
|
-
configurable: false,
|
|
850
|
-
enumerable: false
|
|
851
|
-
})));
|
|
852
|
-
};
|
|
853
|
-
this.configure(config);
|
|
863
|
+
} else {
|
|
864
|
+
return noop;
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
this.echo(current()(_next()));
|
|
868
|
+
}
|
|
869
|
+
}), "hasBlock", {
|
|
870
|
+
value: function value(name) {
|
|
871
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
872
|
+
}
|
|
873
|
+
}), "include", {
|
|
874
|
+
value: function value(path, data, cx) {
|
|
875
|
+
var context = cx === false ? {} : this.clone(true);
|
|
876
|
+
var params = extend(context, data || {});
|
|
877
|
+
var promise = this.render(path, params);
|
|
878
|
+
this.echo(promise);
|
|
879
|
+
}
|
|
880
|
+
}), "use", {
|
|
881
|
+
value: function value(path, namespace) {
|
|
882
|
+
var _this2 = this;
|
|
883
|
+
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
884
|
+
var list = _this2.getMacro();
|
|
885
|
+
each(exports, function (macro, name) {
|
|
886
|
+
list[[namespace, name].join('.')] = macro;
|
|
887
|
+
});
|
|
888
|
+
}));
|
|
889
|
+
}
|
|
890
|
+
}), "async", {
|
|
891
|
+
value: function value(promise, callback) {
|
|
892
|
+
this.echo(Promise.resolve(promise).then(callback));
|
|
893
|
+
}
|
|
894
|
+
}), "get", {
|
|
895
|
+
value: function value(name, defaults) {
|
|
896
|
+
var path = getPath(this, name, true);
|
|
897
|
+
var result = path.shift();
|
|
898
|
+
var prop = path.pop();
|
|
899
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
900
|
+
}
|
|
901
|
+
}), "set", {
|
|
902
|
+
value: function value(name, _value2) {
|
|
903
|
+
var path = getPath(this, name, false);
|
|
904
|
+
var result = path.shift();
|
|
905
|
+
var prop = path.pop();
|
|
906
|
+
if (this.getExtend() && hasProp(result, prop)) {
|
|
907
|
+
return result[prop];
|
|
908
|
+
}
|
|
909
|
+
return result[prop] = _value2;
|
|
910
|
+
}
|
|
911
|
+
}), "each", {
|
|
912
|
+
value: function value(object, callback) {
|
|
913
|
+
if (isString(object)) {
|
|
914
|
+
object = this.get(object, []);
|
|
915
|
+
}
|
|
916
|
+
each(object, callback);
|
|
917
|
+
},
|
|
918
|
+
writable: true
|
|
919
|
+
}), "el", {
|
|
920
|
+
value: function value(tag, attr, content) {
|
|
921
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
922
|
+
this.echo(Promise.resolve(content).then(function (content) {
|
|
923
|
+
return element(tag, attr, content);
|
|
924
|
+
}));
|
|
925
|
+
},
|
|
926
|
+
writable: true
|
|
927
|
+
}), _defineProperty(_Object$definePropert, "ui", {
|
|
928
|
+
value: function value(layout) {},
|
|
929
|
+
writable: true
|
|
930
|
+
})));
|
|
931
|
+
return ContextScope;
|
|
932
|
+
};
|
|
933
|
+
var _scope = /*#__PURE__*/new WeakMap();
|
|
934
|
+
var Context = /*#__PURE__*/function () {
|
|
935
|
+
function Context(config, methods) {
|
|
936
|
+
_classCallCheck(this, Context);
|
|
937
|
+
_classPrivateFieldInitSpec(this, _scope, void 0);
|
|
938
|
+
this.configure(config, methods);
|
|
854
939
|
}
|
|
940
|
+
return _createClass(Context, [{
|
|
941
|
+
key: "create",
|
|
942
|
+
value: function create(data) {
|
|
943
|
+
return new (_classPrivateFieldGet2(_scope, this))(data);
|
|
944
|
+
}
|
|
945
|
+
}, {
|
|
946
|
+
key: "configure",
|
|
947
|
+
value: function configure(config, methods) {
|
|
948
|
+
_classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
|
|
949
|
+
}
|
|
950
|
+
}, {
|
|
951
|
+
key: "helpers",
|
|
952
|
+
value: function helpers(methods) {
|
|
953
|
+
extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
|
|
954
|
+
}
|
|
955
|
+
}]);
|
|
956
|
+
}();
|
|
855
957
|
|
|
958
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
959
|
+
var _extend = /*#__PURE__*/new WeakMap();
|
|
960
|
+
var _context = /*#__PURE__*/new WeakMap();
|
|
961
|
+
var _compiler = /*#__PURE__*/new WeakMap();
|
|
962
|
+
var _cache = /*#__PURE__*/new WeakMap();
|
|
963
|
+
var _template = /*#__PURE__*/new WeakMap();
|
|
964
|
+
var _EJS_brand = /*#__PURE__*/new WeakSet();
|
|
965
|
+
var EJS = /*#__PURE__*/function () {
|
|
856
966
|
function EJS(options) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
return
|
|
967
|
+
_classCallCheck(this, EJS);
|
|
968
|
+
_classPrivateMethodInitSpec(this, _EJS_brand);
|
|
969
|
+
_classPrivateFieldInitSpec(this, _config, {});
|
|
970
|
+
_classPrivateFieldInitSpec(this, _extend, {});
|
|
971
|
+
_classPrivateFieldInitSpec(this, _context, void 0);
|
|
972
|
+
_classPrivateFieldInitSpec(this, _compiler, void 0);
|
|
973
|
+
_classPrivateFieldInitSpec(this, _cache, void 0);
|
|
974
|
+
_classPrivateFieldInitSpec(this, _template, void 0);
|
|
975
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
976
|
+
_classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
|
|
977
|
+
_classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
|
|
978
|
+
_classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
|
|
979
|
+
_classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
980
|
+
//
|
|
981
|
+
bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
|
|
982
|
+
//
|
|
983
|
+
this.helpers({
|
|
984
|
+
require: this.require,
|
|
985
|
+
render: this.render
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
return _createClass(EJS, [{
|
|
989
|
+
key: "configure",
|
|
990
|
+
value: function configure(options) {
|
|
991
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
992
|
+
_classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
|
|
993
|
+
_classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
|
|
994
|
+
_classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
|
|
995
|
+
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
996
|
+
return _classPrivateFieldGet2(_config, this);
|
|
997
|
+
}
|
|
998
|
+
}, {
|
|
999
|
+
key: "render",
|
|
1000
|
+
value: function render(name, data) {
|
|
1001
|
+
var _this = this;
|
|
1002
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1003
|
+
var scope = this.context(data);
|
|
1004
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function (content) {
|
|
887
1005
|
if (scope.getExtend()) {
|
|
888
1006
|
scope.setExtend(false);
|
|
889
1007
|
var layout = scope.getLayout();
|
|
890
1008
|
var _data = scope.clone();
|
|
891
|
-
return
|
|
1009
|
+
return _this.render(layout, _data);
|
|
892
1010
|
}
|
|
893
1011
|
return content;
|
|
894
1012
|
});
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1013
|
+
}
|
|
1014
|
+
}, {
|
|
1015
|
+
key: "helpers",
|
|
1016
|
+
value: function helpers(methods) {
|
|
1017
|
+
_classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
|
|
1018
|
+
}
|
|
1019
|
+
}, {
|
|
1020
|
+
key: "context",
|
|
1021
|
+
value: function context(data) {
|
|
1022
|
+
return _classPrivateFieldGet2(_context, this).create(data);
|
|
1023
|
+
}
|
|
1024
|
+
}, {
|
|
1025
|
+
key: "compile",
|
|
1026
|
+
value: function compile(content, path) {
|
|
1027
|
+
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
1028
|
+
}
|
|
1029
|
+
}, {
|
|
1030
|
+
key: "preload",
|
|
1031
|
+
value: function preload(list) {
|
|
1032
|
+
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
1033
|
+
}
|
|
1034
|
+
}, {
|
|
1035
|
+
key: "create",
|
|
1036
|
+
value: function create(options) {
|
|
1037
|
+
return new this.constructor(options);
|
|
1038
|
+
}
|
|
1039
|
+
}, {
|
|
1040
|
+
key: "require",
|
|
1041
|
+
value: function require(name) {
|
|
1042
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1043
|
+
var scope = this.context({});
|
|
1044
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1045
|
+
return scope.getMacro();
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
}]);
|
|
1049
|
+
}();
|
|
1050
|
+
function _output(path, scope) {
|
|
1051
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1052
|
+
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1053
|
+
var params = [scope, scope.getBuffer(), scope.useSafeValue, scope.useComponent, scope.useElement].concat(globalHelpers.filter(function (name) {
|
|
1054
|
+
return isFunction(scope[name]);
|
|
1055
|
+
}).map(function (name) {
|
|
1056
|
+
return scope[name].bind(scope);
|
|
1057
|
+
}));
|
|
1058
|
+
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1059
|
+
return callback.apply(scope, params);
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
929
1062
|
|
|
930
|
-
|
|
1063
|
+
var path = {};
|
|
931
1064
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
});
|
|
1065
|
+
function readFile(path$1, template) {
|
|
1066
|
+
return new Promise(function (resolve, reject) {
|
|
1067
|
+
path.readFile(joinPath(path$1, template), function (error, data) {
|
|
1068
|
+
if (error) {
|
|
1069
|
+
reject(new TemplateError(error));
|
|
1070
|
+
} else {
|
|
1071
|
+
resolve(data.toString());
|
|
1072
|
+
}
|
|
941
1073
|
});
|
|
942
|
-
}
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
943
1076
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
};
|
|
970
|
-
}
|
|
1077
|
+
/**
|
|
1078
|
+
*
|
|
1079
|
+
* @param {function(config: object):object} configure
|
|
1080
|
+
* @param {function(name: string, data?: object):Promise<string>} render
|
|
1081
|
+
* @return {function(name:any, options:any, callback: any): Promise<void>}
|
|
1082
|
+
*/
|
|
1083
|
+
function expressRenderer(configure, render) {
|
|
1084
|
+
return function (name, options, callback) {
|
|
1085
|
+
if (isFunction(options)) {
|
|
1086
|
+
callback = options;
|
|
1087
|
+
options = {};
|
|
1088
|
+
}
|
|
1089
|
+
options = options || {};
|
|
1090
|
+
var settings = extend({}, options.settings);
|
|
1091
|
+
var viewPath = typeProp(isString, defaults.path, settings['views']);
|
|
1092
|
+
var viewCache = typeProp(isBoolean, defaults.cache, settings['view cache']);
|
|
1093
|
+
var viewOptions = extend({}, settings['view options']);
|
|
1094
|
+
var filename = path.relative(viewPath, name);
|
|
1095
|
+
viewOptions.path = viewPath;
|
|
1096
|
+
viewOptions.cache = viewCache;
|
|
1097
|
+
configure(viewOptions);
|
|
1098
|
+
return render(filename, options).then(function (content) {
|
|
1099
|
+
callback(null, content);
|
|
1100
|
+
})["catch"](function (error) {
|
|
1101
|
+
callback(error);
|
|
1102
|
+
});
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
971
1105
|
|
|
972
|
-
|
|
1106
|
+
var _EJS = new EJS({
|
|
973
1107
|
resolver: readFile
|
|
974
|
-
})
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1108
|
+
}),
|
|
1109
|
+
render = _EJS.render,
|
|
1110
|
+
context = _EJS.context,
|
|
1111
|
+
compile = _EJS.compile,
|
|
1112
|
+
helpers = _EJS.helpers,
|
|
1113
|
+
preload = _EJS.preload,
|
|
1114
|
+
configure = _EJS.configure,
|
|
1115
|
+
create = _EJS.create;
|
|
1116
|
+
var __express = expressRenderer(configure, render);
|
|
983
1117
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1118
|
+
exports.TemplateError = TemplateError;
|
|
1119
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
1120
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
1121
|
+
exports.__express = __express;
|
|
1122
|
+
exports.compile = compile;
|
|
1123
|
+
exports.configure = configure;
|
|
1124
|
+
exports.context = context;
|
|
1125
|
+
exports.create = create;
|
|
1126
|
+
exports.helpers = helpers;
|
|
1127
|
+
exports.preload = preload;
|
|
1128
|
+
exports.render = render;
|
|
995
1129
|
|
|
996
1130
|
}));
|