@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.
package/dist/cjs/index.js CHANGED
@@ -705,7 +705,6 @@ function createBuffer() {
705
705
  }
706
706
 
707
707
  var createContextScope = function createContextScope(config, methods) {
708
- var _Object$definePropert;
709
708
  var _config$vars = config.vars,
710
709
  BLOCKS = _config$vars.BLOCKS,
711
710
  MACRO = _config$vars.MACRO,
@@ -727,206 +726,264 @@ var createContextScope = function createContextScope(config, methods) {
727
726
  Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
728
727
  }
729
728
  Object.assign(ContextScope.prototype, methods);
730
- Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
729
+ Object.defineProperty(ContextScope.prototype, BUFFER, {
731
730
  value: createBuffer()
732
- }), BLOCKS, {
731
+ });
732
+ Object.defineProperty(ContextScope.prototype, BLOCKS, {
733
733
  value: {},
734
734
  writable: true
735
- }), MACRO, {
735
+ });
736
+ Object.defineProperty(ContextScope.prototype, MACRO, {
736
737
  value: {},
737
738
  writable: true
738
- }), LAYOUT, {
739
+ });
740
+ Object.defineProperty(ContextScope.prototype, LAYOUT, {
739
741
  value: false,
740
742
  writable: true
741
- }), EXTEND, {
743
+ });
744
+ Object.defineProperty(ContextScope.prototype, EXTEND, {
742
745
  value: false,
743
746
  writable: true
744
- }), "useSafeValue", {
745
- get: function get() {
746
- return safeValue;
747
- }
748
- }), "useComponent", {
749
- get: function get() {
750
- if (isFunction(this[COMPONENT])) {
751
- return this[COMPONENT].bind(this);
752
- } else {
753
- return function () {
754
- throw new Error("".concat(COMPONENT, " must be a function"));
755
- };
747
+ });
748
+ Object.defineProperties(ContextScope.prototype, {
749
+ /** @type {function} */
750
+ useSafeValue: {
751
+ get: function get() {
752
+ return safeValue;
756
753
  }
757
- }
758
- }), "useElement", {
759
- get: function get() {
760
- if (isFunction(this[ELEMENT])) {
761
- return this[ELEMENT].bind(this);
762
- } else {
754
+ },
755
+ /** @type {function} */
756
+ useComponent: {
757
+ get: function get() {
758
+ if (isFunction(this[COMPONENT])) {
759
+ return this[COMPONENT].bind(this);
760
+ } else {
761
+ return function () {
762
+ throw new Error("".concat(COMPONENT, " must be a function"));
763
+ };
764
+ }
765
+ }
766
+ },
767
+ /** @type {function} */
768
+ useElement: {
769
+ get: function get() {
770
+ if (isFunction(this[ELEMENT])) {
771
+ return this[ELEMENT].bind(this);
772
+ } else {
773
+ return function () {
774
+ throw new Error("".concat(ELEMENT, " must be a function"));
775
+ };
776
+ }
777
+ }
778
+ },
779
+ /** @type {()=>this[MACRO]} */
780
+ getMacro: {
781
+ value: function value() {
782
+ return this[MACRO];
783
+ }
784
+ },
785
+ /** @type {function} */
786
+ getBuffer: {
787
+ value: function value() {
788
+ return this[BUFFER];
789
+ }
790
+ },
791
+ /** @type {function} */
792
+ getBlocks: {
793
+ value: function value() {
794
+ return this[BLOCKS];
795
+ }
796
+ },
797
+ /** @type {function} */
798
+ setExtend: {
799
+ value: function value(_value) {
800
+ this[EXTEND] = _value;
801
+ }
802
+ },
803
+ /** @type {function} */
804
+ getExtend: {
805
+ value: function value() {
806
+ return this[EXTEND];
807
+ }
808
+ },
809
+ /** @type {function} */
810
+ setLayout: {
811
+ value: function value(layout) {
812
+ this[LAYOUT] = layout;
813
+ }
814
+ },
815
+ /** @type {function} */
816
+ getLayout: {
817
+ value: function value() {
818
+ return this[LAYOUT];
819
+ }
820
+ },
821
+ /** @type {function} */
822
+ clone: {
823
+ value: function value(exclude_blocks) {
824
+ var filter = [LAYOUT, EXTEND, BUFFER];
825
+ if (exclude_blocks === true) {
826
+ filter.push(BLOCKS);
827
+ }
828
+ return omit(this, filter);
829
+ }
830
+ },
831
+ /** @type {function} */
832
+ extend: {
833
+ value: function value(layout) {
834
+ this.setExtend(true);
835
+ this.setLayout(layout);
836
+ }
837
+ },
838
+ /** @type {function} */
839
+ echo: {
840
+ value: function value(layout) {
841
+ var buffer = this.getBuffer();
842
+ var params = [].slice.call(arguments);
843
+ params.forEach(buffer);
844
+ }
845
+ },
846
+ /** @type {function} */
847
+ fn: {
848
+ value: function value(callback) {
849
+ var buffer = this.getBuffer();
850
+ var context = this;
763
851
  return function () {
764
- throw new Error("".concat(ELEMENT, " must be a function"));
852
+ if (isFunction(callback)) {
853
+ buffer.backup();
854
+ buffer(callback.apply(context, arguments));
855
+ return buffer.restore();
856
+ }
765
857
  };
766
858
  }
767
- }
768
- }), "getMacro", {
769
- value: function value() {
770
- return this[MACRO];
771
- }
772
- }), "getBuffer", {
773
- value: function value() {
774
- return this[BUFFER];
775
- }
776
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
777
- value: function value() {
778
- return this[BLOCKS];
779
- }
780
- }), "setExtend", {
781
- value: function value(_value) {
782
- this[EXTEND] = _value;
783
- }
784
- }), "getExtend", {
785
- value: function value() {
786
- return this[EXTEND];
787
- }
788
- }), "setLayout", {
789
- value: function value(layout) {
790
- this[LAYOUT] = layout;
791
- }
792
- }), "getLayout", {
793
- value: function value() {
794
- return this[LAYOUT];
795
- }
796
- }), "clone", {
797
- value: function value(exclude_blocks) {
798
- var filter = [LAYOUT, EXTEND, BUFFER];
799
- if (exclude_blocks === true) {
800
- filter.push(BLOCKS);
859
+ },
860
+ /** @type {function} */
861
+ macro: {
862
+ value: function value(name, callback) {
863
+ var list = this.getMacro();
864
+ var macro = this.fn(callback);
865
+ var context = this;
866
+ list[name] = function () {
867
+ return context.echo(macro.apply(undefined, arguments));
868
+ };
801
869
  }
802
- return omit(this, filter);
803
- }
804
- }), "extend", {
805
- value: function value(layout) {
806
- this.setExtend(true);
807
- this.setLayout(layout);
808
- }
809
- }), "echo", {
810
- value: function value(layout) {
811
- var buffer = this.getBuffer();
812
- var params = [].slice.call(arguments);
813
- params.forEach(buffer);
814
- }
815
- }), "fn", {
816
- value: function value(callback) {
817
- var buffer = this.getBuffer();
818
- var context = this;
819
- return function () {
820
- if (isFunction(callback)) {
821
- buffer.backup();
822
- buffer(callback.apply(context, arguments));
823
- return buffer.restore();
870
+ },
871
+ /** @type {function} */
872
+ call: {
873
+ value: function value(name) {
874
+ var list = this.getMacro();
875
+ var macro = list[name];
876
+ var params = [].slice.call(arguments, 1);
877
+ if (isFunction(macro)) {
878
+ return macro.apply(macro, params);
824
879
  }
825
- };
826
- }
827
- }), "macro", {
828
- value: function value(name, callback) {
829
- var list = this.getMacro();
830
- var macro = this.fn(callback);
831
- var context = this;
832
- list[name] = function () {
833
- return context.echo(macro.apply(undefined, arguments));
834
- };
835
- }
836
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
837
- value: function value(name) {
838
- var list = this.getMacro();
839
- var macro = list[name];
840
- var params = [].slice.call(arguments, 1);
841
- if (isFunction(macro)) {
842
- return macro.apply(macro, params);
843
880
  }
844
- }
845
- }), "block", {
846
- value: function value(name, callback) {
847
- var _this = this;
848
- var blocks = this.getBlocks();
849
- blocks[name] = blocks[name] || [];
850
- blocks[name].push(this.fn(callback));
851
- if (this.getExtend()) return;
852
- var list = Object.assign([], blocks[name]);
853
- var current = function current() {
854
- return list.shift();
855
- };
856
- var _next = function next() {
857
- var parent = current();
858
- if (parent) {
859
- return function () {
860
- _this.echo(parent(_next()));
861
- };
862
- } else {
863
- return noop;
864
- }
865
- };
866
- this.echo(current()(_next()));
867
- }
868
- }), "hasBlock", {
869
- value: function value(name) {
870
- return this.getBlocks().hasOwnProperty(name);
871
- }
872
- }), "include", {
873
- value: function value(path, data, cx) {
874
- var context = cx === false ? {} : this.clone(true);
875
- var params = extend(context, data || {});
876
- var promise = this.render(path, params);
877
- this.echo(promise);
878
- }
879
- }), "use", {
880
- value: function value(path, namespace) {
881
- var _this2 = this;
882
- this.echo(Promise.resolve(this.require(path)).then(function (exports) {
883
- var list = _this2.getMacro();
884
- each(exports, function (macro, name) {
885
- list[[namespace, name].join('.')] = macro;
886
- });
887
- }));
888
- }
889
- }), "async", {
890
- value: function value(promise, callback) {
891
- this.echo(Promise.resolve(promise).then(callback));
892
- }
893
- }), "get", {
894
- value: function value(name, defaults) {
895
- var path = getPath(this, name, true);
896
- var result = path.shift();
897
- var prop = path.pop();
898
- return hasProp(result, prop) ? result[prop] : defaults;
899
- }
900
- }), "set", {
901
- value: function value(name, _value2) {
902
- var path = getPath(this, name, false);
903
- var result = path.shift();
904
- var prop = path.pop();
905
- if (this.getExtend() && hasProp(result, prop)) {
906
- return result[prop];
881
+ },
882
+ /** @type {function} */
883
+ block: {
884
+ value: function value(name, callback) {
885
+ var _this = this;
886
+ var blocks = this.getBlocks();
887
+ blocks[name] = blocks[name] || [];
888
+ blocks[name].push(this.fn(callback));
889
+ if (this.getExtend()) return;
890
+ var list = Object.assign([], blocks[name]);
891
+ var current = function current() {
892
+ return list.shift();
893
+ };
894
+ var _next = function next() {
895
+ var parent = current();
896
+ if (parent) {
897
+ return function () {
898
+ _this.echo(parent(_next()));
899
+ };
900
+ } else {
901
+ return noop;
902
+ }
903
+ };
904
+ this.echo(current()(_next()));
907
905
  }
908
- return result[prop] = _value2;
909
- }
910
- }), "each", {
911
- value: function value(object, callback) {
912
- if (isString(object)) {
913
- object = this.get(object, []);
906
+ },
907
+ /** @type {function} */
908
+ hasBlock: {
909
+ value: function value(name) {
910
+ return this.getBlocks().hasOwnProperty(name);
914
911
  }
915
- each(object, callback);
916
912
  },
917
- writable: true
918
- }), "el", {
919
- value: function value(tag, attr, content) {
920
- content = isFunction(content) ? this.fn(content)() : content;
921
- this.echo(Promise.resolve(content).then(function (content) {
922
- return element(tag, attr, content);
923
- }));
913
+ /** @type {function} */
914
+ include: {
915
+ value: function value(path, data, cx) {
916
+ var context = cx === false ? {} : this.clone(true);
917
+ var params = extend(context, data || {});
918
+ var promise = this.render(path, params);
919
+ this.echo(promise);
920
+ }
924
921
  },
925
- writable: true
926
- }), _defineProperty(_Object$definePropert, "ui", {
927
- value: function value(layout) {},
928
- writable: true
929
- })));
922
+ /** @type {function} */
923
+ use: {
924
+ value: function value(path, namespace) {
925
+ var _this2 = this;
926
+ this.echo(Promise.resolve(this.require(path)).then(function (exports) {
927
+ var list = _this2.getMacro();
928
+ each(exports, function (macro, name) {
929
+ list[[namespace, name].join('.')] = macro;
930
+ });
931
+ }));
932
+ }
933
+ },
934
+ /** @type {function} */
935
+ async: {
936
+ value: function value(promise, callback) {
937
+ this.echo(Promise.resolve(promise).then(callback));
938
+ }
939
+ },
940
+ /** @type {function} */
941
+ get: {
942
+ value: function value(name, defaults) {
943
+ var path = getPath(this, name, true);
944
+ var result = path.shift();
945
+ var prop = path.pop();
946
+ return hasProp(result, prop) ? result[prop] : defaults;
947
+ }
948
+ },
949
+ /** @type {function} */
950
+ set: {
951
+ value: function value(name, _value2) {
952
+ var path = getPath(this, name, false);
953
+ var result = path.shift();
954
+ var prop = path.pop();
955
+ if (this.getExtend() && hasProp(result, prop)) {
956
+ return result[prop];
957
+ }
958
+ return result[prop] = _value2;
959
+ }
960
+ },
961
+ /** @type {function} */
962
+ each: {
963
+ value: function value(object, callback) {
964
+ if (isString(object)) {
965
+ object = this.get(object, []);
966
+ }
967
+ each(object, callback);
968
+ },
969
+ writable: true
970
+ },
971
+ /** @type {function} */
972
+ el: {
973
+ value: function value(tag, attr, content) {
974
+ content = isFunction(content) ? this.fn(content)() : content;
975
+ this.echo(Promise.resolve(content).then(function (content) {
976
+ return element(tag, attr, content);
977
+ }));
978
+ },
979
+ writable: true
980
+ },
981
+ /** @type {function} */
982
+ ui: {
983
+ value: function value(layout) {},
984
+ writable: true
985
+ }
986
+ });
930
987
  return ContextScope;
931
988
  };
932
989
  var _scope = /*#__PURE__*/new WeakMap();