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