@kosatyi/ejs 0.0.99 → 0.0.100

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.
@@ -1023,7 +1023,6 @@ function createBuffer() {
1023
1023
  }
1024
1024
 
1025
1025
  var createContextScope = function createContextScope(config, methods) {
1026
- var _Object$definePropert;
1027
1026
  var _config$vars = config.vars,
1028
1027
  BLOCKS = _config$vars.BLOCKS,
1029
1028
  MACRO = _config$vars.MACRO,
@@ -1045,206 +1044,264 @@ var createContextScope = function createContextScope(config, methods) {
1045
1044
  Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
1046
1045
  }
1047
1046
  Object.assign(ContextScope.prototype, methods);
1048
- Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
1047
+ Object.defineProperty(ContextScope.prototype, BUFFER, {
1049
1048
  value: createBuffer()
1050
- }), BLOCKS, {
1049
+ });
1050
+ Object.defineProperty(ContextScope.prototype, BLOCKS, {
1051
1051
  value: {},
1052
1052
  writable: true
1053
- }), MACRO, {
1053
+ });
1054
+ Object.defineProperty(ContextScope.prototype, MACRO, {
1054
1055
  value: {},
1055
1056
  writable: true
1056
- }), LAYOUT, {
1057
+ });
1058
+ Object.defineProperty(ContextScope.prototype, LAYOUT, {
1057
1059
  value: false,
1058
1060
  writable: true
1059
- }), EXTEND, {
1061
+ });
1062
+ Object.defineProperty(ContextScope.prototype, EXTEND, {
1060
1063
  value: false,
1061
1064
  writable: true
1062
- }), "useSafeValue", {
1063
- get: function get() {
1064
- return safeValue;
1065
- }
1066
- }), "useComponent", {
1067
- get: function get() {
1068
- if (isFunction(this[COMPONENT])) {
1069
- return this[COMPONENT].bind(this);
1070
- } else {
1071
- return function () {
1072
- throw new Error("".concat(COMPONENT, " must be a function"));
1073
- };
1065
+ });
1066
+ Object.defineProperties(ContextScope.prototype, {
1067
+ /** @type {function} */
1068
+ useSafeValue: {
1069
+ get: function get() {
1070
+ return safeValue;
1074
1071
  }
1075
- }
1076
- }), "useElement", {
1077
- get: function get() {
1078
- if (isFunction(this[ELEMENT])) {
1079
- return this[ELEMENT].bind(this);
1080
- } else {
1072
+ },
1073
+ /** @type {function} */
1074
+ useComponent: {
1075
+ get: function get() {
1076
+ if (isFunction(this[COMPONENT])) {
1077
+ return this[COMPONENT].bind(this);
1078
+ } else {
1079
+ return function () {
1080
+ throw new Error("".concat(COMPONENT, " must be a function"));
1081
+ };
1082
+ }
1083
+ }
1084
+ },
1085
+ /** @type {function} */
1086
+ useElement: {
1087
+ get: function get() {
1088
+ if (isFunction(this[ELEMENT])) {
1089
+ return this[ELEMENT].bind(this);
1090
+ } else {
1091
+ return function () {
1092
+ throw new Error("".concat(ELEMENT, " must be a function"));
1093
+ };
1094
+ }
1095
+ }
1096
+ },
1097
+ /** @type {()=>this[MACRO]} */
1098
+ getMacro: {
1099
+ value: function value() {
1100
+ return this[MACRO];
1101
+ }
1102
+ },
1103
+ /** @type {function} */
1104
+ getBuffer: {
1105
+ value: function value() {
1106
+ return this[BUFFER];
1107
+ }
1108
+ },
1109
+ /** @type {function} */
1110
+ getBlocks: {
1111
+ value: function value() {
1112
+ return this[BLOCKS];
1113
+ }
1114
+ },
1115
+ /** @type {function} */
1116
+ setExtend: {
1117
+ value: function value(_value) {
1118
+ this[EXTEND] = _value;
1119
+ }
1120
+ },
1121
+ /** @type {function} */
1122
+ getExtend: {
1123
+ value: function value() {
1124
+ return this[EXTEND];
1125
+ }
1126
+ },
1127
+ /** @type {function} */
1128
+ setLayout: {
1129
+ value: function value(layout) {
1130
+ this[LAYOUT] = layout;
1131
+ }
1132
+ },
1133
+ /** @type {function} */
1134
+ getLayout: {
1135
+ value: function value() {
1136
+ return this[LAYOUT];
1137
+ }
1138
+ },
1139
+ /** @type {function} */
1140
+ clone: {
1141
+ value: function value(exclude_blocks) {
1142
+ var filter = [LAYOUT, EXTEND, BUFFER];
1143
+ if (exclude_blocks === true) {
1144
+ filter.push(BLOCKS);
1145
+ }
1146
+ return omit(this, filter);
1147
+ }
1148
+ },
1149
+ /** @type {function} */
1150
+ extend: {
1151
+ value: function value(layout) {
1152
+ this.setExtend(true);
1153
+ this.setLayout(layout);
1154
+ }
1155
+ },
1156
+ /** @type {function} */
1157
+ echo: {
1158
+ value: function value(layout) {
1159
+ var buffer = this.getBuffer();
1160
+ var params = [].slice.call(arguments);
1161
+ params.forEach(buffer);
1162
+ }
1163
+ },
1164
+ /** @type {function} */
1165
+ fn: {
1166
+ value: function value(callback) {
1167
+ var buffer = this.getBuffer();
1168
+ var context = this;
1081
1169
  return function () {
1082
- throw new Error("".concat(ELEMENT, " must be a function"));
1170
+ if (isFunction(callback)) {
1171
+ buffer.backup();
1172
+ buffer(callback.apply(context, arguments));
1173
+ return buffer.restore();
1174
+ }
1083
1175
  };
1084
1176
  }
1085
- }
1086
- }), "getMacro", {
1087
- value: function value() {
1088
- return this[MACRO];
1089
- }
1090
- }), "getBuffer", {
1091
- value: function value() {
1092
- return this[BUFFER];
1093
- }
1094
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
1095
- value: function value() {
1096
- return this[BLOCKS];
1097
- }
1098
- }), "setExtend", {
1099
- value: function value(_value) {
1100
- this[EXTEND] = _value;
1101
- }
1102
- }), "getExtend", {
1103
- value: function value() {
1104
- return this[EXTEND];
1105
- }
1106
- }), "setLayout", {
1107
- value: function value(layout) {
1108
- this[LAYOUT] = layout;
1109
- }
1110
- }), "getLayout", {
1111
- value: function value() {
1112
- return this[LAYOUT];
1113
- }
1114
- }), "clone", {
1115
- value: function value(exclude_blocks) {
1116
- var filter = [LAYOUT, EXTEND, BUFFER];
1117
- if (exclude_blocks === true) {
1118
- filter.push(BLOCKS);
1177
+ },
1178
+ /** @type {function} */
1179
+ macro: {
1180
+ value: function value(name, callback) {
1181
+ var list = this.getMacro();
1182
+ var macro = this.fn(callback);
1183
+ var context = this;
1184
+ list[name] = function () {
1185
+ return context.echo(macro.apply(undefined, arguments));
1186
+ };
1119
1187
  }
1120
- return omit(this, filter);
1121
- }
1122
- }), "extend", {
1123
- value: function value(layout) {
1124
- this.setExtend(true);
1125
- this.setLayout(layout);
1126
- }
1127
- }), "echo", {
1128
- value: function value(layout) {
1129
- var buffer = this.getBuffer();
1130
- var params = [].slice.call(arguments);
1131
- params.forEach(buffer);
1132
- }
1133
- }), "fn", {
1134
- value: function value(callback) {
1135
- var buffer = this.getBuffer();
1136
- var context = this;
1137
- return function () {
1138
- if (isFunction(callback)) {
1139
- buffer.backup();
1140
- buffer(callback.apply(context, arguments));
1141
- return buffer.restore();
1188
+ },
1189
+ /** @type {function} */
1190
+ call: {
1191
+ value: function value(name) {
1192
+ var list = this.getMacro();
1193
+ var macro = list[name];
1194
+ var params = [].slice.call(arguments, 1);
1195
+ if (isFunction(macro)) {
1196
+ return macro.apply(macro, params);
1142
1197
  }
1143
- };
1144
- }
1145
- }), "macro", {
1146
- value: function value(name, callback) {
1147
- var list = this.getMacro();
1148
- var macro = this.fn(callback);
1149
- var context = this;
1150
- list[name] = function () {
1151
- return context.echo(macro.apply(undefined, arguments));
1152
- };
1153
- }
1154
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
1155
- value: function value(name) {
1156
- var list = this.getMacro();
1157
- var macro = list[name];
1158
- var params = [].slice.call(arguments, 1);
1159
- if (isFunction(macro)) {
1160
- return macro.apply(macro, params);
1161
1198
  }
1162
- }
1163
- }), "block", {
1164
- value: function value(name, callback) {
1165
- var _this = this;
1166
- var blocks = this.getBlocks();
1167
- blocks[name] = blocks[name] || [];
1168
- blocks[name].push(this.fn(callback));
1169
- if (this.getExtend()) return;
1170
- var list = Object.assign([], blocks[name]);
1171
- var current = function current() {
1172
- return list.shift();
1173
- };
1174
- var _next = function next() {
1175
- var parent = current();
1176
- if (parent) {
1177
- return function () {
1178
- _this.echo(parent(_next()));
1179
- };
1180
- } else {
1181
- return noop;
1182
- }
1183
- };
1184
- this.echo(current()(_next()));
1185
- }
1186
- }), "hasBlock", {
1187
- value: function value(name) {
1188
- return this.getBlocks().hasOwnProperty(name);
1189
- }
1190
- }), "include", {
1191
- value: function value(path, data, cx) {
1192
- var context = cx === false ? {} : this.clone(true);
1193
- var params = extend(context, data || {});
1194
- var promise = this.render(path, params);
1195
- this.echo(promise);
1196
- }
1197
- }), "use", {
1198
- value: function value(path, namespace) {
1199
- var _this2 = this;
1200
- this.echo(Promise.resolve(this.require(path)).then(function (exports) {
1201
- var list = _this2.getMacro();
1202
- each(exports, function (macro, name) {
1203
- list[[namespace, name].join('.')] = macro;
1204
- });
1205
- }));
1206
- }
1207
- }), "async", {
1208
- value: function value(promise, callback) {
1209
- this.echo(Promise.resolve(promise).then(callback));
1210
- }
1211
- }), "get", {
1212
- value: function value(name, defaults) {
1213
- var path = getPath(this, name, true);
1214
- var result = path.shift();
1215
- var prop = path.pop();
1216
- return hasProp(result, prop) ? result[prop] : defaults;
1217
- }
1218
- }), "set", {
1219
- value: function value(name, _value2) {
1220
- var path = getPath(this, name, false);
1221
- var result = path.shift();
1222
- var prop = path.pop();
1223
- if (this.getExtend() && hasProp(result, prop)) {
1224
- return result[prop];
1199
+ },
1200
+ /** @type {function} */
1201
+ block: {
1202
+ value: function value(name, callback) {
1203
+ var _this = this;
1204
+ var blocks = this.getBlocks();
1205
+ blocks[name] = blocks[name] || [];
1206
+ blocks[name].push(this.fn(callback));
1207
+ if (this.getExtend()) return;
1208
+ var list = Object.assign([], blocks[name]);
1209
+ var current = function current() {
1210
+ return list.shift();
1211
+ };
1212
+ var _next = function next() {
1213
+ var parent = current();
1214
+ if (parent) {
1215
+ return function () {
1216
+ _this.echo(parent(_next()));
1217
+ };
1218
+ } else {
1219
+ return noop;
1220
+ }
1221
+ };
1222
+ this.echo(current()(_next()));
1225
1223
  }
1226
- return result[prop] = _value2;
1227
- }
1228
- }), "each", {
1229
- value: function value(object, callback) {
1230
- if (isString(object)) {
1231
- object = this.get(object, []);
1224
+ },
1225
+ /** @type {function} */
1226
+ hasBlock: {
1227
+ value: function value(name) {
1228
+ return this.getBlocks().hasOwnProperty(name);
1232
1229
  }
1233
- each(object, callback);
1234
1230
  },
1235
- writable: true
1236
- }), "el", {
1237
- value: function value(tag, attr, content) {
1238
- content = isFunction(content) ? this.fn(content)() : content;
1239
- this.echo(Promise.resolve(content).then(function (content) {
1240
- return element(tag, attr, content);
1241
- }));
1231
+ /** @type {function} */
1232
+ include: {
1233
+ value: function value(path, data, cx) {
1234
+ var context = cx === false ? {} : this.clone(true);
1235
+ var params = extend(context, data || {});
1236
+ var promise = this.render(path, params);
1237
+ this.echo(promise);
1238
+ }
1242
1239
  },
1243
- writable: true
1244
- }), _defineProperty(_Object$definePropert, "ui", {
1245
- value: function value(layout) {},
1246
- writable: true
1247
- })));
1240
+ /** @type {function} */
1241
+ use: {
1242
+ value: function value(path, namespace) {
1243
+ var _this2 = this;
1244
+ this.echo(Promise.resolve(this.require(path)).then(function (exports) {
1245
+ var list = _this2.getMacro();
1246
+ each(exports, function (macro, name) {
1247
+ list[[namespace, name].join('.')] = macro;
1248
+ });
1249
+ }));
1250
+ }
1251
+ },
1252
+ /** @type {function} */
1253
+ async: {
1254
+ value: function value(promise, callback) {
1255
+ this.echo(Promise.resolve(promise).then(callback));
1256
+ }
1257
+ },
1258
+ /** @type {function} */
1259
+ get: {
1260
+ value: function value(name, defaults) {
1261
+ var path = getPath(this, name, true);
1262
+ var result = path.shift();
1263
+ var prop = path.pop();
1264
+ return hasProp(result, prop) ? result[prop] : defaults;
1265
+ }
1266
+ },
1267
+ /** @type {function} */
1268
+ set: {
1269
+ value: function value(name, _value2) {
1270
+ var path = getPath(this, name, false);
1271
+ var result = path.shift();
1272
+ var prop = path.pop();
1273
+ if (this.getExtend() && hasProp(result, prop)) {
1274
+ return result[prop];
1275
+ }
1276
+ return result[prop] = _value2;
1277
+ }
1278
+ },
1279
+ /** @type {function} */
1280
+ each: {
1281
+ value: function value(object, callback) {
1282
+ if (isString(object)) {
1283
+ object = this.get(object, []);
1284
+ }
1285
+ each(object, callback);
1286
+ },
1287
+ writable: true
1288
+ },
1289
+ /** @type {function} */
1290
+ el: {
1291
+ value: function value(tag, attr, content) {
1292
+ content = isFunction(content) ? this.fn(content)() : content;
1293
+ this.echo(Promise.resolve(content).then(function (content) {
1294
+ return element(tag, attr, content);
1295
+ }));
1296
+ },
1297
+ writable: true
1298
+ },
1299
+ /** @type {function} */
1300
+ ui: {
1301
+ value: function value(layout) {},
1302
+ writable: true
1303
+ }
1304
+ });
1248
1305
  return ContextScope;
