@kosatyi/ejs 0.0.98 → 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 +82 -223
- package/dist/cjs/index.js +82 -223
- package/dist/cjs/worker.js +82 -223
- package/dist/esm/browser.js +96 -237
- package/dist/esm/index.js +96 -237
- package/dist/esm/worker.js +96 -237
- package/dist/umd/browser.js +82 -223
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/index.js +82 -223
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +82 -223
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/ejs.d.ts +26 -26
package/dist/umd/index.js
CHANGED
|
@@ -337,6 +337,7 @@
|
|
|
337
337
|
defaults.vars = {
|
|
338
338
|
SCOPE: 'ejs',
|
|
339
339
|
COMPONENT: 'ui',
|
|
340
|
+
ELEMENT: 'el',
|
|
340
341
|
EXTEND: '$$e',
|
|
341
342
|
BUFFER: '$$a',
|
|
342
343
|
LAYOUT: '$$l',
|
|
@@ -373,7 +374,6 @@
|
|
|
373
374
|
_classCallCheck(this, Cache);
|
|
374
375
|
_classPrivateFieldInitSpec(this, _enabled, true);
|
|
375
376
|
_classPrivateFieldInitSpec(this, _list, {});
|
|
376
|
-
bindContext(this, ['configure']);
|
|
377
377
|
this.configure(config);
|
|
378
378
|
}
|
|
379
379
|
return _createClass(Cache, [{
|
|
@@ -455,7 +455,6 @@
|
|
|
455
455
|
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
456
456
|
}
|
|
457
457
|
}]);
|
|
458
|
-
bindContext(this, ['configure', 'compile']);
|
|
459
458
|
this.configure(config);
|
|
460
459
|
}
|
|
461
460
|
return _createClass(Compiler, [{
|
|
@@ -490,7 +489,8 @@
|
|
|
490
489
|
SCOPE = _classPrivateFieldGet2$1.SCOPE,
|
|
491
490
|
SAFE = _classPrivateFieldGet2$1.SAFE,
|
|
492
491
|
BUFFER = _classPrivateFieldGet2$1.BUFFER,
|
|
493
|
-
COMPONENT = _classPrivateFieldGet2$1.COMPONENT
|
|
492
|
+
COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
|
|
493
|
+
ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
|
|
494
494
|
var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
|
|
495
495
|
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
496
496
|
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
514
514
|
source += "\n//# sourceURL=".concat(path);
|
|
515
515
|
var result = null;
|
|
516
|
-
var params = [SCOPE,
|
|
516
|
+
var params = [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT].concat(GLOBALS);
|
|
517
517
|
try {
|
|
518
518
|
result = Function.apply(null, params.concat(source));
|
|
519
519
|
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
@@ -544,7 +544,6 @@
|
|
|
544
544
|
assertInstanceOf(compiler, Compiler);
|
|
545
545
|
_classPrivateFieldSet2(_cache$1, this, cache);
|
|
546
546
|
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
547
|
-
bindContext(this, ['configure', 'get']);
|
|
548
547
|
this.configure(config);
|
|
549
548
|
}
|
|
550
549
|
return _createClass(Template, [{
|
|
@@ -706,7 +705,7 @@
|
|
|
706
705
|
return buffer;
|
|
707
706
|
}
|
|
708
707
|
|
|
709
|
-
var
|
|
708
|
+
var createContextScope = function createContextScope(config, methods) {
|
|
710
709
|
var _Object$definePropert;
|
|
711
710
|
var _config$vars = config.vars,
|
|
712
711
|
BLOCKS = _config$vars.BLOCKS,
|
|
@@ -714,9 +713,10 @@
|
|
|
714
713
|
EXTEND = _config$vars.EXTEND,
|
|
715
714
|
LAYOUT = _config$vars.LAYOUT,
|
|
716
715
|
BUFFER = _config$vars.BUFFER,
|
|
717
|
-
COMPONENT = _config$vars.COMPONENT,
|
|
718
716
|
SAFE = _config$vars.SAFE,
|
|
719
|
-
SCOPE = _config$vars.SCOPE
|
|
717
|
+
SCOPE = _config$vars.SCOPE,
|
|
718
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
719
|
+
ELEMENT = _config$vars.ELEMENT;
|
|
720
720
|
/**
|
|
721
721
|
* @name ContextScope
|
|
722
722
|
* @param data
|
|
@@ -725,7 +725,7 @@
|
|
|
725
725
|
function ContextScope(data) {
|
|
726
726
|
this[BLOCKS] = {};
|
|
727
727
|
this[MACRO] = {};
|
|
728
|
-
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT]));
|
|
728
|
+
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
729
729
|
}
|
|
730
730
|
Object.assign(ContextScope.prototype, methods);
|
|
731
731
|
Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
|
|
@@ -742,6 +742,30 @@
|
|
|
742
742
|
}), EXTEND, {
|
|
743
743
|
value: false,
|
|
744
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
|
+
}
|
|
745
769
|
}), "getMacro", {
|
|
746
770
|
value: function value() {
|
|
747
771
|
return this[MACRO];
|
|
@@ -750,19 +774,7 @@
|
|
|
750
774
|
value: function value() {
|
|
751
775
|
return this[BUFFER];
|
|
752
776
|
}
|
|
753
|
-
}), "
|
|
754
|
-
value: function value() {
|
|
755
|
-
var context = this;
|
|
756
|
-
if (COMPONENT in context) {
|
|
757
|
-
return function () {
|
|
758
|
-
return context[COMPONENT].apply(context, arguments);
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
return function () {
|
|
762
|
-
console.log('%s function not defined', COMPONENT);
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
}), "getBlocks", {
|
|
777
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
|
|
766
778
|
value: function value() {
|
|
767
779
|
return this[BLOCKS];
|
|
768
780
|
}
|
|
@@ -770,7 +782,7 @@
|
|
|
770
782
|
value: function value(_value) {
|
|
771
783
|
this[EXTEND] = _value;
|
|
772
784
|
}
|
|
773
|
-
}),
|
|
785
|
+
}), "getExtend", {
|
|
774
786
|
value: function value() {
|
|
775
787
|
return this[EXTEND];
|
|
776
788
|
}
|
|
@@ -806,30 +818,13 @@
|
|
|
806
818
|
var buffer = this.getBuffer();
|
|
807
819
|
var context = this;
|
|
808
820
|
return function () {
|
|
809
|
-
buffer.backup();
|
|
810
821
|
if (isFunction(callback)) {
|
|
811
|
-
|
|
822
|
+
buffer.backup();
|
|
823
|
+
buffer(callback.apply(context, arguments));
|
|
824
|
+
return buffer.restore();
|
|
812
825
|
}
|
|
813
|
-
return buffer.restore();
|
|
814
826
|
};
|
|
815
827
|
}
|
|
816
|
-
}), "get", {
|
|
817
|
-
value: function value(name, defaults) {
|
|
818
|
-
var path = getPath(this, name, true);
|
|
819
|
-
var result = path.shift();
|
|
820
|
-
var prop = path.pop();
|
|
821
|
-
return hasProp(result, prop) ? result[prop] : defaults;
|
|
822
|
-
}
|
|
823
|
-
}), "set", {
|
|
824
|
-
value: function value(name, _value2) {
|
|
825
|
-
var path = getPath(this, name, false);
|
|
826
|
-
var result = path.shift();
|
|
827
|
-
var prop = path.pop();
|
|
828
|
-
if (this.getExtend() && hasProp(result, prop)) {
|
|
829
|
-
return result[prop];
|
|
830
|
-
}
|
|
831
|
-
return result[prop] = _value2;
|
|
832
|
-
}
|
|
833
828
|
}), "macro", {
|
|
834
829
|
value: function value(name, callback) {
|
|
835
830
|
var list = this.getMacro();
|
|
@@ -882,14 +877,11 @@
|
|
|
882
877
|
var promise = this.render(path, params);
|
|
883
878
|
this.echo(promise);
|
|
884
879
|
}
|
|
885
|
-
}), "promiseResolve", {
|
|
886
|
-
value: function value(_value3, callback) {
|
|
887
|
-
return Promise.resolve(isFunction(_value3) ? this.fn(_value3)() : _value3).then(callback.bind(this));
|
|
888
|
-
}
|
|
889
880
|
}), "use", {
|
|
890
881
|
value: function value(path, namespace) {
|
|
891
|
-
|
|
892
|
-
|
|
882
|
+
var _this2 = this;
|
|
883
|
+
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
884
|
+
var list = _this2.getMacro();
|
|
893
885
|
each(exports, function (macro, name) {
|
|
894
886
|
list[[namespace, name].join('.')] = macro;
|
|
895
887
|
});
|
|
@@ -897,9 +889,24 @@
|
|
|
897
889
|
}
|
|
898
890
|
}), "async", {
|
|
899
891
|
value: function value(promise, callback) {
|
|
900
|
-
this.echo(
|
|
901
|
-
|
|
902
|
-
|
|
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;
|
|
903
910
|
}
|
|
904
911
|
}), "each", {
|
|
905
912
|
value: function value(object, callback) {
|
|
@@ -907,17 +914,19 @@
|
|
|
907
914
|
object = this.get(object, []);
|
|
908
915
|
}
|
|
909
916
|
each(object, callback);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
value: function value(tag, attr, content) {
|
|
913
|
-
return element(tag, attr, content);
|
|
914
|
-
}
|
|
917
|
+
},
|
|
918
|
+
writable: true
|
|
915
919
|
}), "el", {
|
|
916
920
|
value: function value(tag, attr, content) {
|
|
917
|
-
|
|
918
|
-
|
|
921
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
922
|
+
this.echo(Promise.resolve(content).then(function (content) {
|
|
923
|
+
return element(tag, attr, content);
|
|
919
924
|
}));
|
|
920
|
-
}
|
|
925
|
+
},
|
|
926
|
+
writable: true
|
|
927
|
+
}), _defineProperty(_Object$definePropert, "ui", {
|
|
928
|
+
value: function value(layout) {},
|
|
929
|
+
writable: true
|
|
921
930
|
})));
|
|
922
931
|
return ContextScope;
|
|
923
932
|
};
|
|
@@ -926,7 +935,6 @@
|
|
|
926
935
|
function Context(config, methods) {
|
|
927
936
|
_classCallCheck(this, Context);
|
|
928
937
|
_classPrivateFieldInitSpec(this, _scope, void 0);
|
|
929
|
-
bindContext(this, ['create', 'helpers', 'configure']);
|
|
930
938
|
this.configure(config, methods);
|
|
931
939
|
}
|
|
932
940
|
return _createClass(Context, [{
|
|
@@ -937,7 +945,7 @@
|
|
|
937
945
|
}, {
|
|
938
946
|
key: "configure",
|
|
939
947
|
value: function configure(config, methods) {
|
|
940
|
-
_classPrivateFieldSet2(_scope, this,
|
|
948
|
+
_classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
|
|
941
949
|
}
|
|
942
950
|
}, {
|
|
943
951
|
key: "helpers",
|
|
@@ -970,10 +978,10 @@
|
|
|
970
978
|
_classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
|
|
971
979
|
_classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
972
980
|
//
|
|
973
|
-
bindContext(this, ['configure', 'create', 'render', 'context', 'preload', 'compile', 'helpers']);
|
|
981
|
+
bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
|
|
974
982
|
//
|
|
975
983
|
this.helpers({
|
|
976
|
-
require:
|
|
984
|
+
require: this.require,
|
|
977
985
|
render: this.render
|
|
978
986
|
});
|
|
979
987
|
}
|
|
@@ -1028,163 +1036,21 @@
|
|
|
1028
1036
|
value: function create(options) {
|
|
1029
1037
|
return new this.constructor(options);
|
|
1030
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
|
+
}
|
|
1031
1048
|
}]);
|
|
1032
1049
|
}();
|
|
1033
|
-
|
|
1034
|
-
// export function EJS2(options) {
|
|
1035
|
-
// const self = {
|
|
1036
|
-
// config: {},
|
|
1037
|
-
// helpers: {},
|
|
1038
|
-
// /**
|
|
1039
|
-
// * @type {Context}
|
|
1040
|
-
// */
|
|
1041
|
-
// context: null,
|
|
1042
|
-
// /**
|
|
1043
|
-
// * @type {Compiler}
|
|
1044
|
-
// */
|
|
1045
|
-
// compiler: null,
|
|
1046
|
-
// /**
|
|
1047
|
-
// * @type {Template}
|
|
1048
|
-
// */
|
|
1049
|
-
// template: null,
|
|
1050
|
-
// /**
|
|
1051
|
-
// * @type {Cache}
|
|
1052
|
-
// */
|
|
1053
|
-
// cache: null,
|
|
1054
|
-
// }
|
|
1055
|
-
// /**
|
|
1056
|
-
// *
|
|
1057
|
-
// */
|
|
1058
|
-
// configSchema(self.config, options || {})
|
|
1059
|
-
// self.context = useContext(self.config, self.helpers)
|
|
1060
|
-
// self.compiler = useCompiler(self.config)
|
|
1061
|
-
// self.cache = useCache(self.config)
|
|
1062
|
-
// self.template = useTemplate(self.config, self.cache, self.compiler)
|
|
1063
|
-
// /**
|
|
1064
|
-
// *
|
|
1065
|
-
// * @param {string} path
|
|
1066
|
-
// * @param {ContextScope} scope
|
|
1067
|
-
// * @return {Promise<string>}
|
|
1068
|
-
// */
|
|
1069
|
-
// const output = (path, scope) => {
|
|
1070
|
-
// const { globalHelpers } = self.config
|
|
1071
|
-
// const params = [
|
|
1072
|
-
// scope,
|
|
1073
|
-
// scope.getComponent(),
|
|
1074
|
-
// scope.getBuffer(),
|
|
1075
|
-
// safeValue,
|
|
1076
|
-
// ].concat(
|
|
1077
|
-
// globalHelpers
|
|
1078
|
-
// .filter((name) => isFunction(scope[name]))
|
|
1079
|
-
// .map((name) => scope[name].bind(scope))
|
|
1080
|
-
// )
|
|
1081
|
-
// return self.template
|
|
1082
|
-
// .get(path)
|
|
1083
|
-
// .then((callback) => callback.apply(scope, params))
|
|
1084
|
-
// }
|
|
1085
|
-
// /**
|
|
1086
|
-
// *
|
|
1087
|
-
// * @param name
|
|
1088
|
-
// * @return {Promise<string>}
|
|
1089
|
-
// */
|
|
1090
|
-
// const require = (name) => {
|
|
1091
|
-
// const filepath = ext(name, self.config.extension)
|
|
1092
|
-
// const scope = context({})
|
|
1093
|
-
// return output(filepath, scope).then(() => scope.getMacro())
|
|
1094
|
-
// }
|
|
1095
|
-
// /**
|
|
1096
|
-
// *
|
|
1097
|
-
// * @param {string} name
|
|
1098
|
-
// * @param {{}} [data]
|
|
1099
|
-
// * @return {Promise<string>}
|
|
1100
|
-
// */
|
|
1101
|
-
// const render = (name, data) => {
|
|
1102
|
-
// const filepath = ext(name, self.config.extension)
|
|
1103
|
-
// const scope = context(data)
|
|
1104
|
-
// return output(filepath, scope).then((content) => {
|
|
1105
|
-
// if (scope.getExtend()) {
|
|
1106
|
-
// scope.setExtend(false)
|
|
1107
|
-
// const layout = scope.getLayout()
|
|
1108
|
-
// const data = scope.clone()
|
|
1109
|
-
// return render(layout, data)
|
|
1110
|
-
// }
|
|
1111
|
-
// return content
|
|
1112
|
-
// })
|
|
1113
|
-
// }
|
|
1114
|
-
// /**
|
|
1115
|
-
// *
|
|
1116
|
-
// * @param options
|
|
1117
|
-
// * @return {{}}
|
|
1118
|
-
// */
|
|
1119
|
-
// const configure = (options = {}) => {
|
|
1120
|
-
// configSchema(self.config, options || {})
|
|
1121
|
-
// self.context.configure(self.config, self.helpers)
|
|
1122
|
-
// self.compiler.configure(self.config)
|
|
1123
|
-
// self.cache.configure(self.config)
|
|
1124
|
-
// self.template.configure(self.config)
|
|
1125
|
-
// return self.config
|
|
1126
|
-
// }
|
|
1127
|
-
// /**
|
|
1128
|
-
// *
|
|
1129
|
-
// * @param methods
|
|
1130
|
-
// */
|
|
1131
|
-
// const helpers = (methods) => {
|
|
1132
|
-
// self.context.helpers(extend(self.helpers, methods))
|
|
1133
|
-
// }
|
|
1134
|
-
// /**
|
|
1135
|
-
// *
|
|
1136
|
-
// * @param list
|
|
1137
|
-
// * @return {*}
|
|
1138
|
-
// */
|
|
1139
|
-
// const preload = (list) => {
|
|
1140
|
-
// return self.cache.load(list || {})
|
|
1141
|
-
// }
|
|
1142
|
-
// /**
|
|
1143
|
-
// *
|
|
1144
|
-
// * @param options
|
|
1145
|
-
// * @return {any}
|
|
1146
|
-
// */
|
|
1147
|
-
// const create = (options) => {
|
|
1148
|
-
// return EJS(options)
|
|
1149
|
-
// }
|
|
1150
|
-
// /**
|
|
1151
|
-
// *
|
|
1152
|
-
// * @param content
|
|
1153
|
-
// * @param path
|
|
1154
|
-
// * @return {Function}
|
|
1155
|
-
// */
|
|
1156
|
-
// const compile = (content, path) => {
|
|
1157
|
-
// return self.compiler.compile(content, path)
|
|
1158
|
-
// }
|
|
1159
|
-
// /**
|
|
1160
|
-
// *
|
|
1161
|
-
// * @param data
|
|
1162
|
-
// * @return {ContextScope}
|
|
1163
|
-
// */
|
|
1164
|
-
// const context = (data = {}) => {
|
|
1165
|
-
// return self.context.create(data)
|
|
1166
|
-
// }
|
|
1167
|
-
// /**
|
|
1168
|
-
// *
|
|
1169
|
-
// */
|
|
1170
|
-
// helpers({ require, render })
|
|
1171
|
-
// /**
|
|
1172
|
-
// *
|
|
1173
|
-
// */
|
|
1174
|
-
// return {
|
|
1175
|
-
// configure,
|
|
1176
|
-
// helpers,
|
|
1177
|
-
// preload,
|
|
1178
|
-
// context,
|
|
1179
|
-
// compile,
|
|
1180
|
-
// create,
|
|
1181
|
-
// render,
|
|
1182
|
-
// }
|
|
1183
|
-
// }
|
|
1184
1050
|
function _output(path, scope) {
|
|
1185
1051
|
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1186
1052
|
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1187
|
-
var params = [scope, scope.
|
|
1053
|
+
var params = [scope, scope.getBuffer(), scope.useSafeValue, scope.useComponent, scope.useElement].concat(globalHelpers.filter(function (name) {
|
|
1188
1054
|
return isFunction(scope[name]);
|
|
1189
1055
|
}).map(function (name) {
|
|
1190
1056
|
return scope[name].bind(scope);
|
|
@@ -1193,13 +1059,6 @@
|
|
|
1193
1059
|
return callback.apply(scope, params);
|
|
1194
1060
|
});
|
|
1195
1061
|
}
|
|
1196
|
-
function _require(name) {
|
|
1197
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1198
|
-
var scope = this.context({});
|
|
1199
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1200
|
-
return scope.getMacro();
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
1062
|
|
|
1204
1063
|
var path = {};
|
|
1205
1064
|
|
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";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function c(t,e,n){r(t,e),e.set(t,n)}function u(t,n,r){return t.set(e(t,n),r),r}function s(t,e){r(t,e),e.add(t)}function a(t,e,n){return e&&function(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,g(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=g(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function g(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},y(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},m=function(t){return"function"==typeof t},w=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},j=function(t){return void 0===t},O="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),E={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&","<":"<",">":">",'"':""","'":"'"},S=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},M=S(x),P=S(E),F=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(M,(function(t){return x[t]}))},W=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?F(n):n},R=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),c=0;c<i.length;c++){var u=i[c];if(m(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(u)){r={};break}r=r[u]=r[u]||{}}return m(r.toJSON)&&(r=r.toJSON()),[r,o]},T=function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))},A=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},C=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},$=function(){},N=function(t,e){var n;for(n in t)_(t,n)&&e(t[n],n,t)},U=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return N(t,(function(t,i,o){var c=e(t,i,o);!1===j(c)&&(n?r.push(c):r[i]=c)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},_=function(t,e){return t&&t.hasOwnProperty(e)},H={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},L=function(t,e){C(t,{path:d(w,H.path,t.path,e.path),export:d(w,H.export,t.export,e.export),resolver:d(m,H.resolver,t.resolver,e.resolver),extension:d(w,H.extension,t.extension,e.extension),withObject:d(k,H.withObject,t.withObject,e.withObject),rmWhitespace:d(k,H.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,H.cache,t.cache,e.cache),token:C({},H.token,t.token,e.token),vars:C({},H.vars,t.vars,e.vars),globalHelpers:d(b,H.globalHelpers,t.globalHelpers,e.globalHelpers)})},J="undefined"!=typeof globalThis?globalThis:window||self,q=new WeakMap,D=new WeakMap,K=function(){return a((function t(e){i(this,t),c(this,q,!0),c(this,D,{}),T(this,["configure"]),this.configure(e)}),[{key:"load",value:function(t){o(q,this)&&C(o(D,this),t||{})}},{key:"get",value:function(t){if(o(q,this))return o(D,this)[t]}},{key:"set",value:function(t,e){o(q,this)&&(o(D,this)[t]=e)}},{key:"exist",value:function(t){return _(o(D,this),t)}},{key:"clear",value:function(){u(D,this,{})}},{key:"remove",value:function(t){delete o(D,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){u(q,this,t.cache),!1===O&&this.load(J[t.export])}}])}(),X=new WeakMap,Y=new WeakMap,z=function(){return a((function t(e){i(this,t),c(this,X,{}),c(this,Y,[{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,"('")}}]),T(this,["configure","compile"]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(X,this).withObject=t.withObject,o(X,this).rmWhitespace=t.rmWhitespace,o(X,this).token=t.token,o(X,this).vars=t.vars,o(X,this).globalHelpers=t.globalHelpers,o(X,this).matches=[],o(X,this).formats=[],o(X,this).slurp={match:"[s\t\n]*",start:[o(X,this).token.start,"_"],end:["_",o(X,this).token.end]},o(Y,this).forEach((function(t){o(X,e).matches.push(o(X,e).token.start.concat(t.symbol).concat(o(X,e).token.regex).concat(o(X,e).token.end)),o(X,e).formats.push(t.format.bind(o(X,e).vars))})),o(X,this).regex=new RegExp(o(X,this).matches.join("|").concat("|$"),"g"),o(X,this).slurpStart=new RegExp([o(X,this).slurp.match,o(X,this).slurp.start.join("")].join(""),"gm"),o(X,this).slurpEnd=new RegExp([o(X,this).slurp.end.join(""),o(X,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(X,this).vars,i=r.SCOPE,c=r.SAFE,u=r.BUFFER,s=r.COMPONENT,a=o(X,this).globalHelpers;o(X,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(X,this).slurpStart,o(X,this).token.start).replace(o(X,this).slurpEnd,o(X,this).token.end);var f,h,l,p="".concat(u,"('");f=o(X,this).regex,h=function(e,r,i){p+=(""+t.slice(r,i)).replace(P,(function(t){return"\\"+E[t]})),e.forEach((function(t,e){t&&(p+=o(X,n).formats[e](t))}))},l=0,t.replace(f,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return h(t,l,e),l=e+n.length,n})),p="try{".concat(p+="');","}catch(e){return ").concat(u,".error(e)}"),o(X,this).withObject&&(p="with(".concat(i,"){").concat(p,"}")),p="".concat(u,".start();").concat(p,"return ").concat(u,".end();"),p+="\n//# sourceURL=".concat(e);var v=null,g=[i,s,u,c].concat(a);try{(v=Function.apply(null,g.concat(p))).source="(function(".concat(g.join(","),"){\n").concat(p,"\n});")}catch(t){throw t.filename=e,t.source=p,t}return v}}])}(),G=new WeakMap,I=new WeakMap,Q=new WeakMap,V=new WeakMap,Z=new WeakSet,tt=function(){return a((function t(e,n,r){i(this,t),s(this,Z),c(this,G,void 0),c(this,I,void 0),c(this,Q,void 0),c(this,V,void 0),R(n,K),R(r,z),u(I,this,n),u(Q,this,r),T(this,["configure","get"]),this.configure(e)}),[{key:"configure",value:function(t){u(G,this,t.path),m(t.resolver)&&u(V,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(I,this).exist(t)?o(I,this).resolve(t):e(Z,this,et).call(this,t).then((function(r){return e(Z,n,nt).call(n,t,e(Z,n,rt).call(n,r,t))}))}}])}();function et(t){return o(V,this).call(this,o(G,this),t)}function nt(t,e){return o(I,this).set(t,e),e}function rt(t,e){return m(t)?t:o(Q,this).compile(t,e)}var it=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ot=" ",ct='"',ut="/",st="<",at=">",ft=function(t,e,n){var r=[],i=-1===it.indexOf(t),o=function(t,e){var n=[];return N(t,(function(t,r,i){var o=e(t,r,i);!1===j(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[F(e),[ct,F(t),ct].join("")].join("=")})).join(ot);return r.push([st,t,ot,o,at].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([st,ut,t,at].join("")),r.join("")},ht=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),a(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(y(Error)),lt=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),c=0;c<r;c++)o[c]=arguments[c];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),a(e)}(ht),pt=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),c=0;c<r;c++)o[c]=arguments[c];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),a(e)}(ht);function vt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function gt(){var t=[],e=[],n=function(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(),vt(n)},n.error=function(t){return e=t,Promise.reject(new pt(e.message));var e},n.end=function(){return vt(e)},n}var yt=new WeakMap,dt=function(){return a((function t(e,n){i(this,t),c(this,yt,void 0),T(this,["create","helpers","configure"]),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){u(yt,this,function(t,e){var n,r=t.vars,i=r.BLOCKS,o=r.MACRO,c=r.EXTEND,u=r.LAYOUT,s=r.BUFFER,a=r.COMPONENT,h=r.SAFE,l=r.SCOPE;function p(t){this[i]={},this[o]={},Object.assign(this,U(t,[l,s,h,a]))}return Object.assign(p.prototype,e),Object.defineProperties(p.prototype,(f(f(f(f(f(f(f(f(f(f(n={},s,{value:gt()}),i,{value:{},writable:!0}),o,{value:{},writable:!0}),u,{value:!1,writable:!0}),c,{value:!1,writable:!0}),"getMacro",{value:function(){return this[o]}}),"getBuffer",{value:function(){return this[s]}}),"getComponent",{value:function(){var t=this;return a in t?function(){return t[a].apply(t,arguments)}:function(){console.log("%s function not defined",a)}}}),"getBlocks",{value:function(){return this[i]}}),"setExtend",{value:function(t){this[c]=t}}),f(f(f(f(f(f(f(f(f(f(n,"getExtend",{value:function(){return this[c]}}),"setLayout",{value:function(t){this[u]=t}}),"getLayout",{value:function(){return this[u]}}),"clone",{value:function(t){var e=[u,c,s];return!0===t&&e.push(i),U(this,e)}}),"extend",{value:function(t){this.setExtend(!0),this.setLayout(t)}}),"echo",{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}}),"fn",{value:function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),m(t)&&t.apply(n,arguments),e.restore()}}}),"get",{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return _(r,i)?r[i]:e}}),"set",{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&_(r,i)?r[i]:r[i]=e}}),"macro",{value: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(f(f(f(f(f(f(f(f(f(n,"call",{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(m(e))return e.apply(e,n)}}),"block",{value: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()},c=function(){var t=o();return t?function(){n.echo(t(c()))}:$};this.echo(o()(c()))}}}),"hasBlock",{value:function(t){return this.getBlocks().hasOwnProperty(t)}}),"include",{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=C(r,e||{}),o=this.render(t,i);this.echo(o)}}),"promiseResolve",{value:function(t,e){return Promise.resolve(m(t)?this.fn(t)():t).then(e.bind(this))}}),"use",{value:function(t,e){this.echo(this.promiseResolve(this.require(t),(function(t){var n=this.getMacro();N(t,(function(t,r){n[[e,r].join(".")]=t}))})))}}),"async",{value:function(t,e){this.echo(this.promiseResolve(t,(function(t){return this.fn(e)(t)})))}}),"each",{value:function(t,e){w(t)&&(t=this.get(t,[])),N(t,e)}}),"element",{value:function(t,e,n){return ft(t,e,n)}}),"el",{value:function(t,e,n){this.echo(this.promiseResolve(n,(function(n){return this.element(t,e,n)})))}}))),p}(t,e))}},{key:"helpers",value:function(t){C(o(yt,this).prototype,t||{})}}])}(),bt=new WeakMap,mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,jt=new WeakMap,Ot=new WeakMap,Et=new WeakSet,xt=function(){return a((function t(n){i(this,t),s(this,Et),c(this,bt,{}),c(this,mt,{}),c(this,wt,void 0),c(this,kt,void 0),c(this,jt,void 0),c(this,Ot,void 0),L(o(bt,this),n||{}),u(wt,this,new dt(o(bt,this),o(mt,this))),u(kt,this,new z(o(bt,this))),u(jt,this,new K(o(bt,this))),u(Ot,this,new tt(o(bt,this),o(jt,this),o(kt,this))),T(this,["configure","create","render","context","preload","compile","helpers"]),this.helpers({require:e(Et,this,Mt),render:this.render})}),[{key:"configure",value:function(t){return L(o(bt,this),t||{}),o(wt,this).configure(o(bt,this),o(mt,this)),o(kt,this).configure(o(bt,this)),o(jt,this).configure(o(bt,this)),o(Ot,this).configure(o(bt,this)),o(bt,this)}},{key:"render",value:function(t,n){var r=this,i=A(t,o(bt,this).extension),c=this.context(n);return e(Et,this,St).call(this,i,c).then((function(t){if(c.getExtend()){c.setExtend(!1);var e=c.getLayout(),n=c.clone();return r.render(e,n)}return t}))}},{key:"helpers",value:function(t){o(wt,this).helpers(C(o(mt,this),t))}},{key:"context",value:function(t){return o(wt,this).create(t)}},{key:"compile",value:function(t,e){return o(kt,this).compile(t,e)}},{key:"preload",value:function(t){return o(jt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}}])}();function St(t,e){var n=o(bt,this).globalHelpers,r=[e,e.getComponent(),e.getBuffer(),W].concat(n.filter((function(t){return m(e[t])})).map((function(t){return e[t].bind(e)})));return o(Ot,this).get(t).then((function(t){return t.apply(e,r)}))}function Mt(t){var n=A(t,o(bt,this).extension),r=this.context({});return e(Et,this,St).call(this,n,r).then((function(){return r.getMacro()}))}var Pt={};var Ft=new xt({resolver:function(t,e){return new Promise((function(n,r){Pt.readFile(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e),(function(t,e){t?r(new ht(t)):n(e.toString())}))}))}}),Wt=Ft.render,Rt=Ft.context,Bt=Ft.compile,Tt=Ft.helpers,At=Ft.preload,Ct=Ft.configure,$t=Ft.create,Nt=function(t,e){return function(n,r,i){m(r)&&(i=r,r={});var o=C({},(r=r||{}).settings),c=d(w,H.path,o.views),u=d(k,H.cache,o["view cache"]),s=C({},o["view options"]),a=Pt.relative(c,n);return s.path=c,s.cache=u,t(s),e(a,r).then((function(t){i(null,t)})).catch((function(t){i(t)}))}}(Ct,Wt);t.TemplateError=ht,t.TemplateNotFound=lt,t.TemplateSyntaxError=pt,t.__express=Nt,t.compile=Bt,t.configure=Ct,t.context=Rt,t.create=$t,t.helpers=Tt,t.preload=At,t.render=Wt}));
|
|
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";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function u(t,e,n){r(t,e),e.set(t,n)}function c(t,n,r){return t.set(e(t,n),r),r}function s(t,e){r(t,e),e.add(t)}function a(t,e,n){return e&&function(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,y(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},g(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},w=function(t){return"function"==typeof t},m=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},E=function(t){return void 0===t},j="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&","<":"<",">":">",'"':""","'":"'"},S=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},M=S(x),P=S(O),F=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(M,(function(t){return x[t]}))},T=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?F(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),u=0;u<i.length;u++){var c=i[u];if(w(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(c)){r={};break}r=r[c]=r[c]||{}}return w(r.toJSON)&&(r=r.toJSON()),[r,o]},R=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},N=function(){},C=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},$=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return C(t,(function(t,i,o){var u=e(t,i,o);!1===E(u)&&(n?r.push(u):r[i]=u)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},U={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},_=function(t,e){A(t,{path:d(m,U.path,t.path,e.path),export:d(m,U.export,t.export,e.export),resolver:d(w,U.resolver,t.resolver,e.resolver),extension:d(m,U.extension,t.extension,e.extension),withObject:d(k,U.withObject,t.withObject,e.withObject),rmWhitespace:d(k,U.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,U.cache,t.cache,e.cache),token:A({},U.token,t.token,e.token),vars:A({},U.vars,t.vars,e.vars),globalHelpers:d(b,U.globalHelpers,t.globalHelpers,e.globalHelpers)})},H="undefined"!=typeof globalThis?globalThis:window||self,q=new WeakMap,J=new WeakMap,D=function(){return a((function t(e){i(this,t),u(this,q,!0),u(this,J,{}),this.configure(e)}),[{key:"load",value:function(t){o(q,this)&&A(o(J,this),t||{})}},{key:"get",value:function(t){if(o(q,this))return o(J,this)[t]}},{key:"set",value:function(t,e){o(q,this)&&(o(J,this)[t]=e)}},{key:"exist",value:function(t){return L(o(J,this),t)}},{key:"clear",value:function(){c(J,this,{})}},{key:"remove",value:function(t){delete o(J,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){c(q,this,t.cache),!1===j&&this.load(H[t.export])}}])}(),K=new WeakMap,V=new WeakMap,X=function(){return a((function t(e){i(this,t),u(this,K,{}),u(this,V,[{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,"('")}}]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(K,this).withObject=t.withObject,o(K,this).rmWhitespace=t.rmWhitespace,o(K,this).token=t.token,o(K,this).vars=t.vars,o(K,this).globalHelpers=t.globalHelpers,o(K,this).matches=[],o(K,this).formats=[],o(K,this).slurp={match:"[s\t\n]*",start:[o(K,this).token.start,"_"],end:["_",o(K,this).token.end]},o(V,this).forEach((function(t){o(K,e).matches.push(o(K,e).token.start.concat(t.symbol).concat(o(K,e).token.regex).concat(o(K,e).token.end)),o(K,e).formats.push(t.format.bind(o(K,e).vars))})),o(K,this).regex=new RegExp(o(K,this).matches.join("|").concat("|$"),"g"),o(K,this).slurpStart=new RegExp([o(K,this).slurp.match,o(K,this).slurp.start.join("")].join(""),"gm"),o(K,this).slurpEnd=new RegExp([o(K,this).slurp.end.join(""),o(K,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(K,this).vars,i=r.SCOPE,u=r.SAFE,c=r.BUFFER,s=r.COMPONENT,a=r.ELEMENT,f=o(K,this).globalHelpers;o(K,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(K,this).slurpStart,o(K,this).token.start).replace(o(K,this).slurpEnd,o(K,this).token.end);var h,l,p,v="".concat(c,"('");h=o(K,this).regex,l=function(e,r,i){v+=(""+t.slice(r,i)).replace(P,(function(t){return"\\"+O[t]})),e.forEach((function(t,e){t&&(v+=o(K,n).formats[e](t))}))},p=0,t.replace(h,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,p,e),p=e+n.length,n})),v="try{".concat(v+="');","}catch(e){return ").concat(c,".error(e)}"),o(K,this).withObject&&(v="with(".concat(i,"){").concat(v,"}")),v="".concat(c,".start();").concat(v,"return ").concat(c,".end();"),v+="\n//# sourceURL=".concat(e);var y=null,g=[i,c,u,s,a].concat(f);try{(y=Function.apply(null,g.concat(v))).source="(function(".concat(g.join(","),"){\n").concat(v,"\n});")}catch(t){throw t.filename=e,t.source=v,t}return y}}])}(),Y=new WeakMap,z=new WeakMap,G=new WeakMap,I=new WeakMap,Q=new WeakSet,Z=function(){return a((function t(e,n,r){i(this,t),s(this,Q),u(this,Y,void 0),u(this,z,void 0),u(this,G,void 0),u(this,I,void 0),W(n,D),W(r,X),c(z,this,n),c(G,this,r),this.configure(e)}),[{key:"configure",value:function(t){c(Y,this,t.path),w(t.resolver)&&c(I,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(z,this).exist(t)?o(z,this).resolve(t):e(Q,this,tt).call(this,t).then((function(r){return e(Q,n,et).call(n,t,e(Q,n,nt).call(n,r,t))}))}}])}();function tt(t){return o(I,this).call(this,o(Y,this),t)}function et(t,e){return o(z,this).set(t,e),e}function nt(t,e){return w(t)?t:o(G,this).compile(t,e)}var rt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=" ",ot='"',ut="/",ct="<",st=">",at=function(t,e,n){var r=[],i=-1===rt.indexOf(t),o=function(t,e){var n=[];return C(t,(function(t,r,i){var o=e(t,r,i);!1===E(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[F(e),[ot,F(t),ot].join("")].join("=")})).join(it);return r.push([ct,t,it,o,st].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([ct,ut,t,st].join("")),r.join("")},ft=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),a(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(g(Error)),ht=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),a(e)}(ft),lt=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),a(e)}(ft);function pt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function vt(){var t=[],e=[],n=function(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(),pt(n)},n.error=function(t){return e=t,Promise.reject(new lt(e.message));var e},n.end=function(){return pt(e)},n}var yt=new WeakMap,gt=function(){return a((function t(e,n){i(this,t),u(this,yt,void 0),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){c(yt,this,function(t,e){var n,r=t.vars,i=r.BLOCKS,o=r.MACRO,u=r.EXTEND,c=r.LAYOUT,s=r.BUFFER,a=r.SAFE,h=r.SCOPE,l=r.COMPONENT,p=r.ELEMENT;function v(t){this[i]={},this[o]={},Object.assign(this,$(t,[h,s,a,l,p]))}return Object.assign(v.prototype,e),Object.defineProperties(v.prototype,(f(f(f(f(f(f(f(f(f(f(n={},s,{value:vt()}),i,{value:{},writable:!0}),o,{value:{},writable:!0}),c,{value:!1,writable:!0}),u,{value:!1,writable:!0}),"useSafeValue",{get:function(){return T}}),"useComponent",{get:function(){return w(this[l])?this[l].bind(this):function(){throw new Error("".concat(l," must be a function"))}}}),"useElement",{get:function(){return w(this[p])?this[p].bind(this):function(){throw new Error("".concat(p," must be a function"))}}}),"getMacro",{value:function(){return this[o]}}),"getBuffer",{value:function(){return this[s]}}),f(f(f(f(f(f(f(f(f(f(n,"getBlocks",{value:function(){return this[i]}}),"setExtend",{value:function(t){this[u]=t}}),"getExtend",{value:function(){return this[u]}}),"setLayout",{value:function(t){this[c]=t}}),"getLayout",{value:function(){return this[c]}}),"clone",{value:function(t){var e=[c,u,s];return!0===t&&e.push(i),$(this,e)}}),"extend",{value:function(t){this.setExtend(!0),this.setLayout(t)}}),"echo",{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}}),"fn",{value:function(t){var e=this.getBuffer(),n=this;return function(){if(w(t))return e.backup(),e(t.apply(n,arguments)),e.restore()}}}),"macro",{value: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(f(f(f(f(f(f(f(f(f(n,"call",{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(w(e))return e.apply(e,n)}}),"block",{value: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()},u=function(){var t=o();return t?function(){n.echo(t(u()))}:N};this.echo(o()(u()))}}}),"hasBlock",{value:function(t){return this.getBlocks().hasOwnProperty(t)}}),"include",{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=A(r,e||{}),o=this.render(t,i);this.echo(o)}}),"use",{value:function(t,e){var n=this;this.echo(Promise.resolve(this.require(t)).then((function(t){var r=n.getMacro();C(t,(function(t,n){r[[e,n].join(".")]=t}))})))}}),"async",{value:function(t,e){this.echo(Promise.resolve(t).then(e))}}),"get",{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return L(r,i)?r[i]:e}}),"set",{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&L(r,i)?r[i]:r[i]=e}}),"each",{value:function(t,e){m(t)&&(t=this.get(t,[])),C(t,e)},writable:!0}),"el",{value:function(t,e,n){n=w(n)?this.fn(n)():n,this.echo(Promise.resolve(n).then((function(n){return at(t,e,n)})))},writable:!0}),f(n,"ui",{value:function(t){},writable:!0}))),v}(t,e))}},{key:"helpers",value:function(t){A(o(yt,this).prototype,t||{})}}])}(),dt=new WeakMap,bt=new WeakMap,wt=new WeakMap,mt=new WeakMap,kt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Ot=function(){return a((function t(e){i(this,t),s(this,jt),u(this,dt,{}),u(this,bt,{}),u(this,wt,void 0),u(this,mt,void 0),u(this,kt,void 0),u(this,Et,void 0),_(o(dt,this),e||{}),c(wt,this,new gt(o(dt,this),o(bt,this))),c(mt,this,new X(o(dt,this))),c(kt,this,new D(o(dt,this))),c(Et,this,new Z(o(dt,this),o(kt,this),o(mt,this))),function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))}(this,["configure","create","render","require","context","preload","compile","helpers"]),this.helpers({require:this.require,render:this.render})}),[{key:"configure",value:function(t){return _(o(dt,this),t||{}),o(wt,this).configure(o(dt,this),o(bt,this)),o(mt,this).configure(o(dt,this)),o(kt,this).configure(o(dt,this)),o(Et,this).configure(o(dt,this)),o(dt,this)}},{key:"render",value:function(t,n){var r=this,i=R(t,o(dt,this).extension),u=this.context(n);return e(jt,this,xt).call(this,i,u).then((function(t){if(u.getExtend()){u.setExtend(!1);var e=u.getLayout(),n=u.clone();return r.render(e,n)}return t}))}},{key:"helpers",value:function(t){o(wt,this).helpers(A(o(bt,this),t))}},{key:"context",value:function(t){return o(wt,this).create(t)}},{key:"compile",value:function(t,e){return o(mt,this).compile(t,e)}},{key:"preload",value:function(t){return o(kt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}},{key:"require",value:function(t){var n=R(t,o(dt,this).extension),r=this.context({});return e(jt,this,xt).call(this,n,r).then((function(){return r.getMacro()}))}}])}();function xt(t,e){var n=o(dt,this).globalHelpers,r=[e,e.getBuffer(),e.useSafeValue,e.useComponent,e.useElement].concat(n.filter((function(t){return w(e[t])})).map((function(t){return e[t].bind(e)})));return o(Et,this).get(t).then((function(t){return t.apply(e,r)}))}var St={};var Mt=new Ot({resolver:function(t,e){return new Promise((function(n,r){St.readFile(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e),(function(t,e){t?r(new ft(t)):n(e.toString())}))}))}}),Pt=Mt.render,Ft=Mt.context,Tt=Mt.compile,Wt=Mt.helpers,Bt=Mt.preload,Rt=Mt.configure,At=Mt.create,Nt=function(t,e){return function(n,r,i){w(r)&&(i=r,r={});var o=A({},(r=r||{}).settings),u=d(m,U.path,o.views),c=d(k,U.cache,o["view cache"]),s=A({},o["view options"]),a=St.relative(u,n);return s.path=u,s.cache=c,t(s),e(a,r).then((function(t){i(null,t)})).catch((function(t){i(t)}))}}(Rt,Pt);t.TemplateError=ft,t.TemplateNotFound=ht,t.TemplateSyntaxError=lt,t.__express=Nt,t.compile=Tt,t.configure=Rt,t.context=Ft,t.create=At,t.helpers=Wt,t.preload=Bt,t.render=Pt}));
|