1249
1306
  };
1250
1307
  var _scope = /*#__PURE__*/new WeakMap();
@@ -609,26 +609,26 @@ const createContextScope = (config, methods) => {
609
609
  );
610
610
  }
611
611
  Object.assign(ContextScope.prototype, methods);
612
+ Object.defineProperty(ContextScope.prototype, BUFFER, {
613
+ value: createBuffer(),
614
+ });
615
+ Object.defineProperty(ContextScope.prototype, BLOCKS, {
616
+ value: {},
617
+ writable: true,
618
+ });
619
+ Object.defineProperty(ContextScope.prototype, MACRO, {
620
+ value: {},
621
+ writable: true,
622
+ });
623
+ Object.defineProperty(ContextScope.prototype, LAYOUT, {
624
+ value: false,
625
+ writable: true,
626
+ });
627
+ Object.defineProperty(ContextScope.prototype, EXTEND, {
628
+ value: false,
629
+ writable: true,
630
+ });
612
631
  Object.defineProperties(ContextScope.prototype, {
613
- [BUFFER]: {
614
- value: createBuffer(),
615
- },
616
- [BLOCKS]: {
617
- value: {},
618
- writable: true,
619
- },
620
- [MACRO]: {
621
- value: {},
622
- writable: true,
623
- },
624
- [LAYOUT]: {
625
- value: false,
626
- writable: true,
627
- },
628
- [EXTEND]: {
629
- value: false,
630
- writable: true,
631
- },
632
632
  /** @type {function} */
633
633
  useSafeValue: {
634
634
  get: () => safeValue,
package/dist/esm/index.js CHANGED
@@ -612,26 +612,26 @@ const createContextScope = (config, methods) => {
612
612
  );
613
613
  }
614
614
  Object.assign(ContextScope.prototype, methods);
615
+ Object.defineProperty(ContextScope.prototype, BUFFER, {
616
+ value: createBuffer(),
617
+ });
618
+ Object.defineProperty(ContextScope.prototype, BLOCKS, {
619
+ value: {},
620
+ writable: true,
621
+ });
622
+ Object.defineProperty(ContextScope.prototype, MACRO, {
623
+ value: {},
624
+ writable: true,
625
+ });
626
+ Object.defineProperty(ContextScope.prototype, LAYOUT, {
627
+ value: false,
628
+ writable: true,
629
+ });
630
+ Object.defineProperty(ContextScope.prototype, EXTEND, {
631
+ value: false,
632
+ writable: true,
633
+ });
615
634
  Object.defineProperties(ContextScope.prototype, {
616
- [BUFFER]: {
617
- value: createBuffer(),
618
- },
619
- [BLOCKS]: {
620
- value: {},
621
- writable: true,
622
- },
623
- [MACRO]: {
624
- value: {},
625
- writable: true,
626
- },
627
- [LAYOUT]: {
628
- value: false,
629
- writable: true,
630
- },
631
- [EXTEND]: {
632
- value: false,
633
- writable: true,
634
- },
635
635
  /** @type {function} */
636
636
  useSafeValue: {
637
637
  get: () => safeValue,
@@ -603,26 +603,26 @@ const createContextScope = (config, methods) => {
603
603
  );
604
604
  }
605
605
  Object.assign(ContextScope.prototype, methods);
606
+ Object.defineProperty(ContextScope.prototype, BUFFER, {
607
+ value: createBuffer(),
608
+ });
609
+ Object.defineProperty(ContextScope.prototype, BLOCKS, {
610
+ value: {},
611
+ writable: true,
612
+ });
613
+ Object.defineProperty(ContextScope.prototype, MACRO, {
614
+ value: {},
615
+ writable: true,
616
+ });
617
+ Object.defineProperty(ContextScope.prototype, LAYOUT, {
618
+ value: false,
619
+ writable: true,
620
+ });
621
+ Object.defineProperty(ContextScope.prototype, EXTEND, {
622
+ value: false,
623
+ writable: true,
624
+ });
606
625
  Object.defineProperties(ContextScope.prototype, {
607
- [BUFFER]: {
608
- value: createBuffer(),
609
- },
610
- [BLOCKS]: {
611
- value: {},
612
- writable: true,
613
- },
614
- [MACRO]: {
615
- value: {},
616
- writable: true,
617
- },
618
- [LAYOUT]: {
619
- value: false,
620
- writable: true,
621
- },
622
- [EXTEND]: {
623
- value: false,
624
- writable: true,
625
- },
626
626
  /** @type {function} */
627
627
  useSafeValue: {
628
628
  get: () => safeValue